nrx-bails 0.0.1

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 (199) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1541 -0
  3. package/WAProto/GenerateStatics.sh +4 -0
  4. package/WAProto/WAProto.proto +4775 -0
  5. package/WAProto/index.d.ts +2 -0
  6. package/WAProto/index.js +169661 -0
  7. package/lib/Defaults/index.d.ts +113 -0
  8. package/lib/Defaults/index.js +156 -0
  9. package/lib/Defaults/phonenumber-mcc.json +223 -0
  10. package/lib/Defaults/ye-bail-version.json +3 -0
  11. package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
  12. package/lib/Signal/Group/ciphertext-message.js +41 -0
  13. package/lib/Signal/Group/group-session-builder.d.ts +8 -0
  14. package/lib/Signal/Group/group-session-builder.js +90 -0
  15. package/lib/Signal/Group/group_cipher.d.ts +12 -0
  16. package/lib/Signal/Group/group_cipher.js +122 -0
  17. package/lib/Signal/Group/index.d.ts +22 -0
  18. package/lib/Signal/Group/index.js +83 -0
  19. package/lib/Signal/Group/keyhelper.d.ts +7 -0
  20. package/lib/Signal/Group/keyhelper.js +81 -0
  21. package/lib/Signal/Group/queue-job.d.ts +3 -0
  22. package/lib/Signal/Group/queue-job.js +83 -0
  23. package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
  24. package/lib/Signal/Group/sender-chain-key.js +60 -0
  25. package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
  26. package/lib/Signal/Group/sender-key-distribution-message.js +92 -0
  27. package/lib/Signal/Group/sender-key-message.d.ts +19 -0
  28. package/lib/Signal/Group/sender-key-message.js +95 -0
  29. package/lib/Signal/Group/sender-key-name.d.ts +12 -0
  30. package/lib/Signal/Group/sender-key-name.js +77 -0
  31. package/lib/Signal/Group/sender-key-record.d.ts +13 -0
  32. package/lib/Signal/Group/sender-key-record.js +79 -0
  33. package/lib/Signal/Group/sender-key-state.d.ts +17 -0
  34. package/lib/Signal/Group/sender-key-state.js +125 -0
  35. package/lib/Signal/Group/sender-message-key.d.ts +12 -0
  36. package/lib/Signal/Group/sender-message-key.js +55 -0
  37. package/lib/Signal/libsignal.d.ts +37 -0
  38. package/lib/Signal/libsignal.js +200 -0
  39. package/lib/Socket/Client/index.d.ts +1 -0
  40. package/lib/Socket/Client/index.js +44 -0
  41. package/lib/Socket/Client/types.d.ts +7 -0
  42. package/lib/Socket/Client/types.js +39 -0
  43. package/lib/Socket/Client/websocket.d.ts +19 -0
  44. package/lib/Socket/Client/websocket.js +137 -0
  45. package/lib/Socket/business.d.ts +329 -0
  46. package/lib/Socket/business.js +286 -0
  47. package/lib/Socket/chats.d.ts +84 -0
  48. package/lib/Socket/chats.js +1022 -0
  49. package/lib/Socket/groups.d.ts +216 -0
  50. package/lib/Socket/groups.js +358 -0
  51. package/lib/Socket/index.d.ts +330 -0
  52. package/lib/Socket/index.js +36 -0
  53. package/lib/Socket/messages-recv.d.ts +271 -0
  54. package/lib/Socket/messages-recv.js +1079 -0
  55. package/lib/Socket/messages-send.d.ts +258 -0
  56. package/lib/Socket/messages-send.js +1190 -0
  57. package/lib/Socket/newsletter.d.ts +253 -0
  58. package/lib/Socket/newsletter.js +362 -0
  59. package/lib/Socket/registration.d.ts +361 -0
  60. package/lib/Socket/registration.js +179 -0
  61. package/lib/Socket/socket.d.ts +33 -0
  62. package/lib/Socket/socket.js +699 -0
  63. package/lib/Socket/usync.d.ts +27 -0
  64. package/lib/Socket/usync.js +96 -0
  65. package/lib/Store/index.d.ts +3 -0
  66. package/lib/Store/index.js +36 -0
  67. package/lib/Store/make-cache-manager-auth-state.d.ts +16 -0
  68. package/lib/Store/make-cache-manager-auth-state.js +118 -0
  69. package/lib/Store/make-in-memory-store.d.ts +64 -0
  70. package/lib/Store/make-in-memory-store.js +465 -0
  71. package/lib/Store/make-ordered-dictionary.d.ts +14 -0
  72. package/lib/Store/make-ordered-dictionary.js +107 -0
  73. package/lib/Store/object-repository.d.ts +11 -0
  74. package/lib/Store/object-repository.js +53 -0
  75. package/lib/Types/Auth.d.ts +1 -0
  76. package/lib/Types/Auth.js +28 -0
  77. package/lib/Types/Call.d.ts +1 -0
  78. package/lib/Types/Call.js +28 -0
  79. package/lib/Types/Chat.d.ts +2 -0
  80. package/lib/Types/Chat.js +30 -0
  81. package/lib/Types/Contact.d.ts +1 -0
  82. package/lib/Types/Contact.js +28 -0
  83. package/lib/Types/Events.d.ts +1 -0
  84. package/lib/Types/Events.js +28 -0
  85. package/lib/Types/GroupMetadata.d.ts +1 -0
  86. package/lib/Types/GroupMetadata.js +28 -0
  87. package/lib/Types/Label.d.ts +2 -0
  88. package/lib/Types/Label.js +53 -0
  89. package/lib/Types/LabelAssociation.d.ts +2 -0
  90. package/lib/Types/LabelAssociation.js +35 -0
  91. package/lib/Types/Message.d.ts +2 -0
  92. package/lib/Types/Message.js +33 -0
  93. package/lib/Types/Newsletter.d.ts +4 -0
  94. package/lib/Types/Newsletter.js +62 -0
  95. package/lib/Types/Product.d.ts +1 -0
  96. package/lib/Types/Product.js +28 -0
  97. package/lib/Types/Signal.d.ts +1 -0
  98. package/lib/Types/Signal.js +28 -0
  99. package/lib/Types/Socket.d.ts +1 -0
  100. package/lib/Types/Socket.js +28 -0
  101. package/lib/Types/State.d.ts +1 -0
  102. package/lib/Types/State.js +28 -0
  103. package/lib/Types/USync.d.ts +1 -0
  104. package/lib/Types/USync.js +28 -0
  105. package/lib/Types/index.d.ts +2 -0
  106. package/lib/Types/index.js +68 -0
  107. package/lib/Utils/auth-utils.d.ts +63 -0
  108. package/lib/Utils/auth-utils.js +248 -0
  109. package/lib/Utils/browser-utils.d.ts +3 -0
  110. package/lib/Utils/browser-utils.js +61 -0
  111. package/lib/Utils/business.d.ts +53 -0
  112. package/lib/Utils/business.js +260 -0
  113. package/lib/Utils/chat-utils.d.ts +253 -0
  114. package/lib/Utils/chat-utils.js +756 -0
  115. package/lib/Utils/crypto.d.ts +43 -0
  116. package/lib/Utils/crypto.js +219 -0
  117. package/lib/Utils/decode-wa-message.d.ts +61 -0
  118. package/lib/Utils/decode-wa-message.js +233 -0
  119. package/lib/Utils/event-buffer.d.ts +17 -0
  120. package/lib/Utils/event-buffer.js +544 -0
  121. package/lib/Utils/generics.d.ts +89 -0
  122. package/lib/Utils/generics.js +471 -0
  123. package/lib/Utils/history.d.ts +59 -0
  124. package/lib/Utils/history.js +120 -0
  125. package/lib/Utils/index.d.ts +1 -0
  126. package/lib/Utils/index.js +61 -0
  127. package/lib/Utils/link-preview.d.ts +19 -0
  128. package/lib/Utils/link-preview.js +152 -0
  129. package/lib/Utils/logger.d.ts +3 -0
  130. package/lib/Utils/logger.js +33 -0
  131. package/lib/Utils/lt-hash.d.ts +13 -0
  132. package/lib/Utils/lt-hash.js +77 -0
  133. package/lib/Utils/make-mutex.d.ts +7 -0
  134. package/lib/Utils/make-mutex.js +69 -0
  135. package/lib/Utils/message-retry-manager.d.ts +34 -0
  136. package/lib/Utils/message-retry-manager.js +154 -0
  137. package/lib/Utils/messages-media.d.ts +137 -0
  138. package/lib/Utils/messages-media.js +1024 -0
  139. package/lib/Utils/messages.d.ts +66 -0
  140. package/lib/Utils/messages.js +1407 -0
  141. package/lib/Utils/noise-handler.d.ts +21 -0
  142. package/lib/Utils/noise-handler.js +176 -0
  143. package/lib/Utils/pre-key-manager.d.ts +13 -0
  144. package/lib/Utils/pre-key-manager.js +93 -0
  145. package/lib/Utils/process-message.d.ts +40 -0
  146. package/lib/Utils/process-message.js +430 -0
  147. package/lib/Utils/signal.d.ts +72 -0
  148. package/lib/Utils/signal.js +179 -0
  149. package/lib/Utils/use-multi-file-auth-state.d.ts +18 -0
  150. package/lib/Utils/use-multi-file-auth-state.js +151 -0
  151. package/lib/Utils/validate-connection.d.ts +43 -0
  152. package/lib/Utils/validate-connection.js +255 -0
  153. package/lib/Utils/ye-bail-event-stream.d.ts +16 -0
  154. package/lib/Utils/ye-bail-event-stream.js +89 -0
  155. package/lib/WABinary/constants.d.ts +23 -0
  156. package/lib/WABinary/constants.js +1328 -0
  157. package/lib/WABinary/decode.d.ts +10 -0
  158. package/lib/WABinary/decode.js +291 -0
  159. package/lib/WABinary/encode.d.ts +2 -0
  160. package/lib/WABinary/encode.js +276 -0
  161. package/lib/WABinary/generic-utils.d.ts +16 -0
  162. package/lib/WABinary/generic-utils.js +155 -0
  163. package/lib/WABinary/index.d.ts +1 -0
  164. package/lib/WABinary/index.js +47 -0
  165. package/lib/WABinary/jid-utils.d.ts +34 -0
  166. package/lib/WABinary/jid-utils.js +111 -0
  167. package/lib/WABinary/types.d.ts +1 -0
  168. package/lib/WABinary/types.js +28 -0
  169. package/lib/WAM/BinaryInfo.d.ts +8 -0
  170. package/lib/WAM/BinaryInfo.js +39 -0
  171. package/lib/WAM/constants.d.ts +35374 -0
  172. package/lib/WAM/constants.js +15376 -0
  173. package/lib/WAM/encode.d.ts +2 -0
  174. package/lib/WAM/encode.js +181 -0
  175. package/lib/WAM/index.d.ts +1 -0
  176. package/lib/WAM/index.js +45 -0
  177. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +14 -0
  178. package/lib/WAUSync/Protocols/USyncContactProtocol.js +58 -0
  179. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
  180. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +83 -0
  181. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
  182. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +56 -0
  183. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
  184. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +68 -0
  185. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +39 -0
  186. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +79 -0
  187. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
  188. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +50 -0
  189. package/lib/WAUSync/Protocols/index.d.ts +1 -0
  190. package/lib/WAUSync/Protocols/index.js +46 -0
  191. package/lib/WAUSync/USyncQuery.d.ts +20 -0
  192. package/lib/WAUSync/USyncQuery.js +115 -0
  193. package/lib/WAUSync/USyncUser.d.ts +13 -0
  194. package/lib/WAUSync/USyncUser.js +52 -0
  195. package/lib/WAUSync/index.d.ts +1 -0
  196. package/lib/WAUSync/index.js +45 -0
  197. package/lib/index.js +81 -0
  198. package/package.json +113 -0
  199. package/requirements.js +32 -0
