@baileys-md/baileys 11.0.3 → 11.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/WAProto/index.js +4182 -13516
- 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/{lib/Signal/Group/sender-message-key.js → WASignalGroup/sender_message_key.js} +16 -4
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.js +71 -52
- package/lib/Defaults/{phonenumber-mcc.js → phonenumber-mcc.json} +1 -1
- package/lib/Signal/libsignal.js +61 -41
- package/lib/Socket/Client/abstract-socket-client.js +13 -0
- package/lib/Socket/Client/index.js +19 -3
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/web-socket-client.js +62 -0
- package/lib/Socket/business.js +42 -37
- package/lib/Socket/chats.js +187 -194
- package/lib/Socket/groups.js +90 -87
- package/lib/Socket/index.js +8 -7
- package/lib/Socket/messages-recv.js +335 -360
- package/lib/Socket/messages-send.js +279 -156
- package/lib/Socket/newsletter.js +213 -144
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.js +161 -128
- package/lib/Socket/usync.js +26 -19
- package/lib/Store/index.js +8 -0
- package/lib/Store/make-cache-manager-store.js +83 -0
- package/lib/{Utils → Store}/make-in-memory-store.js +27 -19
- package/lib/Store/make-mongo-store.js +567 -0
- package/lib/{Utils → Store}/make-ordered-dictionary.js +5 -2
- package/lib/{Utils → Store}/object-repository.js +4 -1
- package/lib/Types/Auth.js +2 -2
- package/lib/Types/Call.js +2 -2
- package/lib/Types/Chat.js +4 -8
- package/lib/Types/Contact.js +2 -2
- package/lib/Types/Events.js +2 -2
- package/lib/Types/GroupMetadata.js +2 -2
- package/lib/Types/Label.js +5 -3
- package/lib/Types/LabelAssociation.js +5 -3
- package/lib/Types/Message.js +7 -7
- package/lib/Types/Newsletter.js +17 -30
- package/lib/Types/Product.js +2 -2
- package/lib/Types/Signal.js +2 -2
- package/lib/Types/Socket.js +2 -3
- package/lib/Types/State.js +2 -2
- package/lib/Types/USync.js +2 -2
- package/lib/Types/index.js +31 -15
- package/lib/Utils/auth-utils.js +47 -31
- package/lib/Utils/baileys-event-stream.js +22 -15
- package/lib/Utils/business.js +69 -66
- package/lib/Utils/chat-utils.js +195 -200
- package/lib/Utils/crypto.js +85 -70
- package/lib/Utils/decode-wa-message.js +51 -46
- package/lib/Utils/event-buffer.js +46 -36
- package/lib/Utils/generics.js +188 -116
- package/lib/Utils/history.js +46 -37
- package/lib/Utils/index.js +33 -19
- package/lib/Utils/link-preview.js +55 -14
- package/lib/Utils/logger.js +7 -3
- package/lib/Utils/lt-hash.js +26 -23
- package/lib/Utils/make-mutex.js +10 -7
- package/lib/Utils/messages-media.js +368 -239
- package/lib/Utils/messages.js +510 -278
- package/lib/Utils/noise-handler.js +31 -22
- package/lib/Utils/process-message.js +148 -144
- package/lib/Utils/signal.js +64 -71
- package/lib/Utils/use-multi-file-auth-state.js +32 -14
- package/lib/Utils/validate-connection.js +115 -72
- package/lib/WABinary/constants.js +20 -1281
- package/lib/WABinary/decode.js +52 -15
- package/lib/WABinary/encode.js +48 -14
- package/lib/WABinary/generic-utils.js +39 -31
- package/lib/WABinary/index.js +21 -6
- package/lib/WABinary/jid-utils.js +40 -23
- package/lib/WABinary/types.js +2 -2
- package/lib/WAM/BinaryInfo.js +5 -2
- package/lib/WAM/constants.js +2366 -2257
- package/lib/WAM/encode.js +21 -17
- package/lib/WAM/index.js +19 -4
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +11 -8
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +14 -11
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +12 -9
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +13 -9
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +22 -20
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +6 -3
- package/lib/WAUSync/Protocols/index.js +20 -5
- package/lib/WAUSync/USyncQuery.js +32 -34
- package/lib/WAUSync/USyncUser.js +5 -2
- package/lib/WAUSync/index.js +19 -4
- package/lib/index.js +33 -11
- package/package.json +61 -21
- package/WAProto/GenerateStatics.sh +0 -3
- package/WAProto/WAProto.proto +0 -4633
- package/WAProto/fix-imports.js +0 -29
- package/lib/Defaults/baileys-version.js +0 -1
- package/lib/Signal/Group/ciphertext-message.js +0 -12
- package/lib/Signal/Group/group-session-builder.js +0 -30
- package/lib/Signal/Group/group_cipher.js +0 -94
- package/lib/Signal/Group/index.js +0 -12
- package/lib/Signal/Group/keyhelper.js +0 -19
- package/lib/Signal/Group/queue-job.js +0 -54
- package/lib/Signal/Group/sender-chain-key.js +0 -32
- package/lib/Signal/Group/sender-key-distribution-message.js +0 -63
- package/lib/Signal/Group/sender-key-message.js +0 -67
- package/lib/Signal/Group/sender-key-name.js +0 -48
- package/lib/Signal/Group/sender-key-record.js +0 -50
- package/lib/Signal/Group/sender-key-state.js +0 -96
- package/lib/Socket/Client/types.js +0 -11
- package/lib/Socket/Client/websocket.js +0 -50
- package/lib/Socket/communities.js +0 -351
- package/lib/Socket/mex.js +0 -42
package/lib/WAM/encode.js
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeWAM = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
3
5
|
const getHeaderBitLength = (key) => (key < 256 ? 2 : 3);
|
|
4
|
-
|
|
6
|
+
const encodeWAM = (binaryInfo) => {
|
|
5
7
|
binaryInfo.buffer = [];
|
|
6
8
|
encodeWAMHeader(binaryInfo);
|
|
7
9
|
encodeEvents(binaryInfo);
|
|
8
10
|
console.log(binaryInfo.buffer);
|
|
9
|
-
const totalSize = binaryInfo.buffer
|
|
11
|
+
const totalSize = binaryInfo.buffer
|
|
12
|
+
.map((a) => a.length)
|
|
13
|
+
.reduce((a, b) => a + b);
|
|
10
14
|
const buffer = Buffer.alloc(totalSize);
|
|
11
15
|
let offset = 0;
|
|
12
|
-
|
|
16
|
+
binaryInfo.buffer.forEach((buffer_) => {
|
|
13
17
|
buffer_.copy(buffer, offset);
|
|
14
18
|
offset += buffer_.length;
|
|
15
|
-
}
|
|
19
|
+
});
|
|
16
20
|
return buffer;
|
|
17
21
|
};
|
|
22
|
+
exports.encodeWAM = encodeWAM;
|
|
18
23
|
function encodeWAMHeader(binaryInfo) {
|
|
19
24
|
const headerBuffer = Buffer.alloc(8); // starting buffer
|
|
20
25
|
headerBuffer.write('WAM', 0, 'utf8');
|
|
@@ -26,34 +31,34 @@ function encodeWAMHeader(binaryInfo) {
|
|
|
26
31
|
}
|
|
27
32
|
function encodeGlobalAttributes(binaryInfo, globals) {
|
|
28
33
|
for (const [key, _value] of Object.entries(globals)) {
|
|
29
|
-
const id = WEB_GLOBALS.find(a => a
|
|
34
|
+
const id = constants_1.WEB_GLOBALS.find(a => (a === null || a === void 0 ? void 0 : a.name) === key).id;
|
|
30
35
|
let value = _value;
|
|
31
36
|
if (typeof value === 'boolean') {
|
|
32
37
|
value = value ? 1 : 0;
|
|
33
38
|
}
|
|
34
|
-
binaryInfo.buffer.push(serializeData(id, value, FLAG_GLOBAL));
|
|
39
|
+
binaryInfo.buffer.push(serializeData(id, value, constants_1.FLAG_GLOBAL));
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
42
|
function encodeEvents(binaryInfo) {
|
|
38
|
-
for (const [name, { props, globals }] of binaryInfo.events.map(a => Object.entries(a)[0])) {
|
|
43
|
+
for (const [name, { props, globals },] of binaryInfo.events.map((a) => Object.entries(a)[0])) {
|
|
39
44
|
encodeGlobalAttributes(binaryInfo, globals);
|
|
40
|
-
const event = WEB_EVENTS.find(a => a.name === name);
|
|
45
|
+
const event = constants_1.WEB_EVENTS.find((a) => a.name === name);
|
|
41
46
|
const props_ = Object.entries(props);
|
|
42
47
|
let extended = false;
|
|
43
48
|
for (const [, value] of props_) {
|
|
44
49
|
extended || (extended = value !== null);
|
|
45
50
|
}
|
|
46
|
-
const eventFlag = extended ? FLAG_EVENT : FLAG_EVENT | FLAG_EXTENDED;
|
|
51
|
+
const eventFlag = extended ? constants_1.FLAG_EVENT : constants_1.FLAG_EVENT | constants_1.FLAG_EXTENDED;
|
|
47
52
|
binaryInfo.buffer.push(serializeData(event.id, -event.weight, eventFlag));
|
|
48
53
|
for (let i = 0; i < props_.length; i++) {
|
|
49
54
|
const [key, _value] = props_[i];
|
|
50
|
-
const id = event.props[key]
|
|
51
|
-
extended = i < props_.length - 1;
|
|
55
|
+
const id = (event.props)[key][0];
|
|
56
|
+
extended = i < (props_.length - 1);
|
|
52
57
|
let value = _value;
|
|
53
58
|
if (typeof value === 'boolean') {
|
|
54
59
|
value = value ? 1 : 0;
|
|
55
60
|
}
|
|
56
|
-
const fieldFlag = extended ? FLAG_EVENT : FLAG_FIELD | FLAG_EXTENDED;
|
|
61
|
+
const fieldFlag = extended ? constants_1.FLAG_EVENT : constants_1.FLAG_FIELD | constants_1.FLAG_EXTENDED;
|
|
57
62
|
binaryInfo.buffer.push(serializeData(id, value, fieldFlag));
|
|
58
63
|
}
|
|
59
64
|
}
|
|
@@ -63,7 +68,7 @@ function serializeData(key, value, flag) {
|
|
|
63
68
|
let buffer;
|
|
64
69
|
let offset = 0;
|
|
65
70
|
if (value === null) {
|
|
66
|
-
if (flag === FLAG_GLOBAL) {
|
|
71
|
+
if (flag === constants_1.FLAG_GLOBAL) {
|
|
67
72
|
buffer = Buffer.alloc(bufferLength);
|
|
68
73
|
offset = serializeHeader(buffer, offset, key, flag);
|
|
69
74
|
return buffer;
|
|
@@ -141,11 +146,10 @@ function serializeHeader(buffer, offset, key, flag) {
|
|
|
141
146
|
offset += 1;
|
|
142
147
|
}
|
|
143
148
|
else {
|
|
144
|
-
buffer.writeUInt8(flag | FLAG_BYTE, offset);
|
|
149
|
+
buffer.writeUInt8(flag | constants_1.FLAG_BYTE, offset);
|
|
145
150
|
offset += 1;
|
|
146
151
|
buffer.writeUInt16LE(key, offset);
|
|
147
152
|
offset += 2;
|
|
148
153
|
}
|
|
149
154
|
return offset;
|
|
150
155
|
}
|
|
151
|
-
//# sourceMappingURL=encode.js.map
|
package/lib/WAM/index.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
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);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./constants"), exports);
|
|
18
|
+
__exportStar(require("./encode"), exports);
|
|
19
|
+
__exportStar(require("./BinaryInfo"), exports);
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.USyncContactProtocol = void 0;
|
|
4
|
+
const WABinary_1 = require("../../WABinary");
|
|
5
|
+
class USyncContactProtocol {
|
|
4
6
|
constructor() {
|
|
5
7
|
this.name = 'contact';
|
|
6
8
|
}
|
|
7
9
|
getQueryElement() {
|
|
8
10
|
return {
|
|
9
11
|
tag: 'contact',
|
|
10
|
-
attrs: {}
|
|
12
|
+
attrs: {},
|
|
11
13
|
};
|
|
12
14
|
}
|
|
13
15
|
getUserElement(user) {
|
|
@@ -15,15 +17,16 @@ export class USyncContactProtocol {
|
|
|
15
17
|
return {
|
|
16
18
|
tag: 'contact',
|
|
17
19
|
attrs: {},
|
|
18
|
-
content: user.phone
|
|
20
|
+
content: user.phone,
|
|
19
21
|
};
|
|
20
22
|
}
|
|
21
23
|
parser(node) {
|
|
24
|
+
var _a;
|
|
22
25
|
if (node.tag === 'contact') {
|
|
23
|
-
assertNodeErrorFree(node);
|
|
24
|
-
return node
|
|
26
|
+
(0, WABinary_1.assertNodeErrorFree)(node);
|
|
27
|
+
return ((_a = node === null || node === void 0 ? void 0 : node.attrs) === null || _a === void 0 ? void 0 : _a.type) === 'in';
|
|
25
28
|
}
|
|
26
29
|
return false;
|
|
27
30
|
}
|
|
28
31
|
}
|
|
29
|
-
|
|
32
|
+
exports.USyncContactProtocol = USyncContactProtocol;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.USyncDeviceProtocol = void 0;
|
|
4
|
+
const WABinary_1 = require("../../WABinary");
|
|
5
|
+
class USyncDeviceProtocol {
|
|
3
6
|
constructor() {
|
|
4
7
|
this.name = 'devices';
|
|
5
8
|
}
|
|
@@ -7,8 +10,8 @@ export class USyncDeviceProtocol {
|
|
|
7
10
|
return {
|
|
8
11
|
tag: 'devices',
|
|
9
12
|
attrs: {
|
|
10
|
-
version: '2'
|
|
11
|
-
}
|
|
13
|
+
version: '2',
|
|
14
|
+
},
|
|
12
15
|
};
|
|
13
16
|
}
|
|
14
17
|
getUserElement( /* user: USyncUser */) {
|
|
@@ -21,10 +24,10 @@ export class USyncDeviceProtocol {
|
|
|
21
24
|
const deviceList = [];
|
|
22
25
|
let keyIndex = undefined;
|
|
23
26
|
if (node.tag === 'devices') {
|
|
24
|
-
assertNodeErrorFree(node);
|
|
25
|
-
const deviceListNode = getBinaryNodeChild(node, 'device-list');
|
|
26
|
-
const keyIndexNode = getBinaryNodeChild(node, 'key-index-list');
|
|
27
|
-
if (Array.isArray(deviceListNode
|
|
27
|
+
(0, WABinary_1.assertNodeErrorFree)(node);
|
|
28
|
+
const deviceListNode = (0, WABinary_1.getBinaryNodeChild)(node, 'device-list');
|
|
29
|
+
const keyIndexNode = (0, WABinary_1.getBinaryNodeChild)(node, 'key-index-list');
|
|
30
|
+
if (Array.isArray(deviceListNode === null || deviceListNode === void 0 ? void 0 : deviceListNode.content)) {
|
|
28
31
|
for (const { tag, attrs } of deviceListNode.content) {
|
|
29
32
|
const id = +attrs.id;
|
|
30
33
|
const keyIndex = +attrs['key-index'];
|
|
@@ -37,10 +40,10 @@ export class USyncDeviceProtocol {
|
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
}
|
|
40
|
-
if (keyIndexNode
|
|
43
|
+
if ((keyIndexNode === null || keyIndexNode === void 0 ? void 0 : keyIndexNode.tag) === 'key-index-list') {
|
|
41
44
|
keyIndex = {
|
|
42
45
|
timestamp: +keyIndexNode.attrs['ts'],
|
|
43
|
-
signedKeyIndex: keyIndexNode
|
|
46
|
+
signedKeyIndex: keyIndexNode === null || keyIndexNode === void 0 ? void 0 : keyIndexNode.content,
|
|
44
47
|
expectedTimestamp: keyIndexNode.attrs['expected_ts'] ? +keyIndexNode.attrs['expected_ts'] : undefined
|
|
45
48
|
};
|
|
46
49
|
}
|
|
@@ -51,4 +54,4 @@ export class USyncDeviceProtocol {
|
|
|
51
54
|
};
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
|
-
|
|
57
|
+
exports.USyncDeviceProtocol = USyncDeviceProtocol;
|
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.USyncDisappearingModeProtocol = void 0;
|
|
4
|
+
const WABinary_1 = require("../../WABinary");
|
|
5
|
+
class USyncDisappearingModeProtocol {
|
|
3
6
|
constructor() {
|
|
4
7
|
this.name = 'disappearing_mode';
|
|
5
8
|
}
|
|
6
9
|
getQueryElement() {
|
|
7
10
|
return {
|
|
8
11
|
tag: 'disappearing_mode',
|
|
9
|
-
attrs: {}
|
|
12
|
+
attrs: {},
|
|
10
13
|
};
|
|
11
14
|
}
|
|
12
15
|
getUserElement() {
|
|
13
16
|
return null;
|
|
14
17
|
}
|
|
15
18
|
parser(node) {
|
|
16
|
-
if (node.tag === '
|
|
17
|
-
assertNodeErrorFree(node);
|
|
18
|
-
const duration = +node
|
|
19
|
-
const setAt = new Date(+(node
|
|
19
|
+
if (node.tag === 'status') {
|
|
20
|
+
(0, WABinary_1.assertNodeErrorFree)(node);
|
|
21
|
+
const duration = +(node === null || node === void 0 ? void 0 : node.attrs.duration);
|
|
22
|
+
const setAt = new Date(+((node === null || node === void 0 ? void 0 : node.attrs.t) || 0) * 1000);
|
|
20
23
|
return {
|
|
21
24
|
duration,
|
|
22
|
-
setAt
|
|
25
|
+
setAt,
|
|
23
26
|
};
|
|
24
27
|
}
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
|
-
|
|
30
|
+
exports.USyncDisappearingModeProtocol = USyncDisappearingModeProtocol;
|
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.USyncStatusProtocol = void 0;
|
|
4
|
+
const WABinary_1 = require("../../WABinary");
|
|
5
|
+
class USyncStatusProtocol {
|
|
3
6
|
constructor() {
|
|
4
7
|
this.name = 'status';
|
|
5
8
|
}
|
|
6
9
|
getQueryElement() {
|
|
7
10
|
return {
|
|
8
11
|
tag: 'status',
|
|
9
|
-
attrs: {}
|
|
12
|
+
attrs: {},
|
|
10
13
|
};
|
|
11
14
|
}
|
|
12
15
|
getUserElement() {
|
|
13
16
|
return null;
|
|
14
17
|
}
|
|
15
18
|
parser(node) {
|
|
19
|
+
var _a;
|
|
16
20
|
if (node.tag === 'status') {
|
|
17
|
-
assertNodeErrorFree(node);
|
|
18
|
-
let status = node
|
|
19
|
-
const setAt = new Date(+(node
|
|
21
|
+
(0, WABinary_1.assertNodeErrorFree)(node);
|
|
22
|
+
let status = node === null || node === void 0 ? void 0 : node.content.toString();
|
|
23
|
+
const setAt = new Date(+((node === null || node === void 0 ? void 0 : node.attrs.t) || 0) * 1000);
|
|
20
24
|
if (!status) {
|
|
21
|
-
if (node.attrs
|
|
25
|
+
if (+((_a = node.attrs) === null || _a === void 0 ? void 0 : _a.code) === 401) {
|
|
22
26
|
status = '';
|
|
23
27
|
}
|
|
24
28
|
else {
|
|
@@ -30,9 +34,9 @@ export class USyncStatusProtocol {
|
|
|
30
34
|
}
|
|
31
35
|
return {
|
|
32
36
|
status,
|
|
33
|
-
setAt
|
|
37
|
+
setAt,
|
|
34
38
|
};
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
|
-
|
|
42
|
+
exports.USyncStatusProtocol = USyncStatusProtocol;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.USyncBotProfileProtocol = void 0;
|
|
4
|
+
const WABinary_1 = require("../../WABinary");
|
|
5
|
+
class USyncBotProfileProtocol {
|
|
4
6
|
constructor() {
|
|
5
7
|
this.name = 'bot';
|
|
6
8
|
}
|
|
@@ -15,37 +17,37 @@ export class USyncBotProfileProtocol {
|
|
|
15
17
|
return {
|
|
16
18
|
tag: 'bot',
|
|
17
19
|
attrs: {},
|
|
18
|
-
content: [{ tag: 'profile', attrs: { persona_id: user.personaId } }]
|
|
20
|
+
content: [{ tag: 'profile', attrs: { 'persona_id': user.personaId } }]
|
|
19
21
|
};
|
|
20
22
|
}
|
|
21
23
|
parser(node) {
|
|
22
|
-
const botNode = getBinaryNodeChild(node, 'bot');
|
|
23
|
-
const profile = getBinaryNodeChild(botNode, 'profile');
|
|
24
|
-
const commandsNode = getBinaryNodeChild(profile, 'commands');
|
|
25
|
-
const promptsNode = getBinaryNodeChild(profile, 'prompts');
|
|
24
|
+
const botNode = (0, WABinary_1.getBinaryNodeChild)(node, 'bot');
|
|
25
|
+
const profile = (0, WABinary_1.getBinaryNodeChild)(botNode, 'profile');
|
|
26
|
+
const commandsNode = (0, WABinary_1.getBinaryNodeChild)(profile, 'commands');
|
|
27
|
+
const promptsNode = (0, WABinary_1.getBinaryNodeChild)(profile, 'prompts');
|
|
26
28
|
const commands = [];
|
|
27
29
|
const prompts = [];
|
|
28
|
-
for (const command of getBinaryNodeChildren(commandsNode, 'command')) {
|
|
30
|
+
for (const command of (0, WABinary_1.getBinaryNodeChildren)(commandsNode, 'command')) {
|
|
29
31
|
commands.push({
|
|
30
|
-
name: getBinaryNodeChildString(command, 'name'),
|
|
31
|
-
description: getBinaryNodeChildString(command, 'description')
|
|
32
|
+
name: (0, WABinary_1.getBinaryNodeChildString)(command, 'name'),
|
|
33
|
+
description: (0, WABinary_1.getBinaryNodeChildString)(command, 'description')
|
|
32
34
|
});
|
|
33
35
|
}
|
|
34
|
-
for (const prompt of getBinaryNodeChildren(promptsNode, 'prompt')) {
|
|
35
|
-
prompts.push(`${getBinaryNodeChildString(prompt, 'emoji')} ${getBinaryNodeChildString(prompt, 'text')}`);
|
|
36
|
+
for (const prompt of (0, WABinary_1.getBinaryNodeChildren)(promptsNode, 'prompt')) {
|
|
37
|
+
prompts.push(`${(0, WABinary_1.getBinaryNodeChildString)(prompt, 'emoji')} ${(0, WABinary_1.getBinaryNodeChildString)(prompt, 'text')}`);
|
|
36
38
|
}
|
|
37
39
|
return {
|
|
38
|
-
isDefault: !!getBinaryNodeChild(profile, 'default'),
|
|
40
|
+
isDefault: !!(0, WABinary_1.getBinaryNodeChild)(profile, 'default'),
|
|
39
41
|
jid: node.attrs.jid,
|
|
40
|
-
name: getBinaryNodeChildString(profile, 'name'),
|
|
41
|
-
attributes: getBinaryNodeChildString(profile, 'attributes'),
|
|
42
|
-
description: getBinaryNodeChildString(profile, 'description'),
|
|
43
|
-
category: getBinaryNodeChildString(profile, 'category'),
|
|
42
|
+
name: (0, WABinary_1.getBinaryNodeChildString)(profile, 'name'),
|
|
43
|
+
attributes: (0, WABinary_1.getBinaryNodeChildString)(profile, 'attributes'),
|
|
44
|
+
description: (0, WABinary_1.getBinaryNodeChildString)(profile, 'description'),
|
|
45
|
+
category: (0, WABinary_1.getBinaryNodeChildString)(profile, 'category'),
|
|
44
46
|
personaId: profile.attrs['persona_id'],
|
|
45
|
-
commandsDescription: getBinaryNodeChildString(commandsNode, 'description'),
|
|
47
|
+
commandsDescription: (0, WABinary_1.getBinaryNodeChildString)(commandsNode, 'description'),
|
|
46
48
|
commands,
|
|
47
49
|
prompts
|
|
48
50
|
};
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
|
-
|
|
53
|
+
exports.USyncBotProfileProtocol = USyncBotProfileProtocol;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.USyncLIDProtocol = void 0;
|
|
4
|
+
class USyncLIDProtocol {
|
|
2
5
|
constructor() {
|
|
3
6
|
this.name = 'lid';
|
|
4
7
|
}
|
|
5
8
|
getQueryElement() {
|
|
6
9
|
return {
|
|
7
10
|
tag: 'lid',
|
|
8
|
-
attrs: {}
|
|
11
|
+
attrs: {},
|
|
9
12
|
};
|
|
10
13
|
}
|
|
11
14
|
getUserElement() {
|
|
@@ -18,4 +21,4 @@ export class USyncLIDProtocol {
|
|
|
18
21
|
return null;
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
|
-
|
|
24
|
+
exports.USyncLIDProtocol = USyncLIDProtocol;
|
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
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);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./USyncDeviceProtocol"), exports);
|
|
18
|
+
__exportStar(require("./USyncContactProtocol"), exports);
|
|
19
|
+
__exportStar(require("./USyncStatusProtocol"), exports);
|
|
20
|
+
__exportStar(require("./USyncDisappearingModeProtocol"), exports);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.USyncQuery = void 0;
|
|
4
|
+
const WABinary_1 = require("../WABinary");
|
|
5
|
+
const UsyncBotProfileProtocol_1 = require("./Protocols/UsyncBotProfileProtocol");
|
|
6
|
+
const UsyncLIDProtocol_1 = require("./Protocols/UsyncLIDProtocol");
|
|
7
|
+
const Protocols_1 = require("./Protocols");
|
|
8
|
+
class USyncQuery {
|
|
7
9
|
constructor() {
|
|
8
10
|
this.protocols = [];
|
|
9
11
|
this.users = [];
|
|
@@ -26,36 +28,32 @@ export class USyncQuery {
|
|
|
26
28
|
if (result.attrs.type !== 'result') {
|
|
27
29
|
return;
|
|
28
30
|
}
|
|
29
|
-
const protocolMap = Object.fromEntries(this.protocols.map(protocol => {
|
|
31
|
+
const protocolMap = Object.fromEntries(this.protocols.map((protocol) => {
|
|
30
32
|
return [protocol.name, protocol.parser];
|
|
31
33
|
}));
|
|
32
34
|
const queryResult = {
|
|
33
35
|
// TODO: implement errors etc.
|
|
34
36
|
list: [],
|
|
35
|
-
sideList: []
|
|
37
|
+
sideList: [],
|
|
36
38
|
};
|
|
37
|
-
const usyncNode = getBinaryNodeChild(result, 'usync');
|
|
39
|
+
const usyncNode = (0, WABinary_1.getBinaryNodeChild)(result, 'usync');
|
|
38
40
|
//TODO: implement error backoff, refresh etc.
|
|
39
41
|
//TODO: see if there are any errors in the result node
|
|
40
42
|
//const resultNode = getBinaryNodeChild(usyncNode, 'result')
|
|
41
|
-
const listNode = getBinaryNodeChild(usyncNode, 'list');
|
|
42
|
-
if (Array.isArray(listNode
|
|
43
|
-
queryResult.list = listNode.content.map(node => {
|
|
44
|
-
const id = node
|
|
45
|
-
const data = Array.isArray(node
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
|
-
.filter(([, b]) => b !== null))
|
|
58
|
-
: {};
|
|
43
|
+
const listNode = (0, WABinary_1.getBinaryNodeChild)(usyncNode, 'list');
|
|
44
|
+
if (Array.isArray(listNode === null || listNode === void 0 ? void 0 : listNode.content) && typeof listNode !== 'undefined') {
|
|
45
|
+
queryResult.list = listNode.content.map((node) => {
|
|
46
|
+
const id = node === null || node === void 0 ? void 0 : node.attrs.jid;
|
|
47
|
+
const data = Array.isArray(node === null || node === void 0 ? void 0 : node.content) ? Object.fromEntries(node.content.map((content) => {
|
|
48
|
+
const protocol = content.tag;
|
|
49
|
+
const parser = protocolMap[protocol];
|
|
50
|
+
if (parser) {
|
|
51
|
+
return [protocol, parser(content)];
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return [protocol, null];
|
|
55
|
+
}
|
|
56
|
+
}).filter(([, b]) => b !== null)) : {};
|
|
59
57
|
return { ...data, id };
|
|
60
58
|
});
|
|
61
59
|
}
|
|
@@ -64,28 +62,28 @@ export class USyncQuery {
|
|
|
64
62
|
return queryResult;
|
|
65
63
|
}
|
|
66
64
|
withDeviceProtocol() {
|
|
67
|
-
this.protocols.push(new USyncDeviceProtocol());
|
|
65
|
+
this.protocols.push(new Protocols_1.USyncDeviceProtocol());
|
|
68
66
|
return this;
|
|
69
67
|
}
|
|
70
68
|
withContactProtocol() {
|
|
71
|
-
this.protocols.push(new USyncContactProtocol());
|
|
69
|
+
this.protocols.push(new Protocols_1.USyncContactProtocol());
|
|
72
70
|
return this;
|
|
73
71
|
}
|
|
74
72
|
withStatusProtocol() {
|
|
75
|
-
this.protocols.push(new USyncStatusProtocol());
|
|
73
|
+
this.protocols.push(new Protocols_1.USyncStatusProtocol());
|
|
76
74
|
return this;
|
|
77
75
|
}
|
|
78
76
|
withDisappearingModeProtocol() {
|
|
79
|
-
this.protocols.push(new USyncDisappearingModeProtocol());
|
|
77
|
+
this.protocols.push(new Protocols_1.USyncDisappearingModeProtocol());
|
|
80
78
|
return this;
|
|
81
79
|
}
|
|
82
80
|
withBotProfileProtocol() {
|
|
83
|
-
this.protocols.push(new USyncBotProfileProtocol());
|
|
81
|
+
this.protocols.push(new UsyncBotProfileProtocol_1.USyncBotProfileProtocol());
|
|
84
82
|
return this;
|
|
85
83
|
}
|
|
86
84
|
withLIDProtocol() {
|
|
87
|
-
this.protocols.push(new USyncLIDProtocol());
|
|
85
|
+
this.protocols.push(new UsyncLIDProtocol_1.USyncLIDProtocol());
|
|
88
86
|
return this;
|
|
89
87
|
}
|
|
90
88
|
}
|
|
91
|
-
|
|
89
|
+
exports.USyncQuery = USyncQuery;
|
package/lib/WAUSync/USyncUser.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.USyncUser = void 0;
|
|
4
|
+
class USyncUser {
|
|
2
5
|
withId(id) {
|
|
3
6
|
this.id = id;
|
|
4
7
|
return this;
|
|
@@ -20,4 +23,4 @@ export class USyncUser {
|
|
|
20
23
|
return this;
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
|
-
|
|
26
|
+
exports.USyncUser = USyncUser;
|
package/lib/WAUSync/index.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
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);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Protocols"), exports);
|
|
18
|
+
__exportStar(require("./USyncQuery"), exports);
|
|
19
|
+
__exportStar(require("./USyncUser"), exports);
|
package/lib/index.js
CHANGED
|
@@ -1,11 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
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);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.proto = exports.makeWASocket = void 0;
|
|
21
|
+
const WAProto_1 = require("../WAProto");
|
|
22
|
+
Object.defineProperty(exports, "proto", { enumerable: true, get: function () { return WAProto_1.proto; } });
|
|
23
|
+
const Socket_1 = __importDefault(require("./Socket"));
|
|
24
|
+
exports.makeWASocket = Socket_1.default;
|
|
25
|
+
__exportStar(require("../WAProto"), exports);
|
|
26
|
+
__exportStar(require("./Utils"), exports);
|
|
27
|
+
__exportStar(require("./Types"), exports);
|
|
28
|
+
__exportStar(require("./Store"), exports);
|
|
29
|
+
__exportStar(require("./Defaults"), exports);
|
|
30
|
+
__exportStar(require("./WABinary"), exports);
|
|
31
|
+
__exportStar(require("./WAM"), exports);
|
|
32
|
+
__exportStar(require("./WAUSync"), exports);
|
|
33
|
+
exports.default = Socket_1.default;
|