@badzz88/baileys 8.5.2 → 8.5.4
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/README.md +1 -1
- package/WAProto/WAProto.proto +1256 -75
- package/WAProto/index.d.ts +36042 -19649
- package/WAProto/index.js +181990 -135645
- package/engine-requirements.js +7 -15
- package/lib/Defaults/index.js +22 -17
- package/lib/Signal/Group/group_cipher.js +5 -5
- package/lib/Signal/Group/keyhelper.js +4 -4
- package/lib/Signal/Group/sender-chain-key.js +2 -2
- package/lib/Signal/Group/sender-key-distribution-message.js +1 -1
- package/lib/Signal/Group/sender-key-message.js +3 -3
- package/lib/Signal/Group/sender-key-record.js +1 -1
- package/lib/Signal/Group/sender-message-key.js +5 -5
- package/lib/Signal/libsignal.js +39 -59
- package/lib/Signal/lid-mapping.js +28 -10
- package/lib/Socket/aigroups.js +5 -5
- package/lib/Socket/business.js +3 -11
- package/lib/Socket/chats.js +668 -319
- package/lib/Socket/communities.js +85 -89
- package/lib/Socket/graphql.js +435 -228
- package/lib/Socket/groups.js +132 -211
- package/lib/Socket/index.js +9 -7
- package/lib/Socket/interactive-handler.js +117 -60
- package/lib/Socket/interop.js +56 -175
- package/lib/Socket/managed-account.js +79 -48
- package/lib/Socket/messages-recv.js +898 -340
- package/lib/Socket/messages-send.js +462 -160
- package/lib/Socket/mex.js +40 -53
- package/lib/Socket/newsletter.js +291 -291
- package/lib/Socket/privacy.js +77 -265
- package/lib/Socket/registration.js +164 -157
- package/lib/Socket/socket.js +181 -199
- package/lib/Socket/username.js +144 -227
- package/lib/Store/make-cache-manager-store.js +2 -2
- package/lib/Store/make-in-memory-store.js +25 -141
- package/lib/Types/Auth.js +3 -3
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Newsletter.js +96 -65
- package/lib/Types/State.js +4 -4
- package/lib/Types/index.js +1 -1
- package/lib/Utils/auth-utils.js +52 -57
- package/lib/Utils/browser-utils.js +1 -1
- package/lib/Utils/business.js +2 -6
- package/lib/Utils/chat-utils.js +102 -38
- package/lib/Utils/crypto.js +54 -84
- package/lib/Utils/decode-wa-message.js +316 -83
- package/lib/Utils/event-buffer.js +37 -61
- package/lib/Utils/generics.js +157 -103
- package/lib/Utils/group-history.js +3 -12
- package/lib/Utils/history.js +15 -15
- package/lib/Utils/index.js +1 -5
- package/lib/Utils/link-preview.js +3 -8
- package/lib/Utils/lt-hash.js +2 -35
- package/lib/Utils/make-mutex.js +1 -1
- package/lib/Utils/message-inspect.js +393 -0
- package/lib/Utils/message-retry-manager.js +27 -92
- package/lib/Utils/messages-media.js +159 -130
- package/lib/Utils/messages.js +144 -566
- package/lib/Utils/meta-ai-msmsg.js +62 -202
- package/lib/Utils/noise-handler.js +19 -21
- package/lib/Utils/offline-node-processor.js +3 -8
- package/lib/Utils/pre-key-manager.js +13 -23
- package/lib/Utils/process-message.js +197 -106
- package/lib/Utils/reporting-utils.js +2 -2
- package/lib/Utils/signal.js +28 -63
- package/lib/Utils/stanza-ack.js +39 -12
- package/lib/Utils/sync-action-utils.js +4 -7
- package/lib/Utils/tc-token-utils.js +20 -25
- package/lib/Utils/use-multi-file-auth-state.js +30 -14
- package/lib/Utils/validate-connection.js +59 -19
- package/lib/WABinary/decode.js +50 -16
- package/lib/WABinary/encode.js +54 -224
- package/lib/WABinary/generic-utils.js +7 -97
- package/lib/WABinary/jid-utils.js +27 -14
- package/lib/WAM/encode.js +7 -7
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +58 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +7 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +13 -5
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -4
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +20 -7
- package/lib/WAUSync/Protocols/USyncNewsletterProtocol.js +865 -0
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +7 -2
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +2 -1
- package/lib/WAUSync/Protocols/index.js +1 -0
- package/lib/WAUSync/USyncBackoff.js +26 -0
- package/lib/WAUSync/USyncQuery.js +77 -6
- package/lib/WAUSync/USyncUser.js +16 -8
- package/lib/WAUSync/index.js +1 -0
- package/lib/antiban.js +608 -854
- package/lib/index.js +3 -3
- package/package.json +16 -19
- package/lib/Socket/luxu.js +0 -387
- package/lib/Socket/text-router.js +0 -83
- package/lib/Store/keyed-db.js +0 -108
- package/lib/Types/Mex.js +0 -112
- package/lib/Utils/command-loader.d.ts +0 -31
- package/lib/Utils/command-loader.js +0 -100
- package/lib/Utils/companion-reg-client-utils.js +0 -42
- package/lib/Utils/curve25519-js.js +0 -275
- package/lib/Utils/native-bridge.js +0 -82
- package/lib/Utils/session-pool.d.ts +0 -16
- package/lib/Utils/session-pool.js +0 -94
- package/lib/Utils/sticker.d.ts +0 -17
- package/lib/Utils/sticker.js +0 -145
- package/lib/Utils/view-once-cache.d.ts +0 -9
- package/lib/Utils/view-once-cache.js +0 -79
package/lib/Utils/crypto.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
-
exports.signedKeyPair =
|
|
3
|
+
exports.signedKeyPair =
|
|
4
|
+
exports.Curve =
|
|
5
|
+
exports.generateSignalPubKey =
|
|
6
|
+
exports.getEnabledFeatures =
|
|
7
|
+
exports.hkdf =
|
|
8
|
+
exports.md5 =
|
|
9
|
+
void 0
|
|
4
10
|
exports.aesEncryptGCM = aesEncryptGCM
|
|
5
11
|
exports.aesDecryptGCM = aesDecryptGCM
|
|
6
12
|
exports.aesEncryptCTR = aesEncryptCTR
|
|
@@ -14,64 +20,36 @@ exports.sha256 = sha256
|
|
|
14
20
|
exports.derivePairingCodeKey = derivePairingCodeKey
|
|
15
21
|
const { subtle } = globalThis.crypto
|
|
16
22
|
const Defaults_1 = require('../Defaults')
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// checks -- see ./curve25519-js.js for details and references.
|
|
25
|
-
|
|
26
|
-
// ── MD5 ────────────────────────────────────────────────────────────────────────
|
|
27
|
-
const md5 = buffer => nodeCrypto.createHash('md5').update(buffer).digest()
|
|
28
|
-
Object.defineProperty(exports, 'md5', { enumerable: true, get: () => md5 })
|
|
29
|
-
|
|
30
|
-
// ── HKDF (RFC 5869) ─────────────────────────────────────────────────────────────
|
|
31
|
-
const hkdfExtractJS = (salt, ikm) => nodeCrypto.createHmac('sha256', salt).update(ikm).digest()
|
|
32
|
-
const hkdfExpandJS = (prk, length, info) => {
|
|
33
|
-
const hashLen = 32
|
|
34
|
-
const n = Math.ceil(length / hashLen)
|
|
35
|
-
let t = Buffer.alloc(0)
|
|
36
|
-
let okm = Buffer.alloc(0)
|
|
37
|
-
for (let i = 1; i <= n; i++) {
|
|
38
|
-
t = nodeCrypto
|
|
39
|
-
.createHmac('sha256', prk)
|
|
40
|
-
.update(Buffer.concat([t, info, Buffer.from([i])]))
|
|
41
|
-
.digest()
|
|
42
|
-
okm = Buffer.concat([okm, t])
|
|
43
|
-
}
|
|
44
|
-
return okm.subarray(0, length)
|
|
45
|
-
}
|
|
46
|
-
const hkdf = (ikm, length, options = {}) => {
|
|
47
|
-
const ikmBuf = Buffer.isBuffer(ikm) ? ikm : Buffer.from(ikm)
|
|
48
|
-
const saltBuf = options.salt
|
|
49
|
-
? Buffer.isBuffer(options.salt)
|
|
50
|
-
? options.salt
|
|
51
|
-
: Buffer.from(options.salt)
|
|
52
|
-
: Buffer.alloc(32) // RFC 5869: default salt is HashLen zero bytes
|
|
53
|
-
const infoBuf = options.info
|
|
54
|
-
? Buffer.isBuffer(options.info)
|
|
55
|
-
? options.info
|
|
56
|
-
: Buffer.from(options.info)
|
|
57
|
-
: Buffer.alloc(0)
|
|
58
|
-
const prk = hkdfExtractJS(saltBuf, ikmBuf)
|
|
59
|
-
return hkdfExpandJS(prk, length, infoBuf)
|
|
60
|
-
}
|
|
61
|
-
Object.defineProperty(exports, 'hkdf', { enumerable: true, get: () => hkdf })
|
|
23
|
+
const rb = require('whatsapp-rust-bridge')
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
Object.defineProperty(exports, 'md5', { enumerable: true, get: () => rb.md5 })
|
|
27
|
+
Object.defineProperty(exports, 'hkdf', { enumerable: true, get: () => rb.hkdf })
|
|
28
|
+
Object.defineProperty(exports, 'getEnabledFeatures', { enumerable: true, get: () => rb.getEnabledFeatures })
|
|
29
|
+
|
|
62
30
|
|
|
63
|
-
// ── Signal pub key helper ─────────────────────────────────────────────────────
|
|
64
31
|
const generateSignalPubKey = pubKey =>
|
|
65
32
|
pubKey.length === 33 ? pubKey : Buffer.concat([Defaults_1.KEY_BUNDLE_TYPE, pubKey])
|
|
66
33
|
exports.generateSignalPubKey = generateSignalPubKey
|
|
67
34
|
|
|
68
|
-
|
|
69
|
-
const curve25519JS = require('./curve25519-js')
|
|
35
|
+
|
|
70
36
|
exports.Curve = {
|
|
71
|
-
generateKeyPair: () =>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
37
|
+
generateKeyPair: () => {
|
|
38
|
+
const pair = rb.generateKeyPair()
|
|
39
|
+
return {
|
|
40
|
+
private: Buffer.from(pair.privKey),
|
|
41
|
+
public: Buffer.from(pair.pubKey).subarray(1)
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
sharedKey: (privateKey, publicKey) => Buffer.from(rb.calculateAgreement(generateSignalPubKey(publicKey), privateKey)),
|
|
45
|
+
sign: (privateKey, buf) => rb.calculateSignature(privateKey, buf),
|
|
46
|
+
verify: (pubKey, message, signature) => {
|
|
47
|
+
try {
|
|
48
|
+
return rb.verifySignature(generateSignalPubKey(pubKey), message, signature)
|
|
49
|
+
} catch {
|
|
50
|
+
return false
|
|
51
|
+
}
|
|
52
|
+
}
|
|
75
53
|
}
|
|
76
54
|
|
|
77
55
|
const signedKeyPair = (identityKeyPair, keyId) => {
|
|
@@ -82,65 +60,57 @@ const signedKeyPair = (identityKeyPair, keyId) => {
|
|
|
82
60
|
}
|
|
83
61
|
exports.signedKeyPair = signedKeyPair
|
|
84
62
|
|
|
85
|
-
|
|
63
|
+
|
|
86
64
|
function aesEncryptGCM(plaintext, key, iv, additionalData) {
|
|
87
|
-
|
|
88
|
-
if (additionalData) cipher.setAAD(additionalData)
|
|
89
|
-
const encrypted = Buffer.concat([cipher.update(plaintext), cipher.final()])
|
|
90
|
-
return Buffer.concat([encrypted, cipher.getAuthTag()])
|
|
65
|
+
return Buffer.from(rb.aesEncryptGCM(plaintext, key, iv, additionalData))
|
|
91
66
|
}
|
|
92
67
|
|
|
93
68
|
function aesDecryptGCM(ciphertext, key, iv, additionalData) {
|
|
94
|
-
|
|
95
|
-
const encrypted = ciphertext.subarray(0, ciphertext.length - 16)
|
|
96
|
-
const decipher = nodeCrypto.createDecipheriv('aes-256-gcm', key, iv)
|
|
97
|
-
if (additionalData) decipher.setAAD(additionalData)
|
|
98
|
-
decipher.setAuthTag(authTag)
|
|
99
|
-
return Buffer.concat([decipher.update(encrypted), decipher.final()])
|
|
69
|
+
return Buffer.from(rb.aesDecryptGCM(ciphertext, key, iv, additionalData))
|
|
100
70
|
}
|
|
101
71
|
|
|
102
|
-
|
|
72
|
+
|
|
103
73
|
function aesEncryptCTR(plaintext, key, iv) {
|
|
104
|
-
|
|
105
|
-
return Buffer.concat([cipher.update(plaintext), cipher.final()])
|
|
74
|
+
return Buffer.from(rb.aesEncryptCTR(plaintext, key, iv))
|
|
106
75
|
}
|
|
107
76
|
|
|
108
77
|
function aesDecryptCTR(ciphertext, key, iv) {
|
|
109
|
-
|
|
110
|
-
return Buffer.concat([decipher.update(ciphertext), decipher.final()])
|
|
78
|
+
return Buffer.from(rb.aesDecryptCTR(ciphertext, key, iv))
|
|
111
79
|
}
|
|
112
80
|
|
|
113
|
-
|
|
81
|
+
|
|
114
82
|
function aesDecrypt(buffer, key) {
|
|
115
|
-
return
|
|
83
|
+
return Buffer.from(rb.aesDecrypt(buffer, key))
|
|
116
84
|
}
|
|
117
85
|
|
|
118
|
-
function
|
|
119
|
-
return
|
|
86
|
+
function aesDecryptWithIV(buffer, key, IV) {
|
|
87
|
+
return Buffer.from(rb.aesDecryptWithIV(buffer, key, IV))
|
|
120
88
|
}
|
|
121
89
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const decipher = nodeCrypto.createDecipheriv('aes-256-cbc', key, IV)
|
|
125
|
-
return Buffer.concat([decipher.update(buffer), decipher.final()])
|
|
90
|
+
function aesEncrypt(buffer, key) {
|
|
91
|
+
return Buffer.from(rb.aesEncrypt(buffer, key))
|
|
126
92
|
}
|
|
127
93
|
|
|
128
94
|
function aesEncrypWithIV(buffer, key, IV) {
|
|
129
|
-
|
|
130
|
-
return Buffer.concat([cipher.update(buffer), cipher.final()])
|
|
95
|
+
return Buffer.from(rb.aesEncrypWithIV(buffer, key, IV))
|
|
131
96
|
}
|
|
132
97
|
|
|
133
|
-
|
|
98
|
+
|
|
134
99
|
function hmacSign(buffer, key, variant = 'sha256') {
|
|
135
|
-
|
|
100
|
+
if (variant !== 'sha256') {
|
|
101
|
+
|
|
102
|
+
const { createHmac } = require('crypto')
|
|
103
|
+
return createHmac(variant, key).update(buffer).digest()
|
|
104
|
+
}
|
|
105
|
+
return Buffer.from(rb.hmacSign(buffer, key))
|
|
136
106
|
}
|
|
137
107
|
|
|
138
|
-
|
|
108
|
+
|
|
139
109
|
function sha256(buffer) {
|
|
140
|
-
return
|
|
110
|
+
return Buffer.from(rb.sha256(buffer))
|
|
141
111
|
}
|
|
142
112
|
|
|
143
|
-
|
|
113
|
+
|
|
144
114
|
async function derivePairingCodeKey(pairingCode, salt) {
|
|
145
115
|
const encoder = new TextEncoder()
|
|
146
116
|
const pairingCodeBuffer = encoder.encode(pairingCode)
|