cuki-bailx 1.1.2 → 1.2.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.
Files changed (116) hide show
  1. package/WAProto/index.js +79296 -118676
  2. package/engine-requirements.js +1 -1
  3. package/lib/Defaults/baileys-version.json +1 -1
  4. package/lib/Defaults/index.d.ts +6 -4
  5. package/lib/Defaults/index.js +102 -78
  6. package/lib/Defaults/phonenumber-mcc.json +223 -0
  7. package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +2 -1
  8. package/lib/Socket/Client/index.d.ts +3 -2
  9. package/lib/Socket/Client/index.js +3 -2
  10. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  11. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  12. package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -2
  13. package/lib/Socket/Client/{websocket.js → web-socket-client.js} +2 -12
  14. package/lib/Socket/business.d.ts +58 -59
  15. package/lib/Socket/chats.d.ts +27 -29
  16. package/lib/Socket/chats.js +90 -97
  17. package/lib/Socket/dugong.d.ts +219 -0
  18. package/lib/Socket/dugong.js +441 -0
  19. package/lib/Socket/groups.d.ts +32 -41
  20. package/lib/Socket/groups.js +5 -20
  21. package/lib/Socket/index.d.ts +64 -63
  22. package/lib/Socket/index.js +2 -2
  23. package/lib/Socket/messages-recv.js +65 -9
  24. package/lib/Socket/messages-send.d.ts +47 -49
  25. package/lib/Socket/messages-send.js +312 -379
  26. package/lib/Socket/newsletter.d.ts +37 -39
  27. package/lib/Socket/newsletter.js +40 -54
  28. package/lib/Socket/registration.d.ts +267 -0
  29. package/lib/Socket/registration.js +166 -0
  30. package/lib/Socket/socket.d.ts +10 -10
  31. package/lib/Socket/socket.js +32 -39
  32. package/lib/Socket/socket.js.bak +630 -0
  33. package/lib/Socket/usync.d.ts +3 -3
  34. package/lib/Store/index.d.ts +2 -1
  35. package/lib/Store/index.js +3 -1
  36. package/lib/Store/make-cache-manager-store.d.ts +13 -0
  37. package/lib/Store/make-cache-manager-store.js +83 -0
  38. package/lib/Store/make-in-memory-store.d.ts +24 -24
  39. package/lib/Store/make-in-memory-store.js +11 -13
  40. package/lib/Store/make-ordered-dictionary.d.ts +1 -1
  41. package/lib/Store/make-ordered-dictionary.js +2 -2
  42. package/lib/Types/Auth.d.ts +7 -0
  43. package/lib/Types/Call.d.ts +1 -1
  44. package/lib/Types/Chat.d.ts +7 -14
  45. package/lib/Types/Contact.d.ts +1 -5
  46. package/lib/Types/Events.d.ts +2 -44
  47. package/lib/Types/GroupMetadata.d.ts +2 -11
  48. package/lib/Types/Label.js +1 -1
  49. package/lib/Types/LabelAssociation.js +1 -1
  50. package/lib/Types/Message.d.ts +21 -148
  51. package/lib/Types/Message.js +2 -0
  52. package/lib/Types/Newsletter.d.ts +13 -0
  53. package/lib/Types/Newsletter.js +17 -3
  54. package/lib/Types/Socket.d.ts +9 -17
  55. package/lib/Types/index.d.ts +1 -8
  56. package/lib/Types/index.js +2 -2
  57. package/lib/Utils/auth-utils.d.ts +3 -3
  58. package/lib/Utils/auth-utils.js +13 -6
  59. package/lib/Utils/business.js +2 -2
  60. package/lib/Utils/chat-utils.d.ts +16 -15
  61. package/lib/Utils/chat-utils.js +35 -36
  62. package/lib/Utils/crypto.d.ts +16 -15
  63. package/lib/Utils/crypto.js +29 -71
  64. package/lib/Utils/decode-wa-message.d.ts +6 -22
  65. package/lib/Utils/decode-wa-message.js +56 -65
  66. package/lib/Utils/event-buffer.d.ts +2 -2
  67. package/lib/Utils/event-buffer.js +7 -11
  68. package/lib/Utils/generics.d.ts +20 -17
  69. package/lib/Utils/generics.js +23 -73
  70. package/lib/Utils/history.d.ts +0 -4
  71. package/lib/Utils/history.js +6 -4
  72. package/lib/Utils/link-preview.d.ts +2 -2
  73. package/lib/Utils/link-preview.js +1 -34
  74. package/lib/Utils/logger.d.ts +3 -10
  75. package/lib/Utils/lt-hash.d.ts +2 -2
  76. package/lib/Utils/lt-hash.js +6 -6
  77. package/lib/Utils/make-mutex.d.ts +2 -2
  78. package/lib/Utils/messages-media.d.ts +24 -28
  79. package/lib/Utils/messages-media.js +115 -263
  80. package/lib/Utils/messages.d.ts +10 -8
  81. package/lib/Utils/messages.js +72 -298
  82. package/lib/Utils/noise-handler.d.ts +12 -10
  83. package/lib/Utils/noise-handler.js +23 -18
  84. package/lib/Utils/process-message.d.ts +4 -5
  85. package/lib/Utils/process-message.js +23 -74
  86. package/lib/Utils/signal.d.ts +1 -2
  87. package/lib/Utils/signal.js +35 -37
  88. package/lib/Utils/use-multi-file-auth-state.d.ts +1 -0
  89. package/lib/Utils/use-multi-file-auth-state.js +6 -51
  90. package/lib/Utils/validate-connection.d.ts +4 -3
  91. package/lib/Utils/validate-connection.js +52 -20
  92. package/lib/WABinary/constants.d.ts +4 -4
  93. package/lib/WABinary/constants.js +13 -1276
  94. package/lib/WABinary/decode.d.ts +4 -3
  95. package/lib/WABinary/decode.js +13 -26
  96. package/lib/WABinary/encode.d.ts +2 -1
  97. package/lib/WABinary/encode.js +17 -39
  98. package/lib/WABinary/generic-utils.d.ts +3 -1
  99. package/lib/WABinary/generic-utils.js +85 -2
  100. package/lib/WABinary/jid-utils.d.ts +5 -10
  101. package/lib/WABinary/jid-utils.js +5 -26
  102. package/lib/WAM/BinaryInfo.d.ts +11 -2
  103. package/lib/WAM/encode.d.ts +2 -1
  104. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
  105. package/lib/index.d.ts +2 -6
  106. package/lib/index.js +7 -21
  107. package/lib/index.js.bak +48 -0
  108. package/package.json +103 -111
  109. package/LICENSE +0 -21
  110. package/WAProto/GenerateStatics.sh +0 -4
  111. package/WAProto/WAProto.proto +0 -4775
  112. package/WAProto/index.d.ts +0 -55057
  113. package/WAProto/index.ts.ts +0 -53473
  114. package/WAProto/p.html +0 -1
  115. package/lib/WABinary/jid-utils.js.bak +0 -83
  116. /package/lib/Socket/Client/{types.js → abstract-socket-client.js} +0 -0
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.makeChatsSocket = void 0;
7
7
  const boom_1 = require("@hapi/boom");
