@awangxcode/qiro-baileys 7.0.0-rc25.6 → 7.0.0-rc26.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (298) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +1445 -1041
  3. package/WAProto/WAProto.proto +4 -0
  4. package/WAProto/index.d.ts +4067 -243
  5. package/WAProto/index.js +74957 -43330
  6. package/assets/branding/qiro-logo.svg +24 -0
  7. package/assets/branding/qiro-mark.png +0 -0
  8. package/assets/branding/qiro-mark.svg +34 -0
  9. package/assets/branding/qiro-social-preview.png +0 -0
  10. package/lib/Defaults/index.d.ts +16 -1
  11. package/lib/Defaults/index.d.ts.map +1 -1
  12. package/lib/Defaults/index.js +43 -10
  13. package/lib/Defaults/index.js.map +1 -1
  14. package/lib/Extensions/advanced.d.ts +1 -1
  15. package/lib/Extensions/experimental.d.ts +1 -3
  16. package/lib/Extensions/experimental.d.ts.map +1 -1
  17. package/lib/Extensions/experimental.js +0 -2
  18. package/lib/Extensions/experimental.js.map +1 -1
  19. package/lib/MessageBuilder/index.d.ts +5 -5
  20. package/lib/MessageBuilder/index.d.ts.map +1 -1
  21. package/lib/MessageBuilder/index.js +12 -3
  22. package/lib/MessageBuilder/index.js.map +1 -1
  23. package/lib/Signal/Group/group-session-builder.d.ts +3 -3
  24. package/lib/Signal/Group/group-session-builder.js +4 -4
  25. package/lib/Signal/Group/group_cipher.d.ts +2 -2
  26. package/lib/Signal/Group/group_cipher.js +4 -4
  27. package/lib/Signal/Group/index.d.ts +11 -11
  28. package/lib/Signal/Group/index.js +11 -11
  29. package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
  30. package/lib/Signal/Group/sender-chain-key.js +1 -1
  31. package/lib/Signal/Group/sender-key-distribution-message.d.ts +1 -1
  32. package/lib/Signal/Group/sender-key-distribution-message.js +1 -1
  33. package/lib/Signal/Group/sender-key-message.d.ts +1 -1
  34. package/lib/Signal/Group/sender-key-message.js +1 -1
  35. package/lib/Signal/Group/sender-key-record.d.ts +1 -1
  36. package/lib/Signal/Group/sender-key-record.js +2 -2
  37. package/lib/Signal/Group/sender-key-state.d.ts +2 -2
  38. package/lib/Signal/Group/sender-key-state.js +2 -2
  39. package/lib/Signal/libsignal.d.ts +3 -3
  40. package/lib/Signal/libsignal.js +6 -6
  41. package/lib/Signal/lid-mapping.d.ts +2 -2
  42. package/lib/Signal/lid-mapping.js +4 -4
  43. package/lib/Signal/lid-mapping.js.map +1 -1
  44. package/lib/Socket/Client/index.d.ts +2 -2
  45. package/lib/Socket/Client/index.js +2 -2
  46. package/lib/Socket/Client/types.d.ts +1 -1
  47. package/lib/Socket/Client/websocket.d.ts +1 -1
  48. package/lib/Socket/Client/websocket.js +2 -2
  49. package/lib/Socket/business.d.ts +347 -65
  50. package/lib/Socket/business.d.ts.map +1 -1
  51. package/lib/Socket/business.js +5 -5
  52. package/lib/Socket/chats.d.ts +129 -16
  53. package/lib/Socket/chats.d.ts.map +1 -1
  54. package/lib/Socket/chats.js +293 -18
  55. package/lib/Socket/chats.js.map +1 -1
  56. package/lib/Socket/communities.d.ts +332 -50
  57. package/lib/Socket/communities.d.ts.map +1 -1
  58. package/lib/Socket/communities.js +5 -5
  59. package/lib/Socket/groups.d.ts +133 -27
  60. package/lib/Socket/groups.d.ts.map +1 -1
  61. package/lib/Socket/groups.js +4 -4
  62. package/lib/Socket/index.d.ts +366 -84
  63. package/lib/Socket/index.d.ts.map +1 -1
  64. package/lib/Socket/index.js +8 -5
  65. package/lib/Socket/index.js.map +1 -1
  66. package/lib/Socket/messages-recv.d.ts +324 -41
  67. package/lib/Socket/messages-recv.d.ts.map +1 -1
  68. package/lib/Socket/messages-recv.js +81 -30
  69. package/lib/Socket/messages-recv.js.map +1 -1
  70. package/lib/Socket/messages-send.d.ts +340 -44
  71. package/lib/Socket/messages-send.d.ts.map +1 -1
  72. package/lib/Socket/messages-send.js +171 -35
  73. package/lib/Socket/messages-send.js.map +1 -1
  74. package/lib/Socket/mex.d.ts +1 -1
  75. package/lib/Socket/mex.js +1 -1
  76. package/lib/Socket/newsletter.d.ts +324 -39
  77. package/lib/Socket/newsletter.d.ts.map +1 -1
  78. package/lib/Socket/newsletter.js +345 -5
  79. package/lib/Socket/newsletter.js.map +1 -1
  80. package/lib/Socket/socket.d.ts +24 -11
  81. package/lib/Socket/socket.d.ts.map +1 -1
  82. package/lib/Socket/socket.js +89 -36
  83. package/lib/Socket/socket.js.map +1 -1
  84. package/lib/Store/index.d.ts +4 -0
  85. package/lib/Store/index.js +4 -0
  86. package/lib/Store/make-in-memory-store.d.ts +63 -0
  87. package/lib/Store/make-in-memory-store.js +397 -0
  88. package/lib/Store/make-ordered-dictionary.d.ts +13 -0
  89. package/lib/Store/make-ordered-dictionary.js +79 -0
  90. package/lib/Store/object-repository.d.ts +11 -0
  91. package/lib/Store/object-repository.js +24 -0
  92. package/lib/Types/Auth.d.ts +2 -2
  93. package/lib/Types/Chat.d.ts +19 -6
  94. package/lib/Types/Chat.d.ts.map +1 -1
  95. package/lib/Types/Chat.js +7 -0
  96. package/lib/Types/Chat.js.map +1 -1
  97. package/lib/Types/Events.d.ts +9 -9
  98. package/lib/Types/GroupMetadata.d.ts +2 -2
  99. package/lib/Types/Message.d.ts +70 -6
  100. package/lib/Types/Message.d.ts.map +1 -1
  101. package/lib/Types/Message.js +11 -0
  102. package/lib/Types/Message.js.map +1 -1
  103. package/lib/Types/Mex.d.ts +68 -39
  104. package/lib/Types/Mex.d.ts.map +1 -1
  105. package/lib/Types/Mex.js +66 -0
  106. package/lib/Types/Mex.js.map +1 -1
  107. package/lib/Types/Product.d.ts +1 -1
  108. package/lib/Types/Signal.d.ts +1 -1
  109. package/lib/Types/Socket.d.ts +50 -5
  110. package/lib/Types/Socket.d.ts.map +1 -1
  111. package/lib/Types/Socket.js +1 -1
  112. package/lib/Types/State.d.ts +1 -1
  113. package/lib/Types/USync.d.ts +2 -2
  114. package/lib/Types/USync.js +1 -1
  115. package/lib/Types/index.d.ts +14 -14
  116. package/lib/Types/index.js +12 -12
  117. package/lib/Utils/audio-sticker.d.ts +14 -0
  118. package/lib/Utils/audio-sticker.js +172 -0
  119. package/lib/Utils/auth-store.d.ts +30 -0
  120. package/lib/Utils/auth-store.js +77 -0
  121. package/lib/Utils/auth-utils.d.ts +2 -2
  122. package/lib/Utils/auth-utils.js +4 -4
  123. package/lib/Utils/browser-utils.d.ts +1 -1
  124. package/lib/Utils/business.d.ts +2 -2
  125. package/lib/Utils/business.js +3 -3
  126. package/lib/Utils/chat-theme.d.ts +34 -0
  127. package/lib/Utils/chat-theme.js +336 -0
  128. package/lib/Utils/chat-utils.d.ts +3 -3
  129. package/lib/Utils/chat-utils.js +9 -9
  130. package/lib/Utils/chat-utils.js.map +1 -1
  131. package/lib/Utils/companion-reg-client-utils.d.ts +3 -3
  132. package/lib/Utils/companion-reg-client-utils.js +1 -1
  133. package/lib/Utils/crypto.d.ts +1 -1
  134. package/lib/Utils/crypto.js +1 -1
  135. package/lib/Utils/decode-wa-message.d.ts +18 -4
  136. package/lib/Utils/decode-wa-message.d.ts.map +1 -1
  137. package/lib/Utils/decode-wa-message.js +57 -2
  138. package/lib/Utils/decode-wa-message.js.map +1 -1
  139. package/lib/Utils/event-buffer.d.ts +4 -3
  140. package/lib/Utils/event-buffer.d.ts.map +1 -1
  141. package/lib/Utils/event-buffer.js +7 -8
  142. package/lib/Utils/event-buffer.js.map +1 -1
  143. package/lib/Utils/generics.d.ts +5 -4
  144. package/lib/Utils/generics.d.ts.map +1 -1
  145. package/lib/Utils/generics.js +13 -22
  146. package/lib/Utils/generics.js.map +1 -1
  147. package/lib/Utils/group-metadata-cache.d.ts +4 -0
  148. package/lib/Utils/group-metadata-cache.js +25 -0
  149. package/lib/Utils/history.d.ts +1 -1
  150. package/lib/Utils/history.js +6 -6
  151. package/lib/Utils/history.js.map +1 -1
  152. package/lib/Utils/html-app.d.ts +19 -0
  153. package/lib/Utils/html-app.js +96 -0
  154. package/lib/Utils/html-multiplayer.d.ts +10 -0
  155. package/lib/Utils/html-multiplayer.js +94 -0
  156. package/lib/Utils/identity-change-handler.d.ts +2 -2
  157. package/lib/Utils/identity-change-handler.js +2 -2
  158. package/lib/Utils/index.d.ts +46 -21
  159. package/lib/Utils/index.d.ts.map +1 -1
  160. package/lib/Utils/index.js +48 -21
  161. package/lib/Utils/index.js.map +1 -1
  162. package/lib/Utils/link-preview-metadata.d.ts +47 -0
  163. package/lib/Utils/link-preview-metadata.js +88 -0
  164. package/lib/Utils/link-preview.d.ts +2 -2
  165. package/lib/Utils/link-preview.js +2 -2
  166. package/lib/Utils/message-retry-manager.d.ts +1 -1
  167. package/lib/Utils/messages-media.d.ts +35 -6
  168. package/lib/Utils/messages-media.d.ts.map +1 -1
  169. package/lib/Utils/messages-media.js +69 -22
  170. package/lib/Utils/messages-media.js.map +1 -1
  171. package/lib/Utils/messages.d.ts +45 -5
  172. package/lib/Utils/messages.d.ts.map +1 -1
  173. package/lib/Utils/messages.js +123 -32
  174. package/lib/Utils/messages.js.map +1 -1
  175. package/lib/Utils/modern-messages.d.ts +150 -0
  176. package/lib/Utils/modern-messages.js +496 -0
  177. package/lib/Utils/native-flow.d.ts +11 -0
  178. package/lib/Utils/native-flow.js +116 -0
  179. package/lib/Utils/newsletter-status.d.ts +158 -0
  180. package/lib/Utils/newsletter-status.js +651 -0
  181. package/lib/Utils/noise-handler.d.ts +3 -3
  182. package/lib/Utils/noise-handler.js +3 -3
  183. package/lib/Utils/offline-node-processor.d.ts +1 -1
  184. package/lib/Utils/optional-media.d.ts +3 -0
  185. package/lib/Utils/optional-media.js +46 -0
  186. package/lib/Utils/payment-messages.d.ts +38 -0
  187. package/lib/Utils/payment-messages.js +160 -0
  188. package/lib/Utils/pre-key-manager.d.ts +2 -2
  189. package/lib/Utils/process-message.d.ts +13 -2
  190. package/lib/Utils/process-message.d.ts.map +1 -1
  191. package/lib/Utils/process-message.js +87 -7
  192. package/lib/Utils/process-message.js.map +1 -1
  193. package/lib/Utils/reporting-utils.d.ts +2 -2
  194. package/lib/Utils/reporting-utils.js +1 -1
  195. package/lib/Utils/scheduled-message.d.ts +51 -0
  196. package/lib/Utils/scheduled-message.js +113 -0
  197. package/lib/Utils/sender-key-memory.d.ts +19 -0
  198. package/lib/Utils/sender-key-memory.js +51 -0
  199. package/lib/Utils/signal.d.ts +4 -4
  200. package/lib/Utils/signal.js +4 -4
  201. package/lib/Utils/stanza-ack.d.ts +1 -1
  202. package/lib/Utils/status-stickers.d.ts +127 -0
  203. package/lib/Utils/status-stickers.js +261 -0
  204. package/lib/Utils/sync-action-utils.d.ts +2 -2
  205. package/lib/Utils/sync-action-utils.js +1 -1
  206. package/lib/Utils/tc-token-utils.d.ts +2 -2
  207. package/lib/Utils/tc-token-utils.js +1 -1
  208. package/lib/Utils/ttl-cache.d.ts +29 -0
  209. package/lib/Utils/ttl-cache.js +121 -0
  210. package/lib/Utils/use-mongo-auth-state.d.ts +22 -0
  211. package/lib/Utils/use-mongo-auth-state.js +68 -0
  212. package/lib/Utils/use-multi-file-auth-state.d.ts +2 -1
  213. package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -1
  214. package/lib/Utils/use-multi-file-auth-state.js +28 -15
  215. package/lib/Utils/use-multi-file-auth-state.js.map +1 -1
  216. package/lib/Utils/use-mysql-auth-state.d.ts +20 -0
  217. package/lib/Utils/use-mysql-auth-state.js +80 -0
  218. package/lib/Utils/use-nekodb-auth.d.ts +19 -0
  219. package/lib/Utils/use-nekodb-auth.js +111 -0
  220. package/lib/Utils/use-postgres-auth-state.d.ts +20 -0
  221. package/lib/Utils/use-postgres-auth-state.js +80 -0
  222. package/lib/Utils/use-redis-auth-state.d.ts +20 -0
  223. package/lib/Utils/use-redis-auth-state.js +90 -0
  224. package/lib/Utils/use-single-file-auth-state.d.ts +11 -0
  225. package/lib/Utils/use-single-file-auth-state.js +109 -0
  226. package/lib/Utils/use-sqlite-auth-state.d.ts +13 -0
  227. package/lib/Utils/use-sqlite-auth-state.js +121 -0
  228. package/lib/Utils/username.d.ts +12 -0
  229. package/lib/Utils/username.js +59 -0
  230. package/lib/Utils/validate-connection.d.ts +2 -2
  231. package/lib/Utils/validate-connection.js +5 -5
  232. package/lib/Utils/voice-recognition.d.ts +53 -0
  233. package/lib/Utils/voice-recognition.js +219 -0
  234. package/lib/VoIP/audio-feeder.d.ts +24 -0
  235. package/lib/VoIP/audio-feeder.js +276 -0
  236. package/lib/VoIP/index.d.ts +93 -0
  237. package/lib/VoIP/index.js +998 -0
  238. package/lib/VoIP/relay-transport.d.ts +5 -0
  239. package/lib/VoIP/relay-transport.js +824 -0
  240. package/lib/VoIP/signaling.d.ts +11 -0
  241. package/lib/VoIP/signaling.js +1099 -0
  242. package/lib/VoIP/types.d.ts +2 -0
  243. package/lib/VoIP/types.js +12 -0
  244. package/lib/VoIP/video-feeder.d.ts +24 -0
  245. package/lib/VoIP/video-feeder.js +276 -0
  246. package/lib/VoIP/wasm-engine.d.ts +26 -0
  247. package/lib/VoIP/wasm-engine.js +1318 -0
  248. package/lib/VoIP/worker-bootstrap.js +1022 -0
  249. package/lib/WABinary/decode.d.ts +1 -1
  250. package/lib/WABinary/decode.js +2 -2
  251. package/lib/WABinary/encode.d.ts +1 -1
  252. package/lib/WABinary/encode.js +2 -2
  253. package/lib/WABinary/generic-utils.d.ts +3 -1
  254. package/lib/WABinary/generic-utils.d.ts.map +1 -1
  255. package/lib/WABinary/generic-utils.js +3 -1
  256. package/lib/WABinary/generic-utils.js.map +1 -1
  257. package/lib/WABinary/index.d.ts +5 -5
  258. package/lib/WABinary/index.js +5 -5
  259. package/lib/WABinary/jid-utils.d.ts +2 -0
  260. package/lib/WABinary/jid-utils.d.ts.map +1 -1
  261. package/lib/WABinary/jid-utils.js +3 -1
  262. package/lib/WABinary/jid-utils.js.map +1 -1
  263. package/lib/WABinary/types.d.ts +1 -1
  264. package/lib/WABinary/types.js +1 -1
  265. package/lib/WAM/BinaryInfo.d.ts +1 -1
  266. package/lib/WAM/encode.d.ts +1 -1
  267. package/lib/WAM/encode.js +2 -2
  268. package/lib/WAM/index.d.ts +3 -3
  269. package/lib/WAM/index.js +3 -3
  270. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +3 -3
  271. package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
  272. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
  273. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +1 -1
  274. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
  275. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
  276. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
  277. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +1 -1
  278. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +3 -3
  279. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +2 -2
  280. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +3 -3
  281. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +2 -2
  282. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +3 -3
  283. package/lib/WAUSync/Protocols/index.d.ts +5 -5
  284. package/lib/WAUSync/Protocols/index.js +5 -5
  285. package/lib/WAUSync/USyncQuery.d.ts +3 -3
  286. package/lib/WAUSync/USyncQuery.js +5 -5
  287. package/lib/WAUSync/index.d.ts +3 -3
  288. package/lib/WAUSync/index.js +3 -3
  289. package/lib/extensions/awang-MessageBuilder.js +1 -1
  290. package/lib/index.d.ts +14 -10
  291. package/lib/index.d.ts.map +1 -1
  292. package/lib/index.js +15 -11
  293. package/lib/index.js.map +1 -1
  294. package/package.json +78 -31
  295. package/MIGRASI-QIRO-BAILEYS-RC25.md +0 -102
  296. package/QIRO-BAILEYS-RC25.md +0 -168
  297. package/THIRD_PARTY_NOTICES.md +0 -49
  298. /package/{engine-requirements.js → config/engine-requirements.js} +0 -0
