@nerxa/socketon 0.0.0-stage → 1.21.1

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 (289) hide show
  1. package/EXPERIMENTAL.md +350 -0
  2. package/LICENSE +24 -0
  3. package/README.md +6317 -2
  4. package/WAProto/index.d.ts +17301 -0
  5. package/WAProto/index.js +125088 -0
  6. package/engine-requirements.js +14 -0
  7. package/package.json +125 -4
  8. package/src/Defaults/index.d.ts +152 -0
  9. package/src/Defaults/index.js +164 -0
  10. package/src/MessageBuilder/bot-signature.d.ts +22 -0
  11. package/src/MessageBuilder/bot-signature.js +122 -0
  12. package/src/MessageBuilder/extras.d.ts +449 -0
  13. package/src/MessageBuilder/extras.js +1356 -0
  14. package/src/MessageBuilder/index.d.ts +210 -0
  15. package/src/MessageBuilder/index.js +3594 -0
  16. package/src/MessageBuilder/metaai.d.ts +438 -0
  17. package/src/MessageBuilder/metaai.js +890 -0
  18. package/src/Signal/Group/ciphertext-message.d.ts +9 -0
  19. package/src/Signal/Group/ciphertext-message.js +11 -0
  20. package/src/Signal/Group/group-session-builder.d.ts +7 -0
  21. package/src/Signal/Group/group-session-builder.js +27 -0
  22. package/src/Signal/Group/group_cipher.d.ts +11 -0
  23. package/src/Signal/Group/group_cipher.js +78 -0
  24. package/src/Signal/Group/index.d.ts +11 -0
  25. package/src/Signal/Group/index.js +11 -0
  26. package/src/Signal/Group/keyhelper.d.ts +6 -0
  27. package/src/Signal/Group/keyhelper.js +17 -0
  28. package/src/Signal/Group/sender-chain-key.d.ts +13 -0
  29. package/src/Signal/Group/sender-chain-key.js +25 -0
  30. package/src/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  31. package/src/Signal/Group/sender-key-distribution-message.js +62 -0
  32. package/src/Signal/Group/sender-key-message.d.ts +18 -0
  33. package/src/Signal/Group/sender-key-message.js +65 -0
  34. package/src/Signal/Group/sender-key-name.d.ts +11 -0
  35. package/src/Signal/Group/sender-key-name.js +47 -0
  36. package/src/Signal/Group/sender-key-record.d.ts +12 -0
  37. package/src/Signal/Group/sender-key-record.js +40 -0
  38. package/src/Signal/Group/sender-key-state.d.ts +16 -0
  39. package/src/Signal/Group/sender-key-state.js +83 -0
  40. package/src/Signal/Group/sender-message-key.d.ts +11 -0
  41. package/src/Signal/Group/sender-message-key.js +25 -0
  42. package/src/Signal/libsignal.d.ts +54 -0
  43. package/src/Signal/libsignal.js +427 -0
  44. package/src/Signal/lid-mapping.d.ts +20 -0
  45. package/src/Signal/lid-mapping.js +274 -0
  46. package/src/Socket/Client/index.d.ts +2 -0
  47. package/src/Socket/Client/index.js +3 -0
  48. package/src/Socket/Client/tcp.js +177 -0
  49. package/src/Socket/Client/types.d.ts +5 -0
  50. package/src/Socket/Client/types.js +9 -0
  51. package/src/Socket/Client/websocket.d.ts +12 -0
  52. package/src/Socket/Client/websocket.js +53 -0
  53. package/src/Socket/business.d.ts +431 -0
  54. package/src/Socket/business.js +379 -0
  55. package/src/Socket/chats.d.ts +247 -0
  56. package/src/Socket/chats.js +1484 -0
  57. package/src/Socket/communities.d.ts +598 -0
  58. package/src/Socket/communities.js +421 -0
  59. package/src/Socket/email.js +145 -0
  60. package/src/Socket/groups.d.ts +298 -0
  61. package/src/Socket/groups.js +339 -0
  62. package/src/Socket/index.d.ts +581 -0
  63. package/src/Socket/index.js +77 -0
  64. package/src/Socket/messages-recv.d.ts +370 -0
  65. package/src/Socket/messages-recv.js +1864 -0
  66. package/src/Socket/messages-send.d.ts +390 -0
  67. package/src/Socket/messages-send.js +1574 -0
  68. package/src/Socket/mex.d.ts +1 -0
  69. package/src/Socket/mex.js +44 -0
  70. package/src/Socket/mobile-builders.js +72 -0
  71. package/src/Socket/mobile.js +424 -0
  72. package/src/Socket/newsletter.d.ts +468 -0
  73. package/src/Socket/newsletter.js +671 -0
  74. package/src/Socket/socket.d.ts +77 -0
  75. package/src/Socket/socket.js +1106 -0
  76. package/src/Store/index.d.ts +3 -0
  77. package/src/Store/index.js +3 -0
  78. package/src/Store/make-in-memory-store.d.ts +62 -0
  79. package/src/Store/make-in-memory-store.js +396 -0
  80. package/src/Store/make-ordered-dictionary.d.ts +12 -0
  81. package/src/Store/make-ordered-dictionary.js +78 -0
  82. package/src/Store/object-repository.d.ts +10 -0
  83. package/src/Store/object-repository.js +23 -0
  84. package/src/Types/Auth.d.ts +1 -0
  85. package/src/Types/Auth.js +1 -0
  86. package/src/Types/Bussines.d.ts +1 -0
  87. package/src/Types/Bussines.js +1 -0
  88. package/src/Types/Call.d.ts +1 -0
  89. package/src/Types/Call.js +1 -0
  90. package/src/Types/Chat.d.ts +2 -0
  91. package/src/Types/Chat.js +24 -0
  92. package/src/Types/Contact.d.ts +1 -0
  93. package/src/Types/Contact.js +1 -0
  94. package/src/Types/Events.d.ts +1 -0
  95. package/src/Types/Events.js +0 -0
  96. package/src/Types/GroupMetadata.d.ts +5 -0
  97. package/src/Types/GroupMetadata.js +6 -0
  98. package/src/Types/Label.d.ts +2 -0
  99. package/src/Types/Label.js +24 -0
  100. package/src/Types/LabelAssociation.d.ts +2 -0
  101. package/src/Types/LabelAssociation.js +6 -0
  102. package/src/Types/Message.d.ts +13 -0
  103. package/src/Types/Message.js +23 -0
  104. package/src/Types/Mex.d.ts +2 -0
  105. package/src/Types/Mex.js +95 -0
  106. package/src/Types/Product.d.ts +1 -0
  107. package/src/Types/Product.js +1 -0
  108. package/src/Types/Signal.d.ts +1 -0
  109. package/src/Types/Signal.js +0 -0
  110. package/src/Types/Socket.d.ts +1 -0
  111. package/src/Types/Socket.js +0 -0
  112. package/src/Types/State.d.ts +5 -0
  113. package/src/Types/State.js +54 -0
  114. package/src/Types/USync.d.ts +1 -0
  115. package/src/Types/USync.js +0 -0
  116. package/src/Types/index.d.ts +13 -0
  117. package/src/Types/index.js +25 -0
  118. package/src/Utils/auth-store.d.ts +29 -0
  119. package/src/Utils/auth-store.js +76 -0
  120. package/src/Utils/auth-utils.d.ts +58 -0
  121. package/src/Utils/auth-utils.js +273 -0
  122. package/src/Utils/browser-utils.d.ts +9 -0
  123. package/src/Utils/browser-utils.js +28 -0
  124. package/src/Utils/business.d.ts +49 -0
  125. package/src/Utils/business.js +226 -0
  126. package/src/Utils/chat-utils.d.ts +408 -0
  127. package/src/Utils/chat-utils.js +846 -0
  128. package/src/Utils/companion-reg-client-utils.d.ts +4 -0
  129. package/src/Utils/companion-reg-client-utils.js +39 -0
  130. package/src/Utils/crypto.d.ts +39 -0
  131. package/src/Utils/crypto.js +110 -0
  132. package/src/Utils/decode-wa-message.d.ts +99 -0
  133. package/src/Utils/decode-wa-message.js +373 -0
  134. package/src/Utils/event-buffer.d.ts +22 -0
  135. package/src/Utils/event-buffer.js +624 -0
  136. package/src/Utils/generics.d.ts +63 -0
  137. package/src/Utils/generics.js +375 -0
  138. package/src/Utils/group-metadata-cache.d.ts +4 -0
  139. package/src/Utils/group-metadata-cache.js +25 -0
  140. package/src/Utils/history.d.ts +75 -0
  141. package/src/Utils/history.js +131 -0
  142. package/src/Utils/html-app.d.ts +19 -0
  143. package/src/Utils/html-app.js +96 -0
  144. package/src/Utils/html-multiplayer.d.ts +10 -0
  145. package/src/Utils/html-multiplayer.js +94 -0
  146. package/src/Utils/identity-change-handler.d.ts +13 -0
  147. package/src/Utils/identity-change-handler.js +48 -0
  148. package/src/Utils/index.d.ts +44 -0
  149. package/src/Utils/index.js +44 -0
  150. package/src/Utils/link-preview-metadata.d.ts +47 -0
  151. package/src/Utils/link-preview-metadata.js +88 -0
  152. package/src/Utils/link-preview.d.ts +12 -0
  153. package/src/Utils/link-preview.js +79 -0
  154. package/src/Utils/logger.d.ts +2 -0
  155. package/src/Utils/logger.js +2 -0
  156. package/src/Utils/lt-hash.d.ts +6 -0
  157. package/src/Utils/lt-hash.js +3 -0
  158. package/src/Utils/make-mutex.d.ts +6 -0
  159. package/src/Utils/make-mutex.js +32 -0
  160. package/src/Utils/message-retry-manager.d.ts +79 -0
  161. package/src/Utils/message-retry-manager.js +255 -0
  162. package/src/Utils/messages-media.d.ts +136 -0
  163. package/src/Utils/messages-media.js +814 -0
  164. package/src/Utils/messages.d.ts +62 -0
  165. package/src/Utils/messages.js +2223 -0
  166. package/src/Utils/mobile-companion-crypto.js +191 -0
  167. package/src/Utils/modern-messages.d.ts +150 -0
  168. package/src/Utils/modern-messages.js +496 -0
  169. package/src/Utils/native-flow.d.ts +11 -0
  170. package/src/Utils/native-flow.js +115 -0
  171. package/src/Utils/newsletter-status.d.ts +158 -0
  172. package/src/Utils/newsletter-status.js +651 -0
  173. package/src/Utils/noise-handler.d.ts +20 -0
  174. package/src/Utils/noise-handler.js +200 -0
  175. package/src/Utils/offline-node-processor.d.ts +9 -0
  176. package/src/Utils/offline-node-processor.js +33 -0
  177. package/src/Utils/optional-media.d.ts +3 -0
  178. package/src/Utils/optional-media.js +45 -0
  179. package/src/Utils/payment-messages.d.ts +66 -0
  180. package/src/Utils/payment-messages.js +160 -0
  181. package/src/Utils/pre-key-manager.d.ts +25 -0
  182. package/src/Utils/pre-key-manager.js +95 -0
  183. package/src/Utils/process-message.d.ts +60 -0
  184. package/src/Utils/process-message.js +688 -0
  185. package/src/Utils/reporting-utils.d.ts +12 -0
  186. package/src/Utils/reporting-utils.js +256 -0
  187. package/src/Utils/scheduled-message.d.ts +51 -0
  188. package/src/Utils/scheduled-message.js +112 -0
  189. package/src/Utils/sender-key-memory.d.ts +19 -0
  190. package/src/Utils/sender-key-memory.js +51 -0
  191. package/src/Utils/signal.d.ts +82 -0
  192. package/src/Utils/signal.js +193 -0
  193. package/src/Utils/stanza-ack.d.ts +16 -0
  194. package/src/Utils/stanza-ack.js +30 -0
  195. package/src/Utils/status-stickers.d.ts +127 -0
  196. package/src/Utils/status-stickers.js +260 -0
  197. package/src/Utils/sync-action-utils.d.ts +2 -0
  198. package/src/Utils/sync-action-utils.js +44 -0
  199. package/src/Utils/tc-token-utils.d.ts +29 -0
  200. package/src/Utils/tc-token-utils.js +155 -0
  201. package/src/Utils/ttl-cache.d.ts +28 -0
  202. package/src/Utils/ttl-cache.js +120 -0
  203. package/src/Utils/use-mongo-auth-state.d.ts +21 -0
  204. package/src/Utils/use-mongo-auth-state.js +67 -0
  205. package/src/Utils/use-multi-file-auth-state.d.ts +11 -0
  206. package/src/Utils/use-multi-file-auth-state.js +106 -0
  207. package/src/Utils/use-mysql-auth-state.d.ts +19 -0
  208. package/src/Utils/use-mysql-auth-state.js +79 -0
  209. package/src/Utils/use-postgres-auth-state.d.ts +19 -0
  210. package/src/Utils/use-postgres-auth-state.js +79 -0
  211. package/src/Utils/use-redis-auth-state.d.ts +19 -0
  212. package/src/Utils/use-redis-auth-state.js +89 -0
  213. package/src/Utils/use-single-file-auth-state.d.ts +10 -0
  214. package/src/Utils/use-single-file-auth-state.js +108 -0
  215. package/src/Utils/use-sqlite-auth-state.d.ts +12 -0
  216. package/src/Utils/use-sqlite-auth-state.js +120 -0
  217. package/src/Utils/useNekoDBAuth.d.ts +19 -0
  218. package/src/Utils/useNekoDBAuth.js +111 -0
  219. package/src/Utils/username.d.ts +12 -0
  220. package/src/Utils/username.js +58 -0
  221. package/src/Utils/validate-connection.d.ts +43 -0
  222. package/src/Utils/validate-connection.js +277 -0
  223. package/src/Utils/voice-recognition.d.ts +53 -0
  224. package/src/Utils/voice-recognition.js +219 -0
  225. package/src/Voip/audio-feeder.d.ts +24 -0
  226. package/src/Voip/audio-feeder.js +268 -0
  227. package/src/Voip/index.d.ts +88 -0
  228. package/src/Voip/index.js +936 -0
  229. package/src/Voip/relay-transport.d.ts +5 -0
  230. package/src/Voip/relay-transport.js +824 -0
  231. package/src/Voip/signaling.d.ts +11 -0
  232. package/src/Voip/signaling.js +1099 -0
  233. package/src/Voip/types.d.ts +2 -0
  234. package/src/Voip/types.js +12 -0
  235. package/src/Voip/video-feeder.d.ts +24 -0
  236. package/src/Voip/video-feeder.js +268 -0
  237. package/src/Voip/wasm-engine.d.ts +26 -0
  238. package/src/Voip/wasm-engine.js +1307 -0
  239. package/src/Voip/worker-bootstrap.js +1023 -0
  240. package/src/WABinary/constants.d.ts +22 -0
  241. package/src/WABinary/constants.js +1300 -0
  242. package/src/WABinary/decode.d.ts +9 -0
  243. package/src/WABinary/decode.js +261 -0
  244. package/src/WABinary/encode.d.ts +2 -0
  245. package/src/WABinary/encode.js +219 -0
  246. package/src/WABinary/generic-utils.d.ts +76 -0
  247. package/src/WABinary/generic-utils.js +214 -0
  248. package/src/WABinary/index.d.ts +5 -0
  249. package/src/WABinary/index.js +5 -0
  250. package/src/WABinary/jid-utils.d.ts +30 -0
  251. package/src/WABinary/jid-utils.js +97 -0
  252. package/src/WABinary/types.d.ts +1 -0
  253. package/src/WABinary/types.js +0 -0
  254. package/src/WAM/BinaryInfo.d.ts +7 -0
  255. package/src/WAM/BinaryInfo.js +9 -0
  256. package/src/WAM/constants.d.ts +34926 -0
  257. package/src/WAM/constants.js +22852 -0
  258. package/src/WAM/encode.d.ts +1 -0
  259. package/src/WAM/encode.js +148 -0
  260. package/src/WAM/index.d.ts +3 -0
  261. package/src/WAM/index.js +3 -0
  262. package/src/WAUSync/Protocols/USyncContactProtocol.d.ts +36 -0
  263. package/src/WAUSync/Protocols/USyncContactProtocol.js +50 -0
  264. package/src/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
  265. package/src/WAUSync/Protocols/USyncDeviceProtocol.js +51 -0
  266. package/src/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  267. package/src/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
  268. package/src/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  269. package/src/WAUSync/Protocols/USyncStatusProtocol.js +37 -0
  270. package/src/WAUSync/Protocols/USyncUsernameProtocol.d.ts +9 -0
  271. package/src/WAUSync/Protocols/USyncUsernameProtocol.js +23 -0
  272. package/src/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +38 -0
  273. package/src/WAUSync/Protocols/UsyncBotProfileProtocol.js +49 -0
  274. package/src/WAUSync/Protocols/UsyncLIDProtocol.d.ts +14 -0
  275. package/src/WAUSync/Protocols/UsyncLIDProtocol.js +28 -0
  276. package/src/WAUSync/Protocols/index.d.ts +5 -0
  277. package/src/WAUSync/Protocols/index.js +5 -0
  278. package/src/WAUSync/USyncQuery.d.ts +20 -0
  279. package/src/WAUSync/USyncQuery.js +93 -0
  280. package/src/WAUSync/USyncUser.d.ts +16 -0
  281. package/src/WAUSync/USyncUser.js +30 -0
  282. package/src/WAUSync/index.d.ts +3 -0
  283. package/src/WAUSync/index.js +3 -0
  284. package/src/assets/wasm/README.md +76 -0
  285. package/src/assets/wasm/loader.js +5 -0
  286. package/src/assets/wasm/whatsapp.wasm +0 -0
  287. package/src/assets/wasm/worker-modules.js +273 -0
  288. package/src/index.d.ts +43 -0
  289. package/src/index.js +48 -0
