@skyzopedia/baileys-mod 5.0.8 → 6.0.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/WAProto/index.js +133384 -57814
- package/engine-requirements.js +10 -0
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.d.ts +53 -0
- package/lib/Defaults/index.js +141 -117
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/ciphertext-message.js +14 -12
- package/lib/Signal/Group/group-session-builder.d.ts +14 -0
- package/lib/Signal/Group/group-session-builder.js +42 -10
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.js +87 -75
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/index.js +57 -13
- package/lib/Signal/Group/keyhelper.d.ts +10 -0
- package/lib/Signal/Group/keyhelper.js +52 -17
- package/lib/Signal/Group/queue-job.d.ts +1 -0
- package/lib/Signal/Group/queue-job.js +57 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/lib/Signal/Group/sender-chain-key.js +33 -27
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +63 -62
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-message.js +66 -65
- package/lib/Signal/Group/sender-key-name.d.ts +17 -0
- package/lib/Signal/Group/sender-key-name.js +44 -45
- package/lib/Signal/Group/sender-key-record.d.ts +30 -0
- package/lib/Signal/Group/sender-key-record.js +49 -39
- package/lib/Signal/Group/sender-key-state.d.ts +38 -0
- package/lib/Signal/Group/sender-key-state.js +93 -80
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/lib/Signal/Group/sender-message-key.js +28 -27
- package/lib/Signal/libsignal.d.ts +3 -0
- package/lib/Signal/libsignal.js +163 -313
- package/lib/Socket/Client/abstract-socket-client.d.ts +17 -0
- package/lib/Socket/Client/abstract-socket-client.js +13 -0
- package/lib/Socket/Client/index.d.ts +3 -0
- package/lib/Socket/Client/index.js +19 -4
- package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/web-socket-client.d.ts +12 -0
- package/lib/Socket/Client/web-socket-client.js +62 -0
- package/lib/Socket/business.d.ts +171 -0
- package/lib/Socket/business.js +242 -359
- package/lib/Socket/chats.d.ts +267 -0
- package/lib/Socket/chats.js +935 -846
- package/lib/Socket/dugong.d.ts +254 -0
- package/lib/Socket/dugong.js +484 -0
- package/lib/Socket/groups.d.ts +115 -0
- package/lib/Socket/groups.js +309 -304
- package/lib/Socket/index.d.ts +173 -0
- package/lib/Socket/index.js +10 -15
- package/lib/Socket/messages-recv.d.ts +161 -0
- package/lib/Socket/messages-recv.js +1054 -1107
- package/lib/Socket/messages-send.d.ts +149 -0
- package/lib/Socket/messages-send.js +447 -706
- package/lib/Socket/newsletter.d.ts +134 -0
- package/lib/Socket/newsletter.js +314 -199
- package/lib/Socket/registration.d.ts +267 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +43 -0
- package/lib/Socket/socket.js +650 -777
- package/lib/Socket/usync.d.ts +36 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/index.js +10 -6
- package/lib/Store/make-cache-manager-store.d.ts +13 -0
- package/lib/Store/make-cache-manager-store.js +81 -73
- package/lib/Store/make-in-memory-store.d.ts +118 -0
- package/lib/Store/make-in-memory-store.js +423 -286
- package/lib/Store/make-ordered-dictionary.d.ts +13 -0
- package/lib/Store/make-ordered-dictionary.js +79 -77
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Store/object-repository.js +26 -24
- package/lib/Types/Auth.d.ts +110 -0
- package/lib/Types/Auth.js +2 -3
- package/lib/Types/Call.d.ts +13 -0
- package/lib/Types/Call.js +2 -3
- package/lib/Types/Chat.d.ts +102 -0
- package/lib/Types/Chat.js +4 -9
- package/lib/Types/Contact.d.ts +19 -0
- package/lib/Types/Contact.js +2 -3
- package/lib/Types/Events.d.ts +157 -0
- package/lib/Types/Events.js +2 -3
- package/lib/Types/GroupMetadata.d.ts +55 -0
- package/lib/Types/GroupMetadata.js +2 -3
- package/lib/Types/Label.d.ts +35 -0
- package/lib/Types/Label.js +26 -24
- package/lib/Types/LabelAssociation.d.ts +29 -0
- package/lib/Types/LabelAssociation.js +8 -6
- package/lib/Types/Message.d.ts +273 -0
- package/lib/Types/Message.js +9 -12
- package/lib/Types/Newsletter.d.ts +103 -0
- package/lib/Types/Newsletter.js +38 -33
- package/lib/Types/Product.d.ts +78 -0
- package/lib/Types/Product.js +2 -3
- package/lib/Types/Signal.d.ts +57 -0
- package/lib/Types/Signal.js +2 -3
- package/lib/Types/Socket.d.ts +111 -0
- package/lib/Types/Socket.js +2 -4
- package/lib/Types/State.d.ts +27 -0
- package/lib/Types/State.js +2 -11
- package/lib/Types/USync.d.ts +25 -0
- package/lib/Types/USync.js +2 -3
- package/lib/Types/index.d.ts +57 -0
- package/lib/Types/index.js +41 -27
- package/lib/Utils/auth-utils.d.ts +18 -0
- package/lib/Utils/auth-utils.js +198 -211
- package/lib/Utils/baileys-event-stream.d.ts +16 -0
- package/lib/Utils/baileys-event-stream.js +61 -42
- package/lib/Utils/business.d.ts +22 -0
- package/lib/Utils/business.js +214 -213
- package/lib/Utils/chat-utils.d.ts +71 -0
- package/lib/Utils/chat-utils.js +687 -710
- package/lib/Utils/crypto.d.ts +41 -0
- package/lib/Utils/crypto.js +133 -112
- package/lib/Utils/decode-wa-message.d.ts +19 -0
- package/lib/Utils/decode-wa-message.js +183 -252
- package/lib/Utils/event-buffer.d.ts +35 -0
- package/lib/Utils/event-buffer.js +496 -510
- package/lib/Utils/generics.d.ts +92 -0
- package/lib/Utils/generics.js +387 -319
- package/lib/Utils/history.d.ts +15 -0
- package/lib/Utils/history.js +92 -83
- package/lib/Utils/index.d.ts +17 -0
- package/lib/Utils/index.js +33 -21
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/link-preview.js +83 -71
- package/lib/Utils/logger.d.ts +4 -0
- package/lib/Utils/logger.js +7 -5
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/lt-hash.js +46 -40
- package/lib/Utils/make-mutex.d.ts +7 -0
- package/lib/Utils/make-mutex.js +41 -34
- package/lib/Utils/messages-media.d.ts +116 -0
- package/lib/Utils/messages-media.js +768 -550
- package/lib/Utils/messages.d.ts +77 -0
- package/lib/Utils/messages.js +263 -362
- package/lib/Utils/noise-handler.d.ts +21 -0
- package/lib/Utils/noise-handler.js +149 -138
- package/lib/Utils/process-message.d.ts +41 -0
- package/lib/Utils/process-message.js +303 -323
- package/lib/Utils/signal.d.ts +32 -0
- package/lib/Utils/signal.js +141 -149
- package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
- package/lib/Utils/use-multi-file-auth-state.js +103 -95
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/lib/Utils/validate-connection.js +220 -183
- package/lib/WABinary/constants.d.ts +30 -0
- package/lib/WABinary/constants.js +35 -1298
- package/lib/WABinary/decode.d.ts +7 -0
- package/lib/WABinary/decode.js +249 -237
- package/lib/WABinary/encode.d.ts +3 -0
- package/lib/WABinary/encode.js +260 -213
- package/lib/WABinary/generic-utils.d.ts +17 -0
- package/lib/WABinary/generic-utils.js +65 -56
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/index.js +21 -7
- package/lib/WABinary/jid-utils.d.ts +31 -0
- package/lib/WABinary/jid-utils.js +58 -89
- package/lib/WABinary/types.d.ts +18 -0
- package/lib/WABinary/types.js +2 -3
- package/lib/WAM/BinaryInfo.d.ts +17 -0
- package/lib/WAM/BinaryInfo.js +12 -10
- package/lib/WAM/constants.d.ts +38 -0
- package/lib/WAM/constants.js +15348 -22851
- package/lib/WAM/encode.d.ts +3 -0
- package/lib/WAM/encode.js +136 -135
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAM/index.js +19 -5
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +30 -28
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +53 -49
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +28 -27
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +39 -36
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -50
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +20 -26
- package/lib/WAUSync/Protocols/index.d.ts +4 -0
- package/lib/WAUSync/Protocols/index.js +20 -6
- package/lib/WAUSync/USyncQuery.d.ts +28 -0
- package/lib/WAUSync/USyncQuery.js +85 -86
- package/lib/WAUSync/USyncUser.d.ts +12 -0
- package/lib/WAUSync/USyncUser.js +25 -23
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/WAUSync/index.js +19 -5
- package/lib/index.d.ts +12 -0
- package/lib/index.js +36 -24
- package/package.json +106 -98
- package/LICENSE +0 -21
- package/WAProto/WAProto.proto +0 -5311
- package/lib/KeyDB/BinarySearch.js +0 -20
- package/lib/KeyDB/KeyedDB.js +0 -167
- package/lib/KeyDB/index.js +0 -4
- package/lib/Signal/lid-mapping.js +0 -155
- package/lib/Socket/Client/types.js +0 -13
- package/lib/Socket/Client/websocket.js +0 -52
- package/lib/Socket/Client/websocket.js.bak +0 -53
- package/lib/Socket/communities.js +0 -413
- package/lib/Socket/mex.js +0 -45
- package/lib/Types/Bussines.js +0 -3
- package/lib/Types/Newsletter.js.bak +0 -33
- package/lib/Utils/browser-utils.js +0 -25
- package/lib/Utils/message-retry-manager.js +0 -113
- package/lib/Utils/messages.js.bak +0 -907
- package/lib/Utils/pre-key-manager.js +0 -85
|
@@ -1,39 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.USyncStatusProtocol = void 0;
|
|
4
|
+
const WABinary_1 = require("../../WABinary");
|
|
5
|
+
class USyncStatusProtocol {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.name = 'status';
|
|
8
|
+
}
|
|
9
|
+
getQueryElement() {
|
|
10
|
+
return {
|
|
11
|
+
tag: 'status',
|
|
12
|
+
attrs: {},
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
getUserElement() {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
parser(node) {
|
|
19
|
+
var _a, _b, _c;
|
|
20
|
+
if (node.tag === 'status') {
|
|
21
|
+
(0, WABinary_1.assertNodeErrorFree)(node);
|
|
22
|
+
let status = (_b = (_a = node === null || node === void 0 ? void 0 : node.content) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : null;
|
|
23
|
+
const setAt = new Date(+((node === null || node === void 0 ? void 0 : node.attrs.t) || 0) * 1000);
|
|
24
|
+
if (!status) {
|
|
25
|
+
if (+((_c = node.attrs) === null || _c === void 0 ? void 0 : _c.code) === 401) {
|
|
26
|
+
status = '';
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
status = null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else if (typeof status === 'string' && status.length === 0) {
|
|
33
|
+
status = null;
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
status,
|
|
37
|
+
setAt,
|
|
38
|
+
};
|
|
27
39
|
}
|
|
28
|
-
}
|
|
29
|
-
else if (typeof status === "string" && status.length === 0) {
|
|
30
|
-
status = null;
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
status,
|
|
34
|
-
setAt
|
|
35
|
-
};
|
|
36
40
|
}
|
|
37
|
-
}
|
|
38
41
|
}
|
|
39
|
-
|
|
42
|
+
exports.USyncStatusProtocol = USyncStatusProtocol;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { USyncQueryProtocol } from '../../Types/USync';
|
|
2
|
+
import { BinaryNode } from '../../WABinary';
|
|
3
|
+
import { USyncUser } from '../USyncUser';
|
|
4
|
+
export type BotProfileCommand = {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
export type BotProfileInfo = {
|
|
9
|
+
jid: string;
|
|
10
|
+
name: string;
|
|
11
|
+
attributes: string;
|
|
12
|
+
description: string;
|
|
13
|
+
category: string;
|
|
14
|
+
isDefault: boolean;
|
|
15
|
+
prompts: string[];
|
|
16
|
+
personaId: string;
|
|
17
|
+
commands: BotProfileCommand[];
|
|
18
|
+
commandsDescription: string;
|
|
19
|
+
};
|
|
20
|
+
export declare class USyncBotProfileProtocol implements USyncQueryProtocol {
|
|
21
|
+
name: string;
|
|
22
|
+
getQueryElement(): BinaryNode;
|
|
23
|
+
getUserElement(user: USyncUser): BinaryNode;
|
|
24
|
+
parser(node: BinaryNode): BotProfileInfo;
|
|
25
|
+
}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
getQueryElement() {
|
|
10
|
-
return {
|
|
11
|
-
tag: "bot",
|
|
12
|
-
attrs: {},
|
|
13
|
-
content: [{ tag: "profile", attrs: { v: "1" } }]
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
getUserElement(user) {
|
|
17
|
-
return {
|
|
18
|
-
tag: "bot",
|
|
19
|
-
attrs: {},
|
|
20
|
-
content: [{ tag: "profile", attrs: { persona_id: user.personaId } }]
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
parser(node) {
|
|
24
|
-
const botNode = getBinaryNodeChild(node, "bot");
|
|
25
|
-
const profile = getBinaryNodeChild(botNode, "profile");
|
|
26
|
-
const commandsNode = getBinaryNodeChild(profile, "commands");
|
|
27
|
-
const promptsNode = getBinaryNodeChild(profile, "prompts");
|
|
28
|
-
const commands = [];
|
|
29
|
-
const prompts = [];
|
|
30
|
-
for (const command of getBinaryNodeChildren(commandsNode, "command")) {
|
|
31
|
-
commands.push({
|
|
32
|
-
name: getBinaryNodeChildString(command, "name"),
|
|
33
|
-
description: getBinaryNodeChildString(command, "description")
|
|
34
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.USyncBotProfileProtocol = void 0;
|
|
4
|
+
const WABinary_1 = require("../../WABinary");
|
|
5
|
+
class USyncBotProfileProtocol {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.name = 'bot';
|
|
35
8
|
}
|
|
36
|
-
|
|
37
|
-
|
|
9
|
+
getQueryElement() {
|
|
10
|
+
return {
|
|
11
|
+
tag: 'bot',
|
|
12
|
+
attrs: {},
|
|
13
|
+
content: [{ tag: 'profile', attrs: { v: '1' } }]
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
getUserElement(user) {
|
|
17
|
+
return {
|
|
18
|
+
tag: 'bot',
|
|
19
|
+
attrs: {},
|
|
20
|
+
content: [{ tag: 'profile', attrs: { 'persona_id': user.personaId } }]
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
parser(node) {
|
|
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');
|
|
28
|
+
const commands = [];
|
|
29
|
+
const prompts = [];
|
|
30
|
+
for (const command of (0, WABinary_1.getBinaryNodeChildren)(commandsNode, 'command')) {
|
|
31
|
+
commands.push({
|
|
32
|
+
name: (0, WABinary_1.getBinaryNodeChildString)(command, 'name'),
|
|
33
|
+
description: (0, WABinary_1.getBinaryNodeChildString)(command, 'description')
|
|
34
|
+
});
|
|
35
|
+
}
|
|
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')}`);
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
isDefault: !!(0, WABinary_1.getBinaryNodeChild)(profile, 'default'),
|
|
41
|
+
jid: node.attrs.jid,
|
|
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'),
|
|
46
|
+
personaId: profile.attrs['persona_id'],
|
|
47
|
+
commandsDescription: (0, WABinary_1.getBinaryNodeChildString)(commandsNode, 'description'),
|
|
48
|
+
commands,
|
|
49
|
+
prompts
|
|
50
|
+
};
|
|
38
51
|
}
|
|
39
|
-
return {
|
|
40
|
-
isDefault: !!getBinaryNodeChild(profile, "default"),
|
|
41
|
-
jid: node.attrs.jid,
|
|
42
|
-
name: getBinaryNodeChildString(profile, "name"),
|
|
43
|
-
attributes: getBinaryNodeChildString(profile, "attributes"),
|
|
44
|
-
description: getBinaryNodeChildString(profile, "description"),
|
|
45
|
-
category: getBinaryNodeChildString(profile, "category"),
|
|
46
|
-
personaId: profile.attrs["persona_id"],
|
|
47
|
-
commandsDescription: getBinaryNodeChildString(commandsNode, "description"),
|
|
48
|
-
commands,
|
|
49
|
-
prompts
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
exports.USyncBotProfileProtocol = USyncBotProfileProtocol;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { USyncQueryProtocol } from '../../Types/USync';
|
|
2
|
+
import { BinaryNode } from '../../WABinary';
|
|
3
|
+
export declare class USyncLIDProtocol implements USyncQueryProtocol {
|
|
4
|
+
name: string;
|
|
5
|
+
getQueryElement(): BinaryNode;
|
|
6
|
+
getUserElement(): null;
|
|
7
|
+
parser(node: BinaryNode): string | null;
|
|
8
|
+
}
|
|
@@ -1,30 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return {
|
|
8
|
-
tag: "lid",
|
|
9
|
-
attrs: {}
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
getUserElement(user) {
|
|
13
|
-
if (user.lid) {
|
|
14
|
-
return {
|
|
15
|
-
tag: "lid",
|
|
16
|
-
attrs: { jid: user.lid }
|
|
17
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.USyncLIDProtocol = void 0;
|
|
4
|
+
class USyncLIDProtocol {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'lid';
|
|
18
7
|
}
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
getQueryElement() {
|
|
9
|
+
return {
|
|
10
|
+
tag: 'lid',
|
|
11
|
+
attrs: {},
|
|
12
|
+
};
|
|
21
13
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
getUserElement() {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
parser(node) {
|
|
18
|
+
if (node.tag === 'lid') {
|
|
19
|
+
return node.attrs.val;
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
26
22
|
}
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
23
|
}
|
|
30
|
-
|
|
24
|
+
exports.USyncLIDProtocol = USyncLIDProtocol;
|
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { USyncQueryProtocol } from '../Types/USync';
|
|
2
|
+
import { BinaryNode } from '../WABinary';
|
|
3
|
+
import { USyncUser } from './USyncUser';
|
|
4
|
+
export type USyncQueryResultList = {
|
|
5
|
+
[protocol: string]: unknown;
|
|
6
|
+
id: string;
|
|
7
|
+
};
|
|
8
|
+
export type USyncQueryResult = {
|
|
9
|
+
list: USyncQueryResultList[];
|
|
10
|
+
sideList: USyncQueryResultList[];
|
|
11
|
+
};
|
|
12
|
+
export declare class USyncQuery {
|
|
13
|
+
protocols: USyncQueryProtocol[];
|
|
14
|
+
users: USyncUser[];
|
|
15
|
+
context: string;
|
|
16
|
+
mode: string;
|
|
17
|
+
constructor();
|
|
18
|
+
withMode(mode: string): this;
|
|
19
|
+
withContext(context: string): this;
|
|
20
|
+
withUser(user: USyncUser): this;
|
|
21
|
+
parseUSyncQueryResult(result: BinaryNode): USyncQueryResult | undefined;
|
|
22
|
+
withDeviceProtocol(): this;
|
|
23
|
+
withContactProtocol(): this;
|
|
24
|
+
withStatusProtocol(): this;
|
|
25
|
+
withDisappearingModeProtocol(): this;
|
|
26
|
+
withBotProfileProtocol(): this;
|
|
27
|
+
withLIDProtocol(): this;
|
|
28
|
+
}
|
|
@@ -1,90 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
withMode(mode) {
|
|
16
|
-
this.mode = mode;
|
|
17
|
-
return this;
|
|
18
|
-
}
|
|
19
|
-
withContext(context) {
|
|
20
|
-
this.context = context;
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
|
-
withUser(user) {
|
|
24
|
-
this.users.push(user);
|
|
25
|
-
return this;
|
|
26
|
-
}
|
|
27
|
-
parseUSyncQueryResult(result) {
|
|
28
|
-
if (!result || result.attrs.type !== "result") {
|
|
29
|
-
return;
|
|
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 {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.protocols = [];
|
|
11
|
+
this.users = [];
|
|
12
|
+
this.context = 'interactive';
|
|
13
|
+
this.mode = 'query';
|
|
30
14
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
.map(content => {
|
|
47
|
-
const protocol = content.tag;
|
|
48
|
-
const parser = protocolMap[protocol];
|
|
49
|
-
if (parser) {
|
|
50
|
-
return [protocol, parser(content)];
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
return [protocol, null];
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
.filter(([, b]) => b !== null))
|
|
57
|
-
: {};
|
|
58
|
-
acc.push({ ...data, id });
|
|
15
|
+
withMode(mode) {
|
|
16
|
+
this.mode = mode;
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
withContext(context) {
|
|
20
|
+
this.context = context;
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
withUser(user) {
|
|
24
|
+
this.users.push(user);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
parseUSyncQueryResult(result) {
|
|
28
|
+
if (result.attrs.type !== 'result') {
|
|
29
|
+
return;
|
|
59
30
|
}
|
|
60
|
-
|
|
61
|
-
|
|
31
|
+
const protocolMap = Object.fromEntries(this.protocols.map((protocol) => {
|
|
32
|
+
return [protocol.name, protocol.parser];
|
|
33
|
+
}));
|
|
34
|
+
const queryResult = {
|
|
35
|
+
// TODO: implement errors etc.
|
|
36
|
+
list: [],
|
|
37
|
+
sideList: [],
|
|
38
|
+
};
|
|
39
|
+
const usyncNode = (0, WABinary_1.getBinaryNodeChild)(result, 'usync');
|
|
40
|
+
//TODO: implement error backoff, refresh etc.
|
|
41
|
+
//TODO: see if there are any errors in the result node
|
|
42
|
+
//const resultNode = getBinaryNodeChild(usyncNode, 'result')
|
|
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)) : {};
|
|
57
|
+
return { ...data, id };
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//TODO: implement side list
|
|
61
|
+
//const sideListNode = getBinaryNodeChild(usyncNode, 'side_list')
|
|
62
|
+
return queryResult;
|
|
63
|
+
}
|
|
64
|
+
withDeviceProtocol() {
|
|
65
|
+
this.protocols.push(new Protocols_1.USyncDeviceProtocol());
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
withContactProtocol() {
|
|
69
|
+
this.protocols.push(new Protocols_1.USyncContactProtocol());
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
withStatusProtocol() {
|
|
73
|
+
this.protocols.push(new Protocols_1.USyncStatusProtocol());
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
withDisappearingModeProtocol() {
|
|
77
|
+
this.protocols.push(new Protocols_1.USyncDisappearingModeProtocol());
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
withBotProfileProtocol() {
|
|
81
|
+
this.protocols.push(new UsyncBotProfileProtocol_1.USyncBotProfileProtocol());
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
withLIDProtocol() {
|
|
85
|
+
this.protocols.push(new UsyncLIDProtocol_1.USyncLIDProtocol());
|
|
86
|
+
return this;
|
|
62
87
|
}
|
|
63
|
-
return queryResult;
|
|
64
|
-
}
|
|
65
|
-
withDeviceProtocol() {
|
|
66
|
-
this.protocols.push(new USyncDeviceProtocol());
|
|
67
|
-
return this;
|
|
68
|
-
}
|
|
69
|
-
withContactProtocol() {
|
|
70
|
-
this.protocols.push(new USyncContactProtocol());
|
|
71
|
-
return this;
|
|
72
|
-
}
|
|
73
|
-
withStatusProtocol() {
|
|
74
|
-
this.protocols.push(new USyncStatusProtocol());
|
|
75
|
-
return this;
|
|
76
|
-
}
|
|
77
|
-
withDisappearingModeProtocol() {
|
|
78
|
-
this.protocols.push(new USyncDisappearingModeProtocol());
|
|
79
|
-
return this;
|
|
80
|
-
}
|
|
81
|
-
withBotProfileProtocol() {
|
|
82
|
-
this.protocols.push(new USyncBotProfileProtocol());
|
|
83
|
-
return this;
|
|
84
|
-
}
|
|
85
|
-
withLIDProtocol() {
|
|
86
|
-
this.protocols.push(new USyncLIDProtocol());
|
|
87
|
-
return this;
|
|
88
|
-
}
|
|
89
88
|
}
|
|
90
|
-
|
|
89
|
+
exports.USyncQuery = USyncQuery;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class USyncUser {
|
|
2
|
+
id: string;
|
|
3
|
+
lid: string;
|
|
4
|
+
phone: string;
|
|
5
|
+
type: string;
|
|
6
|
+
personaId: string;
|
|
7
|
+
withId(id: string): this;
|
|
8
|
+
withLid(lid: string): this;
|
|
9
|
+
withPhone(phone: string): this;
|
|
10
|
+
withType(type: string): this;
|
|
11
|
+
withPersonaId(personaId: string): this;
|
|
12
|
+
}
|
package/lib/WAUSync/USyncUser.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.USyncUser = void 0;
|
|
4
|
+
class USyncUser {
|
|
5
|
+
withId(id) {
|
|
6
|
+
this.id = id;
|
|
7
|
+
return this;
|
|
8
|
+
}
|
|
9
|
+
withLid(lid) {
|
|
10
|
+
this.lid = lid;
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
withPhone(phone) {
|
|
14
|
+
this.phone = phone;
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
withType(type) {
|
|
18
|
+
this.type = type;
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
withPersonaId(personaId) {
|
|
22
|
+
this.personaId = personaId;
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
23
25
|
}
|
|
24
|
-
|
|
26
|
+
exports.USyncUser = USyncUser;
|
package/lib/WAUSync/index.js
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
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("./Protocols"), exports);
|
|
18
|
+
__exportStar(require("./USyncQuery"), exports);
|
|
19
|
+
__exportStar(require("./USyncUser"), exports);
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import makeWASocket from './Socket';
|
|
2
|
+
export * from '../WAProto';
|
|
3
|
+
export * from './Utils';
|
|
4
|
+
export * from './Types';
|
|
5
|
+
export * from './Store';
|
|
6
|
+
export * from './Defaults';
|
|
7
|
+
export * from './WABinary';
|
|
8
|
+
export * from './WAM';
|
|
9
|
+
export * from './WAUSync';
|
|
10
|
+
export type WASocket = ReturnType<typeof makeWASocket>;
|
|
11
|
+
export { makeWASocket };
|
|
12
|
+
export default makeWASocket;
|