diff --git a/.gitignore b/.gitignore index 529e08a..ad1c15d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ lib docs browser-token.json Proxy -messages*.json \ No newline at end of file +messages*.json +test.ts \ No newline at end of file diff --git a/Example/ConversationExtract.js b/Example/ConversationExtract.js deleted file mode 100644 index d1a7333..0000000 --- a/Example/ConversationExtract.js +++ /dev/null @@ -1,97 +0,0 @@ -const WhatsAppWeb = require("../WhatsAppWeb") -const fs = require("fs") - -/** - * Extract all your WhatsApp conversations & save them to a file - * produceAnonData => should the Id of the chat be recorded - * */ -function extractChats (authCreds, outputFile, produceAnonData=false, offset=null) { - let client = new WhatsAppWeb() // instantiate an instance - // internal extract function - const extract = function () { - let rows = 0 - let chats = Object.keys(client.chats) - let encounteredOffset - if (offset) { - encounteredOffset = false - } else { - encounteredOffset = true - fs.writeFileSync(outputFile, "chat,input,output\n") // write header to file - } - - const extractChat = function (index) { - const id = chats[index] - if (id.includes("g.us") || !encounteredOffset) { // skip groups - if (id === offset) { - encounteredOffset = true - } - if (index+1 < chats.length) { - return extractChat(index+1) - } - return - } - console.log("extracting for " + id + "...") - - var curInput = "" - var curOutput = "" - var lastMessage - return client.loadEntireConversation (id, m => { - var text - if (!m.message) { // if message not present, return - return - } else if (m.message.conversation) { // if its a plain text message - text = m.message.conversation - } else if (m.message.extendedTextMessage && m.message.extendedTextMessage.contextInfo) { // if its a reply to a previous message - const mText = m.message.extendedTextMessage.text - const quotedMessage = m.message.extendedTextMessage.contextInfo.quotedMessage - // if it's like a '.' and the quoted message has no text, then just forget it - if (mText.length <= 2 && !quotedMessage.conversation) { - return - } - // if somebody sent like a '.', then the text should be the quoted message - if (mText.length <= 2) { - text = quotedMessage.conversation - } else { // otherwise just use this text - text = mText - } - } else { - return - } - // if the person who sent the message has switched, flush the row - if (lastMessage && !m.key.fromMe && lastMessage.key.fromMe) { - - let row = "" + (produceAnonData ? "" : id) + ",\"" + curInput + "\",\"" + curOutput + "\"\n" - fs.appendFileSync (outputFile, row) - rows += 1 - curInput = "" - curOutput = "" - } - - if (m.key.fromMe) { - curOutput += curOutput === "" ? text : ("\n"+text) - } else { - curInput += curInput === "" ? text : ("\n"+text) - } - - lastMessage = m - }, 50, false) // load from the start, in chunks of 50 - .then (() => console.log("finished extraction for " + id)) - .then (() => { - if (index+1 < chats.length) { - return extractChat(index+1) - } - }) - } - - extractChat(0) - .then (() => { - console.log("extracted all; total " + rows + " rows") - client.logout () - }) - } - client.connect (authCreds) - .then (() => extract()) - .catch (err => console.log("got error: " + error)) -} -let creds = null//JSON.parse(fs.readFileSync("auth_info.json")) -extractChats(creds, "output.csv") \ No newline at end of file diff --git a/Example/example.ts b/Example/example.ts index ad85df4..09545f1 100644 --- a/Example/example.ts +++ b/Example/example.ts @@ -1,13 +1,84 @@ -import makeConnection from '../src' -import * as fs from 'fs' +import { readFileSync, writeFileSync } from "fs" +import P from "pino" +import { Boom } from "@hapi/boom" +import makeWASocket, { WASocket, AuthenticationState, DisconnectReason, AnyMessageContent, BufferJSON, initInMemoryKeyStore, delay } from '../src' -async function example() { - const conn = makeConnection({ - credentials: './auth_info.json' - }) - conn.ev.on('connection.update', state => { - console.log(state) - }) -} +(async() => { + let sock: WASocket | undefined = undefined + // load authentication state from a file + const loadState = () => { + let state: AuthenticationState | undefined = undefined + try { + const value = JSON.parse( + readFileSync('./auth_info_multi.json', { encoding: 'utf-8' }), + BufferJSON.reviver + ) + state = { + creds: value.creds, + // stores pre-keys, session & other keys in a JSON object + // we deserialize it here + keys: initInMemoryKeyStore(value.keys) + } + } catch{ } + return state + } + // save the authentication state to a file + const saveState = (state?: any) => { + console.log('saving pre-keys') + state = state || sock?.authState + writeFileSync( + './auth_info_multi.json', + // BufferJSON replacer utility saves buffers nicely + JSON.stringify(state, BufferJSON.replacer, 2) + ) + } + // start a connection + const startSock = () => { + const sock = makeWASocket({ + logger: P({ level: 'trace' }), + auth: loadState() + }) + sock.ev.on('messages.upsert', m => { + console.log(JSON.stringify(m, undefined, 2)) + + const msg = m.messages[0] + if(!msg.key.fromMe && m.type === 'notify') { + console.log('replying to', m.messages[0].key.remoteJid) + sendMessageWTyping({ text: 'Hello there!' }, m.messages[0].key.remoteJid!) + } + + }) + sock.ev.on('messages.update', m => console.log(m)) + sock.ev.on('presence.update', m => console.log(m)) + sock.ev.on('chats.update', m => console.log(m)) + return sock + } -example().catch((err) => console.log(`encountered error`, err)) \ No newline at end of file + const sendMessageWTyping = async(msg: AnyMessageContent, jid: string) => { + + await sock.presenceSubscribe(jid) + await delay(500) + + await sock.sendPresenceUpdate('composing', jid) + await delay(2000) + + await sock.sendPresenceUpdate('paused', jid) + } + + sock = startSock() + sock.ev.on('connection.update', (update) => { + const { connection, lastDisconnect } = update + if(connection === 'close') { + // reconnect if not logged out + if((lastDisconnect.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut) { + sock = startSock() + } else { + console.log('connection closed') + } + } + console.log('connection update', update) + }) + // listen for when the auth state is updated + // it is imperative you save this data, it affects the signing keys you need to have conversations + sock.ev.on('auth-state.update', () => saveState()) +})() \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index bc4e5a9..0000000 --- a/LICENSE.md +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 Adhiraj Singh - -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/README.md b/README.md index c51a2bc..ac52bfd 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ -# Baileys - Typescript/Javascript WhatsApp Web API +# Baileys MD - Typescript/Javascript WhatsApp Web API + Early Multi-Device Edition. Breaks completely from master. + Baileys does not require Selenium or any other browser to be interface with WhatsApp Web, it does so directly using a **WebSocket**. Not running Selenium or Chromimum saves you like **half a gig** of ram :/ - Thank you to [@Sigalor](https://github.com/sigalor/whatsapp-web-reveng) for writing his observations on the workings of WhatsApp Web and thanks to [@Rhymen](https://github.com/Rhymen/go-whatsapp/) for the __go__ implementation. + Thank you to [@pokearaujo](https://github.com/pokearaujo/multidevice) for writing his observations on the workings of WhatsApp Multi-Device. Baileys is type-safe, extensible and simple to use. If you require more functionality than provided, it'll super easy for you to write an extension. More on this [here](#WritingCustomFunctionality). @@ -12,107 +14,102 @@ **Join the Discord [here](https://discord.gg/7FYURJyqng)** ## Example + Do check out & run [example.ts](Example/example.ts) to see example usage of the library. The script covers most common use cases. To run the example script, download or clone the repo and then type the following in terminal: 1. ``` cd path/to/Baileys ``` -2. ``` npm install ``` -3. ``` npm run example ``` +2. ``` yarn``` +3. ``` yarn example ``` ## Install -Create and cd to your NPM project directory and then in terminal, write: -1. stable: `npm install @adiwajshing/baileys` -2. stabl-ish w quicker fixes & latest features: `npm install github:adiwajshing/baileys` -Do note, the library will likely vary if you're using the NPM package, read that [here](https://www.npmjs.com/package/@adiwajshing/baileys) +Right now, the multi-device branch is only available from GitHub, install using: +``` +yarn add github:adiwajshing/baileys#multi-device +``` Then import in your code using: ``` ts -import { WAConnection } from '@adiwajshing/baileys' +import makeWASocket from '@adiwajshing/baileys' ``` ## Unit Tests -Baileys also comes with a unit test suite. Simply cd into the Baileys directory & run `npm test`. -You will require a phone with WhatsApp to test, and a second WhatsApp number to send messages to. -Set the phone number you can randomly send messages to in a `.env` file with `TEST_JID=1234@s.whatsapp.net` +TODO ## Connecting + ``` ts -import { WAConnection } from '@adiwajshing/baileys' +import makeWASocket from '@adiwajshing/baileys' async function connectToWhatsApp () { - const conn = new WAConnection() - // called when WA sends chats - // this can take up to a few minutes if you have thousands of chats! - conn.on('chats-received', async ({ hasNewChats }) => { - console.log(`you have ${conn.chats.length} chats, new chats available: ${hasNewChats}`) - - const unread = await conn.loadAllUnreadMessages () - console.log ("you have " + unread.length + " unread messages") + const conn = makeWASocket({ + // can provide additional config here + printQRInTerminal: true }) - // called when WA sends chats - // this can take up to a few minutes if you have thousands of contacts! - conn.on('contacts-received', () => { - console.log('you have ' + Object.keys(conn.contacts).length + ' contacts') + sock.ev.on('connection.update', (update) => { + const { connection, lastDisconnect } = update + if(connection === 'close') { + const shouldReconnect = (lastDisconnect.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut + console.log('connection closed due to ', lastDisconnect.error, ', reconnecting ', shouldReconnect) + // reconnect if not logged out + if(shouldReconnect) { + sock = startSock() + } + } else if(connection === 'open') { + console.log('opened connection') + } }) + sock.ev.on('messages.upsert', m => { + console.log(JSON.stringify(m, undefined, 2)) - await conn.connect () - conn.on('chat-update', chatUpdate => { - // `chatUpdate` is a partial object, containing the updated properties of the chat - // received a new message - if (chatUpdate.messages && chatUpdate.count) { - const message = chatUpdate.messages.all()[0] - console.log (message) - } else console.log (chatUpdate) // see updates (can be archived, pinned etc.) + console.log('replying to', m.messages[0].key.remoteJid) + sendMessageWTyping({ text: 'Hello there!' }, m.messages[0].key.remoteJid!) }) } // run in main file -connectToWhatsApp () -.catch (err => console.log("unexpected error: " + err) ) // catch any errors +connectToWhatsApp() ``` If the connection is successful, you will see a QR code printed on your terminal screen, scan it with WhatsApp on your phone and you'll be logged in! -Do note, the `conn.chats` object is a [KeyedDB](https://github.com/adiwajshing/keyed-db). This is done for the following reasons: -- Most applications require chats to be ordered in descending order of time. (`KeyedDB` does this in `log(N)` time) -- Most applications require pagination of chats (Use `chats.paginated()`) -- Most applications require **O(1)** access to chats via the chat ID. (Use `chats.get(jid)` with `KeyedDB`) +**Note:** install `qrcode-terminal` using `yarn add qrcode-terminal` to auto-print the QR to the terminal. + +## Notable Differences Between Baileys Web & MD + +1. Baileys no longer maintains an internal state of chats/contacts/messages. You must take this on your own, simply because your state in MD is its own source of truth & there is no one-size-fits-all way to handle the storage for this. +2. A baileys "socket" is meant to be a temporary & disposable object -- this is done to maintain simplicity & prevent bugs. I felt the entire Baileys object became too bloated as it supported too many configurations. +3. Moreover, Baileys does not offer an inbuilt reconnect mechanism anymore (though it's super easy to set one up on your own with your own rules, check the example script) ## Configuring the Connection -You can configure the connection via the `connectOptions` property. You can even specify an HTTPS proxy. For example: +You can configure the connection by passing a `SocketConfig` object. +The entire `SocketConfig` structure is mentioned here with default values: ``` ts -import { WAConnection, ProxyAgent } from '@adiwajshing/baileys' - -const conn = new WAConnecion () -conn.connectOptions.agent = ProxyAgent ('http://some-host:1234') - -await conn.connect () -console.log ("oh hello " + conn.user.name + "! You connected via a proxy") -``` - -The entire `WAConnectOptions` struct is mentioned here with default values: -``` ts -conn.connectOptions = { - /** fails the connection if no data is received for X seconds */ - maxIdleTimeMs?: 60_000, - /** maximum attempts to connect */ - maxRetries?: 10, - /** max time for the phone to respond to a connectivity test */ - phoneResponseTime?: 15_000, - /** minimum time between new connections */ - connectCooldownMs?: 4000, - /** agent used for WS connections (could be a proxy agent) */ - agent?: Agent = undefined, - /** agent used for fetch requests -- uploading/downloading media */ - fetchAgent?: Agent = undefined, - /** always uses takeover for connecting */ - alwaysUseTakeover: true - /** log QR to terminal */ - logQR: true -} as WAConnectOptions +type SocketConfig = { + /** provide an auth state object to maintain the auth state */ + auth?: AuthenticationState + /** the WS url to connect to WA */ + waWebSocketUrl: string | URL + /** Fails the connection if the connection times out in this time interval or no data is received */ + connectTimeoutMs: number + /** ping-pong interval for WS connection */ + keepAliveIntervalMs: number + /** proxy agent */ + agent?: Agent + /** pino logger */ + logger: Logger + /** version to connect with */ + version: WAVersion + /** override browser config */ + browser: WABrowserDescription + /** agent used for fetch requests -- uploading/downloading media */ + fetchAgent?: Agent + /** should the QR be printed in the terminal */ + printQRInTerminal: boolean +} ``` ## Saving & Restoring Sessions @@ -121,92 +118,126 @@ You obviously don't want to keep scanning the QR code every time you want to con So, you can save the credentials to log back in via: ``` ts +import makeWASocket, { BufferJSON } from '@adiwajshing/baileys' import * as fs from 'fs' -const conn = new WAConnection() +// will initialize a default in-memory auth session +const conn = makeSocket() // this will be called as soon as the credentials are updated -conn.on ('open', () => { +conn.ev.on ('auth-state.update', () => { // save credentials whenever updated console.log (`credentials updated!`) - const authInfo = conn.base64EncodedAuthInfo() // get all the auth info we need to restore this session - fs.writeFileSync('./auth_info.json', JSON.stringify(authInfo, null, '\t')) // save this info to a file + const authInfo = conn.authState // get all the auth info we need to restore this session + // save this info to a file + fs.writeFileSync( + './auth_info.json', + JSON.stringify(authInfo, BufferJSON.replacer, 2) + ) }) -await conn.connect() // connect ``` Then, to restore a session: ``` ts -const conn = new WAConnection() -conn.loadAuthInfo ('./auth_info.json') // will load JSON credentials from file -await conn.connect() -// yay connected without scanning QR -/* - Optionally, you can load the credentials yourself from somewhere - & pass in the JSON object to loadAuthInfo () as well. -*/ -``` +import makeWASocket, { BufferJSON, initInMemoryKeyStore } from '@adiwajshing/baileys' +import * as fs from 'fs' -If you're considering switching from a Chromium/Puppeteer based library, you can use WhatsApp Web's Browser credentials to restore sessions too: -``` ts -conn.loadAuthInfo ('./auth_info_browser.json') -await conn.connect() // works the same -``` -See the browser credentials type in the docs. - -**Note**: Upon every successive connection, WA can update part of the stored credentials. Whenever that happens, the credentials are uploaded, and you should probably update your saved credentials upon receiving the `open` event. Not doing so *may* lead WA to log you out after a few weeks with a 419 error code. - -## QR Callback - -If you want to do some custom processing with the QR code used to authenticate, you can register for the following event: -``` ts -conn.on('qr', qr => { - // Now, use the 'qr' string to display in QR UI or send somewhere +const authJSON = JSON.parse( + fs.readFileSync( + './auth_info.json', + { encoding: 'utf-8' } + ), + BufferJSON.reviver +) +const auth = { + creds: authJSON.creds, + // stores pre-keys, session & other keys in a JSON object + // we deserialize it here + keys: initInMemoryKeyStore(authJSON.keys) } -await conn.connect () +const conn = makeWASocket(auth) +// yay will connect without scanning QR ``` +**Note**: Upon every successive connection, the auth state can update part of the stored credentials. It will also update when a message is received/sent due to signal sessions needing updating. Whenever that happens, the `auth-state.update` event is fired uploaded, and you must update your saved credentials upon receiving the event. Not doing so will prevent your messages from reaching the recipient & other unexpected consequences. + +## Listening to Connection Updates + +Baileys now fires the `connection.update` event to let you know something has updated in the connection. This data has the following structure: +``` ts +type ConnectionState = { + /** connection is now open, connecting or closed */ + connection: WAConnectionState + /** the error that caused the connection to close */ + lastDisconnect?: { + error: Error + date: Date + } + /** is this a new login */ + isNewLogin?: boolean + /** the current QR code */ + qr?: string + /** has the device received all pending notifications while it was offline */ + receivedPendingNotifications?: boolean +} +``` + +Note: this also offers any updates to the QR + ## Handling Events -Baileys now uses the EventEmitter syntax for events. +Baileys uses the EventEmitter syntax for events. They're all nicely typed up, so you shouldn't have any issues with an Intellisense editor like VS Code. -Also, these events are fired regardless of whether they are initiated by the Baileys client or are relayed from your phone. +The events are typed up in a type map, as mentioned here: ``` ts -/** when the connection has opened successfully */ -on (event: 'open', listener: (result: WAOpenResult) => void): this -/** when the connection is opening */ -on (event: 'connecting', listener: () => void): this -/** when the connection has closed */ -on (event: 'close', listener: (err: {reason?: DisconnectReason | string, isReconnecting: boolean}) => void): this -/** when the socket is closed */ -on (event: 'ws-close', listener: (err: {reason?: DisconnectReason | string}) => void): this -/** when a new QR is generated, ready for scanning */ -on (event: 'qr', listener: (qr: string) => void): this -/** when the connection to the phone changes */ -on (event: 'connection-phone-change', listener: (state: {connected: boolean}) => void): this -/** when a contact is updated */ -on (event: 'contact-update', listener: (update: WAContactUpdate) => void): this -/** when a new chat is added */ -on (event: 'chat-new', listener: (chat: WAChat) => void): this -/** when contacts are sent by WA */ -on (event: 'contacts-received', listener: (u: { updatedContacts: Partial[] }) => void): this -/** when chats are sent by WA, and when all messages are received */ -on (event: 'chats-received', listener: (update: {hasNewChats?: boolean}) => void): this -/** when all initial messages are received from WA */ -on (event: 'initial-data-received', listener: (update: {chatsWithMissingMessages: { jid: string, count: number }[] }) => void): this -/** when multiple chats are updated (new message, updated message, deleted, pinned, etc) */ -on (event: 'chats-update', listener: (chats: WAChatUpdate[]) => void): this -/** when a chat is updated (new message, updated message, read message, deleted, pinned, presence updated etc) */ -on (event: 'chat-update', listener: (chat: WAChatUpdate) => void): this -/** when participants are added to a group */ -on (event: 'group-participants-update', listener: (update: {jid: string, participants: string[], actor?: string, action: WAParticipantAction}) => void): this -/** when the group is updated */ -on (event: 'group-update', listener: (update: Partial & {jid: string, actor?: string}) => void): this -/** when WA sends back a pong */ -on (event: 'received-pong', listener: () => void): this -/** when a user is blocked or unblockd */ -on (event: 'blocklist-update', listener: (update: BlocklistUpdate) => void): this + +export type BaileysEventMap = { + /** connection state has been updated -- WS closed, opened, connecting etc. */ + 'connection.update': Partial + /** auth state updated -- some pre keys, or identity keys etc. */ + 'auth-state.update': AuthenticationState + /** set chats (history sync), messages are reverse chronologically sorted */ + 'chats.set': { chats: Chat[], messages: WAMessage[] } + /** update/insert chats */ + 'chats.upsert': Chat[] + /** update the given chats */ + 'chats.update': Partial[] + /** delete chats with given ID */ + 'chats.delete': string[] + /** presence of contact in a chat updated */ + 'presence.update': { id: string, presences: { [participant: string]: PresenceData } } + + 'contacts.upsert': Contact[] + 'contacts.update': Partial[] + + 'messages.delete': { jid: string, ids: string[] } | { jid: string, all: true } + 'messages.update': WAMessageUpdate[] + /** + * add/update the given messages. If they were received while the connection was online, + * the update will have type: "notify" + * */ + 'messages.upsert': { messages: WAMessage[], type: MessageUpdateType } + + 'message-info.update': MessageInfoUpdate[] + + 'groups.update': Partial[] + /** apply an action to participants in a group */ + 'group-participants.update': { id: string, participants: string[], action: ParticipantAction } + + 'blocklist.set': { blocklist: string[] } + 'blocklist.update': { blocklist: string[], type: 'add' | 'remove' } +} +``` + +You can listen to these events like this: +``` ts + +const sock = makeWASocket() +sock.ev.on('messages.upsert', ({ messages }) => { + console.log('got messages', messages) +}) + ``` ## Sending Messages @@ -220,9 +251,12 @@ import { MessageType, MessageOptions, Mimetype } from '@adiwajshing/baileys' const id = 'abcd@s.whatsapp.net' // the WhatsApp ID // send a simple text! -const sentMsg = await conn.sendMessage (id, 'oh hello there', MessageType.text) +const sentMsg = await conn.sendMessage(id, { text: 'oh hello there' }) // send a location! -const sentMsg = await conn.sendMessage(id, {degreesLatitude: 24.121231, degreesLongitude: 55.1121221}, MessageType.location) +const sentMsg = await conn.sendMessage( + id, + { location: { degreesLatitude: 24.121231, degreesLongitude: 55.1121221 } } +) // send a contact! const vcard = 'BEGIN:VCARD\n' // metadata of the contact card + 'VERSION:3.0\n' @@ -230,7 +264,15 @@ const vcard = 'BEGIN:VCARD\n' // metadata of the contact card + 'ORG:Ashoka Uni;\n' // the organization of the contact + 'TEL;type=CELL;type=VOICE;waid=911234567890:+91 12345 67890\n' // WhatsApp ID + phone number + 'END:VCARD' -const sentMsg = await conn.sendMessage(id, {displayname: "Jeff", vcard: vcard}, MessageType.contact) +const sentMsg = await conn.sendMessage( + id, + { + contacts: { + displayName: 'Jeff', + contacts: [{ vcard }] + } + } +) ``` ### Media Messages @@ -244,34 +286,38 @@ import { MessageType, MessageOptions, Mimetype } from '@adiwajshing/baileys' // Sending gifs await conn.sendMessage( id, - fs.readFileSync("Media/ma_gif.mp4"), // load a gif and send it - MessageType.video, - { mimetype: Mimetype.gif, caption: "hello!" } + { + video: fs.readFileSync("Media/ma_gif.mp4"), + caption: "hello!", + gifPlayback: true + } ) await conn.sendMessage( id, - { url: 'Media/ma_gif.mp4' }, // send directly from local file - MessageType.video, - { mimetype: Mimetype.gif, caption: "hello!" } + { + video: "./Media/ma_gif.mp4", + caption: "hello!", + gifPlayback: true + } ) await conn.sendMessage( id, - { url: 'https://giphy.com/gifs/11JTxkrmq4bGE0/html5' }, // send directly from remote url! - MessageType.video, - { mimetype: Mimetype.gif, caption: "hello!" } + { + video: "./Media/ma_gif.mp4", + caption: "hello!", + gifPlayback: true + } ) // send an audio file await conn.sendMessage( id, + { audio: { url: "./Media/audio.mp3" }, mimetype: 'audio/mp4' } { url: "Media/audio.mp3" }, // can send mp3, mp4, & ogg - MessageType.audio, - { mimetype: Mimetype.mp4Audio } // some metadata (can't have caption in audio) ) ``` - ### Notes - `id` is the WhatsApp ID of the person or group you're sending the message to. @@ -279,7 +325,7 @@ await conn.sendMessage( - For broadcast lists it's `[timestamp of creation]@broadcast`. - For stories, the ID is `status@broadcast`. - For media messages, the thumbnail can be generated automatically for images & stickers. Thumbnails for videos can also be generated automatically, though, you need to have `ffmpeg` installed on your system. -- **MessageOptions**: some extra info about the message. It can have the following __optional__ values: +- **MiscGenerationOptions**: some extra info about the message. It can have the following __optional__ values: ``` ts const info: MessageOptions = { quoted: quotedMessage, // the message you want to quote @@ -313,12 +359,16 @@ await conn.forwardMessage ('455@s.whatsapp.net', message) // WA forward the mess ## Reading Messages +A set of message IDs must be explicitly marked read now. +Cannot mark an entire "chat" read as it were with Baileys Web. +This does mean you have to keep track of unread messages. + ``` ts const id = '1234-123@g.us' const messageID = 'AHASHH123123AHGA' // id of the message you want to read +const participant = '912121232@s.whatsapp.net' // the ID of the user that sent the message (undefined for individual chats) -await conn.chatRead (id) // mark all messages in chat as read (equivalent of opening a chat in WA) -await conn.chatRead (id, 'unread') // mark the chat as unread +await conn.sendReadReceipt(id, participant, [messageID]) ``` The message ID is the unique identifier of the message that you are marking as read. On a `WAMessage`, the `messageID` can be accessed using ```messageID = message.key.id```. @@ -326,18 +376,12 @@ The message ID is the unique identifier of the message that you are marking as r ## Update Presence ``` ts -import { Presence } from '@adiwajshing/baileys' -await conn.updatePresence(id, Presence.available) +await conn.updatePresence(id, 'available') ``` This lets the person/group with ``` id ``` know whether you're online, offline, typing etc. where ``` presence ``` can be one of the following: ``` ts -export enum Presence { - available = 'available', // "online" - composing = 'composing', // "typing..." - recording = 'recording', // "recording..." - paused = 'paused' // stopped typing, back to "online" -} +type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused' ``` The presence expires after about 10 seconds. @@ -364,108 +408,74 @@ conn.on ('message-new', async m => { ``` ts const jid = '1234@s.whatsapp.net' // can also be a group -const response = await conn.sendMessage (jid, 'hello!', MessageType.text) // send a message - -await conn.deleteMessage (jid, {id: response.messageID, remoteJid: jid, fromMe: true}) // will delete the sent message for everyone! -await conn.clearMessage (jid, {id: response.messageID, remoteJid: jid, fromMe: true}) // will delete the sent message for only you! +const response = await conn.sendMessage(jid, { text: 'hello!' }) // send a message +// sends a message to delete the given message +// this deletes the message for everyone +await conn.sendMessage(jid, { delete: response.key }) ``` +Note: deleting for oneself is not supported yet + ## Modifying Chats -``` ts -const jid = '1234@s.whatsapp.net' // can also be a group -await conn.modifyChat (jid, ChatModification.archive) // archive chat -await conn.modifyChat (jid, ChatModification.unarchive) // unarchive chat - -const response = await conn.modifyChat (jid, ChatModification.pin) // pin the chat -await conn.modifyChat (jid, ChatModification.unpin) // unpin it - -await conn.modifyChat (jid, ChatModification.mute, 8*60*60*1000) // mute for 8 hours -setTimeout (() => { - conn.modifyChat (jid, ChatModification.unmute) -}, 5000) // unmute after 5 seconds - -await conn.modifyChat (jid, ChatModification.delete) // will delete the chat (can be a group or broadcast list as well) -``` - -**Note:** to unmute or unpin a chat, one must pass the timestamp of the pinning or muting. This is returned by the pin & mute functions. This is also available in the `WAChat` objects of the respective chats, as a `mute` or `pin` property. +TODO: haven't figured this bit out yet. Can receive chat modifications tho. ## Disappearing Messages ``` ts const jid = '1234@s.whatsapp.net' // can also be a group // turn on disappearing messages -await conn.toggleDisappearingMessages( +await conn.sendMessage( jid, - WA_DEFAULT_EPHEMERAL // this is 1 week in seconds -- how long you want messages to appear for -) -// will automatically send as a disappearing message -await conn.sendMessage(jid, 'Hello poof!', MessageType.text) + // this is 1 week in seconds -- how long you want messages to appear for + { disappearingMessagesInChat: WA_DEFAULT_EPHEMERAL } +) +// will send as a disappearing message +await conn.sendMessage(jid, { text: 'hello' }, { ephemeralExpiration: WA_DEFAULT_EPHEMERAL }) // turn off disappearing messages -await conn.toggleDisappearingMessages(jid, 0) +await conn.sendMessage( + jid, + { disappearingMessagesInChat: false } +) ``` ## Misc -- To load chats in a paginated manner - ``` ts - const {chats, cursor} = await conn.loadChats (25) - if (cursor) { - const moreChats = await conn.loadChats (25, cursor) // load the next 25 chats - } - ``` - To check if a given ID is on WhatsApp - Note: this method falls back to using `https://wa.me` to determine whether a number is on WhatsApp in case the WebSocket connection is not open yet. ``` ts const id = '123456' - const exists = await conn.isOnWhatsApp (id) - if (exists) console.log (`${id} exists on WhatsApp, as jid: ${exists.jid}`) + const [result] = await conn.onWhatsApp(id) + if (result.exists) console.log (`${id} exists on WhatsApp, as jid: ${result.jid}`) ``` - To query chat history on a group or with someone - ``` ts - // query the last 25 messages (replace 25 with the number of messages you want to query) - const messages = await conn.loadMessages ("xyz-abc@g.us", 25) - console.log("got back " + messages.length + " messages") - ``` - You can also load the entire conversation history if you want - ``` ts - await conn.loadAllMessages ("xyz@c.us", message => console.log("Loaded message with ID: " + message.key.id)) - console.log("queried all messages") // promise resolves once all messages are retrieved - ``` + TODO, if possible - To get the status of some person ``` ts - const status = await conn.getStatus ("xyz@c.us") // leave empty to get your own status + const status = await conn.fetchStatus("xyz@s.whatsapp.net") console.log("status: " + status) ``` - To get the display picture of some person/group ``` ts - const ppUrl = await conn.getProfilePicture ("xyz@g.us") // leave empty to get your own + const ppUrl = await conn.profilePictureUrl("xyz@g.us") console.log("download profile picture from: " + ppUrl) ``` - To change your display picture or a group's ``` ts const jid = '111234567890-1594482450@g.us' // can be your own too - const img = fs.readFileSync ('new-profile-picture.jpeg') // can be PNG also - await conn.updateProfilePicture (jid, img) + await conn.updateProfilePicture(jid, { url: './new-profile-picture.jpeg' }) ``` - To get someone's presence (if they're typing, online) ``` ts // the presence update is fetched and called here - conn.on ('CB:Presence', json => console.log(json.id + " presence is " + json.type)) - await conn.requestPresenceUpdate ("xyz@c.us") // request the update - ``` -- To search through messages - ``` ts - const response = await conn.searchMessages ('so cool', null, 25, 1) // search in all chats - console.log (`got ${response.messages.length} messages in search`) - - const response2 = await conn.searchMessages ('so cool', '1234@c.us', 25, 1) // search in given chat + conn.ev.on('presence-update', json => console.log(json)) + // request updates for a chat + await conn.presenceSubscribe("xyz@s.whatsapp.net") ``` - To block or unblock user ``` ts - await conn.blockUser ("xyz@c.us", "add") // Block user - await conn.blockUser ("xyz@c.us", "remove") // Unblock user + await conn.updateBlockStatus("xyz@s.whatsapp.net", "block") // Block user + await conn.updateBlockStatus("xyz@s.whatsapp.net", "unblock") // Unblock user ``` Of course, replace ``` xyz ``` with an actual ID. @@ -473,67 +483,52 @@ Of course, replace ``` xyz ``` with an actual ID. - To create a group ``` ts // title & participants - const group = await conn.groupCreate ("My Fab Group", ["abcd@s.whatsapp.net", "efgh@s.whatsapp.net"]) + const group = await conn.groupCreate("My Fab Group", ["1234@s.whatsapp.net", "4564@s.whatsapp.net"]) console.log ("created group with id: " + group.gid) - conn.sendMessage(group.gid, "hello everyone", MessageType.extendedText) // say hello to everyone on the group + conn.sendMessage(group.id, { text: 'hello there' }) // say hello to everyone on the group ``` -- To add people to a group +- To add/remove people to a group or demote/promote people ``` ts // id & people to add to the group (will throw error if it fails) - const response = await conn.groupAdd ("abcd-xyz@g.us", ["abcd@s.whatsapp.net", "efgh@s.whatsapp.net"]) - ``` -- To make/demote admins on a group - ``` ts - // id & people to make admin (will throw error if it fails) - await conn.groupMakeAdmin ("abcd-xyz@g.us", ["abcd@s.whatsapp.net", "efgh@s.whatsapp.net"]) - await conn.groupDemoteAdmin ("abcd-xyz@g.us", ["abcd@s.whatsapp.net", "efgh@s.whatsapp.net"]) // demote admins + const response = await conn.groupParticipantsUpdate( + "abcd-xyz@g.us", + ["abcd@s.whatsapp.net", "efgh@s.whatsapp.net"], + "add" // replace this parameter with "remove", "demote" or "promote" + ) ``` - To change the group's subject ``` ts await conn.groupUpdateSubject("abcd-xyz@g.us", "New Subject!") ``` -- To change the group's description - ``` ts - await conn.groupUpdateDescription("abcd-xyz@g.us", "This group has a new description") - ``` - To change group settings ``` ts - import { GroupSettingChange } from '@adiwajshing/baileys' // only allow admins to send messages - await conn.groupSettingChange ("abcd-xyz@g.us", GroupSettingChange.messageSend, true) + await conn.groupSettingUpdate("abcd-xyz@g.us", 'announcement') // allow everyone to modify the group's settings -- like display picture etc. - await conn.groupSettingChange ("abcd-xyz@g.us", GroupSettingChange.settingChange, false) + await conn.groupSettingUpdate("abcd-xyz@g.us", 'unlocked') // only allow admins to modify the group's settings - await conn.groupSettingChange ("abcd-xyz@g.us", GroupSettingChange.settingChange, true) + await conn.groupSettingUpdate("abcd-xyz@g.us", 'locked') ``` - To leave a group ``` ts - await conn.groupLeave ("abcd-xyz@g.us") // (will throw error if it fails) + await conn.groupLeave("abcd-xyz@g.us") // (will throw error if it fails) ``` - To get the invite code for a group ``` ts - const code = await conn.groupInviteCode ("abcd-xyz@g.us") + const code = await conn.groupInviteCode("abcd-xyz@g.us") console.log("group code: " + code) ``` - To query the metadata of a group ``` ts - const metadata = await conn.groupMetadata ("abcd-xyz@g.us") + const metadata = await conn.groupMetadata("abcd-xyz@g.us") console.log(json.id + ", title: " + json.subject + ", description: " + json.desc) - - // Or if you've left the group -- call this - const metadata2 = await conn.groupMetadataMinimal ("abcd-xyz@g.us") ``` - To join the group using the invitation code ``` ts - const response = await conn.acceptInvite ("xxx") + const response = await conn.acceptInvite("xxx") console.log("joined to: " + response.gid) ``` Of course, replace ``` xxx ``` with invitation code. -- To revokes the current invite link of a group - ``` ts - const response = await conn.revokeInvite ("abcd-xyz@g.us") - console.log("new group code: " + response.code) - ``` ## Broadcast Lists & Stories @@ -542,7 +537,7 @@ Of course, replace ``` xyz ``` with an actual ID. - Broadcast IDs are in the format `12345678@broadcast` - To query a broadcast list's recipients & name: ``` ts - const bList = await conn.getBroadcastListInfo ("1234@broadcast") + const bList = await conn.getBroadcastListInfo("1234@broadcast") console.log (`list name: ${bList.name}, recps: ${bList.recipients}`) ``` @@ -551,53 +546,34 @@ Baileys is written, keeping in mind, that you may require other custom functiona First, enable the logging of unhandled messages from WhatsApp by setting ``` ts -conn.logger.level = 'debug' +const sock = makeWASocket({ + logger: P({ level: 'debug' }), +}) ``` This will enable you to see all sorts of messages WhatsApp sends in the console. Some examples: 1. Functionality to track of the battery percentage of your phone. You enable logging and you'll see a message about your battery pop up in the console: - ```s22, ["action",null,[["battery",{"live":"false","value":"52"},null]]] ``` + ```{"level":10,"fromMe":false,"frame":{"tag":"ib","attrs":{"from":"@s.whatsapp.net"},"content":[{"tag":"edge_routing","attrs":{},"content":[{"tag":"routing_info","attrs":{},"content":{"type":"Buffer","data":[8,2,8,5]}}]}]},"msg":"communication"} ``` - You now know what a battery update looks like. It'll have the following characteristics. - - Given ```const bMessage = ["action",null,[["battery",{"live":"false","value":"52"},null]]]``` - - ```bMessage[0]``` is always ``` "action" ``` - - ```bMessage[1]``` is always ``` null ``` - - ```bMessage[2][0][0]``` is always ``` "battery" ``` + The "frame" is what the message received is, it has three components: + - `tag` -- what this frame is about (eg. message will have "message") + - `attrs` -- a string key-value pair with some metadata (contains ID of the message usually) + - `content` -- the actual data (eg. a message node will have the actual message content in it) + - read more about this format [here](/src/WABinary/readme.md) Hence, you can register a callback for an event using the following: ``` ts - conn.on (`CB:action,,battery`, json => { - const batteryLevelStr = json[2][0][1].value - const batterylevel = parseInt (batteryLevelStr) - console.log ("battery level: " + batterylevel + "%") - }) + // for any message with tag 'edge_routing' + conn.ws.on(`CB:edge_routing`, (node: BinaryNode) => { }) + // for any message with tag 'edge_routing' and id attribute = abcd + conn.ws.on(`CB:edge_routing,id:abcd`, (node: BinaryNode) => { }) + // for any message with tag 'edge_routing', id attribute = abcd & first content node routing_info + conn.ws.on(`CB:edge_routing,id:abcd,routing_info`, (node: BinaryNode) => { }) ``` - This callback will be fired any time a message is received matching the following criteria: - ``` message [0] === "action" && message [1] === null && message[2][0][0] === "battery" ``` -2. Functionality to keep track of the pushname changes on your phone. - You enable logging and you'll see an unhandled message about your pushanme pop up like this: - ```s24, ["Conn",{"pushname":"adiwajshing"}]``` - - You now know what a pushname update looks like. It'll have the following characteristics. - - Given ```const pMessage = ["Conn",{"pushname":"adiwajshing"}] ``` - - ```pMessage[0]``` is always ``` "Conn" ``` - - ```pMessage[1]``` always has the key ``` "pushname" ``` - - ```pMessage[2]``` is always ``` undefined ``` - - Following this, one can implement the following callback: - ``` ts - conn.on ('CB:Conn,pushname', json => { - const pushname = json[1].pushname - conn.user.name = pushname // update on client too - console.log ("Name updated: " + pushname) - }) - ``` - This callback will be fired any time a message is received matching the following criteria: - ``` message [0] === "Conn" && message [1].pushname ``` - -A little more testing will reveal that almost all WhatsApp messages are in the format illustrated above. -Note: except for the first parameter (in the above cases, ```"action"``` or ```"Conn"```), all the other parameters are optional. ### Note + This library was originally a project for **CS-2362 at Ashoka University** and is in no way affiliated with WhatsApp. Use at your own discretion. Do not spam people with this. + + Also, this repo is now licenced under GPL 3 since it uses [libsignal-node](https://git.questbook.io/backend/service-coderunner/-/merge_requests/1) diff --git a/WABinary/Binary.js b/WABinary/Binary.js new file mode 100644 index 0000000..375b63c --- /dev/null +++ b/WABinary/Binary.js @@ -0,0 +1,585 @@ +import { hexAt, hexLongIsNegative, hexLongToHex, negateHexLong, NUM_HEX_IN_LONG } from "./HexHelper"; +import { inflateSync } from 'zlib' + +var l = "", + d = 0; + + const i = 65533, + n = new Uint8Array(10), + s = new Uint8Array(0); + +function u(e) { + if (e === l) return d; + for (var t = e.length, r = 0, a = 0; a < t; a++) { + var i = e.charCodeAt(a); + if (i < 128) r++; + else if (i < 2048) r += 2; + else if (i < 55296 || (57344 <= i && i <= 65535)) r += 3; + else if (55296 <= i && i < 56320 && a + 1 !== t) { + var n = e.charCodeAt(a + 1); + 56320 <= n && n < 57344 ? (a++, (r += 4)) : (r += 3); + } else r += 3; + } + return (l = e), (d = r); +} +function c(e, t, r) { + var a = t >> 21; + if (e) { + var i = Boolean(2097151 & t || r); + return 0 === a || (-1 === a && i); + } + return 0 === a; +} +function p(e, t, r, a, i = undefined) { + return e.readWithViewParser(t, r, a, i); +} +function f(e, t, r, a = undefined, i = undefined) { + return e.readWithBytesParser(t, r, a, i); +} +function h(e, t, r, a) { + return a ? e.getInt8(t) : e.getUint8(t); +} +function _(e, t, r, a) { + return e.getUint16(t, a); +} +function m(e, t, r, a) { + return e.getInt32(t, a); +} +function g(e, t, r, a) { + return e.getUint32(t, a); +} +function v(e, t, r, a, i) { + return a(e.getInt32(i ? t + 4 : t, i), e.getInt32(i ? t : t + 4, i)); +} +function y(e, t, r, a) { + return e.getFloat32(t, a); +} +function E(e, t, r, a) { + return e.getFloat64(t, a); +} +function S(e, t, r, a) { + for (var i = Math.min(a, 10), n = 0, s = 128; n < i && 128 & s; ) + s = e[t + n++]; + if (10 === n && s > 1) throw new Error("ParseError: varint exceeds 64 bits"); + return 128 & s ? n + 1 : n; +} +function T(e, t, r, a) { + var i = 0, + n = 0, + s = r; + 10 === r && (n = 1 & e[t + --s]); + for (var o = s - 1; o >= 0; o--) + (i = (i << 7) | (n >>> 25)), (n = (n << 7) | (127 & e[t + o])); + return a(i, n); +} +function A(e, t, r) { + var a = t + e.byteOffset, + i = e.buffer; + return 0 === a && r === i.byteLength ? i : i.slice(a, a + r); +} +function b(e, t, r) { + return e.subarray(t, t + r); +} +function C(e, t, r) { + for (var a = t + r, n = [], s = null, o = t; o < a; o++) { + n.length > 5e3 && + (s || (s = []), s.push(String.fromCharCode.apply(String, n)), (n = [])); + var l = 0 | e[o]; + if (0 == (128 & l)) n.push(l); + else if (192 == (224 & l)) { + var d = H(e, o + 1, a); + if (d) { + o++; + var u = ((31 & l) << 6) | (63 & d); + u >= 128 ? n.push(u) : n.push(i); + } else n.push(i); + } else if (224 == (240 & l)) { + var c = H(e, o + 1, a), + p = H(e, o + 2, a); + if (c && p) { + o += 2; + var f = ((15 & l) << 12) | ((63 & c) << 6) | (63 & p); + f >= 2048 && !(55296 <= f && f < 57344) ? n.push(f) : n.push(i); + } else c ? (o++, n.push(i)) : n.push(i); + } else if (240 == (248 & l)) { + var h = H(e, o + 1, a), + _ = H(e, o + 2, a), + m = H(e, o + 3, a); + if (h && _ && m) { + o += 3; + var g = ((7 & l) << 18) | ((63 & h) << 12) | ((63 & _) << 6) | (63 & m); + if (g >= 65536 && g <= 1114111) { + var v = g - 65536; + n.push(55296 | (v >> 10), 56320 | (1023 & v)); + } else n.push(i); + } else h && _ ? ((o += 2), n.push(i)) : h ? (o++, n.push(i)) : n.push(i); + } else n.push(i); + } + var y = String.fromCharCode.apply(String, n); + return s ? (s.push(y), s.join("")) : y; +} +function P(e, t, r, a, i) { + return e.writeToView(t, r, a, i); +} +function O(e, t, r, a, i = undefined) { + return e.writeToBytes(t, r, a, i); +} +function M(e, t, r, a) { + e[t] = a; +} +function w(e, t, r, a, i) { + e.setUint16(t, a, i); +} +function I(e, t, r, a, i) { + e.setInt16(t, a, i); +} +function R(e, t, r, a, i) { + e.setUint32(t, a, i); +} +function D(e, t, r, a, i) { + e.setInt32(t, a, i); +} +function N(e, t, r, a, i) { + var n = a < 0, + s = n ? -a : a, + o = Math.floor(s / 4294967296), + l = s - 4294967296 * o; + n && ((o = ~o), 0 === l ? o++ : (l = -l)), + e.setUint32(i ? t + 4 : t, o, i), + e.setUint32(i ? t : t + 4, l, i); +} +function L(e, t, r, a, i) { + e.setFloat32(t, a, i); +} +function k(e, t, r, a, i) { + e.setFloat64(t, a, i); +} +function U(e, t, r, a, i) { + for (var n = a, s = i, o = t + r - 1, l = t; l < o; l++) + (e[l] = 128 | (127 & s)), (s = (n << 25) | (s >>> 7)), (n >>>= 7); + e[o] = s; +} +function G(e, t, r, a) { + for (var i = t, n = a.length, s = 0; s < n; s++) { + var o = a.charCodeAt(s); + if (o < 128) e[i++] = o; + else if (o < 2048) (e[i++] = 192 | (o >> 6)), (e[i++] = 128 | (63 & o)); + else if (o < 55296 || 57344 <= o) + (e[i++] = 224 | (o >> 12)), + (e[i++] = 128 | ((o >> 6) & 63)), + (e[i++] = 128 | (63 & o)); + else if (55296 <= o && o < 56320 && s + 1 !== n) { + var l = a.charCodeAt(s + 1); + if (56320 <= l && l < 57344) { + s++; + var d = 65536 + (((1023 & o) << 10) | (1023 & l)); + (e[i++] = 240 | (d >> 18)), + (e[i++] = 128 | ((d >> 12) & 63)), + (e[i++] = 128 | ((d >> 6) & 63)), + (e[i++] = 128 | (63 & d)); + } else (e[i++] = 239), (e[i++] = 191), (e[i++] = 189); + } else (e[i++] = 239), (e[i++] = 191), (e[i++] = 189); + } +} +function F(e, t, r, i, n) { + for ( + var s = hexLongIsNegative(i), + o = hexLongToHex(i), + l = 0, + d = 0, + u = 0; + u < 16; + u++ + ) + (l = (l << 4) | (d >>> 28)), (d = (d << 4) | hexAt(o, u)); + s && ((l = ~l), 0 === d ? l++ : (d = -d)), + e.setUint32(n ? t + 4 : t, l, n), + e.setUint32(n ? t : t + 4, d, n); +} +function x(e, t, r, a) { + for (var i = 0; i < r; i++) e[t + i] = a[i]; +} +function B(e, t) { + var r, a; + for (e ? ((r = 5), (a = e >>> 3)) : ((r = 1), (a = t >>> 7)); a; ) + r++, (a >>>= 7); + return r; +} +function Y(e, t, r, a) { + if ("number" != typeof e || e != e || Math.floor(e) !== e || e < t || e >= r) { + console.trace('here') + throw new TypeError( + "string" == typeof e + ? `WriteError: string "${e}" is not a valid ${a}` + : `WriteError: ${String(e)} is not a valid ${a}` + ); + } + +} +function K(e, t, r) { + var a = + 4294967296 * (t >= 0 || e ? t : 4294967296 + t) + + (r >= 0 ? r : 4294967296 + r); + if (!c(e, t, r)) + throw new Error(`ReadError: integer exceeded 53 bits (${a})`); + return a; +} +function j(e, t) { + return K(!0, e, t); +} +function W(e, t) { + return K(!1, e, t); +} +function H(e, t, r) { + if (t >= r) return 0; + var a = 0 | e[t]; + return 128 == (192 & a) ? a : 0; +} + +export const numUtf8Bytes = u; +export const longFitsInDouble = c; +export const parseInt64OrThrow = j; +export const parseUint64OrThrow = W; + +export class Binary { + /** @type {Uint8Array} */ + buffer; + readEndIndex; + writeIndex; + bytesTrashed = 0; + earliestIndex = 0; + readIndex = 0; + /** @type {DataView} */ + view = null; + littleEndian = false; + hiddenReads = 0; + hiddenWrites = 0; + + constructor(data = new Uint8Array(0), littleEndian = false) { + if (data instanceof ArrayBuffer) { + this.buffer = new Uint8Array(data); + this.readEndIndex = data.byteLength; + this.writeIndex = data.byteLength; + } + + if (data instanceof Uint8Array) { + this.buffer = data; + this.readEndIndex = data.length; + this.writeIndex = data.length; + } + + this.littleEndian = littleEndian; + } + + size() { + return this.readEndIndex - this.readIndex; + } + + peek(e, t = undefined) { + this.hiddenReads++; + + const r = this.readIndex; + const a = this.bytesTrashed; + + try { + return e(this, t); + } finally { + this.hiddenReads--, (this.readIndex = r - (this.bytesTrashed - a)); + } + } + + advance(e) { + this.shiftReadOrThrow(e); + } + + readWithViewParser(e, t, r, a) { + return t(this.getView(), this.shiftReadOrThrow(e), e, r, a); + } + + readWithBytesParser(e, t, r, a) { + return t(this.buffer, this.shiftReadOrThrow(e), e, r, a); + } + + readUint8() { + //return this.readWithViewParser(1, h, false) + return p(this, 1, h, !1); + } + readInt8() { + return p(this, 1, h, !0); + } + readUint16(e = this.littleEndian) { + return p(this, 2, _, e); + } + readInt32(e = this.littleEndian) { + return p(this, 4, m, e); + } + readUint32(e = this.littleEndian) { + return p(this, 4, g, e); + } + readInt64(e = this.littleEndian) { + return p(this, 8, v, j, e); + } + readUint64(e = this.littleEndian) { + return p(this, 8, v, W, e); + } + readLong(e, t = this.littleEndian) { + return p(this, 8, v, e, t); + } + readFloat32(e = this.littleEndian) { + return p(this, 4, y, e); + } + readFloat64(e = this.littleEndian) { + return p(this, 8, E, e); + } + readVarInt(e) { + var t = f(this, 0, S, this.size()); + return f(this, t, T, e); + } + readBuffer(e = this.size()) { + return 0 === e ? new ArrayBuffer(0) : f(this, e, A); + } + readByteArray(e = this.size()) { + return 0 === e ? new Uint8Array(0) : f(this, e, b); + } + readBinary(e = this.size(), t = this.littleEndian) { + if (0 === e) return new Binary(void 0, t); + var r = f(this, e, b); + return new Binary(r, t); + } + indexOf(e) { + if (0 === e.length) return 0; + for ( + var t = this.buffer, + r = this.readEndIndex, + a = this.readIndex, + i = 0, + n = a, + s = a; + s < r; + s++ + ) + if (t[s] === e[i]) { + if ((0 === i && (n = s), ++i === e.byteLength)) + return s - a - e.byteLength + 1; + } else i > 0 && ((i = 0), (s = n)); + return -1; + 1; + } + readString(e) { + return f(this, e, C); + } + ensureCapacity(e) { + this.maybeReallocate(this.readIndex + e); + } + ensureAdditionalCapacity(e) { + this.maybeReallocate(this.writeIndex + e); + } + writeToView(e, t, r, a) { + var i = this.shiftWriteMaybeReallocate(e); + return t(this.getView(), i, e, r, a); + } + writeToBytes(e, t, r, a) { + var i = this.shiftWriteMaybeReallocate(e); + return t(this.buffer, i, e, r, a); + } + write(...e) { + for (var t = 0; t < e.length; t++) { + var r = e[t]; + "string" == typeof r + ? this.writeString(r) + : "number" == typeof r + ? this.writeUint8(r) + : r instanceof Binary + ? this.writeBinary(r) + : r instanceof ArrayBuffer + ? this.writeBuffer(r) + : r instanceof Uint8Array && this.writeByteArray(r); + } + } + writeUint8(e) { + Y(e, 0, 256, "uint8"), O(this, 1, M, e, !1); + } + writeInt8(e) { + Y(e, -128, 128, "signed int8"), O(this, 1, M, e, !0); + } + writeUint16(e, t = this.littleEndian) { + Y(e, 0, 65536, "uint16"), P(this, 2, w, e, t); + } + writeInt16(e, t = this.littleEndian) { + Y(e, -32768, 32768, "signed int16"), P(this, 2, I, e, t); + } + writeUint32(e, t = this.littleEndian) { + Y(e, 0, 4294967296, "uint32"), P(this, 4, R, e, t); + } + writeInt32(e, t = this.littleEndian) { + Y(e, -2147483648, 2147483648, "signed int32"), P(this, 4, D, e, t); + } + writeUint64(e, t = this.littleEndian) { + Y(e, 0, 0x10000000000000000, "uint64"), P(this, 8, N, e, t); + } + writeInt64(e, t = this.littleEndian) { + Y(e, -0x8000000000000000, 0x8000000000000000, "signed int64"), + P(this, 8, N, e, t); + } + writeFloat32(e, t = this.littleEndian) { + P(this, 4, L, e, t); + } + writeFloat64(e, t = this.littleEndian) { + P(this, 8, k, e, t); + } + writeVarInt(e) { + Y(e, -0x8000000000000000, 0x8000000000000000, "varint (signed int64)"); + var t = e < 0, + r = t ? -e : e, + a = Math.floor(r / 4294967296), + i = r - 4294967296 * a; + t && ((a = ~a), 0 === i ? a++ : (i = -i)), O(this, B(a, i), U, a, i); + } + writeVarIntFromHexLong(e) { + for ( + var t = hexLongIsNegative(e), + r = t ? negateHexLong(e) : e, + i = hexLongToHex(r), + n = 0, + s = 0, + o = 0; + o < NUM_HEX_IN_LONG; + o++ + ) + (n = (n << 4) | (s >>> 28)), (s = (s << 4) | hexAt(i, o)); + t && ((n = ~n), 0 === s ? n++ : (s = -s)), O(this, B(n, s), U, n, s); + } + writeBinary(e) { + var t = e.peek((e) => e.readByteArray()); + if (t.length) { + var r = this.shiftWriteMaybeReallocate(t.length); + this.buffer.set(t, r); + } + } + writeBuffer(e) { + this.writeByteArray(new Uint8Array(e)); + } + writeByteArray(e) { + var t = this.shiftWriteMaybeReallocate(e.length); + this.buffer.set(e, t); + } + writeBufferView(e) { + this.writeByteArray(new Uint8Array(e.buffer, e.byteOffset, e.byteLength)); + } + writeString(e) { + O(this, u(e), G, e); + } + writeHexLong(e, t = this.littleEndian) { + P(this, 8, F, e, t); + } + writeBytes(...e) { + for (var t = 0; t < e.length; t++) Y(e[t], 0, 256, "byte"); + O(this, e.length, x, e); + } + writeAtomically(e, t) { + this.hiddenWrites++; + var r = this.writeIndex, + a = this.bytesTrashed; + try { + var i = e(this, t); + return (r = this.writeIndex), (a = this.bytesTrashed), i; + } finally { + this.hiddenWrites--, (this.writeIndex = r - (this.bytesTrashed - a)); + } + } + + writeWithVarIntLength(e, t) { + var r = this.writeIndex, + a = this.writeAtomically(e, t), + i = this.writeIndex; + this.writeVarInt(i - r); + for (var s = this.writeIndex - i, o = this.buffer, l = 0; l < s; l++) + n[l] = o[i + l]; + for (var d = i - 1; d >= r; d--) o[d + s] = o[d]; + for (var u = 0; u < s; u++) o[r + u] = n[u]; + return a; + } + + static build(...e) { + let t = 0; + let r = 0; + for (t = 0, r = 0; r < e.length; r++) { + let a = e[r]; + "string" == typeof a + ? (t += u(a)) + : "number" == typeof a + ? t++ + : a instanceof Binary + ? (t += a.size()) + : a instanceof ArrayBuffer + ? (t += a.byteLength) + : a instanceof Uint8Array && (t += a.length); + } + + var i = new Binary(); + return i.ensureCapacity(t), i.write.apply(i, arguments), i; + } + + getView() { + return ( + this.view || + (this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset)) + ); + } + + shiftReadOrThrow(e) { + if (e < 0) + throw new Error("ReadError: given negative number of bytes to read"); + var t = this.readIndex, + r = t + e; + if (r > this.readEndIndex) + throw new Error( + t === this.readEndIndex + ? "ReadError: tried to read from depleted binary" + : "ReadError: tried to read beyond end of binary" + ); + return ( + (this.readIndex = r), this.hiddenReads || (this.earliestIndex = r), t + ); + } + + maybeReallocate(e) { + const t = this.buffer; + if (e <= t.length) { + return e; + } + + const r = this.earliestIndex; + const a = e - r; + const i = Math.max(a, 2 * (t.length - r), 64); + const n = new Uint8Array(i); + return ( + r + ? (n.set(t.subarray(r)), + (this.bytesTrashed += r), + (this.readIndex -= r), + (this.readEndIndex -= r), + (this.writeIndex -= r), + (this.earliestIndex = 0)) + : n.set(t), + (this.buffer = n), + (this.view = null), + a + ); + } + + shiftWriteMaybeReallocate(e) { + const t = this.maybeReallocate(this.writeIndex + e); + const r = this.writeIndex; + return ( + (this.writeIndex = t), this.hiddenWrites || (this.readEndIndex = t), r + ); + } + decompressed = () => { + if (2 & this.readUint8()) { + const result = inflateSync(this.readByteArray()) + return new Binary(result) + } + return this + } +} diff --git a/WABinary/Constants.js b/WABinary/Constants.js new file mode 100644 index 0000000..ea674c1 --- /dev/null +++ b/WABinary/Constants.js @@ -0,0 +1,21 @@ +export const DEVICE = { PRIMARY_DEVICE: 0, PRIMARY_VERSION: 0 } + +export const SINGLE_BYTE_TOKEN = ["xmlstreamstart", "xmlstreamend", "s.whatsapp.net", "type", "participant", "from", "receipt", "id", "broadcast", "status", "message", "notification", "notify", "to", "jid", "user", "class", "offline", "g.us", "result", "mediatype", "enc", "skmsg", "off_cnt", "xmlns", "presence", "participants", "ack", "t", "iq", "device_hash", "read", "value", "media", "picture", "chatstate", "unavailable", "text", "urn:xmpp:whatsapp:push", "devices", "verified_name", "contact", "composing", "edge_routing", "routing_info", "item", "image", "verified_level", "get", "fallback_hostname", "2", "media_conn", "1", "v", "handshake", "fallback_class", "count", "config", "offline_preview", "download_buckets", "w:profile:picture", "set", "creation", "location", "fallback_ip4", "msg", "urn:xmpp:ping", "fallback_ip6", "call-creator", "relaylatency", "success", "subscribe", "video", "business_hours_config", "platform", "hostname", "version", "unknown", "0", "ping", "hash", "edit", "subject", "max_buckets", "download", "delivery", "props", "sticker", "name", "last", "contacts", "business", "primary", "preview", "w:p", "pkmsg", "call-id", "retry", "prop", "call", "auth_ttl", "available", "relay_id", "last_id", "day_of_week", "w", "host", "seen", "bits", "list", "atn", "upload", "is_new", "w:stats", "key", "paused", "specific_hours", "multicast", "stream:error", "mmg.whatsapp.net", "code", "deny", "played", "profile", "fna", "device-list", "close_time", "latency", "gcm", "pop", "audio", "26", "w:web", "open_time", "error", "auth", "ip4", "update", "profile_options", "config_value", "category", "catalog_not_created", "00", "config_code", "mode", "catalog_status", "ip6", "blocklist", "registration", "7", "web", "fail", "w:m", "cart_enabled", "ttl", "gif", "300", "device_orientation", "identity", "query", "401", "media-gig2-1.cdn.whatsapp.net", "in", "3", "te2", "add", "fallback", "categories", "ptt", "encrypt", "notice", "thumbnail-document", "item-not-found", "12", "thumbnail-image", "stage", "thumbnail-link", "usync", "out", "thumbnail-video", "8", "01", "context", "sidelist", "thumbnail-gif", "terminate", "not-authorized", "orientation", "dhash", "capability", "side_list", "md-app-state", "description", "serial", "readreceipts", "te", "business_hours", "md-msg-hist", "tag", "attribute_padding", "document", "open_24h", "delete", "expiration", "active", "prev_v_id", "true", "passive", "index", "4", "conflict", "remove", "w:gp2", "config_expo_key", "screen_height", "replaced", "02", "screen_width", "uploadfieldstat", "2:47DEQpj8", "media-bog1-1.cdn.whatsapp.net", "encopt", "url", "catalog_exists", "keygen", "rate", "offer", "opus", "media-mia3-1.cdn.whatsapp.net", "privacy", "media-mia3-2.cdn.whatsapp.net", "signature", "preaccept", "token_id", "media-eze1-1.cdn.whatsapp.net"]; +export const DICTIONARY_0_TOKEN = ["media-for1-1.cdn.whatsapp.net", "relay", "media-gru2-2.cdn.whatsapp.net", "uncompressed", "medium", "voip_settings", "device", "reason", "media-lim1-1.cdn.whatsapp.net", "media-qro1-2.cdn.whatsapp.net", "media-gru1-2.cdn.whatsapp.net", "action", "features", "media-gru2-1.cdn.whatsapp.net", "media-gru1-1.cdn.whatsapp.net", "media-otp1-1.cdn.whatsapp.net", "kyc-id", "priority", "phash", "mute", "token", "100", "media-qro1-1.cdn.whatsapp.net", "none", "media-mrs2-2.cdn.whatsapp.net", "sign_credential", "03", "media-mrs2-1.cdn.whatsapp.net", "protocol", "timezone", "transport", "eph_setting", "1080", "original_dimensions", "media-frx5-1.cdn.whatsapp.net", "background", "disable", "original_image_url", "5", "transaction-id", "direct_path", "103", "appointment_only", "request_image_url", "peer_pid", "address", "105", "104", "102", "media-cdt1-1.cdn.whatsapp.net", "101", "109", "110", "106", "background_location", "v_id", "sync", "status-old", "111", "107", "ppic", "media-scl2-1.cdn.whatsapp.net", "business_profile", "108", "invite", "04", "audio_duration", "media-mct1-1.cdn.whatsapp.net", "media-cdg2-1.cdn.whatsapp.net", "media-los2-1.cdn.whatsapp.net", "invis", "net", "voip_payload_type", "status-revoke-delay", "404", "state", "use_correct_order_for_hmac_sha1", "ver", "media-mad1-1.cdn.whatsapp.net", "order", "540", "skey", "blinded_credential", "android", "contact_remove", "enable_downlink_relay_latency_only", "duration", "enable_vid_one_way_codec_nego", "6", "media-sof1-1.cdn.whatsapp.net", "accept", "all", "signed_credential", "media-atl3-1.cdn.whatsapp.net", "media-lhr8-1.cdn.whatsapp.net", "website", "05", "latitude", "media-dfw5-1.cdn.whatsapp.net", "forbidden", "enable_audio_piggyback_network_mtu_fix", "media-dfw5-2.cdn.whatsapp.net", "note.m4r", "media-atl3-2.cdn.whatsapp.net", "jb_nack_discard_count_fix", "longitude", "Opening.m4r", "media-arn2-1.cdn.whatsapp.net", "email", "timestamp", "admin", "media-pmo1-1.cdn.whatsapp.net", "America/Sao_Paulo", "contact_add", "media-sin6-1.cdn.whatsapp.net", "interactive", "8000", "acs_public_key", "sigquit_anr_detector_release_rollover_percent", "media.fmed1-2.fna.whatsapp.net", "groupadd", "enabled_for_video_upgrade", "latency_update_threshold", "media-frt3-2.cdn.whatsapp.net", "calls_row_constraint_layout", "media.fgbb2-1.fna.whatsapp.net", "mms4_media_retry_notification_encryption_enabled", "timeout", "media-sin6-3.cdn.whatsapp.net", "audio_nack_jitter_multiplier", "jb_discard_count_adjust_pct_rc", "audio_reserve_bps", "delta", "account_sync", "default", "media.fjed4-6.fna.whatsapp.net", "06", "lock_video_orientation", "media-frt3-1.cdn.whatsapp.net", "w:g2", "media-sin6-2.cdn.whatsapp.net", "audio_nack_algo_mask", "media.fgbb2-2.fna.whatsapp.net", "media.fmed1-1.fna.whatsapp.net", "cond_range_target_bitrate", "mms4_server_error_receipt_encryption_enabled", "vid_rc_dyn", "fri", "cart_v1_1_order_message_changes_enabled", "reg_push", "jb_hist_deposit_value", "privatestats", "media.fist7-2.fna.whatsapp.net", "thu", "jb_discard_count_adjust_pct", "mon", "group_call_video_maximization_enabled", "mms_cat_v1_forward_hot_override_enabled", "audio_nack_new_rtt", "media.fsub2-3.fna.whatsapp.net", "media_upload_aggressive_retry_exponential_backoff_enabled", "tue", "wed", "media.fruh4-2.fna.whatsapp.net", "audio_nack_max_seq_req", "max_rtp_audio_packet_resends", "jb_hist_max_cdf_value", "07", "audio_nack_max_jb_delay", "mms_forward_partially_downloaded_video", "media-lcy1-1.cdn.whatsapp.net", "resume", "jb_inband_fec_aware", "new_commerce_entry_point_enabled", "480", "payments_upi_generate_qr_amount_limit", "sigquit_anr_detector_rollover_percent", "media.fsdu2-1.fna.whatsapp.net", "fbns", "aud_pkt_reorder_pct", "dec", "stop_probing_before_accept_send", "media_upload_max_aggressive_retries", "edit_business_profile_new_mode_enabled", "media.fhex4-1.fna.whatsapp.net", "media.fjed4-3.fna.whatsapp.net", "sigquit_anr_detector_64bit_rollover_percent", "cond_range_ema_jb_last_delay", "watls_enable_early_data_http_get", "media.fsdu2-2.fna.whatsapp.net", "message_qr_disambiguation_enabled", "media-mxp1-1.cdn.whatsapp.net", "sat", "vertical", "media.fruh4-5.fna.whatsapp.net", "200", "media-sof1-2.cdn.whatsapp.net", "-1", "height", "product_catalog_hide_show_items_enabled", "deep_copy_frm_last", "tsoffline", "vp8/h.264", "media.fgye5-3.fna.whatsapp.net", "media.ftuc1-2.fna.whatsapp.net", "smb_upsell_chat_banner_enabled", "canonical", "08", "9", ".", "media.fgyd4-4.fna.whatsapp.net", "media.fsti4-1.fna.whatsapp.net", "mms_vcache_aggregation_enabled", "mms_hot_content_timespan_in_seconds", "nse_ver", "rte", "third_party_sticker_web_sync", "cond_range_target_total_bitrate", "media_upload_aggressive_retry_enabled", "instrument_spam_report_enabled", "disable_reconnect_tone", "move_media_folder_from_sister_app", "one_tap_calling_in_group_chat_size", "10", "storage_mgmt_banner_threshold_mb", "enable_backup_passive_mode", "sharechat_inline_player_enabled", "media.fcnq2-1.fna.whatsapp.net", "media.fhex4-2.fna.whatsapp.net", "media.fist6-3.fna.whatsapp.net", "ephemeral_drop_column_stage", "reconnecting_after_network_change_threshold_ms", "media-lhr8-2.cdn.whatsapp.net", "cond_jb_last_delay_ema_alpha", "entry_point_block_logging_enabled", "critical_event_upload_log_config", "respect_initial_bitrate_estimate", "smaller_image_thumbs_status_enabled", "media.fbtz1-4.fna.whatsapp.net", "media.fjed4-1.fna.whatsapp.net", "width", "720", "enable_frame_dropper", "enable_one_side_mode", "urn:xmpp:whatsapp:dirty", "new_sticker_animation_behavior_v2", "media.flim3-2.fna.whatsapp.net", "media.fuio6-2.fna.whatsapp.net", "skip_forced_signaling", "dleq_proof", "status_video_max_bitrate", "lazy_send_probing_req", "enhanced_storage_management", "android_privatestats_endpoint_dit_enabled", "media.fscl13-2.fna.whatsapp.net", "video_duration"]; +export const DICTIONARY_1_TOKEN = ["group_call_discoverability_enabled", "media.faep9-2.fna.whatsapp.net", "msgr", "bloks_loggedin_access_app_id", "db_status_migration_step", "watls_prefer_ip6", "jabber:iq:privacy", "68", "media.fsaw1-11.fna.whatsapp.net", "mms4_media_conn_persist_enabled", "animated_stickers_thread_clean_up", "media.fcgk3-2.fna.whatsapp.net", "media.fcgk4-6.fna.whatsapp.net", "media.fgye5-2.fna.whatsapp.net", "media.flpb1-1.fna.whatsapp.net", "media.fsub2-1.fna.whatsapp.net", "media.fuio6-3.fna.whatsapp.net", "not-allowed", "partial_pjpeg_bw_threshold", "cap_estimated_bitrate", "mms_chatd_resume_check_over_thrift", "smb_upsell_business_profile_enabled", "product_catalog_webclient", "groups", "sigquit_anr_detector_release_updated_rollout", "syncd_key_rotation_enabled", "media.fdmm2-1.fna.whatsapp.net", "media-hou1-1.cdn.whatsapp.net", "remove_old_chat_notifications", "smb_biztools_deeplink_enabled", "use_downloadable_filters_int", "group_qr_codes_enabled", "max_receipt_processing_time", "optimistic_image_processing_enabled", "smaller_video_thumbs_status_enabled", "watls_early_data", "reconnecting_before_relay_failover_threshold_ms", "cond_range_packet_loss_pct", "groups_privacy_blacklist", "status-revoke-drop", "stickers_animated_thumbnail_download", "dedupe_transcode_shared_images", "dedupe_transcode_shared_videos", "media.fcnq2-2.fna.whatsapp.net", "media.fgyd4-1.fna.whatsapp.net", "media.fist7-1.fna.whatsapp.net", "media.flim3-3.fna.whatsapp.net", "add_contact_by_qr_enabled", "https://faq.whatsapp.com/payments", "multicast_limit_global", "sticker_notification_preview", "smb_better_catalog_list_adapters_enabled", "bloks_use_minscript_android", "pen_smoothing_enabled", "media.fcgk4-5.fna.whatsapp.net", "media.fevn1-3.fna.whatsapp.net", "media.fpoj7-1.fna.whatsapp.net", "media-arn2-2.cdn.whatsapp.net", "reconnecting_before_network_change_threshold_ms", "android_media_use_fresco_for_gifs", "cond_in_congestion", "status_image_max_edge", "sticker_search_enabled", "starred_stickers_web_sync", "db_blank_me_jid_migration_step", "media.fist6-2.fna.whatsapp.net", "media.ftuc1-1.fna.whatsapp.net", "09", "anr_fast_logs_upload_rollout", "camera_core_integration_enabled", "11", "third_party_sticker_caching", "thread_dump_contact_support", "wam_privatestats_enabled", "vcard_as_document_size_kb", "maxfpp", "fbip", "ephemeral_allow_group_members", "media-bom1-2.cdn.whatsapp.net", "media-xsp1-1.cdn.whatsapp.net", "disable_prewarm", "frequently_forwarded_max", "media.fbtz1-5.fna.whatsapp.net", "media.fevn7-1.fna.whatsapp.net", "media.fgyd4-2.fna.whatsapp.net", "sticker_tray_animation_fully_visible_items", "green_alert_banner_duration", "reconnecting_after_p2p_failover_threshold_ms", "connected", "share_biz_vcard_enabled", "stickers_animation", "0a", "1200", "WhatsApp", "group_description_length", "p_v_id", "payments_upi_intent_transaction_limit", "frequently_forwarded_messages", "media-xsp1-2.cdn.whatsapp.net", "media.faep8-1.fna.whatsapp.net", "media.faep8-2.fna.whatsapp.net", "media.faep9-1.fna.whatsapp.net", "media.fdmm2-2.fna.whatsapp.net", "media.fgzt3-1.fna.whatsapp.net", "media.flim4-2.fna.whatsapp.net", "media.frao1-1.fna.whatsapp.net", "media.fscl9-2.fna.whatsapp.net", "media.fsub2-2.fna.whatsapp.net", "superadmin", "media.fbog10-1.fna.whatsapp.net", "media.fcgh28-1.fna.whatsapp.net", "media.fjdo10-1.fna.whatsapp.net", "third_party_animated_sticker_import", "delay_fec", "attachment_picker_refresh", "android_linked_devices_re_auth_enabled", "rc_dyn", "green_alert_block_jitter", "add_contact_logging_enabled", "biz_message_logging_enabled", "conversation_media_preview_v2", "media-jnb1-1.cdn.whatsapp.net", "ab_key", "media.fcgk4-2.fna.whatsapp.net", "media.fevn1-1.fna.whatsapp.net", "media.fist6-1.fna.whatsapp.net", "media.fruh4-4.fna.whatsapp.net", "media.fsti4-2.fna.whatsapp.net", "mms_vcard_autodownload_size_kb", "watls_enabled", "notif_ch_override_off", "media.fsaw1-14.fna.whatsapp.net", "media.fscl13-1.fna.whatsapp.net", "db_group_participant_migration_step", "1020", "cond_range_sterm_rtt", "invites_logging_enabled", "triggered_block_enabled", "group_call_max_participants", "media-iad3-1.cdn.whatsapp.net", "product_catalog_open_deeplink", "shops_required_tos_version", "image_max_kbytes", "cond_low_quality_vid_mode", "db_receipt_migration_step", "jb_early_prob_hist_shrink", "media.fdmm2-3.fna.whatsapp.net", "media.fdmm2-4.fna.whatsapp.net", "media.fruh4-1.fna.whatsapp.net", "media.fsaw2-2.fna.whatsapp.net", "remove_geolocation_videos", "new_animation_behavior", "fieldstats_beacon_chance", "403", "authkey_reset_on_ban", "continuous_ptt_playback", "reconnecting_after_relay_failover_threshold_ms", "false", "group", "sun", "conversation_swipe_to_reply", "ephemeral_messages_setting", "smaller_video_thumbs_enabled", "md_device_sync_enabled", "bloks_shops_pdp_url_regex", "lasso_integration_enabled", "media-bom1-1.cdn.whatsapp.net", "new_backup_format_enabled", "256", "media.faep6-1.fna.whatsapp.net", "media.fasr1-1.fna.whatsapp.net", "media.fbtz1-7.fna.whatsapp.net", "media.fesb4-1.fna.whatsapp.net", "media.fjdo1-2.fna.whatsapp.net", "media.frba2-1.fna.whatsapp.net", "watls_no_dns", "600", "db_broadcast_me_jid_migration_step", "new_wam_runtime_enabled", "group_update", "enhanced_block_enabled", "sync_wifi_threshold_kb", "mms_download_nc_cat", "bloks_minification_enabled", "ephemeral_messages_enabled", "reject", "voip_outgoing_xml_signaling", "creator", "dl_bw", "payments_request_messages", "target_bitrate", "bloks_rendercore_enabled", "media-hbe1-1.cdn.whatsapp.net", "media-hel3-1.cdn.whatsapp.net", "media-kut2-2.cdn.whatsapp.net", "media-lax3-1.cdn.whatsapp.net", "media-lax3-2.cdn.whatsapp.net", "sticker_pack_deeplink_enabled", "hq_image_bw_threshold", "status_info", "voip", "dedupe_transcode_videos", "grp_uii_cleanup", "linked_device_max_count", "media.flim1-1.fna.whatsapp.net", "media.fsaw2-1.fna.whatsapp.net", "reconnecting_after_call_active_threshold_ms", "1140", "catalog_pdp_new_design", "media.fbtz1-10.fna.whatsapp.net", "media.fsaw1-15.fna.whatsapp.net", "0b", "consumer_rc_provider", "mms_async_fast_forward_ttl", "jb_eff_size_fix", "voip_incoming_xml_signaling", "media_provider_share_by_uuid", "suspicious_links", "dedupe_transcode_images", "green_alert_modal_start", "media-cgk1-1.cdn.whatsapp.net", "media-lga3-1.cdn.whatsapp.net", "template_doc_mime_types", "important_messages", "user_add", "vcard_max_size_kb", "media.fada2-1.fna.whatsapp.net", "media.fbog2-5.fna.whatsapp.net", "media.fbtz1-3.fna.whatsapp.net", "media.fcgk3-1.fna.whatsapp.net", "media.fcgk7-1.fna.whatsapp.net", "media.flim1-3.fna.whatsapp.net", "media.fscl9-1.fna.whatsapp.net", "ctwa_context_enterprise_enabled", "media.fsaw1-13.fna.whatsapp.net", "media.fuio11-2.fna.whatsapp.net", "status_collapse_muted", "db_migration_level_force", "recent_stickers_web_sync", "bloks_session_state", "bloks_shops_enabled", "green_alert_setting_deep_links_enabled", "restrict_groups", "battery", "green_alert_block_start", "refresh", "ctwa_context_enabled", "md_messaging_enabled", "status_image_quality", "md_blocklist_v2_server", "media-del1-1.cdn.whatsapp.net", "13", "userrate", "a_v_id", "cond_rtt_ema_alpha", "invalid"]; +export const DICTIONARY_2_TOKEN = ["media.fada1-1.fna.whatsapp.net", "media.fadb3-2.fna.whatsapp.net", "media.fbhz2-1.fna.whatsapp.net", "media.fcor2-1.fna.whatsapp.net", "media.fjed4-2.fna.whatsapp.net", "media.flhe4-1.fna.whatsapp.net", "media.frak1-2.fna.whatsapp.net", "media.fsub6-3.fna.whatsapp.net", "media.fsub6-7.fna.whatsapp.net", "media.fvvi1-1.fna.whatsapp.net", "search_v5_eligible", "wam_real_time_enabled", "report_disk_event", "max_tx_rott_based_bitrate", "product", "media.fjdo10-2.fna.whatsapp.net", "video_frame_crc_sample_interval", "media_max_autodownload", "15", "h.264", "wam_privatestats_buffer_count", "md_phash_v2_enabled", "account_transfer_enabled", "business_product_catalog", "enable_non_dyn_codec_param_fix", "is_user_under_epd_jurisdiction", "media.fbog2-4.fna.whatsapp.net", "media.fbtz1-2.fna.whatsapp.net", "media.fcfc1-1.fna.whatsapp.net", "media.fjed4-5.fna.whatsapp.net", "media.flhe4-2.fna.whatsapp.net", "media.flim1-2.fna.whatsapp.net", "media.flos5-1.fna.whatsapp.net", "android_key_store_auth_ver", "010", "anr_process_monitor", "delete_old_auth_key", "media.fcor10-3.fna.whatsapp.net", "storage_usage_enabled", "android_camera2_support_level", "dirty", "consumer_content_provider", "status_video_max_duration", "0c", "bloks_cache_enabled", "media.fadb2-2.fna.whatsapp.net", "media.fbko1-1.fna.whatsapp.net", "media.fbtz1-9.fna.whatsapp.net", "media.fcgk4-4.fna.whatsapp.net", "media.fesb4-2.fna.whatsapp.net", "media.fevn1-2.fna.whatsapp.net", "media.fist2-4.fna.whatsapp.net", "media.fjdo1-1.fna.whatsapp.net", "media.fruh4-6.fna.whatsapp.net", "media.fsrg5-1.fna.whatsapp.net", "media.fsub6-6.fna.whatsapp.net", "minfpp", "5000", "locales", "video_max_bitrate", "use_new_auth_key", "bloks_http_enabled", "heartbeat_interval", "media.fbog11-1.fna.whatsapp.net", "ephemeral_group_query_ts", "fec_nack", "search_in_storage_usage", "c", "media-amt2-1.cdn.whatsapp.net", "linked_devices_ui_enabled", "14", "async_data_load_on_startup", "voip_incoming_xml_ack", "16", "db_migration_step", "init_bwe", "max_participants", "wam_buffer_count", "media.fada2-2.fna.whatsapp.net", "media.fadb3-1.fna.whatsapp.net", "media.fcor2-2.fna.whatsapp.net", "media.fdiy1-2.fna.whatsapp.net", "media.frba3-2.fna.whatsapp.net", "media.fsaw2-3.fna.whatsapp.net", "1280", "status_grid_enabled", "w:biz", "product_catalog_deeplink", "media.fgye10-2.fna.whatsapp.net", "media.fuio11-1.fna.whatsapp.net", "optimistic_upload", "work_manager_init", "lc", "catalog_message", "cond_net_medium", "enable_periodical_aud_rr_processing", "cond_range_ema_rtt", "media-tir2-1.cdn.whatsapp.net", "frame_ms", "group_invite_sending", "payments_web_enabled", "wallpapers_v2", "0d", "browser", "hq_image_max_edge", "image_edit_zoom", "linked_devices_re_auth_enabled", "media.faly3-2.fna.whatsapp.net", "media.fdoh5-3.fna.whatsapp.net", "media.fesb3-1.fna.whatsapp.net", "media.fknu1-1.fna.whatsapp.net", "media.fmex3-1.fna.whatsapp.net", "media.fruh4-3.fna.whatsapp.net", "255", "web_upgrade_to_md_modal", "audio_piggyback_timeout_msec", "enable_audio_oob_fec_feature", "from_ip", "image_max_edge", "message_qr_enabled", "powersave", "receipt_pre_acking", "video_max_edge", "full", "011", "012", "enable_audio_oob_fec_for_sender", "md_voip_enabled", "enable_privatestats", "max_fec_ratio", "payments_cs_faq_url", "media-xsp1-3.cdn.whatsapp.net", "hq_image_quality", "media.fasr1-2.fna.whatsapp.net", "media.fbog3-1.fna.whatsapp.net", "media.ffjr1-6.fna.whatsapp.net", "media.fist2-3.fna.whatsapp.net", "media.flim4-3.fna.whatsapp.net", "media.fpbc2-4.fna.whatsapp.net", "media.fpku1-1.fna.whatsapp.net", "media.frba1-1.fna.whatsapp.net", "media.fudi1-1.fna.whatsapp.net", "media.fvvi1-2.fna.whatsapp.net", "gcm_fg_service", "enable_dec_ltr_size_check", "clear", "lg", "media.fgru11-1.fna.whatsapp.net", "18", "media-lga3-2.cdn.whatsapp.net", "pkey", "0e", "max_subject", "cond_range_lterm_rtt", "announcement_groups", "biz_profile_options", "s_t", "media.fabv2-1.fna.whatsapp.net", "media.fcai3-1.fna.whatsapp.net", "media.fcgh1-1.fna.whatsapp.net", "media.fctg1-4.fna.whatsapp.net", "media.fdiy1-1.fna.whatsapp.net", "media.fisb4-1.fna.whatsapp.net", "media.fpku1-2.fna.whatsapp.net", "media.fros9-1.fna.whatsapp.net", "status_v3_text", "usync_sidelist", "17", "announcement", "...", "md_group_notification", "0f", "animated_pack_in_store", "013", "America/Mexico_City", "1260", "media-ams4-1.cdn.whatsapp.net", "media-cgk1-2.cdn.whatsapp.net", "media-cpt1-1.cdn.whatsapp.net", "media-maa2-1.cdn.whatsapp.net", "media.fgye10-1.fna.whatsapp.net", "e", "catalog_cart", "hfm_string_changes", "init_bitrate", "packless_hsm", "group_info", "America/Belem", "50", "960", "cond_range_bwe", "decode", "encode", "media.fada1-8.fna.whatsapp.net", "media.fadb1-2.fna.whatsapp.net", "media.fasu6-1.fna.whatsapp.net", "media.fbog4-1.fna.whatsapp.net", "media.fcgk9-2.fna.whatsapp.net", "media.fdoh5-2.fna.whatsapp.net", "media.ffjr1-2.fna.whatsapp.net", "media.fgua1-1.fna.whatsapp.net", "media.fgye1-1.fna.whatsapp.net", "media.fist1-4.fna.whatsapp.net", "media.fpbc2-2.fna.whatsapp.net", "media.fres2-1.fna.whatsapp.net", "media.fsdq1-2.fna.whatsapp.net", "media.fsub6-5.fna.whatsapp.net", "profilo_enabled", "template_hsm", "use_disorder_prefetching_timer", "video_codec_priority", "vpx_max_qp", "ptt_reduce_recording_delay", "25", "iphone", "Windows", "s_o", "Africa/Lagos", "abt", "media-kut2-1.cdn.whatsapp.net", "media-mba1-1.cdn.whatsapp.net", "media-mxp1-2.cdn.whatsapp.net", "md_blocklist_v2", "url_text", "enable_short_offset", "group_join_permissions", "enable_audio_piggyback_feature", "image_quality", "media.fcgk7-2.fna.whatsapp.net", "media.fcgk8-2.fna.whatsapp.net", "media.fclo7-1.fna.whatsapp.net", "media.fcmn1-1.fna.whatsapp.net", "media.feoh1-1.fna.whatsapp.net", "media.fgyd4-3.fna.whatsapp.net", "media.fjed4-4.fna.whatsapp.net", "media.flim1-4.fna.whatsapp.net", "media.flim2-4.fna.whatsapp.net", "media.fplu6-1.fna.whatsapp.net", "media.frak1-1.fna.whatsapp.net", "media.fsdq1-1.fna.whatsapp.net", "to_ip", "015", "vp8", "19", "21", "1320", "auth_key_ver", "message_processing_dedup", "server-error", "wap4_enabled", "420", "014", "cond_range_rtt", "ptt_fast_lock_enabled", "media-ort2-1.cdn.whatsapp.net", "fwd_ui_start_ts"]; + +export const DICTIONARY_3_TOKEN = ["contact_blacklist", "Asia/Jakarta", "media.fepa10-1.fna.whatsapp.net", "media.fmex10-3.fna.whatsapp.net", "disorder_prefetching_start_when_empty", "America/Bogota", "use_local_probing_rx_bitrate", "America/Argentina/Buenos_Aires", "cross_post", "media.fabb1-1.fna.whatsapp.net", "media.fbog4-2.fna.whatsapp.net", "media.fcgk9-1.fna.whatsapp.net", "media.fcmn2-1.fna.whatsapp.net", "media.fdel3-1.fna.whatsapp.net", "media.ffjr1-1.fna.whatsapp.net", "media.fgdl5-1.fna.whatsapp.net", "media.flpb1-2.fna.whatsapp.net", "media.fmex2-1.fna.whatsapp.net", "media.frba2-2.fna.whatsapp.net", "media.fros2-2.fna.whatsapp.net", "media.fruh2-1.fna.whatsapp.net", "media.fybz2-2.fna.whatsapp.net", "options", "20", "a", "017", "018", "mute_always", "user_notice", "Asia/Kolkata", "gif_provider", "locked", "media-gua1-1.cdn.whatsapp.net", "piggyback_exclude_force_flush", "24", "media.frec39-1.fna.whatsapp.net", "user_remove", "file_max_size", "cond_packet_loss_pct_ema_alpha", "media.facc1-1.fna.whatsapp.net", "media.fadb2-1.fna.whatsapp.net", "media.faly3-1.fna.whatsapp.net", "media.fbdo6-2.fna.whatsapp.net", "media.fcmn2-2.fna.whatsapp.net", "media.fctg1-3.fna.whatsapp.net", "media.ffez1-2.fna.whatsapp.net", "media.fist1-3.fna.whatsapp.net", "media.fist2-2.fna.whatsapp.net", "media.flim2-2.fna.whatsapp.net", "media.fmct2-3.fna.whatsapp.net", "media.fpei3-1.fna.whatsapp.net", "media.frba3-1.fna.whatsapp.net", "media.fsdu8-2.fna.whatsapp.net", "media.fstu2-1.fna.whatsapp.net", "media_type", "receipt_agg", "016", "enable_pli_for_crc_mismatch", "live", "enc_rekey", "frskmsg", "d", "media.fdel11-2.fna.whatsapp.net", "proto", "2250", "audio_piggyback_enable_cache", "skip_nack_if_ltrp_sent", "mark_dtx_jb_frames", "web_service_delay", "7282", "catalog_send_all", "outgoing", "360", "30", "LIMITED", "019", "audio_picker", "bpv2_phase", "media.fada1-7.fna.whatsapp.net", "media.faep7-1.fna.whatsapp.net", "media.fbko1-2.fna.whatsapp.net", "media.fbni1-2.fna.whatsapp.net", "media.fbtz1-1.fna.whatsapp.net", "media.fbtz1-8.fna.whatsapp.net", "media.fcjs3-1.fna.whatsapp.net", "media.fesb3-2.fna.whatsapp.net", "media.fgdl5-4.fna.whatsapp.net", "media.fist2-1.fna.whatsapp.net", "media.flhe2-2.fna.whatsapp.net", "media.flim2-1.fna.whatsapp.net", "media.fmex1-1.fna.whatsapp.net", "media.fpat3-2.fna.whatsapp.net", "media.fpat3-3.fna.whatsapp.net", "media.fros2-1.fna.whatsapp.net", "media.fsdu8-1.fna.whatsapp.net", "media.fsub3-2.fna.whatsapp.net", "payments_chat_plugin", "cond_congestion_no_rtcp_thr", "green_alert", "not-a-biz", "..", "shops_pdp_urls_config", "source", "media-dus1-1.cdn.whatsapp.net", "mute_video", "01b", "currency", "max_keys", "resume_check", "contact_array", "qr_scanning", "23", "b", "media.fbfh15-1.fna.whatsapp.net", "media.flim22-1.fna.whatsapp.net", "media.fsdu11-1.fna.whatsapp.net", "media.fsdu15-1.fna.whatsapp.net", "Chrome", "fts_version", "60", "media.fada1-6.fna.whatsapp.net", "media.faep4-2.fna.whatsapp.net", "media.fbaq5-1.fna.whatsapp.net", "media.fbni1-1.fna.whatsapp.net", "media.fcai3-2.fna.whatsapp.net", "media.fdel3-2.fna.whatsapp.net", "media.fdmm3-2.fna.whatsapp.net", "media.fhex3-1.fna.whatsapp.net", "media.fisb4-2.fna.whatsapp.net", "media.fkhi5-2.fna.whatsapp.net", "media.flos2-1.fna.whatsapp.net", "media.fmct2-1.fna.whatsapp.net", "media.fntr7-1.fna.whatsapp.net", "media.frak3-1.fna.whatsapp.net", "media.fruh5-2.fna.whatsapp.net", "media.fsub6-1.fna.whatsapp.net", "media.fuab1-2.fna.whatsapp.net", "media.fuio1-1.fna.whatsapp.net", "media.fver1-1.fna.whatsapp.net", "media.fymy1-1.fna.whatsapp.net", "product_catalog", "1380", "audio_oob_fec_max_pkts", "22", "254", "media-ort2-2.cdn.whatsapp.net", "media-sjc3-1.cdn.whatsapp.net", "1600", "01a", "01c", "405", "key_frame_interval", "body", "media.fcgh20-1.fna.whatsapp.net", "media.fesb10-2.fna.whatsapp.net", "125", "2000", "media.fbsb1-1.fna.whatsapp.net", "media.fcmn3-2.fna.whatsapp.net", "media.fcpq1-1.fna.whatsapp.net", "media.fdel1-2.fna.whatsapp.net", "media.ffor2-1.fna.whatsapp.net", "media.fgdl1-4.fna.whatsapp.net", "media.fhex2-1.fna.whatsapp.net", "media.fist1-2.fna.whatsapp.net", "media.fjed5-2.fna.whatsapp.net", "media.flim6-4.fna.whatsapp.net", "media.flos2-2.fna.whatsapp.net", "media.fntr6-2.fna.whatsapp.net", "media.fpku3-2.fna.whatsapp.net", "media.fros8-1.fna.whatsapp.net", "media.fymy1-2.fna.whatsapp.net", "ul_bw", "ltrp_qp_offset", "request", "nack", "dtx_delay_state_reset", "timeoffline", "28", "01f", "32", "enable_ltr_pool", "wa_msys_crypto", "01d", "58", "dtx_freeze_hg_update", "nack_if_rpsi_throttled", "253", "840", "media.famd15-1.fna.whatsapp.net", "media.fbog17-2.fna.whatsapp.net", "media.fcai19-2.fna.whatsapp.net", "media.fcai21-4.fna.whatsapp.net", "media.fesb10-4.fna.whatsapp.net", "media.fesb10-5.fna.whatsapp.net", "media.fmaa12-1.fna.whatsapp.net", "media.fmex11-3.fna.whatsapp.net", "media.fpoa33-1.fna.whatsapp.net", "1050", "021", "clean", "cond_range_ema_packet_loss_pct", "media.fadb6-5.fna.whatsapp.net", "media.faqp4-1.fna.whatsapp.net", "media.fbaq3-1.fna.whatsapp.net", "media.fbel2-1.fna.whatsapp.net", "media.fblr4-2.fna.whatsapp.net", "media.fclo8-1.fna.whatsapp.net", "media.fcoo1-2.fna.whatsapp.net", "media.ffjr1-4.fna.whatsapp.net", "media.ffor9-1.fna.whatsapp.net", "media.fisb3-1.fna.whatsapp.net", "media.fkhi2-2.fna.whatsapp.net", "media.fkhi4-1.fna.whatsapp.net", "media.fpbc1-2.fna.whatsapp.net", "media.fruh2-2.fna.whatsapp.net", "media.fruh5-1.fna.whatsapp.net", "media.fsub3-1.fna.whatsapp.net", "payments_transaction_limit", "252", "27", "29", "tintagel", "01e", "237", "780", "callee_updated_payload", "020", "257", "price", "025", "239", "payments_cs_phone_number", "mediaretry", "w:auth:backup:token", "Glass.caf", "max_bitrate", "240", "251", "660", "media.fbog16-1.fna.whatsapp.net", "media.fcgh21-1.fna.whatsapp.net", "media.fkul19-2.fna.whatsapp.net", "media.flim21-2.fna.whatsapp.net", "media.fmex10-4.fna.whatsapp.net", "64", "33", "34", "35", "interruption", "media.fabv3-1.fna.whatsapp.net", "media.fadb6-1.fna.whatsapp.net", "media.fagr1-1.fna.whatsapp.net", "media.famd1-1.fna.whatsapp.net", "media.famm6-1.fna.whatsapp.net", "media.faqp2-3.fna.whatsapp.net"]; +export const DICTIONARIES = [DICTIONARY_0_TOKEN, DICTIONARY_1_TOKEN, DICTIONARY_2_TOKEN, DICTIONARY_3_TOKEN]; + +export const buildMap = (data) => { + const map = new Map(); + for (let r = 0; r < data.length; r++) { + map.set(data[r], r); + } + + return map; +} + +export const SINGLE_BYTE_TOKEN_MAP = buildMap(SINGLE_BYTE_TOKEN); +export const DICTIONARIES_MAP = DICTIONARIES.map((dict) => buildMap(dict)) \ No newline at end of file diff --git a/WABinary/HexHelper.js b/WABinary/HexHelper.js new file mode 100644 index 0000000..3ecadb8 --- /dev/null +++ b/WABinary/HexHelper.js @@ -0,0 +1,117 @@ +import * as Crypto from "crypto"; + +const r = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70], + a = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102]; + +const i = (e) => { + for (var t = [], a = 0; a < e.length; a++) { + var i = e[a]; + t.push(r[i >> 4], r[15 & i]); + } + return String.fromCharCode.apply(String, t); +}; + +const n = (e, t) => { + var r = e.charCodeAt(t); + return r <= 57 ? r - 48 : r <= 70 ? 10 + r - 65 : 10 + r - 97; +}; + +const s = (e) => { + if (/[^0-9a-fA-F]/.test(e)) throw new Error(`"${e}" is not a valid hex`); + return e; +}; + +const o = (e, t) => { + for (var r = t - e.length, a = e, i = 0; i < r; i++) a = "0" + a; + return a; +}; + +const l = (e) => { + return "-" === e[0]; +}; + +const d = (e) => { + if (e > 4294967295 || e < -4294967296) + throw new Error("uint32ToLowerCaseHex given number over 32 bits"); + return o((e >= 0 ? e : 4294967296 + e).toString(16), 8); +}; + +export const NUM_HEX_IN_LONG = 16; +export const HEX_LOWER = a; + +export const randomHex = function (e) { + var t = new Uint8Array(e); + var bytes = Crypto.randomBytes(t.length); + t.set(bytes); + return i(t); +}; + +export const toHex = i; + +export const toLowerCaseHex = function (e) { + for (var t = [], r = 0; r < e.length; r++) { + var i = e[r]; + t.push(a[i >> 4], a[15 & i]); + } + return String.fromCharCode.apply(String, t); +}; + +export const parseHex = function (e) { + var t = s(e); + if (t.length % 2 != 0) + throw new Error( + `parseHex given hex "${t}" which is not a multiple of 8-bits.` + ); + for ( + var r = new Uint8Array(t.length >> 1), a = 0, i = 0; + a < t.length; + a += 2, i++ + ) + r[i] = (n(t, a) << 4) | n(t, a + 1); + return r.buffer; +}; + +export const hexAt = n; +export const hexOrThrow = s; +export const bytesToBuffer = function (e) { + var t = e.buffer; + return 0 === e.byteOffset && e.length === t.byteLength + ? t + : t.slice(e.byteOffset, e.byteOffset + e.length); +}; + +export const bytesToDebugString = function (e) { + var t = !0, + r = e.length; + for (; t && r; ) { + var a = e[--r]; + t = 32 <= a && a < 127; + } + return t ? JSON.stringify(String.fromCharCode.apply(String, e)) : i(e); +}; + +export const createHexLong = function (e, t = !1) { + var r = s(e); + return ( + (function (e, t) { + if (e.length > t) throw new Error(`"${e}" is longer than ${4 * t} bits.`); + })(r, 16), + `${t ? "-" : ""}0x${o(r, 16)}` + ); +}; + +export const createHexLongFrom32Bits = function (e, t, r = !1) { + var a = d(e), + i = d(t); + return `${r ? "-" : ""}0x${a}${i}`; +}; + +export const hexLongToHex = function (e) { + return e.substring(e.indexOf("0x") + 2); +}; + +export const hexLongIsNegative = l; + +export const negateHexLong = function (e) { + return l(e) ? e.slice(1) : "-" + e; +}; diff --git a/WABinary/readme.md b/WABinary/readme.md new file mode 100644 index 0000000..267c69d --- /dev/null +++ b/WABinary/readme.md @@ -0,0 +1,15 @@ +# WABinary + +Contains the raw JS code to parse WA binary messages. WA uses a tree like structure to encode information, the type for which is written below: + +``` ts +export type BinaryNode = { + tag: string + attrs: Attributes + content?: BinaryNode[] | string | Uint8Array +} +``` + +Do note, the multi-device binary format is very similar to the one on WA Web, though they are not backwards compatible. + +Originally from [pokearaujo/multidevice](https://github.com/pokearaujo/multidevice) \ No newline at end of file diff --git a/src/BinaryNode/GenerateStatics.sh b/WAProto/GenerateStatics.sh similarity index 50% rename from src/BinaryNode/GenerateStatics.sh rename to WAProto/GenerateStatics.sh index 295f6bb..7d77a28 100644 --- a/src/BinaryNode/GenerateStatics.sh +++ b/WAProto/GenerateStatics.sh @@ -1,4 +1,4 @@ -yarn pbjs -t static-module -w commonjs -o ./WAMessage/index.js ./src/BinaryNode/WAMessage.proto; -yarn pbts -o ./WAMessage/index.d.ts ./WAMessage/index.js; +yarn pbjs -t static-module -w commonjs -o ./WAProto/index.js ./WAProto/WAProto.proto; +yarn pbts -o ./WAProto/index.d.ts ./WAProto/index.js; #protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_opt=env=node,useOptionals=true,forceLong=long --ts_proto_out=. ./src/Binary/WAMessage.proto; \ No newline at end of file diff --git a/src/BinaryNode/WAMessage.proto b/WAProto/WAProto.proto similarity index 69% rename from src/BinaryNode/WAMessage.proto rename to WAProto/WAProto.proto index 98cd6ec..1bedf04 100644 --- a/src/BinaryNode/WAMessage.proto +++ b/WAProto/WAProto.proto @@ -1,11 +1,621 @@ syntax = "proto2"; package proto; -message MessageKey { - optional string remoteJid = 1; - optional bool fromMe = 2; - optional string id = 3; - optional string participant = 4; +message AppVersion { + optional uint32 primary = 1; + optional uint32 secondary = 2; + optional uint32 tertiary = 3; + optional uint32 quaternary = 4; + optional uint32 quinary = 5; +} + +message UserAgent { + enum UserAgentPlatform { + ANDROID = 0; + IOS = 1; + WINDOWS_PHONE = 2; + BLACKBERRY = 3; + BLACKBERRYX = 4; + S40 = 5; + S60 = 6; + PYTHON_CLIENT = 7; + TIZEN = 8; + ENTERPRISE = 9; + SMB_ANDROID = 10; + KAIOS = 11; + SMB_IOS = 12; + WINDOWS = 13; + WEB = 14; + PORTAL = 15; + GREEN_ANDROID = 16; + GREEN_IPHONE = 17; + BLUE_ANDROID = 18; + BLUE_IPHONE = 19; + FBLITE_ANDROID = 20; + MLITE_ANDROID = 21; + IGLITE_ANDROID = 22; + PAGE = 23; + MACOS = 24; + VR = 25; + } + optional UserAgentPlatform platform = 1; + optional AppVersion appVersion = 2; + optional string mcc = 3; + optional string mnc = 4; + optional string osVersion = 5; + optional string manufacturer = 6; + optional string device = 7; + optional string osBuildNumber = 8; + optional string phoneId = 9; + enum UserAgentReleaseChannel { + RELEASE = 0; + BETA = 1; + ALPHA = 2; + DEBUG = 3; + } + optional UserAgentReleaseChannel releaseChannel = 10; + optional string localeLanguageIso6391 = 11; + optional string localeCountryIso31661Alpha2 = 12; + optional string deviceBoard = 13; +} + +message WebdPayload { + optional bool usesParticipantInKey = 1; + optional bool supportsStarredMessages = 2; + optional bool supportsDocumentMessages = 3; + optional bool supportsUrlMessages = 4; + optional bool supportsMediaRetry = 5; + optional bool supportsE2EImage = 6; + optional bool supportsE2EVideo = 7; + optional bool supportsE2EAudio = 8; + optional bool supportsE2EDocument = 9; + optional string documentTypes = 10; + optional bytes features = 11; +} + +message WebInfo { + optional string refToken = 1; + optional string version = 2; + optional WebdPayload webdPayload = 3; + enum WebInfoWebSubPlatform { + WEB_BROWSER = 0; + APP_STORE = 1; + WIN_STORE = 2; + DARWIN = 3; + WIN32 = 4; + } + optional WebInfoWebSubPlatform webSubPlatform = 4; +} + +message DNSSource { + enum DNSSourceDNSResolutionMethod { + SYSTEM = 0; + GOOGLE = 1; + HARDCODED = 2; + OVERRIDE = 3; + FALLBACK = 4; + } + optional DNSSourceDNSResolutionMethod dnsMethod = 15; + optional bool appCached = 16; +} + +message CompanionRegData { + optional bytes eRegid = 1; + optional bytes eKeytype = 2; + optional bytes eIdent = 3; + optional bytes eSkeyId = 4; + optional bytes eSkeyVal = 5; + optional bytes eSkeySig = 6; + optional bytes buildHash = 7; + optional bytes companionProps = 8; +} + +message ClientPayload { + optional uint64 username = 1; + optional bool passive = 3; + enum ClientPayloadClientFeature { + NONE = 0; + } + repeated ClientPayloadClientFeature clientFeatures = 4; + optional UserAgent userAgent = 5; + optional WebInfo webInfo = 6; + optional string pushName = 7; + optional sfixed32 sessionId = 9; + optional bool shortConnect = 10; + enum ClientPayloadIOSAppExtension { + SHARE_EXTENSION = 0; + SERVICE_EXTENSION = 1; + INTENTS_EXTENSION = 2; + } + optional ClientPayloadIOSAppExtension iosAppExtension = 30; + enum ClientPayloadConnectType { + CELLULAR_UNKNOWN = 0; + WIFI_UNKNOWN = 1; + CELLULAR_EDGE = 100; + CELLULAR_IDEN = 101; + CELLULAR_UMTS = 102; + CELLULAR_EVDO = 103; + CELLULAR_GPRS = 104; + CELLULAR_HSDPA = 105; + CELLULAR_HSUPA = 106; + CELLULAR_HSPA = 107; + CELLULAR_CDMA = 108; + CELLULAR_1XRTT = 109; + CELLULAR_EHRPD = 110; + CELLULAR_LTE = 111; + CELLULAR_HSPAP = 112; + } + optional ClientPayloadConnectType connectType = 12; + enum ClientPayloadConnectReason { + PUSH = 0; + USER_ACTIVATED = 1; + SCHEDULED = 2; + ERROR_RECONNECT = 3; + NETWORK_SWITCH = 4; + PING_RECONNECT = 5; + } + optional ClientPayloadConnectReason connectReason = 13; + repeated int32 shards = 14; + optional DNSSource dnsSource = 15; + optional uint32 connectAttemptCount = 16; + optional uint32 agent = 17; + optional uint32 device = 18; + optional CompanionRegData regData = 19; + enum ClientPayloadProduct { + WHATSAPP = 0; + MESSENGER = 1; + } + optional ClientPayloadProduct product = 20; + optional bytes fbCat = 21; + optional bytes fbUserAgent = 22; + optional bool oc = 23; +} + +message Details { + optional uint32 serial = 1; + optional string issuer = 2; + optional uint64 expires = 3; + optional string subject = 4; + optional bytes key = 5; +} + +message NoiseCertificate { + optional bytes details = 1; + optional bytes signature = 2; +} + +message ClientHello { + optional bytes ephemeral = 1; + optional bytes static = 2; + optional bytes payload = 3; +} + +message ServerHello { + optional bytes ephemeral = 1; + optional bytes static = 2; + optional bytes payload = 3; +} + +message ClientFinish { + optional bytes static = 1; + optional bytes payload = 2; +} + +message HandshakeMessage { + optional ClientHello clientHello = 2; + optional ServerHello serverHello = 3; + optional ClientFinish clientFinish = 4; +} + +message BizIdentityInfo { + enum BizIdentityInfoVerifiedLevelValue { + UNKNOWN = 0; + LOW = 1; + HIGH = 2; + } + optional BizIdentityInfoVerifiedLevelValue vlevel = 1; + optional VerifiedNameCertificate vnameCert = 2; + optional bool signed = 3; + optional bool revoked = 4; + enum BizIdentityInfoHostStorageType { + ON_PREMISE = 0; + FACEBOOK = 1; + } + optional BizIdentityInfoHostStorageType hostStorage = 5; + enum BizIdentityInfoActualActorsType { + SELF = 0; + BSP = 1; + } + optional BizIdentityInfoActualActorsType actualActors = 6; + optional uint64 privacyModeTs = 7; +} + +message BizAccountLinkInfo { + optional uint64 whatsappBizAcctFbid = 1; + optional string whatsappAcctNumber = 2; + optional uint64 issueTime = 3; + enum BizAccountLinkInfoHostStorageType { + ON_PREMISE = 0; + FACEBOOK = 1; + } + optional BizAccountLinkInfoHostStorageType hostStorage = 4; + enum BizAccountLinkInfoAccountType { + ENTERPRISE = 0; + PAGE = 1; + } + optional BizAccountLinkInfoAccountType accountType = 5; +} + +message BizAccountPayload { + optional VerifiedNameCertificate vnameCert = 1; + optional bytes bizAcctLinkInfo = 2; +} + +//message Details { +// optional uint64 serial = 1; +// optional string issuer = 2; +// optional string verifiedName = 4; +// repeated LocalizedName localizedNames = 8; +// optional uint64 issueTime = 10; +//} + +message VerifiedNameCertificate { + optional bytes details = 1; + optional bytes signature = 2; + optional bytes serverSignature = 3; +} + +message LocalizedName { + optional string lg = 1; + optional string lc = 2; + optional string verifiedName = 3; +} + +message SyncActionData { + optional bytes index = 1; + optional SyncActionValue value = 2; + optional bytes padding = 3; + optional int32 version = 4; +} + +message StarAction { + optional bool starred = 1; +} + +message ContactAction { + optional string fullName = 1; + optional string firstName = 2; +} + +message MuteAction { + optional bool muted = 1; + optional int64 muteEndTimestamp = 2; +} + +message PinAction { + optional bool pinned = 1; +} + +message SecurityNotificationSetting { + optional bool showNotification = 1; +} + +message PushNameSetting { + optional string name = 1; +} + +message LocaleSetting { + optional string locale = 1; +} + +message QuickReplyAction { + optional string shortcut = 1; + optional string message = 2; + repeated string keywords = 3; + optional int32 count = 4; + optional bool deleted = 5; +} + +message LabelAssociationAction { + optional bool labeled = 1; +} + +message LabelEditAction { + optional string name = 1; + optional int32 color = 2; + optional int32 predefinedId = 3; + optional bool deleted = 4; +} + +message RecentStickerWeightsAction { + repeated RecentStickerWeight weights = 1; +} + +message RecentStickerMetadata { + optional string directPath = 1; + optional string encFilehash = 2; + optional string mediaKey = 3; + optional string stanzaId = 4; + optional string chatJid = 5; + optional string participant = 6; + optional bool isSentByMe = 7; +} + +message RecentEmojiWeightsAction { + repeated RecentEmojiWeight weights = 1; +} + +message ArchiveChatAction { + optional bool archived = 1; + optional SyncActionMessageRange messageRange = 2; +} + +message DeleteMessageForMeAction { + optional bool deleteMedia = 1; + optional int64 messageTimestamp = 2; +} + +message MarkChatAsReadAction { + optional bool read = 1; + optional SyncActionMessageRange messageRange = 2; +} + +message ClearChatAction { + optional SyncActionMessageRange messageRange = 1; +} + +message DeleteChatAction { + optional SyncActionMessageRange messageRange = 1; +} + +message UnarchiveChatsSetting { + optional bool unarchiveChats = 1; +} + +message SyncActionMessageRange { + optional int64 lastMessageTimestamp = 1; + optional int64 lastSystemMessageTimestamp = 2; + repeated SyncActionMessage messages = 3; +} + +message SyncActionMessage { + optional MessageKey key = 1; + optional int64 timestamp = 2; +} + +message KeyExpiration { + optional int32 expiredKeyEpoch = 1; +} + +message SyncActionValue { + optional int64 timestamp = 1; + optional StarAction starAction = 2; + optional ContactAction contactAction = 3; + optional MuteAction muteAction = 4; + optional PinAction pinAction = 5; + optional SecurityNotificationSetting securityNotificationSetting = 6; + optional PushNameSetting pushNameSetting = 7; + optional QuickReplyAction quickReplyAction = 8; + optional RecentStickerWeightsAction recentStickerWeightsAction = 9; + optional RecentStickerMetadata recentStickerMetadata = 10; + optional RecentEmojiWeightsAction recentEmojiWeightsAction = 11; + optional LabelEditAction labelEditAction = 14; + optional LabelAssociationAction labelAssociationAction = 15; + optional LocaleSetting localeSetting = 16; + optional ArchiveChatAction archiveChatAction = 17; + optional DeleteMessageForMeAction deleteMessageForMeAction = 18; + optional KeyExpiration keyExpiration = 19; + optional MarkChatAsReadAction markChatAsReadAction = 20; + optional ClearChatAction clearChatAction = 21; + optional DeleteChatAction deleteChatAction = 22; + optional UnarchiveChatsSetting unarchiveChatsSetting = 23; +} + +message RecentEmojiWeight { + optional string emoji = 1; + optional float weight = 2; +} + +message RecentStickerWeight { + optional string filehash = 1; + optional float weight = 2; +} + +message SyncdPatch { + optional SyncdVersion version = 1; + repeated SyncdMutation mutations = 2; + optional ExternalBlobReference externalMutations = 3; + optional bytes snapshotMac = 4; + optional bytes patchMac = 5; + optional KeyId keyId = 6; + optional ExitCode exitCode = 7; + optional uint32 deviceIndex = 8; +} + +message SyncdMutation { + enum SyncdMutationSyncdOperation { + SET = 0; + REMOVE = 1; + } + optional SyncdMutationSyncdOperation operation = 1; + optional SyncdRecord record = 2; +} + +message SyncdMutations { + repeated SyncdMutation mutations = 1; +} + +message SyncdSnapshot { + optional SyncdVersion version = 1; + repeated SyncdRecord records = 2; + optional bytes mac = 3; + optional KeyId keyId = 4; +} + +message ExternalBlobReference { + optional bytes mediaKey = 1; + optional string directPath = 2; + optional string handle = 3; + optional uint64 fileSizeBytes = 4; + optional bytes fileSha256 = 5; + optional bytes fileEncSha256 = 6; +} + +message SyncdRecord { + optional SyncdIndex index = 1; + optional SyncdValue value = 2; + optional KeyId keyId = 3; +} + +message KeyId { + optional bytes id = 1; +} + +message SyncdValue { + optional bytes blob = 1; +} + +message SyncdIndex { + optional bytes blob = 1; +} + +message ExitCode { + optional uint64 code = 1; + optional string text = 2; +} + +message SyncdVersion { + optional uint64 version = 1; +} + +message ServerErrorReceipt { + optional string stanzaId = 1; +} + +message MediaRetryNotification { + optional string stanzaId = 1; + optional string directPath = 2; + enum MediaRetryNotificationResultType { + GENERAL_ERROR = 0; + SUCCESS = 1; + NOT_FOUND = 2; + DECRYPTION_ERROR = 3; + } + optional MediaRetryNotificationResultType result = 3; +} + +message MsgOpaqueData { + optional string body = 1; + optional string caption = 3; + optional string clientUrl = 4; +// optional string loc = 4; + optional double lng = 5; + optional double lat = 7; + optional int32 paymentAmount1000 = 8; + optional string paymentNoteMsgBody = 9; + optional string canonicalUrl = 10; + optional string matchedText = 11; + optional string title = 12; + optional string description = 13; +} + +message MsgRowOpaqueData { + optional MsgOpaqueData currentMsg = 1; + optional MsgOpaqueData quotedMsg = 2; +} + +message Pushname { + optional string id = 1; + optional string pushname = 2; +} + +message HistorySyncMsg { + optional WebMessageInfo message = 1; + optional uint64 msgOrderId = 2; +} + +message Conversation { + required string id = 1; + repeated HistorySyncMsg messages = 2; + optional string newJid = 3; + optional string oldJid = 4; + optional uint64 lastMsgTimestamp = 5; + optional uint32 unreadCount = 6; + optional bool readOnly = 7; + optional bool endOfHistoryTransfer = 8; + optional uint32 ephemeralExpiration = 9; + optional int64 ephemeralSettingTimestamp = 10; + enum ConversationEndOfHistoryTransferType { + COMPLETE_BUT_MORE_MESSAGES_REMAIN_ON_PRIMARY = 0; + COMPLETE_AND_NO_MORE_MESSAGE_REMAIN_ON_PRIMARY = 1; + } + optional ConversationEndOfHistoryTransferType endOfHistoryTransferType = 11; + optional uint64 conversationTimestamp = 12; + optional string name = 13; + optional string pHash = 14; + optional bool notSpam = 15; +} + +message HistorySync { + enum HistorySyncHistorySyncType { + INITIAL_BOOTSTRAP = 0; + INITIAL_STATUS_V3 = 1; + FULL = 2; + RECENT = 3; + PUSH_NAME = 4; + } + required HistorySyncHistorySyncType syncType = 1; + repeated Conversation conversations = 2; + repeated WebMessageInfo statusV3Messages = 3; + optional uint32 chunkOrder = 5; + optional uint32 progress = 6; + repeated Pushname pushnames = 7; +} + +message EphemeralSetting { + optional sfixed32 duration = 1; + optional sfixed64 timestamp = 2; +} + +message PaymentBackground { + optional string id = 1; + optional string fileLength = 2; + optional uint32 width = 3; + optional uint32 height = 4; + optional string mimetype = 5; + optional fixed32 placeholderArgb = 6; + optional fixed32 textArgb = 7; + optional fixed32 subtextArgb = 8; +} + +message Money { + optional int64 value = 1; + optional uint32 offset = 2; + optional string currencyCode = 3; +} + +message HydratedQuickReplyButton { + optional string displayText = 1; + optional string id = 2; +} + +message HydratedURLButton { + optional string displayText = 1; + optional string url = 2; +} + +message HydratedCallButton { + optional string displayText = 1; + optional string phoneNumber = 2; +} + +message HydratedTemplateButton { + optional uint32 index = 4; + oneof hydratedButton { + HydratedQuickReplyButton quickReplyButton = 1; + HydratedURLButton urlButton = 2; + HydratedCallButton callButton = 3; + } } message QuickReplyButton { @@ -115,7 +725,6 @@ message ContextInfo { optional string entryPointConversionSource = 29; optional string entryPointConversionApp = 30; optional uint32 entryPointConversionDelaySeconds = 31; - optional DisappearingMode disappearingMode = 32; } message SenderKeyDistributionMessage { @@ -149,7 +758,6 @@ message ImageMessage { optional string thumbnailDirectPath = 26; optional bytes thumbnailSha256 = 27; optional bytes thumbnailEncSha256 = 28; - optional string staticUrl = 29; } message InvoiceMessage { @@ -289,7 +897,6 @@ message VideoMessage { optional string thumbnailDirectPath = 21; optional bytes thumbnailSha256 = 22; optional bytes thumbnailEncSha256 = 23; - optional string staticUrl = 24; } message Call { @@ -325,7 +932,6 @@ message ProtocolMessage { optional AppStateSyncKeyRequest appStateSyncKeyRequest = 8; optional InitialSecurityNotificationSettingSync initialSecurityNotificationSettingSync = 9; optional AppStateFatalExceptionNotification appStateFatalExceptionNotification = 10; - optional DisappearingMode disappearingMode = 11; } message HistorySyncNotification { @@ -669,59 +1275,6 @@ message ListResponseMessage { optional string description = 5; } -message Header { - optional string title = 1; - optional string subtitle = 2; - oneof media { - DocumentMessage documentMessage = 3; - ImageMessage imageMessage = 4; - } -} - -message Body { - optional string text = 1; -} - -message Footer { - optional string text = 1; -} - -message ShopsMessage { - optional string id = 1; - enum ShopsMessageSurface { - UNKNOWN_SURFACE = 0; - FB = 1; - IG = 2; - WA = 3; - } - optional ShopsMessageSurface surface = 2; - enum ShopsMessageType { - UNKNOWN_TYPE = 0; - PRODUCT = 1; - STOREFRONT = 2; - COLLECTION = 3; - } - optional ShopsMessageType type = 3; - optional int32 messageVersion = 4; -} - -message CollectionMessage { - optional string bizJid = 1; - optional string id = 2; - optional int32 messageVersion = 3; -} - -message InteractiveMessage { - optional Header header = 1; - optional Body body = 2; - optional Footer footer = 3; - optional ContextInfo contextInfo = 15; - oneof interactiveMessage { - ShopsMessage shopsMessage = 4; - CollectionMessage collectionMessage = 5; - } -} - message GroupInviteMessage { optional string groupJid = 1; optional string inviteCode = 2; @@ -837,66 +1390,65 @@ message Message { optional ButtonsMessage buttonsMessage = 42; optional ButtonsResponseMessage buttonsResponseMessage = 43; optional PaymentInviteMessage paymentInviteMessage = 44; - optional InteractiveMessage interactiveMessage = 45; } -message DisappearingMode { - enum DisappearingModeInitiator { - CHANGED_IN_CHAT = 0; - INITIATED_BY_ME = 1; - INITIATED_BY_OTHER = 2; +message CompanionProps { + optional string os = 1; + optional AppVersion version = 2; + enum CompanionPropsPlatformType { + UNKNOWN = 0; + CHROME = 1; + FIREFOX = 2; + IE = 3; + OPERA = 4; + SAFARI = 5; + EDGE = 6; + DESKTOP = 7; + IPAD = 8; + ANDROID_TABLET = 9; + OHANA = 10; + ALOHA = 11; + CATALINA = 12; } - optional DisappearingModeInitiator initiator = 1; + optional CompanionPropsPlatformType platformType = 3; + optional bool requireFullSync = 4; } -message PaymentBackground { - optional string id = 1; - optional uint64 fileLength = 2; - optional uint32 width = 3; - optional uint32 height = 4; - optional string mimetype = 5; - optional fixed32 placeholderArgb = 6; - optional fixed32 textArgb = 7; - optional fixed32 subtextArgb = 8; +message ADVSignedDeviceIdentityHMAC { + optional bytes details = 1; + optional bytes hmac = 2; } -message Money { - optional int64 value = 1; - optional uint32 offset = 2; - optional string currencyCode = 3; +message ADVSignedDeviceIdentity { + optional bytes details = 1; + optional bytes accountSignatureKey = 2; + optional bytes accountSignature = 3; + optional bytes deviceSignature = 4; } -message HydratedQuickReplyButton { - optional string displayText = 1; - optional string id = 2; +message ADVDeviceIdentity { + optional uint32 rawId = 1; + optional uint64 timestamp = 2; + optional uint32 keyIndex = 3; } -message HydratedURLButton { - optional string displayText = 1; - optional string url = 2; +message ADVSignedKeyIndexList { + optional bytes details = 1; + optional bytes accountSignature = 2; } -message HydratedCallButton { - optional string displayText = 1; - optional string phoneNumber = 2; +message ADVKeyIndexList { + optional uint32 rawId = 1; + optional uint64 timestamp = 2; + optional uint32 currentIndex = 3; + repeated uint32 validIndexes = 4 [packed=true]; } -message HydratedTemplateButton { - optional uint32 index = 4; - oneof hydratedButton { - HydratedQuickReplyButton quickReplyButton = 1; - HydratedURLButton urlButton = 2; - HydratedCallButton callButton = 3; - } -} - -message UserReceipt { - required string userJid = 1; - optional int64 receiptTimestamp = 2; - optional int64 readTimestamp = 3; - optional int64 playedTimestamp = 4; - repeated string pendingDeviceJid = 5; - repeated string deliveredDeviceJid = 6; +message MessageKey { + optional string remoteJid = 1; + optional bool fromMe = 2; + optional string id = 3; + optional string participant = 4; } message PhotoChange { @@ -958,7 +1510,6 @@ message WebFeatures { optional WebFeaturesFlag ephemeralAllowGroupMembers = 44; optional WebFeaturesFlag ephemeral24HDuration = 45; optional WebFeaturesFlag mdForceUpgrade = 46; - optional WebFeaturesFlag disappearingMode = 47; } message NotificationMessageInfo { @@ -1194,7 +1745,6 @@ message WebMessageInfo { BIZ_PRIVACY_MODE_INIT_BSP = 127; BIZ_PRIVACY_MODE_TO_FB = 128; BIZ_PRIVACY_MODE_TO_BSP = 129; - DISAPPEARING_MODE = 130; } optional WebMessageInfoStubType messageStubType = 24; optional bool clearMedia = 25; @@ -1218,5 +1768,4 @@ message WebMessageInfo { optional string verifiedBizName = 37; optional MediaData mediaData = 38; optional PhotoChange photoChange = 39; - repeated UserReceipt userReceipt = 40; -} +} \ No newline at end of file diff --git a/WAMessage/index.d.ts b/WAProto/index.d.ts similarity index 60% rename from WAMessage/index.d.ts rename to WAProto/index.d.ts index 5412364..9299a7b 100644 --- a/WAMessage/index.d.ts +++ b/WAProto/index.d.ts @@ -2,109 +2,7691 @@ import * as $protobuf from "protobufjs"; /** Namespace proto. */ export namespace proto { - /** Properties of a MessageKey. */ - interface IMessageKey { + /** Properties of an AppVersion. */ + interface IAppVersion { - /** MessageKey remoteJid */ - remoteJid?: (string|null); + /** AppVersion primary */ + primary?: (number|null); - /** MessageKey fromMe */ - fromMe?: (boolean|null); + /** AppVersion secondary */ + secondary?: (number|null); - /** MessageKey id */ - id?: (string|null); + /** AppVersion tertiary */ + tertiary?: (number|null); - /** MessageKey participant */ - participant?: (string|null); + /** AppVersion quaternary */ + quaternary?: (number|null); + + /** AppVersion quinary */ + quinary?: (number|null); } - /** Represents a MessageKey. */ - class MessageKey implements IMessageKey { + /** Represents an AppVersion. */ + class AppVersion implements IAppVersion { /** - * Constructs a new MessageKey. + * Constructs a new AppVersion. * @param [properties] Properties to set */ - constructor(properties?: proto.IMessageKey); + constructor(properties?: proto.IAppVersion); - /** MessageKey remoteJid. */ - public remoteJid: string; + /** AppVersion primary. */ + public primary: number; - /** MessageKey fromMe. */ - public fromMe: boolean; + /** AppVersion secondary. */ + public secondary: number; - /** MessageKey id. */ - public id: string; + /** AppVersion tertiary. */ + public tertiary: number; - /** MessageKey participant. */ - public participant: string; + /** AppVersion quaternary. */ + public quaternary: number; + + /** AppVersion quinary. */ + public quinary: number; /** - * Creates a new MessageKey instance using the specified properties. + * Creates a new AppVersion instance using the specified properties. * @param [properties] Properties to set - * @returns MessageKey instance + * @returns AppVersion instance */ - public static create(properties?: proto.IMessageKey): proto.MessageKey; + public static create(properties?: proto.IAppVersion): proto.AppVersion; /** - * Encodes the specified MessageKey message. Does not implicitly {@link proto.MessageKey.verify|verify} messages. - * @param message MessageKey message or plain object to encode + * Encodes the specified AppVersion message. Does not implicitly {@link proto.AppVersion.verify|verify} messages. + * @param message AppVersion message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encode(message: proto.IMessageKey, writer?: $protobuf.Writer): $protobuf.Writer; + public static encode(message: proto.IAppVersion, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Encodes the specified MessageKey message, length delimited. Does not implicitly {@link proto.MessageKey.verify|verify} messages. - * @param message MessageKey message or plain object to encode + * Encodes the specified AppVersion message, length delimited. Does not implicitly {@link proto.AppVersion.verify|verify} messages. + * @param message AppVersion message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encodeDelimited(message: proto.IMessageKey, writer?: $protobuf.Writer): $protobuf.Writer; + public static encodeDelimited(message: proto.IAppVersion, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Decodes a MessageKey message from the specified reader or buffer. + * Decodes an AppVersion message from the specified reader or buffer. * @param reader Reader or buffer to decode from * @param [length] Message length if known beforehand - * @returns MessageKey + * @returns AppVersion * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.MessageKey; + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.AppVersion; /** - * Decodes a MessageKey message from the specified reader or buffer, length delimited. + * Decodes an AppVersion message from the specified reader or buffer, length delimited. * @param reader Reader or buffer to decode from - * @returns MessageKey + * @returns AppVersion * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.MessageKey; + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.AppVersion; /** - * Verifies a MessageKey message. + * Verifies an AppVersion message. * @param message Plain object to verify * @returns `null` if valid, otherwise the reason why it is not */ public static verify(message: { [k: string]: any }): (string|null); /** - * Creates a MessageKey message from a plain object. Also converts values to their respective internal types. + * Creates an AppVersion message from a plain object. Also converts values to their respective internal types. * @param object Plain object - * @returns MessageKey + * @returns AppVersion */ - public static fromObject(object: { [k: string]: any }): proto.MessageKey; + public static fromObject(object: { [k: string]: any }): proto.AppVersion; /** - * Creates a plain object from a MessageKey message. Also converts values to other types if specified. - * @param message MessageKey + * Creates a plain object from an AppVersion message. Also converts values to other types if specified. + * @param message AppVersion * @param [options] Conversion options * @returns Plain object */ - public static toObject(message: proto.MessageKey, options?: $protobuf.IConversionOptions): { [k: string]: any }; + public static toObject(message: proto.AppVersion, options?: $protobuf.IConversionOptions): { [k: string]: any }; /** - * Converts this MessageKey to JSON. + * Converts this AppVersion to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a UserAgent. */ + interface IUserAgent { + + /** UserAgent platform */ + platform?: (proto.UserAgent.UserAgentPlatform|null); + + /** UserAgent appVersion */ + appVersion?: (proto.IAppVersion|null); + + /** UserAgent mcc */ + mcc?: (string|null); + + /** UserAgent mnc */ + mnc?: (string|null); + + /** UserAgent osVersion */ + osVersion?: (string|null); + + /** UserAgent manufacturer */ + manufacturer?: (string|null); + + /** UserAgent device */ + device?: (string|null); + + /** UserAgent osBuildNumber */ + osBuildNumber?: (string|null); + + /** UserAgent phoneId */ + phoneId?: (string|null); + + /** UserAgent releaseChannel */ + releaseChannel?: (proto.UserAgent.UserAgentReleaseChannel|null); + + /** UserAgent localeLanguageIso6391 */ + localeLanguageIso6391?: (string|null); + + /** UserAgent localeCountryIso31661Alpha2 */ + localeCountryIso31661Alpha2?: (string|null); + + /** UserAgent deviceBoard */ + deviceBoard?: (string|null); + } + + /** Represents a UserAgent. */ + class UserAgent implements IUserAgent { + + /** + * Constructs a new UserAgent. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IUserAgent); + + /** UserAgent platform. */ + public platform: proto.UserAgent.UserAgentPlatform; + + /** UserAgent appVersion. */ + public appVersion?: (proto.IAppVersion|null); + + /** UserAgent mcc. */ + public mcc: string; + + /** UserAgent mnc. */ + public mnc: string; + + /** UserAgent osVersion. */ + public osVersion: string; + + /** UserAgent manufacturer. */ + public manufacturer: string; + + /** UserAgent device. */ + public device: string; + + /** UserAgent osBuildNumber. */ + public osBuildNumber: string; + + /** UserAgent phoneId. */ + public phoneId: string; + + /** UserAgent releaseChannel. */ + public releaseChannel: proto.UserAgent.UserAgentReleaseChannel; + + /** UserAgent localeLanguageIso6391. */ + public localeLanguageIso6391: string; + + /** UserAgent localeCountryIso31661Alpha2. */ + public localeCountryIso31661Alpha2: string; + + /** UserAgent deviceBoard. */ + public deviceBoard: string; + + /** + * Creates a new UserAgent instance using the specified properties. + * @param [properties] Properties to set + * @returns UserAgent instance + */ + public static create(properties?: proto.IUserAgent): proto.UserAgent; + + /** + * Encodes the specified UserAgent message. Does not implicitly {@link proto.UserAgent.verify|verify} messages. + * @param message UserAgent message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IUserAgent, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UserAgent message, length delimited. Does not implicitly {@link proto.UserAgent.verify|verify} messages. + * @param message UserAgent message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IUserAgent, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a UserAgent message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UserAgent + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.UserAgent; + + /** + * Decodes a UserAgent message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UserAgent + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.UserAgent; + + /** + * Verifies a UserAgent message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a UserAgent message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UserAgent + */ + public static fromObject(object: { [k: string]: any }): proto.UserAgent; + + /** + * Creates a plain object from a UserAgent message. Also converts values to other types if specified. + * @param message UserAgent + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.UserAgent, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UserAgent to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace UserAgent { + + /** UserAgentPlatform enum. */ + enum UserAgentPlatform { + ANDROID = 0, + IOS = 1, + WINDOWS_PHONE = 2, + BLACKBERRY = 3, + BLACKBERRYX = 4, + S40 = 5, + S60 = 6, + PYTHON_CLIENT = 7, + TIZEN = 8, + ENTERPRISE = 9, + SMB_ANDROID = 10, + KAIOS = 11, + SMB_IOS = 12, + WINDOWS = 13, + WEB = 14, + PORTAL = 15, + GREEN_ANDROID = 16, + GREEN_IPHONE = 17, + BLUE_ANDROID = 18, + BLUE_IPHONE = 19, + FBLITE_ANDROID = 20, + MLITE_ANDROID = 21, + IGLITE_ANDROID = 22, + PAGE = 23, + MACOS = 24, + VR = 25 + } + + /** UserAgentReleaseChannel enum. */ + enum UserAgentReleaseChannel { + RELEASE = 0, + BETA = 1, + ALPHA = 2, + DEBUG = 3 + } + } + + /** Properties of a WebdPayload. */ + interface IWebdPayload { + + /** WebdPayload usesParticipantInKey */ + usesParticipantInKey?: (boolean|null); + + /** WebdPayload supportsStarredMessages */ + supportsStarredMessages?: (boolean|null); + + /** WebdPayload supportsDocumentMessages */ + supportsDocumentMessages?: (boolean|null); + + /** WebdPayload supportsUrlMessages */ + supportsUrlMessages?: (boolean|null); + + /** WebdPayload supportsMediaRetry */ + supportsMediaRetry?: (boolean|null); + + /** WebdPayload supportsE2EImage */ + supportsE2EImage?: (boolean|null); + + /** WebdPayload supportsE2EVideo */ + supportsE2EVideo?: (boolean|null); + + /** WebdPayload supportsE2EAudio */ + supportsE2EAudio?: (boolean|null); + + /** WebdPayload supportsE2EDocument */ + supportsE2EDocument?: (boolean|null); + + /** WebdPayload documentTypes */ + documentTypes?: (string|null); + + /** WebdPayload features */ + features?: (Uint8Array|null); + } + + /** Represents a WebdPayload. */ + class WebdPayload implements IWebdPayload { + + /** + * Constructs a new WebdPayload. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IWebdPayload); + + /** WebdPayload usesParticipantInKey. */ + public usesParticipantInKey: boolean; + + /** WebdPayload supportsStarredMessages. */ + public supportsStarredMessages: boolean; + + /** WebdPayload supportsDocumentMessages. */ + public supportsDocumentMessages: boolean; + + /** WebdPayload supportsUrlMessages. */ + public supportsUrlMessages: boolean; + + /** WebdPayload supportsMediaRetry. */ + public supportsMediaRetry: boolean; + + /** WebdPayload supportsE2EImage. */ + public supportsE2EImage: boolean; + + /** WebdPayload supportsE2EVideo. */ + public supportsE2EVideo: boolean; + + /** WebdPayload supportsE2EAudio. */ + public supportsE2EAudio: boolean; + + /** WebdPayload supportsE2EDocument. */ + public supportsE2EDocument: boolean; + + /** WebdPayload documentTypes. */ + public documentTypes: string; + + /** WebdPayload features. */ + public features: Uint8Array; + + /** + * Creates a new WebdPayload instance using the specified properties. + * @param [properties] Properties to set + * @returns WebdPayload instance + */ + public static create(properties?: proto.IWebdPayload): proto.WebdPayload; + + /** + * Encodes the specified WebdPayload message. Does not implicitly {@link proto.WebdPayload.verify|verify} messages. + * @param message WebdPayload message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IWebdPayload, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified WebdPayload message, length delimited. Does not implicitly {@link proto.WebdPayload.verify|verify} messages. + * @param message WebdPayload message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IWebdPayload, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a WebdPayload message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns WebdPayload + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.WebdPayload; + + /** + * Decodes a WebdPayload message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns WebdPayload + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.WebdPayload; + + /** + * Verifies a WebdPayload message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a WebdPayload message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WebdPayload + */ + public static fromObject(object: { [k: string]: any }): proto.WebdPayload; + + /** + * Creates a plain object from a WebdPayload message. Also converts values to other types if specified. + * @param message WebdPayload + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.WebdPayload, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WebdPayload to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a WebInfo. */ + interface IWebInfo { + + /** WebInfo refToken */ + refToken?: (string|null); + + /** WebInfo version */ + version?: (string|null); + + /** WebInfo webdPayload */ + webdPayload?: (proto.IWebdPayload|null); + + /** WebInfo webSubPlatform */ + webSubPlatform?: (proto.WebInfo.WebInfoWebSubPlatform|null); + } + + /** Represents a WebInfo. */ + class WebInfo implements IWebInfo { + + /** + * Constructs a new WebInfo. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IWebInfo); + + /** WebInfo refToken. */ + public refToken: string; + + /** WebInfo version. */ + public version: string; + + /** WebInfo webdPayload. */ + public webdPayload?: (proto.IWebdPayload|null); + + /** WebInfo webSubPlatform. */ + public webSubPlatform: proto.WebInfo.WebInfoWebSubPlatform; + + /** + * Creates a new WebInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns WebInfo instance + */ + public static create(properties?: proto.IWebInfo): proto.WebInfo; + + /** + * Encodes the specified WebInfo message. Does not implicitly {@link proto.WebInfo.verify|verify} messages. + * @param message WebInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IWebInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified WebInfo message, length delimited. Does not implicitly {@link proto.WebInfo.verify|verify} messages. + * @param message WebInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IWebInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a WebInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns WebInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.WebInfo; + + /** + * Decodes a WebInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns WebInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.WebInfo; + + /** + * Verifies a WebInfo message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a WebInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WebInfo + */ + public static fromObject(object: { [k: string]: any }): proto.WebInfo; + + /** + * Creates a plain object from a WebInfo message. Also converts values to other types if specified. + * @param message WebInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.WebInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WebInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace WebInfo { + + /** WebInfoWebSubPlatform enum. */ + enum WebInfoWebSubPlatform { + WEB_BROWSER = 0, + APP_STORE = 1, + WIN_STORE = 2, + DARWIN = 3, + WIN32 = 4 + } + } + + /** Properties of a DNSSource. */ + interface IDNSSource { + + /** DNSSource dnsMethod */ + dnsMethod?: (proto.DNSSource.DNSSourceDNSResolutionMethod|null); + + /** DNSSource appCached */ + appCached?: (boolean|null); + } + + /** Represents a DNSSource. */ + class DNSSource implements IDNSSource { + + /** + * Constructs a new DNSSource. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IDNSSource); + + /** DNSSource dnsMethod. */ + public dnsMethod: proto.DNSSource.DNSSourceDNSResolutionMethod; + + /** DNSSource appCached. */ + public appCached: boolean; + + /** + * Creates a new DNSSource instance using the specified properties. + * @param [properties] Properties to set + * @returns DNSSource instance + */ + public static create(properties?: proto.IDNSSource): proto.DNSSource; + + /** + * Encodes the specified DNSSource message. Does not implicitly {@link proto.DNSSource.verify|verify} messages. + * @param message DNSSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IDNSSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DNSSource message, length delimited. Does not implicitly {@link proto.DNSSource.verify|verify} messages. + * @param message DNSSource message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IDNSSource, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DNSSource message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DNSSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.DNSSource; + + /** + * Decodes a DNSSource message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DNSSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.DNSSource; + + /** + * Verifies a DNSSource message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DNSSource message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DNSSource + */ + public static fromObject(object: { [k: string]: any }): proto.DNSSource; + + /** + * Creates a plain object from a DNSSource message. Also converts values to other types if specified. + * @param message DNSSource + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.DNSSource, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DNSSource to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace DNSSource { + + /** DNSSourceDNSResolutionMethod enum. */ + enum DNSSourceDNSResolutionMethod { + SYSTEM = 0, + GOOGLE = 1, + HARDCODED = 2, + OVERRIDE = 3, + FALLBACK = 4 + } + } + + /** Properties of a CompanionRegData. */ + interface ICompanionRegData { + + /** CompanionRegData eRegid */ + eRegid?: (Uint8Array|null); + + /** CompanionRegData eKeytype */ + eKeytype?: (Uint8Array|null); + + /** CompanionRegData eIdent */ + eIdent?: (Uint8Array|null); + + /** CompanionRegData eSkeyId */ + eSkeyId?: (Uint8Array|null); + + /** CompanionRegData eSkeyVal */ + eSkeyVal?: (Uint8Array|null); + + /** CompanionRegData eSkeySig */ + eSkeySig?: (Uint8Array|null); + + /** CompanionRegData buildHash */ + buildHash?: (Uint8Array|null); + + /** CompanionRegData companionProps */ + companionProps?: (Uint8Array|null); + } + + /** Represents a CompanionRegData. */ + class CompanionRegData implements ICompanionRegData { + + /** + * Constructs a new CompanionRegData. + * @param [properties] Properties to set + */ + constructor(properties?: proto.ICompanionRegData); + + /** CompanionRegData eRegid. */ + public eRegid: Uint8Array; + + /** CompanionRegData eKeytype. */ + public eKeytype: Uint8Array; + + /** CompanionRegData eIdent. */ + public eIdent: Uint8Array; + + /** CompanionRegData eSkeyId. */ + public eSkeyId: Uint8Array; + + /** CompanionRegData eSkeyVal. */ + public eSkeyVal: Uint8Array; + + /** CompanionRegData eSkeySig. */ + public eSkeySig: Uint8Array; + + /** CompanionRegData buildHash. */ + public buildHash: Uint8Array; + + /** CompanionRegData companionProps. */ + public companionProps: Uint8Array; + + /** + * Creates a new CompanionRegData instance using the specified properties. + * @param [properties] Properties to set + * @returns CompanionRegData instance + */ + public static create(properties?: proto.ICompanionRegData): proto.CompanionRegData; + + /** + * Encodes the specified CompanionRegData message. Does not implicitly {@link proto.CompanionRegData.verify|verify} messages. + * @param message CompanionRegData message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.ICompanionRegData, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CompanionRegData message, length delimited. Does not implicitly {@link proto.CompanionRegData.verify|verify} messages. + * @param message CompanionRegData message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.ICompanionRegData, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompanionRegData message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CompanionRegData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.CompanionRegData; + + /** + * Decodes a CompanionRegData message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CompanionRegData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.CompanionRegData; + + /** + * Verifies a CompanionRegData message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a CompanionRegData message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompanionRegData + */ + public static fromObject(object: { [k: string]: any }): proto.CompanionRegData; + + /** + * Creates a plain object from a CompanionRegData message. Also converts values to other types if specified. + * @param message CompanionRegData + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.CompanionRegData, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompanionRegData to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ClientPayload. */ + interface IClientPayload { + + /** ClientPayload username */ + username?: (number|Long|null); + + /** ClientPayload passive */ + passive?: (boolean|null); + + /** ClientPayload clientFeatures */ + clientFeatures?: (proto.ClientPayload.ClientPayloadClientFeature[]|null); + + /** ClientPayload userAgent */ + userAgent?: (proto.IUserAgent|null); + + /** ClientPayload webInfo */ + webInfo?: (proto.IWebInfo|null); + + /** ClientPayload pushName */ + pushName?: (string|null); + + /** ClientPayload sessionId */ + sessionId?: (number|null); + + /** ClientPayload shortConnect */ + shortConnect?: (boolean|null); + + /** ClientPayload iosAppExtension */ + iosAppExtension?: (proto.ClientPayload.ClientPayloadIOSAppExtension|null); + + /** ClientPayload connectType */ + connectType?: (proto.ClientPayload.ClientPayloadConnectType|null); + + /** ClientPayload connectReason */ + connectReason?: (proto.ClientPayload.ClientPayloadConnectReason|null); + + /** ClientPayload shards */ + shards?: (number[]|null); + + /** ClientPayload dnsSource */ + dnsSource?: (proto.IDNSSource|null); + + /** ClientPayload connectAttemptCount */ + connectAttemptCount?: (number|null); + + /** ClientPayload agent */ + agent?: (number|null); + + /** ClientPayload device */ + device?: (number|null); + + /** ClientPayload regData */ + regData?: (proto.ICompanionRegData|null); + + /** ClientPayload product */ + product?: (proto.ClientPayload.ClientPayloadProduct|null); + + /** ClientPayload fbCat */ + fbCat?: (Uint8Array|null); + + /** ClientPayload fbUserAgent */ + fbUserAgent?: (Uint8Array|null); + + /** ClientPayload oc */ + oc?: (boolean|null); + } + + /** Represents a ClientPayload. */ + class ClientPayload implements IClientPayload { + + /** + * Constructs a new ClientPayload. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IClientPayload); + + /** ClientPayload username. */ + public username: (number|Long); + + /** ClientPayload passive. */ + public passive: boolean; + + /** ClientPayload clientFeatures. */ + public clientFeatures: proto.ClientPayload.ClientPayloadClientFeature[]; + + /** ClientPayload userAgent. */ + public userAgent?: (proto.IUserAgent|null); + + /** ClientPayload webInfo. */ + public webInfo?: (proto.IWebInfo|null); + + /** ClientPayload pushName. */ + public pushName: string; + + /** ClientPayload sessionId. */ + public sessionId: number; + + /** ClientPayload shortConnect. */ + public shortConnect: boolean; + + /** ClientPayload iosAppExtension. */ + public iosAppExtension: proto.ClientPayload.ClientPayloadIOSAppExtension; + + /** ClientPayload connectType. */ + public connectType: proto.ClientPayload.ClientPayloadConnectType; + + /** ClientPayload connectReason. */ + public connectReason: proto.ClientPayload.ClientPayloadConnectReason; + + /** ClientPayload shards. */ + public shards: number[]; + + /** ClientPayload dnsSource. */ + public dnsSource?: (proto.IDNSSource|null); + + /** ClientPayload connectAttemptCount. */ + public connectAttemptCount: number; + + /** ClientPayload agent. */ + public agent: number; + + /** ClientPayload device. */ + public device: number; + + /** ClientPayload regData. */ + public regData?: (proto.ICompanionRegData|null); + + /** ClientPayload product. */ + public product: proto.ClientPayload.ClientPayloadProduct; + + /** ClientPayload fbCat. */ + public fbCat: Uint8Array; + + /** ClientPayload fbUserAgent. */ + public fbUserAgent: Uint8Array; + + /** ClientPayload oc. */ + public oc: boolean; + + /** + * Creates a new ClientPayload instance using the specified properties. + * @param [properties] Properties to set + * @returns ClientPayload instance + */ + public static create(properties?: proto.IClientPayload): proto.ClientPayload; + + /** + * Encodes the specified ClientPayload message. Does not implicitly {@link proto.ClientPayload.verify|verify} messages. + * @param message ClientPayload message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IClientPayload, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ClientPayload message, length delimited. Does not implicitly {@link proto.ClientPayload.verify|verify} messages. + * @param message ClientPayload message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IClientPayload, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ClientPayload message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ClientPayload + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.ClientPayload; + + /** + * Decodes a ClientPayload message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ClientPayload + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.ClientPayload; + + /** + * Verifies a ClientPayload message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ClientPayload message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ClientPayload + */ + public static fromObject(object: { [k: string]: any }): proto.ClientPayload; + + /** + * Creates a plain object from a ClientPayload message. Also converts values to other types if specified. + * @param message ClientPayload + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.ClientPayload, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ClientPayload to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace ClientPayload { + + /** ClientPayloadClientFeature enum. */ + enum ClientPayloadClientFeature { + NONE = 0 + } + + /** ClientPayloadIOSAppExtension enum. */ + enum ClientPayloadIOSAppExtension { + SHARE_EXTENSION = 0, + SERVICE_EXTENSION = 1, + INTENTS_EXTENSION = 2 + } + + /** ClientPayloadConnectType enum. */ + enum ClientPayloadConnectType { + CELLULAR_UNKNOWN = 0, + WIFI_UNKNOWN = 1, + CELLULAR_EDGE = 100, + CELLULAR_IDEN = 101, + CELLULAR_UMTS = 102, + CELLULAR_EVDO = 103, + CELLULAR_GPRS = 104, + CELLULAR_HSDPA = 105, + CELLULAR_HSUPA = 106, + CELLULAR_HSPA = 107, + CELLULAR_CDMA = 108, + CELLULAR_1XRTT = 109, + CELLULAR_EHRPD = 110, + CELLULAR_LTE = 111, + CELLULAR_HSPAP = 112 + } + + /** ClientPayloadConnectReason enum. */ + enum ClientPayloadConnectReason { + PUSH = 0, + USER_ACTIVATED = 1, + SCHEDULED = 2, + ERROR_RECONNECT = 3, + NETWORK_SWITCH = 4, + PING_RECONNECT = 5 + } + + /** ClientPayloadProduct enum. */ + enum ClientPayloadProduct { + WHATSAPP = 0, + MESSENGER = 1 + } + } + + /** Properties of a Details. */ + interface IDetails { + + /** Details serial */ + serial?: (number|null); + + /** Details issuer */ + issuer?: (string|null); + + /** Details expires */ + expires?: (number|Long|null); + + /** Details subject */ + subject?: (string|null); + + /** Details key */ + key?: (Uint8Array|null); + } + + /** Represents a Details. */ + class Details implements IDetails { + + /** + * Constructs a new Details. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IDetails); + + /** Details serial. */ + public serial: number; + + /** Details issuer. */ + public issuer: string; + + /** Details expires. */ + public expires: (number|Long); + + /** Details subject. */ + public subject: string; + + /** Details key. */ + public key: Uint8Array; + + /** + * Creates a new Details instance using the specified properties. + * @param [properties] Properties to set + * @returns Details instance + */ + public static create(properties?: proto.IDetails): proto.Details; + + /** + * Encodes the specified Details message. Does not implicitly {@link proto.Details.verify|verify} messages. + * @param message Details message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IDetails, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Details message, length delimited. Does not implicitly {@link proto.Details.verify|verify} messages. + * @param message Details message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IDetails, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Details message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Details + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.Details; + + /** + * Decodes a Details message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Details + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.Details; + + /** + * Verifies a Details message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Details message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Details + */ + public static fromObject(object: { [k: string]: any }): proto.Details; + + /** + * Creates a plain object from a Details message. Also converts values to other types if specified. + * @param message Details + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.Details, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Details to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a NoiseCertificate. */ + interface INoiseCertificate { + + /** NoiseCertificate details */ + details?: (Uint8Array|null); + + /** NoiseCertificate signature */ + signature?: (Uint8Array|null); + } + + /** Represents a NoiseCertificate. */ + class NoiseCertificate implements INoiseCertificate { + + /** + * Constructs a new NoiseCertificate. + * @param [properties] Properties to set + */ + constructor(properties?: proto.INoiseCertificate); + + /** NoiseCertificate details. */ + public details: Uint8Array; + + /** NoiseCertificate signature. */ + public signature: Uint8Array; + + /** + * Creates a new NoiseCertificate instance using the specified properties. + * @param [properties] Properties to set + * @returns NoiseCertificate instance + */ + public static create(properties?: proto.INoiseCertificate): proto.NoiseCertificate; + + /** + * Encodes the specified NoiseCertificate message. Does not implicitly {@link proto.NoiseCertificate.verify|verify} messages. + * @param message NoiseCertificate message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.INoiseCertificate, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified NoiseCertificate message, length delimited. Does not implicitly {@link proto.NoiseCertificate.verify|verify} messages. + * @param message NoiseCertificate message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.INoiseCertificate, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a NoiseCertificate message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns NoiseCertificate + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.NoiseCertificate; + + /** + * Decodes a NoiseCertificate message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns NoiseCertificate + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.NoiseCertificate; + + /** + * Verifies a NoiseCertificate message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a NoiseCertificate message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns NoiseCertificate + */ + public static fromObject(object: { [k: string]: any }): proto.NoiseCertificate; + + /** + * Creates a plain object from a NoiseCertificate message. Also converts values to other types if specified. + * @param message NoiseCertificate + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.NoiseCertificate, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this NoiseCertificate to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ClientHello. */ + interface IClientHello { + + /** ClientHello ephemeral */ + ephemeral?: (Uint8Array|null); + + /** ClientHello static */ + "static"?: (Uint8Array|null); + + /** ClientHello payload */ + payload?: (Uint8Array|null); + } + + /** Represents a ClientHello. */ + class ClientHello implements IClientHello { + + /** + * Constructs a new ClientHello. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IClientHello); + + /** ClientHello ephemeral. */ + public ephemeral: Uint8Array; + + /** ClientHello static. */ + public static: Uint8Array; + + /** ClientHello payload. */ + public payload: Uint8Array; + + /** + * Creates a new ClientHello instance using the specified properties. + * @param [properties] Properties to set + * @returns ClientHello instance + */ + public static create(properties?: proto.IClientHello): proto.ClientHello; + + /** + * Encodes the specified ClientHello message. Does not implicitly {@link proto.ClientHello.verify|verify} messages. + * @param message ClientHello message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IClientHello, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ClientHello message, length delimited. Does not implicitly {@link proto.ClientHello.verify|verify} messages. + * @param message ClientHello message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IClientHello, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ClientHello message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ClientHello + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.ClientHello; + + /** + * Decodes a ClientHello message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ClientHello + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.ClientHello; + + /** + * Verifies a ClientHello message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ClientHello message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ClientHello + */ + public static fromObject(object: { [k: string]: any }): proto.ClientHello; + + /** + * Creates a plain object from a ClientHello message. Also converts values to other types if specified. + * @param message ClientHello + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.ClientHello, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ClientHello to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ServerHello. */ + interface IServerHello { + + /** ServerHello ephemeral */ + ephemeral?: (Uint8Array|null); + + /** ServerHello static */ + "static"?: (Uint8Array|null); + + /** ServerHello payload */ + payload?: (Uint8Array|null); + } + + /** Represents a ServerHello. */ + class ServerHello implements IServerHello { + + /** + * Constructs a new ServerHello. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IServerHello); + + /** ServerHello ephemeral. */ + public ephemeral: Uint8Array; + + /** ServerHello static. */ + public static: Uint8Array; + + /** ServerHello payload. */ + public payload: Uint8Array; + + /** + * Creates a new ServerHello instance using the specified properties. + * @param [properties] Properties to set + * @returns ServerHello instance + */ + public static create(properties?: proto.IServerHello): proto.ServerHello; + + /** + * Encodes the specified ServerHello message. Does not implicitly {@link proto.ServerHello.verify|verify} messages. + * @param message ServerHello message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IServerHello, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ServerHello message, length delimited. Does not implicitly {@link proto.ServerHello.verify|verify} messages. + * @param message ServerHello message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IServerHello, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ServerHello message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ServerHello + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.ServerHello; + + /** + * Decodes a ServerHello message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ServerHello + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.ServerHello; + + /** + * Verifies a ServerHello message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ServerHello message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ServerHello + */ + public static fromObject(object: { [k: string]: any }): proto.ServerHello; + + /** + * Creates a plain object from a ServerHello message. Also converts values to other types if specified. + * @param message ServerHello + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.ServerHello, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ServerHello to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ClientFinish. */ + interface IClientFinish { + + /** ClientFinish static */ + "static"?: (Uint8Array|null); + + /** ClientFinish payload */ + payload?: (Uint8Array|null); + } + + /** Represents a ClientFinish. */ + class ClientFinish implements IClientFinish { + + /** + * Constructs a new ClientFinish. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IClientFinish); + + /** ClientFinish static. */ + public static: Uint8Array; + + /** ClientFinish payload. */ + public payload: Uint8Array; + + /** + * Creates a new ClientFinish instance using the specified properties. + * @param [properties] Properties to set + * @returns ClientFinish instance + */ + public static create(properties?: proto.IClientFinish): proto.ClientFinish; + + /** + * Encodes the specified ClientFinish message. Does not implicitly {@link proto.ClientFinish.verify|verify} messages. + * @param message ClientFinish message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IClientFinish, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ClientFinish message, length delimited. Does not implicitly {@link proto.ClientFinish.verify|verify} messages. + * @param message ClientFinish message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IClientFinish, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ClientFinish message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ClientFinish + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.ClientFinish; + + /** + * Decodes a ClientFinish message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ClientFinish + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.ClientFinish; + + /** + * Verifies a ClientFinish message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ClientFinish message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ClientFinish + */ + public static fromObject(object: { [k: string]: any }): proto.ClientFinish; + + /** + * Creates a plain object from a ClientFinish message. Also converts values to other types if specified. + * @param message ClientFinish + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.ClientFinish, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ClientFinish to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a HandshakeMessage. */ + interface IHandshakeMessage { + + /** HandshakeMessage clientHello */ + clientHello?: (proto.IClientHello|null); + + /** HandshakeMessage serverHello */ + serverHello?: (proto.IServerHello|null); + + /** HandshakeMessage clientFinish */ + clientFinish?: (proto.IClientFinish|null); + } + + /** Represents a HandshakeMessage. */ + class HandshakeMessage implements IHandshakeMessage { + + /** + * Constructs a new HandshakeMessage. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IHandshakeMessage); + + /** HandshakeMessage clientHello. */ + public clientHello?: (proto.IClientHello|null); + + /** HandshakeMessage serverHello. */ + public serverHello?: (proto.IServerHello|null); + + /** HandshakeMessage clientFinish. */ + public clientFinish?: (proto.IClientFinish|null); + + /** + * Creates a new HandshakeMessage instance using the specified properties. + * @param [properties] Properties to set + * @returns HandshakeMessage instance + */ + public static create(properties?: proto.IHandshakeMessage): proto.HandshakeMessage; + + /** + * Encodes the specified HandshakeMessage message. Does not implicitly {@link proto.HandshakeMessage.verify|verify} messages. + * @param message HandshakeMessage message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IHandshakeMessage, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified HandshakeMessage message, length delimited. Does not implicitly {@link proto.HandshakeMessage.verify|verify} messages. + * @param message HandshakeMessage message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IHandshakeMessage, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a HandshakeMessage message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns HandshakeMessage + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.HandshakeMessage; + + /** + * Decodes a HandshakeMessage message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns HandshakeMessage + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.HandshakeMessage; + + /** + * Verifies a HandshakeMessage message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a HandshakeMessage message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns HandshakeMessage + */ + public static fromObject(object: { [k: string]: any }): proto.HandshakeMessage; + + /** + * Creates a plain object from a HandshakeMessage message. Also converts values to other types if specified. + * @param message HandshakeMessage + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.HandshakeMessage, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this HandshakeMessage to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BizIdentityInfo. */ + interface IBizIdentityInfo { + + /** BizIdentityInfo vlevel */ + vlevel?: (proto.BizIdentityInfo.BizIdentityInfoVerifiedLevelValue|null); + + /** BizIdentityInfo vnameCert */ + vnameCert?: (proto.IVerifiedNameCertificate|null); + + /** BizIdentityInfo signed */ + signed?: (boolean|null); + + /** BizIdentityInfo revoked */ + revoked?: (boolean|null); + + /** BizIdentityInfo hostStorage */ + hostStorage?: (proto.BizIdentityInfo.BizIdentityInfoHostStorageType|null); + + /** BizIdentityInfo actualActors */ + actualActors?: (proto.BizIdentityInfo.BizIdentityInfoActualActorsType|null); + + /** BizIdentityInfo privacyModeTs */ + privacyModeTs?: (number|Long|null); + } + + /** Represents a BizIdentityInfo. */ + class BizIdentityInfo implements IBizIdentityInfo { + + /** + * Constructs a new BizIdentityInfo. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IBizIdentityInfo); + + /** BizIdentityInfo vlevel. */ + public vlevel: proto.BizIdentityInfo.BizIdentityInfoVerifiedLevelValue; + + /** BizIdentityInfo vnameCert. */ + public vnameCert?: (proto.IVerifiedNameCertificate|null); + + /** BizIdentityInfo signed. */ + public signed: boolean; + + /** BizIdentityInfo revoked. */ + public revoked: boolean; + + /** BizIdentityInfo hostStorage. */ + public hostStorage: proto.BizIdentityInfo.BizIdentityInfoHostStorageType; + + /** BizIdentityInfo actualActors. */ + public actualActors: proto.BizIdentityInfo.BizIdentityInfoActualActorsType; + + /** BizIdentityInfo privacyModeTs. */ + public privacyModeTs: (number|Long); + + /** + * Creates a new BizIdentityInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns BizIdentityInfo instance + */ + public static create(properties?: proto.IBizIdentityInfo): proto.BizIdentityInfo; + + /** + * Encodes the specified BizIdentityInfo message. Does not implicitly {@link proto.BizIdentityInfo.verify|verify} messages. + * @param message BizIdentityInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IBizIdentityInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BizIdentityInfo message, length delimited. Does not implicitly {@link proto.BizIdentityInfo.verify|verify} messages. + * @param message BizIdentityInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IBizIdentityInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BizIdentityInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BizIdentityInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.BizIdentityInfo; + + /** + * Decodes a BizIdentityInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BizIdentityInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.BizIdentityInfo; + + /** + * Verifies a BizIdentityInfo message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a BizIdentityInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BizIdentityInfo + */ + public static fromObject(object: { [k: string]: any }): proto.BizIdentityInfo; + + /** + * Creates a plain object from a BizIdentityInfo message. Also converts values to other types if specified. + * @param message BizIdentityInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.BizIdentityInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BizIdentityInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace BizIdentityInfo { + + /** BizIdentityInfoVerifiedLevelValue enum. */ + enum BizIdentityInfoVerifiedLevelValue { + UNKNOWN = 0, + LOW = 1, + HIGH = 2 + } + + /** BizIdentityInfoHostStorageType enum. */ + enum BizIdentityInfoHostStorageType { + ON_PREMISE = 0, + FACEBOOK = 1 + } + + /** BizIdentityInfoActualActorsType enum. */ + enum BizIdentityInfoActualActorsType { + SELF = 0, + BSP = 1 + } + } + + /** Properties of a BizAccountLinkInfo. */ + interface IBizAccountLinkInfo { + + /** BizAccountLinkInfo whatsappBizAcctFbid */ + whatsappBizAcctFbid?: (number|Long|null); + + /** BizAccountLinkInfo whatsappAcctNumber */ + whatsappAcctNumber?: (string|null); + + /** BizAccountLinkInfo issueTime */ + issueTime?: (number|Long|null); + + /** BizAccountLinkInfo hostStorage */ + hostStorage?: (proto.BizAccountLinkInfo.BizAccountLinkInfoHostStorageType|null); + + /** BizAccountLinkInfo accountType */ + accountType?: (proto.BizAccountLinkInfo.BizAccountLinkInfoAccountType|null); + } + + /** Represents a BizAccountLinkInfo. */ + class BizAccountLinkInfo implements IBizAccountLinkInfo { + + /** + * Constructs a new BizAccountLinkInfo. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IBizAccountLinkInfo); + + /** BizAccountLinkInfo whatsappBizAcctFbid. */ + public whatsappBizAcctFbid: (number|Long); + + /** BizAccountLinkInfo whatsappAcctNumber. */ + public whatsappAcctNumber: string; + + /** BizAccountLinkInfo issueTime. */ + public issueTime: (number|Long); + + /** BizAccountLinkInfo hostStorage. */ + public hostStorage: proto.BizAccountLinkInfo.BizAccountLinkInfoHostStorageType; + + /** BizAccountLinkInfo accountType. */ + public accountType: proto.BizAccountLinkInfo.BizAccountLinkInfoAccountType; + + /** + * Creates a new BizAccountLinkInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns BizAccountLinkInfo instance + */ + public static create(properties?: proto.IBizAccountLinkInfo): proto.BizAccountLinkInfo; + + /** + * Encodes the specified BizAccountLinkInfo message. Does not implicitly {@link proto.BizAccountLinkInfo.verify|verify} messages. + * @param message BizAccountLinkInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IBizAccountLinkInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BizAccountLinkInfo message, length delimited. Does not implicitly {@link proto.BizAccountLinkInfo.verify|verify} messages. + * @param message BizAccountLinkInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IBizAccountLinkInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BizAccountLinkInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BizAccountLinkInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.BizAccountLinkInfo; + + /** + * Decodes a BizAccountLinkInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BizAccountLinkInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.BizAccountLinkInfo; + + /** + * Verifies a BizAccountLinkInfo message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a BizAccountLinkInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BizAccountLinkInfo + */ + public static fromObject(object: { [k: string]: any }): proto.BizAccountLinkInfo; + + /** + * Creates a plain object from a BizAccountLinkInfo message. Also converts values to other types if specified. + * @param message BizAccountLinkInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.BizAccountLinkInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BizAccountLinkInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace BizAccountLinkInfo { + + /** BizAccountLinkInfoHostStorageType enum. */ + enum BizAccountLinkInfoHostStorageType { + ON_PREMISE = 0, + FACEBOOK = 1 + } + + /** BizAccountLinkInfoAccountType enum. */ + enum BizAccountLinkInfoAccountType { + ENTERPRISE = 0, + PAGE = 1 + } + } + + /** Properties of a BizAccountPayload. */ + interface IBizAccountPayload { + + /** BizAccountPayload vnameCert */ + vnameCert?: (proto.IVerifiedNameCertificate|null); + + /** BizAccountPayload bizAcctLinkInfo */ + bizAcctLinkInfo?: (Uint8Array|null); + } + + /** Represents a BizAccountPayload. */ + class BizAccountPayload implements IBizAccountPayload { + + /** + * Constructs a new BizAccountPayload. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IBizAccountPayload); + + /** BizAccountPayload vnameCert. */ + public vnameCert?: (proto.IVerifiedNameCertificate|null); + + /** BizAccountPayload bizAcctLinkInfo. */ + public bizAcctLinkInfo: Uint8Array; + + /** + * Creates a new BizAccountPayload instance using the specified properties. + * @param [properties] Properties to set + * @returns BizAccountPayload instance + */ + public static create(properties?: proto.IBizAccountPayload): proto.BizAccountPayload; + + /** + * Encodes the specified BizAccountPayload message. Does not implicitly {@link proto.BizAccountPayload.verify|verify} messages. + * @param message BizAccountPayload message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IBizAccountPayload, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BizAccountPayload message, length delimited. Does not implicitly {@link proto.BizAccountPayload.verify|verify} messages. + * @param message BizAccountPayload message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IBizAccountPayload, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BizAccountPayload message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BizAccountPayload + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.BizAccountPayload; + + /** + * Decodes a BizAccountPayload message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BizAccountPayload + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.BizAccountPayload; + + /** + * Verifies a BizAccountPayload message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a BizAccountPayload message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BizAccountPayload + */ + public static fromObject(object: { [k: string]: any }): proto.BizAccountPayload; + + /** + * Creates a plain object from a BizAccountPayload message. Also converts values to other types if specified. + * @param message BizAccountPayload + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.BizAccountPayload, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BizAccountPayload to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a VerifiedNameCertificate. */ + interface IVerifiedNameCertificate { + + /** VerifiedNameCertificate details */ + details?: (Uint8Array|null); + + /** VerifiedNameCertificate signature */ + signature?: (Uint8Array|null); + + /** VerifiedNameCertificate serverSignature */ + serverSignature?: (Uint8Array|null); + } + + /** Represents a VerifiedNameCertificate. */ + class VerifiedNameCertificate implements IVerifiedNameCertificate { + + /** + * Constructs a new VerifiedNameCertificate. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IVerifiedNameCertificate); + + /** VerifiedNameCertificate details. */ + public details: Uint8Array; + + /** VerifiedNameCertificate signature. */ + public signature: Uint8Array; + + /** VerifiedNameCertificate serverSignature. */ + public serverSignature: Uint8Array; + + /** + * Creates a new VerifiedNameCertificate instance using the specified properties. + * @param [properties] Properties to set + * @returns VerifiedNameCertificate instance + */ + public static create(properties?: proto.IVerifiedNameCertificate): proto.VerifiedNameCertificate; + + /** + * Encodes the specified VerifiedNameCertificate message. Does not implicitly {@link proto.VerifiedNameCertificate.verify|verify} messages. + * @param message VerifiedNameCertificate message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IVerifiedNameCertificate, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified VerifiedNameCertificate message, length delimited. Does not implicitly {@link proto.VerifiedNameCertificate.verify|verify} messages. + * @param message VerifiedNameCertificate message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IVerifiedNameCertificate, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a VerifiedNameCertificate message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns VerifiedNameCertificate + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.VerifiedNameCertificate; + + /** + * Decodes a VerifiedNameCertificate message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns VerifiedNameCertificate + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.VerifiedNameCertificate; + + /** + * Verifies a VerifiedNameCertificate message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a VerifiedNameCertificate message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns VerifiedNameCertificate + */ + public static fromObject(object: { [k: string]: any }): proto.VerifiedNameCertificate; + + /** + * Creates a plain object from a VerifiedNameCertificate message. Also converts values to other types if specified. + * @param message VerifiedNameCertificate + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.VerifiedNameCertificate, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this VerifiedNameCertificate to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a LocalizedName. */ + interface ILocalizedName { + + /** LocalizedName lg */ + lg?: (string|null); + + /** LocalizedName lc */ + lc?: (string|null); + + /** LocalizedName verifiedName */ + verifiedName?: (string|null); + } + + /** Represents a LocalizedName. */ + class LocalizedName implements ILocalizedName { + + /** + * Constructs a new LocalizedName. + * @param [properties] Properties to set + */ + constructor(properties?: proto.ILocalizedName); + + /** LocalizedName lg. */ + public lg: string; + + /** LocalizedName lc. */ + public lc: string; + + /** LocalizedName verifiedName. */ + public verifiedName: string; + + /** + * Creates a new LocalizedName instance using the specified properties. + * @param [properties] Properties to set + * @returns LocalizedName instance + */ + public static create(properties?: proto.ILocalizedName): proto.LocalizedName; + + /** + * Encodes the specified LocalizedName message. Does not implicitly {@link proto.LocalizedName.verify|verify} messages. + * @param message LocalizedName message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.ILocalizedName, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified LocalizedName message, length delimited. Does not implicitly {@link proto.LocalizedName.verify|verify} messages. + * @param message LocalizedName message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.ILocalizedName, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a LocalizedName message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns LocalizedName + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.LocalizedName; + + /** + * Decodes a LocalizedName message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns LocalizedName + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.LocalizedName; + + /** + * Verifies a LocalizedName message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a LocalizedName message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns LocalizedName + */ + public static fromObject(object: { [k: string]: any }): proto.LocalizedName; + + /** + * Creates a plain object from a LocalizedName message. Also converts values to other types if specified. + * @param message LocalizedName + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.LocalizedName, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this LocalizedName to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a SyncActionData. */ + interface ISyncActionData { + + /** SyncActionData index */ + index?: (Uint8Array|null); + + /** SyncActionData value */ + value?: (proto.ISyncActionValue|null); + + /** SyncActionData padding */ + padding?: (Uint8Array|null); + + /** SyncActionData version */ + version?: (number|null); + } + + /** Represents a SyncActionData. */ + class SyncActionData implements ISyncActionData { + + /** + * Constructs a new SyncActionData. + * @param [properties] Properties to set + */ + constructor(properties?: proto.ISyncActionData); + + /** SyncActionData index. */ + public index: Uint8Array; + + /** SyncActionData value. */ + public value?: (proto.ISyncActionValue|null); + + /** SyncActionData padding. */ + public padding: Uint8Array; + + /** SyncActionData version. */ + public version: number; + + /** + * Creates a new SyncActionData instance using the specified properties. + * @param [properties] Properties to set + * @returns SyncActionData instance + */ + public static create(properties?: proto.ISyncActionData): proto.SyncActionData; + + /** + * Encodes the specified SyncActionData message. Does not implicitly {@link proto.SyncActionData.verify|verify} messages. + * @param message SyncActionData message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.ISyncActionData, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SyncActionData message, length delimited. Does not implicitly {@link proto.SyncActionData.verify|verify} messages. + * @param message SyncActionData message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.ISyncActionData, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SyncActionData message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SyncActionData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.SyncActionData; + + /** + * Decodes a SyncActionData message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SyncActionData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.SyncActionData; + + /** + * Verifies a SyncActionData message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SyncActionData message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SyncActionData + */ + public static fromObject(object: { [k: string]: any }): proto.SyncActionData; + + /** + * Creates a plain object from a SyncActionData message. Also converts values to other types if specified. + * @param message SyncActionData + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.SyncActionData, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SyncActionData to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a StarAction. */ + interface IStarAction { + + /** StarAction starred */ + starred?: (boolean|null); + } + + /** Represents a StarAction. */ + class StarAction implements IStarAction { + + /** + * Constructs a new StarAction. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IStarAction); + + /** StarAction starred. */ + public starred: boolean; + + /** + * Creates a new StarAction instance using the specified properties. + * @param [properties] Properties to set + * @returns StarAction instance + */ + public static create(properties?: proto.IStarAction): proto.StarAction; + + /** + * Encodes the specified StarAction message. Does not implicitly {@link proto.StarAction.verify|verify} messages. + * @param message StarAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IStarAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StarAction message, length delimited. Does not implicitly {@link proto.StarAction.verify|verify} messages. + * @param message StarAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IStarAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StarAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StarAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.StarAction; + + /** + * Decodes a StarAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StarAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.StarAction; + + /** + * Verifies a StarAction message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a StarAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StarAction + */ + public static fromObject(object: { [k: string]: any }): proto.StarAction; + + /** + * Creates a plain object from a StarAction message. Also converts values to other types if specified. + * @param message StarAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.StarAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StarAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ContactAction. */ + interface IContactAction { + + /** ContactAction fullName */ + fullName?: (string|null); + + /** ContactAction firstName */ + firstName?: (string|null); + } + + /** Represents a ContactAction. */ + class ContactAction implements IContactAction { + + /** + * Constructs a new ContactAction. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IContactAction); + + /** ContactAction fullName. */ + public fullName: string; + + /** ContactAction firstName. */ + public firstName: string; + + /** + * Creates a new ContactAction instance using the specified properties. + * @param [properties] Properties to set + * @returns ContactAction instance + */ + public static create(properties?: proto.IContactAction): proto.ContactAction; + + /** + * Encodes the specified ContactAction message. Does not implicitly {@link proto.ContactAction.verify|verify} messages. + * @param message ContactAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IContactAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ContactAction message, length delimited. Does not implicitly {@link proto.ContactAction.verify|verify} messages. + * @param message ContactAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IContactAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ContactAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ContactAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.ContactAction; + + /** + * Decodes a ContactAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ContactAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.ContactAction; + + /** + * Verifies a ContactAction message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ContactAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ContactAction + */ + public static fromObject(object: { [k: string]: any }): proto.ContactAction; + + /** + * Creates a plain object from a ContactAction message. Also converts values to other types if specified. + * @param message ContactAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.ContactAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ContactAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a MuteAction. */ + interface IMuteAction { + + /** MuteAction muted */ + muted?: (boolean|null); + + /** MuteAction muteEndTimestamp */ + muteEndTimestamp?: (number|Long|null); + } + + /** Represents a MuteAction. */ + class MuteAction implements IMuteAction { + + /** + * Constructs a new MuteAction. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IMuteAction); + + /** MuteAction muted. */ + public muted: boolean; + + /** MuteAction muteEndTimestamp. */ + public muteEndTimestamp: (number|Long); + + /** + * Creates a new MuteAction instance using the specified properties. + * @param [properties] Properties to set + * @returns MuteAction instance + */ + public static create(properties?: proto.IMuteAction): proto.MuteAction; + + /** + * Encodes the specified MuteAction message. Does not implicitly {@link proto.MuteAction.verify|verify} messages. + * @param message MuteAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IMuteAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified MuteAction message, length delimited. Does not implicitly {@link proto.MuteAction.verify|verify} messages. + * @param message MuteAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IMuteAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MuteAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns MuteAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.MuteAction; + + /** + * Decodes a MuteAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns MuteAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.MuteAction; + + /** + * Verifies a MuteAction message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a MuteAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MuteAction + */ + public static fromObject(object: { [k: string]: any }): proto.MuteAction; + + /** + * Creates a plain object from a MuteAction message. Also converts values to other types if specified. + * @param message MuteAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.MuteAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MuteAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a PinAction. */ + interface IPinAction { + + /** PinAction pinned */ + pinned?: (boolean|null); + } + + /** Represents a PinAction. */ + class PinAction implements IPinAction { + + /** + * Constructs a new PinAction. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IPinAction); + + /** PinAction pinned. */ + public pinned: boolean; + + /** + * Creates a new PinAction instance using the specified properties. + * @param [properties] Properties to set + * @returns PinAction instance + */ + public static create(properties?: proto.IPinAction): proto.PinAction; + + /** + * Encodes the specified PinAction message. Does not implicitly {@link proto.PinAction.verify|verify} messages. + * @param message PinAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IPinAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PinAction message, length delimited. Does not implicitly {@link proto.PinAction.verify|verify} messages. + * @param message PinAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IPinAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PinAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PinAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.PinAction; + + /** + * Decodes a PinAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PinAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.PinAction; + + /** + * Verifies a PinAction message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a PinAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PinAction + */ + public static fromObject(object: { [k: string]: any }): proto.PinAction; + + /** + * Creates a plain object from a PinAction message. Also converts values to other types if specified. + * @param message PinAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.PinAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PinAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a SecurityNotificationSetting. */ + interface ISecurityNotificationSetting { + + /** SecurityNotificationSetting showNotification */ + showNotification?: (boolean|null); + } + + /** Represents a SecurityNotificationSetting. */ + class SecurityNotificationSetting implements ISecurityNotificationSetting { + + /** + * Constructs a new SecurityNotificationSetting. + * @param [properties] Properties to set + */ + constructor(properties?: proto.ISecurityNotificationSetting); + + /** SecurityNotificationSetting showNotification. */ + public showNotification: boolean; + + /** + * Creates a new SecurityNotificationSetting instance using the specified properties. + * @param [properties] Properties to set + * @returns SecurityNotificationSetting instance + */ + public static create(properties?: proto.ISecurityNotificationSetting): proto.SecurityNotificationSetting; + + /** + * Encodes the specified SecurityNotificationSetting message. Does not implicitly {@link proto.SecurityNotificationSetting.verify|verify} messages. + * @param message SecurityNotificationSetting message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.ISecurityNotificationSetting, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SecurityNotificationSetting message, length delimited. Does not implicitly {@link proto.SecurityNotificationSetting.verify|verify} messages. + * @param message SecurityNotificationSetting message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.ISecurityNotificationSetting, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SecurityNotificationSetting message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SecurityNotificationSetting + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.SecurityNotificationSetting; + + /** + * Decodes a SecurityNotificationSetting message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SecurityNotificationSetting + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.SecurityNotificationSetting; + + /** + * Verifies a SecurityNotificationSetting message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SecurityNotificationSetting message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SecurityNotificationSetting + */ + public static fromObject(object: { [k: string]: any }): proto.SecurityNotificationSetting; + + /** + * Creates a plain object from a SecurityNotificationSetting message. Also converts values to other types if specified. + * @param message SecurityNotificationSetting + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.SecurityNotificationSetting, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SecurityNotificationSetting to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a PushNameSetting. */ + interface IPushNameSetting { + + /** PushNameSetting name */ + name?: (string|null); + } + + /** Represents a PushNameSetting. */ + class PushNameSetting implements IPushNameSetting { + + /** + * Constructs a new PushNameSetting. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IPushNameSetting); + + /** PushNameSetting name. */ + public name: string; + + /** + * Creates a new PushNameSetting instance using the specified properties. + * @param [properties] Properties to set + * @returns PushNameSetting instance + */ + public static create(properties?: proto.IPushNameSetting): proto.PushNameSetting; + + /** + * Encodes the specified PushNameSetting message. Does not implicitly {@link proto.PushNameSetting.verify|verify} messages. + * @param message PushNameSetting message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IPushNameSetting, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PushNameSetting message, length delimited. Does not implicitly {@link proto.PushNameSetting.verify|verify} messages. + * @param message PushNameSetting message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IPushNameSetting, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PushNameSetting message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PushNameSetting + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.PushNameSetting; + + /** + * Decodes a PushNameSetting message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PushNameSetting + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.PushNameSetting; + + /** + * Verifies a PushNameSetting message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a PushNameSetting message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PushNameSetting + */ + public static fromObject(object: { [k: string]: any }): proto.PushNameSetting; + + /** + * Creates a plain object from a PushNameSetting message. Also converts values to other types if specified. + * @param message PushNameSetting + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.PushNameSetting, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PushNameSetting to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a LocaleSetting. */ + interface ILocaleSetting { + + /** LocaleSetting locale */ + locale?: (string|null); + } + + /** Represents a LocaleSetting. */ + class LocaleSetting implements ILocaleSetting { + + /** + * Constructs a new LocaleSetting. + * @param [properties] Properties to set + */ + constructor(properties?: proto.ILocaleSetting); + + /** LocaleSetting locale. */ + public locale: string; + + /** + * Creates a new LocaleSetting instance using the specified properties. + * @param [properties] Properties to set + * @returns LocaleSetting instance + */ + public static create(properties?: proto.ILocaleSetting): proto.LocaleSetting; + + /** + * Encodes the specified LocaleSetting message. Does not implicitly {@link proto.LocaleSetting.verify|verify} messages. + * @param message LocaleSetting message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.ILocaleSetting, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified LocaleSetting message, length delimited. Does not implicitly {@link proto.LocaleSetting.verify|verify} messages. + * @param message LocaleSetting message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.ILocaleSetting, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a LocaleSetting message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns LocaleSetting + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.LocaleSetting; + + /** + * Decodes a LocaleSetting message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns LocaleSetting + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.LocaleSetting; + + /** + * Verifies a LocaleSetting message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a LocaleSetting message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns LocaleSetting + */ + public static fromObject(object: { [k: string]: any }): proto.LocaleSetting; + + /** + * Creates a plain object from a LocaleSetting message. Also converts values to other types if specified. + * @param message LocaleSetting + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.LocaleSetting, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this LocaleSetting to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a QuickReplyAction. */ + interface IQuickReplyAction { + + /** QuickReplyAction shortcut */ + shortcut?: (string|null); + + /** QuickReplyAction message */ + message?: (string|null); + + /** QuickReplyAction keywords */ + keywords?: (string[]|null); + + /** QuickReplyAction count */ + count?: (number|null); + + /** QuickReplyAction deleted */ + deleted?: (boolean|null); + } + + /** Represents a QuickReplyAction. */ + class QuickReplyAction implements IQuickReplyAction { + + /** + * Constructs a new QuickReplyAction. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IQuickReplyAction); + + /** QuickReplyAction shortcut. */ + public shortcut: string; + + /** QuickReplyAction message. */ + public message: string; + + /** QuickReplyAction keywords. */ + public keywords: string[]; + + /** QuickReplyAction count. */ + public count: number; + + /** QuickReplyAction deleted. */ + public deleted: boolean; + + /** + * Creates a new QuickReplyAction instance using the specified properties. + * @param [properties] Properties to set + * @returns QuickReplyAction instance + */ + public static create(properties?: proto.IQuickReplyAction): proto.QuickReplyAction; + + /** + * Encodes the specified QuickReplyAction message. Does not implicitly {@link proto.QuickReplyAction.verify|verify} messages. + * @param message QuickReplyAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IQuickReplyAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified QuickReplyAction message, length delimited. Does not implicitly {@link proto.QuickReplyAction.verify|verify} messages. + * @param message QuickReplyAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IQuickReplyAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a QuickReplyAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns QuickReplyAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.QuickReplyAction; + + /** + * Decodes a QuickReplyAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns QuickReplyAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.QuickReplyAction; + + /** + * Verifies a QuickReplyAction message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a QuickReplyAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns QuickReplyAction + */ + public static fromObject(object: { [k: string]: any }): proto.QuickReplyAction; + + /** + * Creates a plain object from a QuickReplyAction message. Also converts values to other types if specified. + * @param message QuickReplyAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.QuickReplyAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this QuickReplyAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a LabelAssociationAction. */ + interface ILabelAssociationAction { + + /** LabelAssociationAction labeled */ + labeled?: (boolean|null); + } + + /** Represents a LabelAssociationAction. */ + class LabelAssociationAction implements ILabelAssociationAction { + + /** + * Constructs a new LabelAssociationAction. + * @param [properties] Properties to set + */ + constructor(properties?: proto.ILabelAssociationAction); + + /** LabelAssociationAction labeled. */ + public labeled: boolean; + + /** + * Creates a new LabelAssociationAction instance using the specified properties. + * @param [properties] Properties to set + * @returns LabelAssociationAction instance + */ + public static create(properties?: proto.ILabelAssociationAction): proto.LabelAssociationAction; + + /** + * Encodes the specified LabelAssociationAction message. Does not implicitly {@link proto.LabelAssociationAction.verify|verify} messages. + * @param message LabelAssociationAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.ILabelAssociationAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified LabelAssociationAction message, length delimited. Does not implicitly {@link proto.LabelAssociationAction.verify|verify} messages. + * @param message LabelAssociationAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.ILabelAssociationAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a LabelAssociationAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns LabelAssociationAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.LabelAssociationAction; + + /** + * Decodes a LabelAssociationAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns LabelAssociationAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.LabelAssociationAction; + + /** + * Verifies a LabelAssociationAction message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a LabelAssociationAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns LabelAssociationAction + */ + public static fromObject(object: { [k: string]: any }): proto.LabelAssociationAction; + + /** + * Creates a plain object from a LabelAssociationAction message. Also converts values to other types if specified. + * @param message LabelAssociationAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.LabelAssociationAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this LabelAssociationAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a LabelEditAction. */ + interface ILabelEditAction { + + /** LabelEditAction name */ + name?: (string|null); + + /** LabelEditAction color */ + color?: (number|null); + + /** LabelEditAction predefinedId */ + predefinedId?: (number|null); + + /** LabelEditAction deleted */ + deleted?: (boolean|null); + } + + /** Represents a LabelEditAction. */ + class LabelEditAction implements ILabelEditAction { + + /** + * Constructs a new LabelEditAction. + * @param [properties] Properties to set + */ + constructor(properties?: proto.ILabelEditAction); + + /** LabelEditAction name. */ + public name: string; + + /** LabelEditAction color. */ + public color: number; + + /** LabelEditAction predefinedId. */ + public predefinedId: number; + + /** LabelEditAction deleted. */ + public deleted: boolean; + + /** + * Creates a new LabelEditAction instance using the specified properties. + * @param [properties] Properties to set + * @returns LabelEditAction instance + */ + public static create(properties?: proto.ILabelEditAction): proto.LabelEditAction; + + /** + * Encodes the specified LabelEditAction message. Does not implicitly {@link proto.LabelEditAction.verify|verify} messages. + * @param message LabelEditAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.ILabelEditAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified LabelEditAction message, length delimited. Does not implicitly {@link proto.LabelEditAction.verify|verify} messages. + * @param message LabelEditAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.ILabelEditAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a LabelEditAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns LabelEditAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.LabelEditAction; + + /** + * Decodes a LabelEditAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns LabelEditAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.LabelEditAction; + + /** + * Verifies a LabelEditAction message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a LabelEditAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns LabelEditAction + */ + public static fromObject(object: { [k: string]: any }): proto.LabelEditAction; + + /** + * Creates a plain object from a LabelEditAction message. Also converts values to other types if specified. + * @param message LabelEditAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.LabelEditAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this LabelEditAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a RecentStickerWeightsAction. */ + interface IRecentStickerWeightsAction { + + /** RecentStickerWeightsAction weights */ + weights?: (proto.IRecentStickerWeight[]|null); + } + + /** Represents a RecentStickerWeightsAction. */ + class RecentStickerWeightsAction implements IRecentStickerWeightsAction { + + /** + * Constructs a new RecentStickerWeightsAction. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IRecentStickerWeightsAction); + + /** RecentStickerWeightsAction weights. */ + public weights: proto.IRecentStickerWeight[]; + + /** + * Creates a new RecentStickerWeightsAction instance using the specified properties. + * @param [properties] Properties to set + * @returns RecentStickerWeightsAction instance + */ + public static create(properties?: proto.IRecentStickerWeightsAction): proto.RecentStickerWeightsAction; + + /** + * Encodes the specified RecentStickerWeightsAction message. Does not implicitly {@link proto.RecentStickerWeightsAction.verify|verify} messages. + * @param message RecentStickerWeightsAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IRecentStickerWeightsAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RecentStickerWeightsAction message, length delimited. Does not implicitly {@link proto.RecentStickerWeightsAction.verify|verify} messages. + * @param message RecentStickerWeightsAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IRecentStickerWeightsAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RecentStickerWeightsAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RecentStickerWeightsAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.RecentStickerWeightsAction; + + /** + * Decodes a RecentStickerWeightsAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RecentStickerWeightsAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.RecentStickerWeightsAction; + + /** + * Verifies a RecentStickerWeightsAction message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a RecentStickerWeightsAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RecentStickerWeightsAction + */ + public static fromObject(object: { [k: string]: any }): proto.RecentStickerWeightsAction; + + /** + * Creates a plain object from a RecentStickerWeightsAction message. Also converts values to other types if specified. + * @param message RecentStickerWeightsAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.RecentStickerWeightsAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RecentStickerWeightsAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a RecentStickerMetadata. */ + interface IRecentStickerMetadata { + + /** RecentStickerMetadata directPath */ + directPath?: (string|null); + + /** RecentStickerMetadata encFilehash */ + encFilehash?: (string|null); + + /** RecentStickerMetadata mediaKey */ + mediaKey?: (string|null); + + /** RecentStickerMetadata stanzaId */ + stanzaId?: (string|null); + + /** RecentStickerMetadata chatJid */ + chatJid?: (string|null); + + /** RecentStickerMetadata participant */ + participant?: (string|null); + + /** RecentStickerMetadata isSentByMe */ + isSentByMe?: (boolean|null); + } + + /** Represents a RecentStickerMetadata. */ + class RecentStickerMetadata implements IRecentStickerMetadata { + + /** + * Constructs a new RecentStickerMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IRecentStickerMetadata); + + /** RecentStickerMetadata directPath. */ + public directPath: string; + + /** RecentStickerMetadata encFilehash. */ + public encFilehash: string; + + /** RecentStickerMetadata mediaKey. */ + public mediaKey: string; + + /** RecentStickerMetadata stanzaId. */ + public stanzaId: string; + + /** RecentStickerMetadata chatJid. */ + public chatJid: string; + + /** RecentStickerMetadata participant. */ + public participant: string; + + /** RecentStickerMetadata isSentByMe. */ + public isSentByMe: boolean; + + /** + * Creates a new RecentStickerMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns RecentStickerMetadata instance + */ + public static create(properties?: proto.IRecentStickerMetadata): proto.RecentStickerMetadata; + + /** + * Encodes the specified RecentStickerMetadata message. Does not implicitly {@link proto.RecentStickerMetadata.verify|verify} messages. + * @param message RecentStickerMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IRecentStickerMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RecentStickerMetadata message, length delimited. Does not implicitly {@link proto.RecentStickerMetadata.verify|verify} messages. + * @param message RecentStickerMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IRecentStickerMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RecentStickerMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RecentStickerMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.RecentStickerMetadata; + + /** + * Decodes a RecentStickerMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RecentStickerMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.RecentStickerMetadata; + + /** + * Verifies a RecentStickerMetadata message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a RecentStickerMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RecentStickerMetadata + */ + public static fromObject(object: { [k: string]: any }): proto.RecentStickerMetadata; + + /** + * Creates a plain object from a RecentStickerMetadata message. Also converts values to other types if specified. + * @param message RecentStickerMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.RecentStickerMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RecentStickerMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a RecentEmojiWeightsAction. */ + interface IRecentEmojiWeightsAction { + + /** RecentEmojiWeightsAction weights */ + weights?: (proto.IRecentEmojiWeight[]|null); + } + + /** Represents a RecentEmojiWeightsAction. */ + class RecentEmojiWeightsAction implements IRecentEmojiWeightsAction { + + /** + * Constructs a new RecentEmojiWeightsAction. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IRecentEmojiWeightsAction); + + /** RecentEmojiWeightsAction weights. */ + public weights: proto.IRecentEmojiWeight[]; + + /** + * Creates a new RecentEmojiWeightsAction instance using the specified properties. + * @param [properties] Properties to set + * @returns RecentEmojiWeightsAction instance + */ + public static create(properties?: proto.IRecentEmojiWeightsAction): proto.RecentEmojiWeightsAction; + + /** + * Encodes the specified RecentEmojiWeightsAction message. Does not implicitly {@link proto.RecentEmojiWeightsAction.verify|verify} messages. + * @param message RecentEmojiWeightsAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IRecentEmojiWeightsAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RecentEmojiWeightsAction message, length delimited. Does not implicitly {@link proto.RecentEmojiWeightsAction.verify|verify} messages. + * @param message RecentEmojiWeightsAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IRecentEmojiWeightsAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RecentEmojiWeightsAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RecentEmojiWeightsAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.RecentEmojiWeightsAction; + + /** + * Decodes a RecentEmojiWeightsAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RecentEmojiWeightsAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.RecentEmojiWeightsAction; + + /** + * Verifies a RecentEmojiWeightsAction message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a RecentEmojiWeightsAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RecentEmojiWeightsAction + */ + public static fromObject(object: { [k: string]: any }): proto.RecentEmojiWeightsAction; + + /** + * Creates a plain object from a RecentEmojiWeightsAction message. Also converts values to other types if specified. + * @param message RecentEmojiWeightsAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.RecentEmojiWeightsAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RecentEmojiWeightsAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an ArchiveChatAction. */ + interface IArchiveChatAction { + + /** ArchiveChatAction archived */ + archived?: (boolean|null); + + /** ArchiveChatAction messageRange */ + messageRange?: (proto.ISyncActionMessageRange|null); + } + + /** Represents an ArchiveChatAction. */ + class ArchiveChatAction implements IArchiveChatAction { + + /** + * Constructs a new ArchiveChatAction. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IArchiveChatAction); + + /** ArchiveChatAction archived. */ + public archived: boolean; + + /** ArchiveChatAction messageRange. */ + public messageRange?: (proto.ISyncActionMessageRange|null); + + /** + * Creates a new ArchiveChatAction instance using the specified properties. + * @param [properties] Properties to set + * @returns ArchiveChatAction instance + */ + public static create(properties?: proto.IArchiveChatAction): proto.ArchiveChatAction; + + /** + * Encodes the specified ArchiveChatAction message. Does not implicitly {@link proto.ArchiveChatAction.verify|verify} messages. + * @param message ArchiveChatAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IArchiveChatAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ArchiveChatAction message, length delimited. Does not implicitly {@link proto.ArchiveChatAction.verify|verify} messages. + * @param message ArchiveChatAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IArchiveChatAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ArchiveChatAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ArchiveChatAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.ArchiveChatAction; + + /** + * Decodes an ArchiveChatAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ArchiveChatAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.ArchiveChatAction; + + /** + * Verifies an ArchiveChatAction message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ArchiveChatAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ArchiveChatAction + */ + public static fromObject(object: { [k: string]: any }): proto.ArchiveChatAction; + + /** + * Creates a plain object from an ArchiveChatAction message. Also converts values to other types if specified. + * @param message ArchiveChatAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.ArchiveChatAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ArchiveChatAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DeleteMessageForMeAction. */ + interface IDeleteMessageForMeAction { + + /** DeleteMessageForMeAction deleteMedia */ + deleteMedia?: (boolean|null); + + /** DeleteMessageForMeAction messageTimestamp */ + messageTimestamp?: (number|Long|null); + } + + /** Represents a DeleteMessageForMeAction. */ + class DeleteMessageForMeAction implements IDeleteMessageForMeAction { + + /** + * Constructs a new DeleteMessageForMeAction. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IDeleteMessageForMeAction); + + /** DeleteMessageForMeAction deleteMedia. */ + public deleteMedia: boolean; + + /** DeleteMessageForMeAction messageTimestamp. */ + public messageTimestamp: (number|Long); + + /** + * Creates a new DeleteMessageForMeAction instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteMessageForMeAction instance + */ + public static create(properties?: proto.IDeleteMessageForMeAction): proto.DeleteMessageForMeAction; + + /** + * Encodes the specified DeleteMessageForMeAction message. Does not implicitly {@link proto.DeleteMessageForMeAction.verify|verify} messages. + * @param message DeleteMessageForMeAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IDeleteMessageForMeAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteMessageForMeAction message, length delimited. Does not implicitly {@link proto.DeleteMessageForMeAction.verify|verify} messages. + * @param message DeleteMessageForMeAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IDeleteMessageForMeAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteMessageForMeAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteMessageForMeAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.DeleteMessageForMeAction; + + /** + * Decodes a DeleteMessageForMeAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteMessageForMeAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.DeleteMessageForMeAction; + + /** + * Verifies a DeleteMessageForMeAction message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DeleteMessageForMeAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteMessageForMeAction + */ + public static fromObject(object: { [k: string]: any }): proto.DeleteMessageForMeAction; + + /** + * Creates a plain object from a DeleteMessageForMeAction message. Also converts values to other types if specified. + * @param message DeleteMessageForMeAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.DeleteMessageForMeAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteMessageForMeAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a MarkChatAsReadAction. */ + interface IMarkChatAsReadAction { + + /** MarkChatAsReadAction read */ + read?: (boolean|null); + + /** MarkChatAsReadAction messageRange */ + messageRange?: (proto.ISyncActionMessageRange|null); + } + + /** Represents a MarkChatAsReadAction. */ + class MarkChatAsReadAction implements IMarkChatAsReadAction { + + /** + * Constructs a new MarkChatAsReadAction. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IMarkChatAsReadAction); + + /** MarkChatAsReadAction read. */ + public read: boolean; + + /** MarkChatAsReadAction messageRange. */ + public messageRange?: (proto.ISyncActionMessageRange|null); + + /** + * Creates a new MarkChatAsReadAction instance using the specified properties. + * @param [properties] Properties to set + * @returns MarkChatAsReadAction instance + */ + public static create(properties?: proto.IMarkChatAsReadAction): proto.MarkChatAsReadAction; + + /** + * Encodes the specified MarkChatAsReadAction message. Does not implicitly {@link proto.MarkChatAsReadAction.verify|verify} messages. + * @param message MarkChatAsReadAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IMarkChatAsReadAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified MarkChatAsReadAction message, length delimited. Does not implicitly {@link proto.MarkChatAsReadAction.verify|verify} messages. + * @param message MarkChatAsReadAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IMarkChatAsReadAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MarkChatAsReadAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns MarkChatAsReadAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.MarkChatAsReadAction; + + /** + * Decodes a MarkChatAsReadAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns MarkChatAsReadAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.MarkChatAsReadAction; + + /** + * Verifies a MarkChatAsReadAction message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a MarkChatAsReadAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MarkChatAsReadAction + */ + public static fromObject(object: { [k: string]: any }): proto.MarkChatAsReadAction; + + /** + * Creates a plain object from a MarkChatAsReadAction message. Also converts values to other types if specified. + * @param message MarkChatAsReadAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.MarkChatAsReadAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MarkChatAsReadAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ClearChatAction. */ + interface IClearChatAction { + + /** ClearChatAction messageRange */ + messageRange?: (proto.ISyncActionMessageRange|null); + } + + /** Represents a ClearChatAction. */ + class ClearChatAction implements IClearChatAction { + + /** + * Constructs a new ClearChatAction. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IClearChatAction); + + /** ClearChatAction messageRange. */ + public messageRange?: (proto.ISyncActionMessageRange|null); + + /** + * Creates a new ClearChatAction instance using the specified properties. + * @param [properties] Properties to set + * @returns ClearChatAction instance + */ + public static create(properties?: proto.IClearChatAction): proto.ClearChatAction; + + /** + * Encodes the specified ClearChatAction message. Does not implicitly {@link proto.ClearChatAction.verify|verify} messages. + * @param message ClearChatAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IClearChatAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ClearChatAction message, length delimited. Does not implicitly {@link proto.ClearChatAction.verify|verify} messages. + * @param message ClearChatAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IClearChatAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ClearChatAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ClearChatAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.ClearChatAction; + + /** + * Decodes a ClearChatAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ClearChatAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.ClearChatAction; + + /** + * Verifies a ClearChatAction message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ClearChatAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ClearChatAction + */ + public static fromObject(object: { [k: string]: any }): proto.ClearChatAction; + + /** + * Creates a plain object from a ClearChatAction message. Also converts values to other types if specified. + * @param message ClearChatAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.ClearChatAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ClearChatAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DeleteChatAction. */ + interface IDeleteChatAction { + + /** DeleteChatAction messageRange */ + messageRange?: (proto.ISyncActionMessageRange|null); + } + + /** Represents a DeleteChatAction. */ + class DeleteChatAction implements IDeleteChatAction { + + /** + * Constructs a new DeleteChatAction. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IDeleteChatAction); + + /** DeleteChatAction messageRange. */ + public messageRange?: (proto.ISyncActionMessageRange|null); + + /** + * Creates a new DeleteChatAction instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteChatAction instance + */ + public static create(properties?: proto.IDeleteChatAction): proto.DeleteChatAction; + + /** + * Encodes the specified DeleteChatAction message. Does not implicitly {@link proto.DeleteChatAction.verify|verify} messages. + * @param message DeleteChatAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IDeleteChatAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteChatAction message, length delimited. Does not implicitly {@link proto.DeleteChatAction.verify|verify} messages. + * @param message DeleteChatAction message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IDeleteChatAction, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteChatAction message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteChatAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.DeleteChatAction; + + /** + * Decodes a DeleteChatAction message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteChatAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.DeleteChatAction; + + /** + * Verifies a DeleteChatAction message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DeleteChatAction message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteChatAction + */ + public static fromObject(object: { [k: string]: any }): proto.DeleteChatAction; + + /** + * Creates a plain object from a DeleteChatAction message. Also converts values to other types if specified. + * @param message DeleteChatAction + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.DeleteChatAction, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteChatAction to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an UnarchiveChatsSetting. */ + interface IUnarchiveChatsSetting { + + /** UnarchiveChatsSetting unarchiveChats */ + unarchiveChats?: (boolean|null); + } + + /** Represents an UnarchiveChatsSetting. */ + class UnarchiveChatsSetting implements IUnarchiveChatsSetting { + + /** + * Constructs a new UnarchiveChatsSetting. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IUnarchiveChatsSetting); + + /** UnarchiveChatsSetting unarchiveChats. */ + public unarchiveChats: boolean; + + /** + * Creates a new UnarchiveChatsSetting instance using the specified properties. + * @param [properties] Properties to set + * @returns UnarchiveChatsSetting instance + */ + public static create(properties?: proto.IUnarchiveChatsSetting): proto.UnarchiveChatsSetting; + + /** + * Encodes the specified UnarchiveChatsSetting message. Does not implicitly {@link proto.UnarchiveChatsSetting.verify|verify} messages. + * @param message UnarchiveChatsSetting message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IUnarchiveChatsSetting, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UnarchiveChatsSetting message, length delimited. Does not implicitly {@link proto.UnarchiveChatsSetting.verify|verify} messages. + * @param message UnarchiveChatsSetting message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IUnarchiveChatsSetting, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UnarchiveChatsSetting message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UnarchiveChatsSetting + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.UnarchiveChatsSetting; + + /** + * Decodes an UnarchiveChatsSetting message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UnarchiveChatsSetting + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.UnarchiveChatsSetting; + + /** + * Verifies an UnarchiveChatsSetting message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an UnarchiveChatsSetting message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UnarchiveChatsSetting + */ + public static fromObject(object: { [k: string]: any }): proto.UnarchiveChatsSetting; + + /** + * Creates a plain object from an UnarchiveChatsSetting message. Also converts values to other types if specified. + * @param message UnarchiveChatsSetting + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.UnarchiveChatsSetting, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UnarchiveChatsSetting to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a SyncActionMessageRange. */ + interface ISyncActionMessageRange { + + /** SyncActionMessageRange lastMessageTimestamp */ + lastMessageTimestamp?: (number|Long|null); + + /** SyncActionMessageRange lastSystemMessageTimestamp */ + lastSystemMessageTimestamp?: (number|Long|null); + + /** SyncActionMessageRange messages */ + messages?: (proto.ISyncActionMessage[]|null); + } + + /** Represents a SyncActionMessageRange. */ + class SyncActionMessageRange implements ISyncActionMessageRange { + + /** + * Constructs a new SyncActionMessageRange. + * @param [properties] Properties to set + */ + constructor(properties?: proto.ISyncActionMessageRange); + + /** SyncActionMessageRange lastMessageTimestamp. */ + public lastMessageTimestamp: (number|Long); + + /** SyncActionMessageRange lastSystemMessageTimestamp. */ + public lastSystemMessageTimestamp: (number|Long); + + /** SyncActionMessageRange messages. */ + public messages: proto.ISyncActionMessage[]; + + /** + * Creates a new SyncActionMessageRange instance using the specified properties. + * @param [properties] Properties to set + * @returns SyncActionMessageRange instance + */ + public static create(properties?: proto.ISyncActionMessageRange): proto.SyncActionMessageRange; + + /** + * Encodes the specified SyncActionMessageRange message. Does not implicitly {@link proto.SyncActionMessageRange.verify|verify} messages. + * @param message SyncActionMessageRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.ISyncActionMessageRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SyncActionMessageRange message, length delimited. Does not implicitly {@link proto.SyncActionMessageRange.verify|verify} messages. + * @param message SyncActionMessageRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.ISyncActionMessageRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SyncActionMessageRange message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SyncActionMessageRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.SyncActionMessageRange; + + /** + * Decodes a SyncActionMessageRange message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SyncActionMessageRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.SyncActionMessageRange; + + /** + * Verifies a SyncActionMessageRange message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SyncActionMessageRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SyncActionMessageRange + */ + public static fromObject(object: { [k: string]: any }): proto.SyncActionMessageRange; + + /** + * Creates a plain object from a SyncActionMessageRange message. Also converts values to other types if specified. + * @param message SyncActionMessageRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.SyncActionMessageRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SyncActionMessageRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a SyncActionMessage. */ + interface ISyncActionMessage { + + /** SyncActionMessage key */ + key?: (proto.IMessageKey|null); + + /** SyncActionMessage timestamp */ + timestamp?: (number|Long|null); + } + + /** Represents a SyncActionMessage. */ + class SyncActionMessage implements ISyncActionMessage { + + /** + * Constructs a new SyncActionMessage. + * @param [properties] Properties to set + */ + constructor(properties?: proto.ISyncActionMessage); + + /** SyncActionMessage key. */ + public key?: (proto.IMessageKey|null); + + /** SyncActionMessage timestamp. */ + public timestamp: (number|Long); + + /** + * Creates a new SyncActionMessage instance using the specified properties. + * @param [properties] Properties to set + * @returns SyncActionMessage instance + */ + public static create(properties?: proto.ISyncActionMessage): proto.SyncActionMessage; + + /** + * Encodes the specified SyncActionMessage message. Does not implicitly {@link proto.SyncActionMessage.verify|verify} messages. + * @param message SyncActionMessage message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.ISyncActionMessage, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SyncActionMessage message, length delimited. Does not implicitly {@link proto.SyncActionMessage.verify|verify} messages. + * @param message SyncActionMessage message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.ISyncActionMessage, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SyncActionMessage message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SyncActionMessage + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.SyncActionMessage; + + /** + * Decodes a SyncActionMessage message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SyncActionMessage + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.SyncActionMessage; + + /** + * Verifies a SyncActionMessage message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SyncActionMessage message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SyncActionMessage + */ + public static fromObject(object: { [k: string]: any }): proto.SyncActionMessage; + + /** + * Creates a plain object from a SyncActionMessage message. Also converts values to other types if specified. + * @param message SyncActionMessage + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.SyncActionMessage, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SyncActionMessage to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a KeyExpiration. */ + interface IKeyExpiration { + + /** KeyExpiration expiredKeyEpoch */ + expiredKeyEpoch?: (number|null); + } + + /** Represents a KeyExpiration. */ + class KeyExpiration implements IKeyExpiration { + + /** + * Constructs a new KeyExpiration. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IKeyExpiration); + + /** KeyExpiration expiredKeyEpoch. */ + public expiredKeyEpoch: number; + + /** + * Creates a new KeyExpiration instance using the specified properties. + * @param [properties] Properties to set + * @returns KeyExpiration instance + */ + public static create(properties?: proto.IKeyExpiration): proto.KeyExpiration; + + /** + * Encodes the specified KeyExpiration message. Does not implicitly {@link proto.KeyExpiration.verify|verify} messages. + * @param message KeyExpiration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IKeyExpiration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified KeyExpiration message, length delimited. Does not implicitly {@link proto.KeyExpiration.verify|verify} messages. + * @param message KeyExpiration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IKeyExpiration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a KeyExpiration message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns KeyExpiration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.KeyExpiration; + + /** + * Decodes a KeyExpiration message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns KeyExpiration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.KeyExpiration; + + /** + * Verifies a KeyExpiration message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a KeyExpiration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns KeyExpiration + */ + public static fromObject(object: { [k: string]: any }): proto.KeyExpiration; + + /** + * Creates a plain object from a KeyExpiration message. Also converts values to other types if specified. + * @param message KeyExpiration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.KeyExpiration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this KeyExpiration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a SyncActionValue. */ + interface ISyncActionValue { + + /** SyncActionValue timestamp */ + timestamp?: (number|Long|null); + + /** SyncActionValue starAction */ + starAction?: (proto.IStarAction|null); + + /** SyncActionValue contactAction */ + contactAction?: (proto.IContactAction|null); + + /** SyncActionValue muteAction */ + muteAction?: (proto.IMuteAction|null); + + /** SyncActionValue pinAction */ + pinAction?: (proto.IPinAction|null); + + /** SyncActionValue securityNotificationSetting */ + securityNotificationSetting?: (proto.ISecurityNotificationSetting|null); + + /** SyncActionValue pushNameSetting */ + pushNameSetting?: (proto.IPushNameSetting|null); + + /** SyncActionValue quickReplyAction */ + quickReplyAction?: (proto.IQuickReplyAction|null); + + /** SyncActionValue recentStickerWeightsAction */ + recentStickerWeightsAction?: (proto.IRecentStickerWeightsAction|null); + + /** SyncActionValue recentStickerMetadata */ + recentStickerMetadata?: (proto.IRecentStickerMetadata|null); + + /** SyncActionValue recentEmojiWeightsAction */ + recentEmojiWeightsAction?: (proto.IRecentEmojiWeightsAction|null); + + /** SyncActionValue labelEditAction */ + labelEditAction?: (proto.ILabelEditAction|null); + + /** SyncActionValue labelAssociationAction */ + labelAssociationAction?: (proto.ILabelAssociationAction|null); + + /** SyncActionValue localeSetting */ + localeSetting?: (proto.ILocaleSetting|null); + + /** SyncActionValue archiveChatAction */ + archiveChatAction?: (proto.IArchiveChatAction|null); + + /** SyncActionValue deleteMessageForMeAction */ + deleteMessageForMeAction?: (proto.IDeleteMessageForMeAction|null); + + /** SyncActionValue keyExpiration */ + keyExpiration?: (proto.IKeyExpiration|null); + + /** SyncActionValue markChatAsReadAction */ + markChatAsReadAction?: (proto.IMarkChatAsReadAction|null); + + /** SyncActionValue clearChatAction */ + clearChatAction?: (proto.IClearChatAction|null); + + /** SyncActionValue deleteChatAction */ + deleteChatAction?: (proto.IDeleteChatAction|null); + + /** SyncActionValue unarchiveChatsSetting */ + unarchiveChatsSetting?: (proto.IUnarchiveChatsSetting|null); + } + + /** Represents a SyncActionValue. */ + class SyncActionValue implements ISyncActionValue { + + /** + * Constructs a new SyncActionValue. + * @param [properties] Properties to set + */ + constructor(properties?: proto.ISyncActionValue); + + /** SyncActionValue timestamp. */ + public timestamp: (number|Long); + + /** SyncActionValue starAction. */ + public starAction?: (proto.IStarAction|null); + + /** SyncActionValue contactAction. */ + public contactAction?: (proto.IContactAction|null); + + /** SyncActionValue muteAction. */ + public muteAction?: (proto.IMuteAction|null); + + /** SyncActionValue pinAction. */ + public pinAction?: (proto.IPinAction|null); + + /** SyncActionValue securityNotificationSetting. */ + public securityNotificationSetting?: (proto.ISecurityNotificationSetting|null); + + /** SyncActionValue pushNameSetting. */ + public pushNameSetting?: (proto.IPushNameSetting|null); + + /** SyncActionValue quickReplyAction. */ + public quickReplyAction?: (proto.IQuickReplyAction|null); + + /** SyncActionValue recentStickerWeightsAction. */ + public recentStickerWeightsAction?: (proto.IRecentStickerWeightsAction|null); + + /** SyncActionValue recentStickerMetadata. */ + public recentStickerMetadata?: (proto.IRecentStickerMetadata|null); + + /** SyncActionValue recentEmojiWeightsAction. */ + public recentEmojiWeightsAction?: (proto.IRecentEmojiWeightsAction|null); + + /** SyncActionValue labelEditAction. */ + public labelEditAction?: (proto.ILabelEditAction|null); + + /** SyncActionValue labelAssociationAction. */ + public labelAssociationAction?: (proto.ILabelAssociationAction|null); + + /** SyncActionValue localeSetting. */ + public localeSetting?: (proto.ILocaleSetting|null); + + /** SyncActionValue archiveChatAction. */ + public archiveChatAction?: (proto.IArchiveChatAction|null); + + /** SyncActionValue deleteMessageForMeAction. */ + public deleteMessageForMeAction?: (proto.IDeleteMessageForMeAction|null); + + /** SyncActionValue keyExpiration. */ + public keyExpiration?: (proto.IKeyExpiration|null); + + /** SyncActionValue markChatAsReadAction. */ + public markChatAsReadAction?: (proto.IMarkChatAsReadAction|null); + + /** SyncActionValue clearChatAction. */ + public clearChatAction?: (proto.IClearChatAction|null); + + /** SyncActionValue deleteChatAction. */ + public deleteChatAction?: (proto.IDeleteChatAction|null); + + /** SyncActionValue unarchiveChatsSetting. */ + public unarchiveChatsSetting?: (proto.IUnarchiveChatsSetting|null); + + /** + * Creates a new SyncActionValue instance using the specified properties. + * @param [properties] Properties to set + * @returns SyncActionValue instance + */ + public static create(properties?: proto.ISyncActionValue): proto.SyncActionValue; + + /** + * Encodes the specified SyncActionValue message. Does not implicitly {@link proto.SyncActionValue.verify|verify} messages. + * @param message SyncActionValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.ISyncActionValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SyncActionValue message, length delimited. Does not implicitly {@link proto.SyncActionValue.verify|verify} messages. + * @param message SyncActionValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.ISyncActionValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SyncActionValue message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SyncActionValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.SyncActionValue; + + /** + * Decodes a SyncActionValue message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SyncActionValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.SyncActionValue; + + /** + * Verifies a SyncActionValue message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SyncActionValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SyncActionValue + */ + public static fromObject(object: { [k: string]: any }): proto.SyncActionValue; + + /** + * Creates a plain object from a SyncActionValue message. Also converts values to other types if specified. + * @param message SyncActionValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.SyncActionValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SyncActionValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a RecentEmojiWeight. */ + interface IRecentEmojiWeight { + + /** RecentEmojiWeight emoji */ + emoji?: (string|null); + + /** RecentEmojiWeight weight */ + weight?: (number|null); + } + + /** Represents a RecentEmojiWeight. */ + class RecentEmojiWeight implements IRecentEmojiWeight { + + /** + * Constructs a new RecentEmojiWeight. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IRecentEmojiWeight); + + /** RecentEmojiWeight emoji. */ + public emoji: string; + + /** RecentEmojiWeight weight. */ + public weight: number; + + /** + * Creates a new RecentEmojiWeight instance using the specified properties. + * @param [properties] Properties to set + * @returns RecentEmojiWeight instance + */ + public static create(properties?: proto.IRecentEmojiWeight): proto.RecentEmojiWeight; + + /** + * Encodes the specified RecentEmojiWeight message. Does not implicitly {@link proto.RecentEmojiWeight.verify|verify} messages. + * @param message RecentEmojiWeight message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IRecentEmojiWeight, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RecentEmojiWeight message, length delimited. Does not implicitly {@link proto.RecentEmojiWeight.verify|verify} messages. + * @param message RecentEmojiWeight message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IRecentEmojiWeight, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RecentEmojiWeight message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RecentEmojiWeight + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.RecentEmojiWeight; + + /** + * Decodes a RecentEmojiWeight message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RecentEmojiWeight + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.RecentEmojiWeight; + + /** + * Verifies a RecentEmojiWeight message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a RecentEmojiWeight message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RecentEmojiWeight + */ + public static fromObject(object: { [k: string]: any }): proto.RecentEmojiWeight; + + /** + * Creates a plain object from a RecentEmojiWeight message. Also converts values to other types if specified. + * @param message RecentEmojiWeight + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.RecentEmojiWeight, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RecentEmojiWeight to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a RecentStickerWeight. */ + interface IRecentStickerWeight { + + /** RecentStickerWeight filehash */ + filehash?: (string|null); + + /** RecentStickerWeight weight */ + weight?: (number|null); + } + + /** Represents a RecentStickerWeight. */ + class RecentStickerWeight implements IRecentStickerWeight { + + /** + * Constructs a new RecentStickerWeight. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IRecentStickerWeight); + + /** RecentStickerWeight filehash. */ + public filehash: string; + + /** RecentStickerWeight weight. */ + public weight: number; + + /** + * Creates a new RecentStickerWeight instance using the specified properties. + * @param [properties] Properties to set + * @returns RecentStickerWeight instance + */ + public static create(properties?: proto.IRecentStickerWeight): proto.RecentStickerWeight; + + /** + * Encodes the specified RecentStickerWeight message. Does not implicitly {@link proto.RecentStickerWeight.verify|verify} messages. + * @param message RecentStickerWeight message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IRecentStickerWeight, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RecentStickerWeight message, length delimited. Does not implicitly {@link proto.RecentStickerWeight.verify|verify} messages. + * @param message RecentStickerWeight message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IRecentStickerWeight, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RecentStickerWeight message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RecentStickerWeight + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.RecentStickerWeight; + + /** + * Decodes a RecentStickerWeight message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RecentStickerWeight + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.RecentStickerWeight; + + /** + * Verifies a RecentStickerWeight message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a RecentStickerWeight message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RecentStickerWeight + */ + public static fromObject(object: { [k: string]: any }): proto.RecentStickerWeight; + + /** + * Creates a plain object from a RecentStickerWeight message. Also converts values to other types if specified. + * @param message RecentStickerWeight + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.RecentStickerWeight, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RecentStickerWeight to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a SyncdPatch. */ + interface ISyncdPatch { + + /** SyncdPatch version */ + version?: (proto.ISyncdVersion|null); + + /** SyncdPatch mutations */ + mutations?: (proto.ISyncdMutation[]|null); + + /** SyncdPatch externalMutations */ + externalMutations?: (proto.IExternalBlobReference|null); + + /** SyncdPatch snapshotMac */ + snapshotMac?: (Uint8Array|null); + + /** SyncdPatch patchMac */ + patchMac?: (Uint8Array|null); + + /** SyncdPatch keyId */ + keyId?: (proto.IKeyId|null); + + /** SyncdPatch exitCode */ + exitCode?: (proto.IExitCode|null); + + /** SyncdPatch deviceIndex */ + deviceIndex?: (number|null); + } + + /** Represents a SyncdPatch. */ + class SyncdPatch implements ISyncdPatch { + + /** + * Constructs a new SyncdPatch. + * @param [properties] Properties to set + */ + constructor(properties?: proto.ISyncdPatch); + + /** SyncdPatch version. */ + public version?: (proto.ISyncdVersion|null); + + /** SyncdPatch mutations. */ + public mutations: proto.ISyncdMutation[]; + + /** SyncdPatch externalMutations. */ + public externalMutations?: (proto.IExternalBlobReference|null); + + /** SyncdPatch snapshotMac. */ + public snapshotMac: Uint8Array; + + /** SyncdPatch patchMac. */ + public patchMac: Uint8Array; + + /** SyncdPatch keyId. */ + public keyId?: (proto.IKeyId|null); + + /** SyncdPatch exitCode. */ + public exitCode?: (proto.IExitCode|null); + + /** SyncdPatch deviceIndex. */ + public deviceIndex: number; + + /** + * Creates a new SyncdPatch instance using the specified properties. + * @param [properties] Properties to set + * @returns SyncdPatch instance + */ + public static create(properties?: proto.ISyncdPatch): proto.SyncdPatch; + + /** + * Encodes the specified SyncdPatch message. Does not implicitly {@link proto.SyncdPatch.verify|verify} messages. + * @param message SyncdPatch message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.ISyncdPatch, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SyncdPatch message, length delimited. Does not implicitly {@link proto.SyncdPatch.verify|verify} messages. + * @param message SyncdPatch message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.ISyncdPatch, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SyncdPatch message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SyncdPatch + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.SyncdPatch; + + /** + * Decodes a SyncdPatch message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SyncdPatch + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.SyncdPatch; + + /** + * Verifies a SyncdPatch message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SyncdPatch message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SyncdPatch + */ + public static fromObject(object: { [k: string]: any }): proto.SyncdPatch; + + /** + * Creates a plain object from a SyncdPatch message. Also converts values to other types if specified. + * @param message SyncdPatch + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.SyncdPatch, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SyncdPatch to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a SyncdMutation. */ + interface ISyncdMutation { + + /** SyncdMutation operation */ + operation?: (proto.SyncdMutation.SyncdMutationSyncdOperation|null); + + /** SyncdMutation record */ + record?: (proto.ISyncdRecord|null); + } + + /** Represents a SyncdMutation. */ + class SyncdMutation implements ISyncdMutation { + + /** + * Constructs a new SyncdMutation. + * @param [properties] Properties to set + */ + constructor(properties?: proto.ISyncdMutation); + + /** SyncdMutation operation. */ + public operation: proto.SyncdMutation.SyncdMutationSyncdOperation; + + /** SyncdMutation record. */ + public record?: (proto.ISyncdRecord|null); + + /** + * Creates a new SyncdMutation instance using the specified properties. + * @param [properties] Properties to set + * @returns SyncdMutation instance + */ + public static create(properties?: proto.ISyncdMutation): proto.SyncdMutation; + + /** + * Encodes the specified SyncdMutation message. Does not implicitly {@link proto.SyncdMutation.verify|verify} messages. + * @param message SyncdMutation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.ISyncdMutation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SyncdMutation message, length delimited. Does not implicitly {@link proto.SyncdMutation.verify|verify} messages. + * @param message SyncdMutation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.ISyncdMutation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SyncdMutation message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SyncdMutation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.SyncdMutation; + + /** + * Decodes a SyncdMutation message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SyncdMutation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.SyncdMutation; + + /** + * Verifies a SyncdMutation message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SyncdMutation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SyncdMutation + */ + public static fromObject(object: { [k: string]: any }): proto.SyncdMutation; + + /** + * Creates a plain object from a SyncdMutation message. Also converts values to other types if specified. + * @param message SyncdMutation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.SyncdMutation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SyncdMutation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace SyncdMutation { + + /** SyncdMutationSyncdOperation enum. */ + enum SyncdMutationSyncdOperation { + SET = 0, + REMOVE = 1 + } + } + + /** Properties of a SyncdMutations. */ + interface ISyncdMutations { + + /** SyncdMutations mutations */ + mutations?: (proto.ISyncdMutation[]|null); + } + + /** Represents a SyncdMutations. */ + class SyncdMutations implements ISyncdMutations { + + /** + * Constructs a new SyncdMutations. + * @param [properties] Properties to set + */ + constructor(properties?: proto.ISyncdMutations); + + /** SyncdMutations mutations. */ + public mutations: proto.ISyncdMutation[]; + + /** + * Creates a new SyncdMutations instance using the specified properties. + * @param [properties] Properties to set + * @returns SyncdMutations instance + */ + public static create(properties?: proto.ISyncdMutations): proto.SyncdMutations; + + /** + * Encodes the specified SyncdMutations message. Does not implicitly {@link proto.SyncdMutations.verify|verify} messages. + * @param message SyncdMutations message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.ISyncdMutations, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SyncdMutations message, length delimited. Does not implicitly {@link proto.SyncdMutations.verify|verify} messages. + * @param message SyncdMutations message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.ISyncdMutations, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SyncdMutations message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SyncdMutations + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.SyncdMutations; + + /** + * Decodes a SyncdMutations message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SyncdMutations + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.SyncdMutations; + + /** + * Verifies a SyncdMutations message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SyncdMutations message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SyncdMutations + */ + public static fromObject(object: { [k: string]: any }): proto.SyncdMutations; + + /** + * Creates a plain object from a SyncdMutations message. Also converts values to other types if specified. + * @param message SyncdMutations + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.SyncdMutations, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SyncdMutations to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a SyncdSnapshot. */ + interface ISyncdSnapshot { + + /** SyncdSnapshot version */ + version?: (proto.ISyncdVersion|null); + + /** SyncdSnapshot records */ + records?: (proto.ISyncdRecord[]|null); + + /** SyncdSnapshot mac */ + mac?: (Uint8Array|null); + + /** SyncdSnapshot keyId */ + keyId?: (proto.IKeyId|null); + } + + /** Represents a SyncdSnapshot. */ + class SyncdSnapshot implements ISyncdSnapshot { + + /** + * Constructs a new SyncdSnapshot. + * @param [properties] Properties to set + */ + constructor(properties?: proto.ISyncdSnapshot); + + /** SyncdSnapshot version. */ + public version?: (proto.ISyncdVersion|null); + + /** SyncdSnapshot records. */ + public records: proto.ISyncdRecord[]; + + /** SyncdSnapshot mac. */ + public mac: Uint8Array; + + /** SyncdSnapshot keyId. */ + public keyId?: (proto.IKeyId|null); + + /** + * Creates a new SyncdSnapshot instance using the specified properties. + * @param [properties] Properties to set + * @returns SyncdSnapshot instance + */ + public static create(properties?: proto.ISyncdSnapshot): proto.SyncdSnapshot; + + /** + * Encodes the specified SyncdSnapshot message. Does not implicitly {@link proto.SyncdSnapshot.verify|verify} messages. + * @param message SyncdSnapshot message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.ISyncdSnapshot, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SyncdSnapshot message, length delimited. Does not implicitly {@link proto.SyncdSnapshot.verify|verify} messages. + * @param message SyncdSnapshot message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.ISyncdSnapshot, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SyncdSnapshot message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SyncdSnapshot + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.SyncdSnapshot; + + /** + * Decodes a SyncdSnapshot message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SyncdSnapshot + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.SyncdSnapshot; + + /** + * Verifies a SyncdSnapshot message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SyncdSnapshot message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SyncdSnapshot + */ + public static fromObject(object: { [k: string]: any }): proto.SyncdSnapshot; + + /** + * Creates a plain object from a SyncdSnapshot message. Also converts values to other types if specified. + * @param message SyncdSnapshot + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.SyncdSnapshot, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SyncdSnapshot to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an ExternalBlobReference. */ + interface IExternalBlobReference { + + /** ExternalBlobReference mediaKey */ + mediaKey?: (Uint8Array|null); + + /** ExternalBlobReference directPath */ + directPath?: (string|null); + + /** ExternalBlobReference handle */ + handle?: (string|null); + + /** ExternalBlobReference fileSizeBytes */ + fileSizeBytes?: (number|Long|null); + + /** ExternalBlobReference fileSha256 */ + fileSha256?: (Uint8Array|null); + + /** ExternalBlobReference fileEncSha256 */ + fileEncSha256?: (Uint8Array|null); + } + + /** Represents an ExternalBlobReference. */ + class ExternalBlobReference implements IExternalBlobReference { + + /** + * Constructs a new ExternalBlobReference. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IExternalBlobReference); + + /** ExternalBlobReference mediaKey. */ + public mediaKey: Uint8Array; + + /** ExternalBlobReference directPath. */ + public directPath: string; + + /** ExternalBlobReference handle. */ + public handle: string; + + /** ExternalBlobReference fileSizeBytes. */ + public fileSizeBytes: (number|Long); + + /** ExternalBlobReference fileSha256. */ + public fileSha256: Uint8Array; + + /** ExternalBlobReference fileEncSha256. */ + public fileEncSha256: Uint8Array; + + /** + * Creates a new ExternalBlobReference instance using the specified properties. + * @param [properties] Properties to set + * @returns ExternalBlobReference instance + */ + public static create(properties?: proto.IExternalBlobReference): proto.ExternalBlobReference; + + /** + * Encodes the specified ExternalBlobReference message. Does not implicitly {@link proto.ExternalBlobReference.verify|verify} messages. + * @param message ExternalBlobReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IExternalBlobReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExternalBlobReference message, length delimited. Does not implicitly {@link proto.ExternalBlobReference.verify|verify} messages. + * @param message ExternalBlobReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IExternalBlobReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExternalBlobReference message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExternalBlobReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.ExternalBlobReference; + + /** + * Decodes an ExternalBlobReference message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExternalBlobReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.ExternalBlobReference; + + /** + * Verifies an ExternalBlobReference message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ExternalBlobReference message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExternalBlobReference + */ + public static fromObject(object: { [k: string]: any }): proto.ExternalBlobReference; + + /** + * Creates a plain object from an ExternalBlobReference message. Also converts values to other types if specified. + * @param message ExternalBlobReference + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.ExternalBlobReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExternalBlobReference to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a SyncdRecord. */ + interface ISyncdRecord { + + /** SyncdRecord index */ + index?: (proto.ISyncdIndex|null); + + /** SyncdRecord value */ + value?: (proto.ISyncdValue|null); + + /** SyncdRecord keyId */ + keyId?: (proto.IKeyId|null); + } + + /** Represents a SyncdRecord. */ + class SyncdRecord implements ISyncdRecord { + + /** + * Constructs a new SyncdRecord. + * @param [properties] Properties to set + */ + constructor(properties?: proto.ISyncdRecord); + + /** SyncdRecord index. */ + public index?: (proto.ISyncdIndex|null); + + /** SyncdRecord value. */ + public value?: (proto.ISyncdValue|null); + + /** SyncdRecord keyId. */ + public keyId?: (proto.IKeyId|null); + + /** + * Creates a new SyncdRecord instance using the specified properties. + * @param [properties] Properties to set + * @returns SyncdRecord instance + */ + public static create(properties?: proto.ISyncdRecord): proto.SyncdRecord; + + /** + * Encodes the specified SyncdRecord message. Does not implicitly {@link proto.SyncdRecord.verify|verify} messages. + * @param message SyncdRecord message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.ISyncdRecord, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SyncdRecord message, length delimited. Does not implicitly {@link proto.SyncdRecord.verify|verify} messages. + * @param message SyncdRecord message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.ISyncdRecord, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SyncdRecord message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SyncdRecord + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.SyncdRecord; + + /** + * Decodes a SyncdRecord message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SyncdRecord + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.SyncdRecord; + + /** + * Verifies a SyncdRecord message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SyncdRecord message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SyncdRecord + */ + public static fromObject(object: { [k: string]: any }): proto.SyncdRecord; + + /** + * Creates a plain object from a SyncdRecord message. Also converts values to other types if specified. + * @param message SyncdRecord + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.SyncdRecord, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SyncdRecord to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a KeyId. */ + interface IKeyId { + + /** KeyId id */ + id?: (Uint8Array|null); + } + + /** Represents a KeyId. */ + class KeyId implements IKeyId { + + /** + * Constructs a new KeyId. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IKeyId); + + /** KeyId id. */ + public id: Uint8Array; + + /** + * Creates a new KeyId instance using the specified properties. + * @param [properties] Properties to set + * @returns KeyId instance + */ + public static create(properties?: proto.IKeyId): proto.KeyId; + + /** + * Encodes the specified KeyId message. Does not implicitly {@link proto.KeyId.verify|verify} messages. + * @param message KeyId message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IKeyId, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified KeyId message, length delimited. Does not implicitly {@link proto.KeyId.verify|verify} messages. + * @param message KeyId message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IKeyId, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a KeyId message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns KeyId + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.KeyId; + + /** + * Decodes a KeyId message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns KeyId + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.KeyId; + + /** + * Verifies a KeyId message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a KeyId message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns KeyId + */ + public static fromObject(object: { [k: string]: any }): proto.KeyId; + + /** + * Creates a plain object from a KeyId message. Also converts values to other types if specified. + * @param message KeyId + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.KeyId, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this KeyId to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a SyncdValue. */ + interface ISyncdValue { + + /** SyncdValue blob */ + blob?: (Uint8Array|null); + } + + /** Represents a SyncdValue. */ + class SyncdValue implements ISyncdValue { + + /** + * Constructs a new SyncdValue. + * @param [properties] Properties to set + */ + constructor(properties?: proto.ISyncdValue); + + /** SyncdValue blob. */ + public blob: Uint8Array; + + /** + * Creates a new SyncdValue instance using the specified properties. + * @param [properties] Properties to set + * @returns SyncdValue instance + */ + public static create(properties?: proto.ISyncdValue): proto.SyncdValue; + + /** + * Encodes the specified SyncdValue message. Does not implicitly {@link proto.SyncdValue.verify|verify} messages. + * @param message SyncdValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.ISyncdValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SyncdValue message, length delimited. Does not implicitly {@link proto.SyncdValue.verify|verify} messages. + * @param message SyncdValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.ISyncdValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SyncdValue message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SyncdValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.SyncdValue; + + /** + * Decodes a SyncdValue message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SyncdValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.SyncdValue; + + /** + * Verifies a SyncdValue message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SyncdValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SyncdValue + */ + public static fromObject(object: { [k: string]: any }): proto.SyncdValue; + + /** + * Creates a plain object from a SyncdValue message. Also converts values to other types if specified. + * @param message SyncdValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.SyncdValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SyncdValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a SyncdIndex. */ + interface ISyncdIndex { + + /** SyncdIndex blob */ + blob?: (Uint8Array|null); + } + + /** Represents a SyncdIndex. */ + class SyncdIndex implements ISyncdIndex { + + /** + * Constructs a new SyncdIndex. + * @param [properties] Properties to set + */ + constructor(properties?: proto.ISyncdIndex); + + /** SyncdIndex blob. */ + public blob: Uint8Array; + + /** + * Creates a new SyncdIndex instance using the specified properties. + * @param [properties] Properties to set + * @returns SyncdIndex instance + */ + public static create(properties?: proto.ISyncdIndex): proto.SyncdIndex; + + /** + * Encodes the specified SyncdIndex message. Does not implicitly {@link proto.SyncdIndex.verify|verify} messages. + * @param message SyncdIndex message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.ISyncdIndex, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SyncdIndex message, length delimited. Does not implicitly {@link proto.SyncdIndex.verify|verify} messages. + * @param message SyncdIndex message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.ISyncdIndex, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SyncdIndex message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SyncdIndex + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.SyncdIndex; + + /** + * Decodes a SyncdIndex message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SyncdIndex + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.SyncdIndex; + + /** + * Verifies a SyncdIndex message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SyncdIndex message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SyncdIndex + */ + public static fromObject(object: { [k: string]: any }): proto.SyncdIndex; + + /** + * Creates a plain object from a SyncdIndex message. Also converts values to other types if specified. + * @param message SyncdIndex + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.SyncdIndex, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SyncdIndex to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an ExitCode. */ + interface IExitCode { + + /** ExitCode code */ + code?: (number|Long|null); + + /** ExitCode text */ + text?: (string|null); + } + + /** Represents an ExitCode. */ + class ExitCode implements IExitCode { + + /** + * Constructs a new ExitCode. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IExitCode); + + /** ExitCode code. */ + public code: (number|Long); + + /** ExitCode text. */ + public text: string; + + /** + * Creates a new ExitCode instance using the specified properties. + * @param [properties] Properties to set + * @returns ExitCode instance + */ + public static create(properties?: proto.IExitCode): proto.ExitCode; + + /** + * Encodes the specified ExitCode message. Does not implicitly {@link proto.ExitCode.verify|verify} messages. + * @param message ExitCode message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IExitCode, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExitCode message, length delimited. Does not implicitly {@link proto.ExitCode.verify|verify} messages. + * @param message ExitCode message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IExitCode, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExitCode message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExitCode + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.ExitCode; + + /** + * Decodes an ExitCode message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExitCode + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.ExitCode; + + /** + * Verifies an ExitCode message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ExitCode message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExitCode + */ + public static fromObject(object: { [k: string]: any }): proto.ExitCode; + + /** + * Creates a plain object from an ExitCode message. Also converts values to other types if specified. + * @param message ExitCode + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.ExitCode, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExitCode to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a SyncdVersion. */ + interface ISyncdVersion { + + /** SyncdVersion version */ + version?: (number|Long|null); + } + + /** Represents a SyncdVersion. */ + class SyncdVersion implements ISyncdVersion { + + /** + * Constructs a new SyncdVersion. + * @param [properties] Properties to set + */ + constructor(properties?: proto.ISyncdVersion); + + /** SyncdVersion version. */ + public version: (number|Long); + + /** + * Creates a new SyncdVersion instance using the specified properties. + * @param [properties] Properties to set + * @returns SyncdVersion instance + */ + public static create(properties?: proto.ISyncdVersion): proto.SyncdVersion; + + /** + * Encodes the specified SyncdVersion message. Does not implicitly {@link proto.SyncdVersion.verify|verify} messages. + * @param message SyncdVersion message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.ISyncdVersion, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SyncdVersion message, length delimited. Does not implicitly {@link proto.SyncdVersion.verify|verify} messages. + * @param message SyncdVersion message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.ISyncdVersion, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SyncdVersion message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SyncdVersion + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.SyncdVersion; + + /** + * Decodes a SyncdVersion message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SyncdVersion + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.SyncdVersion; + + /** + * Verifies a SyncdVersion message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SyncdVersion message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SyncdVersion + */ + public static fromObject(object: { [k: string]: any }): proto.SyncdVersion; + + /** + * Creates a plain object from a SyncdVersion message. Also converts values to other types if specified. + * @param message SyncdVersion + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.SyncdVersion, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SyncdVersion to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ServerErrorReceipt. */ + interface IServerErrorReceipt { + + /** ServerErrorReceipt stanzaId */ + stanzaId?: (string|null); + } + + /** Represents a ServerErrorReceipt. */ + class ServerErrorReceipt implements IServerErrorReceipt { + + /** + * Constructs a new ServerErrorReceipt. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IServerErrorReceipt); + + /** ServerErrorReceipt stanzaId. */ + public stanzaId: string; + + /** + * Creates a new ServerErrorReceipt instance using the specified properties. + * @param [properties] Properties to set + * @returns ServerErrorReceipt instance + */ + public static create(properties?: proto.IServerErrorReceipt): proto.ServerErrorReceipt; + + /** + * Encodes the specified ServerErrorReceipt message. Does not implicitly {@link proto.ServerErrorReceipt.verify|verify} messages. + * @param message ServerErrorReceipt message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IServerErrorReceipt, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ServerErrorReceipt message, length delimited. Does not implicitly {@link proto.ServerErrorReceipt.verify|verify} messages. + * @param message ServerErrorReceipt message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IServerErrorReceipt, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ServerErrorReceipt message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ServerErrorReceipt + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.ServerErrorReceipt; + + /** + * Decodes a ServerErrorReceipt message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ServerErrorReceipt + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.ServerErrorReceipt; + + /** + * Verifies a ServerErrorReceipt message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ServerErrorReceipt message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ServerErrorReceipt + */ + public static fromObject(object: { [k: string]: any }): proto.ServerErrorReceipt; + + /** + * Creates a plain object from a ServerErrorReceipt message. Also converts values to other types if specified. + * @param message ServerErrorReceipt + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.ServerErrorReceipt, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ServerErrorReceipt to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a MediaRetryNotification. */ + interface IMediaRetryNotification { + + /** MediaRetryNotification stanzaId */ + stanzaId?: (string|null); + + /** MediaRetryNotification directPath */ + directPath?: (string|null); + + /** MediaRetryNotification result */ + result?: (proto.MediaRetryNotification.MediaRetryNotificationResultType|null); + } + + /** Represents a MediaRetryNotification. */ + class MediaRetryNotification implements IMediaRetryNotification { + + /** + * Constructs a new MediaRetryNotification. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IMediaRetryNotification); + + /** MediaRetryNotification stanzaId. */ + public stanzaId: string; + + /** MediaRetryNotification directPath. */ + public directPath: string; + + /** MediaRetryNotification result. */ + public result: proto.MediaRetryNotification.MediaRetryNotificationResultType; + + /** + * Creates a new MediaRetryNotification instance using the specified properties. + * @param [properties] Properties to set + * @returns MediaRetryNotification instance + */ + public static create(properties?: proto.IMediaRetryNotification): proto.MediaRetryNotification; + + /** + * Encodes the specified MediaRetryNotification message. Does not implicitly {@link proto.MediaRetryNotification.verify|verify} messages. + * @param message MediaRetryNotification message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IMediaRetryNotification, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified MediaRetryNotification message, length delimited. Does not implicitly {@link proto.MediaRetryNotification.verify|verify} messages. + * @param message MediaRetryNotification message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IMediaRetryNotification, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MediaRetryNotification message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns MediaRetryNotification + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.MediaRetryNotification; + + /** + * Decodes a MediaRetryNotification message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns MediaRetryNotification + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.MediaRetryNotification; + + /** + * Verifies a MediaRetryNotification message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a MediaRetryNotification message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MediaRetryNotification + */ + public static fromObject(object: { [k: string]: any }): proto.MediaRetryNotification; + + /** + * Creates a plain object from a MediaRetryNotification message. Also converts values to other types if specified. + * @param message MediaRetryNotification + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.MediaRetryNotification, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MediaRetryNotification to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace MediaRetryNotification { + + /** MediaRetryNotificationResultType enum. */ + enum MediaRetryNotificationResultType { + GENERAL_ERROR = 0, + SUCCESS = 1, + NOT_FOUND = 2, + DECRYPTION_ERROR = 3 + } + } + + /** Properties of a MsgOpaqueData. */ + interface IMsgOpaqueData { + + /** MsgOpaqueData body */ + body?: (string|null); + + /** MsgOpaqueData caption */ + caption?: (string|null); + + /** MsgOpaqueData clientUrl */ + clientUrl?: (string|null); + + /** MsgOpaqueData lng */ + lng?: (number|null); + + /** MsgOpaqueData lat */ + lat?: (number|null); + + /** MsgOpaqueData paymentAmount1000 */ + paymentAmount1000?: (number|null); + + /** MsgOpaqueData paymentNoteMsgBody */ + paymentNoteMsgBody?: (string|null); + + /** MsgOpaqueData canonicalUrl */ + canonicalUrl?: (string|null); + + /** MsgOpaqueData matchedText */ + matchedText?: (string|null); + + /** MsgOpaqueData title */ + title?: (string|null); + + /** MsgOpaqueData description */ + description?: (string|null); + } + + /** Represents a MsgOpaqueData. */ + class MsgOpaqueData implements IMsgOpaqueData { + + /** + * Constructs a new MsgOpaqueData. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IMsgOpaqueData); + + /** MsgOpaqueData body. */ + public body: string; + + /** MsgOpaqueData caption. */ + public caption: string; + + /** MsgOpaqueData clientUrl. */ + public clientUrl: string; + + /** MsgOpaqueData lng. */ + public lng: number; + + /** MsgOpaqueData lat. */ + public lat: number; + + /** MsgOpaqueData paymentAmount1000. */ + public paymentAmount1000: number; + + /** MsgOpaqueData paymentNoteMsgBody. */ + public paymentNoteMsgBody: string; + + /** MsgOpaqueData canonicalUrl. */ + public canonicalUrl: string; + + /** MsgOpaqueData matchedText. */ + public matchedText: string; + + /** MsgOpaqueData title. */ + public title: string; + + /** MsgOpaqueData description. */ + public description: string; + + /** + * Creates a new MsgOpaqueData instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgOpaqueData instance + */ + public static create(properties?: proto.IMsgOpaqueData): proto.MsgOpaqueData; + + /** + * Encodes the specified MsgOpaqueData message. Does not implicitly {@link proto.MsgOpaqueData.verify|verify} messages. + * @param message MsgOpaqueData message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IMsgOpaqueData, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified MsgOpaqueData message, length delimited. Does not implicitly {@link proto.MsgOpaqueData.verify|verify} messages. + * @param message MsgOpaqueData message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IMsgOpaqueData, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MsgOpaqueData message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns MsgOpaqueData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.MsgOpaqueData; + + /** + * Decodes a MsgOpaqueData message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns MsgOpaqueData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.MsgOpaqueData; + + /** + * Verifies a MsgOpaqueData message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a MsgOpaqueData message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MsgOpaqueData + */ + public static fromObject(object: { [k: string]: any }): proto.MsgOpaqueData; + + /** + * Creates a plain object from a MsgOpaqueData message. Also converts values to other types if specified. + * @param message MsgOpaqueData + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.MsgOpaqueData, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MsgOpaqueData to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a MsgRowOpaqueData. */ + interface IMsgRowOpaqueData { + + /** MsgRowOpaqueData currentMsg */ + currentMsg?: (proto.IMsgOpaqueData|null); + + /** MsgRowOpaqueData quotedMsg */ + quotedMsg?: (proto.IMsgOpaqueData|null); + } + + /** Represents a MsgRowOpaqueData. */ + class MsgRowOpaqueData implements IMsgRowOpaqueData { + + /** + * Constructs a new MsgRowOpaqueData. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IMsgRowOpaqueData); + + /** MsgRowOpaqueData currentMsg. */ + public currentMsg?: (proto.IMsgOpaqueData|null); + + /** MsgRowOpaqueData quotedMsg. */ + public quotedMsg?: (proto.IMsgOpaqueData|null); + + /** + * Creates a new MsgRowOpaqueData instance using the specified properties. + * @param [properties] Properties to set + * @returns MsgRowOpaqueData instance + */ + public static create(properties?: proto.IMsgRowOpaqueData): proto.MsgRowOpaqueData; + + /** + * Encodes the specified MsgRowOpaqueData message. Does not implicitly {@link proto.MsgRowOpaqueData.verify|verify} messages. + * @param message MsgRowOpaqueData message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IMsgRowOpaqueData, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified MsgRowOpaqueData message, length delimited. Does not implicitly {@link proto.MsgRowOpaqueData.verify|verify} messages. + * @param message MsgRowOpaqueData message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IMsgRowOpaqueData, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MsgRowOpaqueData message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns MsgRowOpaqueData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.MsgRowOpaqueData; + + /** + * Decodes a MsgRowOpaqueData message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns MsgRowOpaqueData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.MsgRowOpaqueData; + + /** + * Verifies a MsgRowOpaqueData message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a MsgRowOpaqueData message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MsgRowOpaqueData + */ + public static fromObject(object: { [k: string]: any }): proto.MsgRowOpaqueData; + + /** + * Creates a plain object from a MsgRowOpaqueData message. Also converts values to other types if specified. + * @param message MsgRowOpaqueData + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.MsgRowOpaqueData, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MsgRowOpaqueData to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Pushname. */ + interface IPushname { + + /** Pushname id */ + id?: (string|null); + + /** Pushname pushname */ + pushname?: (string|null); + } + + /** Represents a Pushname. */ + class Pushname implements IPushname { + + /** + * Constructs a new Pushname. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IPushname); + + /** Pushname id. */ + public id: string; + + /** Pushname pushname. */ + public pushname: string; + + /** + * Creates a new Pushname instance using the specified properties. + * @param [properties] Properties to set + * @returns Pushname instance + */ + public static create(properties?: proto.IPushname): proto.Pushname; + + /** + * Encodes the specified Pushname message. Does not implicitly {@link proto.Pushname.verify|verify} messages. + * @param message Pushname message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IPushname, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Pushname message, length delimited. Does not implicitly {@link proto.Pushname.verify|verify} messages. + * @param message Pushname message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IPushname, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Pushname message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Pushname + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.Pushname; + + /** + * Decodes a Pushname message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Pushname + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.Pushname; + + /** + * Verifies a Pushname message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Pushname message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Pushname + */ + public static fromObject(object: { [k: string]: any }): proto.Pushname; + + /** + * Creates a plain object from a Pushname message. Also converts values to other types if specified. + * @param message Pushname + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.Pushname, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Pushname to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a HistorySyncMsg. */ + interface IHistorySyncMsg { + + /** HistorySyncMsg message */ + message?: (proto.IWebMessageInfo|null); + + /** HistorySyncMsg msgOrderId */ + msgOrderId?: (number|Long|null); + } + + /** Represents a HistorySyncMsg. */ + class HistorySyncMsg implements IHistorySyncMsg { + + /** + * Constructs a new HistorySyncMsg. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IHistorySyncMsg); + + /** HistorySyncMsg message. */ + public message?: (proto.IWebMessageInfo|null); + + /** HistorySyncMsg msgOrderId. */ + public msgOrderId: (number|Long); + + /** + * Creates a new HistorySyncMsg instance using the specified properties. + * @param [properties] Properties to set + * @returns HistorySyncMsg instance + */ + public static create(properties?: proto.IHistorySyncMsg): proto.HistorySyncMsg; + + /** + * Encodes the specified HistorySyncMsg message. Does not implicitly {@link proto.HistorySyncMsg.verify|verify} messages. + * @param message HistorySyncMsg message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IHistorySyncMsg, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified HistorySyncMsg message, length delimited. Does not implicitly {@link proto.HistorySyncMsg.verify|verify} messages. + * @param message HistorySyncMsg message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IHistorySyncMsg, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a HistorySyncMsg message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns HistorySyncMsg + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.HistorySyncMsg; + + /** + * Decodes a HistorySyncMsg message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns HistorySyncMsg + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.HistorySyncMsg; + + /** + * Verifies a HistorySyncMsg message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a HistorySyncMsg message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns HistorySyncMsg + */ + public static fromObject(object: { [k: string]: any }): proto.HistorySyncMsg; + + /** + * Creates a plain object from a HistorySyncMsg message. Also converts values to other types if specified. + * @param message HistorySyncMsg + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.HistorySyncMsg, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this HistorySyncMsg to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Conversation. */ + interface IConversation { + + /** Conversation id */ + id: string; + + /** Conversation messages */ + messages?: (proto.IHistorySyncMsg[]|null); + + /** Conversation newJid */ + newJid?: (string|null); + + /** Conversation oldJid */ + oldJid?: (string|null); + + /** Conversation lastMsgTimestamp */ + lastMsgTimestamp?: (number|Long|null); + + /** Conversation unreadCount */ + unreadCount?: (number|null); + + /** Conversation readOnly */ + readOnly?: (boolean|null); + + /** Conversation endOfHistoryTransfer */ + endOfHistoryTransfer?: (boolean|null); + + /** Conversation ephemeralExpiration */ + ephemeralExpiration?: (number|null); + + /** Conversation ephemeralSettingTimestamp */ + ephemeralSettingTimestamp?: (number|Long|null); + + /** Conversation endOfHistoryTransferType */ + endOfHistoryTransferType?: (proto.Conversation.ConversationEndOfHistoryTransferType|null); + + /** Conversation conversationTimestamp */ + conversationTimestamp?: (number|Long|null); + + /** Conversation name */ + name?: (string|null); + + /** Conversation pHash */ + pHash?: (string|null); + + /** Conversation notSpam */ + notSpam?: (boolean|null); + } + + /** Represents a Conversation. */ + class Conversation implements IConversation { + + /** + * Constructs a new Conversation. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IConversation); + + /** Conversation id. */ + public id: string; + + /** Conversation messages. */ + public messages: proto.IHistorySyncMsg[]; + + /** Conversation newJid. */ + public newJid: string; + + /** Conversation oldJid. */ + public oldJid: string; + + /** Conversation lastMsgTimestamp. */ + public lastMsgTimestamp: (number|Long); + + /** Conversation unreadCount. */ + public unreadCount: number; + + /** Conversation readOnly. */ + public readOnly: boolean; + + /** Conversation endOfHistoryTransfer. */ + public endOfHistoryTransfer: boolean; + + /** Conversation ephemeralExpiration. */ + public ephemeralExpiration: number; + + /** Conversation ephemeralSettingTimestamp. */ + public ephemeralSettingTimestamp: (number|Long); + + /** Conversation endOfHistoryTransferType. */ + public endOfHistoryTransferType: proto.Conversation.ConversationEndOfHistoryTransferType; + + /** Conversation conversationTimestamp. */ + public conversationTimestamp: (number|Long); + + /** Conversation name. */ + public name: string; + + /** Conversation pHash. */ + public pHash: string; + + /** Conversation notSpam. */ + public notSpam: boolean; + + /** + * Creates a new Conversation instance using the specified properties. + * @param [properties] Properties to set + * @returns Conversation instance + */ + public static create(properties?: proto.IConversation): proto.Conversation; + + /** + * Encodes the specified Conversation message. Does not implicitly {@link proto.Conversation.verify|verify} messages. + * @param message Conversation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IConversation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Conversation message, length delimited. Does not implicitly {@link proto.Conversation.verify|verify} messages. + * @param message Conversation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IConversation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Conversation message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Conversation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.Conversation; + + /** + * Decodes a Conversation message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Conversation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.Conversation; + + /** + * Verifies a Conversation message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Conversation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Conversation + */ + public static fromObject(object: { [k: string]: any }): proto.Conversation; + + /** + * Creates a plain object from a Conversation message. Also converts values to other types if specified. + * @param message Conversation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.Conversation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Conversation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace Conversation { + + /** ConversationEndOfHistoryTransferType enum. */ + enum ConversationEndOfHistoryTransferType { + COMPLETE_BUT_MORE_MESSAGES_REMAIN_ON_PRIMARY = 0, + COMPLETE_AND_NO_MORE_MESSAGE_REMAIN_ON_PRIMARY = 1 + } + } + + /** Properties of a HistorySync. */ + interface IHistorySync { + + /** HistorySync syncType */ + syncType: proto.HistorySync.HistorySyncHistorySyncType; + + /** HistorySync conversations */ + conversations?: (proto.IConversation[]|null); + + /** HistorySync statusV3Messages */ + statusV3Messages?: (proto.IWebMessageInfo[]|null); + + /** HistorySync chunkOrder */ + chunkOrder?: (number|null); + + /** HistorySync progress */ + progress?: (number|null); + + /** HistorySync pushnames */ + pushnames?: (proto.IPushname[]|null); + } + + /** Represents a HistorySync. */ + class HistorySync implements IHistorySync { + + /** + * Constructs a new HistorySync. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IHistorySync); + + /** HistorySync syncType. */ + public syncType: proto.HistorySync.HistorySyncHistorySyncType; + + /** HistorySync conversations. */ + public conversations: proto.IConversation[]; + + /** HistorySync statusV3Messages. */ + public statusV3Messages: proto.IWebMessageInfo[]; + + /** HistorySync chunkOrder. */ + public chunkOrder: number; + + /** HistorySync progress. */ + public progress: number; + + /** HistorySync pushnames. */ + public pushnames: proto.IPushname[]; + + /** + * Creates a new HistorySync instance using the specified properties. + * @param [properties] Properties to set + * @returns HistorySync instance + */ + public static create(properties?: proto.IHistorySync): proto.HistorySync; + + /** + * Encodes the specified HistorySync message. Does not implicitly {@link proto.HistorySync.verify|verify} messages. + * @param message HistorySync message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IHistorySync, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified HistorySync message, length delimited. Does not implicitly {@link proto.HistorySync.verify|verify} messages. + * @param message HistorySync message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IHistorySync, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a HistorySync message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns HistorySync + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.HistorySync; + + /** + * Decodes a HistorySync message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns HistorySync + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.HistorySync; + + /** + * Verifies a HistorySync message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a HistorySync message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns HistorySync + */ + public static fromObject(object: { [k: string]: any }): proto.HistorySync; + + /** + * Creates a plain object from a HistorySync message. Also converts values to other types if specified. + * @param message HistorySync + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.HistorySync, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this HistorySync to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace HistorySync { + + /** HistorySyncHistorySyncType enum. */ + enum HistorySyncHistorySyncType { + INITIAL_BOOTSTRAP = 0, + INITIAL_STATUS_V3 = 1, + FULL = 2, + RECENT = 3, + PUSH_NAME = 4 + } + } + + /** Properties of an EphemeralSetting. */ + interface IEphemeralSetting { + + /** EphemeralSetting duration */ + duration?: (number|null); + + /** EphemeralSetting timestamp */ + timestamp?: (number|Long|null); + } + + /** Represents an EphemeralSetting. */ + class EphemeralSetting implements IEphemeralSetting { + + /** + * Constructs a new EphemeralSetting. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IEphemeralSetting); + + /** EphemeralSetting duration. */ + public duration: number; + + /** EphemeralSetting timestamp. */ + public timestamp: (number|Long); + + /** + * Creates a new EphemeralSetting instance using the specified properties. + * @param [properties] Properties to set + * @returns EphemeralSetting instance + */ + public static create(properties?: proto.IEphemeralSetting): proto.EphemeralSetting; + + /** + * Encodes the specified EphemeralSetting message. Does not implicitly {@link proto.EphemeralSetting.verify|verify} messages. + * @param message EphemeralSetting message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IEphemeralSetting, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified EphemeralSetting message, length delimited. Does not implicitly {@link proto.EphemeralSetting.verify|verify} messages. + * @param message EphemeralSetting message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IEphemeralSetting, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an EphemeralSetting message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns EphemeralSetting + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.EphemeralSetting; + + /** + * Decodes an EphemeralSetting message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns EphemeralSetting + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.EphemeralSetting; + + /** + * Verifies an EphemeralSetting message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an EphemeralSetting message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EphemeralSetting + */ + public static fromObject(object: { [k: string]: any }): proto.EphemeralSetting; + + /** + * Creates a plain object from an EphemeralSetting message. Also converts values to other types if specified. + * @param message EphemeralSetting + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.EphemeralSetting, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EphemeralSetting to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a PaymentBackground. */ + interface IPaymentBackground { + + /** PaymentBackground id */ + id?: (string|null); + + /** PaymentBackground fileLength */ + fileLength?: (string|null); + + /** PaymentBackground width */ + width?: (number|null); + + /** PaymentBackground height */ + height?: (number|null); + + /** PaymentBackground mimetype */ + mimetype?: (string|null); + + /** PaymentBackground placeholderArgb */ + placeholderArgb?: (number|null); + + /** PaymentBackground textArgb */ + textArgb?: (number|null); + + /** PaymentBackground subtextArgb */ + subtextArgb?: (number|null); + } + + /** Represents a PaymentBackground. */ + class PaymentBackground implements IPaymentBackground { + + /** + * Constructs a new PaymentBackground. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IPaymentBackground); + + /** PaymentBackground id. */ + public id: string; + + /** PaymentBackground fileLength. */ + public fileLength: string; + + /** PaymentBackground width. */ + public width: number; + + /** PaymentBackground height. */ + public height: number; + + /** PaymentBackground mimetype. */ + public mimetype: string; + + /** PaymentBackground placeholderArgb. */ + public placeholderArgb: number; + + /** PaymentBackground textArgb. */ + public textArgb: number; + + /** PaymentBackground subtextArgb. */ + public subtextArgb: number; + + /** + * Creates a new PaymentBackground instance using the specified properties. + * @param [properties] Properties to set + * @returns PaymentBackground instance + */ + public static create(properties?: proto.IPaymentBackground): proto.PaymentBackground; + + /** + * Encodes the specified PaymentBackground message. Does not implicitly {@link proto.PaymentBackground.verify|verify} messages. + * @param message PaymentBackground message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IPaymentBackground, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PaymentBackground message, length delimited. Does not implicitly {@link proto.PaymentBackground.verify|verify} messages. + * @param message PaymentBackground message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IPaymentBackground, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PaymentBackground message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PaymentBackground + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.PaymentBackground; + + /** + * Decodes a PaymentBackground message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PaymentBackground + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.PaymentBackground; + + /** + * Verifies a PaymentBackground message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a PaymentBackground message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PaymentBackground + */ + public static fromObject(object: { [k: string]: any }): proto.PaymentBackground; + + /** + * Creates a plain object from a PaymentBackground message. Also converts values to other types if specified. + * @param message PaymentBackground + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.PaymentBackground, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PaymentBackground to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a Money. */ + interface IMoney { + + /** Money value */ + value?: (number|Long|null); + + /** Money offset */ + offset?: (number|null); + + /** Money currencyCode */ + currencyCode?: (string|null); + } + + /** Represents a Money. */ + class Money implements IMoney { + + /** + * Constructs a new Money. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IMoney); + + /** Money value. */ + public value: (number|Long); + + /** Money offset. */ + public offset: number; + + /** Money currencyCode. */ + public currencyCode: string; + + /** + * Creates a new Money instance using the specified properties. + * @param [properties] Properties to set + * @returns Money instance + */ + public static create(properties?: proto.IMoney): proto.Money; + + /** + * Encodes the specified Money message. Does not implicitly {@link proto.Money.verify|verify} messages. + * @param message Money message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IMoney, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Money message, length delimited. Does not implicitly {@link proto.Money.verify|verify} messages. + * @param message Money message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IMoney, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Money message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Money + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.Money; + + /** + * Decodes a Money message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Money + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.Money; + + /** + * Verifies a Money message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Money message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Money + */ + public static fromObject(object: { [k: string]: any }): proto.Money; + + /** + * Creates a plain object from a Money message. Also converts values to other types if specified. + * @param message Money + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.Money, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Money to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a HydratedQuickReplyButton. */ + interface IHydratedQuickReplyButton { + + /** HydratedQuickReplyButton displayText */ + displayText?: (string|null); + + /** HydratedQuickReplyButton id */ + id?: (string|null); + } + + /** Represents a HydratedQuickReplyButton. */ + class HydratedQuickReplyButton implements IHydratedQuickReplyButton { + + /** + * Constructs a new HydratedQuickReplyButton. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IHydratedQuickReplyButton); + + /** HydratedQuickReplyButton displayText. */ + public displayText: string; + + /** HydratedQuickReplyButton id. */ + public id: string; + + /** + * Creates a new HydratedQuickReplyButton instance using the specified properties. + * @param [properties] Properties to set + * @returns HydratedQuickReplyButton instance + */ + public static create(properties?: proto.IHydratedQuickReplyButton): proto.HydratedQuickReplyButton; + + /** + * Encodes the specified HydratedQuickReplyButton message. Does not implicitly {@link proto.HydratedQuickReplyButton.verify|verify} messages. + * @param message HydratedQuickReplyButton message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IHydratedQuickReplyButton, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified HydratedQuickReplyButton message, length delimited. Does not implicitly {@link proto.HydratedQuickReplyButton.verify|verify} messages. + * @param message HydratedQuickReplyButton message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IHydratedQuickReplyButton, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a HydratedQuickReplyButton message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns HydratedQuickReplyButton + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.HydratedQuickReplyButton; + + /** + * Decodes a HydratedQuickReplyButton message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns HydratedQuickReplyButton + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.HydratedQuickReplyButton; + + /** + * Verifies a HydratedQuickReplyButton message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a HydratedQuickReplyButton message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns HydratedQuickReplyButton + */ + public static fromObject(object: { [k: string]: any }): proto.HydratedQuickReplyButton; + + /** + * Creates a plain object from a HydratedQuickReplyButton message. Also converts values to other types if specified. + * @param message HydratedQuickReplyButton + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.HydratedQuickReplyButton, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this HydratedQuickReplyButton to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a HydratedURLButton. */ + interface IHydratedURLButton { + + /** HydratedURLButton displayText */ + displayText?: (string|null); + + /** HydratedURLButton url */ + url?: (string|null); + } + + /** Represents a HydratedURLButton. */ + class HydratedURLButton implements IHydratedURLButton { + + /** + * Constructs a new HydratedURLButton. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IHydratedURLButton); + + /** HydratedURLButton displayText. */ + public displayText: string; + + /** HydratedURLButton url. */ + public url: string; + + /** + * Creates a new HydratedURLButton instance using the specified properties. + * @param [properties] Properties to set + * @returns HydratedURLButton instance + */ + public static create(properties?: proto.IHydratedURLButton): proto.HydratedURLButton; + + /** + * Encodes the specified HydratedURLButton message. Does not implicitly {@link proto.HydratedURLButton.verify|verify} messages. + * @param message HydratedURLButton message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IHydratedURLButton, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified HydratedURLButton message, length delimited. Does not implicitly {@link proto.HydratedURLButton.verify|verify} messages. + * @param message HydratedURLButton message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IHydratedURLButton, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a HydratedURLButton message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns HydratedURLButton + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.HydratedURLButton; + + /** + * Decodes a HydratedURLButton message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns HydratedURLButton + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.HydratedURLButton; + + /** + * Verifies a HydratedURLButton message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a HydratedURLButton message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns HydratedURLButton + */ + public static fromObject(object: { [k: string]: any }): proto.HydratedURLButton; + + /** + * Creates a plain object from a HydratedURLButton message. Also converts values to other types if specified. + * @param message HydratedURLButton + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.HydratedURLButton, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this HydratedURLButton to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a HydratedCallButton. */ + interface IHydratedCallButton { + + /** HydratedCallButton displayText */ + displayText?: (string|null); + + /** HydratedCallButton phoneNumber */ + phoneNumber?: (string|null); + } + + /** Represents a HydratedCallButton. */ + class HydratedCallButton implements IHydratedCallButton { + + /** + * Constructs a new HydratedCallButton. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IHydratedCallButton); + + /** HydratedCallButton displayText. */ + public displayText: string; + + /** HydratedCallButton phoneNumber. */ + public phoneNumber: string; + + /** + * Creates a new HydratedCallButton instance using the specified properties. + * @param [properties] Properties to set + * @returns HydratedCallButton instance + */ + public static create(properties?: proto.IHydratedCallButton): proto.HydratedCallButton; + + /** + * Encodes the specified HydratedCallButton message. Does not implicitly {@link proto.HydratedCallButton.verify|verify} messages. + * @param message HydratedCallButton message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IHydratedCallButton, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified HydratedCallButton message, length delimited. Does not implicitly {@link proto.HydratedCallButton.verify|verify} messages. + * @param message HydratedCallButton message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IHydratedCallButton, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a HydratedCallButton message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns HydratedCallButton + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.HydratedCallButton; + + /** + * Decodes a HydratedCallButton message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns HydratedCallButton + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.HydratedCallButton; + + /** + * Verifies a HydratedCallButton message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a HydratedCallButton message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns HydratedCallButton + */ + public static fromObject(object: { [k: string]: any }): proto.HydratedCallButton; + + /** + * Creates a plain object from a HydratedCallButton message. Also converts values to other types if specified. + * @param message HydratedCallButton + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.HydratedCallButton, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this HydratedCallButton to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a HydratedTemplateButton. */ + interface IHydratedTemplateButton { + + /** HydratedTemplateButton index */ + index?: (number|null); + + /** HydratedTemplateButton quickReplyButton */ + quickReplyButton?: (proto.IHydratedQuickReplyButton|null); + + /** HydratedTemplateButton urlButton */ + urlButton?: (proto.IHydratedURLButton|null); + + /** HydratedTemplateButton callButton */ + callButton?: (proto.IHydratedCallButton|null); + } + + /** Represents a HydratedTemplateButton. */ + class HydratedTemplateButton implements IHydratedTemplateButton { + + /** + * Constructs a new HydratedTemplateButton. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IHydratedTemplateButton); + + /** HydratedTemplateButton index. */ + public index: number; + + /** HydratedTemplateButton quickReplyButton. */ + public quickReplyButton?: (proto.IHydratedQuickReplyButton|null); + + /** HydratedTemplateButton urlButton. */ + public urlButton?: (proto.IHydratedURLButton|null); + + /** HydratedTemplateButton callButton. */ + public callButton?: (proto.IHydratedCallButton|null); + + /** HydratedTemplateButton hydratedButton. */ + public hydratedButton?: ("quickReplyButton"|"urlButton"|"callButton"); + + /** + * Creates a new HydratedTemplateButton instance using the specified properties. + * @param [properties] Properties to set + * @returns HydratedTemplateButton instance + */ + public static create(properties?: proto.IHydratedTemplateButton): proto.HydratedTemplateButton; + + /** + * Encodes the specified HydratedTemplateButton message. Does not implicitly {@link proto.HydratedTemplateButton.verify|verify} messages. + * @param message HydratedTemplateButton message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IHydratedTemplateButton, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified HydratedTemplateButton message, length delimited. Does not implicitly {@link proto.HydratedTemplateButton.verify|verify} messages. + * @param message HydratedTemplateButton message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IHydratedTemplateButton, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a HydratedTemplateButton message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns HydratedTemplateButton + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.HydratedTemplateButton; + + /** + * Decodes a HydratedTemplateButton message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns HydratedTemplateButton + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.HydratedTemplateButton; + + /** + * Verifies a HydratedTemplateButton message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a HydratedTemplateButton message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns HydratedTemplateButton + */ + public static fromObject(object: { [k: string]: any }): proto.HydratedTemplateButton; + + /** + * Creates a plain object from a HydratedTemplateButton message. Also converts values to other types if specified. + * @param message HydratedTemplateButton + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.HydratedTemplateButton, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this HydratedTemplateButton to JSON. * @returns JSON object */ public toJSON(): { [k: string]: any }; @@ -1359,9 +8941,6 @@ export namespace proto { /** ContextInfo entryPointConversionDelaySeconds */ entryPointConversionDelaySeconds?: (number|null); - - /** ContextInfo disappearingMode */ - disappearingMode?: (proto.IDisappearingMode|null); } /** Represents a ContextInfo. */ @@ -1430,9 +9009,6 @@ export namespace proto { /** ContextInfo entryPointConversionDelaySeconds. */ public entryPointConversionDelaySeconds: number; - /** ContextInfo disappearingMode. */ - public disappearingMode?: (proto.IDisappearingMode|null); - /** * Creates a new ContextInfo instance using the specified properties. * @param [properties] Properties to set @@ -1677,9 +9253,6 @@ export namespace proto { /** ImageMessage thumbnailEncSha256 */ thumbnailEncSha256?: (Uint8Array|null); - - /** ImageMessage staticUrl */ - staticUrl?: (string|null); } /** Represents an ImageMessage. */ @@ -1766,9 +9339,6 @@ export namespace proto { /** ImageMessage thumbnailEncSha256. */ public thumbnailEncSha256: Uint8Array; - /** ImageMessage staticUrl. */ - public staticUrl: string; - /** * Creates a new ImageMessage instance using the specified properties. * @param [properties] Properties to set @@ -2890,9 +10460,6 @@ export namespace proto { /** VideoMessage thumbnailEncSha256 */ thumbnailEncSha256?: (Uint8Array|null); - - /** VideoMessage staticUrl */ - staticUrl?: (string|null); } /** Represents a VideoMessage. */ @@ -2970,9 +10537,6 @@ export namespace proto { /** VideoMessage thumbnailEncSha256. */ public thumbnailEncSha256: Uint8Array; - /** VideoMessage staticUrl. */ - public staticUrl: string; - /** * Creates a new VideoMessage instance using the specified properties. * @param [properties] Properties to set @@ -3287,9 +10851,6 @@ export namespace proto { /** ProtocolMessage appStateFatalExceptionNotification */ appStateFatalExceptionNotification?: (proto.IAppStateFatalExceptionNotification|null); - - /** ProtocolMessage disappearingMode */ - disappearingMode?: (proto.IDisappearingMode|null); } /** Represents a ProtocolMessage. */ @@ -3328,9 +10889,6 @@ export namespace proto { /** ProtocolMessage appStateFatalExceptionNotification. */ public appStateFatalExceptionNotification?: (proto.IAppStateFatalExceptionNotification|null); - /** ProtocolMessage disappearingMode. */ - public disappearingMode?: (proto.IDisappearingMode|null); - /** * Creates a new ProtocolMessage instance using the specified properties. * @param [properties] Properties to set @@ -7888,649 +15446,6 @@ export namespace proto { } } - /** Properties of a Header. */ - interface IHeader { - - /** Header title */ - title?: (string|null); - - /** Header subtitle */ - subtitle?: (string|null); - - /** Header documentMessage */ - documentMessage?: (proto.IDocumentMessage|null); - - /** Header imageMessage */ - imageMessage?: (proto.IImageMessage|null); - } - - /** Represents a Header. */ - class Header implements IHeader { - - /** - * Constructs a new Header. - * @param [properties] Properties to set - */ - constructor(properties?: proto.IHeader); - - /** Header title. */ - public title: string; - - /** Header subtitle. */ - public subtitle: string; - - /** Header documentMessage. */ - public documentMessage?: (proto.IDocumentMessage|null); - - /** Header imageMessage. */ - public imageMessage?: (proto.IImageMessage|null); - - /** Header media. */ - public media?: ("documentMessage"|"imageMessage"); - - /** - * Creates a new Header instance using the specified properties. - * @param [properties] Properties to set - * @returns Header instance - */ - public static create(properties?: proto.IHeader): proto.Header; - - /** - * Encodes the specified Header message. Does not implicitly {@link proto.Header.verify|verify} messages. - * @param message Header message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encode(message: proto.IHeader, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Encodes the specified Header message, length delimited. Does not implicitly {@link proto.Header.verify|verify} messages. - * @param message Header message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encodeDelimited(message: proto.IHeader, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Decodes a Header message from the specified reader or buffer. - * @param reader Reader or buffer to decode from - * @param [length] Message length if known beforehand - * @returns Header - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.Header; - - /** - * Decodes a Header message from the specified reader or buffer, length delimited. - * @param reader Reader or buffer to decode from - * @returns Header - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.Header; - - /** - * Verifies a Header message. - * @param message Plain object to verify - * @returns `null` if valid, otherwise the reason why it is not - */ - public static verify(message: { [k: string]: any }): (string|null); - - /** - * Creates a Header message from a plain object. Also converts values to their respective internal types. - * @param object Plain object - * @returns Header - */ - public static fromObject(object: { [k: string]: any }): proto.Header; - - /** - * Creates a plain object from a Header message. Also converts values to other types if specified. - * @param message Header - * @param [options] Conversion options - * @returns Plain object - */ - public static toObject(message: proto.Header, options?: $protobuf.IConversionOptions): { [k: string]: any }; - - /** - * Converts this Header to JSON. - * @returns JSON object - */ - public toJSON(): { [k: string]: any }; - } - - /** Properties of a Body. */ - interface IBody { - - /** Body text */ - text?: (string|null); - } - - /** Represents a Body. */ - class Body implements IBody { - - /** - * Constructs a new Body. - * @param [properties] Properties to set - */ - constructor(properties?: proto.IBody); - - /** Body text. */ - public text: string; - - /** - * Creates a new Body instance using the specified properties. - * @param [properties] Properties to set - * @returns Body instance - */ - public static create(properties?: proto.IBody): proto.Body; - - /** - * Encodes the specified Body message. Does not implicitly {@link proto.Body.verify|verify} messages. - * @param message Body message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encode(message: proto.IBody, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Encodes the specified Body message, length delimited. Does not implicitly {@link proto.Body.verify|verify} messages. - * @param message Body message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encodeDelimited(message: proto.IBody, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Decodes a Body message from the specified reader or buffer. - * @param reader Reader or buffer to decode from - * @param [length] Message length if known beforehand - * @returns Body - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.Body; - - /** - * Decodes a Body message from the specified reader or buffer, length delimited. - * @param reader Reader or buffer to decode from - * @returns Body - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.Body; - - /** - * Verifies a Body message. - * @param message Plain object to verify - * @returns `null` if valid, otherwise the reason why it is not - */ - public static verify(message: { [k: string]: any }): (string|null); - - /** - * Creates a Body message from a plain object. Also converts values to their respective internal types. - * @param object Plain object - * @returns Body - */ - public static fromObject(object: { [k: string]: any }): proto.Body; - - /** - * Creates a plain object from a Body message. Also converts values to other types if specified. - * @param message Body - * @param [options] Conversion options - * @returns Plain object - */ - public static toObject(message: proto.Body, options?: $protobuf.IConversionOptions): { [k: string]: any }; - - /** - * Converts this Body to JSON. - * @returns JSON object - */ - public toJSON(): { [k: string]: any }; - } - - /** Properties of a Footer. */ - interface IFooter { - - /** Footer text */ - text?: (string|null); - } - - /** Represents a Footer. */ - class Footer implements IFooter { - - /** - * Constructs a new Footer. - * @param [properties] Properties to set - */ - constructor(properties?: proto.IFooter); - - /** Footer text. */ - public text: string; - - /** - * Creates a new Footer instance using the specified properties. - * @param [properties] Properties to set - * @returns Footer instance - */ - public static create(properties?: proto.IFooter): proto.Footer; - - /** - * Encodes the specified Footer message. Does not implicitly {@link proto.Footer.verify|verify} messages. - * @param message Footer message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encode(message: proto.IFooter, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Encodes the specified Footer message, length delimited. Does not implicitly {@link proto.Footer.verify|verify} messages. - * @param message Footer message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encodeDelimited(message: proto.IFooter, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Decodes a Footer message from the specified reader or buffer. - * @param reader Reader or buffer to decode from - * @param [length] Message length if known beforehand - * @returns Footer - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.Footer; - - /** - * Decodes a Footer message from the specified reader or buffer, length delimited. - * @param reader Reader or buffer to decode from - * @returns Footer - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.Footer; - - /** - * Verifies a Footer message. - * @param message Plain object to verify - * @returns `null` if valid, otherwise the reason why it is not - */ - public static verify(message: { [k: string]: any }): (string|null); - - /** - * Creates a Footer message from a plain object. Also converts values to their respective internal types. - * @param object Plain object - * @returns Footer - */ - public static fromObject(object: { [k: string]: any }): proto.Footer; - - /** - * Creates a plain object from a Footer message. Also converts values to other types if specified. - * @param message Footer - * @param [options] Conversion options - * @returns Plain object - */ - public static toObject(message: proto.Footer, options?: $protobuf.IConversionOptions): { [k: string]: any }; - - /** - * Converts this Footer to JSON. - * @returns JSON object - */ - public toJSON(): { [k: string]: any }; - } - - /** Properties of a ShopsMessage. */ - interface IShopsMessage { - - /** ShopsMessage id */ - id?: (string|null); - - /** ShopsMessage surface */ - surface?: (proto.ShopsMessage.ShopsMessageSurface|null); - - /** ShopsMessage type */ - type?: (proto.ShopsMessage.ShopsMessageType|null); - - /** ShopsMessage messageVersion */ - messageVersion?: (number|null); - } - - /** Represents a ShopsMessage. */ - class ShopsMessage implements IShopsMessage { - - /** - * Constructs a new ShopsMessage. - * @param [properties] Properties to set - */ - constructor(properties?: proto.IShopsMessage); - - /** ShopsMessage id. */ - public id: string; - - /** ShopsMessage surface. */ - public surface: proto.ShopsMessage.ShopsMessageSurface; - - /** ShopsMessage type. */ - public type: proto.ShopsMessage.ShopsMessageType; - - /** ShopsMessage messageVersion. */ - public messageVersion: number; - - /** - * Creates a new ShopsMessage instance using the specified properties. - * @param [properties] Properties to set - * @returns ShopsMessage instance - */ - public static create(properties?: proto.IShopsMessage): proto.ShopsMessage; - - /** - * Encodes the specified ShopsMessage message. Does not implicitly {@link proto.ShopsMessage.verify|verify} messages. - * @param message ShopsMessage message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encode(message: proto.IShopsMessage, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Encodes the specified ShopsMessage message, length delimited. Does not implicitly {@link proto.ShopsMessage.verify|verify} messages. - * @param message ShopsMessage message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encodeDelimited(message: proto.IShopsMessage, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Decodes a ShopsMessage message from the specified reader or buffer. - * @param reader Reader or buffer to decode from - * @param [length] Message length if known beforehand - * @returns ShopsMessage - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.ShopsMessage; - - /** - * Decodes a ShopsMessage message from the specified reader or buffer, length delimited. - * @param reader Reader or buffer to decode from - * @returns ShopsMessage - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.ShopsMessage; - - /** - * Verifies a ShopsMessage message. - * @param message Plain object to verify - * @returns `null` if valid, otherwise the reason why it is not - */ - public static verify(message: { [k: string]: any }): (string|null); - - /** - * Creates a ShopsMessage message from a plain object. Also converts values to their respective internal types. - * @param object Plain object - * @returns ShopsMessage - */ - public static fromObject(object: { [k: string]: any }): proto.ShopsMessage; - - /** - * Creates a plain object from a ShopsMessage message. Also converts values to other types if specified. - * @param message ShopsMessage - * @param [options] Conversion options - * @returns Plain object - */ - public static toObject(message: proto.ShopsMessage, options?: $protobuf.IConversionOptions): { [k: string]: any }; - - /** - * Converts this ShopsMessage to JSON. - * @returns JSON object - */ - public toJSON(): { [k: string]: any }; - } - - namespace ShopsMessage { - - /** ShopsMessageSurface enum. */ - enum ShopsMessageSurface { - UNKNOWN_SURFACE = 0, - FB = 1, - IG = 2, - WA = 3 - } - - /** ShopsMessageType enum. */ - enum ShopsMessageType { - UNKNOWN_TYPE = 0, - PRODUCT = 1, - STOREFRONT = 2, - COLLECTION = 3 - } - } - - /** Properties of a CollectionMessage. */ - interface ICollectionMessage { - - /** CollectionMessage bizJid */ - bizJid?: (string|null); - - /** CollectionMessage id */ - id?: (string|null); - - /** CollectionMessage messageVersion */ - messageVersion?: (number|null); - } - - /** Represents a CollectionMessage. */ - class CollectionMessage implements ICollectionMessage { - - /** - * Constructs a new CollectionMessage. - * @param [properties] Properties to set - */ - constructor(properties?: proto.ICollectionMessage); - - /** CollectionMessage bizJid. */ - public bizJid: string; - - /** CollectionMessage id. */ - public id: string; - - /** CollectionMessage messageVersion. */ - public messageVersion: number; - - /** - * Creates a new CollectionMessage instance using the specified properties. - * @param [properties] Properties to set - * @returns CollectionMessage instance - */ - public static create(properties?: proto.ICollectionMessage): proto.CollectionMessage; - - /** - * Encodes the specified CollectionMessage message. Does not implicitly {@link proto.CollectionMessage.verify|verify} messages. - * @param message CollectionMessage message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encode(message: proto.ICollectionMessage, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Encodes the specified CollectionMessage message, length delimited. Does not implicitly {@link proto.CollectionMessage.verify|verify} messages. - * @param message CollectionMessage message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encodeDelimited(message: proto.ICollectionMessage, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Decodes a CollectionMessage message from the specified reader or buffer. - * @param reader Reader or buffer to decode from - * @param [length] Message length if known beforehand - * @returns CollectionMessage - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.CollectionMessage; - - /** - * Decodes a CollectionMessage message from the specified reader or buffer, length delimited. - * @param reader Reader or buffer to decode from - * @returns CollectionMessage - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.CollectionMessage; - - /** - * Verifies a CollectionMessage message. - * @param message Plain object to verify - * @returns `null` if valid, otherwise the reason why it is not - */ - public static verify(message: { [k: string]: any }): (string|null); - - /** - * Creates a CollectionMessage message from a plain object. Also converts values to their respective internal types. - * @param object Plain object - * @returns CollectionMessage - */ - public static fromObject(object: { [k: string]: any }): proto.CollectionMessage; - - /** - * Creates a plain object from a CollectionMessage message. Also converts values to other types if specified. - * @param message CollectionMessage - * @param [options] Conversion options - * @returns Plain object - */ - public static toObject(message: proto.CollectionMessage, options?: $protobuf.IConversionOptions): { [k: string]: any }; - - /** - * Converts this CollectionMessage to JSON. - * @returns JSON object - */ - public toJSON(): { [k: string]: any }; - } - - /** Properties of an InteractiveMessage. */ - interface IInteractiveMessage { - - /** InteractiveMessage header */ - header?: (proto.IHeader|null); - - /** InteractiveMessage body */ - body?: (proto.IBody|null); - - /** InteractiveMessage footer */ - footer?: (proto.IFooter|null); - - /** InteractiveMessage contextInfo */ - contextInfo?: (proto.IContextInfo|null); - - /** InteractiveMessage shopsMessage */ - shopsMessage?: (proto.IShopsMessage|null); - - /** InteractiveMessage collectionMessage */ - collectionMessage?: (proto.ICollectionMessage|null); - } - - /** Represents an InteractiveMessage. */ - class InteractiveMessage implements IInteractiveMessage { - - /** - * Constructs a new InteractiveMessage. - * @param [properties] Properties to set - */ - constructor(properties?: proto.IInteractiveMessage); - - /** InteractiveMessage header. */ - public header?: (proto.IHeader|null); - - /** InteractiveMessage body. */ - public body?: (proto.IBody|null); - - /** InteractiveMessage footer. */ - public footer?: (proto.IFooter|null); - - /** InteractiveMessage contextInfo. */ - public contextInfo?: (proto.IContextInfo|null); - - /** InteractiveMessage shopsMessage. */ - public shopsMessage?: (proto.IShopsMessage|null); - - /** InteractiveMessage collectionMessage. */ - public collectionMessage?: (proto.ICollectionMessage|null); - - /** InteractiveMessage interactiveMessage. */ - public interactiveMessage?: ("shopsMessage"|"collectionMessage"); - - /** - * Creates a new InteractiveMessage instance using the specified properties. - * @param [properties] Properties to set - * @returns InteractiveMessage instance - */ - public static create(properties?: proto.IInteractiveMessage): proto.InteractiveMessage; - - /** - * Encodes the specified InteractiveMessage message. Does not implicitly {@link proto.InteractiveMessage.verify|verify} messages. - * @param message InteractiveMessage message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encode(message: proto.IInteractiveMessage, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Encodes the specified InteractiveMessage message, length delimited. Does not implicitly {@link proto.InteractiveMessage.verify|verify} messages. - * @param message InteractiveMessage message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encodeDelimited(message: proto.IInteractiveMessage, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Decodes an InteractiveMessage message from the specified reader or buffer. - * @param reader Reader or buffer to decode from - * @param [length] Message length if known beforehand - * @returns InteractiveMessage - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.InteractiveMessage; - - /** - * Decodes an InteractiveMessage message from the specified reader or buffer, length delimited. - * @param reader Reader or buffer to decode from - * @returns InteractiveMessage - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.InteractiveMessage; - - /** - * Verifies an InteractiveMessage message. - * @param message Plain object to verify - * @returns `null` if valid, otherwise the reason why it is not - */ - public static verify(message: { [k: string]: any }): (string|null); - - /** - * Creates an InteractiveMessage message from a plain object. Also converts values to their respective internal types. - * @param object Plain object - * @returns InteractiveMessage - */ - public static fromObject(object: { [k: string]: any }): proto.InteractiveMessage; - - /** - * Creates a plain object from an InteractiveMessage message. Also converts values to other types if specified. - * @param message InteractiveMessage - * @param [options] Conversion options - * @returns Plain object - */ - public static toObject(message: proto.InteractiveMessage, options?: $protobuf.IConversionOptions): { [k: string]: any }; - - /** - * Converts this InteractiveMessage to JSON. - * @returns JSON object - */ - public toJSON(): { [k: string]: any }; - } - /** Properties of a GroupInviteMessage. */ interface IGroupInviteMessage { @@ -9544,9 +16459,6 @@ export namespace proto { /** Message paymentInviteMessage */ paymentInviteMessage?: (proto.IPaymentInviteMessage|null); - - /** Message interactiveMessage */ - interactiveMessage?: (proto.IInteractiveMessage|null); } /** Represents a Message. */ @@ -9666,9 +16578,6 @@ export namespace proto { /** Message paymentInviteMessage. */ public paymentInviteMessage?: (proto.IPaymentInviteMessage|null); - /** Message interactiveMessage. */ - public interactiveMessage?: (proto.IInteractiveMessage|null); - /** * Creates a new Message instance using the specified properties. * @param [properties] Properties to set @@ -9740,854 +16649,747 @@ export namespace proto { public toJSON(): { [k: string]: any }; } - /** Properties of a DisappearingMode. */ - interface IDisappearingMode { + /** Properties of a CompanionProps. */ + interface ICompanionProps { - /** DisappearingMode initiator */ - initiator?: (proto.DisappearingMode.DisappearingModeInitiator|null); + /** CompanionProps os */ + os?: (string|null); + + /** CompanionProps version */ + version?: (proto.IAppVersion|null); + + /** CompanionProps platformType */ + platformType?: (proto.CompanionProps.CompanionPropsPlatformType|null); + + /** CompanionProps requireFullSync */ + requireFullSync?: (boolean|null); } - /** Represents a DisappearingMode. */ - class DisappearingMode implements IDisappearingMode { + /** Represents a CompanionProps. */ + class CompanionProps implements ICompanionProps { /** - * Constructs a new DisappearingMode. + * Constructs a new CompanionProps. * @param [properties] Properties to set */ - constructor(properties?: proto.IDisappearingMode); + constructor(properties?: proto.ICompanionProps); - /** DisappearingMode initiator. */ - public initiator: proto.DisappearingMode.DisappearingModeInitiator; + /** CompanionProps os. */ + public os: string; + + /** CompanionProps version. */ + public version?: (proto.IAppVersion|null); + + /** CompanionProps platformType. */ + public platformType: proto.CompanionProps.CompanionPropsPlatformType; + + /** CompanionProps requireFullSync. */ + public requireFullSync: boolean; /** - * Creates a new DisappearingMode instance using the specified properties. + * Creates a new CompanionProps instance using the specified properties. * @param [properties] Properties to set - * @returns DisappearingMode instance + * @returns CompanionProps instance */ - public static create(properties?: proto.IDisappearingMode): proto.DisappearingMode; + public static create(properties?: proto.ICompanionProps): proto.CompanionProps; /** - * Encodes the specified DisappearingMode message. Does not implicitly {@link proto.DisappearingMode.verify|verify} messages. - * @param message DisappearingMode message or plain object to encode + * Encodes the specified CompanionProps message. Does not implicitly {@link proto.CompanionProps.verify|verify} messages. + * @param message CompanionProps message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encode(message: proto.IDisappearingMode, writer?: $protobuf.Writer): $protobuf.Writer; + public static encode(message: proto.ICompanionProps, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Encodes the specified DisappearingMode message, length delimited. Does not implicitly {@link proto.DisappearingMode.verify|verify} messages. - * @param message DisappearingMode message or plain object to encode + * Encodes the specified CompanionProps message, length delimited. Does not implicitly {@link proto.CompanionProps.verify|verify} messages. + * @param message CompanionProps message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encodeDelimited(message: proto.IDisappearingMode, writer?: $protobuf.Writer): $protobuf.Writer; + public static encodeDelimited(message: proto.ICompanionProps, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Decodes a DisappearingMode message from the specified reader or buffer. + * Decodes a CompanionProps message from the specified reader or buffer. * @param reader Reader or buffer to decode from * @param [length] Message length if known beforehand - * @returns DisappearingMode + * @returns CompanionProps * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.DisappearingMode; + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.CompanionProps; /** - * Decodes a DisappearingMode message from the specified reader or buffer, length delimited. + * Decodes a CompanionProps message from the specified reader or buffer, length delimited. * @param reader Reader or buffer to decode from - * @returns DisappearingMode + * @returns CompanionProps * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.DisappearingMode; + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.CompanionProps; /** - * Verifies a DisappearingMode message. + * Verifies a CompanionProps message. * @param message Plain object to verify * @returns `null` if valid, otherwise the reason why it is not */ public static verify(message: { [k: string]: any }): (string|null); /** - * Creates a DisappearingMode message from a plain object. Also converts values to their respective internal types. + * Creates a CompanionProps message from a plain object. Also converts values to their respective internal types. * @param object Plain object - * @returns DisappearingMode + * @returns CompanionProps */ - public static fromObject(object: { [k: string]: any }): proto.DisappearingMode; + public static fromObject(object: { [k: string]: any }): proto.CompanionProps; /** - * Creates a plain object from a DisappearingMode message. Also converts values to other types if specified. - * @param message DisappearingMode + * Creates a plain object from a CompanionProps message. Also converts values to other types if specified. + * @param message CompanionProps * @param [options] Conversion options * @returns Plain object */ - public static toObject(message: proto.DisappearingMode, options?: $protobuf.IConversionOptions): { [k: string]: any }; + public static toObject(message: proto.CompanionProps, options?: $protobuf.IConversionOptions): { [k: string]: any }; /** - * Converts this DisappearingMode to JSON. + * Converts this CompanionProps to JSON. * @returns JSON object */ public toJSON(): { [k: string]: any }; } - namespace DisappearingMode { + namespace CompanionProps { - /** DisappearingModeInitiator enum. */ - enum DisappearingModeInitiator { - CHANGED_IN_CHAT = 0, - INITIATED_BY_ME = 1, - INITIATED_BY_OTHER = 2 + /** CompanionPropsPlatformType enum. */ + enum CompanionPropsPlatformType { + UNKNOWN = 0, + CHROME = 1, + FIREFOX = 2, + IE = 3, + OPERA = 4, + SAFARI = 5, + EDGE = 6, + DESKTOP = 7, + IPAD = 8, + ANDROID_TABLET = 9, + OHANA = 10, + ALOHA = 11, + CATALINA = 12 } } - /** Properties of a PaymentBackground. */ - interface IPaymentBackground { + /** Properties of a ADVSignedDeviceIdentityHMAC. */ + interface IADVSignedDeviceIdentityHMAC { - /** PaymentBackground id */ + /** ADVSignedDeviceIdentityHMAC details */ + details?: (Uint8Array|null); + + /** ADVSignedDeviceIdentityHMAC hmac */ + hmac?: (Uint8Array|null); + } + + /** Represents a ADVSignedDeviceIdentityHMAC. */ + class ADVSignedDeviceIdentityHMAC implements IADVSignedDeviceIdentityHMAC { + + /** + * Constructs a new ADVSignedDeviceIdentityHMAC. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IADVSignedDeviceIdentityHMAC); + + /** ADVSignedDeviceIdentityHMAC details. */ + public details: Uint8Array; + + /** ADVSignedDeviceIdentityHMAC hmac. */ + public hmac: Uint8Array; + + /** + * Creates a new ADVSignedDeviceIdentityHMAC instance using the specified properties. + * @param [properties] Properties to set + * @returns ADVSignedDeviceIdentityHMAC instance + */ + public static create(properties?: proto.IADVSignedDeviceIdentityHMAC): proto.ADVSignedDeviceIdentityHMAC; + + /** + * Encodes the specified ADVSignedDeviceIdentityHMAC message. Does not implicitly {@link proto.ADVSignedDeviceIdentityHMAC.verify|verify} messages. + * @param message ADVSignedDeviceIdentityHMAC message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IADVSignedDeviceIdentityHMAC, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ADVSignedDeviceIdentityHMAC message, length delimited. Does not implicitly {@link proto.ADVSignedDeviceIdentityHMAC.verify|verify} messages. + * @param message ADVSignedDeviceIdentityHMAC message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IADVSignedDeviceIdentityHMAC, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ADVSignedDeviceIdentityHMAC message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ADVSignedDeviceIdentityHMAC + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.ADVSignedDeviceIdentityHMAC; + + /** + * Decodes a ADVSignedDeviceIdentityHMAC message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ADVSignedDeviceIdentityHMAC + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.ADVSignedDeviceIdentityHMAC; + + /** + * Verifies a ADVSignedDeviceIdentityHMAC message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ADVSignedDeviceIdentityHMAC message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ADVSignedDeviceIdentityHMAC + */ + public static fromObject(object: { [k: string]: any }): proto.ADVSignedDeviceIdentityHMAC; + + /** + * Creates a plain object from a ADVSignedDeviceIdentityHMAC message. Also converts values to other types if specified. + * @param message ADVSignedDeviceIdentityHMAC + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.ADVSignedDeviceIdentityHMAC, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ADVSignedDeviceIdentityHMAC to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ADVSignedDeviceIdentity. */ + interface IADVSignedDeviceIdentity { + + /** ADVSignedDeviceIdentity details */ + details?: (Uint8Array|null); + + /** ADVSignedDeviceIdentity accountSignatureKey */ + accountSignatureKey?: (Uint8Array|null); + + /** ADVSignedDeviceIdentity accountSignature */ + accountSignature?: (Uint8Array|null); + + /** ADVSignedDeviceIdentity deviceSignature */ + deviceSignature?: (Uint8Array|null); + } + + /** Represents a ADVSignedDeviceIdentity. */ + class ADVSignedDeviceIdentity implements IADVSignedDeviceIdentity { + + /** + * Constructs a new ADVSignedDeviceIdentity. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IADVSignedDeviceIdentity); + + /** ADVSignedDeviceIdentity details. */ + public details: Uint8Array; + + /** ADVSignedDeviceIdentity accountSignatureKey. */ + public accountSignatureKey: Uint8Array; + + /** ADVSignedDeviceIdentity accountSignature. */ + public accountSignature: Uint8Array; + + /** ADVSignedDeviceIdentity deviceSignature. */ + public deviceSignature: Uint8Array; + + /** + * Creates a new ADVSignedDeviceIdentity instance using the specified properties. + * @param [properties] Properties to set + * @returns ADVSignedDeviceIdentity instance + */ + public static create(properties?: proto.IADVSignedDeviceIdentity): proto.ADVSignedDeviceIdentity; + + /** + * Encodes the specified ADVSignedDeviceIdentity message. Does not implicitly {@link proto.ADVSignedDeviceIdentity.verify|verify} messages. + * @param message ADVSignedDeviceIdentity message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IADVSignedDeviceIdentity, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ADVSignedDeviceIdentity message, length delimited. Does not implicitly {@link proto.ADVSignedDeviceIdentity.verify|verify} messages. + * @param message ADVSignedDeviceIdentity message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IADVSignedDeviceIdentity, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ADVSignedDeviceIdentity message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ADVSignedDeviceIdentity + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.ADVSignedDeviceIdentity; + + /** + * Decodes a ADVSignedDeviceIdentity message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ADVSignedDeviceIdentity + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.ADVSignedDeviceIdentity; + + /** + * Verifies a ADVSignedDeviceIdentity message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ADVSignedDeviceIdentity message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ADVSignedDeviceIdentity + */ + public static fromObject(object: { [k: string]: any }): proto.ADVSignedDeviceIdentity; + + /** + * Creates a plain object from a ADVSignedDeviceIdentity message. Also converts values to other types if specified. + * @param message ADVSignedDeviceIdentity + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.ADVSignedDeviceIdentity, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ADVSignedDeviceIdentity to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ADVDeviceIdentity. */ + interface IADVDeviceIdentity { + + /** ADVDeviceIdentity rawId */ + rawId?: (number|null); + + /** ADVDeviceIdentity timestamp */ + timestamp?: (number|Long|null); + + /** ADVDeviceIdentity keyIndex */ + keyIndex?: (number|null); + } + + /** Represents a ADVDeviceIdentity. */ + class ADVDeviceIdentity implements IADVDeviceIdentity { + + /** + * Constructs a new ADVDeviceIdentity. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IADVDeviceIdentity); + + /** ADVDeviceIdentity rawId. */ + public rawId: number; + + /** ADVDeviceIdentity timestamp. */ + public timestamp: (number|Long); + + /** ADVDeviceIdentity keyIndex. */ + public keyIndex: number; + + /** + * Creates a new ADVDeviceIdentity instance using the specified properties. + * @param [properties] Properties to set + * @returns ADVDeviceIdentity instance + */ + public static create(properties?: proto.IADVDeviceIdentity): proto.ADVDeviceIdentity; + + /** + * Encodes the specified ADVDeviceIdentity message. Does not implicitly {@link proto.ADVDeviceIdentity.verify|verify} messages. + * @param message ADVDeviceIdentity message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IADVDeviceIdentity, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ADVDeviceIdentity message, length delimited. Does not implicitly {@link proto.ADVDeviceIdentity.verify|verify} messages. + * @param message ADVDeviceIdentity message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IADVDeviceIdentity, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ADVDeviceIdentity message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ADVDeviceIdentity + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.ADVDeviceIdentity; + + /** + * Decodes a ADVDeviceIdentity message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ADVDeviceIdentity + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.ADVDeviceIdentity; + + /** + * Verifies a ADVDeviceIdentity message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ADVDeviceIdentity message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ADVDeviceIdentity + */ + public static fromObject(object: { [k: string]: any }): proto.ADVDeviceIdentity; + + /** + * Creates a plain object from a ADVDeviceIdentity message. Also converts values to other types if specified. + * @param message ADVDeviceIdentity + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.ADVDeviceIdentity, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ADVDeviceIdentity to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ADVSignedKeyIndexList. */ + interface IADVSignedKeyIndexList { + + /** ADVSignedKeyIndexList details */ + details?: (Uint8Array|null); + + /** ADVSignedKeyIndexList accountSignature */ + accountSignature?: (Uint8Array|null); + } + + /** Represents a ADVSignedKeyIndexList. */ + class ADVSignedKeyIndexList implements IADVSignedKeyIndexList { + + /** + * Constructs a new ADVSignedKeyIndexList. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IADVSignedKeyIndexList); + + /** ADVSignedKeyIndexList details. */ + public details: Uint8Array; + + /** ADVSignedKeyIndexList accountSignature. */ + public accountSignature: Uint8Array; + + /** + * Creates a new ADVSignedKeyIndexList instance using the specified properties. + * @param [properties] Properties to set + * @returns ADVSignedKeyIndexList instance + */ + public static create(properties?: proto.IADVSignedKeyIndexList): proto.ADVSignedKeyIndexList; + + /** + * Encodes the specified ADVSignedKeyIndexList message. Does not implicitly {@link proto.ADVSignedKeyIndexList.verify|verify} messages. + * @param message ADVSignedKeyIndexList message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IADVSignedKeyIndexList, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ADVSignedKeyIndexList message, length delimited. Does not implicitly {@link proto.ADVSignedKeyIndexList.verify|verify} messages. + * @param message ADVSignedKeyIndexList message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IADVSignedKeyIndexList, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ADVSignedKeyIndexList message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ADVSignedKeyIndexList + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.ADVSignedKeyIndexList; + + /** + * Decodes a ADVSignedKeyIndexList message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ADVSignedKeyIndexList + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.ADVSignedKeyIndexList; + + /** + * Verifies a ADVSignedKeyIndexList message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ADVSignedKeyIndexList message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ADVSignedKeyIndexList + */ + public static fromObject(object: { [k: string]: any }): proto.ADVSignedKeyIndexList; + + /** + * Creates a plain object from a ADVSignedKeyIndexList message. Also converts values to other types if specified. + * @param message ADVSignedKeyIndexList + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.ADVSignedKeyIndexList, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ADVSignedKeyIndexList to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ADVKeyIndexList. */ + interface IADVKeyIndexList { + + /** ADVKeyIndexList rawId */ + rawId?: (number|null); + + /** ADVKeyIndexList timestamp */ + timestamp?: (number|Long|null); + + /** ADVKeyIndexList currentIndex */ + currentIndex?: (number|null); + + /** ADVKeyIndexList validIndexes */ + validIndexes?: (number[]|null); + } + + /** Represents a ADVKeyIndexList. */ + class ADVKeyIndexList implements IADVKeyIndexList { + + /** + * Constructs a new ADVKeyIndexList. + * @param [properties] Properties to set + */ + constructor(properties?: proto.IADVKeyIndexList); + + /** ADVKeyIndexList rawId. */ + public rawId: number; + + /** ADVKeyIndexList timestamp. */ + public timestamp: (number|Long); + + /** ADVKeyIndexList currentIndex. */ + public currentIndex: number; + + /** ADVKeyIndexList validIndexes. */ + public validIndexes: number[]; + + /** + * Creates a new ADVKeyIndexList instance using the specified properties. + * @param [properties] Properties to set + * @returns ADVKeyIndexList instance + */ + public static create(properties?: proto.IADVKeyIndexList): proto.ADVKeyIndexList; + + /** + * Encodes the specified ADVKeyIndexList message. Does not implicitly {@link proto.ADVKeyIndexList.verify|verify} messages. + * @param message ADVKeyIndexList message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: proto.IADVKeyIndexList, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ADVKeyIndexList message, length delimited. Does not implicitly {@link proto.ADVKeyIndexList.verify|verify} messages. + * @param message ADVKeyIndexList message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: proto.IADVKeyIndexList, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ADVKeyIndexList message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ADVKeyIndexList + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.ADVKeyIndexList; + + /** + * Decodes a ADVKeyIndexList message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ADVKeyIndexList + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.ADVKeyIndexList; + + /** + * Verifies a ADVKeyIndexList message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ADVKeyIndexList message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ADVKeyIndexList + */ + public static fromObject(object: { [k: string]: any }): proto.ADVKeyIndexList; + + /** + * Creates a plain object from a ADVKeyIndexList message. Also converts values to other types if specified. + * @param message ADVKeyIndexList + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: proto.ADVKeyIndexList, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ADVKeyIndexList to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a MessageKey. */ + interface IMessageKey { + + /** MessageKey remoteJid */ + remoteJid?: (string|null); + + /** MessageKey fromMe */ + fromMe?: (boolean|null); + + /** MessageKey id */ id?: (string|null); - /** PaymentBackground fileLength */ - fileLength?: (number|Long|null); - - /** PaymentBackground width */ - width?: (number|null); - - /** PaymentBackground height */ - height?: (number|null); - - /** PaymentBackground mimetype */ - mimetype?: (string|null); - - /** PaymentBackground placeholderArgb */ - placeholderArgb?: (number|null); - - /** PaymentBackground textArgb */ - textArgb?: (number|null); - - /** PaymentBackground subtextArgb */ - subtextArgb?: (number|null); + /** MessageKey participant */ + participant?: (string|null); } - /** Represents a PaymentBackground. */ - class PaymentBackground implements IPaymentBackground { + /** Represents a MessageKey. */ + class MessageKey implements IMessageKey { /** - * Constructs a new PaymentBackground. + * Constructs a new MessageKey. * @param [properties] Properties to set */ - constructor(properties?: proto.IPaymentBackground); + constructor(properties?: proto.IMessageKey); - /** PaymentBackground id. */ + /** MessageKey remoteJid. */ + public remoteJid: string; + + /** MessageKey fromMe. */ + public fromMe: boolean; + + /** MessageKey id. */ public id: string; - /** PaymentBackground fileLength. */ - public fileLength: (number|Long); - - /** PaymentBackground width. */ - public width: number; - - /** PaymentBackground height. */ - public height: number; - - /** PaymentBackground mimetype. */ - public mimetype: string; - - /** PaymentBackground placeholderArgb. */ - public placeholderArgb: number; - - /** PaymentBackground textArgb. */ - public textArgb: number; - - /** PaymentBackground subtextArgb. */ - public subtextArgb: number; + /** MessageKey participant. */ + public participant: string; /** - * Creates a new PaymentBackground instance using the specified properties. + * Creates a new MessageKey instance using the specified properties. * @param [properties] Properties to set - * @returns PaymentBackground instance + * @returns MessageKey instance */ - public static create(properties?: proto.IPaymentBackground): proto.PaymentBackground; + public static create(properties?: proto.IMessageKey): proto.MessageKey; /** - * Encodes the specified PaymentBackground message. Does not implicitly {@link proto.PaymentBackground.verify|verify} messages. - * @param message PaymentBackground message or plain object to encode + * Encodes the specified MessageKey message. Does not implicitly {@link proto.MessageKey.verify|verify} messages. + * @param message MessageKey message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encode(message: proto.IPaymentBackground, writer?: $protobuf.Writer): $protobuf.Writer; + public static encode(message: proto.IMessageKey, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Encodes the specified PaymentBackground message, length delimited. Does not implicitly {@link proto.PaymentBackground.verify|verify} messages. - * @param message PaymentBackground message or plain object to encode + * Encodes the specified MessageKey message, length delimited. Does not implicitly {@link proto.MessageKey.verify|verify} messages. + * @param message MessageKey message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encodeDelimited(message: proto.IPaymentBackground, writer?: $protobuf.Writer): $protobuf.Writer; + public static encodeDelimited(message: proto.IMessageKey, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Decodes a PaymentBackground message from the specified reader or buffer. + * Decodes a MessageKey message from the specified reader or buffer. * @param reader Reader or buffer to decode from * @param [length] Message length if known beforehand - * @returns PaymentBackground + * @returns MessageKey * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.PaymentBackground; + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.MessageKey; /** - * Decodes a PaymentBackground message from the specified reader or buffer, length delimited. + * Decodes a MessageKey message from the specified reader or buffer, length delimited. * @param reader Reader or buffer to decode from - * @returns PaymentBackground + * @returns MessageKey * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.PaymentBackground; + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.MessageKey; /** - * Verifies a PaymentBackground message. + * Verifies a MessageKey message. * @param message Plain object to verify * @returns `null` if valid, otherwise the reason why it is not */ public static verify(message: { [k: string]: any }): (string|null); /** - * Creates a PaymentBackground message from a plain object. Also converts values to their respective internal types. + * Creates a MessageKey message from a plain object. Also converts values to their respective internal types. * @param object Plain object - * @returns PaymentBackground + * @returns MessageKey */ - public static fromObject(object: { [k: string]: any }): proto.PaymentBackground; + public static fromObject(object: { [k: string]: any }): proto.MessageKey; /** - * Creates a plain object from a PaymentBackground message. Also converts values to other types if specified. - * @param message PaymentBackground + * Creates a plain object from a MessageKey message. Also converts values to other types if specified. + * @param message MessageKey * @param [options] Conversion options * @returns Plain object */ - public static toObject(message: proto.PaymentBackground, options?: $protobuf.IConversionOptions): { [k: string]: any }; + public static toObject(message: proto.MessageKey, options?: $protobuf.IConversionOptions): { [k: string]: any }; /** - * Converts this PaymentBackground to JSON. - * @returns JSON object - */ - public toJSON(): { [k: string]: any }; - } - - /** Properties of a Money. */ - interface IMoney { - - /** Money value */ - value?: (number|Long|null); - - /** Money offset */ - offset?: (number|null); - - /** Money currencyCode */ - currencyCode?: (string|null); - } - - /** Represents a Money. */ - class Money implements IMoney { - - /** - * Constructs a new Money. - * @param [properties] Properties to set - */ - constructor(properties?: proto.IMoney); - - /** Money value. */ - public value: (number|Long); - - /** Money offset. */ - public offset: number; - - /** Money currencyCode. */ - public currencyCode: string; - - /** - * Creates a new Money instance using the specified properties. - * @param [properties] Properties to set - * @returns Money instance - */ - public static create(properties?: proto.IMoney): proto.Money; - - /** - * Encodes the specified Money message. Does not implicitly {@link proto.Money.verify|verify} messages. - * @param message Money message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encode(message: proto.IMoney, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Encodes the specified Money message, length delimited. Does not implicitly {@link proto.Money.verify|verify} messages. - * @param message Money message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encodeDelimited(message: proto.IMoney, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Decodes a Money message from the specified reader or buffer. - * @param reader Reader or buffer to decode from - * @param [length] Message length if known beforehand - * @returns Money - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.Money; - - /** - * Decodes a Money message from the specified reader or buffer, length delimited. - * @param reader Reader or buffer to decode from - * @returns Money - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.Money; - - /** - * Verifies a Money message. - * @param message Plain object to verify - * @returns `null` if valid, otherwise the reason why it is not - */ - public static verify(message: { [k: string]: any }): (string|null); - - /** - * Creates a Money message from a plain object. Also converts values to their respective internal types. - * @param object Plain object - * @returns Money - */ - public static fromObject(object: { [k: string]: any }): proto.Money; - - /** - * Creates a plain object from a Money message. Also converts values to other types if specified. - * @param message Money - * @param [options] Conversion options - * @returns Plain object - */ - public static toObject(message: proto.Money, options?: $protobuf.IConversionOptions): { [k: string]: any }; - - /** - * Converts this Money to JSON. - * @returns JSON object - */ - public toJSON(): { [k: string]: any }; - } - - /** Properties of a HydratedQuickReplyButton. */ - interface IHydratedQuickReplyButton { - - /** HydratedQuickReplyButton displayText */ - displayText?: (string|null); - - /** HydratedQuickReplyButton id */ - id?: (string|null); - } - - /** Represents a HydratedQuickReplyButton. */ - class HydratedQuickReplyButton implements IHydratedQuickReplyButton { - - /** - * Constructs a new HydratedQuickReplyButton. - * @param [properties] Properties to set - */ - constructor(properties?: proto.IHydratedQuickReplyButton); - - /** HydratedQuickReplyButton displayText. */ - public displayText: string; - - /** HydratedQuickReplyButton id. */ - public id: string; - - /** - * Creates a new HydratedQuickReplyButton instance using the specified properties. - * @param [properties] Properties to set - * @returns HydratedQuickReplyButton instance - */ - public static create(properties?: proto.IHydratedQuickReplyButton): proto.HydratedQuickReplyButton; - - /** - * Encodes the specified HydratedQuickReplyButton message. Does not implicitly {@link proto.HydratedQuickReplyButton.verify|verify} messages. - * @param message HydratedQuickReplyButton message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encode(message: proto.IHydratedQuickReplyButton, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Encodes the specified HydratedQuickReplyButton message, length delimited. Does not implicitly {@link proto.HydratedQuickReplyButton.verify|verify} messages. - * @param message HydratedQuickReplyButton message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encodeDelimited(message: proto.IHydratedQuickReplyButton, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Decodes a HydratedQuickReplyButton message from the specified reader or buffer. - * @param reader Reader or buffer to decode from - * @param [length] Message length if known beforehand - * @returns HydratedQuickReplyButton - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.HydratedQuickReplyButton; - - /** - * Decodes a HydratedQuickReplyButton message from the specified reader or buffer, length delimited. - * @param reader Reader or buffer to decode from - * @returns HydratedQuickReplyButton - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.HydratedQuickReplyButton; - - /** - * Verifies a HydratedQuickReplyButton message. - * @param message Plain object to verify - * @returns `null` if valid, otherwise the reason why it is not - */ - public static verify(message: { [k: string]: any }): (string|null); - - /** - * Creates a HydratedQuickReplyButton message from a plain object. Also converts values to their respective internal types. - * @param object Plain object - * @returns HydratedQuickReplyButton - */ - public static fromObject(object: { [k: string]: any }): proto.HydratedQuickReplyButton; - - /** - * Creates a plain object from a HydratedQuickReplyButton message. Also converts values to other types if specified. - * @param message HydratedQuickReplyButton - * @param [options] Conversion options - * @returns Plain object - */ - public static toObject(message: proto.HydratedQuickReplyButton, options?: $protobuf.IConversionOptions): { [k: string]: any }; - - /** - * Converts this HydratedQuickReplyButton to JSON. - * @returns JSON object - */ - public toJSON(): { [k: string]: any }; - } - - /** Properties of a HydratedURLButton. */ - interface IHydratedURLButton { - - /** HydratedURLButton displayText */ - displayText?: (string|null); - - /** HydratedURLButton url */ - url?: (string|null); - } - - /** Represents a HydratedURLButton. */ - class HydratedURLButton implements IHydratedURLButton { - - /** - * Constructs a new HydratedURLButton. - * @param [properties] Properties to set - */ - constructor(properties?: proto.IHydratedURLButton); - - /** HydratedURLButton displayText. */ - public displayText: string; - - /** HydratedURLButton url. */ - public url: string; - - /** - * Creates a new HydratedURLButton instance using the specified properties. - * @param [properties] Properties to set - * @returns HydratedURLButton instance - */ - public static create(properties?: proto.IHydratedURLButton): proto.HydratedURLButton; - - /** - * Encodes the specified HydratedURLButton message. Does not implicitly {@link proto.HydratedURLButton.verify|verify} messages. - * @param message HydratedURLButton message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encode(message: proto.IHydratedURLButton, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Encodes the specified HydratedURLButton message, length delimited. Does not implicitly {@link proto.HydratedURLButton.verify|verify} messages. - * @param message HydratedURLButton message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encodeDelimited(message: proto.IHydratedURLButton, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Decodes a HydratedURLButton message from the specified reader or buffer. - * @param reader Reader or buffer to decode from - * @param [length] Message length if known beforehand - * @returns HydratedURLButton - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.HydratedURLButton; - - /** - * Decodes a HydratedURLButton message from the specified reader or buffer, length delimited. - * @param reader Reader or buffer to decode from - * @returns HydratedURLButton - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.HydratedURLButton; - - /** - * Verifies a HydratedURLButton message. - * @param message Plain object to verify - * @returns `null` if valid, otherwise the reason why it is not - */ - public static verify(message: { [k: string]: any }): (string|null); - - /** - * Creates a HydratedURLButton message from a plain object. Also converts values to their respective internal types. - * @param object Plain object - * @returns HydratedURLButton - */ - public static fromObject(object: { [k: string]: any }): proto.HydratedURLButton; - - /** - * Creates a plain object from a HydratedURLButton message. Also converts values to other types if specified. - * @param message HydratedURLButton - * @param [options] Conversion options - * @returns Plain object - */ - public static toObject(message: proto.HydratedURLButton, options?: $protobuf.IConversionOptions): { [k: string]: any }; - - /** - * Converts this HydratedURLButton to JSON. - * @returns JSON object - */ - public toJSON(): { [k: string]: any }; - } - - /** Properties of a HydratedCallButton. */ - interface IHydratedCallButton { - - /** HydratedCallButton displayText */ - displayText?: (string|null); - - /** HydratedCallButton phoneNumber */ - phoneNumber?: (string|null); - } - - /** Represents a HydratedCallButton. */ - class HydratedCallButton implements IHydratedCallButton { - - /** - * Constructs a new HydratedCallButton. - * @param [properties] Properties to set - */ - constructor(properties?: proto.IHydratedCallButton); - - /** HydratedCallButton displayText. */ - public displayText: string; - - /** HydratedCallButton phoneNumber. */ - public phoneNumber: string; - - /** - * Creates a new HydratedCallButton instance using the specified properties. - * @param [properties] Properties to set - * @returns HydratedCallButton instance - */ - public static create(properties?: proto.IHydratedCallButton): proto.HydratedCallButton; - - /** - * Encodes the specified HydratedCallButton message. Does not implicitly {@link proto.HydratedCallButton.verify|verify} messages. - * @param message HydratedCallButton message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encode(message: proto.IHydratedCallButton, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Encodes the specified HydratedCallButton message, length delimited. Does not implicitly {@link proto.HydratedCallButton.verify|verify} messages. - * @param message HydratedCallButton message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encodeDelimited(message: proto.IHydratedCallButton, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Decodes a HydratedCallButton message from the specified reader or buffer. - * @param reader Reader or buffer to decode from - * @param [length] Message length if known beforehand - * @returns HydratedCallButton - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.HydratedCallButton; - - /** - * Decodes a HydratedCallButton message from the specified reader or buffer, length delimited. - * @param reader Reader or buffer to decode from - * @returns HydratedCallButton - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.HydratedCallButton; - - /** - * Verifies a HydratedCallButton message. - * @param message Plain object to verify - * @returns `null` if valid, otherwise the reason why it is not - */ - public static verify(message: { [k: string]: any }): (string|null); - - /** - * Creates a HydratedCallButton message from a plain object. Also converts values to their respective internal types. - * @param object Plain object - * @returns HydratedCallButton - */ - public static fromObject(object: { [k: string]: any }): proto.HydratedCallButton; - - /** - * Creates a plain object from a HydratedCallButton message. Also converts values to other types if specified. - * @param message HydratedCallButton - * @param [options] Conversion options - * @returns Plain object - */ - public static toObject(message: proto.HydratedCallButton, options?: $protobuf.IConversionOptions): { [k: string]: any }; - - /** - * Converts this HydratedCallButton to JSON. - * @returns JSON object - */ - public toJSON(): { [k: string]: any }; - } - - /** Properties of a HydratedTemplateButton. */ - interface IHydratedTemplateButton { - - /** HydratedTemplateButton index */ - index?: (number|null); - - /** HydratedTemplateButton quickReplyButton */ - quickReplyButton?: (proto.IHydratedQuickReplyButton|null); - - /** HydratedTemplateButton urlButton */ - urlButton?: (proto.IHydratedURLButton|null); - - /** HydratedTemplateButton callButton */ - callButton?: (proto.IHydratedCallButton|null); - } - - /** Represents a HydratedTemplateButton. */ - class HydratedTemplateButton implements IHydratedTemplateButton { - - /** - * Constructs a new HydratedTemplateButton. - * @param [properties] Properties to set - */ - constructor(properties?: proto.IHydratedTemplateButton); - - /** HydratedTemplateButton index. */ - public index: number; - - /** HydratedTemplateButton quickReplyButton. */ - public quickReplyButton?: (proto.IHydratedQuickReplyButton|null); - - /** HydratedTemplateButton urlButton. */ - public urlButton?: (proto.IHydratedURLButton|null); - - /** HydratedTemplateButton callButton. */ - public callButton?: (proto.IHydratedCallButton|null); - - /** HydratedTemplateButton hydratedButton. */ - public hydratedButton?: ("quickReplyButton"|"urlButton"|"callButton"); - - /** - * Creates a new HydratedTemplateButton instance using the specified properties. - * @param [properties] Properties to set - * @returns HydratedTemplateButton instance - */ - public static create(properties?: proto.IHydratedTemplateButton): proto.HydratedTemplateButton; - - /** - * Encodes the specified HydratedTemplateButton message. Does not implicitly {@link proto.HydratedTemplateButton.verify|verify} messages. - * @param message HydratedTemplateButton message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encode(message: proto.IHydratedTemplateButton, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Encodes the specified HydratedTemplateButton message, length delimited. Does not implicitly {@link proto.HydratedTemplateButton.verify|verify} messages. - * @param message HydratedTemplateButton message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encodeDelimited(message: proto.IHydratedTemplateButton, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Decodes a HydratedTemplateButton message from the specified reader or buffer. - * @param reader Reader or buffer to decode from - * @param [length] Message length if known beforehand - * @returns HydratedTemplateButton - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.HydratedTemplateButton; - - /** - * Decodes a HydratedTemplateButton message from the specified reader or buffer, length delimited. - * @param reader Reader or buffer to decode from - * @returns HydratedTemplateButton - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.HydratedTemplateButton; - - /** - * Verifies a HydratedTemplateButton message. - * @param message Plain object to verify - * @returns `null` if valid, otherwise the reason why it is not - */ - public static verify(message: { [k: string]: any }): (string|null); - - /** - * Creates a HydratedTemplateButton message from a plain object. Also converts values to their respective internal types. - * @param object Plain object - * @returns HydratedTemplateButton - */ - public static fromObject(object: { [k: string]: any }): proto.HydratedTemplateButton; - - /** - * Creates a plain object from a HydratedTemplateButton message. Also converts values to other types if specified. - * @param message HydratedTemplateButton - * @param [options] Conversion options - * @returns Plain object - */ - public static toObject(message: proto.HydratedTemplateButton, options?: $protobuf.IConversionOptions): { [k: string]: any }; - - /** - * Converts this HydratedTemplateButton to JSON. - * @returns JSON object - */ - public toJSON(): { [k: string]: any }; - } - - /** Properties of a UserReceipt. */ - interface IUserReceipt { - - /** UserReceipt userJid */ - userJid: string; - - /** UserReceipt receiptTimestamp */ - receiptTimestamp?: (number|Long|null); - - /** UserReceipt readTimestamp */ - readTimestamp?: (number|Long|null); - - /** UserReceipt playedTimestamp */ - playedTimestamp?: (number|Long|null); - - /** UserReceipt pendingDeviceJid */ - pendingDeviceJid?: (string[]|null); - - /** UserReceipt deliveredDeviceJid */ - deliveredDeviceJid?: (string[]|null); - } - - /** Represents a UserReceipt. */ - class UserReceipt implements IUserReceipt { - - /** - * Constructs a new UserReceipt. - * @param [properties] Properties to set - */ - constructor(properties?: proto.IUserReceipt); - - /** UserReceipt userJid. */ - public userJid: string; - - /** UserReceipt receiptTimestamp. */ - public receiptTimestamp: (number|Long); - - /** UserReceipt readTimestamp. */ - public readTimestamp: (number|Long); - - /** UserReceipt playedTimestamp. */ - public playedTimestamp: (number|Long); - - /** UserReceipt pendingDeviceJid. */ - public pendingDeviceJid: string[]; - - /** UserReceipt deliveredDeviceJid. */ - public deliveredDeviceJid: string[]; - - /** - * Creates a new UserReceipt instance using the specified properties. - * @param [properties] Properties to set - * @returns UserReceipt instance - */ - public static create(properties?: proto.IUserReceipt): proto.UserReceipt; - - /** - * Encodes the specified UserReceipt message. Does not implicitly {@link proto.UserReceipt.verify|verify} messages. - * @param message UserReceipt message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encode(message: proto.IUserReceipt, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Encodes the specified UserReceipt message, length delimited. Does not implicitly {@link proto.UserReceipt.verify|verify} messages. - * @param message UserReceipt message or plain object to encode - * @param [writer] Writer to encode to - * @returns Writer - */ - public static encodeDelimited(message: proto.IUserReceipt, writer?: $protobuf.Writer): $protobuf.Writer; - - /** - * Decodes a UserReceipt message from the specified reader or buffer. - * @param reader Reader or buffer to decode from - * @param [length] Message length if known beforehand - * @returns UserReceipt - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): proto.UserReceipt; - - /** - * Decodes a UserReceipt message from the specified reader or buffer, length delimited. - * @param reader Reader or buffer to decode from - * @returns UserReceipt - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): proto.UserReceipt; - - /** - * Verifies a UserReceipt message. - * @param message Plain object to verify - * @returns `null` if valid, otherwise the reason why it is not - */ - public static verify(message: { [k: string]: any }): (string|null); - - /** - * Creates a UserReceipt message from a plain object. Also converts values to their respective internal types. - * @param object Plain object - * @returns UserReceipt - */ - public static fromObject(object: { [k: string]: any }): proto.UserReceipt; - - /** - * Creates a plain object from a UserReceipt message. Also converts values to other types if specified. - * @param message UserReceipt - * @param [options] Conversion options - * @returns Plain object - */ - public static toObject(message: proto.UserReceipt, options?: $protobuf.IConversionOptions): { [k: string]: any }; - - /** - * Converts this UserReceipt to JSON. + * Converts this MessageKey to JSON. * @returns JSON object */ public toJSON(): { [k: string]: any }; @@ -10913,9 +17715,6 @@ export namespace proto { /** WebFeatures mdForceUpgrade */ mdForceUpgrade?: (proto.WebFeatures.WebFeaturesFlag|null); - - /** WebFeatures disappearingMode */ - disappearingMode?: (proto.WebFeatures.WebFeaturesFlag|null); } /** Represents a WebFeatures. */ @@ -11053,9 +17852,6 @@ export namespace proto { /** WebFeatures mdForceUpgrade. */ public mdForceUpgrade: proto.WebFeatures.WebFeaturesFlag; - /** WebFeatures disappearingMode. */ - public disappearingMode: proto.WebFeatures.WebFeaturesFlag; - /** * Creates a new WebFeatures instance using the specified properties. * @param [properties] Properties to set @@ -11666,9 +18462,6 @@ export namespace proto { /** WebMessageInfo photoChange */ photoChange?: (proto.IPhotoChange|null); - - /** WebMessageInfo userReceipt */ - userReceipt?: (proto.IUserReceipt[]|null); } /** Represents a WebMessageInfo. */ @@ -11770,9 +18563,6 @@ export namespace proto { /** WebMessageInfo photoChange. */ public photoChange?: (proto.IPhotoChange|null); - /** WebMessageInfo userReceipt. */ - public userReceipt: proto.IUserReceipt[]; - /** * Creates a new WebMessageInfo instance using the specified properties. * @param [properties] Properties to set @@ -11987,8 +18777,7 @@ export namespace proto { BIZ_PRIVACY_MODE_INIT_FB = 126, BIZ_PRIVACY_MODE_INIT_BSP = 127, BIZ_PRIVACY_MODE_TO_FB = 128, - BIZ_PRIVACY_MODE_TO_BSP = 129, - DISAPPEARING_MODE = 130 + BIZ_PRIVACY_MODE_TO_BSP = 129 } /** WebMessageInfoBizPrivacyStatus enum. */ diff --git a/WAMessage/index.js b/WAProto/index.js similarity index 65% rename from WAMessage/index.js rename to WAProto/index.js index 5f73b72..c2604c7 100644 --- a/WAMessage/index.js +++ b/WAProto/index.js @@ -18,27 +18,28 @@ $root.proto = (function() { */ var proto = {}; - proto.MessageKey = (function() { + proto.AppVersion = (function() { /** - * Properties of a MessageKey. + * Properties of an AppVersion. * @memberof proto - * @interface IMessageKey - * @property {string|null} [remoteJid] MessageKey remoteJid - * @property {boolean|null} [fromMe] MessageKey fromMe - * @property {string|null} [id] MessageKey id - * @property {string|null} [participant] MessageKey participant + * @interface IAppVersion + * @property {number|null} [primary] AppVersion primary + * @property {number|null} [secondary] AppVersion secondary + * @property {number|null} [tertiary] AppVersion tertiary + * @property {number|null} [quaternary] AppVersion quaternary + * @property {number|null} [quinary] AppVersion quinary */ /** - * Constructs a new MessageKey. + * Constructs a new AppVersion. * @memberof proto - * @classdesc Represents a MessageKey. - * @implements IMessageKey + * @classdesc Represents an AppVersion. + * @implements IAppVersion * @constructor - * @param {proto.IMessageKey=} [properties] Properties to set + * @param {proto.IAppVersion=} [properties] Properties to set */ - function MessageKey(properties) { + function AppVersion(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -46,114 +47,127 @@ $root.proto = (function() { } /** - * MessageKey remoteJid. - * @member {string} remoteJid - * @memberof proto.MessageKey + * AppVersion primary. + * @member {number} primary + * @memberof proto.AppVersion * @instance */ - MessageKey.prototype.remoteJid = ""; + AppVersion.prototype.primary = 0; /** - * MessageKey fromMe. - * @member {boolean} fromMe - * @memberof proto.MessageKey + * AppVersion secondary. + * @member {number} secondary + * @memberof proto.AppVersion * @instance */ - MessageKey.prototype.fromMe = false; + AppVersion.prototype.secondary = 0; /** - * MessageKey id. - * @member {string} id - * @memberof proto.MessageKey + * AppVersion tertiary. + * @member {number} tertiary + * @memberof proto.AppVersion * @instance */ - MessageKey.prototype.id = ""; + AppVersion.prototype.tertiary = 0; /** - * MessageKey participant. - * @member {string} participant - * @memberof proto.MessageKey + * AppVersion quaternary. + * @member {number} quaternary + * @memberof proto.AppVersion * @instance */ - MessageKey.prototype.participant = ""; + AppVersion.prototype.quaternary = 0; /** - * Creates a new MessageKey instance using the specified properties. + * AppVersion quinary. + * @member {number} quinary + * @memberof proto.AppVersion + * @instance + */ + AppVersion.prototype.quinary = 0; + + /** + * Creates a new AppVersion instance using the specified properties. * @function create - * @memberof proto.MessageKey + * @memberof proto.AppVersion * @static - * @param {proto.IMessageKey=} [properties] Properties to set - * @returns {proto.MessageKey} MessageKey instance + * @param {proto.IAppVersion=} [properties] Properties to set + * @returns {proto.AppVersion} AppVersion instance */ - MessageKey.create = function create(properties) { - return new MessageKey(properties); + AppVersion.create = function create(properties) { + return new AppVersion(properties); }; /** - * Encodes the specified MessageKey message. Does not implicitly {@link proto.MessageKey.verify|verify} messages. + * Encodes the specified AppVersion message. Does not implicitly {@link proto.AppVersion.verify|verify} messages. * @function encode - * @memberof proto.MessageKey + * @memberof proto.AppVersion * @static - * @param {proto.IMessageKey} message MessageKey message or plain object to encode + * @param {proto.IAppVersion} message AppVersion message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - MessageKey.encode = function encode(message, writer) { + AppVersion.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.remoteJid != null && Object.hasOwnProperty.call(message, "remoteJid")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.remoteJid); - if (message.fromMe != null && Object.hasOwnProperty.call(message, "fromMe")) - writer.uint32(/* id 2, wireType 0 =*/16).bool(message.fromMe); - if (message.id != null && Object.hasOwnProperty.call(message, "id")) - writer.uint32(/* id 3, wireType 2 =*/26).string(message.id); - if (message.participant != null && Object.hasOwnProperty.call(message, "participant")) - writer.uint32(/* id 4, wireType 2 =*/34).string(message.participant); + if (message.primary != null && Object.hasOwnProperty.call(message, "primary")) + writer.uint32(/* id 1, wireType 0 =*/8).uint32(message.primary); + if (message.secondary != null && Object.hasOwnProperty.call(message, "secondary")) + writer.uint32(/* id 2, wireType 0 =*/16).uint32(message.secondary); + if (message.tertiary != null && Object.hasOwnProperty.call(message, "tertiary")) + writer.uint32(/* id 3, wireType 0 =*/24).uint32(message.tertiary); + if (message.quaternary != null && Object.hasOwnProperty.call(message, "quaternary")) + writer.uint32(/* id 4, wireType 0 =*/32).uint32(message.quaternary); + if (message.quinary != null && Object.hasOwnProperty.call(message, "quinary")) + writer.uint32(/* id 5, wireType 0 =*/40).uint32(message.quinary); return writer; }; /** - * Encodes the specified MessageKey message, length delimited. Does not implicitly {@link proto.MessageKey.verify|verify} messages. + * Encodes the specified AppVersion message, length delimited. Does not implicitly {@link proto.AppVersion.verify|verify} messages. * @function encodeDelimited - * @memberof proto.MessageKey + * @memberof proto.AppVersion * @static - * @param {proto.IMessageKey} message MessageKey message or plain object to encode + * @param {proto.IAppVersion} message AppVersion message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - MessageKey.encodeDelimited = function encodeDelimited(message, writer) { + AppVersion.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a MessageKey message from the specified reader or buffer. + * Decodes an AppVersion message from the specified reader or buffer. * @function decode - * @memberof proto.MessageKey + * @memberof proto.AppVersion * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {proto.MessageKey} MessageKey + * @returns {proto.AppVersion} AppVersion * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - MessageKey.decode = function decode(reader, length) { + AppVersion.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.MessageKey(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.AppVersion(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.remoteJid = reader.string(); + message.primary = reader.uint32(); break; case 2: - message.fromMe = reader.bool(); + message.secondary = reader.uint32(); break; case 3: - message.id = reader.string(); + message.tertiary = reader.uint32(); break; case 4: - message.participant = reader.string(); + message.quaternary = reader.uint32(); + break; + case 5: + message.quinary = reader.uint32(); break; default: reader.skipType(tag & 7); @@ -164,112 +178,19425 @@ $root.proto = (function() { }; /** - * Decodes a MessageKey message from the specified reader or buffer, length delimited. + * Decodes an AppVersion message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof proto.MessageKey + * @memberof proto.AppVersion * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {proto.MessageKey} MessageKey + * @returns {proto.AppVersion} AppVersion * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - MessageKey.decodeDelimited = function decodeDelimited(reader) { + AppVersion.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a MessageKey message. + * Verifies an AppVersion message. * @function verify - * @memberof proto.MessageKey + * @memberof proto.AppVersion * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - MessageKey.verify = function verify(message) { + AppVersion.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.remoteJid != null && message.hasOwnProperty("remoteJid")) - if (!$util.isString(message.remoteJid)) - return "remoteJid: string expected"; - if (message.fromMe != null && message.hasOwnProperty("fromMe")) - if (typeof message.fromMe !== "boolean") - return "fromMe: boolean expected"; - if (message.id != null && message.hasOwnProperty("id")) - if (!$util.isString(message.id)) - return "id: string expected"; - if (message.participant != null && message.hasOwnProperty("participant")) - if (!$util.isString(message.participant)) - return "participant: string expected"; + if (message.primary != null && message.hasOwnProperty("primary")) + if (!$util.isInteger(message.primary)) + return "primary: integer expected"; + if (message.secondary != null && message.hasOwnProperty("secondary")) + if (!$util.isInteger(message.secondary)) + return "secondary: integer expected"; + if (message.tertiary != null && message.hasOwnProperty("tertiary")) + if (!$util.isInteger(message.tertiary)) + return "tertiary: integer expected"; + if (message.quaternary != null && message.hasOwnProperty("quaternary")) + if (!$util.isInteger(message.quaternary)) + return "quaternary: integer expected"; + if (message.quinary != null && message.hasOwnProperty("quinary")) + if (!$util.isInteger(message.quinary)) + return "quinary: integer expected"; return null; }; /** - * Creates a MessageKey message from a plain object. Also converts values to their respective internal types. + * Creates an AppVersion message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof proto.MessageKey + * @memberof proto.AppVersion * @static * @param {Object.} object Plain object - * @returns {proto.MessageKey} MessageKey + * @returns {proto.AppVersion} AppVersion */ - MessageKey.fromObject = function fromObject(object) { - if (object instanceof $root.proto.MessageKey) + AppVersion.fromObject = function fromObject(object) { + if (object instanceof $root.proto.AppVersion) return object; - var message = new $root.proto.MessageKey(); - if (object.remoteJid != null) - message.remoteJid = String(object.remoteJid); - if (object.fromMe != null) - message.fromMe = Boolean(object.fromMe); - if (object.id != null) - message.id = String(object.id); - if (object.participant != null) - message.participant = String(object.participant); + var message = new $root.proto.AppVersion(); + if (object.primary != null) + message.primary = object.primary >>> 0; + if (object.secondary != null) + message.secondary = object.secondary >>> 0; + if (object.tertiary != null) + message.tertiary = object.tertiary >>> 0; + if (object.quaternary != null) + message.quaternary = object.quaternary >>> 0; + if (object.quinary != null) + message.quinary = object.quinary >>> 0; return message; }; /** - * Creates a plain object from a MessageKey message. Also converts values to other types if specified. + * Creates a plain object from an AppVersion message. Also converts values to other types if specified. * @function toObject - * @memberof proto.MessageKey + * @memberof proto.AppVersion * @static - * @param {proto.MessageKey} message MessageKey + * @param {proto.AppVersion} message AppVersion * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - MessageKey.toObject = function toObject(message, options) { + AppVersion.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { - object.remoteJid = ""; - object.fromMe = false; - object.id = ""; - object.participant = ""; + object.primary = 0; + object.secondary = 0; + object.tertiary = 0; + object.quaternary = 0; + object.quinary = 0; } - if (message.remoteJid != null && message.hasOwnProperty("remoteJid")) - object.remoteJid = message.remoteJid; - if (message.fromMe != null && message.hasOwnProperty("fromMe")) - object.fromMe = message.fromMe; - if (message.id != null && message.hasOwnProperty("id")) - object.id = message.id; - if (message.participant != null && message.hasOwnProperty("participant")) - object.participant = message.participant; + if (message.primary != null && message.hasOwnProperty("primary")) + object.primary = message.primary; + if (message.secondary != null && message.hasOwnProperty("secondary")) + object.secondary = message.secondary; + if (message.tertiary != null && message.hasOwnProperty("tertiary")) + object.tertiary = message.tertiary; + if (message.quaternary != null && message.hasOwnProperty("quaternary")) + object.quaternary = message.quaternary; + if (message.quinary != null && message.hasOwnProperty("quinary")) + object.quinary = message.quinary; return object; }; /** - * Converts this MessageKey to JSON. + * Converts this AppVersion to JSON. * @function toJSON - * @memberof proto.MessageKey + * @memberof proto.AppVersion * @instance * @returns {Object.} JSON object */ - MessageKey.prototype.toJSON = function toJSON() { + AppVersion.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; - return MessageKey; + return AppVersion; + })(); + + proto.UserAgent = (function() { + + /** + * Properties of a UserAgent. + * @memberof proto + * @interface IUserAgent + * @property {proto.UserAgent.UserAgentPlatform|null} [platform] UserAgent platform + * @property {proto.IAppVersion|null} [appVersion] UserAgent appVersion + * @property {string|null} [mcc] UserAgent mcc + * @property {string|null} [mnc] UserAgent mnc + * @property {string|null} [osVersion] UserAgent osVersion + * @property {string|null} [manufacturer] UserAgent manufacturer + * @property {string|null} [device] UserAgent device + * @property {string|null} [osBuildNumber] UserAgent osBuildNumber + * @property {string|null} [phoneId] UserAgent phoneId + * @property {proto.UserAgent.UserAgentReleaseChannel|null} [releaseChannel] UserAgent releaseChannel + * @property {string|null} [localeLanguageIso6391] UserAgent localeLanguageIso6391 + * @property {string|null} [localeCountryIso31661Alpha2] UserAgent localeCountryIso31661Alpha2 + * @property {string|null} [deviceBoard] UserAgent deviceBoard + */ + + /** + * Constructs a new UserAgent. + * @memberof proto + * @classdesc Represents a UserAgent. + * @implements IUserAgent + * @constructor + * @param {proto.IUserAgent=} [properties] Properties to set + */ + function UserAgent(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UserAgent platform. + * @member {proto.UserAgent.UserAgentPlatform} platform + * @memberof proto.UserAgent + * @instance + */ + UserAgent.prototype.platform = 0; + + /** + * UserAgent appVersion. + * @member {proto.IAppVersion|null|undefined} appVersion + * @memberof proto.UserAgent + * @instance + */ + UserAgent.prototype.appVersion = null; + + /** + * UserAgent mcc. + * @member {string} mcc + * @memberof proto.UserAgent + * @instance + */ + UserAgent.prototype.mcc = ""; + + /** + * UserAgent mnc. + * @member {string} mnc + * @memberof proto.UserAgent + * @instance + */ + UserAgent.prototype.mnc = ""; + + /** + * UserAgent osVersion. + * @member {string} osVersion + * @memberof proto.UserAgent + * @instance + */ + UserAgent.prototype.osVersion = ""; + + /** + * UserAgent manufacturer. + * @member {string} manufacturer + * @memberof proto.UserAgent + * @instance + */ + UserAgent.prototype.manufacturer = ""; + + /** + * UserAgent device. + * @member {string} device + * @memberof proto.UserAgent + * @instance + */ + UserAgent.prototype.device = ""; + + /** + * UserAgent osBuildNumber. + * @member {string} osBuildNumber + * @memberof proto.UserAgent + * @instance + */ + UserAgent.prototype.osBuildNumber = ""; + + /** + * UserAgent phoneId. + * @member {string} phoneId + * @memberof proto.UserAgent + * @instance + */ + UserAgent.prototype.phoneId = ""; + + /** + * UserAgent releaseChannel. + * @member {proto.UserAgent.UserAgentReleaseChannel} releaseChannel + * @memberof proto.UserAgent + * @instance + */ + UserAgent.prototype.releaseChannel = 0; + + /** + * UserAgent localeLanguageIso6391. + * @member {string} localeLanguageIso6391 + * @memberof proto.UserAgent + * @instance + */ + UserAgent.prototype.localeLanguageIso6391 = ""; + + /** + * UserAgent localeCountryIso31661Alpha2. + * @member {string} localeCountryIso31661Alpha2 + * @memberof proto.UserAgent + * @instance + */ + UserAgent.prototype.localeCountryIso31661Alpha2 = ""; + + /** + * UserAgent deviceBoard. + * @member {string} deviceBoard + * @memberof proto.UserAgent + * @instance + */ + UserAgent.prototype.deviceBoard = ""; + + /** + * Creates a new UserAgent instance using the specified properties. + * @function create + * @memberof proto.UserAgent + * @static + * @param {proto.IUserAgent=} [properties] Properties to set + * @returns {proto.UserAgent} UserAgent instance + */ + UserAgent.create = function create(properties) { + return new UserAgent(properties); + }; + + /** + * Encodes the specified UserAgent message. Does not implicitly {@link proto.UserAgent.verify|verify} messages. + * @function encode + * @memberof proto.UserAgent + * @static + * @param {proto.IUserAgent} message UserAgent message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserAgent.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.platform != null && Object.hasOwnProperty.call(message, "platform")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.platform); + if (message.appVersion != null && Object.hasOwnProperty.call(message, "appVersion")) + $root.proto.AppVersion.encode(message.appVersion, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.mcc != null && Object.hasOwnProperty.call(message, "mcc")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.mcc); + if (message.mnc != null && Object.hasOwnProperty.call(message, "mnc")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.mnc); + if (message.osVersion != null && Object.hasOwnProperty.call(message, "osVersion")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.osVersion); + if (message.manufacturer != null && Object.hasOwnProperty.call(message, "manufacturer")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.manufacturer); + if (message.device != null && Object.hasOwnProperty.call(message, "device")) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.device); + if (message.osBuildNumber != null && Object.hasOwnProperty.call(message, "osBuildNumber")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.osBuildNumber); + if (message.phoneId != null && Object.hasOwnProperty.call(message, "phoneId")) + writer.uint32(/* id 9, wireType 2 =*/74).string(message.phoneId); + if (message.releaseChannel != null && Object.hasOwnProperty.call(message, "releaseChannel")) + writer.uint32(/* id 10, wireType 0 =*/80).int32(message.releaseChannel); + if (message.localeLanguageIso6391 != null && Object.hasOwnProperty.call(message, "localeLanguageIso6391")) + writer.uint32(/* id 11, wireType 2 =*/90).string(message.localeLanguageIso6391); + if (message.localeCountryIso31661Alpha2 != null && Object.hasOwnProperty.call(message, "localeCountryIso31661Alpha2")) + writer.uint32(/* id 12, wireType 2 =*/98).string(message.localeCountryIso31661Alpha2); + if (message.deviceBoard != null && Object.hasOwnProperty.call(message, "deviceBoard")) + writer.uint32(/* id 13, wireType 2 =*/106).string(message.deviceBoard); + return writer; + }; + + /** + * Encodes the specified UserAgent message, length delimited. Does not implicitly {@link proto.UserAgent.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.UserAgent + * @static + * @param {proto.IUserAgent} message UserAgent message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UserAgent.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a UserAgent message from the specified reader or buffer. + * @function decode + * @memberof proto.UserAgent + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.UserAgent} UserAgent + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserAgent.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.UserAgent(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.platform = reader.int32(); + break; + case 2: + message.appVersion = $root.proto.AppVersion.decode(reader, reader.uint32()); + break; + case 3: + message.mcc = reader.string(); + break; + case 4: + message.mnc = reader.string(); + break; + case 5: + message.osVersion = reader.string(); + break; + case 6: + message.manufacturer = reader.string(); + break; + case 7: + message.device = reader.string(); + break; + case 8: + message.osBuildNumber = reader.string(); + break; + case 9: + message.phoneId = reader.string(); + break; + case 10: + message.releaseChannel = reader.int32(); + break; + case 11: + message.localeLanguageIso6391 = reader.string(); + break; + case 12: + message.localeCountryIso31661Alpha2 = reader.string(); + break; + case 13: + message.deviceBoard = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a UserAgent message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.UserAgent + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.UserAgent} UserAgent + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UserAgent.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a UserAgent message. + * @function verify + * @memberof proto.UserAgent + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UserAgent.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.platform != null && message.hasOwnProperty("platform")) + switch (message.platform) { + default: + return "platform: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + case 21: + case 22: + case 23: + case 24: + case 25: + break; + } + if (message.appVersion != null && message.hasOwnProperty("appVersion")) { + var error = $root.proto.AppVersion.verify(message.appVersion); + if (error) + return "appVersion." + error; + } + if (message.mcc != null && message.hasOwnProperty("mcc")) + if (!$util.isString(message.mcc)) + return "mcc: string expected"; + if (message.mnc != null && message.hasOwnProperty("mnc")) + if (!$util.isString(message.mnc)) + return "mnc: string expected"; + if (message.osVersion != null && message.hasOwnProperty("osVersion")) + if (!$util.isString(message.osVersion)) + return "osVersion: string expected"; + if (message.manufacturer != null && message.hasOwnProperty("manufacturer")) + if (!$util.isString(message.manufacturer)) + return "manufacturer: string expected"; + if (message.device != null && message.hasOwnProperty("device")) + if (!$util.isString(message.device)) + return "device: string expected"; + if (message.osBuildNumber != null && message.hasOwnProperty("osBuildNumber")) + if (!$util.isString(message.osBuildNumber)) + return "osBuildNumber: string expected"; + if (message.phoneId != null && message.hasOwnProperty("phoneId")) + if (!$util.isString(message.phoneId)) + return "phoneId: string expected"; + if (message.releaseChannel != null && message.hasOwnProperty("releaseChannel")) + switch (message.releaseChannel) { + default: + return "releaseChannel: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + if (message.localeLanguageIso6391 != null && message.hasOwnProperty("localeLanguageIso6391")) + if (!$util.isString(message.localeLanguageIso6391)) + return "localeLanguageIso6391: string expected"; + if (message.localeCountryIso31661Alpha2 != null && message.hasOwnProperty("localeCountryIso31661Alpha2")) + if (!$util.isString(message.localeCountryIso31661Alpha2)) + return "localeCountryIso31661Alpha2: string expected"; + if (message.deviceBoard != null && message.hasOwnProperty("deviceBoard")) + if (!$util.isString(message.deviceBoard)) + return "deviceBoard: string expected"; + return null; + }; + + /** + * Creates a UserAgent message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.UserAgent + * @static + * @param {Object.} object Plain object + * @returns {proto.UserAgent} UserAgent + */ + UserAgent.fromObject = function fromObject(object) { + if (object instanceof $root.proto.UserAgent) + return object; + var message = new $root.proto.UserAgent(); + switch (object.platform) { + case "ANDROID": + case 0: + message.platform = 0; + break; + case "IOS": + case 1: + message.platform = 1; + break; + case "WINDOWS_PHONE": + case 2: + message.platform = 2; + break; + case "BLACKBERRY": + case 3: + message.platform = 3; + break; + case "BLACKBERRYX": + case 4: + message.platform = 4; + break; + case "S40": + case 5: + message.platform = 5; + break; + case "S60": + case 6: + message.platform = 6; + break; + case "PYTHON_CLIENT": + case 7: + message.platform = 7; + break; + case "TIZEN": + case 8: + message.platform = 8; + break; + case "ENTERPRISE": + case 9: + message.platform = 9; + break; + case "SMB_ANDROID": + case 10: + message.platform = 10; + break; + case "KAIOS": + case 11: + message.platform = 11; + break; + case "SMB_IOS": + case 12: + message.platform = 12; + break; + case "WINDOWS": + case 13: + message.platform = 13; + break; + case "WEB": + case 14: + message.platform = 14; + break; + case "PORTAL": + case 15: + message.platform = 15; + break; + case "GREEN_ANDROID": + case 16: + message.platform = 16; + break; + case "GREEN_IPHONE": + case 17: + message.platform = 17; + break; + case "BLUE_ANDROID": + case 18: + message.platform = 18; + break; + case "BLUE_IPHONE": + case 19: + message.platform = 19; + break; + case "FBLITE_ANDROID": + case 20: + message.platform = 20; + break; + case "MLITE_ANDROID": + case 21: + message.platform = 21; + break; + case "IGLITE_ANDROID": + case 22: + message.platform = 22; + break; + case "PAGE": + case 23: + message.platform = 23; + break; + case "MACOS": + case 24: + message.platform = 24; + break; + case "VR": + case 25: + message.platform = 25; + break; + } + if (object.appVersion != null) { + if (typeof object.appVersion !== "object") + throw TypeError(".proto.UserAgent.appVersion: object expected"); + message.appVersion = $root.proto.AppVersion.fromObject(object.appVersion); + } + if (object.mcc != null) + message.mcc = String(object.mcc); + if (object.mnc != null) + message.mnc = String(object.mnc); + if (object.osVersion != null) + message.osVersion = String(object.osVersion); + if (object.manufacturer != null) + message.manufacturer = String(object.manufacturer); + if (object.device != null) + message.device = String(object.device); + if (object.osBuildNumber != null) + message.osBuildNumber = String(object.osBuildNumber); + if (object.phoneId != null) + message.phoneId = String(object.phoneId); + switch (object.releaseChannel) { + case "RELEASE": + case 0: + message.releaseChannel = 0; + break; + case "BETA": + case 1: + message.releaseChannel = 1; + break; + case "ALPHA": + case 2: + message.releaseChannel = 2; + break; + case "DEBUG": + case 3: + message.releaseChannel = 3; + break; + } + if (object.localeLanguageIso6391 != null) + message.localeLanguageIso6391 = String(object.localeLanguageIso6391); + if (object.localeCountryIso31661Alpha2 != null) + message.localeCountryIso31661Alpha2 = String(object.localeCountryIso31661Alpha2); + if (object.deviceBoard != null) + message.deviceBoard = String(object.deviceBoard); + return message; + }; + + /** + * Creates a plain object from a UserAgent message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.UserAgent + * @static + * @param {proto.UserAgent} message UserAgent + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UserAgent.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.platform = options.enums === String ? "ANDROID" : 0; + object.appVersion = null; + object.mcc = ""; + object.mnc = ""; + object.osVersion = ""; + object.manufacturer = ""; + object.device = ""; + object.osBuildNumber = ""; + object.phoneId = ""; + object.releaseChannel = options.enums === String ? "RELEASE" : 0; + object.localeLanguageIso6391 = ""; + object.localeCountryIso31661Alpha2 = ""; + object.deviceBoard = ""; + } + if (message.platform != null && message.hasOwnProperty("platform")) + object.platform = options.enums === String ? $root.proto.UserAgent.UserAgentPlatform[message.platform] : message.platform; + if (message.appVersion != null && message.hasOwnProperty("appVersion")) + object.appVersion = $root.proto.AppVersion.toObject(message.appVersion, options); + if (message.mcc != null && message.hasOwnProperty("mcc")) + object.mcc = message.mcc; + if (message.mnc != null && message.hasOwnProperty("mnc")) + object.mnc = message.mnc; + if (message.osVersion != null && message.hasOwnProperty("osVersion")) + object.osVersion = message.osVersion; + if (message.manufacturer != null && message.hasOwnProperty("manufacturer")) + object.manufacturer = message.manufacturer; + if (message.device != null && message.hasOwnProperty("device")) + object.device = message.device; + if (message.osBuildNumber != null && message.hasOwnProperty("osBuildNumber")) + object.osBuildNumber = message.osBuildNumber; + if (message.phoneId != null && message.hasOwnProperty("phoneId")) + object.phoneId = message.phoneId; + if (message.releaseChannel != null && message.hasOwnProperty("releaseChannel")) + object.releaseChannel = options.enums === String ? $root.proto.UserAgent.UserAgentReleaseChannel[message.releaseChannel] : message.releaseChannel; + if (message.localeLanguageIso6391 != null && message.hasOwnProperty("localeLanguageIso6391")) + object.localeLanguageIso6391 = message.localeLanguageIso6391; + if (message.localeCountryIso31661Alpha2 != null && message.hasOwnProperty("localeCountryIso31661Alpha2")) + object.localeCountryIso31661Alpha2 = message.localeCountryIso31661Alpha2; + if (message.deviceBoard != null && message.hasOwnProperty("deviceBoard")) + object.deviceBoard = message.deviceBoard; + return object; + }; + + /** + * Converts this UserAgent to JSON. + * @function toJSON + * @memberof proto.UserAgent + * @instance + * @returns {Object.} JSON object + */ + UserAgent.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * UserAgentPlatform enum. + * @name proto.UserAgent.UserAgentPlatform + * @enum {number} + * @property {number} ANDROID=0 ANDROID value + * @property {number} IOS=1 IOS value + * @property {number} WINDOWS_PHONE=2 WINDOWS_PHONE value + * @property {number} BLACKBERRY=3 BLACKBERRY value + * @property {number} BLACKBERRYX=4 BLACKBERRYX value + * @property {number} S40=5 S40 value + * @property {number} S60=6 S60 value + * @property {number} PYTHON_CLIENT=7 PYTHON_CLIENT value + * @property {number} TIZEN=8 TIZEN value + * @property {number} ENTERPRISE=9 ENTERPRISE value + * @property {number} SMB_ANDROID=10 SMB_ANDROID value + * @property {number} KAIOS=11 KAIOS value + * @property {number} SMB_IOS=12 SMB_IOS value + * @property {number} WINDOWS=13 WINDOWS value + * @property {number} WEB=14 WEB value + * @property {number} PORTAL=15 PORTAL value + * @property {number} GREEN_ANDROID=16 GREEN_ANDROID value + * @property {number} GREEN_IPHONE=17 GREEN_IPHONE value + * @property {number} BLUE_ANDROID=18 BLUE_ANDROID value + * @property {number} BLUE_IPHONE=19 BLUE_IPHONE value + * @property {number} FBLITE_ANDROID=20 FBLITE_ANDROID value + * @property {number} MLITE_ANDROID=21 MLITE_ANDROID value + * @property {number} IGLITE_ANDROID=22 IGLITE_ANDROID value + * @property {number} PAGE=23 PAGE value + * @property {number} MACOS=24 MACOS value + * @property {number} VR=25 VR value + */ + UserAgent.UserAgentPlatform = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ANDROID"] = 0; + values[valuesById[1] = "IOS"] = 1; + values[valuesById[2] = "WINDOWS_PHONE"] = 2; + values[valuesById[3] = "BLACKBERRY"] = 3; + values[valuesById[4] = "BLACKBERRYX"] = 4; + values[valuesById[5] = "S40"] = 5; + values[valuesById[6] = "S60"] = 6; + values[valuesById[7] = "PYTHON_CLIENT"] = 7; + values[valuesById[8] = "TIZEN"] = 8; + values[valuesById[9] = "ENTERPRISE"] = 9; + values[valuesById[10] = "SMB_ANDROID"] = 10; + values[valuesById[11] = "KAIOS"] = 11; + values[valuesById[12] = "SMB_IOS"] = 12; + values[valuesById[13] = "WINDOWS"] = 13; + values[valuesById[14] = "WEB"] = 14; + values[valuesById[15] = "PORTAL"] = 15; + values[valuesById[16] = "GREEN_ANDROID"] = 16; + values[valuesById[17] = "GREEN_IPHONE"] = 17; + values[valuesById[18] = "BLUE_ANDROID"] = 18; + values[valuesById[19] = "BLUE_IPHONE"] = 19; + values[valuesById[20] = "FBLITE_ANDROID"] = 20; + values[valuesById[21] = "MLITE_ANDROID"] = 21; + values[valuesById[22] = "IGLITE_ANDROID"] = 22; + values[valuesById[23] = "PAGE"] = 23; + values[valuesById[24] = "MACOS"] = 24; + values[valuesById[25] = "VR"] = 25; + return values; + })(); + + /** + * UserAgentReleaseChannel enum. + * @name proto.UserAgent.UserAgentReleaseChannel + * @enum {number} + * @property {number} RELEASE=0 RELEASE value + * @property {number} BETA=1 BETA value + * @property {number} ALPHA=2 ALPHA value + * @property {number} DEBUG=3 DEBUG value + */ + UserAgent.UserAgentReleaseChannel = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "RELEASE"] = 0; + values[valuesById[1] = "BETA"] = 1; + values[valuesById[2] = "ALPHA"] = 2; + values[valuesById[3] = "DEBUG"] = 3; + return values; + })(); + + return UserAgent; + })(); + + proto.WebdPayload = (function() { + + /** + * Properties of a WebdPayload. + * @memberof proto + * @interface IWebdPayload + * @property {boolean|null} [usesParticipantInKey] WebdPayload usesParticipantInKey + * @property {boolean|null} [supportsStarredMessages] WebdPayload supportsStarredMessages + * @property {boolean|null} [supportsDocumentMessages] WebdPayload supportsDocumentMessages + * @property {boolean|null} [supportsUrlMessages] WebdPayload supportsUrlMessages + * @property {boolean|null} [supportsMediaRetry] WebdPayload supportsMediaRetry + * @property {boolean|null} [supportsE2EImage] WebdPayload supportsE2EImage + * @property {boolean|null} [supportsE2EVideo] WebdPayload supportsE2EVideo + * @property {boolean|null} [supportsE2EAudio] WebdPayload supportsE2EAudio + * @property {boolean|null} [supportsE2EDocument] WebdPayload supportsE2EDocument + * @property {string|null} [documentTypes] WebdPayload documentTypes + * @property {Uint8Array|null} [features] WebdPayload features + */ + + /** + * Constructs a new WebdPayload. + * @memberof proto + * @classdesc Represents a WebdPayload. + * @implements IWebdPayload + * @constructor + * @param {proto.IWebdPayload=} [properties] Properties to set + */ + function WebdPayload(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WebdPayload usesParticipantInKey. + * @member {boolean} usesParticipantInKey + * @memberof proto.WebdPayload + * @instance + */ + WebdPayload.prototype.usesParticipantInKey = false; + + /** + * WebdPayload supportsStarredMessages. + * @member {boolean} supportsStarredMessages + * @memberof proto.WebdPayload + * @instance + */ + WebdPayload.prototype.supportsStarredMessages = false; + + /** + * WebdPayload supportsDocumentMessages. + * @member {boolean} supportsDocumentMessages + * @memberof proto.WebdPayload + * @instance + */ + WebdPayload.prototype.supportsDocumentMessages = false; + + /** + * WebdPayload supportsUrlMessages. + * @member {boolean} supportsUrlMessages + * @memberof proto.WebdPayload + * @instance + */ + WebdPayload.prototype.supportsUrlMessages = false; + + /** + * WebdPayload supportsMediaRetry. + * @member {boolean} supportsMediaRetry + * @memberof proto.WebdPayload + * @instance + */ + WebdPayload.prototype.supportsMediaRetry = false; + + /** + * WebdPayload supportsE2EImage. + * @member {boolean} supportsE2EImage + * @memberof proto.WebdPayload + * @instance + */ + WebdPayload.prototype.supportsE2EImage = false; + + /** + * WebdPayload supportsE2EVideo. + * @member {boolean} supportsE2EVideo + * @memberof proto.WebdPayload + * @instance + */ + WebdPayload.prototype.supportsE2EVideo = false; + + /** + * WebdPayload supportsE2EAudio. + * @member {boolean} supportsE2EAudio + * @memberof proto.WebdPayload + * @instance + */ + WebdPayload.prototype.supportsE2EAudio = false; + + /** + * WebdPayload supportsE2EDocument. + * @member {boolean} supportsE2EDocument + * @memberof proto.WebdPayload + * @instance + */ + WebdPayload.prototype.supportsE2EDocument = false; + + /** + * WebdPayload documentTypes. + * @member {string} documentTypes + * @memberof proto.WebdPayload + * @instance + */ + WebdPayload.prototype.documentTypes = ""; + + /** + * WebdPayload features. + * @member {Uint8Array} features + * @memberof proto.WebdPayload + * @instance + */ + WebdPayload.prototype.features = $util.newBuffer([]); + + /** + * Creates a new WebdPayload instance using the specified properties. + * @function create + * @memberof proto.WebdPayload + * @static + * @param {proto.IWebdPayload=} [properties] Properties to set + * @returns {proto.WebdPayload} WebdPayload instance + */ + WebdPayload.create = function create(properties) { + return new WebdPayload(properties); + }; + + /** + * Encodes the specified WebdPayload message. Does not implicitly {@link proto.WebdPayload.verify|verify} messages. + * @function encode + * @memberof proto.WebdPayload + * @static + * @param {proto.IWebdPayload} message WebdPayload message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WebdPayload.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.usesParticipantInKey != null && Object.hasOwnProperty.call(message, "usesParticipantInKey")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.usesParticipantInKey); + if (message.supportsStarredMessages != null && Object.hasOwnProperty.call(message, "supportsStarredMessages")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.supportsStarredMessages); + if (message.supportsDocumentMessages != null && Object.hasOwnProperty.call(message, "supportsDocumentMessages")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.supportsDocumentMessages); + if (message.supportsUrlMessages != null && Object.hasOwnProperty.call(message, "supportsUrlMessages")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.supportsUrlMessages); + if (message.supportsMediaRetry != null && Object.hasOwnProperty.call(message, "supportsMediaRetry")) + writer.uint32(/* id 5, wireType 0 =*/40).bool(message.supportsMediaRetry); + if (message.supportsE2EImage != null && Object.hasOwnProperty.call(message, "supportsE2EImage")) + writer.uint32(/* id 6, wireType 0 =*/48).bool(message.supportsE2EImage); + if (message.supportsE2EVideo != null && Object.hasOwnProperty.call(message, "supportsE2EVideo")) + writer.uint32(/* id 7, wireType 0 =*/56).bool(message.supportsE2EVideo); + if (message.supportsE2EAudio != null && Object.hasOwnProperty.call(message, "supportsE2EAudio")) + writer.uint32(/* id 8, wireType 0 =*/64).bool(message.supportsE2EAudio); + if (message.supportsE2EDocument != null && Object.hasOwnProperty.call(message, "supportsE2EDocument")) + writer.uint32(/* id 9, wireType 0 =*/72).bool(message.supportsE2EDocument); + if (message.documentTypes != null && Object.hasOwnProperty.call(message, "documentTypes")) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.documentTypes); + if (message.features != null && Object.hasOwnProperty.call(message, "features")) + writer.uint32(/* id 11, wireType 2 =*/90).bytes(message.features); + return writer; + }; + + /** + * Encodes the specified WebdPayload message, length delimited. Does not implicitly {@link proto.WebdPayload.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.WebdPayload + * @static + * @param {proto.IWebdPayload} message WebdPayload message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WebdPayload.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a WebdPayload message from the specified reader or buffer. + * @function decode + * @memberof proto.WebdPayload + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.WebdPayload} WebdPayload + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WebdPayload.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.WebdPayload(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.usesParticipantInKey = reader.bool(); + break; + case 2: + message.supportsStarredMessages = reader.bool(); + break; + case 3: + message.supportsDocumentMessages = reader.bool(); + break; + case 4: + message.supportsUrlMessages = reader.bool(); + break; + case 5: + message.supportsMediaRetry = reader.bool(); + break; + case 6: + message.supportsE2EImage = reader.bool(); + break; + case 7: + message.supportsE2EVideo = reader.bool(); + break; + case 8: + message.supportsE2EAudio = reader.bool(); + break; + case 9: + message.supportsE2EDocument = reader.bool(); + break; + case 10: + message.documentTypes = reader.string(); + break; + case 11: + message.features = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a WebdPayload message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.WebdPayload + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.WebdPayload} WebdPayload + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WebdPayload.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a WebdPayload message. + * @function verify + * @memberof proto.WebdPayload + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + WebdPayload.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.usesParticipantInKey != null && message.hasOwnProperty("usesParticipantInKey")) + if (typeof message.usesParticipantInKey !== "boolean") + return "usesParticipantInKey: boolean expected"; + if (message.supportsStarredMessages != null && message.hasOwnProperty("supportsStarredMessages")) + if (typeof message.supportsStarredMessages !== "boolean") + return "supportsStarredMessages: boolean expected"; + if (message.supportsDocumentMessages != null && message.hasOwnProperty("supportsDocumentMessages")) + if (typeof message.supportsDocumentMessages !== "boolean") + return "supportsDocumentMessages: boolean expected"; + if (message.supportsUrlMessages != null && message.hasOwnProperty("supportsUrlMessages")) + if (typeof message.supportsUrlMessages !== "boolean") + return "supportsUrlMessages: boolean expected"; + if (message.supportsMediaRetry != null && message.hasOwnProperty("supportsMediaRetry")) + if (typeof message.supportsMediaRetry !== "boolean") + return "supportsMediaRetry: boolean expected"; + if (message.supportsE2EImage != null && message.hasOwnProperty("supportsE2EImage")) + if (typeof message.supportsE2EImage !== "boolean") + return "supportsE2EImage: boolean expected"; + if (message.supportsE2EVideo != null && message.hasOwnProperty("supportsE2EVideo")) + if (typeof message.supportsE2EVideo !== "boolean") + return "supportsE2EVideo: boolean expected"; + if (message.supportsE2EAudio != null && message.hasOwnProperty("supportsE2EAudio")) + if (typeof message.supportsE2EAudio !== "boolean") + return "supportsE2EAudio: boolean expected"; + if (message.supportsE2EDocument != null && message.hasOwnProperty("supportsE2EDocument")) + if (typeof message.supportsE2EDocument !== "boolean") + return "supportsE2EDocument: boolean expected"; + if (message.documentTypes != null && message.hasOwnProperty("documentTypes")) + if (!$util.isString(message.documentTypes)) + return "documentTypes: string expected"; + if (message.features != null && message.hasOwnProperty("features")) + if (!(message.features && typeof message.features.length === "number" || $util.isString(message.features))) + return "features: buffer expected"; + return null; + }; + + /** + * Creates a WebdPayload message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.WebdPayload + * @static + * @param {Object.} object Plain object + * @returns {proto.WebdPayload} WebdPayload + */ + WebdPayload.fromObject = function fromObject(object) { + if (object instanceof $root.proto.WebdPayload) + return object; + var message = new $root.proto.WebdPayload(); + if (object.usesParticipantInKey != null) + message.usesParticipantInKey = Boolean(object.usesParticipantInKey); + if (object.supportsStarredMessages != null) + message.supportsStarredMessages = Boolean(object.supportsStarredMessages); + if (object.supportsDocumentMessages != null) + message.supportsDocumentMessages = Boolean(object.supportsDocumentMessages); + if (object.supportsUrlMessages != null) + message.supportsUrlMessages = Boolean(object.supportsUrlMessages); + if (object.supportsMediaRetry != null) + message.supportsMediaRetry = Boolean(object.supportsMediaRetry); + if (object.supportsE2EImage != null) + message.supportsE2EImage = Boolean(object.supportsE2EImage); + if (object.supportsE2EVideo != null) + message.supportsE2EVideo = Boolean(object.supportsE2EVideo); + if (object.supportsE2EAudio != null) + message.supportsE2EAudio = Boolean(object.supportsE2EAudio); + if (object.supportsE2EDocument != null) + message.supportsE2EDocument = Boolean(object.supportsE2EDocument); + if (object.documentTypes != null) + message.documentTypes = String(object.documentTypes); + if (object.features != null) + if (typeof object.features === "string") + $util.base64.decode(object.features, message.features = $util.newBuffer($util.base64.length(object.features)), 0); + else if (object.features.length) + message.features = object.features; + return message; + }; + + /** + * Creates a plain object from a WebdPayload message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.WebdPayload + * @static + * @param {proto.WebdPayload} message WebdPayload + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WebdPayload.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.usesParticipantInKey = false; + object.supportsStarredMessages = false; + object.supportsDocumentMessages = false; + object.supportsUrlMessages = false; + object.supportsMediaRetry = false; + object.supportsE2EImage = false; + object.supportsE2EVideo = false; + object.supportsE2EAudio = false; + object.supportsE2EDocument = false; + object.documentTypes = ""; + if (options.bytes === String) + object.features = ""; + else { + object.features = []; + if (options.bytes !== Array) + object.features = $util.newBuffer(object.features); + } + } + if (message.usesParticipantInKey != null && message.hasOwnProperty("usesParticipantInKey")) + object.usesParticipantInKey = message.usesParticipantInKey; + if (message.supportsStarredMessages != null && message.hasOwnProperty("supportsStarredMessages")) + object.supportsStarredMessages = message.supportsStarredMessages; + if (message.supportsDocumentMessages != null && message.hasOwnProperty("supportsDocumentMessages")) + object.supportsDocumentMessages = message.supportsDocumentMessages; + if (message.supportsUrlMessages != null && message.hasOwnProperty("supportsUrlMessages")) + object.supportsUrlMessages = message.supportsUrlMessages; + if (message.supportsMediaRetry != null && message.hasOwnProperty("supportsMediaRetry")) + object.supportsMediaRetry = message.supportsMediaRetry; + if (message.supportsE2EImage != null && message.hasOwnProperty("supportsE2EImage")) + object.supportsE2EImage = message.supportsE2EImage; + if (message.supportsE2EVideo != null && message.hasOwnProperty("supportsE2EVideo")) + object.supportsE2EVideo = message.supportsE2EVideo; + if (message.supportsE2EAudio != null && message.hasOwnProperty("supportsE2EAudio")) + object.supportsE2EAudio = message.supportsE2EAudio; + if (message.supportsE2EDocument != null && message.hasOwnProperty("supportsE2EDocument")) + object.supportsE2EDocument = message.supportsE2EDocument; + if (message.documentTypes != null && message.hasOwnProperty("documentTypes")) + object.documentTypes = message.documentTypes; + if (message.features != null && message.hasOwnProperty("features")) + object.features = options.bytes === String ? $util.base64.encode(message.features, 0, message.features.length) : options.bytes === Array ? Array.prototype.slice.call(message.features) : message.features; + return object; + }; + + /** + * Converts this WebdPayload to JSON. + * @function toJSON + * @memberof proto.WebdPayload + * @instance + * @returns {Object.} JSON object + */ + WebdPayload.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return WebdPayload; + })(); + + proto.WebInfo = (function() { + + /** + * Properties of a WebInfo. + * @memberof proto + * @interface IWebInfo + * @property {string|null} [refToken] WebInfo refToken + * @property {string|null} [version] WebInfo version + * @property {proto.IWebdPayload|null} [webdPayload] WebInfo webdPayload + * @property {proto.WebInfo.WebInfoWebSubPlatform|null} [webSubPlatform] WebInfo webSubPlatform + */ + + /** + * Constructs a new WebInfo. + * @memberof proto + * @classdesc Represents a WebInfo. + * @implements IWebInfo + * @constructor + * @param {proto.IWebInfo=} [properties] Properties to set + */ + function WebInfo(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WebInfo refToken. + * @member {string} refToken + * @memberof proto.WebInfo + * @instance + */ + WebInfo.prototype.refToken = ""; + + /** + * WebInfo version. + * @member {string} version + * @memberof proto.WebInfo + * @instance + */ + WebInfo.prototype.version = ""; + + /** + * WebInfo webdPayload. + * @member {proto.IWebdPayload|null|undefined} webdPayload + * @memberof proto.WebInfo + * @instance + */ + WebInfo.prototype.webdPayload = null; + + /** + * WebInfo webSubPlatform. + * @member {proto.WebInfo.WebInfoWebSubPlatform} webSubPlatform + * @memberof proto.WebInfo + * @instance + */ + WebInfo.prototype.webSubPlatform = 0; + + /** + * Creates a new WebInfo instance using the specified properties. + * @function create + * @memberof proto.WebInfo + * @static + * @param {proto.IWebInfo=} [properties] Properties to set + * @returns {proto.WebInfo} WebInfo instance + */ + WebInfo.create = function create(properties) { + return new WebInfo(properties); + }; + + /** + * Encodes the specified WebInfo message. Does not implicitly {@link proto.WebInfo.verify|verify} messages. + * @function encode + * @memberof proto.WebInfo + * @static + * @param {proto.IWebInfo} message WebInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WebInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.refToken != null && Object.hasOwnProperty.call(message, "refToken")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.refToken); + if (message.version != null && Object.hasOwnProperty.call(message, "version")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.version); + if (message.webdPayload != null && Object.hasOwnProperty.call(message, "webdPayload")) + $root.proto.WebdPayload.encode(message.webdPayload, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.webSubPlatform != null && Object.hasOwnProperty.call(message, "webSubPlatform")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.webSubPlatform); + return writer; + }; + + /** + * Encodes the specified WebInfo message, length delimited. Does not implicitly {@link proto.WebInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.WebInfo + * @static + * @param {proto.IWebInfo} message WebInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WebInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a WebInfo message from the specified reader or buffer. + * @function decode + * @memberof proto.WebInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.WebInfo} WebInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WebInfo.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.WebInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.refToken = reader.string(); + break; + case 2: + message.version = reader.string(); + break; + case 3: + message.webdPayload = $root.proto.WebdPayload.decode(reader, reader.uint32()); + break; + case 4: + message.webSubPlatform = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a WebInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.WebInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.WebInfo} WebInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WebInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a WebInfo message. + * @function verify + * @memberof proto.WebInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + WebInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.refToken != null && message.hasOwnProperty("refToken")) + if (!$util.isString(message.refToken)) + return "refToken: string expected"; + if (message.version != null && message.hasOwnProperty("version")) + if (!$util.isString(message.version)) + return "version: string expected"; + if (message.webdPayload != null && message.hasOwnProperty("webdPayload")) { + var error = $root.proto.WebdPayload.verify(message.webdPayload); + if (error) + return "webdPayload." + error; + } + if (message.webSubPlatform != null && message.hasOwnProperty("webSubPlatform")) + switch (message.webSubPlatform) { + default: + return "webSubPlatform: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } + return null; + }; + + /** + * Creates a WebInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.WebInfo + * @static + * @param {Object.} object Plain object + * @returns {proto.WebInfo} WebInfo + */ + WebInfo.fromObject = function fromObject(object) { + if (object instanceof $root.proto.WebInfo) + return object; + var message = new $root.proto.WebInfo(); + if (object.refToken != null) + message.refToken = String(object.refToken); + if (object.version != null) + message.version = String(object.version); + if (object.webdPayload != null) { + if (typeof object.webdPayload !== "object") + throw TypeError(".proto.WebInfo.webdPayload: object expected"); + message.webdPayload = $root.proto.WebdPayload.fromObject(object.webdPayload); + } + switch (object.webSubPlatform) { + case "WEB_BROWSER": + case 0: + message.webSubPlatform = 0; + break; + case "APP_STORE": + case 1: + message.webSubPlatform = 1; + break; + case "WIN_STORE": + case 2: + message.webSubPlatform = 2; + break; + case "DARWIN": + case 3: + message.webSubPlatform = 3; + break; + case "WIN32": + case 4: + message.webSubPlatform = 4; + break; + } + return message; + }; + + /** + * Creates a plain object from a WebInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.WebInfo + * @static + * @param {proto.WebInfo} message WebInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WebInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.refToken = ""; + object.version = ""; + object.webdPayload = null; + object.webSubPlatform = options.enums === String ? "WEB_BROWSER" : 0; + } + if (message.refToken != null && message.hasOwnProperty("refToken")) + object.refToken = message.refToken; + if (message.version != null && message.hasOwnProperty("version")) + object.version = message.version; + if (message.webdPayload != null && message.hasOwnProperty("webdPayload")) + object.webdPayload = $root.proto.WebdPayload.toObject(message.webdPayload, options); + if (message.webSubPlatform != null && message.hasOwnProperty("webSubPlatform")) + object.webSubPlatform = options.enums === String ? $root.proto.WebInfo.WebInfoWebSubPlatform[message.webSubPlatform] : message.webSubPlatform; + return object; + }; + + /** + * Converts this WebInfo to JSON. + * @function toJSON + * @memberof proto.WebInfo + * @instance + * @returns {Object.} JSON object + */ + WebInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * WebInfoWebSubPlatform enum. + * @name proto.WebInfo.WebInfoWebSubPlatform + * @enum {number} + * @property {number} WEB_BROWSER=0 WEB_BROWSER value + * @property {number} APP_STORE=1 APP_STORE value + * @property {number} WIN_STORE=2 WIN_STORE value + * @property {number} DARWIN=3 DARWIN value + * @property {number} WIN32=4 WIN32 value + */ + WebInfo.WebInfoWebSubPlatform = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "WEB_BROWSER"] = 0; + values[valuesById[1] = "APP_STORE"] = 1; + values[valuesById[2] = "WIN_STORE"] = 2; + values[valuesById[3] = "DARWIN"] = 3; + values[valuesById[4] = "WIN32"] = 4; + return values; + })(); + + return WebInfo; + })(); + + proto.DNSSource = (function() { + + /** + * Properties of a DNSSource. + * @memberof proto + * @interface IDNSSource + * @property {proto.DNSSource.DNSSourceDNSResolutionMethod|null} [dnsMethod] DNSSource dnsMethod + * @property {boolean|null} [appCached] DNSSource appCached + */ + + /** + * Constructs a new DNSSource. + * @memberof proto + * @classdesc Represents a DNSSource. + * @implements IDNSSource + * @constructor + * @param {proto.IDNSSource=} [properties] Properties to set + */ + function DNSSource(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DNSSource dnsMethod. + * @member {proto.DNSSource.DNSSourceDNSResolutionMethod} dnsMethod + * @memberof proto.DNSSource + * @instance + */ + DNSSource.prototype.dnsMethod = 0; + + /** + * DNSSource appCached. + * @member {boolean} appCached + * @memberof proto.DNSSource + * @instance + */ + DNSSource.prototype.appCached = false; + + /** + * Creates a new DNSSource instance using the specified properties. + * @function create + * @memberof proto.DNSSource + * @static + * @param {proto.IDNSSource=} [properties] Properties to set + * @returns {proto.DNSSource} DNSSource instance + */ + DNSSource.create = function create(properties) { + return new DNSSource(properties); + }; + + /** + * Encodes the specified DNSSource message. Does not implicitly {@link proto.DNSSource.verify|verify} messages. + * @function encode + * @memberof proto.DNSSource + * @static + * @param {proto.IDNSSource} message DNSSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DNSSource.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.dnsMethod != null && Object.hasOwnProperty.call(message, "dnsMethod")) + writer.uint32(/* id 15, wireType 0 =*/120).int32(message.dnsMethod); + if (message.appCached != null && Object.hasOwnProperty.call(message, "appCached")) + writer.uint32(/* id 16, wireType 0 =*/128).bool(message.appCached); + return writer; + }; + + /** + * Encodes the specified DNSSource message, length delimited. Does not implicitly {@link proto.DNSSource.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.DNSSource + * @static + * @param {proto.IDNSSource} message DNSSource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DNSSource.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DNSSource message from the specified reader or buffer. + * @function decode + * @memberof proto.DNSSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.DNSSource} DNSSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DNSSource.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.DNSSource(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 15: + message.dnsMethod = reader.int32(); + break; + case 16: + message.appCached = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DNSSource message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.DNSSource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.DNSSource} DNSSource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DNSSource.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DNSSource message. + * @function verify + * @memberof proto.DNSSource + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DNSSource.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.dnsMethod != null && message.hasOwnProperty("dnsMethod")) + switch (message.dnsMethod) { + default: + return "dnsMethod: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } + if (message.appCached != null && message.hasOwnProperty("appCached")) + if (typeof message.appCached !== "boolean") + return "appCached: boolean expected"; + return null; + }; + + /** + * Creates a DNSSource message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.DNSSource + * @static + * @param {Object.} object Plain object + * @returns {proto.DNSSource} DNSSource + */ + DNSSource.fromObject = function fromObject(object) { + if (object instanceof $root.proto.DNSSource) + return object; + var message = new $root.proto.DNSSource(); + switch (object.dnsMethod) { + case "SYSTEM": + case 0: + message.dnsMethod = 0; + break; + case "GOOGLE": + case 1: + message.dnsMethod = 1; + break; + case "HARDCODED": + case 2: + message.dnsMethod = 2; + break; + case "OVERRIDE": + case 3: + message.dnsMethod = 3; + break; + case "FALLBACK": + case 4: + message.dnsMethod = 4; + break; + } + if (object.appCached != null) + message.appCached = Boolean(object.appCached); + return message; + }; + + /** + * Creates a plain object from a DNSSource message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.DNSSource + * @static + * @param {proto.DNSSource} message DNSSource + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DNSSource.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.dnsMethod = options.enums === String ? "SYSTEM" : 0; + object.appCached = false; + } + if (message.dnsMethod != null && message.hasOwnProperty("dnsMethod")) + object.dnsMethod = options.enums === String ? $root.proto.DNSSource.DNSSourceDNSResolutionMethod[message.dnsMethod] : message.dnsMethod; + if (message.appCached != null && message.hasOwnProperty("appCached")) + object.appCached = message.appCached; + return object; + }; + + /** + * Converts this DNSSource to JSON. + * @function toJSON + * @memberof proto.DNSSource + * @instance + * @returns {Object.} JSON object + */ + DNSSource.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * DNSSourceDNSResolutionMethod enum. + * @name proto.DNSSource.DNSSourceDNSResolutionMethod + * @enum {number} + * @property {number} SYSTEM=0 SYSTEM value + * @property {number} GOOGLE=1 GOOGLE value + * @property {number} HARDCODED=2 HARDCODED value + * @property {number} OVERRIDE=3 OVERRIDE value + * @property {number} FALLBACK=4 FALLBACK value + */ + DNSSource.DNSSourceDNSResolutionMethod = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SYSTEM"] = 0; + values[valuesById[1] = "GOOGLE"] = 1; + values[valuesById[2] = "HARDCODED"] = 2; + values[valuesById[3] = "OVERRIDE"] = 3; + values[valuesById[4] = "FALLBACK"] = 4; + return values; + })(); + + return DNSSource; + })(); + + proto.CompanionRegData = (function() { + + /** + * Properties of a CompanionRegData. + * @memberof proto + * @interface ICompanionRegData + * @property {Uint8Array|null} [eRegid] CompanionRegData eRegid + * @property {Uint8Array|null} [eKeytype] CompanionRegData eKeytype + * @property {Uint8Array|null} [eIdent] CompanionRegData eIdent + * @property {Uint8Array|null} [eSkeyId] CompanionRegData eSkeyId + * @property {Uint8Array|null} [eSkeyVal] CompanionRegData eSkeyVal + * @property {Uint8Array|null} [eSkeySig] CompanionRegData eSkeySig + * @property {Uint8Array|null} [buildHash] CompanionRegData buildHash + * @property {Uint8Array|null} [companionProps] CompanionRegData companionProps + */ + + /** + * Constructs a new CompanionRegData. + * @memberof proto + * @classdesc Represents a CompanionRegData. + * @implements ICompanionRegData + * @constructor + * @param {proto.ICompanionRegData=} [properties] Properties to set + */ + function CompanionRegData(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CompanionRegData eRegid. + * @member {Uint8Array} eRegid + * @memberof proto.CompanionRegData + * @instance + */ + CompanionRegData.prototype.eRegid = $util.newBuffer([]); + + /** + * CompanionRegData eKeytype. + * @member {Uint8Array} eKeytype + * @memberof proto.CompanionRegData + * @instance + */ + CompanionRegData.prototype.eKeytype = $util.newBuffer([]); + + /** + * CompanionRegData eIdent. + * @member {Uint8Array} eIdent + * @memberof proto.CompanionRegData + * @instance + */ + CompanionRegData.prototype.eIdent = $util.newBuffer([]); + + /** + * CompanionRegData eSkeyId. + * @member {Uint8Array} eSkeyId + * @memberof proto.CompanionRegData + * @instance + */ + CompanionRegData.prototype.eSkeyId = $util.newBuffer([]); + + /** + * CompanionRegData eSkeyVal. + * @member {Uint8Array} eSkeyVal + * @memberof proto.CompanionRegData + * @instance + */ + CompanionRegData.prototype.eSkeyVal = $util.newBuffer([]); + + /** + * CompanionRegData eSkeySig. + * @member {Uint8Array} eSkeySig + * @memberof proto.CompanionRegData + * @instance + */ + CompanionRegData.prototype.eSkeySig = $util.newBuffer([]); + + /** + * CompanionRegData buildHash. + * @member {Uint8Array} buildHash + * @memberof proto.CompanionRegData + * @instance + */ + CompanionRegData.prototype.buildHash = $util.newBuffer([]); + + /** + * CompanionRegData companionProps. + * @member {Uint8Array} companionProps + * @memberof proto.CompanionRegData + * @instance + */ + CompanionRegData.prototype.companionProps = $util.newBuffer([]); + + /** + * Creates a new CompanionRegData instance using the specified properties. + * @function create + * @memberof proto.CompanionRegData + * @static + * @param {proto.ICompanionRegData=} [properties] Properties to set + * @returns {proto.CompanionRegData} CompanionRegData instance + */ + CompanionRegData.create = function create(properties) { + return new CompanionRegData(properties); + }; + + /** + * Encodes the specified CompanionRegData message. Does not implicitly {@link proto.CompanionRegData.verify|verify} messages. + * @function encode + * @memberof proto.CompanionRegData + * @static + * @param {proto.ICompanionRegData} message CompanionRegData message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompanionRegData.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.eRegid != null && Object.hasOwnProperty.call(message, "eRegid")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.eRegid); + if (message.eKeytype != null && Object.hasOwnProperty.call(message, "eKeytype")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.eKeytype); + if (message.eIdent != null && Object.hasOwnProperty.call(message, "eIdent")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.eIdent); + if (message.eSkeyId != null && Object.hasOwnProperty.call(message, "eSkeyId")) + writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.eSkeyId); + if (message.eSkeyVal != null && Object.hasOwnProperty.call(message, "eSkeyVal")) + writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.eSkeyVal); + if (message.eSkeySig != null && Object.hasOwnProperty.call(message, "eSkeySig")) + writer.uint32(/* id 6, wireType 2 =*/50).bytes(message.eSkeySig); + if (message.buildHash != null && Object.hasOwnProperty.call(message, "buildHash")) + writer.uint32(/* id 7, wireType 2 =*/58).bytes(message.buildHash); + if (message.companionProps != null && Object.hasOwnProperty.call(message, "companionProps")) + writer.uint32(/* id 8, wireType 2 =*/66).bytes(message.companionProps); + return writer; + }; + + /** + * Encodes the specified CompanionRegData message, length delimited. Does not implicitly {@link proto.CompanionRegData.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.CompanionRegData + * @static + * @param {proto.ICompanionRegData} message CompanionRegData message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompanionRegData.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CompanionRegData message from the specified reader or buffer. + * @function decode + * @memberof proto.CompanionRegData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.CompanionRegData} CompanionRegData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompanionRegData.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.CompanionRegData(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.eRegid = reader.bytes(); + break; + case 2: + message.eKeytype = reader.bytes(); + break; + case 3: + message.eIdent = reader.bytes(); + break; + case 4: + message.eSkeyId = reader.bytes(); + break; + case 5: + message.eSkeyVal = reader.bytes(); + break; + case 6: + message.eSkeySig = reader.bytes(); + break; + case 7: + message.buildHash = reader.bytes(); + break; + case 8: + message.companionProps = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CompanionRegData message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.CompanionRegData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.CompanionRegData} CompanionRegData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompanionRegData.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CompanionRegData message. + * @function verify + * @memberof proto.CompanionRegData + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CompanionRegData.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.eRegid != null && message.hasOwnProperty("eRegid")) + if (!(message.eRegid && typeof message.eRegid.length === "number" || $util.isString(message.eRegid))) + return "eRegid: buffer expected"; + if (message.eKeytype != null && message.hasOwnProperty("eKeytype")) + if (!(message.eKeytype && typeof message.eKeytype.length === "number" || $util.isString(message.eKeytype))) + return "eKeytype: buffer expected"; + if (message.eIdent != null && message.hasOwnProperty("eIdent")) + if (!(message.eIdent && typeof message.eIdent.length === "number" || $util.isString(message.eIdent))) + return "eIdent: buffer expected"; + if (message.eSkeyId != null && message.hasOwnProperty("eSkeyId")) + if (!(message.eSkeyId && typeof message.eSkeyId.length === "number" || $util.isString(message.eSkeyId))) + return "eSkeyId: buffer expected"; + if (message.eSkeyVal != null && message.hasOwnProperty("eSkeyVal")) + if (!(message.eSkeyVal && typeof message.eSkeyVal.length === "number" || $util.isString(message.eSkeyVal))) + return "eSkeyVal: buffer expected"; + if (message.eSkeySig != null && message.hasOwnProperty("eSkeySig")) + if (!(message.eSkeySig && typeof message.eSkeySig.length === "number" || $util.isString(message.eSkeySig))) + return "eSkeySig: buffer expected"; + if (message.buildHash != null && message.hasOwnProperty("buildHash")) + if (!(message.buildHash && typeof message.buildHash.length === "number" || $util.isString(message.buildHash))) + return "buildHash: buffer expected"; + if (message.companionProps != null && message.hasOwnProperty("companionProps")) + if (!(message.companionProps && typeof message.companionProps.length === "number" || $util.isString(message.companionProps))) + return "companionProps: buffer expected"; + return null; + }; + + /** + * Creates a CompanionRegData message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.CompanionRegData + * @static + * @param {Object.} object Plain object + * @returns {proto.CompanionRegData} CompanionRegData + */ + CompanionRegData.fromObject = function fromObject(object) { + if (object instanceof $root.proto.CompanionRegData) + return object; + var message = new $root.proto.CompanionRegData(); + if (object.eRegid != null) + if (typeof object.eRegid === "string") + $util.base64.decode(object.eRegid, message.eRegid = $util.newBuffer($util.base64.length(object.eRegid)), 0); + else if (object.eRegid.length) + message.eRegid = object.eRegid; + if (object.eKeytype != null) + if (typeof object.eKeytype === "string") + $util.base64.decode(object.eKeytype, message.eKeytype = $util.newBuffer($util.base64.length(object.eKeytype)), 0); + else if (object.eKeytype.length) + message.eKeytype = object.eKeytype; + if (object.eIdent != null) + if (typeof object.eIdent === "string") + $util.base64.decode(object.eIdent, message.eIdent = $util.newBuffer($util.base64.length(object.eIdent)), 0); + else if (object.eIdent.length) + message.eIdent = object.eIdent; + if (object.eSkeyId != null) + if (typeof object.eSkeyId === "string") + $util.base64.decode(object.eSkeyId, message.eSkeyId = $util.newBuffer($util.base64.length(object.eSkeyId)), 0); + else if (object.eSkeyId.length) + message.eSkeyId = object.eSkeyId; + if (object.eSkeyVal != null) + if (typeof object.eSkeyVal === "string") + $util.base64.decode(object.eSkeyVal, message.eSkeyVal = $util.newBuffer($util.base64.length(object.eSkeyVal)), 0); + else if (object.eSkeyVal.length) + message.eSkeyVal = object.eSkeyVal; + if (object.eSkeySig != null) + if (typeof object.eSkeySig === "string") + $util.base64.decode(object.eSkeySig, message.eSkeySig = $util.newBuffer($util.base64.length(object.eSkeySig)), 0); + else if (object.eSkeySig.length) + message.eSkeySig = object.eSkeySig; + if (object.buildHash != null) + if (typeof object.buildHash === "string") + $util.base64.decode(object.buildHash, message.buildHash = $util.newBuffer($util.base64.length(object.buildHash)), 0); + else if (object.buildHash.length) + message.buildHash = object.buildHash; + if (object.companionProps != null) + if (typeof object.companionProps === "string") + $util.base64.decode(object.companionProps, message.companionProps = $util.newBuffer($util.base64.length(object.companionProps)), 0); + else if (object.companionProps.length) + message.companionProps = object.companionProps; + return message; + }; + + /** + * Creates a plain object from a CompanionRegData message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.CompanionRegData + * @static + * @param {proto.CompanionRegData} message CompanionRegData + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompanionRegData.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if (options.bytes === String) + object.eRegid = ""; + else { + object.eRegid = []; + if (options.bytes !== Array) + object.eRegid = $util.newBuffer(object.eRegid); + } + if (options.bytes === String) + object.eKeytype = ""; + else { + object.eKeytype = []; + if (options.bytes !== Array) + object.eKeytype = $util.newBuffer(object.eKeytype); + } + if (options.bytes === String) + object.eIdent = ""; + else { + object.eIdent = []; + if (options.bytes !== Array) + object.eIdent = $util.newBuffer(object.eIdent); + } + if (options.bytes === String) + object.eSkeyId = ""; + else { + object.eSkeyId = []; + if (options.bytes !== Array) + object.eSkeyId = $util.newBuffer(object.eSkeyId); + } + if (options.bytes === String) + object.eSkeyVal = ""; + else { + object.eSkeyVal = []; + if (options.bytes !== Array) + object.eSkeyVal = $util.newBuffer(object.eSkeyVal); + } + if (options.bytes === String) + object.eSkeySig = ""; + else { + object.eSkeySig = []; + if (options.bytes !== Array) + object.eSkeySig = $util.newBuffer(object.eSkeySig); + } + if (options.bytes === String) + object.buildHash = ""; + else { + object.buildHash = []; + if (options.bytes !== Array) + object.buildHash = $util.newBuffer(object.buildHash); + } + if (options.bytes === String) + object.companionProps = ""; + else { + object.companionProps = []; + if (options.bytes !== Array) + object.companionProps = $util.newBuffer(object.companionProps); + } + } + if (message.eRegid != null && message.hasOwnProperty("eRegid")) + object.eRegid = options.bytes === String ? $util.base64.encode(message.eRegid, 0, message.eRegid.length) : options.bytes === Array ? Array.prototype.slice.call(message.eRegid) : message.eRegid; + if (message.eKeytype != null && message.hasOwnProperty("eKeytype")) + object.eKeytype = options.bytes === String ? $util.base64.encode(message.eKeytype, 0, message.eKeytype.length) : options.bytes === Array ? Array.prototype.slice.call(message.eKeytype) : message.eKeytype; + if (message.eIdent != null && message.hasOwnProperty("eIdent")) + object.eIdent = options.bytes === String ? $util.base64.encode(message.eIdent, 0, message.eIdent.length) : options.bytes === Array ? Array.prototype.slice.call(message.eIdent) : message.eIdent; + if (message.eSkeyId != null && message.hasOwnProperty("eSkeyId")) + object.eSkeyId = options.bytes === String ? $util.base64.encode(message.eSkeyId, 0, message.eSkeyId.length) : options.bytes === Array ? Array.prototype.slice.call(message.eSkeyId) : message.eSkeyId; + if (message.eSkeyVal != null && message.hasOwnProperty("eSkeyVal")) + object.eSkeyVal = options.bytes === String ? $util.base64.encode(message.eSkeyVal, 0, message.eSkeyVal.length) : options.bytes === Array ? Array.prototype.slice.call(message.eSkeyVal) : message.eSkeyVal; + if (message.eSkeySig != null && message.hasOwnProperty("eSkeySig")) + object.eSkeySig = options.bytes === String ? $util.base64.encode(message.eSkeySig, 0, message.eSkeySig.length) : options.bytes === Array ? Array.prototype.slice.call(message.eSkeySig) : message.eSkeySig; + if (message.buildHash != null && message.hasOwnProperty("buildHash")) + object.buildHash = options.bytes === String ? $util.base64.encode(message.buildHash, 0, message.buildHash.length) : options.bytes === Array ? Array.prototype.slice.call(message.buildHash) : message.buildHash; + if (message.companionProps != null && message.hasOwnProperty("companionProps")) + object.companionProps = options.bytes === String ? $util.base64.encode(message.companionProps, 0, message.companionProps.length) : options.bytes === Array ? Array.prototype.slice.call(message.companionProps) : message.companionProps; + return object; + }; + + /** + * Converts this CompanionRegData to JSON. + * @function toJSON + * @memberof proto.CompanionRegData + * @instance + * @returns {Object.} JSON object + */ + CompanionRegData.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CompanionRegData; + })(); + + proto.ClientPayload = (function() { + + /** + * Properties of a ClientPayload. + * @memberof proto + * @interface IClientPayload + * @property {number|Long|null} [username] ClientPayload username + * @property {boolean|null} [passive] ClientPayload passive + * @property {Array.|null} [clientFeatures] ClientPayload clientFeatures + * @property {proto.IUserAgent|null} [userAgent] ClientPayload userAgent + * @property {proto.IWebInfo|null} [webInfo] ClientPayload webInfo + * @property {string|null} [pushName] ClientPayload pushName + * @property {number|null} [sessionId] ClientPayload sessionId + * @property {boolean|null} [shortConnect] ClientPayload shortConnect + * @property {proto.ClientPayload.ClientPayloadIOSAppExtension|null} [iosAppExtension] ClientPayload iosAppExtension + * @property {proto.ClientPayload.ClientPayloadConnectType|null} [connectType] ClientPayload connectType + * @property {proto.ClientPayload.ClientPayloadConnectReason|null} [connectReason] ClientPayload connectReason + * @property {Array.|null} [shards] ClientPayload shards + * @property {proto.IDNSSource|null} [dnsSource] ClientPayload dnsSource + * @property {number|null} [connectAttemptCount] ClientPayload connectAttemptCount + * @property {number|null} [agent] ClientPayload agent + * @property {number|null} [device] ClientPayload device + * @property {proto.ICompanionRegData|null} [regData] ClientPayload regData + * @property {proto.ClientPayload.ClientPayloadProduct|null} [product] ClientPayload product + * @property {Uint8Array|null} [fbCat] ClientPayload fbCat + * @property {Uint8Array|null} [fbUserAgent] ClientPayload fbUserAgent + * @property {boolean|null} [oc] ClientPayload oc + */ + + /** + * Constructs a new ClientPayload. + * @memberof proto + * @classdesc Represents a ClientPayload. + * @implements IClientPayload + * @constructor + * @param {proto.IClientPayload=} [properties] Properties to set + */ + function ClientPayload(properties) { + this.clientFeatures = []; + this.shards = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ClientPayload username. + * @member {number|Long} username + * @memberof proto.ClientPayload + * @instance + */ + ClientPayload.prototype.username = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * ClientPayload passive. + * @member {boolean} passive + * @memberof proto.ClientPayload + * @instance + */ + ClientPayload.prototype.passive = false; + + /** + * ClientPayload clientFeatures. + * @member {Array.} clientFeatures + * @memberof proto.ClientPayload + * @instance + */ + ClientPayload.prototype.clientFeatures = $util.emptyArray; + + /** + * ClientPayload userAgent. + * @member {proto.IUserAgent|null|undefined} userAgent + * @memberof proto.ClientPayload + * @instance + */ + ClientPayload.prototype.userAgent = null; + + /** + * ClientPayload webInfo. + * @member {proto.IWebInfo|null|undefined} webInfo + * @memberof proto.ClientPayload + * @instance + */ + ClientPayload.prototype.webInfo = null; + + /** + * ClientPayload pushName. + * @member {string} pushName + * @memberof proto.ClientPayload + * @instance + */ + ClientPayload.prototype.pushName = ""; + + /** + * ClientPayload sessionId. + * @member {number} sessionId + * @memberof proto.ClientPayload + * @instance + */ + ClientPayload.prototype.sessionId = 0; + + /** + * ClientPayload shortConnect. + * @member {boolean} shortConnect + * @memberof proto.ClientPayload + * @instance + */ + ClientPayload.prototype.shortConnect = false; + + /** + * ClientPayload iosAppExtension. + * @member {proto.ClientPayload.ClientPayloadIOSAppExtension} iosAppExtension + * @memberof proto.ClientPayload + * @instance + */ + ClientPayload.prototype.iosAppExtension = 0; + + /** + * ClientPayload connectType. + * @member {proto.ClientPayload.ClientPayloadConnectType} connectType + * @memberof proto.ClientPayload + * @instance + */ + ClientPayload.prototype.connectType = 0; + + /** + * ClientPayload connectReason. + * @member {proto.ClientPayload.ClientPayloadConnectReason} connectReason + * @memberof proto.ClientPayload + * @instance + */ + ClientPayload.prototype.connectReason = 0; + + /** + * ClientPayload shards. + * @member {Array.} shards + * @memberof proto.ClientPayload + * @instance + */ + ClientPayload.prototype.shards = $util.emptyArray; + + /** + * ClientPayload dnsSource. + * @member {proto.IDNSSource|null|undefined} dnsSource + * @memberof proto.ClientPayload + * @instance + */ + ClientPayload.prototype.dnsSource = null; + + /** + * ClientPayload connectAttemptCount. + * @member {number} connectAttemptCount + * @memberof proto.ClientPayload + * @instance + */ + ClientPayload.prototype.connectAttemptCount = 0; + + /** + * ClientPayload agent. + * @member {number} agent + * @memberof proto.ClientPayload + * @instance + */ + ClientPayload.prototype.agent = 0; + + /** + * ClientPayload device. + * @member {number} device + * @memberof proto.ClientPayload + * @instance + */ + ClientPayload.prototype.device = 0; + + /** + * ClientPayload regData. + * @member {proto.ICompanionRegData|null|undefined} regData + * @memberof proto.ClientPayload + * @instance + */ + ClientPayload.prototype.regData = null; + + /** + * ClientPayload product. + * @member {proto.ClientPayload.ClientPayloadProduct} product + * @memberof proto.ClientPayload + * @instance + */ + ClientPayload.prototype.product = 0; + + /** + * ClientPayload fbCat. + * @member {Uint8Array} fbCat + * @memberof proto.ClientPayload + * @instance + */ + ClientPayload.prototype.fbCat = $util.newBuffer([]); + + /** + * ClientPayload fbUserAgent. + * @member {Uint8Array} fbUserAgent + * @memberof proto.ClientPayload + * @instance + */ + ClientPayload.prototype.fbUserAgent = $util.newBuffer([]); + + /** + * ClientPayload oc. + * @member {boolean} oc + * @memberof proto.ClientPayload + * @instance + */ + ClientPayload.prototype.oc = false; + + /** + * Creates a new ClientPayload instance using the specified properties. + * @function create + * @memberof proto.ClientPayload + * @static + * @param {proto.IClientPayload=} [properties] Properties to set + * @returns {proto.ClientPayload} ClientPayload instance + */ + ClientPayload.create = function create(properties) { + return new ClientPayload(properties); + }; + + /** + * Encodes the specified ClientPayload message. Does not implicitly {@link proto.ClientPayload.verify|verify} messages. + * @function encode + * @memberof proto.ClientPayload + * @static + * @param {proto.IClientPayload} message ClientPayload message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ClientPayload.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.username != null && Object.hasOwnProperty.call(message, "username")) + writer.uint32(/* id 1, wireType 0 =*/8).uint64(message.username); + if (message.passive != null && Object.hasOwnProperty.call(message, "passive")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.passive); + if (message.clientFeatures != null && message.clientFeatures.length) + for (var i = 0; i < message.clientFeatures.length; ++i) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.clientFeatures[i]); + if (message.userAgent != null && Object.hasOwnProperty.call(message, "userAgent")) + $root.proto.UserAgent.encode(message.userAgent, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.webInfo != null && Object.hasOwnProperty.call(message, "webInfo")) + $root.proto.WebInfo.encode(message.webInfo, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.pushName != null && Object.hasOwnProperty.call(message, "pushName")) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.pushName); + if (message.sessionId != null && Object.hasOwnProperty.call(message, "sessionId")) + writer.uint32(/* id 9, wireType 5 =*/77).sfixed32(message.sessionId); + if (message.shortConnect != null && Object.hasOwnProperty.call(message, "shortConnect")) + writer.uint32(/* id 10, wireType 0 =*/80).bool(message.shortConnect); + if (message.connectType != null && Object.hasOwnProperty.call(message, "connectType")) + writer.uint32(/* id 12, wireType 0 =*/96).int32(message.connectType); + if (message.connectReason != null && Object.hasOwnProperty.call(message, "connectReason")) + writer.uint32(/* id 13, wireType 0 =*/104).int32(message.connectReason); + if (message.shards != null && message.shards.length) + for (var i = 0; i < message.shards.length; ++i) + writer.uint32(/* id 14, wireType 0 =*/112).int32(message.shards[i]); + if (message.dnsSource != null && Object.hasOwnProperty.call(message, "dnsSource")) + $root.proto.DNSSource.encode(message.dnsSource, writer.uint32(/* id 15, wireType 2 =*/122).fork()).ldelim(); + if (message.connectAttemptCount != null && Object.hasOwnProperty.call(message, "connectAttemptCount")) + writer.uint32(/* id 16, wireType 0 =*/128).uint32(message.connectAttemptCount); + if (message.agent != null && Object.hasOwnProperty.call(message, "agent")) + writer.uint32(/* id 17, wireType 0 =*/136).uint32(message.agent); + if (message.device != null && Object.hasOwnProperty.call(message, "device")) + writer.uint32(/* id 18, wireType 0 =*/144).uint32(message.device); + if (message.regData != null && Object.hasOwnProperty.call(message, "regData")) + $root.proto.CompanionRegData.encode(message.regData, writer.uint32(/* id 19, wireType 2 =*/154).fork()).ldelim(); + if (message.product != null && Object.hasOwnProperty.call(message, "product")) + writer.uint32(/* id 20, wireType 0 =*/160).int32(message.product); + if (message.fbCat != null && Object.hasOwnProperty.call(message, "fbCat")) + writer.uint32(/* id 21, wireType 2 =*/170).bytes(message.fbCat); + if (message.fbUserAgent != null && Object.hasOwnProperty.call(message, "fbUserAgent")) + writer.uint32(/* id 22, wireType 2 =*/178).bytes(message.fbUserAgent); + if (message.oc != null && Object.hasOwnProperty.call(message, "oc")) + writer.uint32(/* id 23, wireType 0 =*/184).bool(message.oc); + if (message.iosAppExtension != null && Object.hasOwnProperty.call(message, "iosAppExtension")) + writer.uint32(/* id 30, wireType 0 =*/240).int32(message.iosAppExtension); + return writer; + }; + + /** + * Encodes the specified ClientPayload message, length delimited. Does not implicitly {@link proto.ClientPayload.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.ClientPayload + * @static + * @param {proto.IClientPayload} message ClientPayload message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ClientPayload.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ClientPayload message from the specified reader or buffer. + * @function decode + * @memberof proto.ClientPayload + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.ClientPayload} ClientPayload + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ClientPayload.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.ClientPayload(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.username = reader.uint64(); + break; + case 3: + message.passive = reader.bool(); + break; + case 4: + if (!(message.clientFeatures && message.clientFeatures.length)) + message.clientFeatures = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.clientFeatures.push(reader.int32()); + } else + message.clientFeatures.push(reader.int32()); + break; + case 5: + message.userAgent = $root.proto.UserAgent.decode(reader, reader.uint32()); + break; + case 6: + message.webInfo = $root.proto.WebInfo.decode(reader, reader.uint32()); + break; + case 7: + message.pushName = reader.string(); + break; + case 9: + message.sessionId = reader.sfixed32(); + break; + case 10: + message.shortConnect = reader.bool(); + break; + case 30: + message.iosAppExtension = reader.int32(); + break; + case 12: + message.connectType = reader.int32(); + break; + case 13: + message.connectReason = reader.int32(); + break; + case 14: + if (!(message.shards && message.shards.length)) + message.shards = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.shards.push(reader.int32()); + } else + message.shards.push(reader.int32()); + break; + case 15: + message.dnsSource = $root.proto.DNSSource.decode(reader, reader.uint32()); + break; + case 16: + message.connectAttemptCount = reader.uint32(); + break; + case 17: + message.agent = reader.uint32(); + break; + case 18: + message.device = reader.uint32(); + break; + case 19: + message.regData = $root.proto.CompanionRegData.decode(reader, reader.uint32()); + break; + case 20: + message.product = reader.int32(); + break; + case 21: + message.fbCat = reader.bytes(); + break; + case 22: + message.fbUserAgent = reader.bytes(); + break; + case 23: + message.oc = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ClientPayload message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.ClientPayload + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.ClientPayload} ClientPayload + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ClientPayload.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ClientPayload message. + * @function verify + * @memberof proto.ClientPayload + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ClientPayload.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.username != null && message.hasOwnProperty("username")) + if (!$util.isInteger(message.username) && !(message.username && $util.isInteger(message.username.low) && $util.isInteger(message.username.high))) + return "username: integer|Long expected"; + if (message.passive != null && message.hasOwnProperty("passive")) + if (typeof message.passive !== "boolean") + return "passive: boolean expected"; + if (message.clientFeatures != null && message.hasOwnProperty("clientFeatures")) { + if (!Array.isArray(message.clientFeatures)) + return "clientFeatures: array expected"; + for (var i = 0; i < message.clientFeatures.length; ++i) + switch (message.clientFeatures[i]) { + default: + return "clientFeatures: enum value[] expected"; + case 0: + break; + } + } + if (message.userAgent != null && message.hasOwnProperty("userAgent")) { + var error = $root.proto.UserAgent.verify(message.userAgent); + if (error) + return "userAgent." + error; + } + if (message.webInfo != null && message.hasOwnProperty("webInfo")) { + var error = $root.proto.WebInfo.verify(message.webInfo); + if (error) + return "webInfo." + error; + } + if (message.pushName != null && message.hasOwnProperty("pushName")) + if (!$util.isString(message.pushName)) + return "pushName: string expected"; + if (message.sessionId != null && message.hasOwnProperty("sessionId")) + if (!$util.isInteger(message.sessionId)) + return "sessionId: integer expected"; + if (message.shortConnect != null && message.hasOwnProperty("shortConnect")) + if (typeof message.shortConnect !== "boolean") + return "shortConnect: boolean expected"; + if (message.iosAppExtension != null && message.hasOwnProperty("iosAppExtension")) + switch (message.iosAppExtension) { + default: + return "iosAppExtension: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.connectType != null && message.hasOwnProperty("connectType")) + switch (message.connectType) { + default: + return "connectType: enum value expected"; + case 0: + case 1: + case 100: + case 101: + case 102: + case 103: + case 104: + case 105: + case 106: + case 107: + case 108: + case 109: + case 110: + case 111: + case 112: + break; + } + if (message.connectReason != null && message.hasOwnProperty("connectReason")) + switch (message.connectReason) { + default: + return "connectReason: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + break; + } + if (message.shards != null && message.hasOwnProperty("shards")) { + if (!Array.isArray(message.shards)) + return "shards: array expected"; + for (var i = 0; i < message.shards.length; ++i) + if (!$util.isInteger(message.shards[i])) + return "shards: integer[] expected"; + } + if (message.dnsSource != null && message.hasOwnProperty("dnsSource")) { + var error = $root.proto.DNSSource.verify(message.dnsSource); + if (error) + return "dnsSource." + error; + } + if (message.connectAttemptCount != null && message.hasOwnProperty("connectAttemptCount")) + if (!$util.isInteger(message.connectAttemptCount)) + return "connectAttemptCount: integer expected"; + if (message.agent != null && message.hasOwnProperty("agent")) + if (!$util.isInteger(message.agent)) + return "agent: integer expected"; + if (message.device != null && message.hasOwnProperty("device")) + if (!$util.isInteger(message.device)) + return "device: integer expected"; + if (message.regData != null && message.hasOwnProperty("regData")) { + var error = $root.proto.CompanionRegData.verify(message.regData); + if (error) + return "regData." + error; + } + if (message.product != null && message.hasOwnProperty("product")) + switch (message.product) { + default: + return "product: enum value expected"; + case 0: + case 1: + break; + } + if (message.fbCat != null && message.hasOwnProperty("fbCat")) + if (!(message.fbCat && typeof message.fbCat.length === "number" || $util.isString(message.fbCat))) + return "fbCat: buffer expected"; + if (message.fbUserAgent != null && message.hasOwnProperty("fbUserAgent")) + if (!(message.fbUserAgent && typeof message.fbUserAgent.length === "number" || $util.isString(message.fbUserAgent))) + return "fbUserAgent: buffer expected"; + if (message.oc != null && message.hasOwnProperty("oc")) + if (typeof message.oc !== "boolean") + return "oc: boolean expected"; + return null; + }; + + /** + * Creates a ClientPayload message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.ClientPayload + * @static + * @param {Object.} object Plain object + * @returns {proto.ClientPayload} ClientPayload + */ + ClientPayload.fromObject = function fromObject(object) { + if (object instanceof $root.proto.ClientPayload) + return object; + var message = new $root.proto.ClientPayload(); + if (object.username != null) + if ($util.Long) + (message.username = $util.Long.fromValue(object.username)).unsigned = true; + else if (typeof object.username === "string") + message.username = parseInt(object.username, 10); + else if (typeof object.username === "number") + message.username = object.username; + else if (typeof object.username === "object") + message.username = new $util.LongBits(object.username.low >>> 0, object.username.high >>> 0).toNumber(true); + if (object.passive != null) + message.passive = Boolean(object.passive); + if (object.clientFeatures) { + if (!Array.isArray(object.clientFeatures)) + throw TypeError(".proto.ClientPayload.clientFeatures: array expected"); + message.clientFeatures = []; + for (var i = 0; i < object.clientFeatures.length; ++i) + switch (object.clientFeatures[i]) { + default: + case "NONE": + case 0: + message.clientFeatures[i] = 0; + break; + } + } + if (object.userAgent != null) { + if (typeof object.userAgent !== "object") + throw TypeError(".proto.ClientPayload.userAgent: object expected"); + message.userAgent = $root.proto.UserAgent.fromObject(object.userAgent); + } + if (object.webInfo != null) { + if (typeof object.webInfo !== "object") + throw TypeError(".proto.ClientPayload.webInfo: object expected"); + message.webInfo = $root.proto.WebInfo.fromObject(object.webInfo); + } + if (object.pushName != null) + message.pushName = String(object.pushName); + if (object.sessionId != null) + message.sessionId = object.sessionId | 0; + if (object.shortConnect != null) + message.shortConnect = Boolean(object.shortConnect); + switch (object.iosAppExtension) { + case "SHARE_EXTENSION": + case 0: + message.iosAppExtension = 0; + break; + case "SERVICE_EXTENSION": + case 1: + message.iosAppExtension = 1; + break; + case "INTENTS_EXTENSION": + case 2: + message.iosAppExtension = 2; + break; + } + switch (object.connectType) { + case "CELLULAR_UNKNOWN": + case 0: + message.connectType = 0; + break; + case "WIFI_UNKNOWN": + case 1: + message.connectType = 1; + break; + case "CELLULAR_EDGE": + case 100: + message.connectType = 100; + break; + case "CELLULAR_IDEN": + case 101: + message.connectType = 101; + break; + case "CELLULAR_UMTS": + case 102: + message.connectType = 102; + break; + case "CELLULAR_EVDO": + case 103: + message.connectType = 103; + break; + case "CELLULAR_GPRS": + case 104: + message.connectType = 104; + break; + case "CELLULAR_HSDPA": + case 105: + message.connectType = 105; + break; + case "CELLULAR_HSUPA": + case 106: + message.connectType = 106; + break; + case "CELLULAR_HSPA": + case 107: + message.connectType = 107; + break; + case "CELLULAR_CDMA": + case 108: + message.connectType = 108; + break; + case "CELLULAR_1XRTT": + case 109: + message.connectType = 109; + break; + case "CELLULAR_EHRPD": + case 110: + message.connectType = 110; + break; + case "CELLULAR_LTE": + case 111: + message.connectType = 111; + break; + case "CELLULAR_HSPAP": + case 112: + message.connectType = 112; + break; + } + switch (object.connectReason) { + case "PUSH": + case 0: + message.connectReason = 0; + break; + case "USER_ACTIVATED": + case 1: + message.connectReason = 1; + break; + case "SCHEDULED": + case 2: + message.connectReason = 2; + break; + case "ERROR_RECONNECT": + case 3: + message.connectReason = 3; + break; + case "NETWORK_SWITCH": + case 4: + message.connectReason = 4; + break; + case "PING_RECONNECT": + case 5: + message.connectReason = 5; + break; + } + if (object.shards) { + if (!Array.isArray(object.shards)) + throw TypeError(".proto.ClientPayload.shards: array expected"); + message.shards = []; + for (var i = 0; i < object.shards.length; ++i) + message.shards[i] = object.shards[i] | 0; + } + if (object.dnsSource != null) { + if (typeof object.dnsSource !== "object") + throw TypeError(".proto.ClientPayload.dnsSource: object expected"); + message.dnsSource = $root.proto.DNSSource.fromObject(object.dnsSource); + } + if (object.connectAttemptCount != null) + message.connectAttemptCount = object.connectAttemptCount >>> 0; + if (object.agent != null) + message.agent = object.agent >>> 0; + if (object.device != null) + message.device = object.device >>> 0; + if (object.regData != null) { + if (typeof object.regData !== "object") + throw TypeError(".proto.ClientPayload.regData: object expected"); + message.regData = $root.proto.CompanionRegData.fromObject(object.regData); + } + switch (object.product) { + case "WHATSAPP": + case 0: + message.product = 0; + break; + case "MESSENGER": + case 1: + message.product = 1; + break; + } + if (object.fbCat != null) + if (typeof object.fbCat === "string") + $util.base64.decode(object.fbCat, message.fbCat = $util.newBuffer($util.base64.length(object.fbCat)), 0); + else if (object.fbCat.length) + message.fbCat = object.fbCat; + if (object.fbUserAgent != null) + if (typeof object.fbUserAgent === "string") + $util.base64.decode(object.fbUserAgent, message.fbUserAgent = $util.newBuffer($util.base64.length(object.fbUserAgent)), 0); + else if (object.fbUserAgent.length) + message.fbUserAgent = object.fbUserAgent; + if (object.oc != null) + message.oc = Boolean(object.oc); + return message; + }; + + /** + * Creates a plain object from a ClientPayload message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.ClientPayload + * @static + * @param {proto.ClientPayload} message ClientPayload + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ClientPayload.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.clientFeatures = []; + object.shards = []; + } + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.username = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.username = options.longs === String ? "0" : 0; + object.passive = false; + object.userAgent = null; + object.webInfo = null; + object.pushName = ""; + object.sessionId = 0; + object.shortConnect = false; + object.connectType = options.enums === String ? "CELLULAR_UNKNOWN" : 0; + object.connectReason = options.enums === String ? "PUSH" : 0; + object.dnsSource = null; + object.connectAttemptCount = 0; + object.agent = 0; + object.device = 0; + object.regData = null; + object.product = options.enums === String ? "WHATSAPP" : 0; + if (options.bytes === String) + object.fbCat = ""; + else { + object.fbCat = []; + if (options.bytes !== Array) + object.fbCat = $util.newBuffer(object.fbCat); + } + if (options.bytes === String) + object.fbUserAgent = ""; + else { + object.fbUserAgent = []; + if (options.bytes !== Array) + object.fbUserAgent = $util.newBuffer(object.fbUserAgent); + } + object.oc = false; + object.iosAppExtension = options.enums === String ? "SHARE_EXTENSION" : 0; + } + if (message.username != null && message.hasOwnProperty("username")) + if (typeof message.username === "number") + object.username = options.longs === String ? String(message.username) : message.username; + else + object.username = options.longs === String ? $util.Long.prototype.toString.call(message.username) : options.longs === Number ? new $util.LongBits(message.username.low >>> 0, message.username.high >>> 0).toNumber(true) : message.username; + if (message.passive != null && message.hasOwnProperty("passive")) + object.passive = message.passive; + if (message.clientFeatures && message.clientFeatures.length) { + object.clientFeatures = []; + for (var j = 0; j < message.clientFeatures.length; ++j) + object.clientFeatures[j] = options.enums === String ? $root.proto.ClientPayload.ClientPayloadClientFeature[message.clientFeatures[j]] : message.clientFeatures[j]; + } + if (message.userAgent != null && message.hasOwnProperty("userAgent")) + object.userAgent = $root.proto.UserAgent.toObject(message.userAgent, options); + if (message.webInfo != null && message.hasOwnProperty("webInfo")) + object.webInfo = $root.proto.WebInfo.toObject(message.webInfo, options); + if (message.pushName != null && message.hasOwnProperty("pushName")) + object.pushName = message.pushName; + if (message.sessionId != null && message.hasOwnProperty("sessionId")) + object.sessionId = message.sessionId; + if (message.shortConnect != null && message.hasOwnProperty("shortConnect")) + object.shortConnect = message.shortConnect; + if (message.connectType != null && message.hasOwnProperty("connectType")) + object.connectType = options.enums === String ? $root.proto.ClientPayload.ClientPayloadConnectType[message.connectType] : message.connectType; + if (message.connectReason != null && message.hasOwnProperty("connectReason")) + object.connectReason = options.enums === String ? $root.proto.ClientPayload.ClientPayloadConnectReason[message.connectReason] : message.connectReason; + if (message.shards && message.shards.length) { + object.shards = []; + for (var j = 0; j < message.shards.length; ++j) + object.shards[j] = message.shards[j]; + } + if (message.dnsSource != null && message.hasOwnProperty("dnsSource")) + object.dnsSource = $root.proto.DNSSource.toObject(message.dnsSource, options); + if (message.connectAttemptCount != null && message.hasOwnProperty("connectAttemptCount")) + object.connectAttemptCount = message.connectAttemptCount; + if (message.agent != null && message.hasOwnProperty("agent")) + object.agent = message.agent; + if (message.device != null && message.hasOwnProperty("device")) + object.device = message.device; + if (message.regData != null && message.hasOwnProperty("regData")) + object.regData = $root.proto.CompanionRegData.toObject(message.regData, options); + if (message.product != null && message.hasOwnProperty("product")) + object.product = options.enums === String ? $root.proto.ClientPayload.ClientPayloadProduct[message.product] : message.product; + if (message.fbCat != null && message.hasOwnProperty("fbCat")) + object.fbCat = options.bytes === String ? $util.base64.encode(message.fbCat, 0, message.fbCat.length) : options.bytes === Array ? Array.prototype.slice.call(message.fbCat) : message.fbCat; + if (message.fbUserAgent != null && message.hasOwnProperty("fbUserAgent")) + object.fbUserAgent = options.bytes === String ? $util.base64.encode(message.fbUserAgent, 0, message.fbUserAgent.length) : options.bytes === Array ? Array.prototype.slice.call(message.fbUserAgent) : message.fbUserAgent; + if (message.oc != null && message.hasOwnProperty("oc")) + object.oc = message.oc; + if (message.iosAppExtension != null && message.hasOwnProperty("iosAppExtension")) + object.iosAppExtension = options.enums === String ? $root.proto.ClientPayload.ClientPayloadIOSAppExtension[message.iosAppExtension] : message.iosAppExtension; + return object; + }; + + /** + * Converts this ClientPayload to JSON. + * @function toJSON + * @memberof proto.ClientPayload + * @instance + * @returns {Object.} JSON object + */ + ClientPayload.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * ClientPayloadClientFeature enum. + * @name proto.ClientPayload.ClientPayloadClientFeature + * @enum {number} + * @property {number} NONE=0 NONE value + */ + ClientPayload.ClientPayloadClientFeature = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "NONE"] = 0; + return values; + })(); + + /** + * ClientPayloadIOSAppExtension enum. + * @name proto.ClientPayload.ClientPayloadIOSAppExtension + * @enum {number} + * @property {number} SHARE_EXTENSION=0 SHARE_EXTENSION value + * @property {number} SERVICE_EXTENSION=1 SERVICE_EXTENSION value + * @property {number} INTENTS_EXTENSION=2 INTENTS_EXTENSION value + */ + ClientPayload.ClientPayloadIOSAppExtension = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SHARE_EXTENSION"] = 0; + values[valuesById[1] = "SERVICE_EXTENSION"] = 1; + values[valuesById[2] = "INTENTS_EXTENSION"] = 2; + return values; + })(); + + /** + * ClientPayloadConnectType enum. + * @name proto.ClientPayload.ClientPayloadConnectType + * @enum {number} + * @property {number} CELLULAR_UNKNOWN=0 CELLULAR_UNKNOWN value + * @property {number} WIFI_UNKNOWN=1 WIFI_UNKNOWN value + * @property {number} CELLULAR_EDGE=100 CELLULAR_EDGE value + * @property {number} CELLULAR_IDEN=101 CELLULAR_IDEN value + * @property {number} CELLULAR_UMTS=102 CELLULAR_UMTS value + * @property {number} CELLULAR_EVDO=103 CELLULAR_EVDO value + * @property {number} CELLULAR_GPRS=104 CELLULAR_GPRS value + * @property {number} CELLULAR_HSDPA=105 CELLULAR_HSDPA value + * @property {number} CELLULAR_HSUPA=106 CELLULAR_HSUPA value + * @property {number} CELLULAR_HSPA=107 CELLULAR_HSPA value + * @property {number} CELLULAR_CDMA=108 CELLULAR_CDMA value + * @property {number} CELLULAR_1XRTT=109 CELLULAR_1XRTT value + * @property {number} CELLULAR_EHRPD=110 CELLULAR_EHRPD value + * @property {number} CELLULAR_LTE=111 CELLULAR_LTE value + * @property {number} CELLULAR_HSPAP=112 CELLULAR_HSPAP value + */ + ClientPayload.ClientPayloadConnectType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "CELLULAR_UNKNOWN"] = 0; + values[valuesById[1] = "WIFI_UNKNOWN"] = 1; + values[valuesById[100] = "CELLULAR_EDGE"] = 100; + values[valuesById[101] = "CELLULAR_IDEN"] = 101; + values[valuesById[102] = "CELLULAR_UMTS"] = 102; + values[valuesById[103] = "CELLULAR_EVDO"] = 103; + values[valuesById[104] = "CELLULAR_GPRS"] = 104; + values[valuesById[105] = "CELLULAR_HSDPA"] = 105; + values[valuesById[106] = "CELLULAR_HSUPA"] = 106; + values[valuesById[107] = "CELLULAR_HSPA"] = 107; + values[valuesById[108] = "CELLULAR_CDMA"] = 108; + values[valuesById[109] = "CELLULAR_1XRTT"] = 109; + values[valuesById[110] = "CELLULAR_EHRPD"] = 110; + values[valuesById[111] = "CELLULAR_LTE"] = 111; + values[valuesById[112] = "CELLULAR_HSPAP"] = 112; + return values; + })(); + + /** + * ClientPayloadConnectReason enum. + * @name proto.ClientPayload.ClientPayloadConnectReason + * @enum {number} + * @property {number} PUSH=0 PUSH value + * @property {number} USER_ACTIVATED=1 USER_ACTIVATED value + * @property {number} SCHEDULED=2 SCHEDULED value + * @property {number} ERROR_RECONNECT=3 ERROR_RECONNECT value + * @property {number} NETWORK_SWITCH=4 NETWORK_SWITCH value + * @property {number} PING_RECONNECT=5 PING_RECONNECT value + */ + ClientPayload.ClientPayloadConnectReason = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "PUSH"] = 0; + values[valuesById[1] = "USER_ACTIVATED"] = 1; + values[valuesById[2] = "SCHEDULED"] = 2; + values[valuesById[3] = "ERROR_RECONNECT"] = 3; + values[valuesById[4] = "NETWORK_SWITCH"] = 4; + values[valuesById[5] = "PING_RECONNECT"] = 5; + return values; + })(); + + /** + * ClientPayloadProduct enum. + * @name proto.ClientPayload.ClientPayloadProduct + * @enum {number} + * @property {number} WHATSAPP=0 WHATSAPP value + * @property {number} MESSENGER=1 MESSENGER value + */ + ClientPayload.ClientPayloadProduct = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "WHATSAPP"] = 0; + values[valuesById[1] = "MESSENGER"] = 1; + return values; + })(); + + return ClientPayload; + })(); + + proto.Details = (function() { + + /** + * Properties of a Details. + * @memberof proto + * @interface IDetails + * @property {number|null} [serial] Details serial + * @property {string|null} [issuer] Details issuer + * @property {number|Long|null} [expires] Details expires + * @property {string|null} [subject] Details subject + * @property {Uint8Array|null} [key] Details key + */ + + /** + * Constructs a new Details. + * @memberof proto + * @classdesc Represents a Details. + * @implements IDetails + * @constructor + * @param {proto.IDetails=} [properties] Properties to set + */ + function Details(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Details serial. + * @member {number} serial + * @memberof proto.Details + * @instance + */ + Details.prototype.serial = 0; + + /** + * Details issuer. + * @member {string} issuer + * @memberof proto.Details + * @instance + */ + Details.prototype.issuer = ""; + + /** + * Details expires. + * @member {number|Long} expires + * @memberof proto.Details + * @instance + */ + Details.prototype.expires = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * Details subject. + * @member {string} subject + * @memberof proto.Details + * @instance + */ + Details.prototype.subject = ""; + + /** + * Details key. + * @member {Uint8Array} key + * @memberof proto.Details + * @instance + */ + Details.prototype.key = $util.newBuffer([]); + + /** + * Creates a new Details instance using the specified properties. + * @function create + * @memberof proto.Details + * @static + * @param {proto.IDetails=} [properties] Properties to set + * @returns {proto.Details} Details instance + */ + Details.create = function create(properties) { + return new Details(properties); + }; + + /** + * Encodes the specified Details message. Does not implicitly {@link proto.Details.verify|verify} messages. + * @function encode + * @memberof proto.Details + * @static + * @param {proto.IDetails} message Details message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Details.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.serial != null && Object.hasOwnProperty.call(message, "serial")) + writer.uint32(/* id 1, wireType 0 =*/8).uint32(message.serial); + if (message.issuer != null && Object.hasOwnProperty.call(message, "issuer")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.issuer); + if (message.expires != null && Object.hasOwnProperty.call(message, "expires")) + writer.uint32(/* id 3, wireType 0 =*/24).uint64(message.expires); + if (message.subject != null && Object.hasOwnProperty.call(message, "subject")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.subject); + if (message.key != null && Object.hasOwnProperty.call(message, "key")) + writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.key); + return writer; + }; + + /** + * Encodes the specified Details message, length delimited. Does not implicitly {@link proto.Details.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.Details + * @static + * @param {proto.IDetails} message Details message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Details.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Details message from the specified reader or buffer. + * @function decode + * @memberof proto.Details + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.Details} Details + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Details.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.Details(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.serial = reader.uint32(); + break; + case 2: + message.issuer = reader.string(); + break; + case 3: + message.expires = reader.uint64(); + break; + case 4: + message.subject = reader.string(); + break; + case 5: + message.key = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Details message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.Details + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.Details} Details + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Details.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Details message. + * @function verify + * @memberof proto.Details + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Details.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.serial != null && message.hasOwnProperty("serial")) + if (!$util.isInteger(message.serial)) + return "serial: integer expected"; + if (message.issuer != null && message.hasOwnProperty("issuer")) + if (!$util.isString(message.issuer)) + return "issuer: string expected"; + if (message.expires != null && message.hasOwnProperty("expires")) + if (!$util.isInteger(message.expires) && !(message.expires && $util.isInteger(message.expires.low) && $util.isInteger(message.expires.high))) + return "expires: integer|Long expected"; + if (message.subject != null && message.hasOwnProperty("subject")) + if (!$util.isString(message.subject)) + return "subject: string expected"; + if (message.key != null && message.hasOwnProperty("key")) + if (!(message.key && typeof message.key.length === "number" || $util.isString(message.key))) + return "key: buffer expected"; + return null; + }; + + /** + * Creates a Details message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.Details + * @static + * @param {Object.} object Plain object + * @returns {proto.Details} Details + */ + Details.fromObject = function fromObject(object) { + if (object instanceof $root.proto.Details) + return object; + var message = new $root.proto.Details(); + if (object.serial != null) + message.serial = object.serial >>> 0; + if (object.issuer != null) + message.issuer = String(object.issuer); + if (object.expires != null) + if ($util.Long) + (message.expires = $util.Long.fromValue(object.expires)).unsigned = true; + else if (typeof object.expires === "string") + message.expires = parseInt(object.expires, 10); + else if (typeof object.expires === "number") + message.expires = object.expires; + else if (typeof object.expires === "object") + message.expires = new $util.LongBits(object.expires.low >>> 0, object.expires.high >>> 0).toNumber(true); + if (object.subject != null) + message.subject = String(object.subject); + if (object.key != null) + if (typeof object.key === "string") + $util.base64.decode(object.key, message.key = $util.newBuffer($util.base64.length(object.key)), 0); + else if (object.key.length) + message.key = object.key; + return message; + }; + + /** + * Creates a plain object from a Details message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.Details + * @static + * @param {proto.Details} message Details + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Details.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.serial = 0; + object.issuer = ""; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.expires = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.expires = options.longs === String ? "0" : 0; + object.subject = ""; + if (options.bytes === String) + object.key = ""; + else { + object.key = []; + if (options.bytes !== Array) + object.key = $util.newBuffer(object.key); + } + } + if (message.serial != null && message.hasOwnProperty("serial")) + object.serial = message.serial; + if (message.issuer != null && message.hasOwnProperty("issuer")) + object.issuer = message.issuer; + if (message.expires != null && message.hasOwnProperty("expires")) + if (typeof message.expires === "number") + object.expires = options.longs === String ? String(message.expires) : message.expires; + else + object.expires = options.longs === String ? $util.Long.prototype.toString.call(message.expires) : options.longs === Number ? new $util.LongBits(message.expires.low >>> 0, message.expires.high >>> 0).toNumber(true) : message.expires; + if (message.subject != null && message.hasOwnProperty("subject")) + object.subject = message.subject; + if (message.key != null && message.hasOwnProperty("key")) + object.key = options.bytes === String ? $util.base64.encode(message.key, 0, message.key.length) : options.bytes === Array ? Array.prototype.slice.call(message.key) : message.key; + return object; + }; + + /** + * Converts this Details to JSON. + * @function toJSON + * @memberof proto.Details + * @instance + * @returns {Object.} JSON object + */ + Details.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Details; + })(); + + proto.NoiseCertificate = (function() { + + /** + * Properties of a NoiseCertificate. + * @memberof proto + * @interface INoiseCertificate + * @property {Uint8Array|null} [details] NoiseCertificate details + * @property {Uint8Array|null} [signature] NoiseCertificate signature + */ + + /** + * Constructs a new NoiseCertificate. + * @memberof proto + * @classdesc Represents a NoiseCertificate. + * @implements INoiseCertificate + * @constructor + * @param {proto.INoiseCertificate=} [properties] Properties to set + */ + function NoiseCertificate(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * NoiseCertificate details. + * @member {Uint8Array} details + * @memberof proto.NoiseCertificate + * @instance + */ + NoiseCertificate.prototype.details = $util.newBuffer([]); + + /** + * NoiseCertificate signature. + * @member {Uint8Array} signature + * @memberof proto.NoiseCertificate + * @instance + */ + NoiseCertificate.prototype.signature = $util.newBuffer([]); + + /** + * Creates a new NoiseCertificate instance using the specified properties. + * @function create + * @memberof proto.NoiseCertificate + * @static + * @param {proto.INoiseCertificate=} [properties] Properties to set + * @returns {proto.NoiseCertificate} NoiseCertificate instance + */ + NoiseCertificate.create = function create(properties) { + return new NoiseCertificate(properties); + }; + + /** + * Encodes the specified NoiseCertificate message. Does not implicitly {@link proto.NoiseCertificate.verify|verify} messages. + * @function encode + * @memberof proto.NoiseCertificate + * @static + * @param {proto.INoiseCertificate} message NoiseCertificate message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + NoiseCertificate.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.details != null && Object.hasOwnProperty.call(message, "details")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.details); + if (message.signature != null && Object.hasOwnProperty.call(message, "signature")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.signature); + return writer; + }; + + /** + * Encodes the specified NoiseCertificate message, length delimited. Does not implicitly {@link proto.NoiseCertificate.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.NoiseCertificate + * @static + * @param {proto.INoiseCertificate} message NoiseCertificate message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + NoiseCertificate.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a NoiseCertificate message from the specified reader or buffer. + * @function decode + * @memberof proto.NoiseCertificate + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.NoiseCertificate} NoiseCertificate + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + NoiseCertificate.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.NoiseCertificate(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.details = reader.bytes(); + break; + case 2: + message.signature = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a NoiseCertificate message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.NoiseCertificate + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.NoiseCertificate} NoiseCertificate + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + NoiseCertificate.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a NoiseCertificate message. + * @function verify + * @memberof proto.NoiseCertificate + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + NoiseCertificate.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.details != null && message.hasOwnProperty("details")) + if (!(message.details && typeof message.details.length === "number" || $util.isString(message.details))) + return "details: buffer expected"; + if (message.signature != null && message.hasOwnProperty("signature")) + if (!(message.signature && typeof message.signature.length === "number" || $util.isString(message.signature))) + return "signature: buffer expected"; + return null; + }; + + /** + * Creates a NoiseCertificate message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.NoiseCertificate + * @static + * @param {Object.} object Plain object + * @returns {proto.NoiseCertificate} NoiseCertificate + */ + NoiseCertificate.fromObject = function fromObject(object) { + if (object instanceof $root.proto.NoiseCertificate) + return object; + var message = new $root.proto.NoiseCertificate(); + if (object.details != null) + if (typeof object.details === "string") + $util.base64.decode(object.details, message.details = $util.newBuffer($util.base64.length(object.details)), 0); + else if (object.details.length) + message.details = object.details; + if (object.signature != null) + if (typeof object.signature === "string") + $util.base64.decode(object.signature, message.signature = $util.newBuffer($util.base64.length(object.signature)), 0); + else if (object.signature.length) + message.signature = object.signature; + return message; + }; + + /** + * Creates a plain object from a NoiseCertificate message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.NoiseCertificate + * @static + * @param {proto.NoiseCertificate} message NoiseCertificate + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + NoiseCertificate.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if (options.bytes === String) + object.details = ""; + else { + object.details = []; + if (options.bytes !== Array) + object.details = $util.newBuffer(object.details); + } + if (options.bytes === String) + object.signature = ""; + else { + object.signature = []; + if (options.bytes !== Array) + object.signature = $util.newBuffer(object.signature); + } + } + if (message.details != null && message.hasOwnProperty("details")) + object.details = options.bytes === String ? $util.base64.encode(message.details, 0, message.details.length) : options.bytes === Array ? Array.prototype.slice.call(message.details) : message.details; + if (message.signature != null && message.hasOwnProperty("signature")) + object.signature = options.bytes === String ? $util.base64.encode(message.signature, 0, message.signature.length) : options.bytes === Array ? Array.prototype.slice.call(message.signature) : message.signature; + return object; + }; + + /** + * Converts this NoiseCertificate to JSON. + * @function toJSON + * @memberof proto.NoiseCertificate + * @instance + * @returns {Object.} JSON object + */ + NoiseCertificate.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return NoiseCertificate; + })(); + + proto.ClientHello = (function() { + + /** + * Properties of a ClientHello. + * @memberof proto + * @interface IClientHello + * @property {Uint8Array|null} [ephemeral] ClientHello ephemeral + * @property {Uint8Array|null} ["static"] ClientHello static + * @property {Uint8Array|null} [payload] ClientHello payload + */ + + /** + * Constructs a new ClientHello. + * @memberof proto + * @classdesc Represents a ClientHello. + * @implements IClientHello + * @constructor + * @param {proto.IClientHello=} [properties] Properties to set + */ + function ClientHello(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ClientHello ephemeral. + * @member {Uint8Array} ephemeral + * @memberof proto.ClientHello + * @instance + */ + ClientHello.prototype.ephemeral = $util.newBuffer([]); + + /** + * ClientHello static. + * @member {Uint8Array} static + * @memberof proto.ClientHello + * @instance + */ + ClientHello.prototype["static"] = $util.newBuffer([]); + + /** + * ClientHello payload. + * @member {Uint8Array} payload + * @memberof proto.ClientHello + * @instance + */ + ClientHello.prototype.payload = $util.newBuffer([]); + + /** + * Creates a new ClientHello instance using the specified properties. + * @function create + * @memberof proto.ClientHello + * @static + * @param {proto.IClientHello=} [properties] Properties to set + * @returns {proto.ClientHello} ClientHello instance + */ + ClientHello.create = function create(properties) { + return new ClientHello(properties); + }; + + /** + * Encodes the specified ClientHello message. Does not implicitly {@link proto.ClientHello.verify|verify} messages. + * @function encode + * @memberof proto.ClientHello + * @static + * @param {proto.IClientHello} message ClientHello message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ClientHello.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ephemeral != null && Object.hasOwnProperty.call(message, "ephemeral")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.ephemeral); + if (message["static"] != null && Object.hasOwnProperty.call(message, "static")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message["static"]); + if (message.payload != null && Object.hasOwnProperty.call(message, "payload")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.payload); + return writer; + }; + + /** + * Encodes the specified ClientHello message, length delimited. Does not implicitly {@link proto.ClientHello.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.ClientHello + * @static + * @param {proto.IClientHello} message ClientHello message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ClientHello.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ClientHello message from the specified reader or buffer. + * @function decode + * @memberof proto.ClientHello + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.ClientHello} ClientHello + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ClientHello.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.ClientHello(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ephemeral = reader.bytes(); + break; + case 2: + message["static"] = reader.bytes(); + break; + case 3: + message.payload = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ClientHello message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.ClientHello + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.ClientHello} ClientHello + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ClientHello.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ClientHello message. + * @function verify + * @memberof proto.ClientHello + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ClientHello.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ephemeral != null && message.hasOwnProperty("ephemeral")) + if (!(message.ephemeral && typeof message.ephemeral.length === "number" || $util.isString(message.ephemeral))) + return "ephemeral: buffer expected"; + if (message["static"] != null && message.hasOwnProperty("static")) + if (!(message["static"] && typeof message["static"].length === "number" || $util.isString(message["static"]))) + return "static: buffer expected"; + if (message.payload != null && message.hasOwnProperty("payload")) + if (!(message.payload && typeof message.payload.length === "number" || $util.isString(message.payload))) + return "payload: buffer expected"; + return null; + }; + + /** + * Creates a ClientHello message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.ClientHello + * @static + * @param {Object.} object Plain object + * @returns {proto.ClientHello} ClientHello + */ + ClientHello.fromObject = function fromObject(object) { + if (object instanceof $root.proto.ClientHello) + return object; + var message = new $root.proto.ClientHello(); + if (object.ephemeral != null) + if (typeof object.ephemeral === "string") + $util.base64.decode(object.ephemeral, message.ephemeral = $util.newBuffer($util.base64.length(object.ephemeral)), 0); + else if (object.ephemeral.length) + message.ephemeral = object.ephemeral; + if (object["static"] != null) + if (typeof object["static"] === "string") + $util.base64.decode(object["static"], message["static"] = $util.newBuffer($util.base64.length(object["static"])), 0); + else if (object["static"].length) + message["static"] = object["static"]; + if (object.payload != null) + if (typeof object.payload === "string") + $util.base64.decode(object.payload, message.payload = $util.newBuffer($util.base64.length(object.payload)), 0); + else if (object.payload.length) + message.payload = object.payload; + return message; + }; + + /** + * Creates a plain object from a ClientHello message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.ClientHello + * @static + * @param {proto.ClientHello} message ClientHello + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ClientHello.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if (options.bytes === String) + object.ephemeral = ""; + else { + object.ephemeral = []; + if (options.bytes !== Array) + object.ephemeral = $util.newBuffer(object.ephemeral); + } + if (options.bytes === String) + object["static"] = ""; + else { + object["static"] = []; + if (options.bytes !== Array) + object["static"] = $util.newBuffer(object["static"]); + } + if (options.bytes === String) + object.payload = ""; + else { + object.payload = []; + if (options.bytes !== Array) + object.payload = $util.newBuffer(object.payload); + } + } + if (message.ephemeral != null && message.hasOwnProperty("ephemeral")) + object.ephemeral = options.bytes === String ? $util.base64.encode(message.ephemeral, 0, message.ephemeral.length) : options.bytes === Array ? Array.prototype.slice.call(message.ephemeral) : message.ephemeral; + if (message["static"] != null && message.hasOwnProperty("static")) + object["static"] = options.bytes === String ? $util.base64.encode(message["static"], 0, message["static"].length) : options.bytes === Array ? Array.prototype.slice.call(message["static"]) : message["static"]; + if (message.payload != null && message.hasOwnProperty("payload")) + object.payload = options.bytes === String ? $util.base64.encode(message.payload, 0, message.payload.length) : options.bytes === Array ? Array.prototype.slice.call(message.payload) : message.payload; + return object; + }; + + /** + * Converts this ClientHello to JSON. + * @function toJSON + * @memberof proto.ClientHello + * @instance + * @returns {Object.} JSON object + */ + ClientHello.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ClientHello; + })(); + + proto.ServerHello = (function() { + + /** + * Properties of a ServerHello. + * @memberof proto + * @interface IServerHello + * @property {Uint8Array|null} [ephemeral] ServerHello ephemeral + * @property {Uint8Array|null} ["static"] ServerHello static + * @property {Uint8Array|null} [payload] ServerHello payload + */ + + /** + * Constructs a new ServerHello. + * @memberof proto + * @classdesc Represents a ServerHello. + * @implements IServerHello + * @constructor + * @param {proto.IServerHello=} [properties] Properties to set + */ + function ServerHello(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ServerHello ephemeral. + * @member {Uint8Array} ephemeral + * @memberof proto.ServerHello + * @instance + */ + ServerHello.prototype.ephemeral = $util.newBuffer([]); + + /** + * ServerHello static. + * @member {Uint8Array} static + * @memberof proto.ServerHello + * @instance + */ + ServerHello.prototype["static"] = $util.newBuffer([]); + + /** + * ServerHello payload. + * @member {Uint8Array} payload + * @memberof proto.ServerHello + * @instance + */ + ServerHello.prototype.payload = $util.newBuffer([]); + + /** + * Creates a new ServerHello instance using the specified properties. + * @function create + * @memberof proto.ServerHello + * @static + * @param {proto.IServerHello=} [properties] Properties to set + * @returns {proto.ServerHello} ServerHello instance + */ + ServerHello.create = function create(properties) { + return new ServerHello(properties); + }; + + /** + * Encodes the specified ServerHello message. Does not implicitly {@link proto.ServerHello.verify|verify} messages. + * @function encode + * @memberof proto.ServerHello + * @static + * @param {proto.IServerHello} message ServerHello message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServerHello.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ephemeral != null && Object.hasOwnProperty.call(message, "ephemeral")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.ephemeral); + if (message["static"] != null && Object.hasOwnProperty.call(message, "static")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message["static"]); + if (message.payload != null && Object.hasOwnProperty.call(message, "payload")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.payload); + return writer; + }; + + /** + * Encodes the specified ServerHello message, length delimited. Does not implicitly {@link proto.ServerHello.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.ServerHello + * @static + * @param {proto.IServerHello} message ServerHello message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServerHello.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ServerHello message from the specified reader or buffer. + * @function decode + * @memberof proto.ServerHello + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.ServerHello} ServerHello + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServerHello.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.ServerHello(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ephemeral = reader.bytes(); + break; + case 2: + message["static"] = reader.bytes(); + break; + case 3: + message.payload = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ServerHello message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.ServerHello + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.ServerHello} ServerHello + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServerHello.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ServerHello message. + * @function verify + * @memberof proto.ServerHello + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ServerHello.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ephemeral != null && message.hasOwnProperty("ephemeral")) + if (!(message.ephemeral && typeof message.ephemeral.length === "number" || $util.isString(message.ephemeral))) + return "ephemeral: buffer expected"; + if (message["static"] != null && message.hasOwnProperty("static")) + if (!(message["static"] && typeof message["static"].length === "number" || $util.isString(message["static"]))) + return "static: buffer expected"; + if (message.payload != null && message.hasOwnProperty("payload")) + if (!(message.payload && typeof message.payload.length === "number" || $util.isString(message.payload))) + return "payload: buffer expected"; + return null; + }; + + /** + * Creates a ServerHello message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.ServerHello + * @static + * @param {Object.} object Plain object + * @returns {proto.ServerHello} ServerHello + */ + ServerHello.fromObject = function fromObject(object) { + if (object instanceof $root.proto.ServerHello) + return object; + var message = new $root.proto.ServerHello(); + if (object.ephemeral != null) + if (typeof object.ephemeral === "string") + $util.base64.decode(object.ephemeral, message.ephemeral = $util.newBuffer($util.base64.length(object.ephemeral)), 0); + else if (object.ephemeral.length) + message.ephemeral = object.ephemeral; + if (object["static"] != null) + if (typeof object["static"] === "string") + $util.base64.decode(object["static"], message["static"] = $util.newBuffer($util.base64.length(object["static"])), 0); + else if (object["static"].length) + message["static"] = object["static"]; + if (object.payload != null) + if (typeof object.payload === "string") + $util.base64.decode(object.payload, message.payload = $util.newBuffer($util.base64.length(object.payload)), 0); + else if (object.payload.length) + message.payload = object.payload; + return message; + }; + + /** + * Creates a plain object from a ServerHello message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.ServerHello + * @static + * @param {proto.ServerHello} message ServerHello + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ServerHello.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if (options.bytes === String) + object.ephemeral = ""; + else { + object.ephemeral = []; + if (options.bytes !== Array) + object.ephemeral = $util.newBuffer(object.ephemeral); + } + if (options.bytes === String) + object["static"] = ""; + else { + object["static"] = []; + if (options.bytes !== Array) + object["static"] = $util.newBuffer(object["static"]); + } + if (options.bytes === String) + object.payload = ""; + else { + object.payload = []; + if (options.bytes !== Array) + object.payload = $util.newBuffer(object.payload); + } + } + if (message.ephemeral != null && message.hasOwnProperty("ephemeral")) + object.ephemeral = options.bytes === String ? $util.base64.encode(message.ephemeral, 0, message.ephemeral.length) : options.bytes === Array ? Array.prototype.slice.call(message.ephemeral) : message.ephemeral; + if (message["static"] != null && message.hasOwnProperty("static")) + object["static"] = options.bytes === String ? $util.base64.encode(message["static"], 0, message["static"].length) : options.bytes === Array ? Array.prototype.slice.call(message["static"]) : message["static"]; + if (message.payload != null && message.hasOwnProperty("payload")) + object.payload = options.bytes === String ? $util.base64.encode(message.payload, 0, message.payload.length) : options.bytes === Array ? Array.prototype.slice.call(message.payload) : message.payload; + return object; + }; + + /** + * Converts this ServerHello to JSON. + * @function toJSON + * @memberof proto.ServerHello + * @instance + * @returns {Object.} JSON object + */ + ServerHello.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ServerHello; + })(); + + proto.ClientFinish = (function() { + + /** + * Properties of a ClientFinish. + * @memberof proto + * @interface IClientFinish + * @property {Uint8Array|null} ["static"] ClientFinish static + * @property {Uint8Array|null} [payload] ClientFinish payload + */ + + /** + * Constructs a new ClientFinish. + * @memberof proto + * @classdesc Represents a ClientFinish. + * @implements IClientFinish + * @constructor + * @param {proto.IClientFinish=} [properties] Properties to set + */ + function ClientFinish(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ClientFinish static. + * @member {Uint8Array} static + * @memberof proto.ClientFinish + * @instance + */ + ClientFinish.prototype["static"] = $util.newBuffer([]); + + /** + * ClientFinish payload. + * @member {Uint8Array} payload + * @memberof proto.ClientFinish + * @instance + */ + ClientFinish.prototype.payload = $util.newBuffer([]); + + /** + * Creates a new ClientFinish instance using the specified properties. + * @function create + * @memberof proto.ClientFinish + * @static + * @param {proto.IClientFinish=} [properties] Properties to set + * @returns {proto.ClientFinish} ClientFinish instance + */ + ClientFinish.create = function create(properties) { + return new ClientFinish(properties); + }; + + /** + * Encodes the specified ClientFinish message. Does not implicitly {@link proto.ClientFinish.verify|verify} messages. + * @function encode + * @memberof proto.ClientFinish + * @static + * @param {proto.IClientFinish} message ClientFinish message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ClientFinish.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message["static"] != null && Object.hasOwnProperty.call(message, "static")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message["static"]); + if (message.payload != null && Object.hasOwnProperty.call(message, "payload")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.payload); + return writer; + }; + + /** + * Encodes the specified ClientFinish message, length delimited. Does not implicitly {@link proto.ClientFinish.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.ClientFinish + * @static + * @param {proto.IClientFinish} message ClientFinish message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ClientFinish.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ClientFinish message from the specified reader or buffer. + * @function decode + * @memberof proto.ClientFinish + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.ClientFinish} ClientFinish + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ClientFinish.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.ClientFinish(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message["static"] = reader.bytes(); + break; + case 2: + message.payload = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ClientFinish message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.ClientFinish + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.ClientFinish} ClientFinish + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ClientFinish.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ClientFinish message. + * @function verify + * @memberof proto.ClientFinish + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ClientFinish.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message["static"] != null && message.hasOwnProperty("static")) + if (!(message["static"] && typeof message["static"].length === "number" || $util.isString(message["static"]))) + return "static: buffer expected"; + if (message.payload != null && message.hasOwnProperty("payload")) + if (!(message.payload && typeof message.payload.length === "number" || $util.isString(message.payload))) + return "payload: buffer expected"; + return null; + }; + + /** + * Creates a ClientFinish message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.ClientFinish + * @static + * @param {Object.} object Plain object + * @returns {proto.ClientFinish} ClientFinish + */ + ClientFinish.fromObject = function fromObject(object) { + if (object instanceof $root.proto.ClientFinish) + return object; + var message = new $root.proto.ClientFinish(); + if (object["static"] != null) + if (typeof object["static"] === "string") + $util.base64.decode(object["static"], message["static"] = $util.newBuffer($util.base64.length(object["static"])), 0); + else if (object["static"].length) + message["static"] = object["static"]; + if (object.payload != null) + if (typeof object.payload === "string") + $util.base64.decode(object.payload, message.payload = $util.newBuffer($util.base64.length(object.payload)), 0); + else if (object.payload.length) + message.payload = object.payload; + return message; + }; + + /** + * Creates a plain object from a ClientFinish message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.ClientFinish + * @static + * @param {proto.ClientFinish} message ClientFinish + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ClientFinish.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if (options.bytes === String) + object["static"] = ""; + else { + object["static"] = []; + if (options.bytes !== Array) + object["static"] = $util.newBuffer(object["static"]); + } + if (options.bytes === String) + object.payload = ""; + else { + object.payload = []; + if (options.bytes !== Array) + object.payload = $util.newBuffer(object.payload); + } + } + if (message["static"] != null && message.hasOwnProperty("static")) + object["static"] = options.bytes === String ? $util.base64.encode(message["static"], 0, message["static"].length) : options.bytes === Array ? Array.prototype.slice.call(message["static"]) : message["static"]; + if (message.payload != null && message.hasOwnProperty("payload")) + object.payload = options.bytes === String ? $util.base64.encode(message.payload, 0, message.payload.length) : options.bytes === Array ? Array.prototype.slice.call(message.payload) : message.payload; + return object; + }; + + /** + * Converts this ClientFinish to JSON. + * @function toJSON + * @memberof proto.ClientFinish + * @instance + * @returns {Object.} JSON object + */ + ClientFinish.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ClientFinish; + })(); + + proto.HandshakeMessage = (function() { + + /** + * Properties of a HandshakeMessage. + * @memberof proto + * @interface IHandshakeMessage + * @property {proto.IClientHello|null} [clientHello] HandshakeMessage clientHello + * @property {proto.IServerHello|null} [serverHello] HandshakeMessage serverHello + * @property {proto.IClientFinish|null} [clientFinish] HandshakeMessage clientFinish + */ + + /** + * Constructs a new HandshakeMessage. + * @memberof proto + * @classdesc Represents a HandshakeMessage. + * @implements IHandshakeMessage + * @constructor + * @param {proto.IHandshakeMessage=} [properties] Properties to set + */ + function HandshakeMessage(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * HandshakeMessage clientHello. + * @member {proto.IClientHello|null|undefined} clientHello + * @memberof proto.HandshakeMessage + * @instance + */ + HandshakeMessage.prototype.clientHello = null; + + /** + * HandshakeMessage serverHello. + * @member {proto.IServerHello|null|undefined} serverHello + * @memberof proto.HandshakeMessage + * @instance + */ + HandshakeMessage.prototype.serverHello = null; + + /** + * HandshakeMessage clientFinish. + * @member {proto.IClientFinish|null|undefined} clientFinish + * @memberof proto.HandshakeMessage + * @instance + */ + HandshakeMessage.prototype.clientFinish = null; + + /** + * Creates a new HandshakeMessage instance using the specified properties. + * @function create + * @memberof proto.HandshakeMessage + * @static + * @param {proto.IHandshakeMessage=} [properties] Properties to set + * @returns {proto.HandshakeMessage} HandshakeMessage instance + */ + HandshakeMessage.create = function create(properties) { + return new HandshakeMessage(properties); + }; + + /** + * Encodes the specified HandshakeMessage message. Does not implicitly {@link proto.HandshakeMessage.verify|verify} messages. + * @function encode + * @memberof proto.HandshakeMessage + * @static + * @param {proto.IHandshakeMessage} message HandshakeMessage message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HandshakeMessage.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.clientHello != null && Object.hasOwnProperty.call(message, "clientHello")) + $root.proto.ClientHello.encode(message.clientHello, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.serverHello != null && Object.hasOwnProperty.call(message, "serverHello")) + $root.proto.ServerHello.encode(message.serverHello, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.clientFinish != null && Object.hasOwnProperty.call(message, "clientFinish")) + $root.proto.ClientFinish.encode(message.clientFinish, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified HandshakeMessage message, length delimited. Does not implicitly {@link proto.HandshakeMessage.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.HandshakeMessage + * @static + * @param {proto.IHandshakeMessage} message HandshakeMessage message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HandshakeMessage.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a HandshakeMessage message from the specified reader or buffer. + * @function decode + * @memberof proto.HandshakeMessage + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.HandshakeMessage} HandshakeMessage + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HandshakeMessage.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.HandshakeMessage(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.clientHello = $root.proto.ClientHello.decode(reader, reader.uint32()); + break; + case 3: + message.serverHello = $root.proto.ServerHello.decode(reader, reader.uint32()); + break; + case 4: + message.clientFinish = $root.proto.ClientFinish.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a HandshakeMessage message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.HandshakeMessage + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.HandshakeMessage} HandshakeMessage + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HandshakeMessage.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a HandshakeMessage message. + * @function verify + * @memberof proto.HandshakeMessage + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + HandshakeMessage.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.clientHello != null && message.hasOwnProperty("clientHello")) { + var error = $root.proto.ClientHello.verify(message.clientHello); + if (error) + return "clientHello." + error; + } + if (message.serverHello != null && message.hasOwnProperty("serverHello")) { + var error = $root.proto.ServerHello.verify(message.serverHello); + if (error) + return "serverHello." + error; + } + if (message.clientFinish != null && message.hasOwnProperty("clientFinish")) { + var error = $root.proto.ClientFinish.verify(message.clientFinish); + if (error) + return "clientFinish." + error; + } + return null; + }; + + /** + * Creates a HandshakeMessage message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.HandshakeMessage + * @static + * @param {Object.} object Plain object + * @returns {proto.HandshakeMessage} HandshakeMessage + */ + HandshakeMessage.fromObject = function fromObject(object) { + if (object instanceof $root.proto.HandshakeMessage) + return object; + var message = new $root.proto.HandshakeMessage(); + if (object.clientHello != null) { + if (typeof object.clientHello !== "object") + throw TypeError(".proto.HandshakeMessage.clientHello: object expected"); + message.clientHello = $root.proto.ClientHello.fromObject(object.clientHello); + } + if (object.serverHello != null) { + if (typeof object.serverHello !== "object") + throw TypeError(".proto.HandshakeMessage.serverHello: object expected"); + message.serverHello = $root.proto.ServerHello.fromObject(object.serverHello); + } + if (object.clientFinish != null) { + if (typeof object.clientFinish !== "object") + throw TypeError(".proto.HandshakeMessage.clientFinish: object expected"); + message.clientFinish = $root.proto.ClientFinish.fromObject(object.clientFinish); + } + return message; + }; + + /** + * Creates a plain object from a HandshakeMessage message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.HandshakeMessage + * @static + * @param {proto.HandshakeMessage} message HandshakeMessage + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + HandshakeMessage.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.clientHello = null; + object.serverHello = null; + object.clientFinish = null; + } + if (message.clientHello != null && message.hasOwnProperty("clientHello")) + object.clientHello = $root.proto.ClientHello.toObject(message.clientHello, options); + if (message.serverHello != null && message.hasOwnProperty("serverHello")) + object.serverHello = $root.proto.ServerHello.toObject(message.serverHello, options); + if (message.clientFinish != null && message.hasOwnProperty("clientFinish")) + object.clientFinish = $root.proto.ClientFinish.toObject(message.clientFinish, options); + return object; + }; + + /** + * Converts this HandshakeMessage to JSON. + * @function toJSON + * @memberof proto.HandshakeMessage + * @instance + * @returns {Object.} JSON object + */ + HandshakeMessage.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return HandshakeMessage; + })(); + + proto.BizIdentityInfo = (function() { + + /** + * Properties of a BizIdentityInfo. + * @memberof proto + * @interface IBizIdentityInfo + * @property {proto.BizIdentityInfo.BizIdentityInfoVerifiedLevelValue|null} [vlevel] BizIdentityInfo vlevel + * @property {proto.IVerifiedNameCertificate|null} [vnameCert] BizIdentityInfo vnameCert + * @property {boolean|null} [signed] BizIdentityInfo signed + * @property {boolean|null} [revoked] BizIdentityInfo revoked + * @property {proto.BizIdentityInfo.BizIdentityInfoHostStorageType|null} [hostStorage] BizIdentityInfo hostStorage + * @property {proto.BizIdentityInfo.BizIdentityInfoActualActorsType|null} [actualActors] BizIdentityInfo actualActors + * @property {number|Long|null} [privacyModeTs] BizIdentityInfo privacyModeTs + */ + + /** + * Constructs a new BizIdentityInfo. + * @memberof proto + * @classdesc Represents a BizIdentityInfo. + * @implements IBizIdentityInfo + * @constructor + * @param {proto.IBizIdentityInfo=} [properties] Properties to set + */ + function BizIdentityInfo(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BizIdentityInfo vlevel. + * @member {proto.BizIdentityInfo.BizIdentityInfoVerifiedLevelValue} vlevel + * @memberof proto.BizIdentityInfo + * @instance + */ + BizIdentityInfo.prototype.vlevel = 0; + + /** + * BizIdentityInfo vnameCert. + * @member {proto.IVerifiedNameCertificate|null|undefined} vnameCert + * @memberof proto.BizIdentityInfo + * @instance + */ + BizIdentityInfo.prototype.vnameCert = null; + + /** + * BizIdentityInfo signed. + * @member {boolean} signed + * @memberof proto.BizIdentityInfo + * @instance + */ + BizIdentityInfo.prototype.signed = false; + + /** + * BizIdentityInfo revoked. + * @member {boolean} revoked + * @memberof proto.BizIdentityInfo + * @instance + */ + BizIdentityInfo.prototype.revoked = false; + + /** + * BizIdentityInfo hostStorage. + * @member {proto.BizIdentityInfo.BizIdentityInfoHostStorageType} hostStorage + * @memberof proto.BizIdentityInfo + * @instance + */ + BizIdentityInfo.prototype.hostStorage = 0; + + /** + * BizIdentityInfo actualActors. + * @member {proto.BizIdentityInfo.BizIdentityInfoActualActorsType} actualActors + * @memberof proto.BizIdentityInfo + * @instance + */ + BizIdentityInfo.prototype.actualActors = 0; + + /** + * BizIdentityInfo privacyModeTs. + * @member {number|Long} privacyModeTs + * @memberof proto.BizIdentityInfo + * @instance + */ + BizIdentityInfo.prototype.privacyModeTs = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * Creates a new BizIdentityInfo instance using the specified properties. + * @function create + * @memberof proto.BizIdentityInfo + * @static + * @param {proto.IBizIdentityInfo=} [properties] Properties to set + * @returns {proto.BizIdentityInfo} BizIdentityInfo instance + */ + BizIdentityInfo.create = function create(properties) { + return new BizIdentityInfo(properties); + }; + + /** + * Encodes the specified BizIdentityInfo message. Does not implicitly {@link proto.BizIdentityInfo.verify|verify} messages. + * @function encode + * @memberof proto.BizIdentityInfo + * @static + * @param {proto.IBizIdentityInfo} message BizIdentityInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BizIdentityInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.vlevel != null && Object.hasOwnProperty.call(message, "vlevel")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.vlevel); + if (message.vnameCert != null && Object.hasOwnProperty.call(message, "vnameCert")) + $root.proto.VerifiedNameCertificate.encode(message.vnameCert, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.signed != null && Object.hasOwnProperty.call(message, "signed")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.signed); + if (message.revoked != null && Object.hasOwnProperty.call(message, "revoked")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.revoked); + if (message.hostStorage != null && Object.hasOwnProperty.call(message, "hostStorage")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.hostStorage); + if (message.actualActors != null && Object.hasOwnProperty.call(message, "actualActors")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.actualActors); + if (message.privacyModeTs != null && Object.hasOwnProperty.call(message, "privacyModeTs")) + writer.uint32(/* id 7, wireType 0 =*/56).uint64(message.privacyModeTs); + return writer; + }; + + /** + * Encodes the specified BizIdentityInfo message, length delimited. Does not implicitly {@link proto.BizIdentityInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.BizIdentityInfo + * @static + * @param {proto.IBizIdentityInfo} message BizIdentityInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BizIdentityInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BizIdentityInfo message from the specified reader or buffer. + * @function decode + * @memberof proto.BizIdentityInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.BizIdentityInfo} BizIdentityInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BizIdentityInfo.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.BizIdentityInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.vlevel = reader.int32(); + break; + case 2: + message.vnameCert = $root.proto.VerifiedNameCertificate.decode(reader, reader.uint32()); + break; + case 3: + message.signed = reader.bool(); + break; + case 4: + message.revoked = reader.bool(); + break; + case 5: + message.hostStorage = reader.int32(); + break; + case 6: + message.actualActors = reader.int32(); + break; + case 7: + message.privacyModeTs = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BizIdentityInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.BizIdentityInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.BizIdentityInfo} BizIdentityInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BizIdentityInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BizIdentityInfo message. + * @function verify + * @memberof proto.BizIdentityInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BizIdentityInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.vlevel != null && message.hasOwnProperty("vlevel")) + switch (message.vlevel) { + default: + return "vlevel: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.vnameCert != null && message.hasOwnProperty("vnameCert")) { + var error = $root.proto.VerifiedNameCertificate.verify(message.vnameCert); + if (error) + return "vnameCert." + error; + } + if (message.signed != null && message.hasOwnProperty("signed")) + if (typeof message.signed !== "boolean") + return "signed: boolean expected"; + if (message.revoked != null && message.hasOwnProperty("revoked")) + if (typeof message.revoked !== "boolean") + return "revoked: boolean expected"; + if (message.hostStorage != null && message.hasOwnProperty("hostStorage")) + switch (message.hostStorage) { + default: + return "hostStorage: enum value expected"; + case 0: + case 1: + break; + } + if (message.actualActors != null && message.hasOwnProperty("actualActors")) + switch (message.actualActors) { + default: + return "actualActors: enum value expected"; + case 0: + case 1: + break; + } + if (message.privacyModeTs != null && message.hasOwnProperty("privacyModeTs")) + if (!$util.isInteger(message.privacyModeTs) && !(message.privacyModeTs && $util.isInteger(message.privacyModeTs.low) && $util.isInteger(message.privacyModeTs.high))) + return "privacyModeTs: integer|Long expected"; + return null; + }; + + /** + * Creates a BizIdentityInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.BizIdentityInfo + * @static + * @param {Object.} object Plain object + * @returns {proto.BizIdentityInfo} BizIdentityInfo + */ + BizIdentityInfo.fromObject = function fromObject(object) { + if (object instanceof $root.proto.BizIdentityInfo) + return object; + var message = new $root.proto.BizIdentityInfo(); + switch (object.vlevel) { + case "UNKNOWN": + case 0: + message.vlevel = 0; + break; + case "LOW": + case 1: + message.vlevel = 1; + break; + case "HIGH": + case 2: + message.vlevel = 2; + break; + } + if (object.vnameCert != null) { + if (typeof object.vnameCert !== "object") + throw TypeError(".proto.BizIdentityInfo.vnameCert: object expected"); + message.vnameCert = $root.proto.VerifiedNameCertificate.fromObject(object.vnameCert); + } + if (object.signed != null) + message.signed = Boolean(object.signed); + if (object.revoked != null) + message.revoked = Boolean(object.revoked); + switch (object.hostStorage) { + case "ON_PREMISE": + case 0: + message.hostStorage = 0; + break; + case "FACEBOOK": + case 1: + message.hostStorage = 1; + break; + } + switch (object.actualActors) { + case "SELF": + case 0: + message.actualActors = 0; + break; + case "BSP": + case 1: + message.actualActors = 1; + break; + } + if (object.privacyModeTs != null) + if ($util.Long) + (message.privacyModeTs = $util.Long.fromValue(object.privacyModeTs)).unsigned = true; + else if (typeof object.privacyModeTs === "string") + message.privacyModeTs = parseInt(object.privacyModeTs, 10); + else if (typeof object.privacyModeTs === "number") + message.privacyModeTs = object.privacyModeTs; + else if (typeof object.privacyModeTs === "object") + message.privacyModeTs = new $util.LongBits(object.privacyModeTs.low >>> 0, object.privacyModeTs.high >>> 0).toNumber(true); + return message; + }; + + /** + * Creates a plain object from a BizIdentityInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.BizIdentityInfo + * @static + * @param {proto.BizIdentityInfo} message BizIdentityInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BizIdentityInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.vlevel = options.enums === String ? "UNKNOWN" : 0; + object.vnameCert = null; + object.signed = false; + object.revoked = false; + object.hostStorage = options.enums === String ? "ON_PREMISE" : 0; + object.actualActors = options.enums === String ? "SELF" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.privacyModeTs = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.privacyModeTs = options.longs === String ? "0" : 0; + } + if (message.vlevel != null && message.hasOwnProperty("vlevel")) + object.vlevel = options.enums === String ? $root.proto.BizIdentityInfo.BizIdentityInfoVerifiedLevelValue[message.vlevel] : message.vlevel; + if (message.vnameCert != null && message.hasOwnProperty("vnameCert")) + object.vnameCert = $root.proto.VerifiedNameCertificate.toObject(message.vnameCert, options); + if (message.signed != null && message.hasOwnProperty("signed")) + object.signed = message.signed; + if (message.revoked != null && message.hasOwnProperty("revoked")) + object.revoked = message.revoked; + if (message.hostStorage != null && message.hasOwnProperty("hostStorage")) + object.hostStorage = options.enums === String ? $root.proto.BizIdentityInfo.BizIdentityInfoHostStorageType[message.hostStorage] : message.hostStorage; + if (message.actualActors != null && message.hasOwnProperty("actualActors")) + object.actualActors = options.enums === String ? $root.proto.BizIdentityInfo.BizIdentityInfoActualActorsType[message.actualActors] : message.actualActors; + if (message.privacyModeTs != null && message.hasOwnProperty("privacyModeTs")) + if (typeof message.privacyModeTs === "number") + object.privacyModeTs = options.longs === String ? String(message.privacyModeTs) : message.privacyModeTs; + else + object.privacyModeTs = options.longs === String ? $util.Long.prototype.toString.call(message.privacyModeTs) : options.longs === Number ? new $util.LongBits(message.privacyModeTs.low >>> 0, message.privacyModeTs.high >>> 0).toNumber(true) : message.privacyModeTs; + return object; + }; + + /** + * Converts this BizIdentityInfo to JSON. + * @function toJSON + * @memberof proto.BizIdentityInfo + * @instance + * @returns {Object.} JSON object + */ + BizIdentityInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * BizIdentityInfoVerifiedLevelValue enum. + * @name proto.BizIdentityInfo.BizIdentityInfoVerifiedLevelValue + * @enum {number} + * @property {number} UNKNOWN=0 UNKNOWN value + * @property {number} LOW=1 LOW value + * @property {number} HIGH=2 HIGH value + */ + BizIdentityInfo.BizIdentityInfoVerifiedLevelValue = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "UNKNOWN"] = 0; + values[valuesById[1] = "LOW"] = 1; + values[valuesById[2] = "HIGH"] = 2; + return values; + })(); + + /** + * BizIdentityInfoHostStorageType enum. + * @name proto.BizIdentityInfo.BizIdentityInfoHostStorageType + * @enum {number} + * @property {number} ON_PREMISE=0 ON_PREMISE value + * @property {number} FACEBOOK=1 FACEBOOK value + */ + BizIdentityInfo.BizIdentityInfoHostStorageType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ON_PREMISE"] = 0; + values[valuesById[1] = "FACEBOOK"] = 1; + return values; + })(); + + /** + * BizIdentityInfoActualActorsType enum. + * @name proto.BizIdentityInfo.BizIdentityInfoActualActorsType + * @enum {number} + * @property {number} SELF=0 SELF value + * @property {number} BSP=1 BSP value + */ + BizIdentityInfo.BizIdentityInfoActualActorsType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SELF"] = 0; + values[valuesById[1] = "BSP"] = 1; + return values; + })(); + + return BizIdentityInfo; + })(); + + proto.BizAccountLinkInfo = (function() { + + /** + * Properties of a BizAccountLinkInfo. + * @memberof proto + * @interface IBizAccountLinkInfo + * @property {number|Long|null} [whatsappBizAcctFbid] BizAccountLinkInfo whatsappBizAcctFbid + * @property {string|null} [whatsappAcctNumber] BizAccountLinkInfo whatsappAcctNumber + * @property {number|Long|null} [issueTime] BizAccountLinkInfo issueTime + * @property {proto.BizAccountLinkInfo.BizAccountLinkInfoHostStorageType|null} [hostStorage] BizAccountLinkInfo hostStorage + * @property {proto.BizAccountLinkInfo.BizAccountLinkInfoAccountType|null} [accountType] BizAccountLinkInfo accountType + */ + + /** + * Constructs a new BizAccountLinkInfo. + * @memberof proto + * @classdesc Represents a BizAccountLinkInfo. + * @implements IBizAccountLinkInfo + * @constructor + * @param {proto.IBizAccountLinkInfo=} [properties] Properties to set + */ + function BizAccountLinkInfo(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BizAccountLinkInfo whatsappBizAcctFbid. + * @member {number|Long} whatsappBizAcctFbid + * @memberof proto.BizAccountLinkInfo + * @instance + */ + BizAccountLinkInfo.prototype.whatsappBizAcctFbid = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * BizAccountLinkInfo whatsappAcctNumber. + * @member {string} whatsappAcctNumber + * @memberof proto.BizAccountLinkInfo + * @instance + */ + BizAccountLinkInfo.prototype.whatsappAcctNumber = ""; + + /** + * BizAccountLinkInfo issueTime. + * @member {number|Long} issueTime + * @memberof proto.BizAccountLinkInfo + * @instance + */ + BizAccountLinkInfo.prototype.issueTime = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * BizAccountLinkInfo hostStorage. + * @member {proto.BizAccountLinkInfo.BizAccountLinkInfoHostStorageType} hostStorage + * @memberof proto.BizAccountLinkInfo + * @instance + */ + BizAccountLinkInfo.prototype.hostStorage = 0; + + /** + * BizAccountLinkInfo accountType. + * @member {proto.BizAccountLinkInfo.BizAccountLinkInfoAccountType} accountType + * @memberof proto.BizAccountLinkInfo + * @instance + */ + BizAccountLinkInfo.prototype.accountType = 0; + + /** + * Creates a new BizAccountLinkInfo instance using the specified properties. + * @function create + * @memberof proto.BizAccountLinkInfo + * @static + * @param {proto.IBizAccountLinkInfo=} [properties] Properties to set + * @returns {proto.BizAccountLinkInfo} BizAccountLinkInfo instance + */ + BizAccountLinkInfo.create = function create(properties) { + return new BizAccountLinkInfo(properties); + }; + + /** + * Encodes the specified BizAccountLinkInfo message. Does not implicitly {@link proto.BizAccountLinkInfo.verify|verify} messages. + * @function encode + * @memberof proto.BizAccountLinkInfo + * @static + * @param {proto.IBizAccountLinkInfo} message BizAccountLinkInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BizAccountLinkInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.whatsappBizAcctFbid != null && Object.hasOwnProperty.call(message, "whatsappBizAcctFbid")) + writer.uint32(/* id 1, wireType 0 =*/8).uint64(message.whatsappBizAcctFbid); + if (message.whatsappAcctNumber != null && Object.hasOwnProperty.call(message, "whatsappAcctNumber")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.whatsappAcctNumber); + if (message.issueTime != null && Object.hasOwnProperty.call(message, "issueTime")) + writer.uint32(/* id 3, wireType 0 =*/24).uint64(message.issueTime); + if (message.hostStorage != null && Object.hasOwnProperty.call(message, "hostStorage")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.hostStorage); + if (message.accountType != null && Object.hasOwnProperty.call(message, "accountType")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.accountType); + return writer; + }; + + /** + * Encodes the specified BizAccountLinkInfo message, length delimited. Does not implicitly {@link proto.BizAccountLinkInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.BizAccountLinkInfo + * @static + * @param {proto.IBizAccountLinkInfo} message BizAccountLinkInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BizAccountLinkInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BizAccountLinkInfo message from the specified reader or buffer. + * @function decode + * @memberof proto.BizAccountLinkInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.BizAccountLinkInfo} BizAccountLinkInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BizAccountLinkInfo.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.BizAccountLinkInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.whatsappBizAcctFbid = reader.uint64(); + break; + case 2: + message.whatsappAcctNumber = reader.string(); + break; + case 3: + message.issueTime = reader.uint64(); + break; + case 4: + message.hostStorage = reader.int32(); + break; + case 5: + message.accountType = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BizAccountLinkInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.BizAccountLinkInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.BizAccountLinkInfo} BizAccountLinkInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BizAccountLinkInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BizAccountLinkInfo message. + * @function verify + * @memberof proto.BizAccountLinkInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BizAccountLinkInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.whatsappBizAcctFbid != null && message.hasOwnProperty("whatsappBizAcctFbid")) + if (!$util.isInteger(message.whatsappBizAcctFbid) && !(message.whatsappBizAcctFbid && $util.isInteger(message.whatsappBizAcctFbid.low) && $util.isInteger(message.whatsappBizAcctFbid.high))) + return "whatsappBizAcctFbid: integer|Long expected"; + if (message.whatsappAcctNumber != null && message.hasOwnProperty("whatsappAcctNumber")) + if (!$util.isString(message.whatsappAcctNumber)) + return "whatsappAcctNumber: string expected"; + if (message.issueTime != null && message.hasOwnProperty("issueTime")) + if (!$util.isInteger(message.issueTime) && !(message.issueTime && $util.isInteger(message.issueTime.low) && $util.isInteger(message.issueTime.high))) + return "issueTime: integer|Long expected"; + if (message.hostStorage != null && message.hasOwnProperty("hostStorage")) + switch (message.hostStorage) { + default: + return "hostStorage: enum value expected"; + case 0: + case 1: + break; + } + if (message.accountType != null && message.hasOwnProperty("accountType")) + switch (message.accountType) { + default: + return "accountType: enum value expected"; + case 0: + case 1: + break; + } + return null; + }; + + /** + * Creates a BizAccountLinkInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.BizAccountLinkInfo + * @static + * @param {Object.} object Plain object + * @returns {proto.BizAccountLinkInfo} BizAccountLinkInfo + */ + BizAccountLinkInfo.fromObject = function fromObject(object) { + if (object instanceof $root.proto.BizAccountLinkInfo) + return object; + var message = new $root.proto.BizAccountLinkInfo(); + if (object.whatsappBizAcctFbid != null) + if ($util.Long) + (message.whatsappBizAcctFbid = $util.Long.fromValue(object.whatsappBizAcctFbid)).unsigned = true; + else if (typeof object.whatsappBizAcctFbid === "string") + message.whatsappBizAcctFbid = parseInt(object.whatsappBizAcctFbid, 10); + else if (typeof object.whatsappBizAcctFbid === "number") + message.whatsappBizAcctFbid = object.whatsappBizAcctFbid; + else if (typeof object.whatsappBizAcctFbid === "object") + message.whatsappBizAcctFbid = new $util.LongBits(object.whatsappBizAcctFbid.low >>> 0, object.whatsappBizAcctFbid.high >>> 0).toNumber(true); + if (object.whatsappAcctNumber != null) + message.whatsappAcctNumber = String(object.whatsappAcctNumber); + if (object.issueTime != null) + if ($util.Long) + (message.issueTime = $util.Long.fromValue(object.issueTime)).unsigned = true; + else if (typeof object.issueTime === "string") + message.issueTime = parseInt(object.issueTime, 10); + else if (typeof object.issueTime === "number") + message.issueTime = object.issueTime; + else if (typeof object.issueTime === "object") + message.issueTime = new $util.LongBits(object.issueTime.low >>> 0, object.issueTime.high >>> 0).toNumber(true); + switch (object.hostStorage) { + case "ON_PREMISE": + case 0: + message.hostStorage = 0; + break; + case "FACEBOOK": + case 1: + message.hostStorage = 1; + break; + } + switch (object.accountType) { + case "ENTERPRISE": + case 0: + message.accountType = 0; + break; + case "PAGE": + case 1: + message.accountType = 1; + break; + } + return message; + }; + + /** + * Creates a plain object from a BizAccountLinkInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.BizAccountLinkInfo + * @static + * @param {proto.BizAccountLinkInfo} message BizAccountLinkInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BizAccountLinkInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.whatsappBizAcctFbid = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.whatsappBizAcctFbid = options.longs === String ? "0" : 0; + object.whatsappAcctNumber = ""; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.issueTime = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.issueTime = options.longs === String ? "0" : 0; + object.hostStorage = options.enums === String ? "ON_PREMISE" : 0; + object.accountType = options.enums === String ? "ENTERPRISE" : 0; + } + if (message.whatsappBizAcctFbid != null && message.hasOwnProperty("whatsappBizAcctFbid")) + if (typeof message.whatsappBizAcctFbid === "number") + object.whatsappBizAcctFbid = options.longs === String ? String(message.whatsappBizAcctFbid) : message.whatsappBizAcctFbid; + else + object.whatsappBizAcctFbid = options.longs === String ? $util.Long.prototype.toString.call(message.whatsappBizAcctFbid) : options.longs === Number ? new $util.LongBits(message.whatsappBizAcctFbid.low >>> 0, message.whatsappBizAcctFbid.high >>> 0).toNumber(true) : message.whatsappBizAcctFbid; + if (message.whatsappAcctNumber != null && message.hasOwnProperty("whatsappAcctNumber")) + object.whatsappAcctNumber = message.whatsappAcctNumber; + if (message.issueTime != null && message.hasOwnProperty("issueTime")) + if (typeof message.issueTime === "number") + object.issueTime = options.longs === String ? String(message.issueTime) : message.issueTime; + else + object.issueTime = options.longs === String ? $util.Long.prototype.toString.call(message.issueTime) : options.longs === Number ? new $util.LongBits(message.issueTime.low >>> 0, message.issueTime.high >>> 0).toNumber(true) : message.issueTime; + if (message.hostStorage != null && message.hasOwnProperty("hostStorage")) + object.hostStorage = options.enums === String ? $root.proto.BizAccountLinkInfo.BizAccountLinkInfoHostStorageType[message.hostStorage] : message.hostStorage; + if (message.accountType != null && message.hasOwnProperty("accountType")) + object.accountType = options.enums === String ? $root.proto.BizAccountLinkInfo.BizAccountLinkInfoAccountType[message.accountType] : message.accountType; + return object; + }; + + /** + * Converts this BizAccountLinkInfo to JSON. + * @function toJSON + * @memberof proto.BizAccountLinkInfo + * @instance + * @returns {Object.} JSON object + */ + BizAccountLinkInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * BizAccountLinkInfoHostStorageType enum. + * @name proto.BizAccountLinkInfo.BizAccountLinkInfoHostStorageType + * @enum {number} + * @property {number} ON_PREMISE=0 ON_PREMISE value + * @property {number} FACEBOOK=1 FACEBOOK value + */ + BizAccountLinkInfo.BizAccountLinkInfoHostStorageType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ON_PREMISE"] = 0; + values[valuesById[1] = "FACEBOOK"] = 1; + return values; + })(); + + /** + * BizAccountLinkInfoAccountType enum. + * @name proto.BizAccountLinkInfo.BizAccountLinkInfoAccountType + * @enum {number} + * @property {number} ENTERPRISE=0 ENTERPRISE value + * @property {number} PAGE=1 PAGE value + */ + BizAccountLinkInfo.BizAccountLinkInfoAccountType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ENTERPRISE"] = 0; + values[valuesById[1] = "PAGE"] = 1; + return values; + })(); + + return BizAccountLinkInfo; + })(); + + proto.BizAccountPayload = (function() { + + /** + * Properties of a BizAccountPayload. + * @memberof proto + * @interface IBizAccountPayload + * @property {proto.IVerifiedNameCertificate|null} [vnameCert] BizAccountPayload vnameCert + * @property {Uint8Array|null} [bizAcctLinkInfo] BizAccountPayload bizAcctLinkInfo + */ + + /** + * Constructs a new BizAccountPayload. + * @memberof proto + * @classdesc Represents a BizAccountPayload. + * @implements IBizAccountPayload + * @constructor + * @param {proto.IBizAccountPayload=} [properties] Properties to set + */ + function BizAccountPayload(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BizAccountPayload vnameCert. + * @member {proto.IVerifiedNameCertificate|null|undefined} vnameCert + * @memberof proto.BizAccountPayload + * @instance + */ + BizAccountPayload.prototype.vnameCert = null; + + /** + * BizAccountPayload bizAcctLinkInfo. + * @member {Uint8Array} bizAcctLinkInfo + * @memberof proto.BizAccountPayload + * @instance + */ + BizAccountPayload.prototype.bizAcctLinkInfo = $util.newBuffer([]); + + /** + * Creates a new BizAccountPayload instance using the specified properties. + * @function create + * @memberof proto.BizAccountPayload + * @static + * @param {proto.IBizAccountPayload=} [properties] Properties to set + * @returns {proto.BizAccountPayload} BizAccountPayload instance + */ + BizAccountPayload.create = function create(properties) { + return new BizAccountPayload(properties); + }; + + /** + * Encodes the specified BizAccountPayload message. Does not implicitly {@link proto.BizAccountPayload.verify|verify} messages. + * @function encode + * @memberof proto.BizAccountPayload + * @static + * @param {proto.IBizAccountPayload} message BizAccountPayload message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BizAccountPayload.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.vnameCert != null && Object.hasOwnProperty.call(message, "vnameCert")) + $root.proto.VerifiedNameCertificate.encode(message.vnameCert, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.bizAcctLinkInfo != null && Object.hasOwnProperty.call(message, "bizAcctLinkInfo")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.bizAcctLinkInfo); + return writer; + }; + + /** + * Encodes the specified BizAccountPayload message, length delimited. Does not implicitly {@link proto.BizAccountPayload.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.BizAccountPayload + * @static + * @param {proto.IBizAccountPayload} message BizAccountPayload message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BizAccountPayload.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BizAccountPayload message from the specified reader or buffer. + * @function decode + * @memberof proto.BizAccountPayload + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.BizAccountPayload} BizAccountPayload + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BizAccountPayload.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.BizAccountPayload(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.vnameCert = $root.proto.VerifiedNameCertificate.decode(reader, reader.uint32()); + break; + case 2: + message.bizAcctLinkInfo = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BizAccountPayload message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.BizAccountPayload + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.BizAccountPayload} BizAccountPayload + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BizAccountPayload.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BizAccountPayload message. + * @function verify + * @memberof proto.BizAccountPayload + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BizAccountPayload.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.vnameCert != null && message.hasOwnProperty("vnameCert")) { + var error = $root.proto.VerifiedNameCertificate.verify(message.vnameCert); + if (error) + return "vnameCert." + error; + } + if (message.bizAcctLinkInfo != null && message.hasOwnProperty("bizAcctLinkInfo")) + if (!(message.bizAcctLinkInfo && typeof message.bizAcctLinkInfo.length === "number" || $util.isString(message.bizAcctLinkInfo))) + return "bizAcctLinkInfo: buffer expected"; + return null; + }; + + /** + * Creates a BizAccountPayload message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.BizAccountPayload + * @static + * @param {Object.} object Plain object + * @returns {proto.BizAccountPayload} BizAccountPayload + */ + BizAccountPayload.fromObject = function fromObject(object) { + if (object instanceof $root.proto.BizAccountPayload) + return object; + var message = new $root.proto.BizAccountPayload(); + if (object.vnameCert != null) { + if (typeof object.vnameCert !== "object") + throw TypeError(".proto.BizAccountPayload.vnameCert: object expected"); + message.vnameCert = $root.proto.VerifiedNameCertificate.fromObject(object.vnameCert); + } + if (object.bizAcctLinkInfo != null) + if (typeof object.bizAcctLinkInfo === "string") + $util.base64.decode(object.bizAcctLinkInfo, message.bizAcctLinkInfo = $util.newBuffer($util.base64.length(object.bizAcctLinkInfo)), 0); + else if (object.bizAcctLinkInfo.length) + message.bizAcctLinkInfo = object.bizAcctLinkInfo; + return message; + }; + + /** + * Creates a plain object from a BizAccountPayload message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.BizAccountPayload + * @static + * @param {proto.BizAccountPayload} message BizAccountPayload + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BizAccountPayload.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.vnameCert = null; + if (options.bytes === String) + object.bizAcctLinkInfo = ""; + else { + object.bizAcctLinkInfo = []; + if (options.bytes !== Array) + object.bizAcctLinkInfo = $util.newBuffer(object.bizAcctLinkInfo); + } + } + if (message.vnameCert != null && message.hasOwnProperty("vnameCert")) + object.vnameCert = $root.proto.VerifiedNameCertificate.toObject(message.vnameCert, options); + if (message.bizAcctLinkInfo != null && message.hasOwnProperty("bizAcctLinkInfo")) + object.bizAcctLinkInfo = options.bytes === String ? $util.base64.encode(message.bizAcctLinkInfo, 0, message.bizAcctLinkInfo.length) : options.bytes === Array ? Array.prototype.slice.call(message.bizAcctLinkInfo) : message.bizAcctLinkInfo; + return object; + }; + + /** + * Converts this BizAccountPayload to JSON. + * @function toJSON + * @memberof proto.BizAccountPayload + * @instance + * @returns {Object.} JSON object + */ + BizAccountPayload.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return BizAccountPayload; + })(); + + proto.VerifiedNameCertificate = (function() { + + /** + * Properties of a VerifiedNameCertificate. + * @memberof proto + * @interface IVerifiedNameCertificate + * @property {Uint8Array|null} [details] VerifiedNameCertificate details + * @property {Uint8Array|null} [signature] VerifiedNameCertificate signature + * @property {Uint8Array|null} [serverSignature] VerifiedNameCertificate serverSignature + */ + + /** + * Constructs a new VerifiedNameCertificate. + * @memberof proto + * @classdesc Represents a VerifiedNameCertificate. + * @implements IVerifiedNameCertificate + * @constructor + * @param {proto.IVerifiedNameCertificate=} [properties] Properties to set + */ + function VerifiedNameCertificate(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * VerifiedNameCertificate details. + * @member {Uint8Array} details + * @memberof proto.VerifiedNameCertificate + * @instance + */ + VerifiedNameCertificate.prototype.details = $util.newBuffer([]); + + /** + * VerifiedNameCertificate signature. + * @member {Uint8Array} signature + * @memberof proto.VerifiedNameCertificate + * @instance + */ + VerifiedNameCertificate.prototype.signature = $util.newBuffer([]); + + /** + * VerifiedNameCertificate serverSignature. + * @member {Uint8Array} serverSignature + * @memberof proto.VerifiedNameCertificate + * @instance + */ + VerifiedNameCertificate.prototype.serverSignature = $util.newBuffer([]); + + /** + * Creates a new VerifiedNameCertificate instance using the specified properties. + * @function create + * @memberof proto.VerifiedNameCertificate + * @static + * @param {proto.IVerifiedNameCertificate=} [properties] Properties to set + * @returns {proto.VerifiedNameCertificate} VerifiedNameCertificate instance + */ + VerifiedNameCertificate.create = function create(properties) { + return new VerifiedNameCertificate(properties); + }; + + /** + * Encodes the specified VerifiedNameCertificate message. Does not implicitly {@link proto.VerifiedNameCertificate.verify|verify} messages. + * @function encode + * @memberof proto.VerifiedNameCertificate + * @static + * @param {proto.IVerifiedNameCertificate} message VerifiedNameCertificate message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VerifiedNameCertificate.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.details != null && Object.hasOwnProperty.call(message, "details")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.details); + if (message.signature != null && Object.hasOwnProperty.call(message, "signature")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.signature); + if (message.serverSignature != null && Object.hasOwnProperty.call(message, "serverSignature")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.serverSignature); + return writer; + }; + + /** + * Encodes the specified VerifiedNameCertificate message, length delimited. Does not implicitly {@link proto.VerifiedNameCertificate.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.VerifiedNameCertificate + * @static + * @param {proto.IVerifiedNameCertificate} message VerifiedNameCertificate message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VerifiedNameCertificate.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a VerifiedNameCertificate message from the specified reader or buffer. + * @function decode + * @memberof proto.VerifiedNameCertificate + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.VerifiedNameCertificate} VerifiedNameCertificate + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VerifiedNameCertificate.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.VerifiedNameCertificate(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.details = reader.bytes(); + break; + case 2: + message.signature = reader.bytes(); + break; + case 3: + message.serverSignature = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a VerifiedNameCertificate message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.VerifiedNameCertificate + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.VerifiedNameCertificate} VerifiedNameCertificate + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VerifiedNameCertificate.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a VerifiedNameCertificate message. + * @function verify + * @memberof proto.VerifiedNameCertificate + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + VerifiedNameCertificate.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.details != null && message.hasOwnProperty("details")) + if (!(message.details && typeof message.details.length === "number" || $util.isString(message.details))) + return "details: buffer expected"; + if (message.signature != null && message.hasOwnProperty("signature")) + if (!(message.signature && typeof message.signature.length === "number" || $util.isString(message.signature))) + return "signature: buffer expected"; + if (message.serverSignature != null && message.hasOwnProperty("serverSignature")) + if (!(message.serverSignature && typeof message.serverSignature.length === "number" || $util.isString(message.serverSignature))) + return "serverSignature: buffer expected"; + return null; + }; + + /** + * Creates a VerifiedNameCertificate message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.VerifiedNameCertificate + * @static + * @param {Object.} object Plain object + * @returns {proto.VerifiedNameCertificate} VerifiedNameCertificate + */ + VerifiedNameCertificate.fromObject = function fromObject(object) { + if (object instanceof $root.proto.VerifiedNameCertificate) + return object; + var message = new $root.proto.VerifiedNameCertificate(); + if (object.details != null) + if (typeof object.details === "string") + $util.base64.decode(object.details, message.details = $util.newBuffer($util.base64.length(object.details)), 0); + else if (object.details.length) + message.details = object.details; + if (object.signature != null) + if (typeof object.signature === "string") + $util.base64.decode(object.signature, message.signature = $util.newBuffer($util.base64.length(object.signature)), 0); + else if (object.signature.length) + message.signature = object.signature; + if (object.serverSignature != null) + if (typeof object.serverSignature === "string") + $util.base64.decode(object.serverSignature, message.serverSignature = $util.newBuffer($util.base64.length(object.serverSignature)), 0); + else if (object.serverSignature.length) + message.serverSignature = object.serverSignature; + return message; + }; + + /** + * Creates a plain object from a VerifiedNameCertificate message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.VerifiedNameCertificate + * @static + * @param {proto.VerifiedNameCertificate} message VerifiedNameCertificate + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + VerifiedNameCertificate.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if (options.bytes === String) + object.details = ""; + else { + object.details = []; + if (options.bytes !== Array) + object.details = $util.newBuffer(object.details); + } + if (options.bytes === String) + object.signature = ""; + else { + object.signature = []; + if (options.bytes !== Array) + object.signature = $util.newBuffer(object.signature); + } + if (options.bytes === String) + object.serverSignature = ""; + else { + object.serverSignature = []; + if (options.bytes !== Array) + object.serverSignature = $util.newBuffer(object.serverSignature); + } + } + if (message.details != null && message.hasOwnProperty("details")) + object.details = options.bytes === String ? $util.base64.encode(message.details, 0, message.details.length) : options.bytes === Array ? Array.prototype.slice.call(message.details) : message.details; + if (message.signature != null && message.hasOwnProperty("signature")) + object.signature = options.bytes === String ? $util.base64.encode(message.signature, 0, message.signature.length) : options.bytes === Array ? Array.prototype.slice.call(message.signature) : message.signature; + if (message.serverSignature != null && message.hasOwnProperty("serverSignature")) + object.serverSignature = options.bytes === String ? $util.base64.encode(message.serverSignature, 0, message.serverSignature.length) : options.bytes === Array ? Array.prototype.slice.call(message.serverSignature) : message.serverSignature; + return object; + }; + + /** + * Converts this VerifiedNameCertificate to JSON. + * @function toJSON + * @memberof proto.VerifiedNameCertificate + * @instance + * @returns {Object.} JSON object + */ + VerifiedNameCertificate.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return VerifiedNameCertificate; + })(); + + proto.LocalizedName = (function() { + + /** + * Properties of a LocalizedName. + * @memberof proto + * @interface ILocalizedName + * @property {string|null} [lg] LocalizedName lg + * @property {string|null} [lc] LocalizedName lc + * @property {string|null} [verifiedName] LocalizedName verifiedName + */ + + /** + * Constructs a new LocalizedName. + * @memberof proto + * @classdesc Represents a LocalizedName. + * @implements ILocalizedName + * @constructor + * @param {proto.ILocalizedName=} [properties] Properties to set + */ + function LocalizedName(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * LocalizedName lg. + * @member {string} lg + * @memberof proto.LocalizedName + * @instance + */ + LocalizedName.prototype.lg = ""; + + /** + * LocalizedName lc. + * @member {string} lc + * @memberof proto.LocalizedName + * @instance + */ + LocalizedName.prototype.lc = ""; + + /** + * LocalizedName verifiedName. + * @member {string} verifiedName + * @memberof proto.LocalizedName + * @instance + */ + LocalizedName.prototype.verifiedName = ""; + + /** + * Creates a new LocalizedName instance using the specified properties. + * @function create + * @memberof proto.LocalizedName + * @static + * @param {proto.ILocalizedName=} [properties] Properties to set + * @returns {proto.LocalizedName} LocalizedName instance + */ + LocalizedName.create = function create(properties) { + return new LocalizedName(properties); + }; + + /** + * Encodes the specified LocalizedName message. Does not implicitly {@link proto.LocalizedName.verify|verify} messages. + * @function encode + * @memberof proto.LocalizedName + * @static + * @param {proto.ILocalizedName} message LocalizedName message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LocalizedName.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.lg != null && Object.hasOwnProperty.call(message, "lg")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.lg); + if (message.lc != null && Object.hasOwnProperty.call(message, "lc")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.lc); + if (message.verifiedName != null && Object.hasOwnProperty.call(message, "verifiedName")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.verifiedName); + return writer; + }; + + /** + * Encodes the specified LocalizedName message, length delimited. Does not implicitly {@link proto.LocalizedName.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.LocalizedName + * @static + * @param {proto.ILocalizedName} message LocalizedName message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LocalizedName.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a LocalizedName message from the specified reader or buffer. + * @function decode + * @memberof proto.LocalizedName + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.LocalizedName} LocalizedName + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LocalizedName.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.LocalizedName(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.lg = reader.string(); + break; + case 2: + message.lc = reader.string(); + break; + case 3: + message.verifiedName = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a LocalizedName message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.LocalizedName + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.LocalizedName} LocalizedName + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LocalizedName.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a LocalizedName message. + * @function verify + * @memberof proto.LocalizedName + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LocalizedName.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.lg != null && message.hasOwnProperty("lg")) + if (!$util.isString(message.lg)) + return "lg: string expected"; + if (message.lc != null && message.hasOwnProperty("lc")) + if (!$util.isString(message.lc)) + return "lc: string expected"; + if (message.verifiedName != null && message.hasOwnProperty("verifiedName")) + if (!$util.isString(message.verifiedName)) + return "verifiedName: string expected"; + return null; + }; + + /** + * Creates a LocalizedName message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.LocalizedName + * @static + * @param {Object.} object Plain object + * @returns {proto.LocalizedName} LocalizedName + */ + LocalizedName.fromObject = function fromObject(object) { + if (object instanceof $root.proto.LocalizedName) + return object; + var message = new $root.proto.LocalizedName(); + if (object.lg != null) + message.lg = String(object.lg); + if (object.lc != null) + message.lc = String(object.lc); + if (object.verifiedName != null) + message.verifiedName = String(object.verifiedName); + return message; + }; + + /** + * Creates a plain object from a LocalizedName message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.LocalizedName + * @static + * @param {proto.LocalizedName} message LocalizedName + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LocalizedName.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.lg = ""; + object.lc = ""; + object.verifiedName = ""; + } + if (message.lg != null && message.hasOwnProperty("lg")) + object.lg = message.lg; + if (message.lc != null && message.hasOwnProperty("lc")) + object.lc = message.lc; + if (message.verifiedName != null && message.hasOwnProperty("verifiedName")) + object.verifiedName = message.verifiedName; + return object; + }; + + /** + * Converts this LocalizedName to JSON. + * @function toJSON + * @memberof proto.LocalizedName + * @instance + * @returns {Object.} JSON object + */ + LocalizedName.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return LocalizedName; + })(); + + proto.SyncActionData = (function() { + + /** + * Properties of a SyncActionData. + * @memberof proto + * @interface ISyncActionData + * @property {Uint8Array|null} [index] SyncActionData index + * @property {proto.ISyncActionValue|null} [value] SyncActionData value + * @property {Uint8Array|null} [padding] SyncActionData padding + * @property {number|null} [version] SyncActionData version + */ + + /** + * Constructs a new SyncActionData. + * @memberof proto + * @classdesc Represents a SyncActionData. + * @implements ISyncActionData + * @constructor + * @param {proto.ISyncActionData=} [properties] Properties to set + */ + function SyncActionData(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SyncActionData index. + * @member {Uint8Array} index + * @memberof proto.SyncActionData + * @instance + */ + SyncActionData.prototype.index = $util.newBuffer([]); + + /** + * SyncActionData value. + * @member {proto.ISyncActionValue|null|undefined} value + * @memberof proto.SyncActionData + * @instance + */ + SyncActionData.prototype.value = null; + + /** + * SyncActionData padding. + * @member {Uint8Array} padding + * @memberof proto.SyncActionData + * @instance + */ + SyncActionData.prototype.padding = $util.newBuffer([]); + + /** + * SyncActionData version. + * @member {number} version + * @memberof proto.SyncActionData + * @instance + */ + SyncActionData.prototype.version = 0; + + /** + * Creates a new SyncActionData instance using the specified properties. + * @function create + * @memberof proto.SyncActionData + * @static + * @param {proto.ISyncActionData=} [properties] Properties to set + * @returns {proto.SyncActionData} SyncActionData instance + */ + SyncActionData.create = function create(properties) { + return new SyncActionData(properties); + }; + + /** + * Encodes the specified SyncActionData message. Does not implicitly {@link proto.SyncActionData.verify|verify} messages. + * @function encode + * @memberof proto.SyncActionData + * @static + * @param {proto.ISyncActionData} message SyncActionData message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncActionData.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.index != null && Object.hasOwnProperty.call(message, "index")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.index); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + $root.proto.SyncActionValue.encode(message.value, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.padding != null && Object.hasOwnProperty.call(message, "padding")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.padding); + if (message.version != null && Object.hasOwnProperty.call(message, "version")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.version); + return writer; + }; + + /** + * Encodes the specified SyncActionData message, length delimited. Does not implicitly {@link proto.SyncActionData.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.SyncActionData + * @static + * @param {proto.ISyncActionData} message SyncActionData message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncActionData.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SyncActionData message from the specified reader or buffer. + * @function decode + * @memberof proto.SyncActionData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.SyncActionData} SyncActionData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncActionData.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.SyncActionData(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.index = reader.bytes(); + break; + case 2: + message.value = $root.proto.SyncActionValue.decode(reader, reader.uint32()); + break; + case 3: + message.padding = reader.bytes(); + break; + case 4: + message.version = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SyncActionData message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.SyncActionData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.SyncActionData} SyncActionData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncActionData.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SyncActionData message. + * @function verify + * @memberof proto.SyncActionData + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SyncActionData.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.index != null && message.hasOwnProperty("index")) + if (!(message.index && typeof message.index.length === "number" || $util.isString(message.index))) + return "index: buffer expected"; + if (message.value != null && message.hasOwnProperty("value")) { + var error = $root.proto.SyncActionValue.verify(message.value); + if (error) + return "value." + error; + } + if (message.padding != null && message.hasOwnProperty("padding")) + if (!(message.padding && typeof message.padding.length === "number" || $util.isString(message.padding))) + return "padding: buffer expected"; + if (message.version != null && message.hasOwnProperty("version")) + if (!$util.isInteger(message.version)) + return "version: integer expected"; + return null; + }; + + /** + * Creates a SyncActionData message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.SyncActionData + * @static + * @param {Object.} object Plain object + * @returns {proto.SyncActionData} SyncActionData + */ + SyncActionData.fromObject = function fromObject(object) { + if (object instanceof $root.proto.SyncActionData) + return object; + var message = new $root.proto.SyncActionData(); + if (object.index != null) + if (typeof object.index === "string") + $util.base64.decode(object.index, message.index = $util.newBuffer($util.base64.length(object.index)), 0); + else if (object.index.length) + message.index = object.index; + if (object.value != null) { + if (typeof object.value !== "object") + throw TypeError(".proto.SyncActionData.value: object expected"); + message.value = $root.proto.SyncActionValue.fromObject(object.value); + } + if (object.padding != null) + if (typeof object.padding === "string") + $util.base64.decode(object.padding, message.padding = $util.newBuffer($util.base64.length(object.padding)), 0); + else if (object.padding.length) + message.padding = object.padding; + if (object.version != null) + message.version = object.version | 0; + return message; + }; + + /** + * Creates a plain object from a SyncActionData message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.SyncActionData + * @static + * @param {proto.SyncActionData} message SyncActionData + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SyncActionData.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if (options.bytes === String) + object.index = ""; + else { + object.index = []; + if (options.bytes !== Array) + object.index = $util.newBuffer(object.index); + } + object.value = null; + if (options.bytes === String) + object.padding = ""; + else { + object.padding = []; + if (options.bytes !== Array) + object.padding = $util.newBuffer(object.padding); + } + object.version = 0; + } + if (message.index != null && message.hasOwnProperty("index")) + object.index = options.bytes === String ? $util.base64.encode(message.index, 0, message.index.length) : options.bytes === Array ? Array.prototype.slice.call(message.index) : message.index; + if (message.value != null && message.hasOwnProperty("value")) + object.value = $root.proto.SyncActionValue.toObject(message.value, options); + if (message.padding != null && message.hasOwnProperty("padding")) + object.padding = options.bytes === String ? $util.base64.encode(message.padding, 0, message.padding.length) : options.bytes === Array ? Array.prototype.slice.call(message.padding) : message.padding; + if (message.version != null && message.hasOwnProperty("version")) + object.version = message.version; + return object; + }; + + /** + * Converts this SyncActionData to JSON. + * @function toJSON + * @memberof proto.SyncActionData + * @instance + * @returns {Object.} JSON object + */ + SyncActionData.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return SyncActionData; + })(); + + proto.StarAction = (function() { + + /** + * Properties of a StarAction. + * @memberof proto + * @interface IStarAction + * @property {boolean|null} [starred] StarAction starred + */ + + /** + * Constructs a new StarAction. + * @memberof proto + * @classdesc Represents a StarAction. + * @implements IStarAction + * @constructor + * @param {proto.IStarAction=} [properties] Properties to set + */ + function StarAction(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * StarAction starred. + * @member {boolean} starred + * @memberof proto.StarAction + * @instance + */ + StarAction.prototype.starred = false; + + /** + * Creates a new StarAction instance using the specified properties. + * @function create + * @memberof proto.StarAction + * @static + * @param {proto.IStarAction=} [properties] Properties to set + * @returns {proto.StarAction} StarAction instance + */ + StarAction.create = function create(properties) { + return new StarAction(properties); + }; + + /** + * Encodes the specified StarAction message. Does not implicitly {@link proto.StarAction.verify|verify} messages. + * @function encode + * @memberof proto.StarAction + * @static + * @param {proto.IStarAction} message StarAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StarAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.starred != null && Object.hasOwnProperty.call(message, "starred")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.starred); + return writer; + }; + + /** + * Encodes the specified StarAction message, length delimited. Does not implicitly {@link proto.StarAction.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.StarAction + * @static + * @param {proto.IStarAction} message StarAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StarAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a StarAction message from the specified reader or buffer. + * @function decode + * @memberof proto.StarAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.StarAction} StarAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StarAction.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.StarAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.starred = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a StarAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.StarAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.StarAction} StarAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StarAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a StarAction message. + * @function verify + * @memberof proto.StarAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + StarAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.starred != null && message.hasOwnProperty("starred")) + if (typeof message.starred !== "boolean") + return "starred: boolean expected"; + return null; + }; + + /** + * Creates a StarAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.StarAction + * @static + * @param {Object.} object Plain object + * @returns {proto.StarAction} StarAction + */ + StarAction.fromObject = function fromObject(object) { + if (object instanceof $root.proto.StarAction) + return object; + var message = new $root.proto.StarAction(); + if (object.starred != null) + message.starred = Boolean(object.starred); + return message; + }; + + /** + * Creates a plain object from a StarAction message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.StarAction + * @static + * @param {proto.StarAction} message StarAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StarAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.starred = false; + if (message.starred != null && message.hasOwnProperty("starred")) + object.starred = message.starred; + return object; + }; + + /** + * Converts this StarAction to JSON. + * @function toJSON + * @memberof proto.StarAction + * @instance + * @returns {Object.} JSON object + */ + StarAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return StarAction; + })(); + + proto.ContactAction = (function() { + + /** + * Properties of a ContactAction. + * @memberof proto + * @interface IContactAction + * @property {string|null} [fullName] ContactAction fullName + * @property {string|null} [firstName] ContactAction firstName + */ + + /** + * Constructs a new ContactAction. + * @memberof proto + * @classdesc Represents a ContactAction. + * @implements IContactAction + * @constructor + * @param {proto.IContactAction=} [properties] Properties to set + */ + function ContactAction(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ContactAction fullName. + * @member {string} fullName + * @memberof proto.ContactAction + * @instance + */ + ContactAction.prototype.fullName = ""; + + /** + * ContactAction firstName. + * @member {string} firstName + * @memberof proto.ContactAction + * @instance + */ + ContactAction.prototype.firstName = ""; + + /** + * Creates a new ContactAction instance using the specified properties. + * @function create + * @memberof proto.ContactAction + * @static + * @param {proto.IContactAction=} [properties] Properties to set + * @returns {proto.ContactAction} ContactAction instance + */ + ContactAction.create = function create(properties) { + return new ContactAction(properties); + }; + + /** + * Encodes the specified ContactAction message. Does not implicitly {@link proto.ContactAction.verify|verify} messages. + * @function encode + * @memberof proto.ContactAction + * @static + * @param {proto.IContactAction} message ContactAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ContactAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.fullName != null && Object.hasOwnProperty.call(message, "fullName")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.fullName); + if (message.firstName != null && Object.hasOwnProperty.call(message, "firstName")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.firstName); + return writer; + }; + + /** + * Encodes the specified ContactAction message, length delimited. Does not implicitly {@link proto.ContactAction.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.ContactAction + * @static + * @param {proto.IContactAction} message ContactAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ContactAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ContactAction message from the specified reader or buffer. + * @function decode + * @memberof proto.ContactAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.ContactAction} ContactAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ContactAction.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.ContactAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.fullName = reader.string(); + break; + case 2: + message.firstName = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ContactAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.ContactAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.ContactAction} ContactAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ContactAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ContactAction message. + * @function verify + * @memberof proto.ContactAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ContactAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.fullName != null && message.hasOwnProperty("fullName")) + if (!$util.isString(message.fullName)) + return "fullName: string expected"; + if (message.firstName != null && message.hasOwnProperty("firstName")) + if (!$util.isString(message.firstName)) + return "firstName: string expected"; + return null; + }; + + /** + * Creates a ContactAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.ContactAction + * @static + * @param {Object.} object Plain object + * @returns {proto.ContactAction} ContactAction + */ + ContactAction.fromObject = function fromObject(object) { + if (object instanceof $root.proto.ContactAction) + return object; + var message = new $root.proto.ContactAction(); + if (object.fullName != null) + message.fullName = String(object.fullName); + if (object.firstName != null) + message.firstName = String(object.firstName); + return message; + }; + + /** + * Creates a plain object from a ContactAction message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.ContactAction + * @static + * @param {proto.ContactAction} message ContactAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ContactAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.fullName = ""; + object.firstName = ""; + } + if (message.fullName != null && message.hasOwnProperty("fullName")) + object.fullName = message.fullName; + if (message.firstName != null && message.hasOwnProperty("firstName")) + object.firstName = message.firstName; + return object; + }; + + /** + * Converts this ContactAction to JSON. + * @function toJSON + * @memberof proto.ContactAction + * @instance + * @returns {Object.} JSON object + */ + ContactAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ContactAction; + })(); + + proto.MuteAction = (function() { + + /** + * Properties of a MuteAction. + * @memberof proto + * @interface IMuteAction + * @property {boolean|null} [muted] MuteAction muted + * @property {number|Long|null} [muteEndTimestamp] MuteAction muteEndTimestamp + */ + + /** + * Constructs a new MuteAction. + * @memberof proto + * @classdesc Represents a MuteAction. + * @implements IMuteAction + * @constructor + * @param {proto.IMuteAction=} [properties] Properties to set + */ + function MuteAction(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MuteAction muted. + * @member {boolean} muted + * @memberof proto.MuteAction + * @instance + */ + MuteAction.prototype.muted = false; + + /** + * MuteAction muteEndTimestamp. + * @member {number|Long} muteEndTimestamp + * @memberof proto.MuteAction + * @instance + */ + MuteAction.prototype.muteEndTimestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new MuteAction instance using the specified properties. + * @function create + * @memberof proto.MuteAction + * @static + * @param {proto.IMuteAction=} [properties] Properties to set + * @returns {proto.MuteAction} MuteAction instance + */ + MuteAction.create = function create(properties) { + return new MuteAction(properties); + }; + + /** + * Encodes the specified MuteAction message. Does not implicitly {@link proto.MuteAction.verify|verify} messages. + * @function encode + * @memberof proto.MuteAction + * @static + * @param {proto.IMuteAction} message MuteAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MuteAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.muted != null && Object.hasOwnProperty.call(message, "muted")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.muted); + if (message.muteEndTimestamp != null && Object.hasOwnProperty.call(message, "muteEndTimestamp")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.muteEndTimestamp); + return writer; + }; + + /** + * Encodes the specified MuteAction message, length delimited. Does not implicitly {@link proto.MuteAction.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.MuteAction + * @static + * @param {proto.IMuteAction} message MuteAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MuteAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MuteAction message from the specified reader or buffer. + * @function decode + * @memberof proto.MuteAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.MuteAction} MuteAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MuteAction.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.MuteAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.muted = reader.bool(); + break; + case 2: + message.muteEndTimestamp = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MuteAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.MuteAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.MuteAction} MuteAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MuteAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MuteAction message. + * @function verify + * @memberof proto.MuteAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MuteAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.muted != null && message.hasOwnProperty("muted")) + if (typeof message.muted !== "boolean") + return "muted: boolean expected"; + if (message.muteEndTimestamp != null && message.hasOwnProperty("muteEndTimestamp")) + if (!$util.isInteger(message.muteEndTimestamp) && !(message.muteEndTimestamp && $util.isInteger(message.muteEndTimestamp.low) && $util.isInteger(message.muteEndTimestamp.high))) + return "muteEndTimestamp: integer|Long expected"; + return null; + }; + + /** + * Creates a MuteAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.MuteAction + * @static + * @param {Object.} object Plain object + * @returns {proto.MuteAction} MuteAction + */ + MuteAction.fromObject = function fromObject(object) { + if (object instanceof $root.proto.MuteAction) + return object; + var message = new $root.proto.MuteAction(); + if (object.muted != null) + message.muted = Boolean(object.muted); + if (object.muteEndTimestamp != null) + if ($util.Long) + (message.muteEndTimestamp = $util.Long.fromValue(object.muteEndTimestamp)).unsigned = false; + else if (typeof object.muteEndTimestamp === "string") + message.muteEndTimestamp = parseInt(object.muteEndTimestamp, 10); + else if (typeof object.muteEndTimestamp === "number") + message.muteEndTimestamp = object.muteEndTimestamp; + else if (typeof object.muteEndTimestamp === "object") + message.muteEndTimestamp = new $util.LongBits(object.muteEndTimestamp.low >>> 0, object.muteEndTimestamp.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a MuteAction message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.MuteAction + * @static + * @param {proto.MuteAction} message MuteAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MuteAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.muted = false; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.muteEndTimestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.muteEndTimestamp = options.longs === String ? "0" : 0; + } + if (message.muted != null && message.hasOwnProperty("muted")) + object.muted = message.muted; + if (message.muteEndTimestamp != null && message.hasOwnProperty("muteEndTimestamp")) + if (typeof message.muteEndTimestamp === "number") + object.muteEndTimestamp = options.longs === String ? String(message.muteEndTimestamp) : message.muteEndTimestamp; + else + object.muteEndTimestamp = options.longs === String ? $util.Long.prototype.toString.call(message.muteEndTimestamp) : options.longs === Number ? new $util.LongBits(message.muteEndTimestamp.low >>> 0, message.muteEndTimestamp.high >>> 0).toNumber() : message.muteEndTimestamp; + return object; + }; + + /** + * Converts this MuteAction to JSON. + * @function toJSON + * @memberof proto.MuteAction + * @instance + * @returns {Object.} JSON object + */ + MuteAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return MuteAction; + })(); + + proto.PinAction = (function() { + + /** + * Properties of a PinAction. + * @memberof proto + * @interface IPinAction + * @property {boolean|null} [pinned] PinAction pinned + */ + + /** + * Constructs a new PinAction. + * @memberof proto + * @classdesc Represents a PinAction. + * @implements IPinAction + * @constructor + * @param {proto.IPinAction=} [properties] Properties to set + */ + function PinAction(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * PinAction pinned. + * @member {boolean} pinned + * @memberof proto.PinAction + * @instance + */ + PinAction.prototype.pinned = false; + + /** + * Creates a new PinAction instance using the specified properties. + * @function create + * @memberof proto.PinAction + * @static + * @param {proto.IPinAction=} [properties] Properties to set + * @returns {proto.PinAction} PinAction instance + */ + PinAction.create = function create(properties) { + return new PinAction(properties); + }; + + /** + * Encodes the specified PinAction message. Does not implicitly {@link proto.PinAction.verify|verify} messages. + * @function encode + * @memberof proto.PinAction + * @static + * @param {proto.IPinAction} message PinAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PinAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.pinned != null && Object.hasOwnProperty.call(message, "pinned")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.pinned); + return writer; + }; + + /** + * Encodes the specified PinAction message, length delimited. Does not implicitly {@link proto.PinAction.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.PinAction + * @static + * @param {proto.IPinAction} message PinAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PinAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PinAction message from the specified reader or buffer. + * @function decode + * @memberof proto.PinAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.PinAction} PinAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PinAction.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.PinAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pinned = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PinAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.PinAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.PinAction} PinAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PinAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PinAction message. + * @function verify + * @memberof proto.PinAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PinAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.pinned != null && message.hasOwnProperty("pinned")) + if (typeof message.pinned !== "boolean") + return "pinned: boolean expected"; + return null; + }; + + /** + * Creates a PinAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.PinAction + * @static + * @param {Object.} object Plain object + * @returns {proto.PinAction} PinAction + */ + PinAction.fromObject = function fromObject(object) { + if (object instanceof $root.proto.PinAction) + return object; + var message = new $root.proto.PinAction(); + if (object.pinned != null) + message.pinned = Boolean(object.pinned); + return message; + }; + + /** + * Creates a plain object from a PinAction message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.PinAction + * @static + * @param {proto.PinAction} message PinAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PinAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.pinned = false; + if (message.pinned != null && message.hasOwnProperty("pinned")) + object.pinned = message.pinned; + return object; + }; + + /** + * Converts this PinAction to JSON. + * @function toJSON + * @memberof proto.PinAction + * @instance + * @returns {Object.} JSON object + */ + PinAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return PinAction; + })(); + + proto.SecurityNotificationSetting = (function() { + + /** + * Properties of a SecurityNotificationSetting. + * @memberof proto + * @interface ISecurityNotificationSetting + * @property {boolean|null} [showNotification] SecurityNotificationSetting showNotification + */ + + /** + * Constructs a new SecurityNotificationSetting. + * @memberof proto + * @classdesc Represents a SecurityNotificationSetting. + * @implements ISecurityNotificationSetting + * @constructor + * @param {proto.ISecurityNotificationSetting=} [properties] Properties to set + */ + function SecurityNotificationSetting(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SecurityNotificationSetting showNotification. + * @member {boolean} showNotification + * @memberof proto.SecurityNotificationSetting + * @instance + */ + SecurityNotificationSetting.prototype.showNotification = false; + + /** + * Creates a new SecurityNotificationSetting instance using the specified properties. + * @function create + * @memberof proto.SecurityNotificationSetting + * @static + * @param {proto.ISecurityNotificationSetting=} [properties] Properties to set + * @returns {proto.SecurityNotificationSetting} SecurityNotificationSetting instance + */ + SecurityNotificationSetting.create = function create(properties) { + return new SecurityNotificationSetting(properties); + }; + + /** + * Encodes the specified SecurityNotificationSetting message. Does not implicitly {@link proto.SecurityNotificationSetting.verify|verify} messages. + * @function encode + * @memberof proto.SecurityNotificationSetting + * @static + * @param {proto.ISecurityNotificationSetting} message SecurityNotificationSetting message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SecurityNotificationSetting.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.showNotification != null && Object.hasOwnProperty.call(message, "showNotification")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.showNotification); + return writer; + }; + + /** + * Encodes the specified SecurityNotificationSetting message, length delimited. Does not implicitly {@link proto.SecurityNotificationSetting.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.SecurityNotificationSetting + * @static + * @param {proto.ISecurityNotificationSetting} message SecurityNotificationSetting message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SecurityNotificationSetting.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SecurityNotificationSetting message from the specified reader or buffer. + * @function decode + * @memberof proto.SecurityNotificationSetting + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.SecurityNotificationSetting} SecurityNotificationSetting + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SecurityNotificationSetting.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.SecurityNotificationSetting(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.showNotification = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SecurityNotificationSetting message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.SecurityNotificationSetting + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.SecurityNotificationSetting} SecurityNotificationSetting + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SecurityNotificationSetting.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SecurityNotificationSetting message. + * @function verify + * @memberof proto.SecurityNotificationSetting + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SecurityNotificationSetting.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.showNotification != null && message.hasOwnProperty("showNotification")) + if (typeof message.showNotification !== "boolean") + return "showNotification: boolean expected"; + return null; + }; + + /** + * Creates a SecurityNotificationSetting message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.SecurityNotificationSetting + * @static + * @param {Object.} object Plain object + * @returns {proto.SecurityNotificationSetting} SecurityNotificationSetting + */ + SecurityNotificationSetting.fromObject = function fromObject(object) { + if (object instanceof $root.proto.SecurityNotificationSetting) + return object; + var message = new $root.proto.SecurityNotificationSetting(); + if (object.showNotification != null) + message.showNotification = Boolean(object.showNotification); + return message; + }; + + /** + * Creates a plain object from a SecurityNotificationSetting message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.SecurityNotificationSetting + * @static + * @param {proto.SecurityNotificationSetting} message SecurityNotificationSetting + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SecurityNotificationSetting.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.showNotification = false; + if (message.showNotification != null && message.hasOwnProperty("showNotification")) + object.showNotification = message.showNotification; + return object; + }; + + /** + * Converts this SecurityNotificationSetting to JSON. + * @function toJSON + * @memberof proto.SecurityNotificationSetting + * @instance + * @returns {Object.} JSON object + */ + SecurityNotificationSetting.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return SecurityNotificationSetting; + })(); + + proto.PushNameSetting = (function() { + + /** + * Properties of a PushNameSetting. + * @memberof proto + * @interface IPushNameSetting + * @property {string|null} [name] PushNameSetting name + */ + + /** + * Constructs a new PushNameSetting. + * @memberof proto + * @classdesc Represents a PushNameSetting. + * @implements IPushNameSetting + * @constructor + * @param {proto.IPushNameSetting=} [properties] Properties to set + */ + function PushNameSetting(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * PushNameSetting name. + * @member {string} name + * @memberof proto.PushNameSetting + * @instance + */ + PushNameSetting.prototype.name = ""; + + /** + * Creates a new PushNameSetting instance using the specified properties. + * @function create + * @memberof proto.PushNameSetting + * @static + * @param {proto.IPushNameSetting=} [properties] Properties to set + * @returns {proto.PushNameSetting} PushNameSetting instance + */ + PushNameSetting.create = function create(properties) { + return new PushNameSetting(properties); + }; + + /** + * Encodes the specified PushNameSetting message. Does not implicitly {@link proto.PushNameSetting.verify|verify} messages. + * @function encode + * @memberof proto.PushNameSetting + * @static + * @param {proto.IPushNameSetting} message PushNameSetting message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PushNameSetting.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + return writer; + }; + + /** + * Encodes the specified PushNameSetting message, length delimited. Does not implicitly {@link proto.PushNameSetting.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.PushNameSetting + * @static + * @param {proto.IPushNameSetting} message PushNameSetting message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PushNameSetting.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PushNameSetting message from the specified reader or buffer. + * @function decode + * @memberof proto.PushNameSetting + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.PushNameSetting} PushNameSetting + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PushNameSetting.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.PushNameSetting(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PushNameSetting message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.PushNameSetting + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.PushNameSetting} PushNameSetting + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PushNameSetting.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PushNameSetting message. + * @function verify + * @memberof proto.PushNameSetting + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PushNameSetting.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + return null; + }; + + /** + * Creates a PushNameSetting message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.PushNameSetting + * @static + * @param {Object.} object Plain object + * @returns {proto.PushNameSetting} PushNameSetting + */ + PushNameSetting.fromObject = function fromObject(object) { + if (object instanceof $root.proto.PushNameSetting) + return object; + var message = new $root.proto.PushNameSetting(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a PushNameSetting message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.PushNameSetting + * @static + * @param {proto.PushNameSetting} message PushNameSetting + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PushNameSetting.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this PushNameSetting to JSON. + * @function toJSON + * @memberof proto.PushNameSetting + * @instance + * @returns {Object.} JSON object + */ + PushNameSetting.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return PushNameSetting; + })(); + + proto.LocaleSetting = (function() { + + /** + * Properties of a LocaleSetting. + * @memberof proto + * @interface ILocaleSetting + * @property {string|null} [locale] LocaleSetting locale + */ + + /** + * Constructs a new LocaleSetting. + * @memberof proto + * @classdesc Represents a LocaleSetting. + * @implements ILocaleSetting + * @constructor + * @param {proto.ILocaleSetting=} [properties] Properties to set + */ + function LocaleSetting(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * LocaleSetting locale. + * @member {string} locale + * @memberof proto.LocaleSetting + * @instance + */ + LocaleSetting.prototype.locale = ""; + + /** + * Creates a new LocaleSetting instance using the specified properties. + * @function create + * @memberof proto.LocaleSetting + * @static + * @param {proto.ILocaleSetting=} [properties] Properties to set + * @returns {proto.LocaleSetting} LocaleSetting instance + */ + LocaleSetting.create = function create(properties) { + return new LocaleSetting(properties); + }; + + /** + * Encodes the specified LocaleSetting message. Does not implicitly {@link proto.LocaleSetting.verify|verify} messages. + * @function encode + * @memberof proto.LocaleSetting + * @static + * @param {proto.ILocaleSetting} message LocaleSetting message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LocaleSetting.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.locale != null && Object.hasOwnProperty.call(message, "locale")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.locale); + return writer; + }; + + /** + * Encodes the specified LocaleSetting message, length delimited. Does not implicitly {@link proto.LocaleSetting.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.LocaleSetting + * @static + * @param {proto.ILocaleSetting} message LocaleSetting message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LocaleSetting.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a LocaleSetting message from the specified reader or buffer. + * @function decode + * @memberof proto.LocaleSetting + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.LocaleSetting} LocaleSetting + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LocaleSetting.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.LocaleSetting(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.locale = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a LocaleSetting message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.LocaleSetting + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.LocaleSetting} LocaleSetting + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LocaleSetting.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a LocaleSetting message. + * @function verify + * @memberof proto.LocaleSetting + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LocaleSetting.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.locale != null && message.hasOwnProperty("locale")) + if (!$util.isString(message.locale)) + return "locale: string expected"; + return null; + }; + + /** + * Creates a LocaleSetting message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.LocaleSetting + * @static + * @param {Object.} object Plain object + * @returns {proto.LocaleSetting} LocaleSetting + */ + LocaleSetting.fromObject = function fromObject(object) { + if (object instanceof $root.proto.LocaleSetting) + return object; + var message = new $root.proto.LocaleSetting(); + if (object.locale != null) + message.locale = String(object.locale); + return message; + }; + + /** + * Creates a plain object from a LocaleSetting message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.LocaleSetting + * @static + * @param {proto.LocaleSetting} message LocaleSetting + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LocaleSetting.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.locale = ""; + if (message.locale != null && message.hasOwnProperty("locale")) + object.locale = message.locale; + return object; + }; + + /** + * Converts this LocaleSetting to JSON. + * @function toJSON + * @memberof proto.LocaleSetting + * @instance + * @returns {Object.} JSON object + */ + LocaleSetting.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return LocaleSetting; + })(); + + proto.QuickReplyAction = (function() { + + /** + * Properties of a QuickReplyAction. + * @memberof proto + * @interface IQuickReplyAction + * @property {string|null} [shortcut] QuickReplyAction shortcut + * @property {string|null} [message] QuickReplyAction message + * @property {Array.|null} [keywords] QuickReplyAction keywords + * @property {number|null} [count] QuickReplyAction count + * @property {boolean|null} [deleted] QuickReplyAction deleted + */ + + /** + * Constructs a new QuickReplyAction. + * @memberof proto + * @classdesc Represents a QuickReplyAction. + * @implements IQuickReplyAction + * @constructor + * @param {proto.IQuickReplyAction=} [properties] Properties to set + */ + function QuickReplyAction(properties) { + this.keywords = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * QuickReplyAction shortcut. + * @member {string} shortcut + * @memberof proto.QuickReplyAction + * @instance + */ + QuickReplyAction.prototype.shortcut = ""; + + /** + * QuickReplyAction message. + * @member {string} message + * @memberof proto.QuickReplyAction + * @instance + */ + QuickReplyAction.prototype.message = ""; + + /** + * QuickReplyAction keywords. + * @member {Array.} keywords + * @memberof proto.QuickReplyAction + * @instance + */ + QuickReplyAction.prototype.keywords = $util.emptyArray; + + /** + * QuickReplyAction count. + * @member {number} count + * @memberof proto.QuickReplyAction + * @instance + */ + QuickReplyAction.prototype.count = 0; + + /** + * QuickReplyAction deleted. + * @member {boolean} deleted + * @memberof proto.QuickReplyAction + * @instance + */ + QuickReplyAction.prototype.deleted = false; + + /** + * Creates a new QuickReplyAction instance using the specified properties. + * @function create + * @memberof proto.QuickReplyAction + * @static + * @param {proto.IQuickReplyAction=} [properties] Properties to set + * @returns {proto.QuickReplyAction} QuickReplyAction instance + */ + QuickReplyAction.create = function create(properties) { + return new QuickReplyAction(properties); + }; + + /** + * Encodes the specified QuickReplyAction message. Does not implicitly {@link proto.QuickReplyAction.verify|verify} messages. + * @function encode + * @memberof proto.QuickReplyAction + * @static + * @param {proto.IQuickReplyAction} message QuickReplyAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QuickReplyAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.shortcut != null && Object.hasOwnProperty.call(message, "shortcut")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.shortcut); + if (message.message != null && Object.hasOwnProperty.call(message, "message")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.message); + if (message.keywords != null && message.keywords.length) + for (var i = 0; i < message.keywords.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.keywords[i]); + if (message.count != null && Object.hasOwnProperty.call(message, "count")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.count); + if (message.deleted != null && Object.hasOwnProperty.call(message, "deleted")) + writer.uint32(/* id 5, wireType 0 =*/40).bool(message.deleted); + return writer; + }; + + /** + * Encodes the specified QuickReplyAction message, length delimited. Does not implicitly {@link proto.QuickReplyAction.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.QuickReplyAction + * @static + * @param {proto.IQuickReplyAction} message QuickReplyAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QuickReplyAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a QuickReplyAction message from the specified reader or buffer. + * @function decode + * @memberof proto.QuickReplyAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.QuickReplyAction} QuickReplyAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QuickReplyAction.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.QuickReplyAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.shortcut = reader.string(); + break; + case 2: + message.message = reader.string(); + break; + case 3: + if (!(message.keywords && message.keywords.length)) + message.keywords = []; + message.keywords.push(reader.string()); + break; + case 4: + message.count = reader.int32(); + break; + case 5: + message.deleted = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a QuickReplyAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.QuickReplyAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.QuickReplyAction} QuickReplyAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QuickReplyAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a QuickReplyAction message. + * @function verify + * @memberof proto.QuickReplyAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + QuickReplyAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.shortcut != null && message.hasOwnProperty("shortcut")) + if (!$util.isString(message.shortcut)) + return "shortcut: string expected"; + if (message.message != null && message.hasOwnProperty("message")) + if (!$util.isString(message.message)) + return "message: string expected"; + if (message.keywords != null && message.hasOwnProperty("keywords")) { + if (!Array.isArray(message.keywords)) + return "keywords: array expected"; + for (var i = 0; i < message.keywords.length; ++i) + if (!$util.isString(message.keywords[i])) + return "keywords: string[] expected"; + } + if (message.count != null && message.hasOwnProperty("count")) + if (!$util.isInteger(message.count)) + return "count: integer expected"; + if (message.deleted != null && message.hasOwnProperty("deleted")) + if (typeof message.deleted !== "boolean") + return "deleted: boolean expected"; + return null; + }; + + /** + * Creates a QuickReplyAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.QuickReplyAction + * @static + * @param {Object.} object Plain object + * @returns {proto.QuickReplyAction} QuickReplyAction + */ + QuickReplyAction.fromObject = function fromObject(object) { + if (object instanceof $root.proto.QuickReplyAction) + return object; + var message = new $root.proto.QuickReplyAction(); + if (object.shortcut != null) + message.shortcut = String(object.shortcut); + if (object.message != null) + message.message = String(object.message); + if (object.keywords) { + if (!Array.isArray(object.keywords)) + throw TypeError(".proto.QuickReplyAction.keywords: array expected"); + message.keywords = []; + for (var i = 0; i < object.keywords.length; ++i) + message.keywords[i] = String(object.keywords[i]); + } + if (object.count != null) + message.count = object.count | 0; + if (object.deleted != null) + message.deleted = Boolean(object.deleted); + return message; + }; + + /** + * Creates a plain object from a QuickReplyAction message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.QuickReplyAction + * @static + * @param {proto.QuickReplyAction} message QuickReplyAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + QuickReplyAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.keywords = []; + if (options.defaults) { + object.shortcut = ""; + object.message = ""; + object.count = 0; + object.deleted = false; + } + if (message.shortcut != null && message.hasOwnProperty("shortcut")) + object.shortcut = message.shortcut; + if (message.message != null && message.hasOwnProperty("message")) + object.message = message.message; + if (message.keywords && message.keywords.length) { + object.keywords = []; + for (var j = 0; j < message.keywords.length; ++j) + object.keywords[j] = message.keywords[j]; + } + if (message.count != null && message.hasOwnProperty("count")) + object.count = message.count; + if (message.deleted != null && message.hasOwnProperty("deleted")) + object.deleted = message.deleted; + return object; + }; + + /** + * Converts this QuickReplyAction to JSON. + * @function toJSON + * @memberof proto.QuickReplyAction + * @instance + * @returns {Object.} JSON object + */ + QuickReplyAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return QuickReplyAction; + })(); + + proto.LabelAssociationAction = (function() { + + /** + * Properties of a LabelAssociationAction. + * @memberof proto + * @interface ILabelAssociationAction + * @property {boolean|null} [labeled] LabelAssociationAction labeled + */ + + /** + * Constructs a new LabelAssociationAction. + * @memberof proto + * @classdesc Represents a LabelAssociationAction. + * @implements ILabelAssociationAction + * @constructor + * @param {proto.ILabelAssociationAction=} [properties] Properties to set + */ + function LabelAssociationAction(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * LabelAssociationAction labeled. + * @member {boolean} labeled + * @memberof proto.LabelAssociationAction + * @instance + */ + LabelAssociationAction.prototype.labeled = false; + + /** + * Creates a new LabelAssociationAction instance using the specified properties. + * @function create + * @memberof proto.LabelAssociationAction + * @static + * @param {proto.ILabelAssociationAction=} [properties] Properties to set + * @returns {proto.LabelAssociationAction} LabelAssociationAction instance + */ + LabelAssociationAction.create = function create(properties) { + return new LabelAssociationAction(properties); + }; + + /** + * Encodes the specified LabelAssociationAction message. Does not implicitly {@link proto.LabelAssociationAction.verify|verify} messages. + * @function encode + * @memberof proto.LabelAssociationAction + * @static + * @param {proto.ILabelAssociationAction} message LabelAssociationAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LabelAssociationAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.labeled != null && Object.hasOwnProperty.call(message, "labeled")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.labeled); + return writer; + }; + + /** + * Encodes the specified LabelAssociationAction message, length delimited. Does not implicitly {@link proto.LabelAssociationAction.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.LabelAssociationAction + * @static + * @param {proto.ILabelAssociationAction} message LabelAssociationAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LabelAssociationAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a LabelAssociationAction message from the specified reader or buffer. + * @function decode + * @memberof proto.LabelAssociationAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.LabelAssociationAction} LabelAssociationAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LabelAssociationAction.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.LabelAssociationAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.labeled = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a LabelAssociationAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.LabelAssociationAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.LabelAssociationAction} LabelAssociationAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LabelAssociationAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a LabelAssociationAction message. + * @function verify + * @memberof proto.LabelAssociationAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LabelAssociationAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.labeled != null && message.hasOwnProperty("labeled")) + if (typeof message.labeled !== "boolean") + return "labeled: boolean expected"; + return null; + }; + + /** + * Creates a LabelAssociationAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.LabelAssociationAction + * @static + * @param {Object.} object Plain object + * @returns {proto.LabelAssociationAction} LabelAssociationAction + */ + LabelAssociationAction.fromObject = function fromObject(object) { + if (object instanceof $root.proto.LabelAssociationAction) + return object; + var message = new $root.proto.LabelAssociationAction(); + if (object.labeled != null) + message.labeled = Boolean(object.labeled); + return message; + }; + + /** + * Creates a plain object from a LabelAssociationAction message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.LabelAssociationAction + * @static + * @param {proto.LabelAssociationAction} message LabelAssociationAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LabelAssociationAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.labeled = false; + if (message.labeled != null && message.hasOwnProperty("labeled")) + object.labeled = message.labeled; + return object; + }; + + /** + * Converts this LabelAssociationAction to JSON. + * @function toJSON + * @memberof proto.LabelAssociationAction + * @instance + * @returns {Object.} JSON object + */ + LabelAssociationAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return LabelAssociationAction; + })(); + + proto.LabelEditAction = (function() { + + /** + * Properties of a LabelEditAction. + * @memberof proto + * @interface ILabelEditAction + * @property {string|null} [name] LabelEditAction name + * @property {number|null} [color] LabelEditAction color + * @property {number|null} [predefinedId] LabelEditAction predefinedId + * @property {boolean|null} [deleted] LabelEditAction deleted + */ + + /** + * Constructs a new LabelEditAction. + * @memberof proto + * @classdesc Represents a LabelEditAction. + * @implements ILabelEditAction + * @constructor + * @param {proto.ILabelEditAction=} [properties] Properties to set + */ + function LabelEditAction(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * LabelEditAction name. + * @member {string} name + * @memberof proto.LabelEditAction + * @instance + */ + LabelEditAction.prototype.name = ""; + + /** + * LabelEditAction color. + * @member {number} color + * @memberof proto.LabelEditAction + * @instance + */ + LabelEditAction.prototype.color = 0; + + /** + * LabelEditAction predefinedId. + * @member {number} predefinedId + * @memberof proto.LabelEditAction + * @instance + */ + LabelEditAction.prototype.predefinedId = 0; + + /** + * LabelEditAction deleted. + * @member {boolean} deleted + * @memberof proto.LabelEditAction + * @instance + */ + LabelEditAction.prototype.deleted = false; + + /** + * Creates a new LabelEditAction instance using the specified properties. + * @function create + * @memberof proto.LabelEditAction + * @static + * @param {proto.ILabelEditAction=} [properties] Properties to set + * @returns {proto.LabelEditAction} LabelEditAction instance + */ + LabelEditAction.create = function create(properties) { + return new LabelEditAction(properties); + }; + + /** + * Encodes the specified LabelEditAction message. Does not implicitly {@link proto.LabelEditAction.verify|verify} messages. + * @function encode + * @memberof proto.LabelEditAction + * @static + * @param {proto.ILabelEditAction} message LabelEditAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LabelEditAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.color != null && Object.hasOwnProperty.call(message, "color")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.color); + if (message.predefinedId != null && Object.hasOwnProperty.call(message, "predefinedId")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.predefinedId); + if (message.deleted != null && Object.hasOwnProperty.call(message, "deleted")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.deleted); + return writer; + }; + + /** + * Encodes the specified LabelEditAction message, length delimited. Does not implicitly {@link proto.LabelEditAction.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.LabelEditAction + * @static + * @param {proto.ILabelEditAction} message LabelEditAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LabelEditAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a LabelEditAction message from the specified reader or buffer. + * @function decode + * @memberof proto.LabelEditAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.LabelEditAction} LabelEditAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LabelEditAction.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.LabelEditAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.color = reader.int32(); + break; + case 3: + message.predefinedId = reader.int32(); + break; + case 4: + message.deleted = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a LabelEditAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.LabelEditAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.LabelEditAction} LabelEditAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LabelEditAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a LabelEditAction message. + * @function verify + * @memberof proto.LabelEditAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LabelEditAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.color != null && message.hasOwnProperty("color")) + if (!$util.isInteger(message.color)) + return "color: integer expected"; + if (message.predefinedId != null && message.hasOwnProperty("predefinedId")) + if (!$util.isInteger(message.predefinedId)) + return "predefinedId: integer expected"; + if (message.deleted != null && message.hasOwnProperty("deleted")) + if (typeof message.deleted !== "boolean") + return "deleted: boolean expected"; + return null; + }; + + /** + * Creates a LabelEditAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.LabelEditAction + * @static + * @param {Object.} object Plain object + * @returns {proto.LabelEditAction} LabelEditAction + */ + LabelEditAction.fromObject = function fromObject(object) { + if (object instanceof $root.proto.LabelEditAction) + return object; + var message = new $root.proto.LabelEditAction(); + if (object.name != null) + message.name = String(object.name); + if (object.color != null) + message.color = object.color | 0; + if (object.predefinedId != null) + message.predefinedId = object.predefinedId | 0; + if (object.deleted != null) + message.deleted = Boolean(object.deleted); + return message; + }; + + /** + * Creates a plain object from a LabelEditAction message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.LabelEditAction + * @static + * @param {proto.LabelEditAction} message LabelEditAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LabelEditAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.color = 0; + object.predefinedId = 0; + object.deleted = false; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.color != null && message.hasOwnProperty("color")) + object.color = message.color; + if (message.predefinedId != null && message.hasOwnProperty("predefinedId")) + object.predefinedId = message.predefinedId; + if (message.deleted != null && message.hasOwnProperty("deleted")) + object.deleted = message.deleted; + return object; + }; + + /** + * Converts this LabelEditAction to JSON. + * @function toJSON + * @memberof proto.LabelEditAction + * @instance + * @returns {Object.} JSON object + */ + LabelEditAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return LabelEditAction; + })(); + + proto.RecentStickerWeightsAction = (function() { + + /** + * Properties of a RecentStickerWeightsAction. + * @memberof proto + * @interface IRecentStickerWeightsAction + * @property {Array.|null} [weights] RecentStickerWeightsAction weights + */ + + /** + * Constructs a new RecentStickerWeightsAction. + * @memberof proto + * @classdesc Represents a RecentStickerWeightsAction. + * @implements IRecentStickerWeightsAction + * @constructor + * @param {proto.IRecentStickerWeightsAction=} [properties] Properties to set + */ + function RecentStickerWeightsAction(properties) { + this.weights = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RecentStickerWeightsAction weights. + * @member {Array.} weights + * @memberof proto.RecentStickerWeightsAction + * @instance + */ + RecentStickerWeightsAction.prototype.weights = $util.emptyArray; + + /** + * Creates a new RecentStickerWeightsAction instance using the specified properties. + * @function create + * @memberof proto.RecentStickerWeightsAction + * @static + * @param {proto.IRecentStickerWeightsAction=} [properties] Properties to set + * @returns {proto.RecentStickerWeightsAction} RecentStickerWeightsAction instance + */ + RecentStickerWeightsAction.create = function create(properties) { + return new RecentStickerWeightsAction(properties); + }; + + /** + * Encodes the specified RecentStickerWeightsAction message. Does not implicitly {@link proto.RecentStickerWeightsAction.verify|verify} messages. + * @function encode + * @memberof proto.RecentStickerWeightsAction + * @static + * @param {proto.IRecentStickerWeightsAction} message RecentStickerWeightsAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecentStickerWeightsAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.weights != null && message.weights.length) + for (var i = 0; i < message.weights.length; ++i) + $root.proto.RecentStickerWeight.encode(message.weights[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified RecentStickerWeightsAction message, length delimited. Does not implicitly {@link proto.RecentStickerWeightsAction.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.RecentStickerWeightsAction + * @static + * @param {proto.IRecentStickerWeightsAction} message RecentStickerWeightsAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecentStickerWeightsAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RecentStickerWeightsAction message from the specified reader or buffer. + * @function decode + * @memberof proto.RecentStickerWeightsAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.RecentStickerWeightsAction} RecentStickerWeightsAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecentStickerWeightsAction.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.RecentStickerWeightsAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.weights && message.weights.length)) + message.weights = []; + message.weights.push($root.proto.RecentStickerWeight.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RecentStickerWeightsAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.RecentStickerWeightsAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.RecentStickerWeightsAction} RecentStickerWeightsAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecentStickerWeightsAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RecentStickerWeightsAction message. + * @function verify + * @memberof proto.RecentStickerWeightsAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RecentStickerWeightsAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.weights != null && message.hasOwnProperty("weights")) { + if (!Array.isArray(message.weights)) + return "weights: array expected"; + for (var i = 0; i < message.weights.length; ++i) { + var error = $root.proto.RecentStickerWeight.verify(message.weights[i]); + if (error) + return "weights." + error; + } + } + return null; + }; + + /** + * Creates a RecentStickerWeightsAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.RecentStickerWeightsAction + * @static + * @param {Object.} object Plain object + * @returns {proto.RecentStickerWeightsAction} RecentStickerWeightsAction + */ + RecentStickerWeightsAction.fromObject = function fromObject(object) { + if (object instanceof $root.proto.RecentStickerWeightsAction) + return object; + var message = new $root.proto.RecentStickerWeightsAction(); + if (object.weights) { + if (!Array.isArray(object.weights)) + throw TypeError(".proto.RecentStickerWeightsAction.weights: array expected"); + message.weights = []; + for (var i = 0; i < object.weights.length; ++i) { + if (typeof object.weights[i] !== "object") + throw TypeError(".proto.RecentStickerWeightsAction.weights: object expected"); + message.weights[i] = $root.proto.RecentStickerWeight.fromObject(object.weights[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a RecentStickerWeightsAction message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.RecentStickerWeightsAction + * @static + * @param {proto.RecentStickerWeightsAction} message RecentStickerWeightsAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RecentStickerWeightsAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.weights = []; + if (message.weights && message.weights.length) { + object.weights = []; + for (var j = 0; j < message.weights.length; ++j) + object.weights[j] = $root.proto.RecentStickerWeight.toObject(message.weights[j], options); + } + return object; + }; + + /** + * Converts this RecentStickerWeightsAction to JSON. + * @function toJSON + * @memberof proto.RecentStickerWeightsAction + * @instance + * @returns {Object.} JSON object + */ + RecentStickerWeightsAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return RecentStickerWeightsAction; + })(); + + proto.RecentStickerMetadata = (function() { + + /** + * Properties of a RecentStickerMetadata. + * @memberof proto + * @interface IRecentStickerMetadata + * @property {string|null} [directPath] RecentStickerMetadata directPath + * @property {string|null} [encFilehash] RecentStickerMetadata encFilehash + * @property {string|null} [mediaKey] RecentStickerMetadata mediaKey + * @property {string|null} [stanzaId] RecentStickerMetadata stanzaId + * @property {string|null} [chatJid] RecentStickerMetadata chatJid + * @property {string|null} [participant] RecentStickerMetadata participant + * @property {boolean|null} [isSentByMe] RecentStickerMetadata isSentByMe + */ + + /** + * Constructs a new RecentStickerMetadata. + * @memberof proto + * @classdesc Represents a RecentStickerMetadata. + * @implements IRecentStickerMetadata + * @constructor + * @param {proto.IRecentStickerMetadata=} [properties] Properties to set + */ + function RecentStickerMetadata(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RecentStickerMetadata directPath. + * @member {string} directPath + * @memberof proto.RecentStickerMetadata + * @instance + */ + RecentStickerMetadata.prototype.directPath = ""; + + /** + * RecentStickerMetadata encFilehash. + * @member {string} encFilehash + * @memberof proto.RecentStickerMetadata + * @instance + */ + RecentStickerMetadata.prototype.encFilehash = ""; + + /** + * RecentStickerMetadata mediaKey. + * @member {string} mediaKey + * @memberof proto.RecentStickerMetadata + * @instance + */ + RecentStickerMetadata.prototype.mediaKey = ""; + + /** + * RecentStickerMetadata stanzaId. + * @member {string} stanzaId + * @memberof proto.RecentStickerMetadata + * @instance + */ + RecentStickerMetadata.prototype.stanzaId = ""; + + /** + * RecentStickerMetadata chatJid. + * @member {string} chatJid + * @memberof proto.RecentStickerMetadata + * @instance + */ + RecentStickerMetadata.prototype.chatJid = ""; + + /** + * RecentStickerMetadata participant. + * @member {string} participant + * @memberof proto.RecentStickerMetadata + * @instance + */ + RecentStickerMetadata.prototype.participant = ""; + + /** + * RecentStickerMetadata isSentByMe. + * @member {boolean} isSentByMe + * @memberof proto.RecentStickerMetadata + * @instance + */ + RecentStickerMetadata.prototype.isSentByMe = false; + + /** + * Creates a new RecentStickerMetadata instance using the specified properties. + * @function create + * @memberof proto.RecentStickerMetadata + * @static + * @param {proto.IRecentStickerMetadata=} [properties] Properties to set + * @returns {proto.RecentStickerMetadata} RecentStickerMetadata instance + */ + RecentStickerMetadata.create = function create(properties) { + return new RecentStickerMetadata(properties); + }; + + /** + * Encodes the specified RecentStickerMetadata message. Does not implicitly {@link proto.RecentStickerMetadata.verify|verify} messages. + * @function encode + * @memberof proto.RecentStickerMetadata + * @static + * @param {proto.IRecentStickerMetadata} message RecentStickerMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecentStickerMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.directPath != null && Object.hasOwnProperty.call(message, "directPath")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.directPath); + if (message.encFilehash != null && Object.hasOwnProperty.call(message, "encFilehash")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.encFilehash); + if (message.mediaKey != null && Object.hasOwnProperty.call(message, "mediaKey")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.mediaKey); + if (message.stanzaId != null && Object.hasOwnProperty.call(message, "stanzaId")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.stanzaId); + if (message.chatJid != null && Object.hasOwnProperty.call(message, "chatJid")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.chatJid); + if (message.participant != null && Object.hasOwnProperty.call(message, "participant")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.participant); + if (message.isSentByMe != null && Object.hasOwnProperty.call(message, "isSentByMe")) + writer.uint32(/* id 7, wireType 0 =*/56).bool(message.isSentByMe); + return writer; + }; + + /** + * Encodes the specified RecentStickerMetadata message, length delimited. Does not implicitly {@link proto.RecentStickerMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.RecentStickerMetadata + * @static + * @param {proto.IRecentStickerMetadata} message RecentStickerMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecentStickerMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RecentStickerMetadata message from the specified reader or buffer. + * @function decode + * @memberof proto.RecentStickerMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.RecentStickerMetadata} RecentStickerMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecentStickerMetadata.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.RecentStickerMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.directPath = reader.string(); + break; + case 2: + message.encFilehash = reader.string(); + break; + case 3: + message.mediaKey = reader.string(); + break; + case 4: + message.stanzaId = reader.string(); + break; + case 5: + message.chatJid = reader.string(); + break; + case 6: + message.participant = reader.string(); + break; + case 7: + message.isSentByMe = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RecentStickerMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.RecentStickerMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.RecentStickerMetadata} RecentStickerMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecentStickerMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RecentStickerMetadata message. + * @function verify + * @memberof proto.RecentStickerMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RecentStickerMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.directPath != null && message.hasOwnProperty("directPath")) + if (!$util.isString(message.directPath)) + return "directPath: string expected"; + if (message.encFilehash != null && message.hasOwnProperty("encFilehash")) + if (!$util.isString(message.encFilehash)) + return "encFilehash: string expected"; + if (message.mediaKey != null && message.hasOwnProperty("mediaKey")) + if (!$util.isString(message.mediaKey)) + return "mediaKey: string expected"; + if (message.stanzaId != null && message.hasOwnProperty("stanzaId")) + if (!$util.isString(message.stanzaId)) + return "stanzaId: string expected"; + if (message.chatJid != null && message.hasOwnProperty("chatJid")) + if (!$util.isString(message.chatJid)) + return "chatJid: string expected"; + if (message.participant != null && message.hasOwnProperty("participant")) + if (!$util.isString(message.participant)) + return "participant: string expected"; + if (message.isSentByMe != null && message.hasOwnProperty("isSentByMe")) + if (typeof message.isSentByMe !== "boolean") + return "isSentByMe: boolean expected"; + return null; + }; + + /** + * Creates a RecentStickerMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.RecentStickerMetadata + * @static + * @param {Object.} object Plain object + * @returns {proto.RecentStickerMetadata} RecentStickerMetadata + */ + RecentStickerMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.proto.RecentStickerMetadata) + return object; + var message = new $root.proto.RecentStickerMetadata(); + if (object.directPath != null) + message.directPath = String(object.directPath); + if (object.encFilehash != null) + message.encFilehash = String(object.encFilehash); + if (object.mediaKey != null) + message.mediaKey = String(object.mediaKey); + if (object.stanzaId != null) + message.stanzaId = String(object.stanzaId); + if (object.chatJid != null) + message.chatJid = String(object.chatJid); + if (object.participant != null) + message.participant = String(object.participant); + if (object.isSentByMe != null) + message.isSentByMe = Boolean(object.isSentByMe); + return message; + }; + + /** + * Creates a plain object from a RecentStickerMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.RecentStickerMetadata + * @static + * @param {proto.RecentStickerMetadata} message RecentStickerMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RecentStickerMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.directPath = ""; + object.encFilehash = ""; + object.mediaKey = ""; + object.stanzaId = ""; + object.chatJid = ""; + object.participant = ""; + object.isSentByMe = false; + } + if (message.directPath != null && message.hasOwnProperty("directPath")) + object.directPath = message.directPath; + if (message.encFilehash != null && message.hasOwnProperty("encFilehash")) + object.encFilehash = message.encFilehash; + if (message.mediaKey != null && message.hasOwnProperty("mediaKey")) + object.mediaKey = message.mediaKey; + if (message.stanzaId != null && message.hasOwnProperty("stanzaId")) + object.stanzaId = message.stanzaId; + if (message.chatJid != null && message.hasOwnProperty("chatJid")) + object.chatJid = message.chatJid; + if (message.participant != null && message.hasOwnProperty("participant")) + object.participant = message.participant; + if (message.isSentByMe != null && message.hasOwnProperty("isSentByMe")) + object.isSentByMe = message.isSentByMe; + return object; + }; + + /** + * Converts this RecentStickerMetadata to JSON. + * @function toJSON + * @memberof proto.RecentStickerMetadata + * @instance + * @returns {Object.} JSON object + */ + RecentStickerMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return RecentStickerMetadata; + })(); + + proto.RecentEmojiWeightsAction = (function() { + + /** + * Properties of a RecentEmojiWeightsAction. + * @memberof proto + * @interface IRecentEmojiWeightsAction + * @property {Array.|null} [weights] RecentEmojiWeightsAction weights + */ + + /** + * Constructs a new RecentEmojiWeightsAction. + * @memberof proto + * @classdesc Represents a RecentEmojiWeightsAction. + * @implements IRecentEmojiWeightsAction + * @constructor + * @param {proto.IRecentEmojiWeightsAction=} [properties] Properties to set + */ + function RecentEmojiWeightsAction(properties) { + this.weights = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RecentEmojiWeightsAction weights. + * @member {Array.} weights + * @memberof proto.RecentEmojiWeightsAction + * @instance + */ + RecentEmojiWeightsAction.prototype.weights = $util.emptyArray; + + /** + * Creates a new RecentEmojiWeightsAction instance using the specified properties. + * @function create + * @memberof proto.RecentEmojiWeightsAction + * @static + * @param {proto.IRecentEmojiWeightsAction=} [properties] Properties to set + * @returns {proto.RecentEmojiWeightsAction} RecentEmojiWeightsAction instance + */ + RecentEmojiWeightsAction.create = function create(properties) { + return new RecentEmojiWeightsAction(properties); + }; + + /** + * Encodes the specified RecentEmojiWeightsAction message. Does not implicitly {@link proto.RecentEmojiWeightsAction.verify|verify} messages. + * @function encode + * @memberof proto.RecentEmojiWeightsAction + * @static + * @param {proto.IRecentEmojiWeightsAction} message RecentEmojiWeightsAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecentEmojiWeightsAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.weights != null && message.weights.length) + for (var i = 0; i < message.weights.length; ++i) + $root.proto.RecentEmojiWeight.encode(message.weights[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified RecentEmojiWeightsAction message, length delimited. Does not implicitly {@link proto.RecentEmojiWeightsAction.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.RecentEmojiWeightsAction + * @static + * @param {proto.IRecentEmojiWeightsAction} message RecentEmojiWeightsAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecentEmojiWeightsAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RecentEmojiWeightsAction message from the specified reader or buffer. + * @function decode + * @memberof proto.RecentEmojiWeightsAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.RecentEmojiWeightsAction} RecentEmojiWeightsAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecentEmojiWeightsAction.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.RecentEmojiWeightsAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.weights && message.weights.length)) + message.weights = []; + message.weights.push($root.proto.RecentEmojiWeight.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RecentEmojiWeightsAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.RecentEmojiWeightsAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.RecentEmojiWeightsAction} RecentEmojiWeightsAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecentEmojiWeightsAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RecentEmojiWeightsAction message. + * @function verify + * @memberof proto.RecentEmojiWeightsAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RecentEmojiWeightsAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.weights != null && message.hasOwnProperty("weights")) { + if (!Array.isArray(message.weights)) + return "weights: array expected"; + for (var i = 0; i < message.weights.length; ++i) { + var error = $root.proto.RecentEmojiWeight.verify(message.weights[i]); + if (error) + return "weights." + error; + } + } + return null; + }; + + /** + * Creates a RecentEmojiWeightsAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.RecentEmojiWeightsAction + * @static + * @param {Object.} object Plain object + * @returns {proto.RecentEmojiWeightsAction} RecentEmojiWeightsAction + */ + RecentEmojiWeightsAction.fromObject = function fromObject(object) { + if (object instanceof $root.proto.RecentEmojiWeightsAction) + return object; + var message = new $root.proto.RecentEmojiWeightsAction(); + if (object.weights) { + if (!Array.isArray(object.weights)) + throw TypeError(".proto.RecentEmojiWeightsAction.weights: array expected"); + message.weights = []; + for (var i = 0; i < object.weights.length; ++i) { + if (typeof object.weights[i] !== "object") + throw TypeError(".proto.RecentEmojiWeightsAction.weights: object expected"); + message.weights[i] = $root.proto.RecentEmojiWeight.fromObject(object.weights[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a RecentEmojiWeightsAction message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.RecentEmojiWeightsAction + * @static + * @param {proto.RecentEmojiWeightsAction} message RecentEmojiWeightsAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RecentEmojiWeightsAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.weights = []; + if (message.weights && message.weights.length) { + object.weights = []; + for (var j = 0; j < message.weights.length; ++j) + object.weights[j] = $root.proto.RecentEmojiWeight.toObject(message.weights[j], options); + } + return object; + }; + + /** + * Converts this RecentEmojiWeightsAction to JSON. + * @function toJSON + * @memberof proto.RecentEmojiWeightsAction + * @instance + * @returns {Object.} JSON object + */ + RecentEmojiWeightsAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return RecentEmojiWeightsAction; + })(); + + proto.ArchiveChatAction = (function() { + + /** + * Properties of an ArchiveChatAction. + * @memberof proto + * @interface IArchiveChatAction + * @property {boolean|null} [archived] ArchiveChatAction archived + * @property {proto.ISyncActionMessageRange|null} [messageRange] ArchiveChatAction messageRange + */ + + /** + * Constructs a new ArchiveChatAction. + * @memberof proto + * @classdesc Represents an ArchiveChatAction. + * @implements IArchiveChatAction + * @constructor + * @param {proto.IArchiveChatAction=} [properties] Properties to set + */ + function ArchiveChatAction(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ArchiveChatAction archived. + * @member {boolean} archived + * @memberof proto.ArchiveChatAction + * @instance + */ + ArchiveChatAction.prototype.archived = false; + + /** + * ArchiveChatAction messageRange. + * @member {proto.ISyncActionMessageRange|null|undefined} messageRange + * @memberof proto.ArchiveChatAction + * @instance + */ + ArchiveChatAction.prototype.messageRange = null; + + /** + * Creates a new ArchiveChatAction instance using the specified properties. + * @function create + * @memberof proto.ArchiveChatAction + * @static + * @param {proto.IArchiveChatAction=} [properties] Properties to set + * @returns {proto.ArchiveChatAction} ArchiveChatAction instance + */ + ArchiveChatAction.create = function create(properties) { + return new ArchiveChatAction(properties); + }; + + /** + * Encodes the specified ArchiveChatAction message. Does not implicitly {@link proto.ArchiveChatAction.verify|verify} messages. + * @function encode + * @memberof proto.ArchiveChatAction + * @static + * @param {proto.IArchiveChatAction} message ArchiveChatAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ArchiveChatAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.archived != null && Object.hasOwnProperty.call(message, "archived")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.archived); + if (message.messageRange != null && Object.hasOwnProperty.call(message, "messageRange")) + $root.proto.SyncActionMessageRange.encode(message.messageRange, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ArchiveChatAction message, length delimited. Does not implicitly {@link proto.ArchiveChatAction.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.ArchiveChatAction + * @static + * @param {proto.IArchiveChatAction} message ArchiveChatAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ArchiveChatAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ArchiveChatAction message from the specified reader or buffer. + * @function decode + * @memberof proto.ArchiveChatAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.ArchiveChatAction} ArchiveChatAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ArchiveChatAction.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.ArchiveChatAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.archived = reader.bool(); + break; + case 2: + message.messageRange = $root.proto.SyncActionMessageRange.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ArchiveChatAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.ArchiveChatAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.ArchiveChatAction} ArchiveChatAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ArchiveChatAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ArchiveChatAction message. + * @function verify + * @memberof proto.ArchiveChatAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ArchiveChatAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.archived != null && message.hasOwnProperty("archived")) + if (typeof message.archived !== "boolean") + return "archived: boolean expected"; + if (message.messageRange != null && message.hasOwnProperty("messageRange")) { + var error = $root.proto.SyncActionMessageRange.verify(message.messageRange); + if (error) + return "messageRange." + error; + } + return null; + }; + + /** + * Creates an ArchiveChatAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.ArchiveChatAction + * @static + * @param {Object.} object Plain object + * @returns {proto.ArchiveChatAction} ArchiveChatAction + */ + ArchiveChatAction.fromObject = function fromObject(object) { + if (object instanceof $root.proto.ArchiveChatAction) + return object; + var message = new $root.proto.ArchiveChatAction(); + if (object.archived != null) + message.archived = Boolean(object.archived); + if (object.messageRange != null) { + if (typeof object.messageRange !== "object") + throw TypeError(".proto.ArchiveChatAction.messageRange: object expected"); + message.messageRange = $root.proto.SyncActionMessageRange.fromObject(object.messageRange); + } + return message; + }; + + /** + * Creates a plain object from an ArchiveChatAction message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.ArchiveChatAction + * @static + * @param {proto.ArchiveChatAction} message ArchiveChatAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ArchiveChatAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.archived = false; + object.messageRange = null; + } + if (message.archived != null && message.hasOwnProperty("archived")) + object.archived = message.archived; + if (message.messageRange != null && message.hasOwnProperty("messageRange")) + object.messageRange = $root.proto.SyncActionMessageRange.toObject(message.messageRange, options); + return object; + }; + + /** + * Converts this ArchiveChatAction to JSON. + * @function toJSON + * @memberof proto.ArchiveChatAction + * @instance + * @returns {Object.} JSON object + */ + ArchiveChatAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ArchiveChatAction; + })(); + + proto.DeleteMessageForMeAction = (function() { + + /** + * Properties of a DeleteMessageForMeAction. + * @memberof proto + * @interface IDeleteMessageForMeAction + * @property {boolean|null} [deleteMedia] DeleteMessageForMeAction deleteMedia + * @property {number|Long|null} [messageTimestamp] DeleteMessageForMeAction messageTimestamp + */ + + /** + * Constructs a new DeleteMessageForMeAction. + * @memberof proto + * @classdesc Represents a DeleteMessageForMeAction. + * @implements IDeleteMessageForMeAction + * @constructor + * @param {proto.IDeleteMessageForMeAction=} [properties] Properties to set + */ + function DeleteMessageForMeAction(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeleteMessageForMeAction deleteMedia. + * @member {boolean} deleteMedia + * @memberof proto.DeleteMessageForMeAction + * @instance + */ + DeleteMessageForMeAction.prototype.deleteMedia = false; + + /** + * DeleteMessageForMeAction messageTimestamp. + * @member {number|Long} messageTimestamp + * @memberof proto.DeleteMessageForMeAction + * @instance + */ + DeleteMessageForMeAction.prototype.messageTimestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new DeleteMessageForMeAction instance using the specified properties. + * @function create + * @memberof proto.DeleteMessageForMeAction + * @static + * @param {proto.IDeleteMessageForMeAction=} [properties] Properties to set + * @returns {proto.DeleteMessageForMeAction} DeleteMessageForMeAction instance + */ + DeleteMessageForMeAction.create = function create(properties) { + return new DeleteMessageForMeAction(properties); + }; + + /** + * Encodes the specified DeleteMessageForMeAction message. Does not implicitly {@link proto.DeleteMessageForMeAction.verify|verify} messages. + * @function encode + * @memberof proto.DeleteMessageForMeAction + * @static + * @param {proto.IDeleteMessageForMeAction} message DeleteMessageForMeAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteMessageForMeAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.deleteMedia != null && Object.hasOwnProperty.call(message, "deleteMedia")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.deleteMedia); + if (message.messageTimestamp != null && Object.hasOwnProperty.call(message, "messageTimestamp")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.messageTimestamp); + return writer; + }; + + /** + * Encodes the specified DeleteMessageForMeAction message, length delimited. Does not implicitly {@link proto.DeleteMessageForMeAction.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.DeleteMessageForMeAction + * @static + * @param {proto.IDeleteMessageForMeAction} message DeleteMessageForMeAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteMessageForMeAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteMessageForMeAction message from the specified reader or buffer. + * @function decode + * @memberof proto.DeleteMessageForMeAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.DeleteMessageForMeAction} DeleteMessageForMeAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteMessageForMeAction.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.DeleteMessageForMeAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deleteMedia = reader.bool(); + break; + case 2: + message.messageTimestamp = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DeleteMessageForMeAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.DeleteMessageForMeAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.DeleteMessageForMeAction} DeleteMessageForMeAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteMessageForMeAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteMessageForMeAction message. + * @function verify + * @memberof proto.DeleteMessageForMeAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteMessageForMeAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.deleteMedia != null && message.hasOwnProperty("deleteMedia")) + if (typeof message.deleteMedia !== "boolean") + return "deleteMedia: boolean expected"; + if (message.messageTimestamp != null && message.hasOwnProperty("messageTimestamp")) + if (!$util.isInteger(message.messageTimestamp) && !(message.messageTimestamp && $util.isInteger(message.messageTimestamp.low) && $util.isInteger(message.messageTimestamp.high))) + return "messageTimestamp: integer|Long expected"; + return null; + }; + + /** + * Creates a DeleteMessageForMeAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.DeleteMessageForMeAction + * @static + * @param {Object.} object Plain object + * @returns {proto.DeleteMessageForMeAction} DeleteMessageForMeAction + */ + DeleteMessageForMeAction.fromObject = function fromObject(object) { + if (object instanceof $root.proto.DeleteMessageForMeAction) + return object; + var message = new $root.proto.DeleteMessageForMeAction(); + if (object.deleteMedia != null) + message.deleteMedia = Boolean(object.deleteMedia); + if (object.messageTimestamp != null) + if ($util.Long) + (message.messageTimestamp = $util.Long.fromValue(object.messageTimestamp)).unsigned = false; + else if (typeof object.messageTimestamp === "string") + message.messageTimestamp = parseInt(object.messageTimestamp, 10); + else if (typeof object.messageTimestamp === "number") + message.messageTimestamp = object.messageTimestamp; + else if (typeof object.messageTimestamp === "object") + message.messageTimestamp = new $util.LongBits(object.messageTimestamp.low >>> 0, object.messageTimestamp.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a DeleteMessageForMeAction message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.DeleteMessageForMeAction + * @static + * @param {proto.DeleteMessageForMeAction} message DeleteMessageForMeAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteMessageForMeAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.deleteMedia = false; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.messageTimestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.messageTimestamp = options.longs === String ? "0" : 0; + } + if (message.deleteMedia != null && message.hasOwnProperty("deleteMedia")) + object.deleteMedia = message.deleteMedia; + if (message.messageTimestamp != null && message.hasOwnProperty("messageTimestamp")) + if (typeof message.messageTimestamp === "number") + object.messageTimestamp = options.longs === String ? String(message.messageTimestamp) : message.messageTimestamp; + else + object.messageTimestamp = options.longs === String ? $util.Long.prototype.toString.call(message.messageTimestamp) : options.longs === Number ? new $util.LongBits(message.messageTimestamp.low >>> 0, message.messageTimestamp.high >>> 0).toNumber() : message.messageTimestamp; + return object; + }; + + /** + * Converts this DeleteMessageForMeAction to JSON. + * @function toJSON + * @memberof proto.DeleteMessageForMeAction + * @instance + * @returns {Object.} JSON object + */ + DeleteMessageForMeAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DeleteMessageForMeAction; + })(); + + proto.MarkChatAsReadAction = (function() { + + /** + * Properties of a MarkChatAsReadAction. + * @memberof proto + * @interface IMarkChatAsReadAction + * @property {boolean|null} [read] MarkChatAsReadAction read + * @property {proto.ISyncActionMessageRange|null} [messageRange] MarkChatAsReadAction messageRange + */ + + /** + * Constructs a new MarkChatAsReadAction. + * @memberof proto + * @classdesc Represents a MarkChatAsReadAction. + * @implements IMarkChatAsReadAction + * @constructor + * @param {proto.IMarkChatAsReadAction=} [properties] Properties to set + */ + function MarkChatAsReadAction(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MarkChatAsReadAction read. + * @member {boolean} read + * @memberof proto.MarkChatAsReadAction + * @instance + */ + MarkChatAsReadAction.prototype.read = false; + + /** + * MarkChatAsReadAction messageRange. + * @member {proto.ISyncActionMessageRange|null|undefined} messageRange + * @memberof proto.MarkChatAsReadAction + * @instance + */ + MarkChatAsReadAction.prototype.messageRange = null; + + /** + * Creates a new MarkChatAsReadAction instance using the specified properties. + * @function create + * @memberof proto.MarkChatAsReadAction + * @static + * @param {proto.IMarkChatAsReadAction=} [properties] Properties to set + * @returns {proto.MarkChatAsReadAction} MarkChatAsReadAction instance + */ + MarkChatAsReadAction.create = function create(properties) { + return new MarkChatAsReadAction(properties); + }; + + /** + * Encodes the specified MarkChatAsReadAction message. Does not implicitly {@link proto.MarkChatAsReadAction.verify|verify} messages. + * @function encode + * @memberof proto.MarkChatAsReadAction + * @static + * @param {proto.IMarkChatAsReadAction} message MarkChatAsReadAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MarkChatAsReadAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.read != null && Object.hasOwnProperty.call(message, "read")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.read); + if (message.messageRange != null && Object.hasOwnProperty.call(message, "messageRange")) + $root.proto.SyncActionMessageRange.encode(message.messageRange, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified MarkChatAsReadAction message, length delimited. Does not implicitly {@link proto.MarkChatAsReadAction.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.MarkChatAsReadAction + * @static + * @param {proto.IMarkChatAsReadAction} message MarkChatAsReadAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MarkChatAsReadAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MarkChatAsReadAction message from the specified reader or buffer. + * @function decode + * @memberof proto.MarkChatAsReadAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.MarkChatAsReadAction} MarkChatAsReadAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MarkChatAsReadAction.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.MarkChatAsReadAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.read = reader.bool(); + break; + case 2: + message.messageRange = $root.proto.SyncActionMessageRange.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MarkChatAsReadAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.MarkChatAsReadAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.MarkChatAsReadAction} MarkChatAsReadAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MarkChatAsReadAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MarkChatAsReadAction message. + * @function verify + * @memberof proto.MarkChatAsReadAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MarkChatAsReadAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.read != null && message.hasOwnProperty("read")) + if (typeof message.read !== "boolean") + return "read: boolean expected"; + if (message.messageRange != null && message.hasOwnProperty("messageRange")) { + var error = $root.proto.SyncActionMessageRange.verify(message.messageRange); + if (error) + return "messageRange." + error; + } + return null; + }; + + /** + * Creates a MarkChatAsReadAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.MarkChatAsReadAction + * @static + * @param {Object.} object Plain object + * @returns {proto.MarkChatAsReadAction} MarkChatAsReadAction + */ + MarkChatAsReadAction.fromObject = function fromObject(object) { + if (object instanceof $root.proto.MarkChatAsReadAction) + return object; + var message = new $root.proto.MarkChatAsReadAction(); + if (object.read != null) + message.read = Boolean(object.read); + if (object.messageRange != null) { + if (typeof object.messageRange !== "object") + throw TypeError(".proto.MarkChatAsReadAction.messageRange: object expected"); + message.messageRange = $root.proto.SyncActionMessageRange.fromObject(object.messageRange); + } + return message; + }; + + /** + * Creates a plain object from a MarkChatAsReadAction message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.MarkChatAsReadAction + * @static + * @param {proto.MarkChatAsReadAction} message MarkChatAsReadAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MarkChatAsReadAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.read = false; + object.messageRange = null; + } + if (message.read != null && message.hasOwnProperty("read")) + object.read = message.read; + if (message.messageRange != null && message.hasOwnProperty("messageRange")) + object.messageRange = $root.proto.SyncActionMessageRange.toObject(message.messageRange, options); + return object; + }; + + /** + * Converts this MarkChatAsReadAction to JSON. + * @function toJSON + * @memberof proto.MarkChatAsReadAction + * @instance + * @returns {Object.} JSON object + */ + MarkChatAsReadAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return MarkChatAsReadAction; + })(); + + proto.ClearChatAction = (function() { + + /** + * Properties of a ClearChatAction. + * @memberof proto + * @interface IClearChatAction + * @property {proto.ISyncActionMessageRange|null} [messageRange] ClearChatAction messageRange + */ + + /** + * Constructs a new ClearChatAction. + * @memberof proto + * @classdesc Represents a ClearChatAction. + * @implements IClearChatAction + * @constructor + * @param {proto.IClearChatAction=} [properties] Properties to set + */ + function ClearChatAction(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ClearChatAction messageRange. + * @member {proto.ISyncActionMessageRange|null|undefined} messageRange + * @memberof proto.ClearChatAction + * @instance + */ + ClearChatAction.prototype.messageRange = null; + + /** + * Creates a new ClearChatAction instance using the specified properties. + * @function create + * @memberof proto.ClearChatAction + * @static + * @param {proto.IClearChatAction=} [properties] Properties to set + * @returns {proto.ClearChatAction} ClearChatAction instance + */ + ClearChatAction.create = function create(properties) { + return new ClearChatAction(properties); + }; + + /** + * Encodes the specified ClearChatAction message. Does not implicitly {@link proto.ClearChatAction.verify|verify} messages. + * @function encode + * @memberof proto.ClearChatAction + * @static + * @param {proto.IClearChatAction} message ClearChatAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ClearChatAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.messageRange != null && Object.hasOwnProperty.call(message, "messageRange")) + $root.proto.SyncActionMessageRange.encode(message.messageRange, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ClearChatAction message, length delimited. Does not implicitly {@link proto.ClearChatAction.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.ClearChatAction + * @static + * @param {proto.IClearChatAction} message ClearChatAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ClearChatAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ClearChatAction message from the specified reader or buffer. + * @function decode + * @memberof proto.ClearChatAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.ClearChatAction} ClearChatAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ClearChatAction.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.ClearChatAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageRange = $root.proto.SyncActionMessageRange.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ClearChatAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.ClearChatAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.ClearChatAction} ClearChatAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ClearChatAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ClearChatAction message. + * @function verify + * @memberof proto.ClearChatAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ClearChatAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.messageRange != null && message.hasOwnProperty("messageRange")) { + var error = $root.proto.SyncActionMessageRange.verify(message.messageRange); + if (error) + return "messageRange." + error; + } + return null; + }; + + /** + * Creates a ClearChatAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.ClearChatAction + * @static + * @param {Object.} object Plain object + * @returns {proto.ClearChatAction} ClearChatAction + */ + ClearChatAction.fromObject = function fromObject(object) { + if (object instanceof $root.proto.ClearChatAction) + return object; + var message = new $root.proto.ClearChatAction(); + if (object.messageRange != null) { + if (typeof object.messageRange !== "object") + throw TypeError(".proto.ClearChatAction.messageRange: object expected"); + message.messageRange = $root.proto.SyncActionMessageRange.fromObject(object.messageRange); + } + return message; + }; + + /** + * Creates a plain object from a ClearChatAction message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.ClearChatAction + * @static + * @param {proto.ClearChatAction} message ClearChatAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ClearChatAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.messageRange = null; + if (message.messageRange != null && message.hasOwnProperty("messageRange")) + object.messageRange = $root.proto.SyncActionMessageRange.toObject(message.messageRange, options); + return object; + }; + + /** + * Converts this ClearChatAction to JSON. + * @function toJSON + * @memberof proto.ClearChatAction + * @instance + * @returns {Object.} JSON object + */ + ClearChatAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ClearChatAction; + })(); + + proto.DeleteChatAction = (function() { + + /** + * Properties of a DeleteChatAction. + * @memberof proto + * @interface IDeleteChatAction + * @property {proto.ISyncActionMessageRange|null} [messageRange] DeleteChatAction messageRange + */ + + /** + * Constructs a new DeleteChatAction. + * @memberof proto + * @classdesc Represents a DeleteChatAction. + * @implements IDeleteChatAction + * @constructor + * @param {proto.IDeleteChatAction=} [properties] Properties to set + */ + function DeleteChatAction(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeleteChatAction messageRange. + * @member {proto.ISyncActionMessageRange|null|undefined} messageRange + * @memberof proto.DeleteChatAction + * @instance + */ + DeleteChatAction.prototype.messageRange = null; + + /** + * Creates a new DeleteChatAction instance using the specified properties. + * @function create + * @memberof proto.DeleteChatAction + * @static + * @param {proto.IDeleteChatAction=} [properties] Properties to set + * @returns {proto.DeleteChatAction} DeleteChatAction instance + */ + DeleteChatAction.create = function create(properties) { + return new DeleteChatAction(properties); + }; + + /** + * Encodes the specified DeleteChatAction message. Does not implicitly {@link proto.DeleteChatAction.verify|verify} messages. + * @function encode + * @memberof proto.DeleteChatAction + * @static + * @param {proto.IDeleteChatAction} message DeleteChatAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteChatAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.messageRange != null && Object.hasOwnProperty.call(message, "messageRange")) + $root.proto.SyncActionMessageRange.encode(message.messageRange, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified DeleteChatAction message, length delimited. Does not implicitly {@link proto.DeleteChatAction.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.DeleteChatAction + * @static + * @param {proto.IDeleteChatAction} message DeleteChatAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteChatAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteChatAction message from the specified reader or buffer. + * @function decode + * @memberof proto.DeleteChatAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.DeleteChatAction} DeleteChatAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteChatAction.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.DeleteChatAction(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageRange = $root.proto.SyncActionMessageRange.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DeleteChatAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.DeleteChatAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.DeleteChatAction} DeleteChatAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteChatAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteChatAction message. + * @function verify + * @memberof proto.DeleteChatAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteChatAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.messageRange != null && message.hasOwnProperty("messageRange")) { + var error = $root.proto.SyncActionMessageRange.verify(message.messageRange); + if (error) + return "messageRange." + error; + } + return null; + }; + + /** + * Creates a DeleteChatAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.DeleteChatAction + * @static + * @param {Object.} object Plain object + * @returns {proto.DeleteChatAction} DeleteChatAction + */ + DeleteChatAction.fromObject = function fromObject(object) { + if (object instanceof $root.proto.DeleteChatAction) + return object; + var message = new $root.proto.DeleteChatAction(); + if (object.messageRange != null) { + if (typeof object.messageRange !== "object") + throw TypeError(".proto.DeleteChatAction.messageRange: object expected"); + message.messageRange = $root.proto.SyncActionMessageRange.fromObject(object.messageRange); + } + return message; + }; + + /** + * Creates a plain object from a DeleteChatAction message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.DeleteChatAction + * @static + * @param {proto.DeleteChatAction} message DeleteChatAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteChatAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.messageRange = null; + if (message.messageRange != null && message.hasOwnProperty("messageRange")) + object.messageRange = $root.proto.SyncActionMessageRange.toObject(message.messageRange, options); + return object; + }; + + /** + * Converts this DeleteChatAction to JSON. + * @function toJSON + * @memberof proto.DeleteChatAction + * @instance + * @returns {Object.} JSON object + */ + DeleteChatAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DeleteChatAction; + })(); + + proto.UnarchiveChatsSetting = (function() { + + /** + * Properties of an UnarchiveChatsSetting. + * @memberof proto + * @interface IUnarchiveChatsSetting + * @property {boolean|null} [unarchiveChats] UnarchiveChatsSetting unarchiveChats + */ + + /** + * Constructs a new UnarchiveChatsSetting. + * @memberof proto + * @classdesc Represents an UnarchiveChatsSetting. + * @implements IUnarchiveChatsSetting + * @constructor + * @param {proto.IUnarchiveChatsSetting=} [properties] Properties to set + */ + function UnarchiveChatsSetting(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UnarchiveChatsSetting unarchiveChats. + * @member {boolean} unarchiveChats + * @memberof proto.UnarchiveChatsSetting + * @instance + */ + UnarchiveChatsSetting.prototype.unarchiveChats = false; + + /** + * Creates a new UnarchiveChatsSetting instance using the specified properties. + * @function create + * @memberof proto.UnarchiveChatsSetting + * @static + * @param {proto.IUnarchiveChatsSetting=} [properties] Properties to set + * @returns {proto.UnarchiveChatsSetting} UnarchiveChatsSetting instance + */ + UnarchiveChatsSetting.create = function create(properties) { + return new UnarchiveChatsSetting(properties); + }; + + /** + * Encodes the specified UnarchiveChatsSetting message. Does not implicitly {@link proto.UnarchiveChatsSetting.verify|verify} messages. + * @function encode + * @memberof proto.UnarchiveChatsSetting + * @static + * @param {proto.IUnarchiveChatsSetting} message UnarchiveChatsSetting message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UnarchiveChatsSetting.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.unarchiveChats != null && Object.hasOwnProperty.call(message, "unarchiveChats")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.unarchiveChats); + return writer; + }; + + /** + * Encodes the specified UnarchiveChatsSetting message, length delimited. Does not implicitly {@link proto.UnarchiveChatsSetting.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.UnarchiveChatsSetting + * @static + * @param {proto.IUnarchiveChatsSetting} message UnarchiveChatsSetting message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UnarchiveChatsSetting.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UnarchiveChatsSetting message from the specified reader or buffer. + * @function decode + * @memberof proto.UnarchiveChatsSetting + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.UnarchiveChatsSetting} UnarchiveChatsSetting + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UnarchiveChatsSetting.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.UnarchiveChatsSetting(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.unarchiveChats = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UnarchiveChatsSetting message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.UnarchiveChatsSetting + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.UnarchiveChatsSetting} UnarchiveChatsSetting + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UnarchiveChatsSetting.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UnarchiveChatsSetting message. + * @function verify + * @memberof proto.UnarchiveChatsSetting + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UnarchiveChatsSetting.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.unarchiveChats != null && message.hasOwnProperty("unarchiveChats")) + if (typeof message.unarchiveChats !== "boolean") + return "unarchiveChats: boolean expected"; + return null; + }; + + /** + * Creates an UnarchiveChatsSetting message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.UnarchiveChatsSetting + * @static + * @param {Object.} object Plain object + * @returns {proto.UnarchiveChatsSetting} UnarchiveChatsSetting + */ + UnarchiveChatsSetting.fromObject = function fromObject(object) { + if (object instanceof $root.proto.UnarchiveChatsSetting) + return object; + var message = new $root.proto.UnarchiveChatsSetting(); + if (object.unarchiveChats != null) + message.unarchiveChats = Boolean(object.unarchiveChats); + return message; + }; + + /** + * Creates a plain object from an UnarchiveChatsSetting message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.UnarchiveChatsSetting + * @static + * @param {proto.UnarchiveChatsSetting} message UnarchiveChatsSetting + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UnarchiveChatsSetting.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.unarchiveChats = false; + if (message.unarchiveChats != null && message.hasOwnProperty("unarchiveChats")) + object.unarchiveChats = message.unarchiveChats; + return object; + }; + + /** + * Converts this UnarchiveChatsSetting to JSON. + * @function toJSON + * @memberof proto.UnarchiveChatsSetting + * @instance + * @returns {Object.} JSON object + */ + UnarchiveChatsSetting.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return UnarchiveChatsSetting; + })(); + + proto.SyncActionMessageRange = (function() { + + /** + * Properties of a SyncActionMessageRange. + * @memberof proto + * @interface ISyncActionMessageRange + * @property {number|Long|null} [lastMessageTimestamp] SyncActionMessageRange lastMessageTimestamp + * @property {number|Long|null} [lastSystemMessageTimestamp] SyncActionMessageRange lastSystemMessageTimestamp + * @property {Array.|null} [messages] SyncActionMessageRange messages + */ + + /** + * Constructs a new SyncActionMessageRange. + * @memberof proto + * @classdesc Represents a SyncActionMessageRange. + * @implements ISyncActionMessageRange + * @constructor + * @param {proto.ISyncActionMessageRange=} [properties] Properties to set + */ + function SyncActionMessageRange(properties) { + this.messages = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SyncActionMessageRange lastMessageTimestamp. + * @member {number|Long} lastMessageTimestamp + * @memberof proto.SyncActionMessageRange + * @instance + */ + SyncActionMessageRange.prototype.lastMessageTimestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * SyncActionMessageRange lastSystemMessageTimestamp. + * @member {number|Long} lastSystemMessageTimestamp + * @memberof proto.SyncActionMessageRange + * @instance + */ + SyncActionMessageRange.prototype.lastSystemMessageTimestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * SyncActionMessageRange messages. + * @member {Array.} messages + * @memberof proto.SyncActionMessageRange + * @instance + */ + SyncActionMessageRange.prototype.messages = $util.emptyArray; + + /** + * Creates a new SyncActionMessageRange instance using the specified properties. + * @function create + * @memberof proto.SyncActionMessageRange + * @static + * @param {proto.ISyncActionMessageRange=} [properties] Properties to set + * @returns {proto.SyncActionMessageRange} SyncActionMessageRange instance + */ + SyncActionMessageRange.create = function create(properties) { + return new SyncActionMessageRange(properties); + }; + + /** + * Encodes the specified SyncActionMessageRange message. Does not implicitly {@link proto.SyncActionMessageRange.verify|verify} messages. + * @function encode + * @memberof proto.SyncActionMessageRange + * @static + * @param {proto.ISyncActionMessageRange} message SyncActionMessageRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncActionMessageRange.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.lastMessageTimestamp != null && Object.hasOwnProperty.call(message, "lastMessageTimestamp")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.lastMessageTimestamp); + if (message.lastSystemMessageTimestamp != null && Object.hasOwnProperty.call(message, "lastSystemMessageTimestamp")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.lastSystemMessageTimestamp); + if (message.messages != null && message.messages.length) + for (var i = 0; i < message.messages.length; ++i) + $root.proto.SyncActionMessage.encode(message.messages[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified SyncActionMessageRange message, length delimited. Does not implicitly {@link proto.SyncActionMessageRange.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.SyncActionMessageRange + * @static + * @param {proto.ISyncActionMessageRange} message SyncActionMessageRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncActionMessageRange.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SyncActionMessageRange message from the specified reader or buffer. + * @function decode + * @memberof proto.SyncActionMessageRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.SyncActionMessageRange} SyncActionMessageRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncActionMessageRange.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.SyncActionMessageRange(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.lastMessageTimestamp = reader.int64(); + break; + case 2: + message.lastSystemMessageTimestamp = reader.int64(); + break; + case 3: + if (!(message.messages && message.messages.length)) + message.messages = []; + message.messages.push($root.proto.SyncActionMessage.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SyncActionMessageRange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.SyncActionMessageRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.SyncActionMessageRange} SyncActionMessageRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncActionMessageRange.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SyncActionMessageRange message. + * @function verify + * @memberof proto.SyncActionMessageRange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SyncActionMessageRange.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.lastMessageTimestamp != null && message.hasOwnProperty("lastMessageTimestamp")) + if (!$util.isInteger(message.lastMessageTimestamp) && !(message.lastMessageTimestamp && $util.isInteger(message.lastMessageTimestamp.low) && $util.isInteger(message.lastMessageTimestamp.high))) + return "lastMessageTimestamp: integer|Long expected"; + if (message.lastSystemMessageTimestamp != null && message.hasOwnProperty("lastSystemMessageTimestamp")) + if (!$util.isInteger(message.lastSystemMessageTimestamp) && !(message.lastSystemMessageTimestamp && $util.isInteger(message.lastSystemMessageTimestamp.low) && $util.isInteger(message.lastSystemMessageTimestamp.high))) + return "lastSystemMessageTimestamp: integer|Long expected"; + if (message.messages != null && message.hasOwnProperty("messages")) { + if (!Array.isArray(message.messages)) + return "messages: array expected"; + for (var i = 0; i < message.messages.length; ++i) { + var error = $root.proto.SyncActionMessage.verify(message.messages[i]); + if (error) + return "messages." + error; + } + } + return null; + }; + + /** + * Creates a SyncActionMessageRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.SyncActionMessageRange + * @static + * @param {Object.} object Plain object + * @returns {proto.SyncActionMessageRange} SyncActionMessageRange + */ + SyncActionMessageRange.fromObject = function fromObject(object) { + if (object instanceof $root.proto.SyncActionMessageRange) + return object; + var message = new $root.proto.SyncActionMessageRange(); + if (object.lastMessageTimestamp != null) + if ($util.Long) + (message.lastMessageTimestamp = $util.Long.fromValue(object.lastMessageTimestamp)).unsigned = false; + else if (typeof object.lastMessageTimestamp === "string") + message.lastMessageTimestamp = parseInt(object.lastMessageTimestamp, 10); + else if (typeof object.lastMessageTimestamp === "number") + message.lastMessageTimestamp = object.lastMessageTimestamp; + else if (typeof object.lastMessageTimestamp === "object") + message.lastMessageTimestamp = new $util.LongBits(object.lastMessageTimestamp.low >>> 0, object.lastMessageTimestamp.high >>> 0).toNumber(); + if (object.lastSystemMessageTimestamp != null) + if ($util.Long) + (message.lastSystemMessageTimestamp = $util.Long.fromValue(object.lastSystemMessageTimestamp)).unsigned = false; + else if (typeof object.lastSystemMessageTimestamp === "string") + message.lastSystemMessageTimestamp = parseInt(object.lastSystemMessageTimestamp, 10); + else if (typeof object.lastSystemMessageTimestamp === "number") + message.lastSystemMessageTimestamp = object.lastSystemMessageTimestamp; + else if (typeof object.lastSystemMessageTimestamp === "object") + message.lastSystemMessageTimestamp = new $util.LongBits(object.lastSystemMessageTimestamp.low >>> 0, object.lastSystemMessageTimestamp.high >>> 0).toNumber(); + if (object.messages) { + if (!Array.isArray(object.messages)) + throw TypeError(".proto.SyncActionMessageRange.messages: array expected"); + message.messages = []; + for (var i = 0; i < object.messages.length; ++i) { + if (typeof object.messages[i] !== "object") + throw TypeError(".proto.SyncActionMessageRange.messages: object expected"); + message.messages[i] = $root.proto.SyncActionMessage.fromObject(object.messages[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a SyncActionMessageRange message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.SyncActionMessageRange + * @static + * @param {proto.SyncActionMessageRange} message SyncActionMessageRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SyncActionMessageRange.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.messages = []; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.lastMessageTimestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.lastMessageTimestamp = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.lastSystemMessageTimestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.lastSystemMessageTimestamp = options.longs === String ? "0" : 0; + } + if (message.lastMessageTimestamp != null && message.hasOwnProperty("lastMessageTimestamp")) + if (typeof message.lastMessageTimestamp === "number") + object.lastMessageTimestamp = options.longs === String ? String(message.lastMessageTimestamp) : message.lastMessageTimestamp; + else + object.lastMessageTimestamp = options.longs === String ? $util.Long.prototype.toString.call(message.lastMessageTimestamp) : options.longs === Number ? new $util.LongBits(message.lastMessageTimestamp.low >>> 0, message.lastMessageTimestamp.high >>> 0).toNumber() : message.lastMessageTimestamp; + if (message.lastSystemMessageTimestamp != null && message.hasOwnProperty("lastSystemMessageTimestamp")) + if (typeof message.lastSystemMessageTimestamp === "number") + object.lastSystemMessageTimestamp = options.longs === String ? String(message.lastSystemMessageTimestamp) : message.lastSystemMessageTimestamp; + else + object.lastSystemMessageTimestamp = options.longs === String ? $util.Long.prototype.toString.call(message.lastSystemMessageTimestamp) : options.longs === Number ? new $util.LongBits(message.lastSystemMessageTimestamp.low >>> 0, message.lastSystemMessageTimestamp.high >>> 0).toNumber() : message.lastSystemMessageTimestamp; + if (message.messages && message.messages.length) { + object.messages = []; + for (var j = 0; j < message.messages.length; ++j) + object.messages[j] = $root.proto.SyncActionMessage.toObject(message.messages[j], options); + } + return object; + }; + + /** + * Converts this SyncActionMessageRange to JSON. + * @function toJSON + * @memberof proto.SyncActionMessageRange + * @instance + * @returns {Object.} JSON object + */ + SyncActionMessageRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return SyncActionMessageRange; + })(); + + proto.SyncActionMessage = (function() { + + /** + * Properties of a SyncActionMessage. + * @memberof proto + * @interface ISyncActionMessage + * @property {proto.IMessageKey|null} [key] SyncActionMessage key + * @property {number|Long|null} [timestamp] SyncActionMessage timestamp + */ + + /** + * Constructs a new SyncActionMessage. + * @memberof proto + * @classdesc Represents a SyncActionMessage. + * @implements ISyncActionMessage + * @constructor + * @param {proto.ISyncActionMessage=} [properties] Properties to set + */ + function SyncActionMessage(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SyncActionMessage key. + * @member {proto.IMessageKey|null|undefined} key + * @memberof proto.SyncActionMessage + * @instance + */ + SyncActionMessage.prototype.key = null; + + /** + * SyncActionMessage timestamp. + * @member {number|Long} timestamp + * @memberof proto.SyncActionMessage + * @instance + */ + SyncActionMessage.prototype.timestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new SyncActionMessage instance using the specified properties. + * @function create + * @memberof proto.SyncActionMessage + * @static + * @param {proto.ISyncActionMessage=} [properties] Properties to set + * @returns {proto.SyncActionMessage} SyncActionMessage instance + */ + SyncActionMessage.create = function create(properties) { + return new SyncActionMessage(properties); + }; + + /** + * Encodes the specified SyncActionMessage message. Does not implicitly {@link proto.SyncActionMessage.verify|verify} messages. + * @function encode + * @memberof proto.SyncActionMessage + * @static + * @param {proto.ISyncActionMessage} message SyncActionMessage message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncActionMessage.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.key != null && Object.hasOwnProperty.call(message, "key")) + $root.proto.MessageKey.encode(message.key, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.timestamp != null && Object.hasOwnProperty.call(message, "timestamp")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.timestamp); + return writer; + }; + + /** + * Encodes the specified SyncActionMessage message, length delimited. Does not implicitly {@link proto.SyncActionMessage.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.SyncActionMessage + * @static + * @param {proto.ISyncActionMessage} message SyncActionMessage message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncActionMessage.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SyncActionMessage message from the specified reader or buffer. + * @function decode + * @memberof proto.SyncActionMessage + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.SyncActionMessage} SyncActionMessage + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncActionMessage.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.SyncActionMessage(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = $root.proto.MessageKey.decode(reader, reader.uint32()); + break; + case 2: + message.timestamp = reader.int64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SyncActionMessage message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.SyncActionMessage + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.SyncActionMessage} SyncActionMessage + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncActionMessage.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SyncActionMessage message. + * @function verify + * @memberof proto.SyncActionMessage + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SyncActionMessage.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.key != null && message.hasOwnProperty("key")) { + var error = $root.proto.MessageKey.verify(message.key); + if (error) + return "key." + error; + } + if (message.timestamp != null && message.hasOwnProperty("timestamp")) + if (!$util.isInteger(message.timestamp) && !(message.timestamp && $util.isInteger(message.timestamp.low) && $util.isInteger(message.timestamp.high))) + return "timestamp: integer|Long expected"; + return null; + }; + + /** + * Creates a SyncActionMessage message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.SyncActionMessage + * @static + * @param {Object.} object Plain object + * @returns {proto.SyncActionMessage} SyncActionMessage + */ + SyncActionMessage.fromObject = function fromObject(object) { + if (object instanceof $root.proto.SyncActionMessage) + return object; + var message = new $root.proto.SyncActionMessage(); + if (object.key != null) { + if (typeof object.key !== "object") + throw TypeError(".proto.SyncActionMessage.key: object expected"); + message.key = $root.proto.MessageKey.fromObject(object.key); + } + if (object.timestamp != null) + if ($util.Long) + (message.timestamp = $util.Long.fromValue(object.timestamp)).unsigned = false; + else if (typeof object.timestamp === "string") + message.timestamp = parseInt(object.timestamp, 10); + else if (typeof object.timestamp === "number") + message.timestamp = object.timestamp; + else if (typeof object.timestamp === "object") + message.timestamp = new $util.LongBits(object.timestamp.low >>> 0, object.timestamp.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a SyncActionMessage message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.SyncActionMessage + * @static + * @param {proto.SyncActionMessage} message SyncActionMessage + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SyncActionMessage.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.key = null; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.timestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.timestamp = options.longs === String ? "0" : 0; + } + if (message.key != null && message.hasOwnProperty("key")) + object.key = $root.proto.MessageKey.toObject(message.key, options); + if (message.timestamp != null && message.hasOwnProperty("timestamp")) + if (typeof message.timestamp === "number") + object.timestamp = options.longs === String ? String(message.timestamp) : message.timestamp; + else + object.timestamp = options.longs === String ? $util.Long.prototype.toString.call(message.timestamp) : options.longs === Number ? new $util.LongBits(message.timestamp.low >>> 0, message.timestamp.high >>> 0).toNumber() : message.timestamp; + return object; + }; + + /** + * Converts this SyncActionMessage to JSON. + * @function toJSON + * @memberof proto.SyncActionMessage + * @instance + * @returns {Object.} JSON object + */ + SyncActionMessage.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return SyncActionMessage; + })(); + + proto.KeyExpiration = (function() { + + /** + * Properties of a KeyExpiration. + * @memberof proto + * @interface IKeyExpiration + * @property {number|null} [expiredKeyEpoch] KeyExpiration expiredKeyEpoch + */ + + /** + * Constructs a new KeyExpiration. + * @memberof proto + * @classdesc Represents a KeyExpiration. + * @implements IKeyExpiration + * @constructor + * @param {proto.IKeyExpiration=} [properties] Properties to set + */ + function KeyExpiration(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * KeyExpiration expiredKeyEpoch. + * @member {number} expiredKeyEpoch + * @memberof proto.KeyExpiration + * @instance + */ + KeyExpiration.prototype.expiredKeyEpoch = 0; + + /** + * Creates a new KeyExpiration instance using the specified properties. + * @function create + * @memberof proto.KeyExpiration + * @static + * @param {proto.IKeyExpiration=} [properties] Properties to set + * @returns {proto.KeyExpiration} KeyExpiration instance + */ + KeyExpiration.create = function create(properties) { + return new KeyExpiration(properties); + }; + + /** + * Encodes the specified KeyExpiration message. Does not implicitly {@link proto.KeyExpiration.verify|verify} messages. + * @function encode + * @memberof proto.KeyExpiration + * @static + * @param {proto.IKeyExpiration} message KeyExpiration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + KeyExpiration.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.expiredKeyEpoch != null && Object.hasOwnProperty.call(message, "expiredKeyEpoch")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.expiredKeyEpoch); + return writer; + }; + + /** + * Encodes the specified KeyExpiration message, length delimited. Does not implicitly {@link proto.KeyExpiration.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.KeyExpiration + * @static + * @param {proto.IKeyExpiration} message KeyExpiration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + KeyExpiration.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a KeyExpiration message from the specified reader or buffer. + * @function decode + * @memberof proto.KeyExpiration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.KeyExpiration} KeyExpiration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + KeyExpiration.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.KeyExpiration(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.expiredKeyEpoch = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a KeyExpiration message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.KeyExpiration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.KeyExpiration} KeyExpiration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + KeyExpiration.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a KeyExpiration message. + * @function verify + * @memberof proto.KeyExpiration + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + KeyExpiration.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.expiredKeyEpoch != null && message.hasOwnProperty("expiredKeyEpoch")) + if (!$util.isInteger(message.expiredKeyEpoch)) + return "expiredKeyEpoch: integer expected"; + return null; + }; + + /** + * Creates a KeyExpiration message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.KeyExpiration + * @static + * @param {Object.} object Plain object + * @returns {proto.KeyExpiration} KeyExpiration + */ + KeyExpiration.fromObject = function fromObject(object) { + if (object instanceof $root.proto.KeyExpiration) + return object; + var message = new $root.proto.KeyExpiration(); + if (object.expiredKeyEpoch != null) + message.expiredKeyEpoch = object.expiredKeyEpoch | 0; + return message; + }; + + /** + * Creates a plain object from a KeyExpiration message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.KeyExpiration + * @static + * @param {proto.KeyExpiration} message KeyExpiration + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + KeyExpiration.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.expiredKeyEpoch = 0; + if (message.expiredKeyEpoch != null && message.hasOwnProperty("expiredKeyEpoch")) + object.expiredKeyEpoch = message.expiredKeyEpoch; + return object; + }; + + /** + * Converts this KeyExpiration to JSON. + * @function toJSON + * @memberof proto.KeyExpiration + * @instance + * @returns {Object.} JSON object + */ + KeyExpiration.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return KeyExpiration; + })(); + + proto.SyncActionValue = (function() { + + /** + * Properties of a SyncActionValue. + * @memberof proto + * @interface ISyncActionValue + * @property {number|Long|null} [timestamp] SyncActionValue timestamp + * @property {proto.IStarAction|null} [starAction] SyncActionValue starAction + * @property {proto.IContactAction|null} [contactAction] SyncActionValue contactAction + * @property {proto.IMuteAction|null} [muteAction] SyncActionValue muteAction + * @property {proto.IPinAction|null} [pinAction] SyncActionValue pinAction + * @property {proto.ISecurityNotificationSetting|null} [securityNotificationSetting] SyncActionValue securityNotificationSetting + * @property {proto.IPushNameSetting|null} [pushNameSetting] SyncActionValue pushNameSetting + * @property {proto.IQuickReplyAction|null} [quickReplyAction] SyncActionValue quickReplyAction + * @property {proto.IRecentStickerWeightsAction|null} [recentStickerWeightsAction] SyncActionValue recentStickerWeightsAction + * @property {proto.IRecentStickerMetadata|null} [recentStickerMetadata] SyncActionValue recentStickerMetadata + * @property {proto.IRecentEmojiWeightsAction|null} [recentEmojiWeightsAction] SyncActionValue recentEmojiWeightsAction + * @property {proto.ILabelEditAction|null} [labelEditAction] SyncActionValue labelEditAction + * @property {proto.ILabelAssociationAction|null} [labelAssociationAction] SyncActionValue labelAssociationAction + * @property {proto.ILocaleSetting|null} [localeSetting] SyncActionValue localeSetting + * @property {proto.IArchiveChatAction|null} [archiveChatAction] SyncActionValue archiveChatAction + * @property {proto.IDeleteMessageForMeAction|null} [deleteMessageForMeAction] SyncActionValue deleteMessageForMeAction + * @property {proto.IKeyExpiration|null} [keyExpiration] SyncActionValue keyExpiration + * @property {proto.IMarkChatAsReadAction|null} [markChatAsReadAction] SyncActionValue markChatAsReadAction + * @property {proto.IClearChatAction|null} [clearChatAction] SyncActionValue clearChatAction + * @property {proto.IDeleteChatAction|null} [deleteChatAction] SyncActionValue deleteChatAction + * @property {proto.IUnarchiveChatsSetting|null} [unarchiveChatsSetting] SyncActionValue unarchiveChatsSetting + */ + + /** + * Constructs a new SyncActionValue. + * @memberof proto + * @classdesc Represents a SyncActionValue. + * @implements ISyncActionValue + * @constructor + * @param {proto.ISyncActionValue=} [properties] Properties to set + */ + function SyncActionValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SyncActionValue timestamp. + * @member {number|Long} timestamp + * @memberof proto.SyncActionValue + * @instance + */ + SyncActionValue.prototype.timestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * SyncActionValue starAction. + * @member {proto.IStarAction|null|undefined} starAction + * @memberof proto.SyncActionValue + * @instance + */ + SyncActionValue.prototype.starAction = null; + + /** + * SyncActionValue contactAction. + * @member {proto.IContactAction|null|undefined} contactAction + * @memberof proto.SyncActionValue + * @instance + */ + SyncActionValue.prototype.contactAction = null; + + /** + * SyncActionValue muteAction. + * @member {proto.IMuteAction|null|undefined} muteAction + * @memberof proto.SyncActionValue + * @instance + */ + SyncActionValue.prototype.muteAction = null; + + /** + * SyncActionValue pinAction. + * @member {proto.IPinAction|null|undefined} pinAction + * @memberof proto.SyncActionValue + * @instance + */ + SyncActionValue.prototype.pinAction = null; + + /** + * SyncActionValue securityNotificationSetting. + * @member {proto.ISecurityNotificationSetting|null|undefined} securityNotificationSetting + * @memberof proto.SyncActionValue + * @instance + */ + SyncActionValue.prototype.securityNotificationSetting = null; + + /** + * SyncActionValue pushNameSetting. + * @member {proto.IPushNameSetting|null|undefined} pushNameSetting + * @memberof proto.SyncActionValue + * @instance + */ + SyncActionValue.prototype.pushNameSetting = null; + + /** + * SyncActionValue quickReplyAction. + * @member {proto.IQuickReplyAction|null|undefined} quickReplyAction + * @memberof proto.SyncActionValue + * @instance + */ + SyncActionValue.prototype.quickReplyAction = null; + + /** + * SyncActionValue recentStickerWeightsAction. + * @member {proto.IRecentStickerWeightsAction|null|undefined} recentStickerWeightsAction + * @memberof proto.SyncActionValue + * @instance + */ + SyncActionValue.prototype.recentStickerWeightsAction = null; + + /** + * SyncActionValue recentStickerMetadata. + * @member {proto.IRecentStickerMetadata|null|undefined} recentStickerMetadata + * @memberof proto.SyncActionValue + * @instance + */ + SyncActionValue.prototype.recentStickerMetadata = null; + + /** + * SyncActionValue recentEmojiWeightsAction. + * @member {proto.IRecentEmojiWeightsAction|null|undefined} recentEmojiWeightsAction + * @memberof proto.SyncActionValue + * @instance + */ + SyncActionValue.prototype.recentEmojiWeightsAction = null; + + /** + * SyncActionValue labelEditAction. + * @member {proto.ILabelEditAction|null|undefined} labelEditAction + * @memberof proto.SyncActionValue + * @instance + */ + SyncActionValue.prototype.labelEditAction = null; + + /** + * SyncActionValue labelAssociationAction. + * @member {proto.ILabelAssociationAction|null|undefined} labelAssociationAction + * @memberof proto.SyncActionValue + * @instance + */ + SyncActionValue.prototype.labelAssociationAction = null; + + /** + * SyncActionValue localeSetting. + * @member {proto.ILocaleSetting|null|undefined} localeSetting + * @memberof proto.SyncActionValue + * @instance + */ + SyncActionValue.prototype.localeSetting = null; + + /** + * SyncActionValue archiveChatAction. + * @member {proto.IArchiveChatAction|null|undefined} archiveChatAction + * @memberof proto.SyncActionValue + * @instance + */ + SyncActionValue.prototype.archiveChatAction = null; + + /** + * SyncActionValue deleteMessageForMeAction. + * @member {proto.IDeleteMessageForMeAction|null|undefined} deleteMessageForMeAction + * @memberof proto.SyncActionValue + * @instance + */ + SyncActionValue.prototype.deleteMessageForMeAction = null; + + /** + * SyncActionValue keyExpiration. + * @member {proto.IKeyExpiration|null|undefined} keyExpiration + * @memberof proto.SyncActionValue + * @instance + */ + SyncActionValue.prototype.keyExpiration = null; + + /** + * SyncActionValue markChatAsReadAction. + * @member {proto.IMarkChatAsReadAction|null|undefined} markChatAsReadAction + * @memberof proto.SyncActionValue + * @instance + */ + SyncActionValue.prototype.markChatAsReadAction = null; + + /** + * SyncActionValue clearChatAction. + * @member {proto.IClearChatAction|null|undefined} clearChatAction + * @memberof proto.SyncActionValue + * @instance + */ + SyncActionValue.prototype.clearChatAction = null; + + /** + * SyncActionValue deleteChatAction. + * @member {proto.IDeleteChatAction|null|undefined} deleteChatAction + * @memberof proto.SyncActionValue + * @instance + */ + SyncActionValue.prototype.deleteChatAction = null; + + /** + * SyncActionValue unarchiveChatsSetting. + * @member {proto.IUnarchiveChatsSetting|null|undefined} unarchiveChatsSetting + * @memberof proto.SyncActionValue + * @instance + */ + SyncActionValue.prototype.unarchiveChatsSetting = null; + + /** + * Creates a new SyncActionValue instance using the specified properties. + * @function create + * @memberof proto.SyncActionValue + * @static + * @param {proto.ISyncActionValue=} [properties] Properties to set + * @returns {proto.SyncActionValue} SyncActionValue instance + */ + SyncActionValue.create = function create(properties) { + return new SyncActionValue(properties); + }; + + /** + * Encodes the specified SyncActionValue message. Does not implicitly {@link proto.SyncActionValue.verify|verify} messages. + * @function encode + * @memberof proto.SyncActionValue + * @static + * @param {proto.ISyncActionValue} message SyncActionValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncActionValue.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.timestamp != null && Object.hasOwnProperty.call(message, "timestamp")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.timestamp); + if (message.starAction != null && Object.hasOwnProperty.call(message, "starAction")) + $root.proto.StarAction.encode(message.starAction, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.contactAction != null && Object.hasOwnProperty.call(message, "contactAction")) + $root.proto.ContactAction.encode(message.contactAction, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.muteAction != null && Object.hasOwnProperty.call(message, "muteAction")) + $root.proto.MuteAction.encode(message.muteAction, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.pinAction != null && Object.hasOwnProperty.call(message, "pinAction")) + $root.proto.PinAction.encode(message.pinAction, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.securityNotificationSetting != null && Object.hasOwnProperty.call(message, "securityNotificationSetting")) + $root.proto.SecurityNotificationSetting.encode(message.securityNotificationSetting, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.pushNameSetting != null && Object.hasOwnProperty.call(message, "pushNameSetting")) + $root.proto.PushNameSetting.encode(message.pushNameSetting, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.quickReplyAction != null && Object.hasOwnProperty.call(message, "quickReplyAction")) + $root.proto.QuickReplyAction.encode(message.quickReplyAction, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.recentStickerWeightsAction != null && Object.hasOwnProperty.call(message, "recentStickerWeightsAction")) + $root.proto.RecentStickerWeightsAction.encode(message.recentStickerWeightsAction, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.recentStickerMetadata != null && Object.hasOwnProperty.call(message, "recentStickerMetadata")) + $root.proto.RecentStickerMetadata.encode(message.recentStickerMetadata, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); + if (message.recentEmojiWeightsAction != null && Object.hasOwnProperty.call(message, "recentEmojiWeightsAction")) + $root.proto.RecentEmojiWeightsAction.encode(message.recentEmojiWeightsAction, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); + if (message.labelEditAction != null && Object.hasOwnProperty.call(message, "labelEditAction")) + $root.proto.LabelEditAction.encode(message.labelEditAction, writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim(); + if (message.labelAssociationAction != null && Object.hasOwnProperty.call(message, "labelAssociationAction")) + $root.proto.LabelAssociationAction.encode(message.labelAssociationAction, writer.uint32(/* id 15, wireType 2 =*/122).fork()).ldelim(); + if (message.localeSetting != null && Object.hasOwnProperty.call(message, "localeSetting")) + $root.proto.LocaleSetting.encode(message.localeSetting, writer.uint32(/* id 16, wireType 2 =*/130).fork()).ldelim(); + if (message.archiveChatAction != null && Object.hasOwnProperty.call(message, "archiveChatAction")) + $root.proto.ArchiveChatAction.encode(message.archiveChatAction, writer.uint32(/* id 17, wireType 2 =*/138).fork()).ldelim(); + if (message.deleteMessageForMeAction != null && Object.hasOwnProperty.call(message, "deleteMessageForMeAction")) + $root.proto.DeleteMessageForMeAction.encode(message.deleteMessageForMeAction, writer.uint32(/* id 18, wireType 2 =*/146).fork()).ldelim(); + if (message.keyExpiration != null && Object.hasOwnProperty.call(message, "keyExpiration")) + $root.proto.KeyExpiration.encode(message.keyExpiration, writer.uint32(/* id 19, wireType 2 =*/154).fork()).ldelim(); + if (message.markChatAsReadAction != null && Object.hasOwnProperty.call(message, "markChatAsReadAction")) + $root.proto.MarkChatAsReadAction.encode(message.markChatAsReadAction, writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim(); + if (message.clearChatAction != null && Object.hasOwnProperty.call(message, "clearChatAction")) + $root.proto.ClearChatAction.encode(message.clearChatAction, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.deleteChatAction != null && Object.hasOwnProperty.call(message, "deleteChatAction")) + $root.proto.DeleteChatAction.encode(message.deleteChatAction, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); + if (message.unarchiveChatsSetting != null && Object.hasOwnProperty.call(message, "unarchiveChatsSetting")) + $root.proto.UnarchiveChatsSetting.encode(message.unarchiveChatsSetting, writer.uint32(/* id 23, wireType 2 =*/186).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified SyncActionValue message, length delimited. Does not implicitly {@link proto.SyncActionValue.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.SyncActionValue + * @static + * @param {proto.ISyncActionValue} message SyncActionValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncActionValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SyncActionValue message from the specified reader or buffer. + * @function decode + * @memberof proto.SyncActionValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.SyncActionValue} SyncActionValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncActionValue.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.SyncActionValue(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.timestamp = reader.int64(); + break; + case 2: + message.starAction = $root.proto.StarAction.decode(reader, reader.uint32()); + break; + case 3: + message.contactAction = $root.proto.ContactAction.decode(reader, reader.uint32()); + break; + case 4: + message.muteAction = $root.proto.MuteAction.decode(reader, reader.uint32()); + break; + case 5: + message.pinAction = $root.proto.PinAction.decode(reader, reader.uint32()); + break; + case 6: + message.securityNotificationSetting = $root.proto.SecurityNotificationSetting.decode(reader, reader.uint32()); + break; + case 7: + message.pushNameSetting = $root.proto.PushNameSetting.decode(reader, reader.uint32()); + break; + case 8: + message.quickReplyAction = $root.proto.QuickReplyAction.decode(reader, reader.uint32()); + break; + case 9: + message.recentStickerWeightsAction = $root.proto.RecentStickerWeightsAction.decode(reader, reader.uint32()); + break; + case 10: + message.recentStickerMetadata = $root.proto.RecentStickerMetadata.decode(reader, reader.uint32()); + break; + case 11: + message.recentEmojiWeightsAction = $root.proto.RecentEmojiWeightsAction.decode(reader, reader.uint32()); + break; + case 14: + message.labelEditAction = $root.proto.LabelEditAction.decode(reader, reader.uint32()); + break; + case 15: + message.labelAssociationAction = $root.proto.LabelAssociationAction.decode(reader, reader.uint32()); + break; + case 16: + message.localeSetting = $root.proto.LocaleSetting.decode(reader, reader.uint32()); + break; + case 17: + message.archiveChatAction = $root.proto.ArchiveChatAction.decode(reader, reader.uint32()); + break; + case 18: + message.deleteMessageForMeAction = $root.proto.DeleteMessageForMeAction.decode(reader, reader.uint32()); + break; + case 19: + message.keyExpiration = $root.proto.KeyExpiration.decode(reader, reader.uint32()); + break; + case 20: + message.markChatAsReadAction = $root.proto.MarkChatAsReadAction.decode(reader, reader.uint32()); + break; + case 21: + message.clearChatAction = $root.proto.ClearChatAction.decode(reader, reader.uint32()); + break; + case 22: + message.deleteChatAction = $root.proto.DeleteChatAction.decode(reader, reader.uint32()); + break; + case 23: + message.unarchiveChatsSetting = $root.proto.UnarchiveChatsSetting.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SyncActionValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.SyncActionValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.SyncActionValue} SyncActionValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncActionValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SyncActionValue message. + * @function verify + * @memberof proto.SyncActionValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SyncActionValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.timestamp != null && message.hasOwnProperty("timestamp")) + if (!$util.isInteger(message.timestamp) && !(message.timestamp && $util.isInteger(message.timestamp.low) && $util.isInteger(message.timestamp.high))) + return "timestamp: integer|Long expected"; + if (message.starAction != null && message.hasOwnProperty("starAction")) { + var error = $root.proto.StarAction.verify(message.starAction); + if (error) + return "starAction." + error; + } + if (message.contactAction != null && message.hasOwnProperty("contactAction")) { + var error = $root.proto.ContactAction.verify(message.contactAction); + if (error) + return "contactAction." + error; + } + if (message.muteAction != null && message.hasOwnProperty("muteAction")) { + var error = $root.proto.MuteAction.verify(message.muteAction); + if (error) + return "muteAction." + error; + } + if (message.pinAction != null && message.hasOwnProperty("pinAction")) { + var error = $root.proto.PinAction.verify(message.pinAction); + if (error) + return "pinAction." + error; + } + if (message.securityNotificationSetting != null && message.hasOwnProperty("securityNotificationSetting")) { + var error = $root.proto.SecurityNotificationSetting.verify(message.securityNotificationSetting); + if (error) + return "securityNotificationSetting." + error; + } + if (message.pushNameSetting != null && message.hasOwnProperty("pushNameSetting")) { + var error = $root.proto.PushNameSetting.verify(message.pushNameSetting); + if (error) + return "pushNameSetting." + error; + } + if (message.quickReplyAction != null && message.hasOwnProperty("quickReplyAction")) { + var error = $root.proto.QuickReplyAction.verify(message.quickReplyAction); + if (error) + return "quickReplyAction." + error; + } + if (message.recentStickerWeightsAction != null && message.hasOwnProperty("recentStickerWeightsAction")) { + var error = $root.proto.RecentStickerWeightsAction.verify(message.recentStickerWeightsAction); + if (error) + return "recentStickerWeightsAction." + error; + } + if (message.recentStickerMetadata != null && message.hasOwnProperty("recentStickerMetadata")) { + var error = $root.proto.RecentStickerMetadata.verify(message.recentStickerMetadata); + if (error) + return "recentStickerMetadata." + error; + } + if (message.recentEmojiWeightsAction != null && message.hasOwnProperty("recentEmojiWeightsAction")) { + var error = $root.proto.RecentEmojiWeightsAction.verify(message.recentEmojiWeightsAction); + if (error) + return "recentEmojiWeightsAction." + error; + } + if (message.labelEditAction != null && message.hasOwnProperty("labelEditAction")) { + var error = $root.proto.LabelEditAction.verify(message.labelEditAction); + if (error) + return "labelEditAction." + error; + } + if (message.labelAssociationAction != null && message.hasOwnProperty("labelAssociationAction")) { + var error = $root.proto.LabelAssociationAction.verify(message.labelAssociationAction); + if (error) + return "labelAssociationAction." + error; + } + if (message.localeSetting != null && message.hasOwnProperty("localeSetting")) { + var error = $root.proto.LocaleSetting.verify(message.localeSetting); + if (error) + return "localeSetting." + error; + } + if (message.archiveChatAction != null && message.hasOwnProperty("archiveChatAction")) { + var error = $root.proto.ArchiveChatAction.verify(message.archiveChatAction); + if (error) + return "archiveChatAction." + error; + } + if (message.deleteMessageForMeAction != null && message.hasOwnProperty("deleteMessageForMeAction")) { + var error = $root.proto.DeleteMessageForMeAction.verify(message.deleteMessageForMeAction); + if (error) + return "deleteMessageForMeAction." + error; + } + if (message.keyExpiration != null && message.hasOwnProperty("keyExpiration")) { + var error = $root.proto.KeyExpiration.verify(message.keyExpiration); + if (error) + return "keyExpiration." + error; + } + if (message.markChatAsReadAction != null && message.hasOwnProperty("markChatAsReadAction")) { + var error = $root.proto.MarkChatAsReadAction.verify(message.markChatAsReadAction); + if (error) + return "markChatAsReadAction." + error; + } + if (message.clearChatAction != null && message.hasOwnProperty("clearChatAction")) { + var error = $root.proto.ClearChatAction.verify(message.clearChatAction); + if (error) + return "clearChatAction." + error; + } + if (message.deleteChatAction != null && message.hasOwnProperty("deleteChatAction")) { + var error = $root.proto.DeleteChatAction.verify(message.deleteChatAction); + if (error) + return "deleteChatAction." + error; + } + if (message.unarchiveChatsSetting != null && message.hasOwnProperty("unarchiveChatsSetting")) { + var error = $root.proto.UnarchiveChatsSetting.verify(message.unarchiveChatsSetting); + if (error) + return "unarchiveChatsSetting." + error; + } + return null; + }; + + /** + * Creates a SyncActionValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.SyncActionValue + * @static + * @param {Object.} object Plain object + * @returns {proto.SyncActionValue} SyncActionValue + */ + SyncActionValue.fromObject = function fromObject(object) { + if (object instanceof $root.proto.SyncActionValue) + return object; + var message = new $root.proto.SyncActionValue(); + if (object.timestamp != null) + if ($util.Long) + (message.timestamp = $util.Long.fromValue(object.timestamp)).unsigned = false; + else if (typeof object.timestamp === "string") + message.timestamp = parseInt(object.timestamp, 10); + else if (typeof object.timestamp === "number") + message.timestamp = object.timestamp; + else if (typeof object.timestamp === "object") + message.timestamp = new $util.LongBits(object.timestamp.low >>> 0, object.timestamp.high >>> 0).toNumber(); + if (object.starAction != null) { + if (typeof object.starAction !== "object") + throw TypeError(".proto.SyncActionValue.starAction: object expected"); + message.starAction = $root.proto.StarAction.fromObject(object.starAction); + } + if (object.contactAction != null) { + if (typeof object.contactAction !== "object") + throw TypeError(".proto.SyncActionValue.contactAction: object expected"); + message.contactAction = $root.proto.ContactAction.fromObject(object.contactAction); + } + if (object.muteAction != null) { + if (typeof object.muteAction !== "object") + throw TypeError(".proto.SyncActionValue.muteAction: object expected"); + message.muteAction = $root.proto.MuteAction.fromObject(object.muteAction); + } + if (object.pinAction != null) { + if (typeof object.pinAction !== "object") + throw TypeError(".proto.SyncActionValue.pinAction: object expected"); + message.pinAction = $root.proto.PinAction.fromObject(object.pinAction); + } + if (object.securityNotificationSetting != null) { + if (typeof object.securityNotificationSetting !== "object") + throw TypeError(".proto.SyncActionValue.securityNotificationSetting: object expected"); + message.securityNotificationSetting = $root.proto.SecurityNotificationSetting.fromObject(object.securityNotificationSetting); + } + if (object.pushNameSetting != null) { + if (typeof object.pushNameSetting !== "object") + throw TypeError(".proto.SyncActionValue.pushNameSetting: object expected"); + message.pushNameSetting = $root.proto.PushNameSetting.fromObject(object.pushNameSetting); + } + if (object.quickReplyAction != null) { + if (typeof object.quickReplyAction !== "object") + throw TypeError(".proto.SyncActionValue.quickReplyAction: object expected"); + message.quickReplyAction = $root.proto.QuickReplyAction.fromObject(object.quickReplyAction); + } + if (object.recentStickerWeightsAction != null) { + if (typeof object.recentStickerWeightsAction !== "object") + throw TypeError(".proto.SyncActionValue.recentStickerWeightsAction: object expected"); + message.recentStickerWeightsAction = $root.proto.RecentStickerWeightsAction.fromObject(object.recentStickerWeightsAction); + } + if (object.recentStickerMetadata != null) { + if (typeof object.recentStickerMetadata !== "object") + throw TypeError(".proto.SyncActionValue.recentStickerMetadata: object expected"); + message.recentStickerMetadata = $root.proto.RecentStickerMetadata.fromObject(object.recentStickerMetadata); + } + if (object.recentEmojiWeightsAction != null) { + if (typeof object.recentEmojiWeightsAction !== "object") + throw TypeError(".proto.SyncActionValue.recentEmojiWeightsAction: object expected"); + message.recentEmojiWeightsAction = $root.proto.RecentEmojiWeightsAction.fromObject(object.recentEmojiWeightsAction); + } + if (object.labelEditAction != null) { + if (typeof object.labelEditAction !== "object") + throw TypeError(".proto.SyncActionValue.labelEditAction: object expected"); + message.labelEditAction = $root.proto.LabelEditAction.fromObject(object.labelEditAction); + } + if (object.labelAssociationAction != null) { + if (typeof object.labelAssociationAction !== "object") + throw TypeError(".proto.SyncActionValue.labelAssociationAction: object expected"); + message.labelAssociationAction = $root.proto.LabelAssociationAction.fromObject(object.labelAssociationAction); + } + if (object.localeSetting != null) { + if (typeof object.localeSetting !== "object") + throw TypeError(".proto.SyncActionValue.localeSetting: object expected"); + message.localeSetting = $root.proto.LocaleSetting.fromObject(object.localeSetting); + } + if (object.archiveChatAction != null) { + if (typeof object.archiveChatAction !== "object") + throw TypeError(".proto.SyncActionValue.archiveChatAction: object expected"); + message.archiveChatAction = $root.proto.ArchiveChatAction.fromObject(object.archiveChatAction); + } + if (object.deleteMessageForMeAction != null) { + if (typeof object.deleteMessageForMeAction !== "object") + throw TypeError(".proto.SyncActionValue.deleteMessageForMeAction: object expected"); + message.deleteMessageForMeAction = $root.proto.DeleteMessageForMeAction.fromObject(object.deleteMessageForMeAction); + } + if (object.keyExpiration != null) { + if (typeof object.keyExpiration !== "object") + throw TypeError(".proto.SyncActionValue.keyExpiration: object expected"); + message.keyExpiration = $root.proto.KeyExpiration.fromObject(object.keyExpiration); + } + if (object.markChatAsReadAction != null) { + if (typeof object.markChatAsReadAction !== "object") + throw TypeError(".proto.SyncActionValue.markChatAsReadAction: object expected"); + message.markChatAsReadAction = $root.proto.MarkChatAsReadAction.fromObject(object.markChatAsReadAction); + } + if (object.clearChatAction != null) { + if (typeof object.clearChatAction !== "object") + throw TypeError(".proto.SyncActionValue.clearChatAction: object expected"); + message.clearChatAction = $root.proto.ClearChatAction.fromObject(object.clearChatAction); + } + if (object.deleteChatAction != null) { + if (typeof object.deleteChatAction !== "object") + throw TypeError(".proto.SyncActionValue.deleteChatAction: object expected"); + message.deleteChatAction = $root.proto.DeleteChatAction.fromObject(object.deleteChatAction); + } + if (object.unarchiveChatsSetting != null) { + if (typeof object.unarchiveChatsSetting !== "object") + throw TypeError(".proto.SyncActionValue.unarchiveChatsSetting: object expected"); + message.unarchiveChatsSetting = $root.proto.UnarchiveChatsSetting.fromObject(object.unarchiveChatsSetting); + } + return message; + }; + + /** + * Creates a plain object from a SyncActionValue message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.SyncActionValue + * @static + * @param {proto.SyncActionValue} message SyncActionValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SyncActionValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.timestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.timestamp = options.longs === String ? "0" : 0; + object.starAction = null; + object.contactAction = null; + object.muteAction = null; + object.pinAction = null; + object.securityNotificationSetting = null; + object.pushNameSetting = null; + object.quickReplyAction = null; + object.recentStickerWeightsAction = null; + object.recentStickerMetadata = null; + object.recentEmojiWeightsAction = null; + object.labelEditAction = null; + object.labelAssociationAction = null; + object.localeSetting = null; + object.archiveChatAction = null; + object.deleteMessageForMeAction = null; + object.keyExpiration = null; + object.markChatAsReadAction = null; + object.clearChatAction = null; + object.deleteChatAction = null; + object.unarchiveChatsSetting = null; + } + if (message.timestamp != null && message.hasOwnProperty("timestamp")) + if (typeof message.timestamp === "number") + object.timestamp = options.longs === String ? String(message.timestamp) : message.timestamp; + else + object.timestamp = options.longs === String ? $util.Long.prototype.toString.call(message.timestamp) : options.longs === Number ? new $util.LongBits(message.timestamp.low >>> 0, message.timestamp.high >>> 0).toNumber() : message.timestamp; + if (message.starAction != null && message.hasOwnProperty("starAction")) + object.starAction = $root.proto.StarAction.toObject(message.starAction, options); + if (message.contactAction != null && message.hasOwnProperty("contactAction")) + object.contactAction = $root.proto.ContactAction.toObject(message.contactAction, options); + if (message.muteAction != null && message.hasOwnProperty("muteAction")) + object.muteAction = $root.proto.MuteAction.toObject(message.muteAction, options); + if (message.pinAction != null && message.hasOwnProperty("pinAction")) + object.pinAction = $root.proto.PinAction.toObject(message.pinAction, options); + if (message.securityNotificationSetting != null && message.hasOwnProperty("securityNotificationSetting")) + object.securityNotificationSetting = $root.proto.SecurityNotificationSetting.toObject(message.securityNotificationSetting, options); + if (message.pushNameSetting != null && message.hasOwnProperty("pushNameSetting")) + object.pushNameSetting = $root.proto.PushNameSetting.toObject(message.pushNameSetting, options); + if (message.quickReplyAction != null && message.hasOwnProperty("quickReplyAction")) + object.quickReplyAction = $root.proto.QuickReplyAction.toObject(message.quickReplyAction, options); + if (message.recentStickerWeightsAction != null && message.hasOwnProperty("recentStickerWeightsAction")) + object.recentStickerWeightsAction = $root.proto.RecentStickerWeightsAction.toObject(message.recentStickerWeightsAction, options); + if (message.recentStickerMetadata != null && message.hasOwnProperty("recentStickerMetadata")) + object.recentStickerMetadata = $root.proto.RecentStickerMetadata.toObject(message.recentStickerMetadata, options); + if (message.recentEmojiWeightsAction != null && message.hasOwnProperty("recentEmojiWeightsAction")) + object.recentEmojiWeightsAction = $root.proto.RecentEmojiWeightsAction.toObject(message.recentEmojiWeightsAction, options); + if (message.labelEditAction != null && message.hasOwnProperty("labelEditAction")) + object.labelEditAction = $root.proto.LabelEditAction.toObject(message.labelEditAction, options); + if (message.labelAssociationAction != null && message.hasOwnProperty("labelAssociationAction")) + object.labelAssociationAction = $root.proto.LabelAssociationAction.toObject(message.labelAssociationAction, options); + if (message.localeSetting != null && message.hasOwnProperty("localeSetting")) + object.localeSetting = $root.proto.LocaleSetting.toObject(message.localeSetting, options); + if (message.archiveChatAction != null && message.hasOwnProperty("archiveChatAction")) + object.archiveChatAction = $root.proto.ArchiveChatAction.toObject(message.archiveChatAction, options); + if (message.deleteMessageForMeAction != null && message.hasOwnProperty("deleteMessageForMeAction")) + object.deleteMessageForMeAction = $root.proto.DeleteMessageForMeAction.toObject(message.deleteMessageForMeAction, options); + if (message.keyExpiration != null && message.hasOwnProperty("keyExpiration")) + object.keyExpiration = $root.proto.KeyExpiration.toObject(message.keyExpiration, options); + if (message.markChatAsReadAction != null && message.hasOwnProperty("markChatAsReadAction")) + object.markChatAsReadAction = $root.proto.MarkChatAsReadAction.toObject(message.markChatAsReadAction, options); + if (message.clearChatAction != null && message.hasOwnProperty("clearChatAction")) + object.clearChatAction = $root.proto.ClearChatAction.toObject(message.clearChatAction, options); + if (message.deleteChatAction != null && message.hasOwnProperty("deleteChatAction")) + object.deleteChatAction = $root.proto.DeleteChatAction.toObject(message.deleteChatAction, options); + if (message.unarchiveChatsSetting != null && message.hasOwnProperty("unarchiveChatsSetting")) + object.unarchiveChatsSetting = $root.proto.UnarchiveChatsSetting.toObject(message.unarchiveChatsSetting, options); + return object; + }; + + /** + * Converts this SyncActionValue to JSON. + * @function toJSON + * @memberof proto.SyncActionValue + * @instance + * @returns {Object.} JSON object + */ + SyncActionValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return SyncActionValue; + })(); + + proto.RecentEmojiWeight = (function() { + + /** + * Properties of a RecentEmojiWeight. + * @memberof proto + * @interface IRecentEmojiWeight + * @property {string|null} [emoji] RecentEmojiWeight emoji + * @property {number|null} [weight] RecentEmojiWeight weight + */ + + /** + * Constructs a new RecentEmojiWeight. + * @memberof proto + * @classdesc Represents a RecentEmojiWeight. + * @implements IRecentEmojiWeight + * @constructor + * @param {proto.IRecentEmojiWeight=} [properties] Properties to set + */ + function RecentEmojiWeight(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RecentEmojiWeight emoji. + * @member {string} emoji + * @memberof proto.RecentEmojiWeight + * @instance + */ + RecentEmojiWeight.prototype.emoji = ""; + + /** + * RecentEmojiWeight weight. + * @member {number} weight + * @memberof proto.RecentEmojiWeight + * @instance + */ + RecentEmojiWeight.prototype.weight = 0; + + /** + * Creates a new RecentEmojiWeight instance using the specified properties. + * @function create + * @memberof proto.RecentEmojiWeight + * @static + * @param {proto.IRecentEmojiWeight=} [properties] Properties to set + * @returns {proto.RecentEmojiWeight} RecentEmojiWeight instance + */ + RecentEmojiWeight.create = function create(properties) { + return new RecentEmojiWeight(properties); + }; + + /** + * Encodes the specified RecentEmojiWeight message. Does not implicitly {@link proto.RecentEmojiWeight.verify|verify} messages. + * @function encode + * @memberof proto.RecentEmojiWeight + * @static + * @param {proto.IRecentEmojiWeight} message RecentEmojiWeight message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecentEmojiWeight.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.emoji != null && Object.hasOwnProperty.call(message, "emoji")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.emoji); + if (message.weight != null && Object.hasOwnProperty.call(message, "weight")) + writer.uint32(/* id 2, wireType 5 =*/21).float(message.weight); + return writer; + }; + + /** + * Encodes the specified RecentEmojiWeight message, length delimited. Does not implicitly {@link proto.RecentEmojiWeight.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.RecentEmojiWeight + * @static + * @param {proto.IRecentEmojiWeight} message RecentEmojiWeight message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecentEmojiWeight.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RecentEmojiWeight message from the specified reader or buffer. + * @function decode + * @memberof proto.RecentEmojiWeight + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.RecentEmojiWeight} RecentEmojiWeight + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecentEmojiWeight.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.RecentEmojiWeight(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.emoji = reader.string(); + break; + case 2: + message.weight = reader.float(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RecentEmojiWeight message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.RecentEmojiWeight + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.RecentEmojiWeight} RecentEmojiWeight + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecentEmojiWeight.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RecentEmojiWeight message. + * @function verify + * @memberof proto.RecentEmojiWeight + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RecentEmojiWeight.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.emoji != null && message.hasOwnProperty("emoji")) + if (!$util.isString(message.emoji)) + return "emoji: string expected"; + if (message.weight != null && message.hasOwnProperty("weight")) + if (typeof message.weight !== "number") + return "weight: number expected"; + return null; + }; + + /** + * Creates a RecentEmojiWeight message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.RecentEmojiWeight + * @static + * @param {Object.} object Plain object + * @returns {proto.RecentEmojiWeight} RecentEmojiWeight + */ + RecentEmojiWeight.fromObject = function fromObject(object) { + if (object instanceof $root.proto.RecentEmojiWeight) + return object; + var message = new $root.proto.RecentEmojiWeight(); + if (object.emoji != null) + message.emoji = String(object.emoji); + if (object.weight != null) + message.weight = Number(object.weight); + return message; + }; + + /** + * Creates a plain object from a RecentEmojiWeight message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.RecentEmojiWeight + * @static + * @param {proto.RecentEmojiWeight} message RecentEmojiWeight + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RecentEmojiWeight.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.emoji = ""; + object.weight = 0; + } + if (message.emoji != null && message.hasOwnProperty("emoji")) + object.emoji = message.emoji; + if (message.weight != null && message.hasOwnProperty("weight")) + object.weight = options.json && !isFinite(message.weight) ? String(message.weight) : message.weight; + return object; + }; + + /** + * Converts this RecentEmojiWeight to JSON. + * @function toJSON + * @memberof proto.RecentEmojiWeight + * @instance + * @returns {Object.} JSON object + */ + RecentEmojiWeight.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return RecentEmojiWeight; + })(); + + proto.RecentStickerWeight = (function() { + + /** + * Properties of a RecentStickerWeight. + * @memberof proto + * @interface IRecentStickerWeight + * @property {string|null} [filehash] RecentStickerWeight filehash + * @property {number|null} [weight] RecentStickerWeight weight + */ + + /** + * Constructs a new RecentStickerWeight. + * @memberof proto + * @classdesc Represents a RecentStickerWeight. + * @implements IRecentStickerWeight + * @constructor + * @param {proto.IRecentStickerWeight=} [properties] Properties to set + */ + function RecentStickerWeight(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RecentStickerWeight filehash. + * @member {string} filehash + * @memberof proto.RecentStickerWeight + * @instance + */ + RecentStickerWeight.prototype.filehash = ""; + + /** + * RecentStickerWeight weight. + * @member {number} weight + * @memberof proto.RecentStickerWeight + * @instance + */ + RecentStickerWeight.prototype.weight = 0; + + /** + * Creates a new RecentStickerWeight instance using the specified properties. + * @function create + * @memberof proto.RecentStickerWeight + * @static + * @param {proto.IRecentStickerWeight=} [properties] Properties to set + * @returns {proto.RecentStickerWeight} RecentStickerWeight instance + */ + RecentStickerWeight.create = function create(properties) { + return new RecentStickerWeight(properties); + }; + + /** + * Encodes the specified RecentStickerWeight message. Does not implicitly {@link proto.RecentStickerWeight.verify|verify} messages. + * @function encode + * @memberof proto.RecentStickerWeight + * @static + * @param {proto.IRecentStickerWeight} message RecentStickerWeight message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecentStickerWeight.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.filehash != null && Object.hasOwnProperty.call(message, "filehash")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.filehash); + if (message.weight != null && Object.hasOwnProperty.call(message, "weight")) + writer.uint32(/* id 2, wireType 5 =*/21).float(message.weight); + return writer; + }; + + /** + * Encodes the specified RecentStickerWeight message, length delimited. Does not implicitly {@link proto.RecentStickerWeight.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.RecentStickerWeight + * @static + * @param {proto.IRecentStickerWeight} message RecentStickerWeight message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RecentStickerWeight.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RecentStickerWeight message from the specified reader or buffer. + * @function decode + * @memberof proto.RecentStickerWeight + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.RecentStickerWeight} RecentStickerWeight + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecentStickerWeight.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.RecentStickerWeight(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.filehash = reader.string(); + break; + case 2: + message.weight = reader.float(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RecentStickerWeight message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.RecentStickerWeight + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.RecentStickerWeight} RecentStickerWeight + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RecentStickerWeight.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RecentStickerWeight message. + * @function verify + * @memberof proto.RecentStickerWeight + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RecentStickerWeight.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.filehash != null && message.hasOwnProperty("filehash")) + if (!$util.isString(message.filehash)) + return "filehash: string expected"; + if (message.weight != null && message.hasOwnProperty("weight")) + if (typeof message.weight !== "number") + return "weight: number expected"; + return null; + }; + + /** + * Creates a RecentStickerWeight message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.RecentStickerWeight + * @static + * @param {Object.} object Plain object + * @returns {proto.RecentStickerWeight} RecentStickerWeight + */ + RecentStickerWeight.fromObject = function fromObject(object) { + if (object instanceof $root.proto.RecentStickerWeight) + return object; + var message = new $root.proto.RecentStickerWeight(); + if (object.filehash != null) + message.filehash = String(object.filehash); + if (object.weight != null) + message.weight = Number(object.weight); + return message; + }; + + /** + * Creates a plain object from a RecentStickerWeight message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.RecentStickerWeight + * @static + * @param {proto.RecentStickerWeight} message RecentStickerWeight + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RecentStickerWeight.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.filehash = ""; + object.weight = 0; + } + if (message.filehash != null && message.hasOwnProperty("filehash")) + object.filehash = message.filehash; + if (message.weight != null && message.hasOwnProperty("weight")) + object.weight = options.json && !isFinite(message.weight) ? String(message.weight) : message.weight; + return object; + }; + + /** + * Converts this RecentStickerWeight to JSON. + * @function toJSON + * @memberof proto.RecentStickerWeight + * @instance + * @returns {Object.} JSON object + */ + RecentStickerWeight.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return RecentStickerWeight; + })(); + + proto.SyncdPatch = (function() { + + /** + * Properties of a SyncdPatch. + * @memberof proto + * @interface ISyncdPatch + * @property {proto.ISyncdVersion|null} [version] SyncdPatch version + * @property {Array.|null} [mutations] SyncdPatch mutations + * @property {proto.IExternalBlobReference|null} [externalMutations] SyncdPatch externalMutations + * @property {Uint8Array|null} [snapshotMac] SyncdPatch snapshotMac + * @property {Uint8Array|null} [patchMac] SyncdPatch patchMac + * @property {proto.IKeyId|null} [keyId] SyncdPatch keyId + * @property {proto.IExitCode|null} [exitCode] SyncdPatch exitCode + * @property {number|null} [deviceIndex] SyncdPatch deviceIndex + */ + + /** + * Constructs a new SyncdPatch. + * @memberof proto + * @classdesc Represents a SyncdPatch. + * @implements ISyncdPatch + * @constructor + * @param {proto.ISyncdPatch=} [properties] Properties to set + */ + function SyncdPatch(properties) { + this.mutations = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SyncdPatch version. + * @member {proto.ISyncdVersion|null|undefined} version + * @memberof proto.SyncdPatch + * @instance + */ + SyncdPatch.prototype.version = null; + + /** + * SyncdPatch mutations. + * @member {Array.} mutations + * @memberof proto.SyncdPatch + * @instance + */ + SyncdPatch.prototype.mutations = $util.emptyArray; + + /** + * SyncdPatch externalMutations. + * @member {proto.IExternalBlobReference|null|undefined} externalMutations + * @memberof proto.SyncdPatch + * @instance + */ + SyncdPatch.prototype.externalMutations = null; + + /** + * SyncdPatch snapshotMac. + * @member {Uint8Array} snapshotMac + * @memberof proto.SyncdPatch + * @instance + */ + SyncdPatch.prototype.snapshotMac = $util.newBuffer([]); + + /** + * SyncdPatch patchMac. + * @member {Uint8Array} patchMac + * @memberof proto.SyncdPatch + * @instance + */ + SyncdPatch.prototype.patchMac = $util.newBuffer([]); + + /** + * SyncdPatch keyId. + * @member {proto.IKeyId|null|undefined} keyId + * @memberof proto.SyncdPatch + * @instance + */ + SyncdPatch.prototype.keyId = null; + + /** + * SyncdPatch exitCode. + * @member {proto.IExitCode|null|undefined} exitCode + * @memberof proto.SyncdPatch + * @instance + */ + SyncdPatch.prototype.exitCode = null; + + /** + * SyncdPatch deviceIndex. + * @member {number} deviceIndex + * @memberof proto.SyncdPatch + * @instance + */ + SyncdPatch.prototype.deviceIndex = 0; + + /** + * Creates a new SyncdPatch instance using the specified properties. + * @function create + * @memberof proto.SyncdPatch + * @static + * @param {proto.ISyncdPatch=} [properties] Properties to set + * @returns {proto.SyncdPatch} SyncdPatch instance + */ + SyncdPatch.create = function create(properties) { + return new SyncdPatch(properties); + }; + + /** + * Encodes the specified SyncdPatch message. Does not implicitly {@link proto.SyncdPatch.verify|verify} messages. + * @function encode + * @memberof proto.SyncdPatch + * @static + * @param {proto.ISyncdPatch} message SyncdPatch message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncdPatch.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.version != null && Object.hasOwnProperty.call(message, "version")) + $root.proto.SyncdVersion.encode(message.version, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.mutations != null && message.mutations.length) + for (var i = 0; i < message.mutations.length; ++i) + $root.proto.SyncdMutation.encode(message.mutations[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.externalMutations != null && Object.hasOwnProperty.call(message, "externalMutations")) + $root.proto.ExternalBlobReference.encode(message.externalMutations, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.snapshotMac != null && Object.hasOwnProperty.call(message, "snapshotMac")) + writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.snapshotMac); + if (message.patchMac != null && Object.hasOwnProperty.call(message, "patchMac")) + writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.patchMac); + if (message.keyId != null && Object.hasOwnProperty.call(message, "keyId")) + $root.proto.KeyId.encode(message.keyId, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.exitCode != null && Object.hasOwnProperty.call(message, "exitCode")) + $root.proto.ExitCode.encode(message.exitCode, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.deviceIndex != null && Object.hasOwnProperty.call(message, "deviceIndex")) + writer.uint32(/* id 8, wireType 0 =*/64).uint32(message.deviceIndex); + return writer; + }; + + /** + * Encodes the specified SyncdPatch message, length delimited. Does not implicitly {@link proto.SyncdPatch.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.SyncdPatch + * @static + * @param {proto.ISyncdPatch} message SyncdPatch message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncdPatch.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SyncdPatch message from the specified reader or buffer. + * @function decode + * @memberof proto.SyncdPatch + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.SyncdPatch} SyncdPatch + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncdPatch.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.SyncdPatch(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.version = $root.proto.SyncdVersion.decode(reader, reader.uint32()); + break; + case 2: + if (!(message.mutations && message.mutations.length)) + message.mutations = []; + message.mutations.push($root.proto.SyncdMutation.decode(reader, reader.uint32())); + break; + case 3: + message.externalMutations = $root.proto.ExternalBlobReference.decode(reader, reader.uint32()); + break; + case 4: + message.snapshotMac = reader.bytes(); + break; + case 5: + message.patchMac = reader.bytes(); + break; + case 6: + message.keyId = $root.proto.KeyId.decode(reader, reader.uint32()); + break; + case 7: + message.exitCode = $root.proto.ExitCode.decode(reader, reader.uint32()); + break; + case 8: + message.deviceIndex = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SyncdPatch message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.SyncdPatch + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.SyncdPatch} SyncdPatch + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncdPatch.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SyncdPatch message. + * @function verify + * @memberof proto.SyncdPatch + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SyncdPatch.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.version != null && message.hasOwnProperty("version")) { + var error = $root.proto.SyncdVersion.verify(message.version); + if (error) + return "version." + error; + } + if (message.mutations != null && message.hasOwnProperty("mutations")) { + if (!Array.isArray(message.mutations)) + return "mutations: array expected"; + for (var i = 0; i < message.mutations.length; ++i) { + var error = $root.proto.SyncdMutation.verify(message.mutations[i]); + if (error) + return "mutations." + error; + } + } + if (message.externalMutations != null && message.hasOwnProperty("externalMutations")) { + var error = $root.proto.ExternalBlobReference.verify(message.externalMutations); + if (error) + return "externalMutations." + error; + } + if (message.snapshotMac != null && message.hasOwnProperty("snapshotMac")) + if (!(message.snapshotMac && typeof message.snapshotMac.length === "number" || $util.isString(message.snapshotMac))) + return "snapshotMac: buffer expected"; + if (message.patchMac != null && message.hasOwnProperty("patchMac")) + if (!(message.patchMac && typeof message.patchMac.length === "number" || $util.isString(message.patchMac))) + return "patchMac: buffer expected"; + if (message.keyId != null && message.hasOwnProperty("keyId")) { + var error = $root.proto.KeyId.verify(message.keyId); + if (error) + return "keyId." + error; + } + if (message.exitCode != null && message.hasOwnProperty("exitCode")) { + var error = $root.proto.ExitCode.verify(message.exitCode); + if (error) + return "exitCode." + error; + } + if (message.deviceIndex != null && message.hasOwnProperty("deviceIndex")) + if (!$util.isInteger(message.deviceIndex)) + return "deviceIndex: integer expected"; + return null; + }; + + /** + * Creates a SyncdPatch message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.SyncdPatch + * @static + * @param {Object.} object Plain object + * @returns {proto.SyncdPatch} SyncdPatch + */ + SyncdPatch.fromObject = function fromObject(object) { + if (object instanceof $root.proto.SyncdPatch) + return object; + var message = new $root.proto.SyncdPatch(); + if (object.version != null) { + if (typeof object.version !== "object") + throw TypeError(".proto.SyncdPatch.version: object expected"); + message.version = $root.proto.SyncdVersion.fromObject(object.version); + } + if (object.mutations) { + if (!Array.isArray(object.mutations)) + throw TypeError(".proto.SyncdPatch.mutations: array expected"); + message.mutations = []; + for (var i = 0; i < object.mutations.length; ++i) { + if (typeof object.mutations[i] !== "object") + throw TypeError(".proto.SyncdPatch.mutations: object expected"); + message.mutations[i] = $root.proto.SyncdMutation.fromObject(object.mutations[i]); + } + } + if (object.externalMutations != null) { + if (typeof object.externalMutations !== "object") + throw TypeError(".proto.SyncdPatch.externalMutations: object expected"); + message.externalMutations = $root.proto.ExternalBlobReference.fromObject(object.externalMutations); + } + if (object.snapshotMac != null) + if (typeof object.snapshotMac === "string") + $util.base64.decode(object.snapshotMac, message.snapshotMac = $util.newBuffer($util.base64.length(object.snapshotMac)), 0); + else if (object.snapshotMac.length) + message.snapshotMac = object.snapshotMac; + if (object.patchMac != null) + if (typeof object.patchMac === "string") + $util.base64.decode(object.patchMac, message.patchMac = $util.newBuffer($util.base64.length(object.patchMac)), 0); + else if (object.patchMac.length) + message.patchMac = object.patchMac; + if (object.keyId != null) { + if (typeof object.keyId !== "object") + throw TypeError(".proto.SyncdPatch.keyId: object expected"); + message.keyId = $root.proto.KeyId.fromObject(object.keyId); + } + if (object.exitCode != null) { + if (typeof object.exitCode !== "object") + throw TypeError(".proto.SyncdPatch.exitCode: object expected"); + message.exitCode = $root.proto.ExitCode.fromObject(object.exitCode); + } + if (object.deviceIndex != null) + message.deviceIndex = object.deviceIndex >>> 0; + return message; + }; + + /** + * Creates a plain object from a SyncdPatch message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.SyncdPatch + * @static + * @param {proto.SyncdPatch} message SyncdPatch + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SyncdPatch.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.mutations = []; + if (options.defaults) { + object.version = null; + object.externalMutations = null; + if (options.bytes === String) + object.snapshotMac = ""; + else { + object.snapshotMac = []; + if (options.bytes !== Array) + object.snapshotMac = $util.newBuffer(object.snapshotMac); + } + if (options.bytes === String) + object.patchMac = ""; + else { + object.patchMac = []; + if (options.bytes !== Array) + object.patchMac = $util.newBuffer(object.patchMac); + } + object.keyId = null; + object.exitCode = null; + object.deviceIndex = 0; + } + if (message.version != null && message.hasOwnProperty("version")) + object.version = $root.proto.SyncdVersion.toObject(message.version, options); + if (message.mutations && message.mutations.length) { + object.mutations = []; + for (var j = 0; j < message.mutations.length; ++j) + object.mutations[j] = $root.proto.SyncdMutation.toObject(message.mutations[j], options); + } + if (message.externalMutations != null && message.hasOwnProperty("externalMutations")) + object.externalMutations = $root.proto.ExternalBlobReference.toObject(message.externalMutations, options); + if (message.snapshotMac != null && message.hasOwnProperty("snapshotMac")) + object.snapshotMac = options.bytes === String ? $util.base64.encode(message.snapshotMac, 0, message.snapshotMac.length) : options.bytes === Array ? Array.prototype.slice.call(message.snapshotMac) : message.snapshotMac; + if (message.patchMac != null && message.hasOwnProperty("patchMac")) + object.patchMac = options.bytes === String ? $util.base64.encode(message.patchMac, 0, message.patchMac.length) : options.bytes === Array ? Array.prototype.slice.call(message.patchMac) : message.patchMac; + if (message.keyId != null && message.hasOwnProperty("keyId")) + object.keyId = $root.proto.KeyId.toObject(message.keyId, options); + if (message.exitCode != null && message.hasOwnProperty("exitCode")) + object.exitCode = $root.proto.ExitCode.toObject(message.exitCode, options); + if (message.deviceIndex != null && message.hasOwnProperty("deviceIndex")) + object.deviceIndex = message.deviceIndex; + return object; + }; + + /** + * Converts this SyncdPatch to JSON. + * @function toJSON + * @memberof proto.SyncdPatch + * @instance + * @returns {Object.} JSON object + */ + SyncdPatch.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return SyncdPatch; + })(); + + proto.SyncdMutation = (function() { + + /** + * Properties of a SyncdMutation. + * @memberof proto + * @interface ISyncdMutation + * @property {proto.SyncdMutation.SyncdMutationSyncdOperation|null} [operation] SyncdMutation operation + * @property {proto.ISyncdRecord|null} [record] SyncdMutation record + */ + + /** + * Constructs a new SyncdMutation. + * @memberof proto + * @classdesc Represents a SyncdMutation. + * @implements ISyncdMutation + * @constructor + * @param {proto.ISyncdMutation=} [properties] Properties to set + */ + function SyncdMutation(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SyncdMutation operation. + * @member {proto.SyncdMutation.SyncdMutationSyncdOperation} operation + * @memberof proto.SyncdMutation + * @instance + */ + SyncdMutation.prototype.operation = 0; + + /** + * SyncdMutation record. + * @member {proto.ISyncdRecord|null|undefined} record + * @memberof proto.SyncdMutation + * @instance + */ + SyncdMutation.prototype.record = null; + + /** + * Creates a new SyncdMutation instance using the specified properties. + * @function create + * @memberof proto.SyncdMutation + * @static + * @param {proto.ISyncdMutation=} [properties] Properties to set + * @returns {proto.SyncdMutation} SyncdMutation instance + */ + SyncdMutation.create = function create(properties) { + return new SyncdMutation(properties); + }; + + /** + * Encodes the specified SyncdMutation message. Does not implicitly {@link proto.SyncdMutation.verify|verify} messages. + * @function encode + * @memberof proto.SyncdMutation + * @static + * @param {proto.ISyncdMutation} message SyncdMutation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncdMutation.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.operation != null && Object.hasOwnProperty.call(message, "operation")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.operation); + if (message.record != null && Object.hasOwnProperty.call(message, "record")) + $root.proto.SyncdRecord.encode(message.record, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified SyncdMutation message, length delimited. Does not implicitly {@link proto.SyncdMutation.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.SyncdMutation + * @static + * @param {proto.ISyncdMutation} message SyncdMutation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncdMutation.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SyncdMutation message from the specified reader or buffer. + * @function decode + * @memberof proto.SyncdMutation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.SyncdMutation} SyncdMutation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncdMutation.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.SyncdMutation(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.operation = reader.int32(); + break; + case 2: + message.record = $root.proto.SyncdRecord.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SyncdMutation message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.SyncdMutation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.SyncdMutation} SyncdMutation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncdMutation.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SyncdMutation message. + * @function verify + * @memberof proto.SyncdMutation + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SyncdMutation.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.operation != null && message.hasOwnProperty("operation")) + switch (message.operation) { + default: + return "operation: enum value expected"; + case 0: + case 1: + break; + } + if (message.record != null && message.hasOwnProperty("record")) { + var error = $root.proto.SyncdRecord.verify(message.record); + if (error) + return "record." + error; + } + return null; + }; + + /** + * Creates a SyncdMutation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.SyncdMutation + * @static + * @param {Object.} object Plain object + * @returns {proto.SyncdMutation} SyncdMutation + */ + SyncdMutation.fromObject = function fromObject(object) { + if (object instanceof $root.proto.SyncdMutation) + return object; + var message = new $root.proto.SyncdMutation(); + switch (object.operation) { + case "SET": + case 0: + message.operation = 0; + break; + case "REMOVE": + case 1: + message.operation = 1; + break; + } + if (object.record != null) { + if (typeof object.record !== "object") + throw TypeError(".proto.SyncdMutation.record: object expected"); + message.record = $root.proto.SyncdRecord.fromObject(object.record); + } + return message; + }; + + /** + * Creates a plain object from a SyncdMutation message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.SyncdMutation + * @static + * @param {proto.SyncdMutation} message SyncdMutation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SyncdMutation.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.operation = options.enums === String ? "SET" : 0; + object.record = null; + } + if (message.operation != null && message.hasOwnProperty("operation")) + object.operation = options.enums === String ? $root.proto.SyncdMutation.SyncdMutationSyncdOperation[message.operation] : message.operation; + if (message.record != null && message.hasOwnProperty("record")) + object.record = $root.proto.SyncdRecord.toObject(message.record, options); + return object; + }; + + /** + * Converts this SyncdMutation to JSON. + * @function toJSON + * @memberof proto.SyncdMutation + * @instance + * @returns {Object.} JSON object + */ + SyncdMutation.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * SyncdMutationSyncdOperation enum. + * @name proto.SyncdMutation.SyncdMutationSyncdOperation + * @enum {number} + * @property {number} SET=0 SET value + * @property {number} REMOVE=1 REMOVE value + */ + SyncdMutation.SyncdMutationSyncdOperation = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SET"] = 0; + values[valuesById[1] = "REMOVE"] = 1; + return values; + })(); + + return SyncdMutation; + })(); + + proto.SyncdMutations = (function() { + + /** + * Properties of a SyncdMutations. + * @memberof proto + * @interface ISyncdMutations + * @property {Array.|null} [mutations] SyncdMutations mutations + */ + + /** + * Constructs a new SyncdMutations. + * @memberof proto + * @classdesc Represents a SyncdMutations. + * @implements ISyncdMutations + * @constructor + * @param {proto.ISyncdMutations=} [properties] Properties to set + */ + function SyncdMutations(properties) { + this.mutations = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SyncdMutations mutations. + * @member {Array.} mutations + * @memberof proto.SyncdMutations + * @instance + */ + SyncdMutations.prototype.mutations = $util.emptyArray; + + /** + * Creates a new SyncdMutations instance using the specified properties. + * @function create + * @memberof proto.SyncdMutations + * @static + * @param {proto.ISyncdMutations=} [properties] Properties to set + * @returns {proto.SyncdMutations} SyncdMutations instance + */ + SyncdMutations.create = function create(properties) { + return new SyncdMutations(properties); + }; + + /** + * Encodes the specified SyncdMutations message. Does not implicitly {@link proto.SyncdMutations.verify|verify} messages. + * @function encode + * @memberof proto.SyncdMutations + * @static + * @param {proto.ISyncdMutations} message SyncdMutations message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncdMutations.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.mutations != null && message.mutations.length) + for (var i = 0; i < message.mutations.length; ++i) + $root.proto.SyncdMutation.encode(message.mutations[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified SyncdMutations message, length delimited. Does not implicitly {@link proto.SyncdMutations.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.SyncdMutations + * @static + * @param {proto.ISyncdMutations} message SyncdMutations message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncdMutations.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SyncdMutations message from the specified reader or buffer. + * @function decode + * @memberof proto.SyncdMutations + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.SyncdMutations} SyncdMutations + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncdMutations.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.SyncdMutations(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.mutations && message.mutations.length)) + message.mutations = []; + message.mutations.push($root.proto.SyncdMutation.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SyncdMutations message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.SyncdMutations + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.SyncdMutations} SyncdMutations + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncdMutations.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SyncdMutations message. + * @function verify + * @memberof proto.SyncdMutations + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SyncdMutations.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.mutations != null && message.hasOwnProperty("mutations")) { + if (!Array.isArray(message.mutations)) + return "mutations: array expected"; + for (var i = 0; i < message.mutations.length; ++i) { + var error = $root.proto.SyncdMutation.verify(message.mutations[i]); + if (error) + return "mutations." + error; + } + } + return null; + }; + + /** + * Creates a SyncdMutations message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.SyncdMutations + * @static + * @param {Object.} object Plain object + * @returns {proto.SyncdMutations} SyncdMutations + */ + SyncdMutations.fromObject = function fromObject(object) { + if (object instanceof $root.proto.SyncdMutations) + return object; + var message = new $root.proto.SyncdMutations(); + if (object.mutations) { + if (!Array.isArray(object.mutations)) + throw TypeError(".proto.SyncdMutations.mutations: array expected"); + message.mutations = []; + for (var i = 0; i < object.mutations.length; ++i) { + if (typeof object.mutations[i] !== "object") + throw TypeError(".proto.SyncdMutations.mutations: object expected"); + message.mutations[i] = $root.proto.SyncdMutation.fromObject(object.mutations[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a SyncdMutations message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.SyncdMutations + * @static + * @param {proto.SyncdMutations} message SyncdMutations + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SyncdMutations.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.mutations = []; + if (message.mutations && message.mutations.length) { + object.mutations = []; + for (var j = 0; j < message.mutations.length; ++j) + object.mutations[j] = $root.proto.SyncdMutation.toObject(message.mutations[j], options); + } + return object; + }; + + /** + * Converts this SyncdMutations to JSON. + * @function toJSON + * @memberof proto.SyncdMutations + * @instance + * @returns {Object.} JSON object + */ + SyncdMutations.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return SyncdMutations; + })(); + + proto.SyncdSnapshot = (function() { + + /** + * Properties of a SyncdSnapshot. + * @memberof proto + * @interface ISyncdSnapshot + * @property {proto.ISyncdVersion|null} [version] SyncdSnapshot version + * @property {Array.|null} [records] SyncdSnapshot records + * @property {Uint8Array|null} [mac] SyncdSnapshot mac + * @property {proto.IKeyId|null} [keyId] SyncdSnapshot keyId + */ + + /** + * Constructs a new SyncdSnapshot. + * @memberof proto + * @classdesc Represents a SyncdSnapshot. + * @implements ISyncdSnapshot + * @constructor + * @param {proto.ISyncdSnapshot=} [properties] Properties to set + */ + function SyncdSnapshot(properties) { + this.records = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SyncdSnapshot version. + * @member {proto.ISyncdVersion|null|undefined} version + * @memberof proto.SyncdSnapshot + * @instance + */ + SyncdSnapshot.prototype.version = null; + + /** + * SyncdSnapshot records. + * @member {Array.} records + * @memberof proto.SyncdSnapshot + * @instance + */ + SyncdSnapshot.prototype.records = $util.emptyArray; + + /** + * SyncdSnapshot mac. + * @member {Uint8Array} mac + * @memberof proto.SyncdSnapshot + * @instance + */ + SyncdSnapshot.prototype.mac = $util.newBuffer([]); + + /** + * SyncdSnapshot keyId. + * @member {proto.IKeyId|null|undefined} keyId + * @memberof proto.SyncdSnapshot + * @instance + */ + SyncdSnapshot.prototype.keyId = null; + + /** + * Creates a new SyncdSnapshot instance using the specified properties. + * @function create + * @memberof proto.SyncdSnapshot + * @static + * @param {proto.ISyncdSnapshot=} [properties] Properties to set + * @returns {proto.SyncdSnapshot} SyncdSnapshot instance + */ + SyncdSnapshot.create = function create(properties) { + return new SyncdSnapshot(properties); + }; + + /** + * Encodes the specified SyncdSnapshot message. Does not implicitly {@link proto.SyncdSnapshot.verify|verify} messages. + * @function encode + * @memberof proto.SyncdSnapshot + * @static + * @param {proto.ISyncdSnapshot} message SyncdSnapshot message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncdSnapshot.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.version != null && Object.hasOwnProperty.call(message, "version")) + $root.proto.SyncdVersion.encode(message.version, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.records != null && message.records.length) + for (var i = 0; i < message.records.length; ++i) + $root.proto.SyncdRecord.encode(message.records[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.mac != null && Object.hasOwnProperty.call(message, "mac")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.mac); + if (message.keyId != null && Object.hasOwnProperty.call(message, "keyId")) + $root.proto.KeyId.encode(message.keyId, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified SyncdSnapshot message, length delimited. Does not implicitly {@link proto.SyncdSnapshot.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.SyncdSnapshot + * @static + * @param {proto.ISyncdSnapshot} message SyncdSnapshot message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncdSnapshot.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SyncdSnapshot message from the specified reader or buffer. + * @function decode + * @memberof proto.SyncdSnapshot + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.SyncdSnapshot} SyncdSnapshot + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncdSnapshot.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.SyncdSnapshot(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.version = $root.proto.SyncdVersion.decode(reader, reader.uint32()); + break; + case 2: + if (!(message.records && message.records.length)) + message.records = []; + message.records.push($root.proto.SyncdRecord.decode(reader, reader.uint32())); + break; + case 3: + message.mac = reader.bytes(); + break; + case 4: + message.keyId = $root.proto.KeyId.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SyncdSnapshot message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.SyncdSnapshot + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.SyncdSnapshot} SyncdSnapshot + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncdSnapshot.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SyncdSnapshot message. + * @function verify + * @memberof proto.SyncdSnapshot + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SyncdSnapshot.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.version != null && message.hasOwnProperty("version")) { + var error = $root.proto.SyncdVersion.verify(message.version); + if (error) + return "version." + error; + } + if (message.records != null && message.hasOwnProperty("records")) { + if (!Array.isArray(message.records)) + return "records: array expected"; + for (var i = 0; i < message.records.length; ++i) { + var error = $root.proto.SyncdRecord.verify(message.records[i]); + if (error) + return "records." + error; + } + } + if (message.mac != null && message.hasOwnProperty("mac")) + if (!(message.mac && typeof message.mac.length === "number" || $util.isString(message.mac))) + return "mac: buffer expected"; + if (message.keyId != null && message.hasOwnProperty("keyId")) { + var error = $root.proto.KeyId.verify(message.keyId); + if (error) + return "keyId." + error; + } + return null; + }; + + /** + * Creates a SyncdSnapshot message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.SyncdSnapshot + * @static + * @param {Object.} object Plain object + * @returns {proto.SyncdSnapshot} SyncdSnapshot + */ + SyncdSnapshot.fromObject = function fromObject(object) { + if (object instanceof $root.proto.SyncdSnapshot) + return object; + var message = new $root.proto.SyncdSnapshot(); + if (object.version != null) { + if (typeof object.version !== "object") + throw TypeError(".proto.SyncdSnapshot.version: object expected"); + message.version = $root.proto.SyncdVersion.fromObject(object.version); + } + if (object.records) { + if (!Array.isArray(object.records)) + throw TypeError(".proto.SyncdSnapshot.records: array expected"); + message.records = []; + for (var i = 0; i < object.records.length; ++i) { + if (typeof object.records[i] !== "object") + throw TypeError(".proto.SyncdSnapshot.records: object expected"); + message.records[i] = $root.proto.SyncdRecord.fromObject(object.records[i]); + } + } + if (object.mac != null) + if (typeof object.mac === "string") + $util.base64.decode(object.mac, message.mac = $util.newBuffer($util.base64.length(object.mac)), 0); + else if (object.mac.length) + message.mac = object.mac; + if (object.keyId != null) { + if (typeof object.keyId !== "object") + throw TypeError(".proto.SyncdSnapshot.keyId: object expected"); + message.keyId = $root.proto.KeyId.fromObject(object.keyId); + } + return message; + }; + + /** + * Creates a plain object from a SyncdSnapshot message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.SyncdSnapshot + * @static + * @param {proto.SyncdSnapshot} message SyncdSnapshot + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SyncdSnapshot.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.records = []; + if (options.defaults) { + object.version = null; + if (options.bytes === String) + object.mac = ""; + else { + object.mac = []; + if (options.bytes !== Array) + object.mac = $util.newBuffer(object.mac); + } + object.keyId = null; + } + if (message.version != null && message.hasOwnProperty("version")) + object.version = $root.proto.SyncdVersion.toObject(message.version, options); + if (message.records && message.records.length) { + object.records = []; + for (var j = 0; j < message.records.length; ++j) + object.records[j] = $root.proto.SyncdRecord.toObject(message.records[j], options); + } + if (message.mac != null && message.hasOwnProperty("mac")) + object.mac = options.bytes === String ? $util.base64.encode(message.mac, 0, message.mac.length) : options.bytes === Array ? Array.prototype.slice.call(message.mac) : message.mac; + if (message.keyId != null && message.hasOwnProperty("keyId")) + object.keyId = $root.proto.KeyId.toObject(message.keyId, options); + return object; + }; + + /** + * Converts this SyncdSnapshot to JSON. + * @function toJSON + * @memberof proto.SyncdSnapshot + * @instance + * @returns {Object.} JSON object + */ + SyncdSnapshot.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return SyncdSnapshot; + })(); + + proto.ExternalBlobReference = (function() { + + /** + * Properties of an ExternalBlobReference. + * @memberof proto + * @interface IExternalBlobReference + * @property {Uint8Array|null} [mediaKey] ExternalBlobReference mediaKey + * @property {string|null} [directPath] ExternalBlobReference directPath + * @property {string|null} [handle] ExternalBlobReference handle + * @property {number|Long|null} [fileSizeBytes] ExternalBlobReference fileSizeBytes + * @property {Uint8Array|null} [fileSha256] ExternalBlobReference fileSha256 + * @property {Uint8Array|null} [fileEncSha256] ExternalBlobReference fileEncSha256 + */ + + /** + * Constructs a new ExternalBlobReference. + * @memberof proto + * @classdesc Represents an ExternalBlobReference. + * @implements IExternalBlobReference + * @constructor + * @param {proto.IExternalBlobReference=} [properties] Properties to set + */ + function ExternalBlobReference(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExternalBlobReference mediaKey. + * @member {Uint8Array} mediaKey + * @memberof proto.ExternalBlobReference + * @instance + */ + ExternalBlobReference.prototype.mediaKey = $util.newBuffer([]); + + /** + * ExternalBlobReference directPath. + * @member {string} directPath + * @memberof proto.ExternalBlobReference + * @instance + */ + ExternalBlobReference.prototype.directPath = ""; + + /** + * ExternalBlobReference handle. + * @member {string} handle + * @memberof proto.ExternalBlobReference + * @instance + */ + ExternalBlobReference.prototype.handle = ""; + + /** + * ExternalBlobReference fileSizeBytes. + * @member {number|Long} fileSizeBytes + * @memberof proto.ExternalBlobReference + * @instance + */ + ExternalBlobReference.prototype.fileSizeBytes = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * ExternalBlobReference fileSha256. + * @member {Uint8Array} fileSha256 + * @memberof proto.ExternalBlobReference + * @instance + */ + ExternalBlobReference.prototype.fileSha256 = $util.newBuffer([]); + + /** + * ExternalBlobReference fileEncSha256. + * @member {Uint8Array} fileEncSha256 + * @memberof proto.ExternalBlobReference + * @instance + */ + ExternalBlobReference.prototype.fileEncSha256 = $util.newBuffer([]); + + /** + * Creates a new ExternalBlobReference instance using the specified properties. + * @function create + * @memberof proto.ExternalBlobReference + * @static + * @param {proto.IExternalBlobReference=} [properties] Properties to set + * @returns {proto.ExternalBlobReference} ExternalBlobReference instance + */ + ExternalBlobReference.create = function create(properties) { + return new ExternalBlobReference(properties); + }; + + /** + * Encodes the specified ExternalBlobReference message. Does not implicitly {@link proto.ExternalBlobReference.verify|verify} messages. + * @function encode + * @memberof proto.ExternalBlobReference + * @static + * @param {proto.IExternalBlobReference} message ExternalBlobReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExternalBlobReference.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.mediaKey != null && Object.hasOwnProperty.call(message, "mediaKey")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.mediaKey); + if (message.directPath != null && Object.hasOwnProperty.call(message, "directPath")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.directPath); + if (message.handle != null && Object.hasOwnProperty.call(message, "handle")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.handle); + if (message.fileSizeBytes != null && Object.hasOwnProperty.call(message, "fileSizeBytes")) + writer.uint32(/* id 4, wireType 0 =*/32).uint64(message.fileSizeBytes); + if (message.fileSha256 != null && Object.hasOwnProperty.call(message, "fileSha256")) + writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.fileSha256); + if (message.fileEncSha256 != null && Object.hasOwnProperty.call(message, "fileEncSha256")) + writer.uint32(/* id 6, wireType 2 =*/50).bytes(message.fileEncSha256); + return writer; + }; + + /** + * Encodes the specified ExternalBlobReference message, length delimited. Does not implicitly {@link proto.ExternalBlobReference.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.ExternalBlobReference + * @static + * @param {proto.IExternalBlobReference} message ExternalBlobReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExternalBlobReference.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExternalBlobReference message from the specified reader or buffer. + * @function decode + * @memberof proto.ExternalBlobReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.ExternalBlobReference} ExternalBlobReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExternalBlobReference.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.ExternalBlobReference(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.mediaKey = reader.bytes(); + break; + case 2: + message.directPath = reader.string(); + break; + case 3: + message.handle = reader.string(); + break; + case 4: + message.fileSizeBytes = reader.uint64(); + break; + case 5: + message.fileSha256 = reader.bytes(); + break; + case 6: + message.fileEncSha256 = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExternalBlobReference message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.ExternalBlobReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.ExternalBlobReference} ExternalBlobReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExternalBlobReference.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExternalBlobReference message. + * @function verify + * @memberof proto.ExternalBlobReference + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExternalBlobReference.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.mediaKey != null && message.hasOwnProperty("mediaKey")) + if (!(message.mediaKey && typeof message.mediaKey.length === "number" || $util.isString(message.mediaKey))) + return "mediaKey: buffer expected"; + if (message.directPath != null && message.hasOwnProperty("directPath")) + if (!$util.isString(message.directPath)) + return "directPath: string expected"; + if (message.handle != null && message.hasOwnProperty("handle")) + if (!$util.isString(message.handle)) + return "handle: string expected"; + if (message.fileSizeBytes != null && message.hasOwnProperty("fileSizeBytes")) + if (!$util.isInteger(message.fileSizeBytes) && !(message.fileSizeBytes && $util.isInteger(message.fileSizeBytes.low) && $util.isInteger(message.fileSizeBytes.high))) + return "fileSizeBytes: integer|Long expected"; + if (message.fileSha256 != null && message.hasOwnProperty("fileSha256")) + if (!(message.fileSha256 && typeof message.fileSha256.length === "number" || $util.isString(message.fileSha256))) + return "fileSha256: buffer expected"; + if (message.fileEncSha256 != null && message.hasOwnProperty("fileEncSha256")) + if (!(message.fileEncSha256 && typeof message.fileEncSha256.length === "number" || $util.isString(message.fileEncSha256))) + return "fileEncSha256: buffer expected"; + return null; + }; + + /** + * Creates an ExternalBlobReference message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.ExternalBlobReference + * @static + * @param {Object.} object Plain object + * @returns {proto.ExternalBlobReference} ExternalBlobReference + */ + ExternalBlobReference.fromObject = function fromObject(object) { + if (object instanceof $root.proto.ExternalBlobReference) + return object; + var message = new $root.proto.ExternalBlobReference(); + if (object.mediaKey != null) + if (typeof object.mediaKey === "string") + $util.base64.decode(object.mediaKey, message.mediaKey = $util.newBuffer($util.base64.length(object.mediaKey)), 0); + else if (object.mediaKey.length) + message.mediaKey = object.mediaKey; + if (object.directPath != null) + message.directPath = String(object.directPath); + if (object.handle != null) + message.handle = String(object.handle); + if (object.fileSizeBytes != null) + if ($util.Long) + (message.fileSizeBytes = $util.Long.fromValue(object.fileSizeBytes)).unsigned = true; + else if (typeof object.fileSizeBytes === "string") + message.fileSizeBytes = parseInt(object.fileSizeBytes, 10); + else if (typeof object.fileSizeBytes === "number") + message.fileSizeBytes = object.fileSizeBytes; + else if (typeof object.fileSizeBytes === "object") + message.fileSizeBytes = new $util.LongBits(object.fileSizeBytes.low >>> 0, object.fileSizeBytes.high >>> 0).toNumber(true); + if (object.fileSha256 != null) + if (typeof object.fileSha256 === "string") + $util.base64.decode(object.fileSha256, message.fileSha256 = $util.newBuffer($util.base64.length(object.fileSha256)), 0); + else if (object.fileSha256.length) + message.fileSha256 = object.fileSha256; + if (object.fileEncSha256 != null) + if (typeof object.fileEncSha256 === "string") + $util.base64.decode(object.fileEncSha256, message.fileEncSha256 = $util.newBuffer($util.base64.length(object.fileEncSha256)), 0); + else if (object.fileEncSha256.length) + message.fileEncSha256 = object.fileEncSha256; + return message; + }; + + /** + * Creates a plain object from an ExternalBlobReference message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.ExternalBlobReference + * @static + * @param {proto.ExternalBlobReference} message ExternalBlobReference + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExternalBlobReference.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if (options.bytes === String) + object.mediaKey = ""; + else { + object.mediaKey = []; + if (options.bytes !== Array) + object.mediaKey = $util.newBuffer(object.mediaKey); + } + object.directPath = ""; + object.handle = ""; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.fileSizeBytes = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.fileSizeBytes = options.longs === String ? "0" : 0; + if (options.bytes === String) + object.fileSha256 = ""; + else { + object.fileSha256 = []; + if (options.bytes !== Array) + object.fileSha256 = $util.newBuffer(object.fileSha256); + } + if (options.bytes === String) + object.fileEncSha256 = ""; + else { + object.fileEncSha256 = []; + if (options.bytes !== Array) + object.fileEncSha256 = $util.newBuffer(object.fileEncSha256); + } + } + if (message.mediaKey != null && message.hasOwnProperty("mediaKey")) + object.mediaKey = options.bytes === String ? $util.base64.encode(message.mediaKey, 0, message.mediaKey.length) : options.bytes === Array ? Array.prototype.slice.call(message.mediaKey) : message.mediaKey; + if (message.directPath != null && message.hasOwnProperty("directPath")) + object.directPath = message.directPath; + if (message.handle != null && message.hasOwnProperty("handle")) + object.handle = message.handle; + if (message.fileSizeBytes != null && message.hasOwnProperty("fileSizeBytes")) + if (typeof message.fileSizeBytes === "number") + object.fileSizeBytes = options.longs === String ? String(message.fileSizeBytes) : message.fileSizeBytes; + else + object.fileSizeBytes = options.longs === String ? $util.Long.prototype.toString.call(message.fileSizeBytes) : options.longs === Number ? new $util.LongBits(message.fileSizeBytes.low >>> 0, message.fileSizeBytes.high >>> 0).toNumber(true) : message.fileSizeBytes; + if (message.fileSha256 != null && message.hasOwnProperty("fileSha256")) + object.fileSha256 = options.bytes === String ? $util.base64.encode(message.fileSha256, 0, message.fileSha256.length) : options.bytes === Array ? Array.prototype.slice.call(message.fileSha256) : message.fileSha256; + if (message.fileEncSha256 != null && message.hasOwnProperty("fileEncSha256")) + object.fileEncSha256 = options.bytes === String ? $util.base64.encode(message.fileEncSha256, 0, message.fileEncSha256.length) : options.bytes === Array ? Array.prototype.slice.call(message.fileEncSha256) : message.fileEncSha256; + return object; + }; + + /** + * Converts this ExternalBlobReference to JSON. + * @function toJSON + * @memberof proto.ExternalBlobReference + * @instance + * @returns {Object.} JSON object + */ + ExternalBlobReference.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ExternalBlobReference; + })(); + + proto.SyncdRecord = (function() { + + /** + * Properties of a SyncdRecord. + * @memberof proto + * @interface ISyncdRecord + * @property {proto.ISyncdIndex|null} [index] SyncdRecord index + * @property {proto.ISyncdValue|null} [value] SyncdRecord value + * @property {proto.IKeyId|null} [keyId] SyncdRecord keyId + */ + + /** + * Constructs a new SyncdRecord. + * @memberof proto + * @classdesc Represents a SyncdRecord. + * @implements ISyncdRecord + * @constructor + * @param {proto.ISyncdRecord=} [properties] Properties to set + */ + function SyncdRecord(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SyncdRecord index. + * @member {proto.ISyncdIndex|null|undefined} index + * @memberof proto.SyncdRecord + * @instance + */ + SyncdRecord.prototype.index = null; + + /** + * SyncdRecord value. + * @member {proto.ISyncdValue|null|undefined} value + * @memberof proto.SyncdRecord + * @instance + */ + SyncdRecord.prototype.value = null; + + /** + * SyncdRecord keyId. + * @member {proto.IKeyId|null|undefined} keyId + * @memberof proto.SyncdRecord + * @instance + */ + SyncdRecord.prototype.keyId = null; + + /** + * Creates a new SyncdRecord instance using the specified properties. + * @function create + * @memberof proto.SyncdRecord + * @static + * @param {proto.ISyncdRecord=} [properties] Properties to set + * @returns {proto.SyncdRecord} SyncdRecord instance + */ + SyncdRecord.create = function create(properties) { + return new SyncdRecord(properties); + }; + + /** + * Encodes the specified SyncdRecord message. Does not implicitly {@link proto.SyncdRecord.verify|verify} messages. + * @function encode + * @memberof proto.SyncdRecord + * @static + * @param {proto.ISyncdRecord} message SyncdRecord message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncdRecord.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.index != null && Object.hasOwnProperty.call(message, "index")) + $root.proto.SyncdIndex.encode(message.index, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + $root.proto.SyncdValue.encode(message.value, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.keyId != null && Object.hasOwnProperty.call(message, "keyId")) + $root.proto.KeyId.encode(message.keyId, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified SyncdRecord message, length delimited. Does not implicitly {@link proto.SyncdRecord.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.SyncdRecord + * @static + * @param {proto.ISyncdRecord} message SyncdRecord message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncdRecord.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SyncdRecord message from the specified reader or buffer. + * @function decode + * @memberof proto.SyncdRecord + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.SyncdRecord} SyncdRecord + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncdRecord.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.SyncdRecord(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.index = $root.proto.SyncdIndex.decode(reader, reader.uint32()); + break; + case 2: + message.value = $root.proto.SyncdValue.decode(reader, reader.uint32()); + break; + case 3: + message.keyId = $root.proto.KeyId.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SyncdRecord message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.SyncdRecord + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.SyncdRecord} SyncdRecord + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncdRecord.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SyncdRecord message. + * @function verify + * @memberof proto.SyncdRecord + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SyncdRecord.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.index != null && message.hasOwnProperty("index")) { + var error = $root.proto.SyncdIndex.verify(message.index); + if (error) + return "index." + error; + } + if (message.value != null && message.hasOwnProperty("value")) { + var error = $root.proto.SyncdValue.verify(message.value); + if (error) + return "value." + error; + } + if (message.keyId != null && message.hasOwnProperty("keyId")) { + var error = $root.proto.KeyId.verify(message.keyId); + if (error) + return "keyId." + error; + } + return null; + }; + + /** + * Creates a SyncdRecord message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.SyncdRecord + * @static + * @param {Object.} object Plain object + * @returns {proto.SyncdRecord} SyncdRecord + */ + SyncdRecord.fromObject = function fromObject(object) { + if (object instanceof $root.proto.SyncdRecord) + return object; + var message = new $root.proto.SyncdRecord(); + if (object.index != null) { + if (typeof object.index !== "object") + throw TypeError(".proto.SyncdRecord.index: object expected"); + message.index = $root.proto.SyncdIndex.fromObject(object.index); + } + if (object.value != null) { + if (typeof object.value !== "object") + throw TypeError(".proto.SyncdRecord.value: object expected"); + message.value = $root.proto.SyncdValue.fromObject(object.value); + } + if (object.keyId != null) { + if (typeof object.keyId !== "object") + throw TypeError(".proto.SyncdRecord.keyId: object expected"); + message.keyId = $root.proto.KeyId.fromObject(object.keyId); + } + return message; + }; + + /** + * Creates a plain object from a SyncdRecord message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.SyncdRecord + * @static + * @param {proto.SyncdRecord} message SyncdRecord + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SyncdRecord.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.index = null; + object.value = null; + object.keyId = null; + } + if (message.index != null && message.hasOwnProperty("index")) + object.index = $root.proto.SyncdIndex.toObject(message.index, options); + if (message.value != null && message.hasOwnProperty("value")) + object.value = $root.proto.SyncdValue.toObject(message.value, options); + if (message.keyId != null && message.hasOwnProperty("keyId")) + object.keyId = $root.proto.KeyId.toObject(message.keyId, options); + return object; + }; + + /** + * Converts this SyncdRecord to JSON. + * @function toJSON + * @memberof proto.SyncdRecord + * @instance + * @returns {Object.} JSON object + */ + SyncdRecord.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return SyncdRecord; + })(); + + proto.KeyId = (function() { + + /** + * Properties of a KeyId. + * @memberof proto + * @interface IKeyId + * @property {Uint8Array|null} [id] KeyId id + */ + + /** + * Constructs a new KeyId. + * @memberof proto + * @classdesc Represents a KeyId. + * @implements IKeyId + * @constructor + * @param {proto.IKeyId=} [properties] Properties to set + */ + function KeyId(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * KeyId id. + * @member {Uint8Array} id + * @memberof proto.KeyId + * @instance + */ + KeyId.prototype.id = $util.newBuffer([]); + + /** + * Creates a new KeyId instance using the specified properties. + * @function create + * @memberof proto.KeyId + * @static + * @param {proto.IKeyId=} [properties] Properties to set + * @returns {proto.KeyId} KeyId instance + */ + KeyId.create = function create(properties) { + return new KeyId(properties); + }; + + /** + * Encodes the specified KeyId message. Does not implicitly {@link proto.KeyId.verify|verify} messages. + * @function encode + * @memberof proto.KeyId + * @static + * @param {proto.IKeyId} message KeyId message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + KeyId.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.id); + return writer; + }; + + /** + * Encodes the specified KeyId message, length delimited. Does not implicitly {@link proto.KeyId.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.KeyId + * @static + * @param {proto.IKeyId} message KeyId message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + KeyId.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a KeyId message from the specified reader or buffer. + * @function decode + * @memberof proto.KeyId + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.KeyId} KeyId + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + KeyId.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.KeyId(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a KeyId message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.KeyId + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.KeyId} KeyId + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + KeyId.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a KeyId message. + * @function verify + * @memberof proto.KeyId + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + KeyId.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!(message.id && typeof message.id.length === "number" || $util.isString(message.id))) + return "id: buffer expected"; + return null; + }; + + /** + * Creates a KeyId message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.KeyId + * @static + * @param {Object.} object Plain object + * @returns {proto.KeyId} KeyId + */ + KeyId.fromObject = function fromObject(object) { + if (object instanceof $root.proto.KeyId) + return object; + var message = new $root.proto.KeyId(); + if (object.id != null) + if (typeof object.id === "string") + $util.base64.decode(object.id, message.id = $util.newBuffer($util.base64.length(object.id)), 0); + else if (object.id.length) + message.id = object.id; + return message; + }; + + /** + * Creates a plain object from a KeyId message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.KeyId + * @static + * @param {proto.KeyId} message KeyId + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + KeyId.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if (options.bytes === String) + object.id = ""; + else { + object.id = []; + if (options.bytes !== Array) + object.id = $util.newBuffer(object.id); + } + if (message.id != null && message.hasOwnProperty("id")) + object.id = options.bytes === String ? $util.base64.encode(message.id, 0, message.id.length) : options.bytes === Array ? Array.prototype.slice.call(message.id) : message.id; + return object; + }; + + /** + * Converts this KeyId to JSON. + * @function toJSON + * @memberof proto.KeyId + * @instance + * @returns {Object.} JSON object + */ + KeyId.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return KeyId; + })(); + + proto.SyncdValue = (function() { + + /** + * Properties of a SyncdValue. + * @memberof proto + * @interface ISyncdValue + * @property {Uint8Array|null} [blob] SyncdValue blob + */ + + /** + * Constructs a new SyncdValue. + * @memberof proto + * @classdesc Represents a SyncdValue. + * @implements ISyncdValue + * @constructor + * @param {proto.ISyncdValue=} [properties] Properties to set + */ + function SyncdValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SyncdValue blob. + * @member {Uint8Array} blob + * @memberof proto.SyncdValue + * @instance + */ + SyncdValue.prototype.blob = $util.newBuffer([]); + + /** + * Creates a new SyncdValue instance using the specified properties. + * @function create + * @memberof proto.SyncdValue + * @static + * @param {proto.ISyncdValue=} [properties] Properties to set + * @returns {proto.SyncdValue} SyncdValue instance + */ + SyncdValue.create = function create(properties) { + return new SyncdValue(properties); + }; + + /** + * Encodes the specified SyncdValue message. Does not implicitly {@link proto.SyncdValue.verify|verify} messages. + * @function encode + * @memberof proto.SyncdValue + * @static + * @param {proto.ISyncdValue} message SyncdValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncdValue.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.blob != null && Object.hasOwnProperty.call(message, "blob")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.blob); + return writer; + }; + + /** + * Encodes the specified SyncdValue message, length delimited. Does not implicitly {@link proto.SyncdValue.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.SyncdValue + * @static + * @param {proto.ISyncdValue} message SyncdValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncdValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SyncdValue message from the specified reader or buffer. + * @function decode + * @memberof proto.SyncdValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.SyncdValue} SyncdValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncdValue.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.SyncdValue(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blob = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SyncdValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.SyncdValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.SyncdValue} SyncdValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncdValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SyncdValue message. + * @function verify + * @memberof proto.SyncdValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SyncdValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.blob != null && message.hasOwnProperty("blob")) + if (!(message.blob && typeof message.blob.length === "number" || $util.isString(message.blob))) + return "blob: buffer expected"; + return null; + }; + + /** + * Creates a SyncdValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.SyncdValue + * @static + * @param {Object.} object Plain object + * @returns {proto.SyncdValue} SyncdValue + */ + SyncdValue.fromObject = function fromObject(object) { + if (object instanceof $root.proto.SyncdValue) + return object; + var message = new $root.proto.SyncdValue(); + if (object.blob != null) + if (typeof object.blob === "string") + $util.base64.decode(object.blob, message.blob = $util.newBuffer($util.base64.length(object.blob)), 0); + else if (object.blob.length) + message.blob = object.blob; + return message; + }; + + /** + * Creates a plain object from a SyncdValue message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.SyncdValue + * @static + * @param {proto.SyncdValue} message SyncdValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SyncdValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if (options.bytes === String) + object.blob = ""; + else { + object.blob = []; + if (options.bytes !== Array) + object.blob = $util.newBuffer(object.blob); + } + if (message.blob != null && message.hasOwnProperty("blob")) + object.blob = options.bytes === String ? $util.base64.encode(message.blob, 0, message.blob.length) : options.bytes === Array ? Array.prototype.slice.call(message.blob) : message.blob; + return object; + }; + + /** + * Converts this SyncdValue to JSON. + * @function toJSON + * @memberof proto.SyncdValue + * @instance + * @returns {Object.} JSON object + */ + SyncdValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return SyncdValue; + })(); + + proto.SyncdIndex = (function() { + + /** + * Properties of a SyncdIndex. + * @memberof proto + * @interface ISyncdIndex + * @property {Uint8Array|null} [blob] SyncdIndex blob + */ + + /** + * Constructs a new SyncdIndex. + * @memberof proto + * @classdesc Represents a SyncdIndex. + * @implements ISyncdIndex + * @constructor + * @param {proto.ISyncdIndex=} [properties] Properties to set + */ + function SyncdIndex(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SyncdIndex blob. + * @member {Uint8Array} blob + * @memberof proto.SyncdIndex + * @instance + */ + SyncdIndex.prototype.blob = $util.newBuffer([]); + + /** + * Creates a new SyncdIndex instance using the specified properties. + * @function create + * @memberof proto.SyncdIndex + * @static + * @param {proto.ISyncdIndex=} [properties] Properties to set + * @returns {proto.SyncdIndex} SyncdIndex instance + */ + SyncdIndex.create = function create(properties) { + return new SyncdIndex(properties); + }; + + /** + * Encodes the specified SyncdIndex message. Does not implicitly {@link proto.SyncdIndex.verify|verify} messages. + * @function encode + * @memberof proto.SyncdIndex + * @static + * @param {proto.ISyncdIndex} message SyncdIndex message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncdIndex.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.blob != null && Object.hasOwnProperty.call(message, "blob")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.blob); + return writer; + }; + + /** + * Encodes the specified SyncdIndex message, length delimited. Does not implicitly {@link proto.SyncdIndex.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.SyncdIndex + * @static + * @param {proto.ISyncdIndex} message SyncdIndex message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncdIndex.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SyncdIndex message from the specified reader or buffer. + * @function decode + * @memberof proto.SyncdIndex + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.SyncdIndex} SyncdIndex + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncdIndex.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.SyncdIndex(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blob = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SyncdIndex message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.SyncdIndex + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.SyncdIndex} SyncdIndex + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncdIndex.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SyncdIndex message. + * @function verify + * @memberof proto.SyncdIndex + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SyncdIndex.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.blob != null && message.hasOwnProperty("blob")) + if (!(message.blob && typeof message.blob.length === "number" || $util.isString(message.blob))) + return "blob: buffer expected"; + return null; + }; + + /** + * Creates a SyncdIndex message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.SyncdIndex + * @static + * @param {Object.} object Plain object + * @returns {proto.SyncdIndex} SyncdIndex + */ + SyncdIndex.fromObject = function fromObject(object) { + if (object instanceof $root.proto.SyncdIndex) + return object; + var message = new $root.proto.SyncdIndex(); + if (object.blob != null) + if (typeof object.blob === "string") + $util.base64.decode(object.blob, message.blob = $util.newBuffer($util.base64.length(object.blob)), 0); + else if (object.blob.length) + message.blob = object.blob; + return message; + }; + + /** + * Creates a plain object from a SyncdIndex message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.SyncdIndex + * @static + * @param {proto.SyncdIndex} message SyncdIndex + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SyncdIndex.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if (options.bytes === String) + object.blob = ""; + else { + object.blob = []; + if (options.bytes !== Array) + object.blob = $util.newBuffer(object.blob); + } + if (message.blob != null && message.hasOwnProperty("blob")) + object.blob = options.bytes === String ? $util.base64.encode(message.blob, 0, message.blob.length) : options.bytes === Array ? Array.prototype.slice.call(message.blob) : message.blob; + return object; + }; + + /** + * Converts this SyncdIndex to JSON. + * @function toJSON + * @memberof proto.SyncdIndex + * @instance + * @returns {Object.} JSON object + */ + SyncdIndex.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return SyncdIndex; + })(); + + proto.ExitCode = (function() { + + /** + * Properties of an ExitCode. + * @memberof proto + * @interface IExitCode + * @property {number|Long|null} [code] ExitCode code + * @property {string|null} [text] ExitCode text + */ + + /** + * Constructs a new ExitCode. + * @memberof proto + * @classdesc Represents an ExitCode. + * @implements IExitCode + * @constructor + * @param {proto.IExitCode=} [properties] Properties to set + */ + function ExitCode(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExitCode code. + * @member {number|Long} code + * @memberof proto.ExitCode + * @instance + */ + ExitCode.prototype.code = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * ExitCode text. + * @member {string} text + * @memberof proto.ExitCode + * @instance + */ + ExitCode.prototype.text = ""; + + /** + * Creates a new ExitCode instance using the specified properties. + * @function create + * @memberof proto.ExitCode + * @static + * @param {proto.IExitCode=} [properties] Properties to set + * @returns {proto.ExitCode} ExitCode instance + */ + ExitCode.create = function create(properties) { + return new ExitCode(properties); + }; + + /** + * Encodes the specified ExitCode message. Does not implicitly {@link proto.ExitCode.verify|verify} messages. + * @function encode + * @memberof proto.ExitCode + * @static + * @param {proto.IExitCode} message ExitCode message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExitCode.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.code != null && Object.hasOwnProperty.call(message, "code")) + writer.uint32(/* id 1, wireType 0 =*/8).uint64(message.code); + if (message.text != null && Object.hasOwnProperty.call(message, "text")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.text); + return writer; + }; + + /** + * Encodes the specified ExitCode message, length delimited. Does not implicitly {@link proto.ExitCode.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.ExitCode + * @static + * @param {proto.IExitCode} message ExitCode message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExitCode.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExitCode message from the specified reader or buffer. + * @function decode + * @memberof proto.ExitCode + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.ExitCode} ExitCode + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExitCode.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.ExitCode(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.code = reader.uint64(); + break; + case 2: + message.text = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExitCode message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.ExitCode + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.ExitCode} ExitCode + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExitCode.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExitCode message. + * @function verify + * @memberof proto.ExitCode + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExitCode.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.code != null && message.hasOwnProperty("code")) + if (!$util.isInteger(message.code) && !(message.code && $util.isInteger(message.code.low) && $util.isInteger(message.code.high))) + return "code: integer|Long expected"; + if (message.text != null && message.hasOwnProperty("text")) + if (!$util.isString(message.text)) + return "text: string expected"; + return null; + }; + + /** + * Creates an ExitCode message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.ExitCode + * @static + * @param {Object.} object Plain object + * @returns {proto.ExitCode} ExitCode + */ + ExitCode.fromObject = function fromObject(object) { + if (object instanceof $root.proto.ExitCode) + return object; + var message = new $root.proto.ExitCode(); + if (object.code != null) + if ($util.Long) + (message.code = $util.Long.fromValue(object.code)).unsigned = true; + else if (typeof object.code === "string") + message.code = parseInt(object.code, 10); + else if (typeof object.code === "number") + message.code = object.code; + else if (typeof object.code === "object") + message.code = new $util.LongBits(object.code.low >>> 0, object.code.high >>> 0).toNumber(true); + if (object.text != null) + message.text = String(object.text); + return message; + }; + + /** + * Creates a plain object from an ExitCode message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.ExitCode + * @static + * @param {proto.ExitCode} message ExitCode + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExitCode.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.code = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.code = options.longs === String ? "0" : 0; + object.text = ""; + } + if (message.code != null && message.hasOwnProperty("code")) + if (typeof message.code === "number") + object.code = options.longs === String ? String(message.code) : message.code; + else + object.code = options.longs === String ? $util.Long.prototype.toString.call(message.code) : options.longs === Number ? new $util.LongBits(message.code.low >>> 0, message.code.high >>> 0).toNumber(true) : message.code; + if (message.text != null && message.hasOwnProperty("text")) + object.text = message.text; + return object; + }; + + /** + * Converts this ExitCode to JSON. + * @function toJSON + * @memberof proto.ExitCode + * @instance + * @returns {Object.} JSON object + */ + ExitCode.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ExitCode; + })(); + + proto.SyncdVersion = (function() { + + /** + * Properties of a SyncdVersion. + * @memberof proto + * @interface ISyncdVersion + * @property {number|Long|null} [version] SyncdVersion version + */ + + /** + * Constructs a new SyncdVersion. + * @memberof proto + * @classdesc Represents a SyncdVersion. + * @implements ISyncdVersion + * @constructor + * @param {proto.ISyncdVersion=} [properties] Properties to set + */ + function SyncdVersion(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SyncdVersion version. + * @member {number|Long} version + * @memberof proto.SyncdVersion + * @instance + */ + SyncdVersion.prototype.version = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * Creates a new SyncdVersion instance using the specified properties. + * @function create + * @memberof proto.SyncdVersion + * @static + * @param {proto.ISyncdVersion=} [properties] Properties to set + * @returns {proto.SyncdVersion} SyncdVersion instance + */ + SyncdVersion.create = function create(properties) { + return new SyncdVersion(properties); + }; + + /** + * Encodes the specified SyncdVersion message. Does not implicitly {@link proto.SyncdVersion.verify|verify} messages. + * @function encode + * @memberof proto.SyncdVersion + * @static + * @param {proto.ISyncdVersion} message SyncdVersion message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncdVersion.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.version != null && Object.hasOwnProperty.call(message, "version")) + writer.uint32(/* id 1, wireType 0 =*/8).uint64(message.version); + return writer; + }; + + /** + * Encodes the specified SyncdVersion message, length delimited. Does not implicitly {@link proto.SyncdVersion.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.SyncdVersion + * @static + * @param {proto.ISyncdVersion} message SyncdVersion message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SyncdVersion.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SyncdVersion message from the specified reader or buffer. + * @function decode + * @memberof proto.SyncdVersion + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.SyncdVersion} SyncdVersion + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncdVersion.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.SyncdVersion(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.version = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SyncdVersion message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.SyncdVersion + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.SyncdVersion} SyncdVersion + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SyncdVersion.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SyncdVersion message. + * @function verify + * @memberof proto.SyncdVersion + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SyncdVersion.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.version != null && message.hasOwnProperty("version")) + if (!$util.isInteger(message.version) && !(message.version && $util.isInteger(message.version.low) && $util.isInteger(message.version.high))) + return "version: integer|Long expected"; + return null; + }; + + /** + * Creates a SyncdVersion message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.SyncdVersion + * @static + * @param {Object.} object Plain object + * @returns {proto.SyncdVersion} SyncdVersion + */ + SyncdVersion.fromObject = function fromObject(object) { + if (object instanceof $root.proto.SyncdVersion) + return object; + var message = new $root.proto.SyncdVersion(); + if (object.version != null) + if ($util.Long) + (message.version = $util.Long.fromValue(object.version)).unsigned = true; + else if (typeof object.version === "string") + message.version = parseInt(object.version, 10); + else if (typeof object.version === "number") + message.version = object.version; + else if (typeof object.version === "object") + message.version = new $util.LongBits(object.version.low >>> 0, object.version.high >>> 0).toNumber(true); + return message; + }; + + /** + * Creates a plain object from a SyncdVersion message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.SyncdVersion + * @static + * @param {proto.SyncdVersion} message SyncdVersion + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SyncdVersion.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.version = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.version = options.longs === String ? "0" : 0; + if (message.version != null && message.hasOwnProperty("version")) + if (typeof message.version === "number") + object.version = options.longs === String ? String(message.version) : message.version; + else + object.version = options.longs === String ? $util.Long.prototype.toString.call(message.version) : options.longs === Number ? new $util.LongBits(message.version.low >>> 0, message.version.high >>> 0).toNumber(true) : message.version; + return object; + }; + + /** + * Converts this SyncdVersion to JSON. + * @function toJSON + * @memberof proto.SyncdVersion + * @instance + * @returns {Object.} JSON object + */ + SyncdVersion.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return SyncdVersion; + })(); + + proto.ServerErrorReceipt = (function() { + + /** + * Properties of a ServerErrorReceipt. + * @memberof proto + * @interface IServerErrorReceipt + * @property {string|null} [stanzaId] ServerErrorReceipt stanzaId + */ + + /** + * Constructs a new ServerErrorReceipt. + * @memberof proto + * @classdesc Represents a ServerErrorReceipt. + * @implements IServerErrorReceipt + * @constructor + * @param {proto.IServerErrorReceipt=} [properties] Properties to set + */ + function ServerErrorReceipt(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ServerErrorReceipt stanzaId. + * @member {string} stanzaId + * @memberof proto.ServerErrorReceipt + * @instance + */ + ServerErrorReceipt.prototype.stanzaId = ""; + + /** + * Creates a new ServerErrorReceipt instance using the specified properties. + * @function create + * @memberof proto.ServerErrorReceipt + * @static + * @param {proto.IServerErrorReceipt=} [properties] Properties to set + * @returns {proto.ServerErrorReceipt} ServerErrorReceipt instance + */ + ServerErrorReceipt.create = function create(properties) { + return new ServerErrorReceipt(properties); + }; + + /** + * Encodes the specified ServerErrorReceipt message. Does not implicitly {@link proto.ServerErrorReceipt.verify|verify} messages. + * @function encode + * @memberof proto.ServerErrorReceipt + * @static + * @param {proto.IServerErrorReceipt} message ServerErrorReceipt message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServerErrorReceipt.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.stanzaId != null && Object.hasOwnProperty.call(message, "stanzaId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.stanzaId); + return writer; + }; + + /** + * Encodes the specified ServerErrorReceipt message, length delimited. Does not implicitly {@link proto.ServerErrorReceipt.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.ServerErrorReceipt + * @static + * @param {proto.IServerErrorReceipt} message ServerErrorReceipt message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServerErrorReceipt.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ServerErrorReceipt message from the specified reader or buffer. + * @function decode + * @memberof proto.ServerErrorReceipt + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.ServerErrorReceipt} ServerErrorReceipt + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServerErrorReceipt.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.ServerErrorReceipt(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.stanzaId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ServerErrorReceipt message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.ServerErrorReceipt + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.ServerErrorReceipt} ServerErrorReceipt + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServerErrorReceipt.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ServerErrorReceipt message. + * @function verify + * @memberof proto.ServerErrorReceipt + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ServerErrorReceipt.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.stanzaId != null && message.hasOwnProperty("stanzaId")) + if (!$util.isString(message.stanzaId)) + return "stanzaId: string expected"; + return null; + }; + + /** + * Creates a ServerErrorReceipt message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.ServerErrorReceipt + * @static + * @param {Object.} object Plain object + * @returns {proto.ServerErrorReceipt} ServerErrorReceipt + */ + ServerErrorReceipt.fromObject = function fromObject(object) { + if (object instanceof $root.proto.ServerErrorReceipt) + return object; + var message = new $root.proto.ServerErrorReceipt(); + if (object.stanzaId != null) + message.stanzaId = String(object.stanzaId); + return message; + }; + + /** + * Creates a plain object from a ServerErrorReceipt message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.ServerErrorReceipt + * @static + * @param {proto.ServerErrorReceipt} message ServerErrorReceipt + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ServerErrorReceipt.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.stanzaId = ""; + if (message.stanzaId != null && message.hasOwnProperty("stanzaId")) + object.stanzaId = message.stanzaId; + return object; + }; + + /** + * Converts this ServerErrorReceipt to JSON. + * @function toJSON + * @memberof proto.ServerErrorReceipt + * @instance + * @returns {Object.} JSON object + */ + ServerErrorReceipt.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ServerErrorReceipt; + })(); + + proto.MediaRetryNotification = (function() { + + /** + * Properties of a MediaRetryNotification. + * @memberof proto + * @interface IMediaRetryNotification + * @property {string|null} [stanzaId] MediaRetryNotification stanzaId + * @property {string|null} [directPath] MediaRetryNotification directPath + * @property {proto.MediaRetryNotification.MediaRetryNotificationResultType|null} [result] MediaRetryNotification result + */ + + /** + * Constructs a new MediaRetryNotification. + * @memberof proto + * @classdesc Represents a MediaRetryNotification. + * @implements IMediaRetryNotification + * @constructor + * @param {proto.IMediaRetryNotification=} [properties] Properties to set + */ + function MediaRetryNotification(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MediaRetryNotification stanzaId. + * @member {string} stanzaId + * @memberof proto.MediaRetryNotification + * @instance + */ + MediaRetryNotification.prototype.stanzaId = ""; + + /** + * MediaRetryNotification directPath. + * @member {string} directPath + * @memberof proto.MediaRetryNotification + * @instance + */ + MediaRetryNotification.prototype.directPath = ""; + + /** + * MediaRetryNotification result. + * @member {proto.MediaRetryNotification.MediaRetryNotificationResultType} result + * @memberof proto.MediaRetryNotification + * @instance + */ + MediaRetryNotification.prototype.result = 0; + + /** + * Creates a new MediaRetryNotification instance using the specified properties. + * @function create + * @memberof proto.MediaRetryNotification + * @static + * @param {proto.IMediaRetryNotification=} [properties] Properties to set + * @returns {proto.MediaRetryNotification} MediaRetryNotification instance + */ + MediaRetryNotification.create = function create(properties) { + return new MediaRetryNotification(properties); + }; + + /** + * Encodes the specified MediaRetryNotification message. Does not implicitly {@link proto.MediaRetryNotification.verify|verify} messages. + * @function encode + * @memberof proto.MediaRetryNotification + * @static + * @param {proto.IMediaRetryNotification} message MediaRetryNotification message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MediaRetryNotification.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.stanzaId != null && Object.hasOwnProperty.call(message, "stanzaId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.stanzaId); + if (message.directPath != null && Object.hasOwnProperty.call(message, "directPath")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.directPath); + if (message.result != null && Object.hasOwnProperty.call(message, "result")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.result); + return writer; + }; + + /** + * Encodes the specified MediaRetryNotification message, length delimited. Does not implicitly {@link proto.MediaRetryNotification.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.MediaRetryNotification + * @static + * @param {proto.IMediaRetryNotification} message MediaRetryNotification message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MediaRetryNotification.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MediaRetryNotification message from the specified reader or buffer. + * @function decode + * @memberof proto.MediaRetryNotification + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.MediaRetryNotification} MediaRetryNotification + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MediaRetryNotification.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.MediaRetryNotification(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.stanzaId = reader.string(); + break; + case 2: + message.directPath = reader.string(); + break; + case 3: + message.result = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MediaRetryNotification message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.MediaRetryNotification + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.MediaRetryNotification} MediaRetryNotification + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MediaRetryNotification.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MediaRetryNotification message. + * @function verify + * @memberof proto.MediaRetryNotification + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MediaRetryNotification.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.stanzaId != null && message.hasOwnProperty("stanzaId")) + if (!$util.isString(message.stanzaId)) + return "stanzaId: string expected"; + if (message.directPath != null && message.hasOwnProperty("directPath")) + if (!$util.isString(message.directPath)) + return "directPath: string expected"; + if (message.result != null && message.hasOwnProperty("result")) + switch (message.result) { + default: + return "result: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + return null; + }; + + /** + * Creates a MediaRetryNotification message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.MediaRetryNotification + * @static + * @param {Object.} object Plain object + * @returns {proto.MediaRetryNotification} MediaRetryNotification + */ + MediaRetryNotification.fromObject = function fromObject(object) { + if (object instanceof $root.proto.MediaRetryNotification) + return object; + var message = new $root.proto.MediaRetryNotification(); + if (object.stanzaId != null) + message.stanzaId = String(object.stanzaId); + if (object.directPath != null) + message.directPath = String(object.directPath); + switch (object.result) { + case "GENERAL_ERROR": + case 0: + message.result = 0; + break; + case "SUCCESS": + case 1: + message.result = 1; + break; + case "NOT_FOUND": + case 2: + message.result = 2; + break; + case "DECRYPTION_ERROR": + case 3: + message.result = 3; + break; + } + return message; + }; + + /** + * Creates a plain object from a MediaRetryNotification message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.MediaRetryNotification + * @static + * @param {proto.MediaRetryNotification} message MediaRetryNotification + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MediaRetryNotification.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.stanzaId = ""; + object.directPath = ""; + object.result = options.enums === String ? "GENERAL_ERROR" : 0; + } + if (message.stanzaId != null && message.hasOwnProperty("stanzaId")) + object.stanzaId = message.stanzaId; + if (message.directPath != null && message.hasOwnProperty("directPath")) + object.directPath = message.directPath; + if (message.result != null && message.hasOwnProperty("result")) + object.result = options.enums === String ? $root.proto.MediaRetryNotification.MediaRetryNotificationResultType[message.result] : message.result; + return object; + }; + + /** + * Converts this MediaRetryNotification to JSON. + * @function toJSON + * @memberof proto.MediaRetryNotification + * @instance + * @returns {Object.} JSON object + */ + MediaRetryNotification.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * MediaRetryNotificationResultType enum. + * @name proto.MediaRetryNotification.MediaRetryNotificationResultType + * @enum {number} + * @property {number} GENERAL_ERROR=0 GENERAL_ERROR value + * @property {number} SUCCESS=1 SUCCESS value + * @property {number} NOT_FOUND=2 NOT_FOUND value + * @property {number} DECRYPTION_ERROR=3 DECRYPTION_ERROR value + */ + MediaRetryNotification.MediaRetryNotificationResultType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "GENERAL_ERROR"] = 0; + values[valuesById[1] = "SUCCESS"] = 1; + values[valuesById[2] = "NOT_FOUND"] = 2; + values[valuesById[3] = "DECRYPTION_ERROR"] = 3; + return values; + })(); + + return MediaRetryNotification; + })(); + + proto.MsgOpaqueData = (function() { + + /** + * Properties of a MsgOpaqueData. + * @memberof proto + * @interface IMsgOpaqueData + * @property {string|null} [body] MsgOpaqueData body + * @property {string|null} [caption] MsgOpaqueData caption + * @property {string|null} [clientUrl] MsgOpaqueData clientUrl + * @property {number|null} [lng] MsgOpaqueData lng + * @property {number|null} [lat] MsgOpaqueData lat + * @property {number|null} [paymentAmount1000] MsgOpaqueData paymentAmount1000 + * @property {string|null} [paymentNoteMsgBody] MsgOpaqueData paymentNoteMsgBody + * @property {string|null} [canonicalUrl] MsgOpaqueData canonicalUrl + * @property {string|null} [matchedText] MsgOpaqueData matchedText + * @property {string|null} [title] MsgOpaqueData title + * @property {string|null} [description] MsgOpaqueData description + */ + + /** + * Constructs a new MsgOpaqueData. + * @memberof proto + * @classdesc Represents a MsgOpaqueData. + * @implements IMsgOpaqueData + * @constructor + * @param {proto.IMsgOpaqueData=} [properties] Properties to set + */ + function MsgOpaqueData(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MsgOpaqueData body. + * @member {string} body + * @memberof proto.MsgOpaqueData + * @instance + */ + MsgOpaqueData.prototype.body = ""; + + /** + * MsgOpaqueData caption. + * @member {string} caption + * @memberof proto.MsgOpaqueData + * @instance + */ + MsgOpaqueData.prototype.caption = ""; + + /** + * MsgOpaqueData clientUrl. + * @member {string} clientUrl + * @memberof proto.MsgOpaqueData + * @instance + */ + MsgOpaqueData.prototype.clientUrl = ""; + + /** + * MsgOpaqueData lng. + * @member {number} lng + * @memberof proto.MsgOpaqueData + * @instance + */ + MsgOpaqueData.prototype.lng = 0; + + /** + * MsgOpaqueData lat. + * @member {number} lat + * @memberof proto.MsgOpaqueData + * @instance + */ + MsgOpaqueData.prototype.lat = 0; + + /** + * MsgOpaqueData paymentAmount1000. + * @member {number} paymentAmount1000 + * @memberof proto.MsgOpaqueData + * @instance + */ + MsgOpaqueData.prototype.paymentAmount1000 = 0; + + /** + * MsgOpaqueData paymentNoteMsgBody. + * @member {string} paymentNoteMsgBody + * @memberof proto.MsgOpaqueData + * @instance + */ + MsgOpaqueData.prototype.paymentNoteMsgBody = ""; + + /** + * MsgOpaqueData canonicalUrl. + * @member {string} canonicalUrl + * @memberof proto.MsgOpaqueData + * @instance + */ + MsgOpaqueData.prototype.canonicalUrl = ""; + + /** + * MsgOpaqueData matchedText. + * @member {string} matchedText + * @memberof proto.MsgOpaqueData + * @instance + */ + MsgOpaqueData.prototype.matchedText = ""; + + /** + * MsgOpaqueData title. + * @member {string} title + * @memberof proto.MsgOpaqueData + * @instance + */ + MsgOpaqueData.prototype.title = ""; + + /** + * MsgOpaqueData description. + * @member {string} description + * @memberof proto.MsgOpaqueData + * @instance + */ + MsgOpaqueData.prototype.description = ""; + + /** + * Creates a new MsgOpaqueData instance using the specified properties. + * @function create + * @memberof proto.MsgOpaqueData + * @static + * @param {proto.IMsgOpaqueData=} [properties] Properties to set + * @returns {proto.MsgOpaqueData} MsgOpaqueData instance + */ + MsgOpaqueData.create = function create(properties) { + return new MsgOpaqueData(properties); + }; + + /** + * Encodes the specified MsgOpaqueData message. Does not implicitly {@link proto.MsgOpaqueData.verify|verify} messages. + * @function encode + * @memberof proto.MsgOpaqueData + * @static + * @param {proto.IMsgOpaqueData} message MsgOpaqueData message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MsgOpaqueData.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.body != null && Object.hasOwnProperty.call(message, "body")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.body); + if (message.caption != null && Object.hasOwnProperty.call(message, "caption")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.caption); + if (message.clientUrl != null && Object.hasOwnProperty.call(message, "clientUrl")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.clientUrl); + if (message.lng != null && Object.hasOwnProperty.call(message, "lng")) + writer.uint32(/* id 5, wireType 1 =*/41).double(message.lng); + if (message.lat != null && Object.hasOwnProperty.call(message, "lat")) + writer.uint32(/* id 7, wireType 1 =*/57).double(message.lat); + if (message.paymentAmount1000 != null && Object.hasOwnProperty.call(message, "paymentAmount1000")) + writer.uint32(/* id 8, wireType 0 =*/64).int32(message.paymentAmount1000); + if (message.paymentNoteMsgBody != null && Object.hasOwnProperty.call(message, "paymentNoteMsgBody")) + writer.uint32(/* id 9, wireType 2 =*/74).string(message.paymentNoteMsgBody); + if (message.canonicalUrl != null && Object.hasOwnProperty.call(message, "canonicalUrl")) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.canonicalUrl); + if (message.matchedText != null && Object.hasOwnProperty.call(message, "matchedText")) + writer.uint32(/* id 11, wireType 2 =*/90).string(message.matchedText); + if (message.title != null && Object.hasOwnProperty.call(message, "title")) + writer.uint32(/* id 12, wireType 2 =*/98).string(message.title); + if (message.description != null && Object.hasOwnProperty.call(message, "description")) + writer.uint32(/* id 13, wireType 2 =*/106).string(message.description); + return writer; + }; + + /** + * Encodes the specified MsgOpaqueData message, length delimited. Does not implicitly {@link proto.MsgOpaqueData.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.MsgOpaqueData + * @static + * @param {proto.IMsgOpaqueData} message MsgOpaqueData message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MsgOpaqueData.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MsgOpaqueData message from the specified reader or buffer. + * @function decode + * @memberof proto.MsgOpaqueData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.MsgOpaqueData} MsgOpaqueData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MsgOpaqueData.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.MsgOpaqueData(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.body = reader.string(); + break; + case 3: + message.caption = reader.string(); + break; + case 4: + message.clientUrl = reader.string(); + break; + case 5: + message.lng = reader.double(); + break; + case 7: + message.lat = reader.double(); + break; + case 8: + message.paymentAmount1000 = reader.int32(); + break; + case 9: + message.paymentNoteMsgBody = reader.string(); + break; + case 10: + message.canonicalUrl = reader.string(); + break; + case 11: + message.matchedText = reader.string(); + break; + case 12: + message.title = reader.string(); + break; + case 13: + message.description = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MsgOpaqueData message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.MsgOpaqueData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.MsgOpaqueData} MsgOpaqueData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MsgOpaqueData.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MsgOpaqueData message. + * @function verify + * @memberof proto.MsgOpaqueData + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MsgOpaqueData.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.body != null && message.hasOwnProperty("body")) + if (!$util.isString(message.body)) + return "body: string expected"; + if (message.caption != null && message.hasOwnProperty("caption")) + if (!$util.isString(message.caption)) + return "caption: string expected"; + if (message.clientUrl != null && message.hasOwnProperty("clientUrl")) + if (!$util.isString(message.clientUrl)) + return "clientUrl: string expected"; + if (message.lng != null && message.hasOwnProperty("lng")) + if (typeof message.lng !== "number") + return "lng: number expected"; + if (message.lat != null && message.hasOwnProperty("lat")) + if (typeof message.lat !== "number") + return "lat: number expected"; + if (message.paymentAmount1000 != null && message.hasOwnProperty("paymentAmount1000")) + if (!$util.isInteger(message.paymentAmount1000)) + return "paymentAmount1000: integer expected"; + if (message.paymentNoteMsgBody != null && message.hasOwnProperty("paymentNoteMsgBody")) + if (!$util.isString(message.paymentNoteMsgBody)) + return "paymentNoteMsgBody: string expected"; + if (message.canonicalUrl != null && message.hasOwnProperty("canonicalUrl")) + if (!$util.isString(message.canonicalUrl)) + return "canonicalUrl: string expected"; + if (message.matchedText != null && message.hasOwnProperty("matchedText")) + if (!$util.isString(message.matchedText)) + return "matchedText: string expected"; + if (message.title != null && message.hasOwnProperty("title")) + if (!$util.isString(message.title)) + return "title: string expected"; + if (message.description != null && message.hasOwnProperty("description")) + if (!$util.isString(message.description)) + return "description: string expected"; + return null; + }; + + /** + * Creates a MsgOpaqueData message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.MsgOpaqueData + * @static + * @param {Object.} object Plain object + * @returns {proto.MsgOpaqueData} MsgOpaqueData + */ + MsgOpaqueData.fromObject = function fromObject(object) { + if (object instanceof $root.proto.MsgOpaqueData) + return object; + var message = new $root.proto.MsgOpaqueData(); + if (object.body != null) + message.body = String(object.body); + if (object.caption != null) + message.caption = String(object.caption); + if (object.clientUrl != null) + message.clientUrl = String(object.clientUrl); + if (object.lng != null) + message.lng = Number(object.lng); + if (object.lat != null) + message.lat = Number(object.lat); + if (object.paymentAmount1000 != null) + message.paymentAmount1000 = object.paymentAmount1000 | 0; + if (object.paymentNoteMsgBody != null) + message.paymentNoteMsgBody = String(object.paymentNoteMsgBody); + if (object.canonicalUrl != null) + message.canonicalUrl = String(object.canonicalUrl); + if (object.matchedText != null) + message.matchedText = String(object.matchedText); + if (object.title != null) + message.title = String(object.title); + if (object.description != null) + message.description = String(object.description); + return message; + }; + + /** + * Creates a plain object from a MsgOpaqueData message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.MsgOpaqueData + * @static + * @param {proto.MsgOpaqueData} message MsgOpaqueData + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MsgOpaqueData.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.body = ""; + object.caption = ""; + object.clientUrl = ""; + object.lng = 0; + object.lat = 0; + object.paymentAmount1000 = 0; + object.paymentNoteMsgBody = ""; + object.canonicalUrl = ""; + object.matchedText = ""; + object.title = ""; + object.description = ""; + } + if (message.body != null && message.hasOwnProperty("body")) + object.body = message.body; + if (message.caption != null && message.hasOwnProperty("caption")) + object.caption = message.caption; + if (message.clientUrl != null && message.hasOwnProperty("clientUrl")) + object.clientUrl = message.clientUrl; + if (message.lng != null && message.hasOwnProperty("lng")) + object.lng = options.json && !isFinite(message.lng) ? String(message.lng) : message.lng; + if (message.lat != null && message.hasOwnProperty("lat")) + object.lat = options.json && !isFinite(message.lat) ? String(message.lat) : message.lat; + if (message.paymentAmount1000 != null && message.hasOwnProperty("paymentAmount1000")) + object.paymentAmount1000 = message.paymentAmount1000; + if (message.paymentNoteMsgBody != null && message.hasOwnProperty("paymentNoteMsgBody")) + object.paymentNoteMsgBody = message.paymentNoteMsgBody; + if (message.canonicalUrl != null && message.hasOwnProperty("canonicalUrl")) + object.canonicalUrl = message.canonicalUrl; + if (message.matchedText != null && message.hasOwnProperty("matchedText")) + object.matchedText = message.matchedText; + if (message.title != null && message.hasOwnProperty("title")) + object.title = message.title; + if (message.description != null && message.hasOwnProperty("description")) + object.description = message.description; + return object; + }; + + /** + * Converts this MsgOpaqueData to JSON. + * @function toJSON + * @memberof proto.MsgOpaqueData + * @instance + * @returns {Object.} JSON object + */ + MsgOpaqueData.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return MsgOpaqueData; + })(); + + proto.MsgRowOpaqueData = (function() { + + /** + * Properties of a MsgRowOpaqueData. + * @memberof proto + * @interface IMsgRowOpaqueData + * @property {proto.IMsgOpaqueData|null} [currentMsg] MsgRowOpaqueData currentMsg + * @property {proto.IMsgOpaqueData|null} [quotedMsg] MsgRowOpaqueData quotedMsg + */ + + /** + * Constructs a new MsgRowOpaqueData. + * @memberof proto + * @classdesc Represents a MsgRowOpaqueData. + * @implements IMsgRowOpaqueData + * @constructor + * @param {proto.IMsgRowOpaqueData=} [properties] Properties to set + */ + function MsgRowOpaqueData(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MsgRowOpaqueData currentMsg. + * @member {proto.IMsgOpaqueData|null|undefined} currentMsg + * @memberof proto.MsgRowOpaqueData + * @instance + */ + MsgRowOpaqueData.prototype.currentMsg = null; + + /** + * MsgRowOpaqueData quotedMsg. + * @member {proto.IMsgOpaqueData|null|undefined} quotedMsg + * @memberof proto.MsgRowOpaqueData + * @instance + */ + MsgRowOpaqueData.prototype.quotedMsg = null; + + /** + * Creates a new MsgRowOpaqueData instance using the specified properties. + * @function create + * @memberof proto.MsgRowOpaqueData + * @static + * @param {proto.IMsgRowOpaqueData=} [properties] Properties to set + * @returns {proto.MsgRowOpaqueData} MsgRowOpaqueData instance + */ + MsgRowOpaqueData.create = function create(properties) { + return new MsgRowOpaqueData(properties); + }; + + /** + * Encodes the specified MsgRowOpaqueData message. Does not implicitly {@link proto.MsgRowOpaqueData.verify|verify} messages. + * @function encode + * @memberof proto.MsgRowOpaqueData + * @static + * @param {proto.IMsgRowOpaqueData} message MsgRowOpaqueData message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MsgRowOpaqueData.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.currentMsg != null && Object.hasOwnProperty.call(message, "currentMsg")) + $root.proto.MsgOpaqueData.encode(message.currentMsg, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.quotedMsg != null && Object.hasOwnProperty.call(message, "quotedMsg")) + $root.proto.MsgOpaqueData.encode(message.quotedMsg, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified MsgRowOpaqueData message, length delimited. Does not implicitly {@link proto.MsgRowOpaqueData.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.MsgRowOpaqueData + * @static + * @param {proto.IMsgRowOpaqueData} message MsgRowOpaqueData message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MsgRowOpaqueData.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MsgRowOpaqueData message from the specified reader or buffer. + * @function decode + * @memberof proto.MsgRowOpaqueData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.MsgRowOpaqueData} MsgRowOpaqueData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MsgRowOpaqueData.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.MsgRowOpaqueData(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.currentMsg = $root.proto.MsgOpaqueData.decode(reader, reader.uint32()); + break; + case 2: + message.quotedMsg = $root.proto.MsgOpaqueData.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MsgRowOpaqueData message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.MsgRowOpaqueData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.MsgRowOpaqueData} MsgRowOpaqueData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MsgRowOpaqueData.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MsgRowOpaqueData message. + * @function verify + * @memberof proto.MsgRowOpaqueData + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MsgRowOpaqueData.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.currentMsg != null && message.hasOwnProperty("currentMsg")) { + var error = $root.proto.MsgOpaqueData.verify(message.currentMsg); + if (error) + return "currentMsg." + error; + } + if (message.quotedMsg != null && message.hasOwnProperty("quotedMsg")) { + var error = $root.proto.MsgOpaqueData.verify(message.quotedMsg); + if (error) + return "quotedMsg." + error; + } + return null; + }; + + /** + * Creates a MsgRowOpaqueData message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.MsgRowOpaqueData + * @static + * @param {Object.} object Plain object + * @returns {proto.MsgRowOpaqueData} MsgRowOpaqueData + */ + MsgRowOpaqueData.fromObject = function fromObject(object) { + if (object instanceof $root.proto.MsgRowOpaqueData) + return object; + var message = new $root.proto.MsgRowOpaqueData(); + if (object.currentMsg != null) { + if (typeof object.currentMsg !== "object") + throw TypeError(".proto.MsgRowOpaqueData.currentMsg: object expected"); + message.currentMsg = $root.proto.MsgOpaqueData.fromObject(object.currentMsg); + } + if (object.quotedMsg != null) { + if (typeof object.quotedMsg !== "object") + throw TypeError(".proto.MsgRowOpaqueData.quotedMsg: object expected"); + message.quotedMsg = $root.proto.MsgOpaqueData.fromObject(object.quotedMsg); + } + return message; + }; + + /** + * Creates a plain object from a MsgRowOpaqueData message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.MsgRowOpaqueData + * @static + * @param {proto.MsgRowOpaqueData} message MsgRowOpaqueData + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MsgRowOpaqueData.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.currentMsg = null; + object.quotedMsg = null; + } + if (message.currentMsg != null && message.hasOwnProperty("currentMsg")) + object.currentMsg = $root.proto.MsgOpaqueData.toObject(message.currentMsg, options); + if (message.quotedMsg != null && message.hasOwnProperty("quotedMsg")) + object.quotedMsg = $root.proto.MsgOpaqueData.toObject(message.quotedMsg, options); + return object; + }; + + /** + * Converts this MsgRowOpaqueData to JSON. + * @function toJSON + * @memberof proto.MsgRowOpaqueData + * @instance + * @returns {Object.} JSON object + */ + MsgRowOpaqueData.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return MsgRowOpaqueData; + })(); + + proto.Pushname = (function() { + + /** + * Properties of a Pushname. + * @memberof proto + * @interface IPushname + * @property {string|null} [id] Pushname id + * @property {string|null} [pushname] Pushname pushname + */ + + /** + * Constructs a new Pushname. + * @memberof proto + * @classdesc Represents a Pushname. + * @implements IPushname + * @constructor + * @param {proto.IPushname=} [properties] Properties to set + */ + function Pushname(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Pushname id. + * @member {string} id + * @memberof proto.Pushname + * @instance + */ + Pushname.prototype.id = ""; + + /** + * Pushname pushname. + * @member {string} pushname + * @memberof proto.Pushname + * @instance + */ + Pushname.prototype.pushname = ""; + + /** + * Creates a new Pushname instance using the specified properties. + * @function create + * @memberof proto.Pushname + * @static + * @param {proto.IPushname=} [properties] Properties to set + * @returns {proto.Pushname} Pushname instance + */ + Pushname.create = function create(properties) { + return new Pushname(properties); + }; + + /** + * Encodes the specified Pushname message. Does not implicitly {@link proto.Pushname.verify|verify} messages. + * @function encode + * @memberof proto.Pushname + * @static + * @param {proto.IPushname} message Pushname message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Pushname.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.id); + if (message.pushname != null && Object.hasOwnProperty.call(message, "pushname")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.pushname); + return writer; + }; + + /** + * Encodes the specified Pushname message, length delimited. Does not implicitly {@link proto.Pushname.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.Pushname + * @static + * @param {proto.IPushname} message Pushname message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Pushname.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Pushname message from the specified reader or buffer. + * @function decode + * @memberof proto.Pushname + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.Pushname} Pushname + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Pushname.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.Pushname(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.string(); + break; + case 2: + message.pushname = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Pushname message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.Pushname + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.Pushname} Pushname + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Pushname.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Pushname message. + * @function verify + * @memberof proto.Pushname + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Pushname.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isString(message.id)) + return "id: string expected"; + if (message.pushname != null && message.hasOwnProperty("pushname")) + if (!$util.isString(message.pushname)) + return "pushname: string expected"; + return null; + }; + + /** + * Creates a Pushname message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.Pushname + * @static + * @param {Object.} object Plain object + * @returns {proto.Pushname} Pushname + */ + Pushname.fromObject = function fromObject(object) { + if (object instanceof $root.proto.Pushname) + return object; + var message = new $root.proto.Pushname(); + if (object.id != null) + message.id = String(object.id); + if (object.pushname != null) + message.pushname = String(object.pushname); + return message; + }; + + /** + * Creates a plain object from a Pushname message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.Pushname + * @static + * @param {proto.Pushname} message Pushname + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Pushname.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.id = ""; + object.pushname = ""; + } + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + if (message.pushname != null && message.hasOwnProperty("pushname")) + object.pushname = message.pushname; + return object; + }; + + /** + * Converts this Pushname to JSON. + * @function toJSON + * @memberof proto.Pushname + * @instance + * @returns {Object.} JSON object + */ + Pushname.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Pushname; + })(); + + proto.HistorySyncMsg = (function() { + + /** + * Properties of a HistorySyncMsg. + * @memberof proto + * @interface IHistorySyncMsg + * @property {proto.IWebMessageInfo|null} [message] HistorySyncMsg message + * @property {number|Long|null} [msgOrderId] HistorySyncMsg msgOrderId + */ + + /** + * Constructs a new HistorySyncMsg. + * @memberof proto + * @classdesc Represents a HistorySyncMsg. + * @implements IHistorySyncMsg + * @constructor + * @param {proto.IHistorySyncMsg=} [properties] Properties to set + */ + function HistorySyncMsg(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * HistorySyncMsg message. + * @member {proto.IWebMessageInfo|null|undefined} message + * @memberof proto.HistorySyncMsg + * @instance + */ + HistorySyncMsg.prototype.message = null; + + /** + * HistorySyncMsg msgOrderId. + * @member {number|Long} msgOrderId + * @memberof proto.HistorySyncMsg + * @instance + */ + HistorySyncMsg.prototype.msgOrderId = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * Creates a new HistorySyncMsg instance using the specified properties. + * @function create + * @memberof proto.HistorySyncMsg + * @static + * @param {proto.IHistorySyncMsg=} [properties] Properties to set + * @returns {proto.HistorySyncMsg} HistorySyncMsg instance + */ + HistorySyncMsg.create = function create(properties) { + return new HistorySyncMsg(properties); + }; + + /** + * Encodes the specified HistorySyncMsg message. Does not implicitly {@link proto.HistorySyncMsg.verify|verify} messages. + * @function encode + * @memberof proto.HistorySyncMsg + * @static + * @param {proto.IHistorySyncMsg} message HistorySyncMsg message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HistorySyncMsg.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.message != null && Object.hasOwnProperty.call(message, "message")) + $root.proto.WebMessageInfo.encode(message.message, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.msgOrderId != null && Object.hasOwnProperty.call(message, "msgOrderId")) + writer.uint32(/* id 2, wireType 0 =*/16).uint64(message.msgOrderId); + return writer; + }; + + /** + * Encodes the specified HistorySyncMsg message, length delimited. Does not implicitly {@link proto.HistorySyncMsg.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.HistorySyncMsg + * @static + * @param {proto.IHistorySyncMsg} message HistorySyncMsg message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HistorySyncMsg.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a HistorySyncMsg message from the specified reader or buffer. + * @function decode + * @memberof proto.HistorySyncMsg + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.HistorySyncMsg} HistorySyncMsg + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HistorySyncMsg.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.HistorySyncMsg(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.message = $root.proto.WebMessageInfo.decode(reader, reader.uint32()); + break; + case 2: + message.msgOrderId = reader.uint64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a HistorySyncMsg message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.HistorySyncMsg + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.HistorySyncMsg} HistorySyncMsg + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HistorySyncMsg.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a HistorySyncMsg message. + * @function verify + * @memberof proto.HistorySyncMsg + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + HistorySyncMsg.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.message != null && message.hasOwnProperty("message")) { + var error = $root.proto.WebMessageInfo.verify(message.message); + if (error) + return "message." + error; + } + if (message.msgOrderId != null && message.hasOwnProperty("msgOrderId")) + if (!$util.isInteger(message.msgOrderId) && !(message.msgOrderId && $util.isInteger(message.msgOrderId.low) && $util.isInteger(message.msgOrderId.high))) + return "msgOrderId: integer|Long expected"; + return null; + }; + + /** + * Creates a HistorySyncMsg message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.HistorySyncMsg + * @static + * @param {Object.} object Plain object + * @returns {proto.HistorySyncMsg} HistorySyncMsg + */ + HistorySyncMsg.fromObject = function fromObject(object) { + if (object instanceof $root.proto.HistorySyncMsg) + return object; + var message = new $root.proto.HistorySyncMsg(); + if (object.message != null) { + if (typeof object.message !== "object") + throw TypeError(".proto.HistorySyncMsg.message: object expected"); + message.message = $root.proto.WebMessageInfo.fromObject(object.message); + } + if (object.msgOrderId != null) + if ($util.Long) + (message.msgOrderId = $util.Long.fromValue(object.msgOrderId)).unsigned = true; + else if (typeof object.msgOrderId === "string") + message.msgOrderId = parseInt(object.msgOrderId, 10); + else if (typeof object.msgOrderId === "number") + message.msgOrderId = object.msgOrderId; + else if (typeof object.msgOrderId === "object") + message.msgOrderId = new $util.LongBits(object.msgOrderId.low >>> 0, object.msgOrderId.high >>> 0).toNumber(true); + return message; + }; + + /** + * Creates a plain object from a HistorySyncMsg message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.HistorySyncMsg + * @static + * @param {proto.HistorySyncMsg} message HistorySyncMsg + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + HistorySyncMsg.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.message = null; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.msgOrderId = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.msgOrderId = options.longs === String ? "0" : 0; + } + if (message.message != null && message.hasOwnProperty("message")) + object.message = $root.proto.WebMessageInfo.toObject(message.message, options); + if (message.msgOrderId != null && message.hasOwnProperty("msgOrderId")) + if (typeof message.msgOrderId === "number") + object.msgOrderId = options.longs === String ? String(message.msgOrderId) : message.msgOrderId; + else + object.msgOrderId = options.longs === String ? $util.Long.prototype.toString.call(message.msgOrderId) : options.longs === Number ? new $util.LongBits(message.msgOrderId.low >>> 0, message.msgOrderId.high >>> 0).toNumber(true) : message.msgOrderId; + return object; + }; + + /** + * Converts this HistorySyncMsg to JSON. + * @function toJSON + * @memberof proto.HistorySyncMsg + * @instance + * @returns {Object.} JSON object + */ + HistorySyncMsg.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return HistorySyncMsg; + })(); + + proto.Conversation = (function() { + + /** + * Properties of a Conversation. + * @memberof proto + * @interface IConversation + * @property {string} id Conversation id + * @property {Array.|null} [messages] Conversation messages + * @property {string|null} [newJid] Conversation newJid + * @property {string|null} [oldJid] Conversation oldJid + * @property {number|Long|null} [lastMsgTimestamp] Conversation lastMsgTimestamp + * @property {number|null} [unreadCount] Conversation unreadCount + * @property {boolean|null} [readOnly] Conversation readOnly + * @property {boolean|null} [endOfHistoryTransfer] Conversation endOfHistoryTransfer + * @property {number|null} [ephemeralExpiration] Conversation ephemeralExpiration + * @property {number|Long|null} [ephemeralSettingTimestamp] Conversation ephemeralSettingTimestamp + * @property {proto.Conversation.ConversationEndOfHistoryTransferType|null} [endOfHistoryTransferType] Conversation endOfHistoryTransferType + * @property {number|Long|null} [conversationTimestamp] Conversation conversationTimestamp + * @property {string|null} [name] Conversation name + * @property {string|null} [pHash] Conversation pHash + * @property {boolean|null} [notSpam] Conversation notSpam + */ + + /** + * Constructs a new Conversation. + * @memberof proto + * @classdesc Represents a Conversation. + * @implements IConversation + * @constructor + * @param {proto.IConversation=} [properties] Properties to set + */ + function Conversation(properties) { + this.messages = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Conversation id. + * @member {string} id + * @memberof proto.Conversation + * @instance + */ + Conversation.prototype.id = ""; + + /** + * Conversation messages. + * @member {Array.} messages + * @memberof proto.Conversation + * @instance + */ + Conversation.prototype.messages = $util.emptyArray; + + /** + * Conversation newJid. + * @member {string} newJid + * @memberof proto.Conversation + * @instance + */ + Conversation.prototype.newJid = ""; + + /** + * Conversation oldJid. + * @member {string} oldJid + * @memberof proto.Conversation + * @instance + */ + Conversation.prototype.oldJid = ""; + + /** + * Conversation lastMsgTimestamp. + * @member {number|Long} lastMsgTimestamp + * @memberof proto.Conversation + * @instance + */ + Conversation.prototype.lastMsgTimestamp = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * Conversation unreadCount. + * @member {number} unreadCount + * @memberof proto.Conversation + * @instance + */ + Conversation.prototype.unreadCount = 0; + + /** + * Conversation readOnly. + * @member {boolean} readOnly + * @memberof proto.Conversation + * @instance + */ + Conversation.prototype.readOnly = false; + + /** + * Conversation endOfHistoryTransfer. + * @member {boolean} endOfHistoryTransfer + * @memberof proto.Conversation + * @instance + */ + Conversation.prototype.endOfHistoryTransfer = false; + + /** + * Conversation ephemeralExpiration. + * @member {number} ephemeralExpiration + * @memberof proto.Conversation + * @instance + */ + Conversation.prototype.ephemeralExpiration = 0; + + /** + * Conversation ephemeralSettingTimestamp. + * @member {number|Long} ephemeralSettingTimestamp + * @memberof proto.Conversation + * @instance + */ + Conversation.prototype.ephemeralSettingTimestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Conversation endOfHistoryTransferType. + * @member {proto.Conversation.ConversationEndOfHistoryTransferType} endOfHistoryTransferType + * @memberof proto.Conversation + * @instance + */ + Conversation.prototype.endOfHistoryTransferType = 0; + + /** + * Conversation conversationTimestamp. + * @member {number|Long} conversationTimestamp + * @memberof proto.Conversation + * @instance + */ + Conversation.prototype.conversationTimestamp = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * Conversation name. + * @member {string} name + * @memberof proto.Conversation + * @instance + */ + Conversation.prototype.name = ""; + + /** + * Conversation pHash. + * @member {string} pHash + * @memberof proto.Conversation + * @instance + */ + Conversation.prototype.pHash = ""; + + /** + * Conversation notSpam. + * @member {boolean} notSpam + * @memberof proto.Conversation + * @instance + */ + Conversation.prototype.notSpam = false; + + /** + * Creates a new Conversation instance using the specified properties. + * @function create + * @memberof proto.Conversation + * @static + * @param {proto.IConversation=} [properties] Properties to set + * @returns {proto.Conversation} Conversation instance + */ + Conversation.create = function create(properties) { + return new Conversation(properties); + }; + + /** + * Encodes the specified Conversation message. Does not implicitly {@link proto.Conversation.verify|verify} messages. + * @function encode + * @memberof proto.Conversation + * @static + * @param {proto.IConversation} message Conversation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Conversation.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + writer.uint32(/* id 1, wireType 2 =*/10).string(message.id); + if (message.messages != null && message.messages.length) + for (var i = 0; i < message.messages.length; ++i) + $root.proto.HistorySyncMsg.encode(message.messages[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.newJid != null && Object.hasOwnProperty.call(message, "newJid")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.newJid); + if (message.oldJid != null && Object.hasOwnProperty.call(message, "oldJid")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.oldJid); + if (message.lastMsgTimestamp != null && Object.hasOwnProperty.call(message, "lastMsgTimestamp")) + writer.uint32(/* id 5, wireType 0 =*/40).uint64(message.lastMsgTimestamp); + if (message.unreadCount != null && Object.hasOwnProperty.call(message, "unreadCount")) + writer.uint32(/* id 6, wireType 0 =*/48).uint32(message.unreadCount); + if (message.readOnly != null && Object.hasOwnProperty.call(message, "readOnly")) + writer.uint32(/* id 7, wireType 0 =*/56).bool(message.readOnly); + if (message.endOfHistoryTransfer != null && Object.hasOwnProperty.call(message, "endOfHistoryTransfer")) + writer.uint32(/* id 8, wireType 0 =*/64).bool(message.endOfHistoryTransfer); + if (message.ephemeralExpiration != null && Object.hasOwnProperty.call(message, "ephemeralExpiration")) + writer.uint32(/* id 9, wireType 0 =*/72).uint32(message.ephemeralExpiration); + if (message.ephemeralSettingTimestamp != null && Object.hasOwnProperty.call(message, "ephemeralSettingTimestamp")) + writer.uint32(/* id 10, wireType 0 =*/80).int64(message.ephemeralSettingTimestamp); + if (message.endOfHistoryTransferType != null && Object.hasOwnProperty.call(message, "endOfHistoryTransferType")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.endOfHistoryTransferType); + if (message.conversationTimestamp != null && Object.hasOwnProperty.call(message, "conversationTimestamp")) + writer.uint32(/* id 12, wireType 0 =*/96).uint64(message.conversationTimestamp); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 13, wireType 2 =*/106).string(message.name); + if (message.pHash != null && Object.hasOwnProperty.call(message, "pHash")) + writer.uint32(/* id 14, wireType 2 =*/114).string(message.pHash); + if (message.notSpam != null && Object.hasOwnProperty.call(message, "notSpam")) + writer.uint32(/* id 15, wireType 0 =*/120).bool(message.notSpam); + return writer; + }; + + /** + * Encodes the specified Conversation message, length delimited. Does not implicitly {@link proto.Conversation.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.Conversation + * @static + * @param {proto.IConversation} message Conversation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Conversation.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Conversation message from the specified reader or buffer. + * @function decode + * @memberof proto.Conversation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.Conversation} Conversation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Conversation.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.Conversation(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.string(); + break; + case 2: + if (!(message.messages && message.messages.length)) + message.messages = []; + message.messages.push($root.proto.HistorySyncMsg.decode(reader, reader.uint32())); + break; + case 3: + message.newJid = reader.string(); + break; + case 4: + message.oldJid = reader.string(); + break; + case 5: + message.lastMsgTimestamp = reader.uint64(); + break; + case 6: + message.unreadCount = reader.uint32(); + break; + case 7: + message.readOnly = reader.bool(); + break; + case 8: + message.endOfHistoryTransfer = reader.bool(); + break; + case 9: + message.ephemeralExpiration = reader.uint32(); + break; + case 10: + message.ephemeralSettingTimestamp = reader.int64(); + break; + case 11: + message.endOfHistoryTransferType = reader.int32(); + break; + case 12: + message.conversationTimestamp = reader.uint64(); + break; + case 13: + message.name = reader.string(); + break; + case 14: + message.pHash = reader.string(); + break; + case 15: + message.notSpam = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + if (!message.hasOwnProperty("id")) + throw $util.ProtocolError("missing required 'id'", { instance: message }); + return message; + }; + + /** + * Decodes a Conversation message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.Conversation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.Conversation} Conversation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Conversation.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Conversation message. + * @function verify + * @memberof proto.Conversation + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Conversation.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (!$util.isString(message.id)) + return "id: string expected"; + if (message.messages != null && message.hasOwnProperty("messages")) { + if (!Array.isArray(message.messages)) + return "messages: array expected"; + for (var i = 0; i < message.messages.length; ++i) { + var error = $root.proto.HistorySyncMsg.verify(message.messages[i]); + if (error) + return "messages." + error; + } + } + if (message.newJid != null && message.hasOwnProperty("newJid")) + if (!$util.isString(message.newJid)) + return "newJid: string expected"; + if (message.oldJid != null && message.hasOwnProperty("oldJid")) + if (!$util.isString(message.oldJid)) + return "oldJid: string expected"; + if (message.lastMsgTimestamp != null && message.hasOwnProperty("lastMsgTimestamp")) + if (!$util.isInteger(message.lastMsgTimestamp) && !(message.lastMsgTimestamp && $util.isInteger(message.lastMsgTimestamp.low) && $util.isInteger(message.lastMsgTimestamp.high))) + return "lastMsgTimestamp: integer|Long expected"; + if (message.unreadCount != null && message.hasOwnProperty("unreadCount")) + if (!$util.isInteger(message.unreadCount)) + return "unreadCount: integer expected"; + if (message.readOnly != null && message.hasOwnProperty("readOnly")) + if (typeof message.readOnly !== "boolean") + return "readOnly: boolean expected"; + if (message.endOfHistoryTransfer != null && message.hasOwnProperty("endOfHistoryTransfer")) + if (typeof message.endOfHistoryTransfer !== "boolean") + return "endOfHistoryTransfer: boolean expected"; + if (message.ephemeralExpiration != null && message.hasOwnProperty("ephemeralExpiration")) + if (!$util.isInteger(message.ephemeralExpiration)) + return "ephemeralExpiration: integer expected"; + if (message.ephemeralSettingTimestamp != null && message.hasOwnProperty("ephemeralSettingTimestamp")) + if (!$util.isInteger(message.ephemeralSettingTimestamp) && !(message.ephemeralSettingTimestamp && $util.isInteger(message.ephemeralSettingTimestamp.low) && $util.isInteger(message.ephemeralSettingTimestamp.high))) + return "ephemeralSettingTimestamp: integer|Long expected"; + if (message.endOfHistoryTransferType != null && message.hasOwnProperty("endOfHistoryTransferType")) + switch (message.endOfHistoryTransferType) { + default: + return "endOfHistoryTransferType: enum value expected"; + case 0: + case 1: + break; + } + if (message.conversationTimestamp != null && message.hasOwnProperty("conversationTimestamp")) + if (!$util.isInteger(message.conversationTimestamp) && !(message.conversationTimestamp && $util.isInteger(message.conversationTimestamp.low) && $util.isInteger(message.conversationTimestamp.high))) + return "conversationTimestamp: integer|Long expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.pHash != null && message.hasOwnProperty("pHash")) + if (!$util.isString(message.pHash)) + return "pHash: string expected"; + if (message.notSpam != null && message.hasOwnProperty("notSpam")) + if (typeof message.notSpam !== "boolean") + return "notSpam: boolean expected"; + return null; + }; + + /** + * Creates a Conversation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.Conversation + * @static + * @param {Object.} object Plain object + * @returns {proto.Conversation} Conversation + */ + Conversation.fromObject = function fromObject(object) { + if (object instanceof $root.proto.Conversation) + return object; + var message = new $root.proto.Conversation(); + if (object.id != null) + message.id = String(object.id); + if (object.messages) { + if (!Array.isArray(object.messages)) + throw TypeError(".proto.Conversation.messages: array expected"); + message.messages = []; + for (var i = 0; i < object.messages.length; ++i) { + if (typeof object.messages[i] !== "object") + throw TypeError(".proto.Conversation.messages: object expected"); + message.messages[i] = $root.proto.HistorySyncMsg.fromObject(object.messages[i]); + } + } + if (object.newJid != null) + message.newJid = String(object.newJid); + if (object.oldJid != null) + message.oldJid = String(object.oldJid); + if (object.lastMsgTimestamp != null) + if ($util.Long) + (message.lastMsgTimestamp = $util.Long.fromValue(object.lastMsgTimestamp)).unsigned = true; + else if (typeof object.lastMsgTimestamp === "string") + message.lastMsgTimestamp = parseInt(object.lastMsgTimestamp, 10); + else if (typeof object.lastMsgTimestamp === "number") + message.lastMsgTimestamp = object.lastMsgTimestamp; + else if (typeof object.lastMsgTimestamp === "object") + message.lastMsgTimestamp = new $util.LongBits(object.lastMsgTimestamp.low >>> 0, object.lastMsgTimestamp.high >>> 0).toNumber(true); + if (object.unreadCount != null) + message.unreadCount = object.unreadCount >>> 0; + if (object.readOnly != null) + message.readOnly = Boolean(object.readOnly); + if (object.endOfHistoryTransfer != null) + message.endOfHistoryTransfer = Boolean(object.endOfHistoryTransfer); + if (object.ephemeralExpiration != null) + message.ephemeralExpiration = object.ephemeralExpiration >>> 0; + if (object.ephemeralSettingTimestamp != null) + if ($util.Long) + (message.ephemeralSettingTimestamp = $util.Long.fromValue(object.ephemeralSettingTimestamp)).unsigned = false; + else if (typeof object.ephemeralSettingTimestamp === "string") + message.ephemeralSettingTimestamp = parseInt(object.ephemeralSettingTimestamp, 10); + else if (typeof object.ephemeralSettingTimestamp === "number") + message.ephemeralSettingTimestamp = object.ephemeralSettingTimestamp; + else if (typeof object.ephemeralSettingTimestamp === "object") + message.ephemeralSettingTimestamp = new $util.LongBits(object.ephemeralSettingTimestamp.low >>> 0, object.ephemeralSettingTimestamp.high >>> 0).toNumber(); + switch (object.endOfHistoryTransferType) { + case "COMPLETE_BUT_MORE_MESSAGES_REMAIN_ON_PRIMARY": + case 0: + message.endOfHistoryTransferType = 0; + break; + case "COMPLETE_AND_NO_MORE_MESSAGE_REMAIN_ON_PRIMARY": + case 1: + message.endOfHistoryTransferType = 1; + break; + } + if (object.conversationTimestamp != null) + if ($util.Long) + (message.conversationTimestamp = $util.Long.fromValue(object.conversationTimestamp)).unsigned = true; + else if (typeof object.conversationTimestamp === "string") + message.conversationTimestamp = parseInt(object.conversationTimestamp, 10); + else if (typeof object.conversationTimestamp === "number") + message.conversationTimestamp = object.conversationTimestamp; + else if (typeof object.conversationTimestamp === "object") + message.conversationTimestamp = new $util.LongBits(object.conversationTimestamp.low >>> 0, object.conversationTimestamp.high >>> 0).toNumber(true); + if (object.name != null) + message.name = String(object.name); + if (object.pHash != null) + message.pHash = String(object.pHash); + if (object.notSpam != null) + message.notSpam = Boolean(object.notSpam); + return message; + }; + + /** + * Creates a plain object from a Conversation message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.Conversation + * @static + * @param {proto.Conversation} message Conversation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Conversation.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.messages = []; + if (options.defaults) { + object.id = ""; + object.newJid = ""; + object.oldJid = ""; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.lastMsgTimestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.lastMsgTimestamp = options.longs === String ? "0" : 0; + object.unreadCount = 0; + object.readOnly = false; + object.endOfHistoryTransfer = false; + object.ephemeralExpiration = 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.ephemeralSettingTimestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.ephemeralSettingTimestamp = options.longs === String ? "0" : 0; + object.endOfHistoryTransferType = options.enums === String ? "COMPLETE_BUT_MORE_MESSAGES_REMAIN_ON_PRIMARY" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.conversationTimestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.conversationTimestamp = options.longs === String ? "0" : 0; + object.name = ""; + object.pHash = ""; + object.notSpam = false; + } + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + if (message.messages && message.messages.length) { + object.messages = []; + for (var j = 0; j < message.messages.length; ++j) + object.messages[j] = $root.proto.HistorySyncMsg.toObject(message.messages[j], options); + } + if (message.newJid != null && message.hasOwnProperty("newJid")) + object.newJid = message.newJid; + if (message.oldJid != null && message.hasOwnProperty("oldJid")) + object.oldJid = message.oldJid; + if (message.lastMsgTimestamp != null && message.hasOwnProperty("lastMsgTimestamp")) + if (typeof message.lastMsgTimestamp === "number") + object.lastMsgTimestamp = options.longs === String ? String(message.lastMsgTimestamp) : message.lastMsgTimestamp; + else + object.lastMsgTimestamp = options.longs === String ? $util.Long.prototype.toString.call(message.lastMsgTimestamp) : options.longs === Number ? new $util.LongBits(message.lastMsgTimestamp.low >>> 0, message.lastMsgTimestamp.high >>> 0).toNumber(true) : message.lastMsgTimestamp; + if (message.unreadCount != null && message.hasOwnProperty("unreadCount")) + object.unreadCount = message.unreadCount; + if (message.readOnly != null && message.hasOwnProperty("readOnly")) + object.readOnly = message.readOnly; + if (message.endOfHistoryTransfer != null && message.hasOwnProperty("endOfHistoryTransfer")) + object.endOfHistoryTransfer = message.endOfHistoryTransfer; + if (message.ephemeralExpiration != null && message.hasOwnProperty("ephemeralExpiration")) + object.ephemeralExpiration = message.ephemeralExpiration; + if (message.ephemeralSettingTimestamp != null && message.hasOwnProperty("ephemeralSettingTimestamp")) + if (typeof message.ephemeralSettingTimestamp === "number") + object.ephemeralSettingTimestamp = options.longs === String ? String(message.ephemeralSettingTimestamp) : message.ephemeralSettingTimestamp; + else + object.ephemeralSettingTimestamp = options.longs === String ? $util.Long.prototype.toString.call(message.ephemeralSettingTimestamp) : options.longs === Number ? new $util.LongBits(message.ephemeralSettingTimestamp.low >>> 0, message.ephemeralSettingTimestamp.high >>> 0).toNumber() : message.ephemeralSettingTimestamp; + if (message.endOfHistoryTransferType != null && message.hasOwnProperty("endOfHistoryTransferType")) + object.endOfHistoryTransferType = options.enums === String ? $root.proto.Conversation.ConversationEndOfHistoryTransferType[message.endOfHistoryTransferType] : message.endOfHistoryTransferType; + if (message.conversationTimestamp != null && message.hasOwnProperty("conversationTimestamp")) + if (typeof message.conversationTimestamp === "number") + object.conversationTimestamp = options.longs === String ? String(message.conversationTimestamp) : message.conversationTimestamp; + else + object.conversationTimestamp = options.longs === String ? $util.Long.prototype.toString.call(message.conversationTimestamp) : options.longs === Number ? new $util.LongBits(message.conversationTimestamp.low >>> 0, message.conversationTimestamp.high >>> 0).toNumber(true) : message.conversationTimestamp; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.pHash != null && message.hasOwnProperty("pHash")) + object.pHash = message.pHash; + if (message.notSpam != null && message.hasOwnProperty("notSpam")) + object.notSpam = message.notSpam; + return object; + }; + + /** + * Converts this Conversation to JSON. + * @function toJSON + * @memberof proto.Conversation + * @instance + * @returns {Object.} JSON object + */ + Conversation.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * ConversationEndOfHistoryTransferType enum. + * @name proto.Conversation.ConversationEndOfHistoryTransferType + * @enum {number} + * @property {number} COMPLETE_BUT_MORE_MESSAGES_REMAIN_ON_PRIMARY=0 COMPLETE_BUT_MORE_MESSAGES_REMAIN_ON_PRIMARY value + * @property {number} COMPLETE_AND_NO_MORE_MESSAGE_REMAIN_ON_PRIMARY=1 COMPLETE_AND_NO_MORE_MESSAGE_REMAIN_ON_PRIMARY value + */ + Conversation.ConversationEndOfHistoryTransferType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "COMPLETE_BUT_MORE_MESSAGES_REMAIN_ON_PRIMARY"] = 0; + values[valuesById[1] = "COMPLETE_AND_NO_MORE_MESSAGE_REMAIN_ON_PRIMARY"] = 1; + return values; + })(); + + return Conversation; + })(); + + proto.HistorySync = (function() { + + /** + * Properties of a HistorySync. + * @memberof proto + * @interface IHistorySync + * @property {proto.HistorySync.HistorySyncHistorySyncType} syncType HistorySync syncType + * @property {Array.|null} [conversations] HistorySync conversations + * @property {Array.|null} [statusV3Messages] HistorySync statusV3Messages + * @property {number|null} [chunkOrder] HistorySync chunkOrder + * @property {number|null} [progress] HistorySync progress + * @property {Array.|null} [pushnames] HistorySync pushnames + */ + + /** + * Constructs a new HistorySync. + * @memberof proto + * @classdesc Represents a HistorySync. + * @implements IHistorySync + * @constructor + * @param {proto.IHistorySync=} [properties] Properties to set + */ + function HistorySync(properties) { + this.conversations = []; + this.statusV3Messages = []; + this.pushnames = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * HistorySync syncType. + * @member {proto.HistorySync.HistorySyncHistorySyncType} syncType + * @memberof proto.HistorySync + * @instance + */ + HistorySync.prototype.syncType = 0; + + /** + * HistorySync conversations. + * @member {Array.} conversations + * @memberof proto.HistorySync + * @instance + */ + HistorySync.prototype.conversations = $util.emptyArray; + + /** + * HistorySync statusV3Messages. + * @member {Array.} statusV3Messages + * @memberof proto.HistorySync + * @instance + */ + HistorySync.prototype.statusV3Messages = $util.emptyArray; + + /** + * HistorySync chunkOrder. + * @member {number} chunkOrder + * @memberof proto.HistorySync + * @instance + */ + HistorySync.prototype.chunkOrder = 0; + + /** + * HistorySync progress. + * @member {number} progress + * @memberof proto.HistorySync + * @instance + */ + HistorySync.prototype.progress = 0; + + /** + * HistorySync pushnames. + * @member {Array.} pushnames + * @memberof proto.HistorySync + * @instance + */ + HistorySync.prototype.pushnames = $util.emptyArray; + + /** + * Creates a new HistorySync instance using the specified properties. + * @function create + * @memberof proto.HistorySync + * @static + * @param {proto.IHistorySync=} [properties] Properties to set + * @returns {proto.HistorySync} HistorySync instance + */ + HistorySync.create = function create(properties) { + return new HistorySync(properties); + }; + + /** + * Encodes the specified HistorySync message. Does not implicitly {@link proto.HistorySync.verify|verify} messages. + * @function encode + * @memberof proto.HistorySync + * @static + * @param {proto.IHistorySync} message HistorySync message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HistorySync.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.syncType); + if (message.conversations != null && message.conversations.length) + for (var i = 0; i < message.conversations.length; ++i) + $root.proto.Conversation.encode(message.conversations[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.statusV3Messages != null && message.statusV3Messages.length) + for (var i = 0; i < message.statusV3Messages.length; ++i) + $root.proto.WebMessageInfo.encode(message.statusV3Messages[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.chunkOrder != null && Object.hasOwnProperty.call(message, "chunkOrder")) + writer.uint32(/* id 5, wireType 0 =*/40).uint32(message.chunkOrder); + if (message.progress != null && Object.hasOwnProperty.call(message, "progress")) + writer.uint32(/* id 6, wireType 0 =*/48).uint32(message.progress); + if (message.pushnames != null && message.pushnames.length) + for (var i = 0; i < message.pushnames.length; ++i) + $root.proto.Pushname.encode(message.pushnames[i], writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified HistorySync message, length delimited. Does not implicitly {@link proto.HistorySync.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.HistorySync + * @static + * @param {proto.IHistorySync} message HistorySync message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HistorySync.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a HistorySync message from the specified reader or buffer. + * @function decode + * @memberof proto.HistorySync + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.HistorySync} HistorySync + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HistorySync.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.HistorySync(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.syncType = reader.int32(); + break; + case 2: + if (!(message.conversations && message.conversations.length)) + message.conversations = []; + message.conversations.push($root.proto.Conversation.decode(reader, reader.uint32())); + break; + case 3: + if (!(message.statusV3Messages && message.statusV3Messages.length)) + message.statusV3Messages = []; + message.statusV3Messages.push($root.proto.WebMessageInfo.decode(reader, reader.uint32())); + break; + case 5: + message.chunkOrder = reader.uint32(); + break; + case 6: + message.progress = reader.uint32(); + break; + case 7: + if (!(message.pushnames && message.pushnames.length)) + message.pushnames = []; + message.pushnames.push($root.proto.Pushname.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + if (!message.hasOwnProperty("syncType")) + throw $util.ProtocolError("missing required 'syncType'", { instance: message }); + return message; + }; + + /** + * Decodes a HistorySync message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.HistorySync + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.HistorySync} HistorySync + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HistorySync.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a HistorySync message. + * @function verify + * @memberof proto.HistorySync + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + HistorySync.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + switch (message.syncType) { + default: + return "syncType: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } + if (message.conversations != null && message.hasOwnProperty("conversations")) { + if (!Array.isArray(message.conversations)) + return "conversations: array expected"; + for (var i = 0; i < message.conversations.length; ++i) { + var error = $root.proto.Conversation.verify(message.conversations[i]); + if (error) + return "conversations." + error; + } + } + if (message.statusV3Messages != null && message.hasOwnProperty("statusV3Messages")) { + if (!Array.isArray(message.statusV3Messages)) + return "statusV3Messages: array expected"; + for (var i = 0; i < message.statusV3Messages.length; ++i) { + var error = $root.proto.WebMessageInfo.verify(message.statusV3Messages[i]); + if (error) + return "statusV3Messages." + error; + } + } + if (message.chunkOrder != null && message.hasOwnProperty("chunkOrder")) + if (!$util.isInteger(message.chunkOrder)) + return "chunkOrder: integer expected"; + if (message.progress != null && message.hasOwnProperty("progress")) + if (!$util.isInteger(message.progress)) + return "progress: integer expected"; + if (message.pushnames != null && message.hasOwnProperty("pushnames")) { + if (!Array.isArray(message.pushnames)) + return "pushnames: array expected"; + for (var i = 0; i < message.pushnames.length; ++i) { + var error = $root.proto.Pushname.verify(message.pushnames[i]); + if (error) + return "pushnames." + error; + } + } + return null; + }; + + /** + * Creates a HistorySync message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.HistorySync + * @static + * @param {Object.} object Plain object + * @returns {proto.HistorySync} HistorySync + */ + HistorySync.fromObject = function fromObject(object) { + if (object instanceof $root.proto.HistorySync) + return object; + var message = new $root.proto.HistorySync(); + switch (object.syncType) { + case "INITIAL_BOOTSTRAP": + case 0: + message.syncType = 0; + break; + case "INITIAL_STATUS_V3": + case 1: + message.syncType = 1; + break; + case "FULL": + case 2: + message.syncType = 2; + break; + case "RECENT": + case 3: + message.syncType = 3; + break; + case "PUSH_NAME": + case 4: + message.syncType = 4; + break; + } + if (object.conversations) { + if (!Array.isArray(object.conversations)) + throw TypeError(".proto.HistorySync.conversations: array expected"); + message.conversations = []; + for (var i = 0; i < object.conversations.length; ++i) { + if (typeof object.conversations[i] !== "object") + throw TypeError(".proto.HistorySync.conversations: object expected"); + message.conversations[i] = $root.proto.Conversation.fromObject(object.conversations[i]); + } + } + if (object.statusV3Messages) { + if (!Array.isArray(object.statusV3Messages)) + throw TypeError(".proto.HistorySync.statusV3Messages: array expected"); + message.statusV3Messages = []; + for (var i = 0; i < object.statusV3Messages.length; ++i) { + if (typeof object.statusV3Messages[i] !== "object") + throw TypeError(".proto.HistorySync.statusV3Messages: object expected"); + message.statusV3Messages[i] = $root.proto.WebMessageInfo.fromObject(object.statusV3Messages[i]); + } + } + if (object.chunkOrder != null) + message.chunkOrder = object.chunkOrder >>> 0; + if (object.progress != null) + message.progress = object.progress >>> 0; + if (object.pushnames) { + if (!Array.isArray(object.pushnames)) + throw TypeError(".proto.HistorySync.pushnames: array expected"); + message.pushnames = []; + for (var i = 0; i < object.pushnames.length; ++i) { + if (typeof object.pushnames[i] !== "object") + throw TypeError(".proto.HistorySync.pushnames: object expected"); + message.pushnames[i] = $root.proto.Pushname.fromObject(object.pushnames[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a HistorySync message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.HistorySync + * @static + * @param {proto.HistorySync} message HistorySync + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + HistorySync.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.conversations = []; + object.statusV3Messages = []; + object.pushnames = []; + } + if (options.defaults) { + object.syncType = options.enums === String ? "INITIAL_BOOTSTRAP" : 0; + object.chunkOrder = 0; + object.progress = 0; + } + if (message.syncType != null && message.hasOwnProperty("syncType")) + object.syncType = options.enums === String ? $root.proto.HistorySync.HistorySyncHistorySyncType[message.syncType] : message.syncType; + if (message.conversations && message.conversations.length) { + object.conversations = []; + for (var j = 0; j < message.conversations.length; ++j) + object.conversations[j] = $root.proto.Conversation.toObject(message.conversations[j], options); + } + if (message.statusV3Messages && message.statusV3Messages.length) { + object.statusV3Messages = []; + for (var j = 0; j < message.statusV3Messages.length; ++j) + object.statusV3Messages[j] = $root.proto.WebMessageInfo.toObject(message.statusV3Messages[j], options); + } + if (message.chunkOrder != null && message.hasOwnProperty("chunkOrder")) + object.chunkOrder = message.chunkOrder; + if (message.progress != null && message.hasOwnProperty("progress")) + object.progress = message.progress; + if (message.pushnames && message.pushnames.length) { + object.pushnames = []; + for (var j = 0; j < message.pushnames.length; ++j) + object.pushnames[j] = $root.proto.Pushname.toObject(message.pushnames[j], options); + } + return object; + }; + + /** + * Converts this HistorySync to JSON. + * @function toJSON + * @memberof proto.HistorySync + * @instance + * @returns {Object.} JSON object + */ + HistorySync.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * HistorySyncHistorySyncType enum. + * @name proto.HistorySync.HistorySyncHistorySyncType + * @enum {number} + * @property {number} INITIAL_BOOTSTRAP=0 INITIAL_BOOTSTRAP value + * @property {number} INITIAL_STATUS_V3=1 INITIAL_STATUS_V3 value + * @property {number} FULL=2 FULL value + * @property {number} RECENT=3 RECENT value + * @property {number} PUSH_NAME=4 PUSH_NAME value + */ + HistorySync.HistorySyncHistorySyncType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "INITIAL_BOOTSTRAP"] = 0; + values[valuesById[1] = "INITIAL_STATUS_V3"] = 1; + values[valuesById[2] = "FULL"] = 2; + values[valuesById[3] = "RECENT"] = 3; + values[valuesById[4] = "PUSH_NAME"] = 4; + return values; + })(); + + return HistorySync; + })(); + + proto.EphemeralSetting = (function() { + + /** + * Properties of an EphemeralSetting. + * @memberof proto + * @interface IEphemeralSetting + * @property {number|null} [duration] EphemeralSetting duration + * @property {number|Long|null} [timestamp] EphemeralSetting timestamp + */ + + /** + * Constructs a new EphemeralSetting. + * @memberof proto + * @classdesc Represents an EphemeralSetting. + * @implements IEphemeralSetting + * @constructor + * @param {proto.IEphemeralSetting=} [properties] Properties to set + */ + function EphemeralSetting(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EphemeralSetting duration. + * @member {number} duration + * @memberof proto.EphemeralSetting + * @instance + */ + EphemeralSetting.prototype.duration = 0; + + /** + * EphemeralSetting timestamp. + * @member {number|Long} timestamp + * @memberof proto.EphemeralSetting + * @instance + */ + EphemeralSetting.prototype.timestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new EphemeralSetting instance using the specified properties. + * @function create + * @memberof proto.EphemeralSetting + * @static + * @param {proto.IEphemeralSetting=} [properties] Properties to set + * @returns {proto.EphemeralSetting} EphemeralSetting instance + */ + EphemeralSetting.create = function create(properties) { + return new EphemeralSetting(properties); + }; + + /** + * Encodes the specified EphemeralSetting message. Does not implicitly {@link proto.EphemeralSetting.verify|verify} messages. + * @function encode + * @memberof proto.EphemeralSetting + * @static + * @param {proto.IEphemeralSetting} message EphemeralSetting message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EphemeralSetting.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.duration != null && Object.hasOwnProperty.call(message, "duration")) + writer.uint32(/* id 1, wireType 5 =*/13).sfixed32(message.duration); + if (message.timestamp != null && Object.hasOwnProperty.call(message, "timestamp")) + writer.uint32(/* id 2, wireType 1 =*/17).sfixed64(message.timestamp); + return writer; + }; + + /** + * Encodes the specified EphemeralSetting message, length delimited. Does not implicitly {@link proto.EphemeralSetting.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.EphemeralSetting + * @static + * @param {proto.IEphemeralSetting} message EphemeralSetting message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EphemeralSetting.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EphemeralSetting message from the specified reader or buffer. + * @function decode + * @memberof proto.EphemeralSetting + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.EphemeralSetting} EphemeralSetting + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EphemeralSetting.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.EphemeralSetting(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.duration = reader.sfixed32(); + break; + case 2: + message.timestamp = reader.sfixed64(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EphemeralSetting message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.EphemeralSetting + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.EphemeralSetting} EphemeralSetting + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EphemeralSetting.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EphemeralSetting message. + * @function verify + * @memberof proto.EphemeralSetting + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EphemeralSetting.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.duration != null && message.hasOwnProperty("duration")) + if (!$util.isInteger(message.duration)) + return "duration: integer expected"; + if (message.timestamp != null && message.hasOwnProperty("timestamp")) + if (!$util.isInteger(message.timestamp) && !(message.timestamp && $util.isInteger(message.timestamp.low) && $util.isInteger(message.timestamp.high))) + return "timestamp: integer|Long expected"; + return null; + }; + + /** + * Creates an EphemeralSetting message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.EphemeralSetting + * @static + * @param {Object.} object Plain object + * @returns {proto.EphemeralSetting} EphemeralSetting + */ + EphemeralSetting.fromObject = function fromObject(object) { + if (object instanceof $root.proto.EphemeralSetting) + return object; + var message = new $root.proto.EphemeralSetting(); + if (object.duration != null) + message.duration = object.duration | 0; + if (object.timestamp != null) + if ($util.Long) + (message.timestamp = $util.Long.fromValue(object.timestamp)).unsigned = false; + else if (typeof object.timestamp === "string") + message.timestamp = parseInt(object.timestamp, 10); + else if (typeof object.timestamp === "number") + message.timestamp = object.timestamp; + else if (typeof object.timestamp === "object") + message.timestamp = new $util.LongBits(object.timestamp.low >>> 0, object.timestamp.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from an EphemeralSetting message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.EphemeralSetting + * @static + * @param {proto.EphemeralSetting} message EphemeralSetting + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EphemeralSetting.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.duration = 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.timestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.timestamp = options.longs === String ? "0" : 0; + } + if (message.duration != null && message.hasOwnProperty("duration")) + object.duration = message.duration; + if (message.timestamp != null && message.hasOwnProperty("timestamp")) + if (typeof message.timestamp === "number") + object.timestamp = options.longs === String ? String(message.timestamp) : message.timestamp; + else + object.timestamp = options.longs === String ? $util.Long.prototype.toString.call(message.timestamp) : options.longs === Number ? new $util.LongBits(message.timestamp.low >>> 0, message.timestamp.high >>> 0).toNumber() : message.timestamp; + return object; + }; + + /** + * Converts this EphemeralSetting to JSON. + * @function toJSON + * @memberof proto.EphemeralSetting + * @instance + * @returns {Object.} JSON object + */ + EphemeralSetting.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return EphemeralSetting; + })(); + + proto.PaymentBackground = (function() { + + /** + * Properties of a PaymentBackground. + * @memberof proto + * @interface IPaymentBackground + * @property {string|null} [id] PaymentBackground id + * @property {string|null} [fileLength] PaymentBackground fileLength + * @property {number|null} [width] PaymentBackground width + * @property {number|null} [height] PaymentBackground height + * @property {string|null} [mimetype] PaymentBackground mimetype + * @property {number|null} [placeholderArgb] PaymentBackground placeholderArgb + * @property {number|null} [textArgb] PaymentBackground textArgb + * @property {number|null} [subtextArgb] PaymentBackground subtextArgb + */ + + /** + * Constructs a new PaymentBackground. + * @memberof proto + * @classdesc Represents a PaymentBackground. + * @implements IPaymentBackground + * @constructor + * @param {proto.IPaymentBackground=} [properties] Properties to set + */ + function PaymentBackground(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * PaymentBackground id. + * @member {string} id + * @memberof proto.PaymentBackground + * @instance + */ + PaymentBackground.prototype.id = ""; + + /** + * PaymentBackground fileLength. + * @member {string} fileLength + * @memberof proto.PaymentBackground + * @instance + */ + PaymentBackground.prototype.fileLength = ""; + + /** + * PaymentBackground width. + * @member {number} width + * @memberof proto.PaymentBackground + * @instance + */ + PaymentBackground.prototype.width = 0; + + /** + * PaymentBackground height. + * @member {number} height + * @memberof proto.PaymentBackground + * @instance + */ + PaymentBackground.prototype.height = 0; + + /** + * PaymentBackground mimetype. + * @member {string} mimetype + * @memberof proto.PaymentBackground + * @instance + */ + PaymentBackground.prototype.mimetype = ""; + + /** + * PaymentBackground placeholderArgb. + * @member {number} placeholderArgb + * @memberof proto.PaymentBackground + * @instance + */ + PaymentBackground.prototype.placeholderArgb = 0; + + /** + * PaymentBackground textArgb. + * @member {number} textArgb + * @memberof proto.PaymentBackground + * @instance + */ + PaymentBackground.prototype.textArgb = 0; + + /** + * PaymentBackground subtextArgb. + * @member {number} subtextArgb + * @memberof proto.PaymentBackground + * @instance + */ + PaymentBackground.prototype.subtextArgb = 0; + + /** + * Creates a new PaymentBackground instance using the specified properties. + * @function create + * @memberof proto.PaymentBackground + * @static + * @param {proto.IPaymentBackground=} [properties] Properties to set + * @returns {proto.PaymentBackground} PaymentBackground instance + */ + PaymentBackground.create = function create(properties) { + return new PaymentBackground(properties); + }; + + /** + * Encodes the specified PaymentBackground message. Does not implicitly {@link proto.PaymentBackground.verify|verify} messages. + * @function encode + * @memberof proto.PaymentBackground + * @static + * @param {proto.IPaymentBackground} message PaymentBackground message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PaymentBackground.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.id); + if (message.fileLength != null && Object.hasOwnProperty.call(message, "fileLength")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.fileLength); + if (message.width != null && Object.hasOwnProperty.call(message, "width")) + writer.uint32(/* id 3, wireType 0 =*/24).uint32(message.width); + if (message.height != null && Object.hasOwnProperty.call(message, "height")) + writer.uint32(/* id 4, wireType 0 =*/32).uint32(message.height); + if (message.mimetype != null && Object.hasOwnProperty.call(message, "mimetype")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.mimetype); + if (message.placeholderArgb != null && Object.hasOwnProperty.call(message, "placeholderArgb")) + writer.uint32(/* id 6, wireType 5 =*/53).fixed32(message.placeholderArgb); + if (message.textArgb != null && Object.hasOwnProperty.call(message, "textArgb")) + writer.uint32(/* id 7, wireType 5 =*/61).fixed32(message.textArgb); + if (message.subtextArgb != null && Object.hasOwnProperty.call(message, "subtextArgb")) + writer.uint32(/* id 8, wireType 5 =*/69).fixed32(message.subtextArgb); + return writer; + }; + + /** + * Encodes the specified PaymentBackground message, length delimited. Does not implicitly {@link proto.PaymentBackground.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.PaymentBackground + * @static + * @param {proto.IPaymentBackground} message PaymentBackground message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PaymentBackground.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PaymentBackground message from the specified reader or buffer. + * @function decode + * @memberof proto.PaymentBackground + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.PaymentBackground} PaymentBackground + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PaymentBackground.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.PaymentBackground(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.string(); + break; + case 2: + message.fileLength = reader.string(); + break; + case 3: + message.width = reader.uint32(); + break; + case 4: + message.height = reader.uint32(); + break; + case 5: + message.mimetype = reader.string(); + break; + case 6: + message.placeholderArgb = reader.fixed32(); + break; + case 7: + message.textArgb = reader.fixed32(); + break; + case 8: + message.subtextArgb = reader.fixed32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PaymentBackground message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.PaymentBackground + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.PaymentBackground} PaymentBackground + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PaymentBackground.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PaymentBackground message. + * @function verify + * @memberof proto.PaymentBackground + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PaymentBackground.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isString(message.id)) + return "id: string expected"; + if (message.fileLength != null && message.hasOwnProperty("fileLength")) + if (!$util.isString(message.fileLength)) + return "fileLength: string expected"; + if (message.width != null && message.hasOwnProperty("width")) + if (!$util.isInteger(message.width)) + return "width: integer expected"; + if (message.height != null && message.hasOwnProperty("height")) + if (!$util.isInteger(message.height)) + return "height: integer expected"; + if (message.mimetype != null && message.hasOwnProperty("mimetype")) + if (!$util.isString(message.mimetype)) + return "mimetype: string expected"; + if (message.placeholderArgb != null && message.hasOwnProperty("placeholderArgb")) + if (!$util.isInteger(message.placeholderArgb)) + return "placeholderArgb: integer expected"; + if (message.textArgb != null && message.hasOwnProperty("textArgb")) + if (!$util.isInteger(message.textArgb)) + return "textArgb: integer expected"; + if (message.subtextArgb != null && message.hasOwnProperty("subtextArgb")) + if (!$util.isInteger(message.subtextArgb)) + return "subtextArgb: integer expected"; + return null; + }; + + /** + * Creates a PaymentBackground message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.PaymentBackground + * @static + * @param {Object.} object Plain object + * @returns {proto.PaymentBackground} PaymentBackground + */ + PaymentBackground.fromObject = function fromObject(object) { + if (object instanceof $root.proto.PaymentBackground) + return object; + var message = new $root.proto.PaymentBackground(); + if (object.id != null) + message.id = String(object.id); + if (object.fileLength != null) + message.fileLength = String(object.fileLength); + if (object.width != null) + message.width = object.width >>> 0; + if (object.height != null) + message.height = object.height >>> 0; + if (object.mimetype != null) + message.mimetype = String(object.mimetype); + if (object.placeholderArgb != null) + message.placeholderArgb = object.placeholderArgb >>> 0; + if (object.textArgb != null) + message.textArgb = object.textArgb >>> 0; + if (object.subtextArgb != null) + message.subtextArgb = object.subtextArgb >>> 0; + return message; + }; + + /** + * Creates a plain object from a PaymentBackground message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.PaymentBackground + * @static + * @param {proto.PaymentBackground} message PaymentBackground + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PaymentBackground.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.id = ""; + object.fileLength = ""; + object.width = 0; + object.height = 0; + object.mimetype = ""; + object.placeholderArgb = 0; + object.textArgb = 0; + object.subtextArgb = 0; + } + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + if (message.fileLength != null && message.hasOwnProperty("fileLength")) + object.fileLength = message.fileLength; + if (message.width != null && message.hasOwnProperty("width")) + object.width = message.width; + if (message.height != null && message.hasOwnProperty("height")) + object.height = message.height; + if (message.mimetype != null && message.hasOwnProperty("mimetype")) + object.mimetype = message.mimetype; + if (message.placeholderArgb != null && message.hasOwnProperty("placeholderArgb")) + object.placeholderArgb = message.placeholderArgb; + if (message.textArgb != null && message.hasOwnProperty("textArgb")) + object.textArgb = message.textArgb; + if (message.subtextArgb != null && message.hasOwnProperty("subtextArgb")) + object.subtextArgb = message.subtextArgb; + return object; + }; + + /** + * Converts this PaymentBackground to JSON. + * @function toJSON + * @memberof proto.PaymentBackground + * @instance + * @returns {Object.} JSON object + */ + PaymentBackground.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return PaymentBackground; + })(); + + proto.Money = (function() { + + /** + * Properties of a Money. + * @memberof proto + * @interface IMoney + * @property {number|Long|null} [value] Money value + * @property {number|null} [offset] Money offset + * @property {string|null} [currencyCode] Money currencyCode + */ + + /** + * Constructs a new Money. + * @memberof proto + * @classdesc Represents a Money. + * @implements IMoney + * @constructor + * @param {proto.IMoney=} [properties] Properties to set + */ + function Money(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Money value. + * @member {number|Long} value + * @memberof proto.Money + * @instance + */ + Money.prototype.value = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Money offset. + * @member {number} offset + * @memberof proto.Money + * @instance + */ + Money.prototype.offset = 0; + + /** + * Money currencyCode. + * @member {string} currencyCode + * @memberof proto.Money + * @instance + */ + Money.prototype.currencyCode = ""; + + /** + * Creates a new Money instance using the specified properties. + * @function create + * @memberof proto.Money + * @static + * @param {proto.IMoney=} [properties] Properties to set + * @returns {proto.Money} Money instance + */ + Money.create = function create(properties) { + return new Money(properties); + }; + + /** + * Encodes the specified Money message. Does not implicitly {@link proto.Money.verify|verify} messages. + * @function encode + * @memberof proto.Money + * @static + * @param {proto.IMoney} message Money message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Money.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.value); + if (message.offset != null && Object.hasOwnProperty.call(message, "offset")) + writer.uint32(/* id 2, wireType 0 =*/16).uint32(message.offset); + if (message.currencyCode != null && Object.hasOwnProperty.call(message, "currencyCode")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.currencyCode); + return writer; + }; + + /** + * Encodes the specified Money message, length delimited. Does not implicitly {@link proto.Money.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.Money + * @static + * @param {proto.IMoney} message Money message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Money.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Money message from the specified reader or buffer. + * @function decode + * @memberof proto.Money + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.Money} Money + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Money.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.Money(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.value = reader.int64(); + break; + case 2: + message.offset = reader.uint32(); + break; + case 3: + message.currencyCode = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Money message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.Money + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.Money} Money + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Money.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Money message. + * @function verify + * @memberof proto.Money + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Money.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!$util.isInteger(message.value) && !(message.value && $util.isInteger(message.value.low) && $util.isInteger(message.value.high))) + return "value: integer|Long expected"; + if (message.offset != null && message.hasOwnProperty("offset")) + if (!$util.isInteger(message.offset)) + return "offset: integer expected"; + if (message.currencyCode != null && message.hasOwnProperty("currencyCode")) + if (!$util.isString(message.currencyCode)) + return "currencyCode: string expected"; + return null; + }; + + /** + * Creates a Money message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.Money + * @static + * @param {Object.} object Plain object + * @returns {proto.Money} Money + */ + Money.fromObject = function fromObject(object) { + if (object instanceof $root.proto.Money) + return object; + var message = new $root.proto.Money(); + if (object.value != null) + if ($util.Long) + (message.value = $util.Long.fromValue(object.value)).unsigned = false; + else if (typeof object.value === "string") + message.value = parseInt(object.value, 10); + else if (typeof object.value === "number") + message.value = object.value; + else if (typeof object.value === "object") + message.value = new $util.LongBits(object.value.low >>> 0, object.value.high >>> 0).toNumber(); + if (object.offset != null) + message.offset = object.offset >>> 0; + if (object.currencyCode != null) + message.currencyCode = String(object.currencyCode); + return message; + }; + + /** + * Creates a plain object from a Money message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.Money + * @static + * @param {proto.Money} message Money + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Money.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.value = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.value = options.longs === String ? "0" : 0; + object.offset = 0; + object.currencyCode = ""; + } + if (message.value != null && message.hasOwnProperty("value")) + if (typeof message.value === "number") + object.value = options.longs === String ? String(message.value) : message.value; + else + object.value = options.longs === String ? $util.Long.prototype.toString.call(message.value) : options.longs === Number ? new $util.LongBits(message.value.low >>> 0, message.value.high >>> 0).toNumber() : message.value; + if (message.offset != null && message.hasOwnProperty("offset")) + object.offset = message.offset; + if (message.currencyCode != null && message.hasOwnProperty("currencyCode")) + object.currencyCode = message.currencyCode; + return object; + }; + + /** + * Converts this Money to JSON. + * @function toJSON + * @memberof proto.Money + * @instance + * @returns {Object.} JSON object + */ + Money.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return Money; + })(); + + proto.HydratedQuickReplyButton = (function() { + + /** + * Properties of a HydratedQuickReplyButton. + * @memberof proto + * @interface IHydratedQuickReplyButton + * @property {string|null} [displayText] HydratedQuickReplyButton displayText + * @property {string|null} [id] HydratedQuickReplyButton id + */ + + /** + * Constructs a new HydratedQuickReplyButton. + * @memberof proto + * @classdesc Represents a HydratedQuickReplyButton. + * @implements IHydratedQuickReplyButton + * @constructor + * @param {proto.IHydratedQuickReplyButton=} [properties] Properties to set + */ + function HydratedQuickReplyButton(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * HydratedQuickReplyButton displayText. + * @member {string} displayText + * @memberof proto.HydratedQuickReplyButton + * @instance + */ + HydratedQuickReplyButton.prototype.displayText = ""; + + /** + * HydratedQuickReplyButton id. + * @member {string} id + * @memberof proto.HydratedQuickReplyButton + * @instance + */ + HydratedQuickReplyButton.prototype.id = ""; + + /** + * Creates a new HydratedQuickReplyButton instance using the specified properties. + * @function create + * @memberof proto.HydratedQuickReplyButton + * @static + * @param {proto.IHydratedQuickReplyButton=} [properties] Properties to set + * @returns {proto.HydratedQuickReplyButton} HydratedQuickReplyButton instance + */ + HydratedQuickReplyButton.create = function create(properties) { + return new HydratedQuickReplyButton(properties); + }; + + /** + * Encodes the specified HydratedQuickReplyButton message. Does not implicitly {@link proto.HydratedQuickReplyButton.verify|verify} messages. + * @function encode + * @memberof proto.HydratedQuickReplyButton + * @static + * @param {proto.IHydratedQuickReplyButton} message HydratedQuickReplyButton message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HydratedQuickReplyButton.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.displayText != null && Object.hasOwnProperty.call(message, "displayText")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.displayText); + if (message.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.id); + return writer; + }; + + /** + * Encodes the specified HydratedQuickReplyButton message, length delimited. Does not implicitly {@link proto.HydratedQuickReplyButton.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.HydratedQuickReplyButton + * @static + * @param {proto.IHydratedQuickReplyButton} message HydratedQuickReplyButton message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HydratedQuickReplyButton.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a HydratedQuickReplyButton message from the specified reader or buffer. + * @function decode + * @memberof proto.HydratedQuickReplyButton + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.HydratedQuickReplyButton} HydratedQuickReplyButton + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HydratedQuickReplyButton.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.HydratedQuickReplyButton(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.displayText = reader.string(); + break; + case 2: + message.id = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a HydratedQuickReplyButton message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.HydratedQuickReplyButton + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.HydratedQuickReplyButton} HydratedQuickReplyButton + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HydratedQuickReplyButton.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a HydratedQuickReplyButton message. + * @function verify + * @memberof proto.HydratedQuickReplyButton + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + HydratedQuickReplyButton.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.displayText != null && message.hasOwnProperty("displayText")) + if (!$util.isString(message.displayText)) + return "displayText: string expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isString(message.id)) + return "id: string expected"; + return null; + }; + + /** + * Creates a HydratedQuickReplyButton message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.HydratedQuickReplyButton + * @static + * @param {Object.} object Plain object + * @returns {proto.HydratedQuickReplyButton} HydratedQuickReplyButton + */ + HydratedQuickReplyButton.fromObject = function fromObject(object) { + if (object instanceof $root.proto.HydratedQuickReplyButton) + return object; + var message = new $root.proto.HydratedQuickReplyButton(); + if (object.displayText != null) + message.displayText = String(object.displayText); + if (object.id != null) + message.id = String(object.id); + return message; + }; + + /** + * Creates a plain object from a HydratedQuickReplyButton message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.HydratedQuickReplyButton + * @static + * @param {proto.HydratedQuickReplyButton} message HydratedQuickReplyButton + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + HydratedQuickReplyButton.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.displayText = ""; + object.id = ""; + } + if (message.displayText != null && message.hasOwnProperty("displayText")) + object.displayText = message.displayText; + if (message.id != null && message.hasOwnProperty("id")) + object.id = message.id; + return object; + }; + + /** + * Converts this HydratedQuickReplyButton to JSON. + * @function toJSON + * @memberof proto.HydratedQuickReplyButton + * @instance + * @returns {Object.} JSON object + */ + HydratedQuickReplyButton.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return HydratedQuickReplyButton; + })(); + + proto.HydratedURLButton = (function() { + + /** + * Properties of a HydratedURLButton. + * @memberof proto + * @interface IHydratedURLButton + * @property {string|null} [displayText] HydratedURLButton displayText + * @property {string|null} [url] HydratedURLButton url + */ + + /** + * Constructs a new HydratedURLButton. + * @memberof proto + * @classdesc Represents a HydratedURLButton. + * @implements IHydratedURLButton + * @constructor + * @param {proto.IHydratedURLButton=} [properties] Properties to set + */ + function HydratedURLButton(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * HydratedURLButton displayText. + * @member {string} displayText + * @memberof proto.HydratedURLButton + * @instance + */ + HydratedURLButton.prototype.displayText = ""; + + /** + * HydratedURLButton url. + * @member {string} url + * @memberof proto.HydratedURLButton + * @instance + */ + HydratedURLButton.prototype.url = ""; + + /** + * Creates a new HydratedURLButton instance using the specified properties. + * @function create + * @memberof proto.HydratedURLButton + * @static + * @param {proto.IHydratedURLButton=} [properties] Properties to set + * @returns {proto.HydratedURLButton} HydratedURLButton instance + */ + HydratedURLButton.create = function create(properties) { + return new HydratedURLButton(properties); + }; + + /** + * Encodes the specified HydratedURLButton message. Does not implicitly {@link proto.HydratedURLButton.verify|verify} messages. + * @function encode + * @memberof proto.HydratedURLButton + * @static + * @param {proto.IHydratedURLButton} message HydratedURLButton message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HydratedURLButton.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.displayText != null && Object.hasOwnProperty.call(message, "displayText")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.displayText); + if (message.url != null && Object.hasOwnProperty.call(message, "url")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.url); + return writer; + }; + + /** + * Encodes the specified HydratedURLButton message, length delimited. Does not implicitly {@link proto.HydratedURLButton.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.HydratedURLButton + * @static + * @param {proto.IHydratedURLButton} message HydratedURLButton message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HydratedURLButton.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a HydratedURLButton message from the specified reader or buffer. + * @function decode + * @memberof proto.HydratedURLButton + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.HydratedURLButton} HydratedURLButton + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HydratedURLButton.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.HydratedURLButton(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.displayText = reader.string(); + break; + case 2: + message.url = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a HydratedURLButton message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.HydratedURLButton + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.HydratedURLButton} HydratedURLButton + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HydratedURLButton.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a HydratedURLButton message. + * @function verify + * @memberof proto.HydratedURLButton + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + HydratedURLButton.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.displayText != null && message.hasOwnProperty("displayText")) + if (!$util.isString(message.displayText)) + return "displayText: string expected"; + if (message.url != null && message.hasOwnProperty("url")) + if (!$util.isString(message.url)) + return "url: string expected"; + return null; + }; + + /** + * Creates a HydratedURLButton message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.HydratedURLButton + * @static + * @param {Object.} object Plain object + * @returns {proto.HydratedURLButton} HydratedURLButton + */ + HydratedURLButton.fromObject = function fromObject(object) { + if (object instanceof $root.proto.HydratedURLButton) + return object; + var message = new $root.proto.HydratedURLButton(); + if (object.displayText != null) + message.displayText = String(object.displayText); + if (object.url != null) + message.url = String(object.url); + return message; + }; + + /** + * Creates a plain object from a HydratedURLButton message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.HydratedURLButton + * @static + * @param {proto.HydratedURLButton} message HydratedURLButton + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + HydratedURLButton.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.displayText = ""; + object.url = ""; + } + if (message.displayText != null && message.hasOwnProperty("displayText")) + object.displayText = message.displayText; + if (message.url != null && message.hasOwnProperty("url")) + object.url = message.url; + return object; + }; + + /** + * Converts this HydratedURLButton to JSON. + * @function toJSON + * @memberof proto.HydratedURLButton + * @instance + * @returns {Object.} JSON object + */ + HydratedURLButton.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return HydratedURLButton; + })(); + + proto.HydratedCallButton = (function() { + + /** + * Properties of a HydratedCallButton. + * @memberof proto + * @interface IHydratedCallButton + * @property {string|null} [displayText] HydratedCallButton displayText + * @property {string|null} [phoneNumber] HydratedCallButton phoneNumber + */ + + /** + * Constructs a new HydratedCallButton. + * @memberof proto + * @classdesc Represents a HydratedCallButton. + * @implements IHydratedCallButton + * @constructor + * @param {proto.IHydratedCallButton=} [properties] Properties to set + */ + function HydratedCallButton(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * HydratedCallButton displayText. + * @member {string} displayText + * @memberof proto.HydratedCallButton + * @instance + */ + HydratedCallButton.prototype.displayText = ""; + + /** + * HydratedCallButton phoneNumber. + * @member {string} phoneNumber + * @memberof proto.HydratedCallButton + * @instance + */ + HydratedCallButton.prototype.phoneNumber = ""; + + /** + * Creates a new HydratedCallButton instance using the specified properties. + * @function create + * @memberof proto.HydratedCallButton + * @static + * @param {proto.IHydratedCallButton=} [properties] Properties to set + * @returns {proto.HydratedCallButton} HydratedCallButton instance + */ + HydratedCallButton.create = function create(properties) { + return new HydratedCallButton(properties); + }; + + /** + * Encodes the specified HydratedCallButton message. Does not implicitly {@link proto.HydratedCallButton.verify|verify} messages. + * @function encode + * @memberof proto.HydratedCallButton + * @static + * @param {proto.IHydratedCallButton} message HydratedCallButton message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HydratedCallButton.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.displayText != null && Object.hasOwnProperty.call(message, "displayText")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.displayText); + if (message.phoneNumber != null && Object.hasOwnProperty.call(message, "phoneNumber")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.phoneNumber); + return writer; + }; + + /** + * Encodes the specified HydratedCallButton message, length delimited. Does not implicitly {@link proto.HydratedCallButton.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.HydratedCallButton + * @static + * @param {proto.IHydratedCallButton} message HydratedCallButton message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HydratedCallButton.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a HydratedCallButton message from the specified reader or buffer. + * @function decode + * @memberof proto.HydratedCallButton + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.HydratedCallButton} HydratedCallButton + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HydratedCallButton.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.HydratedCallButton(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.displayText = reader.string(); + break; + case 2: + message.phoneNumber = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a HydratedCallButton message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.HydratedCallButton + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.HydratedCallButton} HydratedCallButton + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HydratedCallButton.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a HydratedCallButton message. + * @function verify + * @memberof proto.HydratedCallButton + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + HydratedCallButton.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.displayText != null && message.hasOwnProperty("displayText")) + if (!$util.isString(message.displayText)) + return "displayText: string expected"; + if (message.phoneNumber != null && message.hasOwnProperty("phoneNumber")) + if (!$util.isString(message.phoneNumber)) + return "phoneNumber: string expected"; + return null; + }; + + /** + * Creates a HydratedCallButton message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.HydratedCallButton + * @static + * @param {Object.} object Plain object + * @returns {proto.HydratedCallButton} HydratedCallButton + */ + HydratedCallButton.fromObject = function fromObject(object) { + if (object instanceof $root.proto.HydratedCallButton) + return object; + var message = new $root.proto.HydratedCallButton(); + if (object.displayText != null) + message.displayText = String(object.displayText); + if (object.phoneNumber != null) + message.phoneNumber = String(object.phoneNumber); + return message; + }; + + /** + * Creates a plain object from a HydratedCallButton message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.HydratedCallButton + * @static + * @param {proto.HydratedCallButton} message HydratedCallButton + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + HydratedCallButton.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.displayText = ""; + object.phoneNumber = ""; + } + if (message.displayText != null && message.hasOwnProperty("displayText")) + object.displayText = message.displayText; + if (message.phoneNumber != null && message.hasOwnProperty("phoneNumber")) + object.phoneNumber = message.phoneNumber; + return object; + }; + + /** + * Converts this HydratedCallButton to JSON. + * @function toJSON + * @memberof proto.HydratedCallButton + * @instance + * @returns {Object.} JSON object + */ + HydratedCallButton.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return HydratedCallButton; + })(); + + proto.HydratedTemplateButton = (function() { + + /** + * Properties of a HydratedTemplateButton. + * @memberof proto + * @interface IHydratedTemplateButton + * @property {number|null} [index] HydratedTemplateButton index + * @property {proto.IHydratedQuickReplyButton|null} [quickReplyButton] HydratedTemplateButton quickReplyButton + * @property {proto.IHydratedURLButton|null} [urlButton] HydratedTemplateButton urlButton + * @property {proto.IHydratedCallButton|null} [callButton] HydratedTemplateButton callButton + */ + + /** + * Constructs a new HydratedTemplateButton. + * @memberof proto + * @classdesc Represents a HydratedTemplateButton. + * @implements IHydratedTemplateButton + * @constructor + * @param {proto.IHydratedTemplateButton=} [properties] Properties to set + */ + function HydratedTemplateButton(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * HydratedTemplateButton index. + * @member {number} index + * @memberof proto.HydratedTemplateButton + * @instance + */ + HydratedTemplateButton.prototype.index = 0; + + /** + * HydratedTemplateButton quickReplyButton. + * @member {proto.IHydratedQuickReplyButton|null|undefined} quickReplyButton + * @memberof proto.HydratedTemplateButton + * @instance + */ + HydratedTemplateButton.prototype.quickReplyButton = null; + + /** + * HydratedTemplateButton urlButton. + * @member {proto.IHydratedURLButton|null|undefined} urlButton + * @memberof proto.HydratedTemplateButton + * @instance + */ + HydratedTemplateButton.prototype.urlButton = null; + + /** + * HydratedTemplateButton callButton. + * @member {proto.IHydratedCallButton|null|undefined} callButton + * @memberof proto.HydratedTemplateButton + * @instance + */ + HydratedTemplateButton.prototype.callButton = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * HydratedTemplateButton hydratedButton. + * @member {"quickReplyButton"|"urlButton"|"callButton"|undefined} hydratedButton + * @memberof proto.HydratedTemplateButton + * @instance + */ + Object.defineProperty(HydratedTemplateButton.prototype, "hydratedButton", { + get: $util.oneOfGetter($oneOfFields = ["quickReplyButton", "urlButton", "callButton"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new HydratedTemplateButton instance using the specified properties. + * @function create + * @memberof proto.HydratedTemplateButton + * @static + * @param {proto.IHydratedTemplateButton=} [properties] Properties to set + * @returns {proto.HydratedTemplateButton} HydratedTemplateButton instance + */ + HydratedTemplateButton.create = function create(properties) { + return new HydratedTemplateButton(properties); + }; + + /** + * Encodes the specified HydratedTemplateButton message. Does not implicitly {@link proto.HydratedTemplateButton.verify|verify} messages. + * @function encode + * @memberof proto.HydratedTemplateButton + * @static + * @param {proto.IHydratedTemplateButton} message HydratedTemplateButton message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HydratedTemplateButton.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.quickReplyButton != null && Object.hasOwnProperty.call(message, "quickReplyButton")) + $root.proto.HydratedQuickReplyButton.encode(message.quickReplyButton, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.urlButton != null && Object.hasOwnProperty.call(message, "urlButton")) + $root.proto.HydratedURLButton.encode(message.urlButton, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.callButton != null && Object.hasOwnProperty.call(message, "callButton")) + $root.proto.HydratedCallButton.encode(message.callButton, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.index != null && Object.hasOwnProperty.call(message, "index")) + writer.uint32(/* id 4, wireType 0 =*/32).uint32(message.index); + return writer; + }; + + /** + * Encodes the specified HydratedTemplateButton message, length delimited. Does not implicitly {@link proto.HydratedTemplateButton.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.HydratedTemplateButton + * @static + * @param {proto.IHydratedTemplateButton} message HydratedTemplateButton message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HydratedTemplateButton.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a HydratedTemplateButton message from the specified reader or buffer. + * @function decode + * @memberof proto.HydratedTemplateButton + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.HydratedTemplateButton} HydratedTemplateButton + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HydratedTemplateButton.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.HydratedTemplateButton(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 4: + message.index = reader.uint32(); + break; + case 1: + message.quickReplyButton = $root.proto.HydratedQuickReplyButton.decode(reader, reader.uint32()); + break; + case 2: + message.urlButton = $root.proto.HydratedURLButton.decode(reader, reader.uint32()); + break; + case 3: + message.callButton = $root.proto.HydratedCallButton.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a HydratedTemplateButton message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.HydratedTemplateButton + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.HydratedTemplateButton} HydratedTemplateButton + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HydratedTemplateButton.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a HydratedTemplateButton message. + * @function verify + * @memberof proto.HydratedTemplateButton + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + HydratedTemplateButton.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.index != null && message.hasOwnProperty("index")) + if (!$util.isInteger(message.index)) + return "index: integer expected"; + if (message.quickReplyButton != null && message.hasOwnProperty("quickReplyButton")) { + properties.hydratedButton = 1; + { + var error = $root.proto.HydratedQuickReplyButton.verify(message.quickReplyButton); + if (error) + return "quickReplyButton." + error; + } + } + if (message.urlButton != null && message.hasOwnProperty("urlButton")) { + if (properties.hydratedButton === 1) + return "hydratedButton: multiple values"; + properties.hydratedButton = 1; + { + var error = $root.proto.HydratedURLButton.verify(message.urlButton); + if (error) + return "urlButton." + error; + } + } + if (message.callButton != null && message.hasOwnProperty("callButton")) { + if (properties.hydratedButton === 1) + return "hydratedButton: multiple values"; + properties.hydratedButton = 1; + { + var error = $root.proto.HydratedCallButton.verify(message.callButton); + if (error) + return "callButton." + error; + } + } + return null; + }; + + /** + * Creates a HydratedTemplateButton message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.HydratedTemplateButton + * @static + * @param {Object.} object Plain object + * @returns {proto.HydratedTemplateButton} HydratedTemplateButton + */ + HydratedTemplateButton.fromObject = function fromObject(object) { + if (object instanceof $root.proto.HydratedTemplateButton) + return object; + var message = new $root.proto.HydratedTemplateButton(); + if (object.index != null) + message.index = object.index >>> 0; + if (object.quickReplyButton != null) { + if (typeof object.quickReplyButton !== "object") + throw TypeError(".proto.HydratedTemplateButton.quickReplyButton: object expected"); + message.quickReplyButton = $root.proto.HydratedQuickReplyButton.fromObject(object.quickReplyButton); + } + if (object.urlButton != null) { + if (typeof object.urlButton !== "object") + throw TypeError(".proto.HydratedTemplateButton.urlButton: object expected"); + message.urlButton = $root.proto.HydratedURLButton.fromObject(object.urlButton); + } + if (object.callButton != null) { + if (typeof object.callButton !== "object") + throw TypeError(".proto.HydratedTemplateButton.callButton: object expected"); + message.callButton = $root.proto.HydratedCallButton.fromObject(object.callButton); + } + return message; + }; + + /** + * Creates a plain object from a HydratedTemplateButton message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.HydratedTemplateButton + * @static + * @param {proto.HydratedTemplateButton} message HydratedTemplateButton + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + HydratedTemplateButton.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.index = 0; + if (message.quickReplyButton != null && message.hasOwnProperty("quickReplyButton")) { + object.quickReplyButton = $root.proto.HydratedQuickReplyButton.toObject(message.quickReplyButton, options); + if (options.oneofs) + object.hydratedButton = "quickReplyButton"; + } + if (message.urlButton != null && message.hasOwnProperty("urlButton")) { + object.urlButton = $root.proto.HydratedURLButton.toObject(message.urlButton, options); + if (options.oneofs) + object.hydratedButton = "urlButton"; + } + if (message.callButton != null && message.hasOwnProperty("callButton")) { + object.callButton = $root.proto.HydratedCallButton.toObject(message.callButton, options); + if (options.oneofs) + object.hydratedButton = "callButton"; + } + if (message.index != null && message.hasOwnProperty("index")) + object.index = message.index; + return object; + }; + + /** + * Converts this HydratedTemplateButton to JSON. + * @function toJSON + * @memberof proto.HydratedTemplateButton + * @instance + * @returns {Object.} JSON object + */ + HydratedTemplateButton.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return HydratedTemplateButton; })(); proto.QuickReplyButton = (function() { @@ -3308,7 +22635,6 @@ $root.proto = (function() { * @property {string|null} [entryPointConversionSource] ContextInfo entryPointConversionSource * @property {string|null} [entryPointConversionApp] ContextInfo entryPointConversionApp * @property {number|null} [entryPointConversionDelaySeconds] ContextInfo entryPointConversionDelaySeconds - * @property {proto.IDisappearingMode|null} [disappearingMode] ContextInfo disappearingMode */ /** @@ -3479,14 +22805,6 @@ $root.proto = (function() { */ ContextInfo.prototype.entryPointConversionDelaySeconds = 0; - /** - * ContextInfo disappearingMode. - * @member {proto.IDisappearingMode|null|undefined} disappearingMode - * @memberof proto.ContextInfo - * @instance - */ - ContextInfo.prototype.disappearingMode = null; - /** * Creates a new ContextInfo instance using the specified properties. * @function create @@ -3550,8 +22868,6 @@ $root.proto = (function() { writer.uint32(/* id 30, wireType 2 =*/242).string(message.entryPointConversionApp); if (message.entryPointConversionDelaySeconds != null && Object.hasOwnProperty.call(message, "entryPointConversionDelaySeconds")) writer.uint32(/* id 31, wireType 0 =*/248).uint32(message.entryPointConversionDelaySeconds); - if (message.disappearingMode != null && Object.hasOwnProperty.call(message, "disappearingMode")) - $root.proto.DisappearingMode.encode(message.disappearingMode, writer.uint32(/* id 32, wireType 2 =*/258).fork()).ldelim(); return writer; }; @@ -3645,9 +22961,6 @@ $root.proto = (function() { case 31: message.entryPointConversionDelaySeconds = reader.uint32(); break; - case 32: - message.disappearingMode = $root.proto.DisappearingMode.decode(reader, reader.uint32()); - break; default: reader.skipType(tag & 7); break; @@ -3752,11 +23065,6 @@ $root.proto = (function() { if (message.entryPointConversionDelaySeconds != null && message.hasOwnProperty("entryPointConversionDelaySeconds")) if (!$util.isInteger(message.entryPointConversionDelaySeconds)) return "entryPointConversionDelaySeconds: integer expected"; - if (message.disappearingMode != null && message.hasOwnProperty("disappearingMode")) { - var error = $root.proto.DisappearingMode.verify(message.disappearingMode); - if (error) - return "disappearingMode." + error; - } return null; }; @@ -3840,11 +23148,6 @@ $root.proto = (function() { message.entryPointConversionApp = String(object.entryPointConversionApp); if (object.entryPointConversionDelaySeconds != null) message.entryPointConversionDelaySeconds = object.entryPointConversionDelaySeconds >>> 0; - if (object.disappearingMode != null) { - if (typeof object.disappearingMode !== "object") - throw TypeError(".proto.ContextInfo.disappearingMode: object expected"); - message.disappearingMode = $root.proto.DisappearingMode.fromObject(object.disappearingMode); - } return message; }; @@ -3898,7 +23201,6 @@ $root.proto = (function() { object.entryPointConversionSource = ""; object.entryPointConversionApp = ""; object.entryPointConversionDelaySeconds = 0; - object.disappearingMode = null; } if (message.stanzaId != null && message.hasOwnProperty("stanzaId")) object.stanzaId = message.stanzaId; @@ -3944,8 +23246,6 @@ $root.proto = (function() { object.entryPointConversionApp = message.entryPointConversionApp; if (message.entryPointConversionDelaySeconds != null && message.hasOwnProperty("entryPointConversionDelaySeconds")) object.entryPointConversionDelaySeconds = message.entryPointConversionDelaySeconds; - if (message.disappearingMode != null && message.hasOwnProperty("disappearingMode")) - object.disappearingMode = $root.proto.DisappearingMode.toObject(message.disappearingMode, options); return object; }; @@ -4213,7 +23513,6 @@ $root.proto = (function() { * @property {string|null} [thumbnailDirectPath] ImageMessage thumbnailDirectPath * @property {Uint8Array|null} [thumbnailSha256] ImageMessage thumbnailSha256 * @property {Uint8Array|null} [thumbnailEncSha256] ImageMessage thumbnailEncSha256 - * @property {string|null} [staticUrl] ImageMessage staticUrl */ /** @@ -4433,14 +23732,6 @@ $root.proto = (function() { */ ImageMessage.prototype.thumbnailEncSha256 = $util.newBuffer([]); - /** - * ImageMessage staticUrl. - * @member {string} staticUrl - * @memberof proto.ImageMessage - * @instance - */ - ImageMessage.prototype.staticUrl = ""; - /** * Creates a new ImageMessage instance using the specified properties. * @function create @@ -4517,8 +23808,6 @@ $root.proto = (function() { writer.uint32(/* id 27, wireType 2 =*/218).bytes(message.thumbnailSha256); if (message.thumbnailEncSha256 != null && Object.hasOwnProperty.call(message, "thumbnailEncSha256")) writer.uint32(/* id 28, wireType 2 =*/226).bytes(message.thumbnailEncSha256); - if (message.staticUrl != null && Object.hasOwnProperty.call(message, "staticUrl")) - writer.uint32(/* id 29, wireType 2 =*/234).string(message.staticUrl); return writer; }; @@ -4637,9 +23926,6 @@ $root.proto = (function() { case 28: message.thumbnailEncSha256 = reader.bytes(); break; - case 29: - message.staticUrl = reader.string(); - break; default: reader.skipType(tag & 7); break; @@ -4762,9 +24048,6 @@ $root.proto = (function() { if (message.thumbnailEncSha256 != null && message.hasOwnProperty("thumbnailEncSha256")) if (!(message.thumbnailEncSha256 && typeof message.thumbnailEncSha256.length === "number" || $util.isString(message.thumbnailEncSha256))) return "thumbnailEncSha256: buffer expected"; - if (message.staticUrl != null && message.hasOwnProperty("staticUrl")) - if (!$util.isString(message.staticUrl)) - return "staticUrl: string expected"; return null; }; @@ -4890,8 +24173,6 @@ $root.proto = (function() { $util.base64.decode(object.thumbnailEncSha256, message.thumbnailEncSha256 = $util.newBuffer($util.base64.length(object.thumbnailEncSha256)), 0); else if (object.thumbnailEncSha256.length) message.thumbnailEncSha256 = object.thumbnailEncSha256; - if (object.staticUrl != null) - message.staticUrl = String(object.staticUrl); return message; }; @@ -5004,7 +24285,6 @@ $root.proto = (function() { if (options.bytes !== Array) object.thumbnailEncSha256 = $util.newBuffer(object.thumbnailEncSha256); } - object.staticUrl = ""; } if (message.url != null && message.hasOwnProperty("url")) object.url = message.url; @@ -5068,8 +24348,6 @@ $root.proto = (function() { object.thumbnailSha256 = options.bytes === String ? $util.base64.encode(message.thumbnailSha256, 0, message.thumbnailSha256.length) : options.bytes === Array ? Array.prototype.slice.call(message.thumbnailSha256) : message.thumbnailSha256; if (message.thumbnailEncSha256 != null && message.hasOwnProperty("thumbnailEncSha256")) object.thumbnailEncSha256 = options.bytes === String ? $util.base64.encode(message.thumbnailEncSha256, 0, message.thumbnailEncSha256.length) : options.bytes === Array ? Array.prototype.slice.call(message.thumbnailEncSha256) : message.thumbnailEncSha256; - if (message.staticUrl != null && message.hasOwnProperty("staticUrl")) - object.staticUrl = message.staticUrl; return object; }; @@ -8150,7 +27428,6 @@ $root.proto = (function() { * @property {string|null} [thumbnailDirectPath] VideoMessage thumbnailDirectPath * @property {Uint8Array|null} [thumbnailSha256] VideoMessage thumbnailSha256 * @property {Uint8Array|null} [thumbnailEncSha256] VideoMessage thumbnailEncSha256 - * @property {string|null} [staticUrl] VideoMessage staticUrl */ /** @@ -8345,14 +27622,6 @@ $root.proto = (function() { */ VideoMessage.prototype.thumbnailEncSha256 = $util.newBuffer([]); - /** - * VideoMessage staticUrl. - * @member {string} staticUrl - * @memberof proto.VideoMessage - * @instance - */ - VideoMessage.prototype.staticUrl = ""; - /** * Creates a new VideoMessage instance using the specified properties. * @function create @@ -8422,8 +27691,6 @@ $root.proto = (function() { writer.uint32(/* id 22, wireType 2 =*/178).bytes(message.thumbnailSha256); if (message.thumbnailEncSha256 != null && Object.hasOwnProperty.call(message, "thumbnailEncSha256")) writer.uint32(/* id 23, wireType 2 =*/186).bytes(message.thumbnailEncSha256); - if (message.staticUrl != null && Object.hasOwnProperty.call(message, "staticUrl")) - writer.uint32(/* id 24, wireType 2 =*/194).string(message.staticUrl); return writer; }; @@ -8526,9 +27793,6 @@ $root.proto = (function() { case 23: message.thumbnailEncSha256 = reader.bytes(); break; - case 24: - message.staticUrl = reader.string(); - break; default: reader.skipType(tag & 7); break; @@ -8644,9 +27908,6 @@ $root.proto = (function() { if (message.thumbnailEncSha256 != null && message.hasOwnProperty("thumbnailEncSha256")) if (!(message.thumbnailEncSha256 && typeof message.thumbnailEncSha256.length === "number" || $util.isString(message.thumbnailEncSha256))) return "thumbnailEncSha256: buffer expected"; - if (message.staticUrl != null && message.hasOwnProperty("staticUrl")) - if (!$util.isString(message.staticUrl)) - return "staticUrl: string expected"; return null; }; @@ -8764,8 +28025,6 @@ $root.proto = (function() { $util.base64.decode(object.thumbnailEncSha256, message.thumbnailEncSha256 = $util.newBuffer($util.base64.length(object.thumbnailEncSha256)), 0); else if (object.thumbnailEncSha256.length) message.thumbnailEncSha256 = object.thumbnailEncSha256; - if (object.staticUrl != null) - message.staticUrl = String(object.staticUrl); return message; }; @@ -8856,7 +28115,6 @@ $root.proto = (function() { if (options.bytes !== Array) object.thumbnailEncSha256 = $util.newBuffer(object.thumbnailEncSha256); } - object.staticUrl = ""; } if (message.url != null && message.hasOwnProperty("url")) object.url = message.url; @@ -8911,8 +28169,6 @@ $root.proto = (function() { object.thumbnailSha256 = options.bytes === String ? $util.base64.encode(message.thumbnailSha256, 0, message.thumbnailSha256.length) : options.bytes === Array ? Array.prototype.slice.call(message.thumbnailSha256) : message.thumbnailSha256; if (message.thumbnailEncSha256 != null && message.hasOwnProperty("thumbnailEncSha256")) object.thumbnailEncSha256 = options.bytes === String ? $util.base64.encode(message.thumbnailEncSha256, 0, message.thumbnailEncSha256.length) : options.bytes === Array ? Array.prototype.slice.call(message.thumbnailEncSha256) : message.thumbnailEncSha256; - if (message.staticUrl != null && message.hasOwnProperty("staticUrl")) - object.staticUrl = message.staticUrl; return object; }; @@ -9443,7 +28699,6 @@ $root.proto = (function() { * @property {proto.IAppStateSyncKeyRequest|null} [appStateSyncKeyRequest] ProtocolMessage appStateSyncKeyRequest * @property {proto.IInitialSecurityNotificationSettingSync|null} [initialSecurityNotificationSettingSync] ProtocolMessage initialSecurityNotificationSettingSync * @property {proto.IAppStateFatalExceptionNotification|null} [appStateFatalExceptionNotification] ProtocolMessage appStateFatalExceptionNotification - * @property {proto.IDisappearingMode|null} [disappearingMode] ProtocolMessage disappearingMode */ /** @@ -9533,14 +28788,6 @@ $root.proto = (function() { */ ProtocolMessage.prototype.appStateFatalExceptionNotification = null; - /** - * ProtocolMessage disappearingMode. - * @member {proto.IDisappearingMode|null|undefined} disappearingMode - * @memberof proto.ProtocolMessage - * @instance - */ - ProtocolMessage.prototype.disappearingMode = null; - /** * Creates a new ProtocolMessage instance using the specified properties. * @function create @@ -9583,8 +28830,6 @@ $root.proto = (function() { $root.proto.InitialSecurityNotificationSettingSync.encode(message.initialSecurityNotificationSettingSync, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); if (message.appStateFatalExceptionNotification != null && Object.hasOwnProperty.call(message, "appStateFatalExceptionNotification")) $root.proto.AppStateFatalExceptionNotification.encode(message.appStateFatalExceptionNotification, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); - if (message.disappearingMode != null && Object.hasOwnProperty.call(message, "disappearingMode")) - $root.proto.DisappearingMode.encode(message.disappearingMode, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); return writer; }; @@ -9646,9 +28891,6 @@ $root.proto = (function() { case 10: message.appStateFatalExceptionNotification = $root.proto.AppStateFatalExceptionNotification.decode(reader, reader.uint32()); break; - case 11: - message.disappearingMode = $root.proto.DisappearingMode.decode(reader, reader.uint32()); - break; default: reader.skipType(tag & 7); break; @@ -9735,11 +28977,6 @@ $root.proto = (function() { if (error) return "appStateFatalExceptionNotification." + error; } - if (message.disappearingMode != null && message.hasOwnProperty("disappearingMode")) { - var error = $root.proto.DisappearingMode.verify(message.disappearingMode); - if (error) - return "disappearingMode." + error; - } return null; }; @@ -9834,11 +29071,6 @@ $root.proto = (function() { throw TypeError(".proto.ProtocolMessage.appStateFatalExceptionNotification: object expected"); message.appStateFatalExceptionNotification = $root.proto.AppStateFatalExceptionNotification.fromObject(object.appStateFatalExceptionNotification); } - if (object.disappearingMode != null) { - if (typeof object.disappearingMode !== "object") - throw TypeError(".proto.ProtocolMessage.disappearingMode: object expected"); - message.disappearingMode = $root.proto.DisappearingMode.fromObject(object.disappearingMode); - } return message; }; @@ -9869,7 +29101,6 @@ $root.proto = (function() { object.appStateSyncKeyRequest = null; object.initialSecurityNotificationSettingSync = null; object.appStateFatalExceptionNotification = null; - object.disappearingMode = null; } if (message.key != null && message.hasOwnProperty("key")) object.key = $root.proto.MessageKey.toObject(message.key, options); @@ -9892,8 +29123,6 @@ $root.proto = (function() { object.initialSecurityNotificationSettingSync = $root.proto.InitialSecurityNotificationSettingSync.toObject(message.initialSecurityNotificationSettingSync, options); if (message.appStateFatalExceptionNotification != null && message.hasOwnProperty("appStateFatalExceptionNotification")) object.appStateFatalExceptionNotification = $root.proto.AppStateFatalExceptionNotification.toObject(message.appStateFatalExceptionNotification, options); - if (message.disappearingMode != null && message.hasOwnProperty("disappearingMode")) - object.disappearingMode = $root.proto.DisappearingMode.toObject(message.disappearingMode, options); return object; }; @@ -21579,1594 +40808,6 @@ $root.proto = (function() { return ListResponseMessage; })(); - proto.Header = (function() { - - /** - * Properties of a Header. - * @memberof proto - * @interface IHeader - * @property {string|null} [title] Header title - * @property {string|null} [subtitle] Header subtitle - * @property {proto.IDocumentMessage|null} [documentMessage] Header documentMessage - * @property {proto.IImageMessage|null} [imageMessage] Header imageMessage - */ - - /** - * Constructs a new Header. - * @memberof proto - * @classdesc Represents a Header. - * @implements IHeader - * @constructor - * @param {proto.IHeader=} [properties] Properties to set - */ - function Header(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Header title. - * @member {string} title - * @memberof proto.Header - * @instance - */ - Header.prototype.title = ""; - - /** - * Header subtitle. - * @member {string} subtitle - * @memberof proto.Header - * @instance - */ - Header.prototype.subtitle = ""; - - /** - * Header documentMessage. - * @member {proto.IDocumentMessage|null|undefined} documentMessage - * @memberof proto.Header - * @instance - */ - Header.prototype.documentMessage = null; - - /** - * Header imageMessage. - * @member {proto.IImageMessage|null|undefined} imageMessage - * @memberof proto.Header - * @instance - */ - Header.prototype.imageMessage = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * Header media. - * @member {"documentMessage"|"imageMessage"|undefined} media - * @memberof proto.Header - * @instance - */ - Object.defineProperty(Header.prototype, "media", { - get: $util.oneOfGetter($oneOfFields = ["documentMessage", "imageMessage"]), - set: $util.oneOfSetter($oneOfFields) - }); - - /** - * Creates a new Header instance using the specified properties. - * @function create - * @memberof proto.Header - * @static - * @param {proto.IHeader=} [properties] Properties to set - * @returns {proto.Header} Header instance - */ - Header.create = function create(properties) { - return new Header(properties); - }; - - /** - * Encodes the specified Header message. Does not implicitly {@link proto.Header.verify|verify} messages. - * @function encode - * @memberof proto.Header - * @static - * @param {proto.IHeader} message Header message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Header.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.title != null && Object.hasOwnProperty.call(message, "title")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.title); - if (message.subtitle != null && Object.hasOwnProperty.call(message, "subtitle")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.subtitle); - if (message.documentMessage != null && Object.hasOwnProperty.call(message, "documentMessage")) - $root.proto.DocumentMessage.encode(message.documentMessage, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.imageMessage != null && Object.hasOwnProperty.call(message, "imageMessage")) - $root.proto.ImageMessage.encode(message.imageMessage, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified Header message, length delimited. Does not implicitly {@link proto.Header.verify|verify} messages. - * @function encodeDelimited - * @memberof proto.Header - * @static - * @param {proto.IHeader} message Header message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Header.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a Header message from the specified reader or buffer. - * @function decode - * @memberof proto.Header - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {proto.Header} Header - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Header.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.Header(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.title = reader.string(); - break; - case 2: - message.subtitle = reader.string(); - break; - case 3: - message.documentMessage = $root.proto.DocumentMessage.decode(reader, reader.uint32()); - break; - case 4: - message.imageMessage = $root.proto.ImageMessage.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a Header message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof proto.Header - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {proto.Header} Header - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Header.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a Header message. - * @function verify - * @memberof proto.Header - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Header.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - var properties = {}; - if (message.title != null && message.hasOwnProperty("title")) - if (!$util.isString(message.title)) - return "title: string expected"; - if (message.subtitle != null && message.hasOwnProperty("subtitle")) - if (!$util.isString(message.subtitle)) - return "subtitle: string expected"; - if (message.documentMessage != null && message.hasOwnProperty("documentMessage")) { - properties.media = 1; - { - var error = $root.proto.DocumentMessage.verify(message.documentMessage); - if (error) - return "documentMessage." + error; - } - } - if (message.imageMessage != null && message.hasOwnProperty("imageMessage")) { - if (properties.media === 1) - return "media: multiple values"; - properties.media = 1; - { - var error = $root.proto.ImageMessage.verify(message.imageMessage); - if (error) - return "imageMessage." + error; - } - } - return null; - }; - - /** - * Creates a Header message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof proto.Header - * @static - * @param {Object.} object Plain object - * @returns {proto.Header} Header - */ - Header.fromObject = function fromObject(object) { - if (object instanceof $root.proto.Header) - return object; - var message = new $root.proto.Header(); - if (object.title != null) - message.title = String(object.title); - if (object.subtitle != null) - message.subtitle = String(object.subtitle); - if (object.documentMessage != null) { - if (typeof object.documentMessage !== "object") - throw TypeError(".proto.Header.documentMessage: object expected"); - message.documentMessage = $root.proto.DocumentMessage.fromObject(object.documentMessage); - } - if (object.imageMessage != null) { - if (typeof object.imageMessage !== "object") - throw TypeError(".proto.Header.imageMessage: object expected"); - message.imageMessage = $root.proto.ImageMessage.fromObject(object.imageMessage); - } - return message; - }; - - /** - * Creates a plain object from a Header message. Also converts values to other types if specified. - * @function toObject - * @memberof proto.Header - * @static - * @param {proto.Header} message Header - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Header.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.title = ""; - object.subtitle = ""; - } - if (message.title != null && message.hasOwnProperty("title")) - object.title = message.title; - if (message.subtitle != null && message.hasOwnProperty("subtitle")) - object.subtitle = message.subtitle; - if (message.documentMessage != null && message.hasOwnProperty("documentMessage")) { - object.documentMessage = $root.proto.DocumentMessage.toObject(message.documentMessage, options); - if (options.oneofs) - object.media = "documentMessage"; - } - if (message.imageMessage != null && message.hasOwnProperty("imageMessage")) { - object.imageMessage = $root.proto.ImageMessage.toObject(message.imageMessage, options); - if (options.oneofs) - object.media = "imageMessage"; - } - return object; - }; - - /** - * Converts this Header to JSON. - * @function toJSON - * @memberof proto.Header - * @instance - * @returns {Object.} JSON object - */ - Header.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Header; - })(); - - proto.Body = (function() { - - /** - * Properties of a Body. - * @memberof proto - * @interface IBody - * @property {string|null} [text] Body text - */ - - /** - * Constructs a new Body. - * @memberof proto - * @classdesc Represents a Body. - * @implements IBody - * @constructor - * @param {proto.IBody=} [properties] Properties to set - */ - function Body(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Body text. - * @member {string} text - * @memberof proto.Body - * @instance - */ - Body.prototype.text = ""; - - /** - * Creates a new Body instance using the specified properties. - * @function create - * @memberof proto.Body - * @static - * @param {proto.IBody=} [properties] Properties to set - * @returns {proto.Body} Body instance - */ - Body.create = function create(properties) { - return new Body(properties); - }; - - /** - * Encodes the specified Body message. Does not implicitly {@link proto.Body.verify|verify} messages. - * @function encode - * @memberof proto.Body - * @static - * @param {proto.IBody} message Body message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Body.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.text != null && Object.hasOwnProperty.call(message, "text")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.text); - return writer; - }; - - /** - * Encodes the specified Body message, length delimited. Does not implicitly {@link proto.Body.verify|verify} messages. - * @function encodeDelimited - * @memberof proto.Body - * @static - * @param {proto.IBody} message Body message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Body.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a Body message from the specified reader or buffer. - * @function decode - * @memberof proto.Body - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {proto.Body} Body - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Body.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.Body(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.text = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a Body message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof proto.Body - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {proto.Body} Body - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Body.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a Body message. - * @function verify - * @memberof proto.Body - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Body.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.text != null && message.hasOwnProperty("text")) - if (!$util.isString(message.text)) - return "text: string expected"; - return null; - }; - - /** - * Creates a Body message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof proto.Body - * @static - * @param {Object.} object Plain object - * @returns {proto.Body} Body - */ - Body.fromObject = function fromObject(object) { - if (object instanceof $root.proto.Body) - return object; - var message = new $root.proto.Body(); - if (object.text != null) - message.text = String(object.text); - return message; - }; - - /** - * Creates a plain object from a Body message. Also converts values to other types if specified. - * @function toObject - * @memberof proto.Body - * @static - * @param {proto.Body} message Body - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Body.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.text = ""; - if (message.text != null && message.hasOwnProperty("text")) - object.text = message.text; - return object; - }; - - /** - * Converts this Body to JSON. - * @function toJSON - * @memberof proto.Body - * @instance - * @returns {Object.} JSON object - */ - Body.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Body; - })(); - - proto.Footer = (function() { - - /** - * Properties of a Footer. - * @memberof proto - * @interface IFooter - * @property {string|null} [text] Footer text - */ - - /** - * Constructs a new Footer. - * @memberof proto - * @classdesc Represents a Footer. - * @implements IFooter - * @constructor - * @param {proto.IFooter=} [properties] Properties to set - */ - function Footer(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Footer text. - * @member {string} text - * @memberof proto.Footer - * @instance - */ - Footer.prototype.text = ""; - - /** - * Creates a new Footer instance using the specified properties. - * @function create - * @memberof proto.Footer - * @static - * @param {proto.IFooter=} [properties] Properties to set - * @returns {proto.Footer} Footer instance - */ - Footer.create = function create(properties) { - return new Footer(properties); - }; - - /** - * Encodes the specified Footer message. Does not implicitly {@link proto.Footer.verify|verify} messages. - * @function encode - * @memberof proto.Footer - * @static - * @param {proto.IFooter} message Footer message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Footer.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.text != null && Object.hasOwnProperty.call(message, "text")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.text); - return writer; - }; - - /** - * Encodes the specified Footer message, length delimited. Does not implicitly {@link proto.Footer.verify|verify} messages. - * @function encodeDelimited - * @memberof proto.Footer - * @static - * @param {proto.IFooter} message Footer message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Footer.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a Footer message from the specified reader or buffer. - * @function decode - * @memberof proto.Footer - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {proto.Footer} Footer - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Footer.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.Footer(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.text = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a Footer message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof proto.Footer - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {proto.Footer} Footer - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Footer.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a Footer message. - * @function verify - * @memberof proto.Footer - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Footer.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.text != null && message.hasOwnProperty("text")) - if (!$util.isString(message.text)) - return "text: string expected"; - return null; - }; - - /** - * Creates a Footer message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof proto.Footer - * @static - * @param {Object.} object Plain object - * @returns {proto.Footer} Footer - */ - Footer.fromObject = function fromObject(object) { - if (object instanceof $root.proto.Footer) - return object; - var message = new $root.proto.Footer(); - if (object.text != null) - message.text = String(object.text); - return message; - }; - - /** - * Creates a plain object from a Footer message. Also converts values to other types if specified. - * @function toObject - * @memberof proto.Footer - * @static - * @param {proto.Footer} message Footer - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Footer.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.text = ""; - if (message.text != null && message.hasOwnProperty("text")) - object.text = message.text; - return object; - }; - - /** - * Converts this Footer to JSON. - * @function toJSON - * @memberof proto.Footer - * @instance - * @returns {Object.} JSON object - */ - Footer.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Footer; - })(); - - proto.ShopsMessage = (function() { - - /** - * Properties of a ShopsMessage. - * @memberof proto - * @interface IShopsMessage - * @property {string|null} [id] ShopsMessage id - * @property {proto.ShopsMessage.ShopsMessageSurface|null} [surface] ShopsMessage surface - * @property {proto.ShopsMessage.ShopsMessageType|null} [type] ShopsMessage type - * @property {number|null} [messageVersion] ShopsMessage messageVersion - */ - - /** - * Constructs a new ShopsMessage. - * @memberof proto - * @classdesc Represents a ShopsMessage. - * @implements IShopsMessage - * @constructor - * @param {proto.IShopsMessage=} [properties] Properties to set - */ - function ShopsMessage(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * ShopsMessage id. - * @member {string} id - * @memberof proto.ShopsMessage - * @instance - */ - ShopsMessage.prototype.id = ""; - - /** - * ShopsMessage surface. - * @member {proto.ShopsMessage.ShopsMessageSurface} surface - * @memberof proto.ShopsMessage - * @instance - */ - ShopsMessage.prototype.surface = 0; - - /** - * ShopsMessage type. - * @member {proto.ShopsMessage.ShopsMessageType} type - * @memberof proto.ShopsMessage - * @instance - */ - ShopsMessage.prototype.type = 0; - - /** - * ShopsMessage messageVersion. - * @member {number} messageVersion - * @memberof proto.ShopsMessage - * @instance - */ - ShopsMessage.prototype.messageVersion = 0; - - /** - * Creates a new ShopsMessage instance using the specified properties. - * @function create - * @memberof proto.ShopsMessage - * @static - * @param {proto.IShopsMessage=} [properties] Properties to set - * @returns {proto.ShopsMessage} ShopsMessage instance - */ - ShopsMessage.create = function create(properties) { - return new ShopsMessage(properties); - }; - - /** - * Encodes the specified ShopsMessage message. Does not implicitly {@link proto.ShopsMessage.verify|verify} messages. - * @function encode - * @memberof proto.ShopsMessage - * @static - * @param {proto.IShopsMessage} message ShopsMessage message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ShopsMessage.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.id != null && Object.hasOwnProperty.call(message, "id")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.id); - if (message.surface != null && Object.hasOwnProperty.call(message, "surface")) - writer.uint32(/* id 2, wireType 0 =*/16).int32(message.surface); - if (message.type != null && Object.hasOwnProperty.call(message, "type")) - writer.uint32(/* id 3, wireType 0 =*/24).int32(message.type); - if (message.messageVersion != null && Object.hasOwnProperty.call(message, "messageVersion")) - writer.uint32(/* id 4, wireType 0 =*/32).int32(message.messageVersion); - return writer; - }; - - /** - * Encodes the specified ShopsMessage message, length delimited. Does not implicitly {@link proto.ShopsMessage.verify|verify} messages. - * @function encodeDelimited - * @memberof proto.ShopsMessage - * @static - * @param {proto.IShopsMessage} message ShopsMessage message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ShopsMessage.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ShopsMessage message from the specified reader or buffer. - * @function decode - * @memberof proto.ShopsMessage - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {proto.ShopsMessage} ShopsMessage - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ShopsMessage.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.ShopsMessage(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.id = reader.string(); - break; - case 2: - message.surface = reader.int32(); - break; - case 3: - message.type = reader.int32(); - break; - case 4: - message.messageVersion = reader.int32(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ShopsMessage message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof proto.ShopsMessage - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {proto.ShopsMessage} ShopsMessage - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ShopsMessage.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ShopsMessage message. - * @function verify - * @memberof proto.ShopsMessage - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ShopsMessage.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.id != null && message.hasOwnProperty("id")) - if (!$util.isString(message.id)) - return "id: string expected"; - if (message.surface != null && message.hasOwnProperty("surface")) - switch (message.surface) { - default: - return "surface: enum value expected"; - case 0: - case 1: - case 2: - case 3: - break; - } - if (message.type != null && message.hasOwnProperty("type")) - switch (message.type) { - default: - return "type: enum value expected"; - case 0: - case 1: - case 2: - case 3: - break; - } - if (message.messageVersion != null && message.hasOwnProperty("messageVersion")) - if (!$util.isInteger(message.messageVersion)) - return "messageVersion: integer expected"; - return null; - }; - - /** - * Creates a ShopsMessage message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof proto.ShopsMessage - * @static - * @param {Object.} object Plain object - * @returns {proto.ShopsMessage} ShopsMessage - */ - ShopsMessage.fromObject = function fromObject(object) { - if (object instanceof $root.proto.ShopsMessage) - return object; - var message = new $root.proto.ShopsMessage(); - if (object.id != null) - message.id = String(object.id); - switch (object.surface) { - case "UNKNOWN_SURFACE": - case 0: - message.surface = 0; - break; - case "FB": - case 1: - message.surface = 1; - break; - case "IG": - case 2: - message.surface = 2; - break; - case "WA": - case 3: - message.surface = 3; - break; - } - switch (object.type) { - case "UNKNOWN_TYPE": - case 0: - message.type = 0; - break; - case "PRODUCT": - case 1: - message.type = 1; - break; - case "STOREFRONT": - case 2: - message.type = 2; - break; - case "COLLECTION": - case 3: - message.type = 3; - break; - } - if (object.messageVersion != null) - message.messageVersion = object.messageVersion | 0; - return message; - }; - - /** - * Creates a plain object from a ShopsMessage message. Also converts values to other types if specified. - * @function toObject - * @memberof proto.ShopsMessage - * @static - * @param {proto.ShopsMessage} message ShopsMessage - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ShopsMessage.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.id = ""; - object.surface = options.enums === String ? "UNKNOWN_SURFACE" : 0; - object.type = options.enums === String ? "UNKNOWN_TYPE" : 0; - object.messageVersion = 0; - } - if (message.id != null && message.hasOwnProperty("id")) - object.id = message.id; - if (message.surface != null && message.hasOwnProperty("surface")) - object.surface = options.enums === String ? $root.proto.ShopsMessage.ShopsMessageSurface[message.surface] : message.surface; - if (message.type != null && message.hasOwnProperty("type")) - object.type = options.enums === String ? $root.proto.ShopsMessage.ShopsMessageType[message.type] : message.type; - if (message.messageVersion != null && message.hasOwnProperty("messageVersion")) - object.messageVersion = message.messageVersion; - return object; - }; - - /** - * Converts this ShopsMessage to JSON. - * @function toJSON - * @memberof proto.ShopsMessage - * @instance - * @returns {Object.} JSON object - */ - ShopsMessage.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - /** - * ShopsMessageSurface enum. - * @name proto.ShopsMessage.ShopsMessageSurface - * @enum {number} - * @property {number} UNKNOWN_SURFACE=0 UNKNOWN_SURFACE value - * @property {number} FB=1 FB value - * @property {number} IG=2 IG value - * @property {number} WA=3 WA value - */ - ShopsMessage.ShopsMessageSurface = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "UNKNOWN_SURFACE"] = 0; - values[valuesById[1] = "FB"] = 1; - values[valuesById[2] = "IG"] = 2; - values[valuesById[3] = "WA"] = 3; - return values; - })(); - - /** - * ShopsMessageType enum. - * @name proto.ShopsMessage.ShopsMessageType - * @enum {number} - * @property {number} UNKNOWN_TYPE=0 UNKNOWN_TYPE value - * @property {number} PRODUCT=1 PRODUCT value - * @property {number} STOREFRONT=2 STOREFRONT value - * @property {number} COLLECTION=3 COLLECTION value - */ - ShopsMessage.ShopsMessageType = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "UNKNOWN_TYPE"] = 0; - values[valuesById[1] = "PRODUCT"] = 1; - values[valuesById[2] = "STOREFRONT"] = 2; - values[valuesById[3] = "COLLECTION"] = 3; - return values; - })(); - - return ShopsMessage; - })(); - - proto.CollectionMessage = (function() { - - /** - * Properties of a CollectionMessage. - * @memberof proto - * @interface ICollectionMessage - * @property {string|null} [bizJid] CollectionMessage bizJid - * @property {string|null} [id] CollectionMessage id - * @property {number|null} [messageVersion] CollectionMessage messageVersion - */ - - /** - * Constructs a new CollectionMessage. - * @memberof proto - * @classdesc Represents a CollectionMessage. - * @implements ICollectionMessage - * @constructor - * @param {proto.ICollectionMessage=} [properties] Properties to set - */ - function CollectionMessage(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * CollectionMessage bizJid. - * @member {string} bizJid - * @memberof proto.CollectionMessage - * @instance - */ - CollectionMessage.prototype.bizJid = ""; - - /** - * CollectionMessage id. - * @member {string} id - * @memberof proto.CollectionMessage - * @instance - */ - CollectionMessage.prototype.id = ""; - - /** - * CollectionMessage messageVersion. - * @member {number} messageVersion - * @memberof proto.CollectionMessage - * @instance - */ - CollectionMessage.prototype.messageVersion = 0; - - /** - * Creates a new CollectionMessage instance using the specified properties. - * @function create - * @memberof proto.CollectionMessage - * @static - * @param {proto.ICollectionMessage=} [properties] Properties to set - * @returns {proto.CollectionMessage} CollectionMessage instance - */ - CollectionMessage.create = function create(properties) { - return new CollectionMessage(properties); - }; - - /** - * Encodes the specified CollectionMessage message. Does not implicitly {@link proto.CollectionMessage.verify|verify} messages. - * @function encode - * @memberof proto.CollectionMessage - * @static - * @param {proto.ICollectionMessage} message CollectionMessage message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - CollectionMessage.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.bizJid != null && Object.hasOwnProperty.call(message, "bizJid")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.bizJid); - if (message.id != null && Object.hasOwnProperty.call(message, "id")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.id); - if (message.messageVersion != null && Object.hasOwnProperty.call(message, "messageVersion")) - writer.uint32(/* id 3, wireType 0 =*/24).int32(message.messageVersion); - return writer; - }; - - /** - * Encodes the specified CollectionMessage message, length delimited. Does not implicitly {@link proto.CollectionMessage.verify|verify} messages. - * @function encodeDelimited - * @memberof proto.CollectionMessage - * @static - * @param {proto.ICollectionMessage} message CollectionMessage message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - CollectionMessage.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a CollectionMessage message from the specified reader or buffer. - * @function decode - * @memberof proto.CollectionMessage - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {proto.CollectionMessage} CollectionMessage - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - CollectionMessage.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.CollectionMessage(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.bizJid = reader.string(); - break; - case 2: - message.id = reader.string(); - break; - case 3: - message.messageVersion = reader.int32(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a CollectionMessage message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof proto.CollectionMessage - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {proto.CollectionMessage} CollectionMessage - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - CollectionMessage.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a CollectionMessage message. - * @function verify - * @memberof proto.CollectionMessage - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - CollectionMessage.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.bizJid != null && message.hasOwnProperty("bizJid")) - if (!$util.isString(message.bizJid)) - return "bizJid: string expected"; - if (message.id != null && message.hasOwnProperty("id")) - if (!$util.isString(message.id)) - return "id: string expected"; - if (message.messageVersion != null && message.hasOwnProperty("messageVersion")) - if (!$util.isInteger(message.messageVersion)) - return "messageVersion: integer expected"; - return null; - }; - - /** - * Creates a CollectionMessage message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof proto.CollectionMessage - * @static - * @param {Object.} object Plain object - * @returns {proto.CollectionMessage} CollectionMessage - */ - CollectionMessage.fromObject = function fromObject(object) { - if (object instanceof $root.proto.CollectionMessage) - return object; - var message = new $root.proto.CollectionMessage(); - if (object.bizJid != null) - message.bizJid = String(object.bizJid); - if (object.id != null) - message.id = String(object.id); - if (object.messageVersion != null) - message.messageVersion = object.messageVersion | 0; - return message; - }; - - /** - * Creates a plain object from a CollectionMessage message. Also converts values to other types if specified. - * @function toObject - * @memberof proto.CollectionMessage - * @static - * @param {proto.CollectionMessage} message CollectionMessage - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - CollectionMessage.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.bizJid = ""; - object.id = ""; - object.messageVersion = 0; - } - if (message.bizJid != null && message.hasOwnProperty("bizJid")) - object.bizJid = message.bizJid; - if (message.id != null && message.hasOwnProperty("id")) - object.id = message.id; - if (message.messageVersion != null && message.hasOwnProperty("messageVersion")) - object.messageVersion = message.messageVersion; - return object; - }; - - /** - * Converts this CollectionMessage to JSON. - * @function toJSON - * @memberof proto.CollectionMessage - * @instance - * @returns {Object.} JSON object - */ - CollectionMessage.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return CollectionMessage; - })(); - - proto.InteractiveMessage = (function() { - - /** - * Properties of an InteractiveMessage. - * @memberof proto - * @interface IInteractiveMessage - * @property {proto.IHeader|null} [header] InteractiveMessage header - * @property {proto.IBody|null} [body] InteractiveMessage body - * @property {proto.IFooter|null} [footer] InteractiveMessage footer - * @property {proto.IContextInfo|null} [contextInfo] InteractiveMessage contextInfo - * @property {proto.IShopsMessage|null} [shopsMessage] InteractiveMessage shopsMessage - * @property {proto.ICollectionMessage|null} [collectionMessage] InteractiveMessage collectionMessage - */ - - /** - * Constructs a new InteractiveMessage. - * @memberof proto - * @classdesc Represents an InteractiveMessage. - * @implements IInteractiveMessage - * @constructor - * @param {proto.IInteractiveMessage=} [properties] Properties to set - */ - function InteractiveMessage(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * InteractiveMessage header. - * @member {proto.IHeader|null|undefined} header - * @memberof proto.InteractiveMessage - * @instance - */ - InteractiveMessage.prototype.header = null; - - /** - * InteractiveMessage body. - * @member {proto.IBody|null|undefined} body - * @memberof proto.InteractiveMessage - * @instance - */ - InteractiveMessage.prototype.body = null; - - /** - * InteractiveMessage footer. - * @member {proto.IFooter|null|undefined} footer - * @memberof proto.InteractiveMessage - * @instance - */ - InteractiveMessage.prototype.footer = null; - - /** - * InteractiveMessage contextInfo. - * @member {proto.IContextInfo|null|undefined} contextInfo - * @memberof proto.InteractiveMessage - * @instance - */ - InteractiveMessage.prototype.contextInfo = null; - - /** - * InteractiveMessage shopsMessage. - * @member {proto.IShopsMessage|null|undefined} shopsMessage - * @memberof proto.InteractiveMessage - * @instance - */ - InteractiveMessage.prototype.shopsMessage = null; - - /** - * InteractiveMessage collectionMessage. - * @member {proto.ICollectionMessage|null|undefined} collectionMessage - * @memberof proto.InteractiveMessage - * @instance - */ - InteractiveMessage.prototype.collectionMessage = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * InteractiveMessage interactiveMessage. - * @member {"shopsMessage"|"collectionMessage"|undefined} interactiveMessage - * @memberof proto.InteractiveMessage - * @instance - */ - Object.defineProperty(InteractiveMessage.prototype, "interactiveMessage", { - get: $util.oneOfGetter($oneOfFields = ["shopsMessage", "collectionMessage"]), - set: $util.oneOfSetter($oneOfFields) - }); - - /** - * Creates a new InteractiveMessage instance using the specified properties. - * @function create - * @memberof proto.InteractiveMessage - * @static - * @param {proto.IInteractiveMessage=} [properties] Properties to set - * @returns {proto.InteractiveMessage} InteractiveMessage instance - */ - InteractiveMessage.create = function create(properties) { - return new InteractiveMessage(properties); - }; - - /** - * Encodes the specified InteractiveMessage message. Does not implicitly {@link proto.InteractiveMessage.verify|verify} messages. - * @function encode - * @memberof proto.InteractiveMessage - * @static - * @param {proto.IInteractiveMessage} message InteractiveMessage message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - InteractiveMessage.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.header != null && Object.hasOwnProperty.call(message, "header")) - $root.proto.Header.encode(message.header, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.body != null && Object.hasOwnProperty.call(message, "body")) - $root.proto.Body.encode(message.body, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.footer != null && Object.hasOwnProperty.call(message, "footer")) - $root.proto.Footer.encode(message.footer, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.shopsMessage != null && Object.hasOwnProperty.call(message, "shopsMessage")) - $root.proto.ShopsMessage.encode(message.shopsMessage, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); - if (message.collectionMessage != null && Object.hasOwnProperty.call(message, "collectionMessage")) - $root.proto.CollectionMessage.encode(message.collectionMessage, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); - if (message.contextInfo != null && Object.hasOwnProperty.call(message, "contextInfo")) - $root.proto.ContextInfo.encode(message.contextInfo, writer.uint32(/* id 15, wireType 2 =*/122).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified InteractiveMessage message, length delimited. Does not implicitly {@link proto.InteractiveMessage.verify|verify} messages. - * @function encodeDelimited - * @memberof proto.InteractiveMessage - * @static - * @param {proto.IInteractiveMessage} message InteractiveMessage message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - InteractiveMessage.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes an InteractiveMessage message from the specified reader or buffer. - * @function decode - * @memberof proto.InteractiveMessage - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {proto.InteractiveMessage} InteractiveMessage - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - InteractiveMessage.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.InteractiveMessage(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.header = $root.proto.Header.decode(reader, reader.uint32()); - break; - case 2: - message.body = $root.proto.Body.decode(reader, reader.uint32()); - break; - case 3: - message.footer = $root.proto.Footer.decode(reader, reader.uint32()); - break; - case 15: - message.contextInfo = $root.proto.ContextInfo.decode(reader, reader.uint32()); - break; - case 4: - message.shopsMessage = $root.proto.ShopsMessage.decode(reader, reader.uint32()); - break; - case 5: - message.collectionMessage = $root.proto.CollectionMessage.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes an InteractiveMessage message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof proto.InteractiveMessage - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {proto.InteractiveMessage} InteractiveMessage - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - InteractiveMessage.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies an InteractiveMessage message. - * @function verify - * @memberof proto.InteractiveMessage - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - InteractiveMessage.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - var properties = {}; - if (message.header != null && message.hasOwnProperty("header")) { - var error = $root.proto.Header.verify(message.header); - if (error) - return "header." + error; - } - if (message.body != null && message.hasOwnProperty("body")) { - var error = $root.proto.Body.verify(message.body); - if (error) - return "body." + error; - } - if (message.footer != null && message.hasOwnProperty("footer")) { - var error = $root.proto.Footer.verify(message.footer); - if (error) - return "footer." + error; - } - if (message.contextInfo != null && message.hasOwnProperty("contextInfo")) { - var error = $root.proto.ContextInfo.verify(message.contextInfo); - if (error) - return "contextInfo." + error; - } - if (message.shopsMessage != null && message.hasOwnProperty("shopsMessage")) { - properties.interactiveMessage = 1; - { - var error = $root.proto.ShopsMessage.verify(message.shopsMessage); - if (error) - return "shopsMessage." + error; - } - } - if (message.collectionMessage != null && message.hasOwnProperty("collectionMessage")) { - if (properties.interactiveMessage === 1) - return "interactiveMessage: multiple values"; - properties.interactiveMessage = 1; - { - var error = $root.proto.CollectionMessage.verify(message.collectionMessage); - if (error) - return "collectionMessage." + error; - } - } - return null; - }; - - /** - * Creates an InteractiveMessage message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof proto.InteractiveMessage - * @static - * @param {Object.} object Plain object - * @returns {proto.InteractiveMessage} InteractiveMessage - */ - InteractiveMessage.fromObject = function fromObject(object) { - if (object instanceof $root.proto.InteractiveMessage) - return object; - var message = new $root.proto.InteractiveMessage(); - if (object.header != null) { - if (typeof object.header !== "object") - throw TypeError(".proto.InteractiveMessage.header: object expected"); - message.header = $root.proto.Header.fromObject(object.header); - } - if (object.body != null) { - if (typeof object.body !== "object") - throw TypeError(".proto.InteractiveMessage.body: object expected"); - message.body = $root.proto.Body.fromObject(object.body); - } - if (object.footer != null) { - if (typeof object.footer !== "object") - throw TypeError(".proto.InteractiveMessage.footer: object expected"); - message.footer = $root.proto.Footer.fromObject(object.footer); - } - if (object.contextInfo != null) { - if (typeof object.contextInfo !== "object") - throw TypeError(".proto.InteractiveMessage.contextInfo: object expected"); - message.contextInfo = $root.proto.ContextInfo.fromObject(object.contextInfo); - } - if (object.shopsMessage != null) { - if (typeof object.shopsMessage !== "object") - throw TypeError(".proto.InteractiveMessage.shopsMessage: object expected"); - message.shopsMessage = $root.proto.ShopsMessage.fromObject(object.shopsMessage); - } - if (object.collectionMessage != null) { - if (typeof object.collectionMessage !== "object") - throw TypeError(".proto.InteractiveMessage.collectionMessage: object expected"); - message.collectionMessage = $root.proto.CollectionMessage.fromObject(object.collectionMessage); - } - return message; - }; - - /** - * Creates a plain object from an InteractiveMessage message. Also converts values to other types if specified. - * @function toObject - * @memberof proto.InteractiveMessage - * @static - * @param {proto.InteractiveMessage} message InteractiveMessage - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - InteractiveMessage.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.header = null; - object.body = null; - object.footer = null; - object.contextInfo = null; - } - if (message.header != null && message.hasOwnProperty("header")) - object.header = $root.proto.Header.toObject(message.header, options); - if (message.body != null && message.hasOwnProperty("body")) - object.body = $root.proto.Body.toObject(message.body, options); - if (message.footer != null && message.hasOwnProperty("footer")) - object.footer = $root.proto.Footer.toObject(message.footer, options); - if (message.shopsMessage != null && message.hasOwnProperty("shopsMessage")) { - object.shopsMessage = $root.proto.ShopsMessage.toObject(message.shopsMessage, options); - if (options.oneofs) - object.interactiveMessage = "shopsMessage"; - } - if (message.collectionMessage != null && message.hasOwnProperty("collectionMessage")) { - object.collectionMessage = $root.proto.CollectionMessage.toObject(message.collectionMessage, options); - if (options.oneofs) - object.interactiveMessage = "collectionMessage"; - } - if (message.contextInfo != null && message.hasOwnProperty("contextInfo")) - object.contextInfo = $root.proto.ContextInfo.toObject(message.contextInfo, options); - return object; - }; - - /** - * Converts this InteractiveMessage to JSON. - * @function toJSON - * @memberof proto.InteractiveMessage - * @instance - * @returns {Object.} JSON object - */ - InteractiveMessage.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return InteractiveMessage; - })(); - proto.GroupInviteMessage = (function() { /** @@ -25528,7 +43169,6 @@ $root.proto = (function() { * @property {proto.IButtonsMessage|null} [buttonsMessage] Message buttonsMessage * @property {proto.IButtonsResponseMessage|null} [buttonsResponseMessage] Message buttonsResponseMessage * @property {proto.IPaymentInviteMessage|null} [paymentInviteMessage] Message paymentInviteMessage - * @property {proto.IInteractiveMessage|null} [interactiveMessage] Message interactiveMessage */ /** @@ -25834,14 +43474,6 @@ $root.proto = (function() { */ Message.prototype.paymentInviteMessage = null; - /** - * Message interactiveMessage. - * @member {proto.IInteractiveMessage|null|undefined} interactiveMessage - * @memberof proto.Message - * @instance - */ - Message.prototype.interactiveMessage = null; - /** * Creates a new Message instance using the specified properties. * @function create @@ -25938,8 +43570,6 @@ $root.proto = (function() { $root.proto.ButtonsResponseMessage.encode(message.buttonsResponseMessage, writer.uint32(/* id 43, wireType 2 =*/346).fork()).ldelim(); if (message.paymentInviteMessage != null && Object.hasOwnProperty.call(message, "paymentInviteMessage")) $root.proto.PaymentInviteMessage.encode(message.paymentInviteMessage, writer.uint32(/* id 44, wireType 2 =*/354).fork()).ldelim(); - if (message.interactiveMessage != null && Object.hasOwnProperty.call(message, "interactiveMessage")) - $root.proto.InteractiveMessage.encode(message.interactiveMessage, writer.uint32(/* id 45, wireType 2 =*/362).fork()).ldelim(); return writer; }; @@ -26082,9 +43712,6 @@ $root.proto = (function() { case 44: message.paymentInviteMessage = $root.proto.PaymentInviteMessage.decode(reader, reader.uint32()); break; - case 45: - message.interactiveMessage = $root.proto.InteractiveMessage.decode(reader, reader.uint32()); - break; default: reader.skipType(tag & 7); break; @@ -26298,11 +43925,6 @@ $root.proto = (function() { if (error) return "paymentInviteMessage." + error; } - if (message.interactiveMessage != null && message.hasOwnProperty("interactiveMessage")) { - var error = $root.proto.InteractiveMessage.verify(message.interactiveMessage); - if (error) - return "interactiveMessage." + error; - } return null; }; @@ -26495,11 +44117,6 @@ $root.proto = (function() { throw TypeError(".proto.Message.paymentInviteMessage: object expected"); message.paymentInviteMessage = $root.proto.PaymentInviteMessage.fromObject(object.paymentInviteMessage); } - if (object.interactiveMessage != null) { - if (typeof object.interactiveMessage !== "object") - throw TypeError(".proto.Message.interactiveMessage: object expected"); - message.interactiveMessage = $root.proto.InteractiveMessage.fromObject(object.interactiveMessage); - } return message; }; @@ -26553,7 +44170,6 @@ $root.proto = (function() { object.buttonsMessage = null; object.buttonsResponseMessage = null; object.paymentInviteMessage = null; - object.interactiveMessage = null; } if (message.conversation != null && message.hasOwnProperty("conversation")) object.conversation = message.conversation; @@ -26627,8 +44243,6 @@ $root.proto = (function() { object.buttonsResponseMessage = $root.proto.ButtonsResponseMessage.toObject(message.buttonsResponseMessage, options); if (message.paymentInviteMessage != null && message.hasOwnProperty("paymentInviteMessage")) object.paymentInviteMessage = $root.proto.PaymentInviteMessage.toObject(message.paymentInviteMessage, options); - if (message.interactiveMessage != null && message.hasOwnProperty("interactiveMessage")) - object.interactiveMessage = $root.proto.InteractiveMessage.toObject(message.interactiveMessage, options); return object; }; @@ -26646,24 +44260,27 @@ $root.proto = (function() { return Message; })(); - proto.DisappearingMode = (function() { + proto.CompanionProps = (function() { /** - * Properties of a DisappearingMode. + * Properties of a CompanionProps. * @memberof proto - * @interface IDisappearingMode - * @property {proto.DisappearingMode.DisappearingModeInitiator|null} [initiator] DisappearingMode initiator + * @interface ICompanionProps + * @property {string|null} [os] CompanionProps os + * @property {proto.IAppVersion|null} [version] CompanionProps version + * @property {proto.CompanionProps.CompanionPropsPlatformType|null} [platformType] CompanionProps platformType + * @property {boolean|null} [requireFullSync] CompanionProps requireFullSync */ /** - * Constructs a new DisappearingMode. + * Constructs a new CompanionProps. * @memberof proto - * @classdesc Represents a DisappearingMode. - * @implements IDisappearingMode + * @classdesc Represents a CompanionProps. + * @implements ICompanionProps * @constructor - * @param {proto.IDisappearingMode=} [properties] Properties to set + * @param {proto.ICompanionProps=} [properties] Properties to set */ - function DisappearingMode(properties) { + function CompanionProps(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -26671,75 +44288,114 @@ $root.proto = (function() { } /** - * DisappearingMode initiator. - * @member {proto.DisappearingMode.DisappearingModeInitiator} initiator - * @memberof proto.DisappearingMode + * CompanionProps os. + * @member {string} os + * @memberof proto.CompanionProps * @instance */ - DisappearingMode.prototype.initiator = 0; + CompanionProps.prototype.os = ""; /** - * Creates a new DisappearingMode instance using the specified properties. - * @function create - * @memberof proto.DisappearingMode - * @static - * @param {proto.IDisappearingMode=} [properties] Properties to set - * @returns {proto.DisappearingMode} DisappearingMode instance + * CompanionProps version. + * @member {proto.IAppVersion|null|undefined} version + * @memberof proto.CompanionProps + * @instance */ - DisappearingMode.create = function create(properties) { - return new DisappearingMode(properties); + CompanionProps.prototype.version = null; + + /** + * CompanionProps platformType. + * @member {proto.CompanionProps.CompanionPropsPlatformType} platformType + * @memberof proto.CompanionProps + * @instance + */ + CompanionProps.prototype.platformType = 0; + + /** + * CompanionProps requireFullSync. + * @member {boolean} requireFullSync + * @memberof proto.CompanionProps + * @instance + */ + CompanionProps.prototype.requireFullSync = false; + + /** + * Creates a new CompanionProps instance using the specified properties. + * @function create + * @memberof proto.CompanionProps + * @static + * @param {proto.ICompanionProps=} [properties] Properties to set + * @returns {proto.CompanionProps} CompanionProps instance + */ + CompanionProps.create = function create(properties) { + return new CompanionProps(properties); }; /** - * Encodes the specified DisappearingMode message. Does not implicitly {@link proto.DisappearingMode.verify|verify} messages. + * Encodes the specified CompanionProps message. Does not implicitly {@link proto.CompanionProps.verify|verify} messages. * @function encode - * @memberof proto.DisappearingMode + * @memberof proto.CompanionProps * @static - * @param {proto.IDisappearingMode} message DisappearingMode message or plain object to encode + * @param {proto.ICompanionProps} message CompanionProps message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - DisappearingMode.encode = function encode(message, writer) { + CompanionProps.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.initiator != null && Object.hasOwnProperty.call(message, "initiator")) - writer.uint32(/* id 1, wireType 0 =*/8).int32(message.initiator); + if (message.os != null && Object.hasOwnProperty.call(message, "os")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.os); + if (message.version != null && Object.hasOwnProperty.call(message, "version")) + $root.proto.AppVersion.encode(message.version, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.platformType != null && Object.hasOwnProperty.call(message, "platformType")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.platformType); + if (message.requireFullSync != null && Object.hasOwnProperty.call(message, "requireFullSync")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.requireFullSync); return writer; }; /** - * Encodes the specified DisappearingMode message, length delimited. Does not implicitly {@link proto.DisappearingMode.verify|verify} messages. + * Encodes the specified CompanionProps message, length delimited. Does not implicitly {@link proto.CompanionProps.verify|verify} messages. * @function encodeDelimited - * @memberof proto.DisappearingMode + * @memberof proto.CompanionProps * @static - * @param {proto.IDisappearingMode} message DisappearingMode message or plain object to encode + * @param {proto.ICompanionProps} message CompanionProps message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - DisappearingMode.encodeDelimited = function encodeDelimited(message, writer) { + CompanionProps.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a DisappearingMode message from the specified reader or buffer. + * Decodes a CompanionProps message from the specified reader or buffer. * @function decode - * @memberof proto.DisappearingMode + * @memberof proto.CompanionProps * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {proto.DisappearingMode} DisappearingMode + * @returns {proto.CompanionProps} CompanionProps * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - DisappearingMode.decode = function decode(reader, length) { + CompanionProps.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.DisappearingMode(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.CompanionProps(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.initiator = reader.int32(); + message.os = reader.string(); + break; + case 2: + message.version = $root.proto.AppVersion.decode(reader, reader.uint32()); + break; + case 3: + message.platformType = reader.int32(); + break; + case 4: + message.requireFullSync = reader.bool(); break; default: reader.skipType(tag & 7); @@ -26750,148 +44406,242 @@ $root.proto = (function() { }; /** - * Decodes a DisappearingMode message from the specified reader or buffer, length delimited. + * Decodes a CompanionProps message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof proto.DisappearingMode + * @memberof proto.CompanionProps * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {proto.DisappearingMode} DisappearingMode + * @returns {proto.CompanionProps} CompanionProps * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - DisappearingMode.decodeDelimited = function decodeDelimited(reader) { + CompanionProps.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a DisappearingMode message. + * Verifies a CompanionProps message. * @function verify - * @memberof proto.DisappearingMode + * @memberof proto.CompanionProps * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - DisappearingMode.verify = function verify(message) { + CompanionProps.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.initiator != null && message.hasOwnProperty("initiator")) - switch (message.initiator) { + if (message.os != null && message.hasOwnProperty("os")) + if (!$util.isString(message.os)) + return "os: string expected"; + if (message.version != null && message.hasOwnProperty("version")) { + var error = $root.proto.AppVersion.verify(message.version); + if (error) + return "version." + error; + } + if (message.platformType != null && message.hasOwnProperty("platformType")) + switch (message.platformType) { default: - return "initiator: enum value expected"; + return "platformType: enum value expected"; case 0: case 1: case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: break; } + if (message.requireFullSync != null && message.hasOwnProperty("requireFullSync")) + if (typeof message.requireFullSync !== "boolean") + return "requireFullSync: boolean expected"; return null; }; /** - * Creates a DisappearingMode message from a plain object. Also converts values to their respective internal types. + * Creates a CompanionProps message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof proto.DisappearingMode + * @memberof proto.CompanionProps * @static * @param {Object.} object Plain object - * @returns {proto.DisappearingMode} DisappearingMode + * @returns {proto.CompanionProps} CompanionProps */ - DisappearingMode.fromObject = function fromObject(object) { - if (object instanceof $root.proto.DisappearingMode) + CompanionProps.fromObject = function fromObject(object) { + if (object instanceof $root.proto.CompanionProps) return object; - var message = new $root.proto.DisappearingMode(); - switch (object.initiator) { - case "CHANGED_IN_CHAT": + var message = new $root.proto.CompanionProps(); + if (object.os != null) + message.os = String(object.os); + if (object.version != null) { + if (typeof object.version !== "object") + throw TypeError(".proto.CompanionProps.version: object expected"); + message.version = $root.proto.AppVersion.fromObject(object.version); + } + switch (object.platformType) { + case "UNKNOWN": case 0: - message.initiator = 0; + message.platformType = 0; break; - case "INITIATED_BY_ME": + case "CHROME": case 1: - message.initiator = 1; + message.platformType = 1; break; - case "INITIATED_BY_OTHER": + case "FIREFOX": case 2: - message.initiator = 2; + message.platformType = 2; + break; + case "IE": + case 3: + message.platformType = 3; + break; + case "OPERA": + case 4: + message.platformType = 4; + break; + case "SAFARI": + case 5: + message.platformType = 5; + break; + case "EDGE": + case 6: + message.platformType = 6; + break; + case "DESKTOP": + case 7: + message.platformType = 7; + break; + case "IPAD": + case 8: + message.platformType = 8; + break; + case "ANDROID_TABLET": + case 9: + message.platformType = 9; + break; + case "OHANA": + case 10: + message.platformType = 10; + break; + case "ALOHA": + case 11: + message.platformType = 11; + break; + case "CATALINA": + case 12: + message.platformType = 12; break; } + if (object.requireFullSync != null) + message.requireFullSync = Boolean(object.requireFullSync); return message; }; /** - * Creates a plain object from a DisappearingMode message. Also converts values to other types if specified. + * Creates a plain object from a CompanionProps message. Also converts values to other types if specified. * @function toObject - * @memberof proto.DisappearingMode + * @memberof proto.CompanionProps * @static - * @param {proto.DisappearingMode} message DisappearingMode + * @param {proto.CompanionProps} message CompanionProps * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - DisappearingMode.toObject = function toObject(message, options) { + CompanionProps.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; - if (options.defaults) - object.initiator = options.enums === String ? "CHANGED_IN_CHAT" : 0; - if (message.initiator != null && message.hasOwnProperty("initiator")) - object.initiator = options.enums === String ? $root.proto.DisappearingMode.DisappearingModeInitiator[message.initiator] : message.initiator; + if (options.defaults) { + object.os = ""; + object.version = null; + object.platformType = options.enums === String ? "UNKNOWN" : 0; + object.requireFullSync = false; + } + if (message.os != null && message.hasOwnProperty("os")) + object.os = message.os; + if (message.version != null && message.hasOwnProperty("version")) + object.version = $root.proto.AppVersion.toObject(message.version, options); + if (message.platformType != null && message.hasOwnProperty("platformType")) + object.platformType = options.enums === String ? $root.proto.CompanionProps.CompanionPropsPlatformType[message.platformType] : message.platformType; + if (message.requireFullSync != null && message.hasOwnProperty("requireFullSync")) + object.requireFullSync = message.requireFullSync; return object; }; /** - * Converts this DisappearingMode to JSON. + * Converts this CompanionProps to JSON. * @function toJSON - * @memberof proto.DisappearingMode + * @memberof proto.CompanionProps * @instance * @returns {Object.} JSON object */ - DisappearingMode.prototype.toJSON = function toJSON() { + CompanionProps.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * DisappearingModeInitiator enum. - * @name proto.DisappearingMode.DisappearingModeInitiator + * CompanionPropsPlatformType enum. + * @name proto.CompanionProps.CompanionPropsPlatformType * @enum {number} - * @property {number} CHANGED_IN_CHAT=0 CHANGED_IN_CHAT value - * @property {number} INITIATED_BY_ME=1 INITIATED_BY_ME value - * @property {number} INITIATED_BY_OTHER=2 INITIATED_BY_OTHER value + * @property {number} UNKNOWN=0 UNKNOWN value + * @property {number} CHROME=1 CHROME value + * @property {number} FIREFOX=2 FIREFOX value + * @property {number} IE=3 IE value + * @property {number} OPERA=4 OPERA value + * @property {number} SAFARI=5 SAFARI value + * @property {number} EDGE=6 EDGE value + * @property {number} DESKTOP=7 DESKTOP value + * @property {number} IPAD=8 IPAD value + * @property {number} ANDROID_TABLET=9 ANDROID_TABLET value + * @property {number} OHANA=10 OHANA value + * @property {number} ALOHA=11 ALOHA value + * @property {number} CATALINA=12 CATALINA value */ - DisappearingMode.DisappearingModeInitiator = (function() { + CompanionProps.CompanionPropsPlatformType = (function() { var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "CHANGED_IN_CHAT"] = 0; - values[valuesById[1] = "INITIATED_BY_ME"] = 1; - values[valuesById[2] = "INITIATED_BY_OTHER"] = 2; + values[valuesById[0] = "UNKNOWN"] = 0; + values[valuesById[1] = "CHROME"] = 1; + values[valuesById[2] = "FIREFOX"] = 2; + values[valuesById[3] = "IE"] = 3; + values[valuesById[4] = "OPERA"] = 4; + values[valuesById[5] = "SAFARI"] = 5; + values[valuesById[6] = "EDGE"] = 6; + values[valuesById[7] = "DESKTOP"] = 7; + values[valuesById[8] = "IPAD"] = 8; + values[valuesById[9] = "ANDROID_TABLET"] = 9; + values[valuesById[10] = "OHANA"] = 10; + values[valuesById[11] = "ALOHA"] = 11; + values[valuesById[12] = "CATALINA"] = 12; return values; })(); - return DisappearingMode; + return CompanionProps; })(); - proto.PaymentBackground = (function() { + proto.ADVSignedDeviceIdentityHMAC = (function() { /** - * Properties of a PaymentBackground. + * Properties of a ADVSignedDeviceIdentityHMAC. * @memberof proto - * @interface IPaymentBackground - * @property {string|null} [id] PaymentBackground id - * @property {number|Long|null} [fileLength] PaymentBackground fileLength - * @property {number|null} [width] PaymentBackground width - * @property {number|null} [height] PaymentBackground height - * @property {string|null} [mimetype] PaymentBackground mimetype - * @property {number|null} [placeholderArgb] PaymentBackground placeholderArgb - * @property {number|null} [textArgb] PaymentBackground textArgb - * @property {number|null} [subtextArgb] PaymentBackground subtextArgb + * @interface IADVSignedDeviceIdentityHMAC + * @property {Uint8Array|null} [details] ADVSignedDeviceIdentityHMAC details + * @property {Uint8Array|null} [hmac] ADVSignedDeviceIdentityHMAC hmac */ /** - * Constructs a new PaymentBackground. + * Constructs a new ADVSignedDeviceIdentityHMAC. * @memberof proto - * @classdesc Represents a PaymentBackground. - * @implements IPaymentBackground + * @classdesc Represents a ADVSignedDeviceIdentityHMAC. + * @implements IADVSignedDeviceIdentityHMAC * @constructor - * @param {proto.IPaymentBackground=} [properties] Properties to set + * @param {proto.IADVSignedDeviceIdentityHMAC=} [properties] Properties to set */ - function PaymentBackground(properties) { + function ADVSignedDeviceIdentityHMAC(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -26899,166 +44649,88 @@ $root.proto = (function() { } /** - * PaymentBackground id. - * @member {string} id - * @memberof proto.PaymentBackground + * ADVSignedDeviceIdentityHMAC details. + * @member {Uint8Array} details + * @memberof proto.ADVSignedDeviceIdentityHMAC * @instance */ - PaymentBackground.prototype.id = ""; + ADVSignedDeviceIdentityHMAC.prototype.details = $util.newBuffer([]); /** - * PaymentBackground fileLength. - * @member {number|Long} fileLength - * @memberof proto.PaymentBackground + * ADVSignedDeviceIdentityHMAC hmac. + * @member {Uint8Array} hmac + * @memberof proto.ADVSignedDeviceIdentityHMAC * @instance */ - PaymentBackground.prototype.fileLength = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + ADVSignedDeviceIdentityHMAC.prototype.hmac = $util.newBuffer([]); /** - * PaymentBackground width. - * @member {number} width - * @memberof proto.PaymentBackground - * @instance - */ - PaymentBackground.prototype.width = 0; - - /** - * PaymentBackground height. - * @member {number} height - * @memberof proto.PaymentBackground - * @instance - */ - PaymentBackground.prototype.height = 0; - - /** - * PaymentBackground mimetype. - * @member {string} mimetype - * @memberof proto.PaymentBackground - * @instance - */ - PaymentBackground.prototype.mimetype = ""; - - /** - * PaymentBackground placeholderArgb. - * @member {number} placeholderArgb - * @memberof proto.PaymentBackground - * @instance - */ - PaymentBackground.prototype.placeholderArgb = 0; - - /** - * PaymentBackground textArgb. - * @member {number} textArgb - * @memberof proto.PaymentBackground - * @instance - */ - PaymentBackground.prototype.textArgb = 0; - - /** - * PaymentBackground subtextArgb. - * @member {number} subtextArgb - * @memberof proto.PaymentBackground - * @instance - */ - PaymentBackground.prototype.subtextArgb = 0; - - /** - * Creates a new PaymentBackground instance using the specified properties. + * Creates a new ADVSignedDeviceIdentityHMAC instance using the specified properties. * @function create - * @memberof proto.PaymentBackground + * @memberof proto.ADVSignedDeviceIdentityHMAC * @static - * @param {proto.IPaymentBackground=} [properties] Properties to set - * @returns {proto.PaymentBackground} PaymentBackground instance + * @param {proto.IADVSignedDeviceIdentityHMAC=} [properties] Properties to set + * @returns {proto.ADVSignedDeviceIdentityHMAC} ADVSignedDeviceIdentityHMAC instance */ - PaymentBackground.create = function create(properties) { - return new PaymentBackground(properties); + ADVSignedDeviceIdentityHMAC.create = function create(properties) { + return new ADVSignedDeviceIdentityHMAC(properties); }; /** - * Encodes the specified PaymentBackground message. Does not implicitly {@link proto.PaymentBackground.verify|verify} messages. + * Encodes the specified ADVSignedDeviceIdentityHMAC message. Does not implicitly {@link proto.ADVSignedDeviceIdentityHMAC.verify|verify} messages. * @function encode - * @memberof proto.PaymentBackground + * @memberof proto.ADVSignedDeviceIdentityHMAC * @static - * @param {proto.IPaymentBackground} message PaymentBackground message or plain object to encode + * @param {proto.IADVSignedDeviceIdentityHMAC} message ADVSignedDeviceIdentityHMAC message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - PaymentBackground.encode = function encode(message, writer) { + ADVSignedDeviceIdentityHMAC.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.id != null && Object.hasOwnProperty.call(message, "id")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.id); - if (message.fileLength != null && Object.hasOwnProperty.call(message, "fileLength")) - writer.uint32(/* id 2, wireType 0 =*/16).uint64(message.fileLength); - if (message.width != null && Object.hasOwnProperty.call(message, "width")) - writer.uint32(/* id 3, wireType 0 =*/24).uint32(message.width); - if (message.height != null && Object.hasOwnProperty.call(message, "height")) - writer.uint32(/* id 4, wireType 0 =*/32).uint32(message.height); - if (message.mimetype != null && Object.hasOwnProperty.call(message, "mimetype")) - writer.uint32(/* id 5, wireType 2 =*/42).string(message.mimetype); - if (message.placeholderArgb != null && Object.hasOwnProperty.call(message, "placeholderArgb")) - writer.uint32(/* id 6, wireType 5 =*/53).fixed32(message.placeholderArgb); - if (message.textArgb != null && Object.hasOwnProperty.call(message, "textArgb")) - writer.uint32(/* id 7, wireType 5 =*/61).fixed32(message.textArgb); - if (message.subtextArgb != null && Object.hasOwnProperty.call(message, "subtextArgb")) - writer.uint32(/* id 8, wireType 5 =*/69).fixed32(message.subtextArgb); + if (message.details != null && Object.hasOwnProperty.call(message, "details")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.details); + if (message.hmac != null && Object.hasOwnProperty.call(message, "hmac")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.hmac); return writer; }; /** - * Encodes the specified PaymentBackground message, length delimited. Does not implicitly {@link proto.PaymentBackground.verify|verify} messages. + * Encodes the specified ADVSignedDeviceIdentityHMAC message, length delimited. Does not implicitly {@link proto.ADVSignedDeviceIdentityHMAC.verify|verify} messages. * @function encodeDelimited - * @memberof proto.PaymentBackground + * @memberof proto.ADVSignedDeviceIdentityHMAC * @static - * @param {proto.IPaymentBackground} message PaymentBackground message or plain object to encode + * @param {proto.IADVSignedDeviceIdentityHMAC} message ADVSignedDeviceIdentityHMAC message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - PaymentBackground.encodeDelimited = function encodeDelimited(message, writer) { + ADVSignedDeviceIdentityHMAC.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a PaymentBackground message from the specified reader or buffer. + * Decodes a ADVSignedDeviceIdentityHMAC message from the specified reader or buffer. * @function decode - * @memberof proto.PaymentBackground + * @memberof proto.ADVSignedDeviceIdentityHMAC * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {proto.PaymentBackground} PaymentBackground + * @returns {proto.ADVSignedDeviceIdentityHMAC} ADVSignedDeviceIdentityHMAC * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - PaymentBackground.decode = function decode(reader, length) { + ADVSignedDeviceIdentityHMAC.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.PaymentBackground(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.ADVSignedDeviceIdentityHMAC(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.id = reader.string(); + message.details = reader.bytes(); break; case 2: - message.fileLength = reader.uint64(); - break; - case 3: - message.width = reader.uint32(); - break; - case 4: - message.height = reader.uint32(); - break; - case 5: - message.mimetype = reader.string(); - break; - case 6: - message.placeholderArgb = reader.fixed32(); - break; - case 7: - message.textArgb = reader.fixed32(); - break; - case 8: - message.subtextArgb = reader.fixed32(); + message.hmac = reader.bytes(); break; default: reader.skipType(tag & 7); @@ -27069,180 +44741,671 @@ $root.proto = (function() { }; /** - * Decodes a PaymentBackground message from the specified reader or buffer, length delimited. + * Decodes a ADVSignedDeviceIdentityHMAC message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof proto.PaymentBackground + * @memberof proto.ADVSignedDeviceIdentityHMAC * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {proto.PaymentBackground} PaymentBackground + * @returns {proto.ADVSignedDeviceIdentityHMAC} ADVSignedDeviceIdentityHMAC * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - PaymentBackground.decodeDelimited = function decodeDelimited(reader) { + ADVSignedDeviceIdentityHMAC.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a PaymentBackground message. + * Verifies a ADVSignedDeviceIdentityHMAC message. * @function verify - * @memberof proto.PaymentBackground + * @memberof proto.ADVSignedDeviceIdentityHMAC * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - PaymentBackground.verify = function verify(message) { + ADVSignedDeviceIdentityHMAC.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.id != null && message.hasOwnProperty("id")) - if (!$util.isString(message.id)) - return "id: string expected"; - if (message.fileLength != null && message.hasOwnProperty("fileLength")) - if (!$util.isInteger(message.fileLength) && !(message.fileLength && $util.isInteger(message.fileLength.low) && $util.isInteger(message.fileLength.high))) - return "fileLength: integer|Long expected"; - if (message.width != null && message.hasOwnProperty("width")) - if (!$util.isInteger(message.width)) - return "width: integer expected"; - if (message.height != null && message.hasOwnProperty("height")) - if (!$util.isInteger(message.height)) - return "height: integer expected"; - if (message.mimetype != null && message.hasOwnProperty("mimetype")) - if (!$util.isString(message.mimetype)) - return "mimetype: string expected"; - if (message.placeholderArgb != null && message.hasOwnProperty("placeholderArgb")) - if (!$util.isInteger(message.placeholderArgb)) - return "placeholderArgb: integer expected"; - if (message.textArgb != null && message.hasOwnProperty("textArgb")) - if (!$util.isInteger(message.textArgb)) - return "textArgb: integer expected"; - if (message.subtextArgb != null && message.hasOwnProperty("subtextArgb")) - if (!$util.isInteger(message.subtextArgb)) - return "subtextArgb: integer expected"; + if (message.details != null && message.hasOwnProperty("details")) + if (!(message.details && typeof message.details.length === "number" || $util.isString(message.details))) + return "details: buffer expected"; + if (message.hmac != null && message.hasOwnProperty("hmac")) + if (!(message.hmac && typeof message.hmac.length === "number" || $util.isString(message.hmac))) + return "hmac: buffer expected"; return null; }; /** - * Creates a PaymentBackground message from a plain object. Also converts values to their respective internal types. + * Creates a ADVSignedDeviceIdentityHMAC message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof proto.PaymentBackground + * @memberof proto.ADVSignedDeviceIdentityHMAC * @static * @param {Object.} object Plain object - * @returns {proto.PaymentBackground} PaymentBackground + * @returns {proto.ADVSignedDeviceIdentityHMAC} ADVSignedDeviceIdentityHMAC */ - PaymentBackground.fromObject = function fromObject(object) { - if (object instanceof $root.proto.PaymentBackground) + ADVSignedDeviceIdentityHMAC.fromObject = function fromObject(object) { + if (object instanceof $root.proto.ADVSignedDeviceIdentityHMAC) return object; - var message = new $root.proto.PaymentBackground(); - if (object.id != null) - message.id = String(object.id); - if (object.fileLength != null) - if ($util.Long) - (message.fileLength = $util.Long.fromValue(object.fileLength)).unsigned = true; - else if (typeof object.fileLength === "string") - message.fileLength = parseInt(object.fileLength, 10); - else if (typeof object.fileLength === "number") - message.fileLength = object.fileLength; - else if (typeof object.fileLength === "object") - message.fileLength = new $util.LongBits(object.fileLength.low >>> 0, object.fileLength.high >>> 0).toNumber(true); - if (object.width != null) - message.width = object.width >>> 0; - if (object.height != null) - message.height = object.height >>> 0; - if (object.mimetype != null) - message.mimetype = String(object.mimetype); - if (object.placeholderArgb != null) - message.placeholderArgb = object.placeholderArgb >>> 0; - if (object.textArgb != null) - message.textArgb = object.textArgb >>> 0; - if (object.subtextArgb != null) - message.subtextArgb = object.subtextArgb >>> 0; + var message = new $root.proto.ADVSignedDeviceIdentityHMAC(); + if (object.details != null) + if (typeof object.details === "string") + $util.base64.decode(object.details, message.details = $util.newBuffer($util.base64.length(object.details)), 0); + else if (object.details.length) + message.details = object.details; + if (object.hmac != null) + if (typeof object.hmac === "string") + $util.base64.decode(object.hmac, message.hmac = $util.newBuffer($util.base64.length(object.hmac)), 0); + else if (object.hmac.length) + message.hmac = object.hmac; return message; }; /** - * Creates a plain object from a PaymentBackground message. Also converts values to other types if specified. + * Creates a plain object from a ADVSignedDeviceIdentityHMAC message. Also converts values to other types if specified. * @function toObject - * @memberof proto.PaymentBackground + * @memberof proto.ADVSignedDeviceIdentityHMAC * @static - * @param {proto.PaymentBackground} message PaymentBackground + * @param {proto.ADVSignedDeviceIdentityHMAC} message ADVSignedDeviceIdentityHMAC * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - PaymentBackground.toObject = function toObject(message, options) { + ADVSignedDeviceIdentityHMAC.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { - object.id = ""; + if (options.bytes === String) + object.details = ""; + else { + object.details = []; + if (options.bytes !== Array) + object.details = $util.newBuffer(object.details); + } + if (options.bytes === String) + object.hmac = ""; + else { + object.hmac = []; + if (options.bytes !== Array) + object.hmac = $util.newBuffer(object.hmac); + } + } + if (message.details != null && message.hasOwnProperty("details")) + object.details = options.bytes === String ? $util.base64.encode(message.details, 0, message.details.length) : options.bytes === Array ? Array.prototype.slice.call(message.details) : message.details; + if (message.hmac != null && message.hasOwnProperty("hmac")) + object.hmac = options.bytes === String ? $util.base64.encode(message.hmac, 0, message.hmac.length) : options.bytes === Array ? Array.prototype.slice.call(message.hmac) : message.hmac; + return object; + }; + + /** + * Converts this ADVSignedDeviceIdentityHMAC to JSON. + * @function toJSON + * @memberof proto.ADVSignedDeviceIdentityHMAC + * @instance + * @returns {Object.} JSON object + */ + ADVSignedDeviceIdentityHMAC.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ADVSignedDeviceIdentityHMAC; + })(); + + proto.ADVSignedDeviceIdentity = (function() { + + /** + * Properties of a ADVSignedDeviceIdentity. + * @memberof proto + * @interface IADVSignedDeviceIdentity + * @property {Uint8Array|null} [details] ADVSignedDeviceIdentity details + * @property {Uint8Array|null} [accountSignatureKey] ADVSignedDeviceIdentity accountSignatureKey + * @property {Uint8Array|null} [accountSignature] ADVSignedDeviceIdentity accountSignature + * @property {Uint8Array|null} [deviceSignature] ADVSignedDeviceIdentity deviceSignature + */ + + /** + * Constructs a new ADVSignedDeviceIdentity. + * @memberof proto + * @classdesc Represents a ADVSignedDeviceIdentity. + * @implements IADVSignedDeviceIdentity + * @constructor + * @param {proto.IADVSignedDeviceIdentity=} [properties] Properties to set + */ + function ADVSignedDeviceIdentity(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ADVSignedDeviceIdentity details. + * @member {Uint8Array} details + * @memberof proto.ADVSignedDeviceIdentity + * @instance + */ + ADVSignedDeviceIdentity.prototype.details = $util.newBuffer([]); + + /** + * ADVSignedDeviceIdentity accountSignatureKey. + * @member {Uint8Array} accountSignatureKey + * @memberof proto.ADVSignedDeviceIdentity + * @instance + */ + ADVSignedDeviceIdentity.prototype.accountSignatureKey = $util.newBuffer([]); + + /** + * ADVSignedDeviceIdentity accountSignature. + * @member {Uint8Array} accountSignature + * @memberof proto.ADVSignedDeviceIdentity + * @instance + */ + ADVSignedDeviceIdentity.prototype.accountSignature = $util.newBuffer([]); + + /** + * ADVSignedDeviceIdentity deviceSignature. + * @member {Uint8Array} deviceSignature + * @memberof proto.ADVSignedDeviceIdentity + * @instance + */ + ADVSignedDeviceIdentity.prototype.deviceSignature = $util.newBuffer([]); + + /** + * Creates a new ADVSignedDeviceIdentity instance using the specified properties. + * @function create + * @memberof proto.ADVSignedDeviceIdentity + * @static + * @param {proto.IADVSignedDeviceIdentity=} [properties] Properties to set + * @returns {proto.ADVSignedDeviceIdentity} ADVSignedDeviceIdentity instance + */ + ADVSignedDeviceIdentity.create = function create(properties) { + return new ADVSignedDeviceIdentity(properties); + }; + + /** + * Encodes the specified ADVSignedDeviceIdentity message. Does not implicitly {@link proto.ADVSignedDeviceIdentity.verify|verify} messages. + * @function encode + * @memberof proto.ADVSignedDeviceIdentity + * @static + * @param {proto.IADVSignedDeviceIdentity} message ADVSignedDeviceIdentity message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ADVSignedDeviceIdentity.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.details != null && Object.hasOwnProperty.call(message, "details")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.details); + if (message.accountSignatureKey != null && Object.hasOwnProperty.call(message, "accountSignatureKey")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.accountSignatureKey); + if (message.accountSignature != null && Object.hasOwnProperty.call(message, "accountSignature")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.accountSignature); + if (message.deviceSignature != null && Object.hasOwnProperty.call(message, "deviceSignature")) + writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.deviceSignature); + return writer; + }; + + /** + * Encodes the specified ADVSignedDeviceIdentity message, length delimited. Does not implicitly {@link proto.ADVSignedDeviceIdentity.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.ADVSignedDeviceIdentity + * @static + * @param {proto.IADVSignedDeviceIdentity} message ADVSignedDeviceIdentity message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ADVSignedDeviceIdentity.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ADVSignedDeviceIdentity message from the specified reader or buffer. + * @function decode + * @memberof proto.ADVSignedDeviceIdentity + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.ADVSignedDeviceIdentity} ADVSignedDeviceIdentity + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ADVSignedDeviceIdentity.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.ADVSignedDeviceIdentity(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.details = reader.bytes(); + break; + case 2: + message.accountSignatureKey = reader.bytes(); + break; + case 3: + message.accountSignature = reader.bytes(); + break; + case 4: + message.deviceSignature = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ADVSignedDeviceIdentity message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.ADVSignedDeviceIdentity + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.ADVSignedDeviceIdentity} ADVSignedDeviceIdentity + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ADVSignedDeviceIdentity.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ADVSignedDeviceIdentity message. + * @function verify + * @memberof proto.ADVSignedDeviceIdentity + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ADVSignedDeviceIdentity.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.details != null && message.hasOwnProperty("details")) + if (!(message.details && typeof message.details.length === "number" || $util.isString(message.details))) + return "details: buffer expected"; + if (message.accountSignatureKey != null && message.hasOwnProperty("accountSignatureKey")) + if (!(message.accountSignatureKey && typeof message.accountSignatureKey.length === "number" || $util.isString(message.accountSignatureKey))) + return "accountSignatureKey: buffer expected"; + if (message.accountSignature != null && message.hasOwnProperty("accountSignature")) + if (!(message.accountSignature && typeof message.accountSignature.length === "number" || $util.isString(message.accountSignature))) + return "accountSignature: buffer expected"; + if (message.deviceSignature != null && message.hasOwnProperty("deviceSignature")) + if (!(message.deviceSignature && typeof message.deviceSignature.length === "number" || $util.isString(message.deviceSignature))) + return "deviceSignature: buffer expected"; + return null; + }; + + /** + * Creates a ADVSignedDeviceIdentity message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.ADVSignedDeviceIdentity + * @static + * @param {Object.} object Plain object + * @returns {proto.ADVSignedDeviceIdentity} ADVSignedDeviceIdentity + */ + ADVSignedDeviceIdentity.fromObject = function fromObject(object) { + if (object instanceof $root.proto.ADVSignedDeviceIdentity) + return object; + var message = new $root.proto.ADVSignedDeviceIdentity(); + if (object.details != null) + if (typeof object.details === "string") + $util.base64.decode(object.details, message.details = $util.newBuffer($util.base64.length(object.details)), 0); + else if (object.details.length) + message.details = object.details; + if (object.accountSignatureKey != null) + if (typeof object.accountSignatureKey === "string") + $util.base64.decode(object.accountSignatureKey, message.accountSignatureKey = $util.newBuffer($util.base64.length(object.accountSignatureKey)), 0); + else if (object.accountSignatureKey.length) + message.accountSignatureKey = object.accountSignatureKey; + if (object.accountSignature != null) + if (typeof object.accountSignature === "string") + $util.base64.decode(object.accountSignature, message.accountSignature = $util.newBuffer($util.base64.length(object.accountSignature)), 0); + else if (object.accountSignature.length) + message.accountSignature = object.accountSignature; + if (object.deviceSignature != null) + if (typeof object.deviceSignature === "string") + $util.base64.decode(object.deviceSignature, message.deviceSignature = $util.newBuffer($util.base64.length(object.deviceSignature)), 0); + else if (object.deviceSignature.length) + message.deviceSignature = object.deviceSignature; + return message; + }; + + /** + * Creates a plain object from a ADVSignedDeviceIdentity message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.ADVSignedDeviceIdentity + * @static + * @param {proto.ADVSignedDeviceIdentity} message ADVSignedDeviceIdentity + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ADVSignedDeviceIdentity.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if (options.bytes === String) + object.details = ""; + else { + object.details = []; + if (options.bytes !== Array) + object.details = $util.newBuffer(object.details); + } + if (options.bytes === String) + object.accountSignatureKey = ""; + else { + object.accountSignatureKey = []; + if (options.bytes !== Array) + object.accountSignatureKey = $util.newBuffer(object.accountSignatureKey); + } + if (options.bytes === String) + object.accountSignature = ""; + else { + object.accountSignature = []; + if (options.bytes !== Array) + object.accountSignature = $util.newBuffer(object.accountSignature); + } + if (options.bytes === String) + object.deviceSignature = ""; + else { + object.deviceSignature = []; + if (options.bytes !== Array) + object.deviceSignature = $util.newBuffer(object.deviceSignature); + } + } + if (message.details != null && message.hasOwnProperty("details")) + object.details = options.bytes === String ? $util.base64.encode(message.details, 0, message.details.length) : options.bytes === Array ? Array.prototype.slice.call(message.details) : message.details; + if (message.accountSignatureKey != null && message.hasOwnProperty("accountSignatureKey")) + object.accountSignatureKey = options.bytes === String ? $util.base64.encode(message.accountSignatureKey, 0, message.accountSignatureKey.length) : options.bytes === Array ? Array.prototype.slice.call(message.accountSignatureKey) : message.accountSignatureKey; + if (message.accountSignature != null && message.hasOwnProperty("accountSignature")) + object.accountSignature = options.bytes === String ? $util.base64.encode(message.accountSignature, 0, message.accountSignature.length) : options.bytes === Array ? Array.prototype.slice.call(message.accountSignature) : message.accountSignature; + if (message.deviceSignature != null && message.hasOwnProperty("deviceSignature")) + object.deviceSignature = options.bytes === String ? $util.base64.encode(message.deviceSignature, 0, message.deviceSignature.length) : options.bytes === Array ? Array.prototype.slice.call(message.deviceSignature) : message.deviceSignature; + return object; + }; + + /** + * Converts this ADVSignedDeviceIdentity to JSON. + * @function toJSON + * @memberof proto.ADVSignedDeviceIdentity + * @instance + * @returns {Object.} JSON object + */ + ADVSignedDeviceIdentity.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ADVSignedDeviceIdentity; + })(); + + proto.ADVDeviceIdentity = (function() { + + /** + * Properties of a ADVDeviceIdentity. + * @memberof proto + * @interface IADVDeviceIdentity + * @property {number|null} [rawId] ADVDeviceIdentity rawId + * @property {number|Long|null} [timestamp] ADVDeviceIdentity timestamp + * @property {number|null} [keyIndex] ADVDeviceIdentity keyIndex + */ + + /** + * Constructs a new ADVDeviceIdentity. + * @memberof proto + * @classdesc Represents a ADVDeviceIdentity. + * @implements IADVDeviceIdentity + * @constructor + * @param {proto.IADVDeviceIdentity=} [properties] Properties to set + */ + function ADVDeviceIdentity(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ADVDeviceIdentity rawId. + * @member {number} rawId + * @memberof proto.ADVDeviceIdentity + * @instance + */ + ADVDeviceIdentity.prototype.rawId = 0; + + /** + * ADVDeviceIdentity timestamp. + * @member {number|Long} timestamp + * @memberof proto.ADVDeviceIdentity + * @instance + */ + ADVDeviceIdentity.prototype.timestamp = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * ADVDeviceIdentity keyIndex. + * @member {number} keyIndex + * @memberof proto.ADVDeviceIdentity + * @instance + */ + ADVDeviceIdentity.prototype.keyIndex = 0; + + /** + * Creates a new ADVDeviceIdentity instance using the specified properties. + * @function create + * @memberof proto.ADVDeviceIdentity + * @static + * @param {proto.IADVDeviceIdentity=} [properties] Properties to set + * @returns {proto.ADVDeviceIdentity} ADVDeviceIdentity instance + */ + ADVDeviceIdentity.create = function create(properties) { + return new ADVDeviceIdentity(properties); + }; + + /** + * Encodes the specified ADVDeviceIdentity message. Does not implicitly {@link proto.ADVDeviceIdentity.verify|verify} messages. + * @function encode + * @memberof proto.ADVDeviceIdentity + * @static + * @param {proto.IADVDeviceIdentity} message ADVDeviceIdentity message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ADVDeviceIdentity.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.rawId != null && Object.hasOwnProperty.call(message, "rawId")) + writer.uint32(/* id 1, wireType 0 =*/8).uint32(message.rawId); + if (message.timestamp != null && Object.hasOwnProperty.call(message, "timestamp")) + writer.uint32(/* id 2, wireType 0 =*/16).uint64(message.timestamp); + if (message.keyIndex != null && Object.hasOwnProperty.call(message, "keyIndex")) + writer.uint32(/* id 3, wireType 0 =*/24).uint32(message.keyIndex); + return writer; + }; + + /** + * Encodes the specified ADVDeviceIdentity message, length delimited. Does not implicitly {@link proto.ADVDeviceIdentity.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.ADVDeviceIdentity + * @static + * @param {proto.IADVDeviceIdentity} message ADVDeviceIdentity message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ADVDeviceIdentity.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ADVDeviceIdentity message from the specified reader or buffer. + * @function decode + * @memberof proto.ADVDeviceIdentity + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.ADVDeviceIdentity} ADVDeviceIdentity + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ADVDeviceIdentity.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.ADVDeviceIdentity(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rawId = reader.uint32(); + break; + case 2: + message.timestamp = reader.uint64(); + break; + case 3: + message.keyIndex = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ADVDeviceIdentity message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.ADVDeviceIdentity + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.ADVDeviceIdentity} ADVDeviceIdentity + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ADVDeviceIdentity.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ADVDeviceIdentity message. + * @function verify + * @memberof proto.ADVDeviceIdentity + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ADVDeviceIdentity.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.rawId != null && message.hasOwnProperty("rawId")) + if (!$util.isInteger(message.rawId)) + return "rawId: integer expected"; + if (message.timestamp != null && message.hasOwnProperty("timestamp")) + if (!$util.isInteger(message.timestamp) && !(message.timestamp && $util.isInteger(message.timestamp.low) && $util.isInteger(message.timestamp.high))) + return "timestamp: integer|Long expected"; + if (message.keyIndex != null && message.hasOwnProperty("keyIndex")) + if (!$util.isInteger(message.keyIndex)) + return "keyIndex: integer expected"; + return null; + }; + + /** + * Creates a ADVDeviceIdentity message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.ADVDeviceIdentity + * @static + * @param {Object.} object Plain object + * @returns {proto.ADVDeviceIdentity} ADVDeviceIdentity + */ + ADVDeviceIdentity.fromObject = function fromObject(object) { + if (object instanceof $root.proto.ADVDeviceIdentity) + return object; + var message = new $root.proto.ADVDeviceIdentity(); + if (object.rawId != null) + message.rawId = object.rawId >>> 0; + if (object.timestamp != null) + if ($util.Long) + (message.timestamp = $util.Long.fromValue(object.timestamp)).unsigned = true; + else if (typeof object.timestamp === "string") + message.timestamp = parseInt(object.timestamp, 10); + else if (typeof object.timestamp === "number") + message.timestamp = object.timestamp; + else if (typeof object.timestamp === "object") + message.timestamp = new $util.LongBits(object.timestamp.low >>> 0, object.timestamp.high >>> 0).toNumber(true); + if (object.keyIndex != null) + message.keyIndex = object.keyIndex >>> 0; + return message; + }; + + /** + * Creates a plain object from a ADVDeviceIdentity message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.ADVDeviceIdentity + * @static + * @param {proto.ADVDeviceIdentity} message ADVDeviceIdentity + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ADVDeviceIdentity.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.rawId = 0; if ($util.Long) { var long = new $util.Long(0, 0, true); - object.fileLength = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + object.timestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; } else - object.fileLength = options.longs === String ? "0" : 0; - object.width = 0; - object.height = 0; - object.mimetype = ""; - object.placeholderArgb = 0; - object.textArgb = 0; - object.subtextArgb = 0; + object.timestamp = options.longs === String ? "0" : 0; + object.keyIndex = 0; } - if (message.id != null && message.hasOwnProperty("id")) - object.id = message.id; - if (message.fileLength != null && message.hasOwnProperty("fileLength")) - if (typeof message.fileLength === "number") - object.fileLength = options.longs === String ? String(message.fileLength) : message.fileLength; + if (message.rawId != null && message.hasOwnProperty("rawId")) + object.rawId = message.rawId; + if (message.timestamp != null && message.hasOwnProperty("timestamp")) + if (typeof message.timestamp === "number") + object.timestamp = options.longs === String ? String(message.timestamp) : message.timestamp; else - object.fileLength = options.longs === String ? $util.Long.prototype.toString.call(message.fileLength) : options.longs === Number ? new $util.LongBits(message.fileLength.low >>> 0, message.fileLength.high >>> 0).toNumber(true) : message.fileLength; - if (message.width != null && message.hasOwnProperty("width")) - object.width = message.width; - if (message.height != null && message.hasOwnProperty("height")) - object.height = message.height; - if (message.mimetype != null && message.hasOwnProperty("mimetype")) - object.mimetype = message.mimetype; - if (message.placeholderArgb != null && message.hasOwnProperty("placeholderArgb")) - object.placeholderArgb = message.placeholderArgb; - if (message.textArgb != null && message.hasOwnProperty("textArgb")) - object.textArgb = message.textArgb; - if (message.subtextArgb != null && message.hasOwnProperty("subtextArgb")) - object.subtextArgb = message.subtextArgb; + object.timestamp = options.longs === String ? $util.Long.prototype.toString.call(message.timestamp) : options.longs === Number ? new $util.LongBits(message.timestamp.low >>> 0, message.timestamp.high >>> 0).toNumber(true) : message.timestamp; + if (message.keyIndex != null && message.hasOwnProperty("keyIndex")) + object.keyIndex = message.keyIndex; return object; }; /** - * Converts this PaymentBackground to JSON. + * Converts this ADVDeviceIdentity to JSON. * @function toJSON - * @memberof proto.PaymentBackground + * @memberof proto.ADVDeviceIdentity * @instance * @returns {Object.} JSON object */ - PaymentBackground.prototype.toJSON = function toJSON() { + ADVDeviceIdentity.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; - return PaymentBackground; + return ADVDeviceIdentity; })(); - proto.Money = (function() { + proto.ADVSignedKeyIndexList = (function() { /** - * Properties of a Money. + * Properties of a ADVSignedKeyIndexList. * @memberof proto - * @interface IMoney - * @property {number|Long|null} [value] Money value - * @property {number|null} [offset] Money offset - * @property {string|null} [currencyCode] Money currencyCode + * @interface IADVSignedKeyIndexList + * @property {Uint8Array|null} [details] ADVSignedKeyIndexList details + * @property {Uint8Array|null} [accountSignature] ADVSignedKeyIndexList accountSignature */ /** - * Constructs a new Money. + * Constructs a new ADVSignedKeyIndexList. * @memberof proto - * @classdesc Represents a Money. - * @implements IMoney + * @classdesc Represents a ADVSignedKeyIndexList. + * @implements IADVSignedKeyIndexList * @constructor - * @param {proto.IMoney=} [properties] Properties to set + * @param {proto.IADVSignedKeyIndexList=} [properties] Properties to set */ - function Money(properties) { + function ADVSignedKeyIndexList(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -27250,101 +45413,88 @@ $root.proto = (function() { } /** - * Money value. - * @member {number|Long} value - * @memberof proto.Money + * ADVSignedKeyIndexList details. + * @member {Uint8Array} details + * @memberof proto.ADVSignedKeyIndexList * @instance */ - Money.prototype.value = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + ADVSignedKeyIndexList.prototype.details = $util.newBuffer([]); /** - * Money offset. - * @member {number} offset - * @memberof proto.Money + * ADVSignedKeyIndexList accountSignature. + * @member {Uint8Array} accountSignature + * @memberof proto.ADVSignedKeyIndexList * @instance */ - Money.prototype.offset = 0; + ADVSignedKeyIndexList.prototype.accountSignature = $util.newBuffer([]); /** - * Money currencyCode. - * @member {string} currencyCode - * @memberof proto.Money - * @instance - */ - Money.prototype.currencyCode = ""; - - /** - * Creates a new Money instance using the specified properties. + * Creates a new ADVSignedKeyIndexList instance using the specified properties. * @function create - * @memberof proto.Money + * @memberof proto.ADVSignedKeyIndexList * @static - * @param {proto.IMoney=} [properties] Properties to set - * @returns {proto.Money} Money instance + * @param {proto.IADVSignedKeyIndexList=} [properties] Properties to set + * @returns {proto.ADVSignedKeyIndexList} ADVSignedKeyIndexList instance */ - Money.create = function create(properties) { - return new Money(properties); + ADVSignedKeyIndexList.create = function create(properties) { + return new ADVSignedKeyIndexList(properties); }; /** - * Encodes the specified Money message. Does not implicitly {@link proto.Money.verify|verify} messages. + * Encodes the specified ADVSignedKeyIndexList message. Does not implicitly {@link proto.ADVSignedKeyIndexList.verify|verify} messages. * @function encode - * @memberof proto.Money + * @memberof proto.ADVSignedKeyIndexList * @static - * @param {proto.IMoney} message Money message or plain object to encode + * @param {proto.IADVSignedKeyIndexList} message ADVSignedKeyIndexList message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - Money.encode = function encode(message, writer) { + ADVSignedKeyIndexList.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.value != null && Object.hasOwnProperty.call(message, "value")) - writer.uint32(/* id 1, wireType 0 =*/8).int64(message.value); - if (message.offset != null && Object.hasOwnProperty.call(message, "offset")) - writer.uint32(/* id 2, wireType 0 =*/16).uint32(message.offset); - if (message.currencyCode != null && Object.hasOwnProperty.call(message, "currencyCode")) - writer.uint32(/* id 3, wireType 2 =*/26).string(message.currencyCode); + if (message.details != null && Object.hasOwnProperty.call(message, "details")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.details); + if (message.accountSignature != null && Object.hasOwnProperty.call(message, "accountSignature")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.accountSignature); return writer; }; /** - * Encodes the specified Money message, length delimited. Does not implicitly {@link proto.Money.verify|verify} messages. + * Encodes the specified ADVSignedKeyIndexList message, length delimited. Does not implicitly {@link proto.ADVSignedKeyIndexList.verify|verify} messages. * @function encodeDelimited - * @memberof proto.Money + * @memberof proto.ADVSignedKeyIndexList * @static - * @param {proto.IMoney} message Money message or plain object to encode + * @param {proto.IADVSignedKeyIndexList} message ADVSignedKeyIndexList message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - Money.encodeDelimited = function encodeDelimited(message, writer) { + ADVSignedKeyIndexList.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a Money message from the specified reader or buffer. + * Decodes a ADVSignedKeyIndexList message from the specified reader or buffer. * @function decode - * @memberof proto.Money + * @memberof proto.ADVSignedKeyIndexList * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {proto.Money} Money + * @returns {proto.ADVSignedKeyIndexList} ADVSignedKeyIndexList * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - Money.decode = function decode(reader, length) { + ADVSignedKeyIndexList.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.Money(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.ADVSignedKeyIndexList(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.value = reader.int64(); + message.details = reader.bytes(); break; case 2: - message.offset = reader.uint32(); - break; - case 3: - message.currencyCode = reader.string(); + message.accountSignature = reader.bytes(); break; default: reader.skipType(tag & 7); @@ -27355,139 +45505,138 @@ $root.proto = (function() { }; /** - * Decodes a Money message from the specified reader or buffer, length delimited. + * Decodes a ADVSignedKeyIndexList message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof proto.Money + * @memberof proto.ADVSignedKeyIndexList * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {proto.Money} Money + * @returns {proto.ADVSignedKeyIndexList} ADVSignedKeyIndexList * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - Money.decodeDelimited = function decodeDelimited(reader) { + ADVSignedKeyIndexList.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a Money message. + * Verifies a ADVSignedKeyIndexList message. * @function verify - * @memberof proto.Money + * @memberof proto.ADVSignedKeyIndexList * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - Money.verify = function verify(message) { + ADVSignedKeyIndexList.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.value != null && message.hasOwnProperty("value")) - if (!$util.isInteger(message.value) && !(message.value && $util.isInteger(message.value.low) && $util.isInteger(message.value.high))) - return "value: integer|Long expected"; - if (message.offset != null && message.hasOwnProperty("offset")) - if (!$util.isInteger(message.offset)) - return "offset: integer expected"; - if (message.currencyCode != null && message.hasOwnProperty("currencyCode")) - if (!$util.isString(message.currencyCode)) - return "currencyCode: string expected"; + if (message.details != null && message.hasOwnProperty("details")) + if (!(message.details && typeof message.details.length === "number" || $util.isString(message.details))) + return "details: buffer expected"; + if (message.accountSignature != null && message.hasOwnProperty("accountSignature")) + if (!(message.accountSignature && typeof message.accountSignature.length === "number" || $util.isString(message.accountSignature))) + return "accountSignature: buffer expected"; return null; }; /** - * Creates a Money message from a plain object. Also converts values to their respective internal types. + * Creates a ADVSignedKeyIndexList message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof proto.Money + * @memberof proto.ADVSignedKeyIndexList * @static * @param {Object.} object Plain object - * @returns {proto.Money} Money + * @returns {proto.ADVSignedKeyIndexList} ADVSignedKeyIndexList */ - Money.fromObject = function fromObject(object) { - if (object instanceof $root.proto.Money) + ADVSignedKeyIndexList.fromObject = function fromObject(object) { + if (object instanceof $root.proto.ADVSignedKeyIndexList) return object; - var message = new $root.proto.Money(); - if (object.value != null) - if ($util.Long) - (message.value = $util.Long.fromValue(object.value)).unsigned = false; - else if (typeof object.value === "string") - message.value = parseInt(object.value, 10); - else if (typeof object.value === "number") - message.value = object.value; - else if (typeof object.value === "object") - message.value = new $util.LongBits(object.value.low >>> 0, object.value.high >>> 0).toNumber(); - if (object.offset != null) - message.offset = object.offset >>> 0; - if (object.currencyCode != null) - message.currencyCode = String(object.currencyCode); + var message = new $root.proto.ADVSignedKeyIndexList(); + if (object.details != null) + if (typeof object.details === "string") + $util.base64.decode(object.details, message.details = $util.newBuffer($util.base64.length(object.details)), 0); + else if (object.details.length) + message.details = object.details; + if (object.accountSignature != null) + if (typeof object.accountSignature === "string") + $util.base64.decode(object.accountSignature, message.accountSignature = $util.newBuffer($util.base64.length(object.accountSignature)), 0); + else if (object.accountSignature.length) + message.accountSignature = object.accountSignature; return message; }; /** - * Creates a plain object from a Money message. Also converts values to other types if specified. + * Creates a plain object from a ADVSignedKeyIndexList message. Also converts values to other types if specified. * @function toObject - * @memberof proto.Money + * @memberof proto.ADVSignedKeyIndexList * @static - * @param {proto.Money} message Money + * @param {proto.ADVSignedKeyIndexList} message ADVSignedKeyIndexList * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - Money.toObject = function toObject(message, options) { + ADVSignedKeyIndexList.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.value = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.value = options.longs === String ? "0" : 0; - object.offset = 0; - object.currencyCode = ""; + if (options.bytes === String) + object.details = ""; + else { + object.details = []; + if (options.bytes !== Array) + object.details = $util.newBuffer(object.details); + } + if (options.bytes === String) + object.accountSignature = ""; + else { + object.accountSignature = []; + if (options.bytes !== Array) + object.accountSignature = $util.newBuffer(object.accountSignature); + } } - if (message.value != null && message.hasOwnProperty("value")) - if (typeof message.value === "number") - object.value = options.longs === String ? String(message.value) : message.value; - else - object.value = options.longs === String ? $util.Long.prototype.toString.call(message.value) : options.longs === Number ? new $util.LongBits(message.value.low >>> 0, message.value.high >>> 0).toNumber() : message.value; - if (message.offset != null && message.hasOwnProperty("offset")) - object.offset = message.offset; - if (message.currencyCode != null && message.hasOwnProperty("currencyCode")) - object.currencyCode = message.currencyCode; + if (message.details != null && message.hasOwnProperty("details")) + object.details = options.bytes === String ? $util.base64.encode(message.details, 0, message.details.length) : options.bytes === Array ? Array.prototype.slice.call(message.details) : message.details; + if (message.accountSignature != null && message.hasOwnProperty("accountSignature")) + object.accountSignature = options.bytes === String ? $util.base64.encode(message.accountSignature, 0, message.accountSignature.length) : options.bytes === Array ? Array.prototype.slice.call(message.accountSignature) : message.accountSignature; return object; }; /** - * Converts this Money to JSON. + * Converts this ADVSignedKeyIndexList to JSON. * @function toJSON - * @memberof proto.Money + * @memberof proto.ADVSignedKeyIndexList * @instance * @returns {Object.} JSON object */ - Money.prototype.toJSON = function toJSON() { + ADVSignedKeyIndexList.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; - return Money; + return ADVSignedKeyIndexList; })(); - proto.HydratedQuickReplyButton = (function() { + proto.ADVKeyIndexList = (function() { /** - * Properties of a HydratedQuickReplyButton. + * Properties of a ADVKeyIndexList. * @memberof proto - * @interface IHydratedQuickReplyButton - * @property {string|null} [displayText] HydratedQuickReplyButton displayText - * @property {string|null} [id] HydratedQuickReplyButton id + * @interface IADVKeyIndexList + * @property {number|null} [rawId] ADVKeyIndexList rawId + * @property {number|Long|null} [timestamp] ADVKeyIndexList timestamp + * @property {number|null} [currentIndex] ADVKeyIndexList currentIndex + * @property {Array.|null} [validIndexes] ADVKeyIndexList validIndexes */ /** - * Constructs a new HydratedQuickReplyButton. + * Constructs a new ADVKeyIndexList. * @memberof proto - * @classdesc Represents a HydratedQuickReplyButton. - * @implements IHydratedQuickReplyButton + * @classdesc Represents a ADVKeyIndexList. + * @implements IADVKeyIndexList * @constructor - * @param {proto.IHydratedQuickReplyButton=} [properties] Properties to set + * @param {proto.IADVKeyIndexList=} [properties] Properties to set */ - function HydratedQuickReplyButton(properties) { + function ADVKeyIndexList(properties) { + this.validIndexes = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -27495,88 +45644,125 @@ $root.proto = (function() { } /** - * HydratedQuickReplyButton displayText. - * @member {string} displayText - * @memberof proto.HydratedQuickReplyButton + * ADVKeyIndexList rawId. + * @member {number} rawId + * @memberof proto.ADVKeyIndexList * @instance */ - HydratedQuickReplyButton.prototype.displayText = ""; + ADVKeyIndexList.prototype.rawId = 0; /** - * HydratedQuickReplyButton id. - * @member {string} id - * @memberof proto.HydratedQuickReplyButton + * ADVKeyIndexList timestamp. + * @member {number|Long} timestamp + * @memberof proto.ADVKeyIndexList * @instance */ - HydratedQuickReplyButton.prototype.id = ""; + ADVKeyIndexList.prototype.timestamp = $util.Long ? $util.Long.fromBits(0,0,true) : 0; /** - * Creates a new HydratedQuickReplyButton instance using the specified properties. + * ADVKeyIndexList currentIndex. + * @member {number} currentIndex + * @memberof proto.ADVKeyIndexList + * @instance + */ + ADVKeyIndexList.prototype.currentIndex = 0; + + /** + * ADVKeyIndexList validIndexes. + * @member {Array.} validIndexes + * @memberof proto.ADVKeyIndexList + * @instance + */ + ADVKeyIndexList.prototype.validIndexes = $util.emptyArray; + + /** + * Creates a new ADVKeyIndexList instance using the specified properties. * @function create - * @memberof proto.HydratedQuickReplyButton + * @memberof proto.ADVKeyIndexList * @static - * @param {proto.IHydratedQuickReplyButton=} [properties] Properties to set - * @returns {proto.HydratedQuickReplyButton} HydratedQuickReplyButton instance + * @param {proto.IADVKeyIndexList=} [properties] Properties to set + * @returns {proto.ADVKeyIndexList} ADVKeyIndexList instance */ - HydratedQuickReplyButton.create = function create(properties) { - return new HydratedQuickReplyButton(properties); + ADVKeyIndexList.create = function create(properties) { + return new ADVKeyIndexList(properties); }; /** - * Encodes the specified HydratedQuickReplyButton message. Does not implicitly {@link proto.HydratedQuickReplyButton.verify|verify} messages. + * Encodes the specified ADVKeyIndexList message. Does not implicitly {@link proto.ADVKeyIndexList.verify|verify} messages. * @function encode - * @memberof proto.HydratedQuickReplyButton + * @memberof proto.ADVKeyIndexList * @static - * @param {proto.IHydratedQuickReplyButton} message HydratedQuickReplyButton message or plain object to encode + * @param {proto.IADVKeyIndexList} message ADVKeyIndexList message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - HydratedQuickReplyButton.encode = function encode(message, writer) { + ADVKeyIndexList.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.displayText != null && Object.hasOwnProperty.call(message, "displayText")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.displayText); - if (message.id != null && Object.hasOwnProperty.call(message, "id")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.id); + if (message.rawId != null && Object.hasOwnProperty.call(message, "rawId")) + writer.uint32(/* id 1, wireType 0 =*/8).uint32(message.rawId); + if (message.timestamp != null && Object.hasOwnProperty.call(message, "timestamp")) + writer.uint32(/* id 2, wireType 0 =*/16).uint64(message.timestamp); + if (message.currentIndex != null && Object.hasOwnProperty.call(message, "currentIndex")) + writer.uint32(/* id 3, wireType 0 =*/24).uint32(message.currentIndex); + if (message.validIndexes != null && message.validIndexes.length) { + writer.uint32(/* id 4, wireType 2 =*/34).fork(); + for (var i = 0; i < message.validIndexes.length; ++i) + writer.uint32(message.validIndexes[i]); + writer.ldelim(); + } return writer; }; /** - * Encodes the specified HydratedQuickReplyButton message, length delimited. Does not implicitly {@link proto.HydratedQuickReplyButton.verify|verify} messages. + * Encodes the specified ADVKeyIndexList message, length delimited. Does not implicitly {@link proto.ADVKeyIndexList.verify|verify} messages. * @function encodeDelimited - * @memberof proto.HydratedQuickReplyButton + * @memberof proto.ADVKeyIndexList * @static - * @param {proto.IHydratedQuickReplyButton} message HydratedQuickReplyButton message or plain object to encode + * @param {proto.IADVKeyIndexList} message ADVKeyIndexList message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - HydratedQuickReplyButton.encodeDelimited = function encodeDelimited(message, writer) { + ADVKeyIndexList.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a HydratedQuickReplyButton message from the specified reader or buffer. + * Decodes a ADVKeyIndexList message from the specified reader or buffer. * @function decode - * @memberof proto.HydratedQuickReplyButton + * @memberof proto.ADVKeyIndexList * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {proto.HydratedQuickReplyButton} HydratedQuickReplyButton + * @returns {proto.ADVKeyIndexList} ADVKeyIndexList * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - HydratedQuickReplyButton.decode = function decode(reader, length) { + ADVKeyIndexList.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.HydratedQuickReplyButton(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.ADVKeyIndexList(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.displayText = reader.string(); + message.rawId = reader.uint32(); break; case 2: - message.id = reader.string(); + message.timestamp = reader.uint64(); + break; + case 3: + message.currentIndex = reader.uint32(); + break; + case 4: + if (!(message.validIndexes && message.validIndexes.length)) + message.validIndexes = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.validIndexes.push(reader.uint32()); + } else + message.validIndexes.push(reader.uint32()); break; default: reader.skipType(tag & 7); @@ -27587,1192 +45773,393 @@ $root.proto = (function() { }; /** - * Decodes a HydratedQuickReplyButton message from the specified reader or buffer, length delimited. + * Decodes a ADVKeyIndexList message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof proto.HydratedQuickReplyButton + * @memberof proto.ADVKeyIndexList * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {proto.HydratedQuickReplyButton} HydratedQuickReplyButton + * @returns {proto.ADVKeyIndexList} ADVKeyIndexList * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - HydratedQuickReplyButton.decodeDelimited = function decodeDelimited(reader) { + ADVKeyIndexList.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a HydratedQuickReplyButton message. + * Verifies a ADVKeyIndexList message. * @function verify - * @memberof proto.HydratedQuickReplyButton + * @memberof proto.ADVKeyIndexList * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - HydratedQuickReplyButton.verify = function verify(message) { + ADVKeyIndexList.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.displayText != null && message.hasOwnProperty("displayText")) - if (!$util.isString(message.displayText)) - return "displayText: string expected"; + if (message.rawId != null && message.hasOwnProperty("rawId")) + if (!$util.isInteger(message.rawId)) + return "rawId: integer expected"; + if (message.timestamp != null && message.hasOwnProperty("timestamp")) + if (!$util.isInteger(message.timestamp) && !(message.timestamp && $util.isInteger(message.timestamp.low) && $util.isInteger(message.timestamp.high))) + return "timestamp: integer|Long expected"; + if (message.currentIndex != null && message.hasOwnProperty("currentIndex")) + if (!$util.isInteger(message.currentIndex)) + return "currentIndex: integer expected"; + if (message.validIndexes != null && message.hasOwnProperty("validIndexes")) { + if (!Array.isArray(message.validIndexes)) + return "validIndexes: array expected"; + for (var i = 0; i < message.validIndexes.length; ++i) + if (!$util.isInteger(message.validIndexes[i])) + return "validIndexes: integer[] expected"; + } + return null; + }; + + /** + * Creates a ADVKeyIndexList message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof proto.ADVKeyIndexList + * @static + * @param {Object.} object Plain object + * @returns {proto.ADVKeyIndexList} ADVKeyIndexList + */ + ADVKeyIndexList.fromObject = function fromObject(object) { + if (object instanceof $root.proto.ADVKeyIndexList) + return object; + var message = new $root.proto.ADVKeyIndexList(); + if (object.rawId != null) + message.rawId = object.rawId >>> 0; + if (object.timestamp != null) + if ($util.Long) + (message.timestamp = $util.Long.fromValue(object.timestamp)).unsigned = true; + else if (typeof object.timestamp === "string") + message.timestamp = parseInt(object.timestamp, 10); + else if (typeof object.timestamp === "number") + message.timestamp = object.timestamp; + else if (typeof object.timestamp === "object") + message.timestamp = new $util.LongBits(object.timestamp.low >>> 0, object.timestamp.high >>> 0).toNumber(true); + if (object.currentIndex != null) + message.currentIndex = object.currentIndex >>> 0; + if (object.validIndexes) { + if (!Array.isArray(object.validIndexes)) + throw TypeError(".proto.ADVKeyIndexList.validIndexes: array expected"); + message.validIndexes = []; + for (var i = 0; i < object.validIndexes.length; ++i) + message.validIndexes[i] = object.validIndexes[i] >>> 0; + } + return message; + }; + + /** + * Creates a plain object from a ADVKeyIndexList message. Also converts values to other types if specified. + * @function toObject + * @memberof proto.ADVKeyIndexList + * @static + * @param {proto.ADVKeyIndexList} message ADVKeyIndexList + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ADVKeyIndexList.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.validIndexes = []; + if (options.defaults) { + object.rawId = 0; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.timestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.timestamp = options.longs === String ? "0" : 0; + object.currentIndex = 0; + } + if (message.rawId != null && message.hasOwnProperty("rawId")) + object.rawId = message.rawId; + if (message.timestamp != null && message.hasOwnProperty("timestamp")) + if (typeof message.timestamp === "number") + object.timestamp = options.longs === String ? String(message.timestamp) : message.timestamp; + else + object.timestamp = options.longs === String ? $util.Long.prototype.toString.call(message.timestamp) : options.longs === Number ? new $util.LongBits(message.timestamp.low >>> 0, message.timestamp.high >>> 0).toNumber(true) : message.timestamp; + if (message.currentIndex != null && message.hasOwnProperty("currentIndex")) + object.currentIndex = message.currentIndex; + if (message.validIndexes && message.validIndexes.length) { + object.validIndexes = []; + for (var j = 0; j < message.validIndexes.length; ++j) + object.validIndexes[j] = message.validIndexes[j]; + } + return object; + }; + + /** + * Converts this ADVKeyIndexList to JSON. + * @function toJSON + * @memberof proto.ADVKeyIndexList + * @instance + * @returns {Object.} JSON object + */ + ADVKeyIndexList.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ADVKeyIndexList; + })(); + + proto.MessageKey = (function() { + + /** + * Properties of a MessageKey. + * @memberof proto + * @interface IMessageKey + * @property {string|null} [remoteJid] MessageKey remoteJid + * @property {boolean|null} [fromMe] MessageKey fromMe + * @property {string|null} [id] MessageKey id + * @property {string|null} [participant] MessageKey participant + */ + + /** + * Constructs a new MessageKey. + * @memberof proto + * @classdesc Represents a MessageKey. + * @implements IMessageKey + * @constructor + * @param {proto.IMessageKey=} [properties] Properties to set + */ + function MessageKey(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MessageKey remoteJid. + * @member {string} remoteJid + * @memberof proto.MessageKey + * @instance + */ + MessageKey.prototype.remoteJid = ""; + + /** + * MessageKey fromMe. + * @member {boolean} fromMe + * @memberof proto.MessageKey + * @instance + */ + MessageKey.prototype.fromMe = false; + + /** + * MessageKey id. + * @member {string} id + * @memberof proto.MessageKey + * @instance + */ + MessageKey.prototype.id = ""; + + /** + * MessageKey participant. + * @member {string} participant + * @memberof proto.MessageKey + * @instance + */ + MessageKey.prototype.participant = ""; + + /** + * Creates a new MessageKey instance using the specified properties. + * @function create + * @memberof proto.MessageKey + * @static + * @param {proto.IMessageKey=} [properties] Properties to set + * @returns {proto.MessageKey} MessageKey instance + */ + MessageKey.create = function create(properties) { + return new MessageKey(properties); + }; + + /** + * Encodes the specified MessageKey message. Does not implicitly {@link proto.MessageKey.verify|verify} messages. + * @function encode + * @memberof proto.MessageKey + * @static + * @param {proto.IMessageKey} message MessageKey message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MessageKey.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.remoteJid != null && Object.hasOwnProperty.call(message, "remoteJid")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.remoteJid); + if (message.fromMe != null && Object.hasOwnProperty.call(message, "fromMe")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.fromMe); + if (message.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.id); + if (message.participant != null && Object.hasOwnProperty.call(message, "participant")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.participant); + return writer; + }; + + /** + * Encodes the specified MessageKey message, length delimited. Does not implicitly {@link proto.MessageKey.verify|verify} messages. + * @function encodeDelimited + * @memberof proto.MessageKey + * @static + * @param {proto.IMessageKey} message MessageKey message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MessageKey.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MessageKey message from the specified reader or buffer. + * @function decode + * @memberof proto.MessageKey + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {proto.MessageKey} MessageKey + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MessageKey.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.MessageKey(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.remoteJid = reader.string(); + break; + case 2: + message.fromMe = reader.bool(); + break; + case 3: + message.id = reader.string(); + break; + case 4: + message.participant = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MessageKey message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof proto.MessageKey + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {proto.MessageKey} MessageKey + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MessageKey.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MessageKey message. + * @function verify + * @memberof proto.MessageKey + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MessageKey.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.remoteJid != null && message.hasOwnProperty("remoteJid")) + if (!$util.isString(message.remoteJid)) + return "remoteJid: string expected"; + if (message.fromMe != null && message.hasOwnProperty("fromMe")) + if (typeof message.fromMe !== "boolean") + return "fromMe: boolean expected"; if (message.id != null && message.hasOwnProperty("id")) if (!$util.isString(message.id)) return "id: string expected"; + if (message.participant != null && message.hasOwnProperty("participant")) + if (!$util.isString(message.participant)) + return "participant: string expected"; return null; }; /** - * Creates a HydratedQuickReplyButton message from a plain object. Also converts values to their respective internal types. + * Creates a MessageKey message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof proto.HydratedQuickReplyButton + * @memberof proto.MessageKey * @static * @param {Object.} object Plain object - * @returns {proto.HydratedQuickReplyButton} HydratedQuickReplyButton + * @returns {proto.MessageKey} MessageKey */ - HydratedQuickReplyButton.fromObject = function fromObject(object) { - if (object instanceof $root.proto.HydratedQuickReplyButton) + MessageKey.fromObject = function fromObject(object) { + if (object instanceof $root.proto.MessageKey) return object; - var message = new $root.proto.HydratedQuickReplyButton(); - if (object.displayText != null) - message.displayText = String(object.displayText); + var message = new $root.proto.MessageKey(); + if (object.remoteJid != null) + message.remoteJid = String(object.remoteJid); + if (object.fromMe != null) + message.fromMe = Boolean(object.fromMe); if (object.id != null) message.id = String(object.id); + if (object.participant != null) + message.participant = String(object.participant); return message; }; /** - * Creates a plain object from a HydratedQuickReplyButton message. Also converts values to other types if specified. + * Creates a plain object from a MessageKey message. Also converts values to other types if specified. * @function toObject - * @memberof proto.HydratedQuickReplyButton + * @memberof proto.MessageKey * @static - * @param {proto.HydratedQuickReplyButton} message HydratedQuickReplyButton + * @param {proto.MessageKey} message MessageKey * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - HydratedQuickReplyButton.toObject = function toObject(message, options) { + MessageKey.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; if (options.defaults) { - object.displayText = ""; + object.remoteJid = ""; + object.fromMe = false; object.id = ""; + object.participant = ""; } - if (message.displayText != null && message.hasOwnProperty("displayText")) - object.displayText = message.displayText; + if (message.remoteJid != null && message.hasOwnProperty("remoteJid")) + object.remoteJid = message.remoteJid; + if (message.fromMe != null && message.hasOwnProperty("fromMe")) + object.fromMe = message.fromMe; if (message.id != null && message.hasOwnProperty("id")) object.id = message.id; + if (message.participant != null && message.hasOwnProperty("participant")) + object.participant = message.participant; return object; }; /** - * Converts this HydratedQuickReplyButton to JSON. + * Converts this MessageKey to JSON. * @function toJSON - * @memberof proto.HydratedQuickReplyButton + * @memberof proto.MessageKey * @instance * @returns {Object.} JSON object */ - HydratedQuickReplyButton.prototype.toJSON = function toJSON() { + MessageKey.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; - return HydratedQuickReplyButton; - })(); - - proto.HydratedURLButton = (function() { - - /** - * Properties of a HydratedURLButton. - * @memberof proto - * @interface IHydratedURLButton - * @property {string|null} [displayText] HydratedURLButton displayText - * @property {string|null} [url] HydratedURLButton url - */ - - /** - * Constructs a new HydratedURLButton. - * @memberof proto - * @classdesc Represents a HydratedURLButton. - * @implements IHydratedURLButton - * @constructor - * @param {proto.IHydratedURLButton=} [properties] Properties to set - */ - function HydratedURLButton(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * HydratedURLButton displayText. - * @member {string} displayText - * @memberof proto.HydratedURLButton - * @instance - */ - HydratedURLButton.prototype.displayText = ""; - - /** - * HydratedURLButton url. - * @member {string} url - * @memberof proto.HydratedURLButton - * @instance - */ - HydratedURLButton.prototype.url = ""; - - /** - * Creates a new HydratedURLButton instance using the specified properties. - * @function create - * @memberof proto.HydratedURLButton - * @static - * @param {proto.IHydratedURLButton=} [properties] Properties to set - * @returns {proto.HydratedURLButton} HydratedURLButton instance - */ - HydratedURLButton.create = function create(properties) { - return new HydratedURLButton(properties); - }; - - /** - * Encodes the specified HydratedURLButton message. Does not implicitly {@link proto.HydratedURLButton.verify|verify} messages. - * @function encode - * @memberof proto.HydratedURLButton - * @static - * @param {proto.IHydratedURLButton} message HydratedURLButton message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - HydratedURLButton.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.displayText != null && Object.hasOwnProperty.call(message, "displayText")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.displayText); - if (message.url != null && Object.hasOwnProperty.call(message, "url")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.url); - return writer; - }; - - /** - * Encodes the specified HydratedURLButton message, length delimited. Does not implicitly {@link proto.HydratedURLButton.verify|verify} messages. - * @function encodeDelimited - * @memberof proto.HydratedURLButton - * @static - * @param {proto.IHydratedURLButton} message HydratedURLButton message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - HydratedURLButton.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a HydratedURLButton message from the specified reader or buffer. - * @function decode - * @memberof proto.HydratedURLButton - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {proto.HydratedURLButton} HydratedURLButton - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - HydratedURLButton.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.HydratedURLButton(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.displayText = reader.string(); - break; - case 2: - message.url = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a HydratedURLButton message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof proto.HydratedURLButton - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {proto.HydratedURLButton} HydratedURLButton - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - HydratedURLButton.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a HydratedURLButton message. - * @function verify - * @memberof proto.HydratedURLButton - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - HydratedURLButton.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.displayText != null && message.hasOwnProperty("displayText")) - if (!$util.isString(message.displayText)) - return "displayText: string expected"; - if (message.url != null && message.hasOwnProperty("url")) - if (!$util.isString(message.url)) - return "url: string expected"; - return null; - }; - - /** - * Creates a HydratedURLButton message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof proto.HydratedURLButton - * @static - * @param {Object.} object Plain object - * @returns {proto.HydratedURLButton} HydratedURLButton - */ - HydratedURLButton.fromObject = function fromObject(object) { - if (object instanceof $root.proto.HydratedURLButton) - return object; - var message = new $root.proto.HydratedURLButton(); - if (object.displayText != null) - message.displayText = String(object.displayText); - if (object.url != null) - message.url = String(object.url); - return message; - }; - - /** - * Creates a plain object from a HydratedURLButton message. Also converts values to other types if specified. - * @function toObject - * @memberof proto.HydratedURLButton - * @static - * @param {proto.HydratedURLButton} message HydratedURLButton - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - HydratedURLButton.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.displayText = ""; - object.url = ""; - } - if (message.displayText != null && message.hasOwnProperty("displayText")) - object.displayText = message.displayText; - if (message.url != null && message.hasOwnProperty("url")) - object.url = message.url; - return object; - }; - - /** - * Converts this HydratedURLButton to JSON. - * @function toJSON - * @memberof proto.HydratedURLButton - * @instance - * @returns {Object.} JSON object - */ - HydratedURLButton.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return HydratedURLButton; - })(); - - proto.HydratedCallButton = (function() { - - /** - * Properties of a HydratedCallButton. - * @memberof proto - * @interface IHydratedCallButton - * @property {string|null} [displayText] HydratedCallButton displayText - * @property {string|null} [phoneNumber] HydratedCallButton phoneNumber - */ - - /** - * Constructs a new HydratedCallButton. - * @memberof proto - * @classdesc Represents a HydratedCallButton. - * @implements IHydratedCallButton - * @constructor - * @param {proto.IHydratedCallButton=} [properties] Properties to set - */ - function HydratedCallButton(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * HydratedCallButton displayText. - * @member {string} displayText - * @memberof proto.HydratedCallButton - * @instance - */ - HydratedCallButton.prototype.displayText = ""; - - /** - * HydratedCallButton phoneNumber. - * @member {string} phoneNumber - * @memberof proto.HydratedCallButton - * @instance - */ - HydratedCallButton.prototype.phoneNumber = ""; - - /** - * Creates a new HydratedCallButton instance using the specified properties. - * @function create - * @memberof proto.HydratedCallButton - * @static - * @param {proto.IHydratedCallButton=} [properties] Properties to set - * @returns {proto.HydratedCallButton} HydratedCallButton instance - */ - HydratedCallButton.create = function create(properties) { - return new HydratedCallButton(properties); - }; - - /** - * Encodes the specified HydratedCallButton message. Does not implicitly {@link proto.HydratedCallButton.verify|verify} messages. - * @function encode - * @memberof proto.HydratedCallButton - * @static - * @param {proto.IHydratedCallButton} message HydratedCallButton message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - HydratedCallButton.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.displayText != null && Object.hasOwnProperty.call(message, "displayText")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.displayText); - if (message.phoneNumber != null && Object.hasOwnProperty.call(message, "phoneNumber")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.phoneNumber); - return writer; - }; - - /** - * Encodes the specified HydratedCallButton message, length delimited. Does not implicitly {@link proto.HydratedCallButton.verify|verify} messages. - * @function encodeDelimited - * @memberof proto.HydratedCallButton - * @static - * @param {proto.IHydratedCallButton} message HydratedCallButton message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - HydratedCallButton.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a HydratedCallButton message from the specified reader or buffer. - * @function decode - * @memberof proto.HydratedCallButton - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {proto.HydratedCallButton} HydratedCallButton - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - HydratedCallButton.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.HydratedCallButton(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.displayText = reader.string(); - break; - case 2: - message.phoneNumber = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a HydratedCallButton message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof proto.HydratedCallButton - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {proto.HydratedCallButton} HydratedCallButton - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - HydratedCallButton.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a HydratedCallButton message. - * @function verify - * @memberof proto.HydratedCallButton - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - HydratedCallButton.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.displayText != null && message.hasOwnProperty("displayText")) - if (!$util.isString(message.displayText)) - return "displayText: string expected"; - if (message.phoneNumber != null && message.hasOwnProperty("phoneNumber")) - if (!$util.isString(message.phoneNumber)) - return "phoneNumber: string expected"; - return null; - }; - - /** - * Creates a HydratedCallButton message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof proto.HydratedCallButton - * @static - * @param {Object.} object Plain object - * @returns {proto.HydratedCallButton} HydratedCallButton - */ - HydratedCallButton.fromObject = function fromObject(object) { - if (object instanceof $root.proto.HydratedCallButton) - return object; - var message = new $root.proto.HydratedCallButton(); - if (object.displayText != null) - message.displayText = String(object.displayText); - if (object.phoneNumber != null) - message.phoneNumber = String(object.phoneNumber); - return message; - }; - - /** - * Creates a plain object from a HydratedCallButton message. Also converts values to other types if specified. - * @function toObject - * @memberof proto.HydratedCallButton - * @static - * @param {proto.HydratedCallButton} message HydratedCallButton - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - HydratedCallButton.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.displayText = ""; - object.phoneNumber = ""; - } - if (message.displayText != null && message.hasOwnProperty("displayText")) - object.displayText = message.displayText; - if (message.phoneNumber != null && message.hasOwnProperty("phoneNumber")) - object.phoneNumber = message.phoneNumber; - return object; - }; - - /** - * Converts this HydratedCallButton to JSON. - * @function toJSON - * @memberof proto.HydratedCallButton - * @instance - * @returns {Object.} JSON object - */ - HydratedCallButton.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return HydratedCallButton; - })(); - - proto.HydratedTemplateButton = (function() { - - /** - * Properties of a HydratedTemplateButton. - * @memberof proto - * @interface IHydratedTemplateButton - * @property {number|null} [index] HydratedTemplateButton index - * @property {proto.IHydratedQuickReplyButton|null} [quickReplyButton] HydratedTemplateButton quickReplyButton - * @property {proto.IHydratedURLButton|null} [urlButton] HydratedTemplateButton urlButton - * @property {proto.IHydratedCallButton|null} [callButton] HydratedTemplateButton callButton - */ - - /** - * Constructs a new HydratedTemplateButton. - * @memberof proto - * @classdesc Represents a HydratedTemplateButton. - * @implements IHydratedTemplateButton - * @constructor - * @param {proto.IHydratedTemplateButton=} [properties] Properties to set - */ - function HydratedTemplateButton(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * HydratedTemplateButton index. - * @member {number} index - * @memberof proto.HydratedTemplateButton - * @instance - */ - HydratedTemplateButton.prototype.index = 0; - - /** - * HydratedTemplateButton quickReplyButton. - * @member {proto.IHydratedQuickReplyButton|null|undefined} quickReplyButton - * @memberof proto.HydratedTemplateButton - * @instance - */ - HydratedTemplateButton.prototype.quickReplyButton = null; - - /** - * HydratedTemplateButton urlButton. - * @member {proto.IHydratedURLButton|null|undefined} urlButton - * @memberof proto.HydratedTemplateButton - * @instance - */ - HydratedTemplateButton.prototype.urlButton = null; - - /** - * HydratedTemplateButton callButton. - * @member {proto.IHydratedCallButton|null|undefined} callButton - * @memberof proto.HydratedTemplateButton - * @instance - */ - HydratedTemplateButton.prototype.callButton = null; - - // OneOf field names bound to virtual getters and setters - var $oneOfFields; - - /** - * HydratedTemplateButton hydratedButton. - * @member {"quickReplyButton"|"urlButton"|"callButton"|undefined} hydratedButton - * @memberof proto.HydratedTemplateButton - * @instance - */ - Object.defineProperty(HydratedTemplateButton.prototype, "hydratedButton", { - get: $util.oneOfGetter($oneOfFields = ["quickReplyButton", "urlButton", "callButton"]), - set: $util.oneOfSetter($oneOfFields) - }); - - /** - * Creates a new HydratedTemplateButton instance using the specified properties. - * @function create - * @memberof proto.HydratedTemplateButton - * @static - * @param {proto.IHydratedTemplateButton=} [properties] Properties to set - * @returns {proto.HydratedTemplateButton} HydratedTemplateButton instance - */ - HydratedTemplateButton.create = function create(properties) { - return new HydratedTemplateButton(properties); - }; - - /** - * Encodes the specified HydratedTemplateButton message. Does not implicitly {@link proto.HydratedTemplateButton.verify|verify} messages. - * @function encode - * @memberof proto.HydratedTemplateButton - * @static - * @param {proto.IHydratedTemplateButton} message HydratedTemplateButton message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - HydratedTemplateButton.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.quickReplyButton != null && Object.hasOwnProperty.call(message, "quickReplyButton")) - $root.proto.HydratedQuickReplyButton.encode(message.quickReplyButton, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.urlButton != null && Object.hasOwnProperty.call(message, "urlButton")) - $root.proto.HydratedURLButton.encode(message.urlButton, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.callButton != null && Object.hasOwnProperty.call(message, "callButton")) - $root.proto.HydratedCallButton.encode(message.callButton, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.index != null && Object.hasOwnProperty.call(message, "index")) - writer.uint32(/* id 4, wireType 0 =*/32).uint32(message.index); - return writer; - }; - - /** - * Encodes the specified HydratedTemplateButton message, length delimited. Does not implicitly {@link proto.HydratedTemplateButton.verify|verify} messages. - * @function encodeDelimited - * @memberof proto.HydratedTemplateButton - * @static - * @param {proto.IHydratedTemplateButton} message HydratedTemplateButton message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - HydratedTemplateButton.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a HydratedTemplateButton message from the specified reader or buffer. - * @function decode - * @memberof proto.HydratedTemplateButton - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {proto.HydratedTemplateButton} HydratedTemplateButton - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - HydratedTemplateButton.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.HydratedTemplateButton(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 4: - message.index = reader.uint32(); - break; - case 1: - message.quickReplyButton = $root.proto.HydratedQuickReplyButton.decode(reader, reader.uint32()); - break; - case 2: - message.urlButton = $root.proto.HydratedURLButton.decode(reader, reader.uint32()); - break; - case 3: - message.callButton = $root.proto.HydratedCallButton.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a HydratedTemplateButton message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof proto.HydratedTemplateButton - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {proto.HydratedTemplateButton} HydratedTemplateButton - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - HydratedTemplateButton.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a HydratedTemplateButton message. - * @function verify - * @memberof proto.HydratedTemplateButton - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - HydratedTemplateButton.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - var properties = {}; - if (message.index != null && message.hasOwnProperty("index")) - if (!$util.isInteger(message.index)) - return "index: integer expected"; - if (message.quickReplyButton != null && message.hasOwnProperty("quickReplyButton")) { - properties.hydratedButton = 1; - { - var error = $root.proto.HydratedQuickReplyButton.verify(message.quickReplyButton); - if (error) - return "quickReplyButton." + error; - } - } - if (message.urlButton != null && message.hasOwnProperty("urlButton")) { - if (properties.hydratedButton === 1) - return "hydratedButton: multiple values"; - properties.hydratedButton = 1; - { - var error = $root.proto.HydratedURLButton.verify(message.urlButton); - if (error) - return "urlButton." + error; - } - } - if (message.callButton != null && message.hasOwnProperty("callButton")) { - if (properties.hydratedButton === 1) - return "hydratedButton: multiple values"; - properties.hydratedButton = 1; - { - var error = $root.proto.HydratedCallButton.verify(message.callButton); - if (error) - return "callButton." + error; - } - } - return null; - }; - - /** - * Creates a HydratedTemplateButton message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof proto.HydratedTemplateButton - * @static - * @param {Object.} object Plain object - * @returns {proto.HydratedTemplateButton} HydratedTemplateButton - */ - HydratedTemplateButton.fromObject = function fromObject(object) { - if (object instanceof $root.proto.HydratedTemplateButton) - return object; - var message = new $root.proto.HydratedTemplateButton(); - if (object.index != null) - message.index = object.index >>> 0; - if (object.quickReplyButton != null) { - if (typeof object.quickReplyButton !== "object") - throw TypeError(".proto.HydratedTemplateButton.quickReplyButton: object expected"); - message.quickReplyButton = $root.proto.HydratedQuickReplyButton.fromObject(object.quickReplyButton); - } - if (object.urlButton != null) { - if (typeof object.urlButton !== "object") - throw TypeError(".proto.HydratedTemplateButton.urlButton: object expected"); - message.urlButton = $root.proto.HydratedURLButton.fromObject(object.urlButton); - } - if (object.callButton != null) { - if (typeof object.callButton !== "object") - throw TypeError(".proto.HydratedTemplateButton.callButton: object expected"); - message.callButton = $root.proto.HydratedCallButton.fromObject(object.callButton); - } - return message; - }; - - /** - * Creates a plain object from a HydratedTemplateButton message. Also converts values to other types if specified. - * @function toObject - * @memberof proto.HydratedTemplateButton - * @static - * @param {proto.HydratedTemplateButton} message HydratedTemplateButton - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - HydratedTemplateButton.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.index = 0; - if (message.quickReplyButton != null && message.hasOwnProperty("quickReplyButton")) { - object.quickReplyButton = $root.proto.HydratedQuickReplyButton.toObject(message.quickReplyButton, options); - if (options.oneofs) - object.hydratedButton = "quickReplyButton"; - } - if (message.urlButton != null && message.hasOwnProperty("urlButton")) { - object.urlButton = $root.proto.HydratedURLButton.toObject(message.urlButton, options); - if (options.oneofs) - object.hydratedButton = "urlButton"; - } - if (message.callButton != null && message.hasOwnProperty("callButton")) { - object.callButton = $root.proto.HydratedCallButton.toObject(message.callButton, options); - if (options.oneofs) - object.hydratedButton = "callButton"; - } - if (message.index != null && message.hasOwnProperty("index")) - object.index = message.index; - return object; - }; - - /** - * Converts this HydratedTemplateButton to JSON. - * @function toJSON - * @memberof proto.HydratedTemplateButton - * @instance - * @returns {Object.} JSON object - */ - HydratedTemplateButton.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return HydratedTemplateButton; - })(); - - proto.UserReceipt = (function() { - - /** - * Properties of a UserReceipt. - * @memberof proto - * @interface IUserReceipt - * @property {string} userJid UserReceipt userJid - * @property {number|Long|null} [receiptTimestamp] UserReceipt receiptTimestamp - * @property {number|Long|null} [readTimestamp] UserReceipt readTimestamp - * @property {number|Long|null} [playedTimestamp] UserReceipt playedTimestamp - * @property {Array.|null} [pendingDeviceJid] UserReceipt pendingDeviceJid - * @property {Array.|null} [deliveredDeviceJid] UserReceipt deliveredDeviceJid - */ - - /** - * Constructs a new UserReceipt. - * @memberof proto - * @classdesc Represents a UserReceipt. - * @implements IUserReceipt - * @constructor - * @param {proto.IUserReceipt=} [properties] Properties to set - */ - function UserReceipt(properties) { - this.pendingDeviceJid = []; - this.deliveredDeviceJid = []; - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * UserReceipt userJid. - * @member {string} userJid - * @memberof proto.UserReceipt - * @instance - */ - UserReceipt.prototype.userJid = ""; - - /** - * UserReceipt receiptTimestamp. - * @member {number|Long} receiptTimestamp - * @memberof proto.UserReceipt - * @instance - */ - UserReceipt.prototype.receiptTimestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * UserReceipt readTimestamp. - * @member {number|Long} readTimestamp - * @memberof proto.UserReceipt - * @instance - */ - UserReceipt.prototype.readTimestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * UserReceipt playedTimestamp. - * @member {number|Long} playedTimestamp - * @memberof proto.UserReceipt - * @instance - */ - UserReceipt.prototype.playedTimestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * UserReceipt pendingDeviceJid. - * @member {Array.} pendingDeviceJid - * @memberof proto.UserReceipt - * @instance - */ - UserReceipt.prototype.pendingDeviceJid = $util.emptyArray; - - /** - * UserReceipt deliveredDeviceJid. - * @member {Array.} deliveredDeviceJid - * @memberof proto.UserReceipt - * @instance - */ - UserReceipt.prototype.deliveredDeviceJid = $util.emptyArray; - - /** - * Creates a new UserReceipt instance using the specified properties. - * @function create - * @memberof proto.UserReceipt - * @static - * @param {proto.IUserReceipt=} [properties] Properties to set - * @returns {proto.UserReceipt} UserReceipt instance - */ - UserReceipt.create = function create(properties) { - return new UserReceipt(properties); - }; - - /** - * Encodes the specified UserReceipt message. Does not implicitly {@link proto.UserReceipt.verify|verify} messages. - * @function encode - * @memberof proto.UserReceipt - * @static - * @param {proto.IUserReceipt} message UserReceipt message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - UserReceipt.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - writer.uint32(/* id 1, wireType 2 =*/10).string(message.userJid); - if (message.receiptTimestamp != null && Object.hasOwnProperty.call(message, "receiptTimestamp")) - writer.uint32(/* id 2, wireType 0 =*/16).int64(message.receiptTimestamp); - if (message.readTimestamp != null && Object.hasOwnProperty.call(message, "readTimestamp")) - writer.uint32(/* id 3, wireType 0 =*/24).int64(message.readTimestamp); - if (message.playedTimestamp != null && Object.hasOwnProperty.call(message, "playedTimestamp")) - writer.uint32(/* id 4, wireType 0 =*/32).int64(message.playedTimestamp); - if (message.pendingDeviceJid != null && message.pendingDeviceJid.length) - for (var i = 0; i < message.pendingDeviceJid.length; ++i) - writer.uint32(/* id 5, wireType 2 =*/42).string(message.pendingDeviceJid[i]); - if (message.deliveredDeviceJid != null && message.deliveredDeviceJid.length) - for (var i = 0; i < message.deliveredDeviceJid.length; ++i) - writer.uint32(/* id 6, wireType 2 =*/50).string(message.deliveredDeviceJid[i]); - return writer; - }; - - /** - * Encodes the specified UserReceipt message, length delimited. Does not implicitly {@link proto.UserReceipt.verify|verify} messages. - * @function encodeDelimited - * @memberof proto.UserReceipt - * @static - * @param {proto.IUserReceipt} message UserReceipt message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - UserReceipt.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a UserReceipt message from the specified reader or buffer. - * @function decode - * @memberof proto.UserReceipt - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {proto.UserReceipt} UserReceipt - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - UserReceipt.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.proto.UserReceipt(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.userJid = reader.string(); - break; - case 2: - message.receiptTimestamp = reader.int64(); - break; - case 3: - message.readTimestamp = reader.int64(); - break; - case 4: - message.playedTimestamp = reader.int64(); - break; - case 5: - if (!(message.pendingDeviceJid && message.pendingDeviceJid.length)) - message.pendingDeviceJid = []; - message.pendingDeviceJid.push(reader.string()); - break; - case 6: - if (!(message.deliveredDeviceJid && message.deliveredDeviceJid.length)) - message.deliveredDeviceJid = []; - message.deliveredDeviceJid.push(reader.string()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - if (!message.hasOwnProperty("userJid")) - throw $util.ProtocolError("missing required 'userJid'", { instance: message }); - return message; - }; - - /** - * Decodes a UserReceipt message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof proto.UserReceipt - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {proto.UserReceipt} UserReceipt - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - UserReceipt.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a UserReceipt message. - * @function verify - * @memberof proto.UserReceipt - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - UserReceipt.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (!$util.isString(message.userJid)) - return "userJid: string expected"; - if (message.receiptTimestamp != null && message.hasOwnProperty("receiptTimestamp")) - if (!$util.isInteger(message.receiptTimestamp) && !(message.receiptTimestamp && $util.isInteger(message.receiptTimestamp.low) && $util.isInteger(message.receiptTimestamp.high))) - return "receiptTimestamp: integer|Long expected"; - if (message.readTimestamp != null && message.hasOwnProperty("readTimestamp")) - if (!$util.isInteger(message.readTimestamp) && !(message.readTimestamp && $util.isInteger(message.readTimestamp.low) && $util.isInteger(message.readTimestamp.high))) - return "readTimestamp: integer|Long expected"; - if (message.playedTimestamp != null && message.hasOwnProperty("playedTimestamp")) - if (!$util.isInteger(message.playedTimestamp) && !(message.playedTimestamp && $util.isInteger(message.playedTimestamp.low) && $util.isInteger(message.playedTimestamp.high))) - return "playedTimestamp: integer|Long expected"; - if (message.pendingDeviceJid != null && message.hasOwnProperty("pendingDeviceJid")) { - if (!Array.isArray(message.pendingDeviceJid)) - return "pendingDeviceJid: array expected"; - for (var i = 0; i < message.pendingDeviceJid.length; ++i) - if (!$util.isString(message.pendingDeviceJid[i])) - return "pendingDeviceJid: string[] expected"; - } - if (message.deliveredDeviceJid != null && message.hasOwnProperty("deliveredDeviceJid")) { - if (!Array.isArray(message.deliveredDeviceJid)) - return "deliveredDeviceJid: array expected"; - for (var i = 0; i < message.deliveredDeviceJid.length; ++i) - if (!$util.isString(message.deliveredDeviceJid[i])) - return "deliveredDeviceJid: string[] expected"; - } - return null; - }; - - /** - * Creates a UserReceipt message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof proto.UserReceipt - * @static - * @param {Object.} object Plain object - * @returns {proto.UserReceipt} UserReceipt - */ - UserReceipt.fromObject = function fromObject(object) { - if (object instanceof $root.proto.UserReceipt) - return object; - var message = new $root.proto.UserReceipt(); - if (object.userJid != null) - message.userJid = String(object.userJid); - if (object.receiptTimestamp != null) - if ($util.Long) - (message.receiptTimestamp = $util.Long.fromValue(object.receiptTimestamp)).unsigned = false; - else if (typeof object.receiptTimestamp === "string") - message.receiptTimestamp = parseInt(object.receiptTimestamp, 10); - else if (typeof object.receiptTimestamp === "number") - message.receiptTimestamp = object.receiptTimestamp; - else if (typeof object.receiptTimestamp === "object") - message.receiptTimestamp = new $util.LongBits(object.receiptTimestamp.low >>> 0, object.receiptTimestamp.high >>> 0).toNumber(); - if (object.readTimestamp != null) - if ($util.Long) - (message.readTimestamp = $util.Long.fromValue(object.readTimestamp)).unsigned = false; - else if (typeof object.readTimestamp === "string") - message.readTimestamp = parseInt(object.readTimestamp, 10); - else if (typeof object.readTimestamp === "number") - message.readTimestamp = object.readTimestamp; - else if (typeof object.readTimestamp === "object") - message.readTimestamp = new $util.LongBits(object.readTimestamp.low >>> 0, object.readTimestamp.high >>> 0).toNumber(); - if (object.playedTimestamp != null) - if ($util.Long) - (message.playedTimestamp = $util.Long.fromValue(object.playedTimestamp)).unsigned = false; - else if (typeof object.playedTimestamp === "string") - message.playedTimestamp = parseInt(object.playedTimestamp, 10); - else if (typeof object.playedTimestamp === "number") - message.playedTimestamp = object.playedTimestamp; - else if (typeof object.playedTimestamp === "object") - message.playedTimestamp = new $util.LongBits(object.playedTimestamp.low >>> 0, object.playedTimestamp.high >>> 0).toNumber(); - if (object.pendingDeviceJid) { - if (!Array.isArray(object.pendingDeviceJid)) - throw TypeError(".proto.UserReceipt.pendingDeviceJid: array expected"); - message.pendingDeviceJid = []; - for (var i = 0; i < object.pendingDeviceJid.length; ++i) - message.pendingDeviceJid[i] = String(object.pendingDeviceJid[i]); - } - if (object.deliveredDeviceJid) { - if (!Array.isArray(object.deliveredDeviceJid)) - throw TypeError(".proto.UserReceipt.deliveredDeviceJid: array expected"); - message.deliveredDeviceJid = []; - for (var i = 0; i < object.deliveredDeviceJid.length; ++i) - message.deliveredDeviceJid[i] = String(object.deliveredDeviceJid[i]); - } - return message; - }; - - /** - * Creates a plain object from a UserReceipt message. Also converts values to other types if specified. - * @function toObject - * @memberof proto.UserReceipt - * @static - * @param {proto.UserReceipt} message UserReceipt - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - UserReceipt.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.arrays || options.defaults) { - object.pendingDeviceJid = []; - object.deliveredDeviceJid = []; - } - if (options.defaults) { - object.userJid = ""; - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.receiptTimestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.receiptTimestamp = options.longs === String ? "0" : 0; - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.readTimestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.readTimestamp = options.longs === String ? "0" : 0; - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.playedTimestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.playedTimestamp = options.longs === String ? "0" : 0; - } - if (message.userJid != null && message.hasOwnProperty("userJid")) - object.userJid = message.userJid; - if (message.receiptTimestamp != null && message.hasOwnProperty("receiptTimestamp")) - if (typeof message.receiptTimestamp === "number") - object.receiptTimestamp = options.longs === String ? String(message.receiptTimestamp) : message.receiptTimestamp; - else - object.receiptTimestamp = options.longs === String ? $util.Long.prototype.toString.call(message.receiptTimestamp) : options.longs === Number ? new $util.LongBits(message.receiptTimestamp.low >>> 0, message.receiptTimestamp.high >>> 0).toNumber() : message.receiptTimestamp; - if (message.readTimestamp != null && message.hasOwnProperty("readTimestamp")) - if (typeof message.readTimestamp === "number") - object.readTimestamp = options.longs === String ? String(message.readTimestamp) : message.readTimestamp; - else - object.readTimestamp = options.longs === String ? $util.Long.prototype.toString.call(message.readTimestamp) : options.longs === Number ? new $util.LongBits(message.readTimestamp.low >>> 0, message.readTimestamp.high >>> 0).toNumber() : message.readTimestamp; - if (message.playedTimestamp != null && message.hasOwnProperty("playedTimestamp")) - if (typeof message.playedTimestamp === "number") - object.playedTimestamp = options.longs === String ? String(message.playedTimestamp) : message.playedTimestamp; - else - object.playedTimestamp = options.longs === String ? $util.Long.prototype.toString.call(message.playedTimestamp) : options.longs === Number ? new $util.LongBits(message.playedTimestamp.low >>> 0, message.playedTimestamp.high >>> 0).toNumber() : message.playedTimestamp; - if (message.pendingDeviceJid && message.pendingDeviceJid.length) { - object.pendingDeviceJid = []; - for (var j = 0; j < message.pendingDeviceJid.length; ++j) - object.pendingDeviceJid[j] = message.pendingDeviceJid[j]; - } - if (message.deliveredDeviceJid && message.deliveredDeviceJid.length) { - object.deliveredDeviceJid = []; - for (var j = 0; j < message.deliveredDeviceJid.length; ++j) - object.deliveredDeviceJid[j] = message.deliveredDeviceJid[j]; - } - return object; - }; - - /** - * Converts this UserReceipt to JSON. - * @function toJSON - * @memberof proto.UserReceipt - * @instance - * @returns {Object.} JSON object - */ - UserReceipt.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return UserReceipt; + return MessageKey; })(); proto.PhotoChange = (function() { @@ -29260,7 +46647,6 @@ $root.proto = (function() { * @property {proto.WebFeatures.WebFeaturesFlag|null} [ephemeralAllowGroupMembers] WebFeatures ephemeralAllowGroupMembers * @property {proto.WebFeatures.WebFeaturesFlag|null} [ephemeral24HDuration] WebFeatures ephemeral24HDuration * @property {proto.WebFeatures.WebFeaturesFlag|null} [mdForceUpgrade] WebFeatures mdForceUpgrade - * @property {proto.WebFeatures.WebFeaturesFlag|null} [disappearingMode] WebFeatures disappearingMode */ /** @@ -29614,14 +47000,6 @@ $root.proto = (function() { */ WebFeatures.prototype.mdForceUpgrade = 0; - /** - * WebFeatures disappearingMode. - * @member {proto.WebFeatures.WebFeaturesFlag} disappearingMode - * @memberof proto.WebFeatures - * @instance - */ - WebFeatures.prototype.disappearingMode = 0; - /** * Creates a new WebFeatures instance using the specified properties. * @function create @@ -29730,8 +47108,6 @@ $root.proto = (function() { writer.uint32(/* id 45, wireType 0 =*/360).int32(message.ephemeral24HDuration); if (message.mdForceUpgrade != null && Object.hasOwnProperty.call(message, "mdForceUpgrade")) writer.uint32(/* id 46, wireType 0 =*/368).int32(message.mdForceUpgrade); - if (message.disappearingMode != null && Object.hasOwnProperty.call(message, "disappearingMode")) - writer.uint32(/* id 47, wireType 0 =*/376).int32(message.disappearingMode); return writer; }; @@ -29892,9 +47268,6 @@ $root.proto = (function() { case 46: message.mdForceUpgrade = reader.int32(); break; - case 47: - message.disappearingMode = reader.int32(); - break; default: reader.skipType(tag & 7); break; @@ -30350,16 +47723,6 @@ $root.proto = (function() { case 3: break; } - if (message.disappearingMode != null && message.hasOwnProperty("disappearingMode")) - switch (message.disappearingMode) { - default: - return "disappearingMode: enum value expected"; - case 0: - case 1: - case 2: - case 3: - break; - } return null; }; @@ -31131,24 +48494,6 @@ $root.proto = (function() { message.mdForceUpgrade = 3; break; } - switch (object.disappearingMode) { - case "NOT_STARTED": - case 0: - message.disappearingMode = 0; - break; - case "FORCE_UPGRADE": - case 1: - message.disappearingMode = 1; - break; - case "DEVELOPMENT": - case 2: - message.disappearingMode = 2; - break; - case "PRODUCTION": - case 3: - message.disappearingMode = 3; - break; - } return message; }; @@ -31208,7 +48553,6 @@ $root.proto = (function() { object.ephemeralAllowGroupMembers = options.enums === String ? "NOT_STARTED" : 0; object.ephemeral24HDuration = options.enums === String ? "NOT_STARTED" : 0; object.mdForceUpgrade = options.enums === String ? "NOT_STARTED" : 0; - object.disappearingMode = options.enums === String ? "NOT_STARTED" : 0; } if (message.labelsDisplay != null && message.hasOwnProperty("labelsDisplay")) object.labelsDisplay = options.enums === String ? $root.proto.WebFeatures.WebFeaturesFlag[message.labelsDisplay] : message.labelsDisplay; @@ -31294,8 +48638,6 @@ $root.proto = (function() { object.ephemeral24HDuration = options.enums === String ? $root.proto.WebFeatures.WebFeaturesFlag[message.ephemeral24HDuration] : message.ephemeral24HDuration; if (message.mdForceUpgrade != null && message.hasOwnProperty("mdForceUpgrade")) object.mdForceUpgrade = options.enums === String ? $root.proto.WebFeatures.WebFeaturesFlag[message.mdForceUpgrade] : message.mdForceUpgrade; - if (message.disappearingMode != null && message.hasOwnProperty("disappearingMode")) - object.disappearingMode = options.enums === String ? $root.proto.WebFeatures.WebFeaturesFlag[message.disappearingMode] : message.disappearingMode; return object; }; @@ -32784,7 +50126,6 @@ $root.proto = (function() { * @property {string|null} [verifiedBizName] WebMessageInfo verifiedBizName * @property {proto.IMediaData|null} [mediaData] WebMessageInfo mediaData * @property {proto.IPhotoChange|null} [photoChange] WebMessageInfo photoChange - * @property {Array.|null} [userReceipt] WebMessageInfo userReceipt */ /** @@ -32798,7 +50139,6 @@ $root.proto = (function() { function WebMessageInfo(properties) { this.messageStubParameters = []; this.labels = []; - this.userReceipt = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -33045,14 +50385,6 @@ $root.proto = (function() { */ WebMessageInfo.prototype.photoChange = null; - /** - * WebMessageInfo userReceipt. - * @member {Array.} userReceipt - * @memberof proto.WebMessageInfo - * @instance - */ - WebMessageInfo.prototype.userReceipt = $util.emptyArray; - /** * Creates a new WebMessageInfo instance using the specified properties. * @function create @@ -33138,9 +50470,6 @@ $root.proto = (function() { $root.proto.MediaData.encode(message.mediaData, writer.uint32(/* id 38, wireType 2 =*/306).fork()).ldelim(); if (message.photoChange != null && Object.hasOwnProperty.call(message, "photoChange")) $root.proto.PhotoChange.encode(message.photoChange, writer.uint32(/* id 39, wireType 2 =*/314).fork()).ldelim(); - if (message.userReceipt != null && message.userReceipt.length) - for (var i = 0; i < message.userReceipt.length; ++i) - $root.proto.UserReceipt.encode(message.userReceipt[i], writer.uint32(/* id 40, wireType 2 =*/322).fork()).ldelim(); return writer; }; @@ -33269,11 +50598,6 @@ $root.proto = (function() { case 39: message.photoChange = $root.proto.PhotoChange.decode(reader, reader.uint32()); break; - case 40: - if (!(message.userReceipt && message.userReceipt.length)) - message.userReceipt = []; - message.userReceipt.push($root.proto.UserReceipt.decode(reader, reader.uint32())); - break; default: reader.skipType(tag & 7); break; @@ -33500,7 +50824,6 @@ $root.proto = (function() { case 127: case 128: case 129: - case 130: break; } if (message.clearMedia != null && message.hasOwnProperty("clearMedia")) @@ -33573,15 +50896,6 @@ $root.proto = (function() { if (error) return "photoChange." + error; } - if (message.userReceipt != null && message.hasOwnProperty("userReceipt")) { - if (!Array.isArray(message.userReceipt)) - return "userReceipt: array expected"; - for (var i = 0; i < message.userReceipt.length; ++i) { - var error = $root.proto.UserReceipt.verify(message.userReceipt[i]); - if (error) - return "userReceipt." + error; - } - } return null; }; @@ -34193,10 +51507,6 @@ $root.proto = (function() { case 129: message.messageStubType = 129; break; - case "DISAPPEARING_MODE": - case 130: - message.messageStubType = 130; - break; } if (object.clearMedia != null) message.clearMedia = Boolean(object.clearMedia); @@ -34276,16 +51586,6 @@ $root.proto = (function() { throw TypeError(".proto.WebMessageInfo.photoChange: object expected"); message.photoChange = $root.proto.PhotoChange.fromObject(object.photoChange); } - if (object.userReceipt) { - if (!Array.isArray(object.userReceipt)) - throw TypeError(".proto.WebMessageInfo.userReceipt: array expected"); - message.userReceipt = []; - for (var i = 0; i < object.userReceipt.length; ++i) { - if (typeof object.userReceipt[i] !== "object") - throw TypeError(".proto.WebMessageInfo.userReceipt: object expected"); - message.userReceipt[i] = $root.proto.UserReceipt.fromObject(object.userReceipt[i]); - } - } return message; }; @@ -34305,7 +51605,6 @@ $root.proto = (function() { if (options.arrays || options.defaults) { object.messageStubParameters = []; object.labels = []; - object.userReceipt = []; } if (options.defaults) { object.key = null; @@ -34430,11 +51729,6 @@ $root.proto = (function() { object.mediaData = $root.proto.MediaData.toObject(message.mediaData, options); if (message.photoChange != null && message.hasOwnProperty("photoChange")) object.photoChange = $root.proto.PhotoChange.toObject(message.photoChange, options); - if (message.userReceipt && message.userReceipt.length) { - object.userReceipt = []; - for (var j = 0; j < message.userReceipt.length; ++j) - object.userReceipt[j] = $root.proto.UserReceipt.toObject(message.userReceipt[j], options); - } return object; }; @@ -34605,7 +51899,6 @@ $root.proto = (function() { * @property {number} BIZ_PRIVACY_MODE_INIT_BSP=127 BIZ_PRIVACY_MODE_INIT_BSP value * @property {number} BIZ_PRIVACY_MODE_TO_FB=128 BIZ_PRIVACY_MODE_TO_FB value * @property {number} BIZ_PRIVACY_MODE_TO_BSP=129 BIZ_PRIVACY_MODE_TO_BSP value - * @property {number} DISAPPEARING_MODE=130 DISAPPEARING_MODE value */ WebMessageInfo.WebMessageInfoStubType = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -34739,7 +52032,6 @@ $root.proto = (function() { values[valuesById[127] = "BIZ_PRIVACY_MODE_INIT_BSP"] = 127; values[valuesById[128] = "BIZ_PRIVACY_MODE_TO_FB"] = 128; values[valuesById[129] = "BIZ_PRIVACY_MODE_TO_BSP"] = 129; - values[valuesById[130] = "DISAPPEARING_MODE"] = 130; return values; })(); diff --git a/WASignalGroup/ciphertext_message.js b/WASignalGroup/ciphertext_message.js new file mode 100644 index 0000000..f9bb771 --- /dev/null +++ b/WASignalGroup/ciphertext_message.js @@ -0,0 +1,16 @@ +class CiphertextMessage { + UNSUPPORTED_VERSION = 1; + + CURRENT_VERSION = 3; + + WHISPER_TYPE = 2; + + PREKEY_TYPE = 3; + + SENDERKEY_TYPE = 4; + + SENDERKEY_DISTRIBUTION_TYPE = 5; + + ENCRYPTED_MESSAGE_OVERHEAD = 53; +} +module.exports = CiphertextMessage; \ No newline at end of file diff --git a/WASignalGroup/group.proto b/WASignalGroup/group.proto new file mode 100644 index 0000000..a83c11e --- /dev/null +++ b/WASignalGroup/group.proto @@ -0,0 +1,41 @@ +package groupproto; + +message SenderKeyMessage { + optional uint32 id = 1; + optional uint32 iteration = 2; + optional bytes ciphertext = 3; + } + + message SenderKeyDistributionMessage { + optional uint32 id = 1; + optional uint32 iteration = 2; + optional bytes chainKey = 3; + optional bytes signingKey = 4; + } + + +message SenderKeyStateStructure { + message SenderChainKey { + optional uint32 iteration = 1; + optional bytes seed = 2; + } + + message SenderMessageKey { + optional uint32 iteration = 1; + optional bytes seed = 2; + } + + message SenderSigningKey { + optional bytes public = 1; + optional bytes private = 2; + } + + optional uint32 senderKeyId = 1; + optional SenderChainKey senderChainKey = 2; + optional SenderSigningKey senderSigningKey = 3; + repeated SenderMessageKey senderMessageKeys = 4; +} + +message SenderKeyRecordStructure { + repeated SenderKeyStateStructure senderKeyStates = 1; +} \ No newline at end of file diff --git a/WASignalGroup/group_cipher.js b/WASignalGroup/group_cipher.js new file mode 100644 index 0000000..a10de25 --- /dev/null +++ b/WASignalGroup/group_cipher.js @@ -0,0 +1,106 @@ +const SenderKeyMessage = require('./sender_key_message'); +const crypto = require('libsignal/src/crypto'); + +class GroupCipher { + constructor(senderKeyStore, senderKeyName) { + this.senderKeyStore = senderKeyStore; + this.senderKeyName = senderKeyName; + } + + async encrypt(paddedPlaintext) { + try { + const record = await this.senderKeyStore.loadSenderKey(this.senderKeyName); + const senderKeyState = record.getSenderKeyState(); + const senderKey = senderKeyState.getSenderChainKey().getSenderMessageKey(); + + const ciphertext = await this.getCipherText( + senderKey.getIv(), + senderKey.getCipherKey(), + paddedPlaintext + ); + + const senderKeyMessage = new SenderKeyMessage( + senderKeyState.getKeyId(), + senderKey.getIteration(), + ciphertext, + senderKeyState.getSigningKeyPrivate() + ); + senderKeyState.setSenderChainKey(senderKeyState.getSenderChainKey().getNext()); + await this.senderKeyStore.storeSenderKey(this.senderKeyName, record); + return senderKeyMessage.serialize(); + } catch (e) { + //console.log(e.stack); + throw new Error('NoSessionException'); + } + } + + async decrypt(senderKeyMessageBytes) { + const record = await this.senderKeyStore.loadSenderKey(this.senderKeyName); + if (!record) throw new Error(`No sender key for: ${this.senderKeyName}`); + + const senderKeyMessage = new SenderKeyMessage(null, null, null, null, senderKeyMessageBytes); + + const senderKeyState = record.getSenderKeyState(senderKeyMessage.getKeyId()); + //senderKeyMessage.verifySignature(senderKeyState.getSigningKeyPublic()); + const senderKey = this.getSenderKey(senderKeyState, senderKeyMessage.getIteration()); + // senderKeyState.senderKeyStateStructure.senderSigningKey.private = + + const plaintext = await this.getPlainText( + senderKey.getIv(), + senderKey.getCipherKey(), + senderKeyMessage.getCipherText() + ); + + await this.senderKeyStore.storeSenderKey(this.senderKeyName, record); + + return plaintext; + } + + getSenderKey(senderKeyState, iteration) { + let senderChainKey = senderKeyState.getSenderChainKey(); + if (senderChainKey.getIteration() > iteration) { + if (senderKeyState.hasSenderMessageKey(iteration)) { + return senderKeyState.removeSenderMessageKey(iteration); + } + throw new Error( + `Received message with old counter: ${senderChainKey.getIteration()}, ${iteration}` + ); + } + + if (senderChainKey.getIteration() - iteration > 2000) { + throw new Error('Over 2000 messages into the future!'); + } + + while (senderChainKey.getIteration() < iteration) { + senderKeyState.addSenderMessageKey(senderChainKey.getSenderMessageKey()); + senderChainKey = senderChainKey.getNext(); + } + + senderKeyState.setSenderChainKey(senderChainKey.getNext()); + return senderChainKey.getSenderMessageKey(); + } + + getPlainText(iv, key, ciphertext) { + try { + const plaintext = crypto.decrypt(key, ciphertext, iv); + return plaintext; + } catch (e) { + //console.log(e.stack); + throw new Error('InvalidMessageException'); + } + } + + getCipherText(iv, key, plaintext) { + try { + iv = typeof iv === 'string' ? Buffer.from(iv, 'base64') : iv; + key = typeof key === 'string' ? Buffer.from(key, 'base64') : key; + const crypted = crypto.encrypt(key, Buffer.from(plaintext), iv); + return crypted; + } catch (e) { + //console.log(e.stack); + throw new Error('InvalidMessageException'); + } + } +} + +module.exports = GroupCipher; \ No newline at end of file diff --git a/WASignalGroup/group_session_builder.js b/WASignalGroup/group_session_builder.js new file mode 100644 index 0000000..60c152f --- /dev/null +++ b/WASignalGroup/group_session_builder.js @@ -0,0 +1,51 @@ +//const utils = require('../../common/utils'); +const SenderKeyDistributionMessage = require('./sender_key_distribution_message'); + +const keyhelper = require("libsignal/src/keyhelper"); +class GroupSessionBuilder { + constructor(senderKeyStore) { + this.senderKeyStore = senderKeyStore; + } + + async process(senderKeyName, senderKeyDistributionMessage) { + //console.log('GroupSessionBuilder process', senderKeyName, senderKeyDistributionMessage); + const senderKeyRecord = await this.senderKeyStore.loadSenderKey(senderKeyName); + senderKeyRecord.addSenderKeyState( + senderKeyDistributionMessage.getId(), + senderKeyDistributionMessage.getIteration(), + senderKeyDistributionMessage.getChainKey(), + senderKeyDistributionMessage.getSignatureKey() + ); + await this.senderKeyStore.storeSenderKey(senderKeyName, senderKeyRecord); + } + + // [{"senderKeyId":1742199468,"senderChainKey":{"iteration":0,"seed":"yxMY9VFQcXEP34olRAcGCtsgx1XoKsHfDIh+1ea4HAQ="},"senderSigningKey":{"public":""}}] + async create(senderKeyName) { + try { + const senderKeyRecord = await this.senderKeyStore.loadSenderKey(senderKeyName); + //console.log('GroupSessionBuilder create session', senderKeyName, senderKeyRecord); + + if (senderKeyRecord.isEmpty()) { + const keyId = keyhelper.generateSenderKeyId(); + const senderKey = keyhelper.generateSenderKey(); + const signingKey = keyhelper.generateSenderSigningKey(); + + senderKeyRecord.setSenderKeyState(keyId, 0, senderKey, signingKey); + await this.senderKeyStore.storeSenderKey(senderKeyName, senderKeyRecord); + } + + const state = senderKeyRecord.getSenderKeyState(); + + return new SenderKeyDistributionMessage( + state.getKeyId(), + state.getSenderChainKey().getIteration(), + state.getSenderChainKey().getSeed(), + state.getSigningKeyPublic() + ); + } catch (e) { + //console.log(e.stack); + throw new Error(e); + } + } +} +module.exports = GroupSessionBuilder; \ No newline at end of file diff --git a/WASignalGroup/index.js b/WASignalGroup/index.js new file mode 100644 index 0000000..69b935d --- /dev/null +++ b/WASignalGroup/index.js @@ -0,0 +1,5 @@ +module.exports.GroupSessionBuilder = require('./group_session_builder') +module.exports.SenderKeyDistributionMessage = require('./sender_key_distribution_message') +module.exports.SenderKeyRecord = require('./sender_key_record') +module.exports.SenderKeyName = require('./sender_key_name') +module.exports.GroupCipher = require('./group_cipher') \ No newline at end of file diff --git a/WASignalGroup/protobufs.js b/WASignalGroup/protobufs.js new file mode 100644 index 0000000..797bd73 --- /dev/null +++ b/WASignalGroup/protobufs.js @@ -0,0 +1,13 @@ +const path = require('path'); +const protobuf = require('protobufjs'); + +const protodir = path.resolve(__dirname); +const group = protobuf.loadSync(path.join(protodir, 'group.proto')).lookup('groupproto'); + +module.exports = { + SenderKeyDistributionMessage: group.lookup('SenderKeyDistributionMessage'), + SenderKeyMessage: group.lookup('SenderKeyMessage'), + SenderKeyStateStructure: group.lookup('SenderKeyStateStructure'), + SenderChainKey: group.lookup('SenderChainKey'), + SenderSigningKey: group.lookup('SenderSigningKey'), +}; diff --git a/WASignalGroup/readme.md b/WASignalGroup/readme.md new file mode 100644 index 0000000..8290d9c --- /dev/null +++ b/WASignalGroup/readme.md @@ -0,0 +1,6 @@ +# Signal-Group + +This contains the code to decrypt/encrypt WA group messages. +Originally from [pokearaujo/libsignal-node](https://github.com/pokearaujo/libsignal-node) + +The code has been moved outside the signal package as I felt it didn't belong in ths signal package, as it isn't inherently a part of signal but of WA. \ No newline at end of file diff --git a/WASignalGroup/sender_chain_key.js b/WASignalGroup/sender_chain_key.js new file mode 100644 index 0000000..9a3125b --- /dev/null +++ b/WASignalGroup/sender_chain_key.js @@ -0,0 +1,50 @@ +const SenderMessageKey = require('./sender_message_key'); +//const HKDF = require('./hkdf'); +const crypto = require('libsignal/src/crypto'); + +class SenderChainKey { + MESSAGE_KEY_SEED = Buffer.from([0x01]); + + CHAIN_KEY_SEED = Buffer.from([0x02]); + + iteration = 0; + + chainKey = Buffer.alloc(0); + + constructor(iteration, chainKey) { + this.iteration = iteration; + this.chainKey = chainKey; + } + + getIteration() { + return this.iteration; + } + + getSenderMessageKey() { + return new SenderMessageKey( + this.iteration, + this.getDerivative(this.MESSAGE_KEY_SEED, this.chainKey) + ); + } + + getNext() { + return new SenderChainKey( + this.iteration + 1, + this.getDerivative(this.CHAIN_KEY_SEED, this.chainKey) + ); + } + + getSeed() { + return typeof this.chainKey === 'string' ? Buffer.from(this.chainKey, 'base64') : this.chainKey; + } + + getDerivative(seed, key) { + key = typeof key === 'string' ? Buffer.from(key, 'base64') : key; + const hash = crypto.calculateMAC(key, seed); + //const hash = new Hash().hmac_hash(key, seed, 'sha256', ''); + + return hash; + } +} + +module.exports = SenderChainKey; \ No newline at end of file diff --git a/WASignalGroup/sender_key_distribution_message.js b/WASignalGroup/sender_key_distribution_message.js new file mode 100644 index 0000000..9c1400f --- /dev/null +++ b/WASignalGroup/sender_key_distribution_message.js @@ -0,0 +1,78 @@ +const CiphertextMessage = require('./ciphertext_message'); +const protobufs = require('./protobufs'); + +class SenderKeyDistributionMessage extends CiphertextMessage { + constructor( + id = null, + iteration = null, + chainKey = null, + signatureKey = null, + serialized = null + ) { + super(); + if (serialized) { + try { + const version = serialized[0]; + const message = serialized.slice(1); + + const distributionMessage = protobufs.SenderKeyDistributionMessage.decode( + message + ).toJSON(); + this.serialized = serialized; + this.id = distributionMessage.id; + this.iteration = distributionMessage.iteration; + this.chainKey = distributionMessage.chainKey; + this.signatureKey = distributionMessage.signingKey; + } catch (e) { + throw new Error(e); + } + } else { + const version = this.intsToByteHighAndLow(this.CURRENT_VERSION, this.CURRENT_VERSION); + this.id = id; + this.iteration = iteration; + this.chainKey = chainKey; + this.signatureKey = signatureKey; + const message = protobufs.SenderKeyDistributionMessage.encode( + protobufs.SenderKeyDistributionMessage.create({ + id, + iteration, + chainKey, + signingKey: this.signatureKey, + }) + ).finish(); + this.serialized = Buffer.concat([Buffer.from([version]), message]); + } + } + + intsToByteHighAndLow(highValue, lowValue) { + return (((highValue << 4) | lowValue) & 0xff) % 256; + } + + serialize() { + return this.serialized; + } + + getType() { + return this.SENDERKEY_DISTRIBUTION_TYPE; + } + + getIteration() { + return this.iteration; + } + + getChainKey() { + return typeof this.chainKey === 'string' ? Buffer.from(this.chainKey, 'base64') : this.chainKey; + } + + getSignatureKey() { + return typeof this.signatureKey === 'string' + ? Buffer.from(this.signatureKey, 'base64') + : this.signatureKey; + } + + getId() { + return this.id; + } +} + +module.exports = SenderKeyDistributionMessage; \ No newline at end of file diff --git a/WASignalGroup/sender_key_message.js b/WASignalGroup/sender_key_message.js new file mode 100644 index 0000000..80683a6 --- /dev/null +++ b/WASignalGroup/sender_key_message.js @@ -0,0 +1,92 @@ +const CiphertextMessage = require('./ciphertext_message'); +const curve = require('libsignal/src/curve'); +const protobufs = require('./protobufs'); + +class SenderKeyMessage extends CiphertextMessage { + SIGNATURE_LENGTH = 64; + + constructor( + keyId = null, + iteration = null, + ciphertext = null, + signatureKey = null, + serialized = null + ) { + super(); + if (serialized) { + const version = serialized[0]; + const message = serialized.slice(1, serialized.length - this.SIGNATURE_LENGTH); + const signature = serialized.slice(-1 * this.SIGNATURE_LENGTH); + const senderKeyMessage = protobufs.SenderKeyMessage.decode(message).toJSON(); + senderKeyMessage.ciphertext = Buffer.from(senderKeyMessage.ciphertext, 'base64'); + + this.serialized = serialized; + this.messageVersion = (version & 0xff) >> 4; + + this.keyId = senderKeyMessage.id; + this.iteration = senderKeyMessage.iteration; + this.ciphertext = senderKeyMessage.ciphertext; + this.signature = signature; + } else { + const version = (((this.CURRENT_VERSION << 4) | this.CURRENT_VERSION) & 0xff) % 256; + ciphertext = Buffer.from(ciphertext); // .toString('base64'); + const message = protobufs.SenderKeyMessage.encode( + protobufs.SenderKeyMessage.create({ + id: keyId, + iteration, + ciphertext, + }) + ).finish(); + + const signature = this.getSignature( + signatureKey, + Buffer.concat([Buffer.from([version]), message]) + ); + this.serialized = Buffer.concat([Buffer.from([version]), message, Buffer.from(signature)]); + this.messageVersion = this.CURRENT_VERSION; + this.keyId = keyId; + this.iteration = iteration; + this.ciphertext = ciphertext; + this.signature = signature; + } + } + + getKeyId() { + return this.keyId; + } + + getIteration() { + return this.iteration; + } + + getCipherText() { + return this.ciphertext; + } + + verifySignature(signatureKey) { + const part1 = this.serialized.slice(0, this.serialized.length - this.SIGNATURE_LENGTH + 1); + const part2 = this.serialized.slice(-1 * this.SIGNATURE_LENGTH); + const res = curve.verifySignature(signatureKey, part1, part2); + if (!res) throw new Error('Invalid signature!'); + } + + getSignature(signatureKey, serialized) { + const signature = Buffer.from( + curve.calculateSignature( + signatureKey, + serialized + ) + ); + return signature; + } + + serialize() { + return this.serialized; + } + + getType() { + return 4; + } +} + +module.exports = SenderKeyMessage; \ No newline at end of file diff --git a/WASignalGroup/sender_key_name.js b/WASignalGroup/sender_key_name.js new file mode 100644 index 0000000..e7f5290 --- /dev/null +++ b/WASignalGroup/sender_key_name.js @@ -0,0 +1,70 @@ +function isNull(str) { + return str === null || str.value === ''; +} + +/** + * java String hashCode 的实现 + * @param strKey + * @return intValue + */ +function intValue(num) { + const MAX_VALUE = 0x7fffffff; + const MIN_VALUE = -0x80000000; + if (num > MAX_VALUE || num < MIN_VALUE) { + // eslint-disable-next-line + return (num &= 0xffffffff); + } + return num; +} + +function hashCode(strKey) { + let hash = 0; + if (!isNull(strKey)) { + for (let i = 0; i < strKey.length; i++) { + hash = hash * 31 + strKey.charCodeAt(i); + hash = intValue(hash); + } + } + return hash; +} + +/** + * 将js页面的number类型转换为java的int类型 + * @param num + * @return intValue + */ + +class SenderKeyName { + constructor(groupId, sender) { + this.groupId = groupId; + this.sender = sender; + } + + getGroupId() { + return this.groupId; + } + + getSender() { + return this.sender; + } + + serialize() { + return `${this.groupId}::${this.sender.id}::${this.sender.deviceId}`; + } + + toString() { + return this.serialize(); + } + + equals(other) { + if (other === null) return false; + if (!(other instanceof SenderKeyName)) return false; + return this.groupId === other.groupId && this.sender.toString() === other.sender.toString(); + } + + hashCode() { + return hashCode(this.groupId) ^ hashCode(this.sender.toString()); + } +} + +module.exports = SenderKeyName; \ No newline at end of file diff --git a/WASignalGroup/sender_key_record.js b/WASignalGroup/sender_key_record.js new file mode 100644 index 0000000..e17f290 --- /dev/null +++ b/WASignalGroup/sender_key_record.js @@ -0,0 +1,54 @@ +const SenderKeyState = require('./sender_key_state'); + +class SenderKeyRecord { + MAX_STATES = 5; + + constructor(serialized) { + this.senderKeyStates = []; + + if (serialized) { + const list = serialized; + for (let i = 0; i < list.length; i++) { + const structure = list[i]; + this.senderKeyStates.push( + new SenderKeyState(null, null, null, null, null, null, structure) + ); + } + } + } + + isEmpty() { + return this.senderKeyStates.length === 0; + } + + getSenderKeyState(keyId) { + if (!keyId && this.senderKeyStates.length) return this.senderKeyStates[0]; + for (let i = 0; i < this.senderKeyStates.length; i++) { + const state = this.senderKeyStates[i]; + if (state.getKeyId() === keyId) { + return state; + } + } + throw new Error(`No keys for: ${keyId}`); + } + + addSenderKeyState(id, iteration, chainKey, signatureKey) { + this.senderKeyStates.push(new SenderKeyState(id, iteration, chainKey, null, signatureKey)); + } + + setSenderKeyState(id, iteration, chainKey, keyPair) { + this.senderKeyStates.length = 0; + this.senderKeyStates.push(new SenderKeyState(id, iteration, chainKey, keyPair)); + } + + serialize() { + const recordStructure = []; + for (let i = 0; i < this.senderKeyStates.length; i++) { + const senderKeyState = this.senderKeyStates[i]; + recordStructure.push(senderKeyState.getStructure()); + } + return recordStructure; + } + } + + module.exports = SenderKeyRecord; \ No newline at end of file diff --git a/WASignalGroup/sender_key_state.js b/WASignalGroup/sender_key_state.js new file mode 100644 index 0000000..c3e0fc9 --- /dev/null +++ b/WASignalGroup/sender_key_state.js @@ -0,0 +1,129 @@ +const SenderChainKey = require('./sender_chain_key'); +const SenderMessageKey = require('./sender_message_key'); + +const protobufs = require('./protobufs'); + +class SenderKeyState { + MAX_MESSAGE_KEYS = 2000; + + constructor( + id = null, + iteration = null, + chainKey = null, + signatureKeyPair = null, + signatureKeyPublic = null, + signatureKeyPrivate = null, + senderKeyStateStructure = null + ) { + if (senderKeyStateStructure) { + this.senderKeyStateStructure = senderKeyStateStructure; + } else { + if (signatureKeyPair) { + signatureKeyPublic = signatureKeyPair.public; + signatureKeyPrivate = signatureKeyPair.private; + } + + chainKey = typeof chainKey === 'string' ? Buffer.from(chainKey, 'base64') : chainKey; + this.senderKeyStateStructure = protobufs.SenderKeyStateStructure.create(); + const senderChainKeyStructure = protobufs.SenderChainKey.create(); + senderChainKeyStructure.iteration = iteration; + senderChainKeyStructure.seed = chainKey; + this.senderKeyStateStructure.senderChainKey = senderChainKeyStructure; + + const signingKeyStructure = protobufs.SenderSigningKey.create(); + signingKeyStructure.public = + typeof signatureKeyPublic === 'string' ? + Buffer.from(signatureKeyPublic, 'base64') : + signatureKeyPublic; + if (signatureKeyPrivate) { + signingKeyStructure.private = + typeof signatureKeyPrivate === 'string' ? + Buffer.from(signatureKeyPrivate, 'base64') : + signatureKeyPrivate; + } + this.senderKeyStateStructure.senderKeyId = id; + this.senderChainKey = senderChainKeyStructure; + this.senderKeyStateStructure.senderSigningKey = signingKeyStructure; + } + this.senderKeyStateStructure.senderMessageKeys = + this.senderKeyStateStructure.senderMessageKeys || []; + } + + SenderKeyState(senderKeyStateStructure) { + this.senderKeyStateStructure = senderKeyStateStructure; + } + + getKeyId() { + return this.senderKeyStateStructure.senderKeyId; + } + + getSenderChainKey() { + return new SenderChainKey( + this.senderKeyStateStructure.senderChainKey.iteration, + this.senderKeyStateStructure.senderChainKey.seed + ); + } + + setSenderChainKey(chainKey) { + const senderChainKeyStructure = protobufs.SenderChainKey.create({ + iteration: chainKey.getIteration(), + seed: chainKey.getSeed(), + }); + this.senderKeyStateStructure.senderChainKey = senderChainKeyStructure; + } + + getSigningKeyPublic() { + return typeof this.senderKeyStateStructure.senderSigningKey.public === 'string' ? + Buffer.from(this.senderKeyStateStructure.senderSigningKey.public, 'base64') : + this.senderKeyStateStructure.senderSigningKey.public; + } + + getSigningKeyPrivate() { + return typeof this.senderKeyStateStructure.senderSigningKey.private === 'string' ? + Buffer.from(this.senderKeyStateStructure.senderSigningKey.private, 'base64') : + this.senderKeyStateStructure.senderSigningKey.private; + } + + hasSenderMessageKey(iteration) { + const list = this.senderKeyStateStructure.senderMessageKeys; + for (let o = 0; o < list.length; o++) { + const senderMessageKey = list[o]; + if (senderMessageKey.iteration === iteration) return true; + } + return false; + } + + addSenderMessageKey(senderMessageKey) { + const senderMessageKeyStructure = protobufs.SenderKeyStateStructure.create({ + iteration: senderMessageKey.getIteration(), + seed: senderMessageKey.getSeed(), + }); + this.senderKeyStateStructure.senderMessageKeys.push(senderMessageKeyStructure); + + if (this.senderKeyStateStructure.senderMessageKeys.length > this.MAX_MESSAGE_KEYS) { + this.senderKeyStateStructure.senderMessageKeys.shift(); + } + } + + removeSenderMessageKey(iteration) { + let result = null; + + this.senderKeyStateStructure.senderMessageKeys = this.senderKeyStateStructure.senderMessageKeys.filter( + senderMessageKey => { + if (senderMessageKey.iteration === iteration) result = senderMessageKey; + return senderMessageKey.iteration !== iteration; + } + ); + + if (result != null) { + return new SenderMessageKey(result.iteration, result.seed); + } + return null; + } + + getStructure() { + return this.senderKeyStateStructure; + } +} + +module.exports = SenderKeyState; \ No newline at end of file diff --git a/WASignalGroup/sender_message_key.js b/WASignalGroup/sender_message_key.js new file mode 100644 index 0000000..7639704 --- /dev/null +++ b/WASignalGroup/sender_message_key.js @@ -0,0 +1,39 @@ +const { deriveSecrets } = require('libsignal/src/crypto'); +class SenderMessageKey { + iteration = 0; + + iv = Buffer.alloc(0); + + cipherKey = Buffer.alloc(0); + + seed = Buffer.alloc(0); + + constructor(iteration, seed) { + const derivative = deriveSecrets(seed, Buffer.alloc(32), Buffer.from('WhisperGroup')); + const keys = new Uint8Array(32); + keys.set(new Uint8Array(derivative[0].slice(16))); + keys.set(new Uint8Array(derivative[1].slice(0, 16)), 16); + this.iv = Buffer.from(derivative[0].slice(0, 16)); + this.cipherKey = Buffer.from(keys.buffer); + + this.iteration = iteration; + this.seed = seed; + } + + getIteration() { + return this.iteration; + } + + getIv() { + return this.iv; + } + + getCipherKey() { + return this.cipherKey; + } + + getSeed() { + return this.seed; + } +} +module.exports = SenderMessageKey; \ No newline at end of file diff --git a/package.json b/package.json index 1a277fd..06b5ebd 100644 --- a/package.json +++ b/package.json @@ -33,10 +33,9 @@ }, "dependencies": { "@hapi/boom": "^9.1.3", - "curve25519-js": "^0.0.4", - "futoin-hkdf": "^1.3.2", "got": "^11.8.1", "jimp": "^0.16.1", + "libsignal": "^2.0.1", "music-metadata": "^7.4.1", "pino": "^6.7.0", "protobufjs": "^6.10.1", @@ -48,7 +47,9 @@ }, "files": [ "lib/*", - "WAMessage/*" + "WAProto/*", + "WASignalGroup/*", + "WABinary/*" ], "devDependencies": { "@adiwajshing/keyed-db": "^0.2.4", @@ -57,7 +58,6 @@ "@types/node": "^14.6.2", "@types/pino": "^6.3.2", "@types/ws": "^7.2.6", - "https-proxy-agent": "^5.0.0", "jest": "^27.0.6", "qrcode-terminal": "^0.12.0", "ts-jest": "^27.0.3", diff --git a/src/BinaryNode/decode.ts b/src/BinaryNode/decode.ts deleted file mode 100644 index 7f26239..0000000 --- a/src/BinaryNode/decode.ts +++ /dev/null @@ -1,204 +0,0 @@ -import { proto } from '../../WAMessage' -import { BinaryNode, DoubleByteTokens, SingleByteTokens, Tags } from './types' - -function decode(buffer: Buffer, makeNode: () => T, indexRef: { index: number }) { - - const checkEOS = (length: number) => { - if (indexRef.index + length > buffer.length) { - throw new Error('end of stream') - } - } - const next = () => { - const value = buffer[indexRef.index] - indexRef.index += 1 - return value - } - const readByte = () => { - checkEOS(1) - return next() - } - const readStringFromChars = (length: number) => { - checkEOS(length) - const value = buffer.slice(indexRef.index, indexRef.index + length) - - indexRef.index += length - return value.toString('utf-8') - } - const readBytes = (n: number) => { - checkEOS(n) - const value = buffer.slice(indexRef.index, indexRef.index + n) - indexRef.index += n - return value - } - const readInt = (n: number, littleEndian = false) => { - checkEOS(n) - let val = 0 - for (let i = 0; i < n; i++) { - const shift = littleEndian ? i : n - 1 - i - val |= next() << (shift * 8) - } - return val - } - const readInt20 = () => { - checkEOS(3) - return ((next() & 15) << 16) + (next() << 8) + next() - } - const unpackHex = (value: number) => { - if (value >= 0 && value < 16) { - return value < 10 ? '0'.charCodeAt(0) + value : 'A'.charCodeAt(0) + value - 10 - } - throw new Error('invalid hex: ' + value) - } - const unpackNibble = (value: number) => { - if (value >= 0 && value <= 9) { - return '0'.charCodeAt(0) + value - } - switch (value) { - case 10: - return '-'.charCodeAt(0) - case 11: - return '.'.charCodeAt(0) - case 15: - return '\0'.charCodeAt(0) - default: - throw new Error('invalid nibble: ' + value) - } - } - const unpackByte = (tag: number, value: number) => { - if (tag === Tags.NIBBLE_8) { - return unpackNibble(value) - } else if (tag === Tags.HEX_8) { - return unpackHex(value) - } else { - throw new Error('unknown tag: ' + tag) - } - } - const readPacked8 = (tag: number) => { - const startByte = readByte() - let value = '' - - for (let i = 0; i < (startByte & 127); i++) { - const curByte = readByte() - value += String.fromCharCode(unpackByte(tag, (curByte & 0xf0) >> 4)) - value += String.fromCharCode(unpackByte(tag, curByte & 0x0f)) - } - if (startByte >> 7 !== 0) { - value = value.slice(0, -1) - } - return value - } - const isListTag = (tag: number) => { - return tag === Tags.LIST_EMPTY || tag === Tags.LIST_8 || tag === Tags.LIST_16 - } - const readListSize = (tag: number) => { - switch (tag) { - case Tags.LIST_EMPTY: - return 0 - case Tags.LIST_8: - return readByte() - case Tags.LIST_16: - return readInt(2) - default: - throw new Error('invalid tag for list size: ' + tag) - } - } - const getToken = (index: number) => { - if (index < 3 || index >= SingleByteTokens.length) { - throw new Error('invalid token index: ' + index) - } - return SingleByteTokens[index] - } - const readString = (tag: number) => { - if (tag >= 3 && tag <= 235) { - const token = getToken(tag) - return token// === 's.whatsapp.net' ? 'c.us' : token - } - - switch (tag) { - case Tags.DICTIONARY_0: - case Tags.DICTIONARY_1: - case Tags.DICTIONARY_2: - case Tags.DICTIONARY_3: - return getTokenDouble(tag - Tags.DICTIONARY_0, readByte()) - case Tags.LIST_EMPTY: - return null - case Tags.BINARY_8: - return readStringFromChars(readByte()) - case Tags.BINARY_20: - return readStringFromChars(readInt20()) - case Tags.BINARY_32: - return readStringFromChars(readInt(4)) - case Tags.JID_PAIR: - const i = readString(readByte()) - const j = readString(readByte()) - if (typeof i === 'string' && j) { - return i + '@' + j - } - throw new Error('invalid jid pair: ' + i + ', ' + j) - case Tags.HEX_8: - case Tags.NIBBLE_8: - return readPacked8(tag) - default: - throw new Error('invalid string with tag: ' + tag) - } - } - const readList = (tag: number) => ( - [...new Array(readListSize(tag))].map(() => decode(buffer, makeNode, indexRef)) - ) - const getTokenDouble = (index1: number, index2: number) => { - const n = 256 * index1 + index2 - if (n < 0 || n > DoubleByteTokens.length) { - throw new Error('invalid double token index: ' + n) - } - return DoubleByteTokens[n] - } - const node = makeNode() - const listSize = readListSize(readByte()) - const descrTag = readByte() - if (descrTag === Tags.STREAM_END) { - throw new Error('unexpected stream end') - } - node.header = readString(descrTag) - if (listSize === 0 || !node.header) { - throw new Error('invalid node') - } - // read the attributes in - const attributesLength = (listSize - 1) >> 1 - for (let i = 0; i < attributesLength; i++) { - const key = readString(readByte()) - const b = readByte() - - node.attributes[key] = readString(b) - } - - if (listSize % 2 === 0) { - const tag = readByte() - if (isListTag(tag)) { - node.data = readList(tag) - } else { - let decoded: Buffer | string - switch (tag) { - case Tags.BINARY_8: - decoded = readBytes(readByte()) - break - case Tags.BINARY_20: - decoded = readBytes(readInt20()) - break - case Tags.BINARY_32: - decoded = readBytes(readInt(4)) - break - default: - decoded = readString(tag) - break - } - - if (node.header === 'message' && Buffer.isBuffer(decoded)) { - node.data = proto.WebMessageInfo.decode(decoded) - } else { - node.data = decoded - } - } - } - return node -} -export default decode \ No newline at end of file diff --git a/src/BinaryNode/encode.ts b/src/BinaryNode/encode.ts deleted file mode 100644 index 4499236..0000000 --- a/src/BinaryNode/encode.ts +++ /dev/null @@ -1,123 +0,0 @@ -import { proto } from "../../WAMessage"; -import { BinaryNode, SingleByteTokens, Tags } from "./types"; - -const encode = ({ header, attributes, data }: BinaryNode, buffer: number[] = []) => { - - const pushByte = (value: number) => buffer.push(value & 0xff) - - const pushInt = (value: number, n: number, littleEndian=false) => { - for (let i = 0; i < n; i++) { - const curShift = littleEndian ? i : n - 1 - i - buffer.push((value >> (curShift * 8)) & 0xff) - } - } - const pushBytes = (bytes: Uint8Array | Buffer | number[]) => ( - bytes.forEach (b => buffer.push(b)) - ) - const pushInt20 = (value: number) => ( - pushBytes([(value >> 16) & 0x0f, (value >> 8) & 0xff, value & 0xff]) - ) - const writeByteLength = (length: number) => { - if (length >= 4294967296) throw new Error('string too large to encode: ' + length) - - if (length >= 1 << 20) { - pushByte(Tags.BINARY_32) - pushInt(length, 4) // 32 bit integer - } else if (length >= 256) { - pushByte(Tags.BINARY_20) - pushInt20(length) - } else { - pushByte(Tags.BINARY_8) - pushByte(length) - } - } - const writeStringRaw = (str: string) => { - const bytes = Buffer.from (str, 'utf-8') - writeByteLength(bytes.length) - pushBytes(bytes) - } - const writeToken = (token: number) => { - if (token < 245) { - pushByte(token) - } else if (token <= 500) { - throw new Error('invalid token') - } - } - const writeString = (token: string, i?: boolean) => { - if (token === 'c.us') token = 's.whatsapp.net' - - const tokenIndex = SingleByteTokens.indexOf(token) - if (!i && token === 's.whatsapp.net') { - writeToken(tokenIndex) - } else if (tokenIndex >= 0) { - if (tokenIndex < Tags.SINGLE_BYTE_MAX) { - writeToken(tokenIndex) - } else { - const overflow = tokenIndex - Tags.SINGLE_BYTE_MAX - const dictionaryIndex = overflow >> 8 - if (dictionaryIndex < 0 || dictionaryIndex > 3) { - throw new Error('double byte dict token out of range: ' + token + ', ' + tokenIndex) - } - writeToken(Tags.DICTIONARY_0 + dictionaryIndex) - writeToken(overflow % 256) - } - } else if (token) { - const jidSepIndex = token.indexOf('@') - if (jidSepIndex <= 0) { - writeStringRaw(token) - } else { - writeJid(token.slice(0, jidSepIndex), token.slice(jidSepIndex + 1, token.length)) - } - } - } - const writeJid = (left: string, right: string) => { - pushByte(Tags.JID_PAIR) - left && left.length > 0 ? writeString(left) : writeToken(Tags.LIST_EMPTY) - writeString(right) - } - const writeListStart = (listSize: number) => { - if (listSize === 0) { - pushByte(Tags.LIST_EMPTY) - } else if (listSize < 256) { - pushBytes([Tags.LIST_8, listSize]) - } else { - pushBytes([Tags.LIST_16, listSize]) - } - } - const validAttributes = Object.keys(attributes).filter(k => ( - typeof attributes[k] !== 'undefined' && attributes[k] !== null - )) - - writeListStart(2*validAttributes.length + 1 + (typeof data !== 'undefined' && data !== null ? 1 : 0)) - writeString(header) - - validAttributes.forEach((key) => { - if(typeof attributes[key] === 'string') { - writeString(key) - writeString(attributes[key]) - } - }) - - if(data instanceof proto.WebMessageInfo && !Buffer.isBuffer(data)) { - data = Buffer.from(proto.WebMessageInfo.encode(data).finish()) - } - - if (typeof data === 'string') { - writeString(data, true) - } else if (Buffer.isBuffer(data)) { - writeByteLength(data.length) - pushBytes(data) - } else if (Array.isArray(data)) { - writeListStart(data.length) - for(const item of data) { - if(item) encode(item, buffer) - } - } else if(typeof data === 'undefined' || data === null) { - - } else { - throw new Error(`invalid children for header "${header}": ${data} (${typeof data})`) - } - - return Buffer.from(buffer) -} -export default encode \ No newline at end of file diff --git a/src/BinaryNode/index.ts b/src/BinaryNode/index.ts deleted file mode 100644 index 3eb830b..0000000 --- a/src/BinaryNode/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -import decode from './decode' -import encode from './encode' -import { BinaryNode as BinaryNodeType } from './types' - -export default class BinaryNode extends BinaryNodeType { - toBuffer = () => encode(this, []) - static from = (buffer: Buffer) => decode(buffer, () => new BinaryNode(), { index: 0 }) -} \ No newline at end of file diff --git a/src/BinaryNode/types.ts b/src/BinaryNode/types.ts deleted file mode 100644 index 8e5e56a..0000000 --- a/src/BinaryNode/types.ts +++ /dev/null @@ -1,212 +0,0 @@ -import { proto } from "../../WAMessage" - -export type Attributes = { [key: string]: string } -export type BinaryNodeData = BinaryNode[] | string | Buffer | proto.IWebMessageInfo | undefined -export class BinaryNode { - header: string - attributes: Attributes = {} - data?: BinaryNodeData - - constructor(header?: string, attrs?: Attributes, data?: BinaryNodeData) { - this.header = header - this.attributes = attrs || {} - this.data = data - } -} -export const Tags = { - 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, - SINGLE_BYTE_MAX: 256, - PACKED_MAX: 254, -} -export const DoubleByteTokens = [] -export const SingleByteTokens = [ - null, - null, - null, - '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', - 'quick_reply', - 'sticker', - 'pay_t', - 'accept', - 'reject', - 'sticker_pack', - 'invalid', - 'canceled', - 'missed', - 'connected', - 'result', - 'audio', - 'video', - 'recent', -] \ No newline at end of file diff --git a/src/BrowserMessageDecoding.ts b/src/BrowserMessageDecoding.ts deleted file mode 100644 index 1a59c19..0000000 --- a/src/BrowserMessageDecoding.ts +++ /dev/null @@ -1,41 +0,0 @@ -import fs from 'fs' -import { decodeWAMessage } from './Utils/decode-wa-message' - -interface BrowserMessagesInfo { - bundle: { encKey: string, macKey: string } - harFilePath: string -} -interface WSMessage { - type: 'send' | 'receive', - data: string -} -const file = fs.readFileSync ('./browser-messages.json', {encoding: 'utf-8'}) -const json: BrowserMessagesInfo = JSON.parse (file) - -const encKey = Buffer.from (json.bundle.encKey, 'base64') -const macKey = Buffer.from (json.bundle.macKey, 'base64') - -const harFile = JSON.parse ( fs.readFileSync( json.harFilePath , {encoding: 'utf-8'})) -const entries = harFile['log']['entries'] -let wsMessages: WSMessage[] = [] -entries.forEach ((e, i) => { - if ('_webSocketMessages' in e) { - wsMessages.push (...e['_webSocketMessages']) - } -}) -const decrypt = (buffer, fromMe) => decodeWAMessage(buffer, { macKey, encKey }, fromMe) - -console.log ('parsing ' + wsMessages.length + ' messages') -const list = wsMessages.map ((item, i) => { - const buffer = item.data.includes(',') ? item.data : Buffer.from (item.data, 'base64') - try { - const [tag, json, binaryTags] = decrypt (buffer, item.type === 'send') - - return {tag, json: json && JSON.stringify(json), binaryTags} - } catch (error) { - return { error: error.message, data: buffer.toString('utf-8') } - } -}) -.filter (Boolean) -const str = JSON.stringify (list, null, '\t') -fs.writeFileSync ('decoded-ws.json', str) \ No newline at end of file diff --git a/src/Connection/auth.ts b/src/Connection/auth.ts deleted file mode 100644 index 547340b..0000000 --- a/src/Connection/auth.ts +++ /dev/null @@ -1,275 +0,0 @@ -import { Boom } from '@hapi/boom' -import EventEmitter from "events" -import * as Curve from 'curve25519-js' -import { BaileysEventEmitter, BaileysEventMap, SocketConfig, CurveKeyPair, WAInitResponse, ConnectionState, DisconnectReason } from "../Types" -import { makeSocket } from "./socket" -import { generateClientID, promiseTimeout, normalizedAuthInfo, computeChallengeResponse, validateNewConnection } from "../Utils" -import { randomBytes } from "crypto" -import { AuthenticationCredentials } from "../Types" - -const makeAuthSocket = (config: SocketConfig) => { - const { - logger, - version, - browser, - connectTimeoutMs, - pendingRequestTimeoutMs, - maxQRCodes, - printQRInTerminal, - credentials: anyAuthInfo - } = config - const ev = new EventEmitter() as BaileysEventEmitter - - let authInfo = normalizedAuthInfo(anyAuthInfo) || - // generate client id if not there - { clientID: generateClientID() } as AuthenticationCredentials - - const state: ConnectionState = { - phoneConnected: false, - connection: 'connecting', - } - - const socket = makeSocket({ - ...config, - phoneConnectionChanged: phoneConnected => { - if(phoneConnected !== state.phoneConnected) { - updateState({ phoneConnected }) - } - } - }) - const { ws } = socket - let curveKeys: CurveKeyPair - let initTimeout: NodeJS.Timeout - // add close listener - ws.on('ws-close', (error: Boom | Error) => { - logger.info({ error }, 'Closed connection to WhatsApp') - initTimeout && clearTimeout(initTimeout) - // if no reconnects occur - // send close event - updateState({ - connection: 'close', - qr: undefined, - connectionTriesLeft: undefined, - lastDisconnect: { - error, - date: new Date() - } - }) - }) - /** Can you login to WA without scanning the QR */ - const canLogin = () => !!authInfo?.encKey && !!authInfo?.macKey - - const updateState = (update: Partial) => { - Object.assign(state, update) - ev.emit('connection.update', update) - } - - /** - * Logs you out from WA - * If connected, invalidates the credentials with the server - */ - const logout = async() => { - if(state.connection === 'open') { - await socket.sendMessage({ - json: ['admin', 'Conn', 'disconnect'], - tag: 'goodbye' - }) - } - // will call state update to close connection - socket?.end( - new Boom('Logged Out', { statusCode: DisconnectReason.credentialsInvalidated }) - ) - authInfo = undefined - } - /** Waits for the connection to WA to open up */ - const waitForConnection = async(waitInfinitely: boolean = false) => { - if(state.connection === 'open') return - - let listener: (item: BaileysEventMap['connection.update']) => void - const timeout = waitInfinitely ? undefined : pendingRequestTimeoutMs - if(timeout < 0) { - throw new Boom('Connection Closed', { statusCode: DisconnectReason.connectionClosed }) - } - - await ( - promiseTimeout( - timeout, - (resolve, reject) => { - listener = ({ connection, lastDisconnect }) => { - if(connection === 'open') resolve() - else if(connection == 'close') { - reject(lastDisconnect.error || new Boom('Connection Closed', { statusCode: DisconnectReason.connectionClosed })) - } - } - ev.on('connection.update', listener) - } - ) - .finally(() => ( - ev.off('connection.update', listener) - )) - ) - } - - const updateEncKeys = () => { - // update the keys so we can decrypt traffic - socket.updateKeys({ encKey: authInfo!.encKey, macKey: authInfo!.macKey }) - } - - const generateKeysForAuth = async(ref: string, ttl?: number) => { - curveKeys = Curve.generateKeyPair(randomBytes(32)) - const publicKey = Buffer.from(curveKeys.public).toString('base64') - let qrGens = 0 - - const qrLoop = ttl => { - const qr = [ref, publicKey, authInfo.clientID].join(',') - updateState({ qr }) - - initTimeout = setTimeout(async () => { - if(state.connection !== 'connecting') return - - logger.debug('regenerating QR') - try { - if(qrGens >= maxQRCodes) { - throw new Boom( - 'Too many QR codes', - { statusCode: 429 } - ) - } - // request new QR - const {ref: newRef, ttl: newTTL} = await socket.query({ - json: ['admin', 'Conn', 'reref'], - expect200: true, - longTag: true, - requiresPhoneConnection: false - }) - ttl = newTTL - ref = newRef - } catch (error) { - logger.error({ error }, `error in QR gen`) - if (error.output?.statusCode === 429) { // too many QR requests - socket.end(error) - return - } - } - qrGens += 1 - qrLoop(ttl) - }, ttl || 20_000) // default is 20s, on the off-chance ttl is not present - } - qrLoop(ttl) - } - const onOpen = async() => { - const canDoLogin = canLogin() - const initQuery = (async () => { - const {ref, ttl} = await socket.query({ - json: ['admin', 'init', version, browser, authInfo.clientID, true], - expect200: true, - longTag: true, - requiresPhoneConnection: false - }) as WAInitResponse - - if (!canDoLogin) { - generateKeysForAuth(ref, ttl) - } - })(); - let loginTag: string - if(canDoLogin) { - updateEncKeys() - // if we have the info to restore a closed session - const json = [ - 'admin', - 'login', - authInfo.clientToken, - authInfo.serverToken, - authInfo.clientID, - 'takeover' - ] - loginTag = socket.generateMessageTag(true) - // send login every 10s - const sendLoginReq = () => { - if(state.connection === 'open') { - logger.warn('Received login timeout req when state=open, ignoring...') - return - } - logger.info('sending login request') - socket.sendMessage({ - json, - tag: loginTag - }) - initTimeout = setTimeout(sendLoginReq, 10_000) - } - sendLoginReq() - } - await initQuery - - // wait for response with tag "s1" - let response = await Promise.race( - [ - socket.waitForMessage('s1', false, undefined), - ...(loginTag ? [socket.waitForMessage(loginTag, false, connectTimeoutMs)] : []) - - ] - ) - initTimeout && clearTimeout(initTimeout) - initTimeout = undefined - - if(response.status && response.status !== 200) { - throw new Boom(`Unexpected error in login`, { data: response, statusCode: response.status }) - } - // if its a challenge request (we get it when logging in) - if(response[1]?.challenge) { - const json = computeChallengeResponse(response[1].challenge, authInfo) - logger.info('resolving login challenge') - - await socket.query({ json, expect200: true, timeoutMs: connectTimeoutMs }) - - response = await socket.waitForMessage('s2', true) - } - // validate the new connection - const {user, auth, phone} = validateNewConnection(response[1], authInfo, curveKeys)// validate the connection - const isNewLogin = user.jid !== state.user?.jid - - authInfo = auth - updateEncKeys() - - logger.info({ user }, 'logged in') - - updateState({ - connection: 'open', - phoneConnected: true, - user, - isNewLogin, - phoneInfo: phone, - connectionTriesLeft: undefined, - qr: undefined - }) - ev.emit('credentials.update', auth) - } - ws.once('open', async() => { - try { - await onOpen() - } catch(error) { - socket.end(error) - } - }) - - if(printQRInTerminal) { - ev.on('connection.update', async({ qr }) => { - if(qr) { - const QR = await import('qrcode-terminal').catch(err => { - logger.error('QR code terminal not added as dependency') - }) - QR?.generate(qr, { small: true }) - } - }) - } - return { - ...socket, - ev, - getState: () => state, - getAuthInfo: () => authInfo, - waitForConnection, - canLogin, - logout - } -} -export default makeAuthSocket \ No newline at end of file diff --git a/src/Connection/chats.ts b/src/Connection/chats.ts deleted file mode 100644 index d23d0e8..0000000 --- a/src/Connection/chats.ts +++ /dev/null @@ -1,478 +0,0 @@ -import BinaryNode from "../BinaryNode"; -import { Chat, Contact, Presence, PresenceData, SocketConfig, WAFlag, WAMetric, WABusinessProfile, ChatModification, WAMessageKey, WAMessage, WAMessageUpdate, BaileysEventMap } from "../Types"; -import { debouncedTimeout, unixTimestampSeconds, whatsappID } from "../Utils/generics"; -import makeAuthSocket from "./auth"; -import { Attributes, BinaryNode as BinaryNodeBase } from "../BinaryNode/types"; - -const makeChatsSocket = (config: SocketConfig) => { - const { logger } = config - const sock = makeAuthSocket(config) - const { - ev, - ws: socketEvents, - currentEpoch, - setQuery, - query, - sendMessage, - getState - } = sock - - const chatsDebounceTimeout = debouncedTimeout(10_000, () => sendChatsQuery(1)) - - const sendChatsQuery = (epoch: number) => ( - sendMessage({ - json: new BinaryNode('query', {type: 'chat', epoch: epoch.toString()}), - binaryTag: [ WAMetric.queryChat, WAFlag.ignore ] - }) - ) - - const fetchImageUrl = async(jid: string) => { - const response = await query({ - json: ['query', 'ProfilePicThumb', jid], - expect200: false, - requiresPhoneConnection: false - }) - return response.eurl as string | undefined - } - - const executeChatModification = (node: BinaryNodeBase) => { - const { attributes } = node - const updateType = attributes.type - const jid = whatsappID(attributes?.jid) - - switch(updateType) { - case 'delete': - ev.emit('chats.delete', [jid]) - break - case 'clear': - if(node.data) { - const ids = (node.data as BinaryNode[]).map( - ({ attributes }) => attributes.index - ) - ev.emit('messages.delete', { jid, ids }) - } else { - ev.emit('messages.delete', { jid, all: true }) - } - break - case 'archive': - ev.emit('chats.update', [ { jid, archive: 'true' } ]) - break - case 'unarchive': - ev.emit('chats.update', [ { jid, archive: 'false' } ]) - break - case 'pin': - ev.emit('chats.update', [ { jid, pin: attributes.pin } ]) - break - case 'star': - case 'unstar': - const starred = updateType === 'star' - const updates: WAMessageUpdate[] = (node.data as BinaryNode[]).map( - ({ attributes }) => ({ - key: { - remoteJid: jid, - id: attributes.index, - fromMe: attributes.owner === 'true' - }, - update: { starred } - }) - ) - ev.emit('messages.update', updates) - break - case 'mute': - if(attributes.mute === '0') { - ev.emit('chats.update', [{ jid, mute: null }]) - } else { - ev.emit('chats.update', [{ jid, mute: attributes.mute }]) - } - break - default: - logger.warn({ node }, `received unrecognized chat update`) - break - } - } - - const applyingPresenceUpdate = (update: Attributes): BaileysEventMap['presence.update'] => { - const jid = whatsappID(update.id) - const participant = whatsappID(update.participant || update.id) - - const presence: PresenceData = { - lastSeen: update.t ? +update.t : undefined, - lastKnownPresence: update.type as Presence - } - return { jid, presences: { [participant]: presence } } - } - - ev.on('connection.update', async({ connection }) => { - if(connection !== 'open') return - try { - await Promise.all([ - sendMessage({ - json: new BinaryNode('query', {type: 'contacts', epoch: '1'}), - binaryTag: [ WAMetric.queryContact, WAFlag.ignore ] - }), - sendMessage({ - json: new BinaryNode('query', {type: 'status', epoch: '1'}), - binaryTag: [ WAMetric.queryStatus, WAFlag.ignore ] - }), - sendMessage({ - json: new BinaryNode('query', {type: 'quick_reply', epoch: '1'}), - binaryTag: [ WAMetric.queryQuickReply, WAFlag.ignore ] - }), - sendMessage({ - json: new BinaryNode('query', {type: 'label', epoch: '1'}), - binaryTag: [ WAMetric.queryLabel, WAFlag.ignore ] - }), - sendMessage({ - json: new BinaryNode('query', {type: 'emoji', epoch: '1'}), - binaryTag: [ WAMetric.queryEmoji, WAFlag.ignore ] - }), - sendMessage({ - json: new BinaryNode( - 'action', - { type: 'set', epoch: '1' }, - [ - new BinaryNode('presence', {type: 'available'}) - ] - ), - binaryTag: [ WAMetric.presence, WAFlag.available ] - }) - ]) - chatsDebounceTimeout.start() - - logger.debug('sent init queries') - } catch(error) { - logger.error(`error in sending init queries: ${error}`) - } - }) - socketEvents.on('CB:response,type:chat', async ({ data }: BinaryNode) => { - chatsDebounceTimeout.cancel() - if(Array.isArray(data)) { - const chats = data.map(({ attributes }) => { - return { - ...attributes, - jid: whatsappID(attributes.jid), - t: +attributes.t, - count: +attributes.count - } as Chat - }) - - logger.info(`got ${chats.length} chats`) - ev.emit('chats.set', { chats }) - } - }) - // got all contacts from phone - socketEvents.on('CB:response,type:contacts', async ({ data }: BinaryNode) => { - if(Array.isArray(data)) { - const contacts = data.map(({ attributes }) => { - const contact = attributes as any as Contact - contact.jid = whatsappID(contact.jid) - return contact - }) - - logger.info(`got ${contacts.length} contacts`) - ev.emit('contacts.set', { contacts }) - } - }) - // status updates - socketEvents.on('CB:Status,status', json => { - const jid = whatsappID(json[1].id) - ev.emit('contacts.update', [ { jid, status: json[1].status } ]) - }) - // User Profile Name Updates - socketEvents.on('CB:Conn,pushname', json => { - const { user, connection } = getState() - if(connection === 'open' && json[1].pushname !== user.name) { - user.name = json[1].pushname - ev.emit('connection.update', { user }) - } - }) - // read updates - socketEvents.on ('CB:action,,read', async ({ data }: BinaryNode) => { - if(Array.isArray(data)) { - const { attributes } = data[0] - - const update: Partial = { - jid: whatsappID(attributes.jid) - } - if (attributes.type === 'false') update.count = -1 - else update.count = 0 - - ev.emit('chats.update', [update]) - } - }) - - socketEvents.on('CB:Cmd,type:picture', async json => { - json = json[1] - const jid = whatsappID(json.jid) - const imgUrl = await fetchImageUrl(jid).catch(() => '') - - ev.emit('contacts.update', [ { jid, imgUrl } ]) - }) - - // chat archive, pin etc. - socketEvents.on('CB:action,,chat', ({ data }: BinaryNode) => { - if(Array.isArray(data)) { - const [node] = data - executeChatModification(node) - } - }) - - socketEvents.on('CB:action,,user', (json: BinaryNode) => { - if(Array.isArray(json.data)) { - const user = json.data[0].attributes as any as Contact - user.jid = whatsappID(user.jid) - - ev.emit('contacts.upsert', [user]) - } - }) - - // presence updates - socketEvents.on('CB:Presence', json => { - const update = applyingPresenceUpdate(json[1]) - ev.emit('presence.update', update) - }) - - // blocklist updates - socketEvents.on('CB:Blocklist', json => { - json = json[1] - const blocklist = json.blocklist - ev.emit('blocklist.set', { blocklist }) - }) - - return { - ...sock, - sendChatsQuery, - fetchImageUrl, - chatRead: async(fromMessage: WAMessageKey, count: number) => { - await setQuery ( - [ - new BinaryNode( - 'read', - { - jid: fromMessage.remoteJid, - count: count.toString(), - index: fromMessage.id, - owner: fromMessage.fromMe ? 'true' : 'false' - } - ) - ], - [ WAMetric.read, WAFlag.ignore ] - ) - ev.emit ('chats.update', [{ jid: fromMessage.remoteJid, count: count < 0 ? -1 : 0 }]) - }, - /** - * Modify a given chat (archive, pin etc.) - * @param jid the ID of the person/group you are modifiying - */ - modifyChat: async(jid: string, modification: ChatModification, index?: WAMessageKey) => { - let chatAttrs: Attributes = { jid: jid } - let data: BinaryNode[] | undefined = undefined - const stamp = unixTimestampSeconds() - - if('archive' in modification) { - chatAttrs.type = modification.archive ? 'archive' : 'unarchive' - } else if('pin' in modification) { - chatAttrs.type = 'pin' - if(typeof modification.pin === 'object') { - chatAttrs.previous = modification.pin.remove.toString() - } else { - chatAttrs.pin = stamp.toString() - } - } else if('mute' in modification) { - chatAttrs.type = 'mute' - if(typeof modification.mute === 'object') { - chatAttrs.previous = modification.mute.remove.toString() - } else { - chatAttrs.mute = (stamp + modification.mute).toString() - } - } else if('clear' in modification) { - chatAttrs.type = 'clear' - chatAttrs.modify_tag = Math.round(Math.random ()*1000000).toString() - if(modification.clear !== 'all') { - data = modification.clear.messages.map(({ id, fromMe }) => ( - new BinaryNode( - 'item', - { owner: (!!fromMe).toString(), index: id } - ) - )) - } - } else if('star' in modification) { - chatAttrs.type = modification.star.star ? 'star' : 'unstar' - data = modification.star.messages.map(({ id, fromMe }) => ( - new BinaryNode( - 'item', - { owner: (!!fromMe).toString(), index: id } - ) - )) - } - - if(index) { - chatAttrs.index = index.id - chatAttrs.owner = index.fromMe ? 'true' : 'false' - } - - const node = new BinaryNode('chat', chatAttrs, data) - const response = await setQuery([node], [ WAMetric.chat, WAFlag.ignore ]) - // apply it and emit events - executeChatModification(node) - return response - }, - /** - * Query whether a given number is registered on WhatsApp - * @param str phone number/jid you want to check for - * @returns undefined if the number doesn't exists, otherwise the correctly formatted jid - */ - isOnWhatsApp: async (str: string) => { - const { status, jid, biz } = await query({ - json: ['query', 'exist', str], - requiresPhoneConnection: false - }) - if (status === 200) { - return { - exists: true, - jid: whatsappID(jid), - isBusiness: biz as boolean - } - } - }, - /** - * Tell someone about your presence -- online, typing, offline etc. - * @param jid the ID of the person/group who you are updating - * @param type your presence - */ - updatePresence: (jid: string | undefined, type: Presence) => ( - sendMessage({ - binaryTag: [WAMetric.presence, WAFlag[type]], // weird stuff WA does - json: new BinaryNode( - 'action', - { epoch: currentEpoch().toString(), type: 'set' }, - [ - new BinaryNode( - 'presence', - { type: type, to: jid } - ) - ] - ) - }) - ), - /** - * Request updates on the presence of a user - * this returns nothing, you'll receive updates in chats.update event - * */ - requestPresenceUpdate: async (jid: string) => ( - sendMessage({ json: ['action', 'presence', 'subscribe', jid] }) - ), - /** Query the status of the person (see groupMetadata() for groups) */ - getStatus: async(jid: string) => { - const status: { status: string } = await query({ json: ['query', 'Status', jid], requiresPhoneConnection: false }) - return status - }, - setStatus: async(status: string) => { - const response = await setQuery( - [ - new BinaryNode( - 'status', - {}, - Buffer.from (status, 'utf-8') - ) - ] - ) - ev.emit('contacts.update', [{ jid: getState().user!.jid, status }]) - return response - }, - /** Updates business profile. */ - updateBusinessProfile: async(profile: WABusinessProfile) => { - if (profile.business_hours?.config) { - profile.business_hours.business_config = profile.business_hours.config - delete profile.business_hours.config - } - const json = ['action', "editBusinessProfile", {...profile, v: 2}] - await query({ json, expect200: true, requiresPhoneConnection: true }) - }, - updateProfileName: async(name: string) => { - const response = (await setQuery( - [ - new BinaryNode( - 'profile', - { name } - ) - ] - )) as any as {status: number, pushname: string} - - if (response.status === 200) { - const user = { ...getState().user!, name } - ev.emit('connection.update', { user }) - ev.emit('contacts.update', [{ jid: user.jid, name }]) - } - return response - }, - /** - * Update the profile picture - * @param jid - * @param img - */ - async updateProfilePicture (jid: string, img: Buffer) { - jid = whatsappID (jid) - const data = { img: Buffer.from([]), preview: Buffer.from([]) } //await generateProfilePicture(img) TODO - const tag = this.generateMessageTag () - const query = new BinaryNode( - 'picture', - { jid: jid, id: tag, type: 'set' }, - [ - new BinaryNode('image', {}, data.img), - new BinaryNode('preview', {}, data.preview) - ] - ) - const user = getState().user - const { eurl } = await this.setQuery ([query], [WAMetric.picture, 136], tag) as { eurl: string, status: number } - - if (jid === user.jid) { - user.imgUrl = eurl - ev.emit('connection.update', { user }) - } - ev.emit('contacts.update', [ { jid, imgUrl: eurl } ]) - }, - /** - * Add or remove user from blocklist - * @param jid the ID of the person who you are blocking/unblocking - * @param type type of operation - */ - blockUser: async(jid: string, type: 'add' | 'remove' = 'add') => { - const json = new BinaryNode( - 'block', - { type }, - [ new BinaryNode('user', { jid }) ] - ) - await setQuery ([json], [WAMetric.block, WAFlag.ignore]) - ev.emit('blocklist.update', { blocklist: [jid], type }) - }, - /** - * Query Business Profile (Useful for VCards) - * @param jid Business Jid - * @returns profile object or undefined if not business account - */ - getBusinessProfile: async(jid: string) => { - jid = whatsappID(jid) - const { - profiles: [{ - profile, - wid - }] - } = await query({ - json: [ - "query", "businessProfile", - [ { "wid": jid.replace('@s.whatsapp.net', '@c.us') } ], - 84 - ], - expect200: true, - requiresPhoneConnection: false, - }) - - return { - ...profile, - wid: whatsappID(wid) - } as WABusinessProfile - } - } -} -export default makeChatsSocket \ No newline at end of file diff --git a/src/Connection/groups.ts b/src/Connection/groups.ts deleted file mode 100644 index 9ee0a1c..0000000 --- a/src/Connection/groups.ts +++ /dev/null @@ -1,237 +0,0 @@ -import BinaryNode from "../BinaryNode"; -import { SocketConfig, GroupModificationResponse, ParticipantAction, GroupMetadata, WAFlag, WAMetric, WAGroupCreateResponse, GroupParticipant } from "../Types"; -import { generateMessageID, unixTimestampSeconds, whatsappID } from "../Utils/generics"; -import makeMessagesSocket from "./messages"; - -const makeGroupsSocket = (config: SocketConfig) => { - const { logger } = config - const sock = makeMessagesSocket(config) - const { - ev, - ws: socketEvents, - query, - generateMessageTag, - currentEpoch, - setQuery, - getState - } = sock - - /** Generic function for group queries */ - const groupQuery = async(type: string, jid?: string, subject?: string, participants?: string[], additionalNodes?: BinaryNode[]) => { - const tag = generateMessageTag() - const result = await setQuery ([ - new BinaryNode( - 'group', - { - author: getState().user?.jid, - id: tag, - type: type, - jid: jid, - subject: subject, - }, - participants ? - participants.map(jid => ( - new BinaryNode('participant', { jid }) - )) : - additionalNodes - ) - ], [WAMetric.group, 136], tag) - return result - } - - /** Get the metadata of the group from WA */ - const groupMetadataFull = async (jid: string) => { - const metadata = await query({ - json: ['query', 'GroupMetadata', jid], - expect200: true - }) - metadata.participants = metadata.participants.map(p => ( - { ...p, id: undefined, jid: whatsappID(p.id) } - )) - metadata.owner = whatsappID(metadata.owner) - return metadata as GroupMetadata - } - /** Get the metadata (works after you've left the group also) */ - const groupMetadataMinimal = async (jid: string) => { - const { attributes, data }:BinaryNode = await query({ - json: new BinaryNode( - 'query', - {type: 'group', jid: jid, epoch: currentEpoch().toString()} - ), - binaryTag: [WAMetric.group, WAFlag.ignore], - expect200: true - }) - const participants: GroupParticipant[] = [] - let desc: string | undefined - if(Array.isArray(data) && Array.isArray(data[0].data)) { - const nodes = data[0].data - for(const item of nodes) { - if(item.header === 'participant') { - participants.push({ - jid: item.attributes.jid, - isAdmin: item.attributes.type === 'admin', - isSuperAdmin: false - }) - } else if(item.header === 'description') { - desc = (item.data as Buffer).toString('utf-8') - } - } - } - return { - id: jid, - owner: attributes?.creator, - creator: attributes?.creator, - creation: +attributes?.create, - subject: null, - desc, - participants - } as GroupMetadata - } - - socketEvents.on('CB:Chat,cmd:action', (json: BinaryNode) => { - /*const data = json[1].data - if (data) { - const emitGroupParticipantsUpdate = (action: WAParticipantAction) => this.emitParticipantsUpdate - (json[1].id, data[2].participants.map(whatsappID), action) - const emitGroupUpdate = (data: Partial) => this.emitGroupUpdate(json[1].id, data) - - switch (data[0]) { - case "promote": - emitGroupParticipantsUpdate('promote') - break - case "demote": - emitGroupParticipantsUpdate('demote') - break - case "desc_add": - emitGroupUpdate({ ...data[2], descOwner: data[1] }) - break - default: - this.logger.debug({ unhandled: true }, json) - break - } - }*/ - }) - - return { - ...sock, - groupMetadata: async(jid: string, minimal: boolean) => { - let result: GroupMetadata - - if(minimal) result = await groupMetadataMinimal(jid) - else result = await groupMetadataFull(jid) - - return result - }, - /** - * Create a group - * @param title like, the title of the group - * @param participants people to include in the group - */ - groupCreate: async (title: string, participants: string[]) => { - const response = await groupQuery('create', null, title, participants) as WAGroupCreateResponse - const gid = response.gid - let metadata: GroupMetadata - try { - metadata = await groupMetadataFull(gid) - } catch (error) { - logger.warn (`error in group creation: ${error}, switching gid & checking`) - // if metadata is not available - const comps = gid.replace ('@g.us', '').split ('-') - response.gid = `${comps[0]}-${+comps[1] + 1}@g.us` - - metadata = await groupMetadataFull(gid) - logger.warn (`group ID switched from ${gid} to ${response.gid}`) - } - ev.emit('chats.upsert', [ - { - jid: response.gid, - name: title, - t: unixTimestampSeconds(), - count: 0 - } - ]) - return metadata - }, - /** - * Leave a group - * @param jid the ID of the group - */ - groupLeave: async (jid: string) => { - await groupQuery('leave', jid) - ev.emit('chats.update', [ { jid, read_only: 'true' } ]) - }, - /** - * Update the subject of the group - * @param {string} jid the ID of the group - * @param {string} title the new title of the group - */ - groupUpdateSubject: async (jid: string, title: string) => { - await groupQuery('subject', jid, title) - ev.emit('chats.update', [ { jid, name: title } ]) - ev.emit('contacts.update', [ { jid, name: title } ]) - ev.emit('groups.update', [ { id: jid, subject: title } ]) - }, - /** - * Update the group description - * @param {string} jid the ID of the group - * @param {string} title the new title of the group - */ - groupUpdateDescription: async (jid: string, description: string) => { - const metadata = await groupMetadataFull(jid) - const node = new BinaryNode( - 'description', - {id: generateMessageID(), prev: metadata?.descId}, - Buffer.from (description, 'utf-8') - ) - const response = await groupQuery ('description', jid, null, null, [node]) - ev.emit('groups.update', [ { id: jid, desc: description } ]) - return response - }, - /** - * Update participants in the group - * @param jid the ID of the group - * @param participants the people to add - */ - groupParticipantsUpdate: async(jid: string, participants: string[], action: ParticipantAction) => { - const result: GroupModificationResponse = await groupQuery(action, jid, null, participants) - const jids = Object.keys(result.participants || {}) - ev.emit('group-participants.update', { jid, participants: jids, action }) - return jids - }, - /** Query broadcast list info */ - getBroadcastListInfo: async(jid: string) => { - interface WABroadcastListInfo { - status: number - name: string - recipients?: {id: string}[] - } - - const result = await query({ - json: ['query', 'contact', jid], - expect200: true, - requiresPhoneConnection: true - }) as WABroadcastListInfo - - const metadata: GroupMetadata = { - subject: result.name, - id: jid, - creation: undefined, - owner: getState().user?.jid, - participants: result.recipients!.map(({id}) => ( - { jid: whatsappID(id), isAdmin: false, isSuperAdmin: false } - )) - } - return metadata - }, - inviteCode: async(jid: string) => { - const response = await sock.query({ - json: ['query', 'inviteCode', jid], - expect200: true, - requiresPhoneConnection: false - }) - return response.code as string - } - } - -} -export default makeGroupsSocket \ No newline at end of file diff --git a/src/Connection/index.ts b/src/Connection/index.ts deleted file mode 100644 index b305b20..0000000 --- a/src/Connection/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { SocketConfig } from '../Types' -import { DEFAULT_CONNECTION_CONFIG } from '../Defaults' -import _makeConnection from './groups' -// export the last socket layer -const makeConnection = (config: Partial) => ( - _makeConnection({ - ...DEFAULT_CONNECTION_CONFIG, - ...config - }) -) - -export type Connection = ReturnType - -export default makeConnection \ No newline at end of file diff --git a/src/Connection/messages.ts b/src/Connection/messages.ts deleted file mode 100644 index 9432eb0..0000000 --- a/src/Connection/messages.ts +++ /dev/null @@ -1,577 +0,0 @@ -import BinaryNode from "../BinaryNode"; -import { Boom } from '@hapi/boom' -import { EventEmitter } from 'events' -import { Chat, Presence, WAMessageCursor, SocketConfig, WAMessage, WAMessageKey, ParticipantAction, WAMessageProto, WAMessageStatus, WAMessageStubType, GroupMetadata, AnyMessageContent, MiscMessageGenerationOptions, WAFlag, WAMetric, WAUrlInfo, MediaConnInfo, MessageUpdateType, MessageInfo, MessageInfoUpdate, WAMediaUploadFunction, MediaType, WAMessageUpdate } from "../Types"; -import { isGroupID, toNumber, whatsappID, generateWAMessage, decryptMediaMessageBuffer, extractMessageContent } from "../Utils"; -import makeChatsSocket from "./chats"; -import { DEFAULT_ORIGIN, MEDIA_PATH_MAP, WA_DEFAULT_EPHEMERAL } from "../Defaults"; -import got from "got"; - -const STATUS_MAP = { - read: WAMessageStatus.READ, - message: WAMessageStatus.DELIVERY_ACK, - error: WAMessageStatus.ERROR -} as { [_: string]: WAMessageStatus } - -const makeMessagesSocket = (config: SocketConfig) => { - const { logger } = config - const sock = makeChatsSocket(config) - const { - ev, - ws: socketEvents, - query, - generateMessageTag, - currentEpoch, - setQuery, - getState - } = sock - - let mediaConn: Promise - const refreshMediaConn = async(forceGet = false) => { - let media = await mediaConn - if (!media || forceGet || (new Date().getTime()-media.fetchDate.getTime()) > media.ttl*1000) { - mediaConn = (async() => { - const {media_conn} = await query({ - json: ['query', 'mediaConn'], - requiresPhoneConnection: false - }) - media_conn.fetchDate = new Date() - return media_conn as MediaConnInfo - })() - } - return mediaConn - } - - const fetchMessagesFromWA = async( - jid: string, - count: number, - cursor?: WAMessageCursor - ) => { - let key: WAMessageKey - if(cursor) { - key = 'before' in cursor ? cursor.before : cursor.after - } - const { data }:BinaryNode = await query({ - json: new BinaryNode( - 'query', - { - epoch: currentEpoch().toString(), - type: 'message', - jid: jid, - kind: !cursor || 'before' in cursor ? 'before' : 'after', - count: count.toString(), - index: key?.id, - owner: key?.fromMe === false ? 'false' : 'true', - } - ), - binaryTag: [WAMetric.queryMessages, WAFlag.ignore], - expect200: false, - requiresPhoneConnection: true - }) - if(Array.isArray(data)) { - return data.map(data => data.data as WAMessage) - } - return [] - } - - const updateMediaMessage = async(message: WAMessage) => { - const content = message.message?.audioMessage || message.message?.videoMessage || message.message?.imageMessage || message.message?.stickerMessage || message.message?.documentMessage - if (!content) throw new Boom( - `given message ${message.key.id} is not a media message`, - { statusCode: 400, data: message } - ) - - const response: BinaryNode = await query ({ - json: new BinaryNode( - 'query', - { - type: 'media', - index: message.key.id, - owner: message.key.fromMe ? 'true' : 'false', - jid: message.key.remoteJid, - epoch: currentEpoch().toString() - } - ), - binaryTag: [WAMetric.queryMedia, WAFlag.ignore], - expect200: true, - requiresPhoneConnection: true - }) - const attrs = response.attributes - Object.keys(attrs).forEach (key => content[key] = attrs[key]) // update message - - ev.emit('messages.update', [{ key: message.key, update: { message: message.message } }]) - - return response - } - - const onMessage = (message: WAMessage, type: MessageUpdateType | 'update') => { - const jid = message.key.remoteJid! - // store chat updates in this - const chatUpdate: Partial = { - jid, - } - - const emitGroupUpdate = (update: Partial) => { - ev.emit('groups.update', [ { id: jid, ...update } ]) - } - - if(message.message) { - chatUpdate.t = +toNumber(message.messageTimestamp) - // add to count if the message isn't from me & there exists a message - if(!message.key.fromMe) { - chatUpdate.count = 1 - const participant = whatsappID(message.participant || jid) - - ev.emit( - 'presence.update', - { - jid, - presences: { [participant]: { lastKnownPresence: Presence.available } } - } - ) - } - } - - const ephemeralProtocolMsg = message.message?.ephemeralMessage?.message?.protocolMessage - if ( - ephemeralProtocolMsg && - ephemeralProtocolMsg.type === WAMessageProto.ProtocolMessage.ProtocolMessageType.EPHEMERAL_SETTING - ) { - chatUpdate.eph_setting_ts = message.messageTimestamp.toString() - chatUpdate.ephemeral = ephemeralProtocolMsg.ephemeralExpiration.toString() - - if(isGroupID(jid)) { - emitGroupUpdate({ ephemeralDuration: ephemeralProtocolMsg.ephemeralExpiration || null }) - } - } - const protocolMessage = message.message?.protocolMessage - // if it's a message to delete another message - if (protocolMessage) { - switch (protocolMessage.type) { - case WAMessageProto.ProtocolMessage.ProtocolMessageType.REVOKE: - const key = protocolMessage.key - const messageStubType = WAMessageStubType.REVOKE - ev.emit('messages.update', [ - { - // the key of the deleted message is updated - update: { message: null, key: message.key, messageStubType }, - key - } - ]) - return - default: - break - } - } - - // check if the message is an action - if (message.messageStubType) { - const { user } = getState() - //let actor = whatsappID (message.participant) - let participants: string[] - const emitParticipantsUpdate = (action: ParticipantAction) => ( - ev.emit('group-participants.update', { jid, participants, action }) - ) - - switch (message.messageStubType) { - case WAMessageStubType.CHANGE_EPHEMERAL_SETTING: - chatUpdate.eph_setting_ts = message.messageTimestamp.toString() - chatUpdate.ephemeral = message.messageStubParameters[0] - if(isGroupID(jid)) { - emitGroupUpdate({ ephemeralDuration: +message.messageStubParameters[0] || null }) - } - break - case WAMessageStubType.GROUP_PARTICIPANT_LEAVE: - case WAMessageStubType.GROUP_PARTICIPANT_REMOVE: - participants = message.messageStubParameters.map (whatsappID) - emitParticipantsUpdate('remove') - // mark the chat read only if you left the group - if (participants.includes(user.jid)) { - chatUpdate.read_only = 'true' - } - break - case WAMessageStubType.GROUP_PARTICIPANT_ADD: - case WAMessageStubType.GROUP_PARTICIPANT_INVITE: - case WAMessageStubType.GROUP_PARTICIPANT_ADD_REQUEST_JOIN: - participants = message.messageStubParameters.map (whatsappID) - if (participants.includes(user.jid)) { - chatUpdate.read_only = 'false' - } - emitParticipantsUpdate('add') - break - case WAMessageStubType.GROUP_CHANGE_ANNOUNCE: - const announce = message.messageStubParameters[0] === 'on' ? 'true' : 'false' - emitGroupUpdate({ announce }) - break - case WAMessageStubType.GROUP_CHANGE_RESTRICT: - const restrict = message.messageStubParameters[0] === 'on' ? 'true' : 'false' - emitGroupUpdate({ restrict }) - break - case WAMessageStubType.GROUP_CHANGE_SUBJECT: - case WAMessageStubType.GROUP_CREATE: - chatUpdate.name = message.messageStubParameters[0] - emitGroupUpdate({ subject: chatUpdate.name }) - break - } - } - - if(Object.keys(chatUpdate).length > 1) { - ev.emit('chats.update', [chatUpdate]) - } - if(type === 'update') { - ev.emit('messages.update', [ { update: message, key: message.key } ]) - } else { - ev.emit('messages.upsert', { messages: [message], type }) - } - } - - const waUploadToServer: WAMediaUploadFunction = async(stream, { mediaType, fileEncSha256B64 }) => { - // send a query JSON to obtain the url & auth token to upload our media - let uploadInfo = await refreshMediaConn(false) - - let mediaUrl: string - for (let host of uploadInfo.hosts) { - const auth = encodeURIComponent(uploadInfo.auth) // the auth token - const url = `https://${host.hostname}${MEDIA_PATH_MAP[mediaType]}/${fileEncSha256B64}?auth=${auth}&token=${fileEncSha256B64}` - - try { - const {body: responseText} = await got.post( - url, - { - headers: { - 'Content-Type': 'application/octet-stream', - 'Origin': DEFAULT_ORIGIN - }, - agent: { - https: config.agent - }, - body: stream - } - ) - const result = JSON.parse(responseText) - mediaUrl = result?.url - - if (mediaUrl) break - else { - uploadInfo = await refreshMediaConn(true) - throw new Error(`upload failed, reason: ${JSON.stringify(result)}`) - } - } catch (error) { - const isLast = host.hostname === uploadInfo.hosts[uploadInfo.hosts.length-1].hostname - logger.debug(`Error in uploading to ${host.hostname} (${error}) ${isLast ? '' : ', retrying...'}`) - } - } - if (!mediaUrl) { - throw new Boom( - 'Media upload failed on all hosts', - { statusCode: 500 } - ) - } - return { mediaUrl } - } - - /** Query a string to check if it has a url, if it does, return WAUrlInfo */ - const generateUrlInfo = async(text: string) => { - const response: BinaryNode = await query({ - json: new BinaryNode( - 'query', - { - type: 'url', - url: text, - epoch: currentEpoch().toString() - } - ), - binaryTag: [26, WAFlag.ignore], - expect200: true, - requiresPhoneConnection: false - }) - const urlInfo = { ...response.attributes } as any as WAUrlInfo - if(response && response.data) { - urlInfo.jpegThumbnail = response.data as Buffer - } - return urlInfo - } - - /** Relay (send) a WAMessage; more advanced functionality to send a built WA Message, you may want to stick with sendMessage() */ - const relayWAMessage = async(message: WAMessage, { waitForAck } = { waitForAck: true }) => { - const json = new BinaryNode( - 'action', - { epoch: currentEpoch().toString(), type: 'relay' }, - [ new BinaryNode('message', {}, message) ] - ) - const isMsgToMe = message.key.remoteJid === getState().user?.jid - const flag = isMsgToMe ? WAFlag.acknowledge : WAFlag.ignore // acknowledge when sending message to oneself - const mID = message.key.id - const finalState = isMsgToMe ? WAMessageStatus.READ : WAMessageStatus.SERVER_ACK - - message.status = WAMessageStatus.PENDING - const promise = query({ - json, - binaryTag: [WAMetric.message, flag], - tag: mID, - expect200: true, - requiresPhoneConnection: true - }) - - if(waitForAck) { - await promise - message.status = finalState - } else { - const emitUpdate = (status: WAMessageStatus) => { - message.status = status - ev.emit('messages.update', [ { key: message.key, update: { status } } ]) - } - promise - .then(() => emitUpdate(finalState)) - .catch(() => emitUpdate(WAMessageStatus.ERROR)) - } - - onMessage(message, 'append') - } - - // messages received - const messagesUpdate = ({ data }: BinaryNode, type: 'prepend' | 'last') => { - if(Array.isArray(data)) { - const messages: WAMessage[] = [] - for(let i = data.length-1; i >= 0;i--) { - messages.push(data[i].data as WAMessage) - } - ev.emit('messages.upsert', { messages, type }) - } - } - - socketEvents.on('CB:action,add:last', json => messagesUpdate(json, 'last')) - socketEvents.on('CB:action,add:unread', json => messagesUpdate(json, 'prepend')) - socketEvents.on('CB:action,add:before', json => messagesUpdate(json, 'prepend')) - - // new messages - socketEvents.on('CB:action,add:relay,message', ({data}: BinaryNode) => { - if(Array.isArray(data)) { - for(const { data: msg } of data) { - onMessage(msg as WAMessage, 'notify') - } - } - }) - // If a message has been updated (usually called when a video message gets its upload url, or live locations) - socketEvents.on ('CB:action,add:update,message', ({ data }: BinaryNode) => { - if(Array.isArray(data)) { - for(const { data: msg } of data) { - onMessage(msg as WAMessage, 'update') - } - } - }) - // message status updates - const onMessageStatusUpdate = ({ data }: BinaryNode) => { - if(Array.isArray(data)) { - const updates: WAMessageUpdate[] = [] - for(const { attributes: json } of data) { - const key: WAMessageKey = { - remoteJid: whatsappID(json.jid), - id: json.index, - fromMe: json.owner === 'true' - } - const status = STATUS_MAP[json.type] - - if(status) { - updates.push({ key, update: { status } }) - } else { - logger.warn({ data }, 'got unknown status update for message') - } - } - ev.emit('messages.update', updates) - } - } - const onMessageInfoUpdate = ([,attributes]: [string,{[_: string]: any}]) => { - let ids = attributes.id as string[] | string - if(typeof ids === 'string') { - ids = [ids] - } - let updateKey: keyof MessageInfoUpdate['update'] - switch(attributes.ack.toString()) { - case '2': - updateKey = 'deliveries' - break - case '3': - updateKey = 'reads' - break - default: - logger.warn({ attributes }, `received unknown message info update`) - return - } - const keyPartial = { - remoteJid: whatsappID(attributes.to), - fromMe: whatsappID(attributes.from) === getState().user?.jid, - } - const updates = ids.map(id => ({ - key: { ...keyPartial, id }, - update: { - [updateKey]: { [whatsappID(attributes.participant)]: new Date(+attributes.t) } - } - })) - ev.emit('message-info.update', updates) - // for individual messages - // it means the message is marked read/delivered - if(!isGroupID(keyPartial.remoteJid)) { - ev.emit('messages.update', ids.map(id => ( - { - key: { ...keyPartial, id }, - update: { - status: updateKey === 'deliveries' ? WAMessageStatus.DELIVERY_ACK : WAMessageStatus.READ - } - } - ))) - } - } - - socketEvents.on('CB:action,add:relay,received', onMessageStatusUpdate) - socketEvents.on('CB:action,,received', onMessageStatusUpdate) - - socketEvents.on('CB:Msg', onMessageInfoUpdate) - socketEvents.on('CB:MsgInfo', onMessageInfoUpdate) - - return { - ...sock, - relayWAMessage, - generateUrlInfo, - messageInfo: async(jid: string, messageID: string) => { - const { data }: BinaryNode = await query({ - json: new BinaryNode( - 'query', - {type: 'message_info', index: messageID, jid: jid, epoch: currentEpoch().toString()} - ), - binaryTag: [WAMetric.queryRead, WAFlag.ignore], - expect200: true, - requiresPhoneConnection: true - }) - const info: MessageInfo = { reads: {}, deliveries: {} } - if(Array.isArray(data)) { - for(const { header, data: innerData } of data) { - const [{ attributes }] = (innerData as BinaryNode[]) - const jid = whatsappID(attributes.jid) - const date = new Date(+attributes.t * 1000) - switch(header) { - case 'read': - info.reads[jid] = date - break - case 'delivery': - info.deliveries[jid] = date - break - } - } - } - return info - }, - downloadMediaMessage: async(message: WAMessage, type: 'buffer' | 'stream' = 'buffer') => { - - const downloadMediaMessage = async () => { - let mContent = extractMessageContent(message.message) - if (!mContent) throw new Boom('No message present', { statusCode: 400, data: message }) - - const stream = await decryptMediaMessageBuffer(mContent) - if(type === 'buffer') { - let buffer = Buffer.from([]) - for await(const chunk of stream) { - buffer = Buffer.concat([buffer, chunk]) - } - return buffer - } - return stream - } - - try { - const result = await downloadMediaMessage() - return result - } catch (error) { - if(error.message.includes('404')) { // media needs to be updated - logger.info (`updating media of message: ${message.key.id}`) - - await updateMediaMessage(message) - - const result = await downloadMediaMessage() - return result - } - throw error - } - }, - updateMediaMessage, - fetchMessagesFromWA, - /** Load a single message specified by the ID */ - loadMessageFromWA: async(jid: string, id: string) => { - let message: WAMessage - - // load the message before the given message - let messages = (await fetchMessagesFromWA(jid, 1, { before: {id, fromMe: true} })) - if(!messages[0]) messages = (await fetchMessagesFromWA(jid, 1, { before: {id, fromMe: false} })) - // the message after the loaded message is the message required - const [actual] = await fetchMessagesFromWA(jid, 1, { after: messages[0] && messages[0].key }) - message = actual - return message - }, - searchMessages: async(txt: string, inJid: string | null, count: number, page: number) => { - const {data, attributes}: BinaryNode = await query({ - json: new BinaryNode( - 'query', - { - epoch: currentEpoch().toString(), - type: 'search', - search: txt, - count: count.toString(), - page: page.toString(), - jid: inJid - } - ), - binaryTag: [24, WAFlag.ignore], - expect200: true - }) // encrypt and send off - - const messages = Array.isArray(data) ? data.map(item => item.data as WAMessage) : [] - return { - last: attributes?.last === 'true', - messages - } - }, - sendWAMessage: async( - jid: string, - content: AnyMessageContent, - options: MiscMessageGenerationOptions & { waitForAck?: boolean } - ) => { - const userJid = getState().user?.jid - if( - typeof content === 'object' && - 'disappearingMessagesInChat' in content && - typeof content['disappearingMessagesInChat'] !== 'undefined' && - isGroupID(jid) - ) { - const { disappearingMessagesInChat } = content - const value = typeof disappearingMessagesInChat === 'boolean' ? - (disappearingMessagesInChat ? WA_DEFAULT_EPHEMERAL : 0) : - disappearingMessagesInChat - const tag = generateMessageTag(true) - await setQuery([ - new BinaryNode( - 'group', - { id: tag, jid, type: 'prop', author: userJid }, - [ new BinaryNode('ephemeral', { value: value.toString() }) ] - ) - ], [WAMetric.group, WAFlag.other], tag) - } else { - const msg = await generateWAMessage( - jid, - content, - { - ...options, - logger, - userJid: userJid, - getUrlInfo: generateUrlInfo, - upload: waUploadToServer - } - ) - - await relayWAMessage(msg, { waitForAck: options.waitForAck }) - return msg - } - } - } -} - -export default makeMessagesSocket \ No newline at end of file diff --git a/src/Connection/socket.ts b/src/Connection/socket.ts deleted file mode 100644 index a192638..0000000 --- a/src/Connection/socket.ts +++ /dev/null @@ -1,367 +0,0 @@ -import { Boom } from '@hapi/boom' -import { STATUS_CODES } from "http" -import { promisify } from "util" -import WebSocket from "ws" -import BinaryNode from "../BinaryNode" -import { DisconnectReason, SocketConfig, SocketQueryOptions, SocketSendMessageOptions } from "../Types" -import { aesEncrypt, hmacSign, promiseTimeout, unixTimestampSeconds, decodeWAMessage } from "../Utils" -import { WAFlag, WAMetric, WATag } from "../Types" -import { DEFAULT_ORIGIN, DEF_CALLBACK_PREFIX, DEF_TAG_PREFIX, PHONE_CONNECTION_CB } from "../Defaults" - -/** - * Connects to WA servers and performs: - * - simple queries (no retry mechanism, wait for connection establishment) - * - listen to messages and emit events - * - query phone connection - */ -export const makeSocket = ({ - waWebSocketUrl, - connectTimeoutMs, - phoneResponseTimeMs, - logger, - agent, - keepAliveIntervalMs, - expectResponseTimeout, - phoneConnectionChanged -}: SocketConfig) => { - // for generating tags - const referenceDateSeconds = unixTimestampSeconds(new Date()) - const ws = new WebSocket(waWebSocketUrl, undefined, { - origin: DEFAULT_ORIGIN, - timeout: connectTimeoutMs, - agent, - headers: { - 'Accept-Encoding': 'gzip, deflate, br', - 'Accept-Language': 'en-US,en;q=0.9', - 'Cache-Control': 'no-cache', - 'Host': 'web.whatsapp.com', - 'Pragma': 'no-cache', - 'Sec-WebSocket-Extensions': 'permessage-deflate; client_max_window_bits', - } - }) - ws.setMaxListeners(0) - let lastDateRecv: Date - let epoch = 0 - let authInfo: { encKey: Buffer, macKey: Buffer } - let keepAliveReq: NodeJS.Timeout - - let phoneCheckInterval: NodeJS.Timeout - let phoneCheckListeners = 0 - - const sendPromise = promisify(ws.send) - /** generate message tag and increment epoch */ - const generateMessageTag = (longTag: boolean = false) => { - const tag = `${longTag ? referenceDateSeconds : (referenceDateSeconds%1000)}.--${epoch}` - epoch += 1 // increment message count, it makes the 'epoch' field when sending binary messages - return tag - } - const sendRawMessage = (data: Buffer | string) => sendPromise.call(ws, data) as Promise - /** - * Send a message to the WA servers - * @returns the tag attached in the message - * */ - const sendMessage = async( - { json, binaryTag, tag, longTag }: SocketSendMessageOptions - ) => { - tag = tag || generateMessageTag(longTag) - let data: Buffer | string - if(logger.level === 'trace') { - logger.trace({ tag, fromMe: true, json, binaryTag }, 'communication') - } - - if(binaryTag) { - if(!(json instanceof BinaryNode)) { - throw new Boom(`Invalid binary message of type "${typeof json}". Must be BinaryNode`, { statusCode: 400 }) - } - if(!authInfo) { - throw new Boom('No encryption/mac keys to encrypt node with', { statusCode: 400 }) - } - const binary = json.toBuffer() // encode the JSON to the WhatsApp binary format - - const buff = aesEncrypt(binary, authInfo.encKey) // encrypt it using AES and our encKey - const sign = hmacSign(buff, authInfo.macKey) // sign the message using HMAC and our macKey - - data = Buffer.concat([ - Buffer.from(tag + ','), // generate & prefix the message tag - Buffer.from(binaryTag), // prefix some bytes that tell whatsapp what the message is about - sign, // the HMAC sign of the message - buff, // the actual encrypted buffer - ]) - } else { - data = `${tag},${JSON.stringify(json)}` - } - await sendRawMessage(data) - return tag - } - const end = (error: Error | undefined) => { - logger.debug({ error }, 'connection closed') - - ws.removeAllListeners('close') - ws.removeAllListeners('error') - ws.removeAllListeners('open') - ws.removeAllListeners('message') - - phoneCheckListeners = 0 - clearInterval(keepAliveReq) - clearPhoneCheckInterval() - - if(ws.readyState !== ws.CLOSED && ws.readyState !== ws.CLOSING) { - try { ws.close() } catch { } - } - - ws.emit('ws-close', error) - ws.removeAllListeners('ws-close') - } - const onMessageRecieved = (message: string | Buffer) => { - if(message[0] === '!') { - // when the first character in the message is an '!', the server is sending a pong frame - const timestamp = message.slice(1, message.length).toString ('utf-8') - lastDateRecv = new Date(parseInt(timestamp)) - ws.emit('received-pong') - } else { - let messageTag: string - let json: any - try { - const dec = decodeWAMessage(message, authInfo) - messageTag = dec[0] - json = dec[1] - if (!json) return - } catch (error) { - end(error) - return - } - //if (this.shouldLogMessages) this.messageLog.push ({ tag: messageTag, json: JSON.stringify(json), fromMe: false }) - - if (logger.level === 'trace') { - logger.trace({ tag: messageTag, fromMe: false, json }, 'communication') - } - - let anyTriggered = false - /* Check if this is a response to a message we sent */ - anyTriggered = ws.emit(`${DEF_TAG_PREFIX}${messageTag}`, json) - /* Check if this is a response to a message we are expecting */ - const l0 = json.header || json[0] || '' - const l1 = json?.attributes || json?.[1] || { } - const l2 = json?.data?.[0]?.header || json[2]?.[0] || '' - - Object.keys(l1).forEach(key => { - anyTriggered = ws.emit(`${DEF_CALLBACK_PREFIX}${l0},${key}:${l1[key]},${l2}`, json) || anyTriggered - anyTriggered = ws.emit(`${DEF_CALLBACK_PREFIX}${l0},${key}:${l1[key]}`, json) || anyTriggered - anyTriggered = ws.emit(`${DEF_CALLBACK_PREFIX}${l0},${key}`, json) || anyTriggered - }) - anyTriggered = ws.emit(`${DEF_CALLBACK_PREFIX}${l0},,${l2}`, json) || anyTriggered - anyTriggered = ws.emit(`${DEF_CALLBACK_PREFIX}${l0}`, json) || anyTriggered - - if (!anyTriggered && logger.level === 'debug') { - logger.debug({ unhandled: true, tag: messageTag, fromMe: false, json }, 'communication recv') - } - } - } - - /** Exits a query if the phone connection is active and no response is still found */ - const exitQueryIfResponseNotExpected = (tag: string, cancel: (error: Boom) => void) => { - let timeout: NodeJS.Timeout - const listener = ([, connected]) => { - if(connected) { - timeout = setTimeout(() => { - logger.info({ tag }, `cancelling wait for message as a response is no longer expected from the phone`) - cancel(new Boom('Not expecting a response', { statusCode: 422 })) - }, expectResponseTimeout) - ws.off(PHONE_CONNECTION_CB, listener) - } - } - ws.on(PHONE_CONNECTION_CB, listener) - return () => { - ws.off(PHONE_CONNECTION_CB, listener) - timeout && clearTimeout(timeout) - } - } - /** interval is started when a query takes too long to respond */ - const startPhoneCheckInterval = () => { - phoneCheckListeners += 1 - if (!phoneCheckInterval) { - // if its been a long time and we haven't heard back from WA, send a ping - phoneCheckInterval = setInterval(() => { - if(phoneCheckListeners <= 0) { - logger.warn('phone check called without listeners') - return - } - logger.info('checking phone connection...') - sendAdminTest() - - phoneConnectionChanged(false) - }, phoneResponseTimeMs) - } - } - const clearPhoneCheckInterval = () => { - phoneCheckListeners -= 1 - if (phoneCheckListeners <= 0) { - clearInterval(phoneCheckInterval) - phoneCheckInterval = undefined - phoneCheckListeners = 0 - } - } - /** checks for phone connection */ - const sendAdminTest = () => sendMessage({ json: ['admin', 'test'] }) - /** - * Wait for a message with a certain tag to be received - * @param tag the message tag to await - * @param json query that was sent - * @param timeoutMs timeout after which the promise will reject - */ - const waitForMessage = async(tag: string, requiresPhoneConnection: boolean, timeoutMs?: number) => { - let onRecv: (json) => void - let onErr: (err) => void - let cancelPhoneChecker: () => void - try { - const result = await promiseTimeout(timeoutMs, - (resolve, reject) => { - onRecv = resolve - onErr = err => { - reject(err || new Boom('Connection Closed', { statusCode: DisconnectReason.connectionClosed })) - } - - if(requiresPhoneConnection) { - startPhoneCheckInterval() - cancelPhoneChecker = exitQueryIfResponseNotExpected(tag, onErr) - } - - ws.on(`TAG:${tag}`, onRecv) - ws.on('ws-close', onErr) // if the socket closes, you'll never receive the message - }, - ) - return result as any - } finally { - requiresPhoneConnection && clearPhoneCheckInterval() - cancelPhoneChecker && cancelPhoneChecker() - - ws.off(`TAG:${tag}`, onRecv) - ws.off('ws-close', onErr) // if the socket closes, you'll never receive the message - } - } - /** - * Query something from the WhatsApp servers - * @param json the query itself - * @param binaryTags the tags to attach if the query is supposed to be sent encoded in binary - * @param timeoutMs timeout after which the query will be failed (set to null to disable a timeout) - * @param tag the tag to attach to the message - */ - const query = async( - {json, timeoutMs, expect200, tag, longTag, binaryTag, requiresPhoneConnection}: SocketQueryOptions - ) => { - tag = tag || generateMessageTag(longTag) - const promise = waitForMessage(tag, requiresPhoneConnection, timeoutMs) - - await sendMessage({ json, tag, binaryTag }) - const response = await promise - const responseStatusCode = +(response.status ? response.status : 200) // default status - // read here: http://getstatuscode.com/599 - if(responseStatusCode === 599) { // the connection has gone bad - end(new Boom('WA server overloaded', { statusCode: 599, data: { query: json, response } })) - } - if(expect200 && Math.floor(responseStatusCode/100) !== 2) { - const message = STATUS_CODES[responseStatusCode] || 'unknown' - throw new Boom( - `Unexpected status in '${Array.isArray(json) ? json[0] : (json?.header || 'query')}': ${message}(${responseStatusCode})`, - { data: { query: json, message }, statusCode: response.status } - ) - } - return response - } - const startKeepAliveRequest = () => ( - keepAliveReq = setInterval(() => { - if (!lastDateRecv) lastDateRecv = new Date() - const diff = Date.now() - lastDateRecv.getTime() - /* - check if it's been a suspicious amount of time since the server responded with our last seen - it could be that the network is down - */ - if (diff > keepAliveIntervalMs+5000) { - end(new Boom('Connection was lost', { statusCode: DisconnectReason.connectionLost })) - } else if(ws.readyState === ws.OPEN) { - sendRawMessage('?,,') // if its all good, send a keep alive request - } else { - logger.warn('keep alive called when WS not open') - } - }, keepAliveIntervalMs) - ) - - const waitForSocketOpen = async() => { - if(ws.readyState === ws.OPEN) return - if(ws.readyState === ws.CLOSED || ws.readyState === ws.CLOSING) { - throw new Boom('Connection Closed', { statusCode: DisconnectReason.connectionClosed }) - } - let onOpen: () => void - let onClose: (err: Error) => void - await new Promise((resolve, reject) => { - onOpen = () => resolve(undefined) - onClose = reject - ws.on('open', onOpen) - ws.on('close', onClose) - ws.on('error', onClose) - }) - .finally(() => { - ws.off('open', onOpen) - ws.off('close', onClose) - ws.off('error', onClose) - }) - } - - ws.on('message', onMessageRecieved) - ws.on('open', () => { - startKeepAliveRequest() - logger.info('Opened WS connection to WhatsApp Web') - }) - ws.on('error', end) - ws.on('close', () => end(new Boom('Connection Terminated', { statusCode: DisconnectReason.connectionLost }))) - - ws.on(PHONE_CONNECTION_CB, json => { - if (!json[1]) { - end(new Boom('Connection terminated by phone', { statusCode: DisconnectReason.connectionLost })) - logger.info('Connection terminated by phone, closing...') - } else { - phoneConnectionChanged(true) - } - }) - ws.on('CB:Cmd,type:disconnect', json => { - const {kind} = json[1] - let reason: DisconnectReason - switch(kind) { - case 'replaced': - reason = DisconnectReason.connectionReplaced - break - default: - reason = DisconnectReason.connectionLost - break - } - end(new Boom( - `Connection terminated by server: "${kind || 'unknown'}"`, - { statusCode: reason } - )) - }) - - return { - ws, - updateKeys: (info: { encKey: Buffer, macKey: Buffer }) => authInfo = info, - waitForSocketOpen, - sendRawMessage, - sendMessage, - generateMessageTag, - waitForMessage, - query, - /** Generic function for action, set queries */ - setQuery: async(nodes: BinaryNode[], binaryTag: WATag = [WAMetric.group, WAFlag.ignore], tag?: string) => { - const json = new BinaryNode('action', { epoch: epoch.toString(), type: 'set' }, nodes) - return query({ - json, - binaryTag, - tag, - expect200: true, - requiresPhoneConnection: true - }) as Promise<{ status: number }> - }, - currentEpoch: () => epoch, - end - } -} -export type Socket = ReturnType \ No newline at end of file diff --git a/src/Defaults/index.ts b/src/Defaults/index.ts index d0c7751..ca14a72 100644 --- a/src/Defaults/index.ts +++ b/src/Defaults/index.ts @@ -1,6 +1,6 @@ import P from "pino" import type { MediaType, SocketConfig } from "../Types" -import { Browsers } from "../Utils/generics" +import { Browsers } from "../Utils" export const UNAUTHORIZED_CODES = [401, 403, 419] @@ -13,35 +13,32 @@ export const PHONE_CONNECTION_CB = 'CB:Pong' export const WA_DEFAULT_EPHEMERAL = 7*24*60*60 +export const NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0' +export const NOISE_WA_HEADER = new Uint8Array([87, 65, 5, 2]) // last is "DICT_VERSION" + /** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */ export const URL_REGEX = /[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)?/gi export const DEFAULT_CONNECTION_CONFIG: SocketConfig = { - version: [2, 2130, 9], + version: [2, 2136, 9], browser: Browsers.baileys('Chrome'), - waWebSocketUrl: 'wss://web.whatsapp.com/ws', + waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat', + connectTimeoutMs: 20_000, keepAliveIntervalMs: 25_000, - phoneResponseTimeMs: 15_000, - connectTimeoutMs: 30_000, - expectResponseTimeout: 12_000, logger: P().child({ class: 'baileys' }), - phoneConnectionChanged: () => { }, - maxRetries: 5, - connectCooldownMs: 2500, - pendingRequestTimeoutMs: undefined, - reconnectMode: 'on-connection-error', - maxQRCodes: Infinity, printQRInTerminal: false, } - export const MEDIA_PATH_MAP: { [T in MediaType]: string } = { image: '/mms/image', video: '/mms/video', document: '/mms/document', audio: '/mms/audio', sticker: '/mms/image', + history: '' } -export const MEDIA_KEYS = Object.keys(MEDIA_PATH_MAP) as MediaType[] \ No newline at end of file +export const MEDIA_KEYS = Object.keys(MEDIA_PATH_MAP) as MediaType[] + +export const KEY_BUNDLE_TYPE = '' \ No newline at end of file diff --git a/src/Socket/chats.ts b/src/Socket/chats.ts new file mode 100644 index 0000000..d8c2ec1 --- /dev/null +++ b/src/Socket/chats.ts @@ -0,0 +1,430 @@ +import { decodeSyncdPatch, encodeSyncdPatch } from "../Utils/chat-utils"; +import { SocketConfig, WAPresence, PresenceData, Chat, ChatModification, WAMediaUpload } from "../Types"; +import { BinaryNode, getBinaryNodeChild, getBinaryNodeChildren, jidNormalizedUser, S_WHATSAPP_NET } from "../WABinary"; +import { makeSocket } from "./socket"; +import { proto } from '../../WAProto' +import { toNumber } from "../Utils/generics"; +import { compressImage, generateProfilePicture } from ".."; + +export const makeChatsSocket = (config: SocketConfig) => { + const { logger } = config + const sock = makeSocket(config) + const { + ev, + ws, + authState, + generateMessageTag, + sendNode, + query + } = sock + + const interactiveQuery = async(userNodes: BinaryNode[], queryNode: BinaryNode) => { + const result = await query({ + tag: 'iq', + attrs: { + to: S_WHATSAPP_NET, + type: 'get', + xmlns: 'usync', + + }, + content: [ + { + tag: 'usync', + attrs: { + sid: generateMessageTag(), + mode: 'query', + last: 'true', + index: '0', + context: 'interactive', + }, + content: [ + { + tag: 'query', + attrs: { }, + content: [ queryNode ] + }, + { + tag: 'list', + attrs: { }, + content: userNodes + } + ] + } + ], + }) + + const usyncNode = getBinaryNodeChild(result, 'usync') + const listNode = getBinaryNodeChild(usyncNode, 'list') + const users = getBinaryNodeChildren(listNode, 'user') + + return users + } + + const onWhatsApp = async(...jids: string[]) => { + const results = await interactiveQuery( + [ + { + tag: 'user', + attrs: { }, + content: jids.map( + jid => ({ + tag: 'contact', + attrs: { }, + content: `+${jid}` + }) + ) + } + ], + { tag: 'contact', attrs: { } } + ) + + return results.map(user => { + const contact = getBinaryNodeChild(user, 'contact') + return { exists: contact.attrs.type === 'in', jid: user.attrs.jid } + }).filter(item => item.exists) + } + + const fetchStatus = async(jid: string) => { + const [result] = await interactiveQuery( + [{ tag: 'user', attrs: { jid } }], + { tag: 'status', attrs: { } } + ) + if(result) { + const status = getBinaryNodeChild(result, 'status') + return { + status: status.content!.toString(), + setAt: new Date(+status.attrs.t * 1000) + } + } + } + + const updateProfilePicture = async(jid: string, content: WAMediaUpload) => { + const { img } = await generateProfilePicture('url' in content ? content.url.toString() : content) + await query({ + tag: 'iq', + attrs: { + to: jidNormalizedUser(jid), + type: 'set', + xmlns: 'w:profile:picture' + }, + content: [ + { + tag: 'picture', + attrs: { type: 'image' }, + content: img + } + ] + }) + } + + const fetchBlocklist = async() => { + const result = await query({ + tag: 'iq', + attrs: { + xmlns: 'blocklist', + to: S_WHATSAPP_NET, + type: 'get' + } + }) + console.log('blocklist', result) + } + + const updateBlockStatus = async(jid: string, action: 'block' | 'unblock') => { + await query({ + tag: 'iq', + attrs: { + to: S_WHATSAPP_NET, + type: 'set' + }, + content: [ + { + tag: 'item', + attrs: { + action, + jid + } + } + ] + }) + } + + const fetchPrivacySettings = async() => { + const result = await query({ + tag: 'iq', + attrs: { + xmlns: 'privacy', + to: S_WHATSAPP_NET, + type: 'get' + } + }) + console.log('privacy', result) + } + + const updateAccountSyncTimestamp = async() => { + await sendNode({ + tag: 'iq', + attrs: { + to: S_WHATSAPP_NET, + type: 'set', + xmlns: 'urn:xmpp:whatsapp:dirty', + id: generateMessageTag(), + }, + content: [ + { + tag: 'clean', + attrs: { } + } + ] + }) + } + + const collectionSync = async() => { + const COLLECTIONS = ['critical_block', 'critical_unblock_low', 'regular_low', 'regular_high'] + await sendNode({ + tag: 'iq', + attrs: { + to: S_WHATSAPP_NET, + xmlns: 'w:sync:app:state', + type: 'set', + id: generateMessageTag(), + }, + content: [ + { + tag: 'sync', + attrs: { }, + content: COLLECTIONS.map( + name => ({ + tag: 'collection', + attrs: { name, version: '0', return_snapshot: 'true' } + }) + ) + } + ] + }) + logger.info('synced collection') + } + + const profilePictureUrl = async(jid: string) => { + const result = await query({ + tag: 'iq', + attrs: { + to: jid, + type: 'get', + xmlns: 'w:profile:picture' + }, + content: [ + { tag: 'picture', attrs: { type: 'preview', query: 'url' } } + ] + }) + const child = getBinaryNodeChild(result, 'picture') + return child?.attrs?.url + } + + const sendPresenceUpdate = async(type: WAPresence, toJid?: string) => { + if(type === 'available' || type === 'unavailable') { + await sendNode({ + tag: 'presence', + attrs: { + name: authState.creds.me!.name, + type + } + }) + } else { + await sendNode({ + tag: 'chatstate', + attrs: { + from: authState.creds.me!.id!, + to: toJid, + }, + content: [ + { tag: type, attrs: { } } + ] + }) + } + } + + const presenceSubscribe = (toJid: string) => ( + sendNode({ + tag: 'presence', + attrs: { + to: toJid, + id: generateMessageTag(), + type: 'subscribe' + } + }) + ) + + const handlePresenceUpdate = ({ tag, attrs, content }: BinaryNode) => { + let presence: PresenceData + const jid = attrs.from + const participant = attrs.participant || attrs.from + if(tag === 'presence') { + presence = { + lastKnownPresence: attrs.type === 'unavailable' ? 'unavailable' : 'available', + lastSeen: attrs.t ? +attrs.t : undefined + } + } else if(Array.isArray(content)) { + const [firstChild] = content + let type = firstChild.tag as WAPresence + if(type === 'paused') { + type = 'available' + } + presence = { lastKnownPresence: type } + } else { + logger.error({ tag, attrs, content }, 'recv invalid presence node') + } + if(presence) { + ev.emit('presence.update', { id: jid, presences: { [participant]: presence } }) + } + } + + const processSyncActions = (actions: { action: proto.ISyncActionValue, index: [string, string] }[]) => { + const updates: Partial[] = [] + for(const { action, index: [_, id] } of actions) { + const update: Partial = { id } + if(action?.muteAction) { + update.mute = action.muteAction?.muted ? + toNumber(action.muteAction!.muteEndTimestamp!) : + undefined + } else if(action?.archiveChatAction) { + update.archive = !!action.archiveChatAction?.archived + } else if(action?.markChatAsReadAction) { + update.unreadCount = !!action.markChatAsReadAction?.read ? 0 : -1 + } else if(action?.clearChatAction) { + console.log(action.clearChatAction) + } else if(action?.contactAction) { + ev.emit('contacts.update', [{ id, name: action.contactAction!.fullName }]) + } else if(action?.pushNameSetting) { + authState.creds.me!.name = action?.pushNameSetting?.name! + ev.emit('auth-state.update', authState) + } else { + logger.warn({ action, id }, 'unprocessable update') + } + updates.push(update) + } + ev.emit('chats.update', updates) + } + + const patchChat = async( + jid: string, + modification: ChatModification + ) => { + const patch = encodeSyncdPatch(modification, { remoteJid: jid }, authState) + const type = 'regular_high' + const ver = authState.creds.appStateVersion![type] || 0 + const node: BinaryNode = { + tag: 'iq', + attrs: { + to: S_WHATSAPP_NET, + type: 'set', + xmlns: 'w:sync:app:state' + }, + content: [ + { + tag: 'patch', + attrs: { + name: type, + version: (ver+1).toString(), + return_snapshot: 'false' + }, + content: proto.SyncdPatch.encode(patch).finish() + } + ] + } + await query(node) + + authState.creds.appStateVersion![type] += 1 + ev.emit('auth-state.update', authState) + } + + const resyncState = async(name: 'regular_high' | 'regular_low' = 'regular_high') => { + authState.creds.appStateVersion = authState.creds.appStateVersion || { + regular_high: 0, + regular_low: 0, + critical_unblock_low: 0, + critical_block: 0 + } + const result = await query({ + tag: 'iq', + attrs: { + type: 'set', + xmlns: 'w:sync:app:state', + to: S_WHATSAPP_NET + }, + content: [ + { + tag: 'sync', + attrs: { }, + content: [ + { + tag: 'collection', + attrs: { + name, + version: authState.creds.appStateVersion[name].toString(), + return_snapshot: 'false' + } + } + ] + } + ] + }) + const syncNode = getBinaryNodeChild(result, 'sync') + const collectionNode = getBinaryNodeChild(syncNode, 'collection') + const patchesNode = getBinaryNodeChild(collectionNode, 'patches') + + const patches = getBinaryNodeChildren(patchesNode, 'patch') + const successfulMutations = patches.flatMap(({ content }) => { + if(content) { + const syncd = proto.SyncdPatch.decode(content! as Uint8Array) + const version = toNumber(syncd.version!.version!) + if(version) { + authState.creds.appStateVersion[name] = Math.max(version, authState.creds.appStateVersion[name]) + } + const { mutations, failures } = decodeSyncdPatch(syncd, authState) + if(failures.length) { + logger.info( + { failures: failures.map(f => ({ trace: f.stack, data: f.data })) }, + 'failed to decode' + ) + } + return mutations + } + return [] + }) + processSyncActions(successfulMutations) + ev.emit('auth-state.update', authState) + } + + ws.on('CB:presence', handlePresenceUpdate) + ws.on('CB:chatstate', handlePresenceUpdate) + + ws.on('CB:notification,type:server_sync', (node: BinaryNode) => { + const update = getBinaryNodeChild(node, 'collection') + if(update) { + resyncState(update.attrs.name as any) + } + }) + + ev.on('connection.update', ({ connection }) => { + if(connection === 'open') { + sendPresenceUpdate('available') + fetchBlocklist() + fetchPrivacySettings() + //collectionSync() + } + }) + + return { + ...sock, + patchChat, + sendPresenceUpdate, + presenceSubscribe, + profilePictureUrl, + onWhatsApp, + fetchBlocklist, + fetchPrivacySettings, + fetchStatus, + updateProfilePicture, + updateBlockStatus + } +} \ No newline at end of file diff --git a/src/Socket/groups.ts b/src/Socket/groups.ts new file mode 100644 index 0000000..40eb113 --- /dev/null +++ b/src/Socket/groups.ts @@ -0,0 +1,149 @@ +import { generateMessageID } from "../Utils"; +import { SocketConfig, GroupMetadata, ParticipantAction } from "../Types"; +import { BinaryNode, getBinaryNodeChild, getBinaryNodeChildren, jidDecode, jidEncode } from "../WABinary"; +import { makeChatsSocket } from "./chats"; + +const extractGroupMetadata = (result: BinaryNode) => { + const group = getBinaryNodeChild(result, 'group') + const descChild = getBinaryNodeChild(group, 'description') + let desc: string | undefined + let descId: string | undefined + if(descChild) { + desc = getBinaryNodeChild(descChild, 'body')?.content as string + descId = descChild.attrs.id + } + + const metadata: GroupMetadata = { + id: jidEncode(jidDecode(group.attrs.id).user, 'g.us'), + subject: group.attrs.subject, + creation: +group.attrs.creation, + owner: group.attrs.creator, + desc, + descId, + restrict: !!getBinaryNodeChild(result, 'locked') ? 'true' : 'false', + announce: !!getBinaryNodeChild(result, 'announcement') ? 'true' : 'false', + participants: getBinaryNodeChildren(group, 'participant').map( + ({ attrs }) => { + return { + id: attrs.jid, + admin: attrs.type || null as any, + } + } + ) + } + return metadata +} + +export const makeGroupsSocket = (config: SocketConfig) => { + const sock = makeChatsSocket(config) + const { query } = sock + + const groupQuery = async(jid: string, type: 'get' | 'set', content: BinaryNode[]) => ( + query({ + tag: 'iq', + attrs: { + type, + xmlns: 'w:g2', + to: jid, + }, + content + }) + ) + + const groupMetadata = async(jid: string) => { + const result = await groupQuery( + jid, + 'get', + [ { tag: 'query', attrs: { request: 'interactive' } } ] + ) + return extractGroupMetadata(result) + } + + return { + ...sock, + groupMetadata, + groupCreate: async(subject: string, participants: string[]) => { + const key = generateMessageID() + const result = await groupQuery( + '@g.us', + 'set', + [ + { + tag: 'create', + attrs: { + subject, + key + }, + content: participants.map(jid => ({ + tag: 'participant', + attrs: { jid } + })) + } + ] + ) + return extractGroupMetadata(result) + }, + groupLeave: async(jid: string) => { + await groupQuery( + '@g.us', + 'set', + [ + { + tag: 'leave', + attrs: { }, + content: [ + { tag: 'group', attrs: { jid } } + ] + } + ] + ) + }, + groupUpdateSubject: async(jid: string, subject: string) => { + await groupQuery( + jid, + 'set', + [ + { + tag: 'subject', + attrs: { }, + content: Buffer.from(subject, 'utf-8') + } + ] + ) + }, + groupParticipantsUpdate: async( + jid: string, + participants: string[], + action: ParticipantAction + ) => { + const result = await groupQuery( + jid, + 'set', + participants.map( + jid => ({ + tag: action, + attrs: { }, + content: [{ tag: 'participant', attrs: { jid } }] + }) + ) + ) + const node = getBinaryNodeChild(result, action) + const participantsAffected = getBinaryNodeChildren(node!, 'participant') + return participantsAffected.map(p => p.attrs.jid) + }, + groupInviteCode: async(jid: string) => { + const result = await groupQuery(jid, 'get', [{ tag: 'invite', attrs: {} }]) + const inviteNode = getBinaryNodeChild(result, 'invite') + return inviteNode.attrs.code + }, + groupToggleEphemeral: async(jid: string, ephemeralExpiration: number) => { + const content: BinaryNode = ephemeralExpiration ? + { tag: 'ephemeral', attrs: { ephemeral: ephemeralExpiration.toString() } } : + { tag: 'not_ephemeral', attrs: { } } + await groupQuery(jid, 'set', [content]) + }, + groupSettingUpdate: async(jid: string, setting: 'announcement' | 'not_announcement' | 'locked' | 'unlocked') => { + await groupQuery(jid, 'set', [ { tag: setting, attrs: { } } ]) + } + } +} \ No newline at end of file diff --git a/src/Socket/index.ts b/src/Socket/index.ts new file mode 100644 index 0000000..0ffddfe --- /dev/null +++ b/src/Socket/index.ts @@ -0,0 +1,13 @@ +import { SocketConfig } from '../Types' +import { DEFAULT_CONNECTION_CONFIG } from '../Defaults' +import { makeMessagesSocket as _makeSocket } from './messages-send' + +// export the last socket layer +const makeWASocket = (config: Partial) => ( + _makeSocket({ + ...DEFAULT_CONNECTION_CONFIG, + ...config + }) +) + +export default makeWASocket \ No newline at end of file diff --git a/src/Socket/messages-recv.ts b/src/Socket/messages-recv.ts new file mode 100644 index 0000000..6f5a14c --- /dev/null +++ b/src/Socket/messages-recv.ts @@ -0,0 +1,437 @@ + +import { makeGroupsSocket } from "./groups" +import { SocketConfig, WAMessageStubType, ParticipantAction, Chat, GroupMetadata } from "../Types" +import { decodeMessageStanza, encodeBigEndian, toNumber, whatsappID } from "../Utils" +import { BinaryNode, jidDecode, jidEncode, isJidStatusBroadcast, S_WHATSAPP_NET, areJidsSameUser, getBinaryNodeChildren, getBinaryNodeChild } from '../WABinary' +import { downloadIfHistory } from '../Utils/history' +import { proto } from "../../WAProto" +import { generateSignalPubKey, xmppPreKey, xmppSignedPreKey } from "../Utils/signal" +import { KEY_BUNDLE_TYPE } from "../Defaults" + +export const makeMessagesRecvSocket = (config: SocketConfig) => { + const { logger } = config + const sock = makeGroupsSocket(config) + const { + ev, + authState, + ws, + assertingPreKeys, + sendNode, + } = sock + + const sendMessageAck = async({ attrs }: BinaryNode) => { + const isGroup = !!attrs.participant + const { user: meUser } = jidDecode(authState.creds.me!.id!) + const stanza: BinaryNode = { + tag: 'ack', + attrs: { + class: 'receipt', + id: attrs.id, + to: isGroup ? attrs.from : authState.creds.me!.id, + } + } + if(isGroup) { + stanza.attrs.participant = jidEncode(meUser, 's.whatsapp.net') + } + await sendNode(stanza) + } + + const sendRetryRequest = async(node: BinaryNode) => { + const retryCount = +(node.attrs.retryCount || 0) + 1 + const isGroup = !!node.attrs.participant + const { account, signedPreKey, signedIdentityKey: identityKey } = authState.creds + + const deviceIdentity = proto.ADVSignedDeviceIdentity.encode(account).finish() + await assertingPreKeys(1, async preKeys => { + const [keyId] = Object.keys(preKeys) + const key = preKeys[+keyId] + + const decFrom = node.attrs.from ? jidDecode(node.attrs.from) : undefined + const receipt: BinaryNode = { + tag: 'receipt', + attrs: { + id: node.attrs.id, + type: 'retry', + to: isGroup ? node.attrs.from : jidEncode(decFrom!.user, 's.whatsapp.net', decFrom!.device, 0) + }, + content: [ + { + tag: 'retry', + attrs: { + count: retryCount.toString(), id: node.attrs.id, + t: node.attrs.t, + v: '1' + } + }, + { + tag: 'registration', + attrs: { }, + content: encodeBigEndian(authState.creds.registrationId) + } + ] + } + if(node.attrs.recipient) { + receipt.attrs.recipient = node.attrs.recipient + } + if(node.attrs.participant) { + receipt.attrs.participant = node.attrs.participant + } + if(retryCount > 1) { + const exec = generateSignalPubKey(Buffer.from(KEY_BUNDLE_TYPE)).slice(0, 1); + + (node.content! as BinaryNode[]).push({ + tag: 'keys', + attrs: { }, + content: [ + { tag: 'type', attrs: { }, content: exec }, + { tag: 'identity', attrs: { }, content: identityKey.public }, + xmppPreKey(key, +keyId), + xmppSignedPreKey(signedPreKey), + { tag: 'device-identity', attrs: { }, content: deviceIdentity } + ] + }) + } + await sendNode(node) + + logger.info({ msgId: node.attrs.id, retryCount }, 'sent retry receipt') + + ev.emit('auth-state.update', authState) + }) + } + + const processMessage = (message: proto.IWebMessageInfo, chatUpdate: Partial) => { + const protocolMsg = message.message?.protocolMessage + if(protocolMsg) { + switch(protocolMsg.type) { + case proto.ProtocolMessage.ProtocolMessageType.APP_STATE_SYNC_KEY_SHARE: + const newKeys = JSON.parse(JSON.stringify(protocolMsg.appStateSyncKeyShare!.keys)) + authState.creds.appStateSyncKeys = [ + ...(authState.creds.appStateSyncKeys || []), + ...newKeys + ] + ev.emit('auth-state.update', authState) + break + case proto.ProtocolMessage.ProtocolMessageType.REVOKE: + ev.emit('messages.update', [ + { + key: protocolMsg.key, + update: { message: null, messageStubType: 1, key: message.key } + } + ]) + break + case proto.ProtocolMessage.ProtocolMessageType.EPHEMERAL_SETTING: + chatUpdate.ephemeralSettingTimestamp = toNumber(message.messageTimestamp) + chatUpdate.ephemeralExpiration = protocolMsg.ephemeralExpiration + break + } + } else if(message.messageStubType) { + const meJid = authState.creds.me!.id + const jid = message.key!.remoteJid! + //let actor = whatsappID (message.participant) + let participants: string[] + const emitParticipantsUpdate = (action: ParticipantAction) => ( + ev.emit('group-participants.update', { id: jid, participants, action }) + ) + const emitGroupUpdate = (update: Partial) => { + ev.emit('groups.update', [ { id: jid, ...update } ]) + } + + switch (message.messageStubType) { + case WAMessageStubType.GROUP_PARTICIPANT_LEAVE: + case WAMessageStubType.GROUP_PARTICIPANT_REMOVE: + participants = message.messageStubParameters.map(whatsappID) + emitParticipantsUpdate('remove') + // mark the chat read only if you left the group + if (participants.includes(meJid)) { + chatUpdate.readOnly = true + } + break + case WAMessageStubType.GROUP_PARTICIPANT_ADD: + case WAMessageStubType.GROUP_PARTICIPANT_INVITE: + case WAMessageStubType.GROUP_PARTICIPANT_ADD_REQUEST_JOIN: + participants = message.messageStubParameters.map(whatsappID) + if (participants.includes(meJid)) { + chatUpdate.readOnly = false + } + emitParticipantsUpdate('add') + break + case WAMessageStubType.GROUP_CHANGE_ANNOUNCE: + const announce = message.messageStubParameters[0] === 'on' ? 'true' : 'false' + emitGroupUpdate({ announce }) + break + case WAMessageStubType.GROUP_CHANGE_RESTRICT: + const restrict = message.messageStubParameters[0] === 'on' ? 'true' : 'false' + emitGroupUpdate({ restrict }) + break + case WAMessageStubType.GROUP_CHANGE_SUBJECT: + case WAMessageStubType.GROUP_CREATE: + chatUpdate.name = message.messageStubParameters[0] + emitGroupUpdate({ subject: chatUpdate.name }) + break + } + } + } + + const processHistoryMessage = (item: proto.HistorySync) => { + switch(item.syncType) { + case proto.HistorySync.HistorySyncHistorySyncType.INITIAL_BOOTSTRAP: + const messages: proto.IWebMessageInfo[] = [] + const chats = item.conversations!.map( + c => { + const chat: Chat = { ...c } + //@ts-expect-error + delete chat.messages + for(const item of c.messages || []) { + messages.push(item.message) + } + return chat + } + ) + ev.emit('chats.set', { chats, messages }) + break + case proto.HistorySync.HistorySyncHistorySyncType.PUSH_NAME: + const contacts = item.pushnames.map( + p => ({ notify: p.pushname, id: p.id }) + ) + ev.emit('contacts.upsert', contacts) + break + case proto.HistorySync.HistorySyncHistorySyncType.INITIAL_STATUS_V3: + // TODO + break + } + } + + const processNotification = (node: BinaryNode): Partial => { + const result: Partial = { } + const child = (node.content as BinaryNode[])?.[0] + + if(node.attrs.type === 'w:gp2') { + switch(child?.tag) { + case 'ephemeral': + case 'not_ephemeral': + result.message = { + protocolMessage: { + type: proto.ProtocolMessage.ProtocolMessageType.EPHEMERAL_SETTING, + ephemeralExpiration: +(child.attrs.expiration || 0) + } + } + break + case 'promote': + case 'demote': + case 'remove': + case 'add': + case 'leave': + const stubType = `GROUP_PARTICIPANT_${child.tag!.toUpperCase()}` + result.messageStubType = WAMessageStubType[stubType] + result.messageStubParameters = getBinaryNodeChildren(child, 'participant').map(p => p.attrs.jid) + break + case 'subject': + result.messageStubType = WAMessageStubType.GROUP_CHANGE_SUBJECT + result.messageStubParameters = [ child.attrs.subject ] + break + case 'announcement': + case 'not_announcement': + result.messageStubType = WAMessageStubType.GROUP_CHANGE_ANNOUNCE + result.messageStubParameters = [ (child.tag === 'announcement').toString() ] + break + case 'locked': + case 'unlocked': + result.messageStubType = WAMessageStubType.GROUP_CHANGE_RESTRICT + result.messageStubParameters = [ (child.tag === 'locked').toString() ] + break + + } + } else { + switch(child.tag) { + case 'count': + if(child.attrs.value === '0') { + logger.info('recv all pending notifications') + ev.emit('connection.update', { receivedPendingNotifications: true }) + } + break + case 'devices': + const devices = getBinaryNodeChildren(child, 'device') + if(areJidsSameUser(child.attrs.jid, authState.creds!.me!.id)) { + const deviceJids = devices.map(d => d.attrs.jid) + logger.info({ deviceJids }, 'got my own devices') + } + break + } + } + if(Object.keys(result).length) { + return result + } + } + // recv a message + ws.on('CB:message', async(stanza: BinaryNode) => { + const dec = await decodeMessageStanza(stanza, authState) + const fullMessages: proto.IWebMessageInfo[] = [] + for(const msg of dec.successes) { + const { attrs } = stanza + const isGroup = !!stanza.attrs.participant + const sender = (attrs.participant || attrs.from)?.toString() + const isMe = areJidsSameUser(sender, authState.creds.me!.id) + + await sendMessageAck(stanza) + + logger.debug({ msgId: dec.msgId, sender }, 'send message ack') + + // send delivery receipt + let recpAttrs: { [_: string]: any } + if(isMe) { + recpAttrs = { + type: 'sender', + id: stanza.attrs.id, + to: stanza.attrs.from, + } + if(isGroup) { + recpAttrs.participant = stanza.attrs.participant + } else { + recpAttrs.recipient = stanza.attrs.recipient + } + } else { + const isStatus = isJidStatusBroadcast(stanza.attrs.from) + recpAttrs = { + //type: 'inactive', + id: stanza.attrs.id, + to: dec.chatId, + } + if(isGroup || isStatus) { + recpAttrs.participant = stanza.attrs.participant + } + } + await sendNode({ tag: 'receipt', attrs: recpAttrs }) + + logger.debug({ msgId: dec.msgId }, 'send message receipt') + + const possibleHistory = downloadIfHistory(msg) + if(possibleHistory) { + const history = await possibleHistory + logger.info({ msgId: dec.msgId, type: history.syncType }, 'recv history') + + processHistoryMessage(history) + } else { + const message = msg.deviceSentMessage?.message || msg + fullMessages.push({ + key: { + remoteJid: dec.chatId, + fromMe: isMe, + id: dec.msgId, + participant: dec.participant + }, + message, + status: isMe ? proto.WebMessageInfo.WebMessageInfoStatus.SERVER_ACK : null, + messageTimestamp: dec.timestamp, + pushName: dec.pushname + }) + } + } + + if(dec.successes.length) { + ev.emit('auth-state.update', authState) + if(fullMessages.length) { + ev.emit( + 'messages.upsert', + { + messages: fullMessages.map(m => proto.WebMessageInfo.fromObject(m)), + type: stanza.attrs.offline ? 'append' : 'notify' + } + ) + } + } + + for(const { error } of dec.failures) { + logger.error( + { msgId: dec.msgId, trace: error.stack, data: error.data }, + 'failure in decrypting message' + ) + await sendRetryRequest(stanza) + } + }) + + ws.on('CB:ack,class:message', async(node: BinaryNode) => { + await sendNode({ + tag: 'ack', + attrs: { + class: 'receipt', + id: node.attrs.id, + from: node.attrs.from + } + }) + logger.debug({ attrs: node.attrs }, 'sending receipt for ack') + }) + + const handleReceipt = ({ attrs, content }: BinaryNode) => { + const sender = attrs.participant || attrs.from + const status = attrs.type === 'read' ? proto.WebMessageInfo.WebMessageInfoStatus.READ : proto.WebMessageInfo.WebMessageInfoStatus.DELIVERY_ACK + const ids = [attrs.id] + if(Array.isArray(content)) { + const items = getBinaryNodeChildren(content[0], 'item') + ids.push(...items.map(i => i.attrs.id)) + } + + ev.emit('messages.update', ids.map(id => ({ + key: { + remoteJid: attrs.from, + id: id, + fromMe: areJidsSameUser(sender, authState.creds.me!.id!), + participant: attrs.participant + }, + update: { status } + }))) + } + + ws.on('CB:receipt,type:read', handleReceipt) + ws.on('CB:ack,class:receipt', handleReceipt) + + ws.on('CB:notification', async(node: BinaryNode) => { + const sendAck = async() => { + await sendNode({ + tag: 'ack', + attrs: { + class: 'notification', + id: node.attrs.id, + type: node.attrs.type, + to: node.attrs.from + } + }) + + logger.debug({ msgId: node.attrs.id }, 'ack notification') + } + + await sendAck() + + const msg = processNotification(node) + if(msg) { + const fromMe = areJidsSameUser(node.attrs.participant || node.attrs.from, authState.creds.me!.id) + msg.key = { + remoteJid: node.attrs.from, + fromMe, + participant: node.attrs.participant, + id: node.attrs.id + } + msg.messageTimestamp = +node.attrs.t + + const fullMsg = proto.WebMessageInfo.fromObject(msg) + ev.emit('messages.upsert', { messages: [fullMsg], type: 'append' }) + } + }) + + ev.on('messages.upsert', ({ messages }) => { + const chat: Partial = { id: messages[0].key.remoteJid } + for(const msg of messages) { + processMessage(msg, chat) + if(!!msg.message && !msg.message!.protocolMessage) { + chat.conversationTimestamp = toNumber(msg.messageTimestamp) + if(!msg.key.fromMe) { + chat.unreadCount = (chat.unreadCount || 0) + 1 + } + } + } + if(Object.keys(chat).length > 1) { + ev.emit('chats.update', [ chat ]) + } + }) + + return sock +} \ No newline at end of file diff --git a/src/Socket/messages-send.ts b/src/Socket/messages-send.ts new file mode 100644 index 0000000..509c4f4 --- /dev/null +++ b/src/Socket/messages-send.ts @@ -0,0 +1,392 @@ + +import { makeMessagesRecvSocket } from "./messages-recv" +import { SocketConfig, MediaConnInfo, AnyMessageContent, MiscMessageGenerationOptions, WAMediaUploadFunction } from "../Types" +import { encodeWAMessage, generateMessageID, generateWAMessage } from "../Utils" +import { BinaryNode, getBinaryNodeChild, getBinaryNodeChildren, isJidGroup, jidDecode, jidEncode, S_WHATSAPP_NET } from '../WABinary' +import { proto } from "../../WAProto" +import { encryptSenderKeyMsgSignalProto, encryptSignalProto, extractDeviceJids, jidToSignalProtocolAddress, parseAndInjectE2ESession } from "../Utils/signal" +import { WA_DEFAULT_EPHEMERAL, DEFAULT_ORIGIN, MEDIA_PATH_MAP } from "../Defaults" +import got from "got" +import { Boom } from "@hapi/boom" + +export const makeMessagesSocket = (config: SocketConfig) => { + const { logger } = config + const sock = makeMessagesRecvSocket(config) + const { + ev, + authState, + query, + generateMessageTag, + sendNode, + groupMetadata, + groupToggleEphemeral + } = sock + + let mediaConn: Promise + const refreshMediaConn = async(forceGet = false) => { + let media = await mediaConn + if (!media || forceGet || (new Date().getTime()-media.fetchDate.getTime()) > media.ttl*1000) { + mediaConn = (async() => { + const result = await query({ + tag: 'iq', + attrs: { + type: 'set', + xmlns: 'w:m', + to: S_WHATSAPP_NET, + }, + content: [ { tag: 'media_conn', attrs: { } } ] + }) + const mediaConnNode = getBinaryNodeChild(result, 'media_conn') + const node: MediaConnInfo = { + hosts: getBinaryNodeChildren(mediaConnNode, 'host').map( + item => item.attrs as any + ), + auth: mediaConnNode.attrs.auth, + ttl: +mediaConnNode.attrs.ttl, + fetchDate: new Date() + } + logger.debug('fetched media conn') + return node + })() + } + return mediaConn + } + + const sendReadReceipt = async(jid: string, participant: string | undefined, messageIds: string[]) => { + const node: BinaryNode = { + tag: 'receipt', + attrs: { + id: messageIds[0], + t: Date.now().toString(), + to: jid, + type: 'read' + }, + } + if(participant) { + node.attrs.participant = participant + } + messageIds = messageIds.slice(1) + if(messageIds.length) { + node.content = [ + { + tag: 'list', + attrs: { }, + content: messageIds.map(id => ({ + tag: 'item', + attrs: { id } + })) + } + ] + } + + logger.debug({ jid, messageIds }, 'reading messages') + await sendNode(node) + } + + const getUSyncDevices = async(jids: string[], ignoreZeroDevices: boolean) => { + const users = jids.map(jid => ({ tag: 'user', attrs: { jid } })) + const iq: BinaryNode = { + tag: 'iq', + attrs: { + to: S_WHATSAPP_NET, + type: 'get', + xmlns: 'usync', + }, + content: [ + { + tag: 'usync', + attrs: { + sid: generateMessageTag(), + mode: 'query', + last: 'true', + index: '0', + context: 'message', + }, + content: [ + { + tag: 'query', + attrs: { }, + content: [ + { + tag: 'devices', + attrs: { version: '2' } + } + ] + }, + { tag: 'list', attrs: { }, content: users } + ] + }, + ], + } + const result = await query(iq) + let resultJids = extractDeviceJids(result) + if(ignoreZeroDevices) { + resultJids = resultJids.filter(item => item.device !== 0) + } + + return resultJids + } + + const assertSession = async(jid: string, force: boolean) => { + const addr = jidToSignalProtocolAddress(jid).toString() + const session = await authState.keys.getSession(addr) + if(!session || force) { + logger.debug({ jid }, `fetching session`) + const identity: BinaryNode = { + tag: 'user', + attrs: { jid, reason: 'identity' }, + } + const result = await query({ + tag: 'iq', + attrs: { + xmlns: 'encrypt', + type: 'get', + to: S_WHATSAPP_NET, + }, + content: [ + { + tag: 'key', + attrs: { }, + content: [ identity ] + } + ] + }) + await parseAndInjectE2ESession(result, authState) + return true + } + return false + } + + const createParticipantNode = async(jid: string, bytes: Buffer) => { + await assertSession(jid, false) + + const { type, ciphertext } = await encryptSignalProto(jid, bytes, authState) + const node: BinaryNode = { + tag: 'to', + attrs: { jid }, + content: [{ + tag: 'enc', + attrs: { v: '2', type }, + content: ciphertext + }] + } + return node + } + + const relayMessage = async(jid: string, message: proto.IMessage, msgId?: string) => { + const { user, server } = jidDecode(jid) + const isGroup = server === 'g.us' + msgId = msgId || generateMessageID() + const encodedMsg = encodeWAMessage(message) + const participants: BinaryNode[] = [] + let stanza: BinaryNode + + const destinationJid = jidEncode(user, isGroup ? 'g.us' : 's.whatsapp.net') + + if(isGroup) { + const { ciphertext, senderKeyDistributionMessageKey } = await encryptSenderKeyMsgSignalProto(destinationJid, encodedMsg, authState) + const groupData = await groupMetadata(jid) + const participantsList = groupData.participants.map(p => p.id) + const devices = await getUSyncDevices(participantsList, false) + + logger.debug(`got ${devices.length} additional devices`) + + const encSenderKeyMsg = encodeWAMessage({ + senderKeyDistributionMessage: { + axolotlSenderKeyDistributionMessage: senderKeyDistributionMessageKey, + groupId: destinationJid + } + }) + + for(const {user, device, agent} of devices) { + const jid = jidEncode(user, 's.whatsapp.net', device, agent) + const participant = await createParticipantNode(jid, encSenderKeyMsg) + participants.push(participant) + } + + const binaryNodeContent: BinaryNode[] = [] + if( // if there are some participants with whom the session has not been established + // if there are, we overwrite the senderkey + !!participants.find((p) => ( + !!(p.content as BinaryNode[]).find(({ attrs }) => attrs.type == 'pkmsg') + )) + ) { + binaryNodeContent.push({ + tag: 'participants', + attrs: { }, + content: participants + }) + } + + binaryNodeContent.push({ + tag: 'enc', + attrs: { v: '2', type: 'skmsg' }, + content: ciphertext + }) + + stanza = { + tag: 'message', + attrs: { + id: msgId, + type: 'text', + to: destinationJid + }, + content: binaryNodeContent + } + } else { + const { user: meUser } = jidDecode(authState.creds.me!.id!) + + const messageToMyself: proto.IMessage = { + deviceSentMessage: { + destinationJid, + message + } + } + const encodedMeMsg = encodeWAMessage(messageToMyself) + + participants.push( + await createParticipantNode(jidEncode(user, 's.whatsapp.net'), encodedMsg) + ) + participants.push( + await createParticipantNode(jidEncode(meUser, 's.whatsapp.net'), encodedMeMsg) + ) + const devices = await getUSyncDevices([ authState.creds.me!.id!, jid ], true) + + logger.debug(`got ${devices.length} additional devices`) + + for(const { user, device, agent } of devices) { + const isMe = user === meUser + participants.push( + await createParticipantNode( + jidEncode(user, 's.whatsapp.net', device, agent), + isMe ? encodedMeMsg : encodedMsg + ) + ) + } + + stanza = { + tag: 'message', + attrs: { + id: msgId, + type: 'text', + to: destinationJid + }, + content: [ + { + tag: 'participants', + attrs: { }, + content: participants + }, + ] + } + } + + const shouldHaveIdentity = !!participants.find((p) => ( + !!(p.content as BinaryNode[]).find(({ attrs }) => attrs.type == 'pkmsg') + )) + + if(shouldHaveIdentity) { + (stanza.content as BinaryNode[]).push({ + tag: 'device-identity', + attrs: { }, + content: proto.ADVSignedDeviceIdentity.encode(authState.creds.account).finish() + }) + } + logger.debug({ msgId }, 'sending message') + + await sendNode(stanza) + + ev.emit('auth-state.update', authState) + return msgId + } + + const waUploadToServer: WAMediaUploadFunction = async(stream, { mediaType, fileEncSha256B64 }) => { + // send a query JSON to obtain the url & auth token to upload our media + let uploadInfo = await refreshMediaConn(false) + + let mediaUrl: string + for (let host of uploadInfo.hosts) { + const auth = encodeURIComponent(uploadInfo.auth) // the auth token + const url = `https://${host.hostname}${MEDIA_PATH_MAP[mediaType]}/${fileEncSha256B64}?auth=${auth}&token=${fileEncSha256B64}` + + try { + const {body: responseText} = await got.post( + url, + { + headers: { + 'Content-Type': 'application/octet-stream', + 'Origin': DEFAULT_ORIGIN + }, + agent: { + https: config.agent + }, + body: stream + } + ) + const result = JSON.parse(responseText) + mediaUrl = result?.url + + if (mediaUrl) break + else { + uploadInfo = await refreshMediaConn(true) + throw new Error(`upload failed, reason: ${JSON.stringify(result)}`) + } + } catch (error) { + const isLast = host.hostname === uploadInfo.hosts[uploadInfo.hosts.length-1].hostname + logger.debug(`Error in uploading to ${host.hostname} (${error}) ${isLast ? '' : ', retrying...'}`) + } + } + if (!mediaUrl) { + throw new Boom( + 'Media upload failed on all hosts', + { statusCode: 500 } + ) + } + return { mediaUrl } + } + + return { + ...sock, + assertSession, + relayMessage, + sendReadReceipt, + refreshMediaConn, + sendMessage: async( + jid: string, + content: AnyMessageContent, + options: MiscMessageGenerationOptions = { } + ) => { + const userJid = authState.creds.me!.id + if( + typeof content === 'object' && + 'disappearingMessagesInChat' in content && + typeof content['disappearingMessagesInChat'] !== 'undefined' && + isJidGroup(jid) + ) { + const { disappearingMessagesInChat } = content + const value = typeof disappearingMessagesInChat === 'boolean' ? + (disappearingMessagesInChat ? WA_DEFAULT_EPHEMERAL : 0) : + disappearingMessagesInChat + await groupToggleEphemeral(jid, value) + } else { + const fullMsg = await generateWAMessage( + jid, + content, + { + ...options, + logger, + userJid: userJid, + // multi-device does not have this yet + //getUrlInfo: generateUrlInfo, + upload: waUploadToServer + } + ) + await relayMessage(jid, fullMsg.message) + process.nextTick(() => { + ev.emit('messages.upsert', { messages: [fullMsg], type: 'append' }) + }) + return fullMsg + } + } + } +} \ No newline at end of file diff --git a/src/Socket/socket.ts b/src/Socket/socket.ts new file mode 100644 index 0000000..e3ad179 --- /dev/null +++ b/src/Socket/socket.ts @@ -0,0 +1,469 @@ +import { Boom } from '@hapi/boom' +import EventEmitter from 'events' +import { promisify } from "util" +import WebSocket from "ws" +import { randomBytes } from 'crypto' +import { proto } from '../../WAProto' +import { DisconnectReason, SocketConfig, BaileysEventEmitter } from "../Types" +import { generateCurveKeyPair, initAuthState, generateRegistrationNode, configureSuccessfulPairing, generateLoginNode, encodeBigEndian, promiseTimeout } from "../Utils" +import { DEFAULT_ORIGIN, DEF_TAG_PREFIX, DEF_CALLBACK_PREFIX, KEY_BUNDLE_TYPE } from "../Defaults" +import { assertNodeErrorFree, BinaryNode, encodeBinaryNode, S_WHATSAPP_NET } from '../WABinary' +import noiseHandler from '../Utils/noise-handler' +import { generateOrGetPreKeys, xmppSignedPreKey, xmppPreKey, getPreKeys } from '../Utils/signal' + +/** + * Connects to WA servers and performs: + * - simple queries (no retry mechanism, wait for connection establishment) + * - listen to messages and emit events + * - query phone connection + */ +export const makeSocket = ({ + waWebSocketUrl, + connectTimeoutMs, + logger, + agent, + keepAliveIntervalMs, + version, + browser, + auth: initialAuthState +}: SocketConfig) => { + const ws = new WebSocket(waWebSocketUrl, undefined, { + origin: DEFAULT_ORIGIN, + timeout: connectTimeoutMs, + agent, + headers: { + 'Accept-Encoding': 'gzip, deflate, br', + 'Accept-Language': 'en-US,en;q=0.9', + 'Cache-Control': 'no-cache', + 'Host': 'web.whatsapp.com', + 'Pragma': 'no-cache', + 'Sec-WebSocket-Extensions': 'permessage-deflate; client_max_window_bits' + } + }) + ws.setMaxListeners(0) + /** ephemeral key pair used to encrypt/decrypt communication. Unique for each connection */ + const ephemeralKeyPair = generateCurveKeyPair() + /** WA noise protocol wrapper */ + const noise = noiseHandler(ephemeralKeyPair) + const authState = initialAuthState || initAuthState() + const { creds } = authState + const ev = new EventEmitter() as BaileysEventEmitter + + let lastDateRecv: Date + let epoch = 0 + let keepAliveReq: NodeJS.Timeout + + const uqTagId = `${randomBytes(1).toString('hex')[0]}.${randomBytes(1).toString('hex')[0]}-` + const generateMessageTag = () => `${uqTagId}${epoch++}` + + const sendPromise = promisify(ws.send) + /** send a raw buffer */ + const sendRawMessage = (data: Buffer | Uint8Array) => { + const bytes = noise.encodeFrame(data) + return sendPromise.call(ws, bytes) as Promise + } + /** send a binary node */ + const sendNode = (node: BinaryNode) => { + let buff = encodeBinaryNode(node) + return sendRawMessage(buff) + } + /** await the next incoming message */ + const awaitNextMessage = async(sendMsg?: Uint8Array) => { + if(ws.readyState !== ws.OPEN) { + throw new Boom('Connection Closed', { statusCode: DisconnectReason.connectionClosed }) + } + let onOpen: (data: any) => void + let onClose: (err: Error) => void + + const result = new Promise((resolve, reject) => { + onOpen = (data: any) => resolve(data) + onClose = reject + ws.on('frame', onOpen) + ws.on('close', onClose) + ws.on('error', onClose) + }) + .finally(() => { + ws.off('frame', onOpen) + ws.off('close', onClose) + ws.off('error', onClose) + }) + + if(sendMsg) { + sendRawMessage(sendMsg).catch(onClose) + } + + return result + } + + /** + * Wait for a message with a certain tag to be received + * @param tag the message tag to await + * @param json query that was sent + * @param timeoutMs timeout after which the promise will reject + */ + const waitForMessage = async(msgId: string, timeoutMs?: number) => { + let onRecv: (json) => void + let onErr: (err) => void + try { + const result = await promiseTimeout(timeoutMs, + (resolve, reject) => { + onRecv = resolve + onErr = err => { + reject(err || new Boom('Connection Closed', { statusCode: DisconnectReason.connectionClosed })) + } + + ws.on(`TAG:${msgId}`, onRecv) + ws.on('close', onErr) // if the socket closes, you'll never receive the message + }, + ) + return result as any + } finally { + ws.off(`TAG:${msgId}`, onRecv) + ws.off('close', onErr) // if the socket closes, you'll never receive the message + } + } + /** send a query, and wait for its response. auto-generates message ID if not provided */ + const query = async(node: BinaryNode, timeoutMs?: number) => { + if(!node.attrs.id) node.attrs.id = generateMessageTag() + + const msgId = node.attrs.id + const wait = waitForMessage(msgId, timeoutMs) + + await sendNode(node) + + const result = await (wait as Promise) + if('tag' in result) { + assertNodeErrorFree(result) + } + return result + } + /** connection handshake */ + const validateConnection = async () => { + logger.info('connected to WA Web') + + const init = proto.HandshakeMessage.encode({ + clientHello: { ephemeral: ephemeralKeyPair.public } + }).finish() + + const result = await awaitNextMessage(init) + const handshake = proto.HandshakeMessage.decode(result) + + logger.debug('handshake recv from WA Web') + + const keyEnc = noise.processHandshake(handshake, creds.noiseKey) + logger.info('handshake complete') + + let node: Uint8Array + if(!creds.me) { + logger.info('not logged in, attempting registration...') + node = generateRegistrationNode(creds, { version, browser }) + } else { + logger.info('logging in...') + node = generateLoginNode(creds.me!.id, { version, browser }) + } + const payloadEnc = noise.encrypt(node) + await sendRawMessage( + proto.HandshakeMessage.encode({ + clientFinish: { + static: new Uint8Array(keyEnc), + payload: new Uint8Array(payloadEnc), + }, + }).finish() + ) + noise.finishInit() + startKeepAliveRequest() + } + /** get some pre-keys and do something with them */ + const assertingPreKeys = async(range: number, execute: (keys: { [_: number]: any }) => Promise) => { + const { newPreKeys, lastPreKeyId, preKeysRange } = generateOrGetPreKeys(authState, range) + const preKeys = await getPreKeys(authState.keys, preKeysRange[0], preKeysRange[1]) + + await execute(preKeys) + + creds.serverHasPreKeys = true + creds.nextPreKeyId = Math.max(lastPreKeyId+1, creds.nextPreKeyId) + creds.firstUnuploadedPreKeyId = Math.max(creds.firstUnuploadedPreKeyId, lastPreKeyId+1) + await Promise.all( + Object.keys(newPreKeys).map(k => authState.keys.setPreKey(+k, newPreKeys[+k])) + ) + + ev.emit('auth-state.update', authState) + } + /** generates and uploads a set of pre-keys */ + const uploadPreKeys = async() => { + await assertingPreKeys(50, async preKeys => { + const node: BinaryNode = { + tag: 'iq', + attrs: { + id: generateMessageTag(), + xmlns: 'encrypt', + type: 'set', + to: S_WHATSAPP_NET, + }, + content: [ + { tag: 'registration', attrs: { }, content: encodeBigEndian(creds.registrationId) }, + { tag: 'type', attrs: { }, content: KEY_BUNDLE_TYPE }, + { tag: 'identity', attrs: { }, content: creds.signedIdentityKey.public }, + { tag: 'list', attrs: { }, content: Object.keys(preKeys).map(k => xmppPreKey(preKeys[+k], +k)) }, + xmppSignedPreKey(creds.signedPreKey) + ] + } + await sendNode(node) + + logger.info('uploaded pre-keys') + }) + } + + const onMessageRecieved = (data: Buffer) => { + noise.decodeFrame(data, frame => { + ws.emit('frame', frame) + // if it's a binary node + if(!(frame instanceof Uint8Array)) { + const msgId = frame.attrs.id + + if(logger.level === 'trace') { + logger.trace({ msgId, fromMe: false, frame }, 'communication') + } + + let anyTriggered = false + /* Check if this is a response to a message we sent */ + anyTriggered = ws.emit(`${DEF_TAG_PREFIX}${msgId}`, frame) + /* Check if this is a response to a message we are expecting */ + const l0 = frame.tag + const l1 = frame.attrs || { } + const l2 = Array.isArray(frame.content) ? frame.content[0]?.tag : '' + + Object.keys(l1).forEach(key => { + anyTriggered = ws.emit(`${DEF_CALLBACK_PREFIX}${l0},${key}:${l1[key]},${l2}`, frame) || anyTriggered + anyTriggered = ws.emit(`${DEF_CALLBACK_PREFIX}${l0},${key}:${l1[key]}`, frame) || anyTriggered + anyTriggered = ws.emit(`${DEF_CALLBACK_PREFIX}${l0},${key}`, frame) || anyTriggered + }) + anyTriggered = ws.emit(`${DEF_CALLBACK_PREFIX}${l0},,${l2}`, frame) || anyTriggered + anyTriggered = ws.emit(`${DEF_CALLBACK_PREFIX}${l0}`, frame) || anyTriggered + anyTriggered = ws.emit('frame', frame) || anyTriggered + + if (!anyTriggered && logger.level === 'debug') { + logger.debug({ unhandled: true, msgId, fromMe: false, frame }, 'communication recv') + } + } + }) + } + + const end = (error: Error | undefined) => { + logger.info({ error }, 'connection closed') + + clearInterval(keepAliveReq) + + ws.removeAllListeners('close') + ws.removeAllListeners('error') + ws.removeAllListeners('open') + ws.removeAllListeners('message') + + if(ws.readyState !== ws.CLOSED && ws.readyState !== ws.CLOSING) { + try { ws.close() } catch { } + } + + ev.emit('connection.update', { + connection: 'close', + lastDisconnect: { + error, + date: new Date() + } + }) + ws.removeAllListeners('connection.update') + } + + const waitForSocketOpen = async() => { + if(ws.readyState === ws.OPEN) return + if(ws.readyState === ws.CLOSED || ws.readyState === ws.CLOSING) { + throw new Boom('Connection Closed', { statusCode: DisconnectReason.connectionClosed }) + } + let onOpen: () => void + let onClose: (err: Error) => void + await new Promise((resolve, reject) => { + onOpen = () => resolve(undefined) + onClose = reject + ws.on('open', onOpen) + ws.on('close', onClose) + ws.on('error', onClose) + }) + .finally(() => { + ws.off('open', onOpen) + ws.off('close', onClose) + ws.off('error', onClose) + }) + } + + const startKeepAliveRequest = () => ( + keepAliveReq = setInterval(() => { + if (!lastDateRecv) lastDateRecv = new Date() + const diff = Date.now() - lastDateRecv.getTime() + /* + check if it's been a suspicious amount of time since the server responded with our last seen + it could be that the network is down + */ + if (diff > keepAliveIntervalMs+5000) { + end(new Boom('Connection was lost', { statusCode: DisconnectReason.connectionLost })) + } else if(ws.readyState === ws.OPEN) { + // if its all good, send a keep alive request + query( + { + tag: 'iq', + attrs: { + id: generateMessageTag(), + to: S_WHATSAPP_NET, + type: 'get', + xmlns: 'w:p', + }, + content: [{ tag: 'ping', attrs: { } }] + }, + keepAliveIntervalMs + ) + .then(() => { + lastDateRecv = new Date() + logger.trace('recv keep alive') + }) + .catch(err => end(err)) + } else { + logger.warn('keep alive called when WS not open') + } + }, keepAliveIntervalMs) + ) + /** i have no idea why this exists. pls enlighten me */ + const sendPassiveIq = (tag: 'passive' | 'active') => ( + sendNode({ + tag: 'iq', + attrs: { + to: S_WHATSAPP_NET, + xmlns: 'passive', + type: 'set', + id: generateMessageTag(), + }, + content: [ + { tag, attrs: { } } + ] + }) + ) + /** logout & invalidate connection */ + const logout = async() => { + await sendNode({ + tag: 'iq', + attrs: { + to: S_WHATSAPP_NET, + type: 'set', + id: generateMessageTag(), + xmlns: 'md' + }, + content: [ + { + tag: 'remove-companion-device', + attrs: { + jid: authState.creds.me!.id, + reason: 'user_initiated' + } + } + ] + }) + end(new Boom('Intentional Logout', { statusCode: DisconnectReason.loggedOut })) + } + + ws.on('message', onMessageRecieved) + ws.on('open', validateConnection) + ws.on('error', end) + ws.on('close', () => end(new Boom('Connection Terminated', { statusCode: DisconnectReason.connectionClosed }))) + // the server terminated the connection + ws.on('CB:xmlstreamend', () => { + end(new Boom('Connection Terminated by Server', { statusCode: DisconnectReason.connectionClosed })) + }) + // QR gen + ws.on('CB:iq,type:set,pair-device', async (stanza: BinaryNode) => { + const postQR = async() => { + const QR = await import('qrcode-terminal').catch(err => { + logger.error('add `qrcode-terminal` as a dependency to auto-print QR') + }) + QR?.generate(qr, { small: true }) + } + + const refs = ((stanza.content[0] as BinaryNode).content as BinaryNode[]).map(n => n.content as string) + const iq: BinaryNode = { + tag: 'iq', + attrs: { + to: S_WHATSAPP_NET, + type: 'result', + id: stanza.attrs.id, + } + } + const noiseKeyB64 = Buffer.from(creds.noiseKey.public).toString('base64'); + const identityKeyB64 = Buffer.from(creds.signedIdentityKey.public).toString('base64') + const advB64 = creds.advSecretKey + const qr = [refs[0], noiseKeyB64, identityKeyB64, advB64].join(','); + + ev.emit('connection.update', { qr }) + await postQR() + await sendNode(iq) + }) + // device paired for the first time + // if device pairs successfully, the server asks to restart the connection + ws.on('CB:iq,,pair-success', async(stanza: BinaryNode) => { + logger.debug('pair success recv') + try { + const { reply, creds: updatedCreds } = configureSuccessfulPairing(stanza, creds) + + logger.debug('pairing configured successfully') + + const waiting = awaitNextMessage() + await sendNode(reply) + + const value = (await waiting) as BinaryNode + if(value.tag === 'stream:error') { + if(value.attrs?.code !== '515') { + throw new Boom('Authentication failed', { statusCode: +(value.attrs.code || 500) }) + } + } + Object.assign(creds, updatedCreds) + logger.info({ jid: creds.me!.id }, 'registered connection, restart server') + + ev.emit('auth-state.update', authState) + ev.emit('connection.update', { isNewLogin: true, qr: undefined }) + + end(new Boom('Restart Required', { statusCode: DisconnectReason.restartRequired })) + } catch(error) { + logger.info({ trace: error.stack }, 'error in pairing') + end(error) + } + }) + // login complete + ws.on('CB:success', async() => { + if(!creds.serverHasPreKeys) { + await uploadPreKeys() + } + await sendPassiveIq('active') + ev.emit('connection.update', { connection: 'open' }) + }) + // logged out + ws.on('CB:failure,reason:401', () => { + end(new Boom('Logged Out', { statusCode: DisconnectReason.loggedOut })) + }) + process.nextTick(() => { + ev.emit('connection.update', { connection: 'connecting', receivedPendingNotifications: false }) + }) + + return { + ws, + ev, + authState, + get user () { + return authState.creds.me + }, + assertingPreKeys, + generateMessageTag, + query, + waitForMessage, + waitForSocketOpen, + sendRawMessage, + sendNode, + logout, + end + } +} +export type Socket = ReturnType \ No newline at end of file diff --git a/src/Store/in-memory-store.ts b/src/Store/in-memory-store.ts index 8e4ac32..371d745 100644 --- a/src/Store/in-memory-store.ts +++ b/src/Store/in-memory-store.ts @@ -1,13 +1,13 @@ import type KeyedDB from "@adiwajshing/keyed-db" import type { Comparable } from "@adiwajshing/keyed-db/lib/Types" import type { Logger } from "pino" -import type { Connection } from "../Connection" +import type { Connection } from "../Socket" import type { BaileysEventEmitter, Chat, ConnectionState, Contact, GroupMetadata, MessageInfo, PresenceData, WAMessage, WAMessageCursor, WAMessageKey } from "../Types" import { toNumber } from "../Utils" import makeOrderedDictionary from "./ordered-dictionary" export const waChatKey = (pin: boolean) => ({ - key: (c: Chat) => (pin ? (c.pin ? '1' : '0') : '') + (c.archive === 'true' ? '0' : '1') + c.t.toString(16).padStart(8, '0') + c.jid, + key: (c: Chat) => (pin ? (c.pin ? '1' : '0') : '') + (c.archive ? '0' : '1') + toNumber(c.conversationTimestamp).toString(16).padStart(8, '0') + c.id, compare: (k1: string, k2: string) => k2.localeCompare (k1) }) @@ -30,10 +30,7 @@ export default( const groupMetadata: { [_: string]: GroupMetadata } = { } const messageInfos: { [id: string]: MessageInfo } = { } const presences: { [id: string]: { [participant: string]: PresenceData } } = { } - const state: ConnectionState = { - connection: 'close', - phoneConnected: false - } + const state: ConnectionState = { connection: 'close' } const assertMessageList = (jid: string) => { if(!messages[jid]) messages[jid] = makeMessagesDictionary() @@ -214,7 +211,7 @@ export default( state, presences, listen, - loadMessages: async(jid: string, count: number, cursor: WAMessageCursor, sock: Connection | undefined) => { + /*loadMessages: async(jid: string, count: number, cursor: WAMessageCursor, sock: Connection | undefined) => { const list = assertMessageList(jid) const retrieve = async(count: number, cursor: WAMessageCursor) => { const result = await sock?.fetchMessagesFromWA(jid, count, cursor) @@ -291,6 +288,6 @@ export default( messageInfos[id!] = await sock?.messageInfo(remoteJid, id) } return messageInfos[id!] - } + }*/ } } \ No newline at end of file diff --git a/src/Tests/Common.ts b/src/Tests/Common.ts deleted file mode 100644 index 942f5be..0000000 --- a/src/Tests/Common.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { WAConnection, MessageOptions, MessageType, unixTimestampSeconds, toNumber, GET_MESSAGE_ID, waMessageKey } from '../WAConnection' -import * as assert from 'assert' -import {promises as fs} from 'fs' - -require ('dotenv').config () // dotenv to load test jid -export const testJid = process.env.TEST_JID || '1234@s.whatsapp.net' // set TEST_JID=xyz@s.whatsapp.net in a .env file in the root directory - -export const makeConnection = () => { - const conn = new WAConnection() - conn.connectOptions.maxIdleTimeMs = 15_000 - conn.logger.level = 'debug' - - let evCounts = {} - - conn.on ('close', ({ isReconnecting }) => { - !isReconnecting && console.log ('Events registered: ', evCounts) - }) - - const onM = conn.on - conn.on = (...args: any[]) => { - evCounts[args[0]] = (evCounts[args[0]] || 0) + 1 - return onM.apply (conn, args) - } - const offM = conn.off - conn.off = (...args: any[]) => { - evCounts[args[0]] = (evCounts[args[0]] || 0) - 1 - if (evCounts[args[0]] <= 0) delete evCounts[args[0]] - return offM.apply (conn, args) - } - return conn -} - -export async function sendAndRetrieveMessage(conn: WAConnection, content, type: MessageType, options: MessageOptions = {}, recipientJid = testJid) { - const response = await conn.sendMessage(recipientJid, content, type, options) - const {messages} = await conn.loadMessages(recipientJid, 10) - const message = messages.find (m => m.key.id === response.key.id) - assert.ok(message) - - const chat = conn.chats.get(recipientJid) - - assert.ok (chat.messages.get(GET_MESSAGE_ID(message.key))) - assert.ok (chat.t >= (unixTimestampSeconds()-5) ) - return message -} -export const WAConnectionTest = (name: string, func: (conn: WAConnection) => void) => ( - describe(name, () => { - const conn = new WAConnection() - conn.connectOptions.maxIdleTimeMs = 30_000 - conn.logger.level = 'debug' - - before(async () => { - const file = './auth_info.json' - await conn.loadAuthInfo(file).connect() - await fs.writeFile(file, JSON.stringify(conn.base64EncodedAuthInfo(), null, '\t')) - }) - after(() => conn.close()) - - afterEach (() => assertChatDBIntegrity (conn)) - - func(conn) - }) -) -export const assertChatDBIntegrity = (conn: WAConnection) => { - conn.chats.all ().forEach (chat => ( - assert.deepStrictEqual ( - [...chat.messages.all()].sort ((m1, m2) => waMessageKey.compare(waMessageKey.key(m1), waMessageKey.key(m2))), - chat.messages.all() - ) - )) - conn.chats.all ().forEach (chat => ( - assert.deepStrictEqual ( - chat.messages.all().filter (m => chat.messages.all().filter(m1 => m1.key.id === m.key.id).length > 1), - [] - ) - )) -} diff --git a/src/Tests/Tests.Binary.ts b/src/Tests/Tests.Binary.ts deleted file mode 100644 index f373d61..0000000 --- a/src/Tests/Tests.Binary.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { strict as assert } from 'assert' -import Encoder from '../Binary/Encoder' -import Decoder from '../Binary/Decoder' - -describe('Binary Coding Tests', () => { - const testVectors: [string, Object][] = [ - [ - 'f806092f5a0a10f804f80234fc6c0a350a1b39313735323938373131313740732e77686174736170702e6e657410011a143345423030393637354537454433374141424632122b0a292a7069616e6f20726f6f6d2074696d696e6773206172653a2a0a20363a3030414d2d31323a3030414d18b3faa7f3052003f80234fc4c0a410a1b39313735323938373131313740732e77686174736170702e6e657410001a20304643454335333330463634393239433645394132434646443242433845414418bdfaa7f305c00101f80234fc930a350a1b39313735323938373131313740732e77686174736170702e6e657410011a14334542303033433742353339414644303937353312520a50536f727279206672656e2c204920636f756c646e277420756e6465727374616e6420274c69627261272e2054797065202768656c702720746f206b6e6f77207768617420616c6c20492063616e20646f18c1faa7f3052003f80234fc540a410a1b39313735323938373131313740732e77686174736170702e6e657410001a20413132333042384436423041314437393345433241453245413043313638443812090a076c69627261727918c2faa7f305', - [ - 'action', - { last: 'true', add: 'before' }, - [ - [ - 'message', - null, - { - key: { remoteJid: '917529871117@s.whatsapp.net', fromMe: true, id: '3EB009675E7ED37AABF2' }, - message: { conversation: '*piano room timings are:*\n 6:00AM-12:00AM' }, - messageTimestamp: '1584004403', - status: 'DELIVERY_ACK', - }, - ], - [ - 'message', - null, - { - key: { - remoteJid: '917529871117@s.whatsapp.net', - fromMe: false, - id: '0FCEC5330F64929C6E9A2CFFD2BC8EAD', - }, - messageTimestamp: '1584004413', - messageStubType: 'REVOKE', - }, - ], - [ - 'message', - null, - { - key: { remoteJid: '917529871117@s.whatsapp.net', fromMe: true, id: '3EB003C7B539AFD09753' }, - message: { - conversation: - "Sorry fren, I couldn't understand 'Libra'. Type 'help' to know what all I can do", - }, - messageTimestamp: '1584004417', - status: 'DELIVERY_ACK', - }, - ], - [ - 'message', - null, - { - key: { - remoteJid: '917529871117@s.whatsapp.net', - fromMe: false, - id: 'A1230B8D6B0A1D793EC2AE2EA0C168D8', - }, - message: { conversation: 'library' }, - messageTimestamp: '1584004418', - }, - ], - ], - ], - ], - [ - 'f8063f2dfafc0831323334353637385027fc0431323334f801f80228fc0701020304050607', - [ - 'picture', - {jid: '12345678@c.us', id: '1234'}, - [['image', null, Buffer.from([1,2,3,4,5,6,7])]] - ] - ] - ] - const encoder = new Encoder() - const decoder = new Decoder() - - it('should decode strings', () => { - testVectors.forEach(pair => { - const buff = Buffer.from(pair[0], 'hex') - const decoded = decoder.read(buff) - //console.log((decoded[2][0][2])) - assert.deepStrictEqual(decoded, pair[1]) - - const encoded = encoder.write(decoded) - assert.deepStrictEqual(encoded, buff) - }) - console.log('all coding tests passed') - }) -}) diff --git a/src/Tests/Tests.Connect.ts b/src/Tests/Tests.Connect.ts deleted file mode 100644 index 2608ffb..0000000 --- a/src/Tests/Tests.Connect.ts +++ /dev/null @@ -1,407 +0,0 @@ -import * as assert from 'assert' -import {WAConnection} from '../WAConnection' -import { AuthenticationCredentialsBase64, BaileysError, ReconnectMode, DisconnectReason, WAChat, WAContact } from '../WAConnection/Constants' -import { delay } from '../WAConnection/Utils' -import { assertChatDBIntegrity, makeConnection, testJid } from './Common' - -describe('QR Generation', () => { - it('should generate QR', async () => { - const conn = makeConnection () - conn.connectOptions.maxRetries = 0 - - let calledQR = 0 - conn.removeAllListeners ('qr') - conn.on ('qr', () => calledQR += 1) - - await conn.connect() - .then (() => assert.fail('should not have succeeded')) - .catch (error => {}) - assert.deepStrictEqual ( - Object.keys(conn.eventNames()).filter(key => key.startsWith('TAG:')), - [] - ) - assert.ok(calledQR >= 2, 'QR not called') - }) -}) - -describe('Test Connect', () => { - let auth: AuthenticationCredentialsBase64 - it('should connect', async () => { - console.log('please be ready to scan with your phone') - - const conn = makeConnection () - - let credentialsUpdateCalled = false - conn.on ('credentials-updated', () => credentialsUpdateCalled = true) - - await conn.connect () - assert.ok(conn.user?.jid) - assert.ok(conn.user?.phone) - assert.ok (conn.user?.imgUrl || conn.user.imgUrl === '') - assert.ok (credentialsUpdateCalled) - - assertChatDBIntegrity (conn) - - conn.close() - auth = conn.base64EncodedAuthInfo() - }) - it('should restore session', async () => { - const conn = makeConnection () - - let credentialsUpdateCalled = false - conn.on ('credentials-updated', () => credentialsUpdateCalled = true) - - await conn.loadAuthInfo (auth).connect () - assert.ok(conn.user) - assert.ok(conn.user.jid) - assert.ok (credentialsUpdateCalled) - - assertChatDBIntegrity (conn) - await conn.logout() - conn.loadAuthInfo(auth) - - await conn.connect() - .then (() => assert.fail('should not have reconnected')) - .catch (err => { - assert.ok (err instanceof BaileysError) - assert.ok ((err as BaileysError).status >= 400) - }) - conn.close() - }) - it ('should disconnect & reconnect phone', async () => { - const conn = makeConnection () - conn.logger.level = 'debug' - await conn.loadAuthInfo('./auth_info.json').connect () - assert.strictEqual (conn.phoneConnected, true) - - try { - const waitForEvent = expect => new Promise (resolve => { - conn.on ('connection-phone-change', ({connected}) => { - if (connected === expect) { - conn.removeAllListeners ('connection-phone-change') - resolve(undefined) - } - }) - }) - - console.log ('disconnect your phone from the internet') - await delay (10_000) - console.log ('phone should be disconnected now, testing...') - - const messagesPromise = Promise.all ( - [ - conn.loadMessages (testJid, 50), - conn.getStatus (testJid), - conn.getProfilePicture (testJid).catch (() => '') - ] - ) - - await waitForEvent (false) - - console.log ('reconnect your phone to the internet') - await waitForEvent (true) - - console.log ('reconnected successfully') - - const final = await messagesPromise - assert.ok (final) - } finally { - conn.close () - } - }) -}) -describe ('Reconnects', () => { - const verifyConnectionOpen = async (conn: WAConnection) => { - assert.ok (conn.user.jid) - let failed = false - // check that the connection stays open - conn.on ('close', ({reason}) => { - if(reason !== DisconnectReason.intentional) failed = true - }) - await delay (60*1000) - - const status = await conn.getStatus () - assert.ok (status) - assert.ok (!conn['debounceTimeout']) // this should be null - - conn.close () - - if (failed) assert.fail ('should not have closed again') - } - it('should dispose correctly on bad_session', async () => { - const conn = makeConnection () - conn.autoReconnect = ReconnectMode.onAllErrors - conn.loadAuthInfo ('./auth_info.json') - - let gotClose0 = false - let gotClose1 = false - - conn.on ('ws-close', ({ reason }) => { - gotClose0 = true - }) - conn.on ('close', ({ reason }) => { - if (reason === DisconnectReason.badSession) gotClose1 = true - }) - setTimeout (() => conn['conn'].emit ('message', Buffer.from('some-tag,sdjjij1jo2ejo1je')), 1500) - await conn.connect () - - setTimeout (() => conn['conn'].emit ('message', Buffer.from('some-tag,sdjjij1jo2ejo1je')), 1500) - - await new Promise (resolve => { - conn.on ('open', resolve) - }) - - assert.ok (gotClose0, 'did not receive bad_session close initially') - assert.ok (gotClose1, 'did not receive bad_session close') - - conn.close () - }) - /** - * the idea is to test closing the connection at multiple points in the connection - * and see if the library cleans up resources correctly - */ - it('should cleanup correctly', async () => { - const conn = makeConnection () - conn.autoReconnect = ReconnectMode.onAllErrors - conn.loadAuthInfo ('./auth_info.json') - - let timeout = 0.1 - while (true) { - let tmout = setTimeout (() => conn.close(), timeout*1000) - try { - await conn.connect () - clearTimeout (tmout) - break - } catch (error) { - - } - // exponentially increase the timeout disconnect - timeout *= 2 - } - await verifyConnectionOpen (conn) - }) - /** - * the idea is to test closing the connection at multiple points in the connection - * and see if the library cleans up resources correctly - */ - it('should disrupt connect loop', async () => { - const conn = makeConnection () - - conn.autoReconnect = ReconnectMode.onAllErrors - conn.loadAuthInfo ('./auth_info.json') - - let timeout = 1000 - let tmout - const endConnection = async () => { - while (!conn['conn']) { - await delay(100) - } - conn['conn'].close () - - while (conn['conn']) { - await delay(100) - } - - timeout *= 2 - tmout = setTimeout (endConnection, timeout) - } - tmout = setTimeout (endConnection, timeout) - - await conn.connect () - clearTimeout (tmout) - - await verifyConnectionOpen (conn) - }) - it ('should reconnect on broken connection', async () => { - const conn = makeConnection () - conn.autoReconnect = ReconnectMode.onConnectionLost - - await conn.loadAuthInfo('./auth_info.json').connect () - assert.strictEqual (conn.phoneConnected, true) - - try { - const closeConn = () => conn['conn']?.terminate () - - const task = new Promise (resolve => { - let closes = 0 - conn.on ('close', ({reason, isReconnecting}) => { - console.log (`closed: ${reason}`) - assert.ok (reason) - assert.ok (isReconnecting) - closes += 1 - - // let it fail reconnect a few times - if (closes >= 1) { - conn.removeAllListeners ('close') - conn.removeAllListeners ('connecting') - resolve(undefined) - } - }) - conn.on ('connecting', () => { - // close again - delay (3500).then (closeConn) - }) - }) - - closeConn () - await task - - await new Promise (resolve => { - conn.on ('open', () => { - conn.removeAllListeners ('open') - resolve(undefined) - }) - }) - - conn.close () - - conn.on ('connecting', () => assert.fail('should not connect')) - await delay (2000) - } finally { - conn.removeAllListeners ('connecting') - conn.removeAllListeners ('close') - conn.removeAllListeners ('open') - conn.close () - } - }) - it ('should reconnect & stay connected', async () => { - const conn = makeConnection () - conn.autoReconnect = ReconnectMode.onConnectionLost - - await conn.loadAuthInfo('./auth_info.json').connect () - assert.strictEqual (conn.phoneConnected, true) - - await delay (30*1000) - - conn['conn']?.terminate () - - conn.on ('close', () => { - assert.ok (!conn['lastSeen']) - console.log ('connection closed') - }) - await new Promise (resolve => conn.on ('open', resolve)) - await verifyConnectionOpen (conn) - }) -}) - -describe ('Pending Requests', () => { - it ('should correctly send updates for chats', async () => { - const conn = makeConnection () - conn.pendingRequestTimeoutMs = null - conn.loadAuthInfo('./auth_info.json') - - const task = new Promise(resolve => conn.once('chats-received', resolve)) - await conn.connect () - await task - - conn.close () - - const oldChat = conn.chats.all()[0] - oldChat.archive = 'true' // mark the first chat as archived - oldChat.modify_tag = '1234' // change modify tag to detect change - - const promise = new Promise(resolve => conn.once('chats-update', resolve)) - - const result = await conn.connect () - assert.ok (!result.newConnection) - - const chats = await promise as Partial[] - const chat = chats.find (c => c.jid === oldChat.jid) - assert.ok (chat) - - assert.ok ('archive' in chat) - assert.strictEqual (Object.keys(chat).length, 3) - assert.strictEqual (Object.keys(chats).length, 1) - - conn.close () - }) - it ('should correctly send updates for contacts', async () => { - const conn = makeConnection () - conn.pendingRequestTimeoutMs = null - conn.loadAuthInfo('./auth_info.json') - - const task: any = new Promise(resolve => conn.once('contacts-received', resolve)) - await conn.connect () - const initialResult = await task - assert.strictEqual( - initialResult.updatedContacts.length, - Object.keys(conn.contacts).length - ) - - - conn.close () - - const [jid] = Object.keys(conn.contacts) - const oldContact = conn.contacts[jid] - oldContact.name = 'Lol' - oldContact.index = 'L' - - const promise = new Promise(resolve => conn.once('contacts-received', resolve)) - - const result = await conn.connect () - assert.ok (!result.newConnection) - - const {updatedContacts} = await promise as { updatedContacts: Partial[] } - const contact = updatedContacts.find (c => c.jid === jid) - assert.ok (contact) - - assert.ok ('name' in contact) - assert.strictEqual (Object.keys(contact).length, 3) - assert.strictEqual (Object.keys(updatedContacts).length, 1) - - conn.close () - }) - it('should queue requests when closed', async () => { - const conn = makeConnection () - //conn.pendingRequestTimeoutMs = null - - await conn.loadAuthInfo('./auth_info.json').connect () - - await delay (2000) - - conn.close () - - const task: Promise = conn.query({json: ['query', 'Status', conn.user.jid]}) - - await delay (2000) - - conn.connect () - const json = await task - - assert.ok (json.status) - - conn.close () - }) - it('[MANUAL] should receive query response after phone disconnect', async () => { - const conn = makeConnection () - await conn.loadAuthInfo('./auth_info.json').connect () - - console.log(`disconnect your phone from the internet!`) - await delay(5000) - const task = conn.loadMessages(testJid, 50) - setTimeout(() => console.log('reconnect your phone!'), 20_000) - - const result = await task - assert.ok(result.messages[0]) - assert.ok(!conn['phoneCheckInterval']) // should be undefined - - conn.close () - }) - it('should re-execute query on connection closed error', async () => { - const conn = makeConnection () - //conn.pendingRequestTimeoutMs = 10_000 - await conn.loadAuthInfo('./auth_info.json').connect () - const task: Promise = conn.query({json: ['query', 'Status', conn.user.jid], waitForOpen: true}) - - await delay(20) - conn['onMessageRecieved']('1234,["Pong",false]') // fake cancel the connection - - await delay(2000) - - const json = await task - - assert.ok (json.status) - - conn.close () - }) -}) \ No newline at end of file diff --git a/src/Tests/Tests.Groups.ts b/src/Tests/Tests.Groups.ts deleted file mode 100644 index 6e2339a..0000000 --- a/src/Tests/Tests.Groups.ts +++ /dev/null @@ -1,193 +0,0 @@ -import { MessageType, GroupSettingChange, delay, ChatModification, whatsappID } from '../WAConnection' -import * as assert from 'assert' -import { WAConnectionTest, testJid, sendAndRetrieveMessage } from './Common' - -WAConnectionTest('Groups', (conn) => { - let gid: string - it('should create a group', async () => { - const response = await conn.groupCreate('Cool Test Group', [testJid]) - assert.ok (conn.chats.get(response.gid)) - - const {chats} = await conn.loadChats(10, null) - assert.strictEqual (chats[0].jid, response.gid) // first chat should be new group - - gid = response.gid - - console.log('created group: ' + JSON.stringify(response)) - }) - it('should retrieve group invite code', async () => { - const code = await conn.groupInviteCode(gid) - assert.ok(code) - assert.strictEqual(typeof code, 'string') - }) - it('should joined group via invite code', async () => { - const response = await conn.acceptInvite(gid) - assert.ok(response.status) - assert.strictEqual(response.status, response.gid) - }) - it('should retrieve group metadata', async () => { - const metadata = await conn.groupMetadata(gid) - assert.strictEqual(metadata.id, gid) - assert.strictEqual(metadata.participants.filter((obj) => obj.jid.split('@')[0] === testJid.split('@')[0]).length, 1) - assert.ok(conn.chats.get(gid)) - assert.ok(conn.chats.get(gid).metadata) - }) - it('should update the group description', async () => { - const newDesc = 'Wow this was set from Baileys' - - const waitForEvent = new Promise (resolve => ( - conn.once ('group-update', ({jid, desc}) => { - if (jid === gid && desc) { - assert.strictEqual(desc, newDesc) - assert.strictEqual( - conn.chats.get(jid).metadata.desc, - newDesc - ) - resolve(undefined) - } - }) - )) - await conn.groupUpdateDescription (gid, newDesc) - await waitForEvent - - const metadata = await conn.groupMetadata(gid) - assert.strictEqual(metadata.desc, newDesc) - }) - it('should send a message on the group', async () => { - await sendAndRetrieveMessage(conn, 'Hello!', MessageType.text, {}, gid) - }) - it('should delete a message on the group', async () => { - const message = await sendAndRetrieveMessage(conn, 'Hello!', MessageType.text, {}, gid) - await delay(1500) - await conn.deleteMessage(message.key) - }) - it('should quote a message on the group', async () => { - const {messages} = await conn.loadMessages (gid, 100) - const quotableMessage = messages.find (m => m.message) - assert.ok (quotableMessage, 'need at least one message') - - const response = await conn.sendMessage(gid, 'hello', MessageType.extendedText, {quoted: quotableMessage}) - const loaded = await conn.loadMessages(gid, 10) - const message = loaded.messages.find (m => m.key.id === response.key.id)?.message?.extendedTextMessage - assert.ok(message) - assert.strictEqual (message.contextInfo.stanzaId, quotableMessage.key.id) - }) - it('should update the subject', async () => { - const subject = 'Baileyz ' + Math.floor(Math.random()*5) - const waitForEvent = new Promise (resolve => { - conn.once ('chat-update', ({jid, name}) => { - if (jid === gid) { - assert.strictEqual(name, subject) - assert.strictEqual(conn.chats.get(jid).name, subject) - resolve(undefined) - } - }) - }) - await conn.groupUpdateSubject(gid, subject) - await waitForEvent - - const metadata = await conn.groupMetadata(gid) - assert.strictEqual(metadata.subject, subject) - }) - - it('should update the group settings', async () => { - const waitForEvent = new Promise (resolve => { - conn.once ('group-update', ({jid, announce}) => { - if (jid === gid) { - assert.strictEqual (announce, 'true') - assert.strictEqual(conn.chats.get(gid).metadata.announce, announce) - resolve(undefined) - } - }) - }) - await conn.groupSettingChange (gid, GroupSettingChange.messageSend, true) - - await waitForEvent - conn.removeAllListeners ('group-update') - - await delay (2000) - await conn.groupSettingChange (gid, GroupSettingChange.settingsChange, true) - }) - - it('should promote someone', async () => { - const waitForEvent = new Promise (resolve => { - conn.once ('group-participants-update', ({ jid, action, participants }) => { - if (jid === gid) { - assert.strictEqual (action, 'promote') - console.log(participants) - console.log(conn.chats.get(jid).metadata) - assert.ok( - conn.chats.get(jid).metadata.participants.find(({ jid, isAdmin }) => ( - whatsappID(jid) === whatsappID(participants[0]) && isAdmin - )), - ) - resolve(undefined) - } - - }) - }) - await conn.groupMakeAdmin(gid, [ testJid ]) - await waitForEvent - }) - - it('should remove someone from a group', async () => { - const metadata = await conn.groupMetadata (gid) - if (metadata.participants.find(({jid}) => whatsappID(jid) === testJid)) { - const waitForEvent = new Promise (resolve => { - conn.once ('group-participants-update', ({jid, participants, action}) => { - if (jid === gid) { - assert.strictEqual (participants[0], testJid) - assert.strictEqual (action, 'remove') - assert.deepStrictEqual( - conn.chats.get(jid).metadata.participants.find(p => whatsappID(p.jid) === whatsappID(participants[0])), - undefined - ) - resolve(undefined) - } - }) - }) - - await conn.groupRemove(gid, [testJid]) - await waitForEvent - } else console.log(`could not find testJid`) - }) - - it('should leave the group', async () => { - const waitForEvent = new Promise (resolve => { - conn.once ('chat-update', ({jid, read_only}) => { - if (jid === gid) { - assert.strictEqual (read_only, 'true') - resolve(undefined) - } - }) - }) - await conn.groupLeave(gid) - await waitForEvent - - await conn.groupMetadataMinimal (gid) - }) - it('should archive the group', async () => { - const waitForEvent = new Promise (resolve => { - conn.once ('chat-update', ({jid, archive}) => { - if (jid === gid) { - assert.strictEqual (archive, 'true') - resolve(undefined) - } - }) - }) - await conn.modifyChat(gid, ChatModification.archive) - await waitForEvent - }) - it('should delete the group', async () => { - const waitForEvent = new Promise (resolve => { - conn.once ('chat-update', (chat) => { - if (chat.jid === gid) { - assert.strictEqual (chat['delete'], 'true') - resolve(undefined) - } - }) - }) - await conn.modifyChat(gid, 'delete') - await waitForEvent - }) -}) diff --git a/src/Tests/Tests.Media.ts b/src/Tests/Tests.Media.ts deleted file mode 100644 index 6960438..0000000 --- a/src/Tests/Tests.Media.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { deepStrictEqual, strictEqual } from 'assert' -import { createWriteStream } from 'fs' -import { readFile } from 'fs/promises' -import { proto } from '../../WAMessage' -import { MessageType } from '../WAConnection' -import { aesEncrypWithIV, decryptMediaMessageBuffer, encryptedStream, getMediaKeys, getStream, hmacSign, sha256 } from '../WAConnection/Utils' -import { WAConnectionTest } from './Common' - -describe('Media Download Tests', () => { - - it('should encrypt media streams correctly', async function() { - const url = './Media/meme.jpeg' - const streamValues = await encryptedStream({ url }, MessageType.image) - - const buffer = await readFile(url) - const mediaKeys = getMediaKeys(streamValues.mediaKey, MessageType.image) - - const enc = aesEncrypWithIV(buffer, mediaKeys.cipherKey, mediaKeys.iv) - const mac = hmacSign(Buffer.concat([mediaKeys.iv, enc]), mediaKeys.macKey).slice(0, 10) - const body = Buffer.concat([enc, mac]) // body is enc + mac - const fileSha256 = sha256(buffer) - const fileEncSha256 = sha256(body) - - deepStrictEqual(streamValues.fileSha256, fileSha256) - strictEqual(streamValues.fileLength, buffer.length) - deepStrictEqual(streamValues.mac, mac) - deepStrictEqual(await readFile(streamValues.encBodyPath), body) - deepStrictEqual(streamValues.fileEncSha256, fileEncSha256) - - }) -}) -/* -WAConnectionTest('Media Upload', conn => { - - it('should upload the same file', async () => { - const FILES = [ - { url: './Media/meme.jpeg', type: MessageType.image }, - { url: './Media/ma_gif.mp4', type: MessageType.video }, - { url: './Media/sonata.mp3', type: MessageType.audio }, - ] - }) - -})*/ \ No newline at end of file diff --git a/src/Tests/Tests.Messages.ts b/src/Tests/Tests.Messages.ts deleted file mode 100644 index f271a0f..0000000 --- a/src/Tests/Tests.Messages.ts +++ /dev/null @@ -1,268 +0,0 @@ -import { MessageType, Mimetype, delay, promiseTimeout, WA_MESSAGE_STATUS_TYPE, generateMessageID, WAMessage } from '../WAConnection' -import { promises as fs } from 'fs' -import * as assert from 'assert' -import { WAConnectionTest, testJid, sendAndRetrieveMessage } from './Common' - -WAConnectionTest('Messages', conn => { - - it('should send a text message', async () => { - const message = await sendAndRetrieveMessage(conn, 'hello fren', MessageType.text) - assert.strictEqual(message.message.conversation || message.message.extendedTextMessage?.text, 'hello fren') - }) - it('should send a pending message', async () => { - const message = await sendAndRetrieveMessage(conn, 'hello fren', MessageType.text, { waitForAck: false }) - - await new Promise(resolve => conn.on('chat-update', update => { - if (update.jid === testJid && - update.messages && - update.messages.first.key.id === message.key.id && - update.messages.first.status === WA_MESSAGE_STATUS_TYPE.SERVER_ACK) { - resolve(undefined) - } - })) - - }) - it('should forward a message', async () => { - let {messages} = await conn.loadMessages (testJid, 1) - await conn.forwardMessage (testJid, messages[0], true) - - messages = (await conn.loadMessages (testJid, 1)).messages - const message = messages.slice (-1)[0] - const content = message.message[ Object.keys(message.message)[0] ] - assert.strictEqual (content?.contextInfo?.isForwarded, true) - }) - it('should send a link preview', async () => { - const text = 'hello this is from https://www.github.com/adiwajshing/Baileys' - const message = await sendAndRetrieveMessage(conn, text, MessageType.text, { detectLinks: true }) - const received = message.message.extendedTextMessage - - assert.strictEqual(received.text, text) - assert.ok (received.canonicalUrl) - assert.ok (received.title) - assert.ok (received.description) - }) - it('should quote a message', async () => { - const quoted = (await conn.loadMessages(testJid, 2)).messages[0] - const message = await sendAndRetrieveMessage(conn, 'hello fren 2', MessageType.extendedText, { quoted }) - assert.strictEqual( - message.message.extendedTextMessage.contextInfo.stanzaId, - quoted.key.id - ) - assert.strictEqual( - message.message.extendedTextMessage.contextInfo.participant, - quoted.key.fromMe ? conn.user.jid : quoted.key.id - ) - }) - it('should upload media successfully', async () => { - const content = await fs.readFile('./Media/sonata.mp3') - // run 10 uploads - for (let i = 0; i < 10;i++) { - await conn.prepareMessageContent (content, MessageType.audio, { filename: 'audio.mp3', mimetype: Mimetype.mp4Audio }) - } - }) - it('should send a gif', async () => { - const message = await sendAndRetrieveMessage(conn, { url: './Media/ma_gif.mp4' }, MessageType.video, { mimetype: Mimetype.gif }) - - await conn.downloadAndSaveMediaMessage(message,'./Media/received_vid') - }) - it('should send an audio', async () => { - const content = await fs.readFile('./Media/sonata.mp3') - const message = await sendAndRetrieveMessage(conn, content, MessageType.audio, { mimetype: Mimetype.mp4Audio }) - // check duration was okay - assert.ok (message.message.audioMessage.seconds > 0) - await conn.downloadAndSaveMediaMessage(message,'./Media/received_aud') - }) - it('should send an audio as a voice note', async () => { - const content = await fs.readFile('./Media/sonata.mp3') - const message = await sendAndRetrieveMessage(conn, content, MessageType.audio, { mimetype: Mimetype.mp4Audio, ptt: true }) - - assert.ok (message.message.audioMessage.seconds > 0) - assert.strictEqual (message.message?.audioMessage?.ptt, true) - await conn.downloadAndSaveMediaMessage(message,'./Media/received_aud') - }) - it('should send a jpeg image', async () => { - const message = await sendAndRetrieveMessage(conn, { url: './Media/meme.jpeg' }, MessageType.image) - assert.ok(message.message.imageMessage.jpegThumbnail.length > 0) - const msg = await conn.downloadMediaMessage(message) - assert.deepStrictEqual(msg, await fs.readFile('./Media/meme.jpeg')) - }) - it('should send a remote jpeg image', async () => { - const message = await sendAndRetrieveMessage( - conn, - { url: 'https://www.memestemplates.com/wp-content/uploads/2020/05/tom-with-phone.jpg' }, - MessageType.image - ) - assert.ok (message.message?.imageMessage?.jpegThumbnail) - await conn.downloadMediaMessage(message) - }) - it('should send a png image', async () => { - const content = await fs.readFile('./Media/icon.png') - const message = await sendAndRetrieveMessage(conn, content, MessageType.image, { mimetype: 'image/png' }) - assert.ok (message.message?.imageMessage?.jpegThumbnail) - await conn.downloadMediaMessage(message) - }) - it('should send a sticker', async () => { - const content = await fs.readFile('./Media/octopus.webp') - const message = await sendAndRetrieveMessage(conn, content, MessageType.sticker) - - await conn.downloadMediaMessage(message) - }) - /*it('should send an interactive message', async () => { - - console.log ( - JSON.stringify(await conn.loadMessages (testJid, 5), null, '\t') - ) - const message = conn.prepareMessageFromContent ( - testJid, - { - templateMessage: { - fourRowTemplate: { - content: { - namespace: 'my-namespace', - localizableParams: [ - - ], - params: ['hello!'] - }, - buttons: [ - { - index: 0, - quickReplyButton: { - displayText: { - params: ['my name jeff'] - } - } - }, - { - index: 1, - quickReplyButton: { - displayText: { - params: ['my name NOT jeff'], - } - } - } - ] - } - } - }, - {} - ) - await conn.relayWAMessage (message) - })*/ - it('should send an image & quote', async () => { - const quoted = (await conn.loadMessages(testJid, 2)).messages[0] - const content = await fs.readFile('./Media/meme.jpeg') - const message = await sendAndRetrieveMessage(conn, content, MessageType.image, { quoted }) - - await conn.downloadMediaMessage(message) // check for successful decoding - assert.strictEqual(message.message.imageMessage.contextInfo.stanzaId, quoted.key.id) - }) - it('should send a message & delete it', async () => { - const message = await sendAndRetrieveMessage(conn, 'hello fren', MessageType.text) - await delay (2000) - await conn.deleteMessage (testJid, message.key) - }) - it('should clear the most recent message', async () => { - const {messages} = await conn.loadMessages (testJid, 1) - await delay (2000) - await conn.clearMessage (messages[0].key) - }) - it('should send media after close', async () => { - const content = await fs.readFile('./Media/octopus.webp') - await sendAndRetrieveMessage(conn, content, MessageType.sticker) - - conn.close () - - await conn.connect () - - const content2 = await fs.readFile('./Media/cat.jpeg') - await sendAndRetrieveMessage(conn, content2, MessageType.image) - }) - it('should fail to send a text message', async () => { - const JID = '1234-1234@g.us' - const messageId = generateMessageID() - conn.sendMessage(JID, 'hello', MessageType.text, { messageId }) - - await new Promise(resolve => ( - conn.on ('chat-update', async update => { - console.log(messageId, update.messages?.first) - if ( - update.jid === JID && - update.messages?.first.key.id === messageId && - update.messages.first.status === WA_MESSAGE_STATUS_TYPE.ERROR) { - resolve(undefined) - } - }) - )) - conn.removeAllListeners('chat-update') - }) - it('should maintain message integrity', async () => { - // loading twice does not alter the results - const results = await Promise.all ([ - conn.loadMessages (testJid, 50), - conn.loadMessages (testJid, 50) - ]) - assert.strictEqual (results[0].messages.length, results[1].messages.length) - for (let i = 0; i < results[1].messages.length;i++) { - assert.deepStrictEqual ( - results[0].messages[i].key, - results[1].messages[i].key, - `failed equal at ${i}` - ) - } - assert.ok (results[0].messages.length <= 50) - - // check if messages match server - let msgs = await conn.fetchMessagesFromWA (testJid, 50) - for (let i = 0; i < results[1].messages.length;i++) { - assert.deepStrictEqual ( - results[0].messages[i].key, - msgs[i].key, - `failed equal at ${i}` - ) - } - // check with some arbitary cursors - let cursor = results[0].messages.slice(-1)[0].key - - msgs = await conn.fetchMessagesFromWA (testJid, 20, cursor) - let {messages} = await conn.loadMessages (testJid, 20, cursor) - for (let i = 0; i < messages.length;i++) { - assert.deepStrictEqual ( - messages[i].key, - msgs[i].key, - `failed equal at ${i}` - ) - } - for (let i = 0; i < 3;i++) { - cursor = results[0].messages[i].key - - msgs = await conn.fetchMessagesFromWA (testJid, 20, cursor) - messages = (await conn.loadMessages (testJid, 20, cursor)).messages - for (let i = 0; i < messages.length;i++) { - assert.deepStrictEqual (messages[i].key, msgs[i].key, `failed equal at ${i}`) - } - - cursor = msgs[0].key - - msgs = await conn.fetchMessagesFromWA (testJid, 20, cursor) - messages = (await conn.loadMessages (testJid, 20, cursor)).messages - for (let i = 0; i < messages.length;i++) { - assert.deepStrictEqual (messages[i].key, msgs[i].key, `failed equal at ${i}`) - } - } - }) - it('should deliver a message', async () => { - const response = await conn.sendMessage(testJid, 'My Name Jeff', MessageType.text) - const waitForUpdate = - promiseTimeout(15000, resolve => { - conn.on('chat-update', update => { - if (update.messages?.first.key.id === response.key.id) { - resolve(update.messages.first) - } - }) - }) as Promise - - const m = await waitForUpdate - assert.ok (m.status >= WA_MESSAGE_STATUS_TYPE.DELIVERY_ACK) - }) -}) diff --git a/src/Tests/Tests.Misc.ts b/src/Tests/Tests.Misc.ts deleted file mode 100644 index 8b09bc6..0000000 --- a/src/Tests/Tests.Misc.ts +++ /dev/null @@ -1,430 +0,0 @@ -import { Presence, ChatModification, delay, newMessagesDB, WA_DEFAULT_EPHEMERAL, MessageType, WAMessage } from '../WAConnection' -import { promises as fs } from 'fs' -import * as assert from 'assert' -import got from 'got' -import { WAConnectionTest, testJid, sendAndRetrieveMessage } from './Common' - -WAConnectionTest('Misc', conn => { - - it('should tell if someone has an account on WhatsApp', async () => { - const response = await conn.isOnWhatsApp(testJid) - assert.strictEqual(response, true) - - const responseFail = await conn.isOnWhatsApp('abcd@s.whatsapp.net') - assert.strictEqual(responseFail, false) - }) - it('should return the status', async () => { - const response = await conn.getStatus(testJid) - assert.strictEqual(typeof response.status, 'string') - }) - it('should update status', async () => { - const newStatus = 'v cool status' - - const waitForEvent = new Promise (resolve => { - conn.on ('contact-update', ({jid, status}) => { - if (jid === conn.user.jid) { - assert.strictEqual (status, newStatus) - conn.removeAllListeners ('contact-update') - resolve(undefined) - } - }) - }) - - const response = await conn.getStatus() - assert.strictEqual(typeof response.status, 'string') - - await delay (1000) - - await conn.setStatus (newStatus) - const response2 = await conn.getStatus() - assert.strictEqual (response2.status, newStatus) - - await waitForEvent - - await delay (1000) - - await conn.setStatus (response.status) // update back - }) - it('should update profile name', async () => { - const newName = 'v cool name' - - await delay (1000) - - const originalName = conn.user.name! - - const waitForEvent = new Promise (resolve => { - conn.on ('contact-update', ({name}) => { - assert.strictEqual (name, newName) - conn.removeAllListeners ('contact-update') - resolve () - }) - }) - - await conn.updateProfileName (newName) - - await waitForEvent - - await delay (1000) - - assert.strictEqual (conn.user.name, newName) - - await delay (1000) - - await conn.updateProfileName (originalName) // update back - }) - it('should return the stories', async () => { - await conn.getStories() - }) - - it('should return the profile picture correctly', async () => { - // wait for chats - await new Promise(resolve => ( - conn.once('initial-data-received', resolve) - )) - const pictures = await Promise.all( - conn.chats.all().slice(0, 15).map(({ jid }) => ( - conn.getProfilePicture(jid) - .catch(err => '') - )) - ) - // pictures should return correctly - const truePictures = pictures.filter(pp => !!pp) - assert.strictEqual( - new Set(truePictures).size, - truePictures.length - ) - }) - - it('should change the profile picture', async () => { - await delay (5000) - - const ppUrl = await conn.getProfilePicture(conn.user.jid) - const {rawBody: oldPP} = await got(ppUrl) - - const newPP = await fs.readFile('./Media/cat.jpeg') - await conn.updateProfilePicture(conn.user.jid, newPP) - - await delay (10000) - - await conn.updateProfilePicture (conn.user.jid, oldPP) // revert back - }) - it('should send typing indicator', async () => { - const response = await conn.updatePresence(testJid, Presence.composing) - assert.ok(response) - }) - it('should change a chat read status', async () => { - const jids = conn.chats.all ().map (c => c.jid) - for (let jid of jids.slice(0, 5)) { - console.log (`changing read status for ${jid}`) - const waitForEvent = new Promise (resolve => { - conn.once ('chat-update', ({jid: tJid, count}) => { - if (jid === tJid) { - assert.ok (count < 0) - resolve(undefined) - } - }) - }) - await conn.chatRead (jid, 'unread') - await waitForEvent - - await delay (5000) - - await conn.chatRead (jid, 'read') - } - }) - it('should archive & unarchive', async () => { - // wait for chats - await new Promise(resolve => ( - conn.once('chats-received', ({ }) => resolve(undefined)) - )) - - const idx = conn.chats.all().findIndex(chat => chat.jid === testJid) - await conn.modifyChat (testJid, ChatModification.archive) - const idx2 = conn.chats.all().findIndex(chat => chat.jid === testJid) - assert.ok(idx < idx2) // should move further down the array - - await delay (2000) - await conn.modifyChat (testJid, ChatModification.unarchive) - const idx3 = conn.chats.all().findIndex(chat => chat.jid === testJid) - assert.strictEqual(idx, idx3) // should be back there - }) - it('should archive & unarchive on new message', async () => { - // wait for chats - await new Promise(resolve => ( - conn.once('chats-received', ({ }) => resolve(undefined)) - )) - - const idx = conn.chats.all().findIndex(chat => chat.jid === testJid) - await conn.modifyChat (testJid, ChatModification.archive) - const idx2 = conn.chats.all().findIndex(chat => chat.jid === testJid) - assert.ok(idx < idx2) // should move further down the array - - await delay (2000) - await sendAndRetrieveMessage(conn, 'test', MessageType.text) - // should be unarchived - const idx3 = conn.chats.all().findIndex(chat => chat.jid === testJid) - assert.strictEqual(idx, idx3) // should be back there - }) - it('should pin & unpin a chat', async () => { - await conn.modifyChat (testJid, ChatModification.pin) - await delay (2000) - await conn.modifyChat (testJid, ChatModification.unpin) - }) - it('should mute & unmute a chat', async () => { - const waitForEvent = new Promise (resolve => { - conn.on ('chat-update', ({jid, mute}) => { - if (jid === testJid ) { - assert.ok (mute) - conn.removeAllListeners ('chat-update') - resolve(undefined) - } - }) - }) - await conn.modifyChat (testJid, ChatModification.mute, 8*60*60*1000) // 8 hours in the future - await waitForEvent - await delay (2000) - await conn.modifyChat (testJid, ChatModification.unmute) - }) - it('should star/unstar messages', async () => { - for (let i = 1; i <= 5; i++) { - await conn.sendMessage(testJid, `Message ${i}`, MessageType.text) - await delay(1000) - } - - let response = await conn.loadMessages(testJid, 5) - let starred = response.messages.filter(m => m.starred) - assert.strictEqual(starred.length, 0) - - conn.starMessage(response.messages[2].key) - await delay(2000) - conn.starMessage(response.messages[4].key) - await delay(2000) - - response = await conn.loadMessages(testJid, 5) - starred = response.messages.filter(m => m.starred) - assert.strictEqual(starred.length, 2) - await delay(2000) - - conn.starMessage(response.messages[2].key, 'unstar') - await delay(2000) - - response = await conn.loadMessages(testJid, 5) - starred = response.messages.filter(m => m.starred) - assert.strictEqual(starred.length, 1) - }) - it('should clear a chat', async () => { - // Uses chat with yourself to avoid losing chats - const selfJid = conn.user.jid - - for (let i = 1; i <= 5; i++) { - await conn.sendMessage(selfJid, `Message ${i}`, MessageType.text) - await delay(1000) - } - - let response = await conn.loadMessages(selfJid, 50) - const initialCount = response.messages.length - - assert.ok(response.messages.length >= 0) - - conn.starMessage(response.messages[2].key) - await delay(2000) - conn.starMessage(response.messages[4].key) - await delay(2000) - - await conn.modifyChat(selfJid, ChatModification.clear) - await delay(2000) - - response = await conn.loadMessages(selfJid, 50) - await delay(2000) - assert.ok(response.messages.length < initialCount) - assert.ok(response.messages.length > 1) - - await conn.modifyChat(selfJid, ChatModification.clear, true) - await delay(2000) - - response = await conn.loadMessages(selfJid, 50) - assert.strictEqual(response.messages.length, 1) - }) - it('should return search results', async () => { - const jids = [null, testJid] - for (let i in jids) { - let response = await conn.searchMessages('Hello', jids[i], 25, 1) - assert.ok (response.messages) - assert.ok (response.messages.length >= 0) - - response = await conn.searchMessages('剛剛試咗😋一個字', jids[i], 25, 1) - assert.ok (response.messages) - assert.ok (response.messages.length >= 0) - } - }) - - it('should load a single message', async () => { - const {messages} = await conn.loadMessages (testJid, 25) - for (var message of messages) { - const loaded = await conn.loadMessage (testJid, message.key.id) - assert.strictEqual (loaded.key.id, message.key.id, `loaded message ${JSON.stringify(message)} incorrectly`) - await delay (500) - } - }) - // open the other phone and look at the updates to really verify stuff - it('should send presence updates', async () => { - conn.shouldLogMessages = true - conn.requestPresenceUpdate(testJid) - - const sequence = [ Presence.available, Presence.composing, Presence.paused, Presence.recording, Presence.paused, Presence.unavailable ] - for (const presence of sequence) { - await delay(5000) - await conn.updatePresence(presence !== Presence.unavailable ? testJid : null, presence) - //console.log(conn.messageLog.slice(-1)) - console.log('sent update ', presence) - } - }) - it('should generate link previews correctly', async () => { - await conn.generateLinkPreview ('hello this is from https://www.github.com/adiwajshing/Baileys') - // two links should fail - await assert.rejects ( - conn.generateLinkPreview ('I sent links to https://teachyourselfcs.com/ and https://www.fast.ai/') - ) - }) - // this test requires quite a few messages with the test JID - it('should detect overlaps and clear messages accordingly', async () => { - // wait for chats - await new Promise(resolve => ( - conn.once('initial-data-received', resolve) - )) - - conn.maxCachedMessages = 100 - - const chat = conn.chats.get(testJid) - const oldCount = chat.messages.length - console.log(`test chat has ${oldCount} pre-loaded messages`) - // load 100 messages - await conn.loadMessages(testJid, 100, undefined) - assert.strictEqual(chat.messages.length, 100) - - conn.close() - // remove all latest messages - chat.messages = newMessagesDB( chat.messages.all().slice(0, 20) ) - - const task = new Promise(resolve => ( - conn.on('initial-data-received', ({ chatsWithMissingMessages }) => { - assert.strictEqual(Object.keys(chatsWithMissingMessages).length, 1) - const missing = chatsWithMissingMessages.find(({ jid }) => jid === testJid) - assert.ok(missing, 'missing message not detected') - assert.strictEqual( - conn.chats.get(testJid).messages.length, - missing.count - ) - assert.strictEqual(missing.count, oldCount) - resolve(undefined) - }) - )) - - await conn.connect() - - await task - }) - - it('should toggle disappearing messages', async () => { - let chat = conn.chats.get(testJid) - if (!chat) { - // wait for chats - await new Promise(resolve => ( - conn.once('chats-received', resolve) - )) - chat = conn.chats.get(testJid) - } - - const waitForChatUpdate = (ephemeralOn: boolean) => ( - new Promise(resolve => ( - conn.on('chat-update', ({ jid, ephemeral }) => { - if (jid === testJid && typeof ephemeral !== 'undefined') { - assert.strictEqual(!!(+ephemeral), ephemeralOn) - assert.strictEqual(!!(+chat.ephemeral), ephemeralOn) - resolve(undefined) - conn.removeAllListeners('chat-update') - } - }) - )) - ) - const toggleDisappearingMessages = async (on: boolean) => { - const update = waitForChatUpdate(on) - await conn.toggleDisappearingMessages(testJid, on ? WA_DEFAULT_EPHEMERAL : 0) - await update - } - - if (!chat.eph_setting_ts) { - await toggleDisappearingMessages(true) - } - - await delay(1000) - - let msg = await sendAndRetrieveMessage( - conn, - 'This will go poof 😱', - MessageType.text - ) - assert.ok(msg.message?.ephemeralMessage) - - const contextInfo = msg.message?.ephemeralMessage?.message?.extendedTextMessage?.contextInfo - assert.strictEqual(contextInfo.expiration, chat.ephemeral) - assert.strictEqual(+contextInfo.ephemeralSettingTimestamp, +chat.eph_setting_ts) - // test message deletion - await conn.deleteMessage(testJid, msg.key) - - await delay(1000) - - await toggleDisappearingMessages(false) - - await delay(1000) - - msg = await sendAndRetrieveMessage( - conn, - 'This will not go poof 😔', - MessageType.text - ) - assert.ok(msg.message.extendedTextMessage) - }) - it('should block & unblock a user', async () => { - const blockedCount = conn.blocklist.length; - - const waitForEventAdded = new Promise (resolve => { - conn.once ('blocklist-update', ({added}) => { - assert.ok (added.length) - resolve () - }) - }) - - await conn.blockUser (testJid, 'add') - assert.strictEqual(conn.blocklist.length, blockedCount + 1); - await waitForEventAdded - - await delay (2000) - const waitForEventRemoved = new Promise (resolve => { - conn.once ('blocklist-update', ({removed}) => { - assert.ok (removed.length) - resolve () - }) - }) - - await conn.blockUser (testJid, 'remove') - assert.strictEqual(conn.blocklist.length, blockedCount); - await waitForEventRemoved - }) - it('should exit an invalid query', async () => { - // try and send an already sent message - let msg: WAMessage - await conn.findMessage(testJid, 5, m => { - if(m.key.fromMe) { - msg = m - return true - } - }) - try { - await conn.relayWAMessage(msg) - assert.fail('should not have sent') - } catch(error) { - assert.strictEqual(error.status, 422) - } - }) -}) diff --git a/src/Tests/Tests.Mutex.ts b/src/Tests/Tests.Mutex.ts deleted file mode 100644 index d4e2992..0000000 --- a/src/Tests/Tests.Mutex.ts +++ /dev/null @@ -1,111 +0,0 @@ -import { strict as assert } from 'assert' -import { Mutex } from '../WAConnection/Mutex' - -const DEFAULT_WAIT = 1000 - -class MyClass { - didDoWork = false - values: { [k: string]: number } = {} - counter = 0 - - @Mutex () - async myFunction () { - if (this.didDoWork) return - - await new Promise (resolve => setTimeout(resolve, DEFAULT_WAIT)) - if (this.didDoWork) { - throw new Error ('work already done') - } - this.didDoWork = true - } - @Mutex (key => key) - async myKeyedFunction (key: string) { - if (!this.values[key]) { - await new Promise (resolve => setTimeout(resolve, DEFAULT_WAIT)) - if (this.values[key]) throw new Error ('value already set for ' + key) - this.values[key] = Math.floor(Math.random ()*100) - } - return this.values[key] - } - @Mutex (key => key) - async myQueingFunction (key: string) { - await new Promise (resolve => setTimeout(resolve, DEFAULT_WAIT)) - } - @Mutex () - async myErrorFunction () { - await new Promise (resolve => setTimeout(resolve, 100)) - this.counter += 1 - if (this.counter % 2 === 0) { - throw new Error ('failed') - } - } -} - -describe ('garbage', () => { - it ('should only execute once', async () => { - const stuff = new MyClass () - const start = new Date () - await Promise.all ([...Array(1000)].map(() => stuff.myFunction ())) - const diff = new Date ().getTime()-start.getTime() - assert.ok (diff < DEFAULT_WAIT*1.25) - }) - it ('should only execute once based on the key', async () => { - const stuff = new MyClass () - const start = new Date () - /* - In this test, the mutex will lock the function based on the key. - - So, if the function with argument `key1` is underway - and another function with key `key1` is called, - the call is blocked till the first function completes. - However, if argument `key2` is passed, the function is allowed to pass. - */ - const keys = ['key1', 'key2', 'key3'] - const duplicates = 1000 - const results = await Promise.all ( - keys.flatMap (key => ( - [...Array(duplicates)].map(() => stuff.myKeyedFunction (key)) - )) - ) - assert.deepStrictEqual ( - results.slice(0, duplicates).filter (r => r !== results[0]), - [] - ) - - const diff = new Date ().getTime()-start.getTime() - assert.ok (diff < DEFAULT_WAIT*1.25) - }) - it ('should execute operations in a queue', async () => { - const stuff = new MyClass () - const start = new Date () - - const keys = ['key1', 'key2', 'key3'] - - await Promise.all ( - keys.flatMap (key => ( - [...Array(2)].map(() => stuff.myQueingFunction (key)) - )) - ) - - const diff = new Date ().getTime()-start.getTime() - assert.ok (diff < DEFAULT_WAIT*2.2 && diff > DEFAULT_WAIT*1.5) - }) - it ('should throw an error on selected items', async () => { - const stuff = new MyClass () - const start = new Date () - - const WAIT = 100 - const FUNCS = 40 - const results = await Promise.all ( - [...Array(FUNCS)].map(() => stuff.myErrorFunction ().catch(err => err.message)) - ) - - const diff = new Date ().getTime()-start.getTime() - assert.ok (diff < WAIT*FUNCS*1.1) - - assert.strictEqual ( - results.filter (r => r === 'failed').length, - FUNCS/2 // half should fail - ) - }) -}) \ No newline at end of file diff --git a/src/Tests/_test.manual_tests.ts b/src/Tests/_test.manual_tests.ts deleted file mode 100644 index 367999a..0000000 --- a/src/Tests/_test.manual_tests.ts +++ /dev/null @@ -1,112 +0,0 @@ - -describe ('Reconnects', () => { - const verifyConnectionOpen = async (conn: Connection) => { - expect((await conn.getState()).user).toBeDefined() - let failed = false - // check that the connection stays open - conn.ev.on('state.update', ({ connection, lastDisconnect }) => { - if(connection === 'close' && !!lastDisconnect.error) { - failed = true - } - }) - await delay (60*1000) - conn.close () - - expect(failed).toBe(false) - } - it('should dispose correctly on bad_session', async () => { - const conn = makeConnection({ - reconnectMode: 'on-any-error', - credentials: './auth_info.json', - maxRetries: 2, - connectCooldownMs: 500 - }) - let gotClose0 = false - let gotClose1 = false - - const openPromise = conn.open() - - conn.getSocket().ev.once('ws-close', () => { - gotClose0 = true - }) - conn.ev.on('state.update', ({ lastDisconnect }) => { - //@ts-ignore - if(lastDisconnect?.error?.output?.statusCode === DisconnectReason.badSession) { - gotClose1 = true - } - }) - setTimeout (() => conn.getSocket().ws.emit ('message', Buffer.from('some-tag,sdjjij1jo2ejo1je')), 1500) - await openPromise - - console.log('opened connection') - - await delay(1000) - conn.getSocket().ws.emit ('message', Buffer.from('some-tag,sdjjij1jo2ejo1je')) - - await delay(2000) - await conn.waitForConnection() - - conn.close() - - expect(gotClose0).toBe(true) - expect(gotClose1).toBe(true) - }, 20_000) - /** - * the idea is to test closing the connection at multiple points in the connection - * and see if the library cleans up resources correctly - */ - it('should cleanup correctly', async () => { - const conn = makeConnection({ - reconnectMode: 'on-any-error', - credentials: './auth_info.json' - }) - let timeoutMs = 100 - while (true) { - let tmout = setTimeout (() => { - conn.close() - }, timeoutMs) - try { - await conn.open() - clearTimeout (tmout) - break - } catch (error) { - - } - // exponentially increase the timeout disconnect - timeoutMs *= 2 - } - await verifyConnectionOpen(conn) - }, 120_000) - /** - * the idea is to test closing the connection at multiple points in the connection - * and see if the library cleans up resources correctly - */ - it('should disrupt connect loop', async () => { - const conn = makeConnection({ - reconnectMode: 'on-any-error', - credentials: './auth_info.json' - }) - - let timeout = 1000 - let tmout - const endConnection = async () => { - while (!conn.getSocket()) { - await delay(100) - } - conn.getSocket().end(Boom.preconditionRequired('conn close')) - - while (conn.getSocket()) { - await delay(100) - } - - timeout *= 2 - tmout = setTimeout (endConnection, timeout) - } - tmout = setTimeout (endConnection, timeout) - - await conn.open() - clearTimeout (tmout) - - await verifyConnectionOpen(conn) - }, 120_000) -}) \ No newline at end of file diff --git a/src/Tests/test.binary.ts b/src/Tests/test.binary.ts deleted file mode 100644 index 7263626..0000000 --- a/src/Tests/test.binary.ts +++ /dev/null @@ -1,95 +0,0 @@ -import BinaryNode from '../BinaryNode' - -describe('Binary Coding Tests', () => { - - const TEST_VECTORS: [string, BinaryNode][] = [ - [ - 'f806092f5a0a10f804f80234fc6c0a350a1b39313735323938373131313740732e77686174736170702e6e657410011a143345423030393637354537454433374141424632122b0a292a7069616e6f20726f6f6d2074696d696e6773206172653a2a0a20363a3030414d2d31323a3030414d18b3faa7f3052003f80234fc4c0a410a1b39313735323938373131313740732e77686174736170702e6e657410001a20304643454335333330463634393239433645394132434646443242433845414418bdfaa7f305c00101f80234fc930a350a1b39313735323938373131313740732e77686174736170702e6e657410011a14334542303033433742353339414644303937353312520a50536f727279206672656e2c204920636f756c646e277420756e6465727374616e6420274c69627261272e2054797065202768656c702720746f206b6e6f77207768617420616c6c20492063616e20646f18c1faa7f3052003f80234fc540a410a1b39313735323938373131313740732e77686174736170702e6e657410001a20413132333042384436423041314437393345433241453245413043313638443812090a076c69627261727918c2faa7f305', - new BinaryNode( - 'action', - { last: 'true', add: 'before' }, - [ - new BinaryNode( - 'message', - {}, - { - key: { remoteJid: '917529871117@s.whatsapp.net', fromMe: true, id: '3EB009675E7ED37AABF2' }, - message: { conversation: '*piano room timings are:*\n 6:00AM-12:00AM' }, - messageTimestamp: '1584004403', - status: 'DELIVERY_ACK', - } as any - ), - new BinaryNode( - 'message', - {}, - { - key: { - remoteJid: '917529871117@s.whatsapp.net', - fromMe: false, - id: '0FCEC5330F64929C6E9A2CFFD2BC8EAD', - }, - messageTimestamp: '1584004413', - messageStubType: 'REVOKE', - } as any - ), - new BinaryNode( - 'message', - {}, - { - key: { remoteJid: '917529871117@s.whatsapp.net', fromMe: true, id: '3EB003C7B539AFD09753' }, - message: { - conversation: - "Sorry fren, I couldn't understand 'Libra'. Type 'help' to know what all I can do", - }, - messageTimestamp: '1584004417', - status: 'DELIVERY_ACK', - } as any - ), - new BinaryNode( - 'message', - {}, - { - key: { - remoteJid: '917529871117@s.whatsapp.net', - fromMe: false, - id: 'A1230B8D6B0A1D793EC2AE2EA0C168D8', - }, - message: { conversation: 'library' }, - messageTimestamp: '1584004418', - } as any - ), - ] - ) - ], - [ - 'f8063f2dfafc0831323334353637385027fc0431323334f801f80228fc0701020304050607', - new BinaryNode( - 'picture', - {jid: '12345678@s.whatsapp.net', id: '1234'}, - [ - new BinaryNode( - 'image', - {}, - Buffer.from([1,2,3,4,5,6,7]) - ) - ] - ) - ] - ] - it('should encode/decode strings', () => { - for(const [input, output] of TEST_VECTORS) { - const buff = Buffer.from(input, 'hex') - const node = BinaryNode.from(buff) - expect( - JSON.parse(JSON.stringify(node)) - ).toStrictEqual( - JSON.parse(JSON.stringify(output)) - ) - expect( - node.toBuffer().toString('hex') - ).toStrictEqual( - input - ) - } - }) -}) diff --git a/src/Tests/test.connect.ts b/src/Tests/test.connect.ts deleted file mode 100644 index 4903c2d..0000000 --- a/src/Tests/test.connect.ts +++ /dev/null @@ -1,94 +0,0 @@ -import { Boom } from '@hapi/boom' -import P from 'pino' -import BinaryNode from '../BinaryNode' -import makeConnection from '../Connection' -import { delay } from '../Utils/generics' - -describe('QR Generation', () => { - it('should generate QR', async () => { - const QR_GENS = 1 - const {ev} = makeConnection({ - maxRetries: 0, - maxQRCodes: QR_GENS, - logger: P({ level: 'trace' }) - }) - let calledQR = 0 - ev.on('connection.update', ({ qr }) => { - if(qr) calledQR += 1 - }) - - await expect(open()).rejects.toThrowError('Too many QR codes') - expect(calledQR).toBeGreaterThanOrEqual(QR_GENS) - }, 60_000) -}) - -describe('Test Connect', () => { - - const logger = P({ level: 'trace' }) - - it('should connect', async () => { - - logger.info('please be ready to scan with your phone') - - const conn = makeConnection({ - logger, - printQRInTerminal: true - }) - await conn.waitForConnection(true) - const { user, isNewLogin } = await conn.getState() - expect(user).toHaveProperty('jid') - expect(user).toHaveProperty('name') - expect(isNewLogin).toBe(true) - - conn.end(undefined) - }, 65_000) - - it('should restore session', async () => { - let conn = makeConnection({ - printQRInTerminal: true, - logger, - }) - await conn.waitForConnection(true) - conn.end(undefined) - - await delay(2500) - - conn = makeConnection({ - printQRInTerminal: true, - logger, - }) - await conn.waitForConnection(true) - - const { user, isNewLogin, qr } = await conn.getState() - expect(user).toHaveProperty('jid') - expect(user).toHaveProperty('name') - expect(isNewLogin).toBe(false) - expect(qr).toBe(undefined) - - conn.end(undefined) - }, 65_000) - - it('should logout', async () => { - let conn = makeConnection({ - printQRInTerminal: true, - logger, - }) - await conn.waitForConnection(true) - - const { user, qr } = await conn.getState() - expect(user).toHaveProperty('jid') - expect(user).toHaveProperty('name') - expect(qr).toBe(undefined) - - const credentials = conn.getAuthInfo() - await conn.logout() - - conn = makeConnection({ - credentials, - logger - }) - await expect( - conn.waitForConnection() - ).rejects.toThrowError('Unexpected error in login') - }, 65_000) -}) \ No newline at end of file diff --git a/src/Tests/test.message-gen.ts b/src/Tests/test.message-gen.ts deleted file mode 100644 index 6b325b4..0000000 --- a/src/Tests/test.message-gen.ts +++ /dev/null @@ -1,8 +0,0 @@ - -describe('Message Generation', () => { - - it('should generate a text message', () => { - - }) - -}) \ No newline at end of file diff --git a/src/Tests/test.queries.ts b/src/Tests/test.queries.ts deleted file mode 100644 index f9e28ed..0000000 --- a/src/Tests/test.queries.ts +++ /dev/null @@ -1,165 +0,0 @@ -import BinaryNode from '../BinaryNode' -import makeConnection from '../makeConnection' -import { delay } from '../WAConnection/Utils' - -describe('Queries', () => { - /*it ('should correctly send updates for chats', async () => { - const conn = makeConnection({ - pendingRequestTimeoutMs: undefined, - credentials: './auth_info.json' - }) - const task = new Promise(resolve => conn.once('chats-received', resolve)) - await conn.connect () - await task - - conn.close () - - const oldChat = conn.chats.all()[0] - oldChat.archive = 'true' // mark the first chat as archived - oldChat.modify_tag = '1234' // change modify tag to detect change - - const promise = new Promise(resolve => conn.once('chats-update', resolve)) - - const result = await conn.connect () - assert.ok (!result.newConnection) - - const chats = await promise as Partial[] - const chat = chats.find (c => c.jid === oldChat.jid) - assert.ok (chat) - - assert.ok ('archive' in chat) - assert.strictEqual (Object.keys(chat).length, 3) - assert.strictEqual (Object.keys(chats).length, 1) - - conn.close () - }) - it ('should correctly send updates for contacts', async () => { - const conn = makeConnection () - conn.pendingRequestTimeoutMs = null - conn.loadAuthInfo('./auth_info.json') - - const task: any = new Promise(resolve => conn.once('contacts-received', resolve)) - await conn.connect () - const initialResult = await task - assert.strictEqual( - initialResult.updatedContacts.length, - Object.keys(conn.contacts).length - ) - - - conn.close () - - const [jid] = Object.keys(conn.contacts) - const oldContact = conn.contacts[jid] - oldContact.name = 'Lol' - oldContact.index = 'L' - - const promise = new Promise(resolve => conn.once('contacts-received', resolve)) - - const result = await conn.connect () - assert.ok (!result.newConnection) - - const {updatedContacts} = await promise as { updatedContacts: Partial[] } - const contact = updatedContacts.find (c => c.jid === jid) - assert.ok (contact) - - assert.ok ('name' in contact) - assert.strictEqual (Object.keys(contact).length, 3) - assert.strictEqual (Object.keys(updatedContacts).length, 1) - - conn.close () - })*/ - it('should queue requests when closed', async () => { - const conn = makeConnection({ - credentials: './auth_info.json' - }) - await conn.open() - await delay(2000) - - conn.close() - const { user: { jid } } = await conn.getState() - const task: Promise = conn.query({ - json: ['query', 'Status', jid] - }) - - await delay(2000) - - conn.open() - const json = await task - - expect(json.status).toBeDefined() - - conn.close() - }, 65_000) - - it('[MANUAL] should recieve query response after phone disconnect', async () => { - const conn = makeConnection ({ - printQRInTerminal: true, - credentials: './auth_info.json' - }) - await conn.open() - const { phoneConnected } = await conn.getState() - expect(phoneConnected).toBe(true) - - try { - const waitForEvent = expect => new Promise (resolve => { - conn.ev.on('state.update', ({phoneConnected}) => { - if (phoneConnected === expect) { - conn.ev.removeAllListeners('state.update') - resolve(undefined) - } - }) - }) - - console.log('disconnect your phone from the internet') - await delay(10_000) - console.log('phone should be disconnected now, testing...') - - const query = conn.query({ - json: new BinaryNode( - 'query', - { - epoch: conn.getSocket().currentEpoch().toString(), - type: 'message', - jid: '1234@s.whatsapp.net', - kind: 'before', - count: '10', - } - ), - requiresPhoneConnection: true, - expect200: false - }) - await waitForEvent(false) - - console.log('reconnect your phone to the internet') - await waitForEvent(true) - - console.log('reconnected successfully') - - await expect(query).resolves.toBeDefined() - } finally { - conn.close() - } - }, 65_000) - - it('should re-execute query on connection closed error', async () => { - const conn = makeConnection({ - credentials: './auth_info.json' - }) - await conn.open() - const { user: { jid } } = await conn.getState() - const task: Promise = conn.query({ json: ['query', 'Status', jid], waitForOpen: true }) - - await delay(20) - // fake cancel the connection - conn.getSocket().ev.emit('message', '1234,["Pong",false]') - - await delay(2000) - - const json = await task - - expect(json.status).toBeDefined() - - conn.close() - }, 65_000) -}) \ No newline at end of file diff --git a/src/Types/Auth.ts b/src/Types/Auth.ts index aeaa907..5ff963e 100644 --- a/src/Types/Auth.ts +++ b/src/Types/Auth.ts @@ -1,22 +1,51 @@ +import type { Contact } from "./Contact" +import type { proto } from "../../WAProto" -export interface AuthenticationCredentials { - clientID: string - serverToken: string - clientToken: string - encKey: Buffer - macKey: Buffer +export type KeyPair = { public: Uint8Array, private: Uint8Array } +export type SignedKeyPair = { keyPair: KeyPair, signature: Uint8Array, keyId: number } + +export type ProtocolAddress = { + name: string // jid + deviceId: number } -export interface AuthenticationCredentialsBase64 { - clientID: string - serverToken: string - clientToken: string - encKey: string - macKey: string +export type SignalIdentity = { + identifier: ProtocolAddress + identifierKey: Uint8Array } -export interface AuthenticationCredentialsBrowser { - WABrowserId: string - WASecretBundle: {encKey: string, macKey: string} | string - WAToken1: string - WAToken2: string + +export type CollectionType = 'regular_high' | 'regular_low' | 'critical_unblock_low' | 'critical_block' + +export type AuthenticationCreds = { + noiseKey: KeyPair + signedIdentityKey: KeyPair + signedPreKey: SignedKeyPair + registrationId: number + advSecretKey: string + me?: Contact + account?: proto.ADVSignedDeviceIdentity + signalIdentities?: SignalIdentity[] + appStateSyncKeys?: proto.IAppStateSyncKey[] + appStateVersion?: { + [T in CollectionType]: number + } + + firstUnuploadedPreKeyId: number + serverHasPreKeys: boolean + nextPreKeyId: number } -export type AnyAuthenticationCredentials = AuthenticationCredentialsBrowser | AuthenticationCredentialsBase64 | AuthenticationCredentials \ No newline at end of file +type Awaitable = T | Promise +export type SignalKeyStore = { + getPreKey: (keyId: number) => Awaitable + setPreKey: (keyId: number, pair: KeyPair | null) => Awaitable + + getSession: (sessionId: string) => Awaitable + setSession: (sessionId: string, item: any | null) => Awaitable + + getSenderKey: (id: string) => Awaitable + setSenderKey: (id: string, item: any | null) => Awaitable +} + +export type AuthenticationState = { + creds: AuthenticationCreds + keys: SignalKeyStore +} \ No newline at end of file diff --git a/src/Types/Chat.ts b/src/Types/Chat.ts index 5815b5a..3fbad52 100644 --- a/src/Types/Chat.ts +++ b/src/Types/Chat.ts @@ -1,46 +1,30 @@ +import type { proto } from "../../WAProto" + /** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */ -export enum Presence { - unavailable = 'unavailable', // "offline" - available = 'available', // "online" - composing = 'composing', // "typing..." - recording = 'recording', // "recording..." - paused = 'paused', // stop typing -} +export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused' export interface PresenceData { - lastKnownPresence: Presence + lastKnownPresence: WAPresence lastSeen?: number } -export interface Chat { - jid: string - - t: number - /** number of unread messages, is < 0 if the chat is manually marked unread */ - count: number - archive?: 'true' | 'false' - clear?: 'true' | 'false' - read_only?: 'true' | 'false' - mute?: string - pin?: string - spam?: 'false' | 'true' - modify_tag?: string - name?: string - /** when ephemeral messages were toggled on */ - eph_setting_ts?: string - /** how long each message lasts for */ - ephemeral?: string +export type Chat = Omit & { + /** unix timestamp of date when mute ends, if applicable */ + mute?: number | null + /** timestamp of when pinned */ + pin?: number | null + archive?: boolean } export type ChatModification = { archive: boolean } | { /** pin at current timestamp, or provide timestamp of pin to remove */ - pin: true | { remove: number } + pin: number | null } | { /** mute for duration, or provide timestamp of mute to remove*/ - mute: number | { remove: number } + mute: number | null } | { clear: 'all' | { messages: { id: string, fromMe?: boolean }[] } @@ -51,4 +35,7 @@ export type ChatModification = star: boolean } } | + { + markRead: boolean + } | { delete: true } \ No newline at end of file diff --git a/src/Types/Contact.ts b/src/Types/Contact.ts index cb24f02..f5e74b3 100644 --- a/src/Types/Contact.ts +++ b/src/Types/Contact.ts @@ -1,15 +1,11 @@ export interface Contact { - verify?: string - /** name of the contact, the contact has set on their own on WA */ - notify?: string - jid: string - /** I have no idea */ - vname?: string + id: string /** name of the contact, you have saved on your WA */ name?: string - index?: string - /** short name for the contact */ - short?: string + /** name of the contact, the contact has set on their own on WA */ + notify?: string + /** I have no idea */ + verifiedName?: string // Baileys Added imgUrl?: string status?: string diff --git a/src/Types/GroupMetadata.ts b/src/Types/GroupMetadata.ts index 5e86b97..13b2442 100644 --- a/src/Types/GroupMetadata.ts +++ b/src/Types/GroupMetadata.ts @@ -1,6 +1,6 @@ import { Contact } from "./Contact"; -export type GroupParticipant = (Contact & { isAdmin: boolean; isSuperAdmin: boolean }) +export type GroupParticipant = (Contact & { isAdmin?: boolean; isSuperAdmin?: boolean, admin?: 'admin' | 'superadmin' | null }) export type ParticipantAction = 'add' | 'remove' | 'promote' | 'demote' diff --git a/src/Types/Message.ts b/src/Types/Message.ts index 7deb27e..934e4b5 100644 --- a/src/Types/Message.ts +++ b/src/Types/Message.ts @@ -1,18 +1,18 @@ import type { ReadStream } from "fs" import type { Logger } from "pino" import type { URL } from "url" -import { proto } from '../../WAMessage' +import { proto } from '../../WAProto' // export the WAMessage Prototypes -export { proto as WAMessageProto } -export type WAMessage = proto.WebMessageInfo +export { proto as WAProto } +export type WAMessage = proto.IWebMessageInfo export type WAMessageContent = proto.IMessage -export type WAContactMessage = proto.ContactMessage -export type WAContactsArrayMessage = proto.ContactsArrayMessage +export type WAContactMessage = proto.IContactMessage +export type WAContactsArrayMessage = proto.IContactsArrayMessage export type WAMessageKey = proto.IMessageKey -export type WATextMessage = proto.ExtendedTextMessage +export type WATextMessage = proto.IExtendedTextMessage export type WAContextInfo = proto.IContextInfo -export type WALocationMessage = proto.LocationMessage +export type WALocationMessage = proto.ILocationMessage export type WAGenericMediaMessage = proto.IVideoMessage | proto.IImageMessage | proto.IAudioMessage | proto.IDocumentMessage | proto.IStickerMessage export import WAMessageStubType = proto.WebMessageInfo.WebMessageInfoStubType export import WAMessageStatus = proto.WebMessageInfo.WebMessageInfoStatus @@ -23,20 +23,10 @@ export type MessageType = keyof proto.Message export type MediaConnInfo = { auth: string ttl: number - hosts: { - hostname: string - }[] + hosts: { hostname: string }[] fetchDate: Date } -/** Reverse stub type dictionary */ -export const WA_MESSAGE_STUB_TYPES = function () { - const types = WAMessageStubType - const dict: Record = {} - Object.keys(types).forEach(element => dict[ types[element] ] = element) - return dict -}() - export interface WAUrlInfo { 'canonical-url': string 'matched-text': string @@ -61,7 +51,7 @@ type WithDimensions = { width?: number height?: number } -export type MediaType = 'image' | 'video' | 'sticker' | 'audio' | 'document' +export type MediaType = 'image' | 'video' | 'sticker' | 'audio' | 'document' | 'history' export type AnyMediaMessageContent = ( ({ image: WAMediaUpload @@ -121,10 +111,7 @@ export type MiscMessageGenerationOptions = { /** the message you want to quote */ quoted?: WAMessage /** disappearing messages settings */ - ephemeralOptions?: { - expiration: number | string - eph_setting_ts?: number | string - } + ephemeralExpiration?: number | string } export type MessageGenerationOptionsFromContent = MiscMessageGenerationOptions & { userJid: string @@ -143,7 +130,7 @@ export type MessageContentGenerationOptions = MediaGenerationOptions & { } export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent -export type MessageUpdateType = 'prepend' | 'append' | 'notify' | 'last' +export type MessageUpdateType = 'append' | 'notify' export type MessageInfoEventMap = { [jid: string]: Date } export interface MessageInfo { diff --git a/src/Types/State.ts b/src/Types/State.ts new file mode 100644 index 0000000..754ff32 --- /dev/null +++ b/src/Types/State.ts @@ -0,0 +1,17 @@ +export type WAConnectionState = 'open' | 'connecting' | 'close' + +export type ConnectionState = { + /** connection is now open, connecting or closed */ + connection: WAConnectionState + /** the error that caused the connection to close */ + lastDisconnect?: { + error: Error + date: Date + } + /** is this a new login */ + isNewLogin?: boolean + /** the current QR code */ + qr?: string + /** has the device received all pending notifications while it was offline */ + receivedPendingNotifications?: boolean +} \ No newline at end of file diff --git a/src/Types/Store.ts b/src/Types/Store.ts deleted file mode 100644 index 9c5c65e..0000000 --- a/src/Types/Store.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type KeyedDB from '@adiwajshing/keyed-db' -import type { Chat } from './Chat' -import type { Contact } from './Contact' - -export type WAConnectionState = 'open' | 'connecting' | 'close' - -export type ConnectionState = { - user?: Contact - phoneConnected: boolean - phoneInfo?: any - connection: WAConnectionState - lastDisconnect?: { - error: Error, - date: Date - }, - isNewLogin?: boolean - connectionTriesLeft?: number - qr?: string -} - -export type BaileysState = { - connection: ConnectionState - chats: KeyedDB - contacts: { [jid: string]: Contact } -} \ No newline at end of file diff --git a/src/Types/index.ts b/src/Types/index.ts index 5b0008f..3822933 100644 --- a/src/Types/index.ts +++ b/src/Types/index.ts @@ -2,134 +2,56 @@ export * from './Auth' export * from './GroupMetadata' export * from './Chat' export * from './Contact' -export * from './Store' +export * from './State' export * from './Message' import type EventEmitter from "events" import type { Agent } from "https" import type { Logger } from "pino" import type { URL } from "url" -import type BinaryNode from "../BinaryNode" -import { AnyAuthenticationCredentials, AuthenticationCredentials } from './Auth' + +import { AuthenticationState } from './Auth' import { Chat, PresenceData } from './Chat' import { Contact } from './Contact' -import { ConnectionState } from './Store' +import { ConnectionState } from './State' import { GroupMetadata, ParticipantAction } from './GroupMetadata' -import { MessageInfo, MessageInfoUpdate, MessageUpdateType, WAMessage, WAMessageKey, WAMessageUpdate } from './Message' -import { proto } from '../../WAMessage' - -/** used for binary messages */ -export enum WAMetric { - debugLog = 1, - queryResume = 2, - liveLocation = 3, - queryMedia = 4, - queryChat = 5, - queryContact = 6, - queryMessages = 7, - presence = 8, - presenceSubscribe = 9, - group = 10, - read = 11, - chat = 12, - received = 13, - picture = 14, - status = 15, - message = 16, - queryActions = 17, - block = 18, - queryGroup = 19, - queryPreview = 20, - queryEmoji = 21, - queryRead = 22, - queryVCard = 29, - queryStatus = 30, - queryStatusUpdate = 31, - queryLiveLocation = 33, - queryLabel = 36, - queryQuickReply = 39 -} - -/** used for binary messages */ -export enum WAFlag { - available = 160, - other = 136, // don't know this one - ignore = 1 << 7, - acknowledge = 1 << 6, - unavailable = 1 << 4, - expires = 1 << 3, - composing = 1 << 2, - recording = 1 << 2, - paused = 1 << 2 -} - -/** Tag used with binary queries */ -export type WATag = [WAMetric, WAFlag] - -export type SocketSendMessageOptions = { - json: BinaryNode | any[] - binaryTag?: WATag - tag?: string - longTag?: boolean -} +import { MessageInfoUpdate, MessageUpdateType, WAMessage, WAMessageUpdate } from './Message' export type WAVersion = [number, number, number] export type WABrowserDescription = [string, string, string] export type ReconnectMode = 'no-reconnects' | 'on-any-error' | 'on-connection-error' export type SocketConfig = { + /** provide an auth state object to maintain the auth state */ + auth?: AuthenticationState /** the WS url to connect to WA */ waWebSocketUrl: string | URL - /** Fails the connection if the connection times out in this time interval or no data is received */ + /** Fails the connection if the socket times out in this interval */ connectTimeoutMs: number - /** max time for the phone to respond to a connectivity test */ - phoneResponseTimeMs: number /** ping-pong interval for WS connection */ keepAliveIntervalMs: number - - expectResponseTimeout: number /** proxy agent */ agent?: Agent + /** pino logger */ logger: Logger - + /** version to connect with */ version: WAVersion + /** override browser config */ browser: WABrowserDescription - /** maximum attempts to connect */ - maxRetries: number - connectCooldownMs: number /** agent used for fetch requests -- uploading/downloading media */ fetchAgent?: Agent - /** credentials used to sign back in */ - credentials?: AnyAuthenticationCredentials | string - /** - * Sometimes WA does not send the chats, - * this keeps pinging the phone to send the chats over - * */ - queryChatsTillReceived?: boolean - /** */ - pendingRequestTimeoutMs: number - reconnectMode: ReconnectMode - maxQRCodes: number /** should the QR be printed in the terminal */ printQRInTerminal: boolean - - phoneConnectionChanged: (connected: boolean) => void -} - -export type SocketQueryOptions = SocketSendMessageOptions & { - timeoutMs?: number - expect200?: boolean - requiresPhoneConnection?: boolean } export enum DisconnectReason { connectionClosed = 428, - connectionReplaced = 440, connectionLost = 408, timedOut = 408, - credentialsInvalidated = 401, - badSession = 500 + loggedOut = 401, + badSession = 500, + restartRequired = 410 } export type WAInitResponse = { @@ -160,36 +82,40 @@ export type WABusinessProfile = { wid?: string } -export type QueryOptions = SocketQueryOptions & { - waitForOpen?: boolean - maxRetries?: number - startDebouncedTimeout?: boolean -} export type CurveKeyPair = { private: Uint8Array; public: Uint8Array } export type BaileysEventMap = { + /** connection state has been updated -- WS closed, opened, connecting etc. */ 'connection.update': Partial - 'credentials.update': AuthenticationCredentials - - 'chats.set': { chats: Chat[] } + /** auth state updated -- some pre keys, or identity keys etc. */ + 'auth-state.update': AuthenticationState + /** set chats (history sync), messages are reverse chronologically sorted */ + 'chats.set': { chats: Chat[], messages: WAMessage[] } + /** upsert chats */ 'chats.upsert': Chat[] + /** update the given chats */ 'chats.update': Partial[] + /** delete chats with given ID */ 'chats.delete': string[] + /** presence of contact in a chat updated */ + 'presence.update': { id: string, presences: { [participant: string]: PresenceData } } - 'presence.update': { jid: string, presences: { [participant: string]: PresenceData } } - - 'contacts.set': { contacts: Contact[] } 'contacts.upsert': Contact[] 'contacts.update': Partial[] 'messages.delete': { jid: string, ids: string[] } | { jid: string, all: true } 'messages.update': WAMessageUpdate[] + /** + * add/update the given messages. If they were received while the connection was online, + * the update will have type: "notify" + * */ 'messages.upsert': { messages: WAMessage[], type: MessageUpdateType } 'message-info.update': MessageInfoUpdate[] 'groups.update': Partial[] - 'group-participants.update': { jid: string, participants: string[], action: ParticipantAction } + /** apply an action to participants in a group */ + 'group-participants.update': { id: string, participants: string[], action: ParticipantAction } 'blocklist.set': { blocklist: string[] } 'blocklist.update': { blocklist: string[], type: 'add' | 'remove' } diff --git a/src/Utils/chat-utils.ts b/src/Utils/chat-utils.ts new file mode 100644 index 0000000..075fa91 --- /dev/null +++ b/src/Utils/chat-utils.ts @@ -0,0 +1,198 @@ +import { Boom } from '@hapi/boom' +import { aesDecrypt, hmacSign, aesEncrypt, hkdf } from "./generics" +import { AuthenticationState, ChatModification } from "../Types" +import { proto } from '../../WAProto' +import { LT_HASH_ANTI_TAMPERING } from '../WABinary/LTHash' + +type SyncdType = 'regular_high' | 'regular_low' + +const mutationKeys = (keydata: string) => { + const expanded = hkdf(Buffer.from(keydata, 'base64'), 160, { info: 'WhatsApp Mutation Keys' }) + return { + indexKey: expanded.slice(0, 32), + valueEncryptionKey: expanded.slice(32, 64), + valueMacKey: expanded.slice(64, 96), + snapshotMacKey: expanded.slice(96, 128), + patchMacKey: expanded.slice(128, 160) + } +} + +const generateMac = (operation: proto.SyncdMutation.SyncdMutationSyncdOperation, data: Buffer, keyId: Uint8Array | string, key: Buffer) => { + const getKeyData = () => { + let r: number + switch (operation) { + case proto.SyncdMutation.SyncdMutationSyncdOperation.SET: + r = 0x01 + break + case proto.SyncdMutation.SyncdMutationSyncdOperation.REMOVE: + r = 0x02 + break + } + const buff = Buffer.from([r]) + return Buffer.concat([ buff, Buffer.from(keyId as any, 'base64') ]) + } + const keyData = getKeyData() + + const last = Buffer.alloc(8) // 8 bytes + last.set([ keyData.length ], last.length-1) + + const total = Buffer.concat([ keyData, data, last ]) + const hmac = hmacSign(total, key, 'sha512') + + return hmac.slice(0, 32) +} + +const to64BitNetworkOrder = function(e) { + const t = new ArrayBuffer(8) + new DataView(t).setUint32(4, e, !1) + return Buffer.from(t) +} + +const generateSnapshotMac = (version: number, indexMac: Uint8Array, valueMac: Uint8Array, type: SyncdType, key: Buffer) => { + + const ltHash = () => { + const result = LT_HASH_ANTI_TAMPERING.subtractThenAdd(new Uint8Array(128).buffer, [ new Uint8Array(valueMac).buffer, new Uint8Array(indexMac).buffer ], []) + const buff = Buffer.from(result) + console.log(buff.toString('hex')) + return buff + } + const total = Buffer.concat([ + ltHash(), + to64BitNetworkOrder(version), + Buffer.from(type, 'utf-8') + ]) + return hmacSign(total, key) +} +const generatePatchMac = (snapshotMac: Uint8Array, valueMacs: Uint8Array[], version: number, type: SyncdType, key: Buffer) => { + const total = Buffer.concat([ + snapshotMac, + ...valueMacs, + to64BitNetworkOrder(version), + Buffer.from(type, 'utf-8') + ]) + return hmacSign(total, key) +} + +export const encodeSyncdPatch = (action: ChatModification, lastMessageKey: proto.IMessageKey, { creds: { appStateSyncKeys: [key], appStateVersion } }: AuthenticationState) => { + let syncAction: proto.ISyncActionValue = { } + if('archive' in action) { + syncAction.archiveChatAction = { + archived: action.archive, + messageRange: { + messages: [ + { key: lastMessageKey } + ] + } + } + } else if('mute' in action) { + const value = typeof action.mute === 'number' ? true : false + syncAction.muteAction = { + muted: value, + muteEndTimestamp: typeof action.mute === 'number' ? action.mute : undefined + } + } else if('delete' in action) { + syncAction.deleteChatAction = { } + } else if('markRead' in action) { + syncAction.markChatAsReadAction = { + read: action.markRead + } + } else if('pin' in action) { + throw new Boom('Pin not supported on multi-device yet', { statusCode: 400 }) + } + + const encoded = proto.SyncActionValue.encode(syncAction).finish() + + const index = JSON.stringify([Object.keys(action)[0], lastMessageKey.remoteJid]) + const keyValue = mutationKeys(key.keyData!.keyData! as any) + + const encValue = aesEncrypt(encoded, keyValue.valueEncryptionKey) + const macValue = generateMac(1, encValue, key.keyId!.keyId, keyValue.valueMacKey) + const indexMacValue = hmacSign(Buffer.from(index), keyValue.indexKey) + + const type = 'regular_high' + const v = appStateVersion[type]+1 + + const snapshotMac = generateSnapshotMac(v, indexMacValue, macValue, type, keyValue.snapshotMacKey) + + const patch: proto.ISyncdPatch = { + patchMac: generatePatchMac(snapshotMac, [macValue], v, type, keyValue.patchMacKey), + snapshotMac: snapshotMac, + keyId: { id: key.keyId.keyId }, + mutations: [ + { + operation: 1, + record: { + index: { + blob: indexMacValue + }, + value: { + blob: Buffer.concat([ encValue, macValue ]) + }, + keyId: { id: key.keyId.keyId } + } + } + ] + } + return patch +} + +export const decodeSyncdPatch = (msg: proto.ISyncdPatch, {creds}: AuthenticationState) => { + const keyCache: { [_: string]: ReturnType } = { } + const getKey = (keyId: Uint8Array) => { + const base64Key = Buffer.from(keyId!).toString('base64') + + let key = keyCache[base64Key] + if(!key) { + const keyEnc = creds.appStateSyncKeys?.find(k => ( + (k.keyId!.keyId as any) === base64Key + )) + if(!keyEnc) { + throw new Boom(`failed to find key "${base64Key}" to decode mutation`, { statusCode: 500, data: msg }) + } + const result = mutationKeys(keyEnc.keyData!.keyData as any) + keyCache[base64Key] = result + key = result + } + return key + } + + const mutations: { action: proto.ISyncActionValue, index: [string, string] }[] = [] + const failures: Boom[] = [] + + /*const mainKey = getKey(msg.keyId!.id) + const mutation = msg.mutations![0]!.record + + const patchMac = generatePatchMac(msg.snapshotMac, [ mutation.value!.blob!.slice(-32) ], toNumber(msg.version!.version), 'regular_low', mainKey.patchMacKey) + console.log(patchMac) + console.log(msg.patchMac)*/ + + // indexKey used to HMAC sign record.index.blob + // valueEncryptionKey used to AES-256-CBC encrypt record.value.blob[0:-32] + // the remaining record.value.blob[0:-32] is the mac, it the HMAC sign of key.keyId + decoded proto data + length of bytes in keyId + for(const { operation, record } of msg.mutations!) { + try { + const key = getKey(record.keyId!.id!) + const content = Buffer.from(record.value!.blob!) + const encContent = content.slice(0, -32) + const contentHmac = generateMac(operation, encContent, record.keyId!.id!, key.valueMacKey) + if(Buffer.compare(contentHmac, content.slice(-32)) !== 0) { + throw new Boom('HMAC content verification failed') + } + + const result = aesDecrypt(encContent, key.valueEncryptionKey) + const syncAction = proto.SyncActionData.decode(result) + + const hmac = hmacSign(syncAction.index, key.indexKey) + if(Buffer.compare(hmac, record.index!.blob) !== 0) { + throw new Boom('HMAC index verification failed') + } + + const indexStr = Buffer.from(syncAction.index).toString() + mutations.push({ action: syncAction.value!, index: JSON.parse(indexStr) }) + } catch(error) { + failures.push(new Boom(error, { data: { operation, record } })) + } + } + + return { mutations, failures } +} \ No newline at end of file diff --git a/src/Utils/decode-wa-message.ts b/src/Utils/decode-wa-message.ts index a8e3e97..130c774 100644 --- a/src/Utils/decode-wa-message.ts +++ b/src/Utils/decode-wa-message.ts @@ -1,63 +1,103 @@ import { Boom } from '@hapi/boom' -import BinaryNode from "../BinaryNode" -import { aesDecrypt, hmacSign } from "./generics" -import { DisconnectReason, WATag } from "../Types" +import { unpadRandomMax16 } from "./generics" +import { AuthenticationState } from "../Types" +import { areJidsSameUser, BinaryNode as BinaryNodeM, encodeBinaryNode, isJidBroadcast, isJidGroup, isJidStatusBroadcast, isJidUser } from '../WABinary' +import { decryptGroupSignalProto, decryptSignalProto, processSenderKeyMessage } from './signal' +import { proto } from '../../WAProto' -export const decodeWAMessage = ( - message: string | Buffer, - auth: { macKey: Buffer, encKey: Buffer }, - fromMe: boolean=false -) => { +type MessageType = 'chat' | 'peer_broadcast' | 'other_broadcast' | 'group' | 'direct_peer_status' | 'other_status' - let commaIndex = message.indexOf(',') // all whatsapp messages have a tag and a comma, followed by the actual message - if (commaIndex < 0) throw new Boom('invalid message', { data: message }) // if there was no comma, then this message must be not be valid - - if (message[commaIndex+1] === ',') commaIndex += 1 - let data = message.slice(commaIndex+1, message.length) - - // get the message tag. - // If a query was done, the server will respond with the same message tag we sent the query with - const messageTag: string = message.slice(0, commaIndex).toString() - let json: any - let tags: WATag - if (data.length > 0) { - if (typeof data === 'string') { - json = JSON.parse(data) // parse the JSON +export const decodeMessageStanza = async(stanza: BinaryNodeM, auth: AuthenticationState) => { + const deviceIdentity = (stanza.content as BinaryNodeM[])?.find(m => m.tag === 'device-identity') + const deviceIdentityBytes = deviceIdentity ? deviceIdentity.content as Buffer : undefined + + let msgType: MessageType + let chatId: string + let author: string + + const msgId: string = stanza.attrs.id + const from: string = stanza.attrs.from + const participant: string | undefined = stanza.attrs.participant + const recipient: string | undefined = stanza.attrs.recipient + + const isMe = (jid: string) => areJidsSameUser(jid, auth.creds.me!.id) + + if(isJidUser(from)) { + if(recipient) { + if(!isMe(from)) { + throw new Boom('') + } + chatId = recipient } else { - const { macKey, encKey } = auth || {} - if (!macKey || !encKey) { - throw new Boom('recieved encrypted buffer when auth creds unavailable', { data: message, statusCode: DisconnectReason.badSession }) - } - /* - If the data recieved was not a JSON, then it must be an encrypted message. - Such a message can only be decrypted if we're connected successfully to the servers & have encryption keys - */ - if (fromMe) { - tags = [data[0], data[1]] - data = data.slice(2, data.length) - } - - const checksum = data.slice(0, 32) // the first 32 bytes of the buffer are the HMAC sign of the message - data = data.slice(32, data.length) // the actual message - const computedChecksum = hmacSign(data, macKey) // compute the sign of the message we recieved using our macKey - - if (checksum.equals(computedChecksum)) { - // the checksum the server sent, must match the one we computed for the message to be valid - const decrypted = aesDecrypt(data, encKey) // decrypt using AES - json = BinaryNode.from(decrypted) // decode the binary message into a JSON array - } else { - throw new Boom('Bad checksum', { - data: { - received: checksum.toString('hex'), - computed: computedChecksum.toString('hex'), - data: data.slice(0, 80).toString(), - tag: messageTag, - message: message.slice(0, 80).toString() - }, - statusCode: DisconnectReason.badSession - }) - } - } + chatId = from + } + msgType = 'chat' + author = from + } else if(isJidGroup(from)) { + if(!participant) { + throw new Boom('No participant in group message') + } + msgType = 'group' + author = participant + chatId = from + } else if(isJidBroadcast(from)) { + if(!participant) { + throw new Boom('No participant in group message') + } + const isParticipantMe = isMe(participant) + if(isJidStatusBroadcast(from)) { + msgType = isParticipantMe ? 'direct_peer_status' : 'other_status' + } else { + msgType = isParticipantMe ? 'peer_broadcast' : 'other_broadcast' + } + chatId = from + author = participant + } + const sender = msgType === 'chat' ? author : chatId + + const successes: proto.Message[] = [] + const failures: { error: Boom }[] = [] + if(Array.isArray(stanza.content)) { + for(const { tag, attrs, content } of stanza.content as BinaryNodeM[]) { + if(tag !== 'enc') continue + if(!Buffer.isBuffer(content) && !(content instanceof Uint8Array)) continue + + try { + let msgBuffer: Buffer + + const e2eType = attrs.type + switch(e2eType) { + case 'skmsg': + msgBuffer = await decryptGroupSignalProto(sender, author, content, auth) + break + case 'pkmsg': + case 'msg': + const user = isJidUser(sender) ? sender : author + msgBuffer = await decryptSignalProto(user, e2eType, content as Buffer, auth) + break + } + const msg = proto.Message.decode(unpadRandomMax16(msgBuffer)) + if(msg.senderKeyDistributionMessage) { + await processSenderKeyMessage(author, msg.senderKeyDistributionMessage, auth) + } + + successes.push(msg) + } catch(error) { + failures.push({ error: new Boom(error, { data: Buffer.from(encodeBinaryNode(stanza)).toString('base64') }) }) + } + } + } + + return { + msgId, + chatId, + author, + from, + timestamp: +stanza.attrs.t, + participant, + recipient, + pushname: stanza.attrs.notify, + successes, + failures } - return [messageTag, json, tags] as const } \ No newline at end of file diff --git a/src/Utils/generics.ts b/src/Utils/generics.ts index 3435a85..242c60b 100644 --- a/src/Utils/generics.ts +++ b/src/Utils/generics.ts @@ -1,7 +1,10 @@ import { Boom } from '@hapi/boom' +import CurveCrypto from 'libsignal/src/curve25519_wrapper' import { createCipheriv, createDecipheriv, createHash, createHmac, randomBytes } from 'crypto' -import HKDF from 'futoin-hkdf' import { platform, release } from 'os' +import { KeyPair } from '../Types' +import { proto } from '../../WAProto' +import { Binary } from '../WABinary' const PLATFORM_MAP = { 'aix': 'AIX', @@ -9,6 +12,7 @@ const PLATFORM_MAP = { 'win32': 'Windows', 'android': 'Android' } + export const Browsers = { ubuntu: browser => ['Ubuntu', browser, '18.04'] as [string, string, string], macOS: browser => ['Mac OS', browser, '10.15.3'] as [string, string, string], @@ -16,6 +20,118 @@ export const Browsers = { /** The appropriate browser based on your OS & release */ appropriate: browser => [ PLATFORM_MAP[platform()] || 'Ubuntu', browser, release() ] as [string, string, string] } + +export const BufferJSON = { + replacer: (k, value: any) => { + if(Buffer.isBuffer(value) || value instanceof Uint8Array || value?.type === 'Buffer') { + return { type: 'Buffer', data: Buffer.from(value?.data || value).toString('base64') } + } + return value + }, + reviver: (_, value: any) => { + if(typeof value === 'object' && !!value && (value.buffer === true || value.type === 'Buffer')) { + const val = value.data || value.value + return typeof val === 'string' ? Buffer.from(val, 'base64') : Buffer.from(val) + } + return value + } +} + + +export const writeRandomPadMax16 = function(e: Binary) { + function r(e: Binary, t: number) { + for (var r = 0; r < t; r++) + e.writeUint8(t) + } + + var t = randomBytes(1) + r(e, 1 + (15 & t[0])) + return e +} + +export const unpadRandomMax16 = (e: Uint8Array | Buffer) => { + const t = new Uint8Array(e); + if (0 === t.length) { + throw new Error('unpadPkcs7 given empty bytes'); + } + + var r = t[t.length - 1]; + if (r > t.length) { + throw new Error(`unpad given ${t.length} bytes, but pad is ${r}`); + } + + return new Uint8Array(t.buffer, t.byteOffset, t.length - r); +} + +export const encodeWAMessage = (message: proto.IMessage) => ( + Buffer.from( + writeRandomPadMax16( + new Binary(proto.Message.encode(message).finish()) + ).readByteArray() + ) +) + +export const generateCurveKeyPair = (): KeyPair => { + const { pubKey, privKey } = CurveCrypto.keyPair(randomBytes(32)) + return { + private: Buffer.from(privKey), + public: Buffer.from(pubKey) + } +} + +export const generateSharedKey = (privateKey: Uint8Array, publicKey: Uint8Array) => { + const shared = CurveCrypto.sharedSecret(publicKey, privateKey) + return Buffer.from(shared) +} + +export const curveSign = (privateKey: Uint8Array, buf: Uint8Array) => ( + Buffer.from(CurveCrypto.sign(privateKey, buf)) +) + +export const curveVerify = (pubKey: Uint8Array, message: Uint8Array, signature: Uint8Array) => { + try { + CurveCrypto.verify(pubKey, message, signature) + return true + } catch(error) { + if(error.message.includes('Invalid')) { + return false + } + throw error + } +} + +export const signedKeyPair = (keyPair: KeyPair, keyId: number) => { + const signKeys = generateCurveKeyPair() + const pubKey = new Uint8Array(33) + pubKey.set([5], 0) + pubKey.set(signKeys.public, 1) + + const signature = curveSign(keyPair.private, pubKey) + + return { keyPair: signKeys, signature, keyId } +} + +export const generateRegistrationId = () => ( + Uint16Array.from(randomBytes(2))[0] & 0x3fff +) + +export const encodeInt = (e: number, t: number) => { + for (var r = t, a = new Uint8Array(e), i = e - 1; i >= 0; i--) { + a[i] = 255 & r + r >>>= 8 + } + return a +} +export const encodeBigEndian = (e: number, t=4) => { + let r = e; + let a = new Uint8Array(t); + for (let i = t - 1; i >= 0; i--) { + a[i] = 255 & r + r >>>= 8 + } + return a +} + export const toNumber = (t: Long | number) => (typeof t?.['low'] !== 'undefined' ? t['low'] : t) as number export const whatsappID = (jid: string) => jid?.replace ('@c.us', '@s.whatsapp.net') @@ -48,7 +164,7 @@ export function aesDecryptWithIV(buffer: Buffer, key: Buffer, IV: Buffer) { return Buffer.concat([aes.update(buffer), aes.final()]) } // encrypt AES 256 CBC; where a random IV is prefixed to the buffer -export function aesEncrypt(buffer: Buffer, key: Buffer) { +export function aesEncrypt(buffer: Buffer | Uint8Array, key: Buffer) { const IV = randomBytes(16) const aes = createCipheriv('aes-256-cbc', key, IV) return Buffer.concat([IV, aes.update(buffer), aes.final()]) // prefix IV to the buffer @@ -59,20 +175,47 @@ export function aesEncrypWithIV(buffer: Buffer, key: Buffer, IV: Buffer) { return Buffer.concat([aes.update(buffer), aes.final()]) // prefix IV to the buffer } // sign HMAC using SHA 256 -export function hmacSign(buffer: Buffer, key: Buffer) { - return createHmac('sha256', key).update(buffer).digest() +export function hmacSign(buffer: Buffer | Uint8Array, key: Buffer | Uint8Array, variant: 'sha256' | 'sha512' = 'sha256') { + return createHmac(variant, key).update(buffer).digest() } export function sha256(buffer: Buffer) { return createHash('sha256').update(buffer).digest() } // HKDF key expansion -export function hkdf(buffer: Buffer, expandedLength: number, info = null) { - return HKDF(buffer, expandedLength, { salt: Buffer.alloc(32), info: info, hash: 'SHA-256' }) +// from: https://github.com/benadida/node-hkdf +export function hkdf(buffer: Buffer, expandedLength: number, { info, salt }: { salt?: Buffer, info?: string }) { + const hashAlg = 'sha256' + const hashLength = 32 + salt = salt || Buffer.alloc(hashLength) + // now we compute the PRK + const prk = createHmac(hashAlg, salt).update(buffer).digest() + + let prev = Buffer.from([]) + const buffers = [] + const num_blocks = Math.ceil(expandedLength / hashLength) + + const infoBuff = Buffer.from(info || []) + + for (var i=0; i Math.floor(date.getTime()/1000) export type DebouncedTimeout = ReturnType + export const debouncedTimeout = (intervalMs: number = 1000, task: () => void = undefined) => { let timeout: NodeJS.Timeout return { @@ -135,14 +278,5 @@ export async function promiseTimeout(ms: number, promise: (resolve: (v?: T)=> .finally (cancel) return p as Promise } -// whatsapp requires a message tag for every message, we just use the timestamp as one -export function generateMessageTag(epoch?: number) { - let tag = unixTimestampSeconds().toString() - if (epoch) tag += '.--' + epoch // attach epoch if provided - return tag -} -// generate a random 16 byte client ID -export const generateClientID = () => randomBytes(16).toString('base64') // generate a random ID to attach to a message -// this is the format used for WA Web 4 byte hex prefixed with 3EB0 -export const generateMessageID = () => '3EB0' + randomBytes(4).toString('hex').toUpperCase() \ No newline at end of file +export const generateMessageID = () => 'BAE5' + randomBytes(6).toString('hex').toUpperCase() \ No newline at end of file diff --git a/src/Utils/history.ts b/src/Utils/history.ts new file mode 100644 index 0000000..b304c0a --- /dev/null +++ b/src/Utils/history.ts @@ -0,0 +1,25 @@ +import { downloadContentFromMessage } from "./messages-media"; +import { proto } from "../../WAProto"; +import { promisify } from 'util' +import { inflate } from "zlib"; + +const inflatePromise = promisify(inflate) + +export const downloadIfHistory = (message: proto.IMessage) => { + if(message.protocolMessage?.historySyncNotification) { + return downloadHistory(message.protocolMessage!.historySyncNotification) + } +} + +export const downloadHistory = async(msg: proto.IHistorySyncNotification) => { + const stream = await downloadContentFromMessage(msg, 'history') + let buffer = Buffer.from([]) + for await(const chunk of stream) { + buffer = Buffer.concat([buffer, chunk]) + } + // decompress buffer + buffer = await inflatePromise(buffer) + + const syncData = proto.HistorySync.decode(buffer) + return syncData +} \ No newline at end of file diff --git a/src/Utils/messages-media.ts b/src/Utils/messages-media.ts index 798a8ca..b987422 100644 --- a/src/Utils/messages-media.ts +++ b/src/Utils/messages-media.ts @@ -1,21 +1,18 @@ -import type { Agent } from 'https' import type { Logger } from 'pino' import type { IAudioMetadata } from 'music-metadata' +import { Boom } from '@hapi/boom' import * as Crypto from 'crypto' import { Readable, Transform } from 'stream' import { createReadStream, createWriteStream, promises as fs, WriteStream } from 'fs' import { exec } from 'child_process' import { tmpdir } from 'os' -import HttpsProxyAgent from 'https-proxy-agent' import { URL } from 'url' -import { MessageType, WAMessageContent, WAMessageProto, WAGenericMediaMessage, WAMediaUpload } from '../Types' -import got, { Options, Response } from 'got' import { join } from 'path' -import { generateMessageID, hkdf } from './generics' -import { Boom } from '@hapi/boom' -import { MediaType } from '../Types' -import { DEFAULT_ORIGIN } from '../Defaults' import { once } from 'events' +import got, { Options, Response } from 'got' +import { MessageType, WAMessageContent, WAProto, WAGenericMediaMessage, WAMediaUpload, MediaType } from '../Types' +import { generateMessageID, hkdf } from './generics' +import { DEFAULT_ORIGIN } from '../Defaults' export const hkdfInfoKey = (type: MediaType) => { if(type === 'sticker') type = 'image' @@ -29,7 +26,7 @@ export function getMediaKeys(buffer, mediaType: MediaType) { buffer = Buffer.from(buffer.replace('data:;base64,', ''), 'base64') } // expand using HKDF to 112 bytes, also pass in the relevant app info - const expandedMediaKey = hkdf(buffer, 112, hkdfInfoKey(mediaType)) + const expandedMediaKey = hkdf(buffer, 112, { info: hkdfInfoKey(mediaType) }) return { iv: expandedMediaKey.slice(0, 16), cipherKey: expandedMediaKey.slice(16, 48), @@ -54,20 +51,18 @@ const extractVideoThumb = async ( export const compressImage = async (bufferOrFilePath: Buffer | string) => { const { read, MIME_JPEG } = await import('jimp') const jimp = await read(bufferOrFilePath as any) - const result = await jimp.resize(48, 48).getBufferAsync(MIME_JPEG) + const result = await jimp.resize(32, 32).getBufferAsync(MIME_JPEG) return result } -export const generateProfilePicture = async (buffer: Buffer) => { +export const generateProfilePicture = async (bufferOrFilePath: Buffer | string) => { const { read, MIME_JPEG } = await import('jimp') - const jimp = await read (buffer) + const jimp = await read(bufferOrFilePath as any) const min = Math.min(jimp.getWidth (), jimp.getHeight ()) const cropped = jimp.crop (0, 0, min, min) return { - img: await cropped.resize(640, 640).getBufferAsync (MIME_JPEG), - preview: await cropped.resize(96, 96).getBufferAsync (MIME_JPEG) + img: await cropped.resize(640, 640).getBufferAsync(MIME_JPEG), } } -export const ProxyAgent = (host: string | URL) => HttpsProxyAgent(host) as any as Agent /** gets the SHA256 of the given media message */ export const mediaMessageSHA256B64 = (message: WAMessageContent) => { const media = Object.values(message)[0] as WAGenericMediaMessage @@ -113,7 +108,7 @@ export async function generateThumbnail( } else if(mediaType === 'video') { const imgFilename = join(tmpdir(), generateMessageID() + '.jpg') try { - await extractVideoThumb(file, imgFilename, '00:00:00', { width: 48, height: 48 }) + await extractVideoThumb(file, imgFilename, '00:00:00', { width: 32, height: 32 }) const buff = await fs.readFile(imgFilename) thumbnail = buff.toString('base64') @@ -205,6 +200,47 @@ export const encryptedStream = async(media: WAMediaUpload, mediaType: MediaType, didSaveToTmpPath } } +const DEF_HOST = 'mmg.whatsapp.net' +export const downloadContentFromMessage = async( + { mediaKey, directPath, url }: { mediaKey?: Uint8Array, directPath?: string, url?: string }, + type: MediaType +) => { + const downloadUrl = url || `https://${DEF_HOST}${directPath}` + // download the message + const fetched = await getGotStream(downloadUrl, { + headers: { Origin: DEFAULT_ORIGIN } + }) + let remainingBytes = Buffer.from([]) + const { cipherKey, iv } = getMediaKeys(mediaKey, type) + const aes = Crypto.createDecipheriv("aes-256-cbc", cipherKey, iv) + + const output = new Transform({ + transform(chunk, _, callback) { + let data = Buffer.concat([remainingBytes, chunk]) + const decryptLength = + Math.floor(data.length / 16) * 16 + remainingBytes = data.slice(decryptLength) + data = data.slice(0, decryptLength) + + try { + this.push(aes.update(data)) + callback() + } catch(error) { + callback(error) + } + }, + final(callback) { + try { + this.push(aes.final()) + callback() + } catch(error) { + callback(error) + } + }, + }) + return fetched.pipe(output, { end: true }) +} + /** * Decode a media message (video, image, document, audio) & return decrypted buffer * @param message the media message you want to decode @@ -237,39 +273,7 @@ export async function decryptMediaMessageBuffer(message: WAMessageContent): Prom } else { messageContent = message[type] } - // download the message - const fetched = await getGotStream(messageContent.url, { - headers: { Origin: DEFAULT_ORIGIN } - }) - let remainingBytes = Buffer.from([]) - const { cipherKey, iv } = getMediaKeys(messageContent.mediaKey, type.replace('Message', '') as MediaType) - const aes = Crypto.createDecipheriv("aes-256-cbc", cipherKey, iv) - - const output = new Transform({ - transform(chunk, _, callback) { - let data = Buffer.concat([remainingBytes, chunk]) - const decryptLength = - Math.floor(data.length / 16) * 16 - remainingBytes = data.slice(decryptLength) - data = data.slice(0, decryptLength) - - try { - this.push(aes.update(data)) - callback() - } catch(error) { - callback(error) - } - }, - final(callback) { - try { - this.push(aes.final()) - callback() - } catch(error) { - callback(error) - } - }, - }) - return fetched.pipe(output, { end: true }) + return downloadContentFromMessage(messageContent, type.replace('Message', '') as MediaType) } export function extensionForMediaMessage(message: WAMessageContent) { const getExtension = (mimetype: string) => mimetype.split(';')[0].split('/')[1] @@ -283,10 +287,10 @@ export function extensionForMediaMessage(message: WAMessageContent) { extension = '.jpeg' } else { const messageContent = message[type] as - | WAMessageProto.VideoMessage - | WAMessageProto.ImageMessage - | WAMessageProto.AudioMessage - | WAMessageProto.DocumentMessage + | WAProto.VideoMessage + | WAProto.ImageMessage + | WAProto.AudioMessage + | WAProto.DocumentMessage extension = getExtension (messageContent.mimetype) } return extension diff --git a/src/Utils/messages.ts b/src/Utils/messages.ts index 7e81860..13c58ec 100644 --- a/src/Utils/messages.ts +++ b/src/Utils/messages.ts @@ -1,6 +1,6 @@ import { Boom } from '@hapi/boom' import { createReadStream, promises as fs } from "fs" -import { proto } from '../../WAMessage' +import { proto } from '../../WAProto' import { MEDIA_KEYS, URL_REGEX, WA_DEFAULT_EPHEMERAL } from "../Defaults" import { AnyMediaMessageContent, @@ -13,7 +13,7 @@ import { WAMediaUpload, WAMessage, WAMessageContent, - WAMessageProto, + WAProto, WATextMessage, MediaType, WAMessageStatus @@ -38,14 +38,15 @@ const MIMETYPE_MAP: { [T in MediaType]: string } = { document: 'application/pdf', audio: 'audio/ogg; codecs=opus', sticker: 'image/webp', + history: 'application/x-protobuf' } const MessageTypeProto = { - 'image': WAMessageProto.ImageMessage, - 'video': WAMessageProto.VideoMessage, - 'audio': WAMessageProto.AudioMessage, - 'sticker': WAMessageProto.StickerMessage, - 'document': WAMessageProto.DocumentMessage, + 'image': WAProto.ImageMessage, + 'video': WAProto.VideoMessage, + 'audio': WAProto.AudioMessage, + 'sticker': WAProto.StickerMessage, + 'document': WAProto.DocumentMessage, } as const const ButtonType = proto.ButtonsMessage.ButtonsMessageHeaderType @@ -69,7 +70,7 @@ export const prepareWAMessageMedia = async( if(typeof uploadData.media === 'object' && 'url' in uploadData.media) { const result = !!options.mediaCache && await options.mediaCache!(uploadData.media.url?.toString()) if(result) { - return WAMessageProto.Message.fromObject({ + return WAProto.Message.fromObject({ [`${mediaType}Message`]: result }) } @@ -136,7 +137,7 @@ export const prepareWAMessageMedia = async( } ) } - return WAMessageProto.Message.fromObject(content) + return WAProto.Message.fromObject(content) } export const prepareDisappearingMessageSettingContent = (ephemeralExpiration?: number) => { ephemeralExpiration = ephemeralExpiration || 0 @@ -144,13 +145,13 @@ export const prepareDisappearingMessageSettingContent = (ephemeralExpiration?: n ephemeralMessage: { message: { protocolMessage: { - type: WAMessageProto.ProtocolMessage.ProtocolMessageType.EPHEMERAL_SETTING, + type: WAProto.ProtocolMessage.ProtocolMessageType.EPHEMERAL_SETTING, ephemeralExpiration } } } } - return WAMessageProto.Message.fromObject(content) + return WAProto.Message.fromObject(content) } /** * Generate forwarded message content like WA does @@ -207,14 +208,14 @@ export const generateWAMessageContent = async( throw new Boom('require atleast 1 contact', { statusCode: 400 }) } if(contactLen === 1) { - m.contactMessage = WAMessageProto.ContactMessage.fromObject(message.contacts.contacts[0]) + m.contactMessage = WAProto.ContactMessage.fromObject(message.contacts.contacts[0]) } } else if('location' in message) { - m.locationMessage = WAMessageProto.LocationMessage.fromObject(message.location) + m.locationMessage = WAProto.LocationMessage.fromObject(message.location) } else if('delete' in message) { m.protocolMessage = { key: message.delete, - type: WAMessageProto.ProtocolMessage.ProtocolMessageType.REVOKE + type: WAProto.ProtocolMessage.ProtocolMessageType.REVOKE } } else if('forward' in message) { m = generateForwardMessageContent( @@ -259,7 +260,7 @@ export const generateWAMessageContent = async( m[messageType].contextInfo = m[messageType] || { } m[messageType].contextInfo.mentionedJid = message.mentions } - return WAMessageProto.Message.fromObject(m) + return WAProto.Message.fromObject(m) } export const generateWAMessageFromContent = ( jid: string, @@ -290,7 +291,7 @@ export const generateWAMessageFromContent = ( } if( // if we want to send a disappearing message - !!options?.ephemeralOptions && + !!options?.ephemeralExpiration && // and it's not a protocol message -- delete, toggle disappear message key !== 'protocolMessage' && // already not converted to disappearing message @@ -298,8 +299,8 @@ export const generateWAMessageFromContent = ( ) { message[key].contextInfo = { ...(message[key].contextInfo || {}), - expiration: options.ephemeralOptions.expiration || WA_DEFAULT_EPHEMERAL, - ephemeralSettingTimestamp: options.ephemeralOptions.eph_setting_ts?.toString() + expiration: options.ephemeralExpiration || WA_DEFAULT_EPHEMERAL, + //ephemeralSettingTimestamp: options.ephemeralOptions.eph_setting_ts?.toString() } message = { ephemeralMessage: { @@ -307,7 +308,7 @@ export const generateWAMessageFromContent = ( } } } - message = WAMessageProto.Message.fromObject (message) + message = WAProto.Message.fromObject (message) const messageJSON = { key: { @@ -321,7 +322,7 @@ export const generateWAMessageFromContent = ( participant: jid.includes('@g.us') ? userJid : undefined, status: WAMessageStatus.PENDING } - return WAMessageProto.WebMessageInfo.fromObject (messageJSON) + return WAProto.WebMessageInfo.fromObject (messageJSON) } export const generateWAMessage = async( jid: string, diff --git a/src/Utils/noise-handler.ts b/src/Utils/noise-handler.ts new file mode 100644 index 0000000..1f94871 --- /dev/null +++ b/src/Utils/noise-handler.ts @@ -0,0 +1,167 @@ +import { sha256, generateSharedKey, hkdf } from "./generics"; +import { Binary } from "../WABinary"; +import { createCipheriv, createDecipheriv } from "crypto"; +import { NOISE_MODE, NOISE_WA_HEADER } from "../Defaults"; +import { KeyPair } from "../Types"; +import { BinaryNode, decodeBinaryNode } from "../WABinary"; +import { Boom } from "@hapi/boom"; +import { proto } from '../../WAProto' + +const generateIV = (counter: number) => { + const iv = new ArrayBuffer(12); + new DataView(iv).setUint32(8, counter); + + return new Uint8Array(iv) +} + +export default ({ public: publicKey, private: privateKey }: KeyPair) => { + + const authenticate = (data: Uint8Array) => { + if(!isFinished) { + hash = sha256( Buffer.from(Binary.build(hash, data).readByteArray()) ) + } + } + const encrypt = (plaintext: Uint8Array) => { + const authTagLength = 128 >> 3 + const cipher = createCipheriv('aes-256-gcm', encKey, generateIV(writeCounter), { authTagLength }) + cipher.setAAD(hash) + + const result = Buffer.concat([cipher.update(plaintext), cipher.final(), cipher.getAuthTag()]) + + writeCounter += 1 + + authenticate(result) + return result + } + const decrypt = (ciphertext: Uint8Array) => { + // before the handshake is finished, we use the same counter + // after handshake, the counters are different + const iv = generateIV(isFinished ? readCounter : writeCounter) + const cipher = createDecipheriv('aes-256-gcm', decKey, iv) + // decrypt additional adata + const tagLength = 128 >> 3 + const enc = ciphertext.slice(0, ciphertext.length-tagLength) + const tag = ciphertext.slice(ciphertext.length-tagLength) + // set additional data + cipher.setAAD(hash) + cipher.setAuthTag(tag) + + const result = Buffer.concat([cipher.update(enc), cipher.final()]) + + if(isFinished) readCounter += 1 + else writeCounter += 1 + + authenticate(ciphertext) + return result + } + const localHKDF = (data: Uint8Array) => { + const key = hkdf(Buffer.from(data), 64, { salt, info: '' }) + return [key.slice(0, 32), key.slice(32)] + } + const mixIntoKey = (data: Uint8Array) => { + const [write, read] = localHKDF(data) + salt = write + encKey = read + decKey = read + readCounter = 0 + writeCounter = 0 + } + const finishInit = () => { + const [write, read] = localHKDF(new Uint8Array(0)) + encKey = write + decKey = read + hash = Buffer.from([]) + readCounter = 0 + writeCounter = 0 + isFinished = true + } + + const data = Binary.build(NOISE_MODE).readBuffer() + let hash = Buffer.from(data.byteLength === 32 ? data : sha256(Buffer.from(data))) + let salt = hash + let encKey = hash + let decKey = hash + let readCounter = 0 + let writeCounter = 0 + let isFinished = false + let sentIntro = false + + const outBinary = new Binary() + const inBinary = new Binary() + + authenticate(NOISE_WA_HEADER) + authenticate(publicKey) + + return { + encrypt, + decrypt, + authenticate, + mixIntoKey, + finishInit, + processHandshake: ({ serverHello }: proto.HandshakeMessage, noiseKey: KeyPair) => { + authenticate(serverHello!.ephemeral!) + mixIntoKey(generateSharedKey(privateKey, serverHello.ephemeral!)) + + const decStaticContent = decrypt(serverHello!.static!) + mixIntoKey(generateSharedKey(privateKey, decStaticContent)) + + const certDecoded = decrypt(serverHello!.payload!) + const { details: certDetails, signature: certSignature } = proto.NoiseCertificate.decode(certDecoded) + + const { issuer: certIssuer, key: certKey } = proto.Details.decode(certDetails) + + if(Buffer.compare(decStaticContent, certKey) !== 0) { + throw new Boom('certification match failed', { statusCode: 400 }) + } + + const keyEnc = encrypt(noiseKey.public) + mixIntoKey(generateSharedKey(noiseKey.private, serverHello!.ephemeral!)) + + return keyEnc + }, + encodeFrame: (data: Buffer | Uint8Array) => { + if(isFinished) { + data = encrypt(data) + } + const introSize = sentIntro ? 0 : NOISE_WA_HEADER.length + + outBinary.ensureAdditionalCapacity(introSize + 3 + data.byteLength) + + if (!sentIntro) { + outBinary.writeByteArray(NOISE_WA_HEADER) + sentIntro = true + } + + outBinary.writeUint8(data.byteLength >> 16) + outBinary.writeUint16(65535 & data.byteLength) + outBinary.write(data) + + const bytes = outBinary.readByteArray() + return bytes as Uint8Array + }, + decodeFrame: (newData: Buffer | Uint8Array, onFrame: (buff: Uint8Array | BinaryNode) => void) => { + // the binary protocol uses its own framing mechanism + // on top of the WS frames + // so we get this data and separate out the frames + const getBytesSize = () => { + return (inBinary.readUint8() << 16) | inBinary.readUint16() + } + const peekSize = () => { + return !(inBinary.size() < 3) && getBytesSize() <= inBinary.size() + } + + inBinary.writeByteArray(newData) + while(inBinary.peek(peekSize)) { + const bytes = getBytesSize() + let frame: Uint8Array | BinaryNode = inBinary.readByteArray(bytes) + if(isFinished) { + const result = decrypt(frame as Uint8Array) + const unpacked = new Binary(result).decompressed() + frame = decodeBinaryNode(unpacked) + } + onFrame(frame) + } + inBinary.peek(peekSize) + } + } +} \ No newline at end of file diff --git a/src/Utils/signal.ts b/src/Utils/signal.ts new file mode 100644 index 0000000..2940c7c --- /dev/null +++ b/src/Utils/signal.ts @@ -0,0 +1,253 @@ +import * as libsignal from 'libsignal' +import { encodeBigEndian, generateCurveKeyPair } from "./generics" +import { SenderKeyDistributionMessage, GroupSessionBuilder, SenderKeyRecord, SenderKeyName, GroupCipher } from '../../WASignalGroup' +import { SignalIdentity, SignalKeyStore, SignedKeyPair, KeyPair, AuthenticationState } from "../Types/Auth" +import { assertNodeErrorFree, BinaryNode, getBinaryNodeChild, getBinaryNodeChildBuffer, getBinaryNodeChildUInt, jidDecode } from "../WABinary" +import { proto } from "../../WAProto" + +export const generateSignalPubKey = (pubKey: Uint8Array | Buffer) => { + const newPub = Buffer.alloc(33) + newPub.set([5], 0) + newPub.set(pubKey, 1) + return newPub +} + +const jidToSignalAddress = (jid: string) => jid.split('@')[0] + +export const jidToSignalProtocolAddress = (jid: string) => { + return new libsignal.ProtocolAddress(jidToSignalAddress(jid), 0) +} + +export const jidToSignalSenderKeyName = (group: string, user: string): string => { + return new SenderKeyName(group, jidToSignalProtocolAddress(user)).toString() +} + +export const createSignalIdentity = ( + wid: string, + accountSignatureKey: Uint8Array +): SignalIdentity => { + return { + identifier: { name: wid, deviceId: 0 }, + identifierKey: generateSignalPubKey(accountSignatureKey) + } +} + +export const getPreKeys = async({ getPreKey }: SignalKeyStore, min: number, limit: number) => { + const dict: { [id: number]: KeyPair } = { } + for(let id = min; id < limit;id++) { + const key = await getPreKey(id) + if(key) dict[+id] = key + } + return dict +} + +export const generateOrGetPreKeys = ({ creds }: AuthenticationState, range: number) => { + const avaliable = creds.nextPreKeyId - creds.firstUnuploadedPreKeyId + const remaining = range - avaliable + const lastPreKeyId = creds.nextPreKeyId + remaining - 1 + const newPreKeys: { [id: number]: KeyPair } = { } + if(remaining > 0) { + for(let i = creds.nextPreKeyId;i <= lastPreKeyId;i++) { + newPreKeys[i] = generateCurveKeyPair() + } + } + return { + newPreKeys, + lastPreKeyId, + preKeysRange: [creds.firstUnuploadedPreKeyId, range] as const, + } +} + + +export const xmppSignedPreKey = (key: SignedKeyPair): BinaryNode => ( + { + tag: 'skey', + attrs: { }, + content: [ + { tag: 'id', attrs: { }, content: encodeBigEndian(key.keyId, 3) }, + { tag: 'value', attrs: { }, content: key.keyPair.public }, + { tag: 'signature', attrs: { }, content: key.signature } + ] + } +) + +export const xmppPreKey = (pair: KeyPair, id: number): BinaryNode => ( + { + tag: 'key', + attrs: { }, + content: [ + { tag: 'id', attrs: { }, content: encodeBigEndian(id, 3) }, + { tag: 'value', attrs: { }, content: pair.public } + ] + } +) + +export const signalStorage = ({ creds, keys }: AuthenticationState) => ({ + loadSession: async id => { + const sess = await keys.getSession(id) + if(sess) { + return libsignal.SessionRecord.deserialize(sess) + } + }, + storeSession: async(id, session) => { + await keys.setSession(id, session.serialize()) + }, + isTrustedIdentity: () => { + return true + }, + loadPreKey: async(id: number) => { + const key = await keys.getPreKey(id) + if(key) { + return { + privKey: Buffer.from(key.private), + pubKey: Buffer.from(key.public) + } + } + }, + removePreKey: (id: number) => keys.setPreKey(id, null), + loadSignedPreKey: (keyId: number) => { + const key = creds.signedPreKey + return { + privKey: Buffer.from(key.keyPair.private), + pubKey: Buffer.from(key.keyPair.public) + } + }, + loadSenderKey: async(keyId) => { + const key = await keys.getSenderKey(keyId) + if(key) return new SenderKeyRecord(key) + }, + storeSenderKey: async(keyId, key) => { + await keys.setSenderKey(keyId, key.serialize()) + }, + getOurRegistrationId: () => ( + creds.registrationId + ), + getOurIdentity: () => { + const { signedIdentityKey } = creds + return { + privKey: Buffer.from(signedIdentityKey.private), + pubKey: generateSignalPubKey(signedIdentityKey.public), + } + } +}) + +export const decryptGroupSignalProto = (group: string, user: string, msg: Buffer | Uint8Array, auth: AuthenticationState) => { + const senderName = jidToSignalSenderKeyName(group, user) + const cipher = new GroupCipher(signalStorage(auth), senderName) + + return cipher.decrypt(Buffer.from(msg)) +} + +export const processSenderKeyMessage = async( + authorJid: string, + item: proto.ISenderKeyDistributionMessage, + auth: AuthenticationState +) => { + const builder = new GroupSessionBuilder(signalStorage(auth)) + const senderName = jidToSignalSenderKeyName(item.groupId, authorJid) + + const senderMsg = new SenderKeyDistributionMessage(null, null, null, null, item.axolotlSenderKeyDistributionMessage) + const senderKey = await auth.keys.getSenderKey(senderName) + if(!senderKey) { + const record = new SenderKeyRecord() + await auth.keys.setSenderKey(senderName, record) + } + await builder.process(senderName, senderMsg) +} + +export const decryptSignalProto = async(user: string, type: 'pkmsg' | 'msg', msg: Buffer | Uint8Array, auth: AuthenticationState) => { + const addr = jidToSignalProtocolAddress(user) + const session = new libsignal.SessionCipher(signalStorage(auth), addr) + let result: Buffer + switch(type) { + case 'pkmsg': + result = await session.decryptPreKeyWhisperMessage(msg) + break + case 'msg': + result = await session.decryptWhisperMessage(msg) + break + } + return result +} + + +export const encryptSignalProto = async(user: string, buffer: Buffer, auth: AuthenticationState) => { + const addr = jidToSignalProtocolAddress(user) + const cipher = new libsignal.SessionCipher(signalStorage(auth), addr) + + const { type, body } = await cipher.encrypt(buffer) + return { + type: type === 3 ? 'pkmsg' : 'msg', + ciphertext: Buffer.from(body, 'binary') + } +} + +export const encryptSenderKeyMsgSignalProto = async(group: string, data: Uint8Array | Buffer, auth: AuthenticationState) => { + const storage = signalStorage(auth) + const senderName = jidToSignalSenderKeyName(group, auth.creds.me!.id) + const builder = new GroupSessionBuilder(storage) + + const senderKey = await auth.keys.getSenderKey(senderName) + if(!senderKey) { + const record = new SenderKeyRecord() + await auth.keys.setSenderKey(senderName, record) + } + + const senderKeyDistributionMessage = await builder.create(senderName) + const session = new GroupCipher(storage, senderName) + return { + ciphertext: await session.encrypt(data) as Uint8Array, + senderKeyDistributionMessageKey: senderKeyDistributionMessage.serialize() as Buffer, + } +} + +export const parseAndInjectE2ESession = async(node: BinaryNode, auth: AuthenticationState) => { + const extractKey = (key: BinaryNode) => ( + key ? ({ + keyId: getBinaryNodeChildUInt(key, 'id', 3), + publicKey: generateSignalPubKey( + getBinaryNodeChildBuffer(key, 'value') + ), + signature: getBinaryNodeChildBuffer(key, 'signature'), + }) : undefined + ) + node = getBinaryNodeChild(getBinaryNodeChild(node, 'list'), 'user') + assertNodeErrorFree(node) + + const signedKey = getBinaryNodeChild(node, 'skey') + const key = getBinaryNodeChild(node, 'key') + const identity = getBinaryNodeChildBuffer(node, 'identity') + const jid = node.attrs.jid + const registrationId = getBinaryNodeChildUInt(node, 'registration', 4) + + const device = { + registrationId, + identityKey: generateSignalPubKey(identity), + signedPreKey: extractKey(signedKey), + preKey: extractKey(key) + } + const cipher = new libsignal.SessionBuilder(signalStorage(auth), jidToSignalProtocolAddress(jid)) + await cipher.initOutgoing(device) +} + +export const extractDeviceJids = (result: BinaryNode) => { + const extracted: { user: string, device?: number, agent?: number }[] = [] + for(const node of result.content as BinaryNode[]) { + const list = getBinaryNodeChild(node, 'list')?.content + if(list && Array.isArray(list)) { + for(const item of list) { + const { user } = jidDecode(item.attrs.jid) + const devicesNode = getBinaryNodeChild(item, 'devices') + const deviceListNode = getBinaryNodeChild(devicesNode, 'device-list') + if(Array.isArray(deviceListNode?.content)) { + for(const { tag, attrs } of deviceListNode!.content) { + if(tag === 'device') { + extracted.push({ user, device: +attrs.id }) + } + } + } + } + } + } + return extracted +} \ No newline at end of file diff --git a/src/Utils/validate-connection.ts b/src/Utils/validate-connection.ts index c506bd7..fa2c903 100644 --- a/src/Utils/validate-connection.ts +++ b/src/Utils/validate-connection.ts @@ -1,116 +1,204 @@ -import {Boom} from '@hapi/boom' -import * as Curve from 'curve25519-js' -import type { Contact } from '../Types/Contact' -import type { AnyAuthenticationCredentials, AuthenticationCredentials, AuthenticationCredentialsBase64, CurveKeyPair } from "../Types" -import { aesDecrypt, hkdf, hmacSign, whatsappID } from './generics' -import { readFileSync } from 'fs' +import { Boom } from '@hapi/boom' +import { randomBytes } from 'crypto' +import { proto } from '../../WAProto' +import type { AuthenticationState, SocketConfig, SignalKeyStore, AuthenticationCreds, KeyPair } from "../Types" +import { curveSign, hmacSign, curveVerify, encodeInt, generateCurveKeyPair, generateRegistrationId, signedKeyPair } from './generics' +import { BinaryNode, S_WHATSAPP_NET, jidDecode, Binary } from '../WABinary' +import { createSignalIdentity } from './signal' -export const normalizedAuthInfo = (authInfo: AnyAuthenticationCredentials | string) => { - if (!authInfo) return - - if (typeof authInfo === 'string') { - const file = readFileSync(authInfo, { encoding: 'utf-8' }) // load a closed session back if it exists - authInfo = JSON.parse(file) as AnyAuthenticationCredentials - } - if ('clientID' in authInfo) { - authInfo = { - clientID: authInfo.clientID, - serverToken: authInfo.serverToken, - clientToken: authInfo.clientToken, - encKey: Buffer.isBuffer(authInfo.encKey) ? authInfo.encKey : Buffer.from(authInfo.encKey, 'base64'), - macKey: Buffer.isBuffer(authInfo.macKey) ? authInfo.macKey : Buffer.from(authInfo.macKey, 'base64'), - } - } else { - const secretBundle: {encKey: string, macKey: string} = typeof authInfo.WASecretBundle === 'string' ? JSON.parse (authInfo.WASecretBundle): authInfo.WASecretBundle - authInfo = { - clientID: authInfo.WABrowserId.replace(/\"/g, ''), - serverToken: authInfo.WAToken2.replace(/\"/g, ''), - clientToken: authInfo.WAToken1.replace(/\"/g, ''), - encKey: Buffer.from(secretBundle.encKey, 'base64'), // decode from base64 - macKey: Buffer.from(secretBundle.macKey, 'base64'), // decode from base64 - } - } - return authInfo as AuthenticationCredentials +const ENCODED_VERSION = 'S9Kdc4pc4EJryo21snc5cg==' +const getUserAgent = ({ version, browser }: Pick) => ({ + appVersion: { + primary: version[0], + secondary: version[1], + tertiary: version[2], + }, + platform: 14, + releaseChannel: 0, + mcc: "000", + mnc: "000", + osVersion: browser[2], + manufacturer: "", + device: browser[1], + osBuildNumber: "0.1", + localeLanguageIso6391: 'en', + localeCountryIso31661Alpha2: 'en', +}) + +export const generateLoginNode = (userJid: string, config: Pick) => { + const { user, device } = jidDecode(userJid) + const payload = { + passive: true, + connectType: 1, + connectReason: 1, + userAgent: getUserAgent(config), + webInfo: { webSubPlatform: 0 }, + username: parseInt(user, 10), + device: device, + } + return proto.ClientPayload.encode(payload).finish() } -export const base64EncodedAuthenticationCredentials = (creds: AnyAuthenticationCredentials) => { - const normalized = normalizedAuthInfo(creds) - return { - ...normalized, - encKey: normalized.encKey.toString('base64'), - macKey: normalized.macKey.toString('base64') - } as AuthenticationCredentialsBase64 -} - -/** -* Once the QR code is scanned and we can validate our connection, or we resolved the challenge when logging back in -* @private -* @param json -*/ -export const validateNewConnection = ( - json: { [_: string]: any }, - auth: AuthenticationCredentials, - curveKeys: CurveKeyPair +export const generateRegistrationNode = ( + { registrationId, signedPreKey, signedIdentityKey }: Pick, + config: Pick ) => { - // set metadata: one's WhatsApp ID [cc][number]@s.whatsapp.net, name on WhatsApp, info about the phone - const onValidationSuccess = () => { - const user: Contact = { - jid: whatsappID(json.wid), - name: json.pushname - } - return { user, auth, phone: json.phone } - } - if (!json.secret) { - // if we didn't get a secret, we don't need it, we're validated - if (json.clientToken && json.clientToken !== auth.clientToken) { - auth = { ...auth, clientToken: json.clientToken } - } - if (json.serverToken && json.serverToken !== auth.serverToken) { - auth = { ...auth, serverToken: json.serverToken } - } - return onValidationSuccess() - } - const secret = Buffer.from(json.secret, 'base64') - if (secret.length !== 144) { - throw new Error ('incorrect secret length received: ' + secret.length) - } + const appVersionBuf = new Uint8Array(Buffer.from(ENCODED_VERSION, "base64")); - // generate shared key from our private key & the secret shared by the server - const sharedKey = Curve.sharedKey(curveKeys.private, secret.slice(0, 32)) - // expand the key to 80 bytes using HKDF - const expandedKey = hkdf(sharedKey as Buffer, 80) + const companion = { + os: config.browser[0], + version: { + primary: 10, + secondary: undefined, + tertiary: undefined, + }, + platformType: 1, + requireFullSync: false, + }; - // perform HMAC validation. - const hmacValidationKey = expandedKey.slice(32, 64) - const hmacValidationMessage = Buffer.concat([secret.slice(0, 32), secret.slice(64, secret.length)]) + const companionProto = proto.CompanionProps.encode(companion).finish() - const hmac = hmacSign(hmacValidationMessage, hmacValidationKey) + const registerPayload = { + connectReason: 1, + connectType: 1, + passive: false, + regData: { + buildHash: appVersionBuf, + companionProps: companionProto, + eRegid: encodeInt(4, registrationId), + eKeytype: encodeInt(1, 5), + eIdent: signedIdentityKey.public, + eSkeyId: encodeInt(3, signedPreKey.keyId), + eSkeyVal: signedPreKey.keyPair.public, + eSkeySig: signedPreKey.signature, + }, + userAgent: getUserAgent(config), + webInfo: { + webSubPlatform: 0, + }, + } - if (!hmac.equals(secret.slice(32, 64))) { - // if the checksums didn't match - throw new Boom('HMAC validation failed', { statusCode: 400 }) - } - - // computed HMAC should equal secret[32:64] - // expandedKey[64:] + secret[64:] are the keys, encrypted using AES, that are used to encrypt/decrypt the messages recieved from WhatsApp - // they are encrypted using key: expandedKey[0:32] - const encryptedAESKeys = Buffer.concat([ - expandedKey.slice(64, expandedKey.length), - secret.slice(64, secret.length), - ]) - const decryptedKeys = aesDecrypt(encryptedAESKeys, expandedKey.slice(0, 32)) - // set the credentials - auth = { - encKey: decryptedKeys.slice(0, 32), // first 32 bytes form the key to encrypt/decrypt messages - macKey: decryptedKeys.slice(32, 64), // last 32 bytes from the key to sign messages - clientToken: json.clientToken, - serverToken: json.serverToken, - clientID: auth.clientID, - } - return onValidationSuccess() + return proto.ClientPayload.encode(registerPayload).finish() } -export const computeChallengeResponse = (challenge: string, auth: AuthenticationCredentials) => { - const bytes = Buffer.from(challenge, 'base64') // decode the base64 encoded challenge string - const signed = hmacSign(bytes, auth.macKey).toString('base64') // sign the challenge string with our macKey - return[ 'admin', 'challenge', signed, auth.serverToken, auth.clientID] // prepare to send this signed string with the serverToken & clientID + +export const initInMemoryKeyStore = ( + { preKeys, sessions, senderKeys }: { + preKeys?: { [k: number]: KeyPair }, + sessions?: { [k: string]: any }, + senderKeys?: { [k: string]: any } + } = { }, +) => { + preKeys = preKeys || { } + sessions = sessions || { } + senderKeys = senderKeys || { } + return { + preKeys, + sessions, + senderKeys, + getPreKey: keyId => preKeys[keyId], + setPreKey: (keyId, pair) => { + if(pair) preKeys[keyId] = pair + else delete preKeys[keyId] + }, + getSession: id => sessions[id], + setSession: (id, item) => { + if(item) sessions[id] = item + else delete sessions[id] + }, + getSenderKey: id => { + return senderKeys[id] + }, + setSenderKey: (id, item) => { + if(item) senderKeys[id] = item + else delete senderKeys[id] + } + } as SignalKeyStore +} + +export const initAuthState = (): AuthenticationState => { + const identityKey = generateCurveKeyPair() + return { + creds: { + noiseKey: generateCurveKeyPair(), + signedIdentityKey: identityKey, + signedPreKey: signedKeyPair(identityKey, 1), + registrationId: generateRegistrationId(), + advSecretKey: randomBytes(32).toString('base64'), + + nextPreKeyId: 1, + firstUnuploadedPreKeyId: 1, + serverHasPreKeys: false + }, + keys: initInMemoryKeyStore() + } +} + +export const configureSuccessfulPairing = ( + stanza: BinaryNode, + { advSecretKey, signedIdentityKey, signalIdentities }: Pick +) => { + const pair = stanza.content[0] as BinaryNode + const pairContent = Array.isArray(pair.content) ? pair.content : [] + + const msgId = stanza.attrs.id + const deviceIdentity = pairContent.find(m => m.tag === 'device-identity')?.content + const businessName = pairContent.find(m => m.tag === 'biz')?.attrs?.name + const verifiedName = businessName || '' + const jid = pairContent.find(m => m.tag === 'device')?.attrs?.jid + + const { details, hmac } = proto.ADVSignedDeviceIdentityHMAC.decode(deviceIdentity as Buffer) + + const advSign = hmacSign(details, Buffer.from(advSecretKey, 'base64')) + + if (Buffer.compare(hmac, advSign) !== 0) { + throw new Boom('Invalid pairing') + } + + const account = proto.ADVSignedDeviceIdentity.decode(details) + const { accountSignatureKey, accountSignature } = account + + const accountMsg = Binary.build(new Uint8Array([6, 0]), account.details, signedIdentityKey.public).readByteArray() + if (!curveVerify(accountSignatureKey, accountMsg, accountSignature)) { + throw new Boom('Failed to verify account signature') + } + + const deviceMsg = Binary.build(new Uint8Array([6, 1]), account.details, signedIdentityKey.public, account.accountSignatureKey).readByteArray() + account.deviceSignature = curveSign(signedIdentityKey.private, deviceMsg) + + const identity = createSignalIdentity(jid, accountSignatureKey) + + const keyIndex = proto.ADVDeviceIdentity.decode(account.details).keyIndex + + const accountEnc = proto.ADVSignedDeviceIdentity.encode({ + ...account.toJSON(), + accountSignatureKey: undefined + }).finish() + + const reply: BinaryNode = { + tag: 'iq', + attrs: { + to: S_WHATSAPP_NET, + type: 'result', + id: msgId, + }, + content: [ + { + tag: 'pair-device-sign', + attrs: { }, + content: [ + { tag: 'device-identity', attrs: { 'key-index': `${keyIndex}` }, content: accountEnc } + ] + } + ] + } + + const authUpdate: Partial = { + account, + me: { id: jid, verifiedName }, + signalIdentities: [...(signalIdentities || []), identity] + } + return { + creds: authUpdate, + reply + } } \ No newline at end of file diff --git a/src/WABinary/JidUtils.ts b/src/WABinary/JidUtils.ts new file mode 100644 index 0000000..492e050 --- /dev/null +++ b/src/WABinary/JidUtils.ts @@ -0,0 +1,47 @@ +export const S_WHATSAPP_NET = '@s.whatsapp.net' +export const OFFICIAL_BIZ_JID = '16505361212@c.us' +export const SERVER_JID = 'server@c.us' +export const PSA_WID = '0@c.us'; +export const STORIES_JID = 'status@broadcast' + +export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call' + +export const jidEncode = (user: string | number | null, server: JidServer, device?: number, agent?: number) => { + return `${user || ''}${!!agent ? `_${agent}` : ''}${!!device ? `:${device}` : ''}@${server}` +} + +export const jidDecode = (jid: string) => { + let sepIdx = typeof jid === 'string' ? jid.indexOf('@') : -1 + if(sepIdx < 0) { + return undefined + } + const server = jid.slice(sepIdx+1) + const userCombined = jid.slice(0, sepIdx) + + const [userAgent, device] = userCombined.split(':') + const [user, agent] = userAgent.split('_') + + return { + server, + user, + agent: agent ? +agent : undefined, + device: device ? +device : undefined + } +} +/** is the jid a user */ +export const areJidsSameUser = (jid1: string, jid2: string) => ( + jidDecode(jid1)?.user === jidDecode(jid2)?.user +) +/** is the jid a user */ +export const isJidUser = (jid: string) => (jid?.endsWith('@s.whatsapp.net')) +/** is the jid a broadcast */ +export const isJidBroadcast = (jid: string) => (jid?.endsWith('@broadcast')) +/** is the jid a broadcast */ +export const isJidGroup = (jid: string) => (jid?.endsWith('@g.us')) +/** is the jid the status broadcast */ +export const isJidStatusBroadcast = (jid: string) => jid === 'status@broadcast' + +export const jidNormalizedUser = (jid: string) => { + const { user, server } = jidDecode(jid) + return jidEncode(user, server === 'c.us' ? 's.whatsapp.net' : server as JidServer) +} \ No newline at end of file diff --git a/src/WABinary/LTHash.js b/src/WABinary/LTHash.js new file mode 100644 index 0000000..c902c60 --- /dev/null +++ b/src/WABinary/LTHash.js @@ -0,0 +1,48 @@ +import { hkdf } from "../Utils/generics"; + +const o = 128; + +class d { + constructor(e) { + this.salt = e + } + add(e, t) { + var r = this; + for(const item of t) { + e = r._addSingle(e, item) + } + return e + } + subtract(e, t) { + var r = this; + for(const item of t) { + e = r._subtractSingle(e, item) + } + return e + } + subtractThenAdd(e, t, r) { + var n = this; + return n.add(n.subtract(e, r), t) + } + _addSingle(e, t) { + var r = this; + const n = new Uint8Array(hkdf(t, o, { info: r.salt })).buffer; + return r.performPointwiseWithOverflow(e, n, ((e,t)=>e + t)) + } + _subtractSingle(e, t) { + var r = this; + + const n = new Uint8Array(hkdf(t, o, { info: r.salt })).buffer; + return r.performPointwiseWithOverflow(e, n, ((e,t)=>e - t)) + } + performPointwiseWithOverflow(e, t, r) { + const n = new DataView(e) + , i = new DataView(t) + , a = new ArrayBuffer(n.byteLength) + , s = new DataView(a); + for (let e = 0; e < n.byteLength; e += 2) + s.setUint16(e, r(n.getUint16(e, !0), i.getUint16(e, !0)), !0); + return a + } +} +export const LT_HASH_ANTI_TAMPERING = new d('WhatsApp Patch Integrity') \ No newline at end of file diff --git a/src/WABinary/index.ts b/src/WABinary/index.ts new file mode 100644 index 0000000..bcb8016 --- /dev/null +++ b/src/WABinary/index.ts @@ -0,0 +1,305 @@ +import { DICTIONARIES_MAP, SINGLE_BYTE_TOKEN, SINGLE_BYTE_TOKEN_MAP, DICTIONARIES } from '../../WABinary/Constants'; +import { jidDecode, jidEncode } from './JidUtils'; +import { Binary, numUtf8Bytes } from '../../WABinary/Binary'; +import { Boom } from '@hapi/boom'; + +const LIST1 = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '.', '�', '�', '�', '�']; +const LIST2 = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']; + +function k(data: Binary, uint: number) { + let arr = []; + for (let a = 0; a < uint; a++) { + arr.push(decodeBinaryNode(data)); + } + return arr; +} + +function x(data: Binary, t, r, a) { + const arr = new Array(2 * a - r); + for (let n = 0; n < arr.length - 1; n += 2) { + var s = data.readUint8(); + (arr[n] = t[s >>> 4]), (arr[n + 1] = t[15 & s]); + } + + if (r) { + arr[arr.length - 1] = t[data.readUint8() >>> 4]; + } + + return arr.join(''); +} + +function D(e, t, r) { + var a = e.length % 2 == 1; + r.writeUint8(t); + var i = Math.ceil(e.length / 2); + a && (i |= 128), r.writeUint8(i); + for (var n = 0, s = 0; s < e.length; s++) { + var o = e.charCodeAt(s), + l = null; + if ((48 <= o && o <= 57 ? (l = o - 48) : 255 === t ? (45 === o ? (l = 10) : 46 === o && (l = 11)) : 251 === t && 65 <= o && o <= 70 && (l = o - 55), null == l)) + throw new Error(`Cannot nibble encode ${o}`); + s % 2 == 0 ? ((n = l << 4), s === e.length - 1 && ((n |= 15), r.writeUint8(n))) : ((n |= l), r.writeUint8(n)); + } +} + +function N(e, t) { + if (e < 256) t.writeUint8(252), t.writeUint8(e); + else if (e < 1048576) t.writeUint8(253), t.writeUint8((e >>> 16) & 255), t.writeUint8((e >>> 8) & 255), t.writeUint8(255 & e); + else { + if (!(e < 4294967296)) throw new Error(`Binary with length ${e} is too big for WAP protocol`); + t.writeUint8(254), t.writeUint32(e); + } +} + +function R(e: any, t: Binary) { + var w = null; + if ('' === e) return t.writeUint8(252), void t.writeUint8(0); + var b = SINGLE_BYTE_TOKEN_MAP; + var r = b.get(e); + var c = [236, 237, 238, 239]; + if (null == r) { + if (null == w) { + w = []; + for (var a = 0; a < DICTIONARIES_MAP.length; ++a) w.push(DICTIONARIES_MAP[a]); + } + for (var n = 0; n < w.length; ++n) { + var s = w[n].get(e); + if (null != s) return t.writeUint8(c[n]), void t.writeUint8(s); + } + var o = numUtf8Bytes(e); + if (o < 128) { + if (!/[^0-9.-]+?/.exec(e)) return void D(e, 255, t); + if (!/[^0-9A-F]+?/.exec(e)) return void D(e, 251, t); + } + N(o, t), t.writeString(e); + } else t.writeUint8(r + 1); +} + +function M(e: any, t: Binary) { + var p = 248; + var f = 249; + if (void 0 === e.tag) return t.writeUint8(p), void t.writeUint8(0); + var r = 1; + e.attrs && (r += 2 * Object.keys(e.attrs).length), + e.content && r++, + r < 256 ? (t.writeUint8(p), t.writeUint8(r)) : r < 65536 && (t.writeUint8(f), t.writeUint16(r)), + O(e.tag, t), + e.attrs && + Object.keys(e.attrs).forEach((r) => { + R(r, t), O(e.attrs[r], t); + }); + var a = e.content; + if (Array.isArray(a)) { + a.length < 256 ? (t.writeUint8(p), t.writeUint8(a.length)) : a.length < 65536 && (t.writeUint8(f), t.writeUint16(a.length)); + for (var i = 0; i < a.length; i++) M(a[i], t); + } else a && O(a, t); +} + +function L(data: Binary, t: boolean) { + const n = data.readUint8(); + if (n === 0) { + return null; + } + + if (n === 248) { + return k(data, data.readUint8()); + } + + if (n === 249) { + return k(data, data.readUint16()); + } + + if (n === 252) { + return t ? data.readString(data.readUint8()) : data.readByteArray(data.readUint8()); + } + + if (n === 253) { + const size = ((15 & data.readUint8()) << 16) + (data.readUint8() << 8) + data.readUint8(); + return t ? data.readString(size) : data.readByteArray(size); + } + + if (n === 254) { + return t ? data.readString(data.readUint32()) : data.readByteArray(data.readUint32()); + } + + if (n === 250) { + const user = L(data, true); + if (null != user && 'string' != typeof user) throw new Error(`Decode string got invalid value ${String(t)}, string expected`); + const server = decodeStanzaString(data) + return jidEncode(user, server) + } + + if (n === 247) { + const agent = data.readUint8(); + const device = data.readUint8(); + const user = decodeStanzaString(data); + + return jidEncode(user, 's.whatsapp.net', device, agent); + } + + if (n === 255) { + const number = data.readUint8(); + return x(data, LIST1, number >>> 7, 127 & number); + } + + if (n === 251) { + const number = data.readUint8(); + return x(data, LIST2, number >>> 7, 127 & number); + } + + if (n <= 0 || n >= 240) { + throw new Error('Unable to decode WAP buffer'); + } + + if (n >= 236 && n <= 239) { + const dict = DICTIONARIES[n - 236]; + if (!dict) { + throw new Error(`Missing WAP dictionary ${n - 236}`); + } + + const index = data.readUint8(); + const value = dict[index]; + if (!value) { + throw new Error(`Invalid value index ${index} in dict ${n - 236}`); + } + + return value; + } + + const singleToken = SINGLE_BYTE_TOKEN[n - 1]; + if (!singleToken) throw new Error(`Undefined token with index ${n}`); + + return singleToken; +} + +function O(e: any, t: Binary) { + if (null == e) t.writeUint8(0); + else if (typeof e === 'object' && !(e instanceof Uint8Array) && !Buffer.isBuffer(e) && !Array.isArray(e)) M(e, t); + else if ('string' == typeof e) { + const jid = jidDecode(e) + if(jid) { + if(typeof jid.agent !== 'undefined' || typeof jid.device !== 'undefined') { + var { user: a, agent: i, device: n } = jid; + t.writeUint8(247), t.writeUint8(i || 0), t.writeUint8(n || 0), O(a, t); + } else { + var { user: s, server: l } = jid; + t.writeUint8(250), null != s ? O(s, t) : t.writeUint8(0), O(l, t); + } + } else { + R(e, t); + } + } else { + if (!(e instanceof Uint8Array)) throw new Error('Invalid payload type ' + typeof e); + N(e.length, t), t.writeByteArray(e); + } +} + +function decodeStanzaString(data: Binary) { + // G + const t = L(data, true); + if (typeof t != 'string') { + throw new Error(`Decode string got invalid value ${String(t)}, string expected`); + } + + return t; +} + +function bufferToUInt(e: Uint8Array | Buffer, t: number) { + let a = 0 + for (let i = 0; i < t; i++) a = 256 * a + e[i] + return a +} +/** + * the binary node WA uses internally for communication + * + * this is manipulated soley as an object and it does not have any functions. + * This is done for easy serialization, to prevent running into issues with prototypes & + * to maintain functional code structure + * */ +export type BinaryNode = { + tag: string + attrs: { [key: string]: string } + content?: BinaryNode[] | string | Uint8Array +} +export type BinaryNodeAttributes = BinaryNode['attrs'] +export type BinaryNodeData = BinaryNode['content'] + +export const decodeBinaryNode = (data: Binary): BinaryNode => { + //U + let r = data.readUint8(); + let t = r === 248 ? data.readUint8() : data.readUint16(); + + if (!t) { + throw new Error('Failed to decode node, list cannot be empty'); + } + + const a = {}; + + const n = decodeStanzaString(data); + for (t -= 1; t > 1; ) { + const s = decodeStanzaString(data); + const l = L(data, true); + a[s] = l; + t -= 2; + } + + let i = null; + 1 === t && jidDecode(i = L(data, !1)) && (i = String(i)); + + return { + tag: n, + attrs: a, + content: i + } +} + +export const encodeBinaryNode = (node: BinaryNode) => { + const data = new Binary(); + + O(node, data); + + const dataArr = data.readByteArray(); + const result = new Uint8Array(1 + dataArr.length); + + result[0] = 0; + result.set(dataArr, 1); + + return result; +} + +// some extra useful utilities + +export const getBinaryNodeChildren = ({ content }: BinaryNode, childTag: string) => { + if(Array.isArray(content)) { + return content.filter(item => item.tag == childTag) + } + return [] +} + +export const getBinaryNodeChild = ({ content }: BinaryNode, childTag: string) => { + if(Array.isArray(content)) { + return content.find(item => item.tag == childTag) + } +} + +export const getBinaryNodeChildBuffer = (node: BinaryNode, childTag: string) => { + const child = getBinaryNodeChild(node, childTag)?.content + if(Buffer.isBuffer(child) || child instanceof Uint8Array) { + return child + } +} + +export const getBinaryNodeChildUInt = (node: BinaryNode, childTag: string, length: number) => { + const buff = getBinaryNodeChildBuffer(node, childTag) + if(buff) return bufferToUInt(buff, length) +} + +export const assertNodeErrorFree = (node: BinaryNode) => { + const errNode = getBinaryNodeChild(node, 'error') + if(errNode) { + throw new Boom(errNode.attrs.text || 'Unknown error', { data: +errNode.attrs.code }) + } +} + +export * from './JidUtils' +export { Binary } from '../../WABinary/Binary' \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 1c46348..5f0c293 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,11 @@ -import makeConnection from './Connection' +import makeWASocket from './Socket' -export * from '../WAMessage' +export * from '../WAProto' export * from './Utils' export * from './Types' -export * from './Store' +//export * from './Store' export * from './Defaults' -export default makeConnection \ No newline at end of file +export type WASocket = ReturnType + +export default makeWASocket \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index afcc087..e4c9a2a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -314,6 +314,18 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== +"@cspotcode/source-map-consumer@0.8.0": + version "0.8.0" + resolved "https://registry.yarnpkg.com/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz#33bf4b7b39c178821606f669bbc447a6a629786b" + integrity sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg== + +"@cspotcode/source-map-support@0.6.1": + version "0.6.1" + resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.6.1.tgz#118511f316e2e87ee4294761868e254d3da47960" + integrity sha512-DX3Z+T5dt1ockmPdobJS/FAsQPW4V4SrWEhD2iYQT2Cb2tQsiMnYxrcUH9By/Z3B+v0S5LMBkQtV/XOBbpLEOg== + dependencies: + "@cspotcode/source-map-consumer" "0.8.0" + "@hapi/boom@^9.1.3": version "9.1.3" resolved "https://registry.yarnpkg.com/@hapi/boom/-/boom-9.1.3.tgz#22cad56e39b7a4819161a99b1db19eaaa9b6cc6e" @@ -916,10 +928,10 @@ resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.1.tgz#95f2d167ffb9b8d2068b0b235302fafd4df711f2" integrity sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg== -"@tsconfig/node16@^1.0.1": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.1.tgz#a6ca6a9a0ff366af433f42f5f0e124794ff6b8f1" - integrity sha512-FTgBI767POY/lKNDNbIzgAX6miIDBs6NTCbdlDb8TrWovHsSvaVIZDlTqym29C6UqhzwcJx4CYr+AlrMywA0cA== +"@tsconfig/node16@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.2.tgz#423c77877d0569db20e1fc80885ac4118314010e" + integrity sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA== "@types/babel__core@^7.0.0", "@types/babel__core@^7.1.14": version "7.1.15" @@ -1019,7 +1031,7 @@ dependencies: "@types/node" "*" -"@types/long@^4.0.1": +"@types/long@^4.0.0", "@types/long@^4.0.1": version "4.0.1" resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.1.tgz#459c65fa1867dafe6a8f322c4c51695663cc55e9" integrity sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w== @@ -1029,6 +1041,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-16.3.3.tgz#0c30adff37bbbc7a50eb9b58fae2a504d0d88038" integrity sha512-8h7k1YgQKxKXWckzFCMfsIwn0Y61UK6tlD6y2lOb3hTOIMlK3t9/QwHOhc81TwU+RMf0As5fj7NPjroERCnejQ== +"@types/node@^10.1.0": + version "10.17.60" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.60.tgz#35f3d6213daed95da7f0f73e75bcc6980e90597b" + integrity sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw== + "@types/node@^14.6.2": version "14.17.5" resolved "https://registry.yarnpkg.com/@types/node/-/node-14.17.5.tgz#b59daf6a7ffa461b5648456ca59050ba8e40ed54" @@ -1131,6 +1148,11 @@ acorn-walk@^7.1.1: resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-7.2.0.tgz#0de889a601203909b0fbe07b8938dc21d2e967bc" integrity sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA== +acorn-walk@^8.1.1: + version "8.2.0" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" + integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== + acorn@^7.1.1: version "7.4.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" @@ -1141,6 +1163,11 @@ acorn@^8.2.4: resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.4.1.tgz#56c36251fc7cabc7096adc18f05afe814321a28c" integrity sha512-asabaBSkEKosYKMITunzX177CXxQ4Q8BSSzMTKD+FefUhipQC70gfW5SiUDhYQ3vk8G+81HqQk7Fv9OXwwn9KA== +acorn@^8.4.1: + version "8.5.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.5.0.tgz#4512ccb99b3698c752591e9bb4472e38ad43cee2" + integrity sha512-yXbYeFy+jUuYd3/CDcg2NkIYE991XYX/bje7LmjJigUciaeO1JR4XxXgCIV1/Zc/dRuFEyw1L0pbA+qynJkW5Q== + agent-base@6: version "6.0.2" resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77" @@ -1345,11 +1372,16 @@ buffer-equal@0.0.1: resolved "https://registry.yarnpkg.com/buffer-equal/-/buffer-equal-0.0.1.tgz#91bc74b11ea405bc916bc6aa908faafa5b4aac4b" integrity sha1-kbx0sR6kBbyRa8aqkI+q+ltKrEs= -buffer-from@1.x, buffer-from@^1.0.0: +buffer-from@1.x: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== +buffer-from@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" + integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== + buffer@^5.2.0: version "5.7.1" resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" @@ -1543,11 +1575,6 @@ cssstyle@^2.3.0: dependencies: cssom "~0.3.6" -curve25519-js@^0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/curve25519-js/-/curve25519-js-0.0.4.tgz#e6ad967e8cd284590d657bbfc90d8b50e49ba060" - integrity sha512-axn2UMEnkhyDUPWOwVKBMVIzSQy2ejH2xRGy1wq81dqRwApXfIzfbE3hIX0ZRFBIihf/KDqK158DLwESu4AK1w== - data-urls@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-2.0.0.tgz#156485a72963a970f5d5821aaf642bef2bf2db9b" @@ -1838,11 +1865,6 @@ function-bind@^1.1.1: resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== -futoin-hkdf@^1.3.2: - version "1.4.2" - resolved "https://registry.yarnpkg.com/futoin-hkdf/-/futoin-hkdf-1.4.2.tgz#fd534e848e0e50339b8bfbd81250b09cbff10ba3" - integrity sha512-2BggwLEJOTfXzKq4Tl2bIT37p0IqqKkblH4e0cMp2sXTdmwg/ADBKMxvxaEytYYcgdxgng8+acsi3WgMVUl6CQ== - gensync@^1.0.0-beta.2: version "1.0.0-beta.2" resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" @@ -2681,6 +2703,13 @@ levn@~0.3.0: prelude-ls "~1.1.2" type-check "~0.3.2" +libsignal@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/libsignal/-/libsignal-2.0.1.tgz#c276025c184ae4ebbd7d75c12c0be9f3b50cc19e" + integrity sha512-kqdl/BK5i0WCa4NxhtiBsjSzztB/FtUp3mVVLKBFicWH8rDsq95tEIqNcCaVlflLxOm6T/HRb/zv8IsCe7aopA== + dependencies: + protobufjs "6.8.8" + load-bmfont@^1.3.1, load-bmfont@^1.4.0: version "1.4.1" resolved "https://registry.yarnpkg.com/load-bmfont/-/load-bmfont-1.4.1.tgz#c0f5f4711a1e2ccff725a7b6078087ccfcddd3e9" @@ -3126,6 +3155,25 @@ prompts@^2.0.1: kleur "^3.0.3" sisteransi "^1.0.5" +protobufjs@6.8.8: + version "6.8.8" + resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.8.8.tgz#c8b4f1282fd7a90e6f5b109ed11c84af82908e7c" + integrity sha512-AAmHtD5pXgZfi7GMpllpO3q1Xw1OYldr+dMUlAnffGTAhqkg72WdmSY71uKBF/JuyiKs8psYbtKrhi0ASCD8qw== + dependencies: + "@protobufjs/aspromise" "^1.1.2" + "@protobufjs/base64" "^1.1.2" + "@protobufjs/codegen" "^2.0.4" + "@protobufjs/eventemitter" "^1.1.0" + "@protobufjs/fetch" "^1.1.0" + "@protobufjs/float" "^1.0.2" + "@protobufjs/inquire" "^1.1.0" + "@protobufjs/path" "^1.1.2" + "@protobufjs/pool" "^1.1.0" + "@protobufjs/utf8" "^1.1.0" + "@types/long" "^4.0.0" + "@types/node" "^10.1.0" + long "^4.0.0" + protobufjs@^6.10.1: version "6.11.2" resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.11.2.tgz#de39fabd4ed32beaa08e9bb1e30d08544c1edf8b" @@ -3347,7 +3395,7 @@ sonic-boom@^1.0.2: atomic-sleep "^1.0.0" flatstr "^1.0.12" -source-map-support@^0.5.17, source-map-support@^0.5.6: +source-map-support@^0.5.6: version "0.5.19" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== @@ -3554,19 +3602,21 @@ ts-jest@^27.0.3: yargs-parser "20.x" ts-node@^10.0.0: - version "10.1.0" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.1.0.tgz#e656d8ad3b61106938a867f69c39a8ba6efc966e" - integrity sha512-6szn3+J9WyG2hE+5W8e0ruZrzyk1uFLYye6IGMBadnOzDh8aP7t8CbFpsfCiEx2+wMixAhjFt7lOZC4+l+WbEA== + version "10.2.1" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.2.1.tgz#4cc93bea0a7aba2179497e65bb08ddfc198b3ab5" + integrity sha512-hCnyOyuGmD5wHleOQX6NIjJtYVIO8bPP8F2acWkB4W06wdlkgyvJtubO/I9NkI88hCFECbsEgoLc0VNkYmcSfw== dependencies: + "@cspotcode/source-map-support" "0.6.1" "@tsconfig/node10" "^1.0.7" "@tsconfig/node12" "^1.0.7" "@tsconfig/node14" "^1.0.0" - "@tsconfig/node16" "^1.0.1" + "@tsconfig/node16" "^1.0.2" + acorn "^8.4.1" + acorn-walk "^8.1.1" arg "^4.1.0" create-require "^1.1.0" diff "^4.0.1" make-error "^1.1.1" - source-map-support "^0.5.17" yn "3.1.1" type-check@~0.3.2: