@neelegirl/baileys 2.1.8 → 2.1.9

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
@@ -3,7 +3,7 @@
3
3
  # @neelegirl/baileys
4
4
 
5
5
  ### CommonJS WhatsApp Web runtime for Neelegirl projects
6
- ### Conservative merge strategy based on WhiskeySockets/Baileys
6
+ ### Conservative merge strategy based on WhiskeySockets/Baileys with QR, pairing, and LID/libsignal maintenance
7
7
 
8
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
9
  [![node](https://img.shields.io/badge/node-%3E%3D20-2ea043?style=for-the-badge&logo=node.js)](https://nodejs.org)
@@ -19,7 +19,7 @@
19
19
 
20
20
  | Package | Version | Main goal |
21
21
  |---|---:|---|
22
- | `@neelegirl/baileys` | `2.1.8` | Stable Neelegirl fork with preserved project-specific runtime behavior |
22
+ | `@neelegirl/baileys` | `2.1.9` | Stable Neelegirl fork with preserved project-specific runtime behavior |
23
23
 
24
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)
25
25
 
@@ -30,9 +30,10 @@
30
30
  ## Table of Contents
31
31
 
32
32
  - [Overview](#overview)
33
+ - [Stack relationship](#stack-relationship)
33
34
  - [Why this fork exists](#why-this-fork-exists)
34
35
  - [Protected logic](#protected-logic)
35
- - [What was updated in 2.1.8](#what-was-updated-in-218)
36
+ - [What was updated in 2.1.9](#what-was-updated-in-219)
36
37
  - [Installation](#installation)
37
38
  - [Imports](#imports)
38
39
  - [Quickstart](#quickstart)
@@ -50,13 +51,31 @@
50
51
 
51
52
  `@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.
52
53
 
53
- This package was rechecked against the public WhiskeySockets/Baileys repository on `2026-03-19`. The merge strategy is conservative by design:
54
+ This package was rechecked against the public WhiskeySockets/Baileys repository and the repaired local source package on `2026-03-20`. The merge strategy is conservative by design:
54
55
 
55
56
  - keep working Neelegirl runtime behavior
56
57
  - adopt compatible fixes
57
58
  - avoid blind upstream replacement
58
59
  - avoid destructive refactors in project-critical paths
59
60
 
61
+ ## Stack relationship
62
+
63
+ This fork sits in the middle of the local Neelegirl WhatsApp stack.
64
+
65
+ | Package | Role | Why it matters here |
66
+ |---|---|---|
67
+ | `@neelegirl/baileys` | WhatsApp Web runtime and socket layer | Owns QR, pairing, events, message send/recv, device handling |
68
+ | `@neelegirl/libsignal` | Signal session and identity runtime | Owns session cipher state, identity keys, and LID-aware session migration helpers |
69
+ | `@neelegirl/wa-api` | Convenience wrapper | Wraps the socket for multi-session management and simpler app integration |
70
+
71
+ The recent maintenance pass specifically verified that the Baileys socket layer and the local libsignal-facing repository agree again on:
72
+
73
+ - pairing-code platform handling for WhatsApp Web-style flows
74
+ - LID-to-PN mapping storage
75
+ - session migration helpers
76
+ - history-sync mapping capture
77
+ - conservative JID and device normalization
78
+
60
79
  ## Why this fork exists
61
80
 
62
81
  The local package differs from upstream for practical reasons:
@@ -77,16 +96,19 @@ The following logic was explicitly treated as protected during maintenance:
77
96
  - QR-code generation and QR lifecycle
78
97
  - `NEELE` message-ID generation and related custom handling
79
98
  - existing Neelegirl branding and log output
99
+ - existing WhatsApp Web / browser-specific pairing behavior
80
100
  - existing device, watch, and platform-specific behavior
81
101
  - existing custom community and message-stub handling
82
102
  - existing message-type behavior for conversation, extended text, media, and context handling
83
103
 
84
104
  Nothing in those areas was blindly replaced with upstream code.
85
105
 
86
- ## What was updated in 2.1.8
106
+ ## What was updated in 2.1.9
87
107
 
88
108
  ### Runtime hotfixes
89
109
 
110
+ - fixed hosted device `99` migration so PN sessions move into `@hosted.lid` instead of an invalid plain `@lid` target
111
+ - fixed hosted PN session lookup during PN to LID migration by resolving the actual Signal address key instead of assuming the plain PN key shape
90
112
  - fixed `lru-cache` compatibility so the local CommonJS build works with both direct-class and named-export variants
91
113
  - unblocked `LIDMappingStore` initialization during real bot startup
92
114
  - unblocked the migrated session cache and retry caches that rely on the same constructor shape
@@ -94,6 +116,7 @@ Nothing in those areas was blindly replaced with upstream code.
94
116
 
95
117
  ### Verified after the hotfix
96
118
 
119
+ - hosted device `99` mock migrations now land on `hosted.lid` Signal addresses and no longer get skipped
97
120
  - multi-session startup completed successfully in the local Neelegirl runtime
98
121
  - LID/device watch output continued to work after the patch
99
122
  - the package now starts without the `LRUCache is not a constructor` crash seen before this release
@@ -415,6 +438,8 @@ const result = transferDevice(
415
438
  )
416
439
  ```
417
440
 
441
+ When the source JID is a hosted device such as `491234567890:99@hosted`, the helper now keeps that hosted device space and returns `1234567890:99@hosted.lid`.
442
+
418
443
  ### Why this matters here
419
444
 
420
445
  Neelegirl-specific code in this package already relies on richer identity handling around:
@@ -1629,6 +1654,12 @@ This README is intentionally longer than a minimal package page because users of
1629
1654
 
1630
1655
  ## Release notes
1631
1656
 
1657
+ ### 2.1.9
1658
+
1659
+ - fixed hosted device `99` PN to LID migration so the runtime keeps `hosted` and `hosted.lid` identity space correctly
1660
+ - fixed Signal session lookup for hosted PN sessions during migration by using the real session-address encoding
1661
+ - README and package metadata refreshed to match the current stabilized runtime
1662
+
1632
1663
  ### 2.1.8
1633
1664
 
1634
1665
  - runtime hotfix release for CommonJS `lru-cache` compatibility in the current Neelegirl environment
@@ -175,27 +175,18 @@ function makeLibSignalRepository(auth, logger, pnToLIDFunc) {
175
175
  if (!userDevices.includes(fromDeviceStr)) {
176
176
  userDevices.push(fromDeviceStr)
177
177
  }
178
- const uncachedDevices = userDevices.filter(device => !migratedSessionCache.has(`${user}.${device}`))
179
- const deviceSessionKeys = uncachedDevices.map(device => `${user}.${device}`)
178
+ const uncachedDeviceJids = userDevices
179
+ .map(device => {
180
+ const deviceNum = parseInt(device, 10)
181
+ const normalizedDevice = Number.isNaN(deviceNum) ? 0 : deviceNum
182
+ return `${user}${normalizedDevice ? `:${normalizedDevice}` : ''}@${normalizedDevice === 99 ? 'hosted' : 's.whatsapp.net'}`
183
+ })
184
+ .filter(jid => !migratedSessionCache.has(jidToSignalProtocolAddress(jid).toString()))
185
+ const deviceSessionKeys = uncachedDeviceJids.map(jid => jidToSignalProtocolAddress(jid).toString())
180
186
  const existingSessions = deviceSessionKeys.length
181
187
  ? await parsedKeys.get('session', deviceSessionKeys)
182
188
  : {}
183
- const deviceJids = []
184
- for (const [sessionKey, sessionData] of Object.entries(existingSessions)) {
185
- if (!sessionData) {
186
- continue
187
- }
188
- const deviceStr = sessionKey.split('.')[1]
189
- if (!deviceStr) {
190
- continue
191
- }
192
- const deviceNum = parseInt(deviceStr, 10)
193
- let jid = `${user}${deviceNum ? `:${deviceNum}` : ''}@s.whatsapp.net`
194
- if (deviceNum === 99) {
195
- jid = `${user}:99@hosted`
196
- }
197
- deviceJids.push(jid)
198
- }
189
+ const deviceJids = uncachedDeviceJids.filter(jid => existingSessions[jidToSignalProtocolAddress(jid).toString()])
199
190
  return parsedKeys.transaction(async () => {
200
191
  const migrationOps = deviceJids.map(jid => {
201
192
  const lidWithDevice = (0, WABinary_1.transferDevice)(jid, toJid)
@@ -235,7 +226,7 @@ function makeLibSignalRepository(auth, logger, pnToLIDFunc) {
235
226
  await parsedKeys.set({ session: sessionUpdates })
236
227
  for (const op of migrationOps) {
237
228
  if (sessionUpdates[op.toAddr.toString()] && op.pnUser) {
238
- migratedSessionCache.set(`${op.pnUser}.${op.deviceId}`, true)
229
+ migratedSessionCache.set(op.fromAddr.toString(), true)
239
230
  }
240
231
  }
241
232
  }
@@ -113,10 +113,22 @@ const transferDevice = (fromJid, toJid) => {
113
113
  const fromDecoded = jidDecode(fromJid)
114
114
  const deviceId = fromDecoded?.device || 0
115
115
  const toDecoded = jidDecode(toJid)
116
- if (!toDecoded) {
116
+ if (!toDecoded?.user) {
117
117
  throw new Error(`invalid jid for device transfer: ${toJid}`)
118
118
  }
119
- return jidEncode(toDecoded.user, toDecoded.server, deviceId)
119
+ let server = toDecoded.server
120
+ const isHostedDevice = fromDecoded?.server === 'hosted'
121
+ || fromDecoded?.server === 'hosted.lid'
122
+ || deviceId === 99
123
+ if (isHostedDevice) {
124
+ if (server === 's.whatsapp.net') {
125
+ server = 'hosted'
126
+ }
127
+ else if (server === 'lid') {
128
+ server = 'hosted.lid'
129
+ }
130
+ }
131
+ return jidEncode(toDecoded.user, server, deviceId)
120
132
  }
121
133
 
122
134
  module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neelegirl/baileys",
3
- "version": "2.1.8",
3
+ "version": "2.1.9",
4
4
  "description": "CommonJS Neelegirl Baileys fork with preserved QR/NEELE logic and selective WhiskeySockets/Baileys compatibility updates",
5
5
  "keywords": [
6
6
  "whatsapp",
@@ -29,9 +29,9 @@
29
29
  "main": "lib/index.js",
30
30
  "types": "lib/index.d.ts",
31
31
  "files": [
32
- "lib/**/*",
33
- "WAProto/**/*",
34
- "engine-requirements.js"
32
+ "lib/*",
33
+ "WAProto/*",
34
+ "WASignalGroup/*.js"
35
35
  ],
36
36
  "scripts": {
37
37
  "build:all": "tsc && typedoc",
@@ -69,7 +69,7 @@
69
69
  "conventional-changelog-cli": "^2.2.2",
70
70
  "eslint": "^8.0.0",
71
71
  "jest": "^27.0.6",
72
- "jimp": "^0.16.13",
72
+ "jimp": "^0.16.13",
73
73
  "json": "^11.0.0",
74
74
  "link-preview-js": "^3.0.5",
75
75
  "open": "^8.4.2",
@@ -89,9 +89,6 @@
89
89
  "sharp": "^0.32.6"
90
90
  },
91
91
  "peerDependenciesMeta": {
92
- "audio-decode": {
93
- "optional": true
94
- },
95
92
  "jimp": {
96
93
  "optional": true
97
94
  },
@@ -1,10 +0,0 @@
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
- }