@elrayyxml/baileys 1.0.6 → 1.0.7
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/README.md +58 -26
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +51 -0
- package/lib/Defaults/index.js +4 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/group-session-builder.d.ts +14 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/keyhelper.d.ts +10 -0
- package/lib/Signal/Group/queue-job.d.ts +1 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-name.d.ts +17 -0
- package/lib/Signal/Group/sender-key-record.d.ts +30 -0
- package/lib/Signal/Group/sender-key-state.d.ts +38 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/lib/Signal/libsignal.d.ts +3 -0
- package/lib/Socket/Client/index.d.ts +2 -0
- package/lib/Socket/Client/types.d.ts +16 -0
- package/lib/Socket/Client/websocket.d.ts +13 -0
- package/lib/Socket/business.d.ts +172 -0
- package/lib/Socket/chats.d.ts +82 -0
- package/lib/Socket/groups.d.ts +124 -0
- package/lib/Socket/index.d.ts +172 -0
- package/lib/Socket/messages-recv.d.ts +161 -0
- package/lib/Socket/messages-send.d.ts +151 -0
- package/lib/Socket/messages-send.js +8 -36
- package/lib/Socket/newsletter.d.ts +136 -0
- package/lib/Socket/newsletter.js +5 -1
- package/lib/Socket/socket.d.ts +43 -0
- package/lib/Socket/usync.d.ts +36 -0
- package/lib/Store/index.d.ts +2 -0
- package/lib/Store/make-in-memory-store.d.ts +118 -0
- package/lib/Store/make-ordered-dictionary.d.ts +13 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Types/Auth.d.ts +103 -0
- package/lib/Types/Call.d.ts +13 -0
- package/lib/Types/Chat.d.ts +109 -0
- package/lib/Types/Contact.d.ts +23 -0
- package/lib/Types/Events.d.ts +199 -0
- package/lib/Types/GroupMetadata.d.ts +64 -0
- package/lib/Types/Label.d.ts +35 -0
- package/lib/Types/LabelAssociation.d.ts +29 -0
- package/lib/Types/Message.d.ts +400 -0
- package/lib/Types/Newsletter.d.ts +79 -0
- package/lib/Types/Product.d.ts +78 -0
- package/lib/Types/Signal.d.ts +57 -0
- package/lib/Types/Socket.d.ts +119 -0
- package/lib/Types/State.d.ts +27 -0
- package/lib/Types/USync.d.ts +25 -0
- package/lib/Types/index.d.ts +64 -0
- package/lib/Utils/auth-utils.d.ts +18 -0
- package/lib/Utils/baileys-event-stream.d.ts +16 -0
- package/lib/Utils/business.d.ts +22 -0
- package/lib/Utils/chat-utils.d.ts +70 -0
- package/lib/Utils/crypto.d.ts +40 -0
- package/lib/Utils/decode-wa-message.d.ts +35 -0
- package/lib/Utils/event-buffer.d.ts +35 -0
- package/lib/Utils/generics.d.ts +89 -0
- package/lib/Utils/generics.js +0 -1
- package/lib/Utils/history.d.ts +19 -0
- package/lib/Utils/index.d.ts +17 -0
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/logger.d.ts +11 -0
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/make-mutex.d.ts +7 -0
- package/lib/Utils/messages-media.d.ts +120 -0
- package/lib/Utils/messages.d.ts +75 -0
- package/lib/Utils/messages.js +305 -35
- package/lib/Utils/noise-handler.d.ts +19 -0
- package/lib/Utils/process-message.d.ts +42 -0
- package/lib/Utils/signal.d.ts +33 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +12 -0
- package/lib/Utils/validate-connection.d.ts +10 -0
- package/lib/WABinary/constants.d.ts +27 -0
- package/lib/WABinary/decode.d.ts +6 -0
- package/lib/WABinary/encode.d.ts +2 -0
- package/lib/WABinary/generic-utils.d.ts +14 -0
- package/lib/WABinary/generic-utils.js +1 -9
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/jid-utils.d.ts +36 -0
- package/lib/WABinary/types.d.ts +18 -0
- package/lib/WAM/BinaryInfo.d.ts +8 -0
- package/lib/WAM/constants.d.ts +38 -0
- package/lib/WAM/encode.d.ts +2 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
- package/lib/WAUSync/Protocols/index.d.ts +4 -0
- package/lib/WAUSync/USyncQuery.d.ts +28 -0
- package/lib/WAUSync/USyncUser.d.ts +12 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.js +4 -1
- package/package.json +14 -13
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
import { proto } from '../../WAProto';
|
|
3
|
+
import { AnyMessageContent, MediaConnInfo, MessageReceiptType, MessageRelayOptions, MiscMessageGenerationOptions, SocketConfig, WAMessageKey } from '../Types';
|
|
4
|
+
import { BinaryNode, JidWithDevice } from '../WABinary';
|
|
5
|
+
import { USyncQuery } from '../WAUSync';
|
|
6
|
+
export declare const makeMessagesSocket: (config: SocketConfig) => {
|
|
7
|
+
getPrivacyTokens: (jids: string[]) => Promise<any>;
|
|
8
|
+
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
9
|
+
relayMessage: (jid: string, message: proto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: MessageRelayOptions) => Promise<string>;
|
|
10
|
+
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: MessageReceiptType) => Promise<void>;
|
|
11
|
+
sendReceipts: (keys: WAMessageKey[], type: MessageReceiptType) => Promise<void>;
|
|
12
|
+
readMessages: (keys: WAMessageKey[]) => Promise<void>;
|
|
13
|
+
refreshMediaConn: (forceGet?: boolean) => Promise<MediaConnInfo>;
|
|
14
|
+
waUploadToServer: import("../Types").WAMediaUploadFunction;
|
|
15
|
+
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
16
|
+
[_: string]: string;
|
|
17
|
+
}>;
|
|
18
|
+
getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<JidWithDevice[]>;
|
|
19
|
+
createParticipantNodes: (jids: string[], message: proto.IMessage, extraAttrs?: BinaryNode["attrs"]) => Promise<{
|
|
20
|
+
nodes: any[];
|
|
21
|
+
shouldIncludeDeviceIdentity: boolean;
|
|
22
|
+
}>;
|
|
23
|
+
sendPeerDataOperationMessage: (pdoMessage: proto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
24
|
+
updateMediaMessage: (message: proto.IWebMessageInfo) => Promise<proto.IWebMessageInfo>;
|
|
25
|
+
sendMessage: (jid: string, content: AnyMessageContent, options?: MiscMessageGenerationOptions) => Promise<proto.WebMessageInfo>;
|
|
26
|
+
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
27
|
+
duration: string;
|
|
28
|
+
}>;
|
|
29
|
+
newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
|
|
30
|
+
newsletterUpdateDescription: (jid: string, description?: string) => Promise<void>;
|
|
31
|
+
newsletterUpdateName: (jid: string, name: string) => Promise<void>;
|
|
32
|
+
newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
33
|
+
newsletterRemovePicture: (jid: string) => Promise<void>;
|
|
34
|
+
newsletterUnfollow: (jid: string) => Promise<void>;
|
|
35
|
+
newsletterFollow: (jid: string) => Promise<void>;
|
|
36
|
+
newsletterUnmute: (jid: string) => Promise<void>;
|
|
37
|
+
newsletterMute: (jid: string) => Promise<void>;
|
|
38
|
+
newsletterCreate: (name: string, description?: string, picture?: import("../Types").WAMediaUpload) => Promise<import("../Types").NewsletterMetadata>;
|
|
39
|
+
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole) => Promise<import("../Types").NewsletterMetadata>;
|
|
40
|
+
newsletterAdminCount: (jid: string) => Promise<number>;
|
|
41
|
+
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
|
42
|
+
newsletterDemote: (jid: string, user: string) => Promise<void>;
|
|
43
|
+
newsletterDelete: (jid: string) => Promise<void>;
|
|
44
|
+
newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
|
|
45
|
+
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
46
|
+
newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
47
|
+
groupQuery: (jid: string, type: "get" | "set", content: BinaryNode[]) => Promise<any>;
|
|
48
|
+
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
49
|
+
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
50
|
+
groupLeave: (id: string) => Promise<void>;
|
|
51
|
+
groupUpdateSubject: (jid: string, subject: string) => Promise<void>;
|
|
52
|
+
groupRequestParticipantsList: (jid: string) => Promise<{
|
|
53
|
+
[key: string]: string;
|
|
54
|
+
}[]>;
|
|
55
|
+
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "approve" | "reject") => Promise<{
|
|
56
|
+
status: string;
|
|
57
|
+
jid: string;
|
|
58
|
+
}[]>;
|
|
59
|
+
groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
|
|
60
|
+
status: string;
|
|
61
|
+
jid: string;
|
|
62
|
+
content: BinaryNode;
|
|
63
|
+
}[]>;
|
|
64
|
+
groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
|
|
65
|
+
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
66
|
+
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
67
|
+
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
68
|
+
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
69
|
+
groupAcceptInviteV4: (key: string | WAMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<any>;
|
|
70
|
+
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
71
|
+
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
72
|
+
groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
|
|
73
|
+
groupMemberAddMode: (jid: string, mode: "admin_add" | "all_member_add") => Promise<void>;
|
|
74
|
+
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
|
|
75
|
+
groupFetchAllParticipating: () => Promise<{
|
|
76
|
+
[_: string]: import("../Types").GroupMetadata;
|
|
77
|
+
}>;
|
|
78
|
+
getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
|
|
79
|
+
processingMutex: {
|
|
80
|
+
mutex<T>(code: () => Promise<T> | T): Promise<T>;
|
|
81
|
+
};
|
|
82
|
+
upsertMessage: (msg: import("../Types").WAMessage, type: import("../Types").MessageUpsertType) => Promise<void>;
|
|
83
|
+
appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
|
|
84
|
+
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
|
|
85
|
+
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
|
|
86
|
+
profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
|
|
87
|
+
onWhatsApp: (...jids: string[]) => Promise<{
|
|
88
|
+
jid: string;
|
|
89
|
+
exists: unknown;
|
|
90
|
+
lid: unknown;
|
|
91
|
+
}[] | undefined>;
|
|
92
|
+
fetchBlocklist: () => Promise<string[]>;
|
|
93
|
+
fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
|
|
94
|
+
fetchStatus: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
|
|
95
|
+
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
96
|
+
removeProfilePicture: (jid: string) => Promise<void>;
|
|
97
|
+
updateProfileStatus: (status: string) => Promise<void>;
|
|
98
|
+
updateProfileName: (name: string) => Promise<void>;
|
|
99
|
+
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
|
|
100
|
+
updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
|
|
101
|
+
updateMessagesPrivacy: (value: import("../Types").WAPrivacyMessagesValue) => Promise<void>;
|
|
102
|
+
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
103
|
+
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
|
|
104
|
+
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
105
|
+
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
106
|
+
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
107
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
108
|
+
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
109
|
+
getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
|
|
110
|
+
resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
111
|
+
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
112
|
+
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
|
|
113
|
+
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
114
|
+
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
115
|
+
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
116
|
+
removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
117
|
+
star: (jid: string, messages: {
|
|
118
|
+
id: string;
|
|
119
|
+
fromMe?: boolean;
|
|
120
|
+
}[], star: boolean) => Promise<void>;
|
|
121
|
+
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
|
|
122
|
+
type: "md";
|
|
123
|
+
ws: import("./Client").WebSocketClient;
|
|
124
|
+
ev: import("../Types").BaileysEventEmitter & {
|
|
125
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
126
|
+
buffer(): void;
|
|
127
|
+
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
128
|
+
flush(force?: boolean): boolean;
|
|
129
|
+
isBuffering(): boolean;
|
|
130
|
+
};
|
|
131
|
+
authState: {
|
|
132
|
+
creds: import("../Types").AuthenticationCreds;
|
|
133
|
+
keys: import("../Types").SignalKeyStoreWithTransaction;
|
|
134
|
+
};
|
|
135
|
+
signalRepository: import("../Types").SignalRepository;
|
|
136
|
+
user: import("../Types").Contact | undefined;
|
|
137
|
+
generateMessageTag: () => string;
|
|
138
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
139
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
140
|
+
waitForSocketOpen: () => Promise<void>;
|
|
141
|
+
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
142
|
+
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
143
|
+
logout: (msg?: string) => Promise<void>;
|
|
144
|
+
end: (error: Error | undefined) => void;
|
|
145
|
+
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
146
|
+
uploadPreKeys: (count?: number) => Promise<void>;
|
|
147
|
+
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
148
|
+
requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
|
|
149
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
150
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
151
|
+
};
|
|
@@ -488,8 +488,7 @@ const makeMessagesSocket = (config) => {
|
|
|
488
488
|
content: (0, Utils_1.encodeSignedDeviceIdentity)(authState.creds.account, true)
|
|
489
489
|
});
|
|
490
490
|
logger.debug({ jid }, 'adding device identity');
|
|
491
|
-
}
|
|
492
|
-
|
|
491
|
+
}
|
|
493
492
|
if (AI && isPrivate) {
|
|
494
493
|
const botNode = {
|
|
495
494
|
tag: 'bot',
|
|
@@ -508,7 +507,7 @@ const makeMessagesSocket = (config) => {
|
|
|
508
507
|
else {
|
|
509
508
|
stanza.content.push(botNode)
|
|
510
509
|
}
|
|
511
|
-
}
|
|
510
|
+
}
|
|
512
511
|
if (additionalNodes && additionalNodes.length > 0) {
|
|
513
512
|
stanza.content.push(...additionalNodes);
|
|
514
513
|
}
|
|
@@ -584,6 +583,9 @@ const makeMessagesSocket = (config) => {
|
|
|
584
583
|
if (message.imageMessage) {
|
|
585
584
|
return 'image';
|
|
586
585
|
}
|
|
586
|
+
else if (message.stickerMessage) {
|
|
587
|
+
return message.stickerMessage.isLottie ? '1p_sticker' : message.stickerMessage.isAvatar ? 'avatar_sticker' : 'sticker';
|
|
588
|
+
}
|
|
587
589
|
else if (message.videoMessage) {
|
|
588
590
|
return message.videoMessage.gifPlayback ? 'gif' : 'video';
|
|
589
591
|
}
|
|
@@ -602,6 +604,9 @@ const makeMessagesSocket = (config) => {
|
|
|
602
604
|
else if (message.documentMessage) {
|
|
603
605
|
return 'document';
|
|
604
606
|
}
|
|
607
|
+
else if (message.stickerPackMessage) {
|
|
608
|
+
return 'sticker_pack';
|
|
609
|
+
}
|
|
605
610
|
else if (message.contactsArrayMessage) {
|
|
606
611
|
return 'contact_array';
|
|
607
612
|
}
|
|
@@ -611,9 +616,6 @@ const makeMessagesSocket = (config) => {
|
|
|
611
616
|
else if (message.liveLocationMessage) {
|
|
612
617
|
return 'livelocation';
|
|
613
618
|
}
|
|
614
|
-
else if (message.stickerMessage) {
|
|
615
|
-
return 'sticker';
|
|
616
|
-
}
|
|
617
619
|
else if (message.listMessage) {
|
|
618
620
|
return 'list';
|
|
619
621
|
}
|
|
@@ -642,35 +644,6 @@ const makeMessagesSocket = (config) => {
|
|
|
642
644
|
return 'url';
|
|
643
645
|
}
|
|
644
646
|
};
|
|
645
|
-
const getButtonType = (message) => {
|
|
646
|
-
if (message.listMessage) {
|
|
647
|
-
return 'list'
|
|
648
|
-
}
|
|
649
|
-
else if (message.buttonsMessage) {
|
|
650
|
-
return 'buttons'
|
|
651
|
-
}
|
|
652
|
-
else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'review_and_pay') {
|
|
653
|
-
return 'review_and_pay'
|
|
654
|
-
}
|
|
655
|
-
else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'review_order') {
|
|
656
|
-
return 'review_order'
|
|
657
|
-
}
|
|
658
|
-
else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_info') {
|
|
659
|
-
return 'payment_info'
|
|
660
|
-
}
|
|
661
|
-
else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_status') {
|
|
662
|
-
return 'payment_status'
|
|
663
|
-
}
|
|
664
|
-
else if (message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name === 'payment_method') {
|
|
665
|
-
return 'payment_method'
|
|
666
|
-
}
|
|
667
|
-
else if (message.interactiveMessage && message.interactiveMessage?.nativeFlowMessage) {
|
|
668
|
-
return 'interactive'
|
|
669
|
-
}
|
|
670
|
-
else if (message.interactiveMessage?.nativeFlowMessage) {
|
|
671
|
-
return 'native_flow'
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
647
|
const getPrivacyTokens = async (jids) => {
|
|
675
648
|
const t = (0, Utils_1.unixTimestampSeconds)().toString();
|
|
676
649
|
const result = await query({
|
|
@@ -990,7 +963,6 @@ const makeMessagesSocket = (config) => {
|
|
|
990
963
|
: undefined
|
|
991
964
|
}),
|
|
992
965
|
getProfilePicUrl: sock.profilePictureUrl,
|
|
993
|
-
getCallLink: sock.createCallLink,
|
|
994
966
|
upload: async (readStream, opts) => {
|
|
995
967
|
const up = await waUploadToServer(readStream, { ...opts, newsletter: (0, WABinary_1.isJidNewsletter)(jid) });
|
|
996
968
|
mediaHandle = up.handle;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { SocketConfig, WAMediaUpload, NewsletterMetadata, NewsletterReactionMode, NewsletterViewRole, NewsletterFetchedUpdate } from '../Types';
|
|
2
|
+
import { BinaryNode } from '../WABinary';
|
|
3
|
+
export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
4
|
+
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
5
|
+
duration: string;
|
|
6
|
+
}>;
|
|
7
|
+
newsletterReactionMode: (jid: string, mode: NewsletterReactionMode) => Promise<void>;
|
|
8
|
+
newsletterUpdateDescription: (jid: string, description?: string) => Promise<void>;
|
|
9
|
+
newsletterUpdateName: (jid: string, name: string) => Promise<void>;
|
|
10
|
+
newsletterUpdatePicture: (jid: string, content: WAMediaUpload) => Promise<void>;
|
|
11
|
+
newsletterRemovePicture: (jid: string) => Promise<void>;
|
|
12
|
+
newsletterUnfollow: (jid: string) => Promise<void>;
|
|
13
|
+
newsletterFollow: (jid: string) => Promise<void>;
|
|
14
|
+
newsletterUnmute: (jid: string) => Promise<void>;
|
|
15
|
+
newsletterMute: (jid: string) => Promise<void>;
|
|
16
|
+
newsletterCreate: (name: string, description?: string, picture?: WAMediaUpload) => Promise<NewsletterMetadata>;
|
|
17
|
+
newsletterMetadata: (type: "invite" | "jid", key: string, role?: NewsletterViewRole) => Promise<NewsletterMetadata>;
|
|
18
|
+
newsletterAdminCount: (jid: string) => Promise<number>;
|
|
19
|
+
/**user is Lid, not Jid */
|
|
20
|
+
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
|
21
|
+
/**user is Lid, not Jid */
|
|
22
|
+
newsletterDemote: (jid: string, user: string) => Promise<void>;
|
|
23
|
+
newsletterDelete: (jid: string) => Promise<void>;
|
|
24
|
+
/**if code wasn't passed, the reaction will be removed (if is reacted) */
|
|
25
|
+
newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
|
|
26
|
+
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<NewsletterFetchedUpdate[]>;
|
|
27
|
+
newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<NewsletterFetchedUpdate[]>;
|
|
28
|
+
groupQuery: (jid: string, type: "get" | "set", content: BinaryNode[]) => Promise<any>;
|
|
29
|
+
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
30
|
+
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
31
|
+
groupLeave: (id: string) => Promise<void>;
|
|
32
|
+
groupUpdateSubject: (jid: string, subject: string) => Promise<void>;
|
|
33
|
+
groupRequestParticipantsList: (jid: string) => Promise<{
|
|
34
|
+
[key: string]: string;
|
|
35
|
+
}[]>;
|
|
36
|
+
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "approve" | "reject") => Promise<{
|
|
37
|
+
status: string;
|
|
38
|
+
jid: string;
|
|
39
|
+
}[]>;
|
|
40
|
+
groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
|
|
41
|
+
status: string;
|
|
42
|
+
jid: string;
|
|
43
|
+
content: BinaryNode;
|
|
44
|
+
}[]>;
|
|
45
|
+
groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
|
|
46
|
+
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
47
|
+
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
48
|
+
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
49
|
+
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
50
|
+
groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<any>;
|
|
51
|
+
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
52
|
+
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
53
|
+
groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
|
|
54
|
+
groupMemberAddMode: (jid: string, mode: "admin_add" | "all_member_add") => Promise<void>;
|
|
55
|
+
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
|
|
56
|
+
groupFetchAllParticipating: () => Promise<{
|
|
57
|
+
[_: string]: import("../Types").GroupMetadata;
|
|
58
|
+
}>;
|
|
59
|
+
getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
|
|
60
|
+
processingMutex: {
|
|
61
|
+
mutex<T>(code: () => Promise<T> | T): Promise<T>;
|
|
62
|
+
};
|
|
63
|
+
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
64
|
+
[_: string]: string;
|
|
65
|
+
}>;
|
|
66
|
+
upsertMessage: (msg: import("../Types").WAMessage, type: import("../Types").MessageUpsertType) => Promise<void>;
|
|
67
|
+
appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
|
|
68
|
+
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
|
|
69
|
+
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
|
|
70
|
+
profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
|
|
71
|
+
onWhatsApp: (...jids: string[]) => Promise<{
|
|
72
|
+
jid: string;
|
|
73
|
+
exists: unknown;
|
|
74
|
+
lid: unknown;
|
|
75
|
+
}[] | undefined>;
|
|
76
|
+
fetchBlocklist: () => Promise<string[]>;
|
|
77
|
+
fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
78
|
+
fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
79
|
+
updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>;
|
|
80
|
+
removeProfilePicture: (jid: string) => Promise<void>;
|
|
81
|
+
updateProfileStatus: (status: string) => Promise<void>;
|
|
82
|
+
updateProfileName: (name: string) => Promise<void>;
|
|
83
|
+
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
|
|
84
|
+
updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
|
|
85
|
+
updateMessagesPrivacy: (value: import("../Types").WAPrivacyMessagesValue) => Promise<void>;
|
|
86
|
+
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
87
|
+
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
|
|
88
|
+
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
89
|
+
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
90
|
+
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
91
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
92
|
+
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
93
|
+
getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
|
|
94
|
+
resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
95
|
+
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
96
|
+
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
|
|
97
|
+
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
98
|
+
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
99
|
+
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
100
|
+
removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
101
|
+
star: (jid: string, messages: {
|
|
102
|
+
id: string;
|
|
103
|
+
fromMe?: boolean;
|
|
104
|
+
}[], star: boolean) => Promise<void>;
|
|
105
|
+
executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
|
|
106
|
+
type: "md";
|
|
107
|
+
ws: import("./Client").WebSocketClient;
|
|
108
|
+
ev: import("../Types").BaileysEventEmitter & {
|
|
109
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
110
|
+
buffer(): void;
|
|
111
|
+
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
112
|
+
flush(force?: boolean): boolean;
|
|
113
|
+
isBuffering(): boolean;
|
|
114
|
+
};
|
|
115
|
+
authState: {
|
|
116
|
+
creds: import("../Types").AuthenticationCreds;
|
|
117
|
+
keys: import("../Types").SignalKeyStoreWithTransaction;
|
|
118
|
+
};
|
|
119
|
+
signalRepository: import("../Types").SignalRepository;
|
|
120
|
+
user: import("../Types").Contact | undefined;
|
|
121
|
+
generateMessageTag: () => string;
|
|
122
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
123
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
124
|
+
waitForSocketOpen: () => Promise<void>;
|
|
125
|
+
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
126
|
+
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
127
|
+
logout: (msg?: string) => Promise<void>;
|
|
128
|
+
end: (error: Error | undefined) => void;
|
|
129
|
+
onUnexpectedError: (err: Error | import("@hapi/boom").Boom, msg: string) => void;
|
|
130
|
+
uploadPreKeys: (count?: number) => Promise<void>;
|
|
131
|
+
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
132
|
+
requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
|
|
133
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
134
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
135
|
+
};
|
|
136
|
+
export declare const extractNewsletterMetadata: (node: BinaryNode, isCreate?: boolean) => NewsletterMetadata;
|
package/lib/Socket/newsletter.js
CHANGED
|
@@ -53,7 +53,7 @@ const makeNewsletterSocket = (config) => {
|
|
|
53
53
|
}))
|
|
54
54
|
}
|
|
55
55
|
]
|
|
56
|
-
}));
|
|
56
|
+
}));
|
|
57
57
|
const parseFetchedUpdates = async (node, type) => {
|
|
58
58
|
let child;
|
|
59
59
|
if (type === 'messages')
|
|
@@ -84,6 +84,10 @@ const makeNewsletterSocket = (config) => {
|
|
|
84
84
|
};
|
|
85
85
|
return {
|
|
86
86
|
...sock,
|
|
87
|
+
newsletterFetchAllSubscribe: async () => {
|
|
88
|
+
const list = await executeWMexQuery({}, Types_1.QueryIds.SUBSCRIBED, Types_1.XWAPaths.SUBSCRIBED, query, generateMessageTag);
|
|
89
|
+
return list;
|
|
90
|
+
},
|
|
87
91
|
subscribeNewsletterUpdates: async (jid) => {
|
|
88
92
|
var _a;
|
|
89
93
|
const result = await newsletterQuery(jid, 'set', [{ tag: 'live_updates', attrs: {}, content: [] }]);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
import { SocketConfig } from '../Types';
|
|
3
|
+
import { BinaryNode } from '../WABinary';
|
|
4
|
+
import { WebSocketClient } from './Client';
|
|
5
|
+
/**
|
|
6
|
+
* Connects to WA servers and performs:
|
|
7
|
+
* - simple queries (no retry mechanism, wait for connection establishment)
|
|
8
|
+
* - listen to messages and emit events
|
|
9
|
+
* - query phone connection
|
|
10
|
+
*/
|
|
11
|
+
export declare const makeSocket: (config: SocketConfig) => {
|
|
12
|
+
type: "md";
|
|
13
|
+
ws: WebSocketClient;
|
|
14
|
+
ev: import("../Types").BaileysEventEmitter & {
|
|
15
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
16
|
+
buffer(): void;
|
|
17
|
+
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
18
|
+
flush(force?: boolean): boolean;
|
|
19
|
+
isBuffering(): boolean;
|
|
20
|
+
};
|
|
21
|
+
authState: {
|
|
22
|
+
creds: import("../Types").AuthenticationCreds;
|
|
23
|
+
keys: import("../Types").SignalKeyStoreWithTransaction;
|
|
24
|
+
};
|
|
25
|
+
signalRepository: import("../Types").SignalRepository;
|
|
26
|
+
readonly user: import("../Types").Contact | undefined;
|
|
27
|
+
generateMessageTag: () => string;
|
|
28
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
29
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
30
|
+
waitForSocketOpen: () => Promise<void>;
|
|
31
|
+
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
32
|
+
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
33
|
+
logout: (msg?: string) => Promise<void>;
|
|
34
|
+
end: (error: Error | undefined) => void;
|
|
35
|
+
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
36
|
+
uploadPreKeys: (count?: number) => Promise<void>;
|
|
37
|
+
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
38
|
+
requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
|
|
39
|
+
/** Waits for the connection to WA to reach a state */
|
|
40
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
41
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
42
|
+
};
|
|
43
|
+
export type Socket = ReturnType<typeof makeSocket>;
|
|
@@ -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: string, pairCode: 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,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;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare function makeOrderedDictionary<T>(idGetter: (item: T) => string): {
|
|
2
|
+
array: T[];
|
|
3
|
+
get: (id: string) => T | undefined;
|
|
4
|
+
upsert: (item: T, mode: "append" | "prepend") => void;
|
|
5
|
+
update: (item: T) => boolean;
|
|
6
|
+
remove: (item: T) => boolean;
|
|
7
|
+
updateAssign: (id: string, update: Partial<T>) => boolean;
|
|
8
|
+
clear: () => void;
|
|
9
|
+
filter: (contain: (item: T) => boolean) => void;
|
|
10
|
+
toJSON: () => T[];
|
|
11
|
+
fromJSON: (newItems: T[]) => void;
|
|
12
|
+
};
|
|
13
|
+
export default makeOrderedDictionary;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class ObjectRepository<T extends object> {
|
|
2
|
+
readonly entityMap: Map<string, T>;
|
|
3
|
+
constructor(entities?: Record<string, T>);
|
|
4
|
+
findById(id: string): T | undefined;
|
|
5
|
+
findAll(): T[];
|
|
6
|
+
upsertById(id: string, entity: T): Map<string, T>;
|
|
7
|
+
deleteById(id: string): boolean;
|
|
8
|
+
count(): number;
|
|
9
|
+
toJSON(): T[];
|
|
10
|
+
}
|