@elrayyxml/baileys 1.0.1 → 1.1.1-rc.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/README.MD +11 -2
- package/WAProto/index.d.ts +55057 -0
- package/lib/Defaults/index.js +6 -8
- package/lib/Socket/chats.js +0 -19
- package/lib/Socket/messages-recv.js +3 -91
- package/lib/Socket/messages-send.js +2 -2
- package/lib/Utils/generics.js +1 -1
- package/package.json +10 -3
- package/WAProto/GenerateStatics.sh +0 -4
- package/lib/Utils/browser-utils.js +0 -35
package/lib/Defaults/index.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.DEFAULT_CACHE_TTLS = exports.INITIAL_PREKEY_COUNT = exports.MIN_PREKEY_COUNT = exports.MEDIA_KEYS = exports.MEDIA_HKDF_KEY_MAPPING = exports.MEDIA_PATH_MAP = exports.DEFAULT_CONNECTION_CONFIG = exports.PROCESSABLE_HISTORY_TYPES = exports.WA_CERT_DETAILS = exports.URL_REGEX = exports.NOISE_WA_HEADER = exports.KEY_BUNDLE_TYPE = exports.DICT_VERSION = exports.NOISE_MODE = exports.WA_DEFAULT_EPHEMERAL = exports.PHONE_CONNECTION_CB = exports.DEF_TAG_PREFIX = exports.DEF_CALLBACK_PREFIX = exports.DEFAULT_ORIGIN = exports.UNAUTHORIZED_CODES = void 0;
|
|
7
7
|
const WAProto_1 = require("../../WAProto");
|
|
8
8
|
const libsignal_1 = require("../Signal/libsignal");
|
|
9
|
-
const
|
|
9
|
+
const Utils_1 = require("../Utils");
|
|
10
10
|
const logger_1 = __importDefault(require("../Utils/logger"));
|
|
11
11
|
const baileys_version_json_1 = require("./baileys-version.json");
|
|
12
12
|
exports.UNAUTHORIZED_CODES = [401, 403, 419];
|
|
@@ -33,14 +33,14 @@ exports.PROCESSABLE_HISTORY_TYPES = [
|
|
|
33
33
|
];
|
|
34
34
|
exports.DEFAULT_CONNECTION_CONFIG = {
|
|
35
35
|
version: baileys_version_json_1.version,
|
|
36
|
-
browser:
|
|
36
|
+
browser: Utils_1.Browsers.ubuntu('Chrome'),
|
|
37
37
|
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
|
38
|
-
connectTimeoutMs:
|
|
39
|
-
keepAliveIntervalMs:
|
|
38
|
+
connectTimeoutMs: 20000,
|
|
39
|
+
keepAliveIntervalMs: 30000,
|
|
40
40
|
logger: logger_1.default.child({ class: 'baileys' }),
|
|
41
41
|
printQRInTerminal: false,
|
|
42
42
|
emitOwnEvents: true,
|
|
43
|
-
defaultQueryTimeoutMs:
|
|
43
|
+
defaultQueryTimeoutMs: 60000,
|
|
44
44
|
customUploadHosts: [],
|
|
45
45
|
retryRequestDelayMs: 250,
|
|
46
46
|
maxMsgRetryCount: 5,
|
|
@@ -54,8 +54,6 @@ exports.DEFAULT_CONNECTION_CONFIG = {
|
|
|
54
54
|
linkPreviewImageThumbnailWidth: 192,
|
|
55
55
|
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
|
|
56
56
|
generateHighQualityLinkPreview: false,
|
|
57
|
-
enableAutoSessionRecreation: true,
|
|
58
|
-
enableRecentMessageCache: true,
|
|
59
57
|
options: {},
|
|
60
58
|
appStateMacVerification: {
|
|
61
59
|
patch: false,
|
|
@@ -99,7 +97,7 @@ exports.MEDIA_HKDF_KEY_MAPPING = {
|
|
|
99
97
|
};
|
|
100
98
|
exports.MEDIA_KEYS = Object.keys(exports.MEDIA_PATH_MAP);
|
|
101
99
|
exports.MIN_PREKEY_COUNT = 5;
|
|
102
|
-
exports.INITIAL_PREKEY_COUNT =
|
|
100
|
+
exports.INITIAL_PREKEY_COUNT = 30;
|
|
103
101
|
exports.DEFAULT_CACHE_TTLS = {
|
|
104
102
|
SIGNAL_STORE: 5 * 60, // 5 minutes
|
|
105
103
|
MSG_RETRY: 60 * 60, // 1 hour
|
package/lib/Socket/chats.js
CHANGED
|
@@ -479,24 +479,6 @@ const makeChatsSocket = (config) => {
|
|
|
479
479
|
const child = (0, WABinary_1.getBinaryNodeChild)(result, 'picture');
|
|
480
480
|
return (_a = child === null || child === void 0 ? void 0 : child.attrs) === null || _a === void 0 ? void 0 : _a.url;
|
|
481
481
|
};
|
|
482
|
-
const createCallLink = async (type, event, timeoutMs) => {
|
|
483
|
-
const result = await query({
|
|
484
|
-
tag: 'call',
|
|
485
|
-
attrs: {
|
|
486
|
-
id: generateMessageTag(),
|
|
487
|
-
to: '@call'
|
|
488
|
-
},
|
|
489
|
-
content: [
|
|
490
|
-
{
|
|
491
|
-
tag: 'link_create',
|
|
492
|
-
attrs: { media: type },
|
|
493
|
-
content: event ? [{ tag: 'event', attrs: { start_time: String(event.startTime) } }] : undefined
|
|
494
|
-
}
|
|
495
|
-
]
|
|
496
|
-
}, timeoutMs);
|
|
497
|
-
const child = (0, WABinary_1.getBinaryNodeChild)(result, 'link_create');
|
|
498
|
-
return child?.attrs?.token;
|
|
499
|
-
};
|
|
500
482
|
const sendPresenceUpdate = async (type, toJid) => {
|
|
501
483
|
const me = authState.creds.me;
|
|
502
484
|
if (type === 'available' || type === 'unavailable') {
|
|
@@ -849,7 +831,6 @@ const makeChatsSocket = (config) => {
|
|
|
849
831
|
});
|
|
850
832
|
return {
|
|
851
833
|
...sock,
|
|
852
|
-
createCallLink,
|
|
853
834
|
getBotListV2,
|
|
854
835
|
processingMutex,
|
|
855
836
|
fetchPrivacySettings,
|
|
@@ -34,91 +34,6 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
34
34
|
useClones: false
|
|
35
35
|
}));
|
|
36
36
|
let sendActiveReceipts = false;
|
|
37
|
-
|
|
38
|
-
// ======================== LID MAPPING ========================
|
|
39
|
-
signalRepository.lidMapping = {
|
|
40
|
-
cacheLidToPn: new Map(),
|
|
41
|
-
cachePnToLid: new Map(),
|
|
42
|
-
|
|
43
|
-
getPNForLID: async function(lid) {
|
|
44
|
-
if (!lid) return lid;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (lid.includes('@s.whatsapp.net')) {
|
|
48
|
-
return lid;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (this.cacheLidToPn.has(lid)) {
|
|
53
|
-
return this.cacheLidToPn.get(lid);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
try {
|
|
57
|
-
|
|
58
|
-
return lid;
|
|
59
|
-
} catch (error) {
|
|
60
|
-
logger.debug({ lid, error }, 'Failed to get PN for LID');
|
|
61
|
-
return lid;
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
getLIDForPN: async function(pn) {
|
|
66
|
-
if (!pn) return pn;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (pn.includes('@lid')) {
|
|
70
|
-
return pn;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (this.cachePnToLid.has(pn)) {
|
|
75
|
-
return this.cachePnToLid.get(pn);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
try {
|
|
79
|
-
|
|
80
|
-
return pn;
|
|
81
|
-
} catch (error) {
|
|
82
|
-
logger.debug({ pn, error }, 'Failed to get LID for PN');
|
|
83
|
-
return pn;
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
_captureMappingFromMessage: async function(msg, node) {
|
|
89
|
-
try {
|
|
90
|
-
|
|
91
|
-
if (msg.key.participant && msg.key.participant.includes('@lid') && node.attrs.participant_pn) {
|
|
92
|
-
const lid = msg.key.participant;
|
|
93
|
-
const jid = node.attrs.participant_pn;
|
|
94
|
-
this.cacheLidToPn.set(lid, jid);
|
|
95
|
-
this.cachePnToLid.set(jid, lid);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if ((0, WABinary_1.isJidGroup)(msg.key.remoteJid) &&
|
|
100
|
-
msg.message?.extendedTextMessage?.contextInfo?.participant &&
|
|
101
|
-
msg.message.extendedTextMessage.contextInfo.participant.includes('@lid')) {
|
|
102
|
-
|
|
103
|
-
try {
|
|
104
|
-
const senderLid = msg.message.extendedTextMessage.contextInfo.participant;
|
|
105
|
-
const metadata = await groupMetadata(msg.key.remoteJid);
|
|
106
|
-
const found = metadata.participants.find(p => p.id === senderLid);
|
|
107
|
-
|
|
108
|
-
if (found?.jid) {
|
|
109
|
-
this.cacheLidToPn.set(senderLid, found.jid);
|
|
110
|
-
this.cachePnToLid.set(found.jid, senderLid);
|
|
111
|
-
}
|
|
112
|
-
} catch (error) {
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
} catch (error) {
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
// === END ===
|
|
121
|
-
|
|
122
37
|
const sendMessageAck = async ({ tag, attrs, content }, errorCode) => {
|
|
123
38
|
const stanza = {
|
|
124
39
|
tag: 'ack',
|
|
@@ -359,7 +274,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
359
274
|
case 'leave':
|
|
360
275
|
const stubType = `GROUP_PARTICIPANT_${child.tag.toUpperCase()}`;
|
|
361
276
|
msg.messageStubType = Types_1.WAMessageStubType[stubType];
|
|
362
|
-
const participants = (0, WABinary_1.getBinaryNodeChildren)(child, 'participant').map(p => p.attrs.
|
|
277
|
+
const participants = (0, WABinary_1.getBinaryNodeChildren)(child, 'participant').map(p => p.attrs.phone_number);
|
|
363
278
|
if (participants.length === 1 &&
|
|
364
279
|
// if recv. "remove" message and sender removed themselves
|
|
365
280
|
// mark as left
|
|
@@ -858,10 +773,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
858
773
|
else {
|
|
859
774
|
// no type in the receipt => message delivered
|
|
860
775
|
let type = undefined;
|
|
861
|
-
|
|
862
|
-
await signalRepository.lidMapping._captureMappingFromMessage(msg, node);
|
|
863
|
-
// === MODIFIKASI KONVERSI LID KE JID ===
|
|
864
|
-
/* if ((_b = msg.key.participant) === null || _b === void 0 ? void 0 : _b.endsWith('@lid')) {
|
|
776
|
+
if ((_b = msg.key.participant) === null || _b === void 0 ? void 0 : _b.endsWith('@lid')) {
|
|
865
777
|
msg.key.participant = node.attrs.participant_pn || authState.creds.me.id;
|
|
866
778
|
}
|
|
867
779
|
if ((0, WABinary_1.isJidGroup)(msg.key.remoteJid) && ((_f = (_e = (_d = (_c = msg.message) === null || _c === void 0 ? void 0 : _c.extendedTextMessage) === null || _d === void 0 ? void 0 : _d.contextInfo) === null || _e === void 0 ? void 0 : _e.participant) === null || _f === void 0 ? void 0 : _f.endsWith('@lid'))) {
|
|
@@ -871,7 +783,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
871
783
|
const found = metadata.participants.find(p => p.id === sender);
|
|
872
784
|
msg.message.extendedTextMessage.contextInfo.participant = (found === null || found === void 0 ? void 0 : found.jid) || sender;
|
|
873
785
|
}
|
|
874
|
-
}
|
|
786
|
+
}
|
|
875
787
|
if (!(0, WABinary_1.isJidGroup)(msg.key.remoteJid) && (0, WABinary_1.isLidUser)(msg.key.remoteJid)) {
|
|
876
788
|
msg.key.remoteJid = node.attrs.sender_pn || node.attrs.peer_recipient_pn;
|
|
877
789
|
}
|
|
@@ -744,7 +744,7 @@ const makeMessagesSocket = (config) => {
|
|
|
744
744
|
const productContent = await elrayy.handleProduct(content, jid, quoted);
|
|
745
745
|
const productMsg = await (0, Utils_1.generateWAMessageFromContent)(jid, productContent, { quoted });
|
|
746
746
|
return await relayMessage(jid, productMsg.message, {
|
|
747
|
-
messageId:
|
|
747
|
+
messageId: productMsg.key.id,
|
|
748
748
|
...getParticipantAttr()
|
|
749
749
|
});
|
|
750
750
|
|
|
@@ -752,7 +752,7 @@ const makeMessagesSocket = (config) => {
|
|
|
752
752
|
const interactiveContent = await elrayy.handleInteractive(content, jid, quoted);
|
|
753
753
|
const interactiveMsg = await (0, Utils_1.generateWAMessageFromContent)(jid, interactiveContent, { quoted });
|
|
754
754
|
return await relayMessage(jid, interactiveMsg.message, {
|
|
755
|
-
messageId:
|
|
755
|
+
messageId: interactiveMsg.key.id,
|
|
756
756
|
...getParticipantAttr()
|
|
757
757
|
});
|
|
758
758
|
|
package/lib/Utils/generics.js
CHANGED
|
@@ -263,7 +263,7 @@ exports.printQRIfNecessaryListener = printQRIfNecessaryListener;
|
|
|
263
263
|
* Use to ensure your WA connection is always on the latest version
|
|
264
264
|
*/
|
|
265
265
|
const fetchLatestBaileysVersion = async (options = {}) => {
|
|
266
|
-
const URL = 'https://raw.githubusercontent.com/
|
|
266
|
+
const URL = 'https://raw.githubusercontent.com/ElrayyXml/Baileys/refs/heads/main/lib/Defaults/baileys-version.json';
|
|
267
267
|
try {
|
|
268
268
|
const result = await axios_1.default.get(URL, {
|
|
269
269
|
...options,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elrayyxml/baileys",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1-rc.6",
|
|
4
4
|
"description": "Baileys Modified ElrayyXml",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"baileys",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"multi-device"
|
|
21
21
|
],
|
|
22
22
|
"homepage": "https://www.npmjs.com/package/@elrayyxml/baileys",
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
"repository": {
|
|
24
|
+
"url": "https://www.npmjs.com/package/@elrayyxml/baileys"
|
|
25
25
|
},
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"author": "ElrayyXml",
|
|
@@ -124,3 +124,10 @@
|
|
|
124
124
|
"lib": "lib"
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
yarn pbjs -t static-module -w commonjs -o ./WAProto/index.js ./WAProto/WAProto.proto;
|
|
2
|
-
yarn pbts -o ./WAProto/index.d.ts ./WAProto/index.js;
|
|
3
|
-
|
|
4
|
-
#protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_opt=env=node,useOptionals=true,forceLong=long --ts_proto_out=. ./src/Binary/WAMessage.proto;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPlatformId = exports.Browsers = void 0;
|
|
4
|
-
|
|
5
|
-
const os = require("os");
|
|
6
|
-
const { proto } = require("../../WAProto/index.js");
|
|
7
|
-
|
|
8
|
-
const PLATFORM_MAP = {
|
|
9
|
-
'aix': 'AIX',
|
|
10
|
-
'darwin': 'Mac OS',
|
|
11
|
-
'win32': 'Windows',
|
|
12
|
-
'android': 'Android',
|
|
13
|
-
'freebsd': 'FreeBSD',
|
|
14
|
-
'openbsd': 'OpenBSD',
|
|
15
|
-
'sunos': 'Solaris',
|
|
16
|
-
'linux': undefined, // Default ke Ubuntu untuk Linux
|
|
17
|
-
'haiku': undefined,
|
|
18
|
-
'cygwin': undefined,
|
|
19
|
-
'netbsd': undefined
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
// Fixed: Browsers sekarang fungsi yang return array [platform, browser, version]
|
|
23
|
-
// Ini kompatibel dengan pemanggilan Browsers('Chrome') di Defaults/index.js
|
|
24
|
-
exports.Browsers = (browser) => {
|
|
25
|
-
const osName = PLATFORM_MAP[os.platform()] || 'Ubuntu'; // Default Ubuntu kalau undefined
|
|
26
|
-
const osRelease = os.release(); // Ambil versi OS real-time
|
|
27
|
-
return [osName, browser, osRelease];
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const getPlatformId = (browser) => {
|
|
31
|
-
const platformType = proto.DeviceProps.PlatformType[browser.toUpperCase()];
|
|
32
|
-
return platformType ? platformType.toString() : '1'; // Default Chrome
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
exports.getPlatformId = getPlatformId;
|