dibosockets 1.0.2 → 1.0.4

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 (40) hide show
  1. package/WAProto/WAProto.proto +5619 -5619
  2. package/lib/Api/Internet/growagarden.js +28 -28
  3. package/lib/Api/creator.json +13 -13
  4. package/lib/Api/downloader/tiktokdownload.js +132 -132
  5. package/lib/Api/index.js +38 -38
  6. package/lib/Api/nsfw/loli.js +79 -79
  7. package/lib/Api/stalker/githubstalk.js +46 -46
  8. package/lib/Api/stalker/stalkroblox.js +94 -94
  9. package/lib/Api/stalker/tiktokstalk.js +68 -68
  10. package/lib/Api/tools/ssweb.js +38 -38
  11. package/lib/Defaults/baileys-version.json +3 -3
  12. package/lib/Defaults/index.js +122 -122
  13. package/lib/Defaults/phonenumber_mcc.json +223 -223
  14. package/lib/Socket/RHandler.js +448 -448
  15. package/lib/Socket/business.js +266 -266
  16. package/lib/Socket/chats.js +1137 -1137
  17. package/lib/Socket/communities.js +441 -441
  18. package/lib/Socket/index.js +43 -43
  19. package/lib/Socket/messages-recv.js +1065 -1065
  20. package/lib/Socket/messages-send.js +881 -881
  21. package/lib/Socket/newsletter.js +286 -286
  22. package/lib/Socket/socket.js +666 -666
  23. package/lib/Store/make-in-memory-store.js +439 -439
  24. package/lib/Types/Newsletter.js +18 -18
  25. package/lib/Utils/async-iterable.js +41 -41
  26. package/lib/Utils/baileys-event-stream.js +63 -63
  27. package/lib/Utils/browser-utils.js +34 -34
  28. package/lib/Utils/event-buffer.js +518 -518
  29. package/lib/Utils/generics.js +431 -431
  30. package/lib/Utils/index.js +36 -36
  31. package/lib/Utils/message-retry-manager.js +127 -127
  32. package/lib/Utils/messages-media.js +926 -926
  33. package/lib/Utils/messages.js +1105 -1105
  34. package/lib/Utils/process-message.js +404 -404
  35. package/lib/Utils/resolveJid.js +52 -52
  36. package/lib/Utils/use-multi-file-auth-state.js +122 -122
  37. package/lib/Utils/validate-connection.js +228 -228
  38. package/lib/WABinary/jid-utils.js +85 -85
  39. package/lib/index.js +87 -74
  40. package/package.json +2 -2
