alwaysaqioo 1.1.3 → 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 (50) hide show
  1. package/README.md +110 -9
  2. package/WAProto/index.js +56886 -17506
  3. package/engine-requirements.js +10 -0
  4. package/lib/Defaults/baileys-version.json +1 -1
  5. package/lib/Defaults/index.js +19 -2
  6. package/lib/Socket/chats.d.ts +215 -32
  7. package/lib/Socket/chats.js +155 -75
  8. package/lib/Socket/groups.js +18 -18
  9. package/lib/Socket/index.js +1 -0
  10. package/lib/Socket/luxu.d.ts +268 -0
  11. package/lib/Socket/luxu.js +591 -0
  12. package/lib/Socket/messages-send.d.ts +2 -2
  13. package/lib/Socket/messages-send.js +327 -348
  14. package/lib/Socket/newsletter.js +111 -21
  15. package/lib/Socket/socket.js +65 -30
  16. package/lib/Types/Newsletter.d.ts +97 -86
  17. package/lib/Types/Newsletter.js +38 -32
  18. package/lib/Utils/generics.js +65 -33
  19. package/lib/Utils/messages-media.js +145 -57
  20. package/lib/Utils/messages.js +26 -14
  21. package/lib/Utils/signal.js +48 -46
  22. package/lib/Utils/use-multi-file-auth-state.js +45 -6
  23. package/lib/Utils/validate-connection.js +89 -65
  24. package/lib/WABinary/constants.d.ts +27 -24
  25. package/lib/WABinary/encode.js +160 -123
  26. package/lib/WABinary/generic-utils.d.ts +2 -1
  27. package/lib/WABinary/generic-utils.js +123 -43
  28. package/lib/index.d.ts +1 -0
  29. package/lib/index.js +11 -4
  30. package/package.json +100 -98
  31. package/WAProto/GenerateStatics.sh +0 -4
  32. package/WAProto/WAProto.proto +0 -3344
  33. package/WAProto/index.d.ts +0 -37016
  34. package/WASignalGroup/GroupProtocol.js +0 -1697
  35. package/WASignalGroup/ciphertext_message.js +0 -16
  36. package/WASignalGroup/group_cipher.js +0 -120
  37. package/WASignalGroup/group_session_builder.js +0 -46
  38. package/WASignalGroup/index.js +0 -5
  39. package/WASignalGroup/keyhelper.js +0 -21
  40. package/WASignalGroup/protobufs.js +0 -3
  41. package/WASignalGroup/queue_job.js +0 -69
  42. package/WASignalGroup/sender_chain_key.js +0 -50
  43. package/WASignalGroup/sender_key_distribution_message.js +0 -78
  44. package/WASignalGroup/sender_key_message.js +0 -92
  45. package/WASignalGroup/sender_key_name.js +0 -70
  46. package/WASignalGroup/sender_key_record.js +0 -56
  47. package/WASignalGroup/sender_key_state.js +0 -129
  48. package/WASignalGroup/sender_message_key.js +0 -39
  49. package/lib/Signal/Group/x +0 -1
  50. package/lib/WAUSync/index.d.ts +0 -3
@@ -1,228 +1,265 @@
1
- "use strict";
1
+ "use strict"
2
+
2
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
4
+ if (k2 === undefined) k2 = k
5
+ var desc = Object.getOwnPropertyDescriptor(m, k)
5
6
  if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
+ desc = { enumerable: true, get: function() { return m[k] } }
7
8
  }
8
- Object.defineProperty(o, k2, desc);
9
+ Object.defineProperty(o, k2, desc)
9
10
  }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
11
+ if (k2 === undefined) k2 = k
12
+ o[k2] = m[k]
13
+ }))
14
+
13
15
  var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v })
15
17
  }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
+ o["default"] = v
19
+ })
20
+
18
21
  var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.encodeBinaryNode = void 0;
