@ntzckofficial/baileys 0.0.0-stage → 2.0.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 (289) hide show
  1. package/Example/example.ts +235 -0
  2. package/LICENSE +21 -0
  3. package/README.md +41 -2
  4. package/WAProto/GenerateStatics.sh +3 -0
  5. package/WAProto/WAProto.proto +5479 -0
  6. package/WAProto/fix-imports.js +81 -0
  7. package/WAProto/index.d.ts +17302 -0
  8. package/WAProto/index.js +125089 -0
  9. package/index.cjs +29 -0
  10. package/index.d.ts +2 -0
  11. package/package.json +113 -3
  12. package/src/Defaults/index.d.ts +153 -0
  13. package/src/Defaults/index.js +165 -0
  14. package/src/MessageBuilder/bot-signature.d.ts +22 -0
  15. package/src/MessageBuilder/bot-signature.js +123 -0
  16. package/src/MessageBuilder/extras.d.ts +449 -0
  17. package/src/MessageBuilder/extras.js +1357 -0
  18. package/src/MessageBuilder/index.d.ts +210 -0
  19. package/src/MessageBuilder/index.js +3561 -0
  20. package/src/MessageBuilder/metaai.d.ts +438 -0
  21. package/src/MessageBuilder/metaai.js +891 -0
  22. package/src/Signal/Group/ciphertext-message.d.ts +10 -0
  23. package/src/Signal/Group/ciphertext-message.js +12 -0
  24. package/src/Signal/Group/group-session-builder.d.ts +8 -0
  25. package/src/Signal/Group/group-session-builder.js +28 -0
  26. package/src/Signal/Group/group_cipher.d.ts +11 -0
  27. package/src/Signal/Group/group_cipher.js +79 -0
  28. package/src/Signal/Group/index.d.ts +12 -0
  29. package/src/Signal/Group/index.js +12 -0
  30. package/src/Signal/Group/keyhelper.d.ts +7 -0
  31. package/src/Signal/Group/keyhelper.js +18 -0
  32. package/src/Signal/Group/sender-chain-key.d.ts +14 -0
  33. package/src/Signal/Group/sender-chain-key.js +26 -0
  34. package/src/Signal/Group/sender-key-distribution-message.d.ts +17 -0
  35. package/src/Signal/Group/sender-key-distribution-message.js +63 -0
  36. package/src/Signal/Group/sender-key-message.d.ts +19 -0
  37. package/src/Signal/Group/sender-key-message.js +66 -0
  38. package/src/Signal/Group/sender-key-name.d.ts +12 -0
  39. package/src/Signal/Group/sender-key-name.js +48 -0
  40. package/src/Signal/Group/sender-key-record.d.ts +13 -0
  41. package/src/Signal/Group/sender-key-record.js +41 -0
  42. package/src/Signal/Group/sender-key-state.d.ts +17 -0
  43. package/src/Signal/Group/sender-key-state.js +84 -0
  44. package/src/Signal/Group/sender-message-key.d.ts +12 -0
  45. package/src/Signal/Group/sender-message-key.js +26 -0
  46. package/src/Signal/libsignal.d.ts +55 -0
  47. package/src/Signal/libsignal.js +459 -0
  48. package/src/Signal/lid-mapping.d.ts +21 -0
  49. package/src/Signal/lid-mapping.js +275 -0
  50. package/src/Socket/Client/index.d.ts +3 -0
  51. package/src/Socket/Client/index.js +3 -0
  52. package/src/Socket/Client/types.d.ts +6 -0
  53. package/src/Socket/Client/types.js +10 -0
  54. package/src/Socket/Client/websocket.d.ts +13 -0
  55. package/src/Socket/Client/websocket.js +54 -0
  56. package/src/Socket/business.d.ts +432 -0
  57. package/src/Socket/business.js +380 -0
  58. package/src/Socket/chats.d.ts +248 -0
  59. package/src/Socket/chats.js +1485 -0
  60. package/src/Socket/communities.d.ts +599 -0
  61. package/src/Socket/communities.js +422 -0
  62. package/src/Socket/groups.d.ts +299 -0
  63. package/src/Socket/groups.js +340 -0
  64. package/src/Socket/index.d.ts +582 -0
  65. package/src/Socket/index.js +43 -0
  66. package/src/Socket/messages-recv.d.ts +371 -0
  67. package/src/Socket/messages-recv.js +1813 -0
  68. package/src/Socket/messages-send.d.ts +391 -0
  69. package/src/Socket/messages-send.js +1575 -0
  70. package/src/Socket/mex.d.ts +2 -0
  71. package/src/Socket/mex.js +45 -0
  72. package/src/Socket/newsletter.d.ts +469 -0
  73. package/src/Socket/newsletter.js +643 -0
  74. package/src/Socket/socket.d.ts +78 -0
  75. package/src/Socket/socket.js +1088 -0
  76. package/src/Store/index.d.ts +4 -0
  77. package/src/Store/index.js +4 -0
  78. package/src/Store/make-in-memory-store.d.ts +63 -0
  79. package/src/Store/make-in-memory-store.js +398 -0
  80. package/src/Store/make-ordered-dictionary.d.ts +13 -0
  81. package/src/Store/make-ordered-dictionary.js +79 -0
  82. package/src/Store/object-repository.d.ts +11 -0
  83. package/src/Store/object-repository.js +24 -0
  84. package/src/Types/Auth.d.ts +2 -0
  85. package/src/Types/Auth.js +2 -0
  86. package/src/Types/Bussines.d.ts +2 -0
  87. package/src/Types/Bussines.js +2 -0
  88. package/src/Types/Call.d.ts +2 -0
  89. package/src/Types/Call.js +2 -0
  90. package/src/Types/Chat.d.ts +3 -0
  91. package/src/Types/Chat.js +25 -0
  92. package/src/Types/Contact.d.ts +2 -0
  93. package/src/Types/Contact.js +2 -0
  94. package/src/Types/Events.d.ts +2 -0
  95. package/src/Types/Events.js +1 -0
  96. package/src/Types/GroupMetadata.d.ts +6 -0
  97. package/src/Types/GroupMetadata.js +7 -0
  98. package/src/Types/Label.d.ts +3 -0
  99. package/src/Types/Label.js +25 -0
  100. package/src/Types/LabelAssociation.d.ts +3 -0
  101. package/src/Types/LabelAssociation.js +7 -0
  102. package/src/Types/Message.d.ts +14 -0
  103. package/src/Types/Message.js +24 -0
  104. package/src/Types/Mex.d.ts +3 -0
  105. package/src/Types/Mex.js +96 -0
  106. package/src/Types/Product.d.ts +2 -0
  107. package/src/Types/Product.js +2 -0
  108. package/src/Types/Signal.d.ts +2 -0
  109. package/src/Types/Signal.js +1 -0
  110. package/src/Types/Socket.d.ts +2 -0
  111. package/src/Types/Socket.js +1 -0
  112. package/src/Types/State.d.ts +6 -0
  113. package/src/Types/State.js +55 -0
  114. package/src/Types/USync.d.ts +2 -0
  115. package/src/Types/USync.js +1 -0
  116. package/src/Types/index.d.ts +14 -0
  117. package/src/Types/index.js +26 -0
  118. package/src/Utils/auth-store.d.ts +30 -0
  119. package/src/Utils/auth-store.js +77 -0
  120. package/src/Utils/auth-utils.d.ts +59 -0
  121. package/src/Utils/auth-utils.js +287 -0
  122. package/src/Utils/browser-utils.d.ts +10 -0
  123. package/src/Utils/browser-utils.js +29 -0
  124. package/src/Utils/business.d.ts +50 -0
  125. package/src/Utils/business.js +227 -0
  126. package/src/Utils/chat-utils.d.ts +409 -0
  127. package/src/Utils/chat-utils.js +847 -0
  128. package/src/Utils/companion-reg-client-utils.d.ts +5 -0
  129. package/src/Utils/companion-reg-client-utils.js +40 -0
  130. package/src/Utils/crypto.d.ts +40 -0
  131. package/src/Utils/crypto.js +111 -0
  132. package/src/Utils/decode-wa-message.d.ts +100 -0
  133. package/src/Utils/decode-wa-message.js +398 -0
  134. package/src/Utils/event-buffer.d.ts +23 -0
  135. package/src/Utils/event-buffer.js +625 -0
  136. package/src/Utils/generics.d.ts +64 -0
  137. package/src/Utils/generics.js +376 -0
  138. package/src/Utils/group-metadata-cache.d.ts +5 -0
  139. package/src/Utils/group-metadata-cache.js +26 -0
  140. package/src/Utils/history.d.ts +76 -0
  141. package/src/Utils/history.js +132 -0
  142. package/src/Utils/html-app.d.ts +19 -0
  143. package/src/Utils/html-app.js +97 -0
  144. package/src/Utils/html-multiplayer.d.ts +10 -0
  145. package/src/Utils/html-multiplayer.js +95 -0
  146. package/src/Utils/identity-change-handler.d.ts +14 -0
  147. package/src/Utils/identity-change-handler.js +49 -0
  148. package/src/Utils/index.d.ts +45 -0
  149. package/src/Utils/index.js +45 -0
  150. package/src/Utils/link-preview-metadata.d.ts +47 -0
  151. package/src/Utils/link-preview-metadata.js +89 -0
  152. package/src/Utils/link-preview.d.ts +13 -0
  153. package/src/Utils/link-preview.js +80 -0
  154. package/src/Utils/logger.d.ts +3 -0
  155. package/src/Utils/logger.js +3 -0
  156. package/src/Utils/lt-hash.d.ts +7 -0
  157. package/src/Utils/lt-hash.js +4 -0
  158. package/src/Utils/make-mutex.d.ts +7 -0
  159. package/src/Utils/make-mutex.js +33 -0
  160. package/src/Utils/message-retry-manager.d.ts +80 -0
  161. package/src/Utils/message-retry-manager.js +256 -0
  162. package/src/Utils/messages-media.d.ts +137 -0
  163. package/src/Utils/messages-media.js +815 -0
  164. package/src/Utils/messages.d.ts +63 -0
  165. package/src/Utils/messages.js +2153 -0
  166. package/src/Utils/modern-messages.d.ts +150 -0
  167. package/src/Utils/modern-messages.js +496 -0
  168. package/src/Utils/native-flow.d.ts +11 -0
  169. package/src/Utils/native-flow.js +116 -0
  170. package/src/Utils/newsletter-status.d.ts +158 -0
  171. package/src/Utils/newsletter-status.js +651 -0
  172. package/src/Utils/noise-handler.d.ts +21 -0
  173. package/src/Utils/noise-handler.js +201 -0
  174. package/src/Utils/offline-node-processor.d.ts +10 -0
  175. package/src/Utils/offline-node-processor.js +34 -0
  176. package/src/Utils/optional-media.d.ts +3 -0
  177. package/src/Utils/optional-media.js +46 -0
  178. package/src/Utils/payment-messages.d.ts +66 -0
  179. package/src/Utils/payment-messages.js +161 -0
  180. package/src/Utils/pre-key-manager.d.ts +26 -0
  181. package/src/Utils/pre-key-manager.js +96 -0
  182. package/src/Utils/process-message.d.ts +61 -0
  183. package/src/Utils/process-message.js +689 -0
  184. package/src/Utils/reporting-utils.d.ts +13 -0
  185. package/src/Utils/reporting-utils.js +257 -0
  186. package/src/Utils/scheduled-message.d.ts +51 -0
  187. package/src/Utils/scheduled-message.js +113 -0
  188. package/src/Utils/sender-key-memory.d.ts +20 -0
  189. package/src/Utils/sender-key-memory.js +52 -0
  190. package/src/Utils/signal.d.ts +83 -0
  191. package/src/Utils/signal.js +194 -0
  192. package/src/Utils/stanza-ack.d.ts +17 -0
  193. package/src/Utils/stanza-ack.js +31 -0
  194. package/src/Utils/status-stickers.d.ts +127 -0
  195. package/src/Utils/status-stickers.js +261 -0
  196. package/src/Utils/sync-action-utils.d.ts +3 -0
  197. package/src/Utils/sync-action-utils.js +45 -0
  198. package/src/Utils/tc-token-utils.d.ts +30 -0
  199. package/src/Utils/tc-token-utils.js +156 -0
  200. package/src/Utils/ttl-cache.d.ts +29 -0
  201. package/src/Utils/ttl-cache.js +121 -0
  202. package/src/Utils/use-mongo-auth-state.d.ts +22 -0
  203. package/src/Utils/use-mongo-auth-state.js +68 -0
  204. package/src/Utils/use-multi-file-auth-state.d.ts +12 -0
  205. package/src/Utils/use-multi-file-auth-state.js +119 -0
  206. package/src/Utils/use-mysql-auth-state.d.ts +20 -0
  207. package/src/Utils/use-mysql-auth-state.js +80 -0
  208. package/src/Utils/use-postgres-auth-state.d.ts +20 -0
  209. package/src/Utils/use-postgres-auth-state.js +80 -0
  210. package/src/Utils/use-redis-auth-state.d.ts +20 -0
  211. package/src/Utils/use-redis-auth-state.js +90 -0
  212. package/src/Utils/use-single-file-auth-state.d.ts +11 -0
  213. package/src/Utils/use-single-file-auth-state.js +109 -0
  214. package/src/Utils/use-sqlite-auth-state.d.ts +13 -0
  215. package/src/Utils/use-sqlite-auth-state.js +121 -0
  216. package/src/Utils/useNekoDBAuth.d.ts +19 -0
  217. package/src/Utils/useNekoDBAuth.js +111 -0
  218. package/src/Utils/username.d.ts +12 -0
  219. package/src/Utils/username.js +59 -0
  220. package/src/Utils/validate-connection.d.ts +44 -0
  221. package/src/Utils/validate-connection.js +208 -0
  222. package/src/Utils/voice-recognition.d.ts +53 -0
  223. package/src/Utils/voice-recognition.js +219 -0
  224. package/src/Voip/audio-feeder.d.ts +25 -0
  225. package/src/Voip/audio-feeder.js +269 -0
  226. package/src/Voip/index.d.ts +89 -0
  227. package/src/Voip/index.js +937 -0
  228. package/src/Voip/relay-transport.d.ts +6 -0
  229. package/src/Voip/relay-transport.js +825 -0
  230. package/src/Voip/signaling.d.ts +12 -0
  231. package/src/Voip/signaling.js +1100 -0
  232. package/src/Voip/types.d.ts +3 -0
  233. package/src/Voip/types.js +13 -0
  234. package/src/Voip/video-feeder.d.ts +25 -0
  235. package/src/Voip/video-feeder.js +269 -0
  236. package/src/Voip/wasm-engine.d.ts +27 -0
  237. package/src/Voip/wasm-engine.js +1308 -0
  238. package/src/Voip/worker-bootstrap.js +1024 -0
  239. package/src/WABinary/constants.d.ts +23 -0
  240. package/src/WABinary/constants.js +1301 -0
  241. package/src/WABinary/decode.d.ts +10 -0
  242. package/src/WABinary/decode.js +262 -0
  243. package/src/WABinary/encode.d.ts +3 -0
  244. package/src/WABinary/encode.js +220 -0
  245. package/src/WABinary/generic-utils.d.ts +77 -0
  246. package/src/WABinary/generic-utils.js +215 -0
  247. package/src/WABinary/index.d.ts +6 -0
  248. package/src/WABinary/index.js +6 -0
  249. package/src/WABinary/jid-utils.d.ts +31 -0
  250. package/src/WABinary/jid-utils.js +98 -0
  251. package/src/WABinary/types.d.ts +2 -0
  252. package/src/WABinary/types.js +1 -0
  253. package/src/WAM/BinaryInfo.d.ts +8 -0
  254. package/src/WAM/BinaryInfo.js +10 -0
  255. package/src/WAM/constants.d.ts +34927 -0
  256. package/src/WAM/constants.js +22853 -0
  257. package/src/WAM/encode.d.ts +2 -0
  258. package/src/WAM/encode.js +149 -0
  259. package/src/WAM/index.d.ts +4 -0
  260. package/src/WAM/index.js +4 -0
  261. package/src/WAUSync/Protocols/USyncContactProtocol.d.ts +37 -0
  262. package/src/WAUSync/Protocols/USyncContactProtocol.js +51 -0
  263. package/src/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
  264. package/src/WAUSync/Protocols/USyncDeviceProtocol.js +52 -0
  265. package/src/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
  266. package/src/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -0
  267. package/src/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
  268. package/src/WAUSync/Protocols/USyncStatusProtocol.js +38 -0
  269. package/src/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
  270. package/src/WAUSync/Protocols/USyncUsernameProtocol.js +24 -0
  271. package/src/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +39 -0
  272. package/src/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -0
  273. package/src/WAUSync/Protocols/UsyncLIDProtocol.d.ts +15 -0
  274. package/src/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
  275. package/src/WAUSync/Protocols/index.d.ts +6 -0
  276. package/src/WAUSync/Protocols/index.js +6 -0
  277. package/src/WAUSync/USyncQuery.d.ts +21 -0
  278. package/src/WAUSync/USyncQuery.js +94 -0
  279. package/src/WAUSync/USyncUser.d.ts +17 -0
  280. package/src/WAUSync/USyncUser.js +31 -0
  281. package/src/WAUSync/index.d.ts +4 -0
  282. package/src/WAUSync/index.js +4 -0
  283. package/src/assets/wasm/README.md +76 -0
  284. package/src/assets/wasm/loader.js +5 -0
  285. package/src/assets/wasm/whatsapp.wasm +0 -0
  286. package/src/assets/wasm/worker-modules.js +273 -0
  287. package/src/custom.js +85 -0
  288. package/src/index.d.ts +49 -0
  289. package/src/index.js +55 -0
