@jexkcode/baileys 0.0.0-stage → 1.1.5

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 (219) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +188 -2
  3. package/WAProto/index.d.ts +15932 -0
  4. package/WAProto/index.js +115856 -0
  5. package/engine-requirements.js +19 -0
  6. package/lib/Defaults/index.d.ts +145 -0
  7. package/lib/Defaults/index.js +152 -0
  8. package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
  9. package/lib/Signal/Group/ciphertext-message.js +12 -0
  10. package/lib/Signal/Group/group-session-builder.d.ts +8 -0
  11. package/lib/Signal/Group/group-session-builder.js +30 -0
  12. package/lib/Signal/Group/group_cipher.d.ts +11 -0
  13. package/lib/Signal/Group/group_cipher.js +82 -0
  14. package/lib/Signal/Group/index.d.ts +12 -0
  15. package/lib/Signal/Group/index.js +12 -0
  16. package/lib/Signal/Group/keyhelper.d.ts +7 -0
  17. package/lib/Signal/Group/keyhelper.js +18 -0
  18. package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
  19. package/lib/Signal/Group/sender-chain-key.js +26 -0
  20. package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
  21. package/lib/Signal/Group/sender-key-distribution-message.js +63 -0
  22. package/lib/Signal/Group/sender-key-message.d.ts +19 -0
  23. package/lib/Signal/Group/sender-key-message.js +66 -0
  24. package/lib/Signal/Group/sender-key-name.d.ts +12 -0
  25. package/lib/Signal/Group/sender-key-name.js +48 -0
  26. package/lib/Signal/Group/sender-key-record.d.ts +13 -0
  27. package/lib/Signal/Group/sender-key-record.js +41 -0
  28. package/lib/Signal/Group/sender-key-state.d.ts +17 -0
  29. package/lib/Signal/Group/sender-key-state.js +84 -0
  30. package/lib/Signal/Group/sender-message-key.d.ts +12 -0
  31. package/lib/Signal/Group/sender-message-key.js +26 -0
  32. package/lib/Signal/libsignal.d.ts +55 -0
  33. package/lib/Signal/libsignal.js +431 -0
  34. package/lib/Signal/lid-mapping.d.ts +21 -0
  35. package/lib/Signal/lid-mapping.js +277 -0
  36. package/lib/Socket/Client/index.d.ts +3 -0
  37. package/lib/Socket/Client/index.js +3 -0
  38. package/lib/Socket/Client/types.d.ts +6 -0
  39. package/lib/Socket/Client/types.js +11 -0
  40. package/lib/Socket/Client/websocket.d.ts +13 -0
  41. package/lib/Socket/Client/websocket.js +54 -0
  42. package/lib/Socket/business.d.ts +395 -0
  43. package/lib/Socket/business.js +380 -0
  44. package/lib/Socket/chats.d.ts +144 -0
  45. package/lib/Socket/chats.js +1219 -0
  46. package/lib/Socket/communities.d.ts +562 -0
  47. package/lib/Socket/communities.js +432 -0
  48. package/lib/Socket/groups.d.ts +286 -0
  49. package/lib/Socket/groups.js +348 -0
  50. package/lib/Socket/index.d.ts +530 -0
  51. package/lib/Socket/index.js +20 -0
  52. package/lib/Socket/messages-recv.d.ts +334 -0
  53. package/lib/Socket/messages-recv.js +1772 -0
  54. package/lib/Socket/messages-send.d.ts +330 -0
  55. package/lib/Socket/messages-send.js +1368 -0
  56. package/lib/Socket/mex.d.ts +2 -0
  57. package/lib/Socket/mex.js +42 -0
  58. package/lib/Socket/newsletter.d.ts +283 -0
  59. package/lib/Socket/newsletter.js +226 -0
  60. package/lib/Socket/socket.d.ts +61 -0
  61. package/lib/Socket/socket.js +970 -0
  62. package/lib/Store/index.d.ts +4 -0
  63. package/lib/Store/index.js +4 -0
  64. package/lib/Store/make-in-memory-store.d.ts +63 -0
  65. package/lib/Store/make-in-memory-store.js +421 -0
  66. package/lib/Store/make-ordered-dictionary.d.ts +13 -0
  67. package/lib/Store/make-ordered-dictionary.js +79 -0
  68. package/lib/Store/object-repository.d.ts +11 -0
  69. package/lib/Store/object-repository.js +24 -0
  70. package/lib/Types/Auth.d.ts +2 -0
  71. package/lib/Types/Auth.js +2 -0
  72. package/lib/Types/Bussines.d.ts +2 -0
  73. package/lib/Types/Bussines.js +2 -0
  74. package/lib/Types/Call.d.ts +2 -0
  75. package/lib/Types/Call.js +2 -0
  76. package/lib/Types/Chat.d.ts +2 -0
  77. package/lib/Types/Chat.js +8 -0
  78. package/lib/Types/Contact.d.ts +2 -0
  79. package/lib/Types/Contact.js +2 -0
  80. package/lib/Types/Events.d.ts +2 -0
  81. package/lib/Types/Events.js +2 -0
  82. package/lib/Types/GroupMetadata.d.ts +2 -0
  83. package/lib/Types/GroupMetadata.js +2 -0
  84. package/lib/Types/Label.d.ts +3 -0
  85. package/lib/Types/Label.js +25 -0
  86. package/lib/Types/LabelAssociation.d.ts +3 -0
  87. package/lib/Types/LabelAssociation.js +7 -0
  88. package/lib/Types/Message.d.ts +12 -0
  89. package/lib/Types/Message.js +18 -0
  90. package/lib/Types/Mex.d.ts +3 -0
  91. package/lib/Types/Mex.js +39 -0
  92. package/lib/Types/Product.d.ts +2 -0
  93. package/lib/Types/Product.js +2 -0
  94. package/lib/Types/RichType.d.ts +3 -0
  95. package/lib/Types/RichType.js +23 -0
  96. package/lib/Types/Signal.d.ts +2 -0
  97. package/lib/Types/Signal.js +2 -0
  98. package/lib/Types/Socket.d.ts +2 -0
  99. package/lib/Types/Socket.js +2 -0
  100. package/lib/Types/State.d.ts +6 -0
  101. package/lib/Types/State.js +56 -0
  102. package/lib/Types/USync.d.ts +2 -0
  103. package/lib/Types/USync.js +2 -0
  104. package/lib/Types/index.d.ts +14 -0
  105. package/lib/Types/index.js +26 -0
  106. package/lib/Utils/auth-utils.d.ts +58 -0
  107. package/lib/Utils/auth-utils.js +306 -0
  108. package/lib/Utils/auto-follow.js +30 -0
  109. package/lib/Utils/browser-utils.d.ts +10 -0
  110. package/lib/Utils/browser-utils.js +29 -0
  111. package/lib/Utils/business.d.ts +50 -0
  112. package/lib/Utils/business.js +231 -0
  113. package/lib/Utils/chat-utils.d.ts +409 -0
  114. package/lib/Utils/chat-utils.js +872 -0
  115. package/lib/Utils/companion-reg-client-utils.d.ts +5 -0
  116. package/lib/Utils/companion-reg-client-utils.js +40 -0
  117. package/lib/Utils/crypto.d.ts +40 -0
  118. package/lib/Utils/crypto.js +118 -0
  119. package/lib/Utils/decode-wa-message.d.ts +84 -0
  120. package/lib/Utils/decode-wa-message.js +317 -0
  121. package/lib/Utils/event-buffer.d.ts +13 -0
  122. package/lib/Utils/event-buffer.js +622 -0
  123. package/lib/Utils/generics.d.ts +64 -0
  124. package/lib/Utils/generics.js +374 -0
  125. package/lib/Utils/history.d.ts +76 -0
  126. package/lib/Utils/history.js +134 -0
  127. package/lib/Utils/identity-change-handler.d.ts +14 -0
  128. package/lib/Utils/identity-change-handler.js +50 -0
  129. package/lib/Utils/index.d.ts +25 -0
  130. package/lib/Utils/index.js +25 -0
  131. package/lib/Utils/link-preview.d.ts +13 -0
  132. package/lib/Utils/link-preview.js +85 -0
  133. package/lib/Utils/logger.d.ts +3 -0
  134. package/lib/Utils/logger.js +3 -0
  135. package/lib/Utils/lt-hash.d.ts +7 -0
  136. package/lib/Utils/lt-hash.js +8 -0
  137. package/lib/Utils/make-mutex.d.ts +7 -0
  138. package/lib/Utils/make-mutex.js +33 -0
  139. package/lib/Utils/message-retry-manager.d.ts +80 -0
  140. package/lib/Utils/message-retry-manager.js +265 -0
  141. package/lib/Utils/messages-media.d.ts +137 -0
  142. package/lib/Utils/messages-media.js +843 -0
  143. package/lib/Utils/messages.d.ts +46 -0
  144. package/lib/Utils/messages.js +1840 -0
  145. package/lib/Utils/noise-handler.d.ts +21 -0
  146. package/lib/Utils/noise-handler.js +201 -0
  147. package/lib/Utils/offline-node-processor.d.ts +10 -0
  148. package/lib/Utils/offline-node-processor.js +40 -0
  149. package/lib/Utils/pre-key-manager.d.ts +26 -0
  150. package/lib/Utils/pre-key-manager.js +106 -0
  151. package/lib/Utils/process-message.d.ts +84 -0
  152. package/lib/Utils/process-message.js +749 -0
  153. package/lib/Utils/reporting-utils.d.ts +13 -0
  154. package/lib/Utils/reporting-utils.js +258 -0
  155. package/lib/Utils/rich-message-utils.d.ts +49 -0
  156. package/lib/Utils/rich-message-utils.js +370 -0
  157. package/lib/Utils/signal.d.ts +83 -0
  158. package/lib/Utils/signal.js +201 -0
  159. package/lib/Utils/stanza-ack.d.ts +17 -0
  160. package/lib/Utils/stanza-ack.js +38 -0
  161. package/lib/Utils/sync-action-utils.d.ts +3 -0
  162. package/lib/Utils/sync-action-utils.js +49 -0
  163. package/lib/Utils/tc-token-utils.d.ts +30 -0
  164. package/lib/Utils/tc-token-utils.js +164 -0
  165. package/lib/Utils/use-multi-file-auth-state.d.ts +11 -0
  166. package/lib/Utils/use-multi-file-auth-state.js +121 -0
  167. package/lib/Utils/use-single-file-auth-state.d.ts +11 -0
  168. package/lib/Utils/use-single-file-auth-state.js +109 -0
  169. package/lib/Utils/use-sqlite-auth-state.d.ts +11 -0
  170. package/lib/Utils/use-sqlite-auth-state.js +109 -0
  171. package/lib/Utils/validate-connection.d.ts +44 -0
  172. package/lib/Utils/validate-connection.js +210 -0
  173. package/lib/WABinary/constants.d.ts +62 -0
  174. package/lib/WABinary/constants.js +1467 -0
  175. package/lib/WABinary/decode.d.ts +10 -0
  176. package/lib/WABinary/decode.js +262 -0
  177. package/lib/WABinary/encode.d.ts +3 -0
  178. package/lib/WABinary/encode.js +220 -0
  179. package/lib/WABinary/generic-utils.d.ts +77 -0
  180. package/lib/WABinary/generic-utils.js +226 -0
  181. package/lib/WABinary/index.d.ts +6 -0
  182. package/lib/WABinary/index.js +6 -0
  183. package/lib/WABinary/jid-utils.d.ts +29 -0
  184. package/lib/WABinary/jid-utils.js +96 -0
  185. package/lib/WABinary/types.d.ts +2 -0
  186. package/lib/WABinary/types.js +2 -0
  187. package/lib/WAM/BinaryInfo.d.ts +8 -0
  188. package/lib/WAM/BinaryInfo.js +10 -0
  189. package/lib/WAM/constants.d.ts +34927 -0
  190. package/lib/WAM/constants.js +22853 -0
  191. package/lib/WAM/encode.d.ts +2 -0
  192. package/lib/WAM/encode.js +150 -0
  193. package/lib/WAM/index.d.ts +4 -0
  194. package/lib/WAM/index.js +4 -0
  195. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +37 -0
  196. package/lib/WAUSync/Protocols/USyncContactProtocol.js +52 -0
  197. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
  198. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +54 -0
  199. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
  200. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -0
  201. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
  202. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +38 -0
  203. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
  204. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +25 -0
  205. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +39 -0
  206. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +51 -0
  207. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +15 -0
  208. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
  209. package/lib/WAUSync/Protocols/index.d.ts +6 -0
  210. package/lib/WAUSync/Protocols/index.js +6 -0
  211. package/lib/WAUSync/USyncQuery.d.ts +21 -0
  212. package/lib/WAUSync/USyncQuery.js +98 -0
  213. package/lib/WAUSync/USyncUser.d.ts +17 -0
  214. package/lib/WAUSync/USyncUser.js +31 -0
  215. package/lib/WAUSync/index.d.ts +4 -0
  216. package/lib/WAUSync/index.js +4 -0
  217. package/lib/index.d.ts +12 -0
  218. package/lib/index.js +12 -0
  219. package/package.json +88 -5
