wa-multi-mongodb 3.10.3 → 3.10.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wa-multi-mongodb",
3
- "version": "3.10.3",
3
+ "version": "3.10.6",
4
4
  "description": "Multi Session Whatsapp Library with MongoDB Integration",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/index.js",
@@ -31,7 +31,7 @@
31
31
  "@types/node-cache": "^4.1.3",
32
32
  "@types/qrcode": "^1.5.5",
33
33
  "aws4": "^1.13.2",
34
- "baileys": "^7.0.0-rc.6",
34
+ "baileys": "^7.0.0-rc.9",
35
35
  "dotenv": "^16.5.0",
36
36
  "link-preview-js": "^3.0.14",
37
37
  "mime": "^3.0.0",
@@ -54,4 +54,4 @@
54
54
  "tslib": "^2.8.1",
55
55
  "typescript": "^5.7.2"
56
56
  }
57
- }
57
+ }
package/readme.md CHANGED
@@ -19,6 +19,8 @@ Built on [Baileys](https://github.com/WhiskeySockets/Baileys) Library.
19
19
  - Automatic group chat detection (v3.9.0+)
20
20
  - Hybrid caching system for group metadata (v3.9.4+)
21
21
  - Message deletion for self and others (v3.9.5+)
22
+ - Custom browser configuration (v3.10.4+)
23
+ - LID ↔ PN conversion utilities (v3.10.4+)
22
24
 
23
25
  ## Installation
24
26
 
@@ -113,9 +115,16 @@ await whatsapp.startSession("mysession2", {
113
115
  }
114
116
  });
115
117
 
118
+ // Start with custom browser configuration (v3.10.4+)
119
+ await whatsapp.startSession("mysession3", {
120
+ printQR: true,
121
+ browserType: "windows", // Options: "ubuntu" (default), "macOS", "windows", "appropriate"
122
+ browserName: "My Bot App", // Custom name shown in WhatsApp Linked Devices
123
+ onConnected: () => console.log("Connected with custom browser!"),
124
+ });
125
+
116
126
  // Start session with Pairing Code (v3.9.6+)