8
- const node_cache_1 = __importDefault(require("@cacheable/node-cache"));
9
8
  const WAProto_1 = require("../../WAProto");
10
9
  const Defaults_1 = require("../Defaults");
11
10
  const Types_1 = require("../Types");
@@ -13,6 +12,7 @@ const Utils_1 = require("../Utils");
13
12
  const make_mutex_1 = require("../Utils/make-mutex");
14
13
  const process_message_1 = __importDefault(require("../Utils/process-message"));
15
14
  const WABinary_1 = require("../WABinary");
15
+ const socket_1 = require("./socket");
16
16
  const WAUSync_1 = require("../WAUSync");
17
17
  const usync_1 = require("./usync");
18
18
  const MAX_SYNC_ATTEMPTS = 2;
@@ -25,13 +25,6 @@ const makeChatsSocket = (config) => {
25
25
  let pendingAppStateSync = false;
26
26
  /** this mutex ensures that the notifications (receipts, messages etc.) are processed in order */
27
27
  const processingMutex = (0, make_mutex_1.makeMutex)();
28
- const placeholderResendCache = config.placeholderResendCache || new node_cache_1.default({
29
- stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY, // 1 hour
30
- useClones: false
31
- });
32
- if (!config.placeholderResendCache) {
33
- config.placeholderResendCache = placeholderResendCache;
34
- }
35
28
  /** helper function to fetch the given app state sync key */
36
29
  const getAppStateSyncKey = async (keyId) => {
37
30
  const { [keyId]: key } = await authState.keys.get('app-state-sync-key', [keyId]);
@@ -75,12 +68,6 @@ const makeChatsSocket = (config) => {
75
68
  }]
76
69
  });
