mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
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:
File diff suppressed because it is too large
Load Diff
30844
WAProto/index.d.ts
vendored
30844
WAProto/index.d.ts
vendored
File diff suppressed because it is too large
Load Diff
80376
WAProto/index.js
80376
WAProto/index.js
File diff suppressed because it is too large
Load Diff
@@ -151,7 +151,7 @@ const makeMessagesSocket = (config: LegacySocketConfig) => {
|
|||||||
// if it's a message to delete another message
|
// if it's a message to delete another message
|
||||||
if(protocolMessage) {
|
if(protocolMessage) {
|
||||||
switch (protocolMessage.type) {
|
switch (protocolMessage.type) {
|
||||||
case proto.ProtocolMessage.ProtocolMessageType.REVOKE:
|
case proto.Message.ProtocolMessage.Type.REVOKE:
|
||||||
const key = protocolMessage.key
|
const key = protocolMessage.key
|
||||||
const messageStubType = WAMessageStubType.REVOKE
|
const messageStubType = WAMessageStubType.REVOKE
|
||||||
ev.emit('messages.update', [
|
ev.emit('messages.update', [
|
||||||
@@ -162,7 +162,7 @@ const makeMessagesSocket = (config: LegacySocketConfig) => {
|
|||||||
}
|
}
|
||||||
])
|
])
|
||||||
return
|
return
|
||||||
case proto.ProtocolMessage.ProtocolMessageType.EPHEMERAL_SETTING:
|
case proto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING:
|
||||||
chatUpdate.ephemeralSettingTimestamp = message.messageTimestamp
|
chatUpdate.ephemeralSettingTimestamp = message.messageTimestamp
|
||||||
chatUpdate.ephemeralExpiration = protocolMessage.ephemeralExpiration
|
chatUpdate.ephemeralExpiration = protocolMessage.ephemeralExpiration
|
||||||
|
|
||||||
|
|||||||
@@ -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 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
|
* @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
|
key = typeof key === 'string' ? { remoteJid: key } : key
|
||||||
const results = await groupQuery(inviteMessage.groupJid!, 'set', [{
|
const results = await groupQuery(inviteMessage.groupJid!, 'set', [{
|
||||||
tag: 'accept',
|
tag: 'accept',
|
||||||
@@ -163,7 +163,7 @@ export const makeGroupsSocket = (config: SocketConfig) => {
|
|||||||
// update the invite message to be expired
|
// update the invite message to be expired
|
||||||
if(key.id) {
|
if(key.id) {
|
||||||
// create new invite message that is expired
|
// create new invite message that is expired
|
||||||
inviteMessage = proto.GroupInviteMessage.fromObject(inviteMessage)
|
inviteMessage = proto.Message.GroupInviteMessage.fromObject(inviteMessage)
|
||||||
inviteMessage.inviteExpiration = 0
|
inviteMessage.inviteExpiration = 0
|
||||||
inviteMessage.inviteCode = ''
|
inviteMessage.inviteCode = ''
|
||||||
ev.emit('messages.update', [
|
ev.emit('messages.update', [
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
|||||||
case 'not_ephemeral':
|
case 'not_ephemeral':
|
||||||
result.message = {
|
result.message = {
|
||||||
protocolMessage: {
|
protocolMessage: {
|
||||||
type: proto.ProtocolMessage.ProtocolMessageType.EPHEMERAL_SETTING,
|
type: proto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING,
|
||||||
ephemeralExpiration: +(child.attrs.expiration || 0)
|
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
|
// 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
|
// or another device of ours has read some messages
|
||||||
status > proto.WebMessageInfo.WebMessageInfoStatus.DELIVERY_ACK ||
|
status > proto.WebMessageInfo.Status.DELIVERY_ACK ||
|
||||||
!isNodeFromMe
|
!isNodeFromMe
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
if(isJidGroup(remoteJid)) {
|
if(isJidGroup(remoteJid)) {
|
||||||
if(attrs.participant) {
|
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(
|
ev.emit(
|
||||||
'message-receipt.update',
|
'message-receipt.update',
|
||||||
ids.map(id => ({
|
ids.map(id => ({
|
||||||
@@ -428,7 +428,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
|||||||
async() => {
|
async() => {
|
||||||
await decryptionTask
|
await decryptionTask
|
||||||
// message failed to decrypt
|
// message failed to decrypt
|
||||||
if(msg.messageStubType === proto.WebMessageInfo.WebMessageInfoStubType.CIPHERTEXT) {
|
if(msg.messageStubType === proto.WebMessageInfo.StubType.CIPHERTEXT) {
|
||||||
logger.error(
|
logger.error(
|
||||||
{ key: msg.key, params: msg.messageStubParameters },
|
{ key: msg.key, params: msg.messageStubParameters },
|
||||||
'failure in decrypting message'
|
'failure in decrypting message'
|
||||||
|
|||||||
@@ -550,8 +550,8 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
const media = decryptMediaRetryData(result.media!, mediaKey, result.key.id!)
|
const media = decryptMediaRetryData(result.media!, mediaKey, result.key.id!)
|
||||||
if(media.result !== proto.MediaRetryNotification.MediaRetryNotificationResultType.SUCCESS) {
|
if(media.result !== proto.MediaRetryNotification.ResultType.SUCCESS) {
|
||||||
const resultStr = proto.MediaRetryNotification.MediaRetryNotificationResultType[media.result]
|
const resultStr = proto.MediaRetryNotification.ResultType[media.result]
|
||||||
throw new Boom(
|
throw new Boom(
|
||||||
`Media re-upload failed by device (${resultStr})`,
|
`Media re-upload failed by device (${resultStr})`,
|
||||||
{ data: media, statusCode: getStatusCodeForMediaRetry(media.result) || 404 }
|
{ data: media, statusCode: getStatusCodeForMediaRetry(media.result) || 404 }
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export type SignalDataTypeMap = {
|
|||||||
'session': any
|
'session': any
|
||||||
'sender-key': any
|
'sender-key': any
|
||||||
'sender-key-memory': { [jid: string]: boolean }
|
'sender-key-memory': { [jid: string]: boolean }
|
||||||
'app-state-sync-key': proto.IAppStateSyncKeyData
|
'app-state-sync-key': proto.Message.IAppStateSyncKeyData
|
||||||
'app-state-sync-version': LTHashState
|
'app-state-sync-version': LTHashState
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export type WAPatchCreate = {
|
|||||||
index: string[]
|
index: string[]
|
||||||
type: WAPatchName
|
type: WAPatchName
|
||||||
apiVersion: number
|
apiVersion: number
|
||||||
operation: proto.SyncdMutation.SyncdMutationSyncdOperation
|
operation: proto.SyncdMutation.SyncdOperation
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Chat = proto.IConversation & {
|
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
|
* 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
|
* 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 =
|
export type ChatModification =
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,15 +9,15 @@ import type { GroupMetadata } from './GroupMetadata'
|
|||||||
export { proto as WAProto }
|
export { proto as WAProto }
|
||||||
export type WAMessage = proto.IWebMessageInfo
|
export type WAMessage = proto.IWebMessageInfo
|
||||||
export type WAMessageContent = proto.IMessage
|
export type WAMessageContent = proto.IMessage
|
||||||
export type WAContactMessage = proto.IContactMessage
|
export type WAContactMessage = proto.Message.IContactMessage
|
||||||
export type WAContactsArrayMessage = proto.IContactsArrayMessage
|
export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage
|
||||||
export type WAMessageKey = proto.IMessageKey
|
export type WAMessageKey = proto.IMessageKey
|
||||||
export type WATextMessage = proto.IExtendedTextMessage
|
export type WATextMessage = proto.Message.IExtendedTextMessage
|
||||||
export type WAContextInfo = proto.IContextInfo
|
export type WAContextInfo = proto.IContextInfo
|
||||||
export type WALocationMessage = proto.ILocationMessage
|
export type WALocationMessage = proto.Message.ILocationMessage
|
||||||
export type WAGenericMediaMessage = proto.IVideoMessage | proto.IImageMessage | proto.IAudioMessage | proto.IDocumentMessage | proto.IStickerMessage
|
export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage
|
||||||
export import WAMessageStubType = proto.WebMessageInfo.WebMessageInfoStubType
|
export import WAMessageStubType = proto.WebMessageInfo.StubType
|
||||||
export import WAMessageStatus = proto.WebMessageInfo.WebMessageInfoStatus
|
export import WAMessageStatus = proto.WebMessageInfo.Status
|
||||||
export type WAMediaUpload = Buffer | { url: URL | string } | { stream: Readable }
|
export type WAMediaUpload = Buffer | { url: URL | string } | { stream: Readable }
|
||||||
/** Set of message types that are supported by the library */
|
/** Set of message types that are supported by the library */
|
||||||
export type MessageType = keyof proto.Message
|
export type MessageType = keyof proto.Message
|
||||||
@@ -51,7 +51,7 @@ type ViewOnce = {
|
|||||||
}
|
}
|
||||||
type Buttonable = {
|
type Buttonable = {
|
||||||
/** add buttons to the message */
|
/** add buttons to the message */
|
||||||
buttons?: proto.IButton[]
|
buttons?: proto.Message.ButtonsMessage.IButton[]
|
||||||
}
|
}
|
||||||
type Templatable = {
|
type Templatable = {
|
||||||
/** add buttons to the message (conflicts with normal buttons)*/
|
/** add buttons to the message (conflicts with normal buttons)*/
|
||||||
@@ -61,7 +61,7 @@ type Templatable = {
|
|||||||
}
|
}
|
||||||
type Listable = {
|
type Listable = {
|
||||||
/** Sections of the List */
|
/** Sections of the List */
|
||||||
sections?: proto.ISection[]
|
sections?: proto.Message.ListMessage.ISection[]
|
||||||
|
|
||||||
/** Title of a List Message only */
|
/** Title of a List Message only */
|
||||||
title?: string
|
title?: string
|
||||||
@@ -117,13 +117,13 @@ export type AnyRegularMessageContent = (
|
|||||||
{
|
{
|
||||||
contacts: {
|
contacts: {
|
||||||
displayName?: string
|
displayName?: string
|
||||||
contacts: proto.IContactMessage[]
|
contacts: proto.Message.IContactMessage[]
|
||||||
}
|
}
|
||||||
} |
|
} |
|
||||||
{
|
{
|
||||||
location: WALocationMessage
|
location: WALocationMessage
|
||||||
} | {
|
} | {
|
||||||
react: proto.IReactionMessage
|
react: proto.Message.IReactionMessage
|
||||||
} | {
|
} | {
|
||||||
buttonReply: ButtonReplyInfo
|
buttonReply: ButtonReplyInfo
|
||||||
type: 'template' | 'plain'
|
type: 'template' | 'plain'
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { toNumber } from './generics'
|
|||||||
import { LT_HASH_ANTI_TAMPERING } from './lt-hash'
|
import { LT_HASH_ANTI_TAMPERING } from './lt-hash'
|
||||||
import { downloadContentFromMessage, } from './messages-media'
|
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 mutationKeys = (keydata: Uint8Array) => {
|
||||||
const expanded = hkdf(keydata, 160, { info: 'WhatsApp Mutation Keys' })
|
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 = () => {
|
const getKeyData = () => {
|
||||||
let r: number
|
let r: number
|
||||||
switch (operation) {
|
switch (operation) {
|
||||||
case proto.SyncdMutation.SyncdMutationSyncdOperation.SET:
|
case proto.SyncdMutation.SyncdOperation.SET:
|
||||||
r = 0x01
|
r = 0x01
|
||||||
break
|
break
|
||||||
case proto.SyncdMutation.SyncdMutationSyncdOperation.REMOVE:
|
case proto.SyncdMutation.SyncdOperation.REMOVE:
|
||||||
r = 0x02
|
r = 0x02
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ const to64BitNetworkOrder = (e: number) => {
|
|||||||
return Buffer.from(t)
|
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'>) => {
|
const makeLtHashGenerator = ({ indexValueMap, hash }: Pick<LTHashState, 'hash' | 'indexValueMap'>) => {
|
||||||
indexValueMap = { ...indexValueMap }
|
indexValueMap = { ...indexValueMap }
|
||||||
@@ -65,7 +65,7 @@ const makeLtHashGenerator = ({ indexValueMap, hash }: Pick<LTHashState, 'hash' |
|
|||||||
mix: ({ indexMac, valueMac, operation }: Mac) => {
|
mix: ({ indexMac, valueMac, operation }: Mac) => {
|
||||||
const indexMacBase64 = Buffer.from(indexMac).toString('base64')
|
const indexMacBase64 = Buffer.from(indexMac).toString('base64')
|
||||||
const prevOp = indexValueMap[indexMacBase64]
|
const prevOp = indexValueMap[indexMacBase64]
|
||||||
if(operation === proto.SyncdMutation.SyncdMutationSyncdOperation.REMOVE) {
|
if(operation === proto.SyncdMutation.SyncdOperation.REMOVE) {
|
||||||
if(!prevOp) {
|
if(!prevOp) {
|
||||||
throw new Boom('tried remove, but no previous op', { data: { indexMac, valueMac } })
|
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!) {
|
for(const msgMutation of msgMutations!) {
|
||||||
// if it's a syncdmutation, get the operation property
|
// if it's a syncdmutation, get the operation property
|
||||||
// otherwise, if it's only a record -- it'll be a SET mutation
|
// 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 record = ('record' in msgMutation && !!msgMutation.record) ? msgMutation.record : msgMutation as proto.ISyncdRecord
|
||||||
|
|
||||||
const key = await getKey(record.keyId!.id!)
|
const key = await getKey(record.keyId!.id!)
|
||||||
@@ -460,9 +460,9 @@ export const chatModificationToAppPatch = (
|
|||||||
mod: ChatModification,
|
mod: ChatModification,
|
||||||
jid: string
|
jid: string
|
||||||
) => {
|
) => {
|
||||||
const OP = proto.SyncdMutation.SyncdMutationSyncdOperation
|
const OP = proto.SyncdMutation.SyncdOperation
|
||||||
const getMessageRange = (lastMessages: LastMessageList) => {
|
const getMessageRange = (lastMessages: LastMessageList) => {
|
||||||
let messageRange: proto.ISyncActionMessageRange
|
let messageRange: proto.SyncActionValue.ISyncActionMessageRange
|
||||||
if(Array.isArray(lastMessages)) {
|
if(Array.isArray(lastMessages)) {
|
||||||
const lastMsg = lastMessages[lastMessages.length - 1]
|
const lastMsg = lastMessages[lastMessages.length - 1]
|
||||||
messageRange = {
|
messageRange = {
|
||||||
@@ -713,7 +713,7 @@ export const processSyncAction = (
|
|||||||
logger?.warn({ syncAction, id }, 'unprocessable update')
|
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 chat = recvChats?.[id]
|
||||||
const lastMsgTimestamp = msgRange?.lastMessageTimestamp || msgRange?.lastSystemMessageTimestamp || 0
|
const lastMsgTimestamp = msgRange?.lastMessageTimestamp || msgRange?.lastSystemMessageTimestamp || 0
|
||||||
const chatLastMsgTimestamp = chat?.lastMsgRecvTimestamp || 0
|
const chatLastMsgTimestamp = chat?.lastMsgRecvTimestamp || 0
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export const decodeMessageStanza = (stanza: BinaryNode, auth: AuthenticationStat
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(key.fromMe) {
|
if(key.fromMe) {
|
||||||
fullMessage.status = proto.WebMessageInfo.WebMessageInfoStatus.SERVER_ACK
|
fullMessage.status = proto.WebMessageInfo.Status.SERVER_ACK
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -92,7 +92,7 @@ export const decodeMessageStanza = (stanza: BinaryNode, auth: AuthenticationStat
|
|||||||
for(const { tag, attrs, content } of stanza.content) {
|
for(const { tag, attrs, content } of stanza.content) {
|
||||||
if(tag === 'verified_name' && content instanceof Uint8Array) {
|
if(tag === 'verified_name' && content instanceof Uint8Array) {
|
||||||
const cert = proto.VerifiedNameCertificate.decode(content)
|
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
|
fullMessage.verifiedBizName = details.verifiedName
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ export const decodeMessageStanza = (stanza: BinaryNode, auth: AuthenticationStat
|
|||||||
fullMessage.message = msg
|
fullMessage.message = msg
|
||||||
}
|
}
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
fullMessage.messageStubType = proto.WebMessageInfo.WebMessageInfoStubType.CIPHERTEXT
|
fullMessage.messageStubType = proto.WebMessageInfo.StubType.CIPHERTEXT
|
||||||
fullMessage.messageStubParameters = [error.message]
|
fullMessage.messageStubParameters = [error.message]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,7 @@ export const decodeMessageStanza = (stanza: BinaryNode, auth: AuthenticationStat
|
|||||||
|
|
||||||
// if nothing was found to decrypt
|
// if nothing was found to decrypt
|
||||||
if(!decryptables) {
|
if(!decryptables) {
|
||||||
fullMessage.messageStubType = proto.WebMessageInfo.WebMessageInfoStubType.CIPHERTEXT
|
fullMessage.messageStubType = proto.WebMessageInfo.StubType.CIPHERTEXT
|
||||||
fullMessage.messageStubParameters = [NO_MESSAGE_FOUND_ERROR_TEXT]
|
fullMessage.messageStubParameters = [NO_MESSAGE_FOUND_ERROR_TEXT]
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|||||||
@@ -262,10 +262,10 @@ export const generateMdTagPrefix = () => {
|
|||||||
return `${bytes.readUInt16BE()}.${bytes.readUInt16BE(2)}-`
|
return `${bytes.readUInt16BE()}.${bytes.readUInt16BE(2)}-`
|
||||||
}
|
}
|
||||||
|
|
||||||
const STATUS_MAP: { [_: string]: proto.WebMessageInfo.WebMessageInfoStatus } = {
|
const STATUS_MAP: { [_: string]: proto.WebMessageInfo.Status } = {
|
||||||
'played': proto.WebMessageInfo.WebMessageInfoStatus.PLAYED,
|
'played': proto.WebMessageInfo.Status.PLAYED,
|
||||||
'read': proto.WebMessageInfo.WebMessageInfoStatus.READ,
|
'read': proto.WebMessageInfo.Status.READ,
|
||||||
'read-self': proto.WebMessageInfo.WebMessageInfoStatus.READ
|
'read-self': proto.WebMessageInfo.Status.READ
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Given a type of receipt, returns what the new status of the message should be
|
* 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) => {
|
export const getStatusFromReceiptType = (type: string | undefined) => {
|
||||||
const status = STATUS_MAP[type!]
|
const status = STATUS_MAP[type!]
|
||||||
if(typeof type === 'undefined') {
|
if(typeof type === 'undefined') {
|
||||||
return proto.WebMessageInfo.WebMessageInfoStatus.DELIVERY_ACK
|
return proto.WebMessageInfo.Status.DELIVERY_ACK
|
||||||
}
|
}
|
||||||
|
|
||||||
return status
|
return status
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { downloadContentFromMessage } from './messages-media'
|
|||||||
|
|
||||||
const inflatePromise = promisify(inflate)
|
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')
|
const stream = await downloadContentFromMessage(msg, 'history')
|
||||||
let buffer = Buffer.from([])
|
let buffer = Buffer.from([])
|
||||||
for await (const chunk of stream) {
|
for await (const chunk of stream) {
|
||||||
@@ -33,8 +33,8 @@ export const processHistoryMessage = (
|
|||||||
const chats: Chat[] = []
|
const chats: Chat[] = []
|
||||||
|
|
||||||
switch (item.syncType) {
|
switch (item.syncType) {
|
||||||
case proto.HistorySync.HistorySyncHistorySyncType.INITIAL_BOOTSTRAP:
|
case proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP:
|
||||||
case proto.HistorySync.HistorySyncHistorySyncType.RECENT:
|
case proto.HistorySync.HistorySyncType.RECENT:
|
||||||
for(const chat of item.conversations!) {
|
for(const chat of item.conversations!) {
|
||||||
const contactId = `c:${chat.id}`
|
const contactId = `c:${chat.id}`
|
||||||
if(chat.name && !historyCache.has(contactId)) {
|
if(chat.name && !historyCache.has(contactId)) {
|
||||||
@@ -72,7 +72,7 @@ export const processHistoryMessage = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
case proto.HistorySync.HistorySyncHistorySyncType.PUSH_NAME:
|
case proto.HistorySync.HistorySyncType.PUSH_NAME:
|
||||||
for(const c of item.pushnames!) {
|
for(const c of item.pushnames!) {
|
||||||
const contactId = `c:${c.id}`
|
const contactId = `c:${c.id}`
|
||||||
if(!historyCache.has(contactId)) {
|
if(!historyCache.has(contactId)) {
|
||||||
@@ -82,7 +82,7 @@ export const processHistoryMessage = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
case proto.HistorySync.HistorySyncHistorySyncType.INITIAL_STATUS_V3:
|
case proto.HistorySync.HistorySyncType.INITIAL_STATUS_V3:
|
||||||
// TODO
|
// TODO
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ export const processHistoryMessage = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const downloadAndProcessHistorySyncNotification = async(
|
export const downloadAndProcessHistorySyncNotification = async(
|
||||||
msg: proto.IHistorySyncNotification,
|
msg: proto.Message.IHistorySyncNotification,
|
||||||
historyCache: Set<string>,
|
historyCache: Set<string>,
|
||||||
recvChats: InitialReceivedChatsState
|
recvChats: InitialReceivedChatsState
|
||||||
) => {
|
) => {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { Readable, Transform } from 'stream'
|
|||||||
import { URL } from 'url'
|
import { URL } from 'url'
|
||||||
import { proto } from '../../WAProto'
|
import { proto } from '../../WAProto'
|
||||||
import { DEFAULT_ORIGIN, MEDIA_PATH_MAP } from '../Defaults'
|
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 { BinaryNode, getBinaryNodeChild, getBinaryNodeChildBuffer, jidNormalizedUser } from '../WABinary'
|
||||||
import { aesDecryptGCM, aesEncryptGCM, hkdf } from './crypto'
|
import { aesDecryptGCM, aesEncryptGCM, hkdf } from './crypto'
|
||||||
import { generateMessageID } from './generics'
|
import { generateMessageID } from './generics'
|
||||||
@@ -479,12 +479,8 @@ export function extensionForMediaMessage(message: WAMessageContent) {
|
|||||||
) {
|
) {
|
||||||
extension = '.jpeg'
|
extension = '.jpeg'
|
||||||
} else {
|
} else {
|
||||||
const messageContent = message[type] as
|
const messageContent = message[type] as WAGenericMediaMessage
|
||||||
| WAProto.VideoMessage
|
extension = getExtension(messageContent.mimetype!)
|
||||||
| WAProto.ImageMessage
|
|
||||||
| WAProto.AudioMessage
|
|
||||||
| WAProto.DocumentMessage
|
|
||||||
extension = getExtension (messageContent.mimetype)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return extension
|
return extension
|
||||||
@@ -666,8 +662,8 @@ export const decryptMediaRetryData = (
|
|||||||
export const getStatusCodeForMediaRetry = (code: number) => MEDIA_RETRY_STATUS_MAP[code]
|
export const getStatusCodeForMediaRetry = (code: number) => MEDIA_RETRY_STATUS_MAP[code]
|
||||||
|
|
||||||
const MEDIA_RETRY_STATUS_MAP = {
|
const MEDIA_RETRY_STATUS_MAP = {
|
||||||
[proto.MediaRetryNotification.MediaRetryNotificationResultType.SUCCESS]: 200,
|
[proto.MediaRetryNotification.ResultType.SUCCESS]: 200,
|
||||||
[proto.MediaRetryNotification.MediaRetryNotificationResultType.DECRYPTION_ERROR]: 412,
|
[proto.MediaRetryNotification.ResultType.DECRYPTION_ERROR]: 412,
|
||||||
[proto.MediaRetryNotification.MediaRetryNotificationResultType.NOT_FOUND]: 404,
|
[proto.MediaRetryNotification.ResultType.NOT_FOUND]: 404,
|
||||||
[proto.MediaRetryNotification.MediaRetryNotificationResultType.GENERAL_ERROR]: 418,
|
[proto.MediaRetryNotification.ResultType.GENERAL_ERROR]: 418,
|
||||||
} as const
|
} as const
|
||||||
|
|||||||
@@ -48,14 +48,14 @@ const MIMETYPE_MAP: { [T in MediaType]: string } = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const MessageTypeProto = {
|
const MessageTypeProto = {
|
||||||
'image': WAProto.ImageMessage,
|
'image': WAProto.Message.ImageMessage,
|
||||||
'video': WAProto.VideoMessage,
|
'video': WAProto.Message.VideoMessage,
|
||||||
'audio': WAProto.AudioMessage,
|
'audio': WAProto.Message.AudioMessage,
|
||||||
'sticker': WAProto.StickerMessage,
|
'sticker': WAProto.Message.StickerMessage,
|
||||||
'document': WAProto.DocumentMessage,
|
'document': WAProto.Message.DocumentMessage,
|
||||||
} as const
|
} 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']) => {
|
export const generateLinkPreviewIfRequired = async(text: string, getUrlInfo: MessageGenerationOptions['getUrlInfo'], logger: MessageGenerationOptions['logger']) => {
|
||||||
const matchedUrls = text.match(URL_REGEX)
|
const matchedUrls = text.match(URL_REGEX)
|
||||||
@@ -210,7 +210,7 @@ export const prepareDisappearingMessageSettingContent = (ephemeralExpiration?: n
|
|||||||
ephemeralMessage: {
|
ephemeralMessage: {
|
||||||
message: {
|
message: {
|
||||||
protocolMessage: {
|
protocolMessage: {
|
||||||
type: WAProto.ProtocolMessage.ProtocolMessageType.EPHEMERAL_SETTING,
|
type: WAProto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING,
|
||||||
ephemeralExpiration
|
ephemeralExpiration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -287,22 +287,22 @@ export const generateWAMessageContent = async(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(contactLen === 1) {
|
if(contactLen === 1) {
|
||||||
m.contactMessage = WAProto.ContactMessage.fromObject(message.contacts.contacts[0])
|
m.contactMessage = WAProto.Message.ContactMessage.fromObject(message.contacts.contacts[0])
|
||||||
} else {
|
} else {
|
||||||
m.contactsArrayMessage = WAProto.ContactsArrayMessage.fromObject(message.contacts)
|
m.contactsArrayMessage = WAProto.Message.ContactsArrayMessage.fromObject(message.contacts)
|
||||||
}
|
}
|
||||||
} else if('location' in message) {
|
} 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) {
|
} else if('react' in message) {
|
||||||
if(!message.react.senderTimestampMs) {
|
if(!message.react.senderTimestampMs) {
|
||||||
message.react.senderTimestampMs = Date.now()
|
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) {
|
} else if('delete' in message) {
|
||||||
m.protocolMessage = {
|
m.protocolMessage = {
|
||||||
key: message.delete,
|
key: message.delete,
|
||||||
type: WAProto.ProtocolMessage.ProtocolMessageType.REVOKE
|
type: WAProto.Message.ProtocolMessage.Type.REVOKE
|
||||||
}
|
}
|
||||||
} else if('forward' in message) {
|
} else if('forward' in message) {
|
||||||
m = generateForwardMessageContent(
|
m = generateForwardMessageContent(
|
||||||
@@ -327,7 +327,7 @@ export const generateWAMessageContent = async(
|
|||||||
m.buttonsResponseMessage = {
|
m.buttonsResponseMessage = {
|
||||||
selectedButtonId: message.buttonReply.id,
|
selectedButtonId: message.buttonReply.id,
|
||||||
selectedDisplayText: message.buttonReply.displayText,
|
selectedDisplayText: message.buttonReply.displayText,
|
||||||
type: proto.ButtonsResponseMessage.ButtonsResponseMessageType.DISPLAY_TEXT,
|
type: proto.Message.ButtonsResponseMessage.Type.DISPLAY_TEXT,
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -339,8 +339,8 @@ export const generateWAMessageContent = async(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if('buttons' in message && !!message.buttons) {
|
if('buttons' in message && !!message.buttons) {
|
||||||
const buttonsMessage: proto.IButtonsMessage = {
|
const buttonsMessage: proto.Message.IButtonsMessage = {
|
||||||
buttons: message.buttons!.map(b => ({ ...b, type: proto.Button.ButtonType.RESPONSE }))
|
buttons: message.buttons!.map(b => ({ ...b, type: proto.Message.ButtonsMessage.Button.Type.RESPONSE }))
|
||||||
}
|
}
|
||||||
if('text' in message) {
|
if('text' in message) {
|
||||||
buttonsMessage.contentText = message.text
|
buttonsMessage.contentText = message.text
|
||||||
@@ -362,7 +362,7 @@ export const generateWAMessageContent = async(
|
|||||||
|
|
||||||
m = { buttonsMessage }
|
m = { buttonsMessage }
|
||||||
} else if('templateButtons' in message && !!message.templateButtons) {
|
} else if('templateButtons' in message && !!message.templateButtons) {
|
||||||
const msg: proto.IHydratedFourRowTemplate = {
|
const msg: proto.Message.TemplateMessage.IHydratedFourRowTemplate = {
|
||||||
hydratedButtons: message.templateButtons
|
hydratedButtons: message.templateButtons
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,13 +389,13 @@ export const generateWAMessageContent = async(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if('sections' in message && !!message.sections) {
|
if('sections' in message && !!message.sections) {
|
||||||
const listMessage: proto.IListMessage = {
|
const listMessage: proto.Message.IListMessage = {
|
||||||
sections: message.sections,
|
sections: message.sections,
|
||||||
buttonText: message.buttonText,
|
buttonText: message.buttonText,
|
||||||
title: message.title,
|
title: message.title,
|
||||||
footerText: message.footer,
|
footerText: message.footer,
|
||||||
description: message.text,
|
description: message.text,
|
||||||
listType: proto.ListMessage.ListMessageListType['SINGLE_SELECT']
|
listType: proto.Message.ListMessage.ListType.SINGLE_SELECT
|
||||||
}
|
}
|
||||||
|
|
||||||
m = { listMessage }
|
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
|
* Eg. extracts the inner message from a disappearing message/view once message
|
||||||
*/
|
*/
|
||||||
export const extractMessageContent = (content: WAMessageContent | undefined | null): WAMessageContent | undefined => {
|
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) {
|
if(msg.imageMessage) {
|
||||||
return { imageMessage: msg.imageMessage }
|
return { imageMessage: msg.imageMessage }
|
||||||
} else if(msg.documentMessage) {
|
} else if(msg.documentMessage) {
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ export const makeNoiseHandler = (
|
|||||||
const certDecoded = decrypt(serverHello!.payload!)
|
const certDecoded = decrypt(serverHello!.payload!)
|
||||||
const { intermediate: certIntermediate } = proto.CertChain.decode(certDecoded)
|
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) {
|
if(issuerSerial !== WA_CERT_DETAILS.SERIAL) {
|
||||||
throw new Boom('certification match failed', { statusCode: 400 })
|
throw new Boom('certification match failed', { statusCode: 400 })
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ const processMessage = async(
|
|||||||
const protocolMsg = content?.protocolMessage
|
const protocolMsg = content?.protocolMessage
|
||||||
if(protocolMsg) {
|
if(protocolMsg) {
|
||||||
switch (protocolMsg.type) {
|
switch (protocolMsg.type) {
|
||||||
case proto.ProtocolMessage.ProtocolMessageType.HISTORY_SYNC_NOTIFICATION:
|
case proto.Message.ProtocolMessage.Type.HISTORY_SYNC_NOTIFICATION:
|
||||||
const histNotification = protocolMsg!.historySyncNotification!
|
const histNotification = protocolMsg!.historySyncNotification!
|
||||||
|
|
||||||
logger?.info({ histNotification, id: message.key.id }, 'got history notification')
|
logger?.info({ histNotification, id: message.key.id }, 'got history notification')
|
||||||
@@ -120,7 +120,7 @@ const processMessage = async(
|
|||||||
}
|
}
|
||||||
|
|
||||||
break
|
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
|
const keys = protocolMsg.appStateSyncKeyShare!.keys
|
||||||
if(keys?.length) {
|
if(keys?.length) {
|
||||||
let newAppStateSyncKeyId = ''
|
let newAppStateSyncKeyId = ''
|
||||||
@@ -143,7 +143,7 @@ const processMessage = async(
|
|||||||
}
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
case proto.ProtocolMessage.ProtocolMessageType.REVOKE:
|
case proto.Message.ProtocolMessage.Type.REVOKE:
|
||||||
ev.emit('messages.update', [
|
ev.emit('messages.update', [
|
||||||
{
|
{
|
||||||
key: {
|
key: {
|
||||||
@@ -154,7 +154,7 @@ const processMessage = async(
|
|||||||
}
|
}
|
||||||
])
|
])
|
||||||
break
|
break
|
||||||
case proto.ProtocolMessage.ProtocolMessageType.EPHEMERAL_SETTING:
|
case proto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING:
|
||||||
Object.assign(chat, {
|
Object.assign(chat, {
|
||||||
ephemeralSettingTimestamp: toNumber(message.messageTimestamp),
|
ephemeralSettingTimestamp: toNumber(message.messageTimestamp),
|
||||||
ephemeralExpiration: protocolMsg.ephemeralExpiration || null
|
ephemeralExpiration: protocolMsg.ephemeralExpiration || null
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ export const decryptGroupSignalProto = (group: string, user: string, msg: Buffer
|
|||||||
|
|
||||||
export const processSenderKeyMessage = async(
|
export const processSenderKeyMessage = async(
|
||||||
authorJid: string,
|
authorJid: string,
|
||||||
item: proto.ISenderKeyDistributionMessage,
|
item: proto.Message.ISenderKeyDistributionMessage,
|
||||||
auth: SignalAuthState
|
auth: SignalAuthState
|
||||||
) => {
|
) => {
|
||||||
const builder = new GroupSessionBuilder(signalStorage(auth))
|
const builder = new GroupSessionBuilder(signalStorage(auth))
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export const useMultiFileAuthState = async(folder: string): Promise<{ state: Aut
|
|||||||
async id => {
|
async id => {
|
||||||
let value = await readData(`${type}-${id}.json`)
|
let value = await readData(`${type}-${id}.json`)
|
||||||
if(type === 'app-state-sync-key' && value) {
|
if(type === 'app-state-sync-key' && value) {
|
||||||
value = proto.AppStateSyncKeyData.fromObject(value)
|
value = proto.Message.AppStateSyncKeyData.fromObject(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
data[id] = value
|
data[id] = value
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export const useSingleFileAuthState = (filename: string, logger?: Logger): { sta
|
|||||||
let value = keys[key]?.[id]
|
let value = keys[key]?.[id]
|
||||||
if(value) {
|
if(value) {
|
||||||
if(type === 'app-state-sync-key') {
|
if(type === 'app-state-sync-key') {
|
||||||
value = proto.AppStateSyncKeyData.fromObject(value)
|
value = proto.Message.AppStateSyncKeyData.fromObject(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
dict[id] = value
|
dict[id] = value
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { createSignalIdentity } from './signal'
|
|||||||
|
|
||||||
type ClientPayloadConfig = Pick<SocketConfig, 'version' | 'browser' | 'syncFullHistory'>
|
type ClientPayloadConfig = Pick<SocketConfig, 'version' | 'browser' | 'syncFullHistory'>
|
||||||
|
|
||||||
const getUserAgent = ({ version }: ClientPayloadConfig): proto.IUserAgent => {
|
const getUserAgent = ({ version }: ClientPayloadConfig): proto.ClientPayload.IUserAgent => {
|
||||||
const osVersion = '0.1'
|
const osVersion = '0.1'
|
||||||
return {
|
return {
|
||||||
appVersion: {
|
appVersion: {
|
||||||
@@ -18,8 +18,8 @@ const getUserAgent = ({ version }: ClientPayloadConfig): proto.IUserAgent => {
|
|||||||
secondary: version[1],
|
secondary: version[1],
|
||||||
tertiary: version[2],
|
tertiary: version[2],
|
||||||
},
|
},
|
||||||
platform: proto.UserAgent.UserAgentPlatform.WEB,
|
platform: proto.ClientPayload.UserAgent.Platform.WEB,
|
||||||
releaseChannel: proto.UserAgent.UserAgentReleaseChannel.RELEASE,
|
releaseChannel: proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
||||||
mcc: '000',
|
mcc: '000',
|
||||||
mnc: '000',
|
mnc: '000',
|
||||||
osVersion: osVersion,
|
osVersion: osVersion,
|
||||||
@@ -32,12 +32,12 @@ const getUserAgent = ({ version }: ClientPayloadConfig): proto.IUserAgent => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const PLATFORM_MAP = {
|
const PLATFORM_MAP = {
|
||||||
'Mac OS': proto.WebInfo.WebInfoWebSubPlatform.DARWIN,
|
'Mac OS': proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
|
||||||
'Windows': proto.WebInfo.WebInfoWebSubPlatform.WIN32
|
'Windows': proto.ClientPayload.WebInfo.WebSubPlatform.WIN32
|
||||||
}
|
}
|
||||||
|
|
||||||
const getWebInfo = (config: ClientPayloadConfig): proto.IWebInfo => {
|
const getWebInfo = (config: ClientPayloadConfig): proto.ClientPayload.IWebInfo => {
|
||||||
let webSubPlatform = proto.WebInfo.WebInfoWebSubPlatform.WEB_BROWSER
|
let webSubPlatform = proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER
|
||||||
if(config.syncFullHistory && PLATFORM_MAP[config.browser[0]]) {
|
if(config.syncFullHistory && PLATFORM_MAP[config.browser[0]]) {
|
||||||
webSubPlatform = 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 => {
|
const getClientPayload = (config: ClientPayloadConfig): proto.IClientPayload => {
|
||||||
return {
|
return {
|
||||||
connectType: proto.ClientPayload.ClientPayloadConnectType.WIFI_UNKNOWN,
|
connectType: proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
|
||||||
connectReason: proto.ClientPayload.ClientPayloadConnectReason.USER_ACTIVATED,
|
connectReason: proto.ClientPayload.ConnectReason.USER_ACTIVATED,
|
||||||
userAgent: getUserAgent(config),
|
userAgent: getUserAgent(config),
|
||||||
webInfo: getWebInfo(config),
|
webInfo: getWebInfo(config),
|
||||||
}
|
}
|
||||||
@@ -83,8 +83,8 @@ export const generateRegistrationNode = (
|
|||||||
secondary: +(browserVersion[1] || 1),
|
secondary: +(browserVersion[1] || 1),
|
||||||
tertiary: +(browserVersion[2] || 0),
|
tertiary: +(browserVersion[2] || 0),
|
||||||
},
|
},
|
||||||
platformType: proto.DeviceProps.DevicePropsPlatformType[config.browser[1].toUpperCase()]
|
platformType: proto.DeviceProps.PlatformType[config.browser[1].toUpperCase()]
|
||||||
|| proto.DeviceProps.DevicePropsPlatformType.UNKNOWN,
|
|| proto.DeviceProps.PlatformType.UNKNOWN,
|
||||||
requireFullSync: config.syncFullHistory,
|
requireFullSync: config.syncFullHistory,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user