@d0v3riz/baileys 6.6.1 → 6.6.3

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.
@@ -49,7 +49,7 @@ exports.PROCESSABLE_HISTORY_TYPES = [
49
49
  ];
50
50
  exports.DEFAULT_CONNECTION_CONFIG = {
51
51
  version: baileys_version_json_1.version,
52
- browser: Utils_1.Browsers.baileys('Chrome'),
52
+ browser: Utils_1.Browsers.ubuntu('Chrome'),
53
53
  waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
54
54
  connectTimeoutMs: 20000,
55
55
  keepAliveIntervalMs: 30000,
@@ -15,7 +15,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
15
15
  deleted: number;
16
16
  }>;
17
17
  productUpdate: (productId: string, update: ProductUpdate) => Promise<import("../Types").Product>;
18
- sendMessageAck: ({ tag, attrs }: BinaryNode) => Promise<void>;
18
+ sendMessageAck: ({ tag, attrs, content }: BinaryNode) => Promise<void>;
19
19
  sendRetryRequest: (node: BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
20
20
  rejectCall: (callId: string, callFrom: string) => Promise<void>;
21
21
  getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
@@ -16,7 +16,7 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
16
16
  deleted: number;
17
17
  }>;
18
18
  productUpdate: (productId: string, update: import("../Types").ProductUpdate) => Promise<import("../Types").Product>;
19
- sendMessageAck: ({ tag, attrs }: import("../index").BinaryNode) => Promise<void>;
19
+ sendMessageAck: ({ tag, attrs, content }: import("../index").BinaryNode) => Promise<void>;
20
20
  sendRetryRequest: (node: import("../index").BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
21
21
  rejectCall: (callId: string, callFrom: string) => Promise<void>;
22
22
  getPrivacyTokens: (jids: string[]) => Promise<import("../index").BinaryNode>;
@@ -4,7 +4,7 @@ import { proto } from '../../WAProto';
4
4
  import { MessageReceiptType, MessageRelayOptions, SocketConfig } from '../Types';
5
5
  import { BinaryNode } from '../WABinary';
6
6
  export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
7
- sendMessageAck: ({ tag, attrs }: BinaryNode) => Promise<void>;
7
+ sendMessageAck: ({ tag, attrs, content }: BinaryNode) => Promise<void>;
8
8
  sendRetryRequest: (node: BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
9
9
  rejectCall: (callId: string, callFrom: string) => Promise<void>;
10
10
  getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
@@ -31,7 +31,7 @@ const makeMessagesRecvSocket = (config) => {
31
31
  useClones: false
32
32
  });
33
33
  let sendActiveReceipts = false;
34
- const sendMessageAck = async ({ tag, attrs }) => {
34
+ const sendMessageAck = async ({ tag, attrs, content }) => {
35
35
  const stanza = {
36
36
  tag: 'ack',
37
37
  attrs: {
@@ -46,9 +46,12 @@ const makeMessagesRecvSocket = (config) => {
46
46
  if (!!attrs.recipient) {
47
47
  stanza.attrs.recipient = attrs.recipient;
48
48
  }
49
- if (tag !== 'message' && attrs.type) {
49
+ if (!!attrs.type && (tag !== 'message' || (0, WABinary_1.getBinaryNodeChild)({ tag, attrs, content }, 'unavailable'))) {
50
50
  stanza.attrs.type = attrs.type;
51
51
  }
52
+ if (tag === 'message' && (0, WABinary_1.getBinaryNodeChild)({ tag, attrs, content }, 'unavailable')) {
53
+ stanza.attrs.from = authState.creds.me.id;
54
+ }
52
55
  logger.debug({ recv: { tag, attrs }, sent: stanza.attrs }, 'sent ack');
53
56
  await sendNode(stanza);
54
57
  };
@@ -552,6 +555,12 @@ const makeMessagesRecvSocket = (config) => {
552
555
  };
553
556
  const handleMessage = async (node) => {
554
557
  var _a, _b;
558
+ if ((0, WABinary_1.getBinaryNodeChild)(node, 'unavailable') && !(0, WABinary_1.getBinaryNodeChild)(node, 'enc')) {
559
+ // "missing message from node" fix
560
+ logger.debug(node, 'missing body; sending ack then ignoring.');
561
+ await sendMessageAck(node);
562
+ return;
563
+ }
555
564
  const { fullMessage: msg, category, author, decrypt } = (0, Utils_1.decryptMessageNode)(node, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, logger);
556
565
  if (((_b = (_a = msg.message) === null || _a === void 0 ? void 0 : _a.protocolMessage) === null || _b === void 0 ? void 0 : _b.type) === WAProto_1.proto.Message.ProtocolMessage.Type.SHARE_PHONE_NUMBER) {
557
566
  if (node.attrs.sender_pn) {
@@ -17,7 +17,7 @@ export declare const makeRegistrationSocket: (config: SocketConfig) => {
17
17
  deleted: number;
18
18
  }>;
19
19
  productUpdate: (productId: string, update: import("../Types").ProductUpdate) => Promise<import("../Types").Product>;
20
- sendMessageAck: ({ tag, attrs }: import("../WABinary").BinaryNode) => Promise<void>;
20
+ sendMessageAck: ({ tag, attrs, content }: import("../WABinary").BinaryNode) => Promise<void>;
21
21
  sendRetryRequest: (node: import("../WABinary").BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
22
22
  rejectCall: (callId: string, callFrom: string) => Promise<void>;
23
23
  getPrivacyTokens: (jids: string[]) => Promise<import("../WABinary").BinaryNode>;
@@ -1,5 +1,5 @@
1
1
  import { AuthenticationCreds } from '../Types';
2
- declare const makeCacheManagerAuthState: (store: Store, sessionKey: string) => Promise<{
2
+ declare const makeCacheManagerAuthState: (store: Storage, sessionKey: string) => Promise<{
3
3
  clearState: () => Promise<void>;
4
4
  saveCreds: () => Promise<void>;
5
5
  state: {
@@ -148,7 +148,7 @@ async function promiseTimeout(ms, promise) {
148
148
  }
149
149
  exports.promiseTimeout = promiseTimeout;
150
150
  // generate a random ID to attach to a message
151
- const generateMessageID = () => 'WHPI' + (0, crypto_1.randomBytes)(6).toString('hex').toUpperCase();
151
+ const generateMessageID = () => (process.env.WHATSAPP_CONN_IDMSG || 'WHPI') + (0, crypto_1.randomBytes)(6).toString('hex').toUpperCase();
152
152
  exports.generateMessageID = generateMessageID;
153
153
  function bindWaitForEvent(ev, event) {
154
154
  return async (check, timeoutMs) => {
@@ -213,7 +213,7 @@ exports.getAudioDuration = getAudioDuration;
213
213
  */
214
214
  async function getAudioWaveform(buffer, logger) {
215
215
  try {
216
- const audioDecode = (...args) => import('audio-decode').then(({ default: audioDecode }) => audioDecode(...args));
216
+ const audioDecode = (buffer) => import('audio-decode').then(({ default: audioDecode }) => audioDecode(buffer));
217
217
  let audioData;
218
218
  if (Buffer.isBuffer(buffer)) {
219
219
  audioData = buffer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d0v3riz/baileys",
3
- "version": "6.6.1",
3
+ "version": "6.6.3",
4
4
  "description": "WhatsApp API",
5
5
  "keywords": [
6
6
  "whatsapp",