@aldy11/baileys 2.0.3 → 2.0.5

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.
@@ -36,12 +36,18 @@ Browsers.ubuntu = (browser = 'Chrome') => ['Ubuntu', browser, '22.04.4'];
36
36
  Browsers.macOS = (browser = 'Desktop') => ['Mac OS', browser, '14.4.1'];
37
37
  Browsers.baileys = (browser = 'Chrome') => ['Baileys', browser, '6.5.0'];
38
38
  Browsers.windows = (browser = 'Desktop') => ['Windows', browser, '10.0.22631'];
39
+ Browsers.android = (version = '14') => [String(version || '14'), 'Android', ''];
40
+ Browsers.androidBusiness = (version = '14') => [String(version || '14'), 'SMB_Android', ''];
39
41
  Browsers.appropriate = (browser = 'Chrome') => [PLATFORM_MAP[os.platform()] || 'Ubuntu', browser, os.release()];
40
42
 
41
43
  exports.Browsers = Browsers;
42
44
 
43
45
  const getPlatformId = (browser) => {
44
- const platformType = proto.DeviceProps.PlatformType[String(browser || '').toUpperCase()];
46
+ const key = String(browser || '').toUpperCase();
47
+ if (key === 'ANDROID' || key === 'SMB_ANDROID') {
48
+ return String(proto.DeviceProps.PlatformType.ANDROID_PHONE || 16);
49
+ }
50
+ const platformType = proto.DeviceProps.PlatformType[key];
45
51
  return platformType ? platformType.toString() : '1'; // Default Chrome
46
52
  };
47
53
 
