@neelegirl/baileys 2.0.2 → 2.0.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 +24 -12
- package/WAProto/GenerateStatics.sh +3 -0
- package/WAProto/fix-imports.js +81 -0
- package/lib/Utils/business.js +1 -1
- package/lib/Utils/messages-media.js +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
### *Die WhatsApp Web API, die alles kann*
|
|
6
6
|
### *Smart Queue · QR-Code · Message ID · LID · TypeScript*
|
|
7
7
|
|
|
8
|
-
[](https://github.com/neelegirl/baileys)
|
|
9
9
|
[](https://github.com/WhiskeySockets/Baileys)
|
|
10
10
|
[](https://www.npmjs.com/package/@neelegirl/baileys)
|
|
11
11
|
[](https://www.npmjs.com/package/@neelegirl/baileys)
|
|
12
12
|
[](LICENSE)
|
|
13
|
-
[](https://nodejs.org)
|
|
14
14
|
|
|
15
15
|
---
|
|
16
16
|
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
|
|
21
21
|
| 📦 Paket | 🎯 Baileys API | ✨ Highlights |
|
|
22
22
|
|----------|----------------|----------------|
|
|
23
|
-
| **@neelegirl/baileys v2.0.
|
|
23
|
+
| **@neelegirl/baileys v2.0.4** | **1.7.2** | Upstream-Updates · QR-Code · Message ID · Update-Check von npm |
|
|
24
24
|
|
|
25
|
-
**✨ v2.0.
|
|
25
|
+
**✨ v2.0.4** · README Glow-Up · Kompatibel mit Baileys **1.7.2** · QR & Message ID unverändert · Update-Prüfung via npm-Registry
|
|
26
26
|
|
|
27
27
|
[**Installation**](#-installation) · [**Quickstart**](#-quickstart-guide) · [**Features**](#-neue-features-in-version-200) · [**Dokumentation**](#-dokumentation) · [**Support**](#-support--community)
|
|
28
28
|
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
- [✨ Warum @neelegirl/baileys?](#-warum-neelegirlbaileys)
|
|
36
36
|
- [🚀 Installation](#-installation)
|
|
37
37
|
- [📖 Quickstart Guide](#-quickstart-guide)
|
|
38
|
-
- [✨ Neue Features in Version 2.0.
|
|
38
|
+
- [✨ Neue Features in Version 2.0.4](#-neue-features-in-version-204)
|
|
39
39
|
- [💡 Grundlegende Verwendung](#-grundlegende-verwendung)
|
|
40
40
|
- [🎯 Erweiterte Features](#-erweiterte-features)
|
|
41
41
|
- [📚 Dokumentation](#-dokumentation)
|
|
@@ -188,7 +188,7 @@ startBot().catch(console.error)
|
|
|
188
188
|
|
|
189
189
|
---
|
|
190
190
|
|
|
191
|
-
## ✨ Neue Features in Version 2.0.
|
|
191
|
+
## ✨ Neue Features in Version 2.0.4
|
|
192
192
|
|
|
193
193
|
### 🆕 **Was ist neu?**
|
|
194
194
|
**Kompatibel mit Baileys API 1.7.2** · **Update-Check von npm-Registry** (1× pro Prozess) · **Message ID & QR-Code unverändert**
|
|
@@ -197,11 +197,13 @@ startBot().catch(console.error)
|
|
|
197
197
|
|
|
198
198
|
| 🎯 Feature | 📝 Beschreibung | 🚀 Status |
|
|
199
199
|
|-----------|----------------|-----------|
|
|
200
|
-
|
|
|
201
|
-
|
|
|
202
|
-
|
|
|
203
|
-
|
|
|
204
|
-
|
|
|
200
|
+
| **🔧 Build-Tools** | WAProto GenerateStatics & Fix-Imports Skripte | ✅ **Neu** |
|
|
201
|
+
| **🧪 Engine-Check** | Node.js 20+ Prüfung für stabile Laufzeit | ✅ **Neu** |
|
|
202
|
+
| **🔄 Upstream-Updates** | validate-connection, Defaults & Pairing aus Backup Baileys | ✅ |
|
|
203
|
+
| **🔐 LID in Pairing** | Linked ID (lid) in configureSuccessfulPairing & me | ✅ |
|
|
204
|
+
| **📤 historySyncConfig** | Vollständiges DeviceProps in generateRegistrationNode | ✅ |
|
|
205
|
+
| **🌐 getWebInfo** | Desktop-Check für syncFullHistory (browser[1] === 'Desktop') | ✅ |
|
|
206
|
+
| **⚙️ Defaults** | enableAutoSessionRecreation, enableRecentMessageCache, shouldSyncHistoryMessage | ✅ |
|
|
205
207
|
| **🚀 Smart Message Queue** | Intelligente Queue mit Auto-Retry & Prioritäten | ✅ |
|
|
206
208
|
| **🎨 QR-Anzeige** | Schöne QR-Code-Box · unverändert | ✅ |
|
|
207
209
|
| **🎯 Message ID** | Message-ID-Generierung · unverändert | ✅ |
|
|
@@ -860,7 +862,17 @@ const sock = makeWASocket({
|
|
|
860
862
|
|
|
861
863
|
## 📝 Changelog
|
|
862
864
|
|
|
863
|
-
### Version 2.0.
|
|
865
|
+
### Version 2.0.4 (Aktuell) 🎉
|
|
866
|
+
|
|
867
|
+
- 📖 **README Glow-Up** – Version 2.0.4, Badges & Changelog
|
|
868
|
+
- 🧪 **Engine-Check** – Node.js 20+ Hinweis für stabile Laufzeit
|
|
869
|
+
- 🧰 **WAProto Tools** – GenerateStatics & Fix-Imports Skripte ergänzt
|
|
870
|
+
- 🔔 **Update-Check** – Liest Version von **npm-Registry** (registry.npmjs.org), nur 1× pro Prozess
|
|
871
|
+
- ✨ Semver-Vergleich für „Update verfügbar“ nur bei wirklich neuerer Version
|
|
872
|
+
- 🎨 **QR-Code** & **Message ID** – unverändert
|
|
873
|
+
- 🔄 Kompatibel mit **Baileys API 1.7.2**
|
|
874
|
+
|
|
875
|
+
### Version 2.0.2
|
|
864
876
|
|
|
865
877
|
- 📖 **README Glow-Up** – Version 2.0.2, Badges & Changelog
|
|
866
878
|
- 🔔 **Update-Check** – Liest Version von **npm-Registry** (registry.npmjs.org), nur 1× pro Prozess
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
yarn pbjs -t static-module --no-beautify -w es6 --no-bundle --no-delimited --no-verify --no-comments -o ./index.js ./WAProto.proto;
|
|
2
|
+
yarn pbjs -t static-module --no-beautify -w es6 --no-bundle --no-delimited --no-verify ./WAProto.proto | yarn pbts --no-comments -o ./index.d.ts -;
|
|
3
|
+
node ./fix-imports.js
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from 'fs';
|
|
2
|
+
import { exit } from 'process';
|
|
3
|
+
|
|
4
|
+
const filePath = './index.js'
|
|
5
|
+
|
|
6
|
+
try {
|
|
7
|
+
let content = readFileSync(filePath, 'utf8')
|
|
8
|
+
|
|
9
|
+
content = content.replace(/import \* as (\$protobuf) from/g, 'import $1 from')
|
|
10
|
+
content = content.replace(/(['"])protobufjs\/minimal(['"])/g, '$1protobufjs/minimal.js$2')
|
|
11
|
+
|
|
12
|
+
const marker = 'const $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});\n\n'
|
|
13
|
+
const longToStringHelper =
|
|
14
|
+
'function longToString(value, unsigned) {\n' +
|
|
15
|
+
'\tif (typeof value === "string") {\n' +
|
|
16
|
+
'\t\treturn value;\n' +
|
|
17
|
+
'\t}\n' +
|
|
18
|
+
'\tif (typeof value === "number") {\n' +
|
|
19
|
+
'\t\treturn String(value);\n' +
|
|
20
|
+
'\t}\n' +
|
|
21
|
+
'\tif (!$util.Long) {\n' +
|
|
22
|
+
'\t\treturn String(value);\n' +
|
|
23
|
+
'\t}\n' +
|
|
24
|
+
'\tconst normalized = $util.Long.fromValue(value);\n' +
|
|
25
|
+
'\tconst prepared = unsigned && normalized && typeof normalized.toUnsigned === "function"\n' +
|
|
26
|
+
'\t\t? normalized.toUnsigned()\n' +
|
|
27
|
+
'\t\t: normalized;\n' +
|
|
28
|
+
'\treturn prepared.toString();\n' +
|
|
29
|
+
'}\n\n'
|
|
30
|
+
const longToNumberHelper =
|
|
31
|
+
'function longToNumber(value, unsigned) {\n' +
|
|
32
|
+
'\tif (typeof value === "number") {\n' +
|
|
33
|
+
'\t\treturn value;\n' +
|
|
34
|
+
'\t}\n' +
|
|
35
|
+
'\tif (typeof value === "string") {\n' +
|
|
36
|
+
'\t\tconst numeric = Number(value);\n' +
|
|
37
|
+
'\t\treturn numeric;\n' +
|
|
38
|
+
'\t}\n' +
|
|
39
|
+
'\tif (!$util.Long) {\n' +
|
|
40
|
+
'\t\treturn Number(value);\n' +
|
|
41
|
+
'\t}\n' +
|
|
42
|
+
'\tconst normalized = $util.Long.fromValue(value);\n' +
|
|
43
|
+
'\tconst prepared = unsigned && normalized && typeof normalized.toUnsigned === "function"\n' +
|
|
44
|
+
'\t\t? normalized.toUnsigned()\n' +
|
|
45
|
+
'\t\t: typeof normalized.toSigned === "function"\n' +
|
|
46
|
+
'\t\t\t? normalized.toSigned()\n' +
|
|
47
|
+
'\t\t\t: normalized;\n' +
|
|
48
|
+
'\treturn prepared.toNumber();\n' +
|
|
49
|
+
'}\n\n'
|
|
50
|
+
|
|
51
|
+
if (!content.includes('function longToString(')) {
|
|
52
|
+
const markerIndex = content.indexOf(marker)
|
|
53
|
+
if (markerIndex === -1) {
|
|
54
|
+
throw new Error('Unable to inject Long helpers: marker not found in WAProto index output')
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
content = content.replace(marker, `${marker}${longToStringHelper}${longToNumberHelper}`)
|
|
58
|
+
} else {
|
|
59
|
+
const longToStringRegex = /function longToString\(value, unsigned\) {\n[\s\S]*?\n}\n\n/
|
|
60
|
+
const longToNumberRegex = /function longToNumber\(value, unsigned\) {\n[\s\S]*?\n}\n\n/
|
|
61
|
+
|
|
62
|
+
if (!longToStringRegex.test(content) || !longToNumberRegex.test(content)) {
|
|
63
|
+
throw new Error('Unable to update Long helpers: existing definitions not found')
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
content = content.replace(longToStringRegex, longToStringHelper)
|
|
67
|
+
content = content.replace(longToNumberRegex, longToNumberHelper)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const longPattern = /([ \t]+d\.(\w+) = )o\.longs === String \? \$util\.Long\.prototype\.toString\.call\(m\.\2\) : o\.longs === Number \? new \$util\.LongBits\(m\.\2\.low >>> 0, m\.\2\.high >>> 0\)\.toNumber\((true)?\) : m\.\2;/g
|
|
71
|
+
content = content.replace(longPattern, (_match, prefix, field, unsignedFlag) => {
|
|
72
|
+
const unsignedArg = unsignedFlag ? ', true' : ''
|
|
73
|
+
return `${prefix}o.longs === String ? longToString(m.${field}${unsignedArg}) : o.longs === Number ? longToNumber(m.${field}${unsignedArg}) : m.${field};`
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
writeFileSync(filePath, content, 'utf8')
|
|
77
|
+
console.log(`✅ Fixed imports in ${filePath}`)
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.error(`❌ Error fixing imports: ${error.message}`)
|
|
80
|
+
exit(1)
|
|
81
|
+
}
|
package/lib/Utils/business.js
CHANGED
|
@@ -208,7 +208,7 @@ const uploadingNecessaryImages = async (images, waUploadToServer, timeoutMs = 30
|
|
|
208
208
|
}
|
|
209
209
|
const { stream } = await messages_media_1.getStream(img)
|
|
210
210
|
const hasher = crypto_1.createHash('sha256')
|
|
211
|
-
const filePath = path_1.join(
|
|
211
|
+
const filePath = path_1.join(process.cwd(), 'tmp', 'img' + generics_1.generateMessageID())
|
|
212
212
|
const encFileWriteStream = fs_1.createWriteStream(filePath)
|
|
213
213
|
for await (const block of stream) {
|
|
214
214
|
hasher.update(block)
|
|
@@ -348,7 +348,7 @@ const prepareStream = async (media, mediaType, { logger, saveOriginalFileIfRequi
|
|
|
348
348
|
const { stream, type } = await getStream(media, opts)
|
|
349
349
|
logger?.debug('fetched media stream')
|
|
350
350
|
|
|
351
|
-
const encFilePath = path_1.join(
|
|
351
|
+
const encFilePath = path_1.join(process.cwd(), 'tmp', mediaType + generics_1.generateMessageID() + '-plain')
|
|
352
352
|
const encFileWriteStream = fs_1.createWriteStream(encFilePath)
|
|
353
353
|
|
|
354
354
|
let originalFilePath
|
|
@@ -357,7 +357,7 @@ const prepareStream = async (media, mediaType, { logger, saveOriginalFileIfRequi
|
|
|
357
357
|
if (type === 'file') {
|
|
358
358
|
originalFilePath = media.url.toString()
|
|
359
359
|
} else if (saveOriginalFileIfRequired) {
|
|
360
|
-
originalFilePath = path_1.join(
|
|
360
|
+
originalFilePath = path_1.join(process.cwd(), 'tmp', mediaType + generics_1.generateMessageID() + '-original')
|
|
361
361
|
originalFileStream = fs_1.createWriteStream(originalFilePath)
|
|
362
362
|
}
|
|
363
363
|
|
|
@@ -423,12 +423,12 @@ const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfReq
|
|
|
423
423
|
logger?.debug('fetched media stream')
|
|
424
424
|
const mediaKey = Crypto.randomBytes(32)
|
|
425
425
|
const { cipherKey, iv, macKey } = await getMediaKeys(mediaKey, mediaType)
|
|
426
|
-
const encFilePath = path_1.join(
|
|
426
|
+
const encFilePath = path_1.join(process.cwd(), 'tmp', mediaType + generics_1.generateMessageID() + '-enc')
|
|
427
427
|
const encFileWriteStream = fs_1.createWriteStream(encFilePath)
|
|
428
428
|
let originalFileStream
|
|
429
429
|
let originalFilePath
|
|
430
430
|
if (saveOriginalFileIfRequired) {
|
|
431
|
-
originalFilePath = path_1.join(
|
|
431
|
+
originalFilePath = path_1.join(process.cwd(), 'tmp', mediaType + generics_1.generateMessageID() + '-original')
|
|
432
432
|
originalFileStream = fs_1.createWriteStream(originalFilePath)
|
|
433
433
|
}
|
|
434
434
|
let fileLength = 0
|