@genuxofficial/baileys 2.0.0 → 3.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/LICENSE +1 -1
- package/WAProto/WAProto.proto +4633 -0
- package/engine-requirements.js +1 -1
- package/lib/Defaults/index.d.ts +5 -3
- package/lib/Defaults/index.js +7 -7
- package/lib/Signal/libsignal.js +9 -18
- package/lib/Socket/Client/types.d.ts +2 -0
- package/lib/Socket/Client/websocket.js +1 -1
- package/lib/Socket/business.d.ts +40 -38
- package/lib/Socket/chats.d.ts +17 -20
- package/lib/Socket/chats.js +1 -85
- package/lib/Socket/groups.d.ts +25 -28
- package/lib/Socket/groups.js +9 -10
- package/lib/Socket/index.d.ts +46 -44
- package/lib/Socket/messages-recv.d.ts +37 -36
- package/lib/Socket/messages-recv.js +14 -26
- package/lib/Socket/messages-send.d.ts +35 -33
- package/lib/Socket/messages-send.js +10 -8
- package/lib/Socket/newsletter.d.ts +28 -31
- package/lib/Socket/newsletter.js +21 -17
- package/lib/Socket/socket.d.ts +7 -5
- package/lib/Socket/socket.js +1 -1
- package/lib/Socket/usync.d.ts +11 -9
- package/lib/Socket/usync.js +15 -10
- package/lib/Store/make-in-memory-store.d.ts +1 -1
- package/lib/Store/make-ordered-dictionary.d.ts +1 -1
- package/lib/Types/Auth.d.ts +2 -0
- package/lib/Types/Chat.d.ts +2 -8
- package/lib/Types/Contact.d.ts +0 -5
- package/lib/Types/GroupMetadata.d.ts +4 -5
- package/lib/Types/Label.d.ts +0 -11
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Message.d.ts +27 -2
- package/lib/Types/Newsletter.js +2 -2
- package/lib/Types/Socket.d.ts +2 -0
- package/lib/Types/index.js +1 -1
- package/lib/Utils/auth-utils.js +3 -3
- package/lib/Utils/business.js +17 -5
- package/lib/Utils/chat-utils.d.ts +10 -8
- package/lib/Utils/chat-utils.js +0 -27
- package/lib/Utils/crypto.d.ts +16 -14
- package/lib/Utils/crypto.js +22 -34
- package/lib/Utils/decode-wa-message.d.ts +1 -1
- package/lib/Utils/decode-wa-message.js +16 -31
- package/lib/Utils/generics.d.ts +8 -33
- package/lib/Utils/generics.js +12 -98
- package/lib/Utils/link-preview.js +1 -34
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/messages-media.d.ts +19 -29
- package/lib/Utils/messages-media.js +87 -151
- package/lib/Utils/messages.d.ts +8 -5
- package/lib/Utils/messages.js +20 -28
- package/lib/Utils/noise-handler.d.ts +6 -4
- package/lib/Utils/process-message.js +2 -2
- package/lib/Utils/validate-connection.d.ts +2 -2
- package/lib/WABinary/decode.d.ts +4 -2
- package/lib/WABinary/decode.js +7 -17
- package/lib/WABinary/encode.d.ts +3 -1
- package/lib/WABinary/encode.js +7 -17
- package/lib/WABinary/generic-utils.d.ts +6 -6
- package/lib/WABinary/generic-utils.js +36 -21
- package/lib/WABinary/jid-utils.d.ts +6 -2
- package/lib/WABinary/jid-utils.js +5 -1
- package/lib/WAM/BinaryInfo.d.ts +12 -2
- package/lib/WAM/encode.d.ts +3 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +23 -14
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -2
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +1 -1
- package/lib/WAUSync/USyncQuery.js +13 -17
- package/package.json +59 -53
- package/lib/Store/make-cache-manager-store.d.ts +0 -14
- package/lib/Store/make-cache-manager-store.js +0 -83
@@ -28,13 +28,13 @@ class USyncQuery {
|
|
28
28
|
if (result.attrs.type !== 'result') {
|
29
29
|
return;
|
30
30
|
}
|
31
|
-
const protocolMap = Object.fromEntries(this.protocols.map(protocol => {
|
31
|
+
const protocolMap = Object.fromEntries(this.protocols.map((protocol) => {
|
32
32
|
return [protocol.name, protocol.parser];
|
33
33
|
}));
|
34
34
|
const queryResult = {
|
35
35
|
// TODO: implement errors etc.
|
36
36
|
list: [],
|
37
|
-
sideList: []
|
37
|
+
sideList: [],
|
38
38
|
};
|
39
39
|
const usyncNode = (0, WABinary_1.getBinaryNodeChild)(result, 'usync');
|
40
40
|
//TODO: implement error backoff, refresh etc.
|
@@ -42,22 +42,18 @@ class USyncQuery {
|
|
42
42
|
//const resultNode = getBinaryNodeChild(usyncNode, 'result')
|
43
43
|
const listNode = (0, WABinary_1.getBinaryNodeChild)(usyncNode, 'list');
|
44
44
|
if (Array.isArray(listNode === null || listNode === void 0 ? void 0 : listNode.content) && typeof listNode !== 'undefined') {
|
45
|
-
queryResult.list = listNode.content.map(node => {
|
45
|
+
queryResult.list = listNode.content.map((node) => {
|
46
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)
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
}
|
58
|
-
})
|
59
|
-
.filter(([, b]) => b !== null))
|
60
|
-
: {};
|
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)) : {};
|
61
57
|
return { ...data, id };
|
62
58
|
});
|
63
59
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@genuxofficial/baileys",
|
3
|
-
"version": "
|
4
|
-
"description": "
|
3
|
+
"version": "3.0.0",
|
4
|
+
"description": "WhatsApp API",
|
5
5
|
"keywords": [
|
6
6
|
"baileys",
|
7
7
|
"baileys-mod",
|
@@ -16,7 +16,7 @@
|
|
16
16
|
],
|
17
17
|
"homepage": "https://github.com/genux-official/Baileys",
|
18
18
|
"repository": {
|
19
|
-
"url": "
|
19
|
+
"url": "https://github.com/genux-official/Baileys.git"
|
20
20
|
},
|
21
21
|
"license": "MIT",
|
22
22
|
"author": "Genux Official",
|
@@ -24,83 +24,89 @@
|
|
24
24
|
"types": "lib/index.d.ts",
|
25
25
|
"files": [
|
26
26
|
"lib/*",
|
27
|
-
"WAProto
|
28
|
-
"WAProto/*.js",
|
27
|
+
"WAProto/*",
|
29
28
|
"WASignalGroup/*.js",
|
30
29
|
"engine-requirements.js"
|
31
30
|
],
|
31
|
+
"scripts": {
|
32
|
+
"build:all": "tsc && typedoc",
|
33
|
+
"build:docs": "typedoc",
|
34
|
+
"build:tsc": "tsc",
|
35
|
+
"changelog:last": "conventional-changelog -p angular -r 2",
|
36
|
+
"changelog:preview": "conventional-changelog -p angular -u",
|
37
|
+
"changelog:update": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
|
38
|
+
"example": "node --inspect -r ts-node/register Example/example.ts",
|
39
|
+
"gen:protobuf": "sh WAProto/GenerateStatics.sh",
|
40
|
+
"lint": "eslint src --ext .js,.ts,.jsx,.tsx",
|
41
|
+
"lint:fix": "eslint src --fix --ext .js,.ts,.jsx,.tsx",
|
42
|
+
"prepack": "tsc",
|
43
|
+
"prepare": "tsc",
|
44
|
+
"release": "release-it",
|
45
|
+
"test": "jest"
|
46
|
+
},
|
32
47
|
"dependencies": {
|
33
48
|
"@adiwajshing/keyed-db": "^0.2.4",
|
34
|
-
"@
|
35
|
-
"@queenanya/eslint-config": "github:whiskeysockets/eslint-config",
|
36
|
-
"@hapi/boom": "^10.0.1",
|
37
|
-
"async-lock": "^1.4.1",
|
49
|
+
"@hapi/boom": "^9.1.3",
|
38
50
|
"async-mutex": "^0.5.0",
|
51
|
+
"async-lock": "^1.4.1",
|
52
|
+
"futoin-hkdf": "^1.5.1",
|
39
53
|
"audio-decode": "^2.1.3",
|
40
|
-
"axios": "^1.
|
54
|
+
"axios": "^1.6.0",
|
41
55
|
"cache-manager": "^5.7.6",
|
42
|
-
"
|
56
|
+
"libphonenumber-js": "^1.10.20",
|
57
|
+
"libsignal": "git+https://github.com/WhiskeySockets/libsignal-node.git",
|
43
58
|
"lodash": "^4.17.21",
|
44
59
|
"music-metadata": "^7.12.3",
|
60
|
+
"@cacheable/node-cache": "^1.4.0",
|
45
61
|
"pino": "^9.6",
|
46
|
-
"protobufjs": "^
|
47
|
-
"
|
48
|
-
"ws": "^8.
|
62
|
+
"protobufjs": "^6.11.3",
|
63
|
+
"uuid": "^10.0.0",
|
64
|
+
"ws": "^8.13.0"
|
49
65
|
},
|
50
66
|
"devDependencies": {
|
51
|
-
"@
|
52
|
-
"@types/
|
53
|
-
"@types/
|
54
|
-
"
|
55
|
-
"
|
56
|
-
"
|
57
|
-
"
|
67
|
+
"@adiwajshing/eslint-config": "https://github.com/adiwajshing/eslint-config.git",
|
68
|
+
"@types/got": "^9.6.11",
|
69
|
+
"@types/jest": "^27.5.1",
|
70
|
+
"@types/node": "^16.0.0",
|
71
|
+
"@types/sharp": "^0.29.4",
|
72
|
+
"@types/ws": "^8.0.0",
|
73
|
+
"conventional-changelog-cli": "^2.2.2",
|
74
|
+
"eslint": "^8.0.0",
|
75
|
+
"jest": "^27.0.6",
|
76
|
+
"jimp": "^0.16.1",
|
58
77
|
"json": "^11.0.0",
|
59
|
-
"link-preview-js": "^3.0.
|
60
|
-
"open": "^
|
61
|
-
"
|
62
|
-
"release-it": "^
|
63
|
-
"sharp": "^0.
|
64
|
-
"ts-jest": "^
|
65
|
-
"ts-node": "^10.
|
66
|
-
"typedoc": "^0.
|
67
|
-
"
|
68
|
-
"typescript": "^5.8.2"
|
78
|
+
"link-preview-js": "^3.0.0",
|
79
|
+
"open": "^8.4.2",
|
80
|
+
"qrcode-terminal": "^0.12.0",
|
81
|
+
"release-it": "^15.10.3",
|
82
|
+
"sharp": "^0.32.6",
|
83
|
+
"ts-jest": "^27.0.3",
|
84
|
+
"ts-node": "^10.8.1",
|
85
|
+
"typedoc": "^0.24.7",
|
86
|
+
"typescript": "^4.6.4"
|
69
87
|
},
|
70
88
|
"peerDependencies": {
|
71
|
-
"audio-decode": "^2.1.3",
|
72
89
|
"jimp": "^0.22.12",
|
73
|
-
"link-preview-js": "^3.0.
|
90
|
+
"link-preview-js": "^3.0.0",
|
74
91
|
"qrcode-terminal": "^0.12.0",
|
75
|
-
"sharp": "^0.
|
92
|
+
"sharp": "^0.32.6"
|
76
93
|
},
|
77
94
|
"peerDependenciesMeta": {
|
78
|
-
"audio-decode": {
|
79
|
-
"optional": true
|
80
|
-
},
|
81
95
|
"jimp": {
|
82
96
|
"optional": true
|
83
97
|
},
|
84
98
|
"link-preview-js": {
|
85
99
|
"optional": true
|
86
100
|
},
|
101
|
+
"qrcode-terminal": {
|
102
|
+
"optional": true
|
103
|
+
},
|
87
104
|
"sharp": {
|
88
105
|
"optional": true
|
89
106
|
}
|
90
107
|
},
|
91
|
-
"
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
"changelog:preview": "conventional-changelog -p angular -u",
|
97
|
-
"changelog:update": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
|
98
|
-
"example": "node --inspect -r ts-node/register Example/example.ts",
|
99
|
-
"gen:protobuf": "sh WAProto/GenerateStatics.sh",
|
100
|
-
"lint": "eslint src --ext .js,.ts",
|
101
|
-
"lint:fix": "yarn lint --fix",
|
102
|
-
"preinstall": "node ./engine-requirements.js",
|
103
|
-
"release": "release-it",
|
104
|
-
"test": "jest"
|
105
|
-
}
|
106
|
-
}
|
108
|
+
"packageManager": "yarn@1.22.19",
|
109
|
+
"engines": {
|
110
|
+
"node": ">=20.0.0"
|
111
|
+
}
|
112
|
+
}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import { Store } from 'cache-manager';
|
2
|
-
import { AuthenticationCreds } from '../Types';
|
3
|
-
declare const makeCacheManagerAuthState: (store: Store, sessionKey: string) => Promise<{
|
4
|
-
clearState: () => Promise<void>;
|
5
|
-
saveCreds: () => Promise<void>;
|
6
|
-
state: {
|
7
|
-
creds: AuthenticationCreds;
|
8
|
-
keys: {
|
9
|
-
get: (type: string, ids: string[]) => Promise<{}>;
|
10
|
-
set: (data: any) => Promise<void>;
|
11
|
-
};
|
12
|
-
};
|
13
|
-
}>;
|
14
|
-
export default makeCacheManagerAuthState;
|
@@ -1,83 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const cache_manager_1 = require("cache-manager");
|
7
|
-
const WAProto_1 = require("../../WAProto");
|
8
|
-
const Utils_1 = require("../Utils");
|
9
|
-
const logger_1 = __importDefault(require("../Utils/logger"));
|
10
|
-
const makeCacheManagerAuthState = async (store, sessionKey) => {
|
11
|
-
const defaultKey = (file) => `${sessionKey}:${file}`;
|
12
|
-
const databaseConn = await (0, cache_manager_1.caching)(store);
|
13
|
-
const writeData = async (file, data) => {
|
14
|
-
let ttl = undefined;
|
15
|
-
if (file === 'creds') {
|
16
|
-
ttl = 63115200; // 2 years
|
17
|
-
}
|
18
|
-
await databaseConn.set(defaultKey(file), JSON.stringify(data, Utils_1.BufferJSON.replacer), ttl);
|
19
|
-
};
|
20
|
-
const readData = async (file) => {
|
21
|
-
try {
|
22
|
-
const data = await databaseConn.get(defaultKey(file));
|
23
|
-
if (data) {
|
24
|
-
return JSON.parse(data, Utils_1.BufferJSON.reviver);
|
25
|
-
}
|
26
|
-
return null;
|
27
|
-
}
|
28
|
-
catch (error) {
|
29
|
-
logger_1.default.error(error);
|
30
|
-
return null;
|
31
|
-
}
|
32
|
-
};
|
33
|
-
const removeData = async (file) => {
|
34
|
-
try {
|
35
|
-
return await databaseConn.del(defaultKey(file));
|
36
|
-
}
|
37
|
-
catch (_a) {
|
38
|
-
logger_1.default.error(`Error removing ${file} from session ${sessionKey}`);
|
39
|
-
}
|
40
|
-
};
|
41
|
-
const clearState = async () => {
|
42
|
-
try {
|
43
|
-
const result = await databaseConn.store.keys(`${sessionKey}*`);
|
44
|
-
await Promise.all(result.map(async (key) => await databaseConn.del(key)));
|
45
|
-
}
|
46
|
-
catch (err) {
|
47
|
-
}
|
48
|
-
};
|
49
|
-
const creds = (await readData('creds')) || (0, Utils_1.initAuthCreds)();
|
50
|
-
return {
|
51
|
-
clearState,
|
52
|
-
saveCreds: () => writeData('creds', creds),
|
53
|
-
state: {
|
54
|
-
creds,
|
55
|
-
keys: {
|
56
|
-
get: async (type, ids) => {
|
57
|
-
const data = {};
|
58
|
-
await Promise.all(ids.map(async (id) => {
|
59
|
-
let value = await readData(`${type}-${id}`);
|
60
|
-
if (type === 'app-state-sync-key' && value) {
|
61
|
-
value = WAProto_1.proto.Message.AppStateSyncKeyData.fromObject(value);
|
62
|
-
}
|
63
|
-
data[id] = value;
|
64
|
-
}));
|
65
|
-
return data;
|
66
|
-
},
|
67
|
-
set: async (data) => {
|
68
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
69
|
-
const tasks = [];
|
70
|
-
for (const category in data) {
|
71
|
-
for (const id in data[category]) {
|
72
|
-
const value = data[category][id];
|
73
|
-
const key = `${category}-${id}`;
|
74
|
-
tasks.push(value ? writeData(key, value) : removeData(key));
|
75
|
-
}
|
76
|
-
}
|
77
|
-
await Promise.all(tasks);
|
78
|
-
},
|
79
|
-
}
|
80
|
-
}
|
81
|
-
};
|
82
|
-
};
|
83
|
-
exports.default = makeCacheManagerAuthState;
|