@neelegirl/baileys 2.1.4 → 2.1.6

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,23 +1,27 @@
1
- <div align="center">
1
+ <div align="center">
2
2
 
3
3
  # @neelegirl/baileys
4
4
 
5
- ### CJS-compatible WhatsApp Web API foundation for the Neelegirl ecosystem
5
+ ### CommonJS WhatsApp Web runtime for Neelegirl projects
6
+ ### Conservative merge strategy based on WhiskeySockets/Baileys
6
7
 
7
- [![Version](https://img.shields.io/badge/Version-2.1.4-ff69b4?style=for-the-badge)](https://www.npmjs.com/package/@neelegirl/baileys)
8
- [![Upstream](https://img.shields.io/badge/Upstream-WhiskeySockets%2FBaileys%207.0.0--rc.9-9b59b6?style=for-the-badge)](https://github.com/WhiskeySockets/Baileys)
9
- [![Node](https://img.shields.io/badge/Node-20%2B-2ea043?style=for-the-badge&logo=node.js)](https://nodejs.org)
10
- [![License](https://img.shields.io/badge/License-MIT-f97316?style=for-the-badge)](LICENSE)
8
+ [![npm version](https://img.shields.io/npm/v/@neelegirl/baileys?style=for-the-badge&color=ff69b4&logo=npm)](https://www.npmjs.com/package/@neelegirl/baileys)
9
+ [![node](https://img.shields.io/badge/node-%3E%3D20-2ea043?style=for-the-badge&logo=node.js)](https://nodejs.org)
10
+ [![license](https://img.shields.io/badge/license-MIT-f97316?style=for-the-badge)](LICENSE)
11
+ [![runtime](https://img.shields.io/badge/runtime-CommonJS-2563eb?style=for-the-badge)](https://www.npmjs.com/package/@neelegirl/baileys)
12
+ [![reference](https://img.shields.io/badge/reference-WhiskeySockets%2FBaileys-111827?style=for-the-badge)](https://github.com/WhiskeySockets/Baileys)
13
+
14
+ ---
11
15
 
12
16
  <p align="center">
13
- <img src="https://files.catbox.moe/phppor.JPG" width="760" alt="Neelegirl Baileys Header" />
17
+ <img src="https://files.catbox.moe/phppor.JPG" width="760" alt="@neelegirl/baileys" />
14
18
  </p>
15
19
 
16
- | Package | Latest Version | Upstream Base |
20
+ | Package | Version | Main goal |
17
21
  |---|---:|---|
18
- | `@neelegirl/baileys` | `2.1.4` | `WhiskeySockets/Baileys v7.0.0-rc.9` |
22
+ | `@neelegirl/baileys` | `2.1.6` | Stable Neelegirl fork with preserved project-specific runtime behavior |
19
23
 
20
- [Installation](#installation) · [Quickstart](#quickstart) · [Feature Overview](#feature-overview) · [Compatibility Notes](#compatibility-notes)
24
+ [Installation](#installation) · [Quickstart](#quickstart) · [Protected logic](#protected-logic) · [Device and LID notes](#device-and-lid-notes) · [Verified exports](#verified-exports) · [Release notes](#release-notes)
21
25
 
22
26
  </div>
23
27
 
@@ -25,68 +29,189 @@
25
29
 
26
30
  ## Table of Contents
27
31
 
28
- - [Why this fork](#why-this-fork)
32
+ - [Overview](#overview)
33
+ - [Why this fork exists](#why-this-fork-exists)
34
+ - [Protected logic](#protected-logic)
35
+ - [What was updated in 2.1.6](#what-was-updated-in-216)
29
36
  - [Installation](#installation)
37
+ - [Imports](#imports)
30
38
  - [Quickstart](#quickstart)
31
- - [Feature Overview](#feature-overview)
32
- - [Compatibility Notes](#compatibility-notes)
33
- - [Word2Web Notes](#word2web-notes)
34
- - [Changelog](#changelog)
35
- - [Legal](#legal)
39
+ - [Session storage](#session-storage)
40
+ - [Socket configuration notes](#socket-configuration-notes)
41
+ - [Messages and media](#messages-and-media)
42
+ - [Device and LID notes](#device-and-lid-notes)
43
+ - [Event notes](#event-notes)
44
+ - [Verified exports](#verified-exports)
45
+ - [Known limits](#known-limits)
46
+ - [Release notes](#release-notes)
47
+ - [Disclaimer](#disclaimer)
36
48
 
37
- ---
49
+ ## Overview
38
50
 
39
- ## Why this fork
51
+ `@neelegirl/baileys` is the local CommonJS-oriented Neelegirl fork of Baileys used in this stack. It is meant to keep existing Neelegirl-specific behavior stable while still absorbing compatible fixes from the public WhiskeySockets/Baileys project where that improves correctness.
40
52
 
41
- `@neelegirl/baileys` keeps a CJS-first runtime for projects that depend on `require()` behavior while integrating relevant upstream updates.
53
+ This package was rechecked against the public WhiskeySockets/Baileys repository on `2026-03-19`. The merge strategy is conservative by design:
42
54
 
43
- This fork explicitly keeps two project-critical customizations unchanged:
55
+ - keep working Neelegirl runtime behavior
56
+ - adopt compatible fixes
57
+ - avoid blind upstream replacement
58
+ - avoid destructive refactors in project-critical paths
44
59
 
45
- - QR-code handling logic stays unchanged.
46
- - Message-ID logic containing `NEELE` stays unchanged.
60
+ ## Why this fork exists
47
61
 
48
- ---
62
+ The local package differs from upstream for practical reasons:
63
+
64
+ | Area | Intent |
65
+ |---|---|
66
+ | Module format | Keep CommonJS entrypoints and local consumer compatibility |
67
+ | QR flow | Preserve the existing project-specific QR behavior |
68
+ | Message IDs | Preserve `NEELE`-specific message-ID behavior |
69
+ | Device mapping | Keep project-specific platform and device labeling logic |
70
+ | Logging and watch behavior | Avoid breaking existing Neelegirl operational workflows |
71
+ | LID and JID handling | Extend carefully where current Baileys behavior improves compatibility |
72
+
73
+ ## Protected logic
74
+
75
+ The following logic was explicitly treated as protected during maintenance:
76
+
77
+ - QR-code generation and QR lifecycle
78
+ - `NEELE` message-ID generation and related custom handling
79
+ - existing Neelegirl branding and log output
80
+ - existing device, watch, and platform-specific behavior
81
+ - existing custom community and message-stub handling
82
+ - existing message-type behavior for conversation, extended text, media, and context handling
83
+
84
+ Nothing in those areas was blindly replaced with upstream code.
85
+
86
+ ## What was updated in 2.1.6
87
+
88
+ ### Runtime compatibility
89
+
90
+ - fixed the mismatch between `socket.js` expectations and the local Signal repository implementation
91
+ - added the missing runtime LID mapping store
92
+ - aligned session helpers required by the current local socket logic:
93
+ - `lidMapping`
94
+ - `validateSession`
95
+ - `deleteSession`
96
+ - `migrateSession`
97
+
98
+ ### History and identity handling
99
+
100
+ - history sync processing now collects `phoneNumberToLidMappings`
101
+ - inline bootstrap payloads are handled
102
+ - LID migration sync messages are processed conservatively
103
+ - session migration can now follow PN to LID transitions more cleanly
104
+
105
+ ### JID and device helpers
106
+
107
+ - restored and exposed helpers needed by newer Baileys compatibility work:
108
+ - `WAJIDDomains`
109
+ - `getServerFromDomainType`
110
+ - `isPnUser`
111
+ - `isJidMetaAI`
112
+ - `transferDevice`
113
+ - added a compatibility `browser-utils` re-export for `Browsers` and `getPlatformId`
114
+
115
+ ### Typings and docs
116
+
117
+ - refreshed multiple `.d.ts` files to match the actual current runtime more closely
118
+ - removed false README claims from older documentation
119
+ - replaced stale README imagery with the requested current project image
49
120
 
50
121
  ## Installation
51
122
 
123
+ Use npm:
124
+
52
125
  ```bash
53
126
  npm install @neelegirl/baileys
54
127
  ```
55
128
 
56
- ---
129
+ Use yarn:
57
130
 
58
- ## Quickstart
131
+ ```bash
132
+ yarn add @neelegirl/baileys
133
+ ```
134
+
135
+ Runtime requirement:
136
+
137
+ ```text
138
+ Node.js >= 20
139
+ ```
140
+
141
+ ## Imports
142
+
143
+ CommonJS:
59
144
 
60
145
  ```js
146
+ const makeWASocket = require('@neelegirl/baileys').default
61
147
  const {
62
- default: makeWASocket,
63
- useMultiFileAuthState,
148
+ Browsers,
149
+ DisconnectReason,
64
150
  fetchLatestBaileysVersion,
151
+ useMultiFileAuthState
152
+ } = require('@neelegirl/baileys')
153
+ ```
154
+
155
+ ESM:
156
+
157
+ ```js
158
+ import makeWASocket, {
159
+ Browsers,
65
160
  DisconnectReason,
161
+ fetchLatestBaileysVersion,
162
+ useMultiFileAuthState
163
+ } from '@neelegirl/baileys'
164
+ ```
165
+
166
+ ## Quickstart
167
+
168
+ ### Start with QR
169
+
170
+ ```js
171
+ const makeWASocket = require('@neelegirl/baileys').default
172
+ const {
66
173
  Browsers,
174
+ DisconnectReason,
175
+ fetchLatestBaileysVersion,
176
+ useMultiFileAuthState
67
177
  } = require('@neelegirl/baileys')
68
178
 
69
179
  async function start() {
70
- const { state, saveCreds } = await useMultiFileAuthState('./auth')
180
+ const { state, saveCreds } = await useMultiFileAuthState('./auth_info')
71
181
  const { version } = await fetchLatestBaileysVersion()
72
182
 
73
183
  const sock = makeWASocket({
74
- auth: state,
75
184
  version,
76
- printQRInTerminal: true,
77
- browser: Browsers.ubuntu('Chrome'),
185
+ auth: state,
186
+ browser: Browsers.ubuntu('Neelegirl'),
187
+ printQRInTerminal: true
78
188
  })
79
189
 
80
190
  sock.ev.on('creds.update', saveCreds)
81
191
 
82
192
  sock.ev.on('connection.update', ({ connection, lastDisconnect }) => {
193
+ if (connection === 'open') {
194
+ console.log('connected')
195
+ }
196
+
83
197
  if (connection === 'close') {
84
198
  const code = lastDisconnect?.error?.output?.statusCode
85
- if (code !== DisconnectReason.loggedOut) start()
199
+ const shouldReconnect = code !== DisconnectReason.loggedOut
200
+ if (shouldReconnect) {
201
+ start()
202
+ }
86
203
  }
204
+ })
87
205
 
88
- if (connection === 'open') {
89
- console.log('Connected')
206
+ sock.ev.on('messages.upsert', async ({ messages }) => {
207
+ const msg = messages[0]
208
+ const text =
209
+ msg?.message?.conversation ||
210
+ msg?.message?.extendedTextMessage?.text ||
211
+ ''
212
+
213
+ if (text.toLowerCase() === 'ping') {
214
+ await sock.sendMessage(msg.key.remoteJid, { text: 'pong' })
90
215
  }
91
216
  })
92
217
  }
@@ -94,45 +219,318 @@ async function start() {
94
219
  start().catch(console.error)
95
220
  ```
96
221
 
97
- ---
222
+ ### Start with pairing code
98
223
 
99
- ## Feature Overview
224
+ ```js
225
+ const makeWASocket = require('@neelegirl/baileys').default
226
+ const {
227
+ Browsers,
228
+ fetchLatestBaileysVersion,
229
+ useMultiFileAuthState
230
+ } = require('@neelegirl/baileys')
100
231
 
101
- - Socket, event, auth, and message APIs from the current local CJS distribution
102
- - LID/JID handling in send and receive flows
103
- - Group, community, newsletter, media, and store utilities
104
- - Optional peers for QR rendering, preview extraction, and image/audio processing
105
- - Runtime update-check support kept from the current Neelegirl package line
232
+ async function startPairing() {
233
+ const { state, saveCreds } = await useMultiFileAuthState('./auth_pairing')
234
+ const { version } = await fetchLatestBaileysVersion()
106
235
 
107
- ---
236
+ const sock = makeWASocket({
237
+ version,
238
+ auth: state,
239
+ browser: Browsers.windows('Neelegirl'),
240
+ printQRInTerminal: false
241
+ })
108
242
 
109
- ## Compatibility Notes
243
+ sock.ev.on('creds.update', saveCreds)
110
244
 
111
- - Runtime target: Node.js `>=20`
112
- - Module shape: CJS-first (`main: lib/index.js`)
113
- - Upstream policy: selective backporting from WhiskeySockets/Baileys for compatibility
245
+ if (!sock.authState.creds.registered) {
246
+ const code = await sock.requestPairingCode('491234567890')
247
+ console.log('pairing code:', code)
248
+ }
249
+ }
114
250
 
115
- If you need strict ESM parity with upstream source layout, migrate consumers to ESM first.
251
+ startPairing().catch(console.error)
252
+ ```
116
253
 
117
- ---
254
+ ## Session storage
118
255
 
119
- ## Word2Web Notes
256
+ For development, `useMultiFileAuthState(...)` is the easiest storage helper:
120
257
 
121
- No dedicated Word2Web module is shipped in this package. Document or enable Word2Web behavior only in host projects where it is actually implemented.
258
+ ```js
259
+ const { state, saveCreds } = await useMultiFileAuthState('./auth_info')
260
+ ```
122
261
 
123
- ---
262
+ The package also exports:
124
263
 
125
- ## Changelog
264
+ - `useSingleFileAuthState`
265
+ - `useMongoFileAuthState`
266
+ - `makeInMemoryStore`
126
267
 
127
- ### 2.1.4
268
+ If you build a custom store, the critical rule is simple:
128
269
 
129
- - README restyled to match the main project presentation style
130
- - Package metadata refined for publish consistency
131
- - Dependency alignment with `@neelegirl/libsignal@^1.0.8`
132
- - Existing QR and `NEELE` message-ID custom logic preserved
270
+ - credential updates must be persisted
271
+ - key updates must be persisted
272
+ - ignoring key-store updates will eventually break message delivery
133
273
 
134
- ---
274
+ ## Socket configuration notes
275
+
276
+ Useful socket options that remain especially relevant in this fork:
277
+
278
+ | Option | Why it matters |
279
+ |---|---|
280
+ | `auth` | required session state |
281
+ | `version` | WA Web version selection |
282
+ | `browser` | affects platform/device presentation |
283
+ | `printQRInTerminal` | keeps the existing QR path active |
284
+ | `markOnlineOnConnect` | controls online presence behavior |
285
+ | `syncFullHistory` | enables broader history sync requests |
286
+ | `getMessage` | improves retry and message recovery scenarios |
287
+ | `cachedGroupMetadata` | avoids repeated group fetches |
288
+
289
+ Example:
290
+
291
+ ```js
292
+ const sock = makeWASocket({
293
+ version,
294
+ auth: state,
295
+ browser: Browsers.macOS('Desktop'),
296
+ printQRInTerminal: true,
297
+ markOnlineOnConnect: false,
298
+ syncFullHistory: true,
299
+ getMessage: async (key) => {
300
+ return store.loadMessage(key.remoteJid, key.id)
301
+ },
302
+ cachedGroupMetadata: async (jid) => groupCache.get(jid)
303
+ })
304
+ ```
305
+
306
+ ## Messages and media
307
+
308
+ ### Send a text message
309
+
310
+ ```js
311
+ await sock.sendMessage(jid, { text: 'hello' })
312
+ ```
313
+
314
+ ### Reply to a message
315
+
316
+ ```js
317
+ await sock.sendMessage(
318
+ jid,
319
+ { text: 'this is a reply' },
320
+ { quoted: originalMessage }
321
+ )
322
+ ```
323
+
324
+ ### Send an image
325
+
326
+ ```js
327
+ await sock.sendMessage(jid, {
328
+ image: { url: './image.jpg' },
329
+ caption: 'sample'
330
+ })
331
+ ```
332
+
333
+ ### Send a document
334
+
335
+ ```js
336
+ await sock.sendMessage(jid, {
337
+ document: { url: './report.pdf' },
338
+ mimetype: 'application/pdf',
339
+ fileName: 'report.pdf'
340
+ })
341
+ ```
342
+
343
+ ### Send a reaction
344
+
345
+ ```js
346
+ await sock.sendMessage(jid, {
347
+ react: {
348
+ text: '❤',
349
+ key: message.key
350
+ }
351
+ })
352
+ ```
353
+
354
+ ### Download received media
355
+
356
+ ```js
357
+ const { downloadMediaMessage } = require('@neelegirl/baileys')
358
+
359
+ const buffer = await downloadMediaMessage(
360
+ message,
361
+ 'buffer',
362
+ {},
363
+ { logger: sock.logger, reuploadRequest: sock.updateMediaMessage }
364
+ )
365
+ ```
366
+
367
+ ## Device and LID notes
368
+
369
+ This fork intentionally does more than just plain PN handling.
370
+
371
+ ### Relevant helper exports
372
+
373
+ - `jidDecode`
374
+ - `jidEncode`
375
+ - `jidNormalizedUser`
376
+ - `isPnUser`
377
+ - `isLidUser`
378
+ - `isHostedPnUser`
379
+ - `isHostedLidUser`
380
+ - `transferDevice`
381
+ - `WAJIDDomains`
382
+
383
+ ### Example: inspect a JID
384
+
385
+ ```js
386
+ const { jidDecode } = require('@neelegirl/baileys')
387
+
388
+ const decoded = jidDecode('491234567890@s.whatsapp.net')
389
+ console.log(decoded)
390
+ ```
391
+
392
+ ### Example: preserve device while switching identity space
393
+
394
+ ```js
395
+ const { transferDevice } = require('@neelegirl/baileys')
396
+
397
+ const result = transferDevice(
398
+ '491234567890:5@s.whatsapp.net',
399
+ '1234567890@lid'
400
+ )
401
+ ```
402
+
403
+ ### Why this matters here
404
+
405
+ Neelegirl-specific code in this package already relies on richer identity handling around:
406
+
407
+ - `remoteJid`
408
+ - `remoteJidAlt`
409
+ - `participant`
410
+ - `participantAlt`
411
+ - sender normalization
412
+ - PN and LID mapping
413
+ - device labeling output
414
+
415
+ That is why the maintenance work kept those paths intact and only extended compatibility where necessary.
416
+
417
+ ## Event notes
418
+
419
+ Useful events in the current runtime:
420
+
421
+ ### Connection lifecycle
422
+
423
+ - `connection.update`
424
+ - `creds.update`
425
+
426
+ ### Message flow
427
+
428
+ - `messages.upsert`
429
+ - `messages.update`
430
+ - `messages.reaction`
431
+ - `message-receipt.update`
432
+
433
+ ### History and metadata
434
+
435
+ - `messaging-history.set`
436
+ - `contacts.upsert`
437
+ - `contacts.update`
438
+ - `chats.update`
439
+
440
+ ### Group and community related
441
+
442
+ - `groups.update`
443
+ - `group-participants.update`
444
+ - `group.join-request`
445
+ - `group.member-tag.update`
446
+ - `communities.update`
447
+
448
+ ### Example
449
+
450
+ ```js
451
+ sock.ev.on('messaging-history.set', ({ chats, contacts, messages, lidPnMappings }) => {
452
+ console.log({
453
+ chats: chats.length,
454
+ contacts: contacts.length,
455
+ messages: messages.length,
456
+ lidPnMappings: lidPnMappings?.length || 0
457
+ })
458
+ })
459
+ ```
460
+
461
+ ## Verified exports
462
+
463
+ The following items were verified in the currently prepared package before publish.
464
+
465
+ ### Socket and auth
466
+
467
+ - `makeWASocket`
468
+ - `useMultiFileAuthState`
469
+ - `useSingleFileAuthState`
470
+ - `useMongoFileAuthState`
471
+ - `makeInMemoryStore`
472
+
473
+ ### Version and browser helpers
474
+
475
+ - `fetchLatestBaileysVersion`
476
+ - `fetchLatestWaWebVersion`
477
+ - `Browsers`
478
+ - `getPlatformId`
479
+
480
+ ### JID and identity helpers
481
+
482
+ - `jidDecode`
483
+ - `jidEncode`
484
+ - `jidNormalizedUser`
485
+ - `isPnUser`
486
+ - `isLidUser`
487
+ - `isHostedPnUser`
488
+ - `isHostedLidUser`
489
+ - `isJidMetaAI`
490
+ - `transferDevice`
491
+ - `WAJIDDomains`
492
+
493
+ ### Message and media helpers
494
+
495
+ - `downloadMediaMessage`
496
+ - `downloadAndProcessHistorySyncNotification`
497
+ - `processHistoryMessage`
498
+ - `getHistoryMsg`
499
+ - `getContentType`
500
+ - `normalizeMessageContent`
501
+ - `generateWAMessage`
502
+ - `generateWAMessageContent`
503
+ - `generateWAMessageFromContent`
504
+
505
+ ### USync helpers
506
+
507
+ - `USyncQuery`
508
+ - `USyncUser`
509
+ - `USyncContactProtocol`
510
+ - `USyncLIDProtocol`
511
+ - `USyncDeviceProtocol`
512
+ - `USyncStatusProtocol`
513
+
514
+ ## Known limits
515
+
516
+ - this package is not a direct one-to-one mirror of every newest upstream internal API
517
+ - no restrictive `exports` map was added because that would risk breaking existing CommonJS consumers
518
+ - some upstream files remain intentionally absent because the local Neelegirl fork structure differs by design
519
+
520
+ ## Release notes
521
+
522
+ ### 2.1.6
523
+
524
+ - restored runtime consistency between socket logic and Signal repository behavior
525
+ - added local LID mapping store support
526
+ - improved history sync processing for LID and PN mapping capture
527
+ - added current JID helper compatibility exports
528
+ - refreshed typings and README without touching protected QR and `NEELE` logic
529
+
530
+ ### 2.1.5
531
+
532
+ - previous local package baseline before the current conservative maintenance pass
135
533
 
136
- ## Legal
534
+ ## Disclaimer
137
535
 
138
- This project is not affiliated with WhatsApp. Use responsibly and comply with platform terms and local laws.
536
+ This project is not affiliated with WhatsApp. Use it responsibly. Do not use it for spam, stalking, or abusive automation.
@@ -1,4 +1,9 @@
1
- import { SignalAuthState } from '../Types'
2
- import { SignalRepository } from '../Types/Signal'
1
+ import { LIDMapping, SignalAuthState } from '../Types'
2
+ import { SignalRepositoryWithLIDStore } from '../Types/Signal'
3
+ import type { ILogger } from '../Utils/logger'
3
4
 
4
- export declare function makeLibSignalRepository(auth: SignalAuthState): SignalRepository
5
+ export declare function makeLibSignalRepository(
6
+ auth: SignalAuthState,
7
+ logger: ILogger,
8
+ pnToLIDFunc?: (jids: string[]) => Promise<LIDMapping[] | undefined>
9
+ ): SignalRepositoryWithLIDStore