@hansaka02/baileys 7.3.2 → 7.3.4

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 (202) hide show
  1. package/README.md +247 -203
  2. package/lib/Defaults/connection.js +51 -0
  3. package/lib/Defaults/constants.js +62 -0
  4. package/lib/Defaults/history.js +17 -0
  5. package/lib/Defaults/index.js +36 -142
  6. package/lib/Defaults/media.js +48 -0
  7. package/lib/Defaults/prefix.js +18 -0
  8. package/lib/Signal/Group/group-session-builder.js +10 -42
  9. package/lib/Signal/Group/group_cipher.js +9 -6
  10. package/lib/Signal/Group/index.js +39 -53
  11. package/lib/Signal/Group/keyhelper.js +8 -41
  12. package/lib/Signal/Group/sender-chain-key.js +4 -4
  13. package/lib/Signal/Group/sender-key-distribution-message.js +5 -5
  14. package/lib/Signal/Group/sender-key-message.js +12 -8
  15. package/lib/Signal/Group/sender-key-record.js +7 -7
  16. package/lib/Signal/Group/sender-key-state.js +4 -4
  17. package/lib/Signal/Group/sender-message-key.js +2 -2
  18. package/lib/Signal/libsignal.js +45 -69
  19. package/lib/Signal/lid-mapping.js +15 -11
  20. package/lib/Socket/Client/types.js +2 -2
  21. package/lib/Socket/Client/websocket.js +16 -14
  22. package/lib/Socket/business.js +41 -32
  23. package/lib/Socket/chats.js +123 -98
  24. package/lib/Socket/community.js +50 -40
  25. package/lib/Socket/groups.js +59 -47
  26. package/lib/Socket/index.js +4 -4
  27. package/lib/Socket/messages-recv.js +219 -172
  28. package/lib/Socket/messages-send.js +187 -143
  29. package/lib/Socket/newsletter.js +61 -47
  30. package/lib/Socket/socket.js +133 -90
  31. package/lib/Socket/usync.js +6 -6
  32. package/lib/Store/index.js +27 -11
  33. package/lib/Store/make-cache-manager-store.js +14 -15
  34. package/lib/Store/make-in-memory-store.js +28 -24
  35. package/lib/Types/LabelAssociation.js +2 -2
  36. package/lib/Types/Message.js +6 -6
  37. package/lib/Types/MexUpdates.js +5 -5
  38. package/lib/Types/State.js +4 -4
  39. package/lib/Types/index.js +28 -12
  40. package/lib/Utils/auth-utils.js +28 -26
  41. package/lib/Utils/baileys-event-stream.js +68 -69
  42. package/lib/Utils/business.js +63 -53
  43. package/lib/Utils/chat-utils.js +81 -71
  44. package/lib/Utils/crypto.js +25 -45
  45. package/lib/Utils/decode-wa-message.js +319 -311
  46. package/lib/Utils/event-buffer.js +21 -22
  47. package/lib/Utils/generics.js +65 -82
  48. package/lib/Utils/history.js +21 -21
  49. package/lib/Utils/index.js +27 -13
  50. package/lib/Utils/link-preview.js +7 -30
  51. package/lib/Utils/logger.js +5 -5
  52. package/lib/Utils/lt-hash.js +3 -3
  53. package/lib/Utils/message-retry-manager.js +4 -4
  54. package/lib/Utils/messages-media.js +104 -109
  55. package/lib/Utils/messages.js +203 -171
  56. package/lib/Utils/noise-handler.js +28 -19
  57. package/lib/Utils/process-message.js +111 -96
  58. package/lib/Utils/signal.js +36 -25
  59. package/lib/Utils/use-multi-file-auth-state.js +18 -22
  60. package/lib/Utils/validate-connection.js +52 -45
  61. package/lib/WABinary/decode.js +6 -32
  62. package/lib/WABinary/encode.js +3 -29
  63. package/lib/WABinary/generic-utils.js +4 -4
  64. package/lib/WABinary/index.js +27 -11
  65. package/lib/WAM/encode.js +16 -8
  66. package/lib/WAM/index.js +27 -11
  67. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +20 -16
  68. package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
  69. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +7 -4
  70. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -2
  71. package/lib/WAUSync/Protocols/USyncLIDProtocol.js +0 -2
  72. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -2
  73. package/lib/WAUSync/Protocols/index.js +27 -11
  74. package/lib/WAUSync/USyncQuery.js +17 -10
  75. package/lib/WAUSync/index.js +27 -11
  76. package/lib/index.js +60 -31
  77. package/package.json +8 -14
  78. package/WAProto/AICommon/AICommon.d.ts +0 -11702
  79. package/WAProto/Adv/Adv.d.ts +0 -643
  80. package/WAProto/BotMetadata/BotMetadata.d.ts +0 -5654
  81. package/WAProto/Cert/Cert.d.ts +0 -613
  82. package/WAProto/ChatLockSettings/ChatLockSettings.d.ts +0 -476
  83. package/WAProto/CompanionReg/CompanionReg.d.ts +0 -1361
  84. package/WAProto/DeviceCapabilities/DeviceCapabilities.d.ts +0 -577
  85. package/WAProto/E2E/E2E.d.ts +0 -41724
  86. package/WAProto/Ephemeral/Ephemeral.d.ts +0 -114
  87. package/WAProto/HistorySync/HistorySync.d.ts +0 -51700
  88. package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.d.ts +0 -229
  89. package/WAProto/MdStorageChatRowOpaqueData/MdStorageChatRowOpaqueData.d.ts +0 -583
  90. package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.d.ts +0 -42897
  91. package/WAProto/MmsRetry/MmsRetry.d.ts +0 -243
  92. package/WAProto/Protocol/Protocol.d.ts +0 -270
  93. package/WAProto/Reporting/Reporting.d.ts +0 -371
  94. package/WAProto/ServerSync/ServerSync.d.ts +0 -1285
  95. package/WAProto/SignalLocalStorageProtocol/SignalLocalStorageProtocol.d.ts +0 -1868
  96. package/WAProto/SignalWhisperTextProtocol/SignalWhisperTextProtocol.d.ts +0 -767
  97. package/WAProto/StatusAttributions/StatusAttributions.d.ts +0 -1027
  98. package/WAProto/SyncAction/SyncAction.d.ts +0 -11193
  99. package/WAProto/UserPassword/UserPassword.d.ts +0 -363
  100. package/WAProto/VnameCert/VnameCert.d.ts +0 -821
  101. package/WAProto/Wa6/Wa6.d.ts +0 -2128
  102. package/WAProto/Web/Web.d.ts +0 -46383
  103. package/WAProto/index.d.ts +0 -55
  104. package/lib/Defaults/index.d.ts +0 -77
  105. package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
  106. package/lib/Signal/Group/group-session-builder.d.ts +0 -17
  107. package/lib/Signal/Group/group_cipher.d.ts +0 -19
  108. package/lib/Signal/Group/index.d.ts +0 -11
  109. package/lib/Signal/Group/keyhelper.d.ts +0 -16
  110. package/lib/Signal/Group/sender-chain-key.d.ts +0 -14
  111. package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -17
  112. package/lib/Signal/Group/sender-key-message.d.ts +0 -19
  113. package/lib/Signal/Group/sender-key-name.d.ts +0 -19
  114. package/lib/Signal/Group/sender-key-record.d.ts +0 -32
  115. package/lib/Signal/Group/sender-key-state.d.ts +0 -44
  116. package/lib/Signal/Group/sender-message-key.d.ts +0 -11
  117. package/lib/Signal/libsignal.d.ts +0 -8
  118. package/lib/Signal/lid-mapping.d.ts +0 -28
  119. package/lib/Socket/Client/index.d.ts +0 -2
  120. package/lib/Socket/Client/types.d.ts +0 -16
  121. package/lib/Socket/Client/websocket.d.ts +0 -13
  122. package/lib/Socket/business.d.ts +0 -187
  123. package/lib/Socket/chats.d.ts +0 -97
  124. package/lib/Socket/community.d.ts +0 -129
  125. package/lib/Socket/groups.d.ts +0 -129
  126. package/lib/Socket/index.d.ts +0 -191
  127. package/lib/Socket/messages-recv.d.ts +0 -174
  128. package/lib/Socket/messages-send.d.ts +0 -165
  129. package/lib/Socket/newsletter.d.ts +0 -145
  130. package/lib/Socket/socket.d.ts +0 -45
  131. package/lib/Socket/usync.d.ts +0 -37
  132. package/lib/Store/index.d.ts +0 -4
  133. package/lib/Store/make-cache-manager-store.d.ts +0 -14
  134. package/lib/Store/make-in-memory-store.d.ts +0 -123
  135. package/lib/Store/make-ordered-dictionary.d.ts +0 -12
  136. package/lib/Store/object-repository.d.ts +0 -10
  137. package/lib/Types/Auth.d.ts +0 -121
  138. package/lib/Types/Bussiness.d.ts +0 -28
  139. package/lib/Types/Call.d.ts +0 -14
  140. package/lib/Types/Chat.d.ts +0 -143
  141. package/lib/Types/Contact.d.ts +0 -23
  142. package/lib/Types/Events.d.ts +0 -226
  143. package/lib/Types/GroupMetadata.d.ts +0 -66
  144. package/lib/Types/Label.d.ts +0 -48
  145. package/lib/Types/LabelAssociation.d.ts +0 -35
  146. package/lib/Types/Message.d.ts +0 -484
  147. package/lib/Types/MexUpdates.d.ts +0 -9
  148. package/lib/Types/Newsletter.d.ts +0 -109
  149. package/lib/Types/Product.d.ts +0 -92
  150. package/lib/Types/Signal.d.ts +0 -98
  151. package/lib/Types/Socket.d.ts +0 -141
  152. package/lib/Types/State.d.ts +0 -41
  153. package/lib/Types/USync.d.ts +0 -26
  154. package/lib/Types/index.d.ts +0 -80
  155. package/lib/Utils/auth-utils.d.ts +0 -21
  156. package/lib/Utils/baileys-event-stream.d.ts +0 -18
  157. package/lib/Utils/business.d.ts +0 -29
  158. package/lib/Utils/chat-utils.d.ts +0 -82
  159. package/lib/Utils/crypto.d.ts +0 -56
  160. package/lib/Utils/decode-wa-message.d.ts +0 -53
  161. package/lib/Utils/event-buffer.d.ts +0 -39
  162. package/lib/Utils/generics.d.ts +0 -117
  163. package/lib/Utils/history.d.ts +0 -23
  164. package/lib/Utils/index.d.ts +0 -20
  165. package/lib/Utils/link-preview.d.ts +0 -23
  166. package/lib/Utils/logger.d.ts +0 -13
  167. package/lib/Utils/lt-hash.d.ts +0 -14
  168. package/lib/Utils/make-mutex.d.ts +0 -9
  169. package/lib/Utils/message-retry-manager.d.ts +0 -88
  170. package/lib/Utils/messages-media.d.ts +0 -135
  171. package/lib/Utils/messages.d.ts +0 -105
  172. package/lib/Utils/noise-handler.d.ts +0 -20
  173. package/lib/Utils/process-message.d.ts +0 -49
  174. package/lib/Utils/signal.d.ts +0 -42
  175. package/lib/Utils/use-mongo-file-auth-state.d.ts +0 -6
  176. package/lib/Utils/use-mongo-file-auth-state.js +0 -84
  177. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
  178. package/lib/Utils/use-single-file-auth-state.d.ts +0 -13
  179. package/lib/Utils/use-single-file-auth-state.js +0 -80
  180. package/lib/Utils/validate-connection.d.ts +0 -13
  181. package/lib/WABinary/constants.d.ts +0 -30
  182. package/lib/WABinary/decode.d.ts +0 -9
  183. package/lib/WABinary/encode.d.ts +0 -3
  184. package/lib/WABinary/generic-utils.d.ts +0 -28
  185. package/lib/WABinary/index.d.ts +0 -5
  186. package/lib/WABinary/jid-utils.d.ts +0 -58
  187. package/lib/WABinary/types.d.ts +0 -22
  188. package/lib/WAM/BinaryInfo.d.ts +0 -16
  189. package/lib/WAM/constants.d.ts +0 -47
  190. package/lib/WAM/encode.d.ts +0 -3
  191. package/lib/WAM/index.d.ts +0 -3
  192. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +0 -28
  193. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -10
  194. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -26
  195. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -14
  196. package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +0 -10
  197. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -14
  198. package/lib/WAUSync/Protocols/index.d.ts +0 -6
  199. package/lib/WAUSync/USyncQuery.d.ts +0 -31
  200. package/lib/WAUSync/USyncUser.d.ts +0 -12
  201. package/lib/WAUSync/index.d.ts +0 -3
  202. package/lib/index.d.ts +0 -13
