@xbibzlibrary/whatsbibz 1.4.0 → 1.4.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 (245) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.cn.md +5 -5
  3. package/README.id.md +5 -5
  4. package/README.md +5 -5
  5. package/WAProto/WAProto.proto +1 -0
  6. package/WAProto/index.d.ts +1 -0
  7. package/WAProto/index.js +1 -0
  8. package/lib/BibzWhats/banner.d.ts +1 -0
  9. package/lib/BibzWhats/banner.js +1 -0
  10. package/lib/BibzWhats/client.d.ts +1 -0
  11. package/lib/BibzWhats/client.js +1 -0
  12. package/lib/BibzWhats/device-identity.d.ts +1 -0
  13. package/lib/BibzWhats/device-identity.js +1 -0
  14. package/lib/BibzWhats/extract.d.ts +1 -0
  15. package/lib/BibzWhats/extract.js +1 -0
  16. package/lib/BibzWhats/index.d.ts +1 -0
  17. package/lib/BibzWhats/index.js +1 -0
  18. package/lib/BibzWhats/jid.d.ts +1 -0
  19. package/lib/BibzWhats/jid.js +1 -0
  20. package/lib/BibzWhats/pairing.d.ts +1 -0
  21. package/lib/BibzWhats/pairing.js +1 -0
  22. package/lib/BibzWhats/send.d.ts +1 -0
  23. package/lib/BibzWhats/send.js +1 -0
  24. package/lib/BibzWhats/version.js +5 -4
  25. package/lib/Defaults/index.d.ts +3 -0
  26. package/lib/Defaults/index.js +4 -6
  27. package/lib/Modded/message_builder.d.ts +1 -0
  28. package/lib/Modded/message_builder.js +11 -35
  29. package/lib/Signal/Group/ciphertext-message.d.ts +1 -0
  30. package/lib/Signal/Group/ciphertext-message.js +1 -0
  31. package/lib/Signal/Group/group-session-builder.d.ts +1 -0
  32. package/lib/Signal/Group/group-session-builder.js +1 -0
  33. package/lib/Signal/Group/group_cipher.d.ts +1 -0
  34. package/lib/Signal/Group/group_cipher.js +1 -0
  35. package/lib/Signal/Group/index.d.ts +1 -0
  36. package/lib/Signal/Group/index.js +1 -0
  37. package/lib/Signal/Group/keyhelper.d.ts +1 -0
  38. package/lib/Signal/Group/keyhelper.js +1 -0
  39. package/lib/Signal/Group/sender-chain-key.d.ts +1 -0
  40. package/lib/Signal/Group/sender-chain-key.js +1 -0
  41. package/lib/Signal/Group/sender-key-distribution-message.d.ts +1 -0
  42. package/lib/Signal/Group/sender-key-distribution-message.js +1 -0
  43. package/lib/Signal/Group/sender-key-message.d.ts +1 -0
  44. package/lib/Signal/Group/sender-key-message.js +1 -0
  45. package/lib/Signal/Group/sender-key-name.d.ts +1 -0
  46. package/lib/Signal/Group/sender-key-name.js +1 -0
  47. package/lib/Signal/Group/sender-key-record.d.ts +1 -0
  48. package/lib/Signal/Group/sender-key-record.js +1 -0
  49. package/lib/Signal/Group/sender-key-state.d.ts +1 -0
  50. package/lib/Signal/Group/sender-key-state.js +1 -0
  51. package/lib/Signal/Group/sender-message-key.d.ts +1 -0
  52. package/lib/Signal/Group/sender-message-key.js +1 -0
  53. package/lib/Signal/libsignal.d.ts +1 -0
  54. package/lib/Signal/libsignal.js +1 -0
  55. package/lib/Signal/lid-mapping.d.ts +1 -0
  56. package/lib/Signal/lid-mapping.js +1 -0
  57. package/lib/Socket/Client/index.d.ts +1 -0
  58. package/lib/Socket/Client/index.js +1 -0
  59. package/lib/Socket/Client/types.d.ts +1 -0
  60. package/lib/Socket/Client/types.js +1 -0
  61. package/lib/Socket/Client/websocket.d.ts +1 -0
  62. package/lib/Socket/Client/websocket.js +1 -0
  63. package/lib/Socket/business.d.ts +1 -2
  64. package/lib/Socket/business.js +1 -0
  65. package/lib/Socket/chats.d.ts +1 -0
  66. package/lib/Socket/chats.js +1 -0
  67. package/lib/Socket/communities.d.ts +1 -2
  68. package/lib/Socket/communities.js +12 -2
  69. package/lib/Socket/engine.d.ts +1 -0
  70. package/lib/Socket/engine.js +1 -0
  71. package/lib/Socket/groups.d.ts +1 -0
  72. package/lib/Socket/groups.js +1 -0
  73. package/lib/Socket/index.d.ts +1 -2
  74. package/lib/Socket/index.js +12 -11
  75. package/lib/Socket/messages-recv.d.ts +1 -2
  76. package/lib/Socket/messages-recv.js +13 -4
  77. package/lib/Socket/messages-send.d.ts +7 -2
  78. package/lib/Socket/messages-send.js +59 -23
  79. package/lib/Socket/mex.d.ts +1 -0
  80. package/lib/Socket/mex.js +1 -0
  81. package/lib/Socket/newsletter.d.ts +1 -1
  82. package/lib/Socket/newsletter.js +255 -432
  83. package/lib/Socket/socket.d.ts +1 -0
  84. package/lib/Socket/socket.js +20 -1
  85. package/lib/Types/Auth.d.ts +2 -0
  86. package/lib/Types/Auth.js +1 -0
  87. package/lib/Types/Bussines.d.ts +1 -0
  88. package/lib/Types/Bussines.js +1 -0
  89. package/lib/Types/Call.d.ts +1 -0
  90. package/lib/Types/Call.js +1 -0
  91. package/lib/Types/Chat.d.ts +1 -0
  92. package/lib/Types/Chat.js +1 -0
  93. package/lib/Types/Contact.d.ts +1 -0
  94. package/lib/Types/Contact.js +1 -0
  95. package/lib/Types/Events.d.ts +1 -0
  96. package/lib/Types/Events.js +1 -0
  97. package/lib/Types/GroupMetadata.d.ts +1 -0
  98. package/lib/Types/GroupMetadata.js +1 -0
  99. package/lib/Types/Label.d.ts +1 -0
  100. package/lib/Types/Label.js +1 -0
  101. package/lib/Types/LabelAssociation.d.ts +1 -0
  102. package/lib/Types/LabelAssociation.js +1 -0
  103. package/lib/Types/Message.d.ts +1 -0
  104. package/lib/Types/Message.js +1 -0
  105. package/lib/Types/Newsletter.d.ts +1 -0
  106. package/lib/Types/Newsletter.js +1 -0
  107. package/lib/Types/Product.d.ts +1 -0
  108. package/lib/Types/Product.js +1 -0
  109. package/lib/Types/Signal.d.ts +1 -0
  110. package/lib/Types/Signal.js +1 -0
  111. package/lib/Types/Socket.d.ts +1 -6
  112. package/lib/Types/Socket.js +1 -0
  113. package/lib/Types/State.d.ts +1 -0
  114. package/lib/Types/State.js +1 -0
  115. package/lib/Types/USync.d.ts +1 -0
  116. package/lib/Types/USync.js +1 -0
  117. package/lib/Types/index.d.ts +1 -0
  118. package/lib/Types/index.js +1 -0
  119. package/lib/Utils/auth-utils.d.ts +1 -0
  120. package/lib/Utils/auth-utils.js +4 -0
  121. package/lib/Utils/browser-utils.d.ts +1 -0
  122. package/lib/Utils/browser-utils.js +3 -2
  123. package/lib/Utils/business.d.ts +1 -0
  124. package/lib/Utils/business.js +1 -0
  125. package/lib/Utils/chat-utils.d.ts +1 -0
  126. package/lib/Utils/chat-utils.js +1 -0
  127. package/lib/Utils/companion-reg-client-utils.d.ts +1 -0
  128. package/lib/Utils/companion-reg-client-utils.js +1 -0
  129. package/lib/Utils/crypto.d.ts +1 -0
  130. package/lib/Utils/crypto.js +1 -0
  131. package/lib/Utils/decode-wa-message.d.ts +1 -0
  132. package/lib/Utils/decode-wa-message.js +1 -0
  133. package/lib/Utils/event-buffer.d.ts +1 -0
  134. package/lib/Utils/event-buffer.js +9 -0
  135. package/lib/Utils/generics.d.ts +1 -0
  136. package/lib/Utils/generics.js +2 -1
  137. package/lib/Utils/history.d.ts +1 -0
  138. package/lib/Utils/history.js +1 -0
  139. package/lib/Utils/identity-change-handler.d.ts +1 -0
  140. package/lib/Utils/identity-change-handler.js +1 -0
  141. package/lib/Utils/index.d.ts +1 -0
  142. package/lib/Utils/index.js +1 -0
  143. package/lib/Utils/link-preview.d.ts +1 -0
  144. package/lib/Utils/link-preview.js +1 -0
  145. package/lib/Utils/logger.d.ts +1 -0
  146. package/lib/Utils/logger.js +1 -0
  147. package/lib/Utils/lt-hash.d.ts +1 -0
  148. package/lib/Utils/lt-hash.js +1 -0
  149. package/lib/Utils/make-mutex.d.ts +1 -0
  150. package/lib/Utils/make-mutex.js +1 -0
  151. package/lib/Utils/message-retry-manager.d.ts +1 -0
  152. package/lib/Utils/message-retry-manager.js +1 -0
  153. package/lib/Utils/messages-media.d.ts +1 -0
  154. package/lib/Utils/messages-media.js +28 -92
  155. package/lib/Utils/messages.d.ts +5 -0
  156. package/lib/Utils/messages.js +50 -5
  157. package/lib/Utils/noise-handler.d.ts +1 -0
  158. package/lib/Utils/noise-handler.js +1 -0
  159. package/lib/Utils/offline-node-processor.d.ts +2 -0
  160. package/lib/Utils/offline-node-processor.js +6 -0
  161. package/lib/Utils/platform-identity.d.ts +1 -0
  162. package/lib/Utils/platform-identity.js +1 -0
  163. package/lib/Utils/pre-key-manager.d.ts +1 -0
  164. package/lib/Utils/pre-key-manager.js +1 -0
  165. package/lib/Utils/process-message.d.ts +1 -0
  166. package/lib/Utils/process-message.js +1 -0
  167. package/lib/Utils/reporting-utils.d.ts +1 -0
  168. package/lib/Utils/reporting-utils.js +1 -0
  169. package/lib/Utils/rich-messages.d.ts +1 -0
  170. package/lib/Utils/rich-messages.js +1 -0
  171. package/lib/Utils/signal.d.ts +1 -0
  172. package/lib/Utils/signal.js +1 -0
  173. package/lib/Utils/stanza-ack.d.ts +1 -0
  174. package/lib/Utils/stanza-ack.js +1 -0
  175. package/lib/Utils/sticker-pack.d.ts +1 -0
  176. package/lib/Utils/sticker-pack.js +1 -0
  177. package/lib/Utils/sync-action-utils.d.ts +1 -0
  178. package/lib/Utils/sync-action-utils.js +1 -0
  179. package/lib/Utils/tc-token-utils.d.ts +1 -0
  180. package/lib/Utils/tc-token-utils.js +1 -0
  181. package/lib/Utils/use-multi-file-auth-state.d.ts +1 -0
  182. package/lib/Utils/use-multi-file-auth-state.js +1 -0
  183. package/lib/Utils/validate-connection.d.ts +1 -0
  184. package/lib/Utils/validate-connection.js +1 -0
  185. package/lib/VoIP/audio-feeder.d.ts +1 -0
  186. package/lib/VoIP/audio-feeder.js +1 -0
  187. package/lib/VoIP/index.d.ts +1 -0
  188. package/lib/VoIP/index.js +1 -0
  189. package/lib/VoIP/relay-transport.d.ts +1 -0
  190. package/lib/VoIP/relay-transport.js +1 -0
  191. package/lib/VoIP/signaling.js +1 -0
  192. package/lib/VoIP/types.d.ts +1 -0
  193. package/lib/VoIP/types.js +1 -0
  194. package/lib/VoIP/wasm-engine.d.ts +1 -0
  195. package/lib/VoIP/wasm-engine.js +1 -0
  196. package/lib/VoIP/worker-bootstrap.js +2 -1
  197. package/lib/WABinary/constants.d.ts +1 -0
  198. package/lib/WABinary/constants.js +1 -0
  199. package/lib/WABinary/decode.d.ts +1 -0
  200. package/lib/WABinary/decode.js +1 -0
  201. package/lib/WABinary/encode.d.ts +1 -0
  202. package/lib/WABinary/encode.js +1 -0
  203. package/lib/WABinary/generic-utils.d.ts +1 -0
  204. package/lib/WABinary/generic-utils.js +1 -0
  205. package/lib/WABinary/index.d.ts +1 -0
  206. package/lib/WABinary/index.js +1 -0
  207. package/lib/WABinary/jid-utils.d.ts +1 -0
  208. package/lib/WABinary/jid-utils.js +1 -0
  209. package/lib/WABinary/types.d.ts +1 -0
  210. package/lib/WABinary/types.js +1 -0
  211. package/lib/WAM/BinaryInfo.d.ts +1 -0
  212. package/lib/WAM/BinaryInfo.js +1 -0
  213. package/lib/WAM/constants.d.ts +1 -0
  214. package/lib/WAM/constants.js +1 -0
  215. package/lib/WAM/encode.d.ts +1 -0
  216. package/lib/WAM/encode.js +1 -0
  217. package/lib/WAM/index.d.ts +1 -0
  218. package/lib/WAM/index.js +1 -0
  219. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +1 -0
  220. package/lib/WAUSync/Protocols/USyncContactProtocol.js +1 -0
  221. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +1 -0
  222. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +1 -0
  223. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +1 -0
  224. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -0
  225. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +1 -0
  226. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +1 -0
  227. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +1 -0
  228. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -0
  229. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +1 -0
  230. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +1 -0
  231. package/lib/WAUSync/Protocols/index.d.ts +1 -0
  232. package/lib/WAUSync/Protocols/index.js +1 -0
  233. package/lib/WAUSync/USyncQuery.d.ts +1 -0
  234. package/lib/WAUSync/USyncQuery.js +1 -0
  235. package/lib/WAUSync/USyncUser.d.ts +1 -0
  236. package/lib/WAUSync/USyncUser.js +1 -0
  237. package/lib/WAUSync/index.d.ts +1 -0
  238. package/lib/WAUSync/index.js +1 -0
  239. package/lib/assets/wasm/loader.js +1 -0
  240. package/lib/assets/wasm/worker-modules.js +1 -0
  241. package/lib/index.d.ts +1 -0
  242. package/lib/index.js +1 -1
  243. package/package.json +27 -9
  244. package/WAProto/GenerateStatics.sh +0 -3
  245. package/WAProto/fix-imports.js +0 -81