117
- await whatsapp.startSessionWithPairingCode("mysession3", {
118
- mobile: "6281234567890", // your phone number with country code
127
+ await whatsapp.startSessionWithPairingCode("mysession4", "6281234567890", {
119
128
  onConnected: () => console.log("Pairing session connected!"),
120
129
  onDisconnected: () => console.log("Pairing session disconnected!"),
121
130
  onPairingCode: (code) => {
@@ -124,6 +133,13 @@ await whatsapp.startSessionWithPairingCode("mysession3", {
124
133
  }
125
134
  });
126
135
 
136
+ // Pairing code with custom browser
137
+ await whatsapp.startSessionWithPairingCode("mysession5", "6281234567890", {
138
+ browserType: "macOS",
139
+ browserName: "My Custom Bot",
140
+ onPairingCode: (code) => console.log("Code:", code),
141
+ });
142
+
127
143
  // Get all active sessions
128
144
  const sessions = await whatsapp.getAllSession();
129
145
 
@@ -155,6 +171,44 @@ console.log("Pairing code sessions:", pairingSessions);
155
171
  await whatsapp.reconnectAllPairingCodeSessions();
156
172
  ```
157
173
 
174
+ ### Custom Browser Configuration (v3.10.4+)
175
+
176
+ You can customize the browser type and name that appears in WhatsApp's "Linked Devices" list:
177
+
178
+ ```javascript
179
+ // Available browser types
180
+ type BrowserType = "ubuntu" | "macOS" | "windows" | "appropriate";
181
+
182
+ // Usage examples
183
+ await whatsapp.startSession("session1", {
184
+ browserType: "ubuntu", // Default - Ubuntu browser agent
185
+ browserName: "Chrome", // Default - App name shown in Linked Devices
186
+ });
187
+
188
+ await whatsapp.startSession("session2", {
189
+ browserType: "windows", // Windows browser agent
190
+ browserName: "My Bot App", // Custom app name
191
+ });
192
+
193
+ await whatsapp.startSession("session3", {
194
+ browserType: "macOS", // macOS browser agent
195
+ browserName: "Desktop App",
196
+ });
197
+
198
+ await whatsapp.startSession("session4", {
199
+ browserType: "appropriate", // Auto-detect based on platform
200
+ browserName: "Auto Bot",
201
+ });
202
+ ```
203
+
204
+ | Browser Type | Description |
205
+ |--------------|-------------|
206
+ | `ubuntu` | Ubuntu browser agent (default) |
207
+ | `macOS` | macOS browser agent |
208
+ | `windows` | Windows browser agent |
209
+ | `appropriate` | Auto-detect based on current platform |
210
+
211
+
158
212
  ### Sending Messages
159
213
 
160
214
  ```javascript
@@ -424,8 +478,105 @@ try {
424
478
  }
425
479
  ```
426
480
 
481
+ ## LID ↔ PN Conversion Utilities (v3.10.4+)
482
+
483
+ WhatsApp has introduced LID (Linked ID) as a new anonymous identifier format to enhance user privacy. These utility functions help you convert between LID and Phone Number (PN) formats.
484
+
485
+ ### Understanding LID and PN
486
+
487
+ | Format | Description | Example |
488
+ |--------|-------------|---------|
489
+ | **LID** | Anonymous identifier (new format) | `1524746986546@lid` |
490
+ | **PN/JID** | Phone number based identifier (traditional) | `6281234567890@s.whatsapp.net` |
491
+
492
+ ### Converting LID to Phone Number
493
+
494
+ ```javascript
495
+ // Get phone number from LID
496
+ const result = await whatsapp.getPNForLID("mysession", "1524746986546@lid");
497
+ if (result.success && result.pn) {
498
+ console.log(`Phone number: ${result.pn}`);
499
+ } else {
500
+ console.log("Phone number not found:", result.error);
501
+ }
502
+
503
+ // Returns: { success: boolean, lid: string, pn: string | null, error?: string }
504
+ ```
505
+
506
+ ### Converting Phone Number to LID
507
+
508
+ ```javascript
509
+ // Get LID from phone number
510
+ const result = await whatsapp.getLIDForPN("mysession", "6281234567890");
511
+ if (result.success && result.lid) {
512
+ console.log(`LID: ${result.lid}`);
513
+ } else {
514
+ console.log("LID not found:", result.error);
515
+ }
516
+
517
+ // Returns: { success: boolean, pn: string, lid: string | null, error?: string }
518
+ ```
519
+
520
+ ### Smart Conversion (Auto-detect Format)
521
+
522
+ ```javascript
523
+ // Automatically convert any JID to phone number
524
+ const phoneNumber = await whatsapp.toPhoneNumber("mysession", anyJid);
525
+ if (phoneNumber) {
526
+ console.log(`Phone: ${phoneNumber}`);
527
+ }
528
+
529
+ // Automatically convert any JID to LID
530
+ const lid = await whatsapp.toLID("mysession", "6281234567890@s.whatsapp.net");
531
+ if (lid) {
532
+ console.log(`LID: ${lid}`);
533
+ }
534
+ ```
535
+
536
+ ### Get All Known LID Mappings
537
+
538
+ ```javascript
539
+ // Get all LID-PN mappings for a session
540
+ const mappings = await whatsapp.getAllLIDMappings("mysession");
541
+ for (const { lid, pn } of mappings) {
542
+ console.log(`${lid} => ${pn}`);
543
+ }
544
+ ```
545
+
546
+ ### Format Detection Helpers
547
+
548
+ ```javascript
549
+ // Check if JID is in LID format
550
+ if (whatsapp.isLIDFormat("1524746986546@lid")) {
551
+ console.log("This is an LID");
552
+ }
553
+
554
+ // Check if JID is in PN format
555
+ if (whatsapp.isPNFormat("6281234567890@s.whatsapp.net")) {
556
+ console.log("This is a phone number JID");
557
+ }
558
+ ```
559
+
560
+ ### Important Notes on LID Conversion
561
+
562
+ > ⚠️ **Limitations**:
563
+ > - `getPNForLID` may return `null` for new contacts or when WhatsApp hasn't provided the LID-PN mapping
564
+ > - LID mappings are only available for contacts that have already interacted with your session
565
+ > - WhatsApp is increasingly focusing on privacy, so not all LIDs have known phone numbers
566
+
567
+ | Function | Description |
568
+ |----------|-------------|
569
+ | `getPNForLID(sessionId, lid)` | Convert LID to phone number |
570
+ | `getLIDForPN(sessionId, pn)` | Convert phone number to LID |
571
+ | `toPhoneNumber(sessionId, jid)` | Smart convert any JID to PN |
572
+ | `toLID(sessionId, jid)` | Smart convert any JID to LID |
573
+ | `getAllLIDMappings(sessionId)` | Get all known LID-PN mappings |
574
+ | `isLIDFormat(jid)` | Check if JID is in LID format |
575
+ | `isPNFormat(jid)` | Check if JID is in PN format |
576
+
427
577
  ## Complete Example: Auto-Reconnect Application
428
578
 
579
+
429
580
  ```javascript
430
581
  import * as whatsapp from "wa-multi-mongodb";
431
582
  import { withTimeout } from "wa-multi-mongodb";
@@ -816,7 +967,23 @@ export default WhatsAppQRComponent;
816
967
 
817
968
  ## Changelog
818
969
 
819
- ### v3.10.2 (latest)
970
+ ### v3.10.4 (latest)
971
+ - **Custom Browser Configuration**: Added ability to customize browser type and name for WhatsApp connection
972
+ - New `browserType` option: Choose from "ubuntu" (default), "macOS", "windows", or "appropriate"
973
+ - New `browserName` option: Customize the app name displayed in WhatsApp's "Linked Devices" list
974
+ - Works with both `startSession()` and `startSessionWithPairingCode()` methods
975
+ - Default behavior unchanged (Ubuntu browser with "Chrome" name)
976
+ - **LID ↔ PN Conversion Utilities**: Added comprehensive utilities for converting between LID (Linked ID) and Phone Number formats
977
+ - New `getPNForLID(sessionId, lid)` function to convert LID to phone number
978
+ - New `getLIDForPN(sessionId, pn)` function to convert phone number to LID
979
+ - New `toPhoneNumber(sessionId, jid)` smart conversion function (auto-detects format)
980
+ - New `toLID(sessionId, jid)` smart conversion function (auto-detects format)
981
+ - New `getAllLIDMappings(sessionId)` function to get all known LID-PN mappings
982
+ - New `isLIDFormat(jid)` and `isPNFormat(jid)` helper functions
983
+ - Uses Baileys' internal `signalRepository.lidMapping` for conversions
984
+
985
+
986
+ ### v3.10.2
820
987
  - **Fixed Group JID Validation**: Resolved issue with group chat validation
821
988
  - Fixed `isValidJid()` function to properly validate group JIDs without requiring dash (-) character
822
989
  - Some WhatsApp group IDs don't use dash format, validation now accepts all valid group formats