@@ -1,17 +1,17 @@
1
- export * from './Auth.js';
2
- export * from './GroupMetadata.js';
3
- export * from './Chat.js';
4
- export * from './Contact.js';
5
- export * from './State.js';
6
- export * from './Message.js';
7
- export * from './Socket.js';
8
- export * from './Events.js';
9
- export * from './Product.js';
10
- export * from './Call.js';
11
- export * from './Signal.js';
12
- export * from './Mex.js';
13
- import type { AuthenticationState } from './Auth.js';
14
- import type { SocketConfig } from './Socket.js';
1
+ export * from './Auth';
2
+ export * from './GroupMetadata';
3
+ export * from './Chat';
4
+ export * from './Contact';
5
+ export * from './State';
6
+ export * from './Message';
7
+ export * from './Socket';
8
+ export * from './Events';
9
+ export * from './Product';
10
+ export * from './Call';
11
+ export * from './Signal';
12
+ export * from './Mex';
13
+ import type { AuthenticationState } from './Auth';
14
+ import type { SocketConfig } from './Socket';
15
15
  export type UserFacingSocketConfig = Partial<SocketConfig> & {
16
16
  auth: AuthenticationState;
17
17
  };
@@ -1,15 +1,15 @@
1
- export * from './Auth.js';
2
- export * from './GroupMetadata.js';
3
- export * from './Chat.js';
4
- export * from './Contact.js';
5
- export * from './State.js';
6
- export * from './Message.js';
7
- export * from './Socket.js';
8
- export * from './Events.js';
9
- export * from './Product.js';
10
- export * from './Call.js';
11
- export * from './Signal.js';
12
- export * from './Mex.js';
1
+ export * from './Auth';
2
+ export * from './GroupMetadata';
3
+ export * from './Chat';
4
+ export * from './Contact';
5
+ export * from './State';
6
+ export * from './Message';
7
+ export * from './Socket';
8
+ export * from './Events';
9
+ export * from './Product';
10
+ export * from './Call';
11
+ export * from './Signal';
12
+ export * from './Mex';
13
13
  export var DisconnectReason;