package/index.cjs ADDED
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * rubby-baileys — CJS entry shim (ESM-only as of this build)
5
+ *
6
+ * Why this changed: the previous version of this file used Node's
7
+ * synchronous require(esm) to bridge into lib/index.js at runtime. That
8
+ * only works on Node >=20.19.0 or >=22.12.0 — many hosting panels ship a
9
+ * "Node 22" that is still below 22.12, so `require('rubby-baileys')` would
10
+ * fail there with a confusing native ERR_REQUIRE_ESM error, even though the
11
+ * panel's own spec sheet says "Node 22+". Detecting and working around that
12
+ * per-patch-version gap added a lot of fragile logic for very little value.
13
+ *
14
+ * This package is published as ESM ("type": "module"). Please import it
15
+ * instead of requiring it:
16
+ *
17
+ * import { makeWASocket, useMultiFileAuthState } from 'rubby-baileys';
18
+ *
19
+ * If your project is CommonJS, either:
20
+ * 1) Use a dynamic import (works in any CJS file, any Node version):
21
+ * const { makeWASocket } = await import('rubby-baileys');
22
+ * 2) Or switch your project to ESM ("type": "module" in your
23
+ * package.json, or a .mjs entry file).
24
+ */
25
+ throw new Error(
26
+ "[rubby-baileys] This package is ESM-only — `require('rubby-baileys')` is not supported.\n" +
27
+ "Use `import { makeWASocket } from 'rubby-baileys'` instead, or, from CommonJS code, " +
28
+ "`const { makeWASocket } = await import('rubby-baileys')`."
29
+ );
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './src/index.js';
2
+ export { default, default as makeWASocket } from './src/index.js';
package/package.json CHANGED
@@ -1,6 +1,116 @@
1
1
  {
2
2
  "name": "@ntzckofficial/baileys",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "type": "module",
4
+ "version": "2.0.0",
5
+ "description": "Baileys Whatsapp Bot From ntzckofficial",
6
+ "keywords": [
7
+ "baileys",
8
+ "bot",
9
+ "botwa",
10
+ "interactive-messages",
11
+ "js-whatsapp",
12
+ "multi-device",
13
+ "wabot",
14
+ "whatsapp",
15
+ "whatsapp-api",
16
+ "whatsapp-bot",
17
+ "whatsapp-chat",
18
+ "whatsapp-group",
19
+ "whatsapp-web",
20
+ "ntzckid"
21
+ ],
22
+ "license": "MIT",
23
+ "author": "ntzckid",
24
+ "main": "src/index.js",
25
+ "types": "src/index.d.ts",
26
+ "files": [
27
+ "src/**/*",
28
+ "WAProto/**/*",
29
+ "index.cjs",
30
+ "index.d.ts",
31
+ "engine-requirements.js",
32
+ "Example",
33
+ "LICENSE",
34
+ "LICENSE.forks",
35
+ "NOTICE.forks.md",
36
+ "EXPERIMENTAL.md",
37
+ "README.md"
38
+ ],
39
+ "scripts": {
40
+ "preinstall": "node ./engine-requirements.js",
41
+ "test": "node --test \"test/*.test.js\"",
42
+ "update:version": "node ./script/updatewa.js"
43
+ },
44
+ "dependencies": {
45
+ "@adiwajshing/keyed-db": "^0.2.4",
46
+ "@hapi/boom": "^9.1.3",
47
+ "@rexxhayanasi/wangcap-id-bridge": "^1.0.0",
48
+ "async-mutex": "^0.5.0",
49
+ "fflate": "^0.8.2",
50
+ "libsignal": "^6.0.0",
51
+ "lru-cache": "^11.2.6",
52
+ "music-metadata": "^11.12.3",
53
+ "p-queue": "^9.1.0",
54
+ "pino": "^9.6.0",
55
+ "protobufjs": "^7.5.6",
56
+ "ws": "^8.19.0"
57
+ },
58
+ "peerDependencies": {
59
+ "@napi-rs/image": "~1.12.0",
60
+ "@nekodb/client": "*",
61
+ "audio-decode": "^2.2.3",
62
+ "better-sqlite3": "^11.0.0 || ^12.0.0 || ^13.0.0",
63
+ "fluent-ffmpeg": "*",
64
+ "ioredis": "^5.0.0",
65
+ "jimp": "^1.6.1",
66
+ "link-preview-js": "^3.0.0",
67
+ "mongodb": "^6.0.0",
68
+ "mysql2": "^3.0.0",
69
+ "pg": "^8.0.0",
70
+ "sharp": "^0.35.0"
71
+ },
72
+ "peerDependenciesMeta": {
73
+ "@napi-rs/image": {
74
+ "optional": true
75
+ },
76
+ "@nekodb/client": {
77
+ "optional": true
78
+ },
79
+ "audio-decode": {
80
+ "optional": true
81
+ },
82
+ "better-sqlite3": {
83
+ "optional": true
84
+ },
85
+ "fluent-ffmpeg": {
86
+ "optional": true
87
+ },
88
+ "ioredis": {
89
+ "optional": true
90
+ },
91
+ "jimp": {
92
+ "optional": true
93
+ },
94
+ "link-preview-js": {
95
+ "optional": true
96
+ },
97
+ "mongodb": {
98
+ "optional": true
99
+ },
100
+ "mysql2": {
101
+ "optional": true
102
+ },
103
+ "pg": {
104
+ "optional": true
105
+ },
106
+ "sharp": {
107
+ "optional": true
108
+ }
109
+ },
110
+ "engines": {
111
+ "node": ">=20.0.0"
112
+ },
113
+ "optionalDependencies": {
114
+ "@rexxhayanasi/elaina-anchorguard": "^1.0.0"
115
+ }
6
116
  }