@@ -0,0 +1,27 @@
1
+ export const __esModule: boolean;
2
+ export function makeUSyncSocket(config: any): {
3
+ executeUSyncQuery: (usyncQuery: any) => Promise<any>;
4
+ type: string;
5
+ ws: any;
6
+ ev: any;
7
+ authState: {
8
+ creds: any;
9
+ keys: any;
10
+ };
11
+ signalRepository: any;
12
+ user: any;
13
+ generateMessageTag: () => string;
14
+ query: (node: any, timeoutMs: any) => Promise<any>;
15
+ waitForMessage: (msgId: any, timeoutMs?: any) => Promise<any>;
16
+ waitForSocketOpen: () => Promise<void>;
17
+ sendRawMessage: (data: any) => Promise<void>;
18
+ sendNode: (frame: any) => Promise<void>;
19
+ logout: (msg: any) => Promise<void>;
20
+ end: (error: any) => void;
21
+ onUnexpectedError: (err: any, msg: any) => void;
22
+ uploadPreKeys: (count?: 812) => Promise<void>;
23
+ uploadPreKeysToServerIfRequired: () => Promise<void>;
24
+ requestPairingCode: (phoneNumber: any, pairCode?: string) => Promise<any>;
25
+ waitForConnectionUpdate: any;
26
+ sendWAMBuffer: (wamBuffer: any) => Promise<any>;
27
+ };
@@ -0,0 +1,96 @@
1
+ /**
2
+ * ╔═══════════════════════════════════════════════════════════╗
3
+ * ║ NEROX - WhatsApp API Library ║
4
+ * ║ Premium Edition ║
5
+ * ╚═══════════════════════════════════════════════════════════╝
6
+ *
7
+ * @package nerox-bails
8
+ * @version 0.1.0
9
+ * @author NEROX Development Team
10
+ * @copyright Copyright (c) 2025 NEROX. All rights reserved.
11
+ * @license MIT License
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining
14
+ * a copy of this software and associated documentation files (the "Software"),
15
+ * to deal in the Software without restriction, including without limitation
16
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17
+ * and/or sell copies of the Software, and to permit persons to whom the
18
+ * Software is furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included
21
+ * in all copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26
+ */
27
+ "use strict";
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.makeUSyncSocket = void 0;
30
+ const boom_1 = require("@hapi/boom");
31
+ const WABinary_1 = require("../WABinary");
32
+ const socket_1 = require("./socket");
33
+ const makeUSyncSocket = (config) => {
34
+ const sock = (0, socket_1.makeSocket)(config);
35
+ const { generateMessageTag, query, } = sock;
36
+ const executeUSyncQuery = async (usyncQuery) => {
37
+ if (usyncQuery.protocols.length === 0) {
38
+ throw new boom_1.Boom('USyncQuery must have at least one protocol');
39
+ }
40
+
41
+
42
+ const validUsers = usyncQuery.users;
43
+ const userNodes = validUsers.map((user) => {
44
+ return {
45
+ tag: 'user',
46
+ attrs: {
47
+ jid: !user.phone ? user.id : undefined,
48
+ },
49
+ content: usyncQuery.protocols
50
+ .map((a) => a.getUserElement(user))
51
+ .filter(a => a !== null)
52
+ };
53
+ });
54
+ const listNode = {
55
+ tag: 'list',
56
+ attrs: {},
57
+ content: userNodes
58
+ };
59
+ const queryNode = {
60
+ tag: 'query',
61
+ attrs: {},
62
+ content: usyncQuery.protocols.map((a) => a.getQueryElement())
63
+ };
64
+ const iq = {
65
+ tag: 'iq',
66
+ attrs: {
67
+ to: WABinary_1.S_WHATSAPP_NET,
68
+ type: 'get',
69
+ xmlns: 'usync',
70
+ },
71
+ content: [
72
+ {
73
+ tag: 'usync',
74
+ attrs: {
75
+ context: usyncQuery.context,
76
+ mode: usyncQuery.mode,
77
+ sid: generateMessageTag(),
78
+ last: 'true',
79
+ index: '0',
80
+ },
81
+ content: [
82
+ queryNode,
83
+ listNode
84
+ ]
85
+ }
86
+ ],
87
+ };
88
+ const result = await query(iq);
89
+ return usyncQuery.parseUSyncQueryResult(result);
90
+ };
91
+ return {
92
+ ...sock,
93
+ executeUSyncQuery,
94
+ };
95
+ };
96
+ exports.makeUSyncSocket = makeUSyncSocket;
@@ -0,0 +1,3 @@
1
+ export const __esModule: boolean;
2
+ export { default as makeInMemoryStore } from './make-in-memory-store';
3
+ export { default as makeCacheManagerAuthState } from './make-cache-manager-auth-state';
@@ -0,0 +1,36 @@
1
+ /**
2
+ * ╔═══════════════════════════════════════════════════════════╗
3
+ * ║ NEROX - WhatsApp API Library ║
4
+ * ║ Premium Edition ║
5
+ * ╚═══════════════════════════════════════════════════════════╝
6
+ *
7
+ * @package nerox-bails
8
+ * @version 0.1.0
9
+ * @author NEROX Development Team
10
+ * @copyright Copyright (c) 2025 NEROX. All rights reserved.
11
+ * @license MIT License
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining
14
+ * a copy of this software and associated documentation files (the "Software"),
15
+ * to deal in the Software without restriction, including without limitation
16
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17
+ * and/or sell copies of the Software, and to permit persons to whom the
18
+ * Software is furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included
21
+ * in all copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26
+ */
27
+ "use strict";
28
+ var __importDefault = (this && this.__importDefault) || function (mod) {
29
+ return (mod && mod.__esModule) ? mod : { "default": mod };
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.makeCacheManagerAuthState = exports.makeInMemoryStore = void 0;
33
+ const make_in_memory_store_1 = __importDefault(require("./make-in-memory-store"));
34
+ exports.makeInMemoryStore = make_in_memory_store_1.default;
35
+ const make_cache_manager_auth_state_1 = __importDefault(require("./make-cache-manager-auth-state"));
36
+ exports.makeCacheManagerAuthState = make_cache_manager_auth_state_1.default;
@@ -0,0 +1,16 @@
1
+ export const __esModule: boolean;
2
+ declare const makeCacheManagerAuthState: (store: any, sessionKey: string, opts?: {
3
+ logger?: any;
4
+ }) => Promise<{
5
+ clearState: () => Promise<void>;
6
+ saveCreds: () => Promise<void>;
7
+ state: {
8
+ creds: any;
9
+ keys: {
10
+ get: (type: any, ids: any) => Promise<any>;
11
+ set: (data: any) => Promise<void>;
12
+ };
13
+ };
14
+ }>;
15
+ export default makeCacheManagerAuthState;
16
+
@@ -0,0 +1,118 @@
1
+ /**
2
+ * ╔═══════════════════════════════════════════════════════════╗
3
+ * ║ NEROX - WhatsApp API Library ║
4
+ * ║ Premium Edition ║
5
+ * ╚═══════════════════════════════════════════════════════════╝
6
+ *
7
+ * @package nerox-bails
8
+ * @version 0.1.0
9
+ * @author NEROX Development Team
10
+ * @copyright Copyright (c) 2025 NEROX. All rights reserved.
11
+ * @license MIT License
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining
14
+ * a copy of this software and associated documentation files (the "Software"),
15
+ * to deal in the Software without restriction, including without limitation
16
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17
+ * and/or sell copies of the Software, and to permit persons to whom the
18
+ * Software is furnished to do so, subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included
21
+ * in all copies or substantial portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26
+ */
27
+ "use strict";
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const WAProto_1 = require("../../WAProto");
30
+ const Utils_1 = require("../Utils");
31
+ const logger_1 = require("../Utils/logger");
32
+ const makeCacheManagerAuthState = async (store, sessionKey, opts = {}) => {
33
+ const logger = opts.logger || logger_1.default;
34
+ const scopedKey = (file) => `${sessionKey}:${file}`;
35
+ const writeData = async (file, data) => {
36
+ let ttl = undefined;
37
+ if (file === 'creds') {
38
+ ttl = 63115200;
39
+ }
40
+ await store.set(scopedKey(file), JSON.stringify(data, Utils_1.BufferJSON.replacer), ttl);
41
+ };
42
+ const readData = async (file) => {
43
+ try {
44
+ const data = await store.get(scopedKey(file));
45
+ if (!data) {
46
+ return null;
47
+ }
48
+ if (typeof data === 'string') {
49
+ return JSON.parse(data, Utils_1.BufferJSON.reviver);
50
+ }
51
+ return JSON.parse(String(data), Utils_1.BufferJSON.reviver);
52
+ }
53
+ catch (err) {
54
+ logger.error({ err, file }, 'failed reading auth state item');
55
+ return null;
56
+ }
57
+ };
58
+ const removeData = async (file) => {
59
+ try {
60
+ await store.del(scopedKey(file));
61
+ }
62
+ catch (err) {
63
+ logger.error({ err, file }, 'failed removing auth state item');
64
+ }
65
+ };
66
+ const clearState = async () => {
67
+ try {
68
+ const backing = store === null || store === void 0 ? void 0 : store.store;
69
+ const keysFn = backing && typeof backing.keys === 'function' ? backing.keys.bind(backing) : undefined;
70
+ if (!keysFn) {
71
+ return;
72
+ }
73
+ const keys = await keysFn();
74
+ const prefix = `${sessionKey}:`;
75
+ const toDelete = (keys || []).filter((k) => typeof k === 'string' && k.startsWith(prefix));
76
+ await Promise.all(toDelete.map((k) => store.del(k)));
77
+ }
78
+ catch (err) {
79
+ logger.error({ err }, 'failed clearing auth state');
80
+ }
81
+ };
82
+ const creds = (await readData('creds')) || (0, Utils_1.initAuthCreds)();
83
+ return {
84
+ clearState,
85
+ saveCreds: () => writeData('creds', creds),
86
+ state: {
87
+ creds,
88
+ keys: {
89
+ get: async (type, ids) => {
90
+ const data = {};
91
+ await Promise.all(ids.map(async (id) => {
92
+ const value = await readData(`${type}-${id}`);
93
+ if (type === 'app-state-sync-key' && value) {
94
+ data[id] = WAProto_1.proto.Message.AppStateSyncKeyData.create(value);
95
+ }
96
+ else {
97
+ data[id] = value;
98
+ }
99
+ }));
100
+ return data;
101
+ },
102
+ set: async (data) => {
103
+ const tasks = [];
104
+ for (const category in data) {
105
+ for (const id in data[category]) {
106
+ const value = data[category][id];
107
+ const key = `${category}-${id}`;
108
+ tasks.push(value ? writeData(key, value) : removeData(key));
109
+ }
110
+ }
111
+ await Promise.all(tasks);
112
+ }
113
+ }
114
+ }
115
+ };
116
+ };
117
+ exports.default = makeCacheManagerAuthState;
118
+
@@ -0,0 +1,64 @@
1
+ export const __esModule: boolean;
2
+ export namespace waLabelAssociationKey {
3
+ function key(la: any): any;
4
+ function compare(k1: any, k2: any): any;
5
+ }
6
+ declare function _default(config: any): {
7
+ chats: import("@adiwajshing/keyed-db").default<any, any>;
8
+ contacts: {};
9
+ messages: {};
10
+ groupMetadata: {};
11
+ state: {
12
+ connection: string;
13
+ };
14
+ presences: {};
15
+ labels: object_repository_1.ObjectRepository;
16
+ labelAssociations: import("@adiwajshing/keyed-db").default<any, any>;
17
+ bind: (ev: any) => void;
18
+ /** loads messages from the store, if not found -- uses the legacy connection */
19
+ loadMessages: (jid: any, count: any, cursor: any) => Promise<any>;
20
+ /**
21
+ * Get all available labels for profile
22
+ *
23
+ * Keep in mind that the list is formed from predefined tags and tags
24
+ * that were "caught" during their editing.
25
+ */
26
+ getLabels: () => object_repository_1.ObjectRepository;
27
+ /**
28
+ * Get labels for chat
29
+ *
30
+ * @returns Label IDs
31
+ **/
32
+ getChatLabels: (chatId: any) => any[];
33
+ /**
34
+ * Get labels for message
35
+ *
36
+ * @returns Label IDs
37
+ **/
38
+ getMessageLabels: (messageId: any) => any[];
39
+ loadMessage: (jid: any, id: any) => Promise<any>;
40
+ mostRecentMessage: (jid: any) => Promise<any>;
41
+ fetchImageUrl: (jid: any, sock: any) => Promise<any>;
42
+ fetchGroupMetadata: (jid: any, sock: any) => Promise<any>;
43
+ fetchMessageReceipts: ({ remoteJid, id }: {
44
+ remoteJid: any;
45
+ id: any;
46
+ }) => Promise<any>;
47
+ toJSON: () => {
48
+ chats: import("@adiwajshing/keyed-db").default<any, any>;
49
+ contacts: {};
50
+ messages: {};
51
+ labels: object_repository_1.ObjectRepository;
52
+ labelAssociations: import("@adiwajshing/keyed-db").default<any, any>;
53
+ };
54
+ fromJSON: (json: any) => void;
55
+ writeToFile: (path: any) => void;
56
+ readFromFile: (path: any) => void;
57
+ };
58
+ export default _default;
59
+ export function waChatKey(pin: any): {
60
+ key: (c: any) => string;
61
+ compare: (k1: any, k2: any) => any;
62
+ };
63
+ export function waMessageID(m: any): any;
64
+ import object_repository_1 = require("./object-repository");