@@ -0,0 +1,14 @@
1
+ /* Luna Baileys maintained distribution. Upstream notices and license are preserved in LICENSE. */
2
+ const major = parseInt(
3
+ process.versions.node.split('.')[0],
4
+ 10
5
+ );
6
+
7
+ if (major < 20) {
8
+ console.error(
9
+ `\n❌ This package requires Node.js 20+ to run reliably.\n` +
10
+ ` You are using Node.js ${process.versions.node}.\n` +
11
+ ` Please upgrade to Node.js 20+ to proceed.\n`
12
+ );
13
+ process.exit(1);
14
+ }
package/package.json CHANGED
@@ -1,6 +1,127 @@
1
1
  {
2
2
  "name": "@nerxa/socketon",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.21.1",
4
+ "description": "Nerxa socket / modded Baileys — interactive message, album, messageBuilder, newsletter, VoIP",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/mazikenzagentz-create/luna-baileys-1.git"
8
+ },
9
+ "main": "src/index.js",
10
+ "types": "src/index.d.ts",
11
+ "type": "module",
12
+ "scripts": {
13
+ "preinstall": "node ./engine-requirements.js",
14
+ "test": "node --test \"test/*.test.js\"",
15
+ "update:version": "node ./script/updatewa.js",
16
+ "check:proto": "node ./script/checkproto.js",
17
+ "sync:proto": "node ./script/syncproto.js",
18
+ "build:docs": "node ./script/apiref.js site-api.json && node ./script/builddocs.js site",
19
+ "wa:update": "node ./script/waupdate.js",
20
+ "wa:diff": "node ./script/diffbundle.js",
21
+ "audit:apk": "node ./script/auditapk.js",
22
+ "verify:proto": "node ./script/verifyproto.js",
23
+ "verify:mex": "node ./script/verifymex.js",
24
+ "verify:assets": "node ./script/verifyassets.js",
25
+ "fetch:bundle": "node ./script/fetchbundle.js",
26
+ "test:pairing": "node ./script/testpairing.js",
27
+ "proto:update": "npm run sync:proto && npm run verify:proto && npm run verify:mex && npm run wa:update -- --apply --keep 2 && npm run update:version"
28
+ },
29
+ "engines": {
30
+ "node": ">=20.0.0"
31
+ },
32
+ "files": [
33
+ "src/**/*",
34
+ "WAProto/**/*",
35
+ "engine-requirements.js",
36
+ "EXPERIMENTAL.md",
37
+ "LICENSE",
38
+ "package.json",
39
+ "README.md"
40
+ ],
41
+ "keywords": [
42
+ "nerxa",
43
+ "socketon",
44
+ "baileys",
45
+ "whatsapp",
46
+ "whatsapp-api",
47
+ "whatsapp-bot",
48
+ "multi-device",
49
+ "bot",
50
+ "automation"
51
+ ],
52
+ "author": "nerxa",
53
+ "license": "MIT",
54
+ "publishConfig": {
55
+ "access": "public"
56
+ },
57
+ "dependencies": {
58
+ "@adiwajshing/keyed-db": "^0.2.4",
59
+ "@hapi/boom": "^9.1.3",
60
+ "@rexxhayanasi/wangcap-id-bridge": "^1.0.0",
61
+ "async-mutex": "^0.5.0",
62
+ "chalk": "^5.6.2",
63
+ "fflate": "^0.8.2",
64
+ "libsignal": "^6.0.0",
65
+ "lru-cache": "^11.2.6",
66
+ "music-metadata": "^11.12.3",
67
+ "p-queue": "^9.1.0",
68
+ "pino": "^9.6.0",
69
+ "protobufjs": "^7.5.6",
70
+ "ws": "^8.19.0"
71
+ },
72
+ "optionalDependencies": {
73
+ "@rexxhayanasi/elaina-anchorguard": "^1.0.0"
74
+ },
75
+ "peerDependencies": {
76
+ "@napi-rs/image": "~1.12.0",
77
+ "@nekodb/client": "*",
78
+ "audio-decode": "^2.2.3",
79
+ "better-sqlite3": "^11.0.0 || ^12.0.0 || ^13.0.0",
80
+ "fluent-ffmpeg": "*",
81
+ "ioredis": "^5.0.0",
82
+ "jimp": "^1.6.1",
83
+ "link-preview-js": "^3.0.0",
84
+ "mongodb": "^6.0.0",
85
+ "mysql2": "^3.0.0",
86
+ "pg": "^8.0.0",
87
+ "sharp": "^0.35.0"
88
+ },
89
+ "peerDependenciesMeta": {
90
+ "@napi-rs/image": {
91
+ "optional": true
92
+ },
93
+ "@nekodb/client": {
94
+ "optional": true
95
+ },
96
+ "audio-decode": {
97
+ "optional": true
98
+ },
99
+ "better-sqlite3": {
100
+ "optional": true
101
+ },
102
+ "fluent-ffmpeg": {
103
+ "optional": true
104
+ },
105
+ "ioredis": {
106
+ "optional": true
107
+ },
108
+ "jimp": {
109
+ "optional": true
110
+ },
111
+ "link-preview-js": {
112
+ "optional": true
113
+ },
114
+ "mongodb": {
115
+ "optional": true
116
+ },
117
+ "mysql2": {
118
+ "optional": true
119
+ },
120
+ "pg": {
121
+ "optional": true
122
+ },
123
+ "sharp": {
124
+ "optional": true
125
+ }
126
+ }
127
+ }
@@ -0,0 +1,152 @@
1
+ export const UNAUTHORIZED_CODES: number[];
2
+ export const BIZ_BOT_SUPPORT_PAYLOAD: "{\"version\":1,\"is_ai_message\":true,\"should_upload_client_logs\":false,\"should_show_system_message\":false,\"ticket_id\":\"7004947587700716\",\"citation_items\":[],\"ticket_locale\":\"us\"}";
3
+ export const DEFAULT_ORIGIN: "https://web.whatsapp.com";
4
+ export const CALL_VIDEO_PREFIX: "https://call.whatsapp.com/video/";
5
+ export const CALL_AUDIO_PREFIX: "https://call.whatsapp.com/voice/";
6
+ export const DONATE_URL: "https://www.npmjs.com/package/gojo-baileys";
7
+ export const LIBRARY_NAME: "gojo-baileys";
8
+ export const DEF_CALLBACK_PREFIX: "CB:";
9
+ export const DEF_TAG_PREFIX: "TAG:";
10
+ export const PHONE_CONNECTION_CB: "CB:Pong";
11
+ export const WA_ADV_ACCOUNT_SIG_PREFIX: any;
12
+ export const WA_ADV_DEVICE_SIG_PREFIX: any;
13
+ export const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX: any;
14
+ export const WA_ADV_HOSTED_DEVICE_SIG_PREFIX: any;
15
+ export const WA_DEFAULT_EPHEMERAL: number;
16
+ /** Status messages older than 24 hours are considered expired */
17
+ export const STATUS_EXPIRY_SECONDS: number;
18
+ /** WA Web enforces a 14-day maximum age for placeholder resend requests */
19
+ export const PLACEHOLDER_MAX_AGE_SECONDS: number;
20
+ export const NOISE_MODE: "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
21
+ export const DICT_VERSION: 3;
22
+ export const KEY_BUNDLE_TYPE: any;
23
+ export const NOISE_WA_HEADER: any;
24
+ /** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
25
+ export const URL_REGEX: RegExp;
26
+ export namespace WA_CERT_DETAILS {
27
+ let SERIAL: number;
28
+ let ISSUER: string;
29
+ let PUBLIC_KEY: any;
30
+ }
31
+ export const PROCESSABLE_HISTORY_TYPES: proto.HistorySync.HistorySyncType[];
32
+ export namespace DEFAULT_CACHE_TTLS {
33
+ let SIGNAL_STORE: number;
34
+ let MSG_RETRY: number;
35
+ let CALL_OFFER: number;
36
+ let USER_DEVICES: number;
37
+ let OUTBOUND_RESEND: number;
38
+ }
39
+ export namespace DEFAULT_CONNECTION_CONFIG {
40
+ export { version };
41
+ export let browser: any[];
42
+ export let waWebSocketUrl: string;
43
+ export let connectTimeoutMs: number;
44
+ export let keepAliveIntervalMs: number;
45
+ export let logger: any;
46
+ export let emitOwnEvents: boolean;
47
+ export let defaultQueryTimeoutMs: number;
48
+ export let customUploadHosts: never[];
49
+ export let retryRequestDelayMs: number;
50
+ export let maxMsgRetryCount: number;
51
+ export let ackRetryDelayMs: number;
52
+ export let maxAckRetryCount: number;
53
+ export let maxRetryQueueSize: number;
54
+ export let pairingCodeTimeoutMs: number;
55
+ export let fireInitQueries: boolean;
56
+ export let auth: undefined;
57
+ export let markOnlineOnConnect: boolean;
58
+ export let syncFullHistory: boolean;
59
+ export function patchMessageBeforeSending(msg: any): any;
60
+ export function shouldSyncHistoryMessage({ syncType }: {
61
+ syncType: any;
62
+ }): boolean;
63
+ export function shouldIgnoreJid(): boolean;
64
+ export let linkPreviewImageThumbnailWidth: number;
65
+ export namespace transactionOpts {
66
+ let maxCommitRetries: number;
67
+ let delayBetweenTriesMs: number;
68
+ }
69
+ export let generateHighQualityLinkPreview: boolean;
70
+ export let enableAutoSessionRecreation: boolean;
71
+ export let enableRecentMessageCache: boolean;
72
+ export let options: {};
73
+ export namespace appStateMacVerification {
74
+ let patch: boolean;
75
+ let snapshot: boolean;
76
+ }
77
+ export let countryCode: string;
78
+ export function getMessage(): Promise<undefined>;
79
+ export function cachedGroupMetadata(): Promise<undefined>;
80
+ export { makeLibSignalRepository as makeSignalRepository };
81
+ }
82
+ export const MEDIA_PATH_MAP: {
83
+ image: string;
84
+ video: string;
85
+ document: string;
86
+ audio: string;
87
+ sticker: string;
88
+ 'sticker-pack': string;
89
+ 'thumbnail-sticker-pack': string;
90
+ 'thumbnail-link': string;
91
+ 'thumbnail-image': string;
92
+ 'thumbnail-video': string;
93
+ 'thumbnail-document': string;
94
+ 'product-catalog-image': string;
95
+ 'md-app-state': string;
96
+ 'md-msg-hist': string;
97
+ 'biz-cover-photo': string;
98
+ };
99
+ export const NEWSLETTER_MEDIA_PATH_MAP: {
100
+ image: string;
101
+ video: string;
102
+ document: string;
103
+ audio: string;
104
+ sticker: string;
105
+ 'thumbnail-link': string;
106
+ };
107
+ export const MEDIA_HKDF_KEY_MAPPING: {
108
+ audio: string;
109
+ document: string;
110
+ gif: string;
111
+ image: string;
112
+ ppic: string;
113
+ product: string;
114
+ ptt: string;
115
+ 'sticker-pack': string;
116
+ 'thumbnail-sticker-pack': string;
117
+ sticker: string;
118
+ video: string;
119
+ 'thumbnail-document': string;
120
+ 'thumbnail-image': string;
121
+ 'thumbnail-video': string;
122
+ 'thumbnail-link': string;
123
+ 'md-msg-hist': string;
124
+ 'md-app-state': string;
125
+ 'product-catalog-image': string;
126
+ 'payment-bg-image': string;
127
+ ptv: string;
128
+ 'biz-cover-photo': string;
129
+ location: string;
130
+ contact: string;
131
+ 'voip-token': string;
132
+ };
133
+ export const MEDIA_KEYS: string[];
134
+ /** 120s timeout for history sync stall detection, same as WA Web's handleChunkProgress / restartPausedTimer (g = 120) */
135
+ export const HISTORY_SYNC_PAUSED_TIMEOUT_MS: 120000;
136
+ export const MIN_PREKEY_COUNT: 5;
137
+ export const INITIAL_PREKEY_COUNT: 812;
138
+ export const UPLOAD_TIMEOUT: 30000;
139
+ export namespace TimeMs {
140
+ let Minute: number;
141
+ let Hour: number;
142
+ let Day: number;
143
+ let Week: number;
144
+ }
145
+ import { proto } from '../../WAProto/index.js';
146
+ declare const version: number[];
147
+ import { makeLibSignalRepository } from '../Signal/libsignal.js';
148
+ export {};
149
+ export const MAX_OUTBOUND_RESEND_ENTRIES: number;
150
+ export const MEMBER_LABEL_MAX_LENGTH: number;
151
+ export const DEFAULT_CACHE_MAX_KEYS: number;
152
+ export const PAIRING_RESPONSE_GRACE_MS: number;
@@ -0,0 +1,164 @@
1
+ import { proto } from '../../WAProto/index.js';
2
+ import { makeLibSignalRepository } from '../Signal/libsignal.js';
3
+ import { Browsers } from '../Utils/browser-utils.js';
4
+ import logger from '../Utils/logger.js';
5
+ const version = [2, 3000, 1051456098];
6
+ export const UNAUTHORIZED_CODES = [401, 403, 419];
7
+ export const BIZ_BOT_SUPPORT_PAYLOAD = '{"version":1,"is_ai_message":true,"should_upload_client_logs":false,"should_show_system_message":false,"ticket_id":"7004947587700716","citation_items":[],"ticket_locale":"us"}';
8
+ export const DEFAULT_ORIGIN = 'https://web.whatsapp.com';
9
+ export const CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/';
10
+ export const CALL_AUDIO_PREFIX = 'https://call.whatsapp.com/voice/';
11
+ export const DONATE_URL = 'https://www.npmjs.com/package/gojo-baileys';
12
+ export const LIBRARY_NAME = 'gojo-baileys';
13
+ export const DEF_CALLBACK_PREFIX = 'CB:';
14
+ export const DEF_TAG_PREFIX = 'TAG:';
15
+ export const PHONE_CONNECTION_CB = 'CB:Pong';
16
+ export const WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0]);
17
+ export const WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1]);
18
+ export const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5]);
19
+ export const WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6]);
20
+ export const WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60;
21
+
22
+ export const STATUS_EXPIRY_SECONDS = 24 * 60 * 60;
23
+
24
+ export const PLACEHOLDER_MAX_AGE_SECONDS = 14 * 24 * 60 * 60;
25
+ export const NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0';
26
+ export const DICT_VERSION = 3;
27
+ export const KEY_BUNDLE_TYPE = Buffer.from([5]);
28
+ export const NOISE_WA_HEADER = Buffer.from([87, 65, 6, DICT_VERSION]);
29
+
30
+ export const URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
31
+ export const WA_CERT_DETAILS = {
32
+ SERIAL: 0,
33
+ ISSUER: 'WhatsAppLongTerm1',
34
+ PUBLIC_KEY: Buffer.from('142375574d0a587166aae71ebe516437c4a28b73e3695c6ce1f7f9545da8ee6b', 'hex')
35
+ };
36
+ export const PROCESSABLE_HISTORY_TYPES = [
37
+ proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP,
38
+ proto.HistorySync.HistorySyncType.PUSH_NAME,
39
+ proto.HistorySync.HistorySyncType.RECENT,
40
+ proto.HistorySync.HistorySyncType.FULL,
41
+ proto.HistorySync.HistorySyncType.ON_DEMAND,
42
+ proto.HistorySync.HistorySyncType.NON_BLOCKING_DATA,
43
+ proto.HistorySync.HistorySyncType.INITIAL_STATUS_V3
44
+ ];
45
+ export const DEFAULT_CACHE_TTLS = {
46
+ SIGNAL_STORE: 5 * 60,
47
+ MSG_RETRY: 60 * 60,
48
+ CALL_OFFER: 5 * 60,
49
+ USER_DEVICES: 5 * 60,
50
+ OUTBOUND_RESEND: 60
51
+ };
52
+
53
+ export const MAX_OUTBOUND_RESEND_ENTRIES = 512;
54
+ export const MEMBER_LABEL_MAX_LENGTH = 30;
55
+ export const DEFAULT_CACHE_MAX_KEYS = 20000;
56
+
57
+ export const PAIRING_RESPONSE_GRACE_MS = 30000;
58
+ export const DEFAULT_CONNECTION_CONFIG = {
59
+ version: version,
60
+ browser: Browsers.macOS('Chrome'),
61
+ waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
62
+ connectTimeoutMs: 20000,
63
+ keepAliveIntervalMs: 15000,
64
+ logger: logger.child({ class: 'luna' }),
65
+ emitOwnEvents: true,
66
+ AnchorGuard: false,
67
+ AnchorGuardConfig: {},
68
+ defaultQueryTimeoutMs: 60000,
69
+ customUploadHosts: [],
70
+ retryRequestDelayMs: 250,
71
+ maxMsgRetryCount: 3,
72
+ maxEventListeners: 64,
73
+ ackRetryDelayMs: 750,
74
+ maxAckRetryCount: 3,
75
+ maxRetryQueueSize: 64,
76
+ pairingCodeTimeoutMs: 180000,
77
+ fireInitQueries: true,
78
+ auth: undefined,
79
+ markOnlineOnConnect: true,
80
+ syncFullHistory: true,
81
+ patchMessageBeforeSending: msg => msg,
82
+ shouldSyncHistoryMessage: ({ syncType }) => {
83
+ return syncType !== proto.HistorySync.HistorySyncType.FULL;
84
+ },
85
+ shouldIgnoreJid: () => false,
86
+ linkPreviewImageThumbnailWidth: 192,
87
+ transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
88
+ generateHighQualityLinkPreview: true,
89
+ enableAutoSessionRecreation: true,
90
+ enableRecentMessageCache: true,
91
+ options: {},
92
+ appStateMacVerification: {
93
+ patch: false,
94
+ snapshot: false
95
+ },
96
+ countryCode: 'US',
97
+ getMessage: async () => undefined,
98
+ cachedGroupMetadata: async () => undefined,
99
+ makeSignalRepository: makeLibSignalRepository
100
+ };
101
+ export const MEDIA_PATH_MAP = {
102
+ image: '/mms/image',
103
+ video: '/mms/video',
104
+ document: '/mms/document',
105
+ audio: '/mms/audio',
106
+ sticker: '/mms/image',
107
+ 'sticker-pack': '/mms/sticker-pack',
108
+ 'thumbnail-sticker-pack': '/mms/thumbnail-sticker-pack',
109
+ 'thumbnail-link': '/mms/image',
110
+ 'thumbnail-image': '/mms/image',
111
+ 'thumbnail-video': '/mms/video',
112
+ 'thumbnail-document': '/mms/document',
113
+ 'product-catalog-image': '/product/image',
114
+ 'md-app-state': '',
115
+ 'md-msg-hist': '/mms/md-app-state',
116
+ 'biz-cover-photo': '/pps/biz-cover-photo'
117
+ };
118
+
119
+ export const NEWSLETTER_MEDIA_PATH_MAP = {
120
+ image: '/newsletter/newsletter-image',
121
+ video: '/newsletter/newsletter-video',
122
+ document: '/newsletter/newsletter-document',
123
+ audio: '/newsletter/newsletter-audio',
124
+ sticker: '/newsletter/newsletter-image',
125
+ 'thumbnail-link': '/newsletter/newsletter-thumbnail-link'
126
+ };
127
+ export const MEDIA_HKDF_KEY_MAPPING = {
128
+ audio: 'Audio',
129
+ document: 'Document',
130
+ gif: 'Video',
131
+ image: 'Image',
132
+ ppic: '',
133
+ product: 'Image',
134
+ ptt: 'Audio',
135
+ 'sticker-pack': 'Sticker Pack',
136
+ 'thumbnail-sticker-pack': 'Sticker Pack Thumbnail',
137
+ sticker: 'Image',
138
+ video: 'Video',
139
+ 'thumbnail-document': 'Document Thumbnail',
140
+ 'thumbnail-image': 'Image Thumbnail',
141
+ 'thumbnail-video': 'Video Thumbnail',
142
+ 'thumbnail-link': 'Link Thumbnail',
143
+ 'md-msg-hist': 'History',
144
+ 'md-app-state': 'App State',
145
+ 'product-catalog-image': 'Product Catalog Image',
146
+ 'payment-bg-image': 'Payment Background',
147
+ ptv: 'Video',
148
+ 'biz-cover-photo': 'Image',
149
+ location: 'Location',
150
+ contact: 'Contact',
151
+ 'voip-token': 'Voip Token'
152
+ };
153
+ export const MEDIA_KEYS = Object.keys(MEDIA_PATH_MAP);
154
+
155
+ export const HISTORY_SYNC_PAUSED_TIMEOUT_MS = 120000;
156
+ export const MIN_PREKEY_COUNT = 5;
157
+ export const INITIAL_PREKEY_COUNT = 812;
158
+ export const UPLOAD_TIMEOUT = 30000;
159
+ export const TimeMs = {
160
+ Minute: 60 * 1000,
161
+ Hour: 60 * 60 * 1000,
162
+ Day: 24 * 60 * 60 * 1000,
163
+ Week: 7 * 24 * 60 * 60 * 1000
164
+ };
@@ -0,0 +1,22 @@
1
+ export declare const BOT_SIGNATURE_VERSION: '1';
2
+ export declare const BOT_SIGNATURE_USE_CASE_WA_BOT_MSG: 1;
3
+ export declare const BOT_SIGNATURE_ROOT_VERSION: string;
4
+ export declare const BOT_SIGNATURE_ROOT_CERTIFICATE: string;
5
+
6
+ export declare function loadBotSignatureRoot(): import('crypto').X509Certificate;
7
+
8
+ export declare function constructSignaturePayload(options: {
9
+ botFbid: string;
10
+ messageDigest: Buffer | Uint8Array;
11
+ version?: string;
12
+ }): Buffer;
13
+
14
+ export declare function verifyBotSignature(options: {
15
+ botJid?: string;
16
+ unifiedResponseBytes?: Buffer | Uint8Array;
17
+ proof?: any;
18
+ at?: number;
19
+ root?: import('crypto').X509Certificate;
20
+ }): { status: 'passed' | 'failed'; reason?: string };
21
+
22
+ export declare function isParsableCertificateChain(chain?: unknown): boolean;
@@ -0,0 +1,122 @@
1
+ import { X509Certificate, verify as cryptoVerify } from 'crypto'
2
+
3
+ export const BOT_SIGNATURE_VERSION = '1'
4
+ export const BOT_SIGNATURE_USE_CASE_WA_BOT_MSG = 1
5
+ export const BOT_SIGNATURE_ROOT_VERSION = '2025-10'
6
+
7
+ export const BOT_SIGNATURE_ROOT_CERTIFICATE = `-----BEGIN CERTIFICATE-----
8
+ MIIC7TCCApOgAwIBAgIUAtu5QuxmVhfGT8LPkjfm40mSl0AwCgYIKoZIzj0EAwIw
9
+ dzEgMB4GA1UEAwwXTWV0YSBXQSBGZWF0dXJlIFJvb3QgQ0ExCzAJBgNVBAYTAlVT
10
+ MRMwEQYDVQQIDApDYWxpZm9ybmlhMRMwEQYDVQQHDApNZW5sbyBQYXJrMRwwGgYD
11
+ VQQKDBNNZXRhIFBsYXRmb3JtcyBJbmMuMCAXDTI1MDkwNDE3MzEyNFoYDzIwNjUw
12
+ OTA0MTczMTI0WjB3MSAwHgYDVQQDDBdNZXRhIFdBIEZlYXR1cmUgUm9vdCBDQTEL
13
+ MAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExEzARBgNVBAcMCk1lbmxv
14
+ IFBhcmsxHDAaBgNVBAoME01ldGEgUGxhdGZvcm1zIEluYy4wWTATBgcqhkjOPQIB
15
+ BggqhkjOPQMBBwNCAAT60blw90ebreMkw8+Wpcs0ETAkr1VQjoZoyi7PSSQbsoiP
16
+ qYRnzfRrR+xiahaXbYU83qXiTHjVUiOU9wDxI83qo4H6MIH3MA8GA1UdEwEB/wQF
17
+ MAMBAf8wHQYDVR0OBBYEFNO7KMTVSYUxkL6VS3LyWJw7m76zMIG0BgNVHSMEgaww
18
+ gamAFNO7KMTVSYUxkL6VS3LyWJw7m76zoXukeTB3MSAwHgYDVQQDDBdNZXRhIFdB
19
+ IEZlYXR1cmUgUm9vdCBDQTELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3Ju
20
+ aWExEzARBgNVBAcMCk1lbmxvIFBhcmsxHDAaBgNVBAoME01ldGEgUGxhdGZvcm1z
21
+ IEluYy6CFALbuULsZlYXxk/Cz5I35uNJkpdAMA4GA1UdDwEB/wQEAwIBhjAKBggq
22
+ hkjOPQQDAgNIADBFAiAINhjk9DbP416vx/WjqdUfexgic08aQsxnpDDsNE5M0gIh
23
+ ANorq7KwCQVMtS2or5uKJAQsx1FxCHyDafq2GCk9t0AN
24
+ -----END CERTIFICATE-----`
25
+
26
+ let rootCertificate = null
27
+
28
+ export const loadBotSignatureRoot = () => {
29
+ if (!rootCertificate) {
30
+ rootCertificate = new X509Certificate(BOT_SIGNATURE_ROOT_CERTIFICATE)
31
+ }
32
+ return rootCertificate
33
+ }
34
+
35
+ export const constructSignaturePayload = ({ botFbid, messageDigest, version = BOT_SIGNATURE_VERSION }) =>
36
+ Buffer.concat([Buffer.from(version, 'utf8'), Buffer.from(String(botFbid), 'utf8'), Buffer.from(messageDigest)])
37
+
38
+ export const isParsableCertificateChain = (chain) => {
39
+ if (!Array.isArray(chain) || !chain.length) {
40
+ return false
41
+ }
42
+ try {
43
+ for (const entry of chain) {
44
+ new X509Certificate(Buffer.from(entry))
45
+ }
46
+ return true
47
+ }
48
+ catch {
49
+ return false
50
+ }
51
+ }
52
+
53
+ const failed = reason => ({ status: 'failed', reason })
54
+
55
+ const validAt = (certificate, at) => {
56
+ const from = Date.parse(certificate.validFrom)
57
+ const to = Date.parse(certificate.validTo)
58
+ return Number.isFinite(from) && Number.isFinite(to) && at >= from && at <= to
59
+ }
60
+
61
+ export const verifyBotSignature = ({ botJid, unifiedResponseBytes, proof, at = Date.now(), root = loadBotSignatureRoot() } = {}) => {
62
+ if (!proof) {
63
+ return failed('no WA_BOT_MSG proof')
64
+ }
65
+ if (Number(proof.version) !== 1) {
66
+ return failed(`unsupported signature version ${proof.version}`)
67
+ }
68
+ if (!proof.signature?.length) {
69
+ return failed('proof carries no signature')
70
+ }
71
+ if (!proof.certificateChain?.length) {
72
+ return failed('empty certificate chain')
73
+ }
74
+ if (!unifiedResponseBytes?.length) {
75
+ return failed('no unified response bytes to verify')
76
+ }
77
+ const botFbid = String(botJid ?? '').split('@')[0]
78
+ if (!botFbid) {
79
+ return failed('no bot jid, the fbid is part of the signed payload')
80
+ }
81
+
82
+ let chain
83
+ try {
84
+ chain = proof.certificateChain.map(entry => new X509Certificate(Buffer.from(entry)))
85
+ }
86
+ catch (error) {
87
+ return failed(`certificate did not parse: ${error.message}`)
88
+ }
89
+
90
+ const [leaf] = chain
91
+ if (!validAt(leaf, at)) {
92
+ return failed('leaf certificate is outside its validity window')
93
+ }
94
+
95
+ const full = [...chain, root]
96
+ for (let index = 0; index < full.length - 1; index += 1) {
97
+ const issuer = full[index + 1]
98
+ if (!validAt(issuer, at)) {
99
+ return failed(`issuer at position ${index + 1} is outside its validity window`)
100
+ }
101
+ let ok = false
102
+ try {
103
+ ok = full[index].verify(issuer.publicKey)
104
+ }
105
+ catch (error) {
106
+ return failed(`chain verification threw at position ${index}: ${error.message}`)
107
+ }
108
+ if (!ok) {
109
+ return failed(`chain broken at position ${index}`)
110
+ }
111
+ }
112
+
113
+ const payload = constructSignaturePayload({ botFbid, messageDigest: unifiedResponseBytes })
114
+ let ok = false
115
+ try {
116
+ ok = cryptoVerify(null, payload, leaf.publicKey, Buffer.from(proof.signature))
117
+ }
118
+ catch (error) {
119
+ return failed(`signature verification threw: ${error.message}`)
120
+ }
121
+ return ok ? { status: 'passed' } : failed('signature does not match the unified response bytes')
122
+ }