@@ -0,0 +1,153 @@
1
+ /* Elaina Baileys maintained distribution. Upstream notices and license are preserved in LICENSE and NOTICE.md. */
2
+ export const UNAUTHORIZED_CODES: number[];
3
+ 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\"}";
4
+ export const DEFAULT_ORIGIN: "https://web.whatsapp.com";
5
+ export const CALL_VIDEO_PREFIX: "https://call.whatsapp.com/video/";
6
+ export const CALL_AUDIO_PREFIX: "https://call.whatsapp.com/voice/";
7
+ export const DONATE_URL: "https://www.npmjs.com/package/@rexxhayanasi/elaina-baileys";
8
+ export const LIBRARY_NAME: "rexxhayanasi/elaina-baileys";
9
+ export const DEF_CALLBACK_PREFIX: "CB:";
10
+ export const DEF_TAG_PREFIX: "TAG:";
11
+ export const PHONE_CONNECTION_CB: "CB:Pong";
12
+ export const WA_ADV_ACCOUNT_SIG_PREFIX: any;
13
+ export const WA_ADV_DEVICE_SIG_PREFIX: any;
14
+ export const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX: any;
15
+ export const WA_ADV_HOSTED_DEVICE_SIG_PREFIX: any;
16
+ export const WA_DEFAULT_EPHEMERAL: number;
17
+ /** Status messages older than 24 hours are considered expired */
18
+ export const STATUS_EXPIRY_SECONDS: number;
19
+ /** WA Web enforces a 14-day maximum age for placeholder resend requests */
20
+ export const PLACEHOLDER_MAX_AGE_SECONDS: number;
21
+ export const NOISE_MODE: "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
22
+ export const DICT_VERSION: 3;
23
+ export const KEY_BUNDLE_TYPE: any;
24
+ export const NOISE_WA_HEADER: any;
25
+ /** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
26
+ export const URL_REGEX: RegExp;
27
+ export namespace WA_CERT_DETAILS {
28
+ let SERIAL: number;
29
+ let ISSUER: string;
30
+ let PUBLIC_KEY: any;
31
+ }
32
+ export const PROCESSABLE_HISTORY_TYPES: proto.HistorySync.HistorySyncType[];
33
+ export namespace DEFAULT_CACHE_TTLS {
34
+ let SIGNAL_STORE: number;
35
+ let MSG_RETRY: number;
36
+ let CALL_OFFER: number;
37
+ let USER_DEVICES: number;
38
+ let OUTBOUND_RESEND: number;
39
+ }
40
+ export namespace DEFAULT_CONNECTION_CONFIG {
41
+ export { version };
42
+ export let browser: any[];
43
+ export let waWebSocketUrl: string;
44
+ export let connectTimeoutMs: number;
45
+ export let keepAliveIntervalMs: number;
46
+ export let logger: any;
47
+ export let emitOwnEvents: boolean;
48
+ export let defaultQueryTimeoutMs: number;
49
+ export let customUploadHosts: never[];
50
+ export let retryRequestDelayMs: number;
51
+ export let maxMsgRetryCount: number;
52
+ export let ackRetryDelayMs: number;
53
+ export let maxAckRetryCount: number;
54
+ export let maxRetryQueueSize: number;
55
+ export let pairingCodeTimeoutMs: number;
56
+ export let fireInitQueries: boolean;
57
+ export let auth: undefined;
58
+ export let markOnlineOnConnect: boolean;
59
+ export let syncFullHistory: boolean;
60
+ export function patchMessageBeforeSending(msg: any): any;
61
+ export function shouldSyncHistoryMessage({ syncType }: {
62
+ syncType: any;
63
+ }): boolean;
64
+ export function shouldIgnoreJid(): boolean;
65
+ export let linkPreviewImageThumbnailWidth: number;
66
+ export namespace transactionOpts {
67
+ let maxCommitRetries: number;
68
+ let delayBetweenTriesMs: number;
69
+ }
70
+ export let generateHighQualityLinkPreview: boolean;
71
+ export let enableAutoSessionRecreation: boolean;
72
+ export let enableRecentMessageCache: boolean;
73
+ export let options: {};
74
+ export namespace appStateMacVerification {
75
+ let patch: boolean;
76
+ let snapshot: boolean;
77
+ }
78
+ export let countryCode: string;
79
+ export function getMessage(): Promise<undefined>;
80
+ export function cachedGroupMetadata(): Promise<undefined>;
81
+ export { makeLibSignalRepository as makeSignalRepository };
82
+ }
83
+ export const MEDIA_PATH_MAP: {
84
+ image: string;
85
+ video: string;
86
+ document: string;
87
+ audio: string;
88
+ sticker: string;
89
+ 'sticker-pack': string;
90
+ 'thumbnail-sticker-pack': string;
91
+ 'thumbnail-link': string;
92
+ 'thumbnail-image': string;
93
+ 'thumbnail-video': string;
94
+ 'thumbnail-document': string;
95
+ 'product-catalog-image': string;
96
+ 'md-app-state': string;
97
+ 'md-msg-hist': string;
98
+ 'biz-cover-photo': string;
99
+ };
100
+ export const NEWSLETTER_MEDIA_PATH_MAP: {
101
+ image: string;
102
+ video: string;
103
+ document: string;
104
+ audio: string;
105
+ sticker: string;
106
+ 'thumbnail-link': string;
107
+ };
108
+ export const MEDIA_HKDF_KEY_MAPPING: {
109
+ audio: string;
110
+ document: string;
111
+ gif: string;
112
+ image: string;
113
+ ppic: string;
114
+ product: string;
115
+ ptt: string;
116
+ 'sticker-pack': string;
117
+ 'thumbnail-sticker-pack': string;
118
+ sticker: string;
119
+ video: string;
120
+ 'thumbnail-document': string;
121
+ 'thumbnail-image': string;
122
+ 'thumbnail-video': string;
123
+ 'thumbnail-link': string;
124
+ 'md-msg-hist': string;
125
+ 'md-app-state': string;
126
+ 'product-catalog-image': string;
127
+ 'payment-bg-image': string;
128
+ ptv: string;
129
+ 'biz-cover-photo': string;
130
+ location: string;
131
+ contact: string;
132
+ 'voip-token': string;
133
+ };
134
+ export const MEDIA_KEYS: string[];
135
+ /** 120s timeout for history sync stall detection, same as WA Web's handleChunkProgress / restartPausedTimer (g = 120) */
136
+ export const HISTORY_SYNC_PAUSED_TIMEOUT_MS: 120000;
137
+ export const MIN_PREKEY_COUNT: 5;
138
+ export const INITIAL_PREKEY_COUNT: 812;
139
+ export const UPLOAD_TIMEOUT: 30000;
140
+ export namespace TimeMs {
141
+ let Minute: number;
142
+ let Hour: number;
143
+ let Day: number;
144
+ let Week: number;
145
+ }
146
+ import { proto } from '../../WAProto/index.js';
147
+ declare const version: number[];
148
+ import { makeLibSignalRepository } from '../Signal/libsignal.js';
149
+ export {};
150
+ export const MAX_OUTBOUND_RESEND_ENTRIES: number;
151
+ export const MEMBER_LABEL_MAX_LENGTH: number;
152
+ export const DEFAULT_CACHE_MAX_KEYS: number;
153
+ export const PAIRING_RESPONSE_GRACE_MS: number;
@@ -0,0 +1,165 @@
1
+ /* Elaina Baileys maintained distribution. Upstream notices and license are preserved in LICENSE and NOTICE.md. */
2
+ import { proto } from '../../WAProto/index.js';
3
+ import { makeLibSignalRepository } from '../Signal/libsignal.js';
4
+ import { Browsers } from '../Utils/browser-utils.js';
5
+ import logger from '../Utils/logger.js';
6
+ const version = [2, 3000, 1051456098];
7
+ export const UNAUTHORIZED_CODES = [401, 403, 419];
8
+ 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"}';
9
+ export const DEFAULT_ORIGIN = 'https://web.whatsapp.com';
10
+ export const CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/';
11
+ export const CALL_AUDIO_PREFIX = 'https://call.whatsapp.com/voice/';
12
+ export const DONATE_URL = 'https://www.npmjs.com/package/@rexxhayanasi/elaina-baileys';
13
+ export const LIBRARY_NAME = 'rexxhayanasi/elaina-baileys';
14
+ export const DEF_CALLBACK_PREFIX = 'CB:';
15
+ export const DEF_TAG_PREFIX = 'TAG:';
16
+ export const PHONE_CONNECTION_CB = 'CB:Pong';
17
+ export const WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0]);
18
+ export const WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1]);
19
+ export const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5]);
20
+ export const WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6]);
21
+ export const WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60;
22
+
23
+ export const STATUS_EXPIRY_SECONDS = 24 * 60 * 60;
24
+
25
+ export const PLACEHOLDER_MAX_AGE_SECONDS = 14 * 24 * 60 * 60;
26
+ export const NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0';
27
+ export const DICT_VERSION = 3;
28
+ export const KEY_BUNDLE_TYPE = Buffer.from([5]);
29
+ export const NOISE_WA_HEADER = Buffer.from([87, 65, 6, DICT_VERSION]);
30
+
31
+ export const URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
32
+ export const WA_CERT_DETAILS = {
33
+ SERIAL: 0,
34
+ ISSUER: 'WhatsAppLongTerm1',
35
+ PUBLIC_KEY: Buffer.from('142375574d0a587166aae71ebe516437c4a28b73e3695c6ce1f7f9545da8ee6b', 'hex')
36
+ };
37
+ export const PROCESSABLE_HISTORY_TYPES = [
38
+ proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP,
39
+ proto.HistorySync.HistorySyncType.PUSH_NAME,
40
+ proto.HistorySync.HistorySyncType.RECENT,
41
+ proto.HistorySync.HistorySyncType.FULL,
42
+ proto.HistorySync.HistorySyncType.ON_DEMAND,
43
+ proto.HistorySync.HistorySyncType.NON_BLOCKING_DATA,
44
+ proto.HistorySync.HistorySyncType.INITIAL_STATUS_V3
45
+ ];
46
+ export const DEFAULT_CACHE_TTLS = {
47
+ SIGNAL_STORE: 5 * 60,
48
+ MSG_RETRY: 60 * 60,
49
+ CALL_OFFER: 5 * 60,
50
+ USER_DEVICES: 5 * 60,
51
+ OUTBOUND_RESEND: 60
52
+ };
53
+
54
+ export const MAX_OUTBOUND_RESEND_ENTRIES = 512;
55
+ export const MEMBER_LABEL_MAX_LENGTH = 30;
56
+ export const DEFAULT_CACHE_MAX_KEYS = 20000;
57
+
58
+ export const PAIRING_RESPONSE_GRACE_MS = 30000;
59
+ export const DEFAULT_CONNECTION_CONFIG = {
60
+ version: version,
61
+ browser: Browsers.macOS('Chrome'),
62
+ waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
63
+ connectTimeoutMs: 20000,
64
+ keepAliveIntervalMs: 15000,
65
+ logger: logger.child({ class: 'elaina' }),
66
+ emitOwnEvents: true,
67
+ AnchorGuard: false,
68
+ AnchorGuardConfig: {},
69
+ defaultQueryTimeoutMs: 60000,
70
+ customUploadHosts: [],
71
+ retryRequestDelayMs: 250,
72
+ maxMsgRetryCount: 3,
73
+ maxEventListeners: 64,
74
+ ackRetryDelayMs: 750,
75
+ maxAckRetryCount: 3,
76
+ maxRetryQueueSize: 64,
77
+ pairingCodeTimeoutMs: 180000,
78
+ fireInitQueries: true,
79
+ auth: undefined,
80
+ markOnlineOnConnect: true,
81
+ syncFullHistory: true,
82
+ patchMessageBeforeSending: msg => msg,
83
+ shouldSyncHistoryMessage: ({ syncType }) => {
84
+ return syncType !== proto.HistorySync.HistorySyncType.FULL;
85
+ },
86
+ shouldIgnoreJid: () => false,
87
+ linkPreviewImageThumbnailWidth: 192,
88
+ transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
89
+ generateHighQualityLinkPreview: true,
90
+ enableAutoSessionRecreation: true,
91
+ enableRecentMessageCache: true,
92
+ options: {},
93
+ appStateMacVerification: {
94
+ patch: false,
95
+ snapshot: false
96
+ },
97
+ countryCode: 'US',
98
+ getMessage: async () => undefined,
99
+ cachedGroupMetadata: async () => undefined,
100
+ makeSignalRepository: makeLibSignalRepository
101
+ };
102
+ export const MEDIA_PATH_MAP = {
103
+ image: '/mms/image',
104
+ video: '/mms/video',
105
+ document: '/mms/document',
106
+ audio: '/mms/audio',
107
+ sticker: '/mms/image',
108
+ 'sticker-pack': '/mms/sticker-pack',
109
+ 'thumbnail-sticker-pack': '/mms/thumbnail-sticker-pack',
110
+ 'thumbnail-link': '/mms/image',
111
+ 'thumbnail-image': '/mms/image',
112
+ 'thumbnail-video': '/mms/video',
113
+ 'thumbnail-document': '/mms/document',
114
+ 'product-catalog-image': '/product/image',
115
+ 'md-app-state': '',
116
+ 'md-msg-hist': '/mms/md-app-state',
117
+ 'biz-cover-photo': '/pps/biz-cover-photo'
118
+ };
119
+
120
+ export const NEWSLETTER_MEDIA_PATH_MAP = {
121
+ image: '/newsletter/newsletter-image',
122
+ video: '/newsletter/newsletter-video',
123
+ document: '/newsletter/newsletter-document',
124
+ audio: '/newsletter/newsletter-audio',
125
+ sticker: '/newsletter/newsletter-image',
126
+ 'thumbnail-link': '/newsletter/newsletter-thumbnail-link'
127
+ };
128
+ export const MEDIA_HKDF_KEY_MAPPING = {
129
+ audio: 'Audio',
130
+ document: 'Document',
131
+ gif: 'Video',
132
+ image: 'Image',
133
+ ppic: '',
134
+ product: 'Image',
135
+ ptt: 'Audio',
136
+ 'sticker-pack': 'Sticker Pack',
137
+ 'thumbnail-sticker-pack': 'Sticker Pack Thumbnail',
138
+ sticker: 'Image',
139
+ video: 'Video',
140
+ 'thumbnail-document': 'Document Thumbnail',
141
+ 'thumbnail-image': 'Image Thumbnail',
142
+ 'thumbnail-video': 'Video Thumbnail',
143
+ 'thumbnail-link': 'Link Thumbnail',
144
+ 'md-msg-hist': 'History',
145
+ 'md-app-state': 'App State',
146
+ 'product-catalog-image': 'Product Catalog Image',
147
+ 'payment-bg-image': 'Payment Background',
148
+ ptv: 'Video',
149
+ 'biz-cover-photo': 'Image',
150
+ location: 'Location',
151
+ contact: 'Contact',
152
+ 'voip-token': 'Voip Token'
153
+ };
154
+ export const MEDIA_KEYS = Object.keys(MEDIA_PATH_MAP);
155
+
156
+ export const HISTORY_SYNC_PAUSED_TIMEOUT_MS = 120000;
157
+ export const MIN_PREKEY_COUNT = 5;
158
+ export const INITIAL_PREKEY_COUNT = 812;
159
+ export const UPLOAD_TIMEOUT = 30000;
160
+ export const TimeMs = {
161
+ Minute: 60 * 1000,
162
+ Hour: 60 * 60 * 1000,
163
+ Day: 24 * 60 * 60 * 1000,
164
+ Week: 7 * 24 * 60 * 60 * 1000
165
+ };
@@ -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,123 @@
1
+ /* Elaina Baileys maintained distribution. Upstream notices and license are preserved in LICENSE and NOTICE.md. */
2
+ import { X509Certificate, verify as cryptoVerify } from 'crypto'
3
+
4
+ export const BOT_SIGNATURE_VERSION = '1'
5
+ export const BOT_SIGNATURE_USE_CASE_WA_BOT_MSG = 1
6
+ export const BOT_SIGNATURE_ROOT_VERSION = '2025-10'
7
+
8
+ export const BOT_SIGNATURE_ROOT_CERTIFICATE = `-----BEGIN CERTIFICATE-----
9
+ MIIC7TCCApOgAwIBAgIUAtu5QuxmVhfGT8LPkjfm40mSl0AwCgYIKoZIzj0EAwIw
10
+ dzEgMB4GA1UEAwwXTWV0YSBXQSBGZWF0dXJlIFJvb3QgQ0ExCzAJBgNVBAYTAlVT
11
+ MRMwEQYDVQQIDApDYWxpZm9ybmlhMRMwEQYDVQQHDApNZW5sbyBQYXJrMRwwGgYD
12
+ VQQKDBNNZXRhIFBsYXRmb3JtcyBJbmMuMCAXDTI1MDkwNDE3MzEyNFoYDzIwNjUw
13
+ OTA0MTczMTI0WjB3MSAwHgYDVQQDDBdNZXRhIFdBIEZlYXR1cmUgUm9vdCBDQTEL
14
+ MAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExEzARBgNVBAcMCk1lbmxv
15
+ IFBhcmsxHDAaBgNVBAoME01ldGEgUGxhdGZvcm1zIEluYy4wWTATBgcqhkjOPQIB
16
+ BggqhkjOPQMBBwNCAAT60blw90ebreMkw8+Wpcs0ETAkr1VQjoZoyi7PSSQbsoiP
17
+ qYRnzfRrR+xiahaXbYU83qXiTHjVUiOU9wDxI83qo4H6MIH3MA8GA1UdEwEB/wQF
18
+ MAMBAf8wHQYDVR0OBBYEFNO7KMTVSYUxkL6VS3LyWJw7m76zMIG0BgNVHSMEgaww
19
+ gamAFNO7KMTVSYUxkL6VS3LyWJw7m76zoXukeTB3MSAwHgYDVQQDDBdNZXRhIFdB
20
+ IEZlYXR1cmUgUm9vdCBDQTELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3Ju
21
+ aWExEzARBgNVBAcMCk1lbmxvIFBhcmsxHDAaBgNVBAoME01ldGEgUGxhdGZvcm1z
22
+ IEluYy6CFALbuULsZlYXxk/Cz5I35uNJkpdAMA4GA1UdDwEB/wQEAwIBhjAKBggq
23
+ hkjOPQQDAgNIADBFAiAINhjk9DbP416vx/WjqdUfexgic08aQsxnpDDsNE5M0gIh
24
+ ANorq7KwCQVMtS2or5uKJAQsx1FxCHyDafq2GCk9t0AN
25
+ -----END CERTIFICATE-----`
26
+
27
+ let rootCertificate = null
28
+
29
+ export const loadBotSignatureRoot = () => {
30
+ if (!rootCertificate) {
31
+ rootCertificate = new X509Certificate(BOT_SIGNATURE_ROOT_CERTIFICATE)
32
+ }
33
+ return rootCertificate
34
+ }
35
+
36
+ export const constructSignaturePayload = ({ botFbid, messageDigest, version = BOT_SIGNATURE_VERSION }) =>
37
+ Buffer.concat([Buffer.from(version, 'utf8'), Buffer.from(String(botFbid), 'utf8'), Buffer.from(messageDigest)])
38
+
39
+ export const isParsableCertificateChain = (chain) => {
40
+ if (!Array.isArray(chain) || !chain.length) {
41
+ return false
42
+ }
43
+ try {
44
+ for (const entry of chain) {
45
+ new X509Certificate(Buffer.from(entry))
46
+ }
47
+ return true
48
+ }
49
+ catch {
50
+ return false
51
+ }
52
+ }
53
+
54
+ const failed = reason => ({ status: 'failed', reason })
55
+
56
+ const validAt = (certificate, at) => {
57
+ const from = Date.parse(certificate.validFrom)
58
+ const to = Date.parse(certificate.validTo)
59
+ return Number.isFinite(from) && Number.isFinite(to) && at >= from && at <= to
60
+ }
61
+
62
+ export const verifyBotSignature = ({ botJid, unifiedResponseBytes, proof, at = Date.now(), root = loadBotSignatureRoot() } = {}) => {
63
+ if (!proof) {
64
+ return failed('no WA_BOT_MSG proof')
65
+ }
66
+ if (Number(proof.version) !== 1) {
67
+ return failed(`unsupported signature version ${proof.version}`)
68
+ }
69
+ if (!proof.signature?.length) {
70
+ return failed('proof carries no signature')
71
+ }
72
+ if (!proof.certificateChain?.length) {
73
+ return failed('empty certificate chain')
74
+ }
75
+ if (!unifiedResponseBytes?.length) {
76
+ return failed('no unified response bytes to verify')
77
+ }
78
+ const botFbid = String(botJid ?? '').split('@')[0]
79
+ if (!botFbid) {
80
+ return failed('no bot jid, the fbid is part of the signed payload')
81
+ }
82
+
83
+ let chain
84
+ try {
85
+ chain = proof.certificateChain.map(entry => new X509Certificate(Buffer.from(entry)))
86
+ }
87
+ catch (error) {
88
+ return failed(`certificate did not parse: ${error.message}`)
89
+ }
90
+
91
+ const [leaf] = chain
92
+ if (!validAt(leaf, at)) {
93
+ return failed('leaf certificate is outside its validity window')
94
+ }
95
+
96
+ const full = [...chain, root]
97
+ for (let index = 0; index < full.length - 1; index += 1) {
98
+ const issuer = full[index + 1]
99
+ if (!validAt(issuer, at)) {
100
+ return failed(`issuer at position ${index + 1} is outside its validity window`)
101
+ }
102
+ let ok = false
103
+ try {
104
+ ok = full[index].verify(issuer.publicKey)
105
+ }
106
+ catch (error) {
107
+ return failed(`chain verification threw at position ${index}: ${error.message}`)
108
+ }
109
+ if (!ok) {
110
+ return failed(`chain broken at position ${index}`)
111
+ }
112
+ }
113
+
114
+ const payload = constructSignaturePayload({ botFbid, messageDigest: unifiedResponseBytes })
115
+ let ok = false
116
+ try {
117
+ ok = cryptoVerify(null, payload, leaf.publicKey, Buffer.from(proof.signature))
118
+ }
119
+ catch (error) {
120
+ return failed(`signature verification threw: ${error.message}`)
121
+ }
122
+ return ok ? { status: 'passed' } : failed('signature does not match the unified response bytes')
123
+ }