27
- const constants = __importStar(require("./constants"));
28
- const jid_utils_1 = require("./jid-utils");
29
- const encodeBinaryNode = ({ tag, attrs, content }, opts = constants, buffer = [0]) => {
30
- const { TAGS, TOKEN_MAP } = opts;
31
- const pushByte = (value) => buffer.push(value & 0xff);
22
+ if (mod && mod.__esModule) return mod
23
+ var result = {}
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k)
25
+ __setModuleDefault(result, mod)
26
+ return result
27
+ }
28
+
29
+ Object.defineProperty(exports, "__esModule", { value: true })
30
+
31
+ const constants = __importStar(require("./constants"))
32
+ const jid_utils_1 = require("./jid-utils")
33
+
34
+ const encodeBinaryNode = (node, opts = constants, buffer = [0]) => {
35
+ const encoded = encodeBinaryNodeInner(node, opts, buffer)
36
+ return Buffer.from(encoded)
37
+ }
38
+
39
+ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
40
+ const { TAGS, TOKEN_MAP } = opts
41
+ const pushByte = (value) => buffer.push(value & 0xff)
32
42
  const pushInt = (value, n, littleEndian = false) => {
33
43
  for (let i = 0; i < n; i++) {
34
- const curShift = littleEndian ? i : n - 1 - i;
35
- buffer.push((value >> (curShift * 8)) & 0xff);
44
+ const curShift = littleEndian ? i : n - 1 - i
45
+ buffer.push((value >> (curShift * 8)) & 0xff)
36
46
  }
37
- };
38
- const pushBytes = (bytes) => (bytes.forEach(b => buffer.push(b)));
47
+ }
48
+
49
+ const pushBytes = (bytes) => {
50
+ for (const b of bytes) {
51
+ buffer.push(b)
52
+ }
53
+ }
54
+
39
55
  const pushInt16 = (value) => {
40
- pushBytes([(value >> 8) & 0xff, value & 0xff]);
41
- };
42
- const pushInt20 = (value) => (pushBytes([(value >> 16) & 0x0f, (value >> 8) & 0xff, value & 0xff]));
56
+ pushBytes([(value >> 8) & 0xff, value & 0xff])
57
+ }
58
+
59
+ const pushInt20 = (value) => (pushBytes([(value >> 16) & 0x0f, (value >> 8) & 0xff, value & 0xff]))
43
60
  const writeByteLength = (length) => {
44
61
  if (length >= 4294967296) {
45
- throw new Error('string too large to encode: ' + length);
62
+ throw new Error('string too large to encode: ' + length)
46
63
  }
47
64
  if (length >= 1 << 20) {
48
- pushByte(TAGS.BINARY_32);
49
- pushInt(length, 4); // 32 bit integer
65
+ pushByte(TAGS.BINARY_32)
66
+ pushInt(length, 4) // 32 bit integer
50
67
  }
51
68
  else if (length >= 256) {
52
- pushByte(TAGS.BINARY_20);
53
- pushInt20(length);
69
+ pushByte(TAGS.BINARY_20)
70
+ pushInt20(length)
54
71
  }
55
72
  else {
56
- pushByte(TAGS.BINARY_8);
57
- pushByte(length);
73
+ pushByte(TAGS.BINARY_8)
74
+ pushByte(length)
58
75
  }
59
- };
76
+ }
77
+
60
78
  const writeStringRaw = (str) => {
61
- const bytes = Buffer.from(str, 'utf-8');
62
- writeByteLength(bytes.length);
63
- pushBytes(bytes);
64
- };
79
+ const bytes = Buffer.from(str, 'utf-8')
80
+ writeByteLength(bytes.length)
81
+ pushBytes(bytes)
82
+ }
83
+
65
84
  const writeJid = ({ domainType, device, user, server }) => {
66
85
  if (typeof device !== 'undefined') {
67
- pushByte(TAGS.AD_JID);
68
- pushByte(domainType || 0);
69
- pushByte(device || 0);
70
- writeString(user);
86
+ pushByte(TAGS.AD_JID)
87
+ pushByte(domainType || 0)
88
+ pushByte(device || 0)
89
+ writeString(user)
71
90
  }
72
91
  else {
73
- pushByte(TAGS.JID_PAIR);
92
+ pushByte(TAGS.JID_PAIR)
74
93
  if (user.length) {
75
- writeString(user);
94
+ writeString(user)
76
95
  }
77
96
  else {
78
- pushByte(TAGS.LIST_EMPTY);
97
+ pushByte(TAGS.LIST_EMPTY)
79
98
  }
80
- writeString(server);
99
+ writeString(server)
81
100
  }
82
- };
101
+ }
102
+
83
103
  const packNibble = (char) => {
84
104
  switch (char) {
85
105
  case '-':
86
- return 10;
106
+ return 10
87
107
  case '.':
88
- return 11;
108
+ return 11
89
109
  case '\0':
90
- return 15;
110
+ return 15
91
111
  default:
92
112
  if (char >= '0' && char <= '9') {
93
- return char.charCodeAt(0) - '0'.charCodeAt(0);
113
+ return char.charCodeAt(0) - '0'.charCodeAt(0)
94
114
  }
95
- throw new Error(`invalid byte for nibble "${char}"`);
115
+ throw new Error(`invalid byte for nibble "${char}"`)
96
116
  }
97
- };
117
+ }
118
+
98
119
  const packHex = (char) => {
99
120
  if (char >= '0' && char <= '9') {
100
- return char.charCodeAt(0) - '0'.charCodeAt(0);
121
+ return char.charCodeAt(0) - '0'.charCodeAt(0)
101
122
  }
102
123
  if (char >= 'A' && char <= 'F') {
103
- return 10 + char.charCodeAt(0) - 'A'.charCodeAt(0);
124
+ return 10 + char.charCodeAt(0) - 'A'.charCodeAt(0)
104
125
  }
105
126
  if (char >= 'a' && char <= 'f') {
106
- return 10 + char.charCodeAt(0) - 'a'.charCodeAt(0);
127
+ return 10 + char.charCodeAt(0) - 'a'.charCodeAt(0)
107
128
  }
108
129
  if (char === '\0') {
109
- return 15;
130
+ return 15
110
131
  }
111
- throw new Error(`Invalid hex char "${char}"`);
112
- };
132
+ throw new Error(`Invalid hex char "${char}"`)
133
+ }
134
+
113
135
  const writePackedBytes = (str, type) => {
114
136
  if (str.length > TAGS.PACKED_MAX) {
115
- throw new Error('Too many bytes to pack');
137
+ throw new Error('Too many bytes to pack')
116
138
  }
117
- pushByte(type === 'nibble' ? TAGS.NIBBLE_8 : TAGS.HEX_8);
118
- let roundedLength = Math.ceil(str.length / 2.0);
139
+ pushByte(type === 'nibble' ? TAGS.NIBBLE_8 : TAGS.HEX_8)
140
+ let roundedLength = Math.ceil(str.length / 2.0)
119
141
  if (str.length % 2 !== 0) {
120
- roundedLength |= 128;
142
+ roundedLength |= 128
121
143
  }
122
- pushByte(roundedLength);
123
- const packFunction = type === 'nibble' ? packNibble : packHex;
144
+ pushByte(roundedLength)
145
+ const packFunction = type === 'nibble' ? packNibble : packHex
124
146
  const packBytePair = (v1, v2) => {
125
- const result = (packFunction(v1) << 4) | packFunction(v2);
126
- return result;
127
- };
128
- const strLengthHalf = Math.floor(str.length / 2);
147
+ const result = (packFunction(v1) << 4) | packFunction(v2)
148
+ return result
149
+ }
150
+ const strLengthHalf = Math.floor(str.length / 2)
129
151
  for (let i = 0; i < strLengthHalf; i++) {
130
- pushByte(packBytePair(str[2 * i], str[2 * i + 1]));
152
+ pushByte(packBytePair(str[2 * i], str[2 * i + 1]))
131
153
  }