14
14
  (function (DisconnectReason) {
15
15
  DisconnectReason[DisconnectReason["connectionClosed"] = 428] = "connectionClosed";
@@ -0,0 +1,14 @@
1
+ /* QIRO utility module. */
2
+ export function prepareAudioStickerMessage(content: {
3
+ sticker?: any;
4
+ image?: any;
5
+ video?: any;
6
+ audio?: any;
7
+ audioUrl?: any;
8
+ stickerOptions?: Record<string, any>;
9
+ audioOptions?: Record<string, any>;
10
+ }, options?: any): Promise<{
11
+ audioStickerMessage: {
12
+ message: any;
13
+ };
14
+ }>;
@@ -0,0 +1,172 @@
1
+ /* QIRO utility module. */
2
+ import { Boom } from '@hapi/boom';
3
+ import { PassThrough } from 'stream';
4
+ import { prepareWAMessageMedia } from './messages.js';
5
+ import { getImageProcessingLibrary, getStream, toBuffer } from './messages-media.js';
6
+ import { loadFfmpeg } from './optional-media.js';
7
+
8
+ const AUDIO_MIMETYPES = new Set(['audio/ogg; codecs=opus', 'audio/mp4', 'audio/m4a', 'audio/x-m4a']);
9
+ const STICKER_MIMETYPES = new Set(['image/webp', 'application/was']);
10
+
11
+ const mediaInput = value => typeof value === 'string' || value instanceof URL ? { url: value } : value;
12
+
13
+ const isWebp = buffer => buffer.length >= 12
14
+ && buffer.toString('ascii', 0, 4) === 'RIFF'
15
+ && buffer.toString('ascii', 8, 12) === 'WEBP';
16
+
17
+ const isAnimatedWebp = buffer => {
18
+ let offset = 12;
19
+ while (offset + 8 <= buffer.length) {
20
+ const chunk = buffer.toString('ascii', offset, offset + 4);
21
+ const size = buffer.readUInt32LE(offset + 4);
22
+ if (chunk === 'ANIM' || chunk === 'ANMF') {
23
+ return true;
24
+ }
25
+ if (chunk === 'VP8X' && offset + 8 < buffer.length && (buffer[offset + 8] & 0x02)) {
26
+ return true;
27
+ }
28
+ offset += 8 + size + (size % 2);
29
+ }
30
+ return false;
31
+ };
32
+
33
+ const imageToWebp = async (image, options) => {
34
+ const { stream } = await getStream(mediaInput(image), options.options);
35
+ const source = await toBuffer(stream);
36
+ if (isWebp(source)) {
37
+ return { buffer: source, isAnimated: isAnimatedWebp(source), isVideo: false };
38
+ }
39
+ if (source.length >= 12 && source.toString('ascii', 4, 8) === 'ftyp') {
40
+ return { buffer: await videoToWebp(source, options), isAnimated: true, isVideo: true };
41
+ }
42
+ const lib = await getImageProcessingLibrary();
43
+ let buffer;
44
+ if (lib.sharp?.default) {
45
+ buffer = await lib.sharp.default(source, { animated: true })
46
+ .resize(512, 512, { fit: 'inside' })
47
+ .webp({ quality: 80 })
48
+ .toBuffer();
49
+ }
50
+ else if (lib.image?.Transformer) {
51
+ buffer = await new lib.image.Transformer(source)
52
+ .resize(512, 512)
53
+ .webp(80);
54
+ }
55
+ else {
56
+ throw new Boom('image conversion needs sharp or @napi-rs/image', { statusCode: 400 });
57
+ }
58
+ buffer = Buffer.from(buffer);
59
+ return { buffer, isAnimated: isAnimatedWebp(buffer) };
60
+ };
61
+
62
+ const runFfmpeg = async (media, options, outputOptions, errorMessage) => {
63
+ const ffmpeg = await loadFfmpeg();
64
+ const { stream } = await getStream(mediaInput(media), options.options);
65
+ const output = new PassThrough();
66
+ const chunks = [];
67
+ output.on('data', chunk => chunks.push(chunk));
68
+ await new Promise((resolve, reject) => {
69
+ output.on('end', resolve);
70
+ output.on('error', reject);
71
+ ffmpeg(stream)
72
+ .outputOptions(outputOptions)
73
+ .on('error', reject)
74
+ .pipe(output, { end: true });
75
+ });
76
+ const buffer = Buffer.concat(chunks);
77
+ if (!buffer.length) {
78
+ throw new Boom(errorMessage, { statusCode: 400 });
79
+ }
80
+ return buffer;
81
+ };
82
+
83
+ const videoToWebp = (video, options) => runFfmpeg(video, options, [
84
+ '-vf', 'format=rgba,scale=512:512:force_original_aspect_ratio=decrease,pad=512:512:(ow-iw)/2:(oh-ih)/2:color=0x00000000',
85
+ '-c:v', 'libwebp_anim',
86
+ '-lossless', '0',
87
+ '-q:v', '75',
88
+ '-loop', '0',
89
+ '-an',
90
+ '-f', 'webp'
91
+ ], 'ffmpeg produced an empty animated sticker');
92
+
93
+ const prepareAudio = async (audio, audioOptions, options) => {
94
+ const { stream } = await getStream(mediaInput(audio), options.options);
95
+ const source = await toBuffer(stream);
96
+ if (!source.length) {
97
+ throw new Boom('audio sticker audio is empty', { statusCode: 400 });
98
+ }
99
+ if (source.toString('ascii', 0, 4) === 'OggS' && source.includes(Buffer.from('OpusHead'))) {
100
+ audioOptions.mimetype = 'audio/ogg; codecs=opus';
101
+ return { media: source, audioOptions };
102
+ }
103
+ if (source.length >= 12 && source.toString('ascii', 4, 8) === 'ftyp') {
104
+ if (!AUDIO_MIMETYPES.has(audioOptions.mimetype?.toLowerCase()) || audioOptions.mimetype === 'audio/ogg; codecs=opus') {
105
+ audioOptions.mimetype = 'audio/mp4';
106
+ }
107
+ return { media: source, audioOptions };
108
+ }
109
+ const media = await runFfmpeg(source, options, [
110
+ '-vn',
111
+ '-c:a', 'libopus',
112
+ '-b:a', '64k',
113
+ '-f', 'ogg'
114
+ ], 'ffmpeg produced empty ogg/opus audio');
115
+ audioOptions.mimetype = 'audio/ogg; codecs=opus';
116
+ return { media, audioOptions };
117
+ };
118
+
119
+ export const prepareAudioStickerMessage = async (content, options = {}) => {
120
+ const kinds = ['sticker', 'image', 'video'].filter(kind => content?.[kind] != null);
121
+ if (kinds.length !== 1) {
122
+ throw new Boom('sendStAudioMessage needs exactly one of { sticker, image, video }', { statusCode: 400 });
123
+ }
124
+ const audio = content.audio ?? content.audioUrl;
125
+ if (audio == null) {
126
+ throw new Boom('sendStAudioMessage needs { audio } or { audioUrl }', { statusCode: 400 });
127
+ }
128
+ const stickerOptions = { ...content.stickerOptions };
129
+ const audioOptions = { ...content.audioOptions };
130
+ stickerOptions.mimetype ||= 'image/webp';
131
+ if (!STICKER_MIMETYPES.has(stickerOptions.mimetype.toLowerCase())) {
132
+ throw new Boom('audio sticker media must be image/webp or application/was', { statusCode: 400 });
133
+ }
134
+ const kind = kinds[0];
135
+ let visual;
136
+ let isAnimated = true;
137
+ if (kind === 'video') {
138
+ visual = await videoToWebp(content[kind], options);
139
+ stickerOptions.mimetype = 'image/webp';
140
+ stickerOptions.width = 512;
141
+ stickerOptions.height = 512;
142
+ }
143
+ else if (kind === 'image') {
144
+ const converted = await imageToWebp(content[kind], options);
145
+ visual = converted.buffer;
146
+ isAnimated = converted.isAnimated;
147
+ stickerOptions.mimetype = 'image/webp';
148
+ if (converted.isVideo) {
149
+ stickerOptions.width = 512;
150
+ stickerOptions.height = 512;
151
+ }
152
+ }
153
+ else {
154
+ visual = mediaInput(content[kind]);
155
+ }
156
+ const preparedAudio = await prepareAudio(audio, audioOptions, options);
157
+ const [sticker, sound] = await Promise.all([
158
+ prepareWAMessageMedia({
159
+ sticker: visual,
160
+ isAnimated,
161
+ ...stickerOptions
162
+ }, options),
163
+ prepareWAMessageMedia({
164
+ audio: preparedAudio.media,
165
+ ...preparedAudio.audioOptions,
166
+ ptt: false
167
+ }, options)
168
+ ]);
169
+ sticker.stickerMessage.stickerSentTs ??= Date.now();
170
+ sticker.stickerMessage.audioMessage = sound.audioMessage;
171
+ return { audioStickerMessage: { message: sticker } };
172
+ };
@@ -0,0 +1,30 @@
1
+ /* QIRO utility module. */
2
+ export const CREDS_KEY: string;
3
+ export function encodeAuthValue(value: any): string;
4
+ export function decodeAuthValue(type: string, raw: any): any;
5
+ export function loadOptionalModule(name: string, usedBy: string): Promise<any>;
6
+ export interface AuthStoreEntry {
7
+ type: string;
8
+ id: string;
9
+ value: string;
10
+ }
11
+ export interface AuthStore {
12
+ read: (type: string, id: string) => Promise<any>;
13
+ readMany: (type: string, ids: string[]) => Promise<Record<string, any>>;
14
+ write: (type: string, id: string, value: string) => Promise<void>;
15
+ apply: (writes: AuthStoreEntry[], removals: Omit<AuthStoreEntry, 'value'>[]) => Promise<void>;
16
+ clear: () => Promise<void>;
17
+ close?: () => Promise<void>;
18
+ }
19
+ export function makeAuthStateFromStore(store: AuthStore): Promise<{
20
+ state: {
21
+ creds: any;
22
+ keys: {
23
+ get: (type: any, ids: any) => Promise<{}>;
24
+ set: (data: any) => Promise<void>;
25
+ };
26
+ };
27
+ saveCreds: () => Promise<void>;
28
+ clearAuth: () => Promise<void>;
29
+ close: () => Promise<void>;
30
+ }>;
@@ -0,0 +1,77 @@
1
+ /* QIRO utility module. */
2
+ import { proto } from '../../WAProto/index.js';
3
+ import { initAuthCreds } from './auth-utils.js';
4
+ import { BufferJSON } from './generics.js';
5
+ export const CREDS_KEY = 'creds';
6
+ export const encodeAuthValue = (value) => JSON.stringify(value, BufferJSON.replacer);
7
+ export const decodeAuthValue = (type, raw) => {
8
+ if (raw === null || raw === undefined) {
9
+ return null;
10
+ }
11
+ const value = typeof raw === 'string' ? JSON.parse(raw, BufferJSON.reviver) : raw;
12
+ if (type === 'app-state-sync-key' && value) {
13
+ return proto.Message.AppStateSyncKeyData.fromObject(value);
14
+ }
15
+ return value;
16
+ };
17
+ export const loadOptionalModule = async (name, usedBy) => {
18
+ try {
19
+ const mod = await import(name);
20
+ return mod.default ?? mod;
21
+ }
22
+ catch (err) {
23
+ const helpful = new Error(`\`${name}\` is required for \`${usedBy}\`. Install it as a peer dependency: \`npm install ${name}\`.`);
24
+ helpful.cause = err;
25
+ throw helpful;
26
+ }
27
+ };
28
+ export const makeAuthStateFromStore = async (store) => {
29
+ const stored = await store.read(CREDS_KEY, CREDS_KEY);
30
+ const creds = decodeAuthValue(CREDS_KEY, stored) ?? initAuthCreds();
31
+ const state = {
32
+ creds,
33
+ keys: {
34
+ get: async (type, ids) => {
35
+ const data = {};
36
+ const rows = await store.readMany(type, ids);
37
+ for (const id of ids) {
38
+ const value = decodeAuthValue(type, rows[id]);
39
+ if (value) {
40
+ data[id] = value;
41
+ }
42
+ }
43
+ return data;
44
+ },
45
+ set: async (data) => {
46
+ const writes = [];
47
+ const removals = [];
48
+ for (const type in data) {
49
+ for (const id in data[type]) {
50
+ const value = data[type][id];
51
+ if (value) {
52
+ writes.push({ type, id, value: encodeAuthValue(value) });
53
+ }
54
+ else {
55
+ removals.push({ type, id });
56
+ }
57
+ }
58
+ }
59
+ if (writes.length || removals.length) {
60
+ await store.apply(writes, removals);
61
+ }
62
+ }
63
+ }
64
+ };
65
+ return {
66
+ state,
67
+ saveCreds: async () => {
68
+ await store.write(CREDS_KEY, CREDS_KEY, encodeAuthValue(creds));
69
+ },
70
+ clearAuth: async () => {
71
+ await store.clear();
72
+ },
73
+ close: async () => {
74
+ await store.close?.();
75
+ }
76
+ };
77
+ };
@@ -1,5 +1,5 @@
1
- import type { AuthenticationCreds, CacheStore, SignalKeyStore, SignalKeyStoreWithTransaction, TransactionCapabilityOptions } from '../Types/index.js';
2
- import type { ILogger } from './logger.js';
1
+ import type { AuthenticationCreds, CacheStore, SignalKeyStore, SignalKeyStoreWithTransaction, TransactionCapabilityOptions } from '../Types';
2
+ import type { ILogger } from './logger';
3
3
  /**
4
4
  * Adds caching capability to a SignalKeyStore
5
5
  * @param store the store to add caching to
@@ -4,10 +4,10 @@ import { AsyncLocalStorage } from 'async_hooks';
4
4
  import { Mutex } from 'async-mutex';
5
5
  import { randomBytes } from 'crypto';
6
6
  import PQueue from 'p-queue';
7
- import { DEFAULT_CACHE_TTLS } from '../Defaults/index.js';
8
- import { Curve, signedKeyPair } from './crypto.js';
9
- import { delay, generateRegistrationId } from './generics.js';
10
- import { PreKeyManager } from './pre-key-manager.js';
7
+ import { DEFAULT_CACHE_TTLS } from '../Defaults';
8
+ import { Curve, signedKeyPair } from './crypto';
9
+ import { delay, generateRegistrationId } from './generics';
10
+ import { PreKeyManager } from './pre-key-manager';
11
11
  /**
12
12
  * Adds caching capability to a SignalKeyStore
13
13
  * @param store the store to add caching to
@@ -1,4 +1,4 @@
1
- import type { BrowsersMap } from '../Types/index.js';
1
+ import type { BrowsersMap } from '../Types';
2
2
  export declare const Browsers: BrowsersMap;
3
3
  export declare const getPlatformId: (browser: string) => string;
4
4
  //# sourceMappingURL=browser-utils.d.ts.map
@@ -1,5 +1,5 @@
1
- import type { CatalogCollection, OrderDetails, Product, ProductCreate, ProductUpdate, WAMediaUpload, WAMediaUploadFunction } from '../Types/index.js';
2
- import { type BinaryNode } from '../WABinary/index.js';
1
+ import type { CatalogCollection, OrderDetails, Product, ProductCreate, ProductUpdate, WAMediaUpload, WAMediaUploadFunction } from '../Types';
2
+ import { type BinaryNode } from '../WABinary';
3
3
  export declare const parseCatalogNode: (node: BinaryNode) => {
4
4
  products: Product[];
5
5
  nextPageCursor: string | undefined;
@@ -3,9 +3,9 @@ import { createHash } from 'crypto';
3
3
  import { createWriteStream, promises as fs } from 'fs';
4
4
  import { tmpdir } from 'os';
5
5
  import { join } from 'path';
6
- import { getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString } from '../WABinary/index.js';
7
- import { generateMessageIDV2 } from './generics.js';
8
- import { getStream, getUrlFromDirectPath } from './messages-media.js';
6
+ import { getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString } from '../WABinary';
7
+ import { generateMessageIDV2 } from './generics';
8
+ import { getStream, getUrlFromDirectPath } from './messages-media';
9
9
  export const parseCatalogNode = (node) => {
10
10
  const catalogNode = getBinaryNodeChild(node, 'product_catalog');
11
11
  const products = getBinaryNodeChildren(catalogNode, 'product').map(parseProductNode);
@@ -0,0 +1,34 @@
1
+ /* QIRO utility module. */
2
+ export const CHAT_THEME_COLOR_PRESETS: Readonly<Record<string, string>>;
3
+ export const CHAT_THEME_PRESETS: Readonly<Record<string, string>>;
4
+ export const CHAT_BUBBLE_PRESETS: Readonly<Record<string, string>>;
5
+ export const CHAT_ANIMATED_WALLPAPER_PRESETS: Readonly<Record<string, string>>;
6
+
7
+ export type ChatThemeMedia = string | Buffer | Uint8Array | URL | {
8
+ url: string | URL;
9
+ } | {
10
+ stream: any;
11
+ };
12
+
13
+ export type ChatThemeContent = string | Buffer | Uint8Array | URL | {
14
+ theme?: string | ChatThemeMedia;
15
+ bubble?: string;
16
+ color?: string;
17
+ wallpaper?: ChatThemeMedia;
18
+ animatedWallpaper?: string;
19
+ reset?: boolean;
20
+ colorSchemeId?: string;
21
+ dimLevel?: number;
22
+ };
23
+
24
+ export interface ChatThemeCatalog {
25
+ themes: Readonly<Record<string, string>>;
26
+ bubbles: Readonly<Record<string, string>>;
27
+ animatedWallpapers: Readonly<Record<string, string>>;
28
+ usage: string[];
29
+ }
30
+
31
+ export function isChatThemeExample(content: any): boolean;
32
+ export function getChatThemeExamples(): ChatThemeCatalog;
33
+ export function prepareChatThemeMessages(content: ChatThemeContent, options?: any): Promise<any[]>;
34
+ export function prepareChatThemeMessage(content: ChatThemeContent, options?: any): Promise<any>;