violetics 7.0.1-alpha → 7.0.2-alpha
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 +3 -2
- package/README.md +1001 -232
- package/WAProto/index.js +75379 -142631
- package/engine-requirements.js +11 -8
- package/lib/Defaults/index.js +132 -146
- package/lib/Signal/Group/ciphertext-message.js +2 -6
- package/lib/Signal/Group/group-session-builder.js +7 -42
- package/lib/Signal/Group/group_cipher.js +37 -52
- package/lib/Signal/Group/index.js +11 -57
- package/lib/Signal/Group/keyhelper.js +7 -45
- package/lib/Signal/Group/sender-chain-key.js +7 -16
- package/lib/Signal/Group/sender-key-distribution-message.js +8 -12
- package/lib/Signal/Group/sender-key-message.js +9 -13
- package/lib/Signal/Group/sender-key-name.js +2 -6
- package/lib/Signal/Group/sender-key-record.js +9 -22
- package/lib/Signal/Group/sender-key-state.js +27 -43
- package/lib/Signal/Group/sender-message-key.js +4 -8
- package/lib/Signal/libsignal.js +319 -94
- package/lib/Signal/lid-mapping.js +224 -139
- package/lib/Socket/Client/index.js +2 -19
- package/lib/Socket/Client/types.js +10 -0
- package/lib/Socket/Client/websocket.js +53 -0
- package/lib/Socket/business.js +162 -44
- package/lib/Socket/chats.js +477 -418
- package/lib/Socket/communities.js +430 -0
- package/lib/Socket/groups.js +110 -99
- package/lib/Socket/index.js +10 -10
- package/lib/Socket/messages-recv.js +884 -561
- package/lib/Socket/messages-send.js +859 -428
- package/lib/Socket/mex.js +41 -0
- package/lib/Socket/newsletter.js +195 -390
- package/lib/Socket/socket.js +465 -315
- package/lib/Store/index.js +3 -10
- package/lib/Store/make-in-memory-store.js +73 -79
- package/lib/Store/make-ordered-dictionary.js +4 -7
- package/lib/Store/object-repository.js +2 -6
- package/lib/Types/Auth.js +1 -2
- package/lib/Types/Bussines.js +1 -0
- package/lib/Types/Call.js +1 -2
- package/lib/Types/Chat.js +7 -4
- package/lib/Types/Contact.js +1 -2
- package/lib/Types/Events.js +1 -2
- package/lib/Types/GroupMetadata.js +1 -2
- package/lib/Types/Label.js +2 -5
- package/lib/Types/LabelAssociation.js +2 -5
- package/lib/Types/Message.js +17 -9
- package/lib/Types/Newsletter.js +33 -38
- package/lib/Types/Product.js +1 -2
- package/lib/Types/Signal.js +1 -2
- package/lib/Types/Socket.js +2 -2
- package/lib/Types/State.js +12 -2
- package/lib/Types/USync.js +1 -2
- package/lib/Types/index.js +14 -31
- package/lib/Utils/auth-utils.js +228 -152
- package/lib/Utils/browser-utils.js +28 -0
- package/lib/Utils/business.js +66 -70
- package/lib/Utils/chat-utils.js +331 -249
- package/lib/Utils/crypto.js +57 -91
- package/lib/Utils/decode-wa-message.js +168 -84
- package/lib/Utils/event-buffer.js +138 -80
- package/lib/Utils/generics.js +180 -297
- package/lib/Utils/history.js +83 -49
- package/lib/Utils/identity-change-handler.js +48 -0
- package/lib/Utils/index.js +19 -33
- package/lib/Utils/link-preview.js +14 -23
- package/lib/Utils/logger.js +2 -7
- package/lib/Utils/lt-hash.js +2 -46
- package/lib/Utils/make-mutex.js +24 -47
- package/lib/Utils/message-retry-manager.js +224 -0
- package/lib/Utils/messages-media.js +501 -496
- package/lib/Utils/messages.js +1428 -362
- package/lib/Utils/noise-handler.js +145 -100
- package/lib/Utils/pre-key-manager.js +105 -0
- package/lib/Utils/process-message.js +356 -150
- package/lib/Utils/reporting-utils.js +257 -0
- package/lib/Utils/signal.js +78 -73
- package/lib/Utils/sync-action-utils.js +47 -0
- package/lib/Utils/tc-token-utils.js +17 -0
- package/lib/Utils/use-multi-file-auth-state.js +35 -45
- package/lib/Utils/validate-connection.js +91 -107
- package/lib/WABinary/constants.js +1300 -1304
- package/lib/WABinary/decode.js +26 -48
- package/lib/WABinary/encode.js +109 -155
- package/lib/WABinary/generic-utils.js +161 -149
- package/lib/WABinary/index.js +5 -21
- package/lib/WABinary/jid-utils.js +73 -40
- package/lib/WABinary/types.js +1 -2
- package/lib/WAM/BinaryInfo.js +2 -6
- package/lib/WAM/constants.js +19070 -11568
- package/lib/WAM/encode.js +17 -23
- package/lib/WAM/index.js +3 -19
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +8 -12
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +11 -15
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +9 -13
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +9 -14
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +20 -23
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +13 -9
- package/lib/WAUSync/Protocols/index.js +4 -20
- package/lib/WAUSync/USyncQuery.js +40 -36
- package/lib/WAUSync/USyncUser.js +2 -6
- package/lib/WAUSync/index.js +3 -19
- package/lib/index.js +11 -44
- package/package.json +74 -107
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Signal/Group/queue-job.js +0 -57
- package/lib/Socket/Client/abstract-socket-client.js +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/Client/web-socket-client.js +0 -118
- package/lib/Socket/groupStatus.js +0 -637
- package/lib/Socket/registration.js +0 -166
- package/lib/Socket/usync.js +0 -70
- package/lib/Store/make-cache-manager-store.js +0 -83
- package/lib/Utils/baileys-event-stream.js +0 -63
package/lib/WAM/encode.js
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.encodeWAM = void 0;
|
|
4
|
-
const constants_1 = require("./constants");
|
|
1
|
+
import { BinaryInfo } from './BinaryInfo.js';
|
|
2
|
+
import { FLAG_BYTE, FLAG_EVENT, FLAG_EXTENDED, FLAG_FIELD, FLAG_GLOBAL, WEB_EVENTS, WEB_GLOBALS } from './constants.js';
|
|
5
3
|
const getHeaderBitLength = (key) => (key < 256 ? 2 : 3);
|
|
6
|
-
const encodeWAM = (binaryInfo) => {
|
|
4
|
+
export const encodeWAM = (binaryInfo) => {
|
|
7
5
|
binaryInfo.buffer = [];
|
|
8
6
|
encodeWAMHeader(binaryInfo);
|
|
9
7
|
encodeEvents(binaryInfo);
|
|
10
|
-
|
|
11
|
-
const totalSize = binaryInfo.buffer
|
|
12
|
-
.map((a) => a.length)
|
|
13
|
-
.reduce((a, b) => a + b);
|
|
8
|
+
const totalSize = binaryInfo.buffer.map(a => a.length).reduce((a, b) => a + b);
|
|
14
9
|
const buffer = Buffer.alloc(totalSize);
|
|
15
10
|
let offset = 0;
|
|
16
|
-
binaryInfo.buffer
|
|
11
|
+
for (const buffer_ of binaryInfo.buffer) {
|
|
17
12
|
buffer_.copy(buffer, offset);
|
|
18
13
|
offset += buffer_.length;
|
|
19
|
-
}
|
|
14
|
+
}
|
|
20
15
|
return buffer;
|
|
21
16
|
};
|
|
22
|
-
exports.encodeWAM = encodeWAM;
|
|
23
17
|
function encodeWAMHeader(binaryInfo) {
|
|
24
18
|
const headerBuffer = Buffer.alloc(8); // starting buffer
|
|
25
19
|
headerBuffer.write('WAM', 0, 'utf8');
|
|
@@ -31,34 +25,34 @@ function encodeWAMHeader(binaryInfo) {
|
|
|
31
25
|
}
|
|
32
26
|
function encodeGlobalAttributes(binaryInfo, globals) {
|
|
33
27
|
for (const [key, _value] of Object.entries(globals)) {
|
|
34
|
-
const id =
|
|
28
|
+
const id = WEB_GLOBALS.find(a => a?.name === key).id;
|
|
35
29
|
let value = _value;
|
|
36
30
|
if (typeof value === 'boolean') {
|
|
37
31
|
value = value ? 1 : 0;
|
|
38
32
|
}
|
|
39
|
-
binaryInfo.buffer.push(serializeData(id, value,
|
|
33
|
+
binaryInfo.buffer.push(serializeData(id, value, FLAG_GLOBAL));
|
|
40
34
|
}
|
|
41
35
|
}
|
|
42
36
|
function encodeEvents(binaryInfo) {
|
|
43
|
-
for (const [name, { props, globals }
|
|
37
|
+
for (const [name, { props, globals }] of binaryInfo.events.map(a => Object.entries(a)[0])) {
|
|
44
38
|
encodeGlobalAttributes(binaryInfo, globals);
|
|
45
|
-
const event =
|
|
39
|
+
const event = WEB_EVENTS.find(a => a.name === name);
|
|
46
40
|
const props_ = Object.entries(props);
|
|
47
41
|
let extended = false;
|
|
48
42
|
for (const [, value] of props_) {
|
|
49
43
|
extended || (extended = value !== null);
|
|
50
44
|
}
|
|
51
|
-
const eventFlag = extended ?
|
|
45
|
+
const eventFlag = extended ? FLAG_EVENT : FLAG_EVENT | FLAG_EXTENDED;
|
|
52
46
|
binaryInfo.buffer.push(serializeData(event.id, -event.weight, eventFlag));
|
|
53
47
|
for (let i = 0; i < props_.length; i++) {
|
|
54
48
|
const [key, _value] = props_[i];
|
|
55
|
-
const id =
|
|
56
|
-
extended = i <
|
|
49
|
+
const id = event.props[key]?.[0];
|
|
50
|
+
extended = i < props_.length - 1;
|
|
57
51
|
let value = _value;
|
|
58
52
|
if (typeof value === 'boolean') {
|
|
59
53
|
value = value ? 1 : 0;
|
|
60
54
|
}
|
|
61
|
-
const fieldFlag = extended ?
|
|
55
|
+
const fieldFlag = extended ? FLAG_EVENT : FLAG_FIELD | FLAG_EXTENDED;
|
|
62
56
|
binaryInfo.buffer.push(serializeData(id, value, fieldFlag));
|
|
63
57
|
}
|
|
64
58
|
}
|
|
@@ -68,7 +62,7 @@ function serializeData(key, value, flag) {
|
|
|
68
62
|
let buffer;
|
|
69
63
|
let offset = 0;
|
|
70
64
|
if (value === null) {
|
|
71
|
-
if (flag ===
|
|
65
|
+
if (flag === FLAG_GLOBAL) {
|
|
72
66
|
buffer = Buffer.alloc(bufferLength);
|
|
73
67
|
offset = serializeHeader(buffer, offset, key, flag);
|
|
74
68
|
return buffer;
|
|
@@ -146,10 +140,10 @@ function serializeHeader(buffer, offset, key, flag) {
|
|
|
146
140
|
offset += 1;
|
|
147
141
|
}
|
|
148
142
|
else {
|
|
149
|
-
buffer.writeUInt8(flag |
|
|
143
|
+
buffer.writeUInt8(flag | FLAG_BYTE, offset);
|
|
150
144
|
offset += 1;
|
|
151
145
|
buffer.writeUInt16LE(key, offset);
|
|
152
146
|
offset += 2;
|
|
153
147
|
}
|
|
154
148
|
return offset;
|
|
155
|
-
}
|
|
149
|
+
}
|
package/lib/WAM/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
+
export * from './constants.js';
|
|
2
|
+
export * from './encode.js';
|
|
3
|
+
export * from './BinaryInfo.js';
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const WABinary_1 = require("../../WABinary");
|
|
5
|
-
class USyncContactProtocol {
|
|
1
|
+
import { assertNodeErrorFree } from '../../WABinary/index.js';
|
|
2
|
+
import { USyncUser } from '../USyncUser.js';
|
|
3
|
+
export class USyncContactProtocol {
|
|
6
4
|
constructor() {
|
|
7
5
|
this.name = 'contact';
|
|
8
6
|
}
|
|
9
7
|
getQueryElement() {
|
|
10
8
|
return {
|
|
11
9
|
tag: 'contact',
|
|
12
|
-
attrs: {}
|
|
10
|
+
attrs: {}
|
|
13
11
|
};
|
|
14
12
|
}
|
|
15
13
|
getUserElement(user) {
|
|
@@ -17,16 +15,14 @@ class USyncContactProtocol {
|
|
|
17
15
|
return {
|
|
18
16
|
tag: 'contact',
|
|
19
17
|
attrs: {},
|
|
20
|
-
content: user.phone
|
|
18
|
+
content: user.phone
|
|
21
19
|
};
|
|
22
20
|
}
|
|
23
21
|
parser(node) {
|
|
24
|
-
var _a;
|
|
25
22
|
if (node.tag === 'contact') {
|
|
26
|
-
|
|
27
|
-
return
|
|
23
|
+
assertNodeErrorFree(node);
|
|
24
|
+
return node?.attrs?.type === 'in';
|
|
28
25
|
}
|
|
29
26
|
return false;
|
|
30
27
|
}
|
|
31
|
-
}
|
|
32
|
-
exports.USyncContactProtocol = USyncContactProtocol;
|
|
28
|
+
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.USyncDeviceProtocol = void 0;
|
|
4
|
-
const WABinary_1 = require("../../WABinary");
|
|
5
|
-
class USyncDeviceProtocol {
|
|
1
|
+
import { assertNodeErrorFree, getBinaryNodeChild } from '../../WABinary/index.js';
|
|
2
|
+
export class USyncDeviceProtocol {
|
|
6
3
|
constructor() {
|
|
7
4
|
this.name = 'devices';
|
|
8
5
|
}
|
|
@@ -10,8 +7,8 @@ class USyncDeviceProtocol {
|
|
|
10
7
|
return {
|
|
11
8
|
tag: 'devices',
|
|
12
9
|
attrs: {
|
|
13
|
-
version: '2'
|
|
14
|
-
}
|
|
10
|
+
version: '2'
|
|
11
|
+
}
|
|
15
12
|
};
|
|
16
13
|
}
|
|
17
14
|
getUserElement( /* user: USyncUser */) {
|
|
@@ -24,10 +21,10 @@ class USyncDeviceProtocol {
|
|
|
24
21
|
const deviceList = [];
|
|
25
22
|
let keyIndex = undefined;
|
|
26
23
|
if (node.tag === 'devices') {
|
|
27
|
-
|
|
28
|
-
const deviceListNode =
|
|
29
|
-
const keyIndexNode =
|
|
30
|
-
if (Array.isArray(deviceListNode
|
|
24
|
+
assertNodeErrorFree(node);
|
|
25
|
+
const deviceListNode = getBinaryNodeChild(node, 'device-list');
|
|
26
|
+
const keyIndexNode = getBinaryNodeChild(node, 'key-index-list');
|
|
27
|
+
if (Array.isArray(deviceListNode?.content)) {
|
|
31
28
|
for (const { tag, attrs } of deviceListNode.content) {
|
|
32
29
|
const id = +attrs.id;
|
|
33
30
|
const keyIndex = +attrs['key-index'];
|
|
@@ -40,10 +37,10 @@ class USyncDeviceProtocol {
|
|
|
40
37
|
}
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
|
-
if (
|
|
40
|
+
if (keyIndexNode?.tag === 'key-index-list') {
|
|
44
41
|
keyIndex = {
|
|
45
42
|
timestamp: +keyIndexNode.attrs['ts'],
|
|
46
|
-
signedKeyIndex: keyIndexNode
|
|
43
|
+
signedKeyIndex: keyIndexNode?.content,
|
|
47
44
|
expectedTimestamp: keyIndexNode.attrs['expected_ts'] ? +keyIndexNode.attrs['expected_ts'] : undefined
|
|
48
45
|
};
|
|
49
46
|
}
|
|
@@ -53,5 +50,4 @@ class USyncDeviceProtocol {
|
|
|
53
50
|
keyIndex
|
|
54
51
|
};
|
|
55
52
|
}
|
|
56
|
-
}
|
|
57
|
-
exports.USyncDeviceProtocol = USyncDeviceProtocol;
|
|
53
|
+
}
|
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.USyncDisappearingModeProtocol = void 0;
|
|
4
|
-
const WABinary_1 = require("../../WABinary");
|
|
5
|
-
class USyncDisappearingModeProtocol {
|
|
1
|
+
import { assertNodeErrorFree } from '../../WABinary/index.js';
|
|
2
|
+
export class USyncDisappearingModeProtocol {
|
|
6
3
|
constructor() {
|
|
7
4
|
this.name = 'disappearing_mode';
|
|
8
5
|
}
|
|
9
6
|
getQueryElement() {
|
|
10
7
|
return {
|
|
11
8
|
tag: 'disappearing_mode',
|
|
12
|
-
attrs: {}
|
|
9
|
+
attrs: {}
|
|
13
10
|
};
|
|
14
11
|
}
|
|
15
12
|
getUserElement() {
|
|
16
13
|
return null;
|
|
17
14
|
}
|
|
18
15
|
parser(node) {
|
|
19
|
-
if (node.tag === '
|
|
20
|
-
|
|
21
|
-
const duration = +
|
|
22
|
-
const setAt = new Date(+(
|
|
16
|
+
if (node.tag === 'disappearing_mode') {
|
|
17
|
+
assertNodeErrorFree(node);
|
|
18
|
+
const duration = +node?.attrs.duration;
|
|
19
|
+
const setAt = new Date(+(node?.attrs.t || 0) * 1000);
|
|
23
20
|
return {
|
|
24
21
|
duration,
|
|
25
|
-
setAt
|
|
22
|
+
setAt
|
|
26
23
|
};
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
|
-
}
|
|
30
|
-
exports.USyncDisappearingModeProtocol = USyncDisappearingModeProtocol;
|
|
26
|
+
}
|
|
@@ -1,28 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.USyncStatusProtocol = void 0;
|
|
4
|
-
const WABinary_1 = require("../../WABinary");
|
|
5
|
-
class USyncStatusProtocol {
|
|
1
|
+
import { assertNodeErrorFree } from '../../WABinary/index.js';
|
|
2
|
+
export class USyncStatusProtocol {
|
|
6
3
|
constructor() {
|
|
7
4
|
this.name = 'status';
|
|
8
5
|
}
|
|
9
6
|
getQueryElement() {
|
|
10
7
|
return {
|
|
11
8
|
tag: 'status',
|
|
12
|
-
attrs: {}
|
|
9
|
+
attrs: {}
|
|
13
10
|
};
|
|
14
11
|
}
|
|
15
12
|
getUserElement() {
|
|
16
13
|
return null;
|
|
17
14
|
}
|
|
18
15
|
parser(node) {
|
|
19
|
-
var _a, _b, _c;
|
|
20
16
|
if (node.tag === 'status') {
|
|
21
|
-
|
|
22
|
-
let status =
|
|
23
|
-
const setAt = new Date(+(
|
|
17
|
+
assertNodeErrorFree(node);
|
|
18
|
+
let status = node?.content?.toString() ?? null;
|
|
19
|
+
const setAt = new Date(+(node?.attrs.t || 0) * 1000);
|
|
24
20
|
if (!status) {
|
|
25
|
-
if (
|
|
21
|
+
if (node.attrs?.code && +node.attrs.code === 401) {
|
|
26
22
|
status = '';
|
|
27
23
|
}
|
|
28
24
|
else {
|
|
@@ -34,9 +30,8 @@ class USyncStatusProtocol {
|
|
|
34
30
|
}
|
|
35
31
|
return {
|
|
36
32
|
status,
|
|
37
|
-
setAt
|
|
33
|
+
setAt
|
|
38
34
|
};
|
|
39
35
|
}
|
|
40
36
|
}
|
|
41
|
-
}
|
|
42
|
-
exports.USyncStatusProtocol = USyncStatusProtocol;
|
|
37
|
+
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const WABinary_1 = require("../../WABinary");
|
|
5
|
-
class USyncBotProfileProtocol {
|
|
1
|
+
import { getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString } from '../../WABinary/index.js';
|
|
2
|
+
import { USyncUser } from '../USyncUser.js';
|
|
3
|
+
export class USyncBotProfileProtocol {
|
|
6
4
|
constructor() {
|
|
7
5
|
this.name = 'bot';
|
|
8
6
|
}
|
|
@@ -17,37 +15,36 @@ class USyncBotProfileProtocol {
|
|
|
17
15
|
return {
|
|
18
16
|
tag: 'bot',
|
|
19
17
|
attrs: {},
|
|
20
|
-
content: [{ tag: 'profile', attrs: {
|
|
18
|
+
content: [{ tag: 'profile', attrs: { persona_id: user.personaId } }]
|
|
21
19
|
};
|
|
22
20
|
}
|
|
23
21
|
parser(node) {
|
|
24
|
-
const botNode =
|
|
25
|
-
const profile =
|
|
26
|
-
const commandsNode =
|
|
27
|
-
const promptsNode =
|
|
22
|
+
const botNode = getBinaryNodeChild(node, 'bot');
|
|
23
|
+
const profile = getBinaryNodeChild(botNode, 'profile');
|
|
24
|
+
const commandsNode = getBinaryNodeChild(profile, 'commands');
|
|
25
|
+
const promptsNode = getBinaryNodeChild(profile, 'prompts');
|
|
28
26
|
const commands = [];
|
|
29
27
|
const prompts = [];
|
|
30
|
-
for (const command of
|
|
28
|
+
for (const command of getBinaryNodeChildren(commandsNode, 'command')) {
|
|
31
29
|
commands.push({
|
|
32
|
-
name:
|
|
33
|
-
description:
|
|
30
|
+
name: getBinaryNodeChildString(command, 'name'),
|
|
31
|
+
description: getBinaryNodeChildString(command, 'description')
|
|
34
32
|
});
|
|
35
33
|
}
|
|
36
|
-
for (const prompt of
|
|
37
|
-
prompts.push(`${
|
|
34
|
+
for (const prompt of getBinaryNodeChildren(promptsNode, 'prompt')) {
|
|
35
|
+
prompts.push(`${getBinaryNodeChildString(prompt, 'emoji')} ${getBinaryNodeChildString(prompt, 'text')}`);
|
|
38
36
|
}
|
|
39
37
|
return {
|
|
40
|
-
isDefault: !!
|
|
38
|
+
isDefault: !!getBinaryNodeChild(profile, 'default'),
|
|
41
39
|
jid: node.attrs.jid,
|
|
42
|
-
name:
|
|
43
|
-
attributes:
|
|
44
|
-
description:
|
|
45
|
-
category:
|
|
40
|
+
name: getBinaryNodeChildString(profile, 'name'),
|
|
41
|
+
attributes: getBinaryNodeChildString(profile, 'attributes'),
|
|
42
|
+
description: getBinaryNodeChildString(profile, 'description'),
|
|
43
|
+
category: getBinaryNodeChildString(profile, 'category'),
|
|
46
44
|
personaId: profile.attrs['persona_id'],
|
|
47
|
-
commandsDescription:
|
|
45
|
+
commandsDescription: getBinaryNodeChildString(commandsNode, 'description'),
|
|
48
46
|
commands,
|
|
49
47
|
prompts
|
|
50
48
|
};
|
|
51
49
|
}
|
|
52
|
-
}
|
|
53
|
-
exports.USyncBotProfileProtocol = USyncBotProfileProtocol;
|
|
50
|
+
}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.USyncLIDProtocol = void 0;
|
|
4
|
-
class USyncLIDProtocol {
|
|
1
|
+
export class USyncLIDProtocol {
|
|
5
2
|
constructor() {
|
|
6
3
|
this.name = 'lid';
|
|
7
4
|
}
|
|
8
5
|
getQueryElement() {
|
|
9
6
|
return {
|
|
10
7
|
tag: 'lid',
|
|
11
|
-
attrs: {}
|
|
8
|
+
attrs: {}
|
|
12
9
|
};
|
|
13
10
|
}
|
|
14
|
-
getUserElement() {
|
|
15
|
-
|
|
11
|
+
getUserElement(user) {
|
|
12
|
+
if (user.lid) {
|
|
13
|
+
return {
|
|
14
|
+
tag: 'lid',
|
|
15
|
+
attrs: { jid: user.lid }
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
16
21
|
}
|
|
17
22
|
parser(node) {
|
|
18
23
|
if (node.tag === 'lid') {
|
|
@@ -20,5 +25,4 @@ class USyncLIDProtocol {
|
|
|
20
25
|
}
|
|
21
26
|
return null;
|
|
22
27
|
}
|
|
23
|
-
}
|
|
24
|
-
exports.USyncLIDProtocol = USyncLIDProtocol;
|
|
28
|
+
}
|
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
+
export * from './USyncDeviceProtocol.js';
|
|
2
|
+
export * from './USyncContactProtocol.js';
|
|
3
|
+
export * from './USyncStatusProtocol.js';
|
|
4
|
+
export * from './USyncDisappearingModeProtocol.js';
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const Protocols_1 = require("./Protocols");
|
|
8
|
-
class USyncQuery {
|
|
1
|
+
import { getBinaryNodeChild } from '../WABinary/index.js';
|
|
2
|
+
import { USyncBotProfileProtocol } from './Protocols/UsyncBotProfileProtocol.js';
|
|
3
|
+
import { USyncLIDProtocol } from './Protocols/UsyncLIDProtocol.js';
|
|
4
|
+
import { USyncContactProtocol, USyncDeviceProtocol, USyncDisappearingModeProtocol, USyncStatusProtocol } from './Protocols/index.js';
|
|
5
|
+
import { USyncUser } from './USyncUser.js';
|
|
6
|
+
export class USyncQuery {
|
|
9
7
|
constructor() {
|
|
10
8
|
this.protocols = [];
|
|
11
9
|
this.users = [];
|
|
@@ -25,65 +23,71 @@ class USyncQuery {
|
|
|
25
23
|
return this;
|
|
26
24
|
}
|
|
27
25
|
parseUSyncQueryResult(result) {
|
|
28
|
-
if (result.attrs.type !== 'result') {
|
|
26
|
+
if (!result || result.attrs.type !== 'result') {
|
|
29
27
|
return;
|
|
30
28
|
}
|
|
31
|
-
const protocolMap = Object.fromEntries(this.protocols.map(
|
|
29
|
+
const protocolMap = Object.fromEntries(this.protocols.map(protocol => {
|
|
32
30
|
return [protocol.name, protocol.parser];
|
|
33
31
|
}));
|
|
34
32
|
const queryResult = {
|
|
35
33
|
// TODO: implement errors etc.
|
|
36
34
|
list: [],
|
|
37
|
-
sideList: []
|
|
35
|
+
sideList: []
|
|
38
36
|
};
|
|
39
|
-
const usyncNode =
|
|
37
|
+
const usyncNode = getBinaryNodeChild(result, 'usync');
|
|
40
38
|
//TODO: implement error backoff, refresh etc.
|
|
41
39
|
//TODO: see if there are any errors in the result node
|
|
42
40
|
//const resultNode = getBinaryNodeChild(usyncNode, 'result')
|
|
43
|
-
const listNode =
|
|
44
|
-
if (Array.isArray(listNode
|
|
45
|
-
queryResult.list = listNode.content.
|
|
46
|
-
const id = node
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
41
|
+
const listNode = usyncNode ? getBinaryNodeChild(usyncNode, 'list') : undefined;
|
|
42
|
+
if (listNode?.content && Array.isArray(listNode.content)) {
|
|
43
|
+
queryResult.list = listNode.content.reduce((acc, node) => {
|
|
44
|
+
const id = node?.attrs.jid;
|
|
45
|
+
if (id) {
|
|
46
|
+
const data = Array.isArray(node?.content)
|
|
47
|
+
? Object.fromEntries(node.content
|
|
48
|
+
.map(content => {
|
|
49
|
+
const protocol = content.tag;
|
|
50
|
+
const parser = protocolMap[protocol];
|
|
51
|
+
if (parser) {
|
|
52
|
+
return [protocol, parser(content)];
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
return [protocol, null];
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
.filter(([, b]) => b !== null))
|
|
59
|
+
: {};
|
|
60
|
+
acc.push({ ...data, id });
|
|
61
|
+
}
|
|
62
|
+
return acc;
|
|
63
|
+
}, []);
|
|
59
64
|
}
|
|
60
65
|
//TODO: implement side list
|
|
61
66
|
//const sideListNode = getBinaryNodeChild(usyncNode, 'side_list')
|
|
62
67
|
return queryResult;
|
|
63
68
|
}
|
|
64
69
|
withDeviceProtocol() {
|
|
65
|
-
this.protocols.push(new
|
|
70
|
+
this.protocols.push(new USyncDeviceProtocol());
|
|
66
71
|
return this;
|
|
67
72
|
}
|
|
68
73
|
withContactProtocol() {
|
|
69
|
-
this.protocols.push(new
|
|
74
|
+
this.protocols.push(new USyncContactProtocol());
|
|
70
75
|
return this;
|
|
71
76
|
}
|
|
72
77
|
withStatusProtocol() {
|
|
73
|
-
this.protocols.push(new
|
|
78
|
+
this.protocols.push(new USyncStatusProtocol());
|
|
74
79
|
return this;
|
|
75
80
|
}
|
|
76
81
|
withDisappearingModeProtocol() {
|
|
77
|
-
this.protocols.push(new
|
|
82
|
+
this.protocols.push(new USyncDisappearingModeProtocol());
|
|
78
83
|
return this;
|
|
79
84
|
}
|
|
80
85
|
withBotProfileProtocol() {
|
|
81
|
-
this.protocols.push(new
|
|
86
|
+
this.protocols.push(new USyncBotProfileProtocol());
|
|
82
87
|
return this;
|
|
83
88
|
}
|
|
84
89
|
withLIDProtocol() {
|
|
85
|
-
this.protocols.push(new
|
|
90
|
+
this.protocols.push(new USyncLIDProtocol());
|
|
86
91
|
return this;
|
|
87
92
|
}
|
|
88
|
-
}
|
|
89
|
-
exports.USyncQuery = USyncQuery;
|
|
93
|
+
}
|
package/lib/WAUSync/USyncUser.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.USyncUser = void 0;
|
|
4
|
-
class USyncUser {
|
|
1
|
+
export class USyncUser {
|
|
5
2
|
withId(id) {
|
|
6
3
|
this.id = id;
|
|
7
4
|
return this;
|
|
@@ -22,5 +19,4 @@ class USyncUser {
|
|
|
22
19
|
this.personaId = personaId;
|
|
23
20
|
return this;
|
|
24
21
|
}
|
|
25
|
-
}
|
|
26
|
-
exports.USyncUser = USyncUser;
|
|
22
|
+
}
|
package/lib/WAUSync/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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);
|
|
1
|
+
export * from './Protocols/index.js';
|
|
2
|
+
export * from './USyncQuery.js';
|
|
3
|
+
export * from './USyncUser.js';
|
package/lib/index.js
CHANGED
|
@@ -1,44 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
25
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
26
|
-
};
|
|
27
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
|
-
};
|
|
30
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.makeWASocket = void 0;
|
|
32
|
-
const Socket_1 = __importDefault(require("./Socket"));
|
|
33
|
-
exports.makeWASocket = Socket_1.default;
|
|
34
|
-
__exportStar(require("../WAProto"), exports);
|
|
35
|
-
__exportStar(require("./Utils"), exports);
|
|
36
|
-
__exportStar(require("./Types"), exports);
|
|
37
|
-
__exportStar(require("./Store"), exports);
|
|
38
|
-
__exportStar(require("./Defaults"), exports);
|
|
39
|
-
__exportStar(require("./WABinary"), exports);
|
|
40
|
-
__exportStar(require("./WAM"), exports);
|
|
41
|
-
__exportStar(require("./WAUSync"), exports);
|
|
42
|
-
__exportStar(require("./Signal/lid-mapping"), exports);
|
|
43
|
-
|
|
44
|
-
exports.default = Socket_1.default;
|
|
1
|
+
import makeWASocket from './Socket/index.js';
|
|
2
|
+
export * from '../WAProto/index.js';
|
|
3
|
+
export * from './Utils/index.js';
|
|
4
|
+
export * from './Types/index.js';
|
|
5
|
+
export * from './Defaults/index.js';
|
|
6
|
+
export * from './Store/index.js';
|
|
7
|
+
export * from './WABinary/index.js';
|
|
8
|
+
export * from './WAM/index.js';
|
|
9
|
+
export * from './WAUSync/index.js';
|
|
10
|
+
export { makeWASocket };
|
|
11
|
+
export default makeWASocket;
|