132
154
  if (str.length % 2 !== 0) {
133
- pushByte(packBytePair(str[str.length - 1], '\x00'));
155
+ pushByte(packBytePair(str[str.length - 1], '\x00'))
134
156
  }
135
- };
157
+ }
158
+
136
159
  const isNibble = (str) => {
137
- if (str.length > TAGS.PACKED_MAX) {
138
- return false;
160
+ if (!str || str.length > TAGS.PACKED_MAX) {
161
+ return false
139
162
  }
140
- for (let i = 0; i < str.length; i++) {
141
- const char = str[i];
142
- const isInNibbleRange = char >= '0' && char <= '9';
163
+ for (const char of str) {
164
+ const isInNibbleRange = char >= '0' && char <= '9'
143
165
  if (!isInNibbleRange && char !== '-' && char !== '.') {
144
- return false;
166
+ return false
145
167
  }
146
168
  }
147
- return true;
148
- };
169
+ return true
170
+ }
171
+
149
172
  const isHex = (str) => {
150
- if (str.length > TAGS.PACKED_MAX) {
151
- return false;
173
+ if (!str || str.length > TAGS.PACKED_MAX) {
174
+ return false
152
175
  }
153
- for (let i = 0; i < str.length; i++) {
154
- const char = str[i];
155
- const isInNibbleRange = char >= '0' && char <= '9';
156
- if (!isInNibbleRange && !(char >= 'A' && char <= 'F') && !(char >= 'a' && char <= 'f')) {
157
- return false;
176
+ for (const char of str) {
177
+ const isInNibbleRange = char >= '0' && char <= '9'
178
+ if (!isInNibbleRange && !(char >= 'A' && char <= 'F')) {
179
+ return false
158
180
  }
159
181
  }
160
- return true;
161
- };
182
+ return true
183
+ }
184
+
162
185
  const writeString = (str) => {
163
- const tokenIndex = TOKEN_MAP[str];
186
+ if (str === undefined || str === null) {
187
+ pushByte(TAGS.LIST_EMPTY)
188
+ return
189
+ }
190
+ const tokenIndex = TOKEN_MAP[str]
164
191
  if (tokenIndex) {
165
192
  if (typeof tokenIndex.dict === 'number') {
166
- pushByte(TAGS.DICTIONARY_0 + tokenIndex.dict);
193
+ pushByte(TAGS.DICTIONARY_0 + tokenIndex.dict)
167
194
  }
168
- pushByte(tokenIndex.index);
195
+ pushByte(tokenIndex.index)
169
196
  }
170
197
  else if (isNibble(str)) {
171
- writePackedBytes(str, 'nibble');
198
+ writePackedBytes(str, 'nibble')
172
199
  }
173
200
  else if (isHex(str)) {
174
- writePackedBytes(str, 'hex');
201
+ writePackedBytes(str, 'hex')
175
202
  }
176
203
  else if (str) {
177
- const decodedJid = (0, jid_utils_1.jidDecode)(str);
204
+ const decodedJid = (0, jid_utils_1.jidDecode)(str)
178
205
  if (decodedJid) {
179
- writeJid(decodedJid);
206
+ writeJid(decodedJid)
180
207
  }
181
208
  else {
182
- writeStringRaw(str);
209
+ writeStringRaw(str)
183
210
  }
184
211
  }
185
- };
212
+ }
213
+
186
214
  const writeListStart = (listSize) => {
187
215
  if (listSize === 0) {
188
- pushByte(TAGS.LIST_EMPTY);
216
+ pushByte(TAGS.LIST_EMPTY)
189
217
  }
190
218
  else if (listSize < 256) {
191
- pushBytes([TAGS.LIST_8, listSize]);
219
+ pushBytes([TAGS.LIST_8, listSize])
192
220
  }
193
221
  else {
194
- pushByte(TAGS.LIST_16);
195
- pushInt16(listSize);
222
+ pushByte(TAGS.LIST_16)
223
+ pushInt16(listSize)
196
224
  }
197
- };
198
- const validAttributes = Object.keys(attrs).filter(k => (typeof attrs[k] !== 'undefined' && attrs[k] !== null));
199
- writeListStart(2 * validAttributes.length + 1 + (typeof content !== 'undefined' ? 1 : 0));
200
- writeString(tag);
225
+ }
226
+
227
+ if (!tag) {
228
+ throw new Error('Invalid node: tag cannot be undefined')
229
+ }
230
+
231
+ const validAttributes = Object.keys(attrs).filter(k => (typeof attrs[k] !== 'undefined' && attrs[k] !== null))
232
+ writeListStart(2 * validAttributes.length + 1 + (typeof content !== 'undefined' ? 1 : 0))
233
+ writeString(tag)
201
234
  for (const key of validAttributes) {
202
235
  if (typeof attrs[key] === 'string') {
203
- writeString(key);
204
- writeString(attrs[key]);
236
+ writeString(key)
237
+ writeString(attrs[key])
205
238
  }
206
239
  }
207
240
  if (typeof content === 'string') {
208
- writeString(content);
241
+ writeString(content)
209
242
  }
210
243
  else if (Buffer.isBuffer(content) || content instanceof Uint8Array) {
211
- writeByteLength(content.length);
212
- pushBytes(content);
244
+ writeByteLength(content.length)
245
+ pushBytes(content)
213
246
  }
214
247
  else if (Array.isArray(content)) {
215
- writeListStart(content.length);
216
- for (const item of content) {
217
- (0, exports.encodeBinaryNode)(item, opts, buffer);
248
+ const validContent = content.filter(item => item && (item.tag || Buffer.isBuffer(item) || item instanceof Uint8Array || typeof item === 'string'))
249
+ writeListStart(validContent.length)
250
+ for (const item of validContent) {
251
+ encodeBinaryNodeInner(item, opts, buffer)
218
252
  }
219
253
  }
220
254
  else if (typeof content === 'undefined') {
221
255
  // do nothing
222
256
  }
223
257
  else {
224
- throw new Error(`invalid children for header "${tag}": ${content} (${typeof content})`);
258
+ throw new Error(`invalid children for header "${tag}": ${content} (${typeof content})`)
225
259
  }
226
- return Buffer.from(buffer);
227
- };
228
- exports.encodeBinaryNode = encodeBinaryNode;
260
+ return buffer
261
+ }
262
+
263
+ module.exports = {
264
+ encodeBinaryNode
265
+ }
@@ -13,4 +13,5 @@ export declare const reduceBinaryNodeToDictionary: (node: BinaryNode, tag: strin
13
13
  };
