@japofc/baileys 2.1.0

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 (342) hide show
  1. package/NOTICE.md +111 -0
  2. package/README.md +1254 -0
  3. package/WAProto/index.d.ts +9 -0
  4. package/WAProto/index.js +142276 -0
  5. package/engine-requirements.js +13 -0
  6. package/lib/Builders/A2UI.d.ts +242 -0
  7. package/lib/Builders/A2UI.js +308 -0
  8. package/lib/Builders/AIRich.d.ts +105 -0
  9. package/lib/Builders/AIRich.js +2286 -0
  10. package/lib/Builders/Button.d.ts +103 -0
  11. package/lib/Builders/Button.js +883 -0
  12. package/lib/Builders/ButtonV2.d.ts +28 -0
  13. package/lib/Builders/ButtonV2.js +144 -0
  14. package/lib/Builders/ButtonV3.d.ts +25 -0
  15. package/lib/Builders/ButtonV3.js +184 -0
  16. package/lib/Builders/Carousel.d.ts +22 -0
  17. package/lib/Builders/Carousel.js +111 -0
  18. package/lib/Builders/JapBaileys.d.ts +34 -0
  19. package/lib/Builders/JapBaileys.js +108 -0
  20. package/lib/Builders/Poll.d.ts +25 -0
  21. package/lib/Builders/Poll.js +128 -0
  22. package/lib/Builders/index.d.ts +17 -0
  23. package/lib/Builders/index.js +11 -0
  24. package/lib/Builders/shared.d.ts +67 -0
  25. package/lib/Builders/shared.js +652 -0
  26. package/lib/Defaults/index.d.ts +154 -0
  27. package/lib/Defaults/index.js +178 -0
  28. package/lib/Framework/Bot.d.ts +61 -0
  29. package/lib/Framework/Bot.js +248 -0
  30. package/lib/Framework/Context.d.ts +21 -0
  31. package/lib/Framework/Context.js +89 -0
  32. package/lib/Framework/MediaManager.d.ts +17 -0
  33. package/lib/Framework/MediaManager.js +151 -0
  34. package/lib/Framework/SessionManager.d.ts +13 -0
  35. package/lib/Framework/SessionManager.js +33 -0
  36. package/lib/Framework/StatsManager.d.ts +26 -0
  37. package/lib/Framework/StatsManager.js +119 -0
  38. package/lib/Framework/Store/SQLiteStore.d.ts +11 -0
  39. package/lib/Framework/Store/SQLiteStore.js +73 -0
  40. package/lib/Framework/index.d.ts +9 -0
  41. package/lib/Framework/index.js +10 -0
  42. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  43. package/lib/Signal/Group/ciphertext-message.js +11 -0
  44. package/lib/Signal/Group/group-session-builder.d.ts +7 -0
  45. package/lib/Signal/Group/group-session-builder.js +29 -0
  46. package/lib/Signal/Group/group_cipher.d.ts +10 -0
  47. package/lib/Signal/Group/group_cipher.js +81 -0
  48. package/lib/Signal/Group/index.d.ts +11 -0
  49. package/lib/Signal/Group/index.js +11 -0
  50. package/lib/Signal/Group/keyhelper.d.ts +6 -0
  51. package/lib/Signal/Group/keyhelper.js +17 -0
  52. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  53. package/lib/Signal/Group/sender-chain-key.js +25 -0
  54. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  55. package/lib/Signal/Group/sender-key-distribution-message.js +62 -0
  56. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  57. package/lib/Signal/Group/sender-key-message.js +65 -0
  58. package/lib/Signal/Group/sender-key-name.d.ts +11 -0
  59. package/lib/Signal/Group/sender-key-name.js +47 -0
  60. package/lib/Signal/Group/sender-key-record.d.ts +12 -0
  61. package/lib/Signal/Group/sender-key-record.js +40 -0
  62. package/lib/Signal/Group/sender-key-state.d.ts +16 -0
  63. package/lib/Signal/Group/sender-key-state.js +83 -0
  64. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  65. package/lib/Signal/Group/sender-message-key.js +25 -0
  66. package/lib/Signal/libsignal.d.ts +54 -0
  67. package/lib/Signal/libsignal.js +430 -0
  68. package/lib/Signal/lid-mapping.d.ts +20 -0
  69. package/lib/Signal/lid-mapping.js +276 -0
  70. package/lib/Socket/Client/index.d.ts +2 -0
  71. package/lib/Socket/Client/index.js +2 -0
  72. package/lib/Socket/Client/types.d.ts +5 -0
  73. package/lib/Socket/Client/types.js +10 -0
  74. package/lib/Socket/Client/websocket.d.ts +12 -0
  75. package/lib/Socket/Client/websocket.js +53 -0
  76. package/lib/Socket/business.d.ts +395 -0
  77. package/lib/Socket/business.js +379 -0
  78. package/lib/Socket/chats.d.ts +136 -0
  79. package/lib/Socket/chats.js +1327 -0
  80. package/lib/Socket/communities.d.ts +562 -0
  81. package/lib/Socket/communities.js +439 -0
  82. package/lib/Socket/dugong.d.ts +117 -0
  83. package/lib/Socket/dugong.js +798 -0
  84. package/lib/Socket/groups.d.ts +285 -0
  85. package/lib/Socket/groups.js +354 -0
  86. package/lib/Socket/index.d.ts +585 -0
  87. package/lib/Socket/index.js +52 -0
  88. package/lib/Socket/messages-recv.d.ts +333 -0
  89. package/lib/Socket/messages-recv.js +1781 -0
  90. package/lib/Socket/messages-send.d.ts +353 -0
  91. package/lib/Socket/messages-send.js +1524 -0
  92. package/lib/Socket/mex.d.ts +1 -0
  93. package/lib/Socket/mex.js +41 -0
  94. package/lib/Socket/newsletter.d.ts +286 -0
  95. package/lib/Socket/newsletter.js +364 -0
  96. package/lib/Socket/socket.d.ts +60 -0
  97. package/lib/Socket/socket.js +1012 -0
  98. package/lib/Socket/username.d.ts +82 -0
  99. package/lib/Socket/username.js +159 -0
  100. package/lib/Store/index.d.ts +3 -0
  101. package/lib/Store/index.js +3 -0
  102. package/lib/Store/make-in-memory-store.d.ts +62 -0
  103. package/lib/Store/make-in-memory-store.js +428 -0
  104. package/lib/Store/make-ordered-dictionary.d.ts +12 -0
  105. package/lib/Store/make-ordered-dictionary.js +78 -0
  106. package/lib/Store/object-repository.d.ts +10 -0
  107. package/lib/Store/object-repository.js +23 -0
  108. package/lib/Types/Auth.d.ts +117 -0
  109. package/lib/Types/Auth.js +1 -0
  110. package/lib/Types/Bussines.d.ts +25 -0
  111. package/lib/Types/Call.d.ts +15 -0
  112. package/lib/Types/Call.js +1 -0
  113. package/lib/Types/Chat.d.ts +124 -0
  114. package/lib/Types/Chat.js +7 -0
  115. package/lib/Types/Contact.d.ts +26 -0
  116. package/lib/Types/Contact.js +1 -0
  117. package/lib/Types/Events.d.ts +256 -0
  118. package/lib/Types/Events.js +1 -0
  119. package/lib/Types/GroupMetadata.d.ts +71 -0
  120. package/lib/Types/GroupMetadata.js +1 -0
  121. package/lib/Types/Label.d.ts +5 -0
  122. package/lib/Types/Label.js +24 -0
  123. package/lib/Types/LabelAssociation.d.ts +6 -0
  124. package/lib/Types/LabelAssociation.js +6 -0
  125. package/lib/Types/Message.d.ts +62 -0
  126. package/lib/Types/Message.js +17 -0
  127. package/lib/Types/Mex.d.ts +2 -0
  128. package/lib/Types/Mex.js +38 -0
  129. package/lib/Types/Product.d.ts +79 -0
  130. package/lib/Types/Product.js +1 -0
  131. package/lib/Types/RichType.d.ts +2 -0
  132. package/lib/Types/RichType.js +22 -0
  133. package/lib/Types/Signal.d.ts +87 -0
  134. package/lib/Types/Signal.js +1 -0
  135. package/lib/Types/Socket.d.ts +138 -0
  136. package/lib/Types/Socket.js +1 -0
  137. package/lib/Types/State.d.ts +8 -0
  138. package/lib/Types/State.js +55 -0
  139. package/lib/Types/USync.d.ts +26 -0
  140. package/lib/Types/index.d.ts +68 -0
  141. package/lib/Types/index.js +27 -0
  142. package/lib/Utils/MessageBuilder.d.ts +2 -0
  143. package/lib/Utils/MessageBuilder.js +2 -0
  144. package/lib/Utils/PersistentStore.d.ts +60 -0
  145. package/lib/Utils/PersistentStore.js +592 -0
  146. package/lib/Utils/anti-delete.d.ts +74 -0
  147. package/lib/Utils/anti-delete.js +221 -0
  148. package/lib/Utils/auth-secure.d.ts +86 -0
  149. package/lib/Utils/auth-secure.js +764 -0
  150. package/lib/Utils/auth-utils.d.ts +57 -0
  151. package/lib/Utils/auth-utils.js +306 -0
  152. package/lib/Utils/auto-reply.d.ts +47 -0
  153. package/lib/Utils/auto-reply.js +157 -0
  154. package/lib/Utils/baileys-event-stream.d.ts +8 -0
  155. package/lib/Utils/baileys-event-stream.js +62 -0
  156. package/lib/Utils/browser-utils.d.ts +8 -0
  157. package/lib/Utils/browser-utils.js +27 -0
  158. package/lib/Utils/business.d.ts +49 -0
  159. package/lib/Utils/business.js +239 -0
  160. package/lib/Utils/button-helper-utils.d.ts +53 -0
  161. package/lib/Utils/button-helper-utils.js +312 -0
  162. package/lib/Utils/button-sender.d.ts +54 -0
  163. package/lib/Utils/button-sender.js +822 -0
  164. package/lib/Utils/chat-control.d.ts +159 -0
  165. package/lib/Utils/chat-control.js +230 -0
  166. package/lib/Utils/chat-history-helpers.d.ts +21 -0
  167. package/lib/Utils/chat-history-helpers.js +70 -0
  168. package/lib/Utils/chat-utils.d.ts +407 -0
  169. package/lib/Utils/chat-utils.js +885 -0
  170. package/lib/Utils/companion-reg-client-utils.d.ts +4 -0
  171. package/lib/Utils/companion-reg-client-utils.js +39 -0
  172. package/lib/Utils/crypto.d.ts +41 -0
  173. package/lib/Utils/crypto.js +147 -0
  174. package/lib/Utils/decode-wa-message.d.ts +83 -0
  175. package/lib/Utils/decode-wa-message.js +316 -0
  176. package/lib/Utils/event-buffer.d.ts +12 -0
  177. package/lib/Utils/event-buffer.js +635 -0
  178. package/lib/Utils/generics.d.ts +69 -0
  179. package/lib/Utils/generics.js +438 -0
  180. package/lib/Utils/history-share.d.ts +11 -0
  181. package/lib/Utils/history-share.js +70 -0
  182. package/lib/Utils/history.d.ts +90 -0
  183. package/lib/Utils/history.js +146 -0
  184. package/lib/Utils/humanizer.d.ts +12 -0
  185. package/lib/Utils/humanizer.js +73 -0
  186. package/lib/Utils/identity-change-handler.d.ts +13 -0
  187. package/lib/Utils/identity-change-handler.js +49 -0
  188. package/lib/Utils/index.d.ts +57 -0
  189. package/lib/Utils/index.js +56 -0
  190. package/lib/Utils/jid-tools.d.ts +6 -0
  191. package/lib/Utils/jid-tools.js +77 -0
  192. package/lib/Utils/link-preview.d.ts +12 -0
  193. package/lib/Utils/link-preview.js +84 -0
  194. package/lib/Utils/logger.d.ts +4 -0
  195. package/lib/Utils/logger.js +2 -0
  196. package/lib/Utils/lt-hash.d.ts +12 -0
  197. package/lib/Utils/lt-hash.js +26 -0
  198. package/lib/Utils/make-mutex.d.ts +6 -0
  199. package/lib/Utils/make-mutex.js +32 -0
  200. package/lib/Utils/media-messages.d.ts +18 -0
  201. package/lib/Utils/media-messages.js +70 -0
  202. package/lib/Utils/media-set.d.ts +13 -0
  203. package/lib/Utils/media-set.js +171 -0
  204. package/lib/Utils/message-kind.d.ts +32 -0
  205. package/lib/Utils/message-kind.js +136 -0
  206. package/lib/Utils/message-retry-manager.d.ts +79 -0
  207. package/lib/Utils/message-retry-manager.js +264 -0
  208. package/lib/Utils/message-search.d.ts +44 -0
  209. package/lib/Utils/message-search.js +188 -0
  210. package/lib/Utils/messages-media.d.ts +135 -0
  211. package/lib/Utils/messages-media.js +868 -0
  212. package/lib/Utils/messages.d.ts +44 -0
  213. package/lib/Utils/messages.js +2326 -0
  214. package/lib/Utils/meta-ai.d.ts +13 -0
  215. package/lib/Utils/meta-ai.js +74 -0
  216. package/lib/Utils/mini-app.d.ts +35 -0
  217. package/lib/Utils/mini-app.js +213 -0
  218. package/lib/Utils/noise-handler.d.ts +20 -0
  219. package/lib/Utils/noise-handler.js +200 -0
  220. package/lib/Utils/offline-node-processor.d.ts +9 -0
  221. package/lib/Utils/offline-node-processor.js +39 -0
  222. package/lib/Utils/past-participants.d.ts +14 -0
  223. package/lib/Utils/past-participants.js +40 -0
  224. package/lib/Utils/pre-key-manager.d.ts +25 -0
  225. package/lib/Utils/pre-key-manager.js +105 -0
  226. package/lib/Utils/process-message.d.ts +82 -0
  227. package/lib/Utils/process-message.js +808 -0
  228. package/lib/Utils/qr-render.d.ts +59 -0
  229. package/lib/Utils/qr-render.js +179 -0
  230. package/lib/Utils/qrcodegen.d.ts +79 -0
  231. package/lib/Utils/qrcodegen.js +848 -0
  232. package/lib/Utils/reporting-utils.d.ts +12 -0
  233. package/lib/Utils/reporting-utils.js +257 -0
  234. package/lib/Utils/rich-message-utils.d.ts +48 -0
  235. package/lib/Utils/rich-message-utils.js +444 -0
  236. package/lib/Utils/router.d.ts +37 -0
  237. package/lib/Utils/router.js +165 -0
  238. package/lib/Utils/scheduled-posts.d.ts +30 -0
  239. package/lib/Utils/scheduled-posts.js +110 -0
  240. package/lib/Utils/scheduling.d.ts +42 -0
  241. package/lib/Utils/scheduling.js +139 -0
  242. package/lib/Utils/signal.d.ts +82 -0
  243. package/lib/Utils/signal.js +200 -0
  244. package/lib/Utils/stanza-ack.d.ts +16 -0
  245. package/lib/Utils/stanza-ack.js +37 -0
  246. package/lib/Utils/status.d.ts +50 -0
  247. package/lib/Utils/status.js +107 -0
  248. package/lib/Utils/stickerpack.d.ts +51 -0
  249. package/lib/Utils/stickerpack.js +274 -0
  250. package/lib/Utils/sync-action-utils.d.ts +2 -0
  251. package/lib/Utils/sync-action-utils.js +48 -0
  252. package/lib/Utils/tag.d.ts +12 -0
  253. package/lib/Utils/tag.js +44 -0
  254. package/lib/Utils/tc-token-utils.d.ts +29 -0
  255. package/lib/Utils/tc-token-utils.js +162 -0
  256. package/lib/Utils/templates.d.ts +76 -0
  257. package/lib/Utils/templates.js +150 -0
  258. package/lib/Utils/transcribe.d.ts +12 -0
  259. package/lib/Utils/transcribe.js +107 -0
  260. package/lib/Utils/use-cache-manager-auth-state.d.ts +13 -0
  261. package/lib/Utils/use-cache-manager-auth-state.js +81 -0
  262. package/lib/Utils/use-multi-file-auth-state.d.ts +10 -0
  263. package/lib/Utils/use-multi-file-auth-state.js +166 -0
  264. package/lib/Utils/use-single-file-auth-state.d.ts +10 -0
  265. package/lib/Utils/use-single-file-auth-state.js +113 -0
  266. package/lib/Utils/use-sqlite-auth-state.d.ts +11 -0
  267. package/lib/Utils/use-sqlite-auth-state.js +169 -0
  268. package/lib/Utils/validate-connection.d.ts +42 -0
  269. package/lib/Utils/validate-connection.js +198 -0
  270. package/lib/Utils/vcard.d.ts +58 -0
  271. package/lib/Utils/vcard.js +104 -0
  272. package/lib/Utils/voice-note.d.ts +15 -0
  273. package/lib/Utils/voice-note.js +63 -0
  274. package/lib/VoIP/audio-feeder.d.ts +18 -0
  275. package/lib/VoIP/audio-feeder.js +160 -0
  276. package/lib/VoIP/call-recorder.d.ts +13 -0
  277. package/lib/VoIP/call-recorder.js +73 -0
  278. package/lib/VoIP/index.d.ts +86 -0
  279. package/lib/VoIP/index.js +611 -0
  280. package/lib/VoIP/relay-transport.d.ts +43 -0
  281. package/lib/VoIP/relay-transport.js +563 -0
  282. package/lib/VoIP/signaling.d.ts +26 -0
  283. package/lib/VoIP/signaling.js +662 -0
  284. package/lib/VoIP/types.d.ts +69 -0
  285. package/lib/VoIP/types.js +17 -0
  286. package/lib/VoIP/wasm-engine.d.ts +120 -0
  287. package/lib/VoIP/wasm-engine.js +1358 -0
  288. package/lib/VoIP/worker-bootstrap.d.ts +4 -0
  289. package/lib/VoIP/worker-bootstrap.js +1046 -0
  290. package/lib/WABinary/constants.d.ts +61 -0
  291. package/lib/WABinary/constants.js +1466 -0
  292. package/lib/WABinary/decode.d.ts +9 -0
  293. package/lib/WABinary/decode.js +261 -0
  294. package/lib/WABinary/encode.d.ts +2 -0
  295. package/lib/WABinary/encode.js +219 -0
  296. package/lib/WABinary/generic-utils.d.ts +74 -0
  297. package/lib/WABinary/generic-utils.js +276 -0
  298. package/lib/WABinary/index.d.ts +5 -0
  299. package/lib/WABinary/index.js +5 -0
  300. package/lib/WABinary/jid-utils.d.ts +28 -0
  301. package/lib/WABinary/jid-utils.js +95 -0
  302. package/lib/WABinary/types.d.ts +19 -0
  303. package/lib/WABinary/types.js +1 -0
  304. package/lib/WAM/BinaryInfo.d.ts +7 -0
  305. package/lib/WAM/BinaryInfo.js +9 -0
  306. package/lib/WAM/constants.d.ts +34926 -0
  307. package/lib/WAM/constants.js +22852 -0
  308. package/lib/WAM/encode.d.ts +1 -0
  309. package/lib/WAM/encode.js +149 -0
  310. package/lib/WAM/index.d.ts +3 -0
  311. package/lib/WAM/index.js +3 -0
  312. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +36 -0
  313. package/lib/WAUSync/Protocols/USyncContactProtocol.js +51 -0
  314. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +29 -0
  315. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +62 -0
  316. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  317. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
  318. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  319. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +37 -0
  320. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +9 -0
  321. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +24 -0
  322. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +38 -0
  323. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -0
  324. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +14 -0
  325. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +28 -0
  326. package/lib/WAUSync/Protocols/index.d.ts +7 -0
  327. package/lib/WAUSync/Protocols/index.js +7 -0
  328. package/lib/WAUSync/USyncQuery.d.ts +20 -0
  329. package/lib/WAUSync/USyncQuery.js +121 -0
  330. package/lib/WAUSync/USyncUser.d.ts +16 -0
  331. package/lib/WAUSync/USyncUser.js +30 -0
  332. package/lib/WAUSync/index.d.ts +3 -0
  333. package/lib/WAUSync/index.js +3 -0
  334. package/lib/assets/wasm/loader.d.ts +5 -0
  335. package/lib/assets/wasm/loader.js +5 -0
  336. package/lib/assets/wasm/whatsapp.wasm +0 -0
  337. package/lib/assets/wasm/worker-modules.d.ts +5 -0
  338. package/lib/assets/wasm/worker-modules.js +273 -0
  339. package/lib/index.d.ts +18 -0
  340. package/lib/index.js +23 -0
  341. package/package.json +180 -0
  342. package/postinstall-banner.js +82 -0
