@neelegirl/baileys 2.0.5 → 2.1.0

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 CHANGED
@@ -1,223 +1,180 @@
1
1
  <div align="center">
2
2
 
3
- # 🌸 @neelegirl/baileys 🌸
3
+ # @neelegirl/baileys
4
4
 
5
- ### *Die WhatsApp Web API, die alles kann*
6
- ### *Smart Queue · QR-Code · Message ID · LID · TypeScript*
5
+ **Kuratiertes CommonJS-Fork-Paket auf Basis von WhiskeySockets/Baileys**
6
+ **für Neelegirl und `@neelegirl/wa-api` mit bewusst erhaltenem QR-Flow und `NEELE`-Message-ID-Signatur.**
7
7
 
8
- [![Version](https://img.shields.io/badge/Version-2.0.5-ff69b4?style=for-the-badge&logo=github)](https://github.com/neelegirl/baileys)
9
- [![Baileys API](https://img.shields.io/badge/Baileys_API-1.7.2-9b59b6?style=for-the-badge)](https://github.com/WhiskeySockets/Baileys)
10
8
  [![npm](https://img.shields.io/npm/v/@neelegirl/baileys?style=for-the-badge&color=ff69b4&logo=npm)](https://www.npmjs.com/package/@neelegirl/baileys)
11
- [![Downloads](https://img.shields.io/npm/dw/@neelegirl/baileys?style=for-the-badge&color=ff69b4&logo=npm)](https://www.npmjs.com/package/@neelegirl/baileys)
12
- [![License](https://img.shields.io/github/license/neelegirl/baileys?style=for-the-badge&color=ff69b4)](LICENSE)
13
- [![Node](https://img.shields.io/badge/Node-20+-green?style=for-the-badge&logo=node.js)](https://nodejs.org)
14
-
15
- ---
9
+ [![Node](https://img.shields.io/badge/Node-20+-2ea043?style=for-the-badge&logo=node.js)](https://nodejs.org)
10
+ [![Upstream](https://img.shields.io/badge/WhiskeySockets-Baileys%207.0.0--rc.9-6f42c1?style=for-the-badge)](https://github.com/WhiskeySockets/Baileys)
11
+ [![License](https://img.shields.io/badge/License-MIT-f778ba?style=for-the-badge)](LICENSE)
16
12
 
17
13
  <p align="center">
18
- <img src="https://files.catbox.moe/ru1msl.jpeg" width="720" alt="Neele Baileys Header" />
14
+ <img src="https://files.catbox.moe/phppor.JPG" width="920" alt="Neelegirl Baileys Hero" />
19
15
  </p>
20
16
 
21
- | 📦 Paket | 🎯 Baileys API | ✨ Highlights |
22
- |----------|----------------|----------------|
23
- | **@neelegirl/baileys v2.0.5** | **1.7.2** | Upstream-Updates · QR-Code · Message ID · Update-Check von npm |
24
-
25
- **✨ v2.0.5** · README Glow-Up · Kompatibel mit Baileys **1.7.2** · QR & Message ID unverändert · Update-Prüfung via npm-Registry
26
-
27
- [**Installation**](#-installation) · [**Quickstart**](#-quickstart-guide) · [**Features**](#-neue-features-in-version-200) · [**Dokumentation**](#-dokumentation) · [**Support**](#-support--community)
28
-
29
17
  </div>
30
18
 
31
- ---
32
-
33
- ## 📋 Inhaltsverzeichnis
34
-
35
- - [✨ Warum @neelegirl/baileys?](#-warum-neelegirlbaileys)
36
- - [🚀 Installation](#-installation)
37
- - [📖 Quickstart Guide](#-quickstart-guide)
38
- - [✨ Neue Features in Version 2.0.5](#-neue-features-in-version-205)
39
- - [💡 Grundlegende Verwendung](#-grundlegende-verwendung)
40
- - [🎯 Erweiterte Features](#-erweiterte-features)
41
- - [📚 Dokumentation](#-dokumentation)
42
- - [⚠️ Wichtige Hinweise](#️-wichtige-hinweise)
43
- - [💬 Support & Community](#-support--community)
19
+ ## Überblick
44
20
 
45
- ---
21
+ `@neelegirl/baileys` ist kein blindes 1:1-Repackaging des Upstreams. Dieses Paket hält eine bewusst kompatible CommonJS-Oberfläche für bestehende Neelegirl-/wa-api-Integrationen aufrecht und übernimmt nur solche Änderungen, die technisch sauber in die bestehende Struktur passen.
46
22
 
47
- ## Warum @neelegirl/baileys?
23
+ ### Was in `2.1.0` konkret gemacht wurde
48
24
 
49
- <div align="center">
25
+ - Paketmetadaten, Export-Surface und Node-Anforderungen aufgeräumt
26
+ - Inkonsistente Dependency-Lage korrigiert, inklusive `lru-cache`
27
+ - Signal-Session-Validierung für moderneres Retry-Verhalten ergänzt
28
+ - Retry-Pipeline selektiv an neuere Baileys-Mechanik angenähert
29
+ - Dokumentation vollständig neu geschrieben und auf reale Funktionen reduziert
50
30
 
51
- ### 🌟 **Zauberhafte Vorteile** 🌟
31
+ ### Was absichtlich **nicht** verändert wurde
52
32
 
53
- </div>
33
+ - QR-Code-Logik und QR-Anzeige bleiben unverändert
34
+ - die `NEELE`-Message-ID-Signatur bleibt unverändert
35
+ - projektindividuelle Neelegirl-Anpassungen bleiben erhalten, sofern sie nicht mit einem sicheren Upstream-Backport kollidieren
54
36
 
55
- | Feature | Beschreibung | Status |
56
- |---------|-------------|--------|
57
- | 🧠 **Leichtgewichtig** | Keine Browser- oder Selenium-Monster nötig! | ✅ |
58
- | 🌈 **WebSocket-Magie** | Direkt, schnell & stabil | ✅ |
59
- | 💖 **Multi-Device** | Vollständige Unterstützung | ✅ |
60
- | 🧩 **LID-Kompatibel** | Linked ID Erkennung & Nutzung | ✅ |
61
- | 🧷 **TypeScript** | Saubere Typen, DX zum Verlieben | ✅ |
62
- | 🔄 **Auto-Updates** | Automatische Update-Prüfung | ✅ |
63
- | 📱 **QR-Code** | Schöne QR-Code-Anzeige | ✅ |
64
- | 🎯 **Message ID** | Verbesserte Message-ID-Generierung | ✅ |
65
- | 🚀 **Smart Queue** | Intelligente Nachrichten-Warteschlange | ✅ **NEU!** |
37
+ ## Update-Status
66
38
 
67
- ---
39
+ | Bereich | Status |
40
+ | --- | --- |
41
+ | Paketbasis | gezielte Backports aus aktuellem WhiskeySockets/Baileys-Stand |
42
+ | Modulformat | bewusst CommonJS für bestehende Integrationen |
43
+ | QR-Login | unverändert erhalten |
44
+ | Message-ID-Signatur | unverändert erhalten (`NEELE`) |
45
+ | Vollsync auf Upstream-ESM | **nicht** übernommen |
68
46
 
69
- ## 🚀 Installation
47
+ **Wichtig:** Dieses Paket baut auf aktuellem Upstream-Wissen auf, ist aber **kein vollständiger ESM-Vollsync** auf `baileys@7.0.0-rc.9`. Das ist Absicht, damit bestehende Neelegirl-/wa-api-Projekte nicht durch einen harten Modulwechsel brechen.
70
48
 
71
- ### 📦 Mit npm
49
+ ## Installation
72
50
 
73
51
  ```bash
74
- npm install @neelegirl/baileys@latest
52
+ npm install @neelegirl/baileys
75
53
  ```
76
54
 
77
- ### 📦 Mit yarn
55
+ oder:
78
56
 
79
57
  ```bash
80
- yarn add @neelegirl/baileys@latest
58
+ yarn add @neelegirl/baileys
81
59
  ```
82
60
 
83
- ### 📦 Bleeding-Edge (GitHub)
61
+ ## Voraussetzungen
84
62
 
85
- ```bash
86
- npm install github:neelegirl/baileys
87
- # oder
88
- yarn add github:neelegirl/baileys
89
- ```
63
+ - Node.js `20+`
64
+ - Multi-Device-WhatsApp-Account
65
+ - Schreibzugriff für deine Auth-Dateien
90
66
 
91
- ### 📥 Import
67
+ ## Quickstart
92
68
 
93
- ```typescript
94
- // ES Modules
95
- import makeWASocket, {
96
- useMultiFileAuthState,
97
- DisconnectReason,
98
- fetchLatestBaileysVersion,
99
- Browsers,
100
- createSmartMessageQueue // 🆕 NEU!
101
- } from '@neelegirl/baileys'
102
-
103
- // CommonJS
104
- const {
105
- default: makeWASocket,
106
- useMultiFileAuthState,
107
- createSmartMessageQueue
108
- } = require('@neelegirl/baileys')
109
- ```
110
-
111
- ---
69
+ ### ESM
112
70
 
113
- ## 📖 Quickstart Guide
114
-
115
- ### 🎯 **Für Anfänger: Dein erster Bot in 5 Minuten**
116
-
117
- ```typescript
71
+ ```js
118
72
  import makeWASocket, {
119
- useMultiFileAuthState,
73
+ Browsers,
120
74
  DisconnectReason,
121
- fetchLatestBaileysVersion
75
+ fetchLatestBaileysVersion,
76
+ useMultiFileAuthState
122
77
  } from '@neelegirl/baileys'
123
78
  import { Boom } from '@hapi/boom'
124
79
 
125
80
  async function startBot() {
126
- // 1️⃣ Auth-State laden/speichern
127
81
  const { state, saveCreds } = await useMultiFileAuthState('./auth_info')
128
-
129
- // 2️⃣ Neueste WhatsApp-Version holen
130
82
  const { version } = await fetchLatestBaileysVersion()
131
-
132
- // 3️⃣ Socket erstellen
83
+
133
84
  const sock = makeWASocket({
134
85
  version,
135
86
  auth: state,
136
- printQRInTerminal: true, // QR-Code im Terminal anzeigen
137
- browser: ['Neele Bot', 'Chrome', '1.0.0']
87
+ browser: Browsers.macOS('Desktop'),
88
+ printQRInTerminal: true
138
89
  })
139
-
140
- // 4️⃣ Credentials speichern wenn sie sich ändern
90
+
141
91
  sock.ev.on('creds.update', saveCreds)
142
-
143
- // 5️⃣ Verbindungs-Updates verarbeiten
144
- sock.ev.on('connection.update', (update) => {
145
- const { connection, lastDisconnect } = update
146
-
92
+
93
+ sock.ev.on('connection.update', ({ connection, lastDisconnect, qr }) => {
94
+ if (qr) {
95
+ console.log('QR empfangen scanne ihn in WhatsApp.')
96
+ }
97
+
98
+ if (connection === 'open') {
99
+ console.log('WhatsApp verbunden.')
100
+ }
101
+
147
102
  if (connection === 'close') {
148
- const shouldReconnect =
149
- (lastDisconnect?.error as Boom)?.output?.statusCode !== DisconnectReason.loggedOut
150
-
151
- console.log('🔌 Verbindung geschlossen, reconnect:', shouldReconnect)
103
+ const statusCode = new Boom(lastDisconnect?.error)?.output?.statusCode
104
+ const shouldReconnect = statusCode !== DisconnectReason.loggedOut
105
+ console.log('Verbindung geschlossen. Reconnect:', shouldReconnect)
152
106
  if (shouldReconnect) {
153
- startBot() // Automatisch neu verbinden
107
+ startBot().catch(console.error)
154
108
  }
155
- } else if (connection === 'open') {
156
- console.log('✅ Verbunden mit WhatsApp!')
157
- }
158
- })
159
-
160
- // 6️⃣ Nachrichten empfangen
161
- sock.ev.on('messages.upsert', async ({ messages }) => {
162
- const m = messages[0]
163
- if (!m.message) return
164
-
165
- const jid = m.key.remoteJid!
166
- const text = m.message.conversation || m.message.extendedTextMessage?.text || ''
167
-
168
- // Einfacher Echo-Bot
169
- if (text.toLowerCase() === 'hallo') {
170
- await sock.sendMessage(jid, {
171
- text: '🌸 Hallo! Ich bin ein Neele-Bot! ✨'
172
- })
173
109
  }
174
110
  })
175
111
  }
176
112
 
177
- // Bot starten
178
113
  startBot().catch(console.error)
179
114
  ```
180
115
 
181
- ### 🎨 **Was passiert hier?**
116
+ ### CommonJS
182
117
 
183
- 1. **`useMultiFileAuthState`**: Speichert deine WhatsApp-Session, damit du nicht jedes Mal den QR-Code scannen musst
184
- 2. **`fetchLatestBaileysVersion`**: Holt die neueste WhatsApp-Version automatisch
185
- 3. **`makeWASocket`**: Erstellt die Verbindung zu WhatsApp
186
- 4. **`connection.update`**: Event für Verbindungsstatus (QR-Code, Verbindung, etc.)
187
- 5. **`messages.upsert`**: Event für neue Nachrichten
118
+ ```js
119
+ const {
120
+ default: makeWASocket,
121
+ Browsers,
122
+ fetchLatestBaileysVersion,
123
+ useMultiFileAuthState
124
+ } = require('@neelegirl/baileys')
125
+ ```
188
126
 
189
- ---
127
+ ## Praktische Start-Hinweise
190
128
 
191
- ## Neue Features in Version 2.0.5
129
+ Beim ersten Bot-Start sind diese Meldungen normal und gewollt:
192
130
 
193
- ### 🆕 **Was ist neu?**
194
- **Kompatibel mit Baileys API 1.7.2** · **Update-Check von npm-Registry** (1× pro Prozess) · **Message ID & QR-Code unverändert**
131
+ - `QR empfangen` oder eine QR-Terminalausgabe bei frischer Session
132
+ - `creds.update`, sobald Credentials gespeichert werden
133
+ - `connection: open`, wenn die Sitzung steht
134
+ - erneute Verbindungsversuche nach Netzabbrüchen
195
135
 
196
- <div align="center">
136
+ Wenn du `printQRInTerminal: false` setzt, musst du den QR selbst aus `connection.update` verarbeiten.
197
137
 
198
- | 🎯 Feature | 📝 Beschreibung | 🚀 Status |
199
- |-----------|----------------|-----------|
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 | ✅ |
207
- | **🚀 Smart Message Queue** | Intelligente Queue mit Auto-Retry & Prioritäten | ✅ |
208
- | **🎨 QR-Anzeige** | Schöne QR-Code-Box · unverändert | ✅ |
209
- | **🎯 Message ID** | Message-ID-Generierung · unverändert | ✅ |
210
- | **📦 WhatsApp Version** | [2, 3000, 1032141294] · Basiert auf @whiskeysockets/baileys 7.0.0-rc.9 | ✅ |
138
+ ## Reale Kernfunktionen
211
139
 
212
- </div>
140
+ - `makeWASocket()` – Socket-Initialisierung für WhatsApp Web
141
+ - `useMultiFileAuthState()` und `useMultiFileAuthStateV2()` – persistente Auth-Verwaltung
142
+ - `fetchLatestBaileysVersion()` – Laufzeitabgleich der WhatsApp-Web-Version
143
+ - `makeInMemoryStore()` – In-Memory-Store für Chat-/Kontaktzustand
144
+ - LID-/PN-bezogene Hilfen in `WABinary`, `WAUSync`, `Signal` und `Utils`
213
145
 
214
- ### 🔥 **Neue Funktionen**
146
+ ## Technischer Stand
215
147
 
216
- #### 🚀 **`createSmartMessageQueue()`** - Intelligente Nachrichten-Warteschlange **NEU!**
148
+ Dieses Fork übernimmt bewusst nur Änderungen, die mit dem vorhandenen CommonJS-Build und den bestehenden Neelegirl-Anpassungen sauber zusammenpassen.
217
149
 
218
- Die ultimative Lösung für zuverlässiges Nachrichtenversenden mit automatischen Retries, Prioritäten und Rate-Limiting!
150
+ ### Übernommen bzw. angeglichen
219
151
 
220
- ```typescript
152
+ - modernisierte Paketmetadaten und Export-Pfade
153
+ - Node-20-Laufzeitanforderung
154
+ - Retry-Manager-Anbindung für stabileres Retry-Verhalten
155
+ - Session-Validierung im Signal-Repository
156
+
157
+ ### Bewusst nicht blind übernommen
158
+
159
+ - kompletter ESM-Wechsel des aktuellen Upstreams
160
+ - Rust-Bridge-/ESM-spezifische Upstream-Pfade
161
+ - jede Upstream-Änderung, die die bestehende Neelegirl-/wa-api-Kompatibilität brechen würde
162
+
163
+ ## Bekannte Grenzen
164
+
165
+ - kein vollständiger 1:1-Upstream-Sync auf die aktuelle ESM-Struktur
166
+ - Dokumentation beschreibt nur APIs, die im Paket tatsächlich vorhanden sind
167
+ - wer Upstream-ESM oder den Rust-Bridge-Stack benötigt, sollte ein separates Migrationsprojekt planen statt dieses CJS-Fork umzubauen
168
+
169
+ ## Hinweise für Integrationen
170
+
171
+ - `@neelegirl/wa-api` soll gegen dieselbe Paketversion laufen
172
+ - für lokale Installationen sollte keine veraltete eingebettete Kopie von `@neelegirl/baileys` bevorzugt werden
173
+ - bei eigenen Typimports nutze bevorzugt den Root-Import statt tiefer, interner Pfade
174
+
175
+ ## Lizenz
176
+
177
+ MIT. Upstream-Grundlage stammt von WhiskeySockets/Baileys; dieses Paket bringt darauf abgestimmte Neelegirl-Anpassungen und kompatible Backports zusammen.
221
178
  import { createSmartMessageQueue } from '@neelegirl/baileys'
222
179
 
223
180
  // Queue erstellen
@@ -0,0 +1,10 @@
1
+ const major = parseInt(process.versions.node.split('.')[0], 10);
2
+
3
+ if (major < 20) {
4
+ console.error(
5
+ `\n❌ This package requires Node.js 20+ to run reliably.\n` +
6
+ ` You are using Node.js ${process.versions.node}.\n` +
7
+ ` Please upgrade to Node.js 20+ to proceed.\n`
8
+ );
9
+ process.exit(1);
10
+ }
@@ -93,6 +93,22 @@ function makeLibSignalRepository(auth) {
93
93
  jidToSignalProtocolAddress(jid) {
94
94
  return jidToSignalProtocolAddress(jid).toString()
95
95
  },
96
+ async validateSession(jid) {
97
+ try {
98
+ const addr = jidToSignalProtocolAddress(jid)
99
+ const session = await storage.loadSession(addr.toString())
100
+ if (!session) {
101
+ return { exists: false, reason: 'no session' }
102
+ }
103
+ if (!session.haveOpenSession()) {
104
+ return { exists: false, reason: 'no open session' }
105
+ }
106
+ return { exists: true }
107
+ }
108
+ catch (_error) {
109
+ return { exists: false, reason: 'validation error' }
110
+ }
111
+ },
96
112
  }
97
113
  }
98
114
 
@@ -27,6 +27,7 @@ const makeMessagesRecvSocket = (config) => {
27
27
  maxMsgRetryCount,
28
28
  getMessage,
29
29
  shouldIgnoreJid,
30
+ enableAutoSessionRecreation,
30
31
  } = config;
31
32
  const Neele = messages_send_1.makeMessagesSocket(config);
32
33
  const {
@@ -48,6 +49,7 @@ const makeMessagesRecvSocket = (config) => {
48
49
  getUSyncDevices,
49
50
  createParticipantNodes,
50
51
  sendPeerDataOperationMessage,
52
+ messageRetryManager,
51
53
  } = Neele;
52
54
 
53
55
  /** this mutex ensures that each retryRequest will wait for the previous one to finish */
@@ -243,15 +245,30 @@ const makeMessagesRecvSocket = (config) => {
243
245
  const { key: msgKey } = fullMessage;
244
246
  const msgId = msgKey.id;
245
247
  const key = `${msgId}:${msgKey?.participant}`;
246
- let retryCount = msgRetryCache.get(key) || 0;
248
+ let retryCount;
247
249
 
248
- if (retryCount >= maxMsgRetryCount) {
249
- logger.debug({ retryCount, msgId }, "reached retry limit, clearing");
250
- msgRetryCache.del(key);
251
- return;
250
+ if (messageRetryManager) {
251
+ if (messageRetryManager.hasExceededMaxRetries(msgId)) {
252
+ logger.debug({ msgId }, "reached retry limit, clearing");
253
+ messageRetryManager.markRetryFailed(msgId);
254
+ msgRetryCache.del(key);
255
+ return;
256
+ }
257
+
258
+ retryCount = messageRetryManager.incrementRetryCount(msgId);
259
+ msgRetryCache.set(key, retryCount);
260
+ } else {
261
+ retryCount = msgRetryCache.get(key) || 0;
262
+
263
+ if (retryCount >= maxMsgRetryCount) {
264
+ logger.debug({ retryCount, msgId }, "reached retry limit, clearing");
265
+ msgRetryCache.del(key);
266
+ return;
267
+ }
268
+
269
+ retryCount += 1;
270
+ msgRetryCache.set(key, retryCount);
252
271
  }
253
- retryCount += 1;
254
- msgRetryCache.set(key, retryCount);
255
272
 
256
273
  const {
257
274
  account,
@@ -259,12 +276,58 @@ const makeMessagesRecvSocket = (config) => {
259
276
  signedIdentityKey: identityKey,
260
277
  } = authState.creds;
261
278
 
262
- if (retryCount === 1) {
263
- //request a resend via phone
264
- const msgId = await requestPlaceholderResend(msgKey);
265
- logger.debug(
266
- `sendRetryRequest: requested placeholder resend for message ${msgId}`
267
- );
279
+ let shouldRecreateSession = false;
280
+ let recreateReason = "";
281
+ const fromJid = node.attrs.from;
282
+
283
+ if (
284
+ enableAutoSessionRecreation &&
285
+ messageRetryManager &&
286
+ typeof signalRepository.validateSession === "function"
287
+ ) {
288
+ try {
289
+ const sessionId = signalRepository.jidToSignalProtocolAddress(fromJid);
290
+ const validation = await signalRepository.validateSession(fromJid);
291
+ const result = messageRetryManager.shouldRecreateSession(
292
+ fromJid,
293
+ retryCount,
294
+ validation.exists
295
+ );
296
+
297
+ shouldRecreateSession = result.recreate;
298
+ recreateReason = result.reason;
299
+
300
+ if (shouldRecreateSession) {
301
+ logger.debug(
302
+ { fromJid, retryCount, reason: recreateReason },
303
+ "recreating session for retry"
304
+ );
305
+ await authState.keys.set({ session: { [sessionId]: null } });
306
+ forceIncludeKeys = true;
307
+ }
308
+ } catch (error) {
309
+ logger.warn({ error, fromJid }, "failed to check session recreation");
310
+ }
311
+ }
312
+
313
+ if (retryCount <= 2) {
314
+ if (messageRetryManager) {
315
+ messageRetryManager.schedulePhoneRequest(msgId, async () => {
316
+ try {
317
+ const requestId = await requestPlaceholderResend(msgKey);
318
+ logger.debug(
319
+ `sendRetryRequest: requested placeholder resend (${requestId}) for message ${msgId}`
320
+ );
321
+ } catch (error) {
322
+ logger.warn({ error, msgId }, "failed to send scheduled phone request");
323
+ }
324
+ }, retryRequestDelayMs || 3000);
325
+ } else {
326
+ const requestId = await requestPlaceholderResend(msgKey);
327
+ logger.debug(
328
+ `sendRetryRequest: requested placeholder resend for message ${requestId}`
329
+ );
330
+ }
268
331
  }
269
332
 
270
333
  const deviceIdentity = Utils_1.encodeSignedDeviceIdentity(account, true);
@@ -285,6 +348,7 @@ const makeMessagesRecvSocket = (config) => {
285
348
  id: node.attrs.id,
286
349
  t: node.attrs.t,
287
350
  v: "1",
351
+ error: "0",
288
352
  },
289
353
  },
290
354
  {
@@ -303,7 +367,7 @@ const makeMessagesRecvSocket = (config) => {
303
367
  receipt.attrs.participant = node.attrs.participant;
304
368
  }
305
369
 
306
- if (retryCount > 1 || forceIncludeKeys) {
370
+ if (retryCount > 1 || forceIncludeKeys || shouldRecreateSession) {
307
371
  const { update, preKeys } = await Utils_1.getNextPreKeys(authState, 1);
308
372
  const [keyId] = Object.keys(preKeys);
309
373
  const key = preKeys[+keyId];
@@ -62,6 +62,10 @@ export type SignalRepository = {
62
62
  ciphertext: Uint8Array
63
63
  }>
64
64
  injectE2ESession(opts: E2ESessionOpts): Promise<void>
65
+ validateSession(jid: string): Promise<{
66
+ exists: boolean
67
+ reason?: string
68
+ }>
65
69
  jidToSignalProtocolAddress(jid: string): string
66
70
  }
67
71
 
@@ -91,6 +91,8 @@ export type SocketConfig = {
91
91
  * entails uploading the jpegThumbnail to WA
92
92
  * */
93
93
  generateHighQualityLinkPreview: boolean
94
+ /** Enable automatic Signal session recreation when retries suggest a stale session */
95
+ enableAutoSessionRecreation: boolean
94
96
  /** Enable recent message caching for retry handling */
95
97
  enableRecentMessageCache: boolean
96
98
  /**
package/package.json CHANGED
@@ -1,34 +1,59 @@
1
1
  {
2
2
  "name": "@neelegirl/baileys",
3
- "version": "2.0.5",
4
- "description": "WhatsApp API for wa-api, a multi-device WhatsApp Web API client",
3
+ "version": "2.1.0",
4
+ "description": "Neelegirl CJS fork of WhiskeySockets/Baileys for wa-api, with preserved QR flow and NEELE message IDs.",
5
5
  "keywords": [
6
6
  "whatsapp",
7
- "js-whatsapp",
8
- "whatsapp-api",
7
+ "baileys",
8
+ "whiskeysockets",
9
9
  "whatsapp-web",
10
- "whatsapp-chat",
11
- "whatsapp-group",
12
10
  "automation",
13
- "multi-device"
11
+ "multi-device",
12
+ "lid",
13
+ "wa-api",
14
+ "neelegirl"
14
15
  ],
15
- "homepage": "https://github.com/@neelegirl/baileys",
16
+ "homepage": "https://github.com/neelegirl/baileys",
16
17
  "repository": {
17
- "url": "git@github.com:/@neelegirl/baileys.git"
18
+ "type": "git",
19
+ "url": "git+https://github.com/neelegirl/baileys.git"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/neelegirl/baileys/issues"
18
23
  },
19
24
  "license": "MIT",
20
25
  "author": "Neele",
21
26
  "main": "lib/index.js",
22
27
  "types": "lib/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./lib/index.d.ts",
31
+ "require": "./lib/index.js",
32
+ "default": "./lib/index.js"
33
+ },
34
+ "./lib": {
35
+ "types": "./lib/index.d.ts",
36
+ "require": "./lib/index.js",
37
+ "default": "./lib/index.js"
38
+ },
39
+ "./lib/*": "./lib/*",
40
+ "./WAProto": {
41
+ "types": "./WAProto/index.d.ts",
42
+ "require": "./WAProto/index.js",
43
+ "default": "./WAProto/index.js"
44
+ },
45
+ "./WAProto/*": "./WAProto/*",
46
+ "./package.json": "./package.json"
47
+ },
23
48
  "files": [
24
- "lib/*",
25
- "WAProto/*",
26
- "WASignalGroup/*.js"
49
+ "lib/**/*",
50
+ "WAProto/**/*",
51
+ "engine-requirements.js",
52
+ "README.md",
53
+ "LICENSE"
27
54
  ],
28
55
  "scripts": {
29
- "build:all": "tsc && typedoc",
30
- "build:docs": "typedoc",
31
- "build:tsc": "tsc"
56
+ "preinstall": "node ./engine-requirements.js"
32
57
  },
33
58
  "dependencies": {
34
59
  "@adiwajshing/keyed-db": "^0.2.4",
@@ -41,6 +66,7 @@
41
66
  "cache-manager": "4.0.1",
42
67
  "futoin-hkdf": "^1.5.1",
43
68
  "libphonenumber-js": "^1.10.20",
69
+ "lru-cache": "^11.1.0",
44
70
  "music-metadata": "^7.12.3",
45
71
  "node-cache": "^5.1.2",
46
72
  "pino": "^7.0.0",
@@ -58,7 +84,7 @@
58
84
  "conventional-changelog-cli": "^2.2.2",
59
85
  "eslint": "^8.0.0",
60
86
  "jest": "^27.0.6",
61
- "jimp": "^0.16.13",
87
+ "jimp": "^0.16.13",
62
88
  "json": "^11.0.0",
63
89
  "link-preview-js": "^3.0.5",
64
90
  "open": "^8.4.2",
@@ -90,5 +116,8 @@
90
116
  "optional": true
91
117
  }
92
118
  },
119
+ "engines": {
120
+ "node": ">=20.0.0"
121
+ },
93
122
  "packageManager": "yarn@1.22.19"
94
123
  }