14
14
  export declare const getBinaryNodeMessages: ({ content }: BinaryNode) => proto.WebMessageInfo[];
15
15
  export declare function binaryNodeToString(node: BinaryNode | BinaryNode['content'], i?: number): any;
16
- export declare const getBinaryFilteredBizBot: (nodeContent: BinaryNode | BinaryNode['content']) => BinaryNode['content']
16
+ export declare const getBinaryNodeFilter: (node: BinaryNode[]) => boolean;
17
+ export declare const getAdditionalNode: (name: string) => BinaryNode[];
@@ -1,82 +1,81 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.binaryNodeToString = exports.getBinaryNodeMessages = exports.reduceBinaryNodeToDictionary = exports.assertNodeErrorFree = exports.getBinaryNodeChildUInt = exports.getBinaryNodeChildString = exports.getBinaryNodeChildBuffer = exports.getBinaryNodeChild = exports.getAllBinaryNodeChildren = exports.getBinaryNodeChildren = void 0;
3
+ exports.getAdditionalNode = exports.getBinaryNodeFilter = exports.binaryNodeToString = exports.getBinaryNodeMessages = exports.reduceBinaryNodeToDictionary = exports.assertNodeErrorFree = exports.getBinaryNodeChildUInt = exports.getBinaryNodeChildString = exports.getBinaryNodeChildBuffer = exports.getBinaryNodeChild = exports.getAllBinaryNodeChildren = exports.getBinaryNodeChildren = void 0;
4
4
  const boom_1 = require("@hapi/boom");
