mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix: add option for appStateMacVerification
This commit is contained in:
@@ -55,6 +55,10 @@ export const DEFAULT_CONNECTION_CONFIG: SocketConfig = {
|
||||
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
|
||||
generateHighQualityLinkPreview: false,
|
||||
options: { },
|
||||
appStateMacVerification: {
|
||||
patch: false,
|
||||
snapshot: false,
|
||||
},
|
||||
getMessage: async() => undefined
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,13 @@ import { makeSocket } from './socket'
|
||||
const MAX_SYNC_ATTEMPTS = 2
|
||||
|
||||
export const makeChatsSocket = (config: SocketConfig) => {
|
||||
const { logger, markOnlineOnConnect, shouldSyncHistoryMessage, fireInitQueries } = config
|
||||
const {
|
||||
logger,
|
||||
markOnlineOnConnect,
|
||||
shouldSyncHistoryMessage,
|
||||
fireInitQueries,
|
||||
appStateMacVerification,
|
||||
} = config
|
||||
const sock = makeSocket(config)
|
||||
const {
|
||||
ev,
|
||||
@@ -360,7 +366,13 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
||||
const { patches, hasMorePatches, snapshot } = decoded[name]
|
||||
try {
|
||||
if(snapshot) {
|
||||
const { state: newState, mutationMap } = await decodeSyncdSnapshot(name, snapshot, getAppStateSyncKey, initialVersionMap[name])
|
||||
const { state: newState, mutationMap } = await decodeSyncdSnapshot(
|
||||
name,
|
||||
snapshot,
|
||||
getAppStateSyncKey,
|
||||
initialVersionMap[name],
|
||||
appStateMacVerification.snapshot
|
||||
)
|
||||
states[name] = newState
|
||||
Object.assign(globalMutationMap, mutationMap)
|
||||
|
||||
@@ -377,7 +389,9 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
||||
states[name],
|
||||
getAppStateSyncKey,
|
||||
config.options,
|
||||
initialVersionMap[name]
|
||||
initialVersionMap[name],
|
||||
logger,
|
||||
appStateMacVerification.patch
|
||||
)
|
||||
|
||||
await authState.keys.set({ 'app-state-sync-version': { [name]: newState } })
|
||||
|
||||
@@ -70,6 +70,12 @@ export type SocketConfig = {
|
||||
* */
|
||||
generateHighQualityLinkPreview: boolean
|
||||
|
||||
/** verify app state MACs */
|
||||
appStateMacVerification: {
|
||||
patch: boolean
|
||||
snapshot: boolean
|
||||
}
|
||||
|
||||
/** options for axios */
|
||||
options: AxiosRequestConfig<any>
|
||||
/**
|
||||
|
||||
@@ -445,7 +445,7 @@ export const decodePatches = async(
|
||||
mutationMap[index!] = mutation
|
||||
}
|
||||
: (() => { }),
|
||||
validateMacs
|
||||
true
|
||||
)
|
||||
|
||||
newState.hash = decodeResult.hash
|
||||
|
||||
Reference in New Issue
Block a user