wa-multi-mongodb 3.10.2 → 3.10.4
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/dist/Defaults/index.js +4 -9
- package/dist/Error/index.js +1 -5
- package/dist/Messaging/index.d.ts +1 -1
- package/dist/Messaging/index.js +123 -137
- package/dist/Profile/index.d.ts +1 -1
- package/dist/Profile/index.js +6 -10
- package/dist/Socket/index.d.ts +160 -1
- package/dist/Socket/index.d.ts.map +1 -1
- package/dist/Socket/index.js +462 -200
- package/dist/Types/index.d.ts +21 -0
- package/dist/Types/index.d.ts.map +1 -1
- package/dist/Types/index.js +1 -2
- package/dist/Types/profile.js +1 -2
- package/dist/Utils/create-delay.js +2 -7
- package/dist/Utils/error.js +1 -4
- package/dist/Utils/group-cache.js +8 -15
- package/dist/Utils/index.d.ts +5 -5
- package/dist/Utils/index.js +5 -21
- package/dist/Utils/is-exist.d.ts +1 -1
- package/dist/Utils/is-exist.js +7 -10
- package/dist/Utils/lid-utils.js +13 -20
- package/dist/Utils/message-status.d.ts +1 -1
- package/dist/Utils/message-status.js +7 -11
- package/dist/Utils/mongo-auth-state.js +10 -13
- package/dist/Utils/phone-to-jid.js +6 -14
- package/dist/Utils/save-media.d.ts +1 -1
- package/dist/Utils/save-media.js +16 -26
- package/dist/cjs/Defaults/index.d.ts +21 -0
- package/dist/cjs/Defaults/index.d.ts.map +1 -0
- package/dist/cjs/Defaults/index.js +31 -0
- package/dist/cjs/Error/index.d.ts +5 -0
- package/dist/cjs/Error/index.d.ts.map +1 -0
- package/dist/cjs/Error/index.js +14 -0
- package/dist/cjs/Messaging/index.d.ts +45 -0
- package/dist/cjs/Messaging/index.d.ts.map +1 -0
- package/dist/cjs/Messaging/index.js +784 -0
- package/dist/cjs/Profile/index.d.ts +9 -0
- package/dist/cjs/Profile/index.d.ts.map +1 -0
- package/dist/cjs/Profile/index.js +34 -0
- package/dist/cjs/Socket/index.d.ts +264 -0
- package/dist/cjs/Socket/index.d.ts.map +1 -0
- package/dist/cjs/Socket/index.js +1210 -0
- package/dist/cjs/Types/index.d.ts +95 -0
- package/dist/cjs/Types/index.d.ts.map +1 -0
- package/dist/cjs/Types/index.js +2 -0
- package/dist/cjs/Types/profile.d.ts +5 -0
- package/dist/cjs/Types/profile.d.ts.map +1 -0
- package/dist/cjs/Types/profile.js +2 -0
- package/dist/cjs/Utils/create-delay.d.ts +17 -0
- package/dist/cjs/Utils/create-delay.d.ts.map +1 -0
- package/dist/cjs/Utils/create-delay.js +38 -0
- package/dist/cjs/Utils/error.d.ts +4 -0
- package/dist/cjs/Utils/error.d.ts.map +1 -0
- package/dist/cjs/Utils/error.js +8 -0
- package/dist/cjs/Utils/group-cache.d.ts +23 -0
- package/dist/cjs/Utils/group-cache.d.ts.map +1 -0
- package/dist/cjs/Utils/group-cache.js +176 -0
- package/dist/cjs/Utils/index.d.ts +6 -0
- package/dist/cjs/Utils/index.d.ts.map +1 -0
- package/dist/cjs/Utils/index.js +23 -0
- package/dist/cjs/Utils/is-exist.d.ts +6 -0
- package/dist/cjs/Utils/is-exist.d.ts.map +1 -0
- package/dist/cjs/Utils/is-exist.js +53 -0
- package/dist/cjs/Utils/lid-utils.d.ts +26 -0
- package/dist/cjs/Utils/lid-utils.d.ts.map +1 -0
- package/dist/cjs/Utils/lid-utils.js +81 -0
- package/dist/cjs/Utils/message-status.d.ts +4 -0
- package/dist/cjs/Utils/message-status.d.ts.map +1 -0
- package/dist/cjs/Utils/message-status.js +18 -0
- package/dist/cjs/Utils/mongo-auth-state.d.ts +15 -0
- package/dist/cjs/Utils/mongo-auth-state.d.ts.map +1 -0
- package/dist/cjs/Utils/mongo-auth-state.js +109 -0
- package/dist/cjs/Utils/phone-to-jid.d.ts +17 -0
- package/dist/cjs/Utils/phone-to-jid.d.ts.map +1 -0
- package/dist/cjs/Utils/phone-to-jid.js +51 -0
- package/dist/cjs/Utils/save-media.d.ts +6 -0
- package/dist/cjs/Utils/save-media.d.ts.map +1 -0
- package/dist/cjs/Utils/save-media.js +55 -0
- package/dist/cjs/index.d.ts +8 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +46 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +7 -46
- package/package.json +57 -42
- package/readme.md +170 -3
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("
|
|
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.
|
|
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
|