@awangxcode/qiro-baileys 7.0.0-rc25.5 → 7.0.0-rc26.2
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 +15 -0
- package/README.md +1443 -1033
- package/WAProto/WAProto.proto +4 -0
- package/WAProto/index.d.ts +4067 -243
- package/WAProto/index.js +74957 -43330
- package/assets/branding/qiro-logo.svg +24 -0
- package/assets/branding/qiro-mark.png +0 -0
- package/assets/branding/qiro-mark.svg +34 -0
- package/assets/branding/qiro-social-preview.png +0 -0
- package/lib/Defaults/index.d.ts +16 -1
- package/lib/Defaults/index.d.ts.map +1 -1
- package/lib/Defaults/index.js +43 -10
- package/lib/Defaults/index.js.map +1 -1
- package/lib/Extensions/advanced.d.ts +1 -1
- package/lib/Extensions/experimental.d.ts +1 -3
- package/lib/Extensions/experimental.d.ts.map +1 -1
- package/lib/Extensions/experimental.js +0 -2
- package/lib/Extensions/experimental.js.map +1 -1
- package/lib/MessageBuilder/index.d.ts +5 -5
- package/lib/MessageBuilder/index.d.ts.map +1 -1
- package/lib/MessageBuilder/index.js +12 -3
- package/lib/MessageBuilder/index.js.map +1 -1
- package/lib/Signal/Group/group-session-builder.d.ts +3 -3
- package/lib/Signal/Group/group-session-builder.js +4 -4
- package/lib/Signal/Group/group_cipher.d.ts +2 -2
- package/lib/Signal/Group/group_cipher.js +4 -4
- package/lib/Signal/Group/index.d.ts +11 -11
- package/lib/Signal/Group/index.js +11 -11
- package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
- package/lib/Signal/Group/sender-chain-key.js +1 -1
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +1 -1
- package/lib/Signal/Group/sender-key-distribution-message.js +1 -1
- package/lib/Signal/Group/sender-key-message.d.ts +1 -1
- package/lib/Signal/Group/sender-key-message.js +1 -1
- package/lib/Signal/Group/sender-key-record.d.ts +1 -1
- package/lib/Signal/Group/sender-key-record.js +2 -2
- package/lib/Signal/Group/sender-key-state.d.ts +2 -2
- package/lib/Signal/Group/sender-key-state.js +2 -2
- package/lib/Signal/libsignal.d.ts +3 -3
- package/lib/Signal/libsignal.js +6 -6
- package/lib/Signal/lid-mapping.d.ts +2 -2
- package/lib/Signal/lid-mapping.js +4 -4
- package/lib/Signal/lid-mapping.js.map +1 -1
- package/lib/Socket/Client/index.d.ts +2 -2
- package/lib/Socket/Client/index.js +2 -2
- package/lib/Socket/Client/types.d.ts +1 -1
- package/lib/Socket/Client/websocket.d.ts +1 -1
- package/lib/Socket/Client/websocket.js +2 -2
- package/lib/Socket/business.d.ts +347 -65
- package/lib/Socket/business.d.ts.map +1 -1
- package/lib/Socket/business.js +5 -5
- package/lib/Socket/chats.d.ts +129 -16
- package/lib/Socket/chats.d.ts.map +1 -1
- package/lib/Socket/chats.js +293 -18
- package/lib/Socket/chats.js.map +1 -1
- package/lib/Socket/communities.d.ts +332 -50
- package/lib/Socket/communities.d.ts.map +1 -1
- package/lib/Socket/communities.js +5 -5
- package/lib/Socket/groups.d.ts +133 -27
- package/lib/Socket/groups.d.ts.map +1 -1
- package/lib/Socket/groups.js +4 -4
- package/lib/Socket/index.d.ts +366 -84
- package/lib/Socket/index.d.ts.map +1 -1
- package/lib/Socket/index.js +8 -5
- package/lib/Socket/index.js.map +1 -1
- package/lib/Socket/messages-recv.d.ts +324 -41
- package/lib/Socket/messages-recv.d.ts.map +1 -1
- package/lib/Socket/messages-recv.js +81 -30
- package/lib/Socket/messages-recv.js.map +1 -1
- package/lib/Socket/messages-send.d.ts +340 -44
- package/lib/Socket/messages-send.d.ts.map +1 -1
- package/lib/Socket/messages-send.js +171 -35
- package/lib/Socket/messages-send.js.map +1 -1
- package/lib/Socket/mex.d.ts +1 -1
- package/lib/Socket/mex.js +1 -1
- package/lib/Socket/newsletter.d.ts +324 -39
- package/lib/Socket/newsletter.d.ts.map +1 -1
- package/lib/Socket/newsletter.js +345 -5
- package/lib/Socket/newsletter.js.map +1 -1
- package/lib/Socket/socket.d.ts +24 -11
- package/lib/Socket/socket.d.ts.map +1 -1
- package/lib/Socket/socket.js +89 -36
- package/lib/Socket/socket.js.map +1 -1
- package/lib/Store/index.d.ts +4 -0
- package/lib/Store/index.js +4 -0
- package/lib/Store/make-in-memory-store.d.ts +63 -0
- package/lib/Store/make-in-memory-store.js +397 -0
- package/lib/Store/make-ordered-dictionary.d.ts +13 -0
- package/lib/Store/make-ordered-dictionary.js +79 -0
- package/lib/Store/object-repository.d.ts +11 -0
- package/lib/Store/object-repository.js +24 -0
- package/lib/Types/Auth.d.ts +2 -2
- package/lib/Types/Chat.d.ts +19 -6
- package/lib/Types/Chat.d.ts.map +1 -1
- package/lib/Types/Chat.js +7 -0
- package/lib/Types/Chat.js.map +1 -1
- package/lib/Types/Events.d.ts +9 -9
- package/lib/Types/GroupMetadata.d.ts +2 -2
- package/lib/Types/Message.d.ts +70 -6
- package/lib/Types/Message.d.ts.map +1 -1
- package/lib/Types/Message.js +11 -0
- package/lib/Types/Message.js.map +1 -1
- package/lib/Types/Mex.d.ts +68 -39
- package/lib/Types/Mex.d.ts.map +1 -1
- package/lib/Types/Mex.js +66 -0
- package/lib/Types/Mex.js.map +1 -1
- package/lib/Types/Product.d.ts +1 -1
- package/lib/Types/Signal.d.ts +1 -1
- package/lib/Types/Socket.d.ts +50 -5
- package/lib/Types/Socket.d.ts.map +1 -1
- package/lib/Types/Socket.js +1 -1
- package/lib/Types/State.d.ts +1 -1
- package/lib/Types/USync.d.ts +2 -2
- package/lib/Types/USync.js +1 -1
- package/lib/Types/index.d.ts +14 -14
- package/lib/Types/index.js +12 -12
- package/lib/Utils/audio-sticker.d.ts +14 -0
- package/lib/Utils/audio-sticker.js +172 -0
- package/lib/Utils/auth-store.d.ts +30 -0
- package/lib/Utils/auth-store.js +77 -0
- package/lib/Utils/auth-utils.d.ts +2 -2
- package/lib/Utils/auth-utils.js +4 -4
- package/lib/Utils/browser-utils.d.ts +1 -1
- package/lib/Utils/business.d.ts +2 -2
- package/lib/Utils/business.js +3 -3
- package/lib/Utils/chat-theme.d.ts +34 -0
- package/lib/Utils/chat-theme.js +336 -0
- package/lib/Utils/chat-utils.d.ts +3 -3
- package/lib/Utils/chat-utils.js +9 -9
- package/lib/Utils/chat-utils.js.map +1 -1
- package/lib/Utils/companion-reg-client-utils.d.ts +3 -3
- package/lib/Utils/companion-reg-client-utils.js +1 -1
- package/lib/Utils/crypto.d.ts +1 -1
- package/lib/Utils/crypto.js +1 -1
- package/lib/Utils/decode-wa-message.d.ts +18 -4
- package/lib/Utils/decode-wa-message.d.ts.map +1 -1
- package/lib/Utils/decode-wa-message.js +57 -2
- package/lib/Utils/decode-wa-message.js.map +1 -1
- package/lib/Utils/event-buffer.d.ts +4 -3
- package/lib/Utils/event-buffer.d.ts.map +1 -1
- package/lib/Utils/event-buffer.js +7 -8
- package/lib/Utils/event-buffer.js.map +1 -1
- package/lib/Utils/generics.d.ts +5 -4
- package/lib/Utils/generics.d.ts.map +1 -1
- package/lib/Utils/generics.js +13 -22
- package/lib/Utils/generics.js.map +1 -1
- package/lib/Utils/group-metadata-cache.d.ts +4 -0
- package/lib/Utils/group-metadata-cache.js +25 -0
- package/lib/Utils/history.d.ts +1 -1
- package/lib/Utils/history.js +6 -6
- package/lib/Utils/history.js.map +1 -1
- package/lib/Utils/html-app.d.ts +19 -0
- package/lib/Utils/html-app.js +96 -0
- package/lib/Utils/html-multiplayer.d.ts +10 -0
- package/lib/Utils/html-multiplayer.js +94 -0
- package/lib/Utils/identity-change-handler.d.ts +2 -2
- package/lib/Utils/identity-change-handler.js +2 -2
- package/lib/Utils/index.d.ts +46 -21
- package/lib/Utils/index.d.ts.map +1 -1
- package/lib/Utils/index.js +48 -21
- package/lib/Utils/index.js.map +1 -1
- package/lib/Utils/link-preview-metadata.d.ts +47 -0
- package/lib/Utils/link-preview-metadata.js +88 -0
- package/lib/Utils/link-preview.d.ts +2 -2
- package/lib/Utils/link-preview.js +2 -2
- package/lib/Utils/message-retry-manager.d.ts +1 -1
- package/lib/Utils/messages-media.d.ts +35 -6
- package/lib/Utils/messages-media.d.ts.map +1 -1
- package/lib/Utils/messages-media.js +69 -22
- package/lib/Utils/messages-media.js.map +1 -1
- package/lib/Utils/messages.d.ts +45 -5
- package/lib/Utils/messages.d.ts.map +1 -1
- package/lib/Utils/messages.js +123 -32
- package/lib/Utils/messages.js.map +1 -1
- package/lib/Utils/modern-messages.d.ts +150 -0
- package/lib/Utils/modern-messages.js +496 -0
- package/lib/Utils/native-flow.d.ts +11 -0
- package/lib/Utils/native-flow.js +116 -0
- package/lib/Utils/newsletter-status.d.ts +158 -0
- package/lib/Utils/newsletter-status.js +651 -0
- package/lib/Utils/noise-handler.d.ts +3 -3
- package/lib/Utils/noise-handler.js +3 -3
- package/lib/Utils/offline-node-processor.d.ts +1 -1
- package/lib/Utils/optional-media.d.ts +3 -0
- package/lib/Utils/optional-media.js +46 -0
- package/lib/Utils/payment-messages.d.ts +38 -0
- package/lib/Utils/payment-messages.js +160 -0
- package/lib/Utils/pre-key-manager.d.ts +2 -2
- package/lib/Utils/process-message.d.ts +13 -2
- package/lib/Utils/process-message.d.ts.map +1 -1
- package/lib/Utils/process-message.js +87 -7
- package/lib/Utils/process-message.js.map +1 -1
- package/lib/Utils/reporting-utils.d.ts +2 -2
- package/lib/Utils/reporting-utils.js +1 -1
- package/lib/Utils/scheduled-message.d.ts +51 -0
- package/lib/Utils/scheduled-message.js +113 -0
- package/lib/Utils/sender-key-memory.d.ts +19 -0
- package/lib/Utils/sender-key-memory.js +51 -0
- package/lib/Utils/signal.d.ts +4 -4
- package/lib/Utils/signal.js +4 -4
- package/lib/Utils/stanza-ack.d.ts +1 -1
- package/lib/Utils/status-stickers.d.ts +127 -0
- package/lib/Utils/status-stickers.js +261 -0
- package/lib/Utils/sync-action-utils.d.ts +2 -2
- package/lib/Utils/sync-action-utils.js +1 -1
- package/lib/Utils/tc-token-utils.d.ts +2 -2
- package/lib/Utils/tc-token-utils.js +1 -1
- package/lib/Utils/ttl-cache.d.ts +29 -0
- package/lib/Utils/ttl-cache.js +121 -0
- package/lib/Utils/use-mongo-auth-state.d.ts +22 -0
- package/lib/Utils/use-mongo-auth-state.js +68 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +2 -1
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -1
- package/lib/Utils/use-multi-file-auth-state.js +28 -15
- package/lib/Utils/use-multi-file-auth-state.js.map +1 -1
- package/lib/Utils/use-mysql-auth-state.d.ts +20 -0
- package/lib/Utils/use-mysql-auth-state.js +80 -0
- package/lib/Utils/use-nekodb-auth.d.ts +19 -0
- package/lib/Utils/use-nekodb-auth.js +111 -0
- package/lib/Utils/use-postgres-auth-state.d.ts +20 -0
- package/lib/Utils/use-postgres-auth-state.js +80 -0
- package/lib/Utils/use-redis-auth-state.d.ts +20 -0
- package/lib/Utils/use-redis-auth-state.js +90 -0
- package/lib/Utils/use-single-file-auth-state.d.ts +11 -0
- package/lib/Utils/use-single-file-auth-state.js +109 -0
- package/lib/Utils/use-sqlite-auth-state.d.ts +13 -0
- package/lib/Utils/use-sqlite-auth-state.js +121 -0
- package/lib/Utils/username.d.ts +12 -0
- package/lib/Utils/username.js +59 -0
- package/lib/Utils/validate-connection.d.ts +2 -2
- package/lib/Utils/validate-connection.js +5 -5
- package/lib/Utils/voice-recognition.d.ts +53 -0
- package/lib/Utils/voice-recognition.js +219 -0
- package/lib/VoIP/audio-feeder.d.ts +24 -0
- package/lib/VoIP/audio-feeder.js +276 -0
- package/lib/VoIP/index.d.ts +93 -0
- package/lib/VoIP/index.js +998 -0
- package/lib/VoIP/relay-transport.d.ts +5 -0
- package/lib/VoIP/relay-transport.js +824 -0
- package/lib/VoIP/signaling.d.ts +11 -0
- package/lib/VoIP/signaling.js +1099 -0
- package/lib/VoIP/types.d.ts +2 -0
- package/lib/VoIP/types.js +12 -0
- package/lib/VoIP/video-feeder.d.ts +24 -0
- package/lib/VoIP/video-feeder.js +276 -0
- package/lib/VoIP/wasm-engine.d.ts +26 -0
- package/lib/VoIP/wasm-engine.js +1318 -0
- package/lib/VoIP/worker-bootstrap.js +1022 -0
- package/lib/WABinary/decode.d.ts +1 -1
- package/lib/WABinary/decode.js +2 -2
- package/lib/WABinary/encode.d.ts +1 -1
- package/lib/WABinary/encode.js +2 -2
- package/lib/WABinary/generic-utils.d.ts +3 -1
- package/lib/WABinary/generic-utils.d.ts.map +1 -1
- package/lib/WABinary/generic-utils.js +3 -1
- package/lib/WABinary/generic-utils.js.map +1 -1
- package/lib/WABinary/index.d.ts +5 -5
- package/lib/WABinary/index.js +5 -5
- package/lib/WABinary/jid-utils.d.ts +2 -0
- package/lib/WABinary/jid-utils.d.ts.map +1 -1
- package/lib/WABinary/jid-utils.js +3 -1
- package/lib/WABinary/jid-utils.js.map +1 -1
- package/lib/WABinary/types.d.ts +1 -1
- package/lib/WABinary/types.js +1 -1
- package/lib/WAM/BinaryInfo.d.ts +1 -1
- package/lib/WAM/encode.d.ts +1 -1
- package/lib/WAM/encode.js +2 -2
- package/lib/WAM/index.d.ts +3 -3
- package/lib/WAM/index.js +3 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +3 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +3 -3
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +2 -2
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +3 -3
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +2 -2
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +3 -3
- package/lib/WAUSync/Protocols/index.d.ts +5 -5
- package/lib/WAUSync/Protocols/index.js +5 -5
- package/lib/WAUSync/USyncQuery.d.ts +3 -3
- package/lib/WAUSync/USyncQuery.js +5 -5
- package/lib/WAUSync/index.d.ts +3 -3
- package/lib/WAUSync/index.js +3 -3
- package/lib/extensions/awang-MessageBuilder.js +1 -1
- package/lib/index.d.ts +14 -10
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +15 -11
- package/lib/index.js.map +1 -1
- package/package.json +78 -31
- package/MIGRASI-QIRO-BAILEYS-RC25.md +0 -102
- package/QIRO-BAILEYS-RC25.md +0 -168
- package/THIRD_PARTY_NOTICES.md +0 -49
- /package/{engine-requirements.js → config/engine-requirements.js} +0 -0
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
/* QIRO utility module. */
|
|
2
|
+
import keyedDB from '@adiwajshing/keyed-db';
|
|
3
|
+
import { writeFileSync, readFileSync, existsSync } from 'fs';
|
|
4
|
+
import { proto as WAProto } from '../../WAProto/index.js';
|
|
5
|
+
import { LabelAssociationType } from '../Types/LabelAssociation.js';
|
|
6
|
+
import { DEFAULT_CONNECTION_CONFIG } from '../Defaults/index.js';
|
|
7
|
+
import { md5, toNumber, updateMessageWithReceipt, updateMessageWithReaction } from '../Utils/index.js';
|
|
8
|
+
import { jidDecode, jidNormalizedUser } from '../WABinary/index.js';
|
|
9
|
+
import { makeOrderedDictionary } from './make-ordered-dictionary.js';
|
|
10
|
+
import { ObjectRepository } from './object-repository.js';
|
|
11
|
+
export const waChatKey = (pin) => ({
|
|
12
|
+
key: (c) => (pin ? (c.pinned ? '1' : '0') : '') + (c.archived ? '0' : '1') + (c.conversationTimestamp ? c.conversationTimestamp.toString(16).padStart(8, '0') : '') + c.id,
|
|
13
|
+
compare: (k1, k2) => k2.localeCompare(k1)
|
|
14
|
+
});
|
|
15
|
+
export const waMessageID = (m) => m.key.id || '';
|
|
16
|
+
export const waLabelAssociationKey = {
|
|
17
|
+
key: (la) => (la.type === LabelAssociationType.Chat ? la.chatId + la.labelId : la.chatId + la.messageId + la.labelId),
|
|
18
|
+
compare: (k1, k2) => k2.localeCompare(k1)
|
|
19
|
+
};
|
|
20
|
+
const makeMessagesDictionary = () => makeOrderedDictionary(waMessageID);
|
|
21
|
+
export const makeInMemoryStore = (config = {}) => {
|
|
22
|
+
const socket = config.socket;
|
|
23
|
+
const chatKey = config.chatKey || waChatKey(true);
|
|
24
|
+
const labelAssociationKey = config.labelAssociationKey || waLabelAssociationKey;
|
|
25
|
+
const logger = config.logger || DEFAULT_CONNECTION_CONFIG.logger.child({ stream: 'in-mem-store' });
|
|
26
|
+
const KeyedDB = keyedDB?.default ?? keyedDB;
|
|
27
|
+
const chats = new KeyedDB(chatKey, c => c.id);
|
|
28
|
+
const messages = {};
|
|
29
|
+
const contacts = {};
|
|
30
|
+
const groupMetadata = {};
|
|
31
|
+
const presences = {};
|
|
32
|
+
const state = { connection: 'close' };
|
|
33
|
+
const labels = new ObjectRepository();
|
|
34
|
+
const labelAssociations = new KeyedDB(labelAssociationKey, labelAssociationKey.key);
|
|
35
|
+
const assertMessageList = (jid) => {
|
|
36
|
+
if (!messages[jid]) {
|
|
37
|
+
messages[jid] = makeMessagesDictionary();
|
|
38
|
+
}
|
|
39
|
+
return messages[jid];
|
|
40
|
+
};
|
|
41
|
+
const contactsUpsert = (newContacts) => {
|
|
42
|
+
const oldContacts = new Set(Object.keys(contacts));
|
|
43
|
+
for (const contact of newContacts) {
|
|
44
|
+
oldContacts.delete(contact.id);
|
|
45
|
+
contacts[contact.id] = Object.assign(contacts[contact.id] || {}, contact);
|
|
46
|
+
}
|
|
47
|
+
return oldContacts;
|
|
48
|
+
};
|
|
49
|
+
const labelsUpsert = (newLabels) => {
|
|
50
|
+
for (const label of newLabels) {
|
|
51
|
+
labels.upsertById(label.id, label);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const bind = (ev) => {
|
|
56
|
+
ev.on('connection.update', update => {
|
|
57
|
+
Object.assign(state, update);
|
|
58
|
+
});
|
|
59
|
+
ev.on('messaging-history.set', ({ chats: newChats, contacts: newContacts, messages: newMessages, isLatest, syncType }) => {
|
|
60
|
+
if (syncType === WAProto.HistorySync.HistorySyncType.ON_DEMAND) {
|
|
61
|
+
return;
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
if (isLatest) {
|
|
65
|
+
chats.clear();
|
|
66
|
+
for (const id in messages) {
|
|
67
|
+
delete messages[id];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const chatsAdded = chats.insertIfAbsent(...newChats).length;
|
|
71
|
+
logger.debug({ chatsAdded }, 'synced chats');
|
|
72
|
+
const oldContacts = contactsUpsert(newContacts);
|
|
73
|
+
if (isLatest) {
|
|
74
|
+
for (const jid of oldContacts) {
|
|
75
|
+
delete contacts[jid];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
logger.debug({ deletedContacts: isLatest ? oldContacts.size : 0, newContacts }, 'synced contacts');
|
|
79
|
+
for (const msg of newMessages) {
|
|
80
|
+
const jid = msg.key.remoteJidAlt || msg.key.remoteJid;
|
|
81
|
+
const list = assertMessageList(jid);
|
|
82
|
+
list.upsert(msg, 'prepend');
|
|
83
|
+
}
|
|
84
|
+
logger.debug({ messages: newMessages.length }, 'synced messages');
|
|
85
|
+
});
|
|
86
|
+
ev.on('contacts.upsert', contacts => {
|
|
87
|
+
contactsUpsert(contacts);
|
|
88
|
+
});
|
|
89
|
+
ev.on('contacts.update', async (updates) => {
|
|
90
|
+
var _a;
|
|
91
|
+
for (const update of updates) {
|
|
92
|
+
let contact;
|
|
93
|
+
if (contacts[update.id]) {
|
|
94
|
+
contact = contacts[update.id];
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
const contactHashes = await Promise.all(Object.keys(contacts).map(async (contactId) => {
|
|
98
|
+
const { user } = jidDecode(contactId);
|
|
99
|
+
return [contactId, (await md5(Buffer.from(user + 'WA_ADD_NOTIF', 'utf8'))).toString('base64').slice(0, 3)];
|
|
100
|
+
}));
|
|
101
|
+
contact = contacts[((_a = contactHashes.find(([, b]) => b === update.id)) === null || _a === void 0 ? void 0 : _a[0]) || ''];
|
|
102
|
+
}
|
|
103
|
+
if (contact) {
|
|
104
|
+
if (update.imgUrl === 'changed') {
|
|
105
|
+
contact.imgUrl = socket ? await (socket === null || socket === void 0 ? void 0 : socket.profilePictureUrl(contact.id)) : undefined;
|
|
106
|
+
}
|
|
107
|
+
else if (update.imgUrl === 'removed') {
|
|
108
|
+
delete contact.imgUrl;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
return logger.debug({ update }, 'got update for non-existant contact');
|
|
113
|
+
}
|
|
114
|
+
Object.assign(contacts[contact.id], contact);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
ev.on('chats.upsert', newChats => {
|
|
118
|
+
chats.upsert(...newChats);
|
|
119
|
+
});
|
|
120
|
+
ev.on('chats.update', updates => {
|
|
121
|
+
for (let update of updates) {
|
|
122
|
+
const result = chats.update(update.id, chat => {
|
|
123
|
+
if (update.unreadCount > 0) {
|
|
124
|
+
update = { ...update };
|
|
125
|
+
update.unreadCount = (chat.unreadCount || 0) + update.unreadCount;
|
|
126
|
+
}
|
|
127
|
+
Object.assign(chat, update);
|
|
128
|
+
});
|
|
129
|
+
if (!result) {
|
|
130
|
+
logger.debug({ update }, 'got update for non-existant chat');
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
ev.on('labels.edit', (label) => {
|
|
135
|
+
if (label.deleted) {
|
|
136
|
+
return labels.deleteById(label.id);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (labels.count() < 20) {
|
|
140
|
+
return labels.upsertById(label.id, label);
|
|
141
|
+
}
|
|
142
|
+
logger.error('Labels count exceed');
|
|
143
|
+
});
|
|
144
|
+
ev.on('labels.association', ({ type, association }) => {
|
|
145
|
+
switch (type) {
|
|
146
|
+
case 'add':
|
|
147
|
+
labelAssociations.upsert(association);
|
|
148
|
+
break;
|
|
149
|
+
case 'remove':
|
|
150
|
+
labelAssociations.delete(association);
|
|
151
|
+
break;
|
|
152
|
+
default:
|
|
153
|
+
console.error(`unknown operation type [${type}]`);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
ev.on('presence.update', ({ id, presences: update }) => {
|
|
157
|
+
presences[id] = presences[id] || {};
|
|
158
|
+
Object.assign(presences[id], update);
|
|
159
|
+
});
|
|
160
|
+
ev.on('chats.delete', deletions => {
|
|
161
|
+
for (const item of deletions) {
|
|
162
|
+
if (chats.get(item)) {
|
|
163
|
+
chats.deleteById(item);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
ev.on('messages.upsert', ({ messages: newMessages, type }) => {
|
|
168
|
+
switch (type) {
|
|
169
|
+
case 'append':
|
|
170
|
+
case 'notify':
|
|
171
|
+
for (const msg of newMessages) {
|
|
172
|
+
const jid = jidNormalizedUser(msg.key.remoteJidAlt || msg.key.remoteJid);
|
|
173
|
+
const list = assertMessageList(jid);
|
|
174
|
+
list.upsert(msg, 'append');
|
|
175
|
+
if (type === 'notify' && !chats.get(jid)) {
|
|
176
|
+
ev.emit('chats.upsert', [
|
|
177
|
+
{
|
|
178
|
+
id: jid,
|
|
179
|
+
conversationTimestamp: toNumber(msg.messageTimestamp),
|
|
180
|
+
unreadCount: 1
|
|
181
|
+
}
|
|
182
|
+
]);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
ev.on('messages.update', updates => {
|
|
189
|
+
var _a;
|
|
190
|
+
for (const { update, key } of updates) {
|
|
191
|
+
const list = assertMessageList(jidNormalizedUser(key.remoteJid));
|
|
192
|
+
if (update === null || update === void 0 ? void 0 : update.status) {
|
|
193
|
+
const listStatus = (_a = list.get(key.id)) === null || _a === void 0 ? void 0 : _a.status;
|
|
194
|
+
if (listStatus && (update === null || update === void 0 ? void 0 : update.status) <= listStatus) {
|
|
195
|
+
logger.debug({ update, storedStatus: listStatus }, 'status stored newer then update');
|
|
196
|
+
delete update.status;
|
|
197
|
+
logger.debug({ update }, 'new update object');
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
const result = list.updateAssign(key.id, update);
|
|
201
|
+
if (!result) {
|
|
202
|
+
logger.debug({ update }, 'got update for non-existent message');
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
ev.on('messages.delete', item => {
|
|
207
|
+
if ('all' in item) {
|
|
208
|
+
const list = messages[item.jid];
|
|
209
|
+
list === null || list === void 0 ? void 0 : list.clear();
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
const jid = item.keys[0].remoteJidAlt || item.keys[0].remoteJid;
|
|
213
|
+
const list = messages[jid];
|
|
214
|
+
if (list) {
|
|
215
|
+
const idSet = new Set(item.keys.map(k => k.id));
|
|
216
|
+
list.filter(m => !idSet.has(m.key.id));
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
ev.on('groups.update', updates => {
|
|
221
|
+
for (const update of updates) {
|
|
222
|
+
const id = update.id;
|
|
223
|
+
if (groupMetadata[id]) {
|
|
224
|
+
Object.assign(groupMetadata[id], update);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
logger.debug({ update }, 'got update for non-existant group metadata');
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
ev.on('group-participants.update', ({ id, participants, action }) => {
|
|
232
|
+
const metadata = groupMetadata[id];
|
|
233
|
+
if (metadata) {
|
|
234
|
+
switch (action) {
|
|
235
|
+
case 'add':
|
|
236
|
+
metadata.participants.push(...participants.map(participant => ({ id: participant.id, phoneNumber: participant.phoneNumber, admin: participant.admin })));
|
|
237
|
+
break;
|
|
238
|
+
case 'demote':
|
|
239
|
+
case 'promote':
|
|
240
|
+
for (const participant of metadata.participants) {
|
|
241
|
+
for (const participantData of participants) {
|
|
242
|
+
if (participantData.id === participant.id || participantData.phoneNumber === participant.phoneNumber) {
|
|
243
|
+
participant.admin = action === 'promote' && 'admin';
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
break;
|
|
248
|
+
case 'remove':
|
|
249
|
+
const removeSet = new Set();
|
|
250
|
+
for (const p of participants) {
|
|
251
|
+
if (p.id)
|
|
252
|
+
removeSet.add(p.id);
|
|
253
|
+
if (p.phoneNumber)
|
|
254
|
+
removeSet.add(p.phoneNumber);
|
|
255
|
+
}
|
|
256
|
+
metadata.participants = metadata.participants.reduce((acc, p) => {
|
|
257
|
+
if (!removeSet.has(p.id) && !removeSet.has(p.phoneNumber))
|
|
258
|
+
acc.push(p);
|
|
259
|
+
return acc;
|
|
260
|
+
}, []);
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
ev.on('message-receipt.update', updates => {
|
|
266
|
+
for (const { key, receipt } of updates) {
|
|
267
|
+
const obj = messages[key.remoteJidAlt || key.remoteJid];
|
|
268
|
+
const msg = obj === null || obj === void 0 ? void 0 : obj.get(key.id);
|
|
269
|
+
if (msg) {
|
|
270
|
+
updateMessageWithReceipt(msg, receipt);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
ev.on('messages.reaction', (reactions) => {
|
|
275
|
+
for (const { key, reaction } of reactions) {
|
|
276
|
+
const obj = messages[key.remoteJidAlt || key.remoteJid];
|
|
277
|
+
const msg = obj === null || obj === void 0 ? void 0 : obj.get(key.id);
|
|
278
|
+
if (msg) {
|
|
279
|
+
updateMessageWithReaction(msg, reaction);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
};
|
|
284
|
+
const toJSON = () => ({
|
|
285
|
+
chats,
|
|
286
|
+
contacts,
|
|
287
|
+
messages,
|
|
288
|
+
labels,
|
|
289
|
+
labelAssociations
|
|
290
|
+
});
|
|
291
|
+
const fromJSON = (json) => {
|
|
292
|
+
chats.upsert(...json.chats);
|
|
293
|
+
labelAssociations.upsert(...json.labelAssociations || []);
|
|
294
|
+
contactsUpsert(Object.values(json.contacts));
|
|
295
|
+
labelsUpsert(Object.values(json.labels || {}));
|
|
296
|
+
for (const jid in json.messages) {
|
|
297
|
+
const list = assertMessageList(jid);
|
|
298
|
+
for (const msg of json.messages[jid]) {
|
|
299
|
+
list.upsert(WAProto.WebMessageInfo.fromObject(msg), 'append');
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
return {
|
|
304
|
+
chats,
|
|
305
|
+
contacts,
|
|
306
|
+
messages,
|
|
307
|
+
groupMetadata,
|
|
308
|
+
state,
|
|
309
|
+
presences,
|
|
310
|
+
labels,
|
|
311
|
+
labelAssociations,
|
|
312
|
+
bind,
|
|
313
|
+
|
|
314
|
+
loadMessages: async (jid, count, cursor) => {
|
|
315
|
+
const list = assertMessageList(jid);
|
|
316
|
+
const mode = !cursor || 'before' in cursor ? 'before' : 'after';
|
|
317
|
+
const cursorKey = cursor ? ('before' in cursor ? cursor.before : cursor.after) : undefined;
|
|
318
|
+
const cursorValue = cursorKey ? list.get(cursorKey.id) : undefined;
|
|
319
|
+
let messages;
|
|
320
|
+
if (list && mode === 'before' && (!cursorKey || cursorValue)) {
|
|
321
|
+
if (cursorValue) {
|
|
322
|
+
const msgIdx = list.array.findIndex(m => m.key.id === (cursorKey === null || cursorKey === void 0 ? void 0 : cursorKey.id));
|
|
323
|
+
messages = list.array.slice(0, msgIdx);
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
messages = list.array;
|
|
327
|
+
}
|
|
328
|
+
const diff = count - messages.length;
|
|
329
|
+
if (diff < 0) {
|
|
330
|
+
messages = messages.slice(-count);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
messages = [];
|
|
335
|
+
}
|
|
336
|
+
return messages;
|
|
337
|
+
},
|
|
338
|
+
|
|
339
|
+
getLabels: () => {
|
|
340
|
+
return labels;
|
|
341
|
+
},
|
|
342
|
+
|
|
343
|
+
getChatLabels: (chatId) => {
|
|
344
|
+
return labelAssociations.filter((la) => la.chatId === chatId).all();
|
|
345
|
+
},
|
|
346
|
+
|
|
347
|
+
getMessageLabels: (messageId) => {
|
|
348
|
+
const associations = labelAssociations
|
|
349
|
+
.filter((la) => la.messageId === messageId)
|
|
350
|
+
.all();
|
|
351
|
+
return associations.map(({ labelId }) => labelId);
|
|
352
|
+
},
|
|
353
|
+
loadMessage: async (jid, id) => { var _a; return (_a = messages[jid]) === null || _a === void 0 ? void 0 : _a.get(id); },
|
|
354
|
+
mostRecentMessage: async (jid) => {
|
|
355
|
+
var _a;
|
|
356
|
+
const message = (_a = messages[jid]) === null || _a === void 0 ? void 0 : _a.array.slice(-1)[0];
|
|
357
|
+
return message;
|
|
358
|
+
},
|
|
359
|
+
fetchImageUrl: async (jid, sock) => {
|
|
360
|
+
const contact = contacts[jid];
|
|
361
|
+
if (!contact) {
|
|
362
|
+
return sock === null || sock === void 0 ? void 0 : sock.profilePictureUrl(jid);
|
|
363
|
+
}
|
|
364
|
+
if (typeof contact.imgUrl === 'undefined') {
|
|
365
|
+
contact.imgUrl = await (sock === null || sock === void 0 ? void 0 : sock.profilePictureUrl(jid));
|
|
366
|
+
}
|
|
367
|
+
return contact.imgUrl;
|
|
368
|
+
},
|
|
369
|
+
fetchGroupMetadata: async (jid, sock) => {
|
|
370
|
+
if (!groupMetadata[jid]) {
|
|
371
|
+
const metadata = await (sock === null || sock === void 0 ? void 0 : sock.groupMetadata(jid));
|
|
372
|
+
if (metadata) {
|
|
373
|
+
groupMetadata[jid] = metadata;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return groupMetadata[jid];
|
|
377
|
+
},
|
|
378
|
+
fetchMessageReceipts: async ({ remoteJid, id }) => {
|
|
379
|
+
const list = messages[remoteJid];
|
|
380
|
+
const msg = list === null || list === void 0 ? void 0 : list.get(id);
|
|
381
|
+
return msg === null || msg === void 0 ? void 0 : msg.userReceipt;
|
|
382
|
+
},
|
|
383
|
+
toJSON,
|
|
384
|
+
fromJSON,
|
|
385
|
+
writeToFile: (path) => {
|
|
386
|
+
writeFileSync(path, JSON.stringify(toJSON()));
|
|
387
|
+
},
|
|
388
|
+
readFromFile: (path) => {
|
|
389
|
+
if (existsSync(path)) {
|
|
390
|
+
logger.debug({ path }, 'reading from file');
|
|
391
|
+
const jsonStr = readFileSync(path, { encoding: 'utf-8' });
|
|
392
|
+
const json = JSON.parse(jsonStr);
|
|
393
|
+
fromJSON(json);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* QIRO utility module. */
|
|
2
|
+
export function makeOrderedDictionary(idGetter: any): {
|
|
3
|
+
array: any[];
|
|
4
|
+
get: (id: any) => any;
|
|
5
|
+
upsert: (item: any, mode: any) => void;
|
|
6
|
+
update: (item: any) => boolean;
|
|
7
|
+
remove: (item: any) => boolean;
|
|
8
|
+
updateAssign: (id: any, update: any) => boolean;
|
|
9
|
+
clear: () => void;
|
|
10
|
+
filter: (contain: any) => void;
|
|
11
|
+
toJSON: () => any[];
|
|
12
|
+
fromJSON: (newItems: any) => void;
|
|
13
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/* QIRO utility module. */
|
|
2
|
+
export function makeOrderedDictionary(idGetter) {
|
|
3
|
+
const array = [];
|
|
4
|
+
const dict = {};
|
|
5
|
+
const get = (id) => dict[id];
|
|
6
|
+
const update = (item) => {
|
|
7
|
+
const id = idGetter(item);
|
|
8
|
+
const idx = array.findIndex(i => idGetter(i) === id);
|
|
9
|
+
if (idx >= 0) {
|
|
10
|
+
array[idx] = item;
|
|
11
|
+
dict[id] = item;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
};
|
|
15
|
+
const upsert = (item, mode) => {
|
|
16
|
+
const id = idGetter(item);
|
|
17
|
+
if (get(id)) {
|
|
18
|
+
update(item);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
if (mode === 'append') {
|
|
22
|
+
array.push(item);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
array.splice(0, 0, item);
|
|
26
|
+
}
|
|
27
|
+
dict[id] = item;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const remove = (item) => {
|
|
31
|
+
const id = idGetter(item);
|
|
32
|
+
const idx = array.findIndex(i => idGetter(i) === id);
|
|
33
|
+
if (idx >= 0) {
|
|
34
|
+
array.splice(idx, 1);
|
|
35
|
+
delete dict[id];
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
array,
|
|
42
|
+
get,
|
|
43
|
+
upsert,
|
|
44
|
+
update,
|
|
45
|
+
remove,
|
|
46
|
+
updateAssign: (id, update) => {
|
|
47
|
+
const item = get(id);
|
|
48
|
+
if (item) {
|
|
49
|
+
Object.assign(item, update);
|
|
50
|
+
delete dict[id];
|
|
51
|
+
dict[idGetter(item)] = item;
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
},
|
|
56
|
+
clear: () => {
|
|
57
|
+
array.splice(0, array.length);
|
|
58
|
+
for (const key of Object.keys(dict)) {
|
|
59
|
+
delete dict[key];
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
filter: (contain) => {
|
|
63
|
+
let i = 0;
|
|
64
|
+
while (i < array.length) {
|
|
65
|
+
if (!contain(array[i])) {
|
|
66
|
+
delete dict[idGetter(array[i])];
|
|
67
|
+
array.splice(i, 1);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
i += 1;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
toJSON: () => array,
|
|
75
|
+
fromJSON: (newItems) => {
|
|
76
|
+
array.splice(0, array.length, ...newItems);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* QIRO utility module. */
|
|
2
|
+
export class ObjectRepository {
|
|
3
|
+
constructor(entities?: {});
|
|
4
|
+
entityMap: Map<string, any>;
|
|
5
|
+
findById(id: any): any;
|
|
6
|
+
findAll(): any[];
|
|
7
|
+
upsertById(id: any, entity: any): Map<string, any>;
|
|
8
|
+
deleteById(id: any): boolean;
|
|
9
|
+
count(): number;
|
|
10
|
+
toJSON(): any[];
|
|
11
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* QIRO utility module. */
|
|
2
|
+
export class ObjectRepository {
|
|
3
|
+
constructor(entities = {}) {
|
|
4
|
+
this.entityMap = new Map(Object.entries(entities));
|
|
5
|
+
}
|
|
6
|
+
findById(id) {
|
|
7
|
+
return this.entityMap.get(id);
|
|
8
|
+
}
|
|
9
|
+
findAll() {
|
|
10
|
+
return Array.from(this.entityMap.values());
|
|
11
|
+
}
|
|
12
|
+
upsertById(id, entity) {
|
|
13
|
+
return this.entityMap.set(id, { ...entity });
|
|
14
|
+
}
|
|
15
|
+
deleteById(id) {
|
|
16
|
+
return this.entityMap.delete(id);
|
|
17
|
+
}
|
|
18
|
+
count() {
|
|
19
|
+
return this.entityMap.size;
|
|
20
|
+
}
|
|
21
|
+
toJSON() {
|
|
22
|
+
return this.findAll();
|
|
23
|
+
}
|
|
24
|
+
}
|
package/lib/Types/Auth.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { proto } from '../../WAProto/index.js';
|
|
2
|
-
import type { Contact } from './Contact
|
|
3
|
-
import type { MinimalMessage } from './Message
|
|
2
|
+
import type { Contact } from './Contact';
|
|
3
|
+
import type { MinimalMessage } from './Message';
|
|
4
4
|
export type KeyPair = {
|
|
5
5
|
public: Uint8Array;
|
|
6
6
|
private: Uint8Array;
|
package/lib/Types/Chat.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { proto } from '../../WAProto/index.js';
|
|
2
|
-
import type { AccountSettings } from './Auth
|
|
2
|
+
import type { AccountSettings } from './Auth';
|
|
3
3
|
import type { QuickReplyAction } from './Bussines.js';
|
|
4
|
-
import type { BufferedEventData } from './Events
|
|
5
|
-
import type { LabelActionBody } from './Label
|
|
6
|
-
import type { ChatLabelAssociationActionBody } from './LabelAssociation
|
|
7
|
-
import type { MessageLabelAssociationActionBody } from './LabelAssociation
|
|
8
|
-
import type { MinimalMessage, WAMessageKey } from './Message
|
|
4
|
+
import type { BufferedEventData } from './Events';
|
|
5
|
+
import type { LabelActionBody } from './Label';
|
|
6
|
+
import type { ChatLabelAssociationActionBody } from './LabelAssociation';
|
|
7
|
+
import type { MessageLabelAssociationActionBody } from './LabelAssociation';
|
|
8
|
+
import type { MinimalMessage, WAMessageKey } from './Message';
|
|
9
9
|
/** privacy settings in WhatsApp Web */
|
|
10
10
|
export type WAPrivacyValue = 'all' | 'contacts' | 'contact_blacklist' | 'none';
|
|
11
11
|
export type WAPrivacyOnlineValue = 'all' | 'match_last_seen';
|
|
@@ -15,6 +15,19 @@ export type WAPrivacyCallValue = 'all' | 'known';
|
|
|
15
15
|
export type WAPrivacyMessagesValue = 'all' | 'contacts';
|
|
16
16
|
/** set of statuses visible to other people; see updatePresence() in WhatsAppWeb.Send */
|
|
17
17
|
export type WAPresence = 'unavailable' | 'available' | 'composing' | 'recording' | 'paused';
|
|
18
|
+
export declare const SPAM_FLOWS: Readonly<{
|
|
19
|
+
OverflowMenuReport: "overflow_menu_report";
|
|
20
|
+
ContactInfoReport: "contact_info_report";
|
|
21
|
+
GroupInfoReport: "group_info_report";
|
|
22
|
+
BusinessInfoReport: "business_info_report";
|
|
23
|
+
MessageReport: "message_report";
|
|
24
|
+
}>;
|
|
25
|
+
export type SpamReportOptions = {
|
|
26
|
+
flow?: string;
|
|
27
|
+
source?: string;
|
|
28
|
+
subject?: string;
|
|
29
|
+
isKnownChat?: boolean;
|
|
30
|
+
};
|
|
18
31
|
export declare const ALL_WA_PATCH_NAMES: readonly ["critical_block", "critical_unblock_low", "regular_high", "regular_low", "regular"];
|
|
19
32
|
export type WAPatchName = (typeof ALL_WA_PATCH_NAMES)[number];
|
|
20
33
|
export interface PresenceData {
|
package/lib/Types/Chat.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../src/Types/Chat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAA;AACxE,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,oBAAoB,CAAA;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAE7D,uCAAuC;AACvC,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,UAAU,GAAG,mBAAmB,GAAG,MAAM,CAAA;AAE9E,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,iBAAiB,CAAA;AAE5D,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,UAAU,GAAG,mBAAmB,CAAA;AAE7E,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,MAAM,CAAA;AAEhD,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,OAAO,CAAA;AAEhD,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,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,8BAA8B,CAAA;CAAE,GAChD;IAAE,eAAe,EAAE,8BAA8B,CAAA;CAAE,GACnD;IAAE,eAAe,EAAE,iCAAiC,CAAA;CAAE,GACtD;IAAE,kBAAkB,EAAE,iCAAiC,CAAA;CAAE,GACzD;IAAE,UAAU,EAAE,gBAAgB,CAAA;CAAE,CAAA;AAEnC,MAAM,MAAM,yBAAyB,GAAG;IACvC,CAAC,GAAG,EAAE,MAAM,GAAG;QACd,qDAAqD;QACrD,oBAAoB,CAAC,EAAE,MAAM,CAAA;QAC7B,4CAA4C;QAC5C,gBAAgB,EAAE,MAAM,CAAA;KACxB,CAAA;CACD,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACxC,eAAe,EAAE,eAAe,CAAA;CAChC,CAAA"}
|
package/lib/Types/Chat.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
export const SPAM_FLOWS = Object.freeze({
|
|
2
|
+
OverflowMenuReport: 'overflow_menu_report',
|
|
3
|
+
ContactInfoReport: 'contact_info_report',
|
|
4
|
+
GroupInfoReport: 'group_info_report',
|
|
5
|
+
BusinessInfoReport: 'business_info_report',
|
|
6
|
+
MessageReport: 'message_report'
|
|
7
|
+
});
|
|
1
8
|
export const ALL_WA_PATCH_NAMES = [
|
|
2
9
|
'critical_block',
|
|
3
10
|
'critical_unblock_low',
|
package/lib/Types/Chat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.js","sourceRoot":"","sources":["../../src/Types/Chat.ts"],"names":[],"mappings":"AAyBA,MAAM,CAAC,MAAM,kBAAkB,GAAG;IACjC,gBAAgB;IAChB,sBAAsB;IACtB,cAAc;IACd,aAAa;IACb,SAAS;CACA,CAAA"}
|
|
1
|
+
{"version":3,"file":"Chat.js","sourceRoot":"","sources":["../../src/Types/Chat.ts"],"names":[],"mappings":"AAyBA,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;IACvC,kBAAkB,EAAE,sBAAsB;IAC1C,iBAAiB,EAAE,qBAAqB;IACxC,eAAe,EAAE,mBAAmB;IACpC,kBAAkB,EAAE,sBAAsB;IAC1C,aAAa,EAAE,gBAAgB;CAC/B,CAAC,CAAA;AASF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IACjC,gBAAgB;IAChB,sBAAsB;IACtB,cAAc;IACd,aAAa;IACb,SAAS;CACA,CAAA"}
|
package/lib/Types/Events.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Boom } from '@hapi/boom';
|
|
2
2
|
import { proto } from '../../WAProto/index.js';
|
|
3
|
-
import type { AuthenticationCreds, LIDMapping } from './Auth
|
|
4
|
-
import type { WACallEvent } from './Call
|
|
5
|
-
import type { Chat, ChatUpdate, PresenceData } from './Chat
|
|
6
|
-
import type { Contact } from './Contact
|
|
7
|
-
import type { GroupMetadata, GroupParticipant, ParticipantAction, RequestJoinAction, RequestJoinMethod } from './GroupMetadata
|
|
8
|
-
import type { Label } from './Label
|
|
9
|
-
import type { LabelAssociation } from './LabelAssociation
|
|
10
|
-
import type { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message
|
|
11
|
-
import type { ConnectionState, NewChatMessageCapInfo } from './State
|
|
3
|
+
import type { AuthenticationCreds, LIDMapping } from './Auth';
|
|
4
|
+
import type { WACallEvent } from './Call';
|
|
5
|
+
import type { Chat, ChatUpdate, PresenceData } from './Chat';
|
|
6
|
+
import type { Contact } from './Contact';
|
|
7
|
+
import type { GroupMetadata, GroupParticipant, ParticipantAction, RequestJoinAction, RequestJoinMethod } from './GroupMetadata';
|
|
8
|
+
import type { Label } from './Label';
|
|
9
|
+
import type { LabelAssociation } from './LabelAssociation';
|
|
10
|
+
import type { MessageUpsertType, MessageUserReceiptUpdate, WAMessage, WAMessageKey, WAMessageUpdate } from './Message';
|
|
11
|
+
import type { ConnectionState, NewChatMessageCapInfo } from './State';
|
|
12
12
|
export type BaileysEventMap = {
|
|
13
13
|
/** connection state has been updated -- WS closed, opened, connecting etc. */
|
|
14
14
|
'connection.update': Partial<ConnectionState>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Contact } from './Contact
|
|
2
|
-
import type { WAMessageAddressingMode } from './Message
|
|
1
|
+
import type { Contact } from './Contact';
|
|
2
|
+
import type { WAMessageAddressingMode } from './Message';
|
|
3
3
|
export type GroupParticipant = Contact & {
|
|
4
4
|
isAdmin?: boolean;
|
|
5
5
|
isSuperAdmin?: boolean;
|