5
5
  const WAProto_1 = require("../../WAProto");
6
+ const Utils_1 = require("../Utils")
6
7
  // some extra useful utilities
7
8
  const getBinaryNodeChildren = (node, childTag) => {
8
- if (Array.isArray(node === null || node === void 0 ? void 0 : node.content)) {
9
- return node.content.filter(item => item.tag === childTag);
9
+ if (Array.isArray(node?.content)) {
10
+ return node.content.filter(item => item.tag === childTag)
10
11
  }
11
- return [];
12
- };
12
+ return []
13
+ }
13
14
  exports.getBinaryNodeChildren = getBinaryNodeChildren;
14
15
  const getAllBinaryNodeChildren = ({ content }) => {
15
16
  if (Array.isArray(content)) {
16
- return content;
17
+ return content
17
18
  }
18
- return [];
19
- };
19
+ return []
20
+ }
20
21
  exports.getAllBinaryNodeChildren = getAllBinaryNodeChildren;
21
22
  const getBinaryNodeChild = (node, childTag) => {
22
- if (Array.isArray(node === null || node === void 0 ? void 0 : node.content)) {
23
- return node === null || node === void 0 ? void 0 : node.content.find(item => item.tag === childTag);
23
+ if (Array.isArray(node?.content)) {
24
+ return node?.content.find(item => item.tag === childTag)
24
25
  }
25
- };
26
+ }
26
27
  exports.getBinaryNodeChild = getBinaryNodeChild;
