@genuxofficial/baileys 1.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.
Files changed (80) hide show
  1. package/README.md +5 -1
  2. package/WAProto/WAProto.proto +1385 -96
  3. package/WAProto/index.d.ts +19244 -2787
  4. package/WAProto/index.js +138202 -74217
  5. package/engine-requirements.js +10 -0
  6. package/lib/Defaults/baileys-version.json +1 -1
  7. package/lib/Defaults/index.js +1 -0
  8. package/lib/Socket/business.d.ts +47 -17
  9. package/lib/Socket/chats.d.ts +10 -9
  10. package/lib/Socket/chats.js +36 -16
  11. package/lib/Socket/groups.d.ts +12 -11
  12. package/lib/Socket/groups.js +16 -3
  13. package/lib/Socket/index.d.ts +52 -22
  14. package/lib/Socket/messages-recv.d.ts +46 -15
  15. package/lib/Socket/messages-recv.js +158 -23
  16. package/lib/Socket/messages-send.d.ts +39 -11
  17. package/lib/Socket/messages-send.js +188 -22
  18. package/lib/Socket/newsletter.d.ts +137 -0
  19. package/lib/Socket/newsletter.js +256 -0
  20. package/lib/Socket/socket.d.ts +4 -4
  21. package/lib/Socket/socket.js +25 -12
  22. package/lib/Socket/usync.d.ts +5 -5
  23. package/lib/Store/index.d.ts +1 -2
  24. package/lib/Store/index.js +1 -3
  25. package/lib/Store/make-in-memory-store.js +14 -5
  26. package/lib/Types/Chat.d.ts +6 -5
  27. package/lib/Types/Events.d.ts +27 -0
  28. package/lib/Types/GroupMetadata.d.ts +6 -0
  29. package/lib/Types/Label.d.ts +0 -11
  30. package/lib/Types/Message.d.ts +150 -12
  31. package/lib/Types/Message.js +0 -2
  32. package/lib/Types/Newsletter.d.ts +79 -0
  33. package/lib/Types/Newsletter.js +18 -0
  34. package/lib/Types/Socket.d.ts +8 -3
  35. package/lib/Types/index.d.ts +1 -0
  36. package/lib/Types/index.js +1 -0
  37. package/lib/Utils/auth-utils.d.ts +1 -1
  38. package/lib/Utils/auth-utils.js +3 -4
  39. package/lib/Utils/business.js +15 -3
  40. package/lib/Utils/chat-utils.js +0 -16
  41. package/lib/Utils/crypto.js +6 -4
  42. package/lib/Utils/decode-wa-message.d.ts +5 -3
  43. package/lib/Utils/decode-wa-message.js +158 -31
  44. package/lib/Utils/event-buffer.js +1 -3
  45. package/lib/Utils/generics.d.ts +3 -2
  46. package/lib/Utils/generics.js +16 -36
  47. package/lib/Utils/history.d.ts +2 -2
  48. package/lib/Utils/link-preview.d.ts +1 -1
  49. package/lib/Utils/link-preview.js +1 -24
  50. package/lib/Utils/make-mutex.js +0 -1
  51. package/lib/Utils/messages-media.d.ts +14 -5
  52. package/lib/Utils/messages-media.js +130 -69
  53. package/lib/Utils/messages.d.ts +1 -1
  54. package/lib/Utils/messages.js +309 -57
  55. package/lib/Utils/noise-handler.d.ts +1 -1
  56. package/lib/Utils/process-message.js +0 -1
  57. package/lib/Utils/use-multi-file-auth-state.js +44 -13
  58. package/lib/Utils/validate-connection.js +1 -3
  59. package/lib/WABinary/decode.js +3 -2
  60. package/lib/WABinary/encode.js +13 -5
  61. package/lib/WABinary/generic-utils.d.ts +3 -5
  62. package/lib/WABinary/generic-utils.js +34 -19
  63. package/lib/WABinary/jid-utils.d.ts +12 -3
  64. package/lib/WABinary/jid-utils.js +29 -4
  65. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +21 -12
  66. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +3 -3
  67. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
  68. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  69. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
  70. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  71. package/lib/WAUSync/USyncQuery.d.ts +2 -0
  72. package/lib/WAUSync/USyncQuery.js +10 -0
  73. package/lib/WAUSync/USyncUser.d.ts +2 -0
  74. package/lib/WAUSync/USyncUser.js +4 -0
  75. package/lib/index.d.ts +2 -1
  76. package/lib/index.js +3 -1
  77. package/package.json +20 -12
  78. package/WAProto/GenerateStatics.sh +0 -4
  79. package/lib/Store/make-cache-manager-store.d.ts +0 -14
  80. package/lib/Store/make-cache-manager-store.js +0 -83
