@langitdeveloper/baileys 2.0.8 → 2.0.9
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/WAProto/index.js +131281 -59270
- package/lib/Defaults/baileys-version.json +3 -1
- package/lib/Defaults/index.js +6 -6
- package/lib/Function/Download/tiktok.js +19 -0
- package/lib/Function/Tools/bypass.js +19 -0
- package/lib/Function/index.js +13 -0
- package/lib/Signal/libsignal.js +0 -15
- package/lib/Socket/chats.js +48 -16
- package/lib/Socket/dugong.js +165 -12
- package/lib/Socket/groups.js +0 -1
- package/lib/Socket/messages-send.js +576 -1213
- package/lib/Socket/newsletter.js +212 -99
- package/lib/Socket/socket.js +1 -1
- package/lib/Types/Message.js +0 -1
- package/lib/Types/index.js +0 -2
- package/lib/Utils/generics.js +79 -10
- package/lib/Utils/index.js +0 -4
- package/lib/Utils/messages.js +4 -93
- package/lib/WABinary/generic-utils.js +0 -12
- package/lib/WABinary/jid-utils.js +0 -7
- package/lib/WAUSync/Protocols/index.js +0 -2
- package/lib/index.js +10 -12
- package/package.json +5 -5
- package/lib/Defaults/index.d.ts +0 -53
- package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
- package/lib/Signal/Group/group-session-builder.d.ts +0 -14
- package/lib/Signal/Group/group_cipher.d.ts +0 -17
- package/lib/Signal/Group/index.d.ts +0 -11
- package/lib/Signal/Group/keyhelper.d.ts +0 -10
- package/lib/Signal/Group/queue-job.d.ts +0 -1
- package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
- package/lib/Signal/Group/sender-key-message.d.ts +0 -18
- package/lib/Signal/Group/sender-key-name.d.ts +0 -17
- package/lib/Signal/Group/sender-key-record.d.ts +0 -30
- package/lib/Signal/Group/sender-key-state.d.ts +0 -38
- package/lib/Signal/Group/sender-message-key.d.ts +0 -11
- package/lib/Signal/libsignal.d.ts +0 -3
- package/lib/Signal/lid-mapping.js +0 -164
- package/lib/Socket/Client/abstract-socket-client.d.ts +0 -17
- package/lib/Socket/Client/index.d.ts +0 -3
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/types.js +0 -12
- package/lib/Socket/Client/web-socket-client.d.ts +0 -12
- package/lib/Socket/Client/websocket.js +0 -67
- package/lib/Socket/business.d.ts +0 -171
- package/lib/Socket/chats.d.ts +0 -267
- package/lib/Socket/community.js +0 -454
- package/lib/Socket/dugong.d.ts +0 -254
- package/lib/Socket/groups.d.ts +0 -115
- package/lib/Socket/index.d.ts +0 -173
- package/lib/Socket/messages-recv.d.ts +0 -161
- package/lib/Socket/messages-send.d.ts +0 -149
- package/lib/Socket/mex.js +0 -54
- package/lib/Socket/newsletter.d.ts +0 -134
- package/lib/Socket/registration.d.ts +0 -267
- package/lib/Socket/socket.d.ts +0 -43
- package/lib/Socket/usync.d.ts +0 -36
- package/lib/Store/index.d.ts +0 -3
- package/lib/Store/make-cache-manager-store.d.ts +0 -13
- package/lib/Store/make-in-memory-store.d.ts +0 -118
- package/lib/Store/make-ordered-dictionary.d.ts +0 -13
- package/lib/Store/object-repository.d.ts +0 -10
- package/lib/Types/Auth.d.ts +0 -110
- package/lib/Types/Bussines.js +0 -2
- package/lib/Types/Call.d.ts +0 -13
- package/lib/Types/Chat.d.ts +0 -102
- package/lib/Types/Contact.d.ts +0 -19
- package/lib/Types/Events.d.ts +0 -157
- package/lib/Types/GroupMetadata.d.ts +0 -55
- package/lib/Types/Label.d.ts +0 -35
- package/lib/Types/LabelAssociation.d.ts +0 -29
- package/lib/Types/Message.d.ts +0 -273
- package/lib/Types/MexUpdates.js +0 -15
- package/lib/Types/Newsletter.d.ts +0 -103
- package/lib/Types/Product.d.ts +0 -78
- package/lib/Types/Signal.d.ts +0 -57
- package/lib/Types/Socket.d.ts +0 -111
- package/lib/Types/State.d.ts +0 -27
- package/lib/Types/USync.d.ts +0 -25
- package/lib/Types/index.d.ts +0 -57
- package/lib/Utils/auth-utils.d.ts +0 -18
- package/lib/Utils/baileys-event-stream.d.ts +0 -16
- package/lib/Utils/browser-utils.js +0 -29
- package/lib/Utils/business.d.ts +0 -22
- package/lib/Utils/chat-utils.d.ts +0 -71
- package/lib/Utils/crypto.d.ts +0 -41
- package/lib/Utils/decode-wa-message.d.ts +0 -19
- package/lib/Utils/event-buffer.d.ts +0 -35
- package/lib/Utils/generics.d.ts +0 -92
- package/lib/Utils/history.d.ts +0 -15
- package/lib/Utils/index.d.ts +0 -17
- package/lib/Utils/link-preview.d.ts +0 -21
- package/lib/Utils/logger.d.ts +0 -4
- package/lib/Utils/lt-hash.d.ts +0 -12
- package/lib/Utils/make-mutex.d.ts +0 -7
- package/lib/Utils/message-retry-manager.js +0 -134
- package/lib/Utils/messages-media.d.ts +0 -116
- package/lib/Utils/messages.d.ts +0 -77
- package/lib/Utils/noise-handler.d.ts +0 -21
- package/lib/Utils/pre-key-manager.js +0 -86
- package/lib/Utils/process-message.d.ts +0 -41
- package/lib/Utils/signal.d.ts +0 -32
- package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
- package/lib/Utils/validate-connection.d.ts +0 -11
- package/lib/Utils/vialeys-event-stream.js +0 -41
- package/lib/WABinary/constants.d.ts +0 -30
- package/lib/WABinary/decode.d.ts +0 -7
- package/lib/WABinary/encode.d.ts +0 -3
- package/lib/WABinary/generic-utils.d.ts +0 -17
- package/lib/WABinary/index.d.ts +0 -5
- package/lib/WABinary/jid-utils.d.ts +0 -31
- package/lib/WABinary/types.d.ts +0 -18
- package/lib/WAM/BinaryInfo.d.ts +0 -17
- package/lib/WAM/constants.d.ts +0 -38
- package/lib/WAM/encode.d.ts +0 -3
- package/lib/WAM/index.d.ts +0 -3
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +0 -62
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +0 -24
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
- package/lib/WAUSync/Protocols/index.d.ts +0 -4
- package/lib/WAUSync/USyncQuery.d.ts +0 -28
- package/lib/WAUSync/USyncUser.d.ts +0 -12
- package/lib/WAUSync/index.d.ts +0 -3
- package/lib/index.d.ts +0 -12
package/lib/Utils/messages.js
CHANGED
|
@@ -81,38 +81,6 @@ const prepareWAMessageMedia = async (message, options) => {
|
|
|
81
81
|
|
|
82
82
|
const uploadData = {
|
|
83
83
|
...message,
|
|
84
|
-
...(message.annotations ? {
|
|
85
|
-
annotations: message.annotations
|
|
86
|
-
} : {
|
|
87
|
-
annotations: [
|
|
88
|
-
{
|
|
89
|
-
polygonVertices: [
|
|
90
|
-
{
|
|
91
|
-
x: 60.71664810180664,
|
|
92
|
-
y: -36.39784622192383
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
x: -16.710189819335938,
|
|
96
|
-
y: 49.263675689697266
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
x: -56.585853576660156,
|
|
100
|
-
y: 37.85963439941406
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
x: 20.840980529785156,
|
|
104
|
-
y: -47.80188751220703
|
|
105
|
-
}
|
|
106
|
-
],
|
|
107
|
-
newsletter: {
|
|
108
|
-
newsletterJid: "120363418090359162@newsletter",
|
|
109
|
-
serverMessageId: 0,
|
|
110
|
-
newsletterName: "RiljiX7",
|
|
111
|
-
contentType: "UPDATE",
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
]
|
|
115
|
-
}),
|
|
116
84
|
media: message[mediaType]
|
|
117
85
|
};
|
|
118
86
|
delete uploadData[mediaType];
|
|
@@ -565,66 +533,6 @@ const generateWAMessage = async (jid, content, options) => {
|
|
|
565
533
|
return (0, exports.generateWAMessageFromContent)(jid, await (0, exports.generateWAMessageContent)(content, { newsletter: (0, WABinary_1.isJidNewsLetter)(jid), ...options }), options);
|
|
566
534
|
};
|
|
567
535
|
exports.generateWAMessage = generateWAMessage;
|
|
568
|
-
const prepareAlbumMessageContent = async (jid, albums, options) => {
|
|
569
|
-
if (!Array.isArray(albums)) {
|
|
570
|
-
throw new Error("albums must be an array containing media objects.");
|
|
571
|
-
}
|
|
572
|
-
if (albums.length === 0) {
|
|
573
|
-
throw new Error("albums cannot be empty. At least one media item is required.");
|
|
574
|
-
}
|
|
575
|
-
const validCount = albums.filter((m) => 'image' in m || 'video' in m).length;
|
|
576
|
-
if (validCount === 0) {
|
|
577
|
-
throw new Error("albums contains no valid media. Use 'image' or 'video' keys.");
|
|
578
|
-
}
|
|
579
|
-
let mediaHandle;
|
|
580
|
-
let mediaMsg;
|
|
581
|
-
const message = [];
|
|
582
|
-
const albumMsg = generateWAMessageFromContent(jid, {
|
|
583
|
-
albumMessage: {
|
|
584
|
-
expectedImageCount: albums.filter((item) => 'image' in item).length,
|
|
585
|
-
expectedVideoCount: albums.filter((item) => 'video' in item).length,
|
|
586
|
-
},
|
|
587
|
-
}, options);
|
|
588
|
-
await options.conn.relayMessage(jid, albumMsg.message, {
|
|
589
|
-
messageId: albumMsg.key.id,
|
|
590
|
-
});
|
|
591
|
-
for (const media of albums) {
|
|
592
|
-
let content = {};
|
|
593
|
-
if ('image' in media) {
|
|
594
|
-
content = { image: media.image };
|
|
595
|
-
}
|
|
596
|
-
else if ('video' in media) {
|
|
597
|
-
content = { video: media.video };
|
|
598
|
-
}
|
|
599
|
-
else {
|
|
600
|
-
continue;
|
|
601
|
-
}
|
|
602
|
-
mediaMsg = await generateWAMessage(jid, { ...content, ...media }, {
|
|
603
|
-
userJid: options.userJid,
|
|
604
|
-
upload: async (encFilePath, opts) => {
|
|
605
|
-
const up = await options.conn.waUploadToServer(encFilePath, {
|
|
606
|
-
...opts,
|
|
607
|
-
newsletter: (0, WABinary_1.isJidNewsLetter)(jid),
|
|
608
|
-
});
|
|
609
|
-
mediaHandle = up.handle;
|
|
610
|
-
return up;
|
|
611
|
-
},
|
|
612
|
-
...options,
|
|
613
|
-
});
|
|
614
|
-
if (mediaMsg) {
|
|
615
|
-
mediaMsg.message.messageContextInfo = {
|
|
616
|
-
messageSecret: crypto_1.randomBytes(32),
|
|
617
|
-
messageAssociation: {
|
|
618
|
-
associationType: WAProto_1.proto.MessageAssociation.AssociationType.MEDIA_ALBUM,
|
|
619
|
-
parentMessageKey: albumMsg.key,
|
|
620
|
-
},
|
|
621
|
-
};
|
|
622
|
-
}
|
|
623
|
-
message.push(mediaMsg);
|
|
624
|
-
}
|
|
625
|
-
return message;
|
|
626
|
-
};
|
|
627
|
-
exports.prepareAlbumMessageContent = prepareAlbumMessageContent;
|
|
628
536
|
/** Get the key to access the true type of content */
|
|
629
537
|
const getContentType = (content) => {
|
|
630
538
|
if (content) {
|
|
@@ -869,7 +777,10 @@ const assertMediaContent = (content) => {
|
|
|
869
777
|
|| (content === null || content === void 0 ? void 0 : content.audioMessage)
|
|
870
778
|
|| (content === null || content === void 0 ? void 0 : content.stickerMessage);
|
|
871
779
|
if (!mediaContent) {
|
|
872
|
-
throw new boom_1.Boom('given message is not a media message', {
|
|
780
|
+
throw new boom_1.Boom('given message is not a media message', {
|
|
781
|
+
statusCode: 400,
|
|
782
|
+
data: content
|
|
783
|
+
});
|
|
873
784
|
}
|
|
874
785
|
return mediaContent;
|
|
875
786
|
};
|
|
@@ -196,15 +196,3 @@ const getAdditionalNode = (name) => {
|
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
exports.getAdditionalNode = getAdditionalNode;
|
|
199
|
-
const getBinaryFilteredButtons = (nodeContent) => {
|
|
200
|
-
if (!Array.isArray(nodeContent)) return false;
|
|
201
|
-
return nodeContent.some((a) => ['native_flow'].includes(a?.content?.[0]?.content?.[0]?.tag) ||
|
|
202
|
-
['interactive', 'buttons', 'list'].includes(a?.content?.[0]?.tag) ||
|
|
203
|
-
['hsm', 'biz'].includes(a?.tag));
|
|
204
|
-
};
|
|
205
|
-
exports.getBinaryFilteredButtons = getBinaryFilteredButtons;
|
|
206
|
-
const getBinaryFilteredBizBot = (nodeContent) => {
|
|
207
|
-
if (!Array.isArray(nodeContent)) return false;
|
|
208
|
-
return nodeContent.some((b) => ['bot'].includes(b?.tag) && b?.attrs?.biz_bot === '1');
|
|
209
|
-
};
|
|
210
|
-
exports.getBinaryFilteredBizBot = getBinaryFilteredBizBot;
|
|
@@ -60,10 +60,3 @@ const jidNormalizedUser = (jid) => {
|
|
|
60
60
|
return (0, exports.jidEncode)(user, server === 'c.us' ? 's.whatsapp.net' : server);
|
|
61
61
|
};
|
|
62
62
|
exports.jidNormalizedUser = jidNormalizedUser;
|
|
63
|
-
exports.WAJIDDomains = { WHATSAPP: 0, LID: 1, HOSTED: 128, HOSTED_LID: 129 };
|
|
64
|
-
exports.isPnUser = isJidUser;
|
|
65
|
-
exports.isJidNewsletter = isJidNewsLetter;
|
|
66
|
-
const isHostedPnUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@hosted'));
|
|
67
|
-
exports.isHostedPnUser = isHostedPnUser;
|
|
68
|
-
const isHostedLidUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@hosted.lid'));
|
|
69
|
-
exports.isHostedLidUser = isHostedLidUser;
|
|
@@ -18,5 +18,3 @@ __exportStar(require("./USyncDeviceProtocol"), exports);
|
|
|
18
18
|
__exportStar(require("./USyncContactProtocol"), exports);
|
|
19
19
|
__exportStar(require("./USyncStatusProtocol"), exports);
|
|
20
20
|
__exportStar(require("./USyncDisappearingModeProtocol"), exports);
|
|
21
|
-
__exportStar(require("./USyncBotProfileProtocol"), exports);
|
|
22
|
-
__exportStar(require("./USyncLIDProtocol"), exports);
|
package/lib/index.js
CHANGED
|
@@ -2,19 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
const chalk = require("chalk");
|
|
4
4
|
|
|
5
|
-
console.log(chalk.cyan("Thanks For Using My Baileys @
|
|
5
|
+
console.log(chalk.cyan("Thanks For Using My Baileys @Langit-Official"))
|
|
6
6
|
console.log(chalk.green(`
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
⠀⡀⠤⠀⠄⠀⠀⠀⢃⠘⡻⣿⣿⣿⣿⣿⣿⠿⠀⠃⠀⠀⠀⢀⠠⢄⠠⠀
|
|
17
|
-
⢀⠄⣐⢄⡂⡀⢀⠀⡠⢐⡢⣙⢋⠀⡀⢙⠏⣐⢄⡀⡀⢀⠀⡢⢐⠢⣐⢀`));
|
|
7
|
+
⣿⣿⣿⣿⣿⣷⣿⣿⣿⡅⡹⢿⠆⠙⠋⠉⠻⠿⣿⣿⣿⣿⣿⣿⣮⠻⣦⡙⢷⡑⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣌⠡⠌⠂⣙⠻⣛⠻⠷⠐⠈⠛⢱⣮⣷⣽⣿
|
|
8
|
+
⣿⣿⣿⣿⡇⢿⢹⣿⣶⠐⠁⠀⣀⣠⣤⠄⠀⠀⠈⠙⠻⣿⣿⣿⣦⣵⣌⠻⣷⢝⠦⠚⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢟⣻⣿⣊⡃⠀⣙⠿⣿⣿⣿⣎⢮⡀⢮⣽⣿⣿
|
|
9
|
+
⢿⣿⣿⣿⣧⡸⡎⡛⡩⠖⠀⣴⣿⣿⣿⠀⠀⠀⠀⠸⠇⠀⠙⢿⣿⣿⣿⣷⣌⢷⣑⢷⣄⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣫⠶⠛⠉⠀⠁⠀⠈⠈⠀⠠⠜⠻⣿⣆⢿⣼⣿⣿⣿
|
|
10
|
+
⢐⣿⣿⣿⣿⣧⢧⣧⢻⣦⢀⣹⣿⣿⣿⣇⠀⠄⠀⠀⠀⡀⠀⠈⢻⣿⣿⣿⣿⣷⣝⢦⡹⠷⡙⢿⣿⣿⣿⣿⣿⣿⣿⣿⠈⠁⠀⠀⠀⠁⠀⠀⠀⠱⣶⣄⡀⠀⠈⠛⠜⣿⣿⣿⣿
|
|
11
|
+
⠀⠊⢫⣿⣏⣿⡌⣼⣄⢫⡌⣿⣿⣿⣿⣿⣦⡈⠲⣄⣤⣤⡡⢀⣠⣿⣿⣿⣿⣿⣿⣷⣼⣍⢬⣦⡙⣿⣿⣿⣿⣿⣯⢁⡄⠀⡀⡀⠀⠄⢈⣠⢪⠀⣿⣿⣿⣦⠀⢉⢂⠹⡿⣿⣿
|
|
12
|
+
⠀⠀⠄⢹⢃⢻⣟⠙⣿⣦⠱⢻⣿⣿⣿⣿⣿⣿⣷⣬⣍⣭⣥⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⡙⢿⣼⡿⣿⣿⣿⣿⣿⣷⣄⠘⣱⢦⣤⡴⡿⢈⣼⣿⣿⣿⣇⣴⣶⣮⣅⢻⣿⡏
|
|
13
|
+
⠀⠀⠈⠹⣇⢡⢿⡆⠻⣿⣷⠀⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣍⡻⣿⣟⣻⣿⣿⣿⣿⣷⣦⣥⣬⣤⣴⣾⣿⣿⣿⣿⣷⣿⣿⣿⣿⣷⡜⠃
|
|
14
|
+
⠀⠀⠀⢀⣘⠈⢂⠃⣧⡹⣿⣷⡄⠙⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣮⣅⡙⢿⣟⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠋⡕⠂
|
|
15
|
+
⠀⠀⠀⠀⠀⠀⠛⢷⣜⢷⡌⠻⣿⣿⣦⣝⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⣹⣷⣦⣹⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠉⠃⠀⠉`));
|
|
18
16
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
19
17
|
if (k2 === undefined) k2 = k;
|
|
20
18
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langitdeveloper/baileys",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.9",
|
|
4
4
|
"description": "WhatsApp API Modification By Langit",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"whatsapp",
|
|
7
|
-
"
|
|
7
|
+
"langit"
|
|
8
8
|
],
|
|
9
|
-
"homepage": "https://github.com/langitdeveloper-official/
|
|
9
|
+
"homepage": "https://github.com/langitdeveloper-official/mahiru-baileys",
|
|
10
10
|
"repository": {
|
|
11
|
-
"url": "https://github.com/langitdeveloper-official/
|
|
11
|
+
"url": "https://github.com/langitdeveloper-official/mahiru-baileys"
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"author": "Adhiraj Singh",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"json": "^11.0.0"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
|
-
"jimp": "^
|
|
83
|
+
"jimp": "^1.6.1",
|
|
84
84
|
"link-preview-js": "^3.0.0",
|
|
85
85
|
"qrcode-terminal": "^0.12.0",
|
|
86
86
|
"sharp": "^0.32.2"
|
package/lib/Defaults/index.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { proto } from '../../WAProto';
|
|
4
|
-
import type { MediaType, SocketConfig } from '../Types';
|
|
5
|
-
export declare const UNAUTHORIZED_CODES: number[];
|
|
6
|
-
export declare const DEFAULT_ORIGIN = "https://web.whatsapp.com";
|
|
7
|
-
export declare const DEF_CALLBACK_PREFIX = "CB:";
|
|
8
|
-
export declare const DEF_TAG_PREFIX = "TAG:";
|
|
9
|
-
export declare const PHONE_CONNECTION_CB = "CB:Pong";
|
|
10
|
-
export declare const WA_DEFAULT_EPHEMERAL: number;
|
|
11
|
-
export declare const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
|
|
12
|
-
export declare const DICT_VERSION = 2;
|
|
13
|
-
export declare const KEY_BUNDLE_TYPE: Buffer;
|
|
14
|
-
export declare const NOISE_WA_HEADER: Buffer;
|
|
15
|
-
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
16
|
-
export declare const URL_REGEX: RegExp;
|
|
17
|
-
export declare const WA_CERT_DETAILS: {
|
|
18
|
-
SERIAL: number;
|
|
19
|
-
};
|
|
20
|
-
export declare const PROCESSABLE_HISTORY_TYPES: proto.Message.HistorySyncNotification.HistorySyncType[];
|
|
21
|
-
export declare const DEFAULT_CONNECTION_CONFIG: SocketConfig;
|
|
22
|
-
export declare const MEDIA_PATH_MAP: {
|
|
23
|
-
[T in MediaType]?: string;
|
|
24
|
-
};
|
|
25
|
-
export declare const MEDIA_HKDF_KEY_MAPPING: {
|
|
26
|
-
audio: string;
|
|
27
|
-
document: string;
|
|
28
|
-
gif: string;
|
|
29
|
-
image: string;
|
|
30
|
-
ppic: string;
|
|
31
|
-
product: string;
|
|
32
|
-
ptt: string;
|
|
33
|
-
sticker: string;
|
|
34
|
-
video: string;
|
|
35
|
-
'thumbnail-document': string;
|
|
36
|
-
'thumbnail-image': string;
|
|
37
|
-
'thumbnail-video': string;
|
|
38
|
-
'thumbnail-link': string;
|
|
39
|
-
'md-msg-hist': string;
|
|
40
|
-
'md-app-state': string;
|
|
41
|
-
'product-catalog-image': string;
|
|
42
|
-
'payment-bg-image': string;
|
|
43
|
-
ptv: string;
|
|
44
|
-
};
|
|
45
|
-
export declare const MEDIA_KEYS: ("ppic" | "product" | "image" | "video" | "sticker" | "audio" | "gif" | "ptt" | "thumbnail-document" | "thumbnail-image" | "thumbnail-link" | "thumbnail-video" | "md-app-state" | "md-msg-hist" | "document" | "product-catalog-image" | "payment-bg-image" | "ptv")[];
|
|
46
|
-
export declare const MIN_PREKEY_COUNT = 5;
|
|
47
|
-
export declare const INITIAL_PREKEY_COUNT = 30;
|
|
48
|
-
export declare const DEFAULT_CACHE_TTLS: {
|
|
49
|
-
SIGNAL_STORE: number;
|
|
50
|
-
MSG_RETRY: number;
|
|
51
|
-
CALL_OFFER: number;
|
|
52
|
-
USER_DEVICES: number;
|
|
53
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare class CiphertextMessage {
|
|
2
|
-
readonly UNSUPPORTED_VERSION: number;
|
|
3
|
-
readonly CURRENT_VERSION: number;
|
|
4
|
-
readonly WHISPER_TYPE: number;
|
|
5
|
-
readonly PREKEY_TYPE: number;
|
|
6
|
-
readonly SENDERKEY_TYPE: number;
|
|
7
|
-
readonly SENDERKEY_DISTRIBUTION_TYPE: number;
|
|
8
|
-
readonly ENCRYPTED_MESSAGE_OVERHEAD: number;
|
|
9
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { SenderKeyDistributionMessage } from './sender-key-distribution-message';
|
|
2
|
-
import { SenderKeyName } from './sender-key-name';
|
|
3
|
-
import { SenderKeyRecord } from './sender-key-record';
|
|
4
|
-
interface SenderKeyStore {
|
|
5
|
-
loadSenderKey(senderKeyName: SenderKeyName): Promise<SenderKeyRecord>;
|
|
6
|
-
storeSenderKey(senderKeyName: SenderKeyName, record: SenderKeyRecord): Promise<void>;
|
|
7
|
-
}
|
|
8
|
-
export declare class GroupSessionBuilder {
|
|
9
|
-
private readonly senderKeyStore;
|
|
10
|
-
constructor(senderKeyStore: SenderKeyStore);
|
|
11
|
-
process(senderKeyName: SenderKeyName, senderKeyDistributionMessage: SenderKeyDistributionMessage): Promise<void>;
|
|
12
|
-
create(senderKeyName: SenderKeyName): Promise<SenderKeyDistributionMessage>;
|
|
13
|
-
}
|
|
14
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { SenderKeyName } from './sender-key-name';
|
|
2
|
-
import { SenderKeyRecord } from './sender-key-record';
|
|
3
|
-
export interface SenderKeyStore {
|
|
4
|
-
loadSenderKey(senderKeyName: SenderKeyName): Promise<SenderKeyRecord>;
|
|
5
|
-
storeSenderKey(senderKeyName: SenderKeyName, record: SenderKeyRecord): Promise<void>;
|
|
6
|
-
}
|
|
7
|
-
export declare class GroupCipher {
|
|
8
|
-
private readonly senderKeyStore;
|
|
9
|
-
private readonly senderKeyName;
|
|
10
|
-
constructor(senderKeyStore: SenderKeyStore, senderKeyName: SenderKeyName);
|
|
11
|
-
private queueJob;
|
|
12
|
-
encrypt(paddedPlaintext: Uint8Array | string): Promise<Uint8Array>;
|
|
13
|
-
decrypt(senderKeyMessageBytes: Uint8Array): Promise<Uint8Array>;
|
|
14
|
-
private getSenderKey;
|
|
15
|
-
private getPlainText;
|
|
16
|
-
private getCipherText;
|
|
17
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { GroupSessionBuilder } from './group-session-builder';
|
|
2
|
-
export { SenderKeyDistributionMessage } from './sender-key-distribution-message';
|
|
3
|
-
export { SenderKeyRecord } from './sender-key-record';
|
|
4
|
-
export { SenderKeyName } from './sender-key-name';
|
|
5
|
-
export { GroupCipher } from './group_cipher';
|
|
6
|
-
export { SenderKeyState } from './sender-key-state';
|
|
7
|
-
export { SenderKeyMessage } from './sender-key-message';
|
|
8
|
-
export { SenderMessageKey } from './sender-message-key';
|
|
9
|
-
export { SenderChainKey } from './sender-chain-key';
|
|
10
|
-
export { CiphertextMessage } from './ciphertext-message';
|
|
11
|
-
export * as keyhelper from './keyhelper';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { generateKeyPair } from 'libsignal/src/curve';
|
|
2
|
-
type KeyPairType = ReturnType<typeof generateKeyPair>;
|
|
3
|
-
export declare function generateSenderKey(): Buffer;
|
|
4
|
-
export declare function generateSenderKeyId(): number;
|
|
5
|
-
export interface SigningKeyPair {
|
|
6
|
-
public: Buffer;
|
|
7
|
-
private: Buffer;
|
|
8
|
-
}
|
|
9
|
-
export declare function generateSenderSigningKey(key?: KeyPairType): SigningKeyPair;
|
|
10
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function queueJob<T>(bucket: string | number, awaitable: () => Promise<T>): Promise<T>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { SenderMessageKey } from './sender-message-key';
|
|
2
|
-
export declare class SenderChainKey {
|
|
3
|
-
private readonly MESSAGE_KEY_SEED;
|
|
4
|
-
private readonly CHAIN_KEY_SEED;
|
|
5
|
-
private readonly iteration;
|
|
6
|
-
private readonly chainKey;
|
|
7
|
-
constructor(iteration: number, chainKey: any);
|
|
8
|
-
getIteration(): number;
|
|
9
|
-
getSenderMessageKey(): SenderMessageKey;
|
|
10
|
-
getNext(): SenderChainKey;
|
|
11
|
-
getSeed(): Uint8Array;
|
|
12
|
-
private getDerivative;
|
|
13
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { CiphertextMessage } from './ciphertext-message';
|
|
2
|
-
export declare class SenderKeyDistributionMessage extends CiphertextMessage {
|
|
3
|
-
private readonly id;
|
|
4
|
-
private readonly iteration;
|
|
5
|
-
private readonly chainKey;
|
|
6
|
-
private readonly signatureKey;
|
|
7
|
-
private readonly serialized;
|
|
8
|
-
constructor(id?: number | null, iteration?: number | null, chainKey?: Uint8Array | null, signatureKey?: Uint8Array | null, serialized?: Uint8Array | null);
|
|
9
|
-
private intsToByteHighAndLow;
|
|
10
|
-
serialize(): Uint8Array;
|
|
11
|
-
getType(): number;
|
|
12
|
-
getIteration(): number;
|
|
13
|
-
getChainKey(): Uint8Array;
|
|
14
|
-
getSignatureKey(): Uint8Array;
|
|
15
|
-
getId(): number;
|
|
16
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { CiphertextMessage } from './ciphertext-message';
|
|
2
|
-
export declare class SenderKeyMessage extends CiphertextMessage {
|
|
3
|
-
private readonly SIGNATURE_LENGTH;
|
|
4
|
-
private readonly messageVersion;
|
|
5
|
-
private readonly keyId;
|
|
6
|
-
private readonly iteration;
|
|
7
|
-
private readonly ciphertext;
|
|
8
|
-
private readonly signature;
|
|
9
|
-
private readonly serialized;
|
|
10
|
-
constructor(keyId?: number | null, iteration?: number | null, ciphertext?: Uint8Array | null, signatureKey?: Uint8Array | null, serialized?: Uint8Array | null);
|
|
11
|
-
getKeyId(): number;
|
|
12
|
-
getIteration(): number;
|
|
13
|
-
getCipherText(): Uint8Array;
|
|
14
|
-
verifySignature(signatureKey: Uint8Array): void;
|
|
15
|
-
private getSignature;
|
|
16
|
-
serialize(): Uint8Array;
|
|
17
|
-
getType(): number;
|
|
18
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
interface Sender {
|
|
2
|
-
id: string;
|
|
3
|
-
deviceId: number;
|
|
4
|
-
toString(): string;
|
|
5
|
-
}
|
|
6
|
-
export declare class SenderKeyName {
|
|
7
|
-
private readonly groupId;
|
|
8
|
-
private readonly sender;
|
|
9
|
-
constructor(groupId: string, sender: Sender);
|
|
10
|
-
getGroupId(): string;
|
|
11
|
-
getSender(): Sender;
|
|
12
|
-
serialize(): string;
|
|
13
|
-
toString(): string;
|
|
14
|
-
equals(other: SenderKeyName | null): boolean;
|
|
15
|
-
hashCode(): number;
|
|
16
|
-
}
|
|
17
|
-
export {};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { SenderKeyState } from './sender-key-state';
|
|
2
|
-
export interface SenderKeyStateStructure {
|
|
3
|
-
senderKeyId: number;
|
|
4
|
-
senderChainKey: {
|
|
5
|
-
iteration: number;
|
|
6
|
-
seed: Uint8Array;
|
|
7
|
-
};
|
|
8
|
-
senderSigningKey: {
|
|
9
|
-
public: Uint8Array;
|
|
10
|
-
private?: Uint8Array;
|
|
11
|
-
};
|
|
12
|
-
senderMessageKeys: Array<{
|
|
13
|
-
iteration: number;
|
|
14
|
-
seed: Uint8Array;
|
|
15
|
-
}>;
|
|
16
|
-
}
|
|
17
|
-
export declare class SenderKeyRecord {
|
|
18
|
-
private readonly MAX_STATES;
|
|
19
|
-
private readonly senderKeyStates;
|
|
20
|
-
constructor(serialized?: SenderKeyStateStructure[]);
|
|
21
|
-
isEmpty(): boolean;
|
|
22
|
-
getSenderKeyState(keyId?: number): SenderKeyState | undefined;
|
|
23
|
-
addSenderKeyState(id: number, iteration: number, chainKey: Uint8Array, signatureKey: Uint8Array): void;
|
|
24
|
-
setSenderKeyState(id: number, iteration: number, chainKey: Uint8Array, keyPair: {
|
|
25
|
-
public: Uint8Array;
|
|
26
|
-
private: Uint8Array;
|
|
27
|
-
}): void;
|
|
28
|
-
serialize(): SenderKeyStateStructure[];
|
|
29
|
-
static deserialize(data: Uint8Array | string | SenderKeyStateStructure[]): SenderKeyRecord;
|
|
30
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { SenderChainKey } from './sender-chain-key';
|
|
2
|
-
import { SenderMessageKey } from './sender-message-key';
|
|
3
|
-
interface SenderChainKeyStructure {
|
|
4
|
-
iteration: number;
|
|
5
|
-
seed: Uint8Array;
|
|
6
|
-
}
|
|
7
|
-
interface SenderSigningKeyStructure {
|
|
8
|
-
public: Uint8Array;
|
|
9
|
-
private?: Uint8Array;
|
|
10
|
-
}
|
|
11
|
-
interface SenderMessageKeyStructure {
|
|
12
|
-
iteration: number;
|
|
13
|
-
seed: Uint8Array;
|
|
14
|
-
}
|
|
15
|
-
interface SenderKeyStateStructure {
|
|
16
|
-
senderKeyId: number;
|
|
17
|
-
senderChainKey: SenderChainKeyStructure;
|
|
18
|
-
senderSigningKey: SenderSigningKeyStructure;
|
|
19
|
-
senderMessageKeys: SenderMessageKeyStructure[];
|
|
20
|
-
}
|
|
21
|
-
export declare class SenderKeyState {
|
|
22
|
-
private readonly MAX_MESSAGE_KEYS;
|
|
23
|
-
private readonly senderKeyStateStructure;
|
|
24
|
-
constructor(id?: number | null, iteration?: number | null, chainKey?: Uint8Array | null, signatureKeyPair?: {
|
|
25
|
-
public: Uint8Array;
|
|
26
|
-
private: Uint8Array;
|
|
27
|
-
} | null, signatureKeyPublic?: Uint8Array | null, signatureKeyPrivate?: Uint8Array | null, senderKeyStateStructure?: SenderKeyStateStructure | null);
|
|
28
|
-
getKeyId(): number;
|
|
29
|
-
getSenderChainKey(): SenderChainKey;
|
|
30
|
-
setSenderChainKey(chainKey: SenderChainKey): void;
|
|
31
|
-
getSigningKeyPublic(): Buffer;
|
|
32
|
-
getSigningKeyPrivate(): Buffer | undefined;
|
|
33
|
-
hasSenderMessageKey(iteration: number): boolean;
|
|
34
|
-
addSenderMessageKey(senderMessageKey: SenderMessageKey): void;
|
|
35
|
-
removeSenderMessageKey(iteration: number): SenderMessageKey | null;
|
|
36
|
-
getStructure(): SenderKeyStateStructure;
|
|
37
|
-
}
|
|
38
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare class SenderMessageKey {
|
|
2
|
-
private readonly iteration;
|
|
3
|
-
private readonly iv;
|
|
4
|
-
private readonly cipherKey;
|
|
5
|
-
private readonly seed;
|
|
6
|
-
constructor(iteration: number, seed: Uint8Array);
|
|
7
|
-
getIteration(): number;
|
|
8
|
-
getIv(): Uint8Array;
|
|
9
|
-
getCipherKey(): Uint8Array;
|
|
10
|
-
getSeed(): Uint8Array;
|
|
11
|
-
}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const { LRUCache: LRUCache } = require("lru-cache");
|
|
4
|
-
const {
|
|
5
|
-
isHostedPnUser: isHostedPnUser,
|
|
6
|
-
isLidUser: isLidUser,
|
|
7
|
-
isPnUser: isPnUser,
|
|
8
|
-
jidDecode: jidDecode,
|
|
9
|
-
jidNormalizedUser: jidNormalizedUser,
|
|
10
|
-
WAJIDDomains: WAJIDDomains,
|
|
11
|
-
} = require("../WABinary");
|
|
12
|
-
class LIDMappingStore {
|
|
13
|
-
constructor(keys, logger, pnToLIDFunc) {
|
|
14
|
-
this.mappingCache = new LRUCache({
|
|
15
|
-
ttl: 3 * 24 * 60 * 60 * 1e3,
|
|
16
|
-
ttlAutopurge: true,
|
|
17
|
-
updateAgeOnGet: true,
|
|
18
|
-
});
|
|
19
|
-
this.keys = keys;
|
|
20
|
-
this.pnToLIDFunc = pnToLIDFunc;
|
|
21
|
-
this.logger = logger;
|
|
22
|
-
}
|
|
23
|
-
async storeLIDPNMappings(pairs) {
|
|
24
|
-
const pairMap = {};
|
|
25
|
-
for (const { lid: lid, pn: pn } of pairs) {
|
|
26
|
-
if (!((isLidUser(lid) && isPnUser(pn)) || (isPnUser(lid) && isLidUser(pn)))) {
|
|
27
|
-
this.logger.warn(`Invalid LID-PN mapping: ${lid}, ${pn}`);
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
const lidDecoded = jidDecode(lid);
|
|
31
|
-
const pnDecoded = jidDecode(pn);
|
|
32
|
-
if (!lidDecoded || !pnDecoded) return;
|
|
33
|
-
const pnUser = pnDecoded.user;
|
|
34
|
-
const lidUser = lidDecoded.user;
|
|
35
|
-
let existingLidUser = this.mappingCache.get(`pn:${pnUser}`);
|
|
36
|
-
if (!existingLidUser) {
|
|
37
|
-
this.logger.trace(`Cache miss for PN user ${pnUser}; checking database`);
|
|
38
|
-
const stored = await this.keys.get("lid-mapping", [pnUser]);
|
|
39
|
-
existingLidUser = stored[pnUser];
|
|
40
|
-
if (existingLidUser) {
|
|
41
|
-
this.mappingCache.set(`pn:${pnUser}`, existingLidUser);
|
|
42
|
-
this.mappingCache.set(`lid:${existingLidUser}`, pnUser);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (existingLidUser === lidUser) {
|
|
46
|
-
this.logger.debug(
|
|
47
|
-
{ pnUser: pnUser, lidUser: lidUser },
|
|
48
|
-
"LID mapping already exists, skipping"
|
|
49
|
-
);
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
pairMap[pnUser] = lidUser;
|
|
53
|
-
}
|
|
54
|
-
this.logger.trace(
|
|
55
|
-
{ pairMap: pairMap },
|
|
56
|
-
`Storing ${Object.keys(pairMap).length} pn mappings`
|
|
57
|
-
);
|
|
58
|
-
await this.keys.transaction(async () => {
|
|
59
|
-
for (const [pnUser, lidUser] of Object.entries(pairMap)) {
|
|
60
|
-
await this.keys.set({
|
|
61
|
-
"lid-mapping": { [pnUser]: lidUser, [`${lidUser}_reverse`]: pnUser },
|
|
62
|
-
});
|
|
63
|
-
this.mappingCache.set(`pn:${pnUser}`, lidUser);
|
|
64
|
-
this.mappingCache.set(`lid:${lidUser}`, pnUser);
|
|
65
|
-
}
|
|
66
|
-
}, "lid-mapping");
|
|
67
|
-
}
|
|
68
|
-
async getLIDForPN(pn) {
|
|
69
|
-
return (await this.getLIDsForPNs([pn]))?.[0]?.lid || null;
|
|
70
|
-
}
|
|
71
|
-
async getLIDsForPNs(pns) {
|
|
72
|
-
const usyncFetch = {};
|
|
73
|
-
const successfulPairs = {};
|
|
74
|
-
for (const pn of pns) {
|
|
75
|
-
if (!isPnUser(pn) && !isHostedPnUser(pn)) continue;
|
|
76
|
-
const decoded = jidDecode(pn);
|
|
77
|
-
if (!decoded) continue;
|
|
78
|
-
const pnUser = decoded.user;
|
|
79
|
-
let lidUser = this.mappingCache.get(`pn:${pnUser}`);
|
|
80
|
-
if (!lidUser) {
|
|
81
|
-
const stored = await this.keys.get("lid-mapping", [pnUser]);
|
|
82
|
-
lidUser = stored[pnUser];
|
|
83
|
-
if (lidUser) {
|
|
84
|
-
this.mappingCache.set(`pn:${pnUser}`, lidUser);
|
|
85
|
-
this.mappingCache.set(`lid:${lidUser}`, pnUser);
|
|
86
|
-
} else {
|
|
87
|
-
this.logger.trace(
|
|
88
|
-
`No LID mapping found for PN user ${pnUser}; batch getting from USync`
|
|
89
|
-
);
|
|
90
|
-
const device = decoded.device || 0;
|
|
91
|
-
let normalizedPn = jidNormalizedUser(pn);
|
|
92
|
-
if (isHostedPnUser(normalizedPn)) {
|
|
93
|
-
normalizedPn = `${pnUser}@s.whatsapp.net`;
|
|
94
|
-
}
|
|
95
|
-
if (!usyncFetch[normalizedPn]) {
|
|
96
|
-
usyncFetch[normalizedPn] = [device];
|
|
97
|
-
} else {
|
|
98
|
-
usyncFetch[normalizedPn]?.push(device);
|
|
99
|
-
}
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
lidUser = lidUser.toString();
|
|
104
|
-
if (!lidUser) {
|
|
105
|
-
this.logger.warn(`Invalid or empty LID user for PN ${pn}: lidUser = "${lidUser}"`);
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
const pnDevice = decoded.device !== undefined ? decoded.device : 0;
|
|
109
|
-
const deviceSpecificLid = `${lidUser}${!!pnDevice ? `:${pnDevice}` : ``}@${decoded.server === "hosted" ? "hosted.lid" : "lid"}`;
|
|
110
|
-
this.logger.trace(
|
|
111
|
-
`getLIDForPN: ${pn} → ${deviceSpecificLid} (user mapping with device ${pnDevice})`
|
|
112
|
-
);
|
|
113
|
-
successfulPairs[pn] = { lid: deviceSpecificLid, pn: pn };
|
|
114
|
-
}
|
|
115
|
-
if (Object.keys(usyncFetch).length > 0) {
|
|
116
|
-
const result = await this.pnToLIDFunc?.(Object.keys(usyncFetch));
|
|
117
|
-
if (result && result.length > 0) {
|
|
118
|
-
await this.storeLIDPNMappings(result);
|
|
119
|
-
for (const pair of result) {
|
|
120
|
-
const pnDecoded = jidDecode(pair.pn);
|
|
121
|
-
const pnUser = pnDecoded?.user;
|
|
122
|
-
if (!pnUser) continue;
|
|
123
|
-
const lidUser = jidDecode(pair.lid)?.user;
|
|
124
|
-
if (!lidUser) continue;
|
|
125
|
-
for (const device of usyncFetch[pair.pn]) {
|
|
126
|
-
const deviceSpecificLid = `${lidUser}${!!device ? `:${device}` : ``}@${device === 99 ? "hosted.lid" : "lid"}`;
|
|
127
|
-
this.logger.trace(
|
|
128
|
-
`getLIDForPN: USYNC success for ${pair.pn} → ${deviceSpecificLid} (user mapping with device ${device})`
|
|
129
|
-
);
|
|
130
|
-
const deviceSpecificPn = `${pnUser}${!!device ? `:${device}` : ``}@${device === 99 ? "hosted" : "s.whatsapp.net"}`;
|
|
131
|
-
successfulPairs[deviceSpecificPn] = {
|
|
132
|
-
lid: deviceSpecificLid,
|
|
133
|
-
pn: deviceSpecificPn,
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
} else {
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return Object.values(successfulPairs);
|
|
142
|
-
}
|
|
143
|
-
async getPNForLID(lid) {
|
|
144
|
-
if (!isLidUser(lid)) return null;
|
|
145
|
-
const decoded = jidDecode(lid);
|
|
146
|
-
if (!decoded) return null;
|
|
147
|
-
const lidUser = decoded.user;
|
|
148
|
-
let pnUser = this.mappingCache.get(`lid:${lidUser}`);
|
|
149
|
-
if (!pnUser || typeof pnUser !== "string") {
|
|
150
|
-
const stored = await this.keys.get("lid-mapping", [`${lidUser}_reverse`]);
|
|
151
|
-
pnUser = stored[`${lidUser}_reverse`];
|
|
152
|
-
if (!pnUser || typeof pnUser !== "string") {
|
|
153
|
-
this.logger.trace(`No reverse mapping found for LID user: ${lidUser}`);
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
this.mappingCache.set(`lid:${lidUser}`, pnUser);
|
|
157
|
-
}
|
|
158
|
-
const lidDevice = decoded.device !== undefined ? decoded.device : 0;
|
|
159
|
-
const pnJid = `${pnUser}:${lidDevice}@${decoded.domainType === WAJIDDomains.HOSTED_LID ? "hosted" : "s.whatsapp.net"}`;
|
|
160
|
-
this.logger.trace(`Found reverse mapping: ${lid} → ${pnJid}`);
|
|
161
|
-
return pnJid;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
module.exports = { LIDMappingStore: LIDMappingStore };
|