@@ -2,11 +2,20 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", { value: true })
4
4
 
5
- const boom_1 = require("@hapi/boom")
6
- const WAProto_1 = require("../../WAProto")
7
- const Defaults_1 = require("../Defaults")
8
- const WABinary_1 = require("../WABinary")
9
- const crypto_1 = require("./crypto")
5
+ const { Boom } = require("@hapi/boom")
6
+ const { proto } = require("../../WAProto")
7
+ const {
8
+ NOISE_MODE,
9
+ WA_CERT_DETAILS
10
+ } = require("../Defaults/constants")
11
+ const { decodeBinaryNode } = require("../WABinary")
12
+ const {
13
+ aesDecryptGCM,
14
+ aesEncryptGCM,
15
+ Curve,
16
+ hkdf,
17
+ sha256
18
+ } = require("./crypto")
10
19
 
11
20
  const generateIV = (counter) => {
12
21
  const iv = new ArrayBuffer(12)
@@ -18,11 +27,11 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
18
27
  logger = logger.child({ class: 'ns' })
19
28
  const authenticate = (data) => {
20
29
  if (!isFinished) {
21
- hash = crypto_1.sha256(Buffer.concat([hash, data]))
30
+ hash = sha256(Buffer.concat([hash, data]))
22
31
  }
23
32
  }
24
33
  const encrypt = (plaintext) => {
25
- const result = crypto_1.aesEncryptGCM(plaintext, encKey, generateIV(writeCounter), hash)
34
+ const result = aesEncryptGCM(plaintext, encKey, generateIV(writeCounter), hash)
26
35
  writeCounter += 1
27
36
  authenticate(result)
28
37
  return result
@@ -31,7 +40,7 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
31
40
  // before the handshake is finished, we use the same counter
32
41
  // after handshake, the counters are different
33
42
  const iv = generateIV(isFinished ? readCounter : writeCounter)
34
- const result = crypto_1.aesDecryptGCM(ciphertext, decKey, iv, hash)
43
+ const result = aesDecryptGCM(ciphertext, decKey, iv, hash)
35
44
  if (isFinished) {
36
45
  readCounter += 1
37
46
  }
@@ -42,7 +51,7 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
42
51
  return result
43
52
  }
44
53
  const localHKDF = async (data) => {
45
- const key = await crypto_1.hkdf(Buffer.from(data), 64, { salt, info: '' })
54
+ const key = await hkdf(Buffer.from(data), 64, { salt, info: '' })
46
55
  return [key.slice(0, 32), key.slice(32)]
47
56
  }
48
57
  const mixIntoKey = async (data) => {
@@ -62,8 +71,8 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
62
71
  writeCounter = 0
63
72
  isFinished = true
64
73
  }
65
- const data = Buffer.from(Defaults_1.NOISE_MODE)
66
- let hash = data.byteLength === 32 ? data : crypto_1.sha256(data)
74
+ const data = Buffer.from(NOISE_MODE)
75
+ let hash = data.byteLength === 32 ? data : sha256(data)
67
76
  let salt = hash
68
77
  let encKey = hash
69
78
  let decKey = hash
@@ -82,17 +91,17 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
82
91
  finishInit,
83
92
  processHandshake: async ({ serverHello }, noiseKey) => {
84
93
  authenticate(serverHello.ephemeral)
85
- await mixIntoKey(crypto_1.Curve.sharedKey(privateKey, serverHello.ephemeral))
94
+ await mixIntoKey(Curve.sharedKey(privateKey, serverHello.ephemeral))
86
95
  const decStaticContent = decrypt(serverHello.static)
87
- await mixIntoKey(crypto_1.Curve.sharedKey(privateKey, decStaticContent))
96
+ await mixIntoKey(Curve.sharedKey(privateKey, decStaticContent))
88
97
  const certDecoded = decrypt(serverHello.payload)
89
- const { intermediate: certIntermediate } = WAProto_1.proto.CertChain.decode(certDecoded)
90
- const { issuerSerial } = WAProto_1.proto.CertChain.NoiseCertificate.Details.decode(certIntermediate.details)
91
- if (issuerSerial !== Defaults_1.WA_CERT_DETAILS.SERIAL) {
92
- throw new boom_1.Boom('certification match failed', { statusCode: 400 })
98
+ const { intermediate: certIntermediate } = proto.CertChain.decode(certDecoded)
99
+ const { issuerSerial } = proto.CertChain.NoiseCertificate.Details.decode(certIntermediate.details)
100
+ if (issuerSerial !== WA_CERT_DETAILS.SERIAL) {
101
+ throw new Boom('certification match failed', { statusCode: 400 })
93
102
  }
94
103
  const keyEnc = encrypt(noiseKey.public)
95
- await mixIntoKey(crypto_1.Curve.sharedKey(noiseKey.private, serverHello.ephemeral))
104
+ await mixIntoKey(Curve.sharedKey(noiseKey.private, serverHello.ephemeral))
96
105
  return keyEnc
97
106
  },
98
107
  encodeFrame: (data) => {
@@ -140,7 +149,7 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
140
149
  inBytes = inBytes.slice(size + 3)
141
150
  if (isFinished) {
142
151
  const result = decrypt(frame)
143
- frame = await WABinary_1.decodeBinaryNode(result)
152
+ frame = await decodeBinaryNode(result)
144
153
  }
145
154
  logger.trace({ msg: frame?.attrs?.id }, 'recv frame')
146
155
  onFrame(frame)
@@ -2,31 +2,46 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", { value: true })
4
4
 
5
- const WAProto_1 = require("../../WAProto")
6
- const Types_1 = require("../Types")
7
- const messages_1 = require("../Utils/messages")
8
- const WABinary_1 = require("../WABinary")
9
- const crypto_1 = require("./crypto")
10
- const generics_1 = require("./generics")
11
- const history_1 = require("./history")
5
+ const { proto } = require("../../WAProto")
6
+ const { WAMessageStubType } = require("../Types")
7
+ const {
8
+ getDevice,
9
+ getContentType,
10
+ normalizeMessageContent
11
+ } = require("../Utils")
12
+ const {
13
+ areJidsSameUser,
14
+ isJidBroadcast,
15
+ isJidStatusBroadcast,
16
+ jidNormalizedUser
17
+ } = require("../WABinary")
18
+ const {
19
+ aesDecryptGCM,
20
+ hmacSign
21
+ } = require("./crypto")
22
+ const {
23
+ getKeyAuthor,
24
+ toNumber
25
+ } = require("./generics")
26
+ const { downloadAndProcessHistorySyncNotification } = require("./history")
12
27
 
13
28
  const REAL_MSG_STUB_TYPES = new Set([
14
- Types_1.WAMessageStubType.CALL_MISSED_GROUP_VIDEO,
15
- Types_1.WAMessageStubType.CALL_MISSED_GROUP_VOICE,
16
- Types_1.WAMessageStubType.CALL_MISSED_VIDEO,
17
- Types_1.WAMessageStubType.CALL_MISSED_VOICE
29
+ WAMessageStubType.CALL_MISSED_GROUP_VIDEO,
30
+ WAMessageStubType.CALL_MISSED_GROUP_VOICE,
31
+ WAMessageStubType.CALL_MISSED_VIDEO,
32
+ WAMessageStubType.CALL_MISSED_VOICE
18
33
  ])
19
34
 
20
35
  const REAL_MSG_REQ_ME_STUB_TYPES = new Set([
21
- Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD
36
+ WAMessageStubType.GROUP_PARTICIPANT_ADD
22
37
  ])
23
38
 
24
39
  /** Cleans a received message to further processing */
25
40
  const cleanMessage = (message, meId) => {
26
41
  // ensure remoteJid and participant doesn't have device or agent in it
27
- message.key.remoteJid = WABinary_1.jidNormalizedUser(message.key.remoteJid)
28
- message.key.participant = message.key.participant ? WABinary_1.jidNormalizedUser(message.key.participant) : undefined
29
- const content = messages_1.normalizeMessageContent(message.message)
42
+ message.key.remoteJid = jidNormalizedUser(message.key.remoteJid)
43
+ message.key.participant = message.key.participant ? jidNormalizedUser(message.key.participant) : undefined
44
+ const content = normalizeMessageContent(message.message)
30
45
  // if the message has a reaction, ensure fromMe & remoteJid are from our perspective
31
46
  if (content?.reactionMessage) {
32
47
  normaliseKey(content.reactionMessage.key)
@@ -41,7 +56,7 @@ const cleanMessage = (message, meId) => {
41
56
  // if the sender believed the message being reacted to is not from them
42
57
  // we've to correct the key to be from them, or some other participant
43
58
  msgKey.fromMe = !msgKey.fromMe
44
- ? WABinary_1.areJidsSameUser(msgKey.participant || msgKey.remoteJid, meId)
59
+ ? areJidsSameUser(msgKey.participant || msgKey.remoteJid, meId)
45
60
  // if the message being reacted to, was from them
46
61
  // fromMe automatically becomes false
47
62
  : false
@@ -54,14 +69,14 @@ const cleanMessage = (message, meId) => {
54
69
  }
55
70
 
56
71
  const isRealMessage = (message, meId) => {
57
- const normalizedContent = messages_1.normalizeMessageContent(message.message)
58
- const hasSomeContent = !!messages_1.getContentType(normalizedContent)
72
+ const normalizedContent = normalizeMessageContent(message.message)
73
+ const hasSomeContent = !!getContentType(normalizedContent)
59
74
  return (
60
75
  !!normalizedContent ||
61
76
  REAL_MSG_STUB_TYPES.has(message.messageStubType) ||
62
77
  (
63
78
  REAL_MSG_REQ_ME_STUB_TYPES.has(message.messageStubType) &&
64
- message.messageStubParameters?.some(p => WABinary_1.areJidsSameUser(meId, p))
79
+ message.messageStubParameters?.some(p => areJidsSameUser(meId, p))
65
80
  )
66
81
  ) &&
67
82
  hasSomeContent &&
@@ -77,8 +92,8 @@ const shouldIncrementChatUnread = (message) => (!message.key.fromMe && !message.
77
92
  * Typically -- that'll be the remoteJid, but for broadcasts, it'll be the participant
78
93
  */
79
94
  const getChatId = ({ remoteJid, participant, fromMe }) => {
80
- if (WABinary_1.isJidBroadcast(remoteJid)
81
- && !WABinary_1.isJidStatusBroadcast(remoteJid)
95
+ if (isJidBroadcast(remoteJid)
96
+ && !isJidStatusBroadcast(remoteJid)
82
97
  && !fromMe) {
83
98
  return participant
84
99
  }
@@ -99,12 +114,12 @@ function decryptPollVote({ encPayload, encIv }, { pollCreatorJid, pollMsgId, pol
99
114
  toBinary('Poll Vote'),
100
115
  new Uint8Array([1])
101
116
  ])
102
- const key0 = crypto_1.hmacSign(pollEncKey, new Uint8Array(32), 'sha256')
103
- const decKey = crypto_1.hmacSign(sign, key0, 'sha256')
117
+ const key0 = hmacSign(pollEncKey, new Uint8Array(32), 'sha256')
118
+ const decKey = hmacSign(sign, key0, 'sha256')
104
119
  const aad = toBinary(`${pollMsgId}\u0000${voterJid}`)
105
- const decrypted = crypto_1.aesDecryptGCM(encPayload, decKey, encIv, aad)
120
+ const decrypted = aesDecryptGCM(encPayload, decKey, encIv, aad)
106
121
 
107
- return WAProto_1.proto.Message.PollVoteMessage.decode(decrypted)
122
+ return proto.Message.PollVoteMessage.decode(decrypted)
108
123
 
109
124
  function toBinary(txt) {
110
125
  return Buffer.from(txt)
@@ -125,11 +140,11 @@ function decryptEventEdit({ encPayload, encIv }, { eventCreatorJid, eventMsgId,
125
140
  new Uint8Array([1])
126
141
  ])
127
142
 
128
- const key0 = crypto_1.hmacSign(eventEncKey, new Uint8Array(32), 'sha256')
129
- const decKey = crypto_1.hmacSign(sign, key0, 'sha256')
130
- const decrypted = crypto_1.aesDecryptGCM(encPayload, decKey, encIv, null)
143
+ const key0 = hmacSign(eventEncKey, new Uint8Array(32), 'sha256')
144
+ const decKey = hmacSign(sign, key0, 'sha256')
145
+ const decrypted = aesDecryptGCM(encPayload, decKey, encIv, null)
131
146
 
132
- return WAProto_1.proto.Message.decode(decrypted)
147
+ return proto.Message.decode(decrypted)
133
148
 
134
149
  function toBinary(txt) {
135
150
  return Buffer.from(txt)
@@ -151,12 +166,12 @@ function decryptEventResponse({ encPayload, encIv }, { eventCreatorJid, eventMsg
151
166
  new Uint8Array([1])
152
167
  ])
153
168
 
154
- const key0 = crypto_1.hmacSign(eventEncKey, new Uint8Array(32), 'sha256')
155
- const decKey = crypto_1.hmacSign(sign, key0, 'sha256')
169
+ const key0 = hmacSign(eventEncKey, new Uint8Array(32), 'sha256')
170
+ const decKey = hmacSign(sign, key0, 'sha256')
156
171
  const aad = toBinary(`${eventMsgId}\u0000${responderJid}`)
157
- const decrypted = crypto_1.aesDecryptGCM(encPayload, decKey, encIv, aad)
172
+ const decrypted = aesDecryptGCM(encPayload, decKey, encIv, aad)
158
173
 
159
- return WAProto_1.proto.Message.EventResponseMessage.decode(decrypted)
174
+ return proto.Message.EventResponseMessage.decode(decrypted)
160
175
 
161
176
  function toBinary(txt) {
162
177
  return Buffer.from(txt)
@@ -177,11 +192,11 @@ function decryptComment({ encPayload, encIv }, { commentCreatorJid, commentMsgId
177
192
  new Uint8Array([1])
178
193
  ])
179
194
 
180
- const key0 = crypto_1.hmacSign(commentEncKey, new Uint8Array(32), 'sha256')
181
- const decKey = crypto_1.hmacSign(sign, key0, 'sha256')
182
- const decrypted = crypto_1.aesDecryptGCM(encPayload, decKey, encIv, null)
195
+ const key0 = hmacSign(commentEncKey, new Uint8Array(32), 'sha256')
196
+ const decKey = hmacSign(sign, key0, 'sha256')
197
+ const decrypted = aesDecryptGCM(encPayload, decKey, encIv, null)
183
198
 
184
- return WAProto_1.proto.Message.decode(decrypted)
199
+ return proto.Message.decode(decrypted)
185
200
 
186
201
  function toBinary(txt) {
187
202
  return Buffer.from(txt)
@@ -202,11 +217,11 @@ function decryptReaction({ encPayload, encIv }, { reactionCreatorJid, reactionMs
202
217
  new Uint8Array([1])
203
218
  ])
204
219
 
205
- const key0 = crypto_1.hmacSign(reactionEncKey, new Uint8Array(32), 'sha256')
206
- const decKey = crypto_1.hmacSign(sign, key0, 'sha256')
207
- const decrypted = crypto_1.aesDecryptGCM(encPayload, decKey, encIv, null)
220
+ const key0 = hmacSign(reactionEncKey, new Uint8Array(32), 'sha256')
221
+ const decKey = hmacSign(sign, key0, 'sha256')
222
+ const decrypted = aesDecryptGCM(encPayload, decKey, encIv, null)
208
223
 
209
- return WAProto_1.proto.Message.ReactionMessage.decode(decrypted)
224
+ return proto.Message.ReactionMessage.decode(decrypted)
210
225
 
211
226
  function toBinary(txt) {
212
227
  return Buffer.from(txt)
@@ -217,17 +232,17 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
217
232
  const meId = creds.me.id
218
233
  const meLid = creds.me.lid
219
234
  const { accountSettings } = creds
220
- const chat = { id: WABinary_1.jidNormalizedUser(getChatId(message.key)) }
235
+ const chat = { id: jidNormalizedUser(getChatId(message.key)) }
221
236
  const isRealMsg = isRealMessage(message, meId)
222
237
  if (isRealMsg) {
223
238
  chat.messages = [{ message }]
224
- chat.conversationTimestamp = generics_1.toNumber(message.messageTimestamp)
239
+ chat.conversationTimestamp = toNumber(message.messageTimestamp)
225
240
  // only increment unread count if not CIPHERTEXT and from another person
226
241
  if (shouldIncrementChatUnread(message)) {
227
242
  chat.unreadCount = (chat.unreadCount || 0) + 1
228
243
  }
229
244
  }
230
- const content = messages_1.normalizeMessageContent(message.message)
245
+ const content = normalizeMessageContent(message.message)
231
246
  // unarchive chat if it's a real message, or someone reacted to our message
232
247
  // and we've the unarchive chats setting on
233
248
  if (isRealMsg || content?.reactionMessage?.key?.fromMe
@@ -238,7 +253,7 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
238
253
  const protocolMsg = content?.protocolMessage
239
254
  if (protocolMsg) {
240
255
  switch (protocolMsg.type) {
241
- case WAProto_1.proto.Message.ProtocolMessage.Type.HISTORY_SYNC_NOTIFICATION:
256
+ case proto.Message.ProtocolMessage.Type.HISTORY_SYNC_NOTIFICATION:
242
257
  const histNotification = protocolMsg.historySyncNotification
243
258
  const process = shouldProcessHistoryMsg
244
259
  const isLatest = !creds.processedHistoryMessages?.length
@@ -249,7 +264,7 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
249
264
  isLatest,
250
265
  }, 'got history notification')
251
266
  if (process) {
252
- if (histNotification.syncType !== WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND) {
267
+ if (histNotification.syncType !== proto.HistorySync.HistorySyncType.ON_DEMAND) {
253
268
  ev.emit('creds.update', {
254
269
  processedHistoryMessages: [
255
270
  ...(creds.processedHistoryMessages || []),
@@ -257,17 +272,17 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
257
272
  ]
258
273
  })
259
274
  }
260
- const data = await history_1.downloadAndProcessHistorySyncNotification(histNotification, options)
275
+ const data = await downloadAndProcessHistorySyncNotification(histNotification, options)
261
276
  ev.emit('messaging-history.set', {
262
277
  ...data,
263
- isLatest: histNotification.syncType !== WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND
278
+ isLatest: histNotification.syncType !== proto.HistorySync.HistorySyncType.ON_DEMAND
264
279
  ? isLatest
265
280
  : undefined,
266
281
  peerDataRequestSessionId: histNotification.peerDataRequestSessionId
267
282
  })
268
283
  }
269
284
  break
270
- case WAProto_1.proto.Message.ProtocolMessage.Type.APP_STATE_SYNC_KEY_SHARE:
285
+ case proto.Message.ProtocolMessage.Type.APP_STATE_SYNC_KEY_SHARE:
271
286
  const keys = protocolMsg.appStateSyncKeyShare.keys
272
287
  if (keys?.length) {
273
288
  let newAppStateSyncKeyId = ''
@@ -287,24 +302,24 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
287
302
  logger?.info({ protocolMsg }, 'recv app state sync with 0 keys')
288
303
  }
289
304
  break
290
- case WAProto_1.proto.Message.ProtocolMessage.Type.REVOKE:
305
+ case proto.Message.ProtocolMessage.Type.REVOKE:
291
306
  ev.emit('messages.update', [
292
307
  {
293
308
  key: {
294
309
  ...message.key,
295
310
  id: protocolMsg.key.id
296
311
  },
297
- update: { message: null, messageStubType: Types_1.WAMessageStubType.REVOKE, key: message.key }
312
+ update: { message: null, messageStubType: WAMessageStubType.REVOKE, key: message.key }
298
313
  }
299
314
  ])
300
315
  break
301
- case WAProto_1.proto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING:
316
+ case proto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING:
302
317
  Object.assign(chat, {
303
- ephemeralSettingTimestamp: generics_1.toNumber(message.messageTimestamp),
318
+ ephemeralSettingTimestamp: toNumber(message.messageTimestamp),
304
319
  ephemeralExpiration: protocolMsg.ephemeralExpiration || null
305
320
  })
306
321
  break
307
- case WAProto_1.proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE:
322
+ case proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_RESPONSE_MESSAGE:
308
323
  const response = protocolMsg.peerDataOperationRequestResponseMessage
309
324
  if (response) {
310
325
  await laceholderResendCache?.del(response.stanzaId)
@@ -314,7 +329,7 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
314
329
  const { placeholderMessageResendResponse: retryResponse } = result
315
330
  //eslint-disable-next-line max-depth
316
331
  if (retryResponse) {
317
- const webMessageInfo = WAProto_1.proto.WebMessageInfo.decode(retryResponse.webMessageInfoBytes)
332
+ const webMessageInfo = proto.WebMessageInfo.decode(retryResponse.webMessageInfoBytes)
318
333
  // wait till another upsert event is available, don't want it to be part of the PDO response message
319
334
  setTimeout(() => {
320
335
  ev.emit('messages.upsert', {
@@ -327,7 +342,7 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
327
342
  }
328
343
  }
329
344
  break
330
- case WAProto_1.proto.Message.ProtocolMessage.Type.MESSAGE_EDIT:
345
+ case proto.Message.ProtocolMessage.Type.MESSAGE_EDIT:
331
346
  ev.emit('messages.update', [
332
347
  {
333
348
  // flip the sender / fromMe properties because they're in the perspective of the sender
@@ -339,15 +354,15 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
339
354
  }
340
355
  },
341
356
  messageTimestamp: protocolMsg.timestampMs
342
- ? Math.floor(generics_1.toNumber(protocolMsg.timestampMs) / 1000)
357
+ ? Math.floor(toNumber(protocolMsg.timestampMs) / 1000)
343
358
  : message.messageTimestamp
344
359
  }
345
360
  }
346
361
  ])
347
362
  break
348
- case WAProto_1.proto.Message.ProtocolMessage.Type.LID_MIGRATION_MAPPING_SYNC:
363
+ case proto.Message.ProtocolMessage.Type.LID_MIGRATION_MAPPING_SYNC:
349
364
  const encodedPayload = protocolMsg.lidMigrationMappingSyncMessage?.encodedMappingPayload
350
- const { pnToLidMappings, chatDbMigrationTimestamp } = WAProto_1.proto.LIDMigrationMappingSyncPayload.decode(encodedPayload)
365
+ const { pnToLidMappings, chatDbMigrationTimestamp } = proto.LIDMigrationMappingSyncPayload.decode(encodedPayload)
351
366
 
352
367
  logger?.debug({ pnToLidMappings, chatDbMigrationTimestamp }, 'got lid mappings and chat db migration timestamp')
353
368
 
@@ -360,10 +375,10 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
360
375
 
361
376
  await signalRepository.lidMapping.storeLIDPNMappings(pairs)
362
377
  break
363
- case WAProto_1.proto.Message.ProtocolMessage.Type.LIMIT_SHARING:
378
+ case proto.Message.ProtocolMessage.Type.LIMIT_SHARING:
364
379
  ev.emit('limit-sharing.update', {
365
380
  id: message.key.remoteJid,
366
- author: WABinary_1.areJidsSameUser(message.key.remoteJid, protocolMsg.key.remoteJid) ? WABinary_1.jidNormalizedUser(meId) : message.key.remoteJid,
381
+ author: areJidsSameUser(message.key.remoteJid, protocolMsg.key.remoteJid) ? jidNormalizedUser(meId) : message.key.remoteJid,
367
382
  action: `${protocolMsg.limitSharing.sharingLimited ? 'on' : 'off'}`,
368
383
  trigger: protocolMsg.limitSharing.trigger,
369
384
  update_time: protocolMsg.limitSharing.limitSharingSettingTimestamp
@@ -392,13 +407,13 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
392
407
  const emitGroupRequestJoin = (participant, action, method) => {
393
408
  ev.emit('group.join-request', { id: jid, author: message.participant, participant, action, method: method })
394
409
  }
395
- const participantsIncludesMe = () => participants.find(jid => WABinary_1.areJidsSameUser(meId, jid))
410
+ const participantsIncludesMe = () => participants.find(jid => areJidsSameUser(meId, jid))
396
411
  switch (message.messageStubType) {
397
- case Types_1.WAMessageStubType.GROUP_PARTICIPANT_CHANGE_NUMBER:
412
+ case WAMessageStubType.GROUP_PARTICIPANT_CHANGE_NUMBER:
398
413
  participants = message.messageStubParameters || []
399
414
  emitParticipantsUpdate('modify')
400
415
  break
401
- case Types_1.WAMessageStubType.GROUP_PARTICIPANT_LEAVE:
416
+ case WAMessageStubType.GROUP_PARTICIPANT_LEAVE:
402
417
  participants = message.messageStubParameters || [];
403
418
  emitParticipantsUpdate('leave');
404
419
  // mark the chat read only if you left the group
@@ -406,7 +421,7 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
406
421
  chat.readOnly = true;
407
422
  }
408
423
  break;
409
- case Types_1.WAMessageStubType.GROUP_PARTICIPANT_REMOVE:
424
+ case WAMessageStubType.GROUP_PARTICIPANT_REMOVE:
410
425
  participants = message.messageStubParameters || []
411
426
  emitParticipantsUpdate('remove')
412
427
  // mark the chat read only if you left the group
@@ -414,62 +429,62 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
414
429
  chat.readOnly = true
415
430
  }
416
431
  break
417
- case Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD:
418
- case Types_1.WAMessageStubType.GROUP_PARTICIPANT_INVITE:
432
+ case WAMessageStubType.GROUP_PARTICIPANT_ADD:
433
+ case WAMessageStubType.GROUP_PARTICIPANT_INVITE:
419
434
  let actionGp = 'invite'
420
435
  participants = message.messageStubParameters || []
421
436
  if (participantsIncludesMe()) chat.readOnly = false;
422
437
  if (message?.key?.participant && !participants.includes(message?.key?.participant)) {
423
438
  actionGp = 'approval-invite'
424
439
  }
425
- case Types_1.WAMessageStubType.GROUP_PARTICIPANT_ADD_REQUEST_JOIN:
440
+ case WAMessageStubType.GROUP_PARTICIPANT_ADD_REQUEST_JOIN:
426
441
  participants = message.messageStubParameters || []
427
442
  if (participantsIncludesMe()) {
428
443
  chat.readOnly = false
429
444
  }
430
445
  emitParticipantsUpdate('add')
431
446
  break
432
- case Types_1.WAMessageStubType.GROUP_PARTICIPANT_DEMOTE:
433
- case Types_1.WAMessageStubType.COMMUNITY_PARTICIPANT_DEMOTE:
447
+ case WAMessageStubType.GROUP_PARTICIPANT_DEMOTE:
448
+ case WAMessageStubType.COMMUNITY_PARTICIPANT_DEMOTE:
434
449
  participants = message.messageStubParameters || []
435
450
  emitParticipantsUpdate('demote')
436
451
  break
437
- case Types_1.WAMessageStubType.GROUP_PARTICIPANT_PROMOTE:
438
- case Types_1.WAMessageStubType.COMMUNITY_PARTICIPANT_PROMOTE:
452
+ case WAMessageStubType.GROUP_PARTICIPANT_PROMOTE:
453
+ case WAMessageStubType.COMMUNITY_PARTICIPANT_PROMOTE:
439
454
  participants = message.messageStubParameters || []
440
455
  emitParticipantsUpdate('promote')
441
456
  break
442
- case Types_1.WAMessageStubType.GROUP_CHANGE_ANNOUNCE:
457
+ case WAMessageStubType.GROUP_CHANGE_ANNOUNCE:
443
458
  const announceValue = message.messageStubParameters?.[0]
444
459
  emitGroupUpdate({ announce: announceValue === 'true' || announceValue === 'on' })
445
460
  break
446
- case Types_1.WAMessageStubType.GROUP_CHANGE_RESTRICT:
461
+ case WAMessageStubType.GROUP_CHANGE_RESTRICT:
447
462
  const restrictValue = message.messageStubParameters?.[0]
448
463
  emitGroupUpdate({ restrict: restrictValue === 'true' || restrictValue === 'on' })
449
464
  break
450
- case Types_1.WAMessageStubType.GROUP_CHANGE_SUBJECT:
465
+ case WAMessageStubType.GROUP_CHANGE_SUBJECT:
451
466
  const name = message.messageStubParameters?.[0]
452
467
  chat.name = name
453
468
  emitGroupUpdate({ subject: name })
454
469
  break
455
- case Types_1.WAMessageStubType.GROUP_CHANGE_DESCRIPTION:
470
+ case WAMessageStubType.GROUP_CHANGE_DESCRIPTION:
456
471
  const description = message.messageStubParameters?.[0]
457
472
  chat.description = description
458
473
  emitGroupUpdate({ desc: description })
459
474
  break
460
- case Types_1.WAMessageStubType.GROUP_CHANGE_INVITE_LINK:
475
+ case WAMessageStubType.GROUP_CHANGE_INVITE_LINK:
461
476
  const code = message.messageStubParameters?.[0]
462
477
  emitGroupUpdate({ inviteCode: code })
463
478
  break
464
- case Types_1.WAMessageStubType.GROUP_MEMBER_ADD_MODE:
479
+ case WAMessageStubType.GROUP_MEMBER_ADD_MODE:
465
480
  const memberAddValue = message.messageStubParameters?.[0]
466
481
  emitGroupUpdate({ memberAddMode: memberAddValue === 'all_member_add' })
467
482
  break
468
- case Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_MODE:
483
+ case WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_MODE:
469
484
  const approvalMode = message.messageStubParameters?.[0]
470
485
  emitGroupUpdate({ joinApprovalMode: approvalMode === 'on' })
471
486
  break
472
- case Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD:
487
+ case WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD:
473
488
  const participant = message.messageStubParameters?.[0]
474
489
  const action = message.messageStubParameters?.[1]
475
490
  const method = message.messageStubParameters?.[2]
@@ -485,13 +500,13 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
485
500
  const pollMsg = await getMessage(creationMsgKey)
486
501
  if (pollMsg) {
487
502
  try {
488
- const meLidNormalised = WABinary_1.jidNormalizedUser(meLid)
489
- const getDevice = messages_1.getDevice(creationMsgKey.id)
490
- const pollCreationFromMe = getDevice === 'baileys' ? true : false
503
+ const meLidNormalised = jidNormalizedUser(meLid)
504
+ const deviceType = getDevice(creationMsgKey.id)
505
+ const pollCreationFromMe = deviceType === 'baileys' ? true : false
491
506
  const pollEncKey = pollMsg.messageContextInfo?.messageSecret
492
- const voterJid = generics_1.getKeyAuthor(message.key, meLidNormalised)
507
+ const voterJid = getKeyAuthor(message.key, meLidNormalised)
493
508
 
494
- let pollCreatorJid = generics_1.getKeyAuthor(creationMsgKey, meLidNormalised)
509
+ let pollCreatorJid = getKeyAuthor(creationMsgKey, meLidNormalised)
495
510
 
496
511
  if (pollCreationFromMe) {
497
512
  pollCreatorJid = meLidNormalised
@@ -535,15 +550,15 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
535
550
  const encEventEdit = content.secretEncryptedMessage
536
551
  const creationMsgKey = encEventEdit.targetMessageKey
537
552
 
538
- if (WAProto_1.proto.Message.SecretEncryptedMessage.SecretEncType[encEventEdit.secretEncType] !== 'EVENT_EDIT') return
553
+ if (proto.Message.SecretEncryptedMessage.SecretEncType[encEventEdit.secretEncType] !== 'EVENT_EDIT') return
539
554
 
540
555
  // we need to fetch the event creation message to get the event enc key
541
556
  const eventMsg = await getMessage(creationMsgKey)
542
557
  if (eventMsg) {
543
558
  try {
544
- const meLidNormalised = WABinary_1.jidNormalizedUser(meLid)
545
- const eventCreatorJid = generics_1.getKeyAuthor(message.key, meLidNormalised)
546
- const responderJid = generics_1.getKeyAuthor(message.key, meLidNormalised)
559
+ const meLidNormalised = jidNormalizedUser(meLid)
560
+ const eventCreatorJid = getKeyAuthor(message.key, meLidNormalised)
561
+ const responderJid = getKeyAuthor(message.key, meLidNormalised)
547
562
  const eventEncKey = eventMsg.messageContextInfo?.messageSecret
548
563
 
549
564
  if (!eventEncKey) {
@@ -555,7 +570,7 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
555
570
  eventMsgId: creationMsgKey.id,
556
571
  responderJid
557
572
  })
558
- const content = messages_1.normalizeMessageContent(responseMsg)
573
+ const content = normalizeMessageContent(responseMsg)
559
574
  const protocolMsg = content?.protocolMessage
560
575
 
561
576
  ev.emit('messages.update', [
@@ -569,7 +584,7 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
569
584
  }
570
585
  },
571
586
  messageTimestamp: protocolMsg.timestampMs
572
- ? Math.floor(generics_1.toNumber(protocolMsg.timestampMs) / 1000)
587
+ ? Math.floor(toNumber(protocolMsg.timestampMs) / 1000)
573
588
  : message.messageTimestamp
574
589
  }
575
590
  }
@@ -592,9 +607,9 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
592
607
  const eventMsg = await getMessage(creationMsgKey)
593
608
  if (eventMsg) {
594
609
  try {
595
- const meLidNormalised = WABinary_1.jidNormalizedUser(meLid)
596
- const eventCreatorJid = generics_1.getKeyAuthor(creationMsgKey, meLidNormalised)
597
- const responderJid = generics_1.getKeyAuthor(message.key, meLidNormalised)
610
+ const meLidNormalised = jidNormalizedUser(meLid)
611
+ const eventCreatorJid = getKeyAuthor(creationMsgKey, meLidNormalised)
612
+ const responderJid = getKeyAuthor(message.key, meLidNormalised)
598
613
  const eventEncKey = eventMsg.messageContextInfo?.messageSecret
599
614
 
600
615
  if (!eventEncKey) {
@@ -639,7 +654,7 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
639
654
  const commentMsg = await getMessage(creationMsgKey)
640
655
  if (commentMsg) {
641
656
  try {
642
- const meLidNormalised = WABinary_1.jidNormalizedUser(meLid)
657
+ const meLidNormalised = jidNormalizedUser(meLid)
643
658
  const commentCreatorJid = creationMsgKey.participant ? creationMsgKey.participant : message.key?.participant ? message.key.participant : meLidNormalised
644
659
  const commentJid = message.key?.participant ? message.key.participant : creationMsgKey.participant ? creationMsgKey.participant : meLidNormalised
645
660
  const commentEncKey = commentMsg.messageContextInfo?.messageSecret
@@ -679,7 +694,7 @@ const processMessage = async (message, { shouldProcessHistoryMsg, placeholderRes
679
694
  const reactMsg = await getMessage(creationMsgKey)
680
695
  if (reactMsg) {
681
696
  try {
682
- const meLidNormalised = WABinary_1.jidNormalizedUser(meLid)
697
+ const meLidNormalised = jidNormalizedUser(meLid)
683
698
  const reactionCreatorJid = creationMsgKey.participant ? creationMsgKey.participant : message.key?.participant ? message.key.participant : meLidNormalised
684
699
  const reactionJid = message.key?.participant ? message.key.participant : creationMsgKey.participant ? creationMsgKey.participant : meLidNormalised
685
700
  const reactionEncKey = reactMsg.messageContextInfo?.messageSecret