package/package.json CHANGED
@@ -1,20 +1,22 @@
1
1
  {
2
2
  "name": "@genuxofficial/baileys",
3
- "version": "1.0.0",
3
+ "version": "3.0.0",
4
4
  "description": "WhatsApp API",
5
5
  "keywords": [
6
+ "baileys",
7
+ "baileys-mod",
8
+ "wabot",
6
9
  "whatsapp",
7
10
  "js-whatsapp",
8
11
  "whatsapp-api",
9
12
  "whatsapp-web",
10
- "whatsapp-chat",
11
- "whatsapp-group",
13
+ "whatsapp-bot",
12
14
  "automation",
13
15
  "multi-device"
14
16
  ],
15
17
  "homepage": "https://github.com/genux-official/Baileys",
16
18
  "repository": {
17
- "url": "git@github.com:genux-official/Baileys.git"
19
+ "url": "https://github.com/genux-official/Baileys.git"
18
20
  },
19
21
  "license": "MIT",
20
22
  "author": "Genux Official",
@@ -23,7 +25,8 @@
23
25
  "files": [
24
26
  "lib/*",
25
27
  "WAProto/*",
26
- "WASignalGroup/*.js"
28
+ "WASignalGroup/*.js",
29
+ "engine-requirements.js"
27
30
  ],
28
31
  "scripts": {
29
32
  "build:all": "tsc && typedoc",
@@ -34,8 +37,8 @@
34
37
  "changelog:update": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
35
38
  "example": "node --inspect -r ts-node/register Example/example.ts",
36
39
  "gen:protobuf": "sh WAProto/GenerateStatics.sh",
37
- "lint": "eslint src --ext .js,.ts",
38
- "lint:fix": "yarn lint --fix",
40
+ "lint": "eslint src --ext .js,.ts,.jsx,.tsx",
41
+ "lint:fix": "eslint src --fix --ext .js,.ts,.jsx,.tsx",
39
42
  "prepack": "tsc",
40
43
  "prepare": "tsc",
41
44
  "release": "release-it",
@@ -44,22 +47,24 @@
44
47
  "dependencies": {
45
48
  "@adiwajshing/keyed-db": "^0.2.4",
46
49
  "@hapi/boom": "^9.1.3",
47
- "@whiskeysockets/eslint-config": "github:whiskeysockets/eslint-config",
50
+ "async-mutex": "^0.5.0",
48
51
  "async-lock": "^1.4.1",
52
+ "futoin-hkdf": "^1.5.1",
49
53
  "audio-decode": "^2.1.3",
50
54
  "axios": "^1.6.0",
51
55
  "cache-manager": "^5.7.6",
52
56
  "libphonenumber-js": "^1.10.20",
53
- "libsignal": "github:WhiskeySockets/libsignal-node",
57
+ "libsignal": "git+https://github.com/WhiskeySockets/libsignal-node.git",
54
58
  "lodash": "^4.17.21",
55
59
  "music-metadata": "^7.12.3",
56
60
  "@cacheable/node-cache": "^1.4.0",
57
61
  "pino": "^9.6",
58
- "protobufjs": "^7.2.4",
62
+ "protobufjs": "^6.11.3",
59
63
  "uuid": "^10.0.0",
60
64
  "ws": "^8.13.0"
61
65
  },
62
66
  "devDependencies": {
67
+ "@adiwajshing/eslint-config": "https://github.com/adiwajshing/eslint-config.git",
63
68
  "@types/got": "^9.6.11",
64
69
  "@types/jest": "^27.5.1",
65
70
  "@types/node": "^16.0.0",
@@ -81,7 +86,7 @@
81
86
  "typescript": "^4.6.4"
82
87
  },
83
88
  "peerDependencies": {
84
- "jimp": "^0.16.1",
89
+ "jimp": "^0.22.12",
85
90
  "link-preview-js": "^3.0.0",
86
91
  "qrcode-terminal": "^0.12.0",
87
92
  "sharp": "^0.32.6"
@@ -100,5 +105,8 @@
100
105
  "optional": true
101
106
  }
102
107
  },
103
- "packageManager": "yarn@1.22.19"
108
+ "packageManager": "yarn@1.22.19",
109
+ "engines": {
110
+ "node": ">=20.0.0"
111
+ }
104
112
  }
@@ -1,4 +0,0 @@
1
- yarn pbjs -t static-module -w commonjs -o ./WAProto/index.js ./WAProto/WAProto.proto;
2
- yarn pbts -o ./WAProto/index.d.ts ./WAProto/index.js;
3
-
4
- #protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_opt=env=node,useOptionals=true,forceLong=long --ts_proto_out=. ./src/Binary/WAMessage.proto;
@@ -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;