77
70
  };
78
- const updateMessagesPrivacy = async (value) => {
79
- await privacyQuery('messages', value);
80
- };
81
- const updateCallPrivacy = async (value) => {
82
- await privacyQuery('calladd', value);
83
- };
84
71
  const updateLastSeenPrivacy = async (value) => {
85
72
  await privacyQuery('last', value);
86
73
  };
@@ -115,34 +102,44 @@ const makeChatsSocket = (config) => {
115
102
  }]
116
103
  });
117
104
  };
118
- const getBotListV2 = async () => {
119
- const resp = await query({
105
+ /** helper function to run a generic IQ query */
106
+ const interactiveQuery = async (userNodes, queryNode) => {
107
+ const result = await query({
120
108
  tag: 'iq',
121
109
  attrs: {
122
- xmlns: 'bot',
123
110
  to: WABinary_1.S_WHATSAPP_NET,
124
- type: 'get'
111
+ type: 'get',
112
+ xmlns: 'usync',
125
113
  },
126
- content: [{
127
- tag: 'bot',
114
+ content: [
115
+ {
116
+ tag: 'usync',
128
117
  attrs: {
129
- v: '2'
130
- }
131
- }]
132
- });
133
- const botNode = (0, WABinary_1.getBinaryNodeChild)(resp, 'bot');
134
- const botList = [];
135
- for (const section of (0, WABinary_1.getBinaryNodeChildren)(botNode, 'section')) {
136
- if (section.attrs.type === 'all') {
137
- for (const bot of (0, WABinary_1.getBinaryNodeChildren)(section, 'bot')) {
138
- botList.push({
139
- jid: bot.attrs.jid,
140
- personaId: bot.attrs['persona_id']
141
- });
118
+ sid: generateMessageTag(),
119
+ mode: 'query',
120
+ last: 'true',
121
+ index: '0',
122
+ context: 'interactive',
123
+ },
124
+ content: [
125
+ {
126
+ tag: 'query',
127
+ attrs: {},
128
+ content: [queryNode]
129
+ },
130
+ {
131
+ tag: 'list',
132
+ attrs: {},
133
+ content: userNodes
134
+ }
135
+ ]
142
136
  }
143
- }
144
- }
145
- return botList;
137
+ ],
138
+ });
139
+ const usyncNode = (0, WABinary_1.getBinaryNodeChild)(result, 'usync');
140
+ const listNode = (0, WABinary_1.getBinaryNodeChild)(usyncNode, 'list');
141
+ const users = (0, WABinary_1.getBinaryNodeChildren)(listNode, 'user');
142
+ return users;
146
143
  };
147
144
  const onWhatsApp = async (...jids) => {
148
145
  const usyncQuery = new WAUSync_1.USyncQuery()
@@ -157,26 +154,14 @@ const makeChatsSocket = (config) => {
157
154
  return results.list.filter((a) => !!a.contact).map(({ contact, id, lid }) => ({ jid: id, exists: contact, lid }));
158
155
  }
159
156
  };
160
- const fetchStatus = async (...jids) => {
161
- const usyncQuery = new WAUSync_1.USyncQuery()
162
- .withStatusProtocol();
163
- for (const jid of jids) {
164
- usyncQuery.withUser(new WAUSync_1.USyncUser().withId(jid));
165
- }
166
- const result = await sock.executeUSyncQuery(usyncQuery);
167
- if (result) {
168
- return result.list;
169
- }
170
- };
171
- const fetchDisappearingDuration = async (...jids) => {
172
- const usyncQuery = new WAUSync_1.USyncQuery()
173
- .withDisappearingModeProtocol();
174
- for (const jid of jids) {
175
- usyncQuery.withUser(new WAUSync_1.USyncUser().withId(jid));
176
- }
177
- const result = await sock.executeUSyncQuery(usyncQuery);
157
+ const fetchStatus = async (jid) => {
158
+ const [result] = await interactiveQuery([{ tag: 'user', attrs: { jid } }], { tag: 'status', attrs: {} });
178
159
  if (result) {
179
- return result.list;
160
+ const status = (0, WABinary_1.getBinaryNodeChild)(result, 'status');
161
+ return {
162
+ status: status === null || status === void 0 ? void 0 : status.content.toString(),
163
+ setAt: new Date(+((status === null || status === void 0 ? void 0 : status.attrs.t) || 0) * 1000)
164
+ };
180
165
  }
181
166
  };
182
167
  /** update the profile picture for yourself or a group */
@@ -305,9 +290,9 @@ const makeChatsSocket = (config) => {
305
290
  const email = (0, WABinary_1.getBinaryNodeChild)(profiles, 'email');
306
291
  const category = (0, WABinary_1.getBinaryNodeChild)((0, WABinary_1.getBinaryNodeChild)(profiles, 'categories'), 'category');
307
292
  const businessHours = (0, WABinary_1.getBinaryNodeChild)(profiles, 'business_hours');
308
- const businessHoursConfig = businessHours
309
- ? (0, WABinary_1.getBinaryNodeChildren)(businessHours, 'business_hours_config')
310
- : undefined;
293
+ const businessHoursConfig = businessHours ?
294
+ (0, WABinary_1.getBinaryNodeChildren)(businessHours, 'business_hours_config') :
295
+ undefined;
311
296
  const websiteStr = (_a = website === null || website === void 0 ? void 0 : website.content) === null || _a === void 0 ? void 0 : _a.toString();
312
297
  return {
313
298
  wid: (_b = profiles.attrs) === null || _b === void 0 ? void 0 : _b.jid,
@@ -416,12 +401,16 @@ const makeChatsSocket = (config) => {
416
401
  states[name] = newState;
417
402
  Object.assign(globalMutationMap, mutationMap);
418
403
  logger.info(`restored state of ${name} from snapshot to v${newState.version} with mutations`);
419
- await authState.keys.set({ 'app-state-sync-version': { [name]: newState } });
404
+ await authState.keys.set({ 'app-state-sync-version': {
405
+ [name]: newState
406
+ } });
420
407
  }
421
408
  // only process if there are syncd patches
422
409
  if (patches.length) {
423
410
  const { state: newState, mutationMap } = await (0, Utils_1.decodePatches)(name, patches, states[name], getAppStateSyncKey, config.options, initialVersionMap[name], logger, appStateMacVerification.patch);
424
- await authState.keys.set({ 'app-state-sync-version': { [name]: newState } });
411
+ await authState.keys.set({ 'app-state-sync-version': {
412
+ [name]: newState
413
+ } });
425
414
  logger.info(`synced ${name} to v${newState.version}`);
426
415
  initialVersionMap[name] = newState.version;
427
416
  Object.assign(globalMutationMap, mutationMap);
@@ -436,11 +425,13 @@ const makeChatsSocket = (config) => {
436
425
  catch (error) {
437
426
  // if retry attempts overshoot
438
427
  // or key not found
439
- const isIrrecoverableError = attemptsMap[name] >= MAX_SYNC_ATTEMPTS
440
- || ((_a = error.output) === null || _a === void 0 ? void 0 : _a.statusCode) === 404
441
- || error.name === 'TypeError';
428
+ const isIrrecoverableError = attemptsMap[name] >= MAX_SYNC_ATTEMPTS ||
429
+ ((_a = error.output) === null || _a === void 0 ? void 0 : _a.statusCode) === 404 ||
430
+ error.name === 'TypeError';
442
431
  logger.info({ name, error: error.stack }, `failed to sync state from version${isIrrecoverableError ? '' : ', removing and trying from scratch'}`);
443
- await authState.keys.set({ 'app-state-sync-version': { [name]: null } });
432
+ await authState.keys.set({ 'app-state-sync-version': {
433
+ [name]: null
434
+ } });
444
435
  // increment number of retries
445
436
  attemptsMap[name] = (attemptsMap[name] || 0) + 1;
446
437
  if (isIrrecoverableError) {
@@ -490,7 +481,7 @@ const makeChatsSocket = (config) => {
490
481
  await sendNode({
491
482
  tag: 'presence',
492
483
  attrs: {
493
- name: me.name.replace(/@/g, ''),
484
+ name: me.name,
494
485
  type
495
486
  }
496
487
  });
@@ -524,22 +515,22 @@ const makeChatsSocket = (config) => {
524
515
  id: generateMessageTag(),
525
516
  type: 'subscribe'
526
517
  },
527
- content: tcToken
528
- ? [
518
+ content: tcToken ?
519
+ [
529
520
  {
530
521
  tag: 'tctoken',
531
522
  attrs: {},
532
523
  content: tcToken
533
524
  }
534
- ]
535
- : undefined
525
+ ] :
526
+ undefined
536
527
  }));
537
528
  const handlePresenceUpdate = ({ tag, attrs, content }) => {
538
529
  var _a;
539
530
  let presence;
540
531
  const jid = attrs.from;
541
532
  const participant = attrs.participant || attrs.from;
542
- if (shouldIgnoreJid(jid) && jid != '@s.whatsapp.net') {
533
+ if (shouldIgnoreJid(jid) && jid !== '@s.whatsapp.net') {
543
534
  return;
544
535
  }
545
536
  if (tag === 'presence') {
@@ -563,7 +554,9 @@ const makeChatsSocket = (config) => {
563
554
  logger.error({ tag, attrs, content }, 'recv invalid presence node');
564
555
  }
565
556
  if (presence) {
566
- ev.emit('presence.update', { id: jid, presences: { [participant]: presence } });
557
+ ev.emit('presence.update', { id: jid, presences: {
558
+ [participant]: presence
559
+ } });
567
560
  }
568
561
  };
569
562
  const appPatch = async (patchCreate) => {
@@ -614,7 +607,9 @@ const makeChatsSocket = (config) => {
614
607
  ]
615
608
  };
616
609
  await query(node);
617
- await authState.keys.set({ 'app-state-sync-version': { [name]: state } });
610
+ await authState.keys.set({ 'app-state-sync-version': {
611
+ [name]: state
612
+ } });
618
613
  });
619
614
  });
620
615
  if (config.emitOwnEvents) {
@@ -627,7 +622,7 @@ const makeChatsSocket = (config) => {
627
622
  };
628
623
  /** sending non-abt props may fix QR scan fail if server expects */
629
624
  const fetchProps = async () => {
630
- var _a, _b, _c;
625
+ var _a, _b;
631
626
  const resultNode = await query({
632
627
  tag: 'iq',
633
628
  attrs: {
@@ -636,19 +631,20 @@ const makeChatsSocket = (config) => {
636
631
  type: 'get',
637
632
  },
638
633
  content: [
639
- { tag: 'props', attrs: {
634
+ {
635
+ tag: 'props',
636
+ attrs: {
640
637
  protocol: '2',
641
638
  hash: ((_a = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _a === void 0 ? void 0 : _a.lastPropHash) || ''
642
- } }
639
+ }
640
+ }
643
641
  ]
644
642
  });
645
643
  const propsNode = (0, WABinary_1.getBinaryNodeChild)(resultNode, 'props');
646
644
  let props = {};
647
645
  if (propsNode) {
648
- if ((_b = propsNode.attrs) === null || _b === void 0 ? void 0 : _b.hash) { // on some clients, the hash is returning as undefined
649
- authState.creds.lastPropHash = (_c = propsNode === null || propsNode === void 0 ? void 0 : propsNode.attrs) === null || _c === void 0 ? void 0 : _c.hash;
650
- ev.emit('creds.update', authState.creds);
651
- }
646
+ authState.creds.lastPropHash = (_b = propsNode === null || propsNode === void 0 ? void 0 : propsNode.attrs) === null || _b === void 0 ? void 0 : _b.hash;
647
+ ev.emit('creds.update', authState.creds);
652
648
  props = (0, WABinary_1.reduceBinaryNodeToDictionary)(propsNode, 'prop');
653
649
  }
654
650
  logger.debug('fetched props');
@@ -658,7 +654,7 @@ const makeChatsSocket = (config) => {
658
654
  * modify a chat -- mark unread, read etc.
659
655
  * lastMessages must be sorted in reverse chronologically
660
656
  * requires the last messages till the last message received; required for archive & unread
661
- */
657
+ */
662
658
  const chatModify = (mod, jid) => {
663
659
  const patch = (0, Utils_1.chatModificationToAppPatch)(mod, jid);
664
660
  return appPatch(patch);
@@ -742,25 +738,24 @@ const makeChatsSocket = (config) => {
742
738
  }
743
739
  }
744
740
  const historyMsg = (0, Utils_1.getHistoryMsg)(msg.message);
745
- const shouldProcessHistoryMsg = historyMsg
746
- ? (shouldSyncHistoryMessage(historyMsg)
747
- && Defaults_1.PROCESSABLE_HISTORY_TYPES.includes(historyMsg.syncType))
748
- : false;
741
+ const shouldProcessHistoryMsg = historyMsg ?
742
+ (shouldSyncHistoryMessage(historyMsg) &&
743
+ Defaults_1.PROCESSABLE_HISTORY_TYPES.includes(historyMsg.syncType)) :
744
+ false;
749
745
  if (historyMsg && !authState.creds.myAppStateKeyId) {
750
746
  logger.warn('skipping app state sync, as myAppStateKeyId is not set');
751
747
  pendingAppStateSync = true;
752
748
  }
753
749
  await Promise.all([
754
750
  (async () => {
755
- if (historyMsg
756
- && authState.creds.myAppStateKeyId) {
751
+ if (historyMsg &&
752
+ authState.creds.myAppStateKeyId) {
757
753
  pendingAppStateSync = false;
758
754
  await doAppStateSync();
759
755
  }
760
756
  })(),
761
757
  (0, process_message_1.default)(msg, {
762
758
  shouldProcessHistoryMsg,
763
- placeholderResendCache,
764
759
  ev,
765
760
  creds: authState.creds,
766
761
  keyStore: authState.keys,
@@ -769,8 +764,8 @@ const makeChatsSocket = (config) => {
769
764
  getMessage: config.getMessage,
770
765
  })
771
766
  ]);
772
- if (((_c = (_b = msg.message) === null || _b === void 0 ? void 0 : _b.protocolMessage) === null || _c === void 0 ? void 0 : _c.appStateSyncKeyShare)
773
- && pendingAppStateSync) {
767
+ if (((_c = (_b = msg.message) === null || _b === void 0 ? void 0 : _b.protocolMessage) === null || _c === void 0 ? void 0 : _c.appStateSyncKeyShare) &&
768
+ pendingAppStateSync) {
774
769
  await doAppStateSync();
775
770
  pendingAppStateSync = false;
776
771
  }
@@ -821,17 +816,18 @@ const makeChatsSocket = (config) => {
821
816
  sendPresenceUpdate(markOnlineOnConnect ? 'available' : 'unavailable')
822
817
  .catch(error => onUnexpectedError(error, 'presence update requests'));
823
818
  }
824
- if (receivedPendingNotifications && // if we don't have the app state key
819
+ if (receivedPendingNotifications) {
820
+ // if we don't have the app state key
825
821
  // we keep buffering events until we finally have
826
822
  // the key and can sync the messages
827
- !((_a = authState.creds) === null || _a === void 0 ? void 0 : _a.myAppStateKeyId)) {
828
- ev.buffer();
829
- needToFlushWithAppStateSync = true;
823
+ if (!((_a = authState.creds) === null || _a === void 0 ? void 0 : _a.myAppStateKeyId) && !config.mobile) {
824
+ ev.buffer();
825
+ needToFlushWithAppStateSync = true;
826
+ }
830
827
  }
831
828
  });
832
829
  return {
833
830
  ...sock,
834
- getBotListV2,
835
831
  processingMutex,
836
832
  fetchPrivacySettings,
837
833
  upsertMessage,
@@ -841,15 +837,12 @@ const makeChatsSocket = (config) => {
841
837
  profilePictureUrl,
842
838
  onWhatsApp,
843
839
  fetchBlocklist,
844
- fetchDisappearingDuration,
845
840
  fetchStatus,
846
841
  updateProfilePicture,
847
842
  removeProfilePicture,
848
843
  updateProfileStatus,
849
844
  updateProfileName,
850
845
  updateBlockStatus,
851
- updateCallPrivacy,
852
- updateMessagesPrivacy,
853
846
  updateLastSeenPrivacy,
854
847
  updateOnlinePrivacy,
855
848
  updateProfilePicturePrivacy,
@@ -0,0 +1,219 @@
1
+ // dugong.d.ts
2
+ import { proto } from '../../WAProto';
3
+
4
+ declare namespace kikyy {
5
+ interface MediaUploadOptions {
6
+ fileEncSha256?: Buffer;
7
+ mediaType?: string;
8
+ newsletter?: boolean;
9
+ }
10
+
11
+ type WAMediaUploadFunction = (
12
+ stream: Buffer | NodeJS.ReadableStream,
13
+ options?: MediaUploadOptions
14
+ ) => Promise<{ url: string; directPath: string }>;
15
+
16
+ interface WAMessageContentGenerationOptions {
17
+ upload?: WAMediaUploadFunction;
18
+ mediaCache?: any;
19
+ options?: any;
20
+ logger?: any;
21
+ }
22
+
23
+ interface StickerMessage {
24
+ url: string;
25
+ fileSha256: Buffer | string;
26
+ fileEncSha256: Buffer | string;
27
+ mediaKey: Buffer | string;
28
+ mimetype: string;
29
+ directPath: string;
30
+ fileLength: number | string;
31
+ mediaKeyTimestamp: number | string;
32
+ isAnimated?: boolean;
33
+ stickerSentTs?: number | string;
34
+ isAvatar?: boolean;
35
+ isAiSticker?: boolean;
36
+ isLottie?: boolean;
37
+ }
38
+
39
+ interface PaymentMessage {
40
+ amount: number;
41
+ currency?: string;
42
+ from?: string;
43
+ expiry?: number;
44
+ sticker?: { stickerMessage: StickerMessage };
45
+ note?: string;
46
+ background?: {
47
+ id?: string;
48
+ fileLength?: string;
49
+ width?: number;
50
+ height?: number;
51
+ mimetype?: string;
52
+ placeholderArgb?: number;
53
+ textArgb?: number;
54
+ subtextArgb?: number;
55
+ };
56
+ }
57
+
58
+ interface ProductMessage {
59
+ title: string;
60
+ description: string;
61
+ thumbnail: Buffer | { url: string };
62
+ productId: string;
63
+ retailerId: string;
64
+ url: string;
65
+ body?: string;
66
+ footer?: string;
67
+ buttons?: proto.Message.InteractiveMessage.INativeFlowButton[];
68
+ priceAmount1000?: number | null;
69
+ currencyCode?: string;
70
+ }
71
+
72
+ interface InteractiveMessage {
73
+ title: string;
74
+ footer?: string;
75
+ thumbnail?: string;
76
+ image?: string | Buffer | { url: string };
77
+ video?: string | Buffer | { url: string };
78
+ document?: Buffer;
79
+ mimetype?: string;
80
+ fileName?: string;
81
+ jpegThumbnail?: Buffer; // Hanya Buffer saja
82
+ contextInfo?: {
83
+ mentionedJid?: string[];
84
+ forwardingScore?: number;
85
+ isForwarded?: boolean;
86
+ externalAdReply?: {
87
+ title?: string;
88
+ body?: string;
89
+ mediaType?: number;
90
+ thumbnailUrl?: string;
91
+ mediaUrl?: string;
92
+ sourceUrl?: string;
93
+ showAdAttribution?: boolean;
94
+ renderLargerThumbnail?: boolean;
95
+ [key: string]: any;
96
+ };
97
+ [key: string]: any;
98
+ };
99
+ externalAdReply?: {
100
+ title?: string;
101
+ body?: string;
102
+ mediaType?: number;
103
+ thumbnailUrl?: string;
104
+ mediaUrl?: string;
105
+ sourceUrl?: string;
106
+ showAdAttribution?: boolean;
107
+ renderLargerThumbnail?: boolean;
108
+ [key: string]: any;
109
+ };
110
+ buttons?: proto.Message.InteractiveMessage.INativeFlowButton[];
111
+ nativeFlowMessage?: {
112
+ messageParamsJson?: string;
113
+ buttons?: proto.Message.InteractiveMessage.INativeFlowButton[];
114
+ [key: string]: any;
115
+ };
116
+ }
117
+
118
+ interface AlbumItem {
119
+ image?: { url: string; caption?: string };
120
+ video?: { url: string; caption?: string };
121
+ }
122
+
123
+ interface EventMessageLocation {
124
+ degreesLatitude: number;
125
+ degreesLongitude: number;
126
+ name: string;
127
+ }
128
+
129
+ interface EventMessage {
130
+ isCanceled?: boolean;
131
+ name: string;
132
+ description: string;
133
+ location?: EventMessageLocation;
134
+ joinLink?: string;
135
+ startTime?: string | number;
136
+ endTime?: string | number;
137
+ extraGuestsAllowed?: boolean;
138
+ }
139
+
140
+ interface PollVote {
141
+ optionName: string;
142
+ optionVoteCount: string | number;
143
+ }
144
+
145
+ interface PollResultMessage {
146
+ name: string;
147
+ pollVotes: PollVote[];
148
+ }
149
+
150
+ interface MessageContent {
151
+ requestPaymentMessage?: PaymentMessage;
152
+ productMessage?: ProductMessage;
153
+ interactiveMessage?: InteractiveMessage;
154
+ albumMessage?: AlbumItem[];
155
+ eventMessage?: EventMessage;
156
+ pollResultMessage?: PollResultMessage;
157
+ sender?: string;
158
+ }
159
+
160
+ interface MessageOptions {
161
+ quoted?: proto.IWebMessageInfo;
162
+ filter?: boolean;
163
+ }
164
+
165
+ interface Utils {
166
+ prepareWAMessageMedia: (media: any, options: WAMessageContentGenerationOptions) => Promise<any>;
167
+ generateWAMessageContent: (content: any, options: WAMessageContentGenerationOptions) => Promise<any>;
168
+ generateWAMessageFromContent: (jid: string, content: any, options?: any) => Promise<any>;
169
+ generateWAMessage: (jid: string, content: any, options?: any) => Promise<any>;
170
+ generateMessageID: () => string;
171
+ }
172
+ }
173
+
174
+ declare class kikyy {
175
+ constructor(
176
+ utils: kikyy.Utils,
177
+ waUploadToServer: kikyy.WAMediaUploadFunction,
178
+ relayMessageFn?: (jid: string, content: any, options?: any) => Promise<any>
179
+ );
180
+
181
+ detectType(content: kikyy.MessageContent): 'PAYMENT' | 'PRODUCT' | 'INTERACTIVE' | 'ALBUM' | 'EVENT' | 'POLL_RESULT' | null;
182
+
183
+ handlePayment(
184
+ content: { requestPaymentMessage: kikyy.PaymentMessage },
185
+ quoted?: proto.IWebMessageInfo
186
+ ): Promise<{ requestPaymentMessage: proto.Message.RequestPaymentMessage }>;
187
+
188
+ handleProduct(
189
+ content: { productMessage: kikyy.ProductMessage },
190
+ jid: string,
191
+ quoted?: proto.IWebMessageInfo
192
+ ): Promise<{ viewOnceMessage: proto.Message.ViewOnceMessage }>;
193
+
194
+ handleInteractive(
195
+ content: { interactiveMessage: kikyy.InteractiveMessage },
196
+ jid: string,
197
+ quoted?: proto.IWebMessageInfo
198
+ ): Promise<{ interactiveMessage: proto.Message.InteractiveMessage }>;
199
+
200
+ handleAlbum(
201
+ content: { albumMessage: kikyy.AlbumItem[] },
202
+ jid: string,
203
+ quoted?: proto.IWebMessageInfo
204
+ ): Promise<any>;
205
+
206
+ handleEvent(
207
+ content: { eventMessage: kikyy.EventMessage },
208
+ jid: string,
209
+ quoted?: proto.IWebMessageInfo
210
+ ): Promise<any>;
211
+
212
+ handlePollResult(
213
+ content: { pollResultMessage: kikyy.PollResultMessage },
214
+ jid: string,
215
+ quoted?: proto.IWebMessageInfo
216
+ ): Promise<any>;
217
+ }
218
+
219
+ export = kikyy;