@gqb333/based 2.7.71
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 +58 -0
- package/README.MD +611 -0
- package/WAProto/GenerateStatics.sh +4 -0
- package/WAProto/WAProto.proto +5604 -0
- package/WAProto/index.d.ts +63156 -0
- package/WAProto/index.js +195638 -0
- package/WAProto/p.html +1 -0
- 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 +108 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/ciphertext-message.js +15 -0
- package/lib/Signal/Group/group-session-builder.d.ts +14 -0
- package/lib/Signal/Group/group-session-builder.js +64 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.js +96 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/index.js +57 -0
- package/lib/Signal/Group/keyhelper.d.ts +10 -0
- package/lib/Signal/Group/keyhelper.js +55 -0
- 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 +34 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-message.js +69 -0
- package/lib/Signal/Group/sender-key-name.d.ts +17 -0
- package/lib/Signal/Group/sender-key-name.js +51 -0
- package/lib/Signal/Group/sender-key-record.d.ts +30 -0
- package/lib/Signal/Group/sender-key-record.js +53 -0
- package/lib/Signal/Group/sender-key-state.d.ts +38 -0
- package/lib/Signal/Group/sender-key-state.js +99 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/lib/Signal/Group/sender-message-key.js +29 -0
- package/lib/Signal/libsignal.d.ts +3 -0
- package/lib/Signal/libsignal.js +174 -0
- package/lib/Socket/Client/index.d.ts +2 -0
- package/lib/Socket/Client/index.js +18 -0
- package/lib/Socket/Client/types.d.ts +16 -0
- package/lib/Socket/Client/types.js +13 -0
- package/lib/Socket/Client/websocket.d.ts +13 -0
- package/lib/Socket/Client/websocket.js +111 -0
- package/lib/Socket/business.d.ts +172 -0
- package/lib/Socket/business.js +260 -0
- package/lib/Socket/chats.d.ts +85 -0
- package/lib/Socket/chats.js +1094 -0
- package/lib/Socket/groups.d.ts +124 -0
- package/lib/Socket/groups.js +423 -0
- package/lib/Socket/index.d.ts +172 -0
- package/lib/Socket/index.js +32 -0
- package/lib/Socket/messages-interactive.js +259 -0
- package/lib/Socket/messages-recv.d.ts +161 -0
- package/lib/Socket/messages-recv.js +1474 -0
- package/lib/Socket/messages-send.d.ts +151 -0
- package/lib/Socket/messages-send.js +1085 -0
- package/lib/Socket/newsletter.d.ts +136 -0
- package/lib/Socket/newsletter.js +250 -0
- package/lib/Socket/socket.d.ts +43 -0
- package/lib/Socket/socket.js +1241 -0
- package/lib/Socket/usync.d.ts +36 -0
- package/lib/Socket/usync.js +123 -0
- package/lib/Store/index.d.ts +2 -0
- package/lib/Store/index.js +8 -0
- package/lib/Store/make-in-memory-store.d.ts +118 -0
- package/lib/Store/make-in-memory-store.js +452 -0
- package/lib/Store/make-ordered-dictionary.d.ts +13 -0
- package/lib/Store/make-ordered-dictionary.js +81 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Store/object-repository.js +27 -0
- package/lib/Types/Auth.d.ts +114 -0
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Call.d.ts +13 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Chat.d.ts +109 -0
- package/lib/Types/Chat.js +4 -0
- package/lib/Types/Contact.d.ts +29 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Events.d.ts +199 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/GroupMetadata.d.ts +64 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/Label.d.ts +35 -0
- package/lib/Types/Label.js +27 -0
- package/lib/Types/LabelAssociation.d.ts +29 -0
- package/lib/Types/LabelAssociation.js +9 -0
- package/lib/Types/Message.d.ts +740 -0
- package/lib/Types/Message.js +7 -0
- package/lib/Types/Newsletter.d.ts +22 -0
- package/lib/Types/Newsletter.js +18 -0
- package/lib/Types/Product.d.ts +78 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/Signal.d.ts +63 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Socket.d.ts +134 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/State.d.ts +27 -0
- package/lib/Types/State.js +2 -0
- package/lib/Types/USync.d.ts +25 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.d.ts +65 -0
- package/lib/Types/index.js +43 -0
- package/lib/Utils/auth-utils.d.ts +18 -0
- package/lib/Utils/auth-utils.js +209 -0
- package/lib/Utils/baileys-event-stream.d.ts +16 -0
- package/lib/Utils/baileys-event-stream.js +63 -0
- package/lib/Utils/business.d.ts +22 -0
- package/lib/Utils/business.js +234 -0
- package/lib/Utils/cache-manager.d.ts +16 -0
- package/lib/Utils/cache-manager.js +114 -0
- package/lib/Utils/chat-utils.d.ts +70 -0
- package/lib/Utils/chat-utils.js +734 -0
- package/lib/Utils/crypto.d.ts +40 -0
- package/lib/Utils/crypto.js +193 -0
- package/lib/Utils/decode-wa-message.d.ts +35 -0
- package/lib/Utils/decode-wa-message.js +207 -0
- package/lib/Utils/event-buffer.d.ts +35 -0
- package/lib/Utils/event-buffer.js +619 -0
- package/lib/Utils/generics.d.ts +89 -0
- package/lib/Utils/generics.js +440 -0
- package/lib/Utils/history.d.ts +19 -0
- package/lib/Utils/history.js +94 -0
- package/lib/Utils/index.d.ts +22 -0
- package/lib/Utils/index.js +38 -0
- package/lib/Utils/jid-validation.d.ts +2 -0
- package/lib/Utils/jid-validation.js +186 -0
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/link-preview.js +152 -0
- package/lib/Utils/logger.d.ts +11 -0
- package/lib/Utils/logger.js +59 -0
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/lt-hash.js +51 -0
- package/lib/Utils/make-mutex.d.ts +7 -0
- package/lib/Utils/make-mutex.js +43 -0
- package/lib/Utils/messages-media.d.ts +120 -0
- package/lib/Utils/messages-media.js +848 -0
- package/lib/Utils/messages.d.ts +131 -0
- package/lib/Utils/messages.js +1793 -0
- package/lib/Utils/newsletter-utils.d.ts +2 -0
- package/lib/Utils/newsletter-utils.js +48 -0
- package/lib/Utils/noise-handler.d.ts +19 -0
- package/lib/Utils/noise-handler.js +150 -0
- package/lib/Utils/performance-config.d.ts +70 -0
- package/lib/Utils/performance-config.js +183 -0
- package/lib/Utils/process-message.d.ts +42 -0
- package/lib/Utils/process-message.js +498 -0
- package/lib/Utils/rate-limiter.js +90 -0
- package/lib/Utils/retry.js +66 -0
- package/lib/Utils/signal.d.ts +33 -0
- package/lib/Utils/signal.js +153 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +12 -0
- package/lib/Utils/use-multi-file-auth-state.js +129 -0
- package/lib/Utils/validate-connection.d.ts +10 -0
- package/lib/Utils/validate-connection.js +233 -0
- package/lib/WABinary/constants.d.ts +27 -0
- package/lib/WABinary/constants.js +1303 -0
- package/lib/WABinary/decode.d.ts +6 -0
- package/lib/WABinary/decode.js +279 -0
- package/lib/WABinary/encode.d.ts +2 -0
- package/lib/WABinary/encode.js +264 -0
- package/lib/WABinary/generic-utils.d.ts +14 -0
- package/lib/WABinary/generic-utils.js +114 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/index.js +21 -0
- package/lib/WABinary/jid-utils.d.ts +38 -0
- package/lib/WABinary/jid-utils.js +485 -0
- package/lib/WABinary/types.d.ts +18 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WAM/BinaryInfo.d.ts +8 -0
- package/lib/WAM/BinaryInfo.js +13 -0
- package/lib/WAM/constants.d.ts +38 -0
- package/lib/WAM/constants.js +15350 -0
- package/lib/WAM/encode.d.ts +2 -0
- package/lib/WAM/encode.js +155 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAM/index.js +19 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +102 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +110 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
- package/lib/WAUSync/Protocols/index.d.ts +4 -0
- package/lib/WAUSync/Protocols/index.js +20 -0
- package/lib/WAUSync/USyncQuery.d.ts +28 -0
- package/lib/WAUSync/USyncQuery.js +147 -0
- package/lib/WAUSync/USyncUser.d.ts +12 -0
- package/lib/WAUSync/USyncUser.js +26 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/WAUSync/index.js +19 -0
- package/lib/index.d.ts +17 -0
- package/lib/index.js +53 -0
- package/package.json +104 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
import { SocketConfig } from '../Types';
|
|
3
|
+
import { BinaryNode } from '../WABinary';
|
|
4
|
+
import { USyncQuery } from '../WAUSync';
|
|
5
|
+
export declare const makeUSyncSocket: (config: SocketConfig) => {
|
|
6
|
+
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
|
|
7
|
+
type: "md";
|
|
8
|
+
ws: import("./Client").WebSocketClient;
|
|
9
|
+
ev: import("../Types").BaileysEventEmitter & {
|
|
10
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
11
|
+
buffer(): void;
|
|
12
|
+
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
13
|
+
flush(force?: boolean): boolean;
|
|
14
|
+
isBuffering(): boolean;
|
|
15
|
+
};
|
|
16
|
+
authState: {
|
|
17
|
+
creds: import("../Types").AuthenticationCreds;
|
|
18
|
+
keys: import("../Types").SignalKeyStoreWithTransaction;
|
|
19
|
+
};
|
|
20
|
+
signalRepository: import("../Types").SignalRepository;
|
|
21
|
+
user: import("../Types").Contact | undefined;
|
|
22
|
+
generateMessageTag: () => string;
|
|
23
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
24
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
25
|
+
waitForSocketOpen: () => Promise<void>;
|
|
26
|
+
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
27
|
+
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
28
|
+
logout: (msg?: string) => Promise<void>;
|
|
29
|
+
end: (error: Error | undefined) => void;
|
|
30
|
+
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
31
|
+
uploadPreKeys: (count?: number) => Promise<void>;
|
|
32
|
+
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
33
|
+
requestPairingCode: (phoneNumber: any, pairKey?: string) => Promise<string>;
|
|
34
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
35
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
36
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeUSyncSocket = void 0;
|
|
4
|
+
const boom_1 = require("@hapi/boom");
|
|
5
|
+
const WABinary_1 = require("../WABinary");
|
|
6
|
+
const socket_1 = require("./socket");
|
|
7
|
+
const retry_1 = require("../Utils/retry");
|
|
8
|
+
const makeUSyncSocket = (config) => {
|
|
9
|
+
const sock = (0, socket_1.makeSocket)(config);
|
|
10
|
+
const { generateMessageTag, query, } = sock;
|
|
11
|
+
const executeUSyncQuery = async (usyncQuery) => {
|
|
12
|
+
if (usyncQuery.protocols.length === 0) {
|
|
13
|
+
throw new boom_1.Boom('USyncQuery must have at least one protocol');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Validate users and filter out invalid ones
|
|
17
|
+
const validUsers = [];
|
|
18
|
+
const invalidUsers = [];
|
|
19
|
+
|
|
20
|
+
for (const user of usyncQuery.users) {
|
|
21
|
+
// Check if user has valid identifier (either id or phone)
|
|
22
|
+
if (user.id || user.phone) {
|
|
23
|
+
// Additional validation for JID format if id is provided
|
|
24
|
+
if (user.id) {
|
|
25
|
+
// Check if it's a valid JID format (user@server)
|
|
26
|
+
const decodedJid = (0, WABinary_1.jidDecode)(user.id);
|
|
27
|
+
if (decodedJid && decodedJid.user && decodedJid.server) {
|
|
28
|
+
validUsers.push(user);
|
|
29
|
+
} else {
|
|
30
|
+
invalidUsers.push(user);
|
|
31
|
+
}
|
|
32
|
+
} else if (user.phone && typeof user.phone === 'string' && user.phone.length > 0) {
|
|
33
|
+
validUsers.push(user);
|
|
34
|
+
} else {
|
|
35
|
+
invalidUsers.push(user);
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
invalidUsers.push(user);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Log warning for invalid users
|
|
43
|
+
if (invalidUsers.length > 0) {
|
|
44
|
+
config.logger?.warn({
|
|
45
|
+
invalidUsers: invalidUsers.map(u => ({ id: u.id, phone: u.phone })),
|
|
46
|
+
totalUsers: usyncQuery.users.length,
|
|
47
|
+
validUsers: validUsers.length
|
|
48
|
+
}, `Found ${invalidUsers.length} invalid users in USync query, they will be excluded`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Throw warning if no valid users found
|
|
52
|
+
if (validUsers.length === 0) {
|
|
53
|
+
throw new boom_1.Boom('No valid users found in USync query', { statusCode: 400 });
|
|
54
|
+
}
|
|
55
|
+
const userNodes = validUsers.map((user) => {
|
|
56
|
+
return {
|
|
57
|
+
tag: 'user',
|
|
58
|
+
attrs: {
|
|
59
|
+
jid: !user.phone ? user.id : undefined,
|
|
60
|
+
},
|
|
61
|
+
content: usyncQuery.protocols
|
|
62
|
+
.map((a) => a.getUserElement(user))
|
|
63
|
+
.filter(a => a !== null)
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
const listNode = {
|
|
67
|
+
tag: 'list',
|
|
68
|
+
attrs: {},
|
|
69
|
+
content: userNodes
|
|
70
|
+
};
|
|
71
|
+
const queryNode = {
|
|
72
|
+
tag: 'query',
|
|
73
|
+
attrs: {},
|
|
74
|
+
content: usyncQuery.protocols.map((a) => a.getQueryElement())
|
|
75
|
+
};
|
|
76
|
+
const iq = {
|
|
77
|
+
tag: 'iq',
|
|
78
|
+
attrs: {
|
|
79
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
80
|
+
type: 'get',
|
|
81
|
+
xmlns: 'usync',
|
|
82
|
+
},
|
|
83
|
+
content: [
|
|
84
|
+
{
|
|
85
|
+
tag: 'usync',
|
|
86
|
+
attrs: {
|
|
87
|
+
context: usyncQuery.context,
|
|
88
|
+
mode: usyncQuery.mode,
|
|
89
|
+
sid: generateMessageTag(),
|
|
90
|
+
last: 'true',
|
|
91
|
+
index: '0',
|
|
92
|
+
},
|
|
93
|
+
content: [
|
|
94
|
+
queryNode,
|
|
95
|
+
listNode
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
};
|
|
100
|
+
const result = await (0, retry_1.retryWithBackoff)(() => query(iq), {
|
|
101
|
+
retries: 2,
|
|
102
|
+
baseMs: 2000,
|
|
103
|
+
maxMs: 10000,
|
|
104
|
+
jitter: true,
|
|
105
|
+
timeoutPerAttemptMs: 15000,
|
|
106
|
+
shouldRetry: (err) => {
|
|
107
|
+
if (err.message.includes('WebSocket is not open')) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
var _a;
|
|
111
|
+
const status = ((_a = err.output) === null || _a === void 0 ? void 0 : _a.statusCode) || (err === null || err === void 0 ? void 0 : err.statusCode);
|
|
112
|
+
return !status || (status >= 500 || status === 408 || status === 429);
|
|
113
|
+
},
|
|
114
|
+
onRetry: (err, n) => sock.logger.warn({ err, attempt: n }, 'retrying usync query')
|
|
115
|
+
});
|
|
116
|
+
return usyncQuery.parseUSyncQueryResult(result);
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
...sock,
|
|
120
|
+
executeUSyncQuery,
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
exports.makeUSyncSocket = makeUSyncSocket;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
exports.makeInMemoryStore = void 0;
|
|
7
|
+
const make_in_memory_store_1 = __importDefault(require("./make-in-memory-store"));
|
|
8
|
+
exports.makeInMemoryStore = make_in_memory_store_1.default;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type KeyedDB from '@adiwajshing/keyed-db';
|
|
2
|
+
import type { Comparable } from '@adiwajshing/keyed-db/lib/Types';
|
|
3
|
+
import { proto } from '../../WAProto';
|
|
4
|
+
import type makeMDSocket from '../Socket';
|
|
5
|
+
import type { BaileysEventEmitter, Chat, ConnectionState, Contact, GroupMetadata, PresenceData, WAMessage, WAMessageCursor, WAMessageKey } from '../Types';
|
|
6
|
+
import { Label } from '../Types/Label';
|
|
7
|
+
import { LabelAssociation } from '../Types/LabelAssociation';
|
|
8
|
+
import { ILogger } from '../Utils/logger';
|
|
9
|
+
import { ObjectRepository } from './object-repository';
|
|
10
|
+
type WASocket = ReturnType<typeof makeMDSocket>;
|
|
11
|
+
export declare const waChatKey: (pin: boolean) => {
|
|
12
|
+
key: (c: Chat) => string;
|
|
13
|
+
compare: (k1: string, k2: string) => number;
|
|
14
|
+
};
|
|
15
|
+
export declare const waMessageID: (m: WAMessage) => string;
|
|
16
|
+
export declare const waLabelAssociationKey: Comparable<LabelAssociation, string>;
|
|
17
|
+
export type BaileysInMemoryStoreConfig = {
|
|
18
|
+
chatKey?: Comparable<Chat, string>;
|
|
19
|
+
labelAssociationKey?: Comparable<LabelAssociation, string>;
|
|
20
|
+
logger?: ILogger;
|
|
21
|
+
socket?: WASocket;
|
|
22
|
+
};
|
|
23
|
+
declare const _default: (config: BaileysInMemoryStoreConfig) => {
|
|
24
|
+
chats: KeyedDB<Chat, string>;
|
|
25
|
+
contacts: {
|
|
26
|
+
[_: string]: Contact;
|
|
27
|
+
};
|
|
28
|
+
messages: {
|
|
29
|
+
[_: string]: {
|
|
30
|
+
array: WAMessage[];
|
|
31
|
+
get: (id: string) => WAMessage | undefined;
|
|
32
|
+
upsert: (item: WAMessage, mode: "append" | "prepend") => void;
|
|
33
|
+
update: (item: WAMessage) => boolean;
|
|
34
|
+
remove: (item: WAMessage) => boolean;
|
|
35
|
+
updateAssign: (id: string, update: Partial<WAMessage>) => boolean;
|
|
36
|
+
clear: () => void;
|
|
37
|
+
filter: (contain: (item: WAMessage) => boolean) => void;
|
|
38
|
+
toJSON: () => WAMessage[];
|
|
39
|
+
fromJSON: (newItems: WAMessage[]) => void;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
groupMetadata: {
|
|
43
|
+
[_: string]: GroupMetadata;
|
|
44
|
+
};
|
|
45
|
+
state: ConnectionState;
|
|
46
|
+
presences: {
|
|
47
|
+
[id: string]: {
|
|
48
|
+
[participant: string]: PresenceData;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
labels: ObjectRepository<Label>;
|
|
52
|
+
labelAssociations: KeyedDB<LabelAssociation, string>;
|
|
53
|
+
bind: (ev: BaileysEventEmitter) => void;
|
|
54
|
+
/** loads messages from the store, if not found -- uses the legacy connection */
|
|
55
|
+
loadMessages: (jid: string, count: number, cursor: WAMessageCursor) => Promise<WAMessage[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Get all available labels for profile
|
|
58
|
+
*
|
|
59
|
+
* Keep in mind that the list is formed from predefined tags and tags
|
|
60
|
+
* that were "caught" during their editing.
|
|
61
|
+
*/
|
|
62
|
+
getLabels: () => ObjectRepository<Label>;
|
|
63
|
+
/**
|
|
64
|
+
* Get labels for chat
|
|
65
|
+
*
|
|
66
|
+
* @returns Label IDs
|
|
67
|
+
**/
|
|
68
|
+
getChatLabels: (chatId: string) => LabelAssociation[];
|
|
69
|
+
/**
|
|
70
|
+
* Get labels for message
|
|
71
|
+
*
|
|
72
|
+
* @returns Label IDs
|
|
73
|
+
**/
|
|
74
|
+
getMessageLabels: (messageId: string) => string[];
|
|
75
|
+
loadMessage: (jid: string, id: string) => Promise<WAMessage | undefined>;
|
|
76
|
+
mostRecentMessage: (jid: string) => Promise<WAMessage>;
|
|
77
|
+
fetchImageUrl: (jid: string, sock: WASocket | undefined) => Promise<string | null | undefined>;
|
|
78
|
+
fetchGroupMetadata: (jid: string, sock: WASocket | undefined) => Promise<GroupMetadata>;
|
|
79
|
+
fetchMessageReceipts: ({ remoteJid, id }: WAMessageKey) => Promise<proto.IUserReceipt[] | null | undefined>;
|
|
80
|
+
toJSON: () => {
|
|
81
|
+
chats: KeyedDB<Chat, string>;
|
|
82
|
+
contacts: {
|
|
83
|
+
[_: string]: Contact;
|
|
84
|
+
};
|
|
85
|
+
messages: {
|
|
86
|
+
[_: string]: {
|
|
87
|
+
array: WAMessage[];
|
|
88
|
+
get: (id: string) => WAMessage | undefined;
|
|
89
|
+
upsert: (item: WAMessage, mode: "append" | "prepend") => void;
|
|
90
|
+
update: (item: WAMessage) => boolean;
|
|
91
|
+
remove: (item: WAMessage) => boolean;
|
|
92
|
+
updateAssign: (id: string, update: Partial<WAMessage>) => boolean;
|
|
93
|
+
clear: () => void;
|
|
94
|
+
filter: (contain: (item: WAMessage) => boolean) => void;
|
|
95
|
+
toJSON: () => WAMessage[];
|
|
96
|
+
fromJSON: (newItems: WAMessage[]) => void;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
labels: ObjectRepository<Label>;
|
|
100
|
+
labelAssociations: KeyedDB<LabelAssociation, string>;
|
|
101
|
+
};
|
|
102
|
+
fromJSON: (json: {
|
|
103
|
+
chats: Chat[];
|
|
104
|
+
contacts: {
|
|
105
|
+
[id: string]: Contact;
|
|
106
|
+
};
|
|
107
|
+
messages: {
|
|
108
|
+
[id: string]: WAMessage[];
|
|
109
|
+
};
|
|
110
|
+
labels: {
|
|
111
|
+
[labelId: string]: Label;
|
|
112
|
+
};
|
|
113
|
+
labelAssociations: LabelAssociation[];
|
|
114
|
+
}) => void;
|
|
115
|
+
writeToFile: (path: string) => void;
|
|
116
|
+
readFromFile: (path: string) => void;
|
|
117
|
+
};
|
|
118
|
+
export default _default;
|