@builderbot/provider-baileys 1.3.5-alpha.5 → 1.3.5-alpha.7
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/bailey.d.ts +43 -0
- package/dist/bailey.d.ts.map +1 -1
- package/dist/baileyWrapper.d.ts +2 -2
- package/dist/baileyWrapper.d.ts.map +1 -1
- package/dist/index.cjs +327 -22
- package/dist/index.mjs +327 -22
- package/dist/utils.d.ts +64 -11
- package/dist/utils.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/bailey.d.ts
CHANGED
|
@@ -198,8 +198,51 @@ declare class BaileysProvider extends ProviderClass<WASocket> {
|
|
|
198
198
|
saveFile: (ctx: Partial<WAMessage & BotContext>, options?: {
|
|
199
199
|
path: string;
|
|
200
200
|
}) => Promise<string>;
|
|
201
|
+
/**
|
|
202
|
+
* Extracts sender information from MessageKey using Baileys v7.0.0+ Alt fields
|
|
203
|
+
* Optimized for performance and proper LID handling
|
|
204
|
+
* @param key MessageKey with potential remoteJidAlt/participantAlt fields
|
|
205
|
+
* @returns Object with identifier, type, and isLID flag
|
|
206
|
+
*/
|
|
207
|
+
private extractSenderWithAltFields;
|
|
201
208
|
private shouldReconnect;
|
|
202
209
|
private delayedReconnect;
|
|
210
|
+
/**
|
|
211
|
+
* Validates if the auth state supports LID system (lid-mapping and device-index keys)
|
|
212
|
+
* Required for Baileys v7.0.0+ LID system
|
|
213
|
+
* @param state The authentication state from useMultiFileAuthState
|
|
214
|
+
*/
|
|
215
|
+
private validateLIDSupport;
|
|
216
|
+
/**
|
|
217
|
+
* Checks if the auth state has LID system support
|
|
218
|
+
* @param state The authentication state
|
|
219
|
+
* @returns boolean indicating LID support
|
|
220
|
+
*/
|
|
221
|
+
private hasLIDSupport;
|
|
222
|
+
/**
|
|
223
|
+
* Gets the LID mapping store from the socket
|
|
224
|
+
* @returns The LID mapping store or null if not available
|
|
225
|
+
*/
|
|
226
|
+
getLIDMappingStore(): any;
|
|
227
|
+
/**
|
|
228
|
+
* Public method to get LID from PN using the internal store
|
|
229
|
+
* @param phoneNumber Phone number to get LID for
|
|
230
|
+
* @returns Promise<string | null> LID or null if not found
|
|
231
|
+
*/
|
|
232
|
+
getLIDFromPN(phoneNumber: string): Promise<string | null>;
|
|
233
|
+
/**
|
|
234
|
+
* Public method to get PN from LID using the internal store
|
|
235
|
+
* @param lid LID to get phone number for
|
|
236
|
+
* @returns Promise<string | null> Phone number or null if not found
|
|
237
|
+
*/
|
|
238
|
+
getPNFromLID(lid: string): Promise<string | null>;
|
|
239
|
+
/**
|
|
240
|
+
* Public method to store a LID-PN mapping
|
|
241
|
+
* @param lid Local Identifier
|
|
242
|
+
* @param phoneNumber Phone Number
|
|
243
|
+
* @returns Promise<boolean> Success status
|
|
244
|
+
*/
|
|
245
|
+
storeLIDPNMapping(lid: string, phoneNumber: string): Promise<boolean>;
|
|
203
246
|
}
|
|
204
247
|
export { BaileysProvider };
|
|
205
248
|
//# sourceMappingURL=bailey.d.ts.map
|
package/dist/bailey.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bailey.d.ts","sourceRoot":"","sources":["../src/bailey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAS,MAAM,iBAAiB,CAAA;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAIjF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,IAAI,CAAA;AAI9C,OAAO,SAAS,MAAM,YAAY,CAAA;AAIlC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAG3D,OAAO,EAGH,eAAe,EAEf,SAAS,EACT,QAAQ,EASR,KAAK,EAER,MAAM,iBAAiB,CAAA;AAExB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAA;
|
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U,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAgBtE;;;;OAIG;IACU,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAgB9D;;;;;OAKG;IACU,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAgBrF;AAED,OAAO,EAAE,eAAe,EAAE,CAAA"}
|
package/dist/baileyWrapper.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { useMultiFileAuthState, DisconnectReason, proto, makeCacheableSignalKeyStore, getAggregateVotesInPollMessage, WASocket, BaileysEventMap, AnyMediaMessageContent, AnyMessageContent, PollMessageOptions, downloadMediaMessage, WAMessage, MessageUpsertType, isJidGroup, isJidBroadcast, makeWASocket as makeWASocketOther } from 'baileys';
|
|
2
|
-
export { makeWASocketOther, useMultiFileAuthState, DisconnectReason, proto, makeCacheableSignalKeyStore, getAggregateVotesInPollMessage, WASocket, BaileysEventMap, AnyMediaMessageContent, AnyMessageContent, PollMessageOptions, downloadMediaMessage, WAMessage, MessageUpsertType, isJidGroup, isJidBroadcast, };
|
|
1
|
+
import { useMultiFileAuthState, DisconnectReason, proto, makeCacheableSignalKeyStore, getAggregateVotesInPollMessage, WASocket, BaileysEventMap, AnyMediaMessageContent, AnyMessageContent, PollMessageOptions, downloadMediaMessage, WAMessage, MessageUpsertType, isJidGroup, isJidBroadcast, makeWASocket as makeWASocketOther, isPnUser } from 'baileys';
|
|
2
|
+
export { makeWASocketOther, useMultiFileAuthState, DisconnectReason, proto, makeCacheableSignalKeyStore, getAggregateVotesInPollMessage, WASocket, BaileysEventMap, AnyMediaMessageContent, AnyMessageContent, PollMessageOptions, downloadMediaMessage, WAMessage, MessageUpsertType, isJidGroup, isJidBroadcast, isPnUser, };
|
|
3
3
|
//# sourceMappingURL=baileyWrapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baileyWrapper.d.ts","sourceRoot":"","sources":["../src/baileyWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,qBAAqB,EACrB,gBAAgB,EAChB,KAAK,EACL,2BAA2B,EAC3B,8BAA8B,EAC9B,QAAQ,EACR,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,YAAY,IAAI,iBAAiB,
|
|
1
|
+
{"version":3,"file":"baileyWrapper.d.ts","sourceRoot":"","sources":["../src/baileyWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,qBAAqB,EACrB,gBAAgB,EAChB,KAAK,EACL,2BAA2B,EAC3B,8BAA8B,EAC9B,QAAQ,EACR,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,YAAY,IAAI,iBAAiB,EACjC,QAAQ,EACX,MAAM,SAAS,CAAA;AAEhB,OAAO,EACH,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,KAAK,EACL,2BAA2B,EAC3B,8BAA8B,EAC9B,QAAQ,EACR,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,QAAQ,GACX,CAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -3824,28 +3824,54 @@ const emptyDirSessions = async (pathBase) => new Promise((resolve, reject) => {
|
|
|
3824
3824
|
});
|
|
3825
3825
|
});
|
|
3826
3826
|
/**
|
|
3827
|
-
* Cleans
|
|
3828
|
-
*
|
|
3829
|
-
* @
|
|
3827
|
+
* Cleans and extracts the appropriate identifier from MessageKey, supporting LID system.
|
|
3828
|
+
* Uses remoteJidAlt/participantAlt when available according to Baileys v7.0.0+ specs.
|
|
3829
|
+
* @param key The MessageKey object from Baileys with LID support
|
|
3830
|
+
* @returns The appropriate identifier (PN or LID)
|
|
3830
3831
|
*/
|
|
3831
3832
|
function baileyCleanNumberWithLid(key) {
|
|
3832
|
-
|
|
3833
|
-
|
|
3833
|
+
// For groups: use participantAlt if available, fallback to participant
|
|
3834
|
+
if (key.participant || key.participantAlt) {
|
|
3835
|
+
const groupParticipant = key.participantAlt || key.participant;
|
|
3836
|
+
return groupParticipant || '';
|
|
3837
|
+
}
|
|
3838
|
+
// For DMs: use remoteJidAlt if available, fallback to remoteJid
|
|
3839
|
+
if (key.remoteJid || key.remoteJidAlt) {
|
|
3840
|
+
const directMessage = key.remoteJidAlt || key.remoteJid;
|
|
3841
|
+
// If we have a LID and senderPn is available, prefer the PN for compatibility
|
|
3842
|
+
if (directMessage?.includes('@lid') && key.senderPn) {
|
|
3843
|
+
return key.senderPn;
|
|
3844
|
+
}
|
|
3845
|
+
return directMessage || '';
|
|
3846
|
+
}
|
|
3847
|
+
return '';
|
|
3834
3848
|
}
|
|
3835
3849
|
/**
|
|
3836
|
-
* Cleans the WhatsApp number format.
|
|
3837
|
-
* @param number The WhatsApp number to be cleaned.
|
|
3850
|
+
* Cleans the WhatsApp number format, supporting both LIDs and PNs.
|
|
3851
|
+
* @param number The WhatsApp number/LID to be cleaned.
|
|
3838
3852
|
* @param full Whether to return the full number format or not.
|
|
3839
|
-
* @returns The cleaned number.
|
|
3853
|
+
* @returns The cleaned number or LID.
|
|
3840
3854
|
*/
|
|
3841
3855
|
const baileyCleanNumber = (number, full = false) => {
|
|
3856
|
+
// Handle group chats - return as is
|
|
3842
3857
|
const regexGroup = /\@g.us\b/gm;
|
|
3843
|
-
const
|
|
3844
|
-
if (
|
|
3858
|
+
const existGroup = number.match(regexGroup);
|
|
3859
|
+
if (existGroup)
|
|
3845
3860
|
return number;
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3861
|
+
// Handle LIDs - return as is since they should be preserved
|
|
3862
|
+
if (number.includes('@lid')) {
|
|
3863
|
+
return number;
|
|
3864
|
+
}
|
|
3865
|
+
// Handle PNs (Phone Numbers) - traditional format
|
|
3866
|
+
if (number.includes('@s.whatsapp.net')) {
|
|
3867
|
+
if (full) {
|
|
3868
|
+
return number.replace('@s.whatsapp.net', '').replace('+', '').replace(/\s/g, '');
|
|
3869
|
+
}
|
|
3870
|
+
return number;
|
|
3871
|
+
}
|
|
3872
|
+
// Clean and format as PN if it's a raw phone number
|
|
3873
|
+
const cleanedNumber = number.replace('+', '').replace(/\s/g, '');
|
|
3874
|
+
return full ? cleanedNumber : `${cleanedNumber}@s.whatsapp.net`;
|
|
3849
3875
|
};
|
|
3850
3876
|
/**
|
|
3851
3877
|
* Generates an image from a base64 string.
|
|
@@ -3864,14 +3890,69 @@ const baileyGenerateImage = async (base64, name = 'qr.png') => {
|
|
|
3864
3890
|
await bot.utils.cleanImage(PATH_QR);
|
|
3865
3891
|
};
|
|
3866
3892
|
/**
|
|
3867
|
-
* Validates if the given
|
|
3868
|
-
*
|
|
3869
|
-
* @
|
|
3893
|
+
* Validates if the given identifier is a valid WhatsApp user identifier (PN or LID) and not a group ID.
|
|
3894
|
+
* Compatible with Baileys v7.0.0+ LID system.
|
|
3895
|
+
* @param rawIdentifier The identifier to validate (PN, LID, or other)
|
|
3896
|
+
* @returns True if it's a valid user identifier, false otherwise
|
|
3870
3897
|
*/
|
|
3871
|
-
const baileyIsValidNumber = (
|
|
3898
|
+
const baileyIsValidNumber = (rawIdentifier) => {
|
|
3899
|
+
if (!rawIdentifier || typeof rawIdentifier !== 'string') {
|
|
3900
|
+
return false;
|
|
3901
|
+
}
|
|
3902
|
+
// Exclude group chats
|
|
3872
3903
|
const regexGroup = /\@g.us\b/gm;
|
|
3873
|
-
const
|
|
3874
|
-
|
|
3904
|
+
const isGroup = rawIdentifier.match(regexGroup);
|
|
3905
|
+
if (isGroup)
|
|
3906
|
+
return false;
|
|
3907
|
+
// Exclude broadcast lists
|
|
3908
|
+
if (rawIdentifier.includes('@broadcast'))
|
|
3909
|
+
return false;
|
|
3910
|
+
// Accept LIDs (Local Identifiers) - preferred format
|
|
3911
|
+
if (rawIdentifier.includes('@lid'))
|
|
3912
|
+
return true;
|
|
3913
|
+
// Accept PNs (Phone Numbers) - legacy format but still valid
|
|
3914
|
+
if (rawIdentifier.includes('@s.whatsapp.net'))
|
|
3915
|
+
return true;
|
|
3916
|
+
// For raw numbers, consider them valid if they look like phone numbers
|
|
3917
|
+
const cleanNumber = rawIdentifier.replace(/\D/g, ''); // Remove non-digits
|
|
3918
|
+
return cleanNumber.length >= 10 && cleanNumber.length <= 15; // Reasonable phone number length
|
|
3919
|
+
};
|
|
3920
|
+
/**
|
|
3921
|
+
* Stores a single LID-PN mapping in the store.
|
|
3922
|
+
* @param lidStore The LID mapping store from sock.signalRepository.lidMapping
|
|
3923
|
+
* @param lid The Local Identifier
|
|
3924
|
+
* @param phoneNumber The Phone Number
|
|
3925
|
+
* @returns Promise<void>
|
|
3926
|
+
*/
|
|
3927
|
+
const baileyStoreLIDPNMapping = async (lidStore, lid, phoneNumber) => {
|
|
3928
|
+
try {
|
|
3929
|
+
if (!lidStore || !lidStore.storeLIDPNMapping) {
|
|
3930
|
+
console.warn('LID store not available or storeLIDPNMapping method missing');
|
|
3931
|
+
return;
|
|
3932
|
+
}
|
|
3933
|
+
await lidStore.storeLIDPNMapping(lid, phoneNumber);
|
|
3934
|
+
}
|
|
3935
|
+
catch (error) {
|
|
3936
|
+
console.error('Error storing LID-PN mapping:', error);
|
|
3937
|
+
}
|
|
3938
|
+
};
|
|
3939
|
+
/**
|
|
3940
|
+
* Stores multiple LID-PN mappings in the store.
|
|
3941
|
+
* @param lidStore The LID mapping store from sock.signalRepository.lidMapping
|
|
3942
|
+
* @param mappings Object with LID-PN mappings
|
|
3943
|
+
* @returns Promise<void>
|
|
3944
|
+
*/
|
|
3945
|
+
const baileyStoreLIDPNMappings = async (lidStore, mappings) => {
|
|
3946
|
+
try {
|
|
3947
|
+
if (!lidStore || !lidStore.storeLIDPNMappings) {
|
|
3948
|
+
console.warn('LID store not available or storeLIDPNMappings method missing');
|
|
3949
|
+
return;
|
|
3950
|
+
}
|
|
3951
|
+
await lidStore.storeLIDPNMappings(mappings);
|
|
3952
|
+
}
|
|
3953
|
+
catch (error) {
|
|
3954
|
+
console.error('Error storing LID-PN mappings:', error);
|
|
3955
|
+
}
|
|
3875
3956
|
};
|
|
3876
3957
|
|
|
3877
3958
|
var mimeTypes = {};
|
|
@@ -30995,7 +31076,8 @@ class BaileysProvider extends bot.ProviderClass {
|
|
|
30995
31076
|
};
|
|
30996
31077
|
this.getMessage = async (key) => {
|
|
30997
31078
|
// only if store is present
|
|
30998
|
-
|
|
31079
|
+
// In Baileys v7.0.0+ fromObject() was replaced with create()
|
|
31080
|
+
return baileys.proto.Message.create({});
|
|
30999
31081
|
};
|
|
31000
31082
|
this.saveCredsGlobal = null;
|
|
31001
31083
|
/**
|
|
@@ -31006,6 +31088,9 @@ class BaileysProvider extends bot.ProviderClass {
|
|
|
31006
31088
|
const { state, saveCreds } = await baileys.useMultiFileAuthState(NAME_DIR_SESSION);
|
|
31007
31089
|
const loggerBaileys = pino$1({ level: 'fatal' });
|
|
31008
31090
|
this.saveCredsGlobal = saveCreds;
|
|
31091
|
+
// Verificar soporte para LID system (Baileys v7.0.0+)
|
|
31092
|
+
this.validateLIDSupport(state);
|
|
31093
|
+
this.logger.log(`[${new Date().toISOString()}] LID system support: ${this.hasLIDSupport(state) ? 'ENABLED' : 'DISABLED'}`);
|
|
31009
31094
|
try {
|
|
31010
31095
|
if (this.globalVendorArgs.useBaileysStore) {
|
|
31011
31096
|
if (this.globalVendorArgs.timeRelease > 0) {
|
|
@@ -31032,7 +31117,7 @@ class BaileysProvider extends bot.ProviderClass {
|
|
|
31032
31117
|
generateHighQualityLinkPreview: true,
|
|
31033
31118
|
getMessage: this.getMessage,
|
|
31034
31119
|
msgRetryCounterCache: this.msgRetryCounterCache,
|
|
31035
|
-
userDevicesCache: this.userDevicesCache,
|
|
31120
|
+
userDevicesCache: this.userDevicesCache, // NodeCache compatibility with Baileys v7.0.0+
|
|
31036
31121
|
retryRequestDelayMs: 1000, // Mayor delay entre reintentos
|
|
31037
31122
|
maxMsgRetryCount: 8, // Más intentos de reenvío
|
|
31038
31123
|
connectTimeoutMs: 60_000, // 1 minuto timeout conexión
|
|
@@ -31246,11 +31331,15 @@ class BaileysProvider extends bot.ProviderClass {
|
|
|
31246
31331
|
this.logger.log(`[${new Date().toISOString()}] Message received from phone, id=${messageCtx.requestId}`, messageCtx);
|
|
31247
31332
|
}
|
|
31248
31333
|
}
|
|
31334
|
+
// Extract sender using Baileys v7.0.0+ LID system with Alt fields
|
|
31335
|
+
const senderInfo = this.extractSenderWithAltFields(messageCtx?.key);
|
|
31249
31336
|
let payload = {
|
|
31250
31337
|
...messageCtx,
|
|
31251
31338
|
body: textToBody,
|
|
31252
31339
|
name: messageCtx?.pushName,
|
|
31253
|
-
from:
|
|
31340
|
+
from: senderInfo.identifier,
|
|
31341
|
+
fromType: senderInfo.type, // 'lid', 'pn', or 'unknown'
|
|
31342
|
+
isLID: senderInfo.isLID,
|
|
31254
31343
|
};
|
|
31255
31344
|
if (messageCtx.message?.locationMessage) {
|
|
31256
31345
|
const { degreesLatitude, degreesLongitude } = messageCtx.message.locationMessage;
|
|
@@ -31367,6 +31456,44 @@ class BaileysProvider extends bot.ProviderClass {
|
|
|
31367
31456
|
}
|
|
31368
31457
|
},
|
|
31369
31458
|
},
|
|
31459
|
+
{
|
|
31460
|
+
event: 'lid-mapping.update',
|
|
31461
|
+
func: async (lidMappingUpdate) => {
|
|
31462
|
+
try {
|
|
31463
|
+
this.logger.log(`[${new Date().toISOString()}] LID mapping update received:`, lidMappingUpdate);
|
|
31464
|
+
const lidStore = this.getLIDMappingStore();
|
|
31465
|
+
if (!lidStore) {
|
|
31466
|
+
this.logger.log(`[${new Date().toISOString()}] LID store not available for mapping update`);
|
|
31467
|
+
return;
|
|
31468
|
+
}
|
|
31469
|
+
// Process LID mapping updates according to Baileys v7.0.0+ specs
|
|
31470
|
+
if (lidMappingUpdate && typeof lidMappingUpdate === 'object') {
|
|
31471
|
+
// Use our utility functions for consistent LID handling
|
|
31472
|
+
// Store individual mappings using our wrapper functions
|
|
31473
|
+
for (const [lid, pn] of Object.entries(lidMappingUpdate)) {
|
|
31474
|
+
if (lid && pn && typeof lid === 'string' && typeof pn === 'string') {
|
|
31475
|
+
await baileyStoreLIDPNMapping(lidStore, lid, pn);
|
|
31476
|
+
this.logger.log(`[${new Date().toISOString()}] Stored LID mapping: ${lid} <-> ${pn}`);
|
|
31477
|
+
}
|
|
31478
|
+
}
|
|
31479
|
+
// Batch store if multiple mappings using our wrapper function
|
|
31480
|
+
if (Object.keys(lidMappingUpdate).length > 1) {
|
|
31481
|
+
await baileyStoreLIDPNMappings(lidStore, lidMappingUpdate);
|
|
31482
|
+
this.logger.log(`[${new Date().toISOString()}] Batch stored ${Object.keys(lidMappingUpdate).length} LID mappings`);
|
|
31483
|
+
}
|
|
31484
|
+
// Emit custom event for external listeners
|
|
31485
|
+
this.emit('lid_mapping_updated', {
|
|
31486
|
+
mappings: lidMappingUpdate,
|
|
31487
|
+
timestamp: new Date().toISOString(),
|
|
31488
|
+
count: Object.keys(lidMappingUpdate).length
|
|
31489
|
+
});
|
|
31490
|
+
}
|
|
31491
|
+
}
|
|
31492
|
+
catch (error) {
|
|
31493
|
+
this.logger.log(`[${new Date().toISOString()}] Error processing lid-mapping.update:`, error);
|
|
31494
|
+
}
|
|
31495
|
+
},
|
|
31496
|
+
},
|
|
31370
31497
|
];
|
|
31371
31498
|
/**
|
|
31372
31499
|
* @param {string} orderId
|
|
@@ -31811,6 +31938,61 @@ class BaileysProvider extends bot.ProviderClass {
|
|
|
31811
31938
|
.get('/', this.indexHome);
|
|
31812
31939
|
}
|
|
31813
31940
|
afterHttpServerInit() { }
|
|
31941
|
+
/**
|
|
31942
|
+
* Extracts sender information from MessageKey using Baileys v7.0.0+ Alt fields
|
|
31943
|
+
* Optimized for performance and proper LID handling
|
|
31944
|
+
* @param key MessageKey with potential remoteJidAlt/participantAlt fields
|
|
31945
|
+
* @returns Object with identifier, type, and isLID flag
|
|
31946
|
+
*/
|
|
31947
|
+
extractSenderWithAltFields(key) {
|
|
31948
|
+
try {
|
|
31949
|
+
// For groups: prioritize participantAlt over participant
|
|
31950
|
+
if (key?.participant || key?.participantAlt) {
|
|
31951
|
+
const groupSender = key.participantAlt || key.participant;
|
|
31952
|
+
if (groupSender) {
|
|
31953
|
+
return {
|
|
31954
|
+
identifier: baileyCleanNumber(groupSender),
|
|
31955
|
+
type: groupSender.includes('@lid') ? 'lid' : groupSender.includes('@s.whatsapp.net') ? 'pn' : 'unknown',
|
|
31956
|
+
isLID: groupSender.includes('@lid')
|
|
31957
|
+
};
|
|
31958
|
+
}
|
|
31959
|
+
}
|
|
31960
|
+
// For DMs: prioritize remoteJidAlt over remoteJid
|
|
31961
|
+
if (key?.remoteJid || key?.remoteJidAlt) {
|
|
31962
|
+
const directSender = key.remoteJidAlt || key.remoteJid;
|
|
31963
|
+
// Handle LID with fallback to PN from senderPn
|
|
31964
|
+
if (directSender?.includes('@lid') && key.senderPn) {
|
|
31965
|
+
return {
|
|
31966
|
+
identifier: baileyCleanNumber(key.senderPn), // Use PN for compatibility
|
|
31967
|
+
type: 'pn', // Even though original is LID, we return PN for compatibility
|
|
31968
|
+
isLID: true // Flag indicates original was LID
|
|
31969
|
+
};
|
|
31970
|
+
}
|
|
31971
|
+
if (directSender) {
|
|
31972
|
+
return {
|
|
31973
|
+
identifier: baileyCleanNumber(directSender),
|
|
31974
|
+
type: directSender.includes('@lid') ? 'lid' : directSender.includes('@s.whatsapp.net') ? 'pn' : 'unknown',
|
|
31975
|
+
isLID: directSender.includes('@lid')
|
|
31976
|
+
};
|
|
31977
|
+
}
|
|
31978
|
+
}
|
|
31979
|
+
// Fallback to empty
|
|
31980
|
+
return {
|
|
31981
|
+
identifier: '',
|
|
31982
|
+
type: 'unknown',
|
|
31983
|
+
isLID: false
|
|
31984
|
+
};
|
|
31985
|
+
}
|
|
31986
|
+
catch (error) {
|
|
31987
|
+
this.logger.log(`[${new Date().toISOString()}] Error extracting sender with Alt fields:`, error);
|
|
31988
|
+
// Fallback to original method
|
|
31989
|
+
return {
|
|
31990
|
+
identifier: baileyCleanNumberWithLid(key),
|
|
31991
|
+
type: 'unknown',
|
|
31992
|
+
isLID: false
|
|
31993
|
+
};
|
|
31994
|
+
}
|
|
31995
|
+
}
|
|
31814
31996
|
shouldReconnect(statusCode) {
|
|
31815
31997
|
// Lista de códigos donde SÍ debemos reconectar
|
|
31816
31998
|
const reconnectableCodes = [
|
|
@@ -31851,6 +32033,129 @@ class BaileysProvider extends bot.ProviderClass {
|
|
|
31851
32033
|
}
|
|
31852
32034
|
}, delay);
|
|
31853
32035
|
}
|
|
32036
|
+
/**
|
|
32037
|
+
* Validates if the auth state supports LID system (lid-mapping and device-index keys)
|
|
32038
|
+
* Required for Baileys v7.0.0+ LID system
|
|
32039
|
+
* @param state The authentication state from useMultiFileAuthState
|
|
32040
|
+
*/
|
|
32041
|
+
validateLIDSupport(state) {
|
|
32042
|
+
try {
|
|
32043
|
+
const hasLidMapping = state.keys && typeof state.keys === 'object';
|
|
32044
|
+
const hasDeviceIndex = state.creds && typeof state.creds === 'object';
|
|
32045
|
+
if (!hasLidMapping) {
|
|
32046
|
+
this.logger.log(`[${new Date().toISOString()}] WARNING: Auth state may not support lid-mapping`);
|
|
32047
|
+
}
|
|
32048
|
+
if (!hasDeviceIndex) {
|
|
32049
|
+
this.logger.log(`[${new Date().toISOString()}] WARNING: Auth state may not support device-index`);
|
|
32050
|
+
}
|
|
32051
|
+
// Log auth state structure for debugging (without sensitive data)
|
|
32052
|
+
this.logger.log(`[${new Date().toISOString()}] Auth state keys available:`, Object.keys(state));
|
|
32053
|
+
if (state.keys) {
|
|
32054
|
+
this.logger.log(`[${new Date().toISOString()}] Signal keys structure available: ${typeof state.keys}`);
|
|
32055
|
+
}
|
|
32056
|
+
if (state.creds) {
|
|
32057
|
+
this.logger.log(`[${new Date().toISOString()}] Credentials structure available: ${typeof state.creds}`);
|
|
32058
|
+
}
|
|
32059
|
+
}
|
|
32060
|
+
catch (error) {
|
|
32061
|
+
this.logger.log(`[${new Date().toISOString()}] Error validating LID support:`, error);
|
|
32062
|
+
}
|
|
32063
|
+
}
|
|
32064
|
+
/**
|
|
32065
|
+
* Checks if the auth state has LID system support
|
|
32066
|
+
* @param state The authentication state
|
|
32067
|
+
* @returns boolean indicating LID support
|
|
32068
|
+
*/
|
|
32069
|
+
hasLIDSupport(state) {
|
|
32070
|
+
try {
|
|
32071
|
+
// Check for the presence of keys and creds which should support LID mapping
|
|
32072
|
+
const hasKeys = state.keys && typeof state.keys === 'object';
|
|
32073
|
+
const hasCreds = state.creds && typeof state.creds === 'object';
|
|
32074
|
+
return hasKeys && hasCreds;
|
|
32075
|
+
}
|
|
32076
|
+
catch (error) {
|
|
32077
|
+
this.logger.log(`[${new Date().toISOString()}] Error checking LID support:`, error);
|
|
32078
|
+
return false;
|
|
32079
|
+
}
|
|
32080
|
+
}
|
|
32081
|
+
/**
|
|
32082
|
+
* Gets the LID mapping store from the socket
|
|
32083
|
+
* @returns The LID mapping store or null if not available
|
|
32084
|
+
*/
|
|
32085
|
+
getLIDMappingStore() {
|
|
32086
|
+
try {
|
|
32087
|
+
if (this.vendor && this.vendor.signalRepository && this.vendor.signalRepository.lidMapping) {
|
|
32088
|
+
return this.vendor.signalRepository.lidMapping;
|
|
32089
|
+
}
|
|
32090
|
+
return null;
|
|
32091
|
+
}
|
|
32092
|
+
catch (error) {
|
|
32093
|
+
this.logger.log(`[${new Date().toISOString()}] Error accessing LID mapping store:`, error);
|
|
32094
|
+
return null;
|
|
32095
|
+
}
|
|
32096
|
+
}
|
|
32097
|
+
/**
|
|
32098
|
+
* Public method to get LID from PN using the internal store
|
|
32099
|
+
* @param phoneNumber Phone number to get LID for
|
|
32100
|
+
* @returns Promise<string | null> LID or null if not found
|
|
32101
|
+
*/
|
|
32102
|
+
async getLIDFromPN(phoneNumber) {
|
|
32103
|
+
const lidStore = this.getLIDMappingStore();
|
|
32104
|
+
if (!lidStore) {
|
|
32105
|
+
this.logger.log(`[${new Date().toISOString()}] LID store not available for getLIDFromPN`);
|
|
32106
|
+
return null;
|
|
32107
|
+
}
|
|
32108
|
+
try {
|
|
32109
|
+
const lid = await lidStore.getLIDForPN(phoneNumber);
|
|
32110
|
+
return lid || null;
|
|
32111
|
+
}
|
|
32112
|
+
catch (error) {
|
|
32113
|
+
this.logger.log(`[${new Date().toISOString()}] Error getting LID from PN ${phoneNumber}:`, error);
|
|
32114
|
+
return null;
|
|
32115
|
+
}
|
|
32116
|
+
}
|
|
32117
|
+
/**
|
|
32118
|
+
* Public method to get PN from LID using the internal store
|
|
32119
|
+
* @param lid LID to get phone number for
|
|
32120
|
+
* @returns Promise<string | null> Phone number or null if not found
|
|
32121
|
+
*/
|
|
32122
|
+
async getPNFromLID(lid) {
|
|
32123
|
+
const lidStore = this.getLIDMappingStore();
|
|
32124
|
+
if (!lidStore) {
|
|
32125
|
+
this.logger.log(`[${new Date().toISOString()}] LID store not available for getPNFromLID`);
|
|
32126
|
+
return null;
|
|
32127
|
+
}
|
|
32128
|
+
try {
|
|
32129
|
+
const phoneNumber = await lidStore.getPNForLID(lid);
|
|
32130
|
+
return phoneNumber || null;
|
|
32131
|
+
}
|
|
32132
|
+
catch (error) {
|
|
32133
|
+
this.logger.log(`[${new Date().toISOString()}] Error getting PN from LID ${lid}:`, error);
|
|
32134
|
+
return null;
|
|
32135
|
+
}
|
|
32136
|
+
}
|
|
32137
|
+
/**
|
|
32138
|
+
* Public method to store a LID-PN mapping
|
|
32139
|
+
* @param lid Local Identifier
|
|
32140
|
+
* @param phoneNumber Phone Number
|
|
32141
|
+
* @returns Promise<boolean> Success status
|
|
32142
|
+
*/
|
|
32143
|
+
async storeLIDPNMapping(lid, phoneNumber) {
|
|
32144
|
+
const lidStore = this.getLIDMappingStore();
|
|
32145
|
+
if (!lidStore) {
|
|
32146
|
+
this.logger.log(`[${new Date().toISOString()}] LID store not available for storeLIDPNMapping`);
|
|
32147
|
+
return false;
|
|
32148
|
+
}
|
|
32149
|
+
try {
|
|
32150
|
+
await baileyStoreLIDPNMapping(lidStore, lid, phoneNumber);
|
|
32151
|
+
this.logger.log(`[${new Date().toISOString()}] Successfully stored LID mapping: ${lid} <-> ${phoneNumber}`);
|
|
32152
|
+
return true;
|
|
32153
|
+
}
|
|
32154
|
+
catch (error) {
|
|
32155
|
+
this.logger.log(`[${new Date().toISOString()}] Error storing LID mapping ${lid}<->${phoneNumber}:`, error);
|
|
32156
|
+
return false;
|
|
32157
|
+
}
|
|
32158
|
+
}
|
|
31854
32159
|
}
|
|
31855
32160
|
|
|
31856
32161
|
exports.BaileysProvider = BaileysProvider;
|
package/dist/index.mjs
CHANGED
|
@@ -3822,28 +3822,54 @@ const emptyDirSessions = async (pathBase) => new Promise((resolve, reject) => {
|
|
|
3822
3822
|
});
|
|
3823
3823
|
});
|
|
3824
3824
|
/**
|
|
3825
|
-
* Cleans
|
|
3826
|
-
*
|
|
3827
|
-
* @
|
|
3825
|
+
* Cleans and extracts the appropriate identifier from MessageKey, supporting LID system.
|
|
3826
|
+
* Uses remoteJidAlt/participantAlt when available according to Baileys v7.0.0+ specs.
|
|
3827
|
+
* @param key The MessageKey object from Baileys with LID support
|
|
3828
|
+
* @returns The appropriate identifier (PN or LID)
|
|
3828
3829
|
*/
|
|
3829
3830
|
function baileyCleanNumberWithLid(key) {
|
|
3830
|
-
|
|
3831
|
-
|
|
3831
|
+
// For groups: use participantAlt if available, fallback to participant
|
|
3832
|
+
if (key.participant || key.participantAlt) {
|
|
3833
|
+
const groupParticipant = key.participantAlt || key.participant;
|
|
3834
|
+
return groupParticipant || '';
|
|
3835
|
+
}
|
|
3836
|
+
// For DMs: use remoteJidAlt if available, fallback to remoteJid
|
|
3837
|
+
if (key.remoteJid || key.remoteJidAlt) {
|
|
3838
|
+
const directMessage = key.remoteJidAlt || key.remoteJid;
|
|
3839
|
+
// If we have a LID and senderPn is available, prefer the PN for compatibility
|
|
3840
|
+
if (directMessage?.includes('@lid') && key.senderPn) {
|
|
3841
|
+
return key.senderPn;
|
|
3842
|
+
}
|
|
3843
|
+
return directMessage || '';
|
|
3844
|
+
}
|
|
3845
|
+
return '';
|
|
3832
3846
|
}
|
|
3833
3847
|
/**
|
|
3834
|
-
* Cleans the WhatsApp number format.
|
|
3835
|
-
* @param number The WhatsApp number to be cleaned.
|
|
3848
|
+
* Cleans the WhatsApp number format, supporting both LIDs and PNs.
|
|
3849
|
+
* @param number The WhatsApp number/LID to be cleaned.
|
|
3836
3850
|
* @param full Whether to return the full number format or not.
|
|
3837
|
-
* @returns The cleaned number.
|
|
3851
|
+
* @returns The cleaned number or LID.
|
|
3838
3852
|
*/
|
|
3839
3853
|
const baileyCleanNumber = (number, full = false) => {
|
|
3854
|
+
// Handle group chats - return as is
|
|
3840
3855
|
const regexGroup = /\@g.us\b/gm;
|
|
3841
|
-
const
|
|
3842
|
-
if (
|
|
3856
|
+
const existGroup = number.match(regexGroup);
|
|
3857
|
+
if (existGroup)
|
|
3843
3858
|
return number;
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3859
|
+
// Handle LIDs - return as is since they should be preserved
|
|
3860
|
+
if (number.includes('@lid')) {
|
|
3861
|
+
return number;
|
|
3862
|
+
}
|
|
3863
|
+
// Handle PNs (Phone Numbers) - traditional format
|
|
3864
|
+
if (number.includes('@s.whatsapp.net')) {
|
|
3865
|
+
if (full) {
|
|
3866
|
+
return number.replace('@s.whatsapp.net', '').replace('+', '').replace(/\s/g, '');
|
|
3867
|
+
}
|
|
3868
|
+
return number;
|
|
3869
|
+
}
|
|
3870
|
+
// Clean and format as PN if it's a raw phone number
|
|
3871
|
+
const cleanedNumber = number.replace('+', '').replace(/\s/g, '');
|
|
3872
|
+
return full ? cleanedNumber : `${cleanedNumber}@s.whatsapp.net`;
|
|
3847
3873
|
};
|
|
3848
3874
|
/**
|
|
3849
3875
|
* Generates an image from a base64 string.
|
|
@@ -3862,14 +3888,69 @@ const baileyGenerateImage = async (base64, name = 'qr.png') => {
|
|
|
3862
3888
|
await utils$d.cleanImage(PATH_QR);
|
|
3863
3889
|
};
|
|
3864
3890
|
/**
|
|
3865
|
-
* Validates if the given
|
|
3866
|
-
*
|
|
3867
|
-
* @
|
|
3891
|
+
* Validates if the given identifier is a valid WhatsApp user identifier (PN or LID) and not a group ID.
|
|
3892
|
+
* Compatible with Baileys v7.0.0+ LID system.
|
|
3893
|
+
* @param rawIdentifier The identifier to validate (PN, LID, or other)
|
|
3894
|
+
* @returns True if it's a valid user identifier, false otherwise
|
|
3868
3895
|
*/
|
|
3869
|
-
const baileyIsValidNumber = (
|
|
3896
|
+
const baileyIsValidNumber = (rawIdentifier) => {
|
|
3897
|
+
if (!rawIdentifier || typeof rawIdentifier !== 'string') {
|
|
3898
|
+
return false;
|
|
3899
|
+
}
|
|
3900
|
+
// Exclude group chats
|
|
3870
3901
|
const regexGroup = /\@g.us\b/gm;
|
|
3871
|
-
const
|
|
3872
|
-
|
|
3902
|
+
const isGroup = rawIdentifier.match(regexGroup);
|
|
3903
|
+
if (isGroup)
|
|
3904
|
+
return false;
|
|
3905
|
+
// Exclude broadcast lists
|
|
3906
|
+
if (rawIdentifier.includes('@broadcast'))
|
|
3907
|
+
return false;
|
|
3908
|
+
// Accept LIDs (Local Identifiers) - preferred format
|
|
3909
|
+
if (rawIdentifier.includes('@lid'))
|
|
3910
|
+
return true;
|
|
3911
|
+
// Accept PNs (Phone Numbers) - legacy format but still valid
|
|
3912
|
+
if (rawIdentifier.includes('@s.whatsapp.net'))
|
|
3913
|
+
return true;
|
|
3914
|
+
// For raw numbers, consider them valid if they look like phone numbers
|
|
3915
|
+
const cleanNumber = rawIdentifier.replace(/\D/g, ''); // Remove non-digits
|
|
3916
|
+
return cleanNumber.length >= 10 && cleanNumber.length <= 15; // Reasonable phone number length
|
|
3917
|
+
};
|
|
3918
|
+
/**
|
|
3919
|
+
* Stores a single LID-PN mapping in the store.
|
|
3920
|
+
* @param lidStore The LID mapping store from sock.signalRepository.lidMapping
|
|
3921
|
+
* @param lid The Local Identifier
|
|
3922
|
+
* @param phoneNumber The Phone Number
|
|
3923
|
+
* @returns Promise<void>
|
|
3924
|
+
*/
|
|
3925
|
+
const baileyStoreLIDPNMapping = async (lidStore, lid, phoneNumber) => {
|
|
3926
|
+
try {
|
|
3927
|
+
if (!lidStore || !lidStore.storeLIDPNMapping) {
|
|
3928
|
+
console.warn('LID store not available or storeLIDPNMapping method missing');
|
|
3929
|
+
return;
|
|
3930
|
+
}
|
|
3931
|
+
await lidStore.storeLIDPNMapping(lid, phoneNumber);
|
|
3932
|
+
}
|
|
3933
|
+
catch (error) {
|
|
3934
|
+
console.error('Error storing LID-PN mapping:', error);
|
|
3935
|
+
}
|
|
3936
|
+
};
|
|
3937
|
+
/**
|
|
3938
|
+
* Stores multiple LID-PN mappings in the store.
|
|
3939
|
+
* @param lidStore The LID mapping store from sock.signalRepository.lidMapping
|
|
3940
|
+
* @param mappings Object with LID-PN mappings
|
|
3941
|
+
* @returns Promise<void>
|
|
3942
|
+
*/
|
|
3943
|
+
const baileyStoreLIDPNMappings = async (lidStore, mappings) => {
|
|
3944
|
+
try {
|
|
3945
|
+
if (!lidStore || !lidStore.storeLIDPNMappings) {
|
|
3946
|
+
console.warn('LID store not available or storeLIDPNMappings method missing');
|
|
3947
|
+
return;
|
|
3948
|
+
}
|
|
3949
|
+
await lidStore.storeLIDPNMappings(mappings);
|
|
3950
|
+
}
|
|
3951
|
+
catch (error) {
|
|
3952
|
+
console.error('Error storing LID-PN mappings:', error);
|
|
3953
|
+
}
|
|
3873
3954
|
};
|
|
3874
3955
|
|
|
3875
3956
|
var mimeTypes = {};
|
|
@@ -30993,7 +31074,8 @@ class BaileysProvider extends ProviderClass {
|
|
|
30993
31074
|
};
|
|
30994
31075
|
this.getMessage = async (key) => {
|
|
30995
31076
|
// only if store is present
|
|
30996
|
-
|
|
31077
|
+
// In Baileys v7.0.0+ fromObject() was replaced with create()
|
|
31078
|
+
return proto$2.Message.create({});
|
|
30997
31079
|
};
|
|
30998
31080
|
this.saveCredsGlobal = null;
|
|
30999
31081
|
/**
|
|
@@ -31004,6 +31086,9 @@ class BaileysProvider extends ProviderClass {
|
|
|
31004
31086
|
const { state, saveCreds } = await useMultiFileAuthState(NAME_DIR_SESSION);
|
|
31005
31087
|
const loggerBaileys = pino$1({ level: 'fatal' });
|
|
31006
31088
|
this.saveCredsGlobal = saveCreds;
|
|
31089
|
+
// Verificar soporte para LID system (Baileys v7.0.0+)
|
|
31090
|
+
this.validateLIDSupport(state);
|
|
31091
|
+
this.logger.log(`[${new Date().toISOString()}] LID system support: ${this.hasLIDSupport(state) ? 'ENABLED' : 'DISABLED'}`);
|
|
31007
31092
|
try {
|
|
31008
31093
|
if (this.globalVendorArgs.useBaileysStore) {
|
|
31009
31094
|
if (this.globalVendorArgs.timeRelease > 0) {
|
|
@@ -31030,7 +31115,7 @@ class BaileysProvider extends ProviderClass {
|
|
|
31030
31115
|
generateHighQualityLinkPreview: true,
|
|
31031
31116
|
getMessage: this.getMessage,
|
|
31032
31117
|
msgRetryCounterCache: this.msgRetryCounterCache,
|
|
31033
|
-
userDevicesCache: this.userDevicesCache,
|
|
31118
|
+
userDevicesCache: this.userDevicesCache, // NodeCache compatibility with Baileys v7.0.0+
|
|
31034
31119
|
retryRequestDelayMs: 1000, // Mayor delay entre reintentos
|
|
31035
31120
|
maxMsgRetryCount: 8, // Más intentos de reenvío
|
|
31036
31121
|
connectTimeoutMs: 60_000, // 1 minuto timeout conexión
|
|
@@ -31244,11 +31329,15 @@ class BaileysProvider extends ProviderClass {
|
|
|
31244
31329
|
this.logger.log(`[${new Date().toISOString()}] Message received from phone, id=${messageCtx.requestId}`, messageCtx);
|
|
31245
31330
|
}
|
|
31246
31331
|
}
|
|
31332
|
+
// Extract sender using Baileys v7.0.0+ LID system with Alt fields
|
|
31333
|
+
const senderInfo = this.extractSenderWithAltFields(messageCtx?.key);
|
|
31247
31334
|
let payload = {
|
|
31248
31335
|
...messageCtx,
|
|
31249
31336
|
body: textToBody,
|
|
31250
31337
|
name: messageCtx?.pushName,
|
|
31251
|
-
from:
|
|
31338
|
+
from: senderInfo.identifier,
|
|
31339
|
+
fromType: senderInfo.type, // 'lid', 'pn', or 'unknown'
|
|
31340
|
+
isLID: senderInfo.isLID,
|
|
31252
31341
|
};
|
|
31253
31342
|
if (messageCtx.message?.locationMessage) {
|
|
31254
31343
|
const { degreesLatitude, degreesLongitude } = messageCtx.message.locationMessage;
|
|
@@ -31365,6 +31454,44 @@ class BaileysProvider extends ProviderClass {
|
|
|
31365
31454
|
}
|
|
31366
31455
|
},
|
|
31367
31456
|
},
|
|
31457
|
+
{
|
|
31458
|
+
event: 'lid-mapping.update',
|
|
31459
|
+
func: async (lidMappingUpdate) => {
|
|
31460
|
+
try {
|
|
31461
|
+
this.logger.log(`[${new Date().toISOString()}] LID mapping update received:`, lidMappingUpdate);
|
|
31462
|
+
const lidStore = this.getLIDMappingStore();
|
|
31463
|
+
if (!lidStore) {
|
|
31464
|
+
this.logger.log(`[${new Date().toISOString()}] LID store not available for mapping update`);
|
|
31465
|
+
return;
|
|
31466
|
+
}
|
|
31467
|
+
// Process LID mapping updates according to Baileys v7.0.0+ specs
|
|
31468
|
+
if (lidMappingUpdate && typeof lidMappingUpdate === 'object') {
|
|
31469
|
+
// Use our utility functions for consistent LID handling
|
|
31470
|
+
// Store individual mappings using our wrapper functions
|
|
31471
|
+
for (const [lid, pn] of Object.entries(lidMappingUpdate)) {
|
|
31472
|
+
if (lid && pn && typeof lid === 'string' && typeof pn === 'string') {
|
|
31473
|
+
await baileyStoreLIDPNMapping(lidStore, lid, pn);
|
|
31474
|
+
this.logger.log(`[${new Date().toISOString()}] Stored LID mapping: ${lid} <-> ${pn}`);
|
|
31475
|
+
}
|
|
31476
|
+
}
|
|
31477
|
+
// Batch store if multiple mappings using our wrapper function
|
|
31478
|
+
if (Object.keys(lidMappingUpdate).length > 1) {
|
|
31479
|
+
await baileyStoreLIDPNMappings(lidStore, lidMappingUpdate);
|
|
31480
|
+
this.logger.log(`[${new Date().toISOString()}] Batch stored ${Object.keys(lidMappingUpdate).length} LID mappings`);
|
|
31481
|
+
}
|
|
31482
|
+
// Emit custom event for external listeners
|
|
31483
|
+
this.emit('lid_mapping_updated', {
|
|
31484
|
+
mappings: lidMappingUpdate,
|
|
31485
|
+
timestamp: new Date().toISOString(),
|
|
31486
|
+
count: Object.keys(lidMappingUpdate).length
|
|
31487
|
+
});
|
|
31488
|
+
}
|
|
31489
|
+
}
|
|
31490
|
+
catch (error) {
|
|
31491
|
+
this.logger.log(`[${new Date().toISOString()}] Error processing lid-mapping.update:`, error);
|
|
31492
|
+
}
|
|
31493
|
+
},
|
|
31494
|
+
},
|
|
31368
31495
|
];
|
|
31369
31496
|
/**
|
|
31370
31497
|
* @param {string} orderId
|
|
@@ -31809,6 +31936,61 @@ class BaileysProvider extends ProviderClass {
|
|
|
31809
31936
|
.get('/', this.indexHome);
|
|
31810
31937
|
}
|
|
31811
31938
|
afterHttpServerInit() { }
|
|
31939
|
+
/**
|
|
31940
|
+
* Extracts sender information from MessageKey using Baileys v7.0.0+ Alt fields
|
|
31941
|
+
* Optimized for performance and proper LID handling
|
|
31942
|
+
* @param key MessageKey with potential remoteJidAlt/participantAlt fields
|
|
31943
|
+
* @returns Object with identifier, type, and isLID flag
|
|
31944
|
+
*/
|
|
31945
|
+
extractSenderWithAltFields(key) {
|
|
31946
|
+
try {
|
|
31947
|
+
// For groups: prioritize participantAlt over participant
|
|
31948
|
+
if (key?.participant || key?.participantAlt) {
|
|
31949
|
+
const groupSender = key.participantAlt || key.participant;
|
|
31950
|
+
if (groupSender) {
|
|
31951
|
+
return {
|
|
31952
|
+
identifier: baileyCleanNumber(groupSender),
|
|
31953
|
+
type: groupSender.includes('@lid') ? 'lid' : groupSender.includes('@s.whatsapp.net') ? 'pn' : 'unknown',
|
|
31954
|
+
isLID: groupSender.includes('@lid')
|
|
31955
|
+
};
|
|
31956
|
+
}
|
|
31957
|
+
}
|
|
31958
|
+
// For DMs: prioritize remoteJidAlt over remoteJid
|
|
31959
|
+
if (key?.remoteJid || key?.remoteJidAlt) {
|
|
31960
|
+
const directSender = key.remoteJidAlt || key.remoteJid;
|
|
31961
|
+
// Handle LID with fallback to PN from senderPn
|
|
31962
|
+
if (directSender?.includes('@lid') && key.senderPn) {
|
|
31963
|
+
return {
|
|
31964
|
+
identifier: baileyCleanNumber(key.senderPn), // Use PN for compatibility
|
|
31965
|
+
type: 'pn', // Even though original is LID, we return PN for compatibility
|
|
31966
|
+
isLID: true // Flag indicates original was LID
|
|
31967
|
+
};
|
|
31968
|
+
}
|
|
31969
|
+
if (directSender) {
|
|
31970
|
+
return {
|
|
31971
|
+
identifier: baileyCleanNumber(directSender),
|
|
31972
|
+
type: directSender.includes('@lid') ? 'lid' : directSender.includes('@s.whatsapp.net') ? 'pn' : 'unknown',
|
|
31973
|
+
isLID: directSender.includes('@lid')
|
|
31974
|
+
};
|
|
31975
|
+
}
|
|
31976
|
+
}
|
|
31977
|
+
// Fallback to empty
|
|
31978
|
+
return {
|
|
31979
|
+
identifier: '',
|
|
31980
|
+
type: 'unknown',
|
|
31981
|
+
isLID: false
|
|
31982
|
+
};
|
|
31983
|
+
}
|
|
31984
|
+
catch (error) {
|
|
31985
|
+
this.logger.log(`[${new Date().toISOString()}] Error extracting sender with Alt fields:`, error);
|
|
31986
|
+
// Fallback to original method
|
|
31987
|
+
return {
|
|
31988
|
+
identifier: baileyCleanNumberWithLid(key),
|
|
31989
|
+
type: 'unknown',
|
|
31990
|
+
isLID: false
|
|
31991
|
+
};
|
|
31992
|
+
}
|
|
31993
|
+
}
|
|
31812
31994
|
shouldReconnect(statusCode) {
|
|
31813
31995
|
// Lista de códigos donde SÍ debemos reconectar
|
|
31814
31996
|
const reconnectableCodes = [
|
|
@@ -31849,6 +32031,129 @@ class BaileysProvider extends ProviderClass {
|
|
|
31849
32031
|
}
|
|
31850
32032
|
}, delay);
|
|
31851
32033
|
}
|
|
32034
|
+
/**
|
|
32035
|
+
* Validates if the auth state supports LID system (lid-mapping and device-index keys)
|
|
32036
|
+
* Required for Baileys v7.0.0+ LID system
|
|
32037
|
+
* @param state The authentication state from useMultiFileAuthState
|
|
32038
|
+
*/
|
|
32039
|
+
validateLIDSupport(state) {
|
|
32040
|
+
try {
|
|
32041
|
+
const hasLidMapping = state.keys && typeof state.keys === 'object';
|
|
32042
|
+
const hasDeviceIndex = state.creds && typeof state.creds === 'object';
|
|
32043
|
+
if (!hasLidMapping) {
|
|
32044
|
+
this.logger.log(`[${new Date().toISOString()}] WARNING: Auth state may not support lid-mapping`);
|
|
32045
|
+
}
|
|
32046
|
+
if (!hasDeviceIndex) {
|
|
32047
|
+
this.logger.log(`[${new Date().toISOString()}] WARNING: Auth state may not support device-index`);
|
|
32048
|
+
}
|
|
32049
|
+
// Log auth state structure for debugging (without sensitive data)
|
|
32050
|
+
this.logger.log(`[${new Date().toISOString()}] Auth state keys available:`, Object.keys(state));
|
|
32051
|
+
if (state.keys) {
|
|
32052
|
+
this.logger.log(`[${new Date().toISOString()}] Signal keys structure available: ${typeof state.keys}`);
|
|
32053
|
+
}
|
|
32054
|
+
if (state.creds) {
|
|
32055
|
+
this.logger.log(`[${new Date().toISOString()}] Credentials structure available: ${typeof state.creds}`);
|
|
32056
|
+
}
|
|
32057
|
+
}
|
|
32058
|
+
catch (error) {
|
|
32059
|
+
this.logger.log(`[${new Date().toISOString()}] Error validating LID support:`, error);
|
|
32060
|
+
}
|
|
32061
|
+
}
|
|
32062
|
+
/**
|
|
32063
|
+
* Checks if the auth state has LID system support
|
|
32064
|
+
* @param state The authentication state
|
|
32065
|
+
* @returns boolean indicating LID support
|
|
32066
|
+
*/
|
|
32067
|
+
hasLIDSupport(state) {
|
|
32068
|
+
try {
|
|
32069
|
+
// Check for the presence of keys and creds which should support LID mapping
|
|
32070
|
+
const hasKeys = state.keys && typeof state.keys === 'object';
|
|
32071
|
+
const hasCreds = state.creds && typeof state.creds === 'object';
|
|
32072
|
+
return hasKeys && hasCreds;
|
|
32073
|
+
}
|
|
32074
|
+
catch (error) {
|
|
32075
|
+
this.logger.log(`[${new Date().toISOString()}] Error checking LID support:`, error);
|
|
32076
|
+
return false;
|
|
32077
|
+
}
|
|
32078
|
+
}
|
|
32079
|
+
/**
|
|
32080
|
+
* Gets the LID mapping store from the socket
|
|
32081
|
+
* @returns The LID mapping store or null if not available
|
|
32082
|
+
*/
|
|
32083
|
+
getLIDMappingStore() {
|
|
32084
|
+
try {
|
|
32085
|
+
if (this.vendor && this.vendor.signalRepository && this.vendor.signalRepository.lidMapping) {
|
|
32086
|
+
return this.vendor.signalRepository.lidMapping;
|
|
32087
|
+
}
|
|
32088
|
+
return null;
|
|
32089
|
+
}
|
|
32090
|
+
catch (error) {
|
|
32091
|
+
this.logger.log(`[${new Date().toISOString()}] Error accessing LID mapping store:`, error);
|
|
32092
|
+
return null;
|
|
32093
|
+
}
|
|
32094
|
+
}
|
|
32095
|
+
/**
|
|
32096
|
+
* Public method to get LID from PN using the internal store
|
|
32097
|
+
* @param phoneNumber Phone number to get LID for
|
|
32098
|
+
* @returns Promise<string | null> LID or null if not found
|
|
32099
|
+
*/
|
|
32100
|
+
async getLIDFromPN(phoneNumber) {
|
|
32101
|
+
const lidStore = this.getLIDMappingStore();
|
|
32102
|
+
if (!lidStore) {
|
|
32103
|
+
this.logger.log(`[${new Date().toISOString()}] LID store not available for getLIDFromPN`);
|
|
32104
|
+
return null;
|
|
32105
|
+
}
|
|
32106
|
+
try {
|
|
32107
|
+
const lid = await lidStore.getLIDForPN(phoneNumber);
|
|
32108
|
+
return lid || null;
|
|
32109
|
+
}
|
|
32110
|
+
catch (error) {
|
|
32111
|
+
this.logger.log(`[${new Date().toISOString()}] Error getting LID from PN ${phoneNumber}:`, error);
|
|
32112
|
+
return null;
|
|
32113
|
+
}
|
|
32114
|
+
}
|
|
32115
|
+
/**
|
|
32116
|
+
* Public method to get PN from LID using the internal store
|
|
32117
|
+
* @param lid LID to get phone number for
|
|
32118
|
+
* @returns Promise<string | null> Phone number or null if not found
|
|
32119
|
+
*/
|
|
32120
|
+
async getPNFromLID(lid) {
|
|
32121
|
+
const lidStore = this.getLIDMappingStore();
|
|
32122
|
+
if (!lidStore) {
|
|
32123
|
+
this.logger.log(`[${new Date().toISOString()}] LID store not available for getPNFromLID`);
|
|
32124
|
+
return null;
|
|
32125
|
+
}
|
|
32126
|
+
try {
|
|
32127
|
+
const phoneNumber = await lidStore.getPNForLID(lid);
|
|
32128
|
+
return phoneNumber || null;
|
|
32129
|
+
}
|
|
32130
|
+
catch (error) {
|
|
32131
|
+
this.logger.log(`[${new Date().toISOString()}] Error getting PN from LID ${lid}:`, error);
|
|
32132
|
+
return null;
|
|
32133
|
+
}
|
|
32134
|
+
}
|
|
32135
|
+
/**
|
|
32136
|
+
* Public method to store a LID-PN mapping
|
|
32137
|
+
* @param lid Local Identifier
|
|
32138
|
+
* @param phoneNumber Phone Number
|
|
32139
|
+
* @returns Promise<boolean> Success status
|
|
32140
|
+
*/
|
|
32141
|
+
async storeLIDPNMapping(lid, phoneNumber) {
|
|
32142
|
+
const lidStore = this.getLIDMappingStore();
|
|
32143
|
+
if (!lidStore) {
|
|
32144
|
+
this.logger.log(`[${new Date().toISOString()}] LID store not available for storeLIDPNMapping`);
|
|
32145
|
+
return false;
|
|
32146
|
+
}
|
|
32147
|
+
try {
|
|
32148
|
+
await baileyStoreLIDPNMapping(lidStore, lid, phoneNumber);
|
|
32149
|
+
this.logger.log(`[${new Date().toISOString()}] Successfully stored LID mapping: ${lid} <-> ${phoneNumber}`);
|
|
32150
|
+
return true;
|
|
32151
|
+
}
|
|
32152
|
+
catch (error) {
|
|
32153
|
+
this.logger.log(`[${new Date().toISOString()}] Error storing LID mapping ${lid}<->${phoneNumber}:`, error);
|
|
32154
|
+
return false;
|
|
32155
|
+
}
|
|
32156
|
+
}
|
|
31852
32157
|
}
|
|
31853
32158
|
|
|
31854
32159
|
export { BaileysProvider, baileyCleanNumber, baileyCleanNumberWithLid };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
declare const emptyDirSessions: (pathBase: string) => Promise<unknown>;
|
|
2
2
|
/**
|
|
3
|
-
* Cleans
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
3
|
+
* Cleans and extracts the appropriate identifier from MessageKey, supporting LID system.
|
|
4
|
+
* Uses remoteJidAlt/participantAlt when available according to Baileys v7.0.0+ specs.
|
|
5
|
+
* @param key The MessageKey object from Baileys with LID support
|
|
6
|
+
* @returns The appropriate identifier (PN or LID)
|
|
6
7
|
*/
|
|
7
8
|
declare function baileyCleanNumberWithLid(key: {
|
|
8
9
|
senderPn?: string;
|
|
9
10
|
remoteJid?: string;
|
|
11
|
+
remoteJidAlt?: string;
|
|
12
|
+
participantAlt?: string;
|
|
13
|
+
participant?: string;
|
|
10
14
|
}): string;
|
|
11
15
|
/**
|
|
12
|
-
* Cleans the WhatsApp number format.
|
|
13
|
-
* @param number The WhatsApp number to be cleaned.
|
|
16
|
+
* Cleans the WhatsApp number format, supporting both LIDs and PNs.
|
|
17
|
+
* @param number The WhatsApp number/LID to be cleaned.
|
|
14
18
|
* @param full Whether to return the full number format or not.
|
|
15
|
-
* @returns The cleaned number.
|
|
19
|
+
* @returns The cleaned number or LID.
|
|
16
20
|
*/
|
|
17
21
|
declare const baileyCleanNumber: (number: string, full?: boolean) => string;
|
|
18
22
|
/**
|
|
@@ -22,10 +26,59 @@ declare const baileyCleanNumber: (number: string, full?: boolean) => string;
|
|
|
22
26
|
*/
|
|
23
27
|
declare const baileyGenerateImage: (base64: string, name?: string) => Promise<void>;
|
|
24
28
|
/**
|
|
25
|
-
* Validates if the given
|
|
26
|
-
*
|
|
27
|
-
* @
|
|
29
|
+
* Validates if the given identifier is a valid WhatsApp user identifier (PN or LID) and not a group ID.
|
|
30
|
+
* Compatible with Baileys v7.0.0+ LID system.
|
|
31
|
+
* @param rawIdentifier The identifier to validate (PN, LID, or other)
|
|
32
|
+
* @returns True if it's a valid user identifier, false otherwise
|
|
28
33
|
*/
|
|
29
|
-
declare const baileyIsValidNumber: (
|
|
30
|
-
|
|
34
|
+
declare const baileyIsValidNumber: (rawIdentifier: string) => boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Gets the LID (Local Identifier) for a given PN (Phone Number).
|
|
37
|
+
* @param lidStore The LID mapping store from sock.signalRepository.lidMapping
|
|
38
|
+
* @param phoneNumber The phone number to get LID for
|
|
39
|
+
* @returns The LID if found, null otherwise
|
|
40
|
+
*/
|
|
41
|
+
declare const baileyGetLIDFromPN: (lidStore: any, phoneNumber: string) => Promise<string | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Gets the PN (Phone Number) for a given LID (Local Identifier).
|
|
44
|
+
* @param lidStore The LID mapping store from sock.signalRepository.lidMapping
|
|
45
|
+
* @param lid The LID to get phone number for
|
|
46
|
+
* @returns The phone number if found, null otherwise
|
|
47
|
+
*/
|
|
48
|
+
declare const baileyGetPNFromLID: (lidStore: any, lid: string) => Promise<string | null>;
|
|
49
|
+
/**
|
|
50
|
+
* Gets multiple LIDs for given PNs (Phone Numbers).
|
|
51
|
+
* @param lidStore The LID mapping store from sock.signalRepository.lidMapping
|
|
52
|
+
* @param phoneNumbers Array of phone numbers to get LIDs for
|
|
53
|
+
* @returns Object mapping phone numbers to their LIDs
|
|
54
|
+
*/
|
|
55
|
+
declare const baileyGetLIDsFromPNs: (lidStore: any, phoneNumbers: string[]) => Promise<Record<string, string>>;
|
|
56
|
+
/**
|
|
57
|
+
* Stores a single LID-PN mapping in the store.
|
|
58
|
+
* @param lidStore The LID mapping store from sock.signalRepository.lidMapping
|
|
59
|
+
* @param lid The Local Identifier
|
|
60
|
+
* @param phoneNumber The Phone Number
|
|
61
|
+
* @returns Promise<void>
|
|
62
|
+
*/
|
|
63
|
+
declare const baileyStoreLIDPNMapping: (lidStore: any, lid: string, phoneNumber: string) => Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Stores multiple LID-PN mappings in the store.
|
|
66
|
+
* @param lidStore The LID mapping store from sock.signalRepository.lidMapping
|
|
67
|
+
* @param mappings Object with LID-PN mappings
|
|
68
|
+
* @returns Promise<void>
|
|
69
|
+
*/
|
|
70
|
+
declare const baileyStoreLIDPNMappings: (lidStore: any, mappings: Record<string, string>) => Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Determines if a JID is a LID (Local Identifier).
|
|
73
|
+
* @param jid The JID to check
|
|
74
|
+
* @returns True if it's a LID, false otherwise
|
|
75
|
+
*/
|
|
76
|
+
declare const baileyIsLID: (jid: string) => boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Determines if a JID is a PN (Phone Number).
|
|
79
|
+
* @param jid The JID to check
|
|
80
|
+
* @returns True if it's a PN, false otherwise
|
|
81
|
+
*/
|
|
82
|
+
declare const baileyIsPN: (jid: string) => boolean;
|
|
83
|
+
export { baileyCleanNumber, baileyGenerateImage, baileyIsValidNumber, emptyDirSessions, baileyCleanNumberWithLid, baileyGetLIDFromPN, baileyGetPNFromLID, baileyGetLIDsFromPNs, baileyStoreLIDPNMapping, baileyStoreLIDPNMappings, baileyIsLID, baileyIsPN };
|
|
31
84
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,gBAAgB,GAAU,UAAU,MAAM,qBAM1C,CAAA;AAEN
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,gBAAg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C,KAAG,OAAO,CAAC,IAAI,CAUrG,CAAA;AAED;;;;GAIG;AACH,QAAA,MAAM,WAAW,GAAI,KAAK,MAAM,KAAG,OAElC,CAAA;AAED;;;;GAIG;AACH,QAAA,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,OAEjC,CAAA;AAED,OAAO,EACH,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,WAAW,EACX,UAAU,EACb,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builderbot/provider-baileys",
|
|
3
|
-
"version": "1.3.5-alpha.
|
|
3
|
+
"version": "1.3.5-alpha.7",
|
|
4
4
|
"description": "Now I'm the model of a modern major general / The venerated Virginian veteran whose men are all / Lining up, to put me up on a pedestal / Writin' letters to relatives / Embellishin' my elegance and eloquence / But the elephant is in the room / The truth is in ya face when ya hear the British cannons go / BOOM",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Leifer Mendez <leifer33@gmail.com>",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"@adiwajshing/keyed-db": "^0.2.4",
|
|
70
70
|
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
|
71
71
|
"@types/polka": "^0.5.7",
|
|
72
|
-
"baileys": "
|
|
72
|
+
"baileys": "7.0.0-rc.5",
|
|
73
73
|
"cheerio": "^1.1.2",
|
|
74
74
|
"fluent-ffmpeg": "^2.1.2",
|
|
75
75
|
"fs-extra": "^11.2.0",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"node-cache": "^5.1.2",
|
|
78
78
|
"sharp": "0.33.3"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "cb069d5c88102d204b4e60cfcb5403a5fa152c11"
|
|
81
81
|
}
|