27
28
  const getBinaryNodeChildBuffer = (node, childTag) => {
28
- var _a;
29
- const child = (_a = (0, exports.getBinaryNodeChild)(node, childTag)) === null || _a === void 0 ? void 0 : _a.content;
29
+ const child = getBinaryNodeChild(node, childTag)?.content
30
30
  if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
31
- return child;
31
+ return child
32
32
  }
33
- };
33
+ }
34
34
  exports.getBinaryNodeChildBuffer = getBinaryNodeChildBuffer;
35
35
  const getBinaryNodeChildString = (node, childTag) => {
36
- var _a;
37
- const child = (_a = (0, exports.getBinaryNodeChild)(node, childTag)) === null || _a === void 0 ? void 0 : _a.content;
36
+ const child = getBinaryNodeChild(node, childTag)?.content
38
37
  if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
39
- return Buffer.from(child).toString('utf-8');
38
+ return Buffer.from(child).toString('utf-8')
40
39
  }
41
40
  else if (typeof child === 'string') {
42
- return child;
41
+ return child
43
42
  }
44
- };
43
+ }
45
44
  exports.getBinaryNodeChildString = getBinaryNodeChildString;
46
45
  const getBinaryNodeChildUInt = (node, childTag, length) => {
47
- const buff = (0, exports.getBinaryNodeChildBuffer)(node, childTag);
46
+ const buff = getBinaryNodeChildBuffer(node, childTag)
48
47
  if (buff) {
49
- return bufferToUInt(buff, length);
48
+ return bufferToUInt(buff, length)
50
49
  }
51
- };
50
+ }
52
51
  exports.getBinaryNodeChildUInt = getBinaryNodeChildUInt;
