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/dist/Socket/index.d.ts +159 -0
- package/dist/Socket/index.d.ts.map +1 -1
- package/dist/Socket/index.js +362 -9
- package/dist/Types/index.d.ts +26 -0
- package/dist/Types/index.d.ts.map +1 -1
- package/dist/cjs/Socket/index.d.ts +159 -0
- package/dist/cjs/Socket/index.d.ts.map +1 -1
- package/dist/cjs/Socket/index.js +369 -9
- package/dist/cjs/Types/index.d.ts +26 -0
- package/dist/cjs/Types/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/readme.md +170 -3
|
@@ -102,4 +102,163 @@ export declare const getGroupMetadata: (sessionId: string, jid: string, forceFet
|
|
|
102
102
|
export declare const clearGroupMetadataCache: (sessionId: string, jid: string) => Promise<void>;
|
|
103
103
|
export declare const clearSessionGroupMetadataCache: (sessionId: string) => Promise<void>;
|
|
104
104
|
export declare const clearAllGroupMetadataCache: () => void;
|
|
105
|
+
/**
|
|
106
|
+
* Result type for LID to PN conversion
|
|
107
|
+
*/
|
|
108
|
+
export interface LIDConversionResult {
|
|
109
|
+
success: boolean;
|
|
110
|
+
lid: string;
|
|
111
|
+
pn: string | null;
|
|
112
|
+
error?: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Result type for PN to LID conversion
|
|
116
|
+
*/
|
|
117
|
+
export interface PNConversionResult {
|
|
118
|
+
success: boolean;
|
|
119
|
+
pn: string;
|
|
120
|
+
lid: string | null;
|
|
121
|
+
error?: string;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* LID Mapping entry type
|
|
125
|
+
*/
|
|
126
|
+
export interface LIDMappingEntry {
|
|
127
|
+
lid: string;
|
|
128
|
+
pn: string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Convert LID (Linked ID) to Phone Number (PN/JID)
|
|
132
|
+
*
|
|
133
|
+
* This function uses Baileys' internal signalRepository.lidMapping to retrieve
|
|
134
|
+
* the phone number associated with a given LID.
|
|
135
|
+
*
|
|
136
|
+
* @param sessionId - Session ID to use for conversion
|
|
137
|
+
* @param lid - The LID to convert (e.g., "1524746986546@lid")
|
|
138
|
+
* @returns Promise<LIDConversionResult> - Result object with the phone number or null if not found
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* const result = await whatsapp.getPNForLID("mysession", "1524746986546@lid");
|
|
143
|
+
* if (result.success && result.pn) {
|
|
144
|
+
* console.log(`Phone number: ${result.pn}`);
|
|
145
|
+
* } else {
|
|
146
|
+
* console.log("Phone number not found for this LID");
|
|
147
|
+
* }
|
|
148
|
+
* ```
|
|
149
|
+
*
|
|
150
|
+
* @note This function may return null for new contacts or when WhatsApp
|
|
151
|
+
* hasn't provided the LID-PN mapping yet. Not all LIDs have known phone numbers.
|
|
152
|
+
*/
|
|
153
|
+
export declare const getPNForLID: (sessionId: string, lid: string) => Promise<LIDConversionResult>;
|
|
154
|
+
/**
|
|
155
|
+
* Convert Phone Number (PN/JID) to LID (Linked ID)
|
|
156
|
+
*
|
|
157
|
+
* This function uses Baileys' internal signalRepository.lidMapping to retrieve
|
|
158
|
+
* the LID associated with a given phone number.
|
|
159
|
+
*
|
|
160
|
+
* @param sessionId - Session ID to use for conversion
|
|
161
|
+
* @param pn - The phone number/JID to convert (e.g., "6281234567890" or "6281234567890@s.whatsapp.net")
|
|
162
|
+
* @returns Promise<PNConversionResult> - Result object with the LID or null if not found
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* const result = await whatsapp.getLIDForPN("mysession", "6281234567890");
|
|
167
|
+
* if (result.success && result.lid) {
|
|
168
|
+
* console.log(`LID: ${result.lid}`);
|
|
169
|
+
* } else {
|
|
170
|
+
* console.log("LID not found for this phone number");
|
|
171
|
+
* }
|
|
172
|
+
* ```
|
|
173
|
+
*
|
|
174
|
+
* @note This function may return null for contacts that haven't been encountered
|
|
175
|
+
* with their LID mapping yet.
|
|
176
|
+
*/
|
|
177
|
+
export declare const getLIDForPN: (sessionId: string, pn: string) => Promise<PNConversionResult>;
|
|
178
|
+
/**
|
|
179
|
+
* Get all known LID-PN mappings for a session
|
|
180
|
+
*
|
|
181
|
+
* This function retrieves all LID to phone number mappings that are currently
|
|
182
|
+
* stored in the session's signal repository.
|
|
183
|
+
*
|
|
184
|
+
* @param sessionId - Session ID to get mappings from
|
|
185
|
+
* @returns Promise<LIDMappingEntry[]> - Array of LID-PN mapping entries
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* const mappings = await whatsapp.getAllLIDMappings("mysession");
|
|
190
|
+
* for (const mapping of mappings) {
|
|
191
|
+
* console.log(`${mapping.lid} => ${mapping.pn}`);
|
|
192
|
+
* }
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
195
|
+
* @note This may return an empty array if no mappings are available yet.
|
|
196
|
+
*/
|
|
197
|
+
export declare const getAllLIDMappings: (sessionId: string) => Promise<LIDMappingEntry[]>;
|
|
198
|
+
/**
|
|
199
|
+
* Check if a JID is in LID format
|
|
200
|
+
*
|
|
201
|
+
* @param jid - The JID to check
|
|
202
|
+
* @returns boolean - True if the JID is in LID format
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* if (whatsapp.isLIDFormat("1524746986546@lid")) {
|
|
207
|
+
* console.log("This is an LID");
|
|
208
|
+
* }
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
export declare const isLIDFormat: (jid: string) => boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Check if a JID is in Phone Number format (@s.whatsapp.net)
|
|
214
|
+
*
|
|
215
|
+
* @param jid - The JID to check
|
|
216
|
+
* @returns boolean - True if the JID is in PN format
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```typescript
|
|
220
|
+
* if (whatsapp.isPNFormat("6281234567890@s.whatsapp.net")) {
|
|
221
|
+
* console.log("This is a phone number JID");
|
|
222
|
+
* }
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
export declare const isPNFormat: (jid: string) => boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Smart convert any JID to phone number
|
|
228
|
+
*
|
|
229
|
+
* Automatically detects if the input is an LID and converts it to PN,
|
|
230
|
+
* or returns the PN if already in PN format.
|
|
231
|
+
*
|
|
232
|
+
* @param sessionId - Session ID to use for conversion
|
|
233
|
+
* @param jid - Any JID (LID or PN format)
|
|
234
|
+
* @returns Promise<string | null> - Phone number or null if conversion failed
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```typescript
|
|
238
|
+
* const pn = await whatsapp.toPhoneNumber("mysession", jid);
|
|
239
|
+
* if (pn) {
|
|
240
|
+
* console.log(`Phone number: ${pn}`);
|
|
241
|
+
* }
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
export declare const toPhoneNumber: (sessionId: string, jid: string) => Promise<string | null>;
|
|
245
|
+
/**
|
|
246
|
+
* Smart convert any JID to LID
|
|
247
|
+
*
|
|
248
|
+
* Automatically detects if the input is a PN and converts it to LID,
|
|
249
|
+
* or returns the LID if already in LID format.
|
|
250
|
+
*
|
|
251
|
+
* @param sessionId - Session ID to use for conversion
|
|
252
|
+
* @param jid - Any JID (LID or PN format)
|
|
253
|
+
* @returns Promise<string | null> - LID or null if conversion failed
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```typescript
|
|
257
|
+
* const lid = await whatsapp.toLID("mysession", "6281234567890@s.whatsapp.net");
|
|
258
|
+
* if (lid) {
|
|
259
|
+
* console.log(`LID: ${lid}`);
|
|
260
|
+
* }
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
export declare const toLID: (sessionId: string, jid: string) => Promise<string | null>;
|
|
105
264
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Socket/index.ts"],"names":[],"mappings":"AAAA,OAAqB,EAInB,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Socket/index.ts"],"names":[],"mappings":"AAAA,OAAqB,EAInB,QAAQ,EAET,MAAM,SAAS,CAAC;AAMjB,OAAO,KAAK,EAEV,eAAe,EACf,cAAc,EACd,kBAAkB,EAEnB,MAAM,UAAU,CAAC;AAiElB;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAU,KAAK,MAAM,kBAkB5C,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,GAAG,QAEjD;AAkBD,eAAO,MAAM,YAAY,GACvB,kBAAuB,EACvB,UAAS,kBAAsC,KAC9C,OAAO,CAAC,QAAQ,CA+JlB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,GACtC,WAAW,MAAM,EACjB,aAAa,MAAM,EACnB,UAAS,kBAAuB,KAC/B,OAAO,CAAC,QAAQ,CAiNlB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,iCArYf,kBAAkB,KAC1B,OAAO,CAAC,QAAQ,CAoYsB,CAAC;AA4C1C,eAAO,MAAM,aAAa,GAAU,WAAW,MAAM,kBAmCpD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,QAAa,OAAO,CAAC,MAAM,EAAE,CAsBtD,CAAC;AAGF,eAAO,MAAM,iBAAiB,QAAO,MAAM,EAAiC,CAAC;AAE7E,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,QAAQ,GAAG,SACrB,CAAC;AAoChC;;GAEG;AACH,eAAO,MAAM,uBAAuB,YAMnC,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,UAAU,CAAC,GAAG,EAAE,eAAe,KAAK,GAAG,SAExE,CAAC;AACF,eAAO,MAAM,WAAW,GACtB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F;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,KAAG,OAEzC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,OAExC,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,aAAa,GAAU,WAAW,MAAM,EAAE,KAAK,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAoCzF,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,KAAK,GAAU,WAAW,MAAM,EAAE,KAAK,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAkBjF,CAAC"}
|
package/dist/cjs/Socket/index.js
CHANGED
|
@@ -45,7 +45,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
45
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.clearAllGroupMetadataCache = exports.clearSessionGroupMetadataCache = exports.clearGroupMetadataCache = exports.getGroupMetadata = exports.setGroupCacheConfig = exports.getSessionStatus = exports.getPairingCodeSessions = exports.reconnectAllPairingCodeSessions = exports.reconnect = exports.setCredentialsDir = exports.setMongoDBNames = exports.loadSessionsFromMongo = exports.onPairingCode = exports.onMessageUpdate = exports.onConnecting = exports.onDisconnected = exports.onConnected = exports.onQRUpdated = exports.onMessageReceived = exports.loadSessionsFromStorage = exports.getSession = exports.getAllSessionSync = exports.getAllSession = exports.deleteSession = exports.startWhatsapp = exports.startSessionWithPairingCode = exports.startSession = exports.setMongoURI = void 0;
|
|
48
|
+
exports.toLID = exports.toPhoneNumber = exports.isPNFormat = exports.isLIDFormat = exports.getAllLIDMappings = exports.getLIDForPN = exports.getPNForLID = exports.clearAllGroupMetadataCache = exports.clearSessionGroupMetadataCache = exports.clearGroupMetadataCache = exports.getGroupMetadata = exports.setGroupCacheConfig = exports.getSessionStatus = exports.getPairingCodeSessions = exports.reconnectAllPairingCodeSessions = exports.reconnect = exports.setCredentialsDir = exports.setMongoDBNames = exports.loadSessionsFromMongo = exports.onPairingCode = exports.onMessageUpdate = exports.onConnecting = exports.onDisconnected = exports.onConnected = exports.onQRUpdated = exports.onMessageReceived = exports.loadSessionsFromStorage = exports.getSession = exports.getAllSessionSync = exports.getAllSession = exports.deleteSession = exports.startWhatsapp = exports.startSessionWithPairingCode = exports.startSession = exports.setMongoURI = void 0;
|
|
49
49
|
exports.setMongoCollection = setMongoCollection;
|
|
50
50
|
const baileys_1 = __importStar(require("baileys"));
|
|
51
51
|
const path_1 = __importDefault(require("path"));
|
|
@@ -61,6 +61,32 @@ const mongodb_1 = require("mongodb");
|
|
|
61
61
|
const mongo_auth_state_1 = require("../Utils/mongo-auth-state");
|
|
62
62
|
const create_delay_1 = require("../Utils/create-delay");
|
|
63
63
|
const sessions = new Map();
|
|
64
|
+
/**
|
|
65
|
+
* Helper function to generate browser configuration based on type and name
|
|
66
|
+
* @param browserType - Browser type (ubuntu, macOS, windows, appropriate)
|
|
67
|
+
* @param browserName - Custom browser/app name
|
|
68
|
+
* @returns Browser configuration tuple for Baileys
|
|
69
|
+
*/
|
|
70
|
+
const getBrowserConfig = (browserType = "ubuntu", browserName = "Chrome") => {
|
|
71
|
+
let browserTuple;
|
|
72
|
+
switch (browserType) {
|
|
73
|
+
case "macOS":
|
|
74
|
+
browserTuple = baileys_1.Browsers.macOS(browserName);
|
|
75
|
+
break;
|
|
76
|
+
case "windows":
|
|
77
|
+
browserTuple = baileys_1.Browsers.windows(browserName);
|
|
78
|
+
break;
|
|
79
|
+
case "appropriate":
|
|
80
|
+
browserTuple = baileys_1.Browsers.appropriate(browserName);
|
|
81
|
+
break;
|
|
82
|
+
case "ubuntu":
|
|
83
|
+
default:
|
|
84
|
+
browserTuple = baileys_1.Browsers.ubuntu(browserName);
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
// Convert readonly tuple to mutable tuple for Baileys compatibility
|
|
88
|
+
return [...browserTuple];
|
|
89
|
+
};
|
|
64
90
|
const callback = new Map();
|
|
65
91
|
const retryCount = new Map();
|
|
66
92
|
// Tambahkan Map untuk melacak session yang menggunakan pairing code
|
|
@@ -126,7 +152,7 @@ const startSession = (...args_1) => __awaiter(void 0, [...args_1], void 0, funct
|
|
|
126
152
|
auth: state,
|
|
127
153
|
logger: P,
|
|
128
154
|
markOnlineOnConnect: false,
|
|
129
|
-
browser:
|
|
155
|
+
browser: getBrowserConfig(options.browserType, options.browserName),
|
|
130
156
|
// Configure caching group metadata using our hybrid implementation with session ID
|
|
131
157
|
cachedGroupMetadata: (jid) => __awaiter(void 0, void 0, void 0, function* () {
|
|
132
158
|
return yield Utils_1.groupCache.get(sessionId, jid);
|
|
@@ -135,7 +161,7 @@ const startSession = (...args_1) => __awaiter(void 0, [...args_1], void 0, funct
|
|
|
135
161
|
sessions.set(sessionId, Object.assign({}, sock));
|
|
136
162
|
try {
|
|
137
163
|
sock.ev.process((events) => __awaiter(void 0, void 0, void 0, function* () {
|
|
138
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
164
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
139
165
|
if (events["connection.update"]) {
|
|
140
166
|
const update = events["connection.update"];
|
|
141
167
|
const { connection, lastDisconnect } = update;
|
|
@@ -243,12 +269,19 @@ const startSession = (...args_1) => __awaiter(void 0, [...args_1], void 0, funct
|
|
|
243
269
|
}
|
|
244
270
|
const msg = rawMsg;
|
|
245
271
|
msg.sessionId = sessionId;
|
|
272
|
+
// Get normalized sender phone number using toPhoneNumber
|
|
273
|
+
// For group messages, sender is in 'participant', for personal chats it's in 'remoteJid'
|
|
274
|
+
const isGroup = ((_r = (_q = msg.key) === null || _q === void 0 ? void 0 : _q.remoteJid) === null || _r === void 0 ? void 0 : _r.endsWith('@g.us')) || false;
|
|
275
|
+
const senderJid = isGroup
|
|
276
|
+
? (((_s = msg.key) === null || _s === void 0 ? void 0 : _s.participant) || '')
|
|
277
|
+
: (((_t = msg.key) === null || _t === void 0 ? void 0 : _t.remoteJid) || '');
|
|
278
|
+
msg.sender = yield (0, exports.toPhoneNumber)(sessionId, senderJid);
|
|
246
279
|
msg.saveImage = (path) => (0, save_media_1.saveImageHandler)(msg, path);
|
|
247
280
|
msg.saveVideo = (path) => (0, save_media_1.saveVideoHandler)(msg, path);
|
|
248
281
|
msg.saveDocument = (path) => (0, save_media_1.saveDocumentHandler)(msg, path);
|
|
249
282
|
msg.saveAudio = (path) => (0, save_media_1.saveAudioHandler)(msg, path);
|
|
250
|
-
(
|
|
251
|
-
(
|
|
283
|
+
(_u = callback.get(Defaults_1.CALLBACK_KEY.ON_MESSAGE_RECEIVED)) === null || _u === void 0 ? void 0 : _u(Object.assign({}, msg));
|
|
284
|
+
(_v = options.onMessageReceived) === null || _v === void 0 ? void 0 : _v.call(options, msg);
|
|
252
285
|
}
|
|
253
286
|
}
|
|
254
287
|
}));
|
|
@@ -286,7 +319,7 @@ const startSessionWithPairingCode = (sessionId_1, phoneNumber_1, ...args_1) => _
|
|
|
286
319
|
auth: state,
|
|
287
320
|
logger: P,
|
|
288
321
|
markOnlineOnConnect: false,
|
|
289
|
-
browser:
|
|
322
|
+
browser: getBrowserConfig(options.browserType, options.browserName),
|
|
290
323
|
// Opsi tambahan untuk meningkatkan kompatibilitas
|
|
291
324
|
linkPreviewImageThumbnailWidth: 300,
|
|
292
325
|
generateHighQualityLinkPreview: true,
|
|
@@ -326,7 +359,7 @@ const startSessionWithPairingCode = (sessionId_1, phoneNumber_1, ...args_1) => _
|
|
|
326
359
|
}
|
|
327
360
|
}
|
|
328
361
|
sock.ev.process((events) => __awaiter(void 0, void 0, void 0, function* () {
|
|
329
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
362
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
330
363
|
if (events["connection.update"]) {
|
|
331
364
|
const update = events["connection.update"];
|
|
332
365
|
const { connection, lastDisconnect } = update;
|
|
@@ -446,12 +479,19 @@ const startSessionWithPairingCode = (sessionId_1, phoneNumber_1, ...args_1) => _
|
|
|
446
479
|
}
|
|
447
480
|
const msg = rawMsg;
|
|
448
481
|
msg.sessionId = sessionId;
|
|
482
|
+
// Get normalized sender phone number using toPhoneNumber
|
|
483
|
+
// For group messages, sender is in 'participant', for personal chats it's in 'remoteJid'
|
|
484
|
+
const isGroup = ((_q = (_p = msg.key) === null || _p === void 0 ? void 0 : _p.remoteJid) === null || _q === void 0 ? void 0 : _q.endsWith('@g.us')) || false;
|
|
485
|
+
const senderJid = isGroup
|
|
486
|
+
? (((_r = msg.key) === null || _r === void 0 ? void 0 : _r.participant) || '')
|
|
487
|
+
: (((_s = msg.key) === null || _s === void 0 ? void 0 : _s.remoteJid) || '');
|
|
488
|
+
msg.sender = yield (0, exports.toPhoneNumber)(sessionId, senderJid);
|
|
449
489
|
msg.saveImage = (path) => (0, save_media_1.saveImageHandler)(msg, path);
|
|
450
490
|
msg.saveVideo = (path) => (0, save_media_1.saveVideoHandler)(msg, path);
|
|
451
491
|
msg.saveDocument = (path) => (0, save_media_1.saveDocumentHandler)(msg, path);
|
|
452
492
|
msg.saveAudio = (path) => (0, save_media_1.saveAudioHandler)(msg, path);
|
|
453
|
-
(
|
|
454
|
-
(
|
|
493
|
+
(_t = callback.get(Defaults_1.CALLBACK_KEY.ON_MESSAGE_RECEIVED)) === null || _t === void 0 ? void 0 : _t(Object.assign({}, msg));
|
|
494
|
+
(_u = options.onMessageReceived) === null || _u === void 0 ? void 0 : _u.call(options, msg);
|
|
455
495
|
}
|
|
456
496
|
}
|
|
457
497
|
}));
|
|
@@ -873,3 +913,323 @@ const clearAllGroupMetadataCache = () => {
|
|
|
873
913
|
Utils_1.groupCache.flush();
|
|
874
914
|
};
|
|
875
915
|
exports.clearAllGroupMetadataCache = clearAllGroupMetadataCache;
|
|
916
|
+
/**
|
|
917
|
+
* Convert LID (Linked ID) to Phone Number (PN/JID)
|
|
918
|
+
*
|
|
919
|
+
* This function uses Baileys' internal signalRepository.lidMapping to retrieve
|
|
920
|
+
* the phone number associated with a given LID.
|
|
921
|
+
*
|
|
922
|
+
* @param sessionId - Session ID to use for conversion
|
|
923
|
+
* @param lid - The LID to convert (e.g., "1524746986546@lid")
|
|
924
|
+
* @returns Promise<LIDConversionResult> - Result object with the phone number or null if not found
|
|
925
|
+
*
|
|
926
|
+
* @example
|
|
927
|
+
* ```typescript
|
|
928
|
+
* const result = await whatsapp.getPNForLID("mysession", "1524746986546@lid");
|
|
929
|
+
* if (result.success && result.pn) {
|
|
930
|
+
* console.log(`Phone number: ${result.pn}`);
|
|
931
|
+
* } else {
|
|
932
|
+
* console.log("Phone number not found for this LID");
|
|
933
|
+
* }
|
|
934
|
+
* ```
|
|
935
|
+
*
|
|
936
|
+
* @note This function may return null for new contacts or when WhatsApp
|
|
937
|
+
* hasn't provided the LID-PN mapping yet. Not all LIDs have known phone numbers.
|
|
938
|
+
*/
|
|
939
|
+
const getPNForLID = (sessionId, lid) => __awaiter(void 0, void 0, void 0, function* () {
|
|
940
|
+
var _a, _b;
|
|
941
|
+
const session = (0, exports.getSession)(sessionId);
|
|
942
|
+
if (!session) {
|
|
943
|
+
return {
|
|
944
|
+
success: false,
|
|
945
|
+
lid,
|
|
946
|
+
pn: null,
|
|
947
|
+
error: Defaults_1.Messages.sessionNotFound(sessionId)
|
|
948
|
+
};
|
|
949
|
+
}
|
|
950
|
+
try {
|
|
951
|
+
// Normalize LID format
|
|
952
|
+
let normalizedLid = lid;
|
|
953
|
+
if (!lid.includes('@lid')) {
|
|
954
|
+
normalizedLid = `${lid}@lid`;
|
|
955
|
+
}
|
|
956
|
+
// Access the signalRepository.lidMapping to get PN for LID
|
|
957
|
+
const signalRepo = session.signalRepository;
|
|
958
|
+
if (!signalRepo || !signalRepo.lidMapping) {
|
|
959
|
+
return {
|
|
960
|
+
success: false,
|
|
961
|
+
lid: normalizedLid,
|
|
962
|
+
pn: null,
|
|
963
|
+
error: "LID mapping not available in this session"
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
// Try to get the phone number for the LID (getPNForLID is async!)
|
|
967
|
+
const pn = (yield ((_b = (_a = signalRepo.lidMapping).getPNForLID) === null || _b === void 0 ? void 0 : _b.call(_a, normalizedLid))) || null;
|
|
968
|
+
return {
|
|
969
|
+
success: pn !== null,
|
|
970
|
+
lid: normalizedLid,
|
|
971
|
+
pn
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
catch (error) {
|
|
975
|
+
return {
|
|
976
|
+
success: false,
|
|
977
|
+
lid,
|
|
978
|
+
pn: null,
|
|
979
|
+
error: `Failed to convert LID to PN: ${error.message || String(error)}`
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
});
|
|
983
|
+
exports.getPNForLID = getPNForLID;
|
|
984
|
+
/**
|
|
985
|
+
* Convert Phone Number (PN/JID) to LID (Linked ID)
|
|
986
|
+
*
|
|
987
|
+
* This function uses Baileys' internal signalRepository.lidMapping to retrieve
|
|
988
|
+
* the LID associated with a given phone number.
|
|
989
|
+
*
|
|
990
|
+
* @param sessionId - Session ID to use for conversion
|
|
991
|
+
* @param pn - The phone number/JID to convert (e.g., "6281234567890" or "6281234567890@s.whatsapp.net")
|
|
992
|
+
* @returns Promise<PNConversionResult> - Result object with the LID or null if not found
|
|
993
|
+
*
|
|
994
|
+
* @example
|
|
995
|
+
* ```typescript
|
|
996
|
+
* const result = await whatsapp.getLIDForPN("mysession", "6281234567890");
|
|
997
|
+
* if (result.success && result.lid) {
|
|
998
|
+
* console.log(`LID: ${result.lid}`);
|
|
999
|
+
* } else {
|
|
1000
|
+
* console.log("LID not found for this phone number");
|
|
1001
|
+
* }
|
|
1002
|
+
* ```
|
|
1003
|
+
*
|
|
1004
|
+
* @note This function may return null for contacts that haven't been encountered
|
|
1005
|
+
* with their LID mapping yet.
|
|
1006
|
+
*/
|
|
1007
|
+
const getLIDForPN = (sessionId, pn) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1008
|
+
var _a, _b;
|
|
1009
|
+
const session = (0, exports.getSession)(sessionId);
|
|
1010
|
+
if (!session) {
|
|
1011
|
+
return {
|
|
1012
|
+
success: false,
|
|
1013
|
+
pn,
|
|
1014
|
+
lid: null,
|
|
1015
|
+
error: Defaults_1.Messages.sessionNotFound(sessionId)
|
|
1016
|
+
};
|
|
1017
|
+
}
|
|
1018
|
+
try {
|
|
1019
|
+
// Normalize PN format
|
|
1020
|
+
let normalizedPn = pn.replace(/\D/g, ''); // Remove non-digits
|
|
1021
|
+
if (!pn.includes('@s.whatsapp.net')) {
|
|
1022
|
+
normalizedPn = `${normalizedPn}@s.whatsapp.net`;
|
|
1023
|
+
}
|
|
1024
|
+
else {
|
|
1025
|
+
normalizedPn = pn;
|
|
1026
|
+
}
|
|
1027
|
+
// Access the signalRepository.lidMapping to get LID for PN
|
|
1028
|
+
const signalRepo = session.signalRepository;
|
|
1029
|
+
if (!signalRepo || !signalRepo.lidMapping) {
|
|
1030
|
+
return {
|
|
1031
|
+
success: false,
|
|
1032
|
+
pn: normalizedPn,
|
|
1033
|
+
lid: null,
|
|
1034
|
+
error: "LID mapping not available in this session"
|
|
1035
|
+
};
|
|
1036
|
+
}
|
|
1037
|
+
// Try to get the LID for the phone number
|
|
1038
|
+
const lid = ((_b = (_a = signalRepo.lidMapping).getLIDForPN) === null || _b === void 0 ? void 0 : _b.call(_a, normalizedPn)) || null;
|
|
1039
|
+
return {
|
|
1040
|
+
success: lid !== null,
|
|
1041
|
+
pn: normalizedPn,
|
|
1042
|
+
lid
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
catch (error) {
|
|
1046
|
+
return {
|
|
1047
|
+
success: false,
|
|
1048
|
+
pn,
|
|
1049
|
+
lid: null,
|
|
1050
|
+
error: `Failed to convert PN to LID: ${error.message || String(error)}`
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
});
|
|
1054
|
+
exports.getLIDForPN = getLIDForPN;
|
|
1055
|
+
/**
|
|
1056
|
+
* Get all known LID-PN mappings for a session
|
|
1057
|
+
*
|
|
1058
|
+
* This function retrieves all LID to phone number mappings that are currently
|
|
1059
|
+
* stored in the session's signal repository.
|
|
1060
|
+
*
|
|
1061
|
+
* @param sessionId - Session ID to get mappings from
|
|
1062
|
+
* @returns Promise<LIDMappingEntry[]> - Array of LID-PN mapping entries
|
|
1063
|
+
*
|
|
1064
|
+
* @example
|
|
1065
|
+
* ```typescript
|
|
1066
|
+
* const mappings = await whatsapp.getAllLIDMappings("mysession");
|
|
1067
|
+
* for (const mapping of mappings) {
|
|
1068
|
+
* console.log(`${mapping.lid} => ${mapping.pn}`);
|
|
1069
|
+
* }
|
|
1070
|
+
* ```
|
|
1071
|
+
*
|
|
1072
|
+
* @note This may return an empty array if no mappings are available yet.
|
|
1073
|
+
*/
|
|
1074
|
+
const getAllLIDMappings = (sessionId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1075
|
+
const session = (0, exports.getSession)(sessionId);
|
|
1076
|
+
if (!session) {
|
|
1077
|
+
throw new Error_1.WhatsappError(Defaults_1.Messages.sessionNotFound(sessionId));
|
|
1078
|
+
}
|
|
1079
|
+
try {
|
|
1080
|
+
const signalRepo = session.signalRepository;
|
|
1081
|
+
if (!signalRepo || !signalRepo.lidMapping) {
|
|
1082
|
+
return [];
|
|
1083
|
+
}
|
|
1084
|
+
// Try to get all mappings if available
|
|
1085
|
+
const getAllMappings = signalRepo.lidMapping.getAll || signalRepo.lidMapping.getAllMappings;
|
|
1086
|
+
if (typeof getAllMappings === 'function') {
|
|
1087
|
+
const mappings = getAllMappings();
|
|
1088
|
+
if (Array.isArray(mappings)) {
|
|
1089
|
+
return mappings;
|
|
1090
|
+
}
|
|
1091
|
+
// If it's a Map or Object, convert to array
|
|
1092
|
+
if (mappings instanceof Map) {
|
|
1093
|
+
return Array.from(mappings.entries()).map(([lid, pn]) => ({ lid, pn: pn }));
|
|
1094
|
+
}
|
|
1095
|
+
if (typeof mappings === 'object') {
|
|
1096
|
+
return Object.entries(mappings).map(([lid, pn]) => ({ lid, pn: pn }));
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
// Alternative: Try to access internal store directly
|
|
1100
|
+
const store = signalRepo.lidMapping.store || signalRepo.lidMapping._store;
|
|
1101
|
+
if (store) {
|
|
1102
|
+
if (store instanceof Map) {
|
|
1103
|
+
return Array.from(store.entries()).map(([lid, pn]) => ({ lid, pn: pn }));
|
|
1104
|
+
}
|
|
1105
|
+
if (typeof store === 'object') {
|
|
1106
|
+
return Object.entries(store).map(([lid, pn]) => ({ lid, pn: pn }));
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
return [];
|
|
1110
|
+
}
|
|
1111
|
+
catch (error) {
|
|
1112
|
+
throw new Error_1.WhatsappError(`Failed to get LID mappings: ${error.message || String(error)}`);
|
|
1113
|
+
}
|
|
1114
|
+
});
|
|
1115
|
+
exports.getAllLIDMappings = getAllLIDMappings;
|
|
1116
|
+
/**
|
|
1117
|
+
* Check if a JID is in LID format
|
|
1118
|
+
*
|
|
1119
|
+
* @param jid - The JID to check
|
|
1120
|
+
* @returns boolean - True if the JID is in LID format
|
|
1121
|
+
*
|
|
1122
|
+
* @example
|
|
1123
|
+
* ```typescript
|
|
1124
|
+
* if (whatsapp.isLIDFormat("1524746986546@lid")) {
|
|
1125
|
+
* console.log("This is an LID");
|
|
1126
|
+
* }
|
|
1127
|
+
* ```
|
|
1128
|
+
*/
|
|
1129
|
+
const isLIDFormat = (jid) => {
|
|
1130
|
+
return jid.includes('@lid');
|
|
1131
|
+
};
|
|
1132
|
+
exports.isLIDFormat = isLIDFormat;
|
|
1133
|
+
/**
|
|
1134
|
+
* Check if a JID is in Phone Number format (@s.whatsapp.net)
|
|
1135
|
+
*
|
|
1136
|
+
* @param jid - The JID to check
|
|
1137
|
+
* @returns boolean - True if the JID is in PN format
|
|
1138
|
+
*
|
|
1139
|
+
* @example
|
|
1140
|
+
* ```typescript
|
|
1141
|
+
* if (whatsapp.isPNFormat("6281234567890@s.whatsapp.net")) {
|
|
1142
|
+
* console.log("This is a phone number JID");
|
|
1143
|
+
* }
|
|
1144
|
+
* ```
|
|
1145
|
+
*/
|
|
1146
|
+
const isPNFormat = (jid) => {
|
|
1147
|
+
return jid.includes('@s.whatsapp.net');
|
|
1148
|
+
};
|
|
1149
|
+
exports.isPNFormat = isPNFormat;
|
|
1150
|
+
/**
|
|
1151
|
+
* Smart convert any JID to phone number
|
|
1152
|
+
*
|
|
1153
|
+
* Automatically detects if the input is an LID and converts it to PN,
|
|
1154
|
+
* or returns the PN if already in PN format.
|
|
1155
|
+
*
|
|
1156
|
+
* @param sessionId - Session ID to use for conversion
|
|
1157
|
+
* @param jid - Any JID (LID or PN format)
|
|
1158
|
+
* @returns Promise<string | null> - Phone number or null if conversion failed
|
|
1159
|
+
*
|
|
1160
|
+
* @example
|
|
1161
|
+
* ```typescript
|
|
1162
|
+
* const pn = await whatsapp.toPhoneNumber("mysession", jid);
|
|
1163
|
+
* if (pn) {
|
|
1164
|
+
* console.log(`Phone number: ${pn}`);
|
|
1165
|
+
* }
|
|
1166
|
+
* ```
|
|
1167
|
+
*/
|
|
1168
|
+
const toPhoneNumber = (sessionId, jid) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1169
|
+
// Handle null/undefined input
|
|
1170
|
+
if (!jid) {
|
|
1171
|
+
return null;
|
|
1172
|
+
}
|
|
1173
|
+
// If it's a group or broadcast, return null
|
|
1174
|
+
if (jid.includes('@g.us') || jid.includes('@broadcast')) {
|
|
1175
|
+
return null;
|
|
1176
|
+
}
|
|
1177
|
+
// If already in PN format, use jidNormalizedUser to remove device ID
|
|
1178
|
+
if ((0, exports.isPNFormat)(jid)) {
|
|
1179
|
+
// Use jidNormalizedUser to normalize and remove device ID (e.g., :0, :1)
|
|
1180
|
+
const normalized = (0, baileys_1.jidNormalizedUser)(jid);
|
|
1181
|
+
return normalized || jid; // Fallback to original if normalization fails
|
|
1182
|
+
}
|
|
1183
|
+
// If it's an LID, try to convert
|
|
1184
|
+
if ((0, exports.isLIDFormat)(jid)) {
|
|
1185
|
+
const lidResult = yield (0, exports.getPNForLID)(sessionId, jid);
|
|
1186
|
+
if (lidResult.pn) {
|
|
1187
|
+
// Use jidNormalizedUser to normalize the result and remove device ID
|
|
1188
|
+
const normalized = (0, baileys_1.jidNormalizedUser)(lidResult.pn);
|
|
1189
|
+
return normalized || lidResult.pn; // Fallback to original if normalization fails
|
|
1190
|
+
}
|
|
1191
|
+
return null;
|
|
1192
|
+
}
|
|
1193
|
+
// If it's just a number, format it as PN (no device ID needed)
|
|
1194
|
+
const phoneNumber = jid.replace(/\D/g, '');
|
|
1195
|
+
if (phoneNumber.length >= 10) {
|
|
1196
|
+
return `${phoneNumber}@s.whatsapp.net`;
|
|
1197
|
+
}
|
|
1198
|
+
return null;
|
|
1199
|
+
});
|
|
1200
|
+
exports.toPhoneNumber = toPhoneNumber;
|
|
1201
|
+
/**
|
|
1202
|
+
* Smart convert any JID to LID
|
|
1203
|
+
*
|
|
1204
|
+
* Automatically detects if the input is a PN and converts it to LID,
|
|
1205
|
+
* or returns the LID if already in LID format.
|
|
1206
|
+
*
|
|
1207
|
+
* @param sessionId - Session ID to use for conversion
|
|
1208
|
+
* @param jid - Any JID (LID or PN format)
|
|
1209
|
+
* @returns Promise<string | null> - LID or null if conversion failed
|
|
1210
|
+
*
|
|
1211
|
+
* @example
|
|
1212
|
+
* ```typescript
|
|
1213
|
+
* const lid = await whatsapp.toLID("mysession", "6281234567890@s.whatsapp.net");
|
|
1214
|
+
* if (lid) {
|
|
1215
|
+
* console.log(`LID: ${lid}`);
|
|
1216
|
+
* }
|
|
1217
|
+
* ```
|
|
1218
|
+
*/
|
|
1219
|
+
const toLID = (sessionId, jid) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1220
|
+
// If already in LID format, return as-is
|
|
1221
|
+
if ((0, exports.isLIDFormat)(jid)) {
|
|
1222
|
+
return jid;
|
|
1223
|
+
}
|
|
1224
|
+
// If it's a PN, try to convert
|
|
1225
|
+
if ((0, exports.isPNFormat)(jid) || /^\d+$/.test(jid.replace(/\D/g, ''))) {
|
|
1226
|
+
const result = yield (0, exports.getLIDForPN)(sessionId, jid);
|
|
1227
|
+
return result.lid;
|
|
1228
|
+
}
|
|
1229
|
+
// If it's a group or broadcast, return null
|
|
1230
|
+
if (jid.includes('@g.us') || jid.includes('@broadcast')) {
|
|
1231
|
+
return null;
|
|
1232
|
+
}
|
|
1233
|
+
return null;
|
|
1234
|
+
});
|
|
1235
|
+
exports.toLID = toLID;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { WAMessageUpdate, proto } from "baileys";
|
|
2
|
+
/**
|
|
3
|
+
* Supported browser types for WhatsApp connection
|
|
4
|
+
* - ubuntu: Uses Ubuntu browser agent (default)
|
|
5
|
+
* - macOS: Uses macOS browser agent
|
|
6
|
+
* - windows: Uses Windows browser agent
|
|
7
|
+
* - appropriate: Uses appropriate browser based on platform
|
|
8
|
+
*/
|
|
9
|
+
export type BrowserType = "ubuntu" | "macOS" | "windows" | "appropriate";
|
|
2
10
|
export interface SendMessageTypes {
|
|
3
11
|
to: string | number;
|
|
4
12
|
text?: string;
|
|
@@ -27,6 +35,11 @@ export interface MessageReceived extends proto.IWebMessageInfo {
|
|
|
27
35
|
* Your Session ID
|
|
28
36
|
*/
|
|
29
37
|
sessionId: string;
|
|
38
|
+
/**
|
|
39
|
+
* Sender's phone number in normalized format (without device ID)
|
|
40
|
+
* @example "6281234567890@s.whatsapp.net"
|
|
41
|
+
*/
|
|
42
|
+
sender: string | null;
|
|
30
43
|
/**
|
|
31
44
|
* @param path save image location path with extension
|
|
32
45
|
* @example "./myimage.jpg"
|
|
@@ -53,6 +66,19 @@ export interface StartSessionParams {
|
|
|
53
66
|
* Print QR Code into Terminal
|
|
54
67
|
*/
|
|
55
68
|
printQR?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Browser type for WhatsApp connection
|
|
71
|
+
* Options: "ubuntu" (default), "macOS", "windows", "appropriate"
|
|
72
|
+
* @default "ubuntu"
|
|
73
|
+
*/
|
|
74
|
+
browserType?: BrowserType;
|
|
75
|
+
/**
|
|
76
|
+
* Custom browser/app name displayed in WhatsApp
|
|
77
|
+
* This name will appear in "Linked Devices" on your phone
|
|
78
|
+
* @default "Chrome"
|
|
79
|
+
* @example "My Bot App"
|
|
80
|
+
*/
|
|
81
|
+
browserName?: string;
|
|
56
82
|
onQRUpdated?: (qr: string) => void;
|
|
57
83
|
onConnected?: () => void;
|
|
58
84
|
onConnecting?: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEjD,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC;CACnC;AAED,MAAM,WAAW,2BAA4B,SAAQ,gBAAgB;IACnE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,cAAe,SAAQ,gBAAgB;IACtD,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;I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