@queenanya/baileys 6.7.1 → 6.7.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.
@@ -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>;
@@ -15,7 +15,7 @@ const getUserAgent = (config) => {
15
15
  const version = config.mobile ? [2, 24, 5] : config.version;
16
16
  const device = config.mobile ? 'iPhone_7' : 'Desktop';
17
17
  const manufacturer = config.mobile ? 'Apple' : '';
18
- const platform = config.mobile ? WAProto_1.proto.ClientPayload.UserAgent.Platform.IOS : WAProto_1.proto.ClientPayload.UserAgent.Platform.MACOS;
18
+ const platform = config.mobile ? WAProto_1.proto.ClientPayload.UserAgent.Platform.IOS : WAProto_1.proto.ClientPayload.UserAgent.Platform.WEB;
19
19
  const phoneId = config.mobile ? { phoneId: config.auth.creds.phoneId } : {};
20
20
  return {
21
21
  appVersion: {
@@ -36,12 +36,26 @@ const getUserAgent = (config) => {
36
36
  ...phoneId
37
37
  };
38
38
  };
39
+ const PLATFORM_MAP = {
40
+ 'Mac OS': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
41
+ 'Windows': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WIN32
42
+ };
43
+ const getWebInfo = (config) => {
44
+ let webSubPlatform = WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER;
45
+ if (config.syncFullHistory && PLATFORM_MAP[config.browser[0]]) {
46
+ webSubPlatform = PLATFORM_MAP[config.browser[0]];
47
+ }
48
+ return { webSubPlatform };
49
+ };
39
50
  const getClientPayload = (config) => {
40
51
  const payload = {
41
52
  connectType: WAProto_1.proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
42
53
  connectReason: WAProto_1.proto.ClientPayload.ConnectReason.USER_ACTIVATED,
43
54
  userAgent: getUserAgent(config),
44
55
  };
56
+ if (!config.mobile) {
57
+ payload.webInfo = getWebInfo(config);
58
+ }
45
59
  return payload;
46
60
  };
47
61
  const generateMobileNode = (config) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@queenanya/baileys",
3
- "version": "6.7.1",
3
+ "version": "6.7.2",
4
4
  "description": "WhatsApp API",
5
5
  "keywords": [
6
6
  "whatsapp",