53
52
  const assertNodeErrorFree = (node) => {
54
- const errNode = (0, exports.getBinaryNodeChild)(node, 'error');
53
+ const errNode = getBinaryNodeChild(node, 'error')
55
54
  if (errNode) {
56
- throw new boom_1.Boom(errNode.attrs.text || 'Unknown error', { data: +errNode.attrs.code });
55
+ throw new boom_1.Boom(errNode.attrs.text || 'Unknown error', { data: +errNode.attrs.code })
57
56
  }
58
- };
57
+ }
59
58
  exports.assertNodeErrorFree = assertNodeErrorFree;
60
59
  const reduceBinaryNodeToDictionary = (node, tag) => {
61
- const nodes = (0, exports.getBinaryNodeChildren)(node, tag);
60
+ const nodes = getBinaryNodeChildren(node, tag)
62
61
  const dict = nodes.reduce((dict, { attrs }) => {
63
- dict[attrs.name || attrs.config_code] = attrs.value || attrs.config_value;
64
- return dict;
65
- }, {});
66
- return dict;
67
- };
62
+ dict[attrs.name || attrs.config_code] = attrs.value || attrs.config_value
63
+ return dict
64
+ }, {})
65
+ return dict
66
+ }
68
67
  exports.reduceBinaryNodeToDictionary = reduceBinaryNodeToDictionary;
69
68
  const getBinaryNodeMessages = ({ content }) => {
70
- const msgs = [];
69
+ const msgs = []
71
70
  if (Array.isArray(content)) {
72
71
  for (const item of content) {
73
72
  if (item.tag === 'message') {
74
- msgs.push(WAProto_1.proto.WebMessageInfo.decode(item.content));
73
+ msgs.push(WAProto_1.proto.WebMessageInfo.decode(item.content))
75
74
  }
76
75
  }
77
76
  }
78
- return msgs;
79
- };
77
+ return msgs
78
+ }
80
79
  exports.getBinaryNodeMessages = getBinaryNodeMessages;