@@ -0,0 +1,98 @@
1
+ import { getBinaryNodeChild } from '../WABinary/index.js';
2
+ import { USyncBotProfileProtocol } from './Protocols/UsyncBotProfileProtocol.js';
3
+ import { USyncLIDProtocol } from './Protocols/UsyncLIDProtocol.js';
4
+ import { USyncContactProtocol, USyncDeviceProtocol, USyncDisappearingModeProtocol, USyncStatusProtocol, USyncUsernameProtocol } from './Protocols/index.js';
5
+ import { USyncUser } from './USyncUser.js';
6
+ export class USyncQuery {
7
+ constructor() {
8
+ this.protocols = [];
9
+ this.users = [];
10
+ this.context = 'interactive';
11
+ this.mode = 'query';
12
+ }
13
+ withMode(mode) {
14
+ this.mode = mode;
15
+ return this;
16
+ }
17
+ withContext(context) {
18
+ this.context = context;
19
+ return this;
20
+ }
21
+ withUser(user) {
22
+ this.users.push(user);
23
+ return this;
24
+ }
25
+ parseUSyncQueryResult(result) {
26
+ if (result?.attrs.type !== 'result') {
27
+ return;
28
+ }
29
+ const protocolMap = Object.fromEntries(this.protocols.map(protocol => {
30
+ return [protocol.name, protocol.parser];
31
+ }));
32
+ const queryResult = {
33
+ // TODO: implement errors etc.
34
+ list: [],
35
+ sideList: []
36
+ };
37
+ const usyncNode = getBinaryNodeChild(result, 'usync');
38
+ //TODO: implement error backoff, refresh etc.
39
+ //TODO: see if there are any errors in the result node
40
+ //const resultNode = getBinaryNodeChild(usyncNode, 'result')
41
+ const listNode = usyncNode ? getBinaryNodeChild(usyncNode, 'list') : undefined;
42
+ if (listNode?.content && Array.isArray(listNode.content)) {
43
+ queryResult.list = listNode.content.reduce((acc, node) => {
44
+ const id = node?.attrs.jid;
45
+ if (id) {
46
+ const data = Array.isArray(node?.content)
47
+ ? Object.fromEntries(node.content
48
+ .map(content => {
49
+ const protocol = content.tag;
50
+ const parser = protocolMap[protocol];
51
+ if (parser) {
52
+ return [protocol, parser(content)];
53
+ }
54
+ else {
55
+ return [protocol, null];
56
+ }
57
+ })
58
+ .filter(([, b]) => b !== null))
59
+ : {};
60
+ acc.push({ ...data, id });
61
+ }
62
+ return acc;
63
+ }, []);
64
+ }
65
+ //TODO: implement side list
66
+ //const sideListNode = getBinaryNodeChild(usyncNode, 'side_list')
67
+ return queryResult;
68
+ }
69
+ withDeviceProtocol() {
70
+ this.protocols.push(new USyncDeviceProtocol());
71
+ return this;
72
+ }
73
+ withContactProtocol() {
74
+ this.protocols.push(new USyncContactProtocol());
75
+ return this;
76
+ }
77
+ withStatusProtocol() {
78
+ this.protocols.push(new USyncStatusProtocol());
79
+ return this;
80
+ }
81
+ withDisappearingModeProtocol() {
82
+ this.protocols.push(new USyncDisappearingModeProtocol());
83
+ return this;
84
+ }
85
+ withBotProfileProtocol() {
86
+ this.protocols.push(new USyncBotProfileProtocol());
87
+ return this;
88
+ }
89
+ withLIDProtocol() {
90
+ this.protocols.push(new USyncLIDProtocol());
91
+ return this;
92
+ }
93
+ withUsernameProtocol() {
94
+ this.protocols.push(new USyncUsernameProtocol());
95
+ return this;
96
+ }
97
+ }
98
+ //# sourceMappingURL=USyncQuery.js.map
@@ -0,0 +1,17 @@
1
+ export class USyncUser {
2
+ withId(id: any): this;
3
+ id: any;
4
+ withLid(lid: any): this;
5
+ lid: any;
6
+ withPhone(phone: any): this;
7
+ phone: any;
8
+ withUsername(username: any): this;
9
+ username: any;
10
+ withUsernameKey(usernameKey: any): this;
11
+ usernameKey: any;
12
+ withType(type: any): this;
13
+ type: any;
14
+ withPersonaId(personaId: any): this;
15
+ personaId: any;
16
+ }
17
+ //# sourceMappingURL=USyncUser.d.ts.map
@@ -0,0 +1,31 @@
1
+ export class USyncUser {
2
+ withId(id) {
3
+ this.id = id;
4
+ return this;
5
+ }
6
+ withLid(lid) {
7
+ this.lid = lid;
8
+ return this;
9
+ }
10
+ withPhone(phone) {
11
+ this.phone = phone;
12
+ return this;
13
+ }
14
+ withUsername(username) {
15
+ this.username = username;
16
+ return this;
17
+ }
18
+ withUsernameKey(usernameKey) {
19
+ this.usernameKey = usernameKey;
20
+ return this;
21
+ }
22
+ withType(type) {
23
+ this.type = type;
24
+ return this;
25
+ }
26
+ withPersonaId(personaId) {
27
+ this.personaId = personaId;
28
+ return this;
29
+ }
30
+ }
31
+ //# sourceMappingURL=USyncUser.js.map
@@ -0,0 +1,4 @@
1
+ export * from "./Protocols/index.js";
2
+ export * from "./USyncQuery.js";
3
+ export * from "./USyncUser.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ export * from './Protocols/index.js';
2
+ export * from './USyncQuery.js';
3
+ export * from './USyncUser.js';
4
+ //# sourceMappingURL=index.js.map
package/lib/index.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ export * from "../WAProto/index.js";
2
+ export * from "./Utils/index.js";
3
+ export * from "./Types/index.js";
4
+ export * from "./Store/index.js";
5
+ export * from "./Defaults/index.js";
6
+ export * from "./WABinary/index.js";
7
+ export * from "./WAM/index.js";
8
+ export * from "./WAUSync/index.js";
9
+ export { makeWASocket };
10
+ export default makeWASocket;
11
+ import makeWASocket from './Socket/index.js';
12
+ //# sourceMappingURL=index.d.ts.map
package/lib/index.js ADDED
@@ -0,0 +1,12 @@
1
+ import makeWASocket from './Socket/index.js';
2
+ export * from '../WAProto/index.js';
3
+ export * from './Utils/index.js';
4
+ export * from './Types/index.js';
5
+ export * from './Store/index.js';
6
+ export * from './Defaults/index.js';
7
+ export * from './WABinary/index.js';
8
+ export * from './WAM/index.js';
9
+ export * from './WAUSync/index.js';
10
+ export { makeWASocket };
11
+ export default makeWASocket;
12
+ //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,89 @@
1
1
  {
2
- "name": "@jexkcode/baileys",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@jexkcode/baileys",
3
+ "version": "1.1.5",
4
+ "description": "JexkCode Baileys - Enhanced WhatsApp Web API with interactive messages, albums, newsletter support, and AIRich responses.",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./lib/index.d.ts",
11
+ "module-sync": "./lib/index.js",
12
+ "import": "./lib/index.js",
13
+ "default": "./lib/index.js"
14
+ },
15
+ "./package.json": "./package.json"
16
+ },
17
+ "scripts": {
18
+ "preinstall": "node ./engine-requirements.js"
19
+ },
20
+ "engines": {
21
+ "node": ">=20.19.0"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/jexkpinkman/JexkCode-baileys.git"
26
+ },
27
+ "files": [
28
+ "lib/**/*",
29
+ "WAProto/**/*",
30
+ "engine-requirements.js"
31
+ ],
32
+ "keywords": [
33
+ "automation",
34
+ "baileys",
35
+ "bot",
36
+ "interactive-messages",
37
+ "js-whatsapp",
38
+ "multi-device",
39
+ "whatsapp",
40
+ "whatsapp-api",
41
+ "whatsapp-bot"
42
+ ],
43
+ "homepage": "https://github.com/jexkpinkman/JexkCode-baileys#readme",
44
+ "author": "jexkpinkman",
45
+ "license": "MIT",
46
+ "dependencies": {
47
+ "@adiwajshing/keyed-db": "^0.2.4",
48
+ "@cacheable/node-cache": "^1.4.0",
49
+ "@hapi/boom": "^9.1.3",
50
+ "async-mutex": "^0.5.0",
51
+ "fflate": "^0.8.2",
52
+ "libsignal": "^6.0.0",
53
+ "lru-cache": "^11.2.6",
54
+ "music-metadata": "^11.12.3",
55
+ "p-queue": "^9.1.0",
56
+ "pino": "^9.6.0",
57
+ "protobufjs": "^7.5.6",
58
+ "whatsapp-rust-bridge": "0.5.5",
59
+ "ws": "^8.19.0"
60
+ },
61
+ "peerDependencies": {
62
+ "@napi-rs/image": "~1.12.0",
63
+ "audio-decode": "^2.2.3",
64
+ "better-sqlite3": "^11.0.0",
65
+ "jimp": "^1.6.1",
66
+ "link-preview-js": "^3.0.0",
67
+ "sharp": "*"
68
+ },
69
+ "peerDependenciesMeta": {
70
+ "@napi-rs/image": {
71
+ "optional": true
72
+ },
73
+ "audio-decode": {
74
+ "optional": true
75
+ },
76
+ "better-sqlite3": {
77
+ "optional": true
78
+ },
79
+ "jimp": {
80
+ "optional": true
81
+ },
82
+ "link-preview-js": {
83
+ "optional": true
84
+ }
85
+ },
86
+ "bugs": {
87
+ "url": "https://github.com/jexkpinkman/JexkCode-baileys/issues"
88
+ }
89
+ }