mid-baileys 0.7.21 → 0.7.23
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/lib/Defaults/index.js +2 -2
- package/lib/Socket/chats.js +1 -1
- package/lib/Socket/messages-recv.js +1 -1
- package/lib/Socket/messages-send.js +8 -2
- package/lib/Utils/generics.js +31 -2
- package/lib/Utils/index.js +0 -1
- package/lib/Utils/messages.js +12 -12
- package/lib/Utils/validate-connection.js +11 -11
- package/package.json +2 -2
- 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.MIN_UPLOAD_INTERVAL = exports.UPLOAD_TIMEOUT = 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.WA_ADV_HOSTED_DEVICE_SIG_PREFIX = exports.WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = exports.WA_ADV_DEVICE_SIG_PREFIX = exports.WA_ADV_ACCOUNT_SIG_PREFIX = exports.UNAUTHORIZED_CODES = exports.version = void 0;
|
|
7
7
|
const WAProto_1 = require("../../WAProto");
|
|
8
8
|
const libsignal_1 = require("../Signal/libsignal");
|
|
9
|
-
const
|
|
9
|
+
const generics_1 = require("../Utils/generics");
|
|
10
10
|
const logger_1 = __importDefault(require("../Utils/logger"));
|
|
11
11
|
exports.version = [2, 3000, 1035194821];
|
|
12
12
|
exports.UNAUTHORIZED_CODES = [401, 403, 419];
|
|
@@ -40,7 +40,7 @@ exports.PROCESSABLE_HISTORY_TYPES = [
|
|
|
40
40
|
];
|
|
41
41
|
exports.DEFAULT_CONNECTION_CONFIG = {
|
|
42
42
|
version: exports.version,
|
|
43
|
-
browser: (0,
|
|
43
|
+
browser: (0, generics_1.Browsers)('Chrome'),
|
|
44
44
|
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
|
45
45
|
connectTimeoutMs: 20_000,
|
|
46
46
|
keepAliveIntervalMs: 30_000,
|
package/lib/Socket/chats.js
CHANGED
|
@@ -823,7 +823,7 @@ const makeChatsSocket = (config) => {
|
|
|
823
823
|
let jid = msg.key.fromMe ? authState.creds.me.id : (msg.key.participant || msg.key.remoteJid);
|
|
824
824
|
jid = (0, WABinary_1.jidNormalizedUser)(jid);
|
|
825
825
|
if (!msg.key.fromMe) {
|
|
826
|
-
|
|
826
|
+
// ev.emit('contacts.update', [{ id: jid, notify: msg.pushName, verifiedName: msg.verifiedBizName }]);
|
|
827
827
|
}
|
|
828
828
|
if (msg.key.fromMe && msg.pushName && ((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.name) !== msg.pushName) {
|
|
829
829
|
ev.emit('creds.update', { me: { ...authState.creds.me, name: msg.pushName } });
|
|
@@ -130,7 +130,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
130
130
|
}
|
|
131
131
|
await query(stanza)
|
|
132
132
|
}
|
|
133
|
-
|
|
133
|
+
const offerCall = async (toJid, isVideo = false) => {
|
|
134
134
|
const callId = (0, crypto_1.randomBytes)(16).toString('hex').toUpperCase().substring(0, 64);
|
|
135
135
|
const offerContent = [];
|
|
136
136
|
offerContent.push({ tag: 'audio', attrs: { enc: 'opus', rate: '16000' }, content: undefined });
|
|
@@ -731,6 +731,9 @@ const makeMessagesSocket = (config) => {
|
|
|
731
731
|
else if (message.stickerMessage) {
|
|
732
732
|
return 'sticker';
|
|
733
733
|
}
|
|
734
|
+
else if (message.stickerPackMessage) {
|
|
735
|
+
return 'sticker_pack'
|
|
736
|
+
}
|
|
734
737
|
else if (message.listMessage) {
|
|
735
738
|
return 'list';
|
|
736
739
|
}
|
|
@@ -752,6 +755,9 @@ const makeMessagesSocket = (config) => {
|
|
|
752
755
|
else if (message.groupInviteMessage || message.extendedTextMessage?.matchedText) {
|
|
753
756
|
return 'url';
|
|
754
757
|
}
|
|
758
|
+
else if (/https:\/\/wa\.me\/p\/\d+\/\d+/.test(message.extendedTextMessage?.text)) {
|
|
759
|
+
return 'productlink'
|
|
760
|
+
}
|
|
755
761
|
};
|
|
756
762
|
const getPrivacyTokens = async (jids) => {
|
|
757
763
|
const t = (0, Utils_1.unixTimestampSeconds)().toString();
|
|
@@ -1015,7 +1021,7 @@ if (typeof content === 'object' && content.audio && content.ptt) {
|
|
|
1015
1021
|
}
|
|
1016
1022
|
else if (isPollMsg) {
|
|
1017
1023
|
additionalNodes.push({
|
|
1018
|
-
tag:
|
|
1024
|
+
tag: 'meta',
|
|
1019
1025
|
attrs: {
|
|
1020
1026
|
polltype: isQuizMsg ? 'quiz_creation' : isPollResultMsg || isPollUpdateMsg ? 'vote' : 'creation',
|
|
1021
1027
|
contenttype: isPollMsg ? 'text' : undefined
|
|
@@ -1055,4 +1061,4 @@ if (typeof content === 'object' && content.audio && content.ptt) {
|
|
|
1055
1061
|
}
|
|
1056
1062
|
};
|
|
1057
1063
|
};
|
|
1058
|
-
exports.makeMessagesSocket = makeMessagesSocket;
|
|
1064
|
+
exports.makeMessagesSocket = makeMessagesSocket;
|
package/lib/Utils/generics.js
CHANGED
|
@@ -44,11 +44,27 @@ exports.bytesToCrockford = bytesToCrockford;
|
|
|
44
44
|
const boom_1 = require("@hapi/boom");
|
|
45
45
|
const axios_1 = __importDefault(require("axios"));
|
|
46
46
|
const crypto_1 = require("crypto");
|
|
47
|
-
const os_1 = require("os");
|
|
48
47
|
const WAProto_1 = require("../../WAProto");
|
|
49
48
|
const version_json_1 = require("../Defaults/version.json");
|
|
50
49
|
const Types_1 = require("../Types");
|
|
51
50
|
const WABinary_1 = require("../WABinary");
|
|
51
|
+
const os = require("os");
|
|
52
|
+
|
|
53
|
+
const PLATFORM_MAP = {
|
|
54
|
+
'aix': 'AIX',
|
|
55
|
+
'darwin': 'Mac OS',
|
|
56
|
+
'win32': 'Windows',
|
|
57
|
+
'android': 'Android',
|
|
58
|
+
'freebsd': 'FreeBSD',
|
|
59
|
+
'openbsd': 'OpenBSD',
|
|
60
|
+
'sunos': 'Solaris',
|
|
61
|
+
'linux': undefined, // Default ke Ubuntu untuk Linux
|
|
62
|
+
'haiku': undefined,
|
|
63
|
+
'cygwin': undefined,
|
|
64
|
+
'netbsd': undefined
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
|
|
52
68
|
const COMPANION_PLATFORM_MAP = {
|
|
53
69
|
'Chrome': '49',
|
|
54
70
|
'Edge': '50',
|
|
@@ -69,15 +85,28 @@ exports.Browsers = {
|
|
|
69
85
|
ubuntu: (browser) => ['Ubuntu', browser, '22.04.4'],
|
|
70
86
|
macOS: (browser) => ['Mac OS', browser, '14.4.1'],
|
|
71
87
|
baileys: (browser) => ['Baileys', browser, '6.5.0'],
|
|
88
|
+
android: (browser) => [browser, 'Android', '13.0.0'],
|
|
72
89
|
windows: (browser) => ['Windows', browser, '10.0.22631'],
|
|
73
90
|
/** The appropriate browser based on your OS & release */
|
|
74
|
-
appropriate: (browser) => [PLATFORM_MAP[(0,
|
|
91
|
+
appropriate: (browser) => [PLATFORM_MAP[(0, os.platform)()] || 'Ubuntu', browser, (0, os.release)()]
|
|
75
92
|
};
|
|
76
93
|
const getPlatformId = (browser) => {
|
|
77
94
|
const platformType = WAProto_1.proto.DeviceProps.PlatformType[browser.toUpperCase()];
|
|
78
95
|
return platformType ? platformType.toString() : '49'; //chrome
|
|
79
96
|
};
|
|
97
|
+
|
|
80
98
|
exports.getPlatformId = getPlatformId;
|
|
99
|
+
// FIXED: Cleaned up the double return syntax error
|
|
100
|
+
const getPlatformType = (platform) => {
|
|
101
|
+
const platformType = platform.toUpperCase();
|
|
102
|
+
// If your config browser has Android, return ANDROID_PHONE safely
|
|
103
|
+
if (platformType === 'ANDROID') {
|
|
104
|
+
return WAProto_1.proto.DeviceProps.PlatformType.ANDROID_PHONE;
|
|
105
|
+
}
|
|
106
|
+
return WAProto_1.proto.DeviceProps.PlatformType[platformType] || WAProto_1.proto.DeviceProps.PlatformType.CHROME;
|
|
107
|
+
};
|
|
108
|
+
exports.getPlatformType = getPlatformType;
|
|
109
|
+
|
|
81
110
|
exports.BufferJSON = {
|
|
82
111
|
replacer: (k, value) => {
|
|
83
112
|
if (Buffer.isBuffer(value) || value instanceof Uint8Array || (value === null || value === void 0 ? void 0 : value.type) === 'Buffer') {
|
package/lib/Utils/index.js
CHANGED
|
@@ -32,4 +32,3 @@ __exportStar(require("./link-preview"), exports);
|
|
|
32
32
|
__exportStar(require("./event-buffer"), exports);
|
|
33
33
|
__exportStar(require("./process-message"), exports);
|
|
34
34
|
__exportStar(require("./message-retry-manager"), exports);
|
|
35
|
-
__exportStar(require("./browser-utils"), exports);
|
package/lib/Utils/messages.js
CHANGED
|
@@ -583,25 +583,25 @@ if ('text' in message) {
|
|
|
583
583
|
else if ('requestPhoneNumber' in message) {
|
|
584
584
|
m.requestPhoneNumberMessage = {};
|
|
585
585
|
}
|
|
586
|
-
else if ('gcstory' in message) {
|
|
587
|
-
const
|
|
586
|
+
else if ('gcstory' in message || 'groupStory' in message) {
|
|
587
|
+
const story = message.gcstory || message.groupStory;
|
|
588
588
|
let content;
|
|
589
|
-
if (
|
|
589
|
+
if (story.text) {
|
|
590
590
|
content = {
|
|
591
591
|
extendedTextMessage: {
|
|
592
|
-
text:
|
|
593
|
-
backgroundArgb: toHex(
|
|
594
|
-
font:
|
|
592
|
+
text: story.text,
|
|
593
|
+
backgroundArgb: toHex(story.background) || 0xFF000000,
|
|
594
|
+
font: story.font || 4,
|
|
595
595
|
}
|
|
596
596
|
};
|
|
597
|
-
} else if (
|
|
598
|
-
const mediaType =
|
|
599
|
-
let mediaContent = { [mediaType]:
|
|
597
|
+
} else if (story.image || story.video || story.audio) {
|
|
598
|
+
const mediaType = story.image ? 'image' : (story.video ? 'video' : 'audio');
|
|
599
|
+
let mediaContent = { [mediaType]: story.image || story.video || story.audio };
|
|
600
600
|
let mediaOptions = { ...options };
|
|
601
|
-
if (
|
|
602
|
-
if (
|
|
601
|
+
if (story.caption) mediaContent.caption = story.caption;
|
|
602
|
+
if (story.audio) {
|
|
603
603
|
mediaContent.mimetype = 'audio/mpeg';
|
|
604
|
-
mediaContent.ptt =
|
|
604
|
+
mediaContent.ptt = story.ppt !== undefined ? !!story.ppt : true;
|
|
605
605
|
mediaOptions.backgroundColor = gcstory.background || '#000000';
|
|
606
606
|
}
|
|
607
607
|
const media = await (0, exports.prepareWAMessageMedia)(mediaContent, mediaOptions);
|
|
@@ -17,10 +17,13 @@ const getUserAgent = (config) => {
|
|
|
17
17
|
secondary: config.version[1],
|
|
18
18
|
tertiary: config.version[2],
|
|
19
19
|
},
|
|
20
|
-
|
|
20
|
+
// Using ANDROID or SMB_ANDROID consistently for mobile emulation
|
|
21
|
+
// For Wa Business: WAProto_1.proto.ClientPayload.UserAgent.Platform.SMB_ANDROID
|
|
22
|
+
platform: config.browser[0].toLocaleLowerCase().includes('13') ? WAProto_1.proto.ClientPayload.UserAgent.Platform.ANDROID : config.browser[0].toLocaleLowerCase().includes('14') ? WAProto_1.proto.ClientPayload.UserAgent.Platform.SMB_ANDROID :
|
|
23
|
+
WAProto_1.proto.ClientPayload.UserAgent.Platform.WEB,
|
|
21
24
|
releaseChannel: WAProto_1.proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
|
22
|
-
osVersion: '0.
|
|
23
|
-
device: '
|
|
25
|
+
osVersion: '13.0.0', // Dynamic or stable Android version
|
|
26
|
+
device: config.browser[0] || 'Android', // Match your browser config array
|
|
24
27
|
osBuildNumber: '0.1',
|
|
25
28
|
localeLanguageIso6391: 'en',
|
|
26
29
|
mnc: '000',
|
|
@@ -48,7 +51,9 @@ const getClientPayload = (config) => {
|
|
|
48
51
|
connectReason: WAProto_1.proto.ClientPayload.ConnectReason.USER_ACTIVATED,
|
|
49
52
|
userAgent: getUserAgent(config),
|
|
50
53
|
};
|
|
51
|
-
|
|
54
|
+
if (!config.browser[1].toLocaleLowerCase().includes('android')) {
|
|
55
|
+
payload.webInfo = getWebInfo(config)
|
|
56
|
+
}
|
|
52
57
|
return payload;
|
|
53
58
|
};
|
|
54
59
|
|
|
@@ -66,19 +71,14 @@ const generateLoginNode = (userJid, config) => {
|
|
|
66
71
|
};
|
|
67
72
|
exports.generateLoginNode = generateLoginNode;
|
|
68
73
|
|
|
69
|
-
const getPlatformType = (platform) => {
|
|
70
|
-
const platformType = platform.toUpperCase();
|
|
71
|
-
return WAProto_1.proto.DeviceProps.PlatformType[platformType] || WAProto_1.proto.DeviceProps.PlatformType.CHROME;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
74
|
const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentityKey }, config) => {
|
|
75
75
|
const appVersionBuf = (0, crypto_1.createHash)('md5')
|
|
76
76
|
.update(config.version.join('.'))
|
|
77
77
|
.digest();
|
|
78
78
|
|
|
79
79
|
const companion = {
|
|
80
|
-
os: config.browser[0],
|
|
81
|
-
platformType: getPlatformType(config.browser[1]),
|
|
80
|
+
os: config.browser[0] || 'Android',
|
|
81
|
+
platformType: (0, generics_1.getPlatformType)(config.browser[1]),
|
|
82
82
|
requireFullSync: config.syncFullHistory,
|
|
83
83
|
historySyncConfig: {
|
|
84
84
|
storageQuotaMb: 10240,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mid-baileys",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.23",
|
|
4
4
|
"description": "WhatsApp Web API Library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"midsoune",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"cache-manager": "^5.7.6",
|
|
48
48
|
"cheerio": "^1.0.0-rc.10",
|
|
49
49
|
"libphonenumber-js": "^1.10.20",
|
|
50
|
-
"libsignal": "
|
|
50
|
+
"libsignal": "github:NaufalYupra/libsignal-node",
|
|
51
51
|
"lodash": "^4.17.21",
|
|
52
52
|
"music-metadata": "^7.12.3",
|
|
53
53
|
"pino": "^9.6",
|
|
@@ -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;
|