@hiroosy/baileys-lite 0.4.0 → 0.4.2

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 CHANGED
@@ -1,18 +1,22 @@
1
- <div align=center><img src="https://files.catbox.moe/bzw1x3.png"/></div>
1
+ # Baileys-Lite
2
2
 
3
- <p align="center">
3
+ <p align="left">
4
4
  <a href="https://www.npmjs.com/package/@hiroosy/baileys-lite"><img height="25" alt="npm version" src="https://img.shields.io/npm/v/@hiroosy/baileys-lite?color=CB3837&style=for-the-badge&logo=npm" /></a>
5
5
  <a href="https://www.npmjs.com/package/@hiroosy/baileys-lite"><img height="25" alt="npm package size" src="https://img.shields.io/npm/unpacked-size/@hiroosy/baileys-lite?label=size&color=2F855A&style=for-the-badge&logo=npm" /></a>
6
6
  <img height="25" alt="node version" src="https://img.shields.io/badge/NodeJS_>=18-000000.svg?&style=for-the-badge&logo=node.js&logoColor=green" />
7
7
  </p>
8
8
 
9
- **High-Performance Javascript Baileys**, built for high-scalability workloads, multi-session operation, and full user configurability.
10
-
11
- - [x] Support LID/PN/Username.
12
- - [x] High performance for multi sessions.
13
- - [x] Zero dependency.
14
- - [x] Low memory & CPU consumption.
15
- - [x] Calls: Video & Audio, group calls, call links, and waiting rooms.
9
+ **High-Performance Javascript Baileys**, built for high-scalability workloads, built-in modules, multi-session operation, and full user configurability.
10
+
11
+ | Feature | Baileys-Lite | Whiskeysockets |
12
+ | --- | --- | --- |
13
+ | RAM usage | 80 mb | 150mb+ |
14
+ | Call | Yes | No |
15
+ | Ping | 8 ms | 200 ms |
16
+ | Multi sessions limit | 100+, still fast | 2-10, slow |
17
+ | LID/PN/Username | Yes, all | Only LID and PN |
18
+ | SQL session | Yes | No |
19
+ | Node required | >=18 | >=20 |
16
20
 
17
21
  ---
