@neelegirl/baileys 2.1.6 → 2.1.8

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
@@ -19,7 +19,7 @@
19
19
 
20
20
  | Package | Version | Main goal |
21
21
  |---|---:|---|
22
- | `@neelegirl/baileys` | `2.1.6` | Stable Neelegirl fork with preserved project-specific runtime behavior |
22
+ | `@neelegirl/baileys` | `2.1.8` | 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
 
@@ -32,7 +32,7 @@
32
32
  - [Overview](#overview)
33
33
  - [Why this fork exists](#why-this-fork-exists)
34
34
  - [Protected logic](#protected-logic)
35
- - [What was updated in 2.1.6](#what-was-updated-in-216)
35
+ - [What was updated in 2.1.8](#what-was-updated-in-218)
36
36
  - [Installation](#installation)
37
37
  - [Imports](#imports)
38
38
  - [Quickstart](#quickstart)
@@ -83,6 +83,21 @@ The following logic was explicitly treated as protected during maintenance:
83
83
 
84
84
  Nothing in those areas was blindly replaced with upstream code.
85
85
 
86
+ ## What was updated in 2.1.8
87
+
88
+ ### Runtime hotfixes
89
+
90
+ - fixed `lru-cache` compatibility so the local CommonJS build works with both direct-class and named-export variants
91
+ - unblocked `LIDMappingStore` initialization during real bot startup
92
+ - unblocked the migrated session cache and retry caches that rely on the same constructor shape
93
+ - kept QR flow, `NEELE` message-ID logic, and project-specific device/watch handling untouched
94
+
95
+ ### Verified after the hotfix
96
+
97
+ - multi-session startup completed successfully in the local Neelegirl runtime
98
+ - LID/device watch output continued to work after the patch
99
+ - the package now starts without the `LRUCache is not a constructor` crash seen before this release
100
+
86
101
  ## What was updated in 2.1.6
87
102
 
88
103
  ### Runtime compatibility
@@ -517,7 +532,1114 @@ The following items were verified in the currently prepared package before publi
517
532
  - no restrictive `exports` map was added because that would risk breaking existing CommonJS consumers
518
533
  - some upstream files remain intentionally absent because the local Neelegirl fork structure differs by design
519
534
 
520
- ## Release notes
535
+ ## Deep-dive: message handling
536
+
537
+ This fork pays extra attention to message handling because several Neelegirl-specific customizations already depend on richer metadata than a plain "text or media" abstraction.
538
+
539
+ ### Why message handling is sensitive here
540
+
541
+ The package needs to preserve behavior around:
542
+
543
+ - `conversation`
544
+ - `extendedTextMessage`
545
+ - `imageMessage`
546
+ - `videoMessage`
547
+ - `documentMessage`
548
+ - `contextInfo`
549
+ - `participant`
550
+ - `participantAlt`
551
+ - `remoteJid`
552
+ - `remoteJidAlt`
553
+ - normalized sender values
554
+ - device and platform labels
555
+
556
+ That is why the maintenance pass intentionally avoided broad message-processing rewrites.
557
+
558
+ ### Reading text safely
559
+
560
+ For many bots, the most robust quick read path is still:
561
+
562
+ ```js
563
+ const text =
564
+ message?.message?.conversation ||
565
+ message?.message?.extendedTextMessage?.text ||
566
+ ''
567
+ ```
568
+
569
+ This stays valid because the fork intentionally keeps compatibility with the most common text cases.
570
+
571
+ ### Example: normalize the sender view
572
+
573
+ ```js
574
+ const {
575
+ jidDecode,
576
+ jidNormalizedUser,
577
+ isLidUser,
578
+ isPnUser
579
+ } = require('@neelegirl/baileys')
580
+
581
+ function inspectSender(msg) {
582
+ const raw =
583
+ msg?.key?.participant ||
584
+ msg?.participant ||
585
+ msg?.key?.remoteJid ||
586
+ ''
587
+
588
+ const normalized = jidNormalizedUser(raw)
589
+ const decoded = jidDecode(raw)
590
+
591
+ return {
592
+ raw,
593
+ normalized,
594
+ decoded,
595
+ isPn: isPnUser(raw),
596
+ isLid: isLidUser(raw)
597
+ }
598
+ }
599
+ ```
600
+
601
+ ### Example: handle text, media, and fallback cleanly
602
+
603
+ ```js
604
+ function getPrimaryContent(msg) {
605
+ const m = msg?.message || {}
606
+
607
+ if (m.conversation) {
608
+ return { type: 'conversation', text: m.conversation }
609
+ }
610
+
611
+ if (m.extendedTextMessage?.text) {
612
+ return { type: 'extendedTextMessage', text: m.extendedTextMessage.text }
613
+ }
614
+
615
+ if (m.imageMessage) {
616
+ return {
617
+ type: 'imageMessage',
618
+ caption: m.imageMessage.caption || ''
619
+ }
620
+ }
621
+
622
+ if (m.videoMessage) {
623
+ return {
624
+ type: 'videoMessage',
625
+ caption: m.videoMessage.caption || ''
626
+ }
627
+ }
628
+
629
+ if (m.documentMessage) {
630
+ return {
631
+ type: 'documentMessage',
632
+ fileName: m.documentMessage.fileName || ''
633
+ }
634
+ }
635
+
636
+ return { type: 'unknown' }
637
+ }
638
+ ```
639
+
640
+ ### Conversation vs extended text
641
+
642
+ The classic split is still important:
643
+
644
+ | Field | Typical use |
645
+ |---|---|
646
+ | `conversation` | direct simple text |
647
+ | `extendedTextMessage.text` | richer text message with more surrounding metadata |
648
+
649
+ Bots that only read one of the two will still miss messages in practice.
650
+
651
+ ### Media notes
652
+
653
+ Current helpers still support common media workflows:
654
+
655
+ - send image
656
+ - send video
657
+ - send audio
658
+ - send sticker
659
+ - send document
660
+ - download received media
661
+ - request media re-upload when needed
662
+
663
+ ### Downloading media carefully
664
+
665
+ ```js
666
+ const {
667
+ downloadMediaMessage,
668
+ getContentType
669
+ } = require('@neelegirl/baileys')
670
+
671
+ sock.ev.on('messages.upsert', async ({ messages }) => {
672
+ const msg = messages[0]
673
+ if (!msg?.message) {
674
+ return
675
+ }
676
+
677
+ const type = getContentType(msg.message)
678
+ if (type === 'imageMessage') {
679
+ const buffer = await downloadMediaMessage(
680
+ msg,
681
+ 'buffer',
682
+ {},
683
+ {
684
+ logger: sock.logger,
685
+ reuploadRequest: sock.updateMediaMessage
686
+ }
687
+ )
688
+
689
+ console.log('downloaded image bytes:', buffer.length)
690
+ }
691
+ })
692
+ ```
693
+
694
+ ### Polls, reactions, edits
695
+
696
+ The runtime still supports event flows around:
697
+
698
+ - reactions
699
+ - poll updates
700
+ - message edits
701
+
702
+ This is another reason the current `process-message` path was updated only where necessary.
703
+
704
+ ## Deep-dive: device and browser behavior
705
+
706
+ Device identity matters more than many wrappers admit. In this fork it is especially relevant because the project already uses browser and device strings in a more opinionated way.
707
+
708
+ ### Browser helper examples
709
+
710
+ ```js
711
+ const { Browsers } = require('@neelegirl/baileys')
712
+
713
+ const webProfile = Browsers.ubuntu('Neelegirl')
714
+ const desktopProfile = Browsers.macOS('Desktop')
715
+ const mobileStyleProfile = Browsers.iOS('Neelegirl iOS')
716
+ ```
717
+
718
+ ### `getPlatformId`
719
+
720
+ The compatibility export `getPlatformId` exists so consumers do not have to guess how platform names map into the pairing flow.
721
+
722
+ ```js
723
+ const { getPlatformId } = require('@neelegirl/baileys')
724
+
725
+ console.log(getPlatformId('Chrome'))
726
+ console.log(getPlatformId('Desktop'))
727
+ ```
728
+
729
+ ### Why not flatten device logic
730
+
731
+ During maintenance, device logic was not "simplified" because doing that would risk losing:
732
+
733
+ - Web labels
734
+ - Desktop labels
735
+ - iOS labels
736
+ - Android labels
737
+ - hosted PN and hosted LID distinctions
738
+
739
+ ### Device-aware identity helpers
740
+
741
+ ```js
742
+ const {
743
+ jidDecode,
744
+ transferDevice
745
+ } = require('@neelegirl/baileys')
746
+
747
+ const from = '491234567890:5@s.whatsapp.net'
748
+ const to = '1234567890@lid'
749
+
750
+ console.log(jidDecode(from))
751
+ console.log(transferDevice(from, to))
752
+ ```
753
+
754
+ ### Practical device matrix
755
+
756
+ | Concern | Why it matters |
757
+ |---|---|
758
+ | browser string | affects how the client is presented |
759
+ | platform id | used in pairing-related flows |
760
+ | desktop-like browser | can influence history sync behavior |
761
+ | hosted device space | matters for some LID and hosted identity transitions |
762
+
763
+ ## Deep-dive: JID and LID handling
764
+
765
+ One of the biggest reasons to maintain this fork carefully is identity handling.
766
+
767
+ ### Common identity spaces
768
+
769
+ | Space | Example |
770
+ |---|---|
771
+ | PN user | `491234567890@s.whatsapp.net` |
772
+ | LID user | `1234567890@lid` |
773
+ | hosted PN | `491234567890:99@hosted` |
774
+ | hosted LID | `1234567890:99@hosted.lid` |
775
+
776
+ ### Helpers exposed by the current package
777
+
778
+ - `jidDecode`
779
+ - `jidEncode`
780
+ - `jidNormalizedUser`
781
+ - `isPnUser`
782
+ - `isLidUser`
783
+ - `isHostedPnUser`
784
+ - `isHostedLidUser`
785
+ - `getServerFromDomainType`
786
+ - `transferDevice`
787
+ - `WAJIDDomains`
788
+
789
+ ### Example: decode and route by identity type
790
+
791
+ ```js
792
+ const {
793
+ jidDecode,
794
+ isPnUser,
795
+ isLidUser,
796
+ isHostedPnUser,
797
+ isHostedLidUser
798
+ } = require('@neelegirl/baileys')
799
+
800
+ function classify(jid) {
801
+ return {
802
+ jid,
803
+ decoded: jidDecode(jid),
804
+ pn: !!isPnUser(jid),
805
+ lid: !!isLidUser(jid),
806
+ hostedPn: !!isHostedPnUser(jid),
807
+ hostedLid: !!isHostedLidUser(jid)
808
+ }
809
+ }
810
+ ```
811
+
812
+ ### Example: server from domain type
813
+
814
+ ```js
815
+ const {
816
+ WAJIDDomains,
817
+ getServerFromDomainType
818
+ } = require('@neelegirl/baileys')
819
+
820
+ console.log(getServerFromDomainType('s.whatsapp.net', WAJIDDomains.WHATSAPP))
821
+ console.log(getServerFromDomainType('s.whatsapp.net', WAJIDDomains.LID))
822
+ console.log(getServerFromDomainType('s.whatsapp.net', WAJIDDomains.HOSTED))
823
+ console.log(getServerFromDomainType('s.whatsapp.net', WAJIDDomains.HOSTED_LID))
824
+ ```
825
+
826
+ ### Why this matters to bots
827
+
828
+ If your bot logs sender ids, checks participants, stores device metadata, or combines phone-number and LID records, identity mismatches will show up quickly unless the JID layer is handled carefully.
829
+
830
+ That is exactly why:
831
+
832
+ - the local `jid-utils` was extended
833
+ - history sync now collects LID-to-PN mapping data
834
+ - session migration helpers now exist in the signal repository
835
+
836
+ ## Deep-dive: history sync behavior
837
+
838
+ The current local package now handles history sync more consistently with the existing socket expectations.
839
+
840
+ ### What is processed
841
+
842
+ - conversations
843
+ - contacts
844
+ - messages
845
+ - `phoneNumberToLidMappings`
846
+ - inline bootstrap payloads when present
847
+
848
+ ### What gets emitted
849
+
850
+ The important event remains:
851
+
852
+ ```js
853
+ sock.ev.on('messaging-history.set', (data) => {
854
+ console.log(data)
855
+ })
856
+ ```
857
+
858
+ ### Example: inspect incoming history batches
859
+
860
+ ```js
861
+ sock.ev.on('messaging-history.set', ({ chats, contacts, messages, lidPnMappings, isLatest }) => {
862
+ console.log({
863
+ chats: chats.length,
864
+ contacts: contacts.length,
865
+ messages: messages.length,
866
+ lidPnMappings: lidPnMappings?.length || 0,
867
+ isLatest
868
+ })
869
+ })
870
+ ```
871
+
872
+ ### Why the mapping part matters
873
+
874
+ If you maintain your own sender normalization or account mapping layer, the `lidPnMappings` portion can help reconcile:
875
+
876
+ - phone-number identity space
877
+ - LID identity space
878
+ - device-level migration paths
879
+
880
+ ## Cookbook: common tasks
881
+
882
+ ### Send text
883
+
884
+ ```js
885
+ await sock.sendMessage(jid, { text: 'hello' })
886
+ ```
887
+
888
+ ### Send image with caption
889
+
890
+ ```js
891
+ await sock.sendMessage(jid, {
892
+ image: { url: './image.jpg' },
893
+ caption: 'caption'
894
+ })
895
+ ```
896
+
897
+ ### Send video
898
+
899
+ ```js
900
+ await sock.sendMessage(jid, {
901
+ video: { url: './video.mp4' },
902
+ caption: 'video'
903
+ })
904
+ ```
905
+
906
+ ### Send document
907
+
908
+ ```js
909
+ await sock.sendMessage(jid, {
910
+ document: { url: './report.pdf' },
911
+ mimetype: 'application/pdf',
912
+ fileName: 'report.pdf'
913
+ })
914
+ ```
915
+
916
+ ### Send sticker
917
+
918
+ ```js
919
+ await sock.sendMessage(jid, {
920
+ sticker: { url: './sticker.webp' }
921
+ })
922
+ ```
923
+
924
+ ### Send location
925
+
926
+ ```js
927
+ await sock.sendMessage(jid, {
928
+ location: {
929
+ degreesLatitude: 52.52,
930
+ degreesLongitude: 13.405
931
+ }
932
+ })
933
+ ```
934
+
935
+ ### Send contact
936
+
937
+ ```js
938
+ const vcard = [
939
+ 'BEGIN:VCARD',
940
+ 'VERSION:3.0',
941
+ 'FN:Example Contact',
942
+ 'TEL;type=CELL;type=VOICE;waid=491234567890:+49 123 4567890',
943
+ 'END:VCARD'
944
+ ].join('\n')
945
+
946
+ await sock.sendMessage(jid, {
947
+ contacts: {
948
+ displayName: 'Example Contact',
949
+ contacts: [{ vcard }]
950
+ }
951
+ })
952
+ ```
953
+
954
+ ### Send reaction
955
+
956
+ ```js
957
+ await sock.sendMessage(jid, {
958
+ react: {
959
+ text: '❤',
960
+ key: message.key
961
+ }
962
+ })
963
+ ```
964
+
965
+ ### Remove reaction
966
+
967
+ ```js
968
+ await sock.sendMessage(jid, {
969
+ react: {
970
+ text: '',
971
+ key: message.key
972
+ }
973
+ })
974
+ ```
975
+
976
+ ### Edit a message
977
+
978
+ ```js
979
+ const sent = await sock.sendMessage(jid, { text: 'draft' })
980
+
981
+ await sock.sendMessage(jid, {
982
+ text: 'final text',
983
+ edit: sent.key
984
+ })
985
+ ```
986
+
987
+ ### Delete for everyone
988
+
989
+ ```js
990
+ await sock.sendMessage(jid, {
991
+ delete: message.key
992
+ })
993
+ ```
994
+
995
+ ### Mention a user
996
+
997
+ ```js
998
+ await sock.sendMessage(jid, {
999
+ text: '@491234567890 hello',
1000
+ mentions: ['491234567890@s.whatsapp.net']
1001
+ })
1002
+ ```
1003
+
1004
+ ### Forward a message
1005
+
1006
+ ```js
1007
+ await sock.sendMessage(jid, {
1008
+ forward: originalMessage
1009
+ })
1010
+ ```
1011
+
1012
+ ### Send poll
1013
+
1014
+ ```js
1015
+ await sock.sendMessage(jid, {
1016
+ poll: {
1017
+ name: 'Choose one',
1018
+ values: ['A', 'B', 'C'],
1019
+ selectableCount: 1
1020
+ }
1021
+ })
1022
+ ```
1023
+
1024
+ ## Group and community notes
1025
+
1026
+ The current fork still exposes the usual group-oriented socket methods, and the event layer keeps its extended handling for participant and community metadata.
1027
+
1028
+ ### Example: create a group
1029
+
1030
+ ```js
1031
+ const group = await sock.groupCreate('Example Group', [
1032
+ '491111111111@s.whatsapp.net',
1033
+ '492222222222@s.whatsapp.net'
1034
+ ])
1035
+
1036
+ console.log(group.id)
1037
+ ```
1038
+
1039
+ ### Example: add participants
1040
+
1041
+ ```js
1042
+ await sock.groupParticipantsUpdate(
1043
+ group.id,
1044
+ ['493333333333@s.whatsapp.net'],
1045
+ 'add'
1046
+ )
1047
+ ```
1048
+
1049
+ ### Example: change subject
1050
+
1051
+ ```js
1052
+ await sock.groupUpdateSubject(group.id, 'New Subject')
1053
+ ```
1054
+
1055
+ ### Example: change description
1056
+
1057
+ ```js
1058
+ await sock.groupUpdateDescription(group.id, 'New Description')
1059
+ ```
1060
+
1061
+ ### Example: fetch metadata
1062
+
1063
+ ```js
1064
+ const metadata = await sock.groupMetadata(group.id)
1065
+ console.log(metadata.subject)
1066
+ ```
1067
+
1068
+ ### Event surfaces that matter here
1069
+
1070
+ - `groups.update`
1071
+ - `group-participants.update`
1072
+ - `group.join-request`
1073
+ - `group.member-tag.update`
1074
+ - `communities.update`
1075
+
1076
+ ### Why the fork keeps custom group handling
1077
+
1078
+ The local project already has richer handling around:
1079
+
1080
+ - group author info
1081
+ - participant alternatives
1082
+ - community-specific stubs
1083
+ - label changes
1084
+
1085
+ That is why those paths were preserved instead of normalized down to a simpler generic structure.
1086
+
1087
+ ## Event reference
1088
+
1089
+ The package uses the event-emitter style surface exposed through `sock.ev`.
1090
+
1091
+ ### High-value events
1092
+
1093
+ | Event | Typical use |
1094
+ |---|---|
1095
+ | `connection.update` | login, reconnect, QR lifecycle |
1096
+ | `creds.update` | persist auth state |
1097
+ | `messages.upsert` | incoming messages |
1098
+ | `messages.update` | edits, receipts, state changes |
1099
+ | `messages.reaction` | reaction handling |
1100
+ | `messaging-history.set` | first sync and history batches |
1101
+ | `contacts.update` | contact refresh |
1102
+ | `chats.update` | chat state changes |
1103
+ | `groups.update` | group metadata changes |
1104
+ | `group-participants.update` | participant changes |
1105
+
1106
+ ### Example: connection update
1107
+
1108
+ ```js
1109
+ sock.ev.on('connection.update', (update) => {
1110
+ const { connection, qr, isNewLogin, lastDisconnect } = update
1111
+
1112
+ if (qr) {
1113
+ console.log('qr available')
1114
+ }
1115
+
1116
+ if (isNewLogin) {
1117
+ console.log('new login established')
1118
+ }
1119
+
1120
+ if (connection === 'close') {
1121
+ console.log(lastDisconnect?.error)
1122
+ }
1123
+ })
1124
+ ```
1125
+
1126
+ ### Example: messages upsert
1127
+
1128
+ ```js
1129
+ sock.ev.on('messages.upsert', ({ messages, type }) => {
1130
+ console.log(type, messages.length)
1131
+ })
1132
+ ```
1133
+
1134
+ ### Example: group participants update
1135
+
1136
+ ```js
1137
+ sock.ev.on('group-participants.update', (event) => {
1138
+ console.log({
1139
+ id: event.id,
1140
+ author: event.author,
1141
+ action: event.action,
1142
+ participants: event.participants
1143
+ })
1144
+ })
1145
+ ```
1146
+
1147
+ ### Example: group join requests
1148
+
1149
+ ```js
1150
+ sock.ev.on('group.join-request', (event) => {
1151
+ console.log(event)
1152
+ })
1153
+ ```
1154
+
1155
+ ### Example: reactions
1156
+
1157
+ ```js
1158
+ sock.ev.on('messages.reaction', (items) => {
1159
+ for (const item of items) {
1160
+ console.log(item.reaction)
1161
+ }
1162
+ })
1163
+ ```
1164
+
1165
+ ## Logging notes
1166
+
1167
+ The package continues to work with a `pino`-style logger object. In practice:
1168
+
1169
+ - quiet logs are appropriate for production wrappers
1170
+ - `debug` is helpful when exploring socket flow
1171
+ - `trace` is useful when inspecting binary-node behavior and protocol details
1172
+
1173
+ ### Example
1174
+
1175
+ ```js
1176
+ const pino = require('pino')
1177
+
1178
+ const sock = makeWASocket({
1179
+ version,
1180
+ auth: state,
1181
+ logger: pino({ level: 'info' }),
1182
+ browser: Browsers.ubuntu('Neelegirl'),
1183
+ printQRInTerminal: true
1184
+ })
1185
+ ```
1186
+
1187
+ ### Why logs were preserved
1188
+
1189
+ Neelegirl-specific logging output and watch behavior were explicitly treated as protected. The goal was not to "prettify" logs at the cost of losing operational context.
1190
+
1191
+ ## Update notice
1192
+
1193
+ This package already contains a runtime npm-version check in the current Neelegirl fork.
1194
+
1195
+ ### What it really does
1196
+
1197
+ - it checks the npm registry
1198
+ - it does not self-update
1199
+ - it prints a hint only
1200
+ - it is intentionally lightweight
1201
+
1202
+ ### When it appears
1203
+
1204
+ In the current local fork, the update notice is tied to the existing connection and QR-related flow, and it is designed to run once per process.
1205
+
1206
+ ### Realistic expectation
1207
+
1208
+ If a newer version exists, you still update manually:
1209
+
1210
+ ```bash
1211
+ npm install @neelegirl/baileys@latest
1212
+ ```
1213
+
1214
+ This is the realistic behavior. The package does not automatically replace files in your project.
1215
+
1216
+ ## Troubleshooting
1217
+
1218
+ ### QR is not appearing
1219
+
1220
+ Check:
1221
+
1222
+ - `printQRInTerminal: true`
1223
+ - your auth folder is not already fully logged in
1224
+ - the socket is actually being started
1225
+ - your terminal is not swallowing QR output
1226
+
1227
+ ### Pairing code does not return
1228
+
1229
+ Check:
1230
+
1231
+ - `printQRInTerminal` is disabled for pairing flow
1232
+ - the phone number is passed without `+`
1233
+ - the session is not already registered
1234
+
1235
+ ### Messages are not sending after reconnect
1236
+
1237
+ Check:
1238
+
1239
+ - auth state persistence
1240
+ - key-store persistence
1241
+ - `creds.update` listener
1242
+ - whether your custom store is actually writing signal keys back
1243
+
1244
+ ### Sender ids look inconsistent
1245
+
1246
+ Check whether you are mixing:
1247
+
1248
+ - PN ids
1249
+ - LID ids
1250
+ - hosted PN ids
1251
+ - hosted LID ids
1252
+
1253
+ Normalize before storing or comparing.
1254
+
1255
+ ### History sync looks incomplete
1256
+
1257
+ Check:
1258
+
1259
+ - `syncFullHistory`
1260
+ - browser profile choice
1261
+ - first-login behavior versus reconnect behavior
1262
+ - whether you are handling `messaging-history.set`
1263
+
1264
+ ## FAQ
1265
+
1266
+ ### Is this the official Baileys package?
1267
+
1268
+ No. It is a Neelegirl-maintained fork.
1269
+
1270
+ ### Is it based on public WhiskeySockets/Baileys?
1271
+
1272
+ Yes, but selectively and conservatively.
1273
+
1274
+ ### Does it preserve the custom QR flow?
1275
+
1276
+ Yes.
1277
+
1278
+ ### Does it preserve `NEELE` message IDs?
1279
+
1280
+ Yes.
1281
+
1282
+ ### Does it mirror every upstream internal file?
1283
+
1284
+ No.
1285
+
1286
+ ### Does it include a CLI?
1287
+
1288
+ No.
1289
+
1290
+ ### Does it auto-update itself?
1291
+
1292
+ No. It can show an update hint, but updating remains manual.
1293
+
1294
+ ### Should I use this instead of upstream for Neelegirl projects?
1295
+
1296
+ If your project depends on the current Neelegirl-specific runtime behavior, yes.
1297
+
1298
+ ### Can I still access lower-level helpers?
1299
+
1300
+ Yes. The package exports a broad set of utilities and socket-related helpers.
1301
+
1302
+ ### Why not just overwrite everything with upstream?
1303
+
1304
+ Because that would risk breaking project-specific runtime behavior that already exists locally.
1305
+
1306
+ ### Why are LID helpers emphasized so much?
1307
+
1308
+ Because identity handling is one of the areas most likely to cause subtle regressions in message processing, logging, and sender tracking.
1309
+
1310
+ ## Configuration patterns
1311
+
1312
+ This section is intentionally verbose because configuration details are where many WhatsApp Web client issues begin.
1313
+
1314
+ ### Minimal practical config
1315
+
1316
+ ```js
1317
+ const sock = makeWASocket({
1318
+ version,
1319
+ auth: state,
1320
+ browser: Browsers.ubuntu('Neelegirl'),
1321
+ printQRInTerminal: true
1322
+ })
1323
+ ```
1324
+
1325
+ ### Quiet production-oriented config
1326
+
1327
+ ```js
1328
+ const pino = require('pino')
1329
+
1330
+ const sock = makeWASocket({
1331
+ version,
1332
+ auth: state,
1333
+ browser: Browsers.windows('Neelegirl Bot'),
1334
+ printQRInTerminal: false,
1335
+ logger: pino({ level: 'silent' }),
1336
+ markOnlineOnConnect: false,
1337
+ syncFullHistory: false
1338
+ })
1339
+ ```
1340
+
1341
+ ### Store-aware config
1342
+
1343
+ ```js
1344
+ const sock = makeWASocket({
1345
+ version,
1346
+ auth: state,
1347
+ browser: Browsers.macOS('Desktop'),
1348
+ printQRInTerminal: true,
1349
+ getMessage: async (key) => {
1350
+ return store.loadMessage(key.remoteJid, key.id)
1351
+ },
1352
+ cachedGroupMetadata: async (jid) => {
1353
+ return groupCache.get(jid)
1354
+ }
1355
+ })
1356
+ ```
1357
+
1358
+ ### Config checklist
1359
+
1360
+ | Question | Why to check it |
1361
+ |---|---|
1362
+ | did you pass `auth` | required for login state |
1363
+ | did you persist `creds.update` | prevents key drift |
1364
+ | did you choose an appropriate `browser` | affects presentation and sometimes sync behavior |
1365
+ | did you define `getMessage` if needed | helps retry and recovery flows |
1366
+ | did you define `cachedGroupMetadata` if group-heavy | reduces repeated metadata fetches |
1367
+
1368
+ ## Auth and persistence patterns
1369
+
1370
+ ### Multi-file auth state
1371
+
1372
+ This is usually the easiest place to start:
1373
+
1374
+ ```js
1375
+ const { state, saveCreds } = await useMultiFileAuthState('./auth_info')
1376
+
1377
+ const sock = makeWASocket({
1378
+ version,
1379
+ auth: state,
1380
+ browser: Browsers.ubuntu('Neelegirl'),
1381
+ printQRInTerminal: true
1382
+ })
1383
+
1384
+ sock.ev.on('creds.update', saveCreds)
1385
+ ```
1386
+
1387
+ ### Single-file auth state
1388
+
1389
+ ```js
1390
+ const { state, saveCreds } = await useSingleFileAuthState('./auth.json')
1391
+
1392
+ const sock = makeWASocket({
1393
+ version,
1394
+ auth: state,
1395
+ browser: Browsers.ubuntu('Neelegirl'),
1396
+ printQRInTerminal: true
1397
+ })
1398
+
1399
+ sock.ev.on('creds.update', saveCreds)
1400
+ ```
1401
+
1402
+ ### Mongo-style helper
1403
+
1404
+ If your project uses the local helper for mongo-backed auth state:
1405
+
1406
+ ```js
1407
+ const { state, saveCreds } = await useMongoFileAuthState(mongoCollection)
1408
+ ```
1409
+
1410
+ ### Custom persistence rules
1411
+
1412
+ If you write your own auth store:
1413
+
1414
+ - persist credentials
1415
+ - persist signal keys
1416
+ - persist updates promptly
1417
+ - do not drop `creds.update`
1418
+ - do not ignore key mutations
1419
+
1420
+ ## Store usage
1421
+
1422
+ The package still exports `makeInMemoryStore` for simple local state handling.
1423
+
1424
+ ### Example
1425
+
1426
+ ```js
1427
+ const pino = require('pino')
1428
+ const { makeInMemoryStore } = require('@neelegirl/baileys')
1429
+
1430
+ const store = makeInMemoryStore({
1431
+ logger: pino({ level: 'silent' })
1432
+ })
1433
+
1434
+ store.bind(sock.ev)
1435
+ ```
1436
+
1437
+ ### Typical uses
1438
+
1439
+ - quick development persistence
1440
+ - message lookup for retry helpers
1441
+ - chat cache
1442
+ - contact cache
1443
+
1444
+ ### Caveat
1445
+
1446
+ For serious production systems, build a proper persistent store instead of keeping too much history only in memory.
1447
+
1448
+ ## More cookbook examples
1449
+
1450
+ ### Mark messages as read
1451
+
1452
+ ```js
1453
+ await sock.readMessages([message.key])
1454
+ ```
1455
+
1456
+ ### Update presence
1457
+
1458
+ ```js
1459
+ await sock.sendPresenceUpdate('available', jid)
1460
+ await sock.sendPresenceUpdate('unavailable', jid)
1461
+ ```
1462
+
1463
+ ### Subscribe to another user's presence
1464
+
1465
+ ```js
1466
+ await sock.presenceSubscribe(jid)
1467
+ ```
1468
+
1469
+ ### Fetch profile picture
1470
+
1471
+ ```js
1472
+ const url = await sock.profilePictureUrl(jid, 'image')
1473
+ console.log(url)
1474
+ ```
1475
+
1476
+ ### Fetch status
1477
+
1478
+ ```js
1479
+ const status = await sock.fetchStatus(jid)
1480
+ console.log(status)
1481
+ ```
1482
+
1483
+ ### Check if a number is on WhatsApp
1484
+
1485
+ ```js
1486
+ const [result] = await sock.onWhatsApp('491234567890@s.whatsapp.net')
1487
+ console.log(result)
1488
+ ```
1489
+
1490
+ ### Run a USync query
1491
+
1492
+ ```js
1493
+ const {
1494
+ USyncQuery,
1495
+ USyncUser
1496
+ } = require('@neelegirl/baileys')
1497
+
1498
+ const query = new USyncQuery()
1499
+ .withContactProtocol()
1500
+ .withUser(new USyncUser().withPhone('+491234567890'))
1501
+
1502
+ const result = await sock.executeUSyncQuery(query)
1503
+ console.log(result)
1504
+ ```
1505
+
1506
+ ### Fetch group invite code
1507
+
1508
+ ```js
1509
+ const code = await sock.groupInviteCode(groupId)
1510
+ console.log(code)
1511
+ ```
1512
+
1513
+ ### Accept invite
1514
+
1515
+ ```js
1516
+ const joined = await sock.groupAcceptInvite(code)
1517
+ console.log(joined)
1518
+ ```
1519
+
1520
+ ### Update profile status
1521
+
1522
+ ```js
1523
+ await sock.updateProfileStatus('hello from neelegirl')
1524
+ ```
1525
+
1526
+ ### Update profile name
1527
+
1528
+ ```js
1529
+ await sock.updateProfileName('Neelegirl Bot')
1530
+ ```
1531
+
1532
+ ## Architecture notes
1533
+
1534
+ This local package can be thought of in layers:
1535
+
1536
+ | Layer | Responsibility |
1537
+ |---|---|
1538
+ | socket layer | connection, noise, login, QR, pairing |
1539
+ | utils layer | message building, media handling, parsing, helpers |
1540
+ | binary layer | JID parsing and node encoding/decoding |
1541
+ | signal layer | session crypto, sender keys, LID mapping |
1542
+ | store layer | optional in-memory cache and helpers |
1543
+
1544
+ ### Why the signal layer mattered in this maintenance pass
1545
+
1546
+ The socket already expected LID-aware signal helpers, but the older local `libsignal.js` did not fully provide them. That mismatch was one of the most important actual runtime corrections in the recent update.
1547
+
1548
+ ## Automatic update note
1549
+
1550
+ This package can show an update hint, but it does not auto-patch your installation.
1551
+
1552
+ ### Realistic behavior summary
1553
+
1554
+ | Behavior | Status |
1555
+ |---|---|
1556
+ | check registry | yes |
1557
+ | run once per process | yes |
1558
+ | self-update code | no |
1559
+ | replace files automatically | no |
1560
+ | tell you what to run | yes |
1561
+
1562
+ ### Manual update commands
1563
+
1564
+ ```bash
1565
+ npm install @neelegirl/baileys@latest
1566
+ ```
1567
+
1568
+ ```bash
1569
+ yarn add @neelegirl/baileys@latest
1570
+ ```
1571
+
1572
+ ### Why not self-update
1573
+
1574
+ Auto-replacing package files inside an active bot environment would be risky and surprising. A hint is realistic. Silent mutation of dependencies is not.
1575
+
1576
+ ## Glossary
1577
+
1578
+ ### PN
1579
+
1580
+ Phone-number identity space, typically `@s.whatsapp.net`.
1581
+
1582
+ ### LID
1583
+
1584
+ Linked identity space, typically `@lid`.
1585
+
1586
+ ### hosted PN
1587
+
1588
+ Hosted phone-number identity space, often seen with device-specific hosted forms.
1589
+
1590
+ ### hosted LID
1591
+
1592
+ Hosted LID identity space, often seen when identity and hosted-device concerns intersect.
1593
+
1594
+ ### `participantAlt`
1595
+
1596
+ Project-specific alternate participant metadata preserved in the local fork.
1597
+
1598
+ ### `remoteJidAlt`
1599
+
1600
+ Project-specific alternate remote jid metadata preserved in the local fork.
1601
+
1602
+ ### `senderNormalized`
1603
+
1604
+ A generic phrase used in many bot projects to refer to the stable sender representation after identity reconciliation.
1605
+
1606
+ ## Project policy
1607
+
1608
+ This fork intentionally prioritizes:
1609
+
1610
+ - stable behavior for existing Neelegirl consumers
1611
+ - conservative compatibility updates
1612
+ - readable maintenance over flashy churn
1613
+ - truthful documentation over exaggerated claims
1614
+
1615
+ It intentionally avoids:
1616
+
1617
+ - blind upstream overwrite
1618
+ - destructive export-map tightening
1619
+ - rewriting protected project logic just to look more "modern"
1620
+
1621
+ ## Documentation philosophy
1622
+
1623
+ This README is intentionally longer than a minimal package page because users of this fork usually need:
1624
+
1625
+ - a clear explanation of why the fork exists
1626
+ - reassurance about what custom logic is protected
1627
+ - a practical guide for auth, QR, pairing, and message handling
1628
+ - a realistic statement of what is and is not updated automatically
1629
+
1630
+ ## Release notes
1631
+
1632
+ ### 2.1.8
1633
+
1634
+ - runtime hotfix release for CommonJS `lru-cache` compatibility in the current Neelegirl environment
1635
+ - fixed constructor resolution used by LID mapping and retry cache initialization
1636
+ - dependency range aligned to `@neelegirl/libsignal@^1.0.12`
1637
+
1638
+ ### 2.1.7
1639
+
1640
+ - documentation expansion release
1641
+ - Baileys README now includes deep operational guidance and realistic update behavior notes
1642
+ - dependency range aligned to `@neelegirl/libsignal@^1.0.11`
521
1643
 
522
1644
  ### 2.1.6
523
1645
 
@@ -4,7 +4,8 @@ Object.defineProperty(exports, "__esModule", { value: true })
4
4
 
5
5
  const libsignal = require("@neelegirl/libsignal")
6
6
  const { PreKeyWhisperMessage } = require("@neelegirl/libsignal/src/protobufs")
7
- const { LRUCache } = require("lru-cache")
7
+ const LRUCacheModule = require("lru-cache")
8
+ const LRUCache = LRUCacheModule.LRUCache || LRUCacheModule
8
9
  const WASignalGroup_1 = require("./WASignalGroup")
9
10
  const lid_mapping_1 = require("./lid-mapping")
10
11
  const Utils_1 = require("../Utils")
@@ -2,7 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", { value: true })
4
4
 
5
- const { LRUCache } = require("lru-cache")
5
+ const LRUCacheModule = require("lru-cache")
6
+ const LRUCache = LRUCacheModule.LRUCache || LRUCacheModule
6
7
  const WABinary_1 = require("../WABinary")
7
8
 
8
9
  class LIDMappingStore {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MessageRetryManager = void 0;
4
4
  const lru_cache_1 = require("lru-cache");
5
+ const LRUCache = lru_cache_1.LRUCache || lru_cache_1;
5
6
  /** Number of sent messages to cache in memory for handling retry receipts */
6
7
  const RECENT_MESSAGES_SIZE = 512;
7
8
  const MESSAGE_KEY_SEPARATOR = '\u0000';
@@ -11,7 +12,7 @@ const PHONE_REQUEST_DELAY = 3000;
11
12
  class MessageRetryManager {
12
13
  constructor(logger, maxMsgRetryCount) {
13
14
  this.logger = logger;
14
- this.recentMessagesMap = new lru_cache_1.LRUCache({
15
+ this.recentMessagesMap = new LRUCache({
15
16
  max: RECENT_MESSAGES_SIZE,
16
17
  ttl: 5 * 60 * 1000,
17
18
  ttlAutopurge: true,
@@ -24,11 +25,11 @@ class MessageRetryManager {
24
25
  }
25
26
  });
26
27
  this.messageKeyIndex = new Map();
27
- this.sessionRecreateHistory = new lru_cache_1.LRUCache({
28
+ this.sessionRecreateHistory = new LRUCache({
28
29
  ttl: RECREATE_SESSION_TIMEOUT * 2,
29
30
  ttlAutopurge: true
30
31
  });
31
- this.retryCounters = new lru_cache_1.LRUCache({
32
+ this.retryCounters = new LRUCache({
32
33
  ttl: 15 * 60 * 1000,
33
34
  ttlAutopurge: true,
34
35
  updateAgeOnGet: true
@@ -176,4 +177,3 @@ exports.MessageRetryManager = MessageRetryManager;
176
177
  //# sourceMappingURL=message-retry-manager.js.map
177
178
 
178
179
 
179
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neelegirl/baileys",
3
- "version": "2.1.6",
3
+ "version": "2.1.8",
4
4
  "description": "CommonJS Neelegirl Baileys fork with preserved QR/NEELE logic and selective WhiskeySockets/Baileys compatibility updates",
5
5
  "keywords": [
6
6
  "whatsapp",
@@ -44,7 +44,7 @@
44
44
  "@adiwajshing/keyed-db": "^0.2.4",
45
45
  "@cacheable/node-cache": "^1.5.4",
46
46
  "@hapi/boom": "^9.1.3",
47
- "@neelegirl/libsignal": "^1.0.9",
47
+ "@neelegirl/libsignal": "^1.0.12",
48
48
  "async-mutex": "^0.5.0",
49
49
  "audio-decode": "^2.1.3",
50
50
  "axios": "^1.3.3",