feat: update proto

The new proto extract has a bunch of breaking changes, so if you were using the raw proto in your code somewhere -- then you may have to update your code to make it work with the new proto

!BREAKING_CHANGE
This commit is contained in:
Adhiraj Singh
2022-08-01 10:43:01 +05:30
parent 9c83cd96d2
commit 2549d10be9
22 changed files with 58772 additions and 55399 deletions

File diff suppressed because it is too large Load Diff

30844
WAProto/index.d.ts vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -151,7 +151,7 @@ const makeMessagesSocket = (config: LegacySocketConfig) => {
// if it's a message to delete another message
if(protocolMessage) {
switch (protocolMessage.type) {
case proto.ProtocolMessage.ProtocolMessageType.REVOKE:
case proto.Message.ProtocolMessage.Type.REVOKE:
const key = protocolMessage.key
const messageStubType = WAMessageStubType.REVOKE
ev.emit('messages.update', [
@@ -162,7 +162,7 @@ const makeMessagesSocket = (config: LegacySocketConfig) => {
}
])
return
case proto.ProtocolMessage.ProtocolMessageType.EPHEMERAL_SETTING:
case proto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING:
chatUpdate.ephemeralSettingTimestamp = message.messageTimestamp
chatUpdate.ephemeralExpiration = protocolMessage.ephemeralExpiration

View File

@@ -147,7 +147,7 @@ export const makeGroupsSocket = (config: SocketConfig) => {
* @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
* @param inviteMessage the message to accept
*/
groupAcceptInviteV4: async(key: string | WAMessageKey, inviteMessage: proto.IGroupInviteMessage) => {
groupAcceptInviteV4: async(key: string | WAMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => {
key = typeof key === 'string' ? { remoteJid: key } : key
const results = await groupQuery(inviteMessage.groupJid!, 'set', [{
tag: 'accept',
@@ -163,7 +163,7 @@ export const makeGroupsSocket = (config: SocketConfig) => {
// update the invite message to be expired
if(key.id) {
// create new invite message that is expired
inviteMessage = proto.GroupInviteMessage.fromObject(inviteMessage)
inviteMessage = proto.Message.GroupInviteMessage.fromObject(inviteMessage)
inviteMessage.inviteExpiration = 0
inviteMessage.inviteCode = ''
ev.emit('messages.update', [

View File

@@ -193,7 +193,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
case 'not_ephemeral':
result.message = {
protocolMessage: {
type: proto.ProtocolMessage.ProtocolMessageType.EPHEMERAL_SETTING,
type: proto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING,
ephemeralExpiration: +(child.attrs.expiration || 0)
}
}
@@ -340,13 +340,13 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
(
// basically, we only want to know when a message from us has been delivered to/read by the other person
// or another device of ours has read some messages
status > proto.WebMessageInfo.WebMessageInfoStatus.DELIVERY_ACK ||
status > proto.WebMessageInfo.Status.DELIVERY_ACK ||
!isNodeFromMe
)
) {
if(isJidGroup(remoteJid)) {
if(attrs.participant) {
const updateKey: keyof MessageUserReceipt = status === proto.WebMessageInfo.WebMessageInfoStatus.DELIVERY_ACK ? 'receiptTimestamp' : 'readTimestamp'
const updateKey: keyof MessageUserReceipt = status === proto.WebMessageInfo.Status.DELIVERY_ACK ? 'receiptTimestamp' : 'readTimestamp'
ev.emit(
'message-receipt.update',
ids.map(id => ({
@@ -428,7 +428,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
async() => {
await decryptionTask
// message failed to decrypt
if(msg.messageStubType === proto.WebMessageInfo.WebMessageInfoStubType.CIPHERTEXT) {
if(msg.messageStubType === proto.WebMessageInfo.StubType.CIPHERTEXT) {
logger.error(
{ key: msg.key, params: msg.messageStubParameters },
'failure in decrypting message'

View File

@@ -550,8 +550,8 @@ export const makeMessagesSocket = (config: SocketConfig) => {
} else {
try {
const media = decryptMediaRetryData(result.media!, mediaKey, result.key.id!)
if(media.result !== proto.MediaRetryNotification.MediaRetryNotificationResultType.SUCCESS) {
const resultStr = proto.MediaRetryNotification.MediaRetryNotificationResultType[media.result]
if(media.result !== proto.MediaRetryNotification.ResultType.SUCCESS) {
const resultStr = proto.MediaRetryNotification.ResultType[media.result]
throw new Boom(
`Media re-upload failed by device (${resultStr})`,
{ data: media, statusCode: getStatusCodeForMediaRetry(media.result) || 404 }

View File

@@ -56,7 +56,7 @@ export type SignalDataTypeMap = {
'session': any
'sender-key': any
'sender-key-memory': { [jid: string]: boolean }
'app-state-sync-key': proto.IAppStateSyncKeyData
'app-state-sync-key': proto.Message.IAppStateSyncKeyData
'app-state-sync-version': LTHashState
}

View File

@@ -30,7 +30,7 @@ export type WAPatchCreate = {
index: string[]
type: WAPatchName
apiVersion: number
operation: proto.SyncdMutation.SyncdMutationSyncdOperation
operation: proto.SyncdMutation.SyncdOperation
}
export type Chat = proto.IConversation & {
@@ -45,7 +45,7 @@ export type Chat = proto.IConversation & {
* the last messages in a chat, sorted reverse-chronologically. That is, the latest message should be first in the chat
* for MD modifications, the last message in the array (i.e. the earlist message) must be the last message recv in the chat
* */
export type LastMessageList = MinimalMessage[] | proto.ISyncActionMessageRange
export type LastMessageList = MinimalMessage[] | proto.SyncActionValue.ISyncActionMessageRange
export type ChatModification =
{

View File

@@ -9,15 +9,15 @@ import type { GroupMetadata } from './GroupMetadata'
export { proto as WAProto }
export type WAMessage = proto.IWebMessageInfo
export type WAMessageContent = proto.IMessage
export type WAContactMessage = proto.IContactMessage
export type WAContactsArrayMessage = proto.IContactsArrayMessage
export type WAContactMessage = proto.Message.IContactMessage
export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage
export type WAMessageKey = proto.IMessageKey
export type WATextMessage = proto.IExtendedTextMessage
export type WATextMessage = proto.Message.IExtendedTextMessage
export type WAContextInfo = proto.IContextInfo
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
export type WALocationMessage = proto.Message.ILocationMessage
export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage
export import WAMessageStubType = proto.WebMessageInfo.StubType
export import WAMessageStatus = proto.WebMessageInfo.Status
export type WAMediaUpload = Buffer | { url: URL | string } | { stream: Readable }
/** Set of message types that are supported by the library */
export type MessageType = keyof proto.Message
@@ -51,7 +51,7 @@ type ViewOnce = {
}
type Buttonable = {
/** add buttons to the message */
buttons?: proto.IButton[]
buttons?: proto.Message.ButtonsMessage.IButton[]
}
type Templatable = {
/** add buttons to the message (conflicts with normal buttons)*/
@@ -61,7 +61,7 @@ type Templatable = {
}
type Listable = {
/** Sections of the List */
sections?: proto.ISection[]
sections?: proto.Message.ListMessage.ISection[]
/** Title of a List Message only */
title?: string
@@ -117,13 +117,13 @@ export type AnyRegularMessageContent = (
{
contacts: {
displayName?: string
contacts: proto.IContactMessage[]
contacts: proto.Message.IContactMessage[]
}
} |
{
location: WALocationMessage
} | {
react: proto.IReactionMessage
react: proto.Message.IReactionMessage
} | {
buttonReply: ButtonReplyInfo
type: 'template' | 'plain'

View File

@@ -8,7 +8,7 @@ import { toNumber } from './generics'
import { LT_HASH_ANTI_TAMPERING } from './lt-hash'
import { downloadContentFromMessage, } from './messages-media'
type FetchAppStateSyncKey = (keyId: string) => Promise<proto.IAppStateSyncKeyData> | proto.IAppStateSyncKeyData
type FetchAppStateSyncKey = (keyId: string) => Promise<proto.Message.IAppStateSyncKeyData> | proto.Message.IAppStateSyncKeyData
const mutationKeys = (keydata: Uint8Array) => {
const expanded = hkdf(keydata, 160, { info: 'WhatsApp Mutation Keys' })
@@ -21,14 +21,14 @@ const mutationKeys = (keydata: Uint8Array) => {
}
}
const generateMac = (operation: proto.SyncdMutation.SyncdMutationSyncdOperation, data: Buffer, keyId: Uint8Array | string, key: Buffer) => {
const generateMac = (operation: proto.SyncdMutation.SyncdOperation, data: Buffer, keyId: Uint8Array | string, key: Buffer) => {
const getKeyData = () => {
let r: number
switch (operation) {
case proto.SyncdMutation.SyncdMutationSyncdOperation.SET:
case proto.SyncdMutation.SyncdOperation.SET:
r = 0x01
break
case proto.SyncdMutation.SyncdMutationSyncdOperation.REMOVE:
case proto.SyncdMutation.SyncdOperation.REMOVE:
r = 0x02
break
}
@@ -54,7 +54,7 @@ const to64BitNetworkOrder = (e: number) => {
return Buffer.from(t)
}
type Mac = { indexMac: Uint8Array, valueMac: Uint8Array, operation: proto.SyncdMutation.SyncdMutationSyncdOperation }
type Mac = { indexMac: Uint8Array, valueMac: Uint8Array, operation: proto.SyncdMutation.SyncdOperation }
const makeLtHashGenerator = ({ indexValueMap, hash }: Pick<LTHashState, 'hash' | 'indexValueMap'>) => {
indexValueMap = { ...indexValueMap }
@@ -65,7 +65,7 @@ const makeLtHashGenerator = ({ indexValueMap, hash }: Pick<LTHashState, 'hash' |
mix: ({ indexMac, valueMac, operation }: Mac) => {
const indexMacBase64 = Buffer.from(indexMac).toString('base64')
const prevOp = indexValueMap[indexMacBase64]
if(operation === proto.SyncdMutation.SyncdMutationSyncdOperation.REMOVE) {
if(operation === proto.SyncdMutation.SyncdOperation.REMOVE) {
if(!prevOp) {
throw new Boom('tried remove, but no previous op', { data: { indexMac, valueMac } })
}
@@ -212,7 +212,7 @@ export const decodeSyncdMutations = async(
for(const msgMutation of msgMutations!) {
// if it's a syncdmutation, get the operation property
// otherwise, if it's only a record -- it'll be a SET mutation
const operation = 'operation' in msgMutation ? msgMutation.operation : proto.SyncdMutation.SyncdMutationSyncdOperation.SET
const operation = 'operation' in msgMutation ? msgMutation.operation : proto.SyncdMutation.SyncdOperation.SET
const record = ('record' in msgMutation && !!msgMutation.record) ? msgMutation.record : msgMutation as proto.ISyncdRecord
const key = await getKey(record.keyId!.id!)
@@ -460,9 +460,9 @@ export const chatModificationToAppPatch = (
mod: ChatModification,
jid: string
) => {
const OP = proto.SyncdMutation.SyncdMutationSyncdOperation
const OP = proto.SyncdMutation.SyncdOperation
const getMessageRange = (lastMessages: LastMessageList) => {
let messageRange: proto.ISyncActionMessageRange
let messageRange: proto.SyncActionValue.ISyncActionMessageRange
if(Array.isArray(lastMessages)) {
const lastMsg = lastMessages[lastMessages.length - 1]
messageRange = {
@@ -713,7 +713,7 @@ export const processSyncAction = (
logger?.warn({ syncAction, id }, 'unprocessable update')
}
function isValidPatchBasedOnMessageRange(id: string, msgRange: proto.ISyncActionMessageRange | null | undefined) {
function isValidPatchBasedOnMessageRange(id: string, msgRange: proto.SyncActionValue.ISyncActionMessageRange | null | undefined) {
const chat = recvChats?.[id]
const lastMsgTimestamp = msgRange?.lastMessageTimestamp || msgRange?.lastSystemMessageTimestamp || 0
const chatLastMsgTimestamp = chat?.lastMsgRecvTimestamp || 0

View File

@@ -79,7 +79,7 @@ export const decodeMessageStanza = (stanza: BinaryNode, auth: AuthenticationStat
}
if(key.fromMe) {
fullMessage.status = proto.WebMessageInfo.WebMessageInfoStatus.SERVER_ACK
fullMessage.status = proto.WebMessageInfo.Status.SERVER_ACK
}
return {
@@ -92,7 +92,7 @@ export const decodeMessageStanza = (stanza: BinaryNode, auth: AuthenticationStat
for(const { tag, attrs, content } of stanza.content) {
if(tag === 'verified_name' && content instanceof Uint8Array) {
const cert = proto.VerifiedNameCertificate.decode(content)
const details = proto.VerifiedNameDetails.decode(cert.details)
const details = proto.VerifiedNameCertificate.Details.decode(cert.details)
fullMessage.verifiedBizName = details.verifiedName
}
@@ -135,7 +135,7 @@ export const decodeMessageStanza = (stanza: BinaryNode, auth: AuthenticationStat
fullMessage.message = msg
}
} catch(error) {
fullMessage.messageStubType = proto.WebMessageInfo.WebMessageInfoStubType.CIPHERTEXT
fullMessage.messageStubType = proto.WebMessageInfo.StubType.CIPHERTEXT
fullMessage.messageStubParameters = [error.message]
}
}
@@ -143,7 +143,7 @@ export const decodeMessageStanza = (stanza: BinaryNode, auth: AuthenticationStat
// if nothing was found to decrypt
if(!decryptables) {
fullMessage.messageStubType = proto.WebMessageInfo.WebMessageInfoStubType.CIPHERTEXT
fullMessage.messageStubType = proto.WebMessageInfo.StubType.CIPHERTEXT
fullMessage.messageStubParameters = [NO_MESSAGE_FOUND_ERROR_TEXT]
}
})()

View File

@@ -262,10 +262,10 @@ export const generateMdTagPrefix = () => {
return `${bytes.readUInt16BE()}.${bytes.readUInt16BE(2)}-`
}
const STATUS_MAP: { [_: string]: proto.WebMessageInfo.WebMessageInfoStatus } = {
'played': proto.WebMessageInfo.WebMessageInfoStatus.PLAYED,
'read': proto.WebMessageInfo.WebMessageInfoStatus.READ,
'read-self': proto.WebMessageInfo.WebMessageInfoStatus.READ
const STATUS_MAP: { [_: string]: proto.WebMessageInfo.Status } = {
'played': proto.WebMessageInfo.Status.PLAYED,
'read': proto.WebMessageInfo.Status.READ,
'read-self': proto.WebMessageInfo.Status.READ
}
/**
* Given a type of receipt, returns what the new status of the message should be
@@ -274,7 +274,7 @@ const STATUS_MAP: { [_: string]: proto.WebMessageInfo.WebMessageInfoStatus } = {
export const getStatusFromReceiptType = (type: string | undefined) => {
const status = STATUS_MAP[type!]
if(typeof type === 'undefined') {
return proto.WebMessageInfo.WebMessageInfoStatus.DELIVERY_ACK
return proto.WebMessageInfo.Status.DELIVERY_ACK
}
return status

View File

@@ -9,7 +9,7 @@ import { downloadContentFromMessage } from './messages-media'
const inflatePromise = promisify(inflate)
export const downloadHistory = async(msg: proto.IHistorySyncNotification) => {
export const downloadHistory = async(msg: proto.Message.IHistorySyncNotification) => {
const stream = await downloadContentFromMessage(msg, 'history')
let buffer = Buffer.from([])
for await (const chunk of stream) {
@@ -33,8 +33,8 @@ export const processHistoryMessage = (
const chats: Chat[] = []
switch (item.syncType) {
case proto.HistorySync.HistorySyncHistorySyncType.INITIAL_BOOTSTRAP:
case proto.HistorySync.HistorySyncHistorySyncType.RECENT:
case proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP:
case proto.HistorySync.HistorySyncType.RECENT:
for(const chat of item.conversations!) {
const contactId = `c:${chat.id}`
if(chat.name && !historyCache.has(contactId)) {
@@ -72,7 +72,7 @@ export const processHistoryMessage = (
}
break
case proto.HistorySync.HistorySyncHistorySyncType.PUSH_NAME:
case proto.HistorySync.HistorySyncType.PUSH_NAME:
for(const c of item.pushnames!) {
const contactId = `c:${c.id}`
if(!historyCache.has(contactId)) {
@@ -82,7 +82,7 @@ export const processHistoryMessage = (
}
break
case proto.HistorySync.HistorySyncHistorySyncType.INITIAL_STATUS_V3:
case proto.HistorySync.HistorySyncType.INITIAL_STATUS_V3:
// TODO
break
}
@@ -98,7 +98,7 @@ export const processHistoryMessage = (
}
export const downloadAndProcessHistorySyncNotification = async(
msg: proto.IHistorySyncNotification,
msg: proto.Message.IHistorySyncNotification,
historyCache: Set<string>,
recvChats: InitialReceivedChatsState
) => {

View File

@@ -12,7 +12,7 @@ import { Readable, Transform } from 'stream'
import { URL } from 'url'
import { proto } from '../../WAProto'
import { DEFAULT_ORIGIN, MEDIA_PATH_MAP } from '../Defaults'
import { BaileysEventMap, CommonSocketConfig, DownloadableMessage, MediaConnInfo, MediaDecryptionKeyInfo, MediaType, MessageType, WAGenericMediaMessage, WAMediaUpload, WAMediaUploadFunction, WAMessageContent, WAProto } from '../Types'
import { BaileysEventMap, CommonSocketConfig, DownloadableMessage, MediaConnInfo, MediaDecryptionKeyInfo, MediaType, MessageType, WAGenericMediaMessage, WAMediaUpload, WAMediaUploadFunction, WAMessageContent } from '../Types'
import { BinaryNode, getBinaryNodeChild, getBinaryNodeChildBuffer, jidNormalizedUser } from '../WABinary'
import { aesDecryptGCM, aesEncryptGCM, hkdf } from './crypto'
import { generateMessageID } from './generics'
@@ -479,12 +479,8 @@ export function extensionForMediaMessage(message: WAMessageContent) {
) {
extension = '.jpeg'
} else {
const messageContent = message[type] as
| WAProto.VideoMessage
| WAProto.ImageMessage
| WAProto.AudioMessage
| WAProto.DocumentMessage
extension = getExtension (messageContent.mimetype)
const messageContent = message[type] as WAGenericMediaMessage
extension = getExtension(messageContent.mimetype!)
}
return extension
@@ -666,8 +662,8 @@ export const decryptMediaRetryData = (
export const getStatusCodeForMediaRetry = (code: number) => MEDIA_RETRY_STATUS_MAP[code]
const MEDIA_RETRY_STATUS_MAP = {
[proto.MediaRetryNotification.MediaRetryNotificationResultType.SUCCESS]: 200,
[proto.MediaRetryNotification.MediaRetryNotificationResultType.DECRYPTION_ERROR]: 412,
[proto.MediaRetryNotification.MediaRetryNotificationResultType.NOT_FOUND]: 404,
[proto.MediaRetryNotification.MediaRetryNotificationResultType.GENERAL_ERROR]: 418,
[proto.MediaRetryNotification.ResultType.SUCCESS]: 200,
[proto.MediaRetryNotification.ResultType.DECRYPTION_ERROR]: 412,
[proto.MediaRetryNotification.ResultType.NOT_FOUND]: 404,
[proto.MediaRetryNotification.ResultType.GENERAL_ERROR]: 418,
} as const

View File

@@ -48,14 +48,14 @@ const MIMETYPE_MAP: { [T in MediaType]: string } = {
}
const MessageTypeProto = {
'image': WAProto.ImageMessage,
'video': WAProto.VideoMessage,
'audio': WAProto.AudioMessage,
'sticker': WAProto.StickerMessage,
'document': WAProto.DocumentMessage,
'image': WAProto.Message.ImageMessage,
'video': WAProto.Message.VideoMessage,
'audio': WAProto.Message.AudioMessage,
'sticker': WAProto.Message.StickerMessage,
'document': WAProto.Message.DocumentMessage,
} as const
const ButtonType = proto.ButtonsMessage.ButtonsMessageHeaderType
const ButtonType = proto.Message.ButtonsMessage.HeaderType
export const generateLinkPreviewIfRequired = async(text: string, getUrlInfo: MessageGenerationOptions['getUrlInfo'], logger: MessageGenerationOptions['logger']) => {
const matchedUrls = text.match(URL_REGEX)
@@ -210,7 +210,7 @@ export const prepareDisappearingMessageSettingContent = (ephemeralExpiration?: n
ephemeralMessage: {
message: {
protocolMessage: {
type: WAProto.ProtocolMessage.ProtocolMessageType.EPHEMERAL_SETTING,
type: WAProto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING,
ephemeralExpiration
}
}
@@ -287,22 +287,22 @@ export const generateWAMessageContent = async(
}
if(contactLen === 1) {
m.contactMessage = WAProto.ContactMessage.fromObject(message.contacts.contacts[0])
m.contactMessage = WAProto.Message.ContactMessage.fromObject(message.contacts.contacts[0])
} else {
m.contactsArrayMessage = WAProto.ContactsArrayMessage.fromObject(message.contacts)
m.contactsArrayMessage = WAProto.Message.ContactsArrayMessage.fromObject(message.contacts)
}
} else if('location' in message) {
m.locationMessage = WAProto.LocationMessage.fromObject(message.location)
m.locationMessage = WAProto.Message.LocationMessage.fromObject(message.location)
} else if('react' in message) {
if(!message.react.senderTimestampMs) {
message.react.senderTimestampMs = Date.now()
}
m.reactionMessage = WAProto.ReactionMessage.fromObject(message.react)
m.reactionMessage = WAProto.Message.ReactionMessage.fromObject(message.react)
} else if('delete' in message) {
m.protocolMessage = {
key: message.delete,
type: WAProto.ProtocolMessage.ProtocolMessageType.REVOKE
type: WAProto.Message.ProtocolMessage.Type.REVOKE
}
} else if('forward' in message) {
m = generateForwardMessageContent(
@@ -327,7 +327,7 @@ export const generateWAMessageContent = async(
m.buttonsResponseMessage = {
selectedButtonId: message.buttonReply.id,
selectedDisplayText: message.buttonReply.displayText,
type: proto.ButtonsResponseMessage.ButtonsResponseMessageType.DISPLAY_TEXT,
type: proto.Message.ButtonsResponseMessage.Type.DISPLAY_TEXT,
}
break
}
@@ -339,8 +339,8 @@ export const generateWAMessageContent = async(
}
if('buttons' in message && !!message.buttons) {
const buttonsMessage: proto.IButtonsMessage = {
buttons: message.buttons!.map(b => ({ ...b, type: proto.Button.ButtonType.RESPONSE }))
const buttonsMessage: proto.Message.IButtonsMessage = {
buttons: message.buttons!.map(b => ({ ...b, type: proto.Message.ButtonsMessage.Button.Type.RESPONSE }))
}
if('text' in message) {
buttonsMessage.contentText = message.text
@@ -362,7 +362,7 @@ export const generateWAMessageContent = async(
m = { buttonsMessage }
} else if('templateButtons' in message && !!message.templateButtons) {
const msg: proto.IHydratedFourRowTemplate = {
const msg: proto.Message.TemplateMessage.IHydratedFourRowTemplate = {
hydratedButtons: message.templateButtons
}
@@ -389,13 +389,13 @@ export const generateWAMessageContent = async(
}
if('sections' in message && !!message.sections) {
const listMessage: proto.IListMessage = {
const listMessage: proto.Message.IListMessage = {
sections: message.sections,
buttonText: message.buttonText,
title: message.title,
footerText: message.footer,
description: message.text,
listType: proto.ListMessage.ListMessageListType['SINGLE_SELECT']
listType: proto.Message.ListMessage.ListType.SINGLE_SELECT
}
m = { listMessage }
@@ -537,7 +537,7 @@ export const normalizeMessageContent = (content: WAMessageContent | null | undef
* Eg. extracts the inner message from a disappearing message/view once message
*/
export const extractMessageContent = (content: WAMessageContent | undefined | null): WAMessageContent | undefined => {
const extractFromTemplateMessage = (msg: proto.IHydratedFourRowTemplate | proto.IButtonsMessage) => {
const extractFromTemplateMessage = (msg: proto.Message.TemplateMessage.IHydratedFourRowTemplate | proto.Message.IButtonsMessage) => {
if(msg.imageMessage) {
return { imageMessage: msg.imageMessage }
} else if(msg.documentMessage) {

View File

@@ -105,7 +105,7 @@ export const makeNoiseHandler = (
const certDecoded = decrypt(serverHello!.payload!)
const { intermediate: certIntermediate } = proto.CertChain.decode(certDecoded)
const { issuerSerial } = proto.CertChainNoiseCertificateDetails.decode(certIntermediate!.details!)
const { issuerSerial } = proto.CertChain.NoiseCertificate.Details.decode(certIntermediate!.details!)
if(issuerSerial !== WA_CERT_DETAILS.SERIAL) {
throw new Boom('certification match failed', { statusCode: 400 })

View File

@@ -88,7 +88,7 @@ const processMessage = async(
const protocolMsg = content?.protocolMessage
if(protocolMsg) {
switch (protocolMsg.type) {
case proto.ProtocolMessage.ProtocolMessageType.HISTORY_SYNC_NOTIFICATION:
case proto.Message.ProtocolMessage.Type.HISTORY_SYNC_NOTIFICATION:
const histNotification = protocolMsg!.historySyncNotification!
logger?.info({ histNotification, id: message.key.id }, 'got history notification')
@@ -120,7 +120,7 @@ const processMessage = async(
}
break
case proto.ProtocolMessage.ProtocolMessageType.APP_STATE_SYNC_KEY_SHARE:
case proto.Message.ProtocolMessage.Type.APP_STATE_SYNC_KEY_SHARE:
const keys = protocolMsg.appStateSyncKeyShare!.keys
if(keys?.length) {
let newAppStateSyncKeyId = ''
@@ -143,7 +143,7 @@ const processMessage = async(
}
break
case proto.ProtocolMessage.ProtocolMessageType.REVOKE:
case proto.Message.ProtocolMessage.Type.REVOKE:
ev.emit('messages.update', [
{
key: {
@@ -154,7 +154,7 @@ const processMessage = async(
}
])
break
case proto.ProtocolMessage.ProtocolMessageType.EPHEMERAL_SETTING:
case proto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING:
Object.assign(chat, {
ephemeralSettingTimestamp: toNumber(message.messageTimestamp),
ephemeralExpiration: protocolMsg.ephemeralExpiration || null

View File

@@ -138,7 +138,7 @@ export const decryptGroupSignalProto = (group: string, user: string, msg: Buffer
export const processSenderKeyMessage = async(
authorJid: string,
item: proto.ISenderKeyDistributionMessage,
item: proto.Message.ISenderKeyDistributionMessage,
auth: SignalAuthState
) => {
const builder = new GroupSessionBuilder(signalStorage(auth))

View File

@@ -59,7 +59,7 @@ export const useMultiFileAuthState = async(folder: string): Promise<{ state: Aut
async id => {
let value = await readData(`${type}-${id}.json`)
if(type === 'app-state-sync-key' && value) {
value = proto.AppStateSyncKeyData.fromObject(value)
value = proto.Message.AppStateSyncKeyData.fromObject(value)
}
data[id] = value

View File

@@ -59,7 +59,7 @@ export const useSingleFileAuthState = (filename: string, logger?: Logger): { sta
let value = keys[key]?.[id]
if(value) {
if(type === 'app-state-sync-key') {
value = proto.AppStateSyncKeyData.fromObject(value)
value = proto.Message.AppStateSyncKeyData.fromObject(value)
}
dict[id] = value

View File

@@ -10,7 +10,7 @@ import { createSignalIdentity } from './signal'
type ClientPayloadConfig = Pick<SocketConfig, 'version' | 'browser' | 'syncFullHistory'>
const getUserAgent = ({ version }: ClientPayloadConfig): proto.IUserAgent => {
const getUserAgent = ({ version }: ClientPayloadConfig): proto.ClientPayload.IUserAgent => {
const osVersion = '0.1'
return {
appVersion: {
@@ -18,8 +18,8 @@ const getUserAgent = ({ version }: ClientPayloadConfig): proto.IUserAgent => {
secondary: version[1],
tertiary: version[2],
},
platform: proto.UserAgent.UserAgentPlatform.WEB,
releaseChannel: proto.UserAgent.UserAgentReleaseChannel.RELEASE,
platform: proto.ClientPayload.UserAgent.Platform.WEB,
releaseChannel: proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
mcc: '000',
mnc: '000',
osVersion: osVersion,
@@ -32,12 +32,12 @@ const getUserAgent = ({ version }: ClientPayloadConfig): proto.IUserAgent => {
}
const PLATFORM_MAP = {
'Mac OS': proto.WebInfo.WebInfoWebSubPlatform.DARWIN,
'Windows': proto.WebInfo.WebInfoWebSubPlatform.WIN32
'Mac OS': proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
'Windows': proto.ClientPayload.WebInfo.WebSubPlatform.WIN32
}
const getWebInfo = (config: ClientPayloadConfig): proto.IWebInfo => {
let webSubPlatform = proto.WebInfo.WebInfoWebSubPlatform.WEB_BROWSER
const getWebInfo = (config: ClientPayloadConfig): proto.ClientPayload.IWebInfo => {
let webSubPlatform = proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER
if(config.syncFullHistory && PLATFORM_MAP[config.browser[0]]) {
webSubPlatform = PLATFORM_MAP[config.browser[0]]
}
@@ -47,8 +47,8 @@ const getWebInfo = (config: ClientPayloadConfig): proto.IWebInfo => {
const getClientPayload = (config: ClientPayloadConfig): proto.IClientPayload => {
return {
connectType: proto.ClientPayload.ClientPayloadConnectType.WIFI_UNKNOWN,
connectReason: proto.ClientPayload.ClientPayloadConnectReason.USER_ACTIVATED,
connectType: proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
connectReason: proto.ClientPayload.ConnectReason.USER_ACTIVATED,
userAgent: getUserAgent(config),
webInfo: getWebInfo(config),
}
@@ -83,8 +83,8 @@ export const generateRegistrationNode = (
secondary: +(browserVersion[1] || 1),
tertiary: +(browserVersion[2] || 0),
},
platformType: proto.DeviceProps.DevicePropsPlatformType[config.browser[1].toUpperCase()]
|| proto.DeviceProps.DevicePropsPlatformType.UNKNOWN,
platformType: proto.DeviceProps.PlatformType[config.browser[1].toUpperCase()]
|| proto.DeviceProps.PlatformType.UNKNOWN,
requireFullSync: config.syncFullHistory,
}