@@ -0,0 +1,107 @@
1
+ // JAP@Add --- part of the @japofc/baileys utils (status-helpers.ts) (type-only
2
+ // annotations dropped; behavior unchanged). status-posting.ts (the other
3
+ // addon shipping identical STATUS_BACKGROUNDS/STATUS_FONTS/createXStatus/
4
+ // StatusHelper) additionally exposed `makeStatusMentionsAddon`, a
5
+ // socket-factory-style addon requiring deep internal wiring (authState,
6
+ // waUploadToServer, groupMetadata, generateWAMessageContent) matching
7
+ // Baileys' own makeXSocket pattern — left out of this port as too tightly
8
+ // coupled to socket internals to safely merge without live testing.
9
+ // Basic status mentions are still supported via createTextStatus's own
10
+ // `mentions` option (contextInfo.mentionedJid).
11
+ import { randomBytes } from 'crypto';
12
+ export const STATUS_BROADCAST_JID = 'status@broadcast';
13
+ export const STATUS_BACKGROUNDS = {
14
+ solid: {
15
+ green: '#25D366',
16
+ blue: '#34B7F1',
17
+ purple: '#8B5CF6',
18
+ red: '#EF4444',
19
+ orange: '#F97316',
20
+ yellow: '#EAB308',
21
+ pink: '#EC4899',
22
+ teal: '#14B8A6',
23
+ gray: '#6B7280',
24
+ black: '#000000',
25
+ white: '#FFFFFF'
26
+ },
27
+ gradient: {
28
+ sunset: ['#F97316', '#EF4444'],
29
+ ocean: ['#3B82F6', '#06B6D4'],
30
+ forest: ['#22C55E', '#10B981'],
31
+ purple: ['#8B5CF6', '#EC4899'],
32
+ midnight: ['#1E3A8A', '#4C1D95'],
33
+ aurora: ['#06B6D4', '#8B5CF6', '#EC4899']
34
+ }
35
+ };
36
+ export const STATUS_FONTS = {
37
+ SANS_SERIF: 0,
38
+ SERIF: 1,
39
+ NORICAN: 2,
40
+ BRYNDAN: 3,
41
+ BEBASNEUE: 4,
42
+ OSWALD: 5,
43
+ DAMION: 6,
44
+ DANCING: 7,
45
+ COMFORTAA: 8,
46
+ EXOTWO: 9
47
+ };
48
+ /** Generate a status message ID with a 4NY4W3B prefix. */
49
+ export const generateStatusMessageId = () => `4NY4W3B${randomBytes(16).toString('hex').toUpperCase()}`;
50
+ export const createTextStatus = (options) => ({
51
+ text: options.text,
52
+ backgroundColor: options.backgroundColor || STATUS_BACKGROUNDS.solid.green,
53
+ font: options.font ?? STATUS_FONTS.SANS_SERIF,
54
+ textColor: options.textColor || '#FFFFFF',
55
+ contextInfo: { mentionedJid: options.mentions || [], isForwarded: false }
56
+ });
57
+ export const createImageStatus = (media, options) => ({
58
+ image: typeof media === 'string' ? { url: media } : media,
59
+ caption: options?.caption || ''
60
+ });
61
+ export const createVideoStatus = (media, options) => ({
62
+ video: typeof media === 'string' ? { url: media } : media,
63
+ caption: options?.caption || '',
64
+ gifPlayback: options?.gifPlayback || false
65
+ });
66
+ export const createAudioStatus = (media, options) => ({
67
+ audio: typeof media === 'string' ? { url: media } : media,
68
+ ptt: true,
69
+ mimetype: 'audio/ogg; codecs=opus',
70
+ waveform: options?.waveform
71
+ });
72
+ export const getStatusJid = () => STATUS_BROADCAST_JID;
73
+ /** Convenience wrappers + a `send()` that routes group vs. individual/broadcast status delivery. */
74
+ export const StatusHelper = {
75
+ text: (text, backgroundColor, font) => createTextStatus({ text, backgroundColor, font }),
76
+ image: (buffer, caption) => createImageStatus(buffer, { caption }),
77
+ imageUrl: (url, caption) => createImageStatus(url, { caption }),
78
+ video: (buffer, caption) => createVideoStatus(buffer, { caption }),
79
+ videoUrl: (url, caption) => createVideoStatus(url, { caption }),
80
+ gif: (buffer, caption) => createVideoStatus(buffer, { caption, gifPlayback: true }),
81
+ voiceNote: (buffer) => createAudioStatus(buffer),
82
+ /**
83
+ * Send a status to specific JIDs (groups and/or individuals).
84
+ * Handles group status (groupStatus:true) and broadcast (status@broadcast) separately.
85
+ * Pass an empty jidList (or omit it) to broadcast to everyone.
86
+ */
87
+ send: async (sock, content, jidList = []) => {
88
+ const groups = jidList.filter((j) => j?.endsWith('@g.us'));
89
+ const individuals = jidList.filter((j) => j?.endsWith('@s.whatsapp.net') || j?.endsWith('@lid'));
90
+ let lastResult;
91
+ if (groups.length > 0) {
92
+ const groupContent = { ...content, groupStatus: true };
93
+ for (const groupJid of groups) {
94
+ lastResult = await sock.sendMessage(groupJid, groupContent, { messageId: generateStatusMessageId() });
95
+ }
96
+ }
97
+ if (individuals.length > 0 || jidList.length === 0) {
98
+ const result = await sock.sendMessage(STATUS_BROADCAST_JID, content, {
99
+ statusJidList: individuals.length > 0 ? individuals : undefined,
100
+ messageId: generateStatusMessageId()
101
+ });
102
+ if (!lastResult)
103
+ lastResult = result;
104
+ }
105
+ return lastResult;
106
+ }
107
+ };
@@ -0,0 +1,51 @@
1
+ import type { ILogger } from './logger.js';
2
+ import type { WAMediaUpload } from '../Types/index.js';
3
+ import { proto } from '../../WAProto/index.js';
4
+ export declare const isWebPBuffer: (buffer: Buffer) => boolean;
5
+ export declare const isAnimatedWebP: (buffer: Buffer) => boolean;
6
+ export declare const convertToWebP: (input: WAMediaUpload) => Promise<{
7
+ buffer: Buffer;
8
+ isAnimated: boolean;
9
+ }>;
10
+ export declare const generateStickerPackId: () => string;
11
+ export declare const buildStickerPackProto: (pack: {
12
+ name: string;
13
+ publisher: string;
14
+ packId?: string;
15
+ description?: string;
16
+ }) => {
17
+ name: string;
18
+ publisher: string;
19
+ packId: string;
20
+ description: string;
21
+ };
22
+ export declare const STICKER_PACK_MESSAGE_TYPE: 'sticker_pack';
23
+ export type JapStickerInput = {
24
+ data: WAMediaUpload;
25
+ emojis?: string[];
26
+ accessibilityLabel?: string;
27
+ };
28
+ export type JapStickerPackInput = {
29
+ cover: WAMediaUpload;
30
+ stickers: JapStickerInput[];
31
+ name?: string;
32
+ publisher?: string;
33
+ description?: string;
34
+ };
35
+ export type JapStickerPackOptions = {
36
+ logger?: ILogger;
37
+ upload: (filePath: string, opts: {
38
+ fileEncSha256B64: string;
39
+ mediaType: string;
40
+ timeoutMs?: number;
41
+ }) => Promise<{
42
+ directPath: string;
43
+ }>;
44
+ options?: RequestInit;
45
+ mediaUploadTimeoutMs?: number;
46
+ mediaCache?: {
47
+ get: (key: string) => Promise<Buffer | undefined>;
48
+ set: (key: string, value: Buffer) => void;
49
+ };
50
+ };
51
+ export declare const prepareStickerPackMessage: (message: JapStickerPackInput, options: JapStickerPackOptions) => Promise<any>;
@@ -0,0 +1,274 @@
1
+ /**
2
+ * JAP@Add --- part of the @japofc/baileys utils (stickerpack.ts.)
3
+ *
4
+ * Adds support for building/sending WhatsApp Sticker Pack messages.
5
+ *
6
+ * Exports:
7
+ * - convertToWebP() — converts a Buffer, URL string, or Stream into a WebP
8
+ * sticker buffer (passthrough if already WebP), sharp → @napi-rs/image
9
+ * fallback chain, 512x512 'inside' fit, quality 80.
10
+ * - generateStickerPackId() — generates a random pack ID
11
+ * - buildStickerPackProto() — builds the proto-level payload for a StickerPackMessage
12
+ * - STICKER_PACK_MESSAGE_TYPE — the message type string 'sticker_pack'
13
+ * - prepareStickerPackMessage() — full ZIP-build + upload + thumbnail
14
+ * pipeline for a ready-to-send stickerPackMessage.
15
+ *
16
+ * NOTE: source imported isWebPBuffer/isAnimatedWebP from its own
17
+ * from-messages.ts, which is not part of this fork's port. Reimplemented
18
+ * below as small standalone binary-sniffing helpers (RIFF/WEBP header +
19
+ * ANIM chunk check) so this file has no external dependency on that addon.
20
+ */
21
+ import { Boom } from '@hapi/boom';
22
+ import { zip } from 'fflate';
23
+ import { promises as fsPromises } from 'fs';
24
+ import { proto } from '../../WAProto/index.js';
25
+ import { sha256 } from './crypto.js';
26
+ import { generateMessageIDV2, unixTimestampSeconds } from './generics.js';
27
+ import { encryptedStream, getImageProcessingLibrary, getStream, toBuffer } from './messages-media.js';
28
+ /** True if `buffer` starts with a RIFF....WEBP container header. */
29
+ export const isWebPBuffer = (buffer) => {
30
+ return (buffer.length > 12 &&
31
+ buffer.toString('ascii', 0, 4) === 'RIFF' &&
32
+ buffer.toString('ascii', 8, 12) === 'WEBP');
33
+ };
34
+ /** True if a WebP buffer contains an ANIM chunk (animated sticker). */
35
+ export const isAnimatedWebP = (buffer) => {
36
+ return isWebPBuffer(buffer) && buffer.includes(Buffer.from('ANIM', 'ascii'));
37
+ };
38
+ /**
39
+ * Convert a Buffer, URL string, or Stream into a WebP sticker buffer.
40
+ * If the input is already a valid WebP, it's returned untouched (and
41
+ * `isAnimated` reflects whether it's an animated WebP).
42
+ */
43
+ export const convertToWebP = async (input) => {
44
+ const { stream } = await getStream(input);
45
+ const buffer = await toBuffer(stream);
46
+ if (isWebPBuffer(buffer)) {
47
+ return { buffer, isAnimated: isAnimatedWebP(buffer) };
48
+ }
49
+ const lib = await getImageProcessingLibrary();
50
+ const hasSharp = 'sharp' in lib && !!lib.sharp?.default;
51
+ const hasImage = 'image' in lib && !!lib.image?.Transformer;
52
+ if (!hasSharp && !hasImage) {
53
+ throw new Boom('No image processing library (sharp or @napi-rs/image) available for converting sticker to WebP.');
54
+ }
55
+ let webpBuffer;
56
+ if (hasSharp) {
57
+ webpBuffer = await lib.sharp
58
+ .default(buffer)
59
+ .resize(512, 512, { fit: 'inside' })
60
+ .webp({ quality: 80 })
61
+ .toBuffer();
62
+ }
63
+ else {
64
+ webpBuffer = await new lib.image.Transformer(buffer).resize(512, 512).webp(80);
65
+ }
66
+ return { buffer: webpBuffer, isAnimated: false };
67
+ };
68
+ /** Generate a random sticker pack ID (16 hex chars). */
69
+ export const generateStickerPackId = () => {
70
+ const arr = new Uint8Array(8);
71
+ for (let i = 0; i < 8; i++)
72
+ arr[i] = Math.floor(Math.random() * 256);
73
+ return Array.from(arr)
74
+ .map((b) => b.toString(16).padStart(2, '0'))
75
+ .join('');
76
+ };
77
+ /** Build the proto-level stickerPackMessage payload (name/publisher/packId/description only). */
78
+ export const buildStickerPackProto = (pack) => ({
79
+ name: pack.name,
80
+ publisher: pack.publisher,
81
+ packId: pack.packId ?? generateStickerPackId(),
82
+ description: pack.description ?? ''
83
+ });
84
+ /** stickerPack message type marker — for use with getMediaType()-style dispatch. */
85
+ export const STICKER_PACK_MESSAGE_TYPE = 'sticker_pack';
86
+ const ITSL_CONCURRENCY_LIMIT = 15;
87
+ /**
88
+ * Build a complete, ready-to-send stickerPackMessage (ZIP built, encrypted,
89
+ * and uploaded) — full pipeline: per-sticker WebP conversion (15-way
90
+ * concurrency batching), 1MB per-sticker size limit, 60-sticker pack limit,
91
+ * cover→trayIcon-in-ZIP, and a separate 252×252 JPEG thumbnail upload.
92
+ */
93
+ export const prepareStickerPackMessage = async (message, options) => {
94
+ // JAP@Fix (bug 62): packId was never destructured here, so a caller-supplied
95
+ // pack ID was silently dropped and a fresh one always generated below.
96
+ const { cover, stickers = [], name = '📦 Sticker Pack', publisher = 'GitHub: JAPofc', description = '🏷️ japofc/baileys', packId } = message;
97
+ if (stickers.length > 60) {
98
+ throw new Boom('Sticker pack exceeds the maximum limit of 60 stickers', { statusCode: 400 });
99
+ }
100
+ if (stickers.length === 0) {
101
+ throw new Boom('Sticker pack must contain at least one sticker', { statusCode: 400 });
102
+ }
103
+ if (!cover) {
104
+ throw new Boom('Sticker pack must contain a cover', { statusCode: 400 });
105
+ }
106
+ const { logger } = options;
107
+ // Media caching (keyed by concatenated sticker URLs, if all stickers are URL-based)
108
+ let cacheableKey = false;
109
+ if (stickers.length && options.mediaCache) {
110
+ const urls = [];
111
+ for (const s of stickers) {
112
+ const data = s.data;
113
+ if (typeof data === 'object' && data?.url)
114
+ urls.push(data.url);
115
+ }
116
+ if (urls.length > 0)
117
+ cacheableKey = 'sticker:' + urls.join('@');
118
+ }
119
+ if (cacheableKey) {
120
+ const mediaBuff = await options.mediaCache.get(cacheableKey);
121
+ if (mediaBuff) {
122
+ logger?.debug({ cacheableKey }, 'got media cache hit');
123
+ return proto.Message.StickerPackMessage.decode(mediaBuff);
124
+ }
125
+ }
126
+ const lib = await getImageProcessingLibrary();
127
+ const hasSharp = 'sharp' in lib && !!lib.sharp?.default;
128
+ const hasImage = 'image' in lib && !!lib.image?.Transformer;
129
+ if (!hasSharp && !hasImage) {
130
+ throw new Boom('No image processing library (sharp or @napi-rs/image) available for converting sticker to WebP.');
131
+ }
132
+ const stickerPackIdValue = packId ?? generateMessageIDV2();
133
+ const stickerData = {};
134
+ const stickerMetadata = new Array(stickers.length);
135
+ for (let i = 0; i < stickers.length; i += ITSL_CONCURRENCY_LIMIT) {
136
+ const chunkEnd = Math.min(i + ITSL_CONCURRENCY_LIMIT, stickers.length);
137
+ const promises = [];
138
+ for (let j = i; j < chunkEnd; j++) {
139
+ promises.push((async (index) => {
140
+ const sticker = stickers[index];
141
+ const { stream } = await getStream(sticker.data);
142
+ const buffer = await toBuffer(stream);
143
+ let webpBuffer;
144
+ let isAnimated = false;
145
+ if (isWebPBuffer(buffer)) {
146
+ webpBuffer = buffer;
147
+ isAnimated = isAnimatedWebP(buffer);
148
+ }
149
+ else if (hasSharp) {
150
+ webpBuffer = await lib.sharp
151
+ .default(buffer)
152
+ .resize(512, 512, { fit: 'inside' })
153
+ .webp({ quality: 80 })
154
+ .toBuffer();
155
+ }
156
+ else {
157
+ webpBuffer = await new lib.image.Transformer(buffer).resize(512, 512).webp(80);
158
+ }
159
+ if (webpBuffer.length > 1024 * 1024) {
160
+ throw new Boom(`Sticker at index ${index} exceeds the 1MB size limit`, { statusCode: 400 });
161
+ }
162
+ const hash = sha256(webpBuffer).toString('base64').replace(/\//g, '-');
163
+ const fileName = `${hash}.webp`;
164
+ stickerData[fileName] = [new Uint8Array(webpBuffer), { level: 0 }];
165
+ stickerMetadata[index] = {
166
+ fileName,
167
+ mimetype: 'image/webp',
168
+ isAnimated,
169
+ emojis: sticker.emojis || ['✨'],
170
+ accessibilityLabel: sticker.accessibilityLabel || '‎'
171
+ };
172
+ })(j));
173
+ }
174
+ await Promise.all(promises);
175
+ }
176
+ const trayIconFileName = `${stickerPackIdValue}.webp`;
177
+ const { stream: coverStream } = await getStream(cover);
178
+ const coverBuffer = await toBuffer(coverStream);
179
+ let coverWebpBuffer;
180
+ if (isWebPBuffer(coverBuffer)) {
181
+ coverWebpBuffer = coverBuffer;
182
+ }
183
+ else if (hasSharp) {
184
+ coverWebpBuffer = await lib.sharp
185
+ .default(coverBuffer)
186
+ .resize(512, 512, { fit: 'inside' })
187
+ .webp({ quality: 80 })
188
+ .toBuffer();
189
+ }
190
+ else {
191
+ coverWebpBuffer = await new lib.image.Transformer(coverBuffer).resize(512, 512).webp(80);
192
+ }
193
+ stickerData[trayIconFileName] = [new Uint8Array(coverWebpBuffer), { level: 0 }];
194
+ const zipBuffer = await new Promise((resolve, reject) => {
195
+ zip(stickerData, (error, data) => (error ? reject(error) : resolve(Buffer.from(data))));
196
+ });
197
+ const stickerPackUpload = await encryptedStream(zipBuffer, 'sticker-pack', { logger, opts: options.options });
198
+ let stickerPackUploadResult;
199
+ try {
200
+ stickerPackUploadResult = await options.upload(stickerPackUpload.encFilePath, {
201
+ fileEncSha256B64: stickerPackUpload.fileEncSha256.toString('base64'),
202
+ mediaType: 'sticker-pack',
203
+ timeoutMs: options.mediaUploadTimeoutMs
204
+ });
205
+ }
206
+ finally {
207
+ fsPromises.unlink(stickerPackUpload.encFilePath).catch(() => logger?.warn('failed to remove tmp file'));
208
+ }
209
+ const obj = {
210
+ name,
211
+ publisher,
212
+ stickerPackId: stickerPackIdValue,
213
+ packDescription: description,
214
+ stickerPackOrigin: proto.Message.StickerPackMessage.StickerPackOrigin.USER_CREATED,
215
+ stickerPackSize: zipBuffer.length,
216
+ stickers: stickerMetadata,
217
+ fileSha256: stickerPackUpload.fileSha256,
218
+ fileEncSha256: stickerPackUpload.fileEncSha256,
219
+ mediaKey: stickerPackUpload.mediaKey,
220
+ directPath: stickerPackUploadResult.directPath,
221
+ fileLength: stickerPackUpload.fileLength,
222
+ mediaKeyTimestamp: unixTimestampSeconds(),
223
+ trayIconFileName
224
+ };
225
+ try {
226
+ let thumbnailBuffer;
227
+ if (hasSharp) {
228
+ thumbnailBuffer = await lib.sharp.default(coverBuffer).resize(252, 252).jpeg().toBuffer();
229
+ }
230
+ else {
231
+ // hasImage is guaranteed here since hasSharp||hasImage is enforced above.
232
+ // JAP@Fix (bug 63): removed a jimp fallback branch that could never be
233
+ // reached (the earlier guard already requires sharp or image), and which
234
+ // main sticker/cover conversion above doesn't support anyway — it was
235
+ // dead code presenting a false sense of a jimp-only code path.
236
+ thumbnailBuffer = await new lib.image.Transformer(coverBuffer).resize(252, 252).jpeg();
237
+ }
238
+ if (!thumbnailBuffer || thumbnailBuffer.length === 0) {
239
+ throw new Error('Failed to generate thumbnail buffer');
240
+ }
241
+ const thumbUpload = await encryptedStream(thumbnailBuffer, 'thumbnail-sticker-pack', {
242
+ logger,
243
+ opts: options.options,
244
+ mediaKey: stickerPackUpload.mediaKey
245
+ });
246
+ let thumbUploadResult;
247
+ try {
248
+ thumbUploadResult = await options.upload(thumbUpload.encFilePath, {
249
+ fileEncSha256B64: thumbUpload.fileEncSha256.toString('base64'),
250
+ mediaType: 'thumbnail-sticker-pack',
251
+ timeoutMs: options.mediaUploadTimeoutMs
252
+ });
253
+ }
254
+ finally {
255
+ fsPromises.unlink(thumbUpload.encFilePath).catch(() => logger?.warn('failed to remove tmp file'));
256
+ }
257
+ Object.assign(obj, {
258
+ thumbnailDirectPath: thumbUploadResult.directPath,
259
+ thumbnailSha256: thumbUpload.fileSha256,
260
+ thumbnailEncSha256: thumbUpload.fileEncSha256,
261
+ thumbnailHeight: 252,
262
+ thumbnailWidth: 252,
263
+ imageDataHash: sha256(thumbnailBuffer).toString('base64')
264
+ });
265
+ }
266
+ catch (error) {
267
+ logger?.warn(`Thumbnail generation failed: ${error}`);
268
+ }
269
+ if (cacheableKey) {
270
+ logger?.debug({ cacheableKey }, 'set cache (background)');
271
+ options.mediaCache.set(cacheableKey, Buffer.from(proto.Message.StickerPackMessage.encode(obj).finish()));
272
+ }
273
+ return proto.Message.StickerPackMessage.fromObject(obj);
274
+ };
@@ -0,0 +1,2 @@
1
+ export function processContactAction(action: any, id: any, logger: any): any[];
2
+ export function emitSyncActionResults(ev: any, results: any): void;
@@ -0,0 +1,48 @@
1
+ import { proto } from '../../WAProto/index.js';
2
+ import { isLidUser, isPnUser } from '../WABinary/index.js';
3
+ /**
4
+ * Process contactAction and return events to emit.
5
+ * Pure function - no side effects.
6
+ */
7
+ export const processContactAction = (action, id, logger) => {
8
+ const results = [];
9
+ if (!id) {
10
+ logger?.warn({ hasFullName: !!action.fullName, hasLidJid: !!action.lidJid, hasPnJid: !!action.pnJid }, 'contactAction sync: missing id in index');
11
+ return results;
12
+ }
13
+ const lidJid = action.lidJid;
14
+ const idIsPn = isPnUser(id);
15
+ // PN is in index[1], not in contactAction.pnJid which is usually null
16
+ const phoneNumber = idIsPn ? id : action.pnJid || undefined;
17
+ // Always emit contacts.upsert
18
+ results.push({
19
+ event: 'contacts.upsert',
20
+ data: [
21
+ {
22
+ id,
23
+ name: action.fullName || action.firstName || action.username || undefined,
24
+ username: action.username || undefined,
25
+ lid: lidJid || undefined,
26
+ phoneNumber
27
+ }
28
+ ]
29
+ });
30
+ // Emit lid-mapping.update if we have valid LID-PN pair
31
+ if (lidJid && isLidUser(lidJid) && idIsPn) {
32
+ results.push({
33
+ event: 'lid-mapping.update',
34
+ data: { lid: lidJid, pn: id }
35
+ });
36
+ }
37
+ return results;
38
+ };
39
+ export const emitSyncActionResults = (ev, results) => {
40
+ for (const result of results) {
41
+ if (result.event === 'contacts.upsert') {
42
+ ev.emit('contacts.upsert', result.data);
43
+ }
44
+ else {
45
+ ev.emit('lid-mapping.update', result.data);
46
+ }
47
+ }
48
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * JAP@Add --- Type declarations for tag-all / hide-tag.
3
+ */
4
+ export interface TagBuildOptions {
5
+ hide?: boolean;
6
+ }
7
+ export declare const buildTagContent: (participants: any[], text?: string, opts?: TagBuildOptions) => {
8
+ text: string;
9
+ mentions: string[];
10
+ };
11
+ export declare const tagAll: (sock: any, jid: string, text?: string, options?: any) => Promise<any>;
12
+ export declare const hideTag: (sock: any, jid: string, text?: string, options?: any) => Promise<any>;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * JAP@Add --- tag-all / hide-tag senders for groups.
3
+ *
4
+ * ```js
5
+ * await tagAll(sock, groupJid, 'Rapat jam 10 ya!') // text + @everyone list
6
+ * await hideTag(sock, groupJid, 'Pengumuman 📢') // mentions everyone, shows no tags
7
+ * // or as socket methods: sock.tagAll(jid, ...), sock.hideTag(jid, ...)
8
+ * ```
9
+ */
10
+ import { Boom } from '@hapi/boom';
11
+ const participantJids = (participants) => (participants || [])
12
+ .map((p) => (typeof p === 'string' ? p : p?.id))
13
+ .filter((j) => typeof j === 'string' && j.includes('@'));
14
+ /** Build `sendMessage`-ready content mentioning every participant. */
15
+ export const buildTagContent = (participants, text = '', { hide = false } = {}) => {
16
+ const mentions = participantJids(participants);
17
+ if (!mentions.length) {
18
+ throw new Boom('tagAll: no participants to mention', { statusCode: 400 });
19
+ }
20
+ const body = hide
21
+ ? String(text || '')
22
+ : `${String(text || '')}\n${mentions.map((j) => `@${j.split('@')[0]}`).join(' ')}`.trim();
23
+ return { text: body, mentions };
24
+ };
25
+ const assertGroupSock = (sock, jid) => {
26
+ if (!sock || typeof sock.sendMessage !== 'function' || typeof sock.groupMetadata !== 'function') {
27
+ throw new Boom('tagAll(sock, ...) requires an active Baileys socket with groupMetadata', { statusCode: 400 });
28
+ }
29
+ if (typeof jid !== 'string' || !jid.endsWith('@g.us')) {
30
+ throw new Boom('tagAll only works in groups (@g.us)', { statusCode: 400 });
31
+ }
32
+ };
33
+ /** Mention all group members with a visible @list. */
34
+ export const tagAll = async (sock, jid, text = '', options = {}) => {
35
+ assertGroupSock(sock, jid);
36
+ const meta = await sock.groupMetadata(jid);
37
+ return sock.sendMessage(jid, buildTagContent(meta.participants, text), options);
38
+ };
39
+ /** Mention all group members without showing any @tags. */
40
+ export const hideTag = async (sock, jid, text = '', options = {}) => {
41
+ assertGroupSock(sock, jid);
42
+ const meta = await sock.groupMetadata(jid);
43
+ return sock.sendMessage(jid, buildTagContent(meta.participants, text, { hide: true }), options);
44
+ };
@@ -0,0 +1,29 @@
1
+ /** Read the persisted tctoken JID index and return its entries (never contains the sentinel key itself). */
2
+ export function readTcTokenIndex(keys: any): Promise<any[]>;
3
+ /** Build a SignalDataSet fragment that writes the merged index (persisted ∪ added) under the sentinel key. */
4
+ export function buildMergedTcTokenIndexWrite(keys: any, addedJids: any): Promise<{
5
+ __index: {
6
+ token: any;
7
+ };
8
+ }>;
9
+ export function isTcTokenExpired(timestamp: any): boolean;
10
+ export function shouldSendNewTcToken(senderTimestamp: any): boolean;
11
+ /** Resolve JID to LID for tctoken storage (WA Web stores under LID) */
12
+ export function resolveTcTokenJid(jid: any, getLIDForPN: any): Promise<any>;
13
+ /** Resolve target JID for issuing privacy token based on AB prop 14303 */
14
+ export function resolveIssuanceJid(jid: any, issueToLid: any, getLIDForPN: any, getPNForLID: any): Promise<any>;
15
+ export function buildTcTokenFromJid({ authState, jid, baseContent, getLIDForPN }: {
16
+ authState: any;
17
+ jid: any;
18
+ baseContent?: never[] | undefined;
19
+ getLIDForPN: any;
20
+ }): Promise<any[] | undefined>;
21
+ export function storeTcTokensFromIqResult({ result, fallbackJid, keys, getLIDForPN, onNewJidStored }: {
22
+ result: any;
23
+ fallbackJid: any;
24
+ keys: any;
25
+ getLIDForPN: any;
26
+ onNewJidStored: any;
27
+ }): Promise<void>;
28
+ /** Sentinel key under `tctoken` store holding a JSON array of tracked storage JIDs for cross-session pruning. */
29
+ export const TC_TOKEN_INDEX_KEY: "__index";