18
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hiroosy/baileys-lite",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "A Lightweight Baileys built with Pure NodeJs 18+",
5
5
  "repository": {
6
6
  "type": "git",
@@ -37,6 +37,7 @@ import {
37
37
  NO_MESSAGE_FOUND_ERROR_TEXT,
38
38
  readTcTokenIndex,
39
39
  resolveIssuanceJid,
40
+ resolvePlaceholderResendSkipSubtype,
40
41
  resolveTcTokenJid,
41
42
  SERVER_ERROR_CODES,
42
43
  storeTcTokensFromIqResult,
@@ -1346,12 +1347,9 @@ export const makeMessagesRecvSocket = (config) => {
1346
1347
  }
1347
1348
  if (msg.messageStubParameters?.[0] === NO_MESSAGE_FOUND_ERROR_TEXT) {
1348
1349
 
1349
- const unavailableNode = getBinaryNodeChild(node, 'unavailable');
1350
- const unavailableType = unavailableNode?.attrs?.type;
1351
- if (unavailableType === 'bot_unavailable_fanout' ||
1352
- unavailableType === 'hosted_unavailable_fanout' ||
1353
- unavailableType === 'view_once_unavailable_fanout') {
1354
- logger.debug({ msgId: msg.key.id, unavailableType }, 'skipping placeholder resend for excluded unavailable type');
1350
+ const skipSubtype = resolvePlaceholderResendSkipSubtype(node);
1351
+ if (skipSubtype) {
1352
+ logger.debug({ msgId: msg.key.id, subtype: skipSubtype }, 'skipping placeholder resend for excluded unavailable type');
1355
1353
  acked = true;
1356
1354
  return sendMessageAck(node);
1357
1355
  }
@@ -26,6 +26,7 @@ import {
26
26
  generateWAMessage,
27
27
  generateWAMessageFromContent,
28
28
  hasValidAlbumMedia,
29
+ isViewOnceMessage,
29
30
  normalizeMessageContent,
30
31
  shouldIncludeBizBinaryNode
31
32
  } from '../utils/message-compose.js'
@@ -550,8 +551,12 @@ export const makeMessagesSocket = (config) => {
550
551
  const isNeedMetaAttrs = innerMessage?.pinInChatMessage || innerMessage?.keepInChatMessage || innerMessage?.reactionMessage;
551
552
  const isGroupStatus = message?.groupStatusMessage || message?.groupStatusMessageV2;
552
553
  const isPollUpdate = innerMessage?.pollUpdateMessage;
553
- if (isNeedMetaAttrs || isGroupStatus || isPollUpdate) {
554
+ const isViewOnce = isViewOnceMessage(message);
555
+ if (isNeedMetaAttrs || isGroupStatus || isPollUpdate || isViewOnce) {
554
556
  const metaAttrs = {};
557
+ if (isViewOnce) {
558
+ metaAttrs.view_once = 'true';
559
+ }
555
560
  if (isNeedMetaAttrs) {
556
561
  metaAttrs.content_type = 'add_on';
557
562
  }
@@ -69,10 +69,6 @@ export const makeSocket = config => {
69
69
  const uqTagId = generateMdTagPrefix()
70
70
  const generateMessageTag = () => `${uqTagId}${epoch++}`
71
71
 
72
- if (browser[1].toLocaleLowerCase().includes('android')) {
73
- logger.warn('⚠️ Using the Android browser is experimental and may lead to unexpected behavior. Use at your own risk.')
74
- }
75
-
76
72
  const syncDisabled = PROCESSABLE_HISTORY_TYPES.map(syncType => config.shouldSyncHistoryMessage({ syncType })).filter(x => x === false).length === PROCESSABLE_HISTORY_TYPES.length
77
73
  if (syncDisabled) {
78
74
  logger.warn('⚠️ DANGER: DISABLING ALL SYNC BY shouldSyncHistoryMsg PREVENTS BAILEYS FROM ACCESSING INITIAL LID MAPPINGS, LEADING TO INSTABILIY AND SESSION ERRORS')
@@ -522,6 +522,34 @@ function isSessionRecordError(error) {
522
522
  return DECRYPTION_RETRY_CONFIG.sessionRecordErrors.some(pattern => errorMessage.includes(pattern))
523
523
  }
524
524
 
525
+ const UNAVAILABLE_SKIP_SUBTYPE_BY_KIND = {
526
+ bot: 'bot_unavailable_fanout',
527
+ hosted: 'hosted_unavailable_fanout',
528
+ view_once: 'view_once_unavailable_fanout',
529
+ sender_drop: 'acp_unavailable_fanout'
530
+ }
531
+ const UNAVAILABLE_SKIP_SUBTYPES = new Set(Object.values(UNAVAILABLE_SKIP_SUBTYPE_BY_KIND))
532
+
533
+ export function resolveUnavailableKind(node) {
534
+ const content = Array.isArray(node?.content) ? node.content : []
535
+ const unavailable = content.find(child => child?.tag === 'unavailable')
536
+ if (!unavailable) return null
537
+ if (content.some(child => child?.tag === 'bot')) return 'bot'
538
+ if (unavailable.attrs?.hosted === 'true') return 'hosted'
539
+ const type = unavailable.attrs?.type
540
+ return type === 'view_once' || type === 'sender_drop' ? type : 'other'
541
+ }
542
+
543
+ export function resolvePlaceholderResendSkipSubtype(node) {
544
+ const subtype = node?.attrs?.subtype
545
+ if (typeof subtype === 'string' && UNAVAILABLE_SKIP_SUBTYPES.has(subtype)) return subtype
546
+ const unavailable = Array.isArray(node?.content) ? node.content.find(child => child?.tag === 'unavailable') : undefined
547
+ const legacyType = unavailable?.attrs?.type
548
+ if (typeof legacyType === 'string' && UNAVAILABLE_SKIP_SUBTYPES.has(legacyType)) return legacyType
549
+ const kind = resolveUnavailableKind(node)
550
+ return kind && kind !== 'other' ? UNAVAILABLE_SKIP_SUBTYPE_BY_KIND[kind] : null
551
+ }
552
+
525
553
  export const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
526
554
  const { fullMessage, author, sender } = decodeMessageNode(stanza, meId, meLid)
527
555
  return {
@@ -530,6 +558,10 @@ export const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
530
558
  author,
531
559
  async decrypt() {
532
560
  let decryptables = 0
561
+ let decryptedAny = false
562
+ let decryptFailed = false
563
+ let skmsgFailed = false
564
+ if (resolveUnavailableKind(stanza) === 'view_once') fullMessage.key.isViewOnce = true
533
565
  if (Array.isArray(stanza.content)) {
534
566
  for (const { tag, attrs, content } of stanza.content) {
535
567
  if (tag === 'verified_name' && content instanceof Uint8Array) {
@@ -537,9 +569,6 @@ export const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
537
569
  const details = proto.VerifiedNameCertificate.Details.decode(cert.details)
538
570
  fullMessage.verifiedBizName = details.verifiedName
539
571
  }
540
- if (tag === 'unavailable' && attrs.type === 'view_once') {
541
- fullMessage.key.isViewOnce = true
542
- }
543
572
  if (attrs.count && tag === 'enc') fullMessage.retryCount = Number(attrs.count)
544
573
  if (tag !== 'enc' && tag !== 'plaintext') continue
545
574
  if (!(content instanceof Uint8Array)) continue
@@ -577,6 +606,7 @@ export const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
577
606
  }
578
607
  if (fullMessage.message) Object.assign(fullMessage.message, msg)
579
608
  else fullMessage.message = msg
609
+ decryptedAny = true
580
610
  } catch (err) {
581
611
  logger.error(
582
612
  {
@@ -589,6 +619,8 @@ export const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
589
619
  },
590
620
  'failed to decrypt message'
591
621
  )
622
+ decryptFailed = true
623
+ if (attrs.type === 'skmsg') skmsgFailed = true
592
624
  fullMessage.messageStubType = proto.WebMessageInfo.StubType.CIPHERTEXT
593
625
  fullMessage.messageStubParameters = [err.message.toString()]
594
626
  }
@@ -597,6 +629,9 @@ export const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
597
629
  if (!decryptables && !fullMessage.key?.isViewOnce) {
598
630
  fullMessage.messageStubType = proto.WebMessageInfo.StubType.CIPHERTEXT
599
631
  fullMessage.messageStubParameters = [NO_MESSAGE_FOUND_ERROR_TEXT]
632
+ } else if (decryptFailed && decryptedAny && !skmsgFailed) {
633
+ delete fullMessage.messageStubType
634
+ delete fullMessage.messageStubParameters
600
635
  }
601
636
  }
602
637
  }
@@ -1553,6 +1553,15 @@ export const normalizeMessageContent = content => {
1553
1553
  return content
1554
1554
  }
1555
1555
 
1556
+ const VIEW_ONCE_MEDIA_KEYS = ['imageMessage', 'videoMessage', 'ptvMessage', 'audioMessage']
1557
+
1558
+ export const isViewOnceMessage = message => {
1559
+ if (!message) return false
1560
+ if (message.viewOnceMessage || message.viewOnceMessageV2) return true
1561
+ const inner = normalizeMessageContent(message)
1562
+ return !!inner && VIEW_ONCE_MEDIA_KEYS.some(key => !!inner[key]?.viewOnce)
1563
+ }
1564
+
1556
1565
  export const extractMessageContent = content => {
1557
1566
  const extractFromTemplateMessage = msg => {
1558
1567
  if (msg.imageMessage) return { imageMessage: msg.imageMessage }
@@ -17,6 +17,7 @@ import {
17
17
  isHostedLidUser,
18
18
  isHostedPnUser,
19
19
  isJidBroadcast,
20
+ isJidGroup,
20
21
  isJidStatusBroadcast,
21
22
  isLidUser,
22
23
  isPnUser,
@@ -152,11 +153,57 @@ export function decryptMessageEdit({ encPayload, encIv }, { originalSenderJid, o
152
153
  return proto.Message.decode(decrypted)
153
154
  }
154
155
 
156
+ const orderLidFirst = jids => [...jids.filter(jid => isLidUser(jid)), ...jids.filter(jid => !isLidUser(jid))]
157
+
158
+ const collectUserJids = (...candidates) => {
159
+ const out = []
160
+ for (const candidate of candidates) {
161
+ if (typeof candidate !== 'string' || !candidate) continue
162
+ const user = jidNormalizedUser(candidate)
163
+ if (user && !out.includes(user)) out.push(user)
164
+ }
165
+ return out
166
+ }
167
+
168
+ const resolveSenderJids = async (rawJid, alternates, lidMapping) => {
169
+ let lid
170
+ let pn
171
+ if (rawJid && isLidUser(rawJid)) {
172
+ lid = rawJid
173
+ pn = await lidMapping?.getPNForLID(rawJid).catch(() => null)
174
+ } else if (rawJid && isPnUser(rawJid)) {
175
+ pn = rawJid
176
+ lid = await lidMapping?.getLIDForPN(rawJid).catch(() => null)
177
+ }
178
+ return orderLidFirst(collectUserJids(lid, pn, rawJid, ...alternates))
179
+ }
180
+
181
+ const resolveEditParentJids = async (targetKey, meId, meLid, lidMapping) => {
182
+ if (targetKey?.fromMe) return orderLidFirst(collectUserJids(meLid, meId))
183
+ return resolveSenderJids(targetKey?.participant || targetKey?.remoteJid, [targetKey?.participantAlt, targetKey?.remoteJidAlt], lidMapping)
184
+ }
185
+
186
+ const resolveEditEditorJids = async (messageKey, meId, meLid, lidMapping) => {
187
+ if (messageKey?.fromMe) return orderLidFirst(collectUserJids(meLid, meId))
188
+ return resolveSenderJids(messageKey?.participant || messageKey?.remoteJid, [messageKey?.participantAlt, messageKey?.remoteJidAlt], lidMapping)
189
+ }
190
+
191
+ const decryptEditWithSenderFallback = ({ encPayload, encIv, editEncKey, originalMsgId, parentJids, editorJids }) => {
192
+ let lastError
193
+ for (const originalSenderJid of parentJids) {
194
+ for (const editorJid of editorJids) {
195
+ try {
196
+ return decryptMessageEdit({ encPayload, encIv }, { editEncKey, originalSenderJid, originalMsgId, editorJid })
197
+ } catch (err) {
198
+ lastError = err
199
+ }
200
+ }
201
+ }
202
+ throw lastError ?? new Error('no sender candidates for message edit')
203
+ }
204
+
155
205
  const buildEditUpdate = args => {
156
- const editedInner = decryptMessageEdit(
157
- { encPayload: args.encPayload, encIv: args.encIv },
158
- { editEncKey: args.editEncKey, originalSenderJid: args.originalSenderJid, originalMsgId: args.originalMsgId, editorJid: args.editorJid }
159
- )
206
+ const editedInner = decryptEditWithSenderFallback(args)
160
207
  const editProtocol = editedInner.protocolMessage
161
208
  const innerEdited = editProtocol?.editedMessage
162
209
  if (!innerEdited) {
@@ -212,7 +259,7 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
212
259
  processedHistoryMessages: [...(creds.processedHistoryMessages || []), { key: message.key, messageTimestamp: message.messageTimestamp }].slice(-MAX_PROCESSED_HISTORY_MESSAGES)
213
260
  })
214
261
  }
215
- const data = await downloadAndProcessHistorySyncNotification(histNotification, options, logger)
262
+ const data = await downloadAndProcessHistorySyncNotification(histNotification, options, logger, meId)
216
263
  if (data.lidPnMappings?.length) {
217
264
  logger?.debug({ count: data.lidPnMappings.length }, 'processing LID-PN mappings from history sync')
218
265
  await signalRepository.lidMapping.storeLIDPNMappings(data.lidPnMappings).catch(err => logger?.warn({ err }, 'failed to store LID-PN mappings from history sync'))
@@ -356,30 +403,29 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
356
403
  const targetMsg = await getMessage(targetKey)
357
404
  if (targetMsg) {
358
405
  try {
359
- const meIdNormalised = jidNormalizedUser(meId)
360
- const origSenderRaw = targetKey.participant || targetKey.remoteJid
361
- const origSenderPn = isLidUser(origSenderRaw) ? await signalRepository.lidMapping.getPNForLID(origSenderRaw) : origSenderRaw
362
- const originalSenderJid = getKeyAuthor({ remoteJid: jidNormalizedUser(origSenderPn), fromMe: meIdNormalised === origSenderPn }, meIdNormalised)
363
- const editorJid = getKeyAuthor(message.key, meIdNormalised)
364
406
  const editEncKey = targetMsg?.messageContextInfo?.messageSecret
365
407
  if (!editEncKey) {
366
408
  logger?.warn({ targetKey }, 'message edit: missing messageSecret on original message — cannot decrypt')
367
- return
409
+ } else {
410
+ const meIdNormalised = jidNormalizedUser(meId)
411
+ const meLid = creds.me?.lid
412
+ const parentJids = await resolveEditParentJids(targetKey, meIdNormalised, meLid, signalRepository.lidMapping)
413
+ const editorJids = await resolveEditEditorJids(message.key, meIdNormalised, meLid, signalRepository.lidMapping)
414
+ const update = buildEditUpdate({
415
+ editEncKey,
416
+ encPayload: secEnc.encPayload,
417
+ encIv: secEnc.encIv,
418
+ parentJids,
419
+ editorJids,
420
+ originalMsgId: targetKey.id,
421
+ messageKey: message.key,
422
+ targetKeyId: targetKey.id,
423
+ fallbackTimestamp: toNumber(message.messageTimestamp),
424
+ logger,
425
+ targetKey
426
+ })
427
+ if (update) ev.emit('messages.update', [update])
368
428
  }
369
- const update = buildEditUpdate({
370
- editEncKey,
371
- encPayload: secEnc.encPayload,
372
- encIv: secEnc.encIv,
373
- originalSenderJid,
374
- originalMsgId: targetKey.id,
375
- editorJid,
376
- messageKey: message.key,
377
- targetKeyId: targetKey.id,
378
- fallbackTimestamp: toNumber(message.messageTimestamp),
379
- logger,
380
- targetKey
381
- })
382
- if (update) ev.emit('messages.update', [update])
383
429
  } catch (err) {
384
430
  logger?.warn({ err, targetKey }, 'failed to decrypt secretEncryptedMessage MESSAGE_EDIT')
385
431
  }
@@ -738,7 +784,15 @@ export const downloadHistory = async (msg, options) => {
738
784
  return proto.HistorySync.decode(inflated)
739
785
  }
740
786
 
741
- export const processHistoryMessage = (item, logger) => {
787
+ const applyHistoryMessageAuthor = (message, chatId, meId) => {
788
+ if (!isJidGroup(chatId) && !isJidBroadcast(chatId)) return
789
+ if (message.key.participant) return
790
+ const selfAuthor = message.originalSelfAuthorUserJidString || meId
791
+ const author = message.participant || (message.key.fromMe && selfAuthor ? jidNormalizedUser(selfAuthor) : undefined)
792
+ if (author) message.key.participant = author
793
+ }
794
+
795
+ export const processHistoryMessage = (item, logger, meId) => {
742
796
  const messages = []
743
797
  const contacts = []
744
798
  const chats = []
@@ -747,18 +801,23 @@ export const processHistoryMessage = (item, logger) => {
747
801
  for (const m of item.phoneNumberToLidMappings || []) {
748
802
  if (m.lidJid && m.pnJid) lidPnMappings.push({ lid: m.lidJid, pn: m.pnJid })
749
803
  }
804
+ for (const m of item.inlineContacts || []) {
805
+ if (m.lidJid && m.pnJid) lidPnMappings.push({ lid: m.lidJid, pn: m.pnJid })
806
+ }
750
807
  switch (item.syncType) {
751
808
  case proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP:
752
809
  case proto.HistorySync.HistorySyncType.RECENT:
753
810
  case proto.HistorySync.HistorySyncType.FULL:
754
811
  case proto.HistorySync.HistorySyncType.ON_DEMAND:
755
- for (const chat of item.conversations) {
756
- contacts.push({ id: chat.id, name: chat.displayName || chat.name || chat.username || undefined, username: chat.username || undefined, lid: chat.lidJid || chat.accountLid || undefined, phoneNumber: chat.pnJid || undefined })
812
+ for (const chat of item.conversations || []) {
813
+ if (!chat?.id) continue
814
+ const chatLid = chat.lidJid || chat.accountLid || undefined
815
+ contacts.push({ id: chat.id, name: chat.displayName || chat.name || chat.username || undefined, username: chat.username || undefined, lid: chatLid, phoneNumber: chat.pnJid || undefined })
757
816
  const chatId = chat.id
758
817
  const isLid = isLidUser(chatId) || isHostedLidUser(chatId)
759
818
  const isPn = isPnUser(chatId) || isHostedPnUser(chatId)
760
819
  if (isLid && chat.pnJid) lidPnMappings.push({ lid: chatId, pn: chat.pnJid })
761
- else if (isPn && chat.lidJid) lidPnMappings.push({ lid: chat.lidJid, pn: chatId })
820
+ else if (isPn && chatLid) lidPnMappings.push({ lid: chatLid, pn: chatId })
762
821
  else if (isLid && !chat.pnJid) {
763
822
  const pnFromReceipt = extractPnFromMessages(chat.messages || [])
764
823
  if (pnFromReceipt) lidPnMappings.push({ lid: chatId, pn: pnFromReceipt })
@@ -766,7 +825,9 @@ export const processHistoryMessage = (item, logger) => {
766
825
  const msgs = chat.messages || []
767
826
  delete chat.messages
768
827
  for (const item_ of msgs) {
769
- const message = item_.message
828
+ const message = item_?.message
829
+ if (!message?.key) continue
830
+ applyHistoryMessageAuthor(message, chatId, meId)
770
831
  messages.push(message)
771
832
  if (!chat.messages?.length) chat.messages = [{ message }]
772
833
  if (!message.key.fromMe && !chat.lastMessageRecvTimestamp) chat.lastMessageRecvTimestamp = toNumber(message.messageTimestamp)
@@ -781,17 +842,17 @@ export const processHistoryMessage = (item, logger) => {
781
842
  }
782
843
  break
783
844
  case proto.HistorySync.HistorySyncType.PUSH_NAME:
784
- for (const c of item.pushnames) contacts.push({ id: c.id, notify: c.pushname })
845
+ for (const c of item.pushnames || []) contacts.push({ id: c.id, notify: c.pushname })
785
846
  break
786
847
  }
787
848
  return { chats, contacts, messages, lidPnMappings, pastParticipants: item.pastParticipants, syncType: item.syncType, progress: item.progress }
788
849
  }
789
850
 
790
- export const downloadAndProcessHistorySyncNotification = async (msg, options, logger) => {
851
+ export const downloadAndProcessHistorySyncNotification = async (msg, options, logger, meId) => {
791
852
  const historyMsg = msg.initialHistBootstrapInlinePayload
792
853
  ? proto.HistorySync.decode(await inflatePromise(msg.initialHistBootstrapInlinePayload))
793
854
  : await downloadHistory(msg, options)
794
- return processHistoryMessage(historyMsg, logger)
855
+ return processHistoryMessage(historyMsg, logger, meId)
795
856
  }
796
857
 
797
858
  export const getHistoryMsg = message => {
@@ -890,9 +890,7 @@ const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5])
890
890
 
891
891
  const getUserAgent = config => ({
892
892
  appVersion: { primary: config.version[0], secondary: config.version[1], tertiary: config.version[2] },
893
- platform: config.browser[1].toLocaleLowerCase().includes('android')
894
- ? proto.ClientPayload.UserAgent.Platform.ANDROID
895
- : proto.ClientPayload.UserAgent.Platform.WEB,
893
+ platform: proto.ClientPayload.UserAgent.Platform.WEB,
896
894
  releaseChannel: proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
897
895
  osVersion: '0.1',
898
896
  device: 'Desktop',
@@ -922,7 +920,7 @@ const getClientPayload = config => {
922
920
  connectReason: proto.ClientPayload.ConnectReason.USER_ACTIVATED,
923
921
  userAgent: getUserAgent(config)
924
922
  }
925
- if (!config.browser[1].toLocaleLowerCase().includes('android')) payload.webInfo = getWebInfo(config)
923
+ payload.webInfo = getWebInfo(config)
926
924
  if (config.pushName) payload.pushName = config.pushName
927
925
  return payload
928
926
  }
@@ -935,7 +933,7 @@ export const generateLoginNode = (userJid, config) => {
935
933
 
936
934
  const getPlatformType = platform => {
937
935
  const platformType = platform.toUpperCase()
938
- if (platformType === 'ANDROID') return proto.DeviceProps.PlatformType.ANDROID_PHONE
936
+ if (platformType === 'ANDROID') return proto.DeviceProps.PlatformType.UNKNOWN
939
937
  return proto.DeviceProps.PlatformType[platformType] || proto.DeviceProps.PlatformType.CHROME
940
938
  }
941
939
 
package/src/voip/index.js CHANGED
@@ -196,7 +196,7 @@ class VoipCall extends EventEmitter {
196
196
  this.#loop = !!opts.loop;
197
197
  this.#onItemAdvance = opts.onItemAdvance;
198
198
  this.#target = opts.target ?? null;
199
- this.#autoDowngrade = opts.autoDowngrade === undefined ? true : !!opts.autoDowngrade;
199
+ this.#autoDowngrade = opts.autoDowngrade === undefined ? false : !!opts.autoDowngrade;
200
200
  this.#startVideoOnFirst = !!opts.startVideoOnFirst;
201
201
  this.#normalize = opts.normalize ?? null;
202
202
  }
@@ -6,6 +6,7 @@ import { toBytesView, toError } from '../shim/util.js';
6
6
  import { TEXT_DECODER } from '../bytes.js';
7
7
  import { DEFAULT_VIDEO_CONFIG } from '../types.js';
8
8
  import { auHasIDR } from './h264.js';
9
+ const isUrlSource = source => /^[a-z][a-z0-9+.-]+:\/\//i.test(String(source || ''));
9
10
  const FFMPEG_BIN = 'ffmpeg';
10
11
  const MAX_STDERR_CHARS = 16 * 1024;
11
12
 
@@ -80,11 +81,13 @@ export class WaVideoEngine {
80
81
  }
81
82
 
82
83
  async loadVideoFile(videoPath) {
83
- try {
84
- await access(videoPath);
85
- }
86
- catch {
87
- throw new Error(`File not found: ${videoPath}`);
84
+ if (!isUrlSource(videoPath)) {
85
+ try {
86
+ await access(videoPath);
87
+ }
88
+ catch {
89
+ throw new Error(`File not found: ${videoPath}`);
90
+ }
88
91
  }
89
92
  if (!(await hasFfmpeg(FFMPEG_BIN))) {
90
93
  throw new Error('ffmpeg not found on PATH (install ffmpeg to load video files)');
@@ -115,7 +118,9 @@ export class WaVideoEngine {
115
118
  const inputArgs = this.sourceKind === 'blank'
116
119
 
117
120
  ? ['-f', 'lavfi', '-re', '-i', `color=c=black:s=${outW}x${outH}:r=${this.frameRate}`]
118
- : ['-stream_loop', '-1', '-re', '-i', this.videoPath];
121
+ : isUrlSource(this.videoPath)
122
+ ? ['-re', '-i', this.videoPath]
123
+ : ['-stream_loop', '-1', '-re', '-i', this.videoPath];
119
124
 
120
125
  const args = [
121
126
  '-hide_banner', '-loglevel', 'error',