nrx-bails 0.0.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 (199) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1541 -0
  3. package/WAProto/GenerateStatics.sh +4 -0
  4. package/WAProto/WAProto.proto +4775 -0
  5. package/WAProto/index.d.ts +2 -0
  6. package/WAProto/index.js +169661 -0
  7. package/lib/Defaults/index.d.ts +113 -0
  8. package/lib/Defaults/index.js +156 -0
  9. package/lib/Defaults/phonenumber-mcc.json +223 -0
  10. package/lib/Defaults/ye-bail-version.json +3 -0
  11. package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
  12. package/lib/Signal/Group/ciphertext-message.js +41 -0
  13. package/lib/Signal/Group/group-session-builder.d.ts +8 -0
  14. package/lib/Signal/Group/group-session-builder.js +90 -0
  15. package/lib/Signal/Group/group_cipher.d.ts +12 -0
  16. package/lib/Signal/Group/group_cipher.js +122 -0
  17. package/lib/Signal/Group/index.d.ts +22 -0
  18. package/lib/Signal/Group/index.js +83 -0
  19. package/lib/Signal/Group/keyhelper.d.ts +7 -0
  20. package/lib/Signal/Group/keyhelper.js +81 -0
  21. package/lib/Signal/Group/queue-job.d.ts +3 -0
  22. package/lib/Signal/Group/queue-job.js +83 -0
  23. package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
  24. package/lib/Signal/Group/sender-chain-key.js +60 -0
  25. package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
  26. package/lib/Signal/Group/sender-key-distribution-message.js +92 -0
  27. package/lib/Signal/Group/sender-key-message.d.ts +19 -0
  28. package/lib/Signal/Group/sender-key-message.js +95 -0
  29. package/lib/Signal/Group/sender-key-name.d.ts +12 -0
  30. package/lib/Signal/Group/sender-key-name.js +77 -0
  31. package/lib/Signal/Group/sender-key-record.d.ts +13 -0
  32. package/lib/Signal/Group/sender-key-record.js +79 -0
  33. package/lib/Signal/Group/sender-key-state.d.ts +17 -0
  34. package/lib/Signal/Group/sender-key-state.js +125 -0
  35. package/lib/Signal/Group/sender-message-key.d.ts +12 -0
  36. package/lib/Signal/Group/sender-message-key.js +55 -0
  37. package/lib/Signal/libsignal.d.ts +37 -0
  38. package/lib/Signal/libsignal.js +200 -0
  39. package/lib/Socket/Client/index.d.ts +1 -0
  40. package/lib/Socket/Client/index.js +44 -0
  41. package/lib/Socket/Client/types.d.ts +7 -0
  42. package/lib/Socket/Client/types.js +39 -0
  43. package/lib/Socket/Client/websocket.d.ts +19 -0
  44. package/lib/Socket/Client/websocket.js +137 -0
  45. package/lib/Socket/business.d.ts +329 -0
  46. package/lib/Socket/business.js +286 -0
  47. package/lib/Socket/chats.d.ts +84 -0
  48. package/lib/Socket/chats.js +1022 -0
  49. package/lib/Socket/groups.d.ts +216 -0
  50. package/lib/Socket/groups.js +358 -0
  51. package/lib/Socket/index.d.ts +330 -0
  52. package/lib/Socket/index.js +36 -0
  53. package/lib/Socket/messages-recv.d.ts +271 -0
  54. package/lib/Socket/messages-recv.js +1079 -0
  55. package/lib/Socket/messages-send.d.ts +258 -0
  56. package/lib/Socket/messages-send.js +1190 -0
  57. package/lib/Socket/newsletter.d.ts +253 -0
  58. package/lib/Socket/newsletter.js +362 -0
  59. package/lib/Socket/registration.d.ts +361 -0
  60. package/lib/Socket/registration.js +179 -0
  61. package/lib/Socket/socket.d.ts +33 -0
  62. package/lib/Socket/socket.js +699 -0
  63. package/lib/Socket/usync.d.ts +27 -0
  64. package/lib/Socket/usync.js +96 -0
  65. package/lib/Store/index.d.ts +3 -0
  66. package/lib/Store/index.js +36 -0
  67. package/lib/Store/make-cache-manager-auth-state.d.ts +16 -0
  68. package/lib/Store/make-cache-manager-auth-state.js +118 -0
  69. package/lib/Store/make-in-memory-store.d.ts +64 -0
  70. package/lib/Store/make-in-memory-store.js +465 -0
  71. package/lib/Store/make-ordered-dictionary.d.ts +14 -0
  72. package/lib/Store/make-ordered-dictionary.js +107 -0
  73. package/lib/Store/object-repository.d.ts +11 -0
  74. package/lib/Store/object-repository.js +53 -0
  75. package/lib/Types/Auth.d.ts +1 -0
  76. package/lib/Types/Auth.js +28 -0
  77. package/lib/Types/Call.d.ts +1 -0
  78. package/lib/Types/Call.js +28 -0
  79. package/lib/Types/Chat.d.ts +2 -0
  80. package/lib/Types/Chat.js +30 -0
  81. package/lib/Types/Contact.d.ts +1 -0
  82. package/lib/Types/Contact.js +28 -0
  83. package/lib/Types/Events.d.ts +1 -0
  84. package/lib/Types/Events.js +28 -0
  85. package/lib/Types/GroupMetadata.d.ts +1 -0
  86. package/lib/Types/GroupMetadata.js +28 -0
  87. package/lib/Types/Label.d.ts +2 -0
  88. package/lib/Types/Label.js +53 -0
  89. package/lib/Types/LabelAssociation.d.ts +2 -0
  90. package/lib/Types/LabelAssociation.js +35 -0
  91. package/lib/Types/Message.d.ts +2 -0
  92. package/lib/Types/Message.js +33 -0
  93. package/lib/Types/Newsletter.d.ts +4 -0
  94. package/lib/Types/Newsletter.js +62 -0
  95. package/lib/Types/Product.d.ts +1 -0
  96. package/lib/Types/Product.js +28 -0
  97. package/lib/Types/Signal.d.ts +1 -0
  98. package/lib/Types/Signal.js +28 -0
  99. package/lib/Types/Socket.d.ts +1 -0
  100. package/lib/Types/Socket.js +28 -0
  101. package/lib/Types/State.d.ts +1 -0
  102. package/lib/Types/State.js +28 -0
  103. package/lib/Types/USync.d.ts +1 -0
  104. package/lib/Types/USync.js +28 -0
  105. package/lib/Types/index.d.ts +2 -0
  106. package/lib/Types/index.js +68 -0
  107. package/lib/Utils/auth-utils.d.ts +63 -0
  108. package/lib/Utils/auth-utils.js +248 -0
  109. package/lib/Utils/browser-utils.d.ts +3 -0
  110. package/lib/Utils/browser-utils.js +61 -0
  111. package/lib/Utils/business.d.ts +53 -0
  112. package/lib/Utils/business.js +260 -0
  113. package/lib/Utils/chat-utils.d.ts +253 -0
  114. package/lib/Utils/chat-utils.js +756 -0
  115. package/lib/Utils/crypto.d.ts +43 -0
  116. package/lib/Utils/crypto.js +219 -0
  117. package/lib/Utils/decode-wa-message.d.ts +61 -0
  118. package/lib/Utils/decode-wa-message.js +233 -0
  119. package/lib/Utils/event-buffer.d.ts +17 -0
  120. package/lib/Utils/event-buffer.js +544 -0
  121. package/lib/Utils/generics.d.ts +89 -0
  122. package/lib/Utils/generics.js +471 -0
  123. package/lib/Utils/history.d.ts +59 -0
  124. package/lib/Utils/history.js +120 -0
  125. package/lib/Utils/index.d.ts +1 -0
  126. package/lib/Utils/index.js +61 -0
  127. package/lib/Utils/link-preview.d.ts +19 -0
  128. package/lib/Utils/link-preview.js +152 -0
  129. package/lib/Utils/logger.d.ts +3 -0
  130. package/lib/Utils/logger.js +33 -0
  131. package/lib/Utils/lt-hash.d.ts +13 -0
  132. package/lib/Utils/lt-hash.js +77 -0
  133. package/lib/Utils/make-mutex.d.ts +7 -0
  134. package/lib/Utils/make-mutex.js +69 -0
  135. package/lib/Utils/message-retry-manager.d.ts +34 -0
  136. package/lib/Utils/message-retry-manager.js +154 -0
  137. package/lib/Utils/messages-media.d.ts +137 -0
  138. package/lib/Utils/messages-media.js +1024 -0
  139. package/lib/Utils/messages.d.ts +66 -0
  140. package/lib/Utils/messages.js +1407 -0
  141. package/lib/Utils/noise-handler.d.ts +21 -0
  142. package/lib/Utils/noise-handler.js +176 -0
  143. package/lib/Utils/pre-key-manager.d.ts +13 -0
  144. package/lib/Utils/pre-key-manager.js +93 -0
  145. package/lib/Utils/process-message.d.ts +40 -0
  146. package/lib/Utils/process-message.js +430 -0
  147. package/lib/Utils/signal.d.ts +72 -0
  148. package/lib/Utils/signal.js +179 -0
  149. package/lib/Utils/use-multi-file-auth-state.d.ts +18 -0
  150. package/lib/Utils/use-multi-file-auth-state.js +151 -0
  151. package/lib/Utils/validate-connection.d.ts +43 -0
  152. package/lib/Utils/validate-connection.js +255 -0
  153. package/lib/Utils/ye-bail-event-stream.d.ts +16 -0
  154. package/lib/Utils/ye-bail-event-stream.js +89 -0
  155. package/lib/WABinary/constants.d.ts +23 -0
  156. package/lib/WABinary/constants.js +1328 -0
  157. package/lib/WABinary/decode.d.ts +10 -0
  158. package/lib/WABinary/decode.js +291 -0
  159. package/lib/WABinary/encode.d.ts +2 -0
  160. package/lib/WABinary/encode.js +276 -0
  161. package/lib/WABinary/generic-utils.d.ts +16 -0
  162. package/lib/WABinary/generic-utils.js +155 -0
  163. package/lib/WABinary/index.d.ts +1 -0
  164. package/lib/WABinary/index.js +47 -0
  165. package/lib/WABinary/jid-utils.d.ts +34 -0
  166. package/lib/WABinary/jid-utils.js +111 -0
  167. package/lib/WABinary/types.d.ts +1 -0
  168. package/lib/WABinary/types.js +28 -0
  169. package/lib/WAM/BinaryInfo.d.ts +8 -0
  170. package/lib/WAM/BinaryInfo.js +39 -0
  171. package/lib/WAM/constants.d.ts +35374 -0
  172. package/lib/WAM/constants.js +15376 -0
  173. package/lib/WAM/encode.d.ts +2 -0
  174. package/lib/WAM/encode.js +181 -0
  175. package/lib/WAM/index.d.ts +1 -0
  176. package/lib/WAM/index.js +45 -0
  177. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +14 -0
  178. package/lib/WAUSync/Protocols/USyncContactProtocol.js +58 -0
  179. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
  180. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +83 -0
  181. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
  182. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +56 -0
  183. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
  184. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +68 -0
  185. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +39 -0
  186. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +79 -0
  187. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
  188. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +50 -0
  189. package/lib/WAUSync/Protocols/index.d.ts +1 -0
  190. package/lib/WAUSync/Protocols/index.js +46 -0
  191. package/lib/WAUSync/USyncQuery.d.ts +20 -0
  192. package/lib/WAUSync/USyncQuery.js +115 -0
  193. package/lib/WAUSync/USyncUser.d.ts +13 -0
  194. package/lib/WAUSync/USyncUser.js +52 -0
  195. package/lib/WAUSync/index.d.ts +1 -0
  196. package/lib/WAUSync/index.js +45 -0
  197. package/lib/index.js +81 -0
  198. package/package.json +113 -0
  199. package/requirements.js +32 -0