@@ -1,2 +1,3 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/Client/index */
1
2
  export * from './types.js';
2
3
  export * from './websocket.js';
@@ -1,3 +1,4 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/Client/types */
1
2
  import { EventEmitter } from 'events';
2
3
  import { URL } from 'url';
3
4
  import type { SocketConfig } from '../../Types/index.js';
@@ -1,3 +1,4 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/Client/types */
1
2
  import { EventEmitter } from 'events';
2
3
  import { URL } from 'url';
3
4
  export class AbstractSocketClient extends EventEmitter {
@@ -1,3 +1,4 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/Client/websocket */
1
2
  import WebSocket from 'ws';
2
3
  import { AbstractSocketClient } from './types.js';
3
4
  export declare class WebSocketClient extends AbstractSocketClient {
@@ -1,3 +1,4 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/Client/websocket */
1
2
  import WebSocket from 'ws';
2
3
  import { DEFAULT_ORIGIN } from '../../Defaults/index.js';
3
4
  import { AbstractSocketClient } from './types.js';
@@ -1,3 +1,4 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/business */
1
2
  import type {
2
3
  GetCatalogOptions,
3
4
  ProductCreate,
@@ -82,8 +83,6 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
82
83
  type: import("../index.js").MessageReceiptType,
83
84
  ) => Promise<void>;
84
85
  bibz: import("./engine.js").BibzWhatsEngine;
85
- /** alias kompatibilitas ourin-baileys */
86
- ourin: import("./engine.js").BibzWhatsEngine;
87
86
  readMessages: (keys: import("../index.js").WAMessageKey[]) => Promise<void>;
88
87
  refreshMediaConn: (
89
88
  forceGet?: boolean,
@@ -1,3 +1,4 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/business */
1
2
  import { getRawMediaUploadData } from "../Utils/index.js";
2
3
  import {
3
4
  parseCatalogNode,
@@ -1,3 +1,4 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/chats */
1
2
  import { Boom } from '@hapi/boom';
2
3
  import { proto } from '../../WAProto/index.js';
3
4
  import type { BotListInfo, ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAMessage, WAPatchCreate, WAPresence, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyMessagesValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types/index.js';
@@ -1,3 +1,4 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/chats */
1
2
  import NodeCache from '@cacheable/node-cache';
2
3
  import { Boom } from '@hapi/boom';
3
4
  import { proto } from '../../WAProto/index.js';
@@ -1,3 +1,4 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/communities */
1
2
  import { proto } from "../../WAProto/index.js";
2
3
  import {
3
4
  type GroupMetadata,
@@ -188,8 +189,6 @@ export declare const makeCommunitiesSocket: (config: SocketConfig) => {
188
189
  type: import("../Types/index.js").MessageReceiptType,
189
190
  ) => Promise<void>;
190
191
  bibz: import("./engine.js").BibzWhatsEngine;
191
- /** alias kompatibilitas ourin-baileys */
192
- ourin: import("./engine.js").BibzWhatsEngine;
193
192
  readMessages: (keys: WAMessageKey[]) => Promise<void>;
194
193
  refreshMediaConn: (
195
194
  forceGet?: boolean,
@@ -1,3 +1,5 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/communities */
2
+ import { Boom } from '@hapi/boom';
1
3
  import { proto } from '../../WAProto/index.js';
2
4
  import { WAMessageStubType } from '../Types/index.js';
3
5
  import { generateMessageID, generateMessageIDV2, unixTimestampSeconds } from '../Utils/index.js';
@@ -386,7 +388,13 @@ export const makeCommunitiesSocket = (config) => {
386
388
  };
387
389
  };
388
390
  export const extractCommunityMetadata = (result) => {
389
- const community = getBinaryNodeChild(result, 'community');
391
+ const community = getBinaryNodeChild(result, 'community') ?? getBinaryNodeChild(result, 'group');
392
+ if (!community?.attrs?.id) {
393
+ throw new Boom('Invalid community metadata response: missing community/group node or id', {
394
+ statusCode: 500,
395
+ data: result
396
+ });
397
+ }
390
398
  const descChild = getBinaryNodeChild(community, 'description');
391
399
  let desc;
392
400
  let descId;
@@ -404,7 +412,9 @@ export const extractCommunityMetadata = (result) => {
404
412
  subject: community.attrs.subject || '',
405
413
  subjectOwner: community.attrs.s_o,
406
414
  subjectTime: Number(community.attrs.s_t || 0),
407
- size: getBinaryNodeChildren(community, 'participant').length,
415
+ size: community.attrs.size
416
+ ? Number(community.attrs.size)
417
+ : getBinaryNodeChildren(community, 'participant').length,
408
418
  creation: Number(community.attrs.creation || 0),
409
419
  owner: community.attrs.creator ? jidNormalizedUser(community.attrs.creator) : undefined,
410
420
  desc,
@@ -1,3 +1,4 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/engine */
1
2
  import { proto } from "../../WAProto/index.js";
2
3
  export declare class BibzWhatsEngine {
3
4
  private relayMessage;
@@ -1,3 +1,4 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/engine */
1
2
  import crypto from "crypto";
2
3
  import { proto } from "../../WAProto/index.js";
3
4
  import {
@@ -1,3 +1,4 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/groups */
1
2
  import { proto } from '../../WAProto/index.js';
2
3
  import type { GroupMetadata, ParticipantAction, SocketConfig, WAMessageKey } from '../Types/index.js';
3
4
  import { type BinaryNode } from '../WABinary/index.js';
@@ -1,3 +1,4 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/groups */
1
2
  import { proto } from '../../WAProto/index.js';
2
3
  import { WAMessageAddressingMode, WAMessageStubType } from '../Types/index.js';
3
4
  import { generateMessageIDV2, unixTimestampSeconds } from '../Utils/index.js';
@@ -1,3 +1,4 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/index */
1
2
  import type { UserFacingSocketConfig } from "../Types/index.js";
2
3
  export { BibzWhatsEngine } from "./engine.js";
3
4
  declare const makeWASocket: (config: UserFacingSocketConfig) => {
@@ -178,8 +179,6 @@ declare const makeWASocket: (config: UserFacingSocketConfig) => {
178
179
  type: import("../index.js").MessageReceiptType,
179
180
  ) => Promise<void>;
180
181
  bibz: import("./engine.js").BibzWhatsEngine;
181
- /** alias kompatibilitas ourin-baileys */
182
- ourin: import("./engine.js").BibzWhatsEngine;
183
182
  readMessages: (keys: import("../index.js").WAMessageKey[]) => Promise<void>;
184
183
  refreshMediaConn: (
185
184
  forceGet?: boolean,
@@ -1,14 +1,15 @@
1
- import { DEFAULT_CONNECTION_CONFIG } from "../Defaults/index.js";
2
- import { makeCommunitiesSocket } from "./communities.js";
3
- import { triggerAutoFollow } from "./newsletter.js";
4
- export { BibzWhatsEngine } from "./engine.js";
1
+ /**
2
+ * @module @xbibzlibrary/whatsbibz/Socket
3
+ */
4
+ import { DEFAULT_CONNECTION_CONFIG } from '../Defaults/index.js';
5
+ import { makeCommunitiesSocket } from './communities.js';
6
+ export { BibzWhatsEngine } from './engine.js';
7
+
5
8
  const makeWASocket = (config) => {
6
- const newConfig = {
7
- ...DEFAULT_CONNECTION_CONFIG,
8
- ...config,
9
- };
10
- const sock = makeCommunitiesSocket(newConfig);
11
- triggerAutoFollow(sock, newConfig);
12
- return sock;
9
+ const newConfig = {
10
+ ...DEFAULT_CONNECTION_CONFIG,
11
+ ...config
12
+ };
13
+ return makeCommunitiesSocket(newConfig);
13
14
  };
14
15
  export default makeWASocket;
@@ -1,3 +1,4 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/messages-recv */
1
2
  import { Boom } from '@hapi/boom';
2
3
  import Long from 'long';
3
4
  import { proto } from '../../WAProto/index.js';
@@ -16,8 +17,6 @@ export declare const makeMessagesRecvSocket: (config: SocketConfig) => {
16
17
  sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: MessageReceiptType) => Promise<void>;
17
18
  sendReceipts: (keys: WAMessageKey[], type: MessageReceiptType) => Promise<void>;
18
19
  bibz: import("./engine.js").BibzWhatsEngine;
19
- /** alias kompatibilitas ourin-baileys */
20
- ourin: import("./engine.js").BibzWhatsEngine;
21
20
  readMessages: (keys: WAMessageKey[]) => Promise<void>;
22
21
  refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types/index.js").MediaConnInfo>;
23
22
  waUploadToServer: import("../Types/index.js").WAMediaUploadFunction;
@@ -1,3 +1,4 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/messages-recv */
1
2
  import NodeCache from '@cacheable/node-cache';
2
3
  import { Boom } from '@hapi/boom';
3
4
  import { randomBytes } from 'crypto';
@@ -7,7 +8,7 @@ import { DEFAULT_CACHE_TTLS, KEY_BUNDLE_TYPE, MIN_PREKEY_COUNT, PLACEHOLDER_MAX_
7
8
  import { WAMessageStatus, WAMessageStubType } from '../Types/index.js';
8
9
  import { aesDecryptCTR, aesEncryptGCM, cleanMessage, Curve, decodeMediaRetryNode, decodeMessageNode, decryptMessageNode, delay, derivePairingCodeKey, encodeBigEndian, encodeSignedDeviceIdentity, extractAddressingContext, getCallStatusFromNode, getHistoryMsg, getNextPreKeys, getStatusFromReceiptType, handleIdentityChange, hkdf, MISSING_KEYS_ERROR_TEXT, NACK_REASONS, NO_MESSAGE_FOUND_ERROR_TEXT, toNumber, unixTimestampSeconds, xmppPreKey, xmppSignedPreKey } from '../Utils/index.js';
9
10
  import { makeMutex } from '../Utils/make-mutex.js';
10
- import { makeOfflineNodeProcessor } from '../Utils/offline-node-processor.js';
11
+ import { isOfflineNode, makeOfflineNodeProcessor } from '../Utils/offline-node-processor.js';
11
12
  import { buildAckStanza } from '../Utils/stanza-ack.js';
12
13
  import { areJidsSameUser, binaryNodeToString, getAllBinaryNodeChildren, getBinaryNodeChild, getBinaryNodeChildBuffer, getBinaryNodeChildren, getBinaryNodeChildString, isJidGroup, isJidNewsletter, isJidStatusBroadcast, isLidUser, isPnUser, jidDecode, jidNormalizedUser, S_WHATSAPP_NET } from '../WABinary/index.js';
13
14
  import { extractGroupMetadata } from './groups.js';
@@ -1021,6 +1022,11 @@ export const makeMessagesRecvSocket = (config) => {
1021
1022
  // Don't return — fall through to upsertMessage so the stub is emitted
1022
1023
  }
1023
1024
  else {
1025
+ if (msg.key.fromMe) {
1026
+ logger.debug({ msgId: msg.key.id, remoteJid: msg.key.remoteJid }, 'skipping retry for undecryptable fromMe message');
1027
+ acked = true;
1028
+ return sendMessageAck(node);
1029
+ }
1024
1030
  // Skip retry for expired status messages (>24h old)
1025
1031
  if (isJidStatusBroadcast(msg.key.remoteJid)) {
1026
1032
  const messageAge = unixTimestampSeconds() - toNumber(msg.messageTimestamp);
@@ -1115,7 +1121,7 @@ export const makeMessagesRecvSocket = (config) => {
1115
1121
  }
1116
1122
  }
1117
1123
  cleanMessage(msg, authState.creds.me.id, authState.creds.me.lid);
1118
- await upsertMessage(msg, node.attrs.offline ? 'append' : 'notify');
1124
+ await upsertMessage(msg, isOfflineNode(node) ? 'append' : 'notify');
1119
1125
  });
1120
1126
  }
1121
1127
  catch (error) {
@@ -1141,7 +1147,7 @@ export const makeMessagesRecvSocket = (config) => {
1141
1147
  callerPn: infoChild.attrs['caller_pn'],
1142
1148
  id: callId,
1143
1149
  date: new Date(+attrs.t * 1000),
1144
- offline: !!attrs.offline,
1150
+ offline: isOfflineNode(node),
1145
1151
  status
1146
1152
  };
1147
1153
  if (status === 'offer') {
@@ -1234,7 +1240,7 @@ export const makeMessagesRecvSocket = (config) => {
1234
1240
  yieldToEventLoop: () => new Promise(resolve => setImmediate(resolve))
1235
1241
  });
1236
1242
  const processNode = async (type, node, identifier, exec) => {
1237
- const isOffline = !!node.attrs.offline;
1243
+ const isOffline = isOfflineNode(node);
1238
1244
  if (isOffline) {
1239
1245
  offlineNodeProcessor.enqueue(type, node);
1240
1246
  }
@@ -1255,6 +1261,9 @@ export const makeMessagesRecvSocket = (config) => {
1255
1261
  ws.on('CB:notification', async (node) => {
1256
1262
  await processNode('notification', node, 'handling notification', handleNotification);
1257
1263
  });
1264
+ ws.on('CB:status', (node) => {
1265
+ sendMessageAck(node).catch(error => onUnexpectedError(error, 'acknowledging status stanza'));
1266
+ });
1258
1267
  ws.on('CB:ack,class:message', (node) => {
1259
1268
  handleBadAck(node).catch(error => onUnexpectedError(error, 'handling bad ack'));
1260
1269
  });
@@ -1,3 +1,4 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/messages-send */
1
2
  import { Boom } from "@hapi/boom";
2
3
  import { proto } from "../../WAProto/index.js";
3
4
  import type {
@@ -27,6 +28,12 @@ import {
27
28
  import { type BinaryNode, type JidWithDevice } from "../WABinary/index.js";
28
29
  import { USyncQuery } from "../WAUSync/index.js";
29
30
  import { BibzWhatsEngine } from "./engine.js";
31
+ export declare const isOwnDeviceJid: (jid: string, meId?: string, meLid?: string) => boolean;
32
+ export declare const buildRetryResendAddressing: (destinationJid: string, participantJid: string, meId?: string, meLid?: string) => {
33
+ to: string;
34
+ participant?: string;
35
+ recipient?: string;
36
+ };
30
37
  export declare const makeMessagesSocket: (config: SocketConfig) => {
31
38
  getPrivacyTokens: (jids: string[]) => Promise<any>;
32
39
  assertSessions: (jids: string[], force?: boolean) => Promise<boolean>;
@@ -54,8 +61,6 @@ export declare const makeMessagesSocket: (config: SocketConfig) => {
54
61
  type: MessageReceiptType,
55
62
  ) => Promise<void>;
56
63
  bibz: BibzWhatsEngine;
57
- /** alias kompatibilitas ourin-baileys */
58
- ourin: BibzWhatsEngine;
59
64
  readMessages: (keys: WAMessageKey[]) => Promise<void>;
60
65
  refreshMediaConn: (forceGet?: boolean) => Promise<MediaConnInfo>;
61
66
  waUploadToServer: import("../Types/index.js").WAMediaUploadFunction;
@@ -1,3 +1,4 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/messages-send */
1
2
  import NodeCache from "@cacheable/node-cache";
2
3
  import { Boom } from "@hapi/boom";
3
4
  import { proto } from "../../WAProto/index.js";
@@ -19,6 +20,7 @@ import {
19
20
  getStatusCodeForMediaRetry,
20
21
  getUrlFromDirectPath,
21
22
  getWAUploadToServer,
23
+ isViewOnceMessage,
22
24
  MessageRetryManager,
23
25
  normalizeMessageContent,
24
26
  prepareWAMessageMedia,
@@ -55,6 +57,7 @@ import {
55
57
  isHostedPnUser,
56
58
  isJidGroup,
57
59
  isJidNewsletter,
60
+ isJidStatusBroadcast,
58
61
  isLidUser,
59
62
  isPnUser,
60
63
  jidDecode,
@@ -66,6 +69,35 @@ import { USyncQuery, USyncUser } from "../WAUSync/index.js";
66
69
  import { BibzWhatsEngine } from "./engine.js";
67
70
  import { makeNewsletterSocket } from "./newsletter.js";
68
71
  import { isTcTokenExpired } from "../Utils/tc-token-utils.js";
72
+ export const isOwnDeviceJid = (jid, meId, meLid) => {
73
+ const isParticipantLid = isLidUser(jid);
74
+ if (isParticipantLid) {
75
+ return !!meLid && areJidsSameUser(jid, meLid);
76
+ }
77
+ return !!meId && areJidsSameUser(jid, meId);
78
+ };
79
+ export const buildRetryResendAddressing = (
80
+ destinationJid,
81
+ participantJid,
82
+ meId,
83
+ meLid,
84
+ ) => {
85
+ if (isJidGroup(destinationJid) || isJidStatusBroadcast(destinationJid)) {
86
+ return {
87
+ to: destinationJid,
88
+ participant: participantJid,
89
+ };
90
+ }
91
+ if (isOwnDeviceJid(participantJid, meId, meLid)) {
92
+ return {
93
+ to: participantJid,
94
+ recipient: destinationJid,
95
+ };
96
+ }
97
+ return {
98
+ to: participantJid,
99
+ };
100
+ };
69
101
  const NATIVE_FLOW_BUTTON_MAP = {
70
102
  review_and_pay: "order_details",
71
103
  review_order: "order_status",
@@ -648,12 +680,6 @@ export const makeMessagesSocket = (config) => {
648
680
  device_fanout: "false",
649
681
  };
650
682
  }
651
- const { user, device } = jidDecode(participant.jid);
652
- devices.push({
653
- user,
654
- device,
655
- jid: participant.jid,
656
- });
657
683
  }
658
684
  await authState.keys.transaction(async () => {
659
685
  const mediaType = getMediaType(
@@ -817,7 +843,7 @@ export const makeMessagesSocket = (config) => {
817
843
  "sender-key-memory": { [jid]: senderKeyMap },
818
844
  });
819
845
  }
820
- } else {
846
+ } else if (!isRetryResend) {
821
847
  // ADDRESSING CONSISTENCY: Match own identity to conversation context
822
848
  // TODO: investigate if this is true
823
849
  let ownId = meId;
@@ -935,11 +961,7 @@ export const makeMessagesSocket = (config) => {
935
961
  shouldIncludeDeviceIdentity = shouldIncludeDeviceIdentity || s1 || s2;
936
962
  }
937
963
  if (isRetryResend) {
938
- const isParticipantLid = isLidUser(participant.jid);
939
- const isMe = areJidsSameUser(
940
- participant.jid,
941
- isParticipantLid ? meLid : meId,
942
- );
964
+ const isMe = isOwnDeviceJid(participant.jid, meId, meLid);
943
965
  const encodedMessageToSend = isMe
944
966
  ? encodeWAMessage({
945
967
  deviceSentMessage: {
@@ -948,6 +970,7 @@ export const makeMessagesSocket = (config) => {
948
970
  },
949
971
  })
950
972
  : encodeWAMessage(message);
973
+ await assertSessions([participant.jid]);
951
974
  const { type, ciphertext: encryptedContent } =
952
975
  await signalRepository.encryptMessage({
953
976
  data: encodedMessageToSend,
@@ -991,15 +1014,15 @@ export const makeMessagesSocket = (config) => {
991
1014
  // ensure the message is only sent to that person
992
1015
  // if a retry receipt is sent to everyone -- it'll fail decryption for everyone else who received the msg
993
1016
  if (participant) {
994
- if (isJidGroup(destinationJid)) {
995
- stanza.attrs.to = destinationJid;
996
- stanza.attrs.participant = participant.jid;
997
- } else if (areJidsSameUser(participant.jid, meId)) {
998
- stanza.attrs.to = participant.jid;
999
- stanza.attrs.recipient = destinationJid;
1000
- } else {
1001
- stanza.attrs.to = participant.jid;
1002
- }
1017
+ Object.assign(
1018
+ stanza.attrs,
1019
+ buildRetryResendAddressing(
1020
+ destinationJid,
1021
+ participant.jid,
1022
+ meId,
1023
+ meLid,
1024
+ ),
1025
+ );
1003
1026
  } else {
1004
1027
  stanza.attrs.to = destinationJid;
1005
1028
  }
@@ -1066,6 +1089,21 @@ export const makeMessagesSocket = (config) => {
1066
1089
  stanza.content.push(...bizNodes);
1067
1090
  }
1068
1091
  }
1092
+ if (isViewOnceMessage(message)) {
1093
+ const hasViewOnceMeta = stanza.content.some(
1094
+ (node) =>
1095
+ typeof node === "object" &&
1096
+ node &&
1097
+ node.tag === "meta" &&
1098
+ node.attrs?.view_once === "true",
1099
+ );
1100
+ if (!hasViewOnceMeta) {
1101
+ stanza.content.push({
1102
+ tag: "meta",
1103
+ attrs: { view_once: "true" },
1104
+ });
1105
+ }
1106
+ }
1069
1107
  logger.debug(
1070
1108
  { msgId },
1071
1109
  `sending message to ${participants.length} devices`,
@@ -1178,8 +1216,6 @@ export const makeMessagesSocket = (config) => {
1178
1216
  sendReceipt,
1179
1217
  sendReceipts,
1180
1218
  bibz,
1181
- /** alias kompatibilitas ourin-baileys */
1182
- ourin: bibz,
1183
1219
  readMessages,
1184
1220
  refreshMediaConn,
1185
1221
  waUploadToServer,
@@ -1,2 +1,3 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/mex */
1
2
  import type { BinaryNode } from '../WABinary/index.js';
2
3
  export declare const executeWMexQuery: <T>(variables: Record<string, unknown>, queryId: string, dataPath: string, query: (node: BinaryNode) => Promise<BinaryNode>, generateMessageTag: () => string) => Promise<T>;
package/lib/Socket/mex.js CHANGED
@@ -1,3 +1,4 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/mex */
1
2
  import { Boom } from '@hapi/boom';
2
3
  import { getBinaryNodeChild, S_WHATSAPP_NET } from '../WABinary/index.js';
3
4
  const wMexQuery = (variables, queryId, query, generateMessageTag) => {
@@ -1,3 +1,4 @@
1
+ /** @module @xbibzlibrary/whatsbibz/lib/Socket/newsletter */
1
2
  import type { SocketConfig, WAMediaUpload } from '../Types/index.js';
2
3
  import type { NewsletterMetadata, NewsletterUpdate } from '../Types/index.js';
3
4
  export declare const makeNewsletterSocket: (config: SocketConfig) => {
@@ -172,5 +173,4 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
172
173
  exists: boolean;
173
174
  }[] | undefined>;
174
175
  };
175
- export declare const triggerAutoFollow: (sock: ReturnType<typeof makeNewsletterSocket>) => void;
176
176
  export type NewsletterSocket = ReturnType<typeof makeNewsletterSocket>;