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