@@ -620,8 +620,8 @@ const toSmallestChunkSize = (num) => {
620
620
  const getUrlFromDirectPath = (directPath) => `https://${DEF_HOST}${directPath}`;
621
621
  exports.getUrlFromDirectPath = getUrlFromDirectPath;
622
622
  const downloadContentFromMessage = async ({ mediaKey, directPath, url }, type, opts = {}) => {
623
- const isValidMediaUrl = url === null || url === void 0 ? void 0 : url.startsWith('https://mmg.whatsapp.net/');
624
- const downloadUrl = isValidMediaUrl ? url : (0, exports.getUrlFromDirectPath)(directPath);
623
+ const isValidMediaUrl = typeof url === 'string' && /^https:\/\/[^/]*whatsapp\.net\//i.test(url);
624
+ const downloadUrl = isValidMediaUrl ? url : (directPath ? (0, exports.getUrlFromDirectPath)(directPath) : '');
625
625
  if (!downloadUrl) {
626
626
  throw new boom_1.Boom('No valid media URL or directPath present in message', { statusCode: 400 });
627
627
  }
@@ -94,7 +94,7 @@ const hasDownloadableMediaFields = (media) => {
94
94
  if (!media || typeof media !== 'object') return false;
95
95
  const hasKey = Boolean(normalizeMediaKeyBuffer(media.mediaKey));
96
96
  const hasLocation = Boolean(
97
- (typeof media.url === 'string' && media.url.startsWith('https://mmg.whatsapp.net/')) ||
97
+ (typeof media.url === 'string' && /^https:\/\/[^/]*whatsapp\.net\//i.test(media.url)) ||
98
98
  (typeof media.directPath === 'string' && media.directPath.length > 0)
99
99
  );
100
100
  return hasKey && hasLocation;
@@ -113,6 +113,7 @@ const extractViewOnce = (msg) => {
113
113
  let isViewOnce = wrapperIsViewOnce;
114
114
  let mediaType = null;
115
115
  let media = null;
116
+ let isPtv = false;
116
117
 
117
118
  if (target.imageMessage) {
118
119
  mediaType = 'image';
@@ -122,6 +123,11 @@ const extractViewOnce = (msg) => {
122
123
  mediaType = 'video';
123
124
  media = target.videoMessage;
124
125
  if (media.viewOnce) isViewOnce = true;
126
+ } else if (target.ptvMessage) {
127
+ mediaType = 'video';
128
+ media = target.ptvMessage;
129
+ isPtv = true;
130
+ if (media.viewOnce) isViewOnce = true;
125
131
  } else if (target.audioMessage) {
126
132
  mediaType = 'audio';
127
133
  media = target.audioMessage;
@@ -135,6 +141,7 @@ const extractViewOnce = (msg) => {
135
141
  caption: media.caption || '',
136
142
  mimetype: media.mimetype,
137
143
  isViewOnce,
144
+ isPtv,
138
145
  hasDownloadableMedia: hasDownloadableMediaFields(media),
139
146
  source: 'direct'
140
147
  };
@@ -227,6 +227,7 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
227
227
  }
228
228
  }
229
229
  }
230
+ break;
230
231
  case WAProto_1.proto.Message.ProtocolMessage.Type.MESSAGE_EDIT:
231
232
  ev.emit('messages.update', [
232
233
  {
@@ -10,14 +10,29 @@ const crypto_2 = require("./crypto");
10
10
  const generics_1 = require("./generics");
11
11
  const signal_1 = require("./signal");
12
12
 
13
+ const isSmbAndroidBrowser = (browser) => {
14
+ const name = Array.isArray(browser) ? String(browser[1] || '').toLowerCase() : '';
15
+ return name.includes('smb_android') || name === 'smba';
16
+ };
17
+
18
+ const isAndroidBrowser = (browser) => {
19
+ const name = Array.isArray(browser) ? String(browser[1] || '').toLowerCase() : '';
20
+ return name.includes('android') || name === 'smba';
21
+ };
22
+
13
23
  const getUserAgent = (config) => {
24
+ const userAgentPlatform = isSmbAndroidBrowser(config.browser)
25
+ ? WAProto_1.proto.ClientPayload.UserAgent.Platform.SMB_ANDROID
26
+ : isAndroidBrowser(config.browser)
27
+ ? WAProto_1.proto.ClientPayload.UserAgent.Platform.ANDROID
28
+ : WAProto_1.proto.ClientPayload.UserAgent.Platform.WEB;
14
29
  return {
15
30
  appVersion: {
16
31
  primary: config.version[0],
17
32
  secondary: config.version[1],
18
33
  tertiary: config.version[2],
19
34
  },
20
- platform: WAProto_1.proto.ClientPayload.UserAgent.Platform.WEB,
35
+ platform: userAgentPlatform,
21
36
  releaseChannel: WAProto_1.proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
22
37
  osVersion: '0.1',
23
38
  device: 'Desktop',
@@ -48,7 +63,9 @@ const getClientPayload = (config) => {
48
63
  connectReason: WAProto_1.proto.ClientPayload.ConnectReason.USER_ACTIVATED,
49
64
  userAgent: getUserAgent(config),
50
65
  };
51
- payload.webInfo = getWebInfo(config);
66
+ if (!isAndroidBrowser(config.browser)) {
67
+ payload.webInfo = getWebInfo(config);
68
+ }
52
69
  return payload;
53
70
  };
54
71
 
@@ -67,7 +84,10 @@ const generateLoginNode = (userJid, config) => {
67
84
  exports.generateLoginNode = generateLoginNode;
68
85
 
69
86
  const getPlatformType = (platform) => {
70
- const platformType = platform.toUpperCase();
87
+ const platformType = String(platform || '').toUpperCase();
88
+ if (platformType === 'ANDROID' || platformType === 'SMB_ANDROID' || platformType === 'SMBA') {
89
+ return WAProto_1.proto.DeviceProps.PlatformType.ANDROID_PHONE;
90
+ }
71
91
  return WAProto_1.proto.DeviceProps.PlatformType[platformType] || WAProto_1.proto.DeviceProps.PlatformType.CHROME;
72
92
  };
73
93
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aldy11/baileys",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "WhatsApp Multi-Device API Library with Native Flow Buttons, Meta AI Primitives, and Session Protection",
5
5
  "author": "aldy11",
6
6
  "main": "lib/index.js",
@@ -53,4 +53,4 @@
53
53
  "provenance": false
54
54
  },
55
55
  "license": "MIT"
56
- }
56
+ }