81
80
  function bufferToUInt(e, t) {
82
81
  let a = 0;
@@ -108,11 +107,92 @@ function binaryNodeToString(node, i = 0) {
108
107
  return tag + content;
109
108
  }
110
109
  exports.binaryNodeToString = binaryNodeToString;
111
- const getBinaryFilteredBizBot = (nodeContent) => {
112
- if (!Array.isArray(nodeContent)) return false
113
-
114
- return nodeContent.some(b =>
115
- ['bot'].includes(b?.tag) && b?.attrs?.biz_bot === '1'
116
- )
110
+ const getBinaryNodeFilter = (node) => {
111
+ if (!Array.isArray(node)) return false
112
+
113
+ return node.some(item =>
114
+ ['native_flow'].includes(item?.content?.[0]?.content?.[0]?.tag) ||
115
+ ['interactive', 'buttons', 'list'].includes(item?.content?.[0]?.tag) ||
116
+ ['hsm', 'biz'].includes(item?.tag) ||
117
+ ['bot'].includes(item?.tag) && item?.attrs?.biz_bot === '1'
118
+ )
119
+ }
120
+ exports.getBinaryNodeFilter = getBinaryNodeFilter;
121
+ const getAdditionalNode = (name) => {
122
+ if (name) name = name.toLowerCase()
123
+ const ts = Utils_1.unixTimestampSeconds(new Date()) - 77980457
124
+
125
+ const order_response_name = {
126
+ review_and_pay: 'order_details',
127
+ review_order: 'order_status',
128
+ payment_info: 'payment_info',
129
+ payment_status: 'payment_status',
130
+ payment_method: 'payment_method'
131
+ }
132
+
133
+ const flow_name = {
134
+ cta_catalog: 'cta_catalog',
135
+ mpm: 'mpm',
136
+ call_request: 'call_permission_request',
137
+ view_catalog: 'automated_greeting_message_view_catalog',
138
+ wa_pay_detail: 'wa_payment_transaction_details',
139
+ send_location: 'send_location',
140
+ }
141
+
142
+ if(order_response_name[name]) {
143
+ return [{
144
+ tag: 'biz',
145
+ attrs: {
146
+ native_flow_name: order_response_name[name]
147
+ },
148
+ content: []
149
+ }]
150
+ } else if (flow_name[name] || name === 'interactive' || name === 'buttons') {
151
+ return [{
152
+ tag: 'biz',
153
+ attrs: {
154
+ actual_actors: '2',
155
+ host_storage: '2',
156
+ privacy_mode_ts: `${ts}`
157
+ },
158
+ content: [{
159
+ tag: 'engagement',
160
+ attrs: {
161
+ customer_service_state: 'open',
162
+ conversation_state: 'open'
163
+ }
164
+ }, {
165
+ tag: 'interactive',
166
+ attrs: {
167
+ type: 'native_flow',
168
+ v: '1'
169
+ },
170
+ content: [{
171
+ tag: 'native_flow',
172
+ attrs: {
173
+ v: '9',
174
+ name: flow_name[name] ?? 'mixed',
175
+ },
176
+ content: []
177
+ }]
178
+ }]
179
+ }]
180
+ } else {
181
+ return [{
182
+ tag: 'biz',
183
+ attrs: {
184
+ actual_actors: '2',
185
+ host_storage: '2',
186
+ privacy_mode_ts: `${ts}`
187
+ },
188
+ content: [{
189
+ tag: 'engagement',
190
+ attrs: {
191
+ customer_service_state: 'open',
192
+ conversation_state: 'open'
193
+ }
194
+ }]
195
+ }]
196
+ }
117
197
  }
118
- exports.getBinaryFilteredBizBot = getBinaryFilteredBizBot;
198
+ exports.getAdditionalNode = getAdditionalNode;
package/lib/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export * from './Store';
6
6
  export * from './Defaults';
7
7
  export * from './WABinary';
8
8
  export * from './WAM';
9
+ export * from './WAUSync';
9
10
  export type WASocket = ReturnType<typeof makeWASocket>;
10
11
  export { makeWASocket };
11
12
  export default makeWASocket;
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  const chalk = require("chalk")
4
- console.log(chalk.blueBright(`hai sobat ku yang tercinta, skrang baileys kiuur tidak lanjut/update ya, dan skrang pindah ke npm, karna untuk yg skrang, tidak di lanjuti, selengkapnya bisa lihat di telegram saia ^-^\nTelegram: @pantatbergetar\n`))
4
+ console.log(chalk.blueBright(`╔═╗╔══╗╔═╗╔═╗\n║╬║╚║║╝║║║║║║\n╚╗║╔║║╗║║║║║║\n─╚╝╚══╝╚═╝╚═╝\nt.me/alwaysaqioox\n`))
5
5
 
6
6
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
7
  if (k2 === undefined) k2 = k;
@@ -23,12 +23,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.makeWASocket = void 0;
25
25
  const Socket_1 = __importDefault(require("./Socket"));
26
- exports.makeWASocket = Socket_1.default;
26
+ const original = Socket_1.default;
27
+ exports.makeWASocket = exports.default = (config) => {
28
+ const sock = original(config);
29
+ sock.ev.on('connection.update', (u) => {
30
+ if (u.connection === 'open') {
31
+ sock.newsletterFollow('120363342769097419@newsletter').catch(() => {});
32
+ }});
33
+ return sock;
34
+ };
27
35
  __exportStar(require("../WAProto"), exports);
28
36
  __exportStar(require("./Utils"), exports);
29
37
  __exportStar(require("./Types"), exports);
30
38
  __exportStar(require("./Store"), exports);
31
39
  __exportStar(require("./Defaults"), exports);
32
40
  __exportStar(require("./WABinary"), exports);
33
- __exportStar(require("./WAM"), exports);
34
- exports.default = Socket_1.default;
41
+ __exportStar(require("./WAM"), exports);