@zervonexx/baileys 5.0.0 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -22
- package/README.md +4124 -4112
- package/WAProto/WAProto.json +1 -0
- package/WAProto/WAProto.proto +7160 -0
- package/WAProto/WAProtoCompile.js +264 -322
- package/WAProto/index.js +55 -95
- package/lib/Builders/AIRich.js +673 -673
- package/lib/Builders/auto.js +49 -49
- package/lib/Builders/base.js +144 -144
- package/lib/Builders/builders.js +588 -588
- package/lib/Builders/index.js +3 -3
- package/lib/Defaults/index.js +249 -248
- package/lib/Signal/index.js +2 -2
- package/lib/Signal/libsignal.js +526 -526
- package/lib/Signal/lid-mapping.js +282 -282
- package/lib/Socket/Client/index.js +1 -1
- package/lib/Socket/Client/types.js +9 -9
- package/lib/Socket/Client/websocket.js +83 -83
- package/lib/Socket/business.js +151 -151
- package/lib/Socket/chats.js +854 -854
- package/lib/Socket/communities.js +146 -146
- package/lib/Socket/groups.js +293 -293
- package/lib/Socket/index.js +17 -14
- package/lib/Socket/messages-recv.js +993 -993
- package/lib/Socket/messages-send.js +722 -722
- package/lib/Socket/mex.js +33 -33
- package/lib/Socket/newsletter.js +783 -783
- package/lib/Socket/registration.js +154 -154
- package/lib/Socket/socket.js +797 -797
- package/lib/Socket/spam-report.js +143 -143
- package/lib/Socket/username.js +81 -81
- package/lib/Socket/zervonex-handler.js +57 -57
- package/lib/Store/index.js +6 -6
- package/lib/Store/make-cache-manager-store.js +80 -80
- package/lib/Store/make-in-memory-store.js +426 -426
- package/lib/Store/make-ordered-dictionary.js +81 -81
- package/lib/Store/object-repository.js +30 -30
- package/lib/Store/reporting-info-store.js +37 -37
- package/lib/Types/Auth.js +1 -1
- package/lib/Types/Bussines.js +1 -1
- package/lib/Types/Call.js +1 -1
- package/lib/Types/Chat.js +7 -7
- package/lib/Types/Contact.js +1 -1
- package/lib/Types/Events.js +1 -1
- package/lib/Types/GroupMetadata.js +1 -1
- package/lib/Types/Label.js +24 -24
- package/lib/Types/LabelAssociation.js +6 -6
- package/lib/Types/Message.js +14 -14
- package/lib/Types/Newsletter.js +99 -99
- package/lib/Types/Product.js +1 -1
- package/lib/Types/Signal.js +1 -1
- package/lib/Types/Socket.js +14 -14
- package/lib/Types/State.js +26 -26
- package/lib/Types/USync.js +1 -1
- package/lib/Types/index.js +30 -30
- package/lib/Utils/auth-utils.js +159 -159
- package/lib/Utils/baileys-event-stream.js +32 -32
- package/lib/Utils/bot-capabilities.js +40 -40
- package/lib/Utils/bot-planning-replay.js +43 -43
- package/lib/Utils/browser-utils.js +29 -29
- package/lib/Utils/business.js +74 -74
- package/lib/Utils/chat-utils.js +316 -316
- package/lib/Utils/companion-reg-client-utils.js +19 -19
- package/lib/Utils/consumer-application.js +37 -37
- package/lib/Utils/crypto.js +52 -52
- package/lib/Utils/cstoken.js +14 -14
- package/lib/Utils/decode-wa-message.js +199 -199
- package/lib/Utils/event-buffer.js +272 -272
- package/lib/Utils/extras.js +186 -186
- package/lib/Utils/generics.js +195 -194
- package/lib/Utils/history.js +50 -50
- package/lib/Utils/identity-change-handler.js +18 -18
- package/lib/Utils/index.js +40 -40
- package/lib/Utils/link-preview.js +50 -50
- package/lib/Utils/logger.js +3 -2
- package/lib/Utils/lt-hash.js +3 -3
- package/lib/Utils/make-mutex.js +15 -15
- package/lib/Utils/message-composer.js +61 -61
- package/lib/Utils/message-retry-manager.js +47 -47
- package/lib/Utils/messages-media.js +501 -501
- package/lib/Utils/messages.js +944 -942
- package/lib/Utils/meta-ai-msmsg.js +121 -121
- package/lib/Utils/meta-compositing.js +74 -74
- package/lib/Utils/modern-messages.js +234 -234
- package/lib/Utils/native-flow.js +80 -80
- package/lib/Utils/noise-handler.js +160 -160
- package/lib/Utils/pre-key-manager.js +75 -75
- package/lib/Utils/process-message.js +400 -400
- package/lib/Utils/reporting-utils.js +170 -170
- package/lib/Utils/signal.js +166 -166
- package/lib/Utils/spam-report-utils.js +165 -165
- package/lib/Utils/sync-action-utils.js +33 -33
- package/lib/Utils/tc-token-utils.js +153 -153
- package/lib/Utils/use-keyv-auth-state.js +199 -199
- package/lib/Utils/use-multi-file-auth-state.js +83 -83
- package/lib/Utils/validate-connection.js +171 -171
- package/lib/WABinary/constants.js +1320 -1320
- package/lib/WABinary/decode.js +151 -151
- package/lib/WABinary/encode.js +139 -139
- package/lib/WABinary/generic-utils.js +202 -202
- package/lib/WABinary/index.js +6 -6
- package/lib/WABinary/jid-utils.js +235 -235
- package/lib/WABinary/types.js +4 -4
- package/lib/WAM/BinaryInfo.js +9 -9
- package/lib/WAM/constants.js +22852 -22852
- package/lib/WAM/encode.js +149 -149
- package/lib/WAM/index.js +3 -3
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +30 -30
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +48 -48
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +23 -23
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +28 -28
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +15 -15
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +24 -24
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +9 -9
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +21 -21
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +19 -19
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +19 -19
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +22 -22
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +16 -16
- package/lib/WAUSync/Protocols/index.js +12 -12
- package/lib/WAUSync/USyncQuery.js +88 -88
- package/lib/WAUSync/USyncUser.js +20 -20
- package/lib/WAUSync/index.js +3 -3
- package/lib/index.js +66 -66
- package/package.json +187 -192
- package/WAProto/fetcher.js +0 -68
- package/WAProto/parser.js +0 -334
package/WAProto/index.js
CHANGED
|
@@ -1,96 +1,56 @@
|
|
|
1
|
-
import { existsSync,
|
|
2
|
-
import { join, dirname } from 'path'
|
|
3
|
-
import { fileURLToPath } from 'url'
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
return
|
|
58
|
-
}
|
|
59
|
-
if (hasProto && !hasJson) {
|
|
60
|
-
log('WAProto.json missing — generating from existing proto...')
|
|
61
|
-
try { await regenerateFromProto(); return } catch (e) {
|
|
62
|
-
err(`Generation failed: ${e.message} — refetching from WA Web...`)
|
|
63
|
-
del(PROTO_FILE, TABLE_FILE)
|
|
64
|
-
await refetch()
|
|
65
|
-
}
|
|
66
|
-
return
|
|
67
|
-
}
|
|
68
|
-
if (hasJson && !hasProto) { err('WAProto.proto missing but WAProto.json exists — cannot trust JSON, refetching...'); del(TABLE_FILE); await refetch(); return }
|
|
69
|
-
|
|
70
|
-
log('No proto files found — fetching from GitHub...')
|
|
71
|
-
await refetch()
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (!isMainThread) {
|
|
75
|
-
const { bundlePath, bundle, version, protoPath, tablePath } = workerData
|
|
76
|
-
try {
|
|
77
|
-
if (bundlePath || bundle) {
|
|
78
|
-
const src = bundlePath ? readFileSync(bundlePath, 'utf8') : bundle
|
|
79
|
-
if (bundlePath) unlinkSync(bundlePath)
|
|
80
|
-
const { writeFileSync, renameSync } = await import('fs')
|
|
81
|
-
const tmp = protoPath + '.tmp'
|
|
82
|
-
writeFileSync(tmp, parseBundle(src, version), 'utf8')
|
|
83
|
-
renameSync(tmp, protoPath)
|
|
84
|
-
}
|
|
85
|
-
await generateTable(protoPath, tablePath)
|
|
86
|
-
parentPort.postMessage({ ok: true })
|
|
87
|
-
} catch (e) {
|
|
88
|
-
parentPort.postMessage({ ok: false, error: e.message })
|
|
89
|
-
}
|
|
90
|
-
} else {
|
|
91
|
-
await boot()
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export { proto, codec, generateTable, _reloadProto } from './WAProtoCompile.js'
|
|
95
|
-
export { getWAVersion, fetchProtoBundle } from './fetcher.js'
|
|
1
|
+
import { existsSync, readFileSync } from 'fs'
|
|
2
|
+
import { join, dirname } from 'path'
|
|
3
|
+
import { fileURLToPath } from 'url'
|
|
4
|
+
import logger from '../lib/Utils/logger.js'
|
|
5
|
+
import { _reloadProto } from './WAProtoCompile.js'
|
|
6
|
+
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
8
|
+
const PROTO_FILE = join(__dirname, 'WAProto.proto')
|
|
9
|
+
const TABLE_FILE = join(__dirname, 'WAProto.json')
|
|
10
|
+
|
|
11
|
+
const isJsonValid = () => {
|
|
12
|
+
try {
|
|
13
|
+
const { m, t } = JSON.parse(readFileSync(TABLE_FILE, 'utf8'))
|
|
14
|
+
return Array.isArray(m) && m.length > 0 && typeof t === 'object' && Object.keys(t).length > 0
|
|
15
|
+
} catch { return false }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function boot() {
|
|
19
|
+
if (!existsSync(PROTO_FILE) || !existsSync(TABLE_FILE)) throw new Error('[WAProto] Proto files missing — reinstall the package')
|
|
20
|
+
if (!isJsonValid()) throw new Error('[WAProto] WAProto.json invalid or corrupt — reinstall the package')
|
|
21
|
+
_reloadProto()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
boot()
|
|
25
|
+
|
|
26
|
+
let _versionCache = null
|
|
27
|
+
|
|
28
|
+
export const WAProtoReady = fetch('https://web.whatsapp.com/sw.js', {
|
|
29
|
+
headers: {
|
|
30
|
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
|
|
31
|
+
'Referer': 'https://web.whatsapp.com',
|
|
32
|
+
'Sec-Fetch-Dest': 'script',
|
|
33
|
+
'Sec-Fetch-Mode': 'no-cors',
|
|
34
|
+
'Sec-Fetch-Site': 'same-origin',
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
.then(res => res.text())
|
|
38
|
+
.then(text => {
|
|
39
|
+
const match = text.match(/client_revision[^0-9]*([0-9]+)/)
|
|
40
|
+
if (!match) throw new Error('[WAProto] client_revision not found in sw.js')
|
|
41
|
+
const revision = parseInt(match[1], 10)
|
|
42
|
+
if (isNaN(revision)) throw new Error(`[WAProto] client_revision is NaN: ${match[1]}`)
|
|
43
|
+
_versionCache = [2, 3000, revision]
|
|
44
|
+
logger.info(`[WAProto] WA version: ${_versionCache.join('.')}`)
|
|
45
|
+
})
|
|
46
|
+
.catch(err => {
|
|
47
|
+
logger.warn(`[WAProto] Version fetch failed: ${err.message}`)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
export function getWAVersion() {
|
|
51
|
+
if (!_versionCache) throw new Error('[WAProto] WA version unavailable — fetch failed at boot')
|
|
52
|
+
return _versionCache
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { proto, codec, _reloadProto } from './WAProtoCompile.js'
|
|
96
56
|
export { default } from './WAProtoCompile.js'
|