@@ -0,0 +1,2 @@
1
+ export const __esModule: boolean;
2
+ export function encodeWAM(binaryInfo: any): Buffer<ArrayBuffer>;
@@ -0,0 +1,181 @@
1
+ /**
2
+ * ╔═══════════════════════════════════════════════════════════╗
3
+ * ║ NEROX - WhatsApp API Library ║
4
+ * ║ Premium Edition ║
5
+ * ╚═══════════════════════════════════════════════════════════╝
6
+ *
7
+ * @package nerox-bails
8
+ * @version 0.1.0
9
+ * @author NEROX Development Team
10
+ * @copyright Copyright (c) 2025 NEROX. All rights reserved.
11
+ * @license MIT License
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining
14
+ * a copy of this software and associated documentation files (the "Software"),
15
+ * to deal in the Software without restriction, including without limitation
16
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17
+ * and/or sell copies of the Software, and to permit persons to whom the
18
+ * Software is furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included
21
+ * in all copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26
+ */
27
+ "use strict";
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.encodeWAM = void 0;
30
+ const constants_1 = require("./constants");
31
+ const getHeaderBitLength = (key) => (key < 256 ? 2 : 3);
32
+ const encodeWAM = (binaryInfo) => {
33
+ binaryInfo.buffer = [];
34
+ encodeWAMHeader(binaryInfo);
35
+ encodeEvents(binaryInfo);
36
+ console.log(binaryInfo.buffer);
37
+ const totalSize = binaryInfo.buffer
38
+ .map((a) => a.length)
39
+ .reduce((a, b) => a + b);
40
+ const buffer = Buffer.alloc(totalSize);
41
+ let offset = 0;
42
+ binaryInfo.buffer.forEach((buffer_) => {
43
+ buffer_.copy(buffer, offset);
44
+ offset += buffer_.length;
45
+ });
46
+ return buffer;
47
+ };
48
+ exports.encodeWAM = encodeWAM;
49
+ function encodeWAMHeader(binaryInfo) {
50
+ const headerBuffer = Buffer.alloc(8);
51
+ headerBuffer.write('WAM', 0, 'utf8');
52
+ headerBuffer.writeUInt8(binaryInfo.protocolVersion, 3);
53
+ headerBuffer.writeUInt8(1, 4);
54
+ headerBuffer.writeUInt16BE(binaryInfo.sequence, 5);
55
+ headerBuffer.writeUInt8(0, 7);
56
+ binaryInfo.buffer.push(headerBuffer);
57
+ }
58
+ function encodeGlobalAttributes(binaryInfo, globals) {
59
+ for (const [key, _value] of Object.entries(globals)) {
60
+ const id = constants_1.WEB_GLOBALS.find(a => (a === null || a === void 0 ? void 0 : a.name) === key).id;
61
+ let value = _value;
62
+ if (typeof value === 'boolean') {
63
+ value = value ? 1 : 0;
64
+ }
65
+ binaryInfo.buffer.push(serializeData(id, value, constants_1.FLAG_GLOBAL));
66
+ }
67
+ }
68
+ function encodeEvents(binaryInfo) {
69
+ for (const [name, { props, globals },] of binaryInfo.events.map((a) => Object.entries(a)[0])) {
70
+ encodeGlobalAttributes(binaryInfo, globals);
71
+ const event = constants_1.WEB_EVENTS.find((a) => a.name === name);
72
+ const props_ = Object.entries(props);
73
+ let extended = false;
74
+ for (const [, value] of props_) {
75
+ extended || (extended = value !== null);
76
+ }
77
+ const eventFlag = extended ? constants_1.FLAG_EVENT : constants_1.FLAG_EVENT | constants_1.FLAG_EXTENDED;
78
+ binaryInfo.buffer.push(serializeData(event.id, -event.weight, eventFlag));
79
+ for (let i = 0; i < props_.length; i++) {
80
+ const [key, _value] = props_[i];
81
+ const id = (event.props)[key][0];
82
+ extended = i < (props_.length - 1);
83
+ let value = _value;
84
+ if (typeof value === 'boolean') {
85
+ value = value ? 1 : 0;
86
+ }
87
+ const fieldFlag = extended ? constants_1.FLAG_EVENT : constants_1.FLAG_FIELD | constants_1.FLAG_EXTENDED;
88
+ binaryInfo.buffer.push(serializeData(id, value, fieldFlag));
89
+ }
90
+ }
91
+ }
92
+ function serializeData(key, value, flag) {
93
+ const bufferLength = getHeaderBitLength(key);
94
+ let buffer;
95
+ let offset = 0;
96
+ if (value === null) {
97
+ if (flag === constants_1.FLAG_GLOBAL) {
98
+ buffer = Buffer.alloc(bufferLength);
99
+ offset = serializeHeader(buffer, offset, key, flag);
100
+ return buffer;
101
+ }
102
+ }
103
+ else if (typeof value === 'number' && Number.isInteger(value)) {
104
+
105
+ if (value === 0 || value === 1) {
106
+ buffer = Buffer.alloc(bufferLength);
107
+ offset = serializeHeader(buffer, offset, key, flag | ((value + 1) << 4));
108
+ return buffer;
109
+ }
110
+ else if (-128 <= value && value < 128) {
111
+ buffer = Buffer.alloc(bufferLength + 1);
112
+ offset = serializeHeader(buffer, offset, key, flag | (3 << 4));
113
+ buffer.writeInt8(value, offset);
114
+ return buffer;
115
+ }
116
+ else if (-32768 <= value && value < 32768) {
117
+ buffer = Buffer.alloc(bufferLength + 2);
118
+ offset = serializeHeader(buffer, offset, key, flag | (4 << 4));
119
+ buffer.writeInt16LE(value, offset);
120
+ return buffer;
121
+ }
122
+ else if (-2147483648 <= value && value < 2147483648) {
123
+ buffer = Buffer.alloc(bufferLength + 4);
124
+ offset = serializeHeader(buffer, offset, key, flag | (5 << 4));
125
+ buffer.writeInt32LE(value, offset);
126
+ return buffer;
127
+ }
128
+ else {
129
+ buffer = Buffer.alloc(bufferLength + 8);
130
+ offset = serializeHeader(buffer, offset, key, flag | (7 << 4));
131
+ buffer.writeDoubleLE(value, offset);
132
+ return buffer;
133
+ }
134
+ }
135
+ else if (typeof value === 'number') {
136
+
137
+ buffer = Buffer.alloc(bufferLength + 8);
138
+ offset = serializeHeader(buffer, offset, key, flag | (7 << 4));
139
+ buffer.writeDoubleLE(value, offset);
140
+ return buffer;
141
+ }
142
+ else if (typeof value === 'string') {
143
+
144
+ const utf8Bytes = Buffer.byteLength(value, 'utf8');
145
+ if (utf8Bytes < 256) {
146
+ buffer = Buffer.alloc(bufferLength + 1 + utf8Bytes);
147
+ offset = serializeHeader(buffer, offset, key, flag | (8 << 4));
148
+ buffer.writeUint8(utf8Bytes, offset++);
149
+ }
150
+ else if (utf8Bytes < 65536) {
151
+ buffer = Buffer.alloc(bufferLength + 2 + utf8Bytes);
152
+ offset = serializeHeader(buffer, offset, key, flag | (9 << 4));
153
+ buffer.writeUInt16LE(utf8Bytes, offset);
154
+ offset += 2;
155
+ }
156
+ else {
157
+ buffer = Buffer.alloc(bufferLength + 4 + utf8Bytes);
158
+ offset = serializeHeader(buffer, offset, key, flag | (10 << 4));
159
+ buffer.writeUInt32LE(utf8Bytes, offset);
160
+ offset += 4;
161
+ }
162
+ buffer.write(value, offset, 'utf8');
163
+ return buffer;
164
+ }
165
+ throw 'missing';
166
+ }
167
+ function serializeHeader(buffer, offset, key, flag) {
168
+ if (key < 256) {
169
+ buffer.writeUInt8(flag, offset);
170
+ offset += 1;
171
+ buffer.writeUInt8(key, offset);
172
+ offset += 1;
173
+ }
174
+ else {
175
+ buffer.writeUInt8(flag | constants_1.FLAG_BYTE, offset);
176
+ offset += 1;
177
+ buffer.writeUInt16LE(key, offset);
178
+ offset += 2;
179
+ }
180
+ return offset;
181
+ }
@@ -0,0 +1 @@
1
+ export const __esModule: boolean;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * ╔═══════════════════════════════════════════════════════════╗
3
+ * ║ NEROX - WhatsApp API Library ║
4
+ * ║ Premium Edition ║
5
+ * ╚═══════════════════════════════════════════════════════════╝
6
+ *
7
+ * @package nerox-bails
8
+ * @version 0.1.0
9
+ * @author NEROX Development Team
10
+ * @copyright Copyright (c) 2025 NEROX. All rights reserved.
11
+ * @license MIT License
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining
14
+ * a copy of this software and associated documentation files (the "Software"),
15
+ * to deal in the Software without restriction, including without limitation
16
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17
+ * and/or sell copies of the Software, and to permit persons to whom the
18
+ * Software is furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included
21
+ * in all copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26
+ */
27
+ "use strict";
28
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29
+ if (k2 === undefined) k2 = k;
30
+ var desc = Object.getOwnPropertyDescriptor(m, k);
31
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
32
+ desc = { enumerable: true, get: function() { return m[k]; } };
33
+ }
34
+ Object.defineProperty(o, k2, desc);
35
+ }) : (function(o, m, k, k2) {
36
+ if (k2 === undefined) k2 = k;
37
+ o[k2] = m[k];
38
+ }));
39
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
40
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
41
+ };
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ __exportStar(require("./constants"), exports);
44
+ __exportStar(require("./encode"), exports);
45
+ __exportStar(require("./BinaryInfo"), exports);
@@ -0,0 +1,14 @@
1
+ export const __esModule: boolean;
2
+ export class USyncContactProtocol {
3
+ name: string;
4
+ getQueryElement(): {
5
+ tag: string;
6
+ attrs: {};
7
+ };
8
+ getUserElement(user: any): {
9
+ tag: string;
10
+ attrs: {};
11
+ content: any;
12
+ };
13
+ parser(node: any): boolean;
14
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * ╔═══════════════════════════════════════════════════════════╗
3
+ * ║ NEROX - WhatsApp API Library ║
4
+ * ║ Premium Edition ║
5
+ * ╚═══════════════════════════════════════════════════════════╝
6
+ *
7
+ * @package nerox-bails
8
+ * @version 0.1.0
9
+ * @author NEROX Development Team
10
+ * @copyright Copyright (c) 2025 NEROX. All rights reserved.
11
+ * @license MIT License
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining
14
+ * a copy of this software and associated documentation files (the "Software"),
15
+ * to deal in the Software without restriction, including without limitation
16
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17
+ * and/or sell copies of the Software, and to permit persons to whom the
18
+ * Software is furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included
21
+ * in all copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26
+ */
27
+ "use strict";
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.USyncContactProtocol = void 0;
30
+ const WABinary_1 = require("../../WABinary");
31
+ class USyncContactProtocol {
32
+ constructor() {
33
+ this.name = 'contact';
34
+ }
35
+ getQueryElement() {
36
+ return {
37
+ tag: 'contact',
38
+ attrs: {},
39
+ };
40
+ }
41
+ getUserElement(user) {
42
+
43
+ return {
44
+ tag: 'contact',
45
+ attrs: {},
46
+ content: user.phone,
47
+ };
48
+ }
49
+ parser(node) {
50
+ var _a;
51
+ if (node.tag === 'contact') {
52
+ (0, WABinary_1.assertNodeErrorFree)(node);
53
+ return ((_a = node === null || node === void 0 ? void 0 : node.attrs) === null || _a === void 0 ? void 0 : _a.type) === 'in';
54
+ }
55
+ return false;
56
+ }
57
+ }
58
+ exports.USyncContactProtocol = USyncContactProtocol;
@@ -0,0 +1,23 @@
1
+ export const __esModule: boolean;
2
+ export class USyncDeviceProtocol {
3
+ name: string;
4
+ getQueryElement(): {
5
+ tag: string;
6
+ attrs: {
7
+ version: string;
8
+ };
9
+ };
10
+ getUserElement(): any;
11
+ parser(node: any): {
12
+ deviceList: {
13
+ id: number;
14
+ keyIndex: number;
15
+ isHosted: boolean;
16
+ }[];
17
+ keyIndex: {
18
+ timestamp: number;
19
+ signedKeyIndex: any;
20
+ expectedTimestamp: number;
21
+ };
22
+ };
23
+ }
@@ -0,0 +1,83 @@
1
+ /**
2
+ * ╔═══════════════════════════════════════════════════════════╗
3
+ * ║ NEROX - WhatsApp API Library ║
4
+ * ║ Premium Edition ║
5
+ * ╚═══════════════════════════════════════════════════════════╝
6
+ *
7
+ * @package nerox-bails
8
+ * @version 0.1.0
9
+ * @author NEROX Development Team
10
+ * @copyright Copyright (c) 2025 NEROX. All rights reserved.
11
+ * @license MIT License
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining
14
+ * a copy of this software and associated documentation files (the "Software"),
15
+ * to deal in the Software without restriction, including without limitation
16
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17
+ * and/or sell copies of the Software, and to permit persons to whom the
18
+ * Software is furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included
21
+ * in all copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26
+ */
27
+ "use strict";
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.USyncDeviceProtocol = void 0;
30
+ const WABinary_1 = require("../../WABinary");
31
+ class USyncDeviceProtocol {
32
+ constructor() {
33
+ this.name = 'devices';
34
+ }
35
+ getQueryElement() {
36
+ return {
37
+ tag: 'devices',
38
+ attrs: {
39
+ version: '2',
40
+ },
41
+ };
42
+ }
43
+ getUserElement( /* user: USyncUser */) {
44
+
45
+
46
+
47
+ return null;
48
+ }
49
+ parser(node) {
50
+ const deviceList = [];
51
+ let keyIndex = undefined;
52
+ if (node.tag === 'devices') {
53
+ (0, WABinary_1.assertNodeErrorFree)(node);
54
+ const deviceListNode = (0, WABinary_1.getBinaryNodeChild)(node, 'device-list');
55
+ const keyIndexNode = (0, WABinary_1.getBinaryNodeChild)(node, 'key-index-list');
56
+ if (Array.isArray(deviceListNode === null || deviceListNode === void 0 ? void 0 : deviceListNode.content)) {
57
+ for (const { tag, attrs } of deviceListNode.content) {
58
+ const id = +attrs.id;
59
+ const keyIndex = +attrs['key-index'];
60
+ if (tag === 'device') {
61
+ deviceList.push({
62
+ id,
63
+ keyIndex,
64
+ isHosted: !!(attrs['is_hosted'] && attrs['is_hosted'] === 'true')
65
+ });
66
+ }
67
+ }
68
+ }
69
+ if ((keyIndexNode === null || keyIndexNode === void 0 ? void 0 : keyIndexNode.tag) === 'key-index-list') {
70
+ keyIndex = {
71
+ timestamp: +keyIndexNode.attrs['ts'],
72
+ signedKeyIndex: keyIndexNode === null || keyIndexNode === void 0 ? void 0 : keyIndexNode.content,
73
+ expectedTimestamp: keyIndexNode.attrs['expected_ts'] ? +keyIndexNode.attrs['expected_ts'] : undefined
74
+ };
75
+ }
76
+ }
77
+ return {
78
+ deviceList,
79
+ keyIndex
80
+ };
81
+ }
82
+ }
83
+ exports.USyncDeviceProtocol = USyncDeviceProtocol;
@@ -0,0 +1,13 @@
1
+ export const __esModule: boolean;
2
+ export class USyncDisappearingModeProtocol {
3
+ name: string;
4
+ getQueryElement(): {
5
+ tag: string;
6
+ attrs: {};
7
+ };
8
+ getUserElement(): any;
9
+ parser(node: any): {
10
+ duration: number;
11
+ setAt: Date;
12
+ };
13
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * ╔═══════════════════════════════════════════════════════════╗
3
+ * ║ NEROX - WhatsApp API Library ║
4
+ * ║ Premium Edition ║
5
+ * ╚═══════════════════════════════════════════════════════════╝
6
+ *
7
+ * @package nerox-bails
8
+ * @version 0.1.0
9
+ * @author NEROX Development Team
10
+ * @copyright Copyright (c) 2025 NEROX. All rights reserved.
11
+ * @license MIT License
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining
14
+ * a copy of this software and associated documentation files (the "Software"),
15
+ * to deal in the Software without restriction, including without limitation
16
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17
+ * and/or sell copies of the Software, and to permit persons to whom the
18
+ * Software is furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included
21
+ * in all copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26
+ */
27
+ "use strict";
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.USyncDisappearingModeProtocol = void 0;
30
+ const WABinary_1 = require("../../WABinary");
31
+ class USyncDisappearingModeProtocol {
32
+ constructor() {
33
+ this.name = 'disappearing_mode';
34
+ }
35
+ getQueryElement() {
36
+ return {
37
+ tag: 'disappearing_mode',
38
+ attrs: {},
39
+ };
40
+ }
41
+ getUserElement() {
42
+ return null;
43
+ }
44
+ parser(node) {
45
+ if (node.tag === 'disappearing_mode') {
46
+ (0, WABinary_1.assertNodeErrorFree)(node);
47
+ const duration = +(node === null || node === void 0 ? void 0 : node.attrs.duration);
48
+ const setAt = new Date(+((node === null || node === void 0 ? void 0 : node.attrs.t) || 0) * 1000);
49
+ return {
50
+ duration,
51
+ setAt,
52
+ };
53
+ }
54
+ }
55
+ }
56
+ exports.USyncDisappearingModeProtocol = USyncDisappearingModeProtocol;
@@ -0,0 +1,13 @@
1
+ export const __esModule: boolean;
2
+ export class USyncStatusProtocol {
3
+ name: string;
4
+ getQueryElement(): {
5
+ tag: string;
6
+ attrs: {};
7
+ };
8
+ getUserElement(): any;
9
+ parser(node: any): {
10
+ status: any;
11
+ setAt: Date;
12
+ };
13
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * ╔═══════════════════════════════════════════════════════════╗
3
+ * ║ NEROX - WhatsApp API Library ║
4
+ * ║ Premium Edition ║
5
+ * ╚═══════════════════════════════════════════════════════════╝
6
+ *
7
+ * @package nerox-bails
8
+ * @version 0.1.0
9
+ * @author NEROX Development Team
10
+ * @copyright Copyright (c) 2025 NEROX. All rights reserved.
11
+ * @license MIT License
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining
14
+ * a copy of this software and associated documentation files (the "Software"),
15
+ * to deal in the Software without restriction, including without limitation
16
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17
+ * and/or sell copies of the Software, and to permit persons to whom the
18
+ * Software is furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included
21
+ * in all copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26
+ */
27
+ "use strict";
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.USyncStatusProtocol = void 0;
30
+ const WABinary_1 = require("../../WABinary");
31
+ class USyncStatusProtocol {
32
+ constructor() {
33
+ this.name = 'status';
34
+ }
35
+ getQueryElement() {
36
+ return {
37
+ tag: 'status',
38
+ attrs: {},
39
+ };
40
+ }
41
+ getUserElement() {
42
+ return null;
43
+ }
44
+ parser(node) {
45
+ var _a, _b, _c;
46
+ if (node.tag === 'status') {
47
+ (0, WABinary_1.assertNodeErrorFree)(node);
48
+ let status = (_b = (_a = node === null || node === void 0 ? void 0 : node.content) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : null;
49
+ const setAt = new Date(+((node === null || node === void 0 ? void 0 : node.attrs.t) || 0) * 1000);
50
+ if (!status) {
51
+ if (+((_c = node.attrs) === null || _c === void 0 ? void 0 : _c.code) === 401) {
52
+ status = '';
53
+ }
54
+ else {
55
+ status = null;
56
+ }
57
+ }
58
+ else if (typeof status === 'string' && status.length === 0) {
59
+ status = null;
60
+ }
61
+ return {
62
+ status,
63
+ setAt,
64
+ };
65
+ }
66
+ }
67
+ }
68
+ exports.USyncStatusProtocol = USyncStatusProtocol;
@@ -0,0 +1,39 @@
1
+ export const __esModule: boolean;
2
+ export class USyncBotProfileProtocol {
3
+ name: string;
4
+ getQueryElement(): {
5
+ tag: string;
6
+ attrs: {};
7
+ content: {
8
+ tag: string;
9
+ attrs: {
10
+ v: string;
11
+ };
12
+ }[];
13
+ };
14
+ getUserElement(user: any): {
15
+ tag: string;
16
+ attrs: {};
17
+ content: {
18
+ tag: string;
19
+ attrs: {
20
+ persona_id: any;
21
+ };
22
+ }[];
23
+ };
24
+ parser(node: any): {
25
+ isDefault: boolean;
26
+ jid: any;
27
+ name: any;
28
+ attributes: any;
29
+ description: any;
30
+ category: any;
31
+ personaId: any;
32
+ commandsDescription: any;
33
+ commands: {
34
+ name: any;
35
+ description: any;
36
+ }[];
37
+ prompts: string[];
38
+ };
39
+ }