@@ -1,52 +1,52 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.resolveJid = resolveJid;
5
-
6
- /**
7
- Resolve LID / raw id menjadi JID WhatsApp asli
8
- @param {import('@rexxhayanasi/elaina-baileys').WASocket} conn
9
- @param {any} m
10
- @param {string|null} target
11
- @returns {Promise<string|null>}
12
- */
13
-
14
- async function resolveJid(conn, m, target) {
15
- let input =
16
- target ||
17
- (m.mentionedJid && m.mentionedJid[0]) ||
18
- (m.quoted && m.quoted.sender) ||
19
- m.sender;
20
-
21
- if (!input) return null;
22
-
23
-
24
- if (/@s.whatsapp.net$/.test(input))
25
- return input;
26
-
27
-
28
- if (!m.isGroup || !m.chat)
29
- return null;
30
-
31
- let meta;
32
- try {
33
- meta = await conn.groupMetadata(m.chat);
34
- } catch {
35
- return null;
36
- }
37
-
38
- if (!meta || !Array.isArray(meta.participants))
39
- return null;
40
-
41
- const participant = meta.participants.find(p =>
42
- p.jid === input ||
43
- p.id === input ||
44
- p.lid === input ||
45
- (typeof input === "string" && input.replace(/@lid$/, "") === p.lid?.replace(/@lid$/, ""))
46
- );
47
-
48
- if (participant && participant.jid)
49
- return participant.jid;
50
-
51
- return null;
52
- }
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.resolveJid = resolveJid;
5
+
6
+ /**
7
+ Resolve LID / raw id menjadi JID WhatsApp asli
8
+ @param {import('@rexxhayanasi/elaina-baileys').WASocket} conn
9
+ @param {any} m
10
+ @param {string|null} target
11
+ @returns {Promise<string|null>}
12
+ */
13
+
14
+ async function resolveJid(conn, m, target) {
15
+ let input =
16
+ target ||
17
+ (m.mentionedJid && m.mentionedJid[0]) ||
18
+ (m.quoted && m.quoted.sender) ||
19
+ m.sender;
20
+
21
+ if (!input) return null;
22
+
23
+
24
+ if (/@s.whatsapp.net$/.test(input))
25
+ return input;
26
+
27
+
28
+ if (!m.isGroup || !m.chat)
29
+ return null;
30
+
31
+ let meta;
32
+ try {
33
+ meta = await conn.groupMetadata(m.chat);
34
+ } catch {
35
+ return null;
36
+ }
37
+
38
+ if (!meta || !Array.isArray(meta.participants))
39
+ return null;
40
+
41
+ const participant = meta.participants.find(p =>
42
+ p.jid === input ||
43
+ p.id === input ||
44
+ p.lid === input ||
45
+ (typeof input === "string" && input.replace(/@lid$/, "") === p.lid?.replace(/@lid$/, ""))
46
+ );
47
+
48
+ if (participant && participant.jid)
49
+ return participant.jid;
50
+
51
+ return null;
52
+ }
@@ -1,122 +1,122 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useMultiFileAuthState = void 0;
4
- const async_mutex_1 = require("async-mutex");
5
- const promises_1 = require("fs/promises");
6
- const path_1 = require("path");
7
- const WAProto_1 = require("../../WAProto");
8
- const auth_utils_1 = require("./auth-utils");
9
- const generics_1 = require("./generics");
10
- // We need to lock files due to the fact that we are using async functions to read and write files
11
- const fileLocks = new Map();
12
- // Get or create a mutex for a specific file path
13
- const getFileLock = (path) => {
14
- let mutex = fileLocks.get(path);
15
- if (!mutex) {
16
- mutex = new async_mutex_1.Mutex();
17
- fileLocks.set(path, mutex);
18
- }
19
- return mutex;
20
- };
21
- /**
22
- * stores the full authentication state in a single folder.
23
- * Far more efficient than singlefileauthstate
24
- *
25
- * Again, I wouldn't endorse this for any production level use other than perhaps a bot.
26
- * Would recommend writing an auth state for use with a proper SQL or No-SQL DB
27
- * */
28
- const useMultiFileAuthState = async (folder) => {
29
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
- const writeData = async (data, file) => {
31
- const filePath = (0, path_1.join)(folder, fixFileName(file));
32
- const mutex = getFileLock(filePath);
33
- return mutex.acquire().then(async (release) => {
34
- try {
35
- await (0, promises_1.writeFile)(filePath, JSON.stringify(data, generics_1.BufferJSON.replacer));
36
- }
37
- finally {
38
- release();
39
- }
40
- });
41
- };
42
- const readData = async (file) => {
43
- try {
44
- const filePath = (0, path_1.join)(folder, fixFileName(file));
45
- const mutex = getFileLock(filePath);
46
- return await mutex.acquire().then(async (release) => {
47
- try {
48
- const data = await (0, promises_1.readFile)(filePath, { encoding: 'utf-8' });
49
- return JSON.parse(data, generics_1.BufferJSON.reviver);
50
- }
51
- finally {
52
- release();
53
- }
54
- });
55
- }
56
- catch (error) {
57
- return null;
58
- }
59
- };
60
- const removeData = async (file) => {
61
- try {
62
- const filePath = (0, path_1.join)(folder, fixFileName(file));
63
- const mutex = getFileLock(filePath);
64
- return mutex.acquire().then(async (release) => {
65
- try {
66
- await (0, promises_1.unlink)(filePath);
67
- }
68
- catch (_a) {
69
- }
70
- finally {
71
- release();
72
- }
73
- });
74
- }
75
- catch (_a) {
76
- }
77
- };
78
- const folderInfo = await (0, promises_1.stat)(folder).catch(() => { });
79
- if (folderInfo) {
80
- if (!folderInfo.isDirectory()) {
81
- throw new Error(`found something that is not a directory at ${folder}, either delete it or specify a different location`);
82
- }
83
- }
84
- else {
85
- await (0, promises_1.mkdir)(folder, { recursive: true });
86
- }
87
- const fixFileName = (file) => { var _a; return (_a = file === null || file === void 0 ? void 0 : file.replace(/\//g, '__')) === null || _a === void 0 ? void 0 : _a.replace(/:/g, '-'); };
88
- const creds = await readData('creds.json') || (0, auth_utils_1.initAuthCreds)();
89
- return {
90
- state: {
91
- creds,
92
- keys: {
93
- get: async (type, ids) => {
94
- const data = {};
95
- await Promise.all(ids.map(async (id) => {
96
- let value = await readData(`${type}-${id}.json`);
97
- if (type === 'app-state-sync-key' && value) {
98
- value = WAProto_1.proto.Message.AppStateSyncKeyData.fromObject(value);
99
- }
100
- data[id] = value;
101
- }));
102
- return data;
103
- },
104
- set: async (data) => {
105
- const tasks = [];
106
- for (const category in data) {
107
- for (const id in data[category]) {
108
- const value = data[category][id];
109
- const file = `${category}-${id}.json`;
110
- tasks.push(value ? writeData(value, file) : removeData(file));
111
- }
112
- }
113
- await Promise.all(tasks);
114
- }
115
- }
116
- },
117
- saveCreds: async () => {
118
- return writeData(creds, 'creds.json');
119
- }
120
- };
121
- };
122
- exports.useMultiFileAuthState = useMultiFileAuthState;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMultiFileAuthState = void 0;
4
+ const async_mutex_1 = require("async-mutex");
5
+ const promises_1 = require("fs/promises");
6
+ const path_1 = require("path");
7
+ const WAProto_1 = require("../../WAProto");
8
+ const auth_utils_1 = require("./auth-utils");
9
+ const generics_1 = require("./generics");
10
+ // We need to lock files due to the fact that we are using async functions to read and write files
11
+ const fileLocks = new Map();
12
+ // Get or create a mutex for a specific file path
13
+ const getFileLock = (path) => {
14
+ let mutex = fileLocks.get(path);
15
+ if (!mutex) {
16
+ mutex = new async_mutex_1.Mutex();
17
+ fileLocks.set(path, mutex);
18
+ }
19
+ return mutex;
20
+ };
21
+ /**
22
+ * stores the full authentication state in a single folder.
23
+ * Far more efficient than singlefileauthstate
24
+ *
25
+ * Again, I wouldn't endorse this for any production level use other than perhaps a bot.
26
+ * Would recommend writing an auth state for use with a proper SQL or No-SQL DB
27
+ * */
28
+ const useMultiFileAuthState = async (folder) => {
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
+ const writeData = async (data, file) => {
31
+ const filePath = (0, path_1.join)(folder, fixFileName(file));
32
+ const mutex = getFileLock(filePath);
33
+ return mutex.acquire().then(async (release) => {
34
+ try {
35
+ await (0, promises_1.writeFile)(filePath, JSON.stringify(data, generics_1.BufferJSON.replacer));
36
+ }
37
+ finally {
38
+ release();
39
+ }
40
+ });
41
+ };
42
+ const readData = async (file) => {
43
+ try {
44
+ const filePath = (0, path_1.join)(folder, fixFileName(file));
45
+ const mutex = getFileLock(filePath);
46
+ return await mutex.acquire().then(async (release) => {
47
+ try {
48
+ const data = await (0, promises_1.readFile)(filePath, { encoding: 'utf-8' });
49
+ return JSON.parse(data, generics_1.BufferJSON.reviver);
50
+ }
51
+ finally {
52
+ release();
53
+ }
54
+ });
55
+ }
56
+ catch (error) {
57
+ return null;
58
+ }
59
+ };
60
+ const removeData = async (file) => {
61
+ try {
62
+ const filePath = (0, path_1.join)(folder, fixFileName(file));
63
+ const mutex = getFileLock(filePath);
64
+ return mutex.acquire().then(async (release) => {
65
+ try {
66
+ await (0, promises_1.unlink)(filePath);
67
+ }
68
+ catch (_a) {
69
+ }
70
+ finally {
71
+ release();
72
+ }
73
+ });
74
+ }
75
+ catch (_a) {
76
+ }
77
+ };
78
+ const folderInfo = await (0, promises_1.stat)(folder).catch(() => { });
79
+ if (folderInfo) {
80
+ if (!folderInfo.isDirectory()) {
81
+ throw new Error(`found something that is not a directory at ${folder}, either delete it or specify a different location`);
82
+ }
83
+ }
84
+ else {
85
+ await (0, promises_1.mkdir)(folder, { recursive: true });
86
+ }
87
+ const fixFileName = (file) => { var _a; return (_a = file === null || file === void 0 ? void 0 : file.replace(/\//g, '__')) === null || _a === void 0 ? void 0 : _a.replace(/:/g, '-'); };
88
+ const creds = await readData('creds.json') || (0, auth_utils_1.initAuthCreds)();
89
+ return {
90
+ state: {
91
+ creds,
92
+ keys: {
93
+ get: async (type, ids) => {
94
+ const data = {};
95
+ await Promise.all(ids.map(async (id) => {
96
+ let value = await readData(`${type}-${id}.json`);
97
+ if (type === 'app-state-sync-key' && value) {
98
+ value = WAProto_1.proto.Message.AppStateSyncKeyData.fromObject(value);
99
+ }
100
+ data[id] = value;
101
+ }));
102
+ return data;
103
+ },
104
+ set: async (data) => {
105
+ const tasks = [];
106
+ for (const category in data) {
107
+ for (const id in data[category]) {
108
+ const value = data[category][id];
109
+ const file = `${category}-${id}.json`;
110
+ tasks.push(value ? writeData(value, file) : removeData(file));
111
+ }
112
+ }
113
+ await Promise.all(tasks);
114
+ }
115
+ }
116
+ },
117
+ saveCreds: async () => {
118
+ return writeData(creds, 'creds.json');
119
+ }
120
+ };
121
+ };
122
+ exports.useMultiFileAuthState = useMultiFileAuthState;