angularsockets 1.0.3 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.MD +170 -0
- package/README.md +163 -1813
- package/WAProto/GenerateStatics.sh +4 -0
- package/WAProto/WAProto.proto +4775 -0
- package/WAProto/index.d.ts +4798 -124
- package/WAProto/index.js +14270 -302
- package/WAProto/index.ts.ts +53473 -0
- package/engine-requirements.js +10 -0
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +4 -6
- package/lib/Defaults/index.js +4 -6
- 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/{WASignalGroup/sender_message_key.js → lib/Signal/Group/sender-message-key.js} +6 -16
- package/lib/Signal/libsignal.js +51 -29
- package/lib/Socket/Client/index.d.ts +2 -3
- package/lib/Socket/Client/index.js +2 -3
- package/lib/Socket/Client/{abstract-socket-client.d.ts → types.d.ts} +1 -2
- package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +2 -1
- package/lib/Socket/Client/{web-socket-client.js → websocket.js} +54 -5
- package/lib/Socket/RHandler.d.ts +416 -0
- package/lib/Socket/RHandler.js +530 -0
- package/lib/Socket/business.d.ts +39 -37
- package/lib/Socket/chats.d.ts +36 -23
- package/lib/Socket/chats.js +74 -116
- package/lib/Socket/groups.d.ts +42 -33
- package/lib/Socket/groups.js +26 -9
- package/lib/Socket/index.d.ts +39 -39
- package/lib/Socket/index.js +2 -2
- package/lib/Socket/messages-recv.d.ts +37 -34
- package/lib/Socket/messages-recv.js +111 -29
- package/lib/Socket/messages-send.d.ts +50 -53
- package/lib/Socket/messages-send.js +213 -397
- package/lib/Socket/newsletter.d.ts +25 -21
- package/lib/Socket/newsletter.js +92 -25
- package/lib/Socket/socket.d.ts +10 -11
- package/lib/Socket/socket.js +34 -23
- package/lib/Socket/usync.d.ts +11 -12
- package/lib/Store/index.d.ts +1 -2
- package/lib/Store/index.js +1 -3
- package/lib/Store/make-in-memory-store.d.ts +22 -22
- package/lib/Store/make-in-memory-store.js +21 -13
- package/lib/Store/make-ordered-dictionary.d.ts +1 -1
- package/lib/Types/Auth.d.ts +0 -6
- package/lib/Types/Chat.d.ts +6 -4
- package/lib/Types/Contact.d.ts +5 -1
- package/lib/Types/Events.d.ts +27 -0
- package/lib/Types/GroupMetadata.d.ts +8 -0
- package/lib/Types/Label.d.ts +0 -11
- package/lib/Types/Message.d.ts +59 -90
- package/lib/Types/Message.js +0 -2
- package/lib/Types/Newsletter.d.ts +97 -86
- package/lib/Types/Newsletter.js +38 -32
- package/lib/Types/Socket.d.ts +10 -7
- package/lib/Types/index.d.ts +1 -3
- package/lib/Types/index.js +1 -1
- package/lib/Utils/audioToBuffer.js +29 -0
- package/lib/Utils/auth-utils.d.ts +3 -3
- package/lib/Utils/auth-utils.js +13 -41
- package/lib/Utils/business.d.ts +1 -1
- package/lib/Utils/chat-utils.d.ts +12 -12
- package/lib/Utils/chat-utils.js +4 -19
- package/lib/Utils/crypto.d.ts +15 -15
- package/lib/Utils/crypto.js +6 -12
- package/lib/Utils/decode-wa-message.d.ts +5 -6
- package/lib/Utils/decode-wa-message.js +28 -55
- package/lib/Utils/event-buffer.d.ts +2 -2
- package/lib/Utils/event-buffer.js +2 -1
- package/lib/Utils/generics.d.ts +12 -11
- package/lib/Utils/generics.js +64 -38
- package/lib/Utils/history.d.ts +2 -2
- package/lib/Utils/history.js +1 -1
- package/lib/Utils/index.d.ts +2 -0
- package/lib/Utils/index.js +3 -0
- package/lib/Utils/link-preview.d.ts +2 -2
- package/lib/Utils/link-preview.js +34 -1
- package/lib/Utils/logger.d.ts +10 -1
- package/lib/Utils/lt-hash.d.ts +2 -2
- package/lib/Utils/lt-hash.js +6 -6
- package/lib/Utils/messages-media.d.ts +40 -29
- package/lib/Utils/messages-media.js +276 -110
- package/lib/Utils/messages.d.ts +8 -10
- package/lib/Utils/messages.js +126 -317
- package/lib/Utils/noise-handler.d.ts +10 -11
- package/lib/Utils/noise-handler.js +3 -13
- package/lib/Utils/process-message.d.ts +3 -2
- package/lib/Utils/process-message.js +17 -5
- package/lib/Utils/signal.js +2 -8
- package/lib/Utils/streamToBuffer.js +15 -0
- package/lib/Utils/use-multi-file-auth-state.js +72 -242
- package/lib/Utils/validate-connection.d.ts +2 -3
- package/lib/Utils/validate-connection.js +19 -51
- package/lib/WABinary/constants.d.ts +4 -4
- package/lib/WABinary/constants.js +1276 -13
- package/lib/WABinary/decode.d.ts +2 -2
- package/lib/WABinary/decode.js +3 -2
- package/lib/WABinary/encode.js +5 -7
- package/lib/WABinary/generic-utils.d.ts +2 -2
- package/lib/WABinary/jid-utils.d.ts +9 -4
- package/lib/WABinary/jid-utils.js +26 -5
- package/lib/WABinary/jid-utils.js.bak +83 -0
- package/lib/WAM/encode.d.ts +1 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +3 -3
- package/lib/WAUSync/USyncUser.d.ts +2 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +48 -4
- package/lib/index.js.bak +56 -0
- package/package.json +43 -35
- package/WASignalGroup/GroupProtocol.js +0 -1697
- package/WASignalGroup/ciphertext_message.js +0 -16
- package/WASignalGroup/group_cipher.js +0 -120
- package/WASignalGroup/group_session_builder.js +0 -46
- package/WASignalGroup/index.js +0 -5
- package/WASignalGroup/keyhelper.js +0 -21
- package/WASignalGroup/protobufs.js +0 -3
- package/WASignalGroup/queue_job.js +0 -69
- package/WASignalGroup/sender_chain_key.js +0 -50
- package/WASignalGroup/sender_key_distribution_message.js +0 -78
- package/WASignalGroup/sender_key_message.js +0 -92
- package/WASignalGroup/sender_key_name.js +0 -70
- package/WASignalGroup/sender_key_record.js +0 -56
- package/WASignalGroup/sender_key_state.js +0 -129
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/registration.d.ts +0 -264
- package/lib/Socket/registration.js +0 -166
- package/lib/Store/make-cache-manager-store.d.ts +0 -14
- package/lib/Store/make-cache-manager-store.js +0 -83
- package/lib/Utils/use-single-file-auth-state.d.ts +0 -12
- package/lib/Utils/use-single-file-auth-state.js +0 -75
- /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SocketConfig, WAMediaUpload, NewsletterMetadata, NewsletterReactionMode, NewsletterViewRole, NewsletterFetchedUpdate } from '../Types';
|
|
2
2
|
import { BinaryNode } from '../WABinary';
|
|
3
3
|
export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
4
4
|
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
@@ -13,8 +13,7 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
|
13
13
|
newsletterFollow: (jid: string) => Promise<void>;
|
|
14
14
|
newsletterUnmute: (jid: string) => Promise<void>;
|
|
15
15
|
newsletterMute: (jid: string) => Promise<void>;
|
|
16
|
-
|
|
17
|
-
newsletterCreate: (name: string, description: string) => Promise<NewsletterMetadata>;
|
|
16
|
+
newsletterCreate: (name: string, description?: string, picture?: WAMediaUpload) => Promise<NewsletterMetadata>;
|
|
18
17
|
newsletterMetadata: (type: "invite" | "jid", key: string, role?: NewsletterViewRole) => Promise<NewsletterMetadata>;
|
|
19
18
|
newsletterAdminCount: (jid: string) => Promise<number>;
|
|
20
19
|
/**user is Lid, not Jid */
|
|
@@ -23,9 +22,10 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
|
23
22
|
newsletterDemote: (jid: string, user: string) => Promise<void>;
|
|
24
23
|
newsletterDelete: (jid: string) => Promise<void>;
|
|
25
24
|
/**if code wasn't passed, the reaction will be removed (if is reacted) */
|
|
26
|
-
newsletterReactMessage: (jid: string,
|
|
25
|
+
newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
|
|
27
26
|
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<NewsletterFetchedUpdate[]>;
|
|
28
27
|
newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<NewsletterFetchedUpdate[]>;
|
|
28
|
+
groupQuery: (jid: string, type: "get" | "set", content: BinaryNode[]) => Promise<any>;
|
|
29
29
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
30
30
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
|
31
31
|
groupLeave: (id: string) => Promise<void>;
|
|
@@ -46,7 +46,8 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
|
46
46
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
47
47
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
48
48
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
49
|
-
|
|
49
|
+
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
50
|
+
groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<any>;
|
|
50
51
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
51
52
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
52
53
|
groupSettingUpdate: (jid: string, setting: "announcement" | "not_announcement" | "locked" | "unlocked") => Promise<void>;
|
|
@@ -55,40 +56,42 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
|
55
56
|
groupFetchAllParticipating: () => Promise<{
|
|
56
57
|
[_: string]: import("../Types").GroupMetadata;
|
|
57
58
|
}>;
|
|
59
|
+
getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
|
|
58
60
|
processingMutex: {
|
|
59
61
|
mutex<T>(code: () => Promise<T> | T): Promise<T>;
|
|
60
62
|
};
|
|
61
63
|
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
62
64
|
[_: string]: string;
|
|
63
65
|
}>;
|
|
64
|
-
upsertMessage: (msg: import("../Types").
|
|
66
|
+
upsertMessage: (msg: import("../Types").WAMessage, type: import("../Types").MessageUpsertType) => Promise<void>;
|
|
65
67
|
appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
|
|
66
68
|
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
|
|
67
69
|
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
|
|
68
70
|
profilePictureUrl: (jid: string, type?: "preview" | "image", timeoutMs?: number) => Promise<string | undefined>;
|
|
69
71
|
onWhatsApp: (...jids: string[]) => Promise<{
|
|
70
|
-
exists: boolean;
|
|
71
72
|
jid: string;
|
|
72
|
-
|
|
73
|
+
exists: unknown;
|
|
74
|
+
lid: unknown;
|
|
75
|
+
}[] | undefined>;
|
|
73
76
|
fetchBlocklist: () => Promise<string[]>;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
setAt: Date;
|
|
77
|
-
} | undefined>;
|
|
77
|
+
fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
78
|
+
fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
|
|
78
79
|
updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>;
|
|
79
80
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
80
81
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
81
82
|
updateProfileName: (name: string) => Promise<void>;
|
|
82
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>;
|
|
83
86
|
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
84
87
|
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
|
|
85
88
|
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
86
89
|
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
87
90
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
88
|
-
updateGroupsAddPrivacy: (value: import("../Types").
|
|
91
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
89
92
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
90
93
|
getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
|
|
91
|
-
resyncAppState: (collections: readonly ("
|
|
94
|
+
resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
92
95
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
93
96
|
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
|
|
94
97
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
@@ -99,8 +102,9 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
|
99
102
|
id: string;
|
|
100
103
|
fromMe?: boolean;
|
|
101
104
|
}[], star: boolean) => Promise<void>;
|
|
105
|
+
executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
|
|
102
106
|
type: "md";
|
|
103
|
-
ws:
|
|
107
|
+
ws: import("./Client").WebSocketClient;
|
|
104
108
|
ev: import("../Types").BaileysEventEmitter & {
|
|
105
109
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
106
110
|
buffer(): void;
|
|
@@ -115,18 +119,18 @@ export declare const makeNewsletterSocket: (config: SocketConfig) => {
|
|
|
115
119
|
signalRepository: import("../Types").SignalRepository;
|
|
116
120
|
user: import("../Types").Contact | undefined;
|
|
117
121
|
generateMessageTag: () => string;
|
|
118
|
-
query: (node: BinaryNode, timeoutMs?: number) => Promise<
|
|
119
|
-
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<
|
|
122
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
123
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
120
124
|
waitForSocketOpen: () => Promise<void>;
|
|
121
125
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
122
126
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
123
127
|
logout: (msg?: string) => Promise<void>;
|
|
124
128
|
end: (error: Error | undefined) => void;
|
|
125
|
-
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
129
|
+
onUnexpectedError: (err: Error | import("@hapi/boom").Boom, msg: string) => void;
|
|
126
130
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
127
131
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
128
|
-
requestPairingCode: (phoneNumber:
|
|
129
|
-
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined
|
|
130
|
-
sendWAMBuffer: (wamBuffer: Buffer) => Promise<
|
|
132
|
+
requestPairingCode: (phoneNumber: any, pairKey?: string) => Promise<string>;
|
|
133
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
134
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
131
135
|
};
|
|
132
136
|
export declare const extractNewsletterMetadata: (node: BinaryNode, isCreate?: boolean) => NewsletterMetadata;
|
package/lib/Socket/newsletter.js
CHANGED
|
@@ -5,6 +5,64 @@ const Types_1 = require("../Types");
|
|
|
5
5
|
const Utils_1 = require("../Utils");
|
|
6
6
|
const WABinary_1 = require("../WABinary");
|
|
7
7
|
const groups_1 = require("./groups");
|
|
8
|
+
|
|
9
|
+
const { Boom } = require('@hapi/boom');
|
|
10
|
+
|
|
11
|
+
const wMexQuery = (
|
|
12
|
+
variables,
|
|
13
|
+
queryId,
|
|
14
|
+
query,
|
|
15
|
+
generateMessageTag
|
|
16
|
+
) => {
|
|
17
|
+
return query({
|
|
18
|
+
tag: 'iq',
|
|
19
|
+
attrs: {
|
|
20
|
+
id: generateMessageTag(),
|
|
21
|
+
type: 'get',
|
|
22
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
23
|
+
xmlns: 'w:mex'
|
|
24
|
+
},
|
|
25
|
+
content: [
|
|
26
|
+
{
|
|
27
|
+
tag: 'query',
|
|
28
|
+
attrs: { query_id: queryId },
|
|
29
|
+
content: Buffer.from(JSON.stringify({ variables }), 'utf-8')
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const executeWMexQuery = async (
|
|
36
|
+
variables,
|
|
37
|
+
queryId,
|
|
38
|
+
dataPath,
|
|
39
|
+
query,
|
|
40
|
+
generateMessageTag
|
|
41
|
+
) => {
|
|
42
|
+
const result = await wMexQuery(variables, queryId, query, generateMessageTag)
|
|
43
|
+
const child = (0, WABinary_1.getBinaryNodeChild)(result, 'result')
|
|
44
|
+
if (child?.content) {
|
|
45
|
+
const data = JSON.parse(child.content.toString())
|
|
46
|
+
|
|
47
|
+
if (data.errors && data.errors.length > 0) {
|
|
48
|
+
const errorMessages = data.errors.map((err) => err.message || 'Unknown error').join(', ')
|
|
49
|
+
const firstError = data.errors[0]
|
|
50
|
+
const errorCode = firstError.extensions?.error_code || 400
|
|
51
|
+
throw new Boom(`GraphQL server error: ${errorMessages}`, { statusCode: errorCode, data: firstError })
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const response = dataPath ? data?.data?.[dataPath] : data?.data
|
|
55
|
+
if (typeof response !== 'undefined') {
|
|
56
|
+
return response
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const action = (dataPath || '').startsWith('xwa2_')
|
|
61
|
+
? dataPath.substring(5).replace(/_/g, ' ')
|
|
62
|
+
: dataPath?.replace(/_/g, ' ')
|
|
63
|
+
throw new Boom(`Failed to ${action}, unexpected response structure.`, { statusCode: 400, data: result })
|
|
64
|
+
}
|
|
65
|
+
|
|
8
66
|
const makeNewsletterSocket = (config) => {
|
|
9
67
|
const sock = (0, groups_1.makeGroupsSocket)(config);
|
|
10
68
|
const { authState, signalRepository, query, generateMessageTag } = sock;
|
|
@@ -71,6 +129,16 @@ const makeNewsletterSocket = (config) => {
|
|
|
71
129
|
};
|
|
72
130
|
return {
|
|
73
131
|
...sock,
|
|
132
|
+
newsletterFetchAllSubscribe: async () => {
|
|
133
|
+
const list = await executeWMexQuery(
|
|
134
|
+
{},
|
|
135
|
+
'6388546374527196',
|
|
136
|
+
'xwa2_newsletter_subscribed',
|
|
137
|
+
query,
|
|
138
|
+
generateMessageTag
|
|
139
|
+
);
|
|
140
|
+
return list;
|
|
141
|
+
},
|
|
74
142
|
subscribeNewsletterUpdates: async (jid) => {
|
|
75
143
|
var _a;
|
|
76
144
|
const result = await newsletterQuery(jid, 'set', [{ tag: 'live_updates', attrs: {}, content: [] }]);
|
|
@@ -115,9 +183,9 @@ const makeNewsletterSocket = (config) => {
|
|
|
115
183
|
await newsletterWMexQuery(jid, Types_1.QueryIds.MUTE);
|
|
116
184
|
},
|
|
117
185
|
newsletterAction: async (jid, type) => {
|
|
118
|
-
await newsletterWMexQuery(jid,
|
|
186
|
+
await newsletterWMexQuery(jid, type.toUpperCase());
|
|
119
187
|
},
|
|
120
|
-
newsletterCreate: async (name, description) => {
|
|
188
|
+
newsletterCreate: async (name, description, reaction_codes) => {
|
|
121
189
|
//TODO: Implement TOS system wide for Meta AI, communities, and here etc.
|
|
122
190
|
/**tos query */
|
|
123
191
|
await query({
|
|
@@ -140,7 +208,7 @@ const makeNewsletterSocket = (config) => {
|
|
|
140
208
|
]
|
|
141
209
|
});
|
|
142
210
|
const result = await newsletterWMexQuery(undefined, Types_1.QueryIds.CREATE, {
|
|
143
|
-
input: { name, description, settings:
|
|
211
|
+
input: { name, description, settings: { 'reaction_codes': { value: reaction_codes.toUpperCase() } } }
|
|
144
212
|
});
|
|
145
213
|
return (0, exports.extractNewsletterMetadata)(result, true);
|
|
146
214
|
},
|
|
@@ -182,7 +250,7 @@ const makeNewsletterSocket = (config) => {
|
|
|
182
250
|
newsletterReactMessage: async (jid, serverId, code) => {
|
|
183
251
|
await query({
|
|
184
252
|
tag: 'message',
|
|
185
|
-
attrs: { to: jid, ...(!code ? { edit: '7' } : {}), type: 'reaction', 'server_id': serverId, id:
|
|
253
|
+
attrs: { to: jid, ...(!code ? { edit: '7' } : {}), type: 'reaction', 'server_id': serverId, id: (0, Utils_1.generateMessageID)() },
|
|
186
254
|
content: [{
|
|
187
255
|
tag: 'reaction',
|
|
188
256
|
attrs: code ? { code } : {}
|
|
@@ -211,26 +279,25 @@ const makeNewsletterSocket = (config) => {
|
|
|
211
279
|
};
|
|
212
280
|
exports.makeNewsletterSocket = makeNewsletterSocket;
|
|
213
281
|
const extractNewsletterMetadata = (node, isCreate) => {
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
|
|
282
|
+
const result = WABinary_1.getBinaryNodeChild(node, 'result')?.content?.toString()
|
|
283
|
+
const metadataPath = JSON.parse(result).data[isCreate ? Types_1.XWAPaths.CREATE : Types_1.XWAPaths.NEWSLETTER]
|
|
284
|
+
|
|
217
285
|
const metadata = {
|
|
218
|
-
id: metadataPath
|
|
219
|
-
state: metadataPath
|
|
220
|
-
|
|
221
|
-
name: metadataPath
|
|
222
|
-
nameTime: +metadataPath
|
|
223
|
-
description: metadataPath
|
|
224
|
-
descriptionTime: +metadataPath
|
|
225
|
-
invite: metadataPath
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
};
|
|
286
|
+
id: metadataPath?.id,
|
|
287
|
+
state: metadataPath?.state?.type,
|
|
288
|
+
creation_time: +metadataPath?.thread_metadata?.creation_time,
|
|
289
|
+
name: metadataPath?.thread_metadata?.name?.text,
|
|
290
|
+
nameTime: +metadataPath?.thread_metadata?.name?.update_time,
|
|
291
|
+
description: metadataPath?.thread_metadata?.description?.text,
|
|
292
|
+
descriptionTime: +metadataPath?.thread_metadata?.description?.update_time,
|
|
293
|
+
invite: metadataPath?.thread_metadata?.invite,
|
|
294
|
+
picture: Utils_1.getUrlFromDirectPath(metadataPath?.thread_metadata?.picture?.direct_path || ''),
|
|
295
|
+
preview: Utils_1.getUrlFromDirectPath(metadataPath?.thread_metadata?.preview?.direct_path || ''),
|
|
296
|
+
reaction_codes: metadataPath?.thread_metadata?.settings?.reaction_codes?.value,
|
|
297
|
+
subscribers: +metadataPath?.thread_metadata?.subscribers_count,
|
|
298
|
+
verification: metadataPath?.thread_metadata?.verification,
|
|
299
|
+
viewer_metadata: metadataPath?.viewer_metadata
|
|
300
|
+
}
|
|
301
|
+
return metadata
|
|
302
|
+
}
|
|
236
303
|
exports.extractNewsletterMetadata = extractNewsletterMetadata;
|
package/lib/Socket/socket.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import { Boom } from '@hapi/boom';
|
|
4
2
|
import { SocketConfig } from '../Types';
|
|
5
3
|
import { BinaryNode } from '../WABinary';
|
|
4
|
+
import { WebSocketClient } from './Client';
|
|
6
5
|
/**
|
|
7
6
|
* Connects to WA servers and performs:
|
|
8
7
|
* - simple queries (no retry mechanism, wait for connection establishment)
|
|
@@ -11,12 +10,12 @@ import { BinaryNode } from '../WABinary';
|
|
|
11
10
|
*/
|
|
12
11
|
export declare const makeSocket: (config: SocketConfig) => {
|
|
13
12
|
type: "md";
|
|
14
|
-
ws:
|
|
13
|
+
ws: WebSocketClient;
|
|
15
14
|
ev: import("../Types").BaileysEventEmitter & {
|
|
16
|
-
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
|
15
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
17
16
|
buffer(): void;
|
|
18
|
-
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T
|
|
19
|
-
flush(force?: boolean
|
|
17
|
+
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
18
|
+
flush(force?: boolean): boolean;
|
|
20
19
|
isBuffering(): boolean;
|
|
21
20
|
};
|
|
22
21
|
authState: {
|
|
@@ -26,8 +25,8 @@ export declare const makeSocket: (config: SocketConfig) => {
|
|
|
26
25
|
signalRepository: import("../Types").SignalRepository;
|
|
27
26
|
readonly user: import("../Types").Contact | undefined;
|
|
28
27
|
generateMessageTag: () => string;
|
|
29
|
-
query: (node: BinaryNode, timeoutMs?: number) => Promise<
|
|
30
|
-
waitForMessage: <
|
|
28
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
29
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
31
30
|
waitForSocketOpen: () => Promise<void>;
|
|
32
31
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
33
32
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
@@ -36,9 +35,9 @@ export declare const makeSocket: (config: SocketConfig) => {
|
|
|
36
35
|
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
37
36
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
38
37
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
39
|
-
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
38
|
+
requestPairingCode: (phoneNumber: any, pairKey?: string) => Promise<string>;
|
|
40
39
|
/** Waits for the connection to WA to reach a state */
|
|
41
|
-
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined
|
|
42
|
-
sendWAMBuffer: (wamBuffer: Buffer) => Promise<
|
|
40
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
41
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
43
42
|
};
|
|
44
43
|
export type Socket = ReturnType<typeof makeSocket>;
|
package/lib/Socket/socket.js
CHANGED
|
@@ -20,21 +20,14 @@ const Client_1 = require("./Client");
|
|
|
20
20
|
const makeSocket = (config) => {
|
|
21
21
|
var _a, _b;
|
|
22
22
|
const { waWebSocketUrl, connectTimeoutMs, logger, keepAliveIntervalMs, browser, auth: authState, printQRInTerminal, defaultQueryTimeoutMs, transactionOpts, qrTimeout, makeSignalRepository, } = config;
|
|
23
|
-
|
|
24
|
-
config.mobile = config.mobile || url.protocol === 'tcp:';
|
|
25
|
-
if (config.mobile && url.protocol !== 'tcp:') {
|
|
26
|
-
url = new url_1.URL(`tcp://${Defaults_1.MOBILE_ENDPOINT}:${Defaults_1.MOBILE_PORT}`);
|
|
27
|
-
}
|
|
28
|
-
if (!config.mobile && url.protocol === 'wss' && ((_a = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _a === void 0 ? void 0 : _a.routingInfo)) {
|
|
29
|
-
url.searchParams.append('ED', authState.creds.routingInfo.toString('base64url'));
|
|
30
|
-
}
|
|
23
|
+
const url = typeof waWebSocketUrl === 'string' ? new url_1.URL(waWebSocketUrl) : waWebSocketUrl;
|
|
31
24
|
if (config.mobile || url.protocol === 'tcp:') {
|
|
32
25
|
throw new boom_1.Boom('Mobile API is not supported anymore', { statusCode: Types_1.DisconnectReason.loggedOut });
|
|
33
26
|
}
|
|
34
27
|
if (url.protocol === 'wss' && ((_a = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _a === void 0 ? void 0 : _a.routingInfo)) {
|
|
35
28
|
url.searchParams.append('ED', authState.creds.routingInfo.toString('base64url'));
|
|
36
29
|
}
|
|
37
|
-
const ws =
|
|
30
|
+
const ws = new Client_1.WebSocketClient(url, config);
|
|
38
31
|
ws.connect();
|
|
39
32
|
const ev = (0, Utils_1.makeEventBuffer)(logger);
|
|
40
33
|
/** ephemeral key pair used to encrypt/decrypt communication. Unique for each connection */
|
|
@@ -42,8 +35,7 @@ const makeSocket = (config) => {
|
|
|
42
35
|
/** WA noise protocol wrapper */
|
|
43
36
|
const noise = (0, Utils_1.makeNoiseHandler)({
|
|
44
37
|
keyPair: ephemeralKeyPair,
|
|
45
|
-
NOISE_HEADER:
|
|
46
|
-
mobile: config.mobile,
|
|
38
|
+
NOISE_HEADER: Defaults_1.NOISE_WA_HEADER,
|
|
47
39
|
logger,
|
|
48
40
|
routingInfo: (_b = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _b === void 0 ? void 0 : _b.routingInfo
|
|
49
41
|
});
|
|
@@ -86,6 +78,25 @@ const makeSocket = (config) => {
|
|
|
86
78
|
/** log & process any unexpected errors */
|
|
87
79
|
const onUnexpectedError = (err, msg) => {
|
|
88
80
|
logger.error({ err }, `unexpected error in '${msg}'`);
|
|
81
|
+
const message = (err && ((err.stack || err.message) || String(err))).toLowerCase();
|
|
82
|
+
// auto recover from cryptographic desyncs by re-uploading prekeys
|
|
83
|
+
if (message.includes('bad mac') || (message.includes('mac') && message.includes('invalid'))) {
|
|
84
|
+
try {
|
|
85
|
+
uploadPreKeysToServerIfRequired(true)
|
|
86
|
+
.catch(e => logger.warn({ e }, 'failed to re-upload prekeys after bad mac'));
|
|
87
|
+
}
|
|
88
|
+
catch (_e) {
|
|
89
|
+
// ignore
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// gently back off when encountering rate limits (429)
|
|
93
|
+
if (message.includes('429') || message.includes('rate limit')) {
|
|
94
|
+
const wait = Math.min(30000, (config.backoffDelayMs || 5000));
|
|
95
|
+
logger.info({ wait }, 'backing off due to rate limit');
|
|
96
|
+
setTimeout(() => {
|
|
97
|
+
// intentionally empty; wait to delay further sends
|
|
98
|
+
}, wait);
|
|
99
|
+
}
|
|
89
100
|
};
|
|
90
101
|
/** await the next incoming message */
|
|
91
102
|
const awaitNextMessage = async (sendMsg) => {
|
|
@@ -122,7 +133,7 @@ const makeSocket = (config) => {
|
|
|
122
133
|
let onRecv;
|
|
123
134
|
let onErr;
|
|
124
135
|
try {
|
|
125
|
-
|
|
136
|
+
const result = await (0, Utils_1.promiseTimeout)(timeoutMs, (resolve, reject) => {
|
|
126
137
|
onRecv = resolve;
|
|
127
138
|
onErr = err => {
|
|
128
139
|
reject(err || new boom_1.Boom('Connection Closed', { statusCode: Types_1.DisconnectReason.connectionClosed }));
|
|
@@ -131,6 +142,7 @@ const makeSocket = (config) => {
|
|
|
131
142
|
ws.on('close', onErr); // if the socket closes, you'll never receive the message
|
|
132
143
|
ws.off('error', onErr);
|
|
133
144
|
});
|
|
145
|
+
return result;
|
|
134
146
|
}
|
|
135
147
|
finally {
|
|
136
148
|
ws.off(`TAG:${msgId}`, onRecv);
|
|
@@ -144,9 +156,10 @@ const makeSocket = (config) => {
|
|
|
144
156
|
node.attrs.id = generateMessageTag();
|
|
145
157
|
}
|
|
146
158
|
const msgId = node.attrs.id;
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
159
|
+
const [result] = await Promise.all([
|
|
160
|
+
waitForMessage(msgId, timeoutMs),
|
|
161
|
+
sendNode(node)
|
|
162
|
+
]);
|
|
150
163
|
if ('tag' in result) {
|
|
151
164
|
(0, WABinary_1.assertNodeErrorFree)(result);
|
|
152
165
|
}
|
|
@@ -165,10 +178,7 @@ const makeSocket = (config) => {
|
|
|
165
178
|
logger.trace({ handshake }, 'handshake recv from WA');
|
|
166
179
|
const keyEnc = await noise.processHandshake(handshake, creds.noiseKey);
|
|
167
180
|
let node;
|
|
168
|
-
if (
|
|
169
|
-
node = (0, Utils_1.generateMobileNode)(config);
|
|
170
|
-
}
|
|
171
|
-
else if (!creds.me) {
|
|
181
|
+
if (!creds.me) {
|
|
172
182
|
node = (0, Utils_1.generateRegistrationNode)(creds, config);
|
|
173
183
|
logger.info({ node }, 'not logged in, attempting registration...');
|
|
174
184
|
}
|
|
@@ -183,7 +193,7 @@ const makeSocket = (config) => {
|
|
|
183
193
|
payload: payloadEnc,
|
|
184
194
|
},
|
|
185
195
|
}).finish());
|
|
186
|
-
|
|
196
|
+
noise.finishInit();
|
|
187
197
|
startKeepAliveRequest();
|
|
188
198
|
};
|
|
189
199
|
const getAvailablePreKeysOnServer = async () => {
|
|
@@ -371,10 +381,11 @@ const makeSocket = (config) => {
|
|
|
371
381
|
}
|
|
372
382
|
end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }));
|
|
373
383
|
};
|
|
374
|
-
const requestPairingCode = async (phoneNumber, pairKey = "
|
|
384
|
+
const requestPairingCode = async (phoneNumber, pairKey = "MRFRANKX") => {
|
|
375
385
|
if (pairKey) {
|
|
376
|
-
|
|
377
|
-
}
|
|
386
|
+
authState.creds.pairingCode = pairKey.toUpperCase();
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
378
389
|
authState.creds.pairingCode = (0, Utils_1.bytesToCrockford)((0, crypto_1.randomBytes)(5));
|
|
379
390
|
}
|
|
380
391
|
authState.creds.me = {
|
package/lib/Socket/usync.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Boom } from '@hapi/boom';
|
|
3
2
|
import { SocketConfig } from '../Types';
|
|
4
3
|
import { BinaryNode } from '../WABinary';
|
|
@@ -6,12 +5,12 @@ import { USyncQuery } from '../WAUSync';
|
|
|
6
5
|
export declare const makeUSyncSocket: (config: SocketConfig) => {
|
|
7
6
|
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
|
|
8
7
|
type: "md";
|
|
9
|
-
ws:
|
|
8
|
+
ws: import("./Client").WebSocketClient;
|
|
10
9
|
ev: import("../Types").BaileysEventEmitter & {
|
|
11
|
-
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
|
10
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (() => void);
|
|
12
11
|
buffer(): void;
|
|
13
|
-
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T
|
|
14
|
-
flush(force?: boolean
|
|
12
|
+
createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);
|
|
13
|
+
flush(force?: boolean): boolean;
|
|
15
14
|
isBuffering(): boolean;
|
|
16
15
|
};
|
|
17
16
|
authState: {
|
|
@@ -21,17 +20,17 @@ export declare const makeUSyncSocket: (config: SocketConfig) => {
|
|
|
21
20
|
signalRepository: import("../Types").SignalRepository;
|
|
22
21
|
user: import("../Types").Contact | undefined;
|
|
23
22
|
generateMessageTag: () => string;
|
|
24
|
-
query: (node: BinaryNode, timeoutMs?: number
|
|
25
|
-
waitForMessage: <
|
|
23
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
|
24
|
+
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
26
25
|
waitForSocketOpen: () => Promise<void>;
|
|
27
26
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
28
27
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
|
29
|
-
logout: (msg?: string
|
|
28
|
+
logout: (msg?: string) => Promise<void>;
|
|
30
29
|
end: (error: Error | undefined) => void;
|
|
31
|
-
onUnexpectedError: (err: Error | Boom
|
|
30
|
+
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
32
31
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
33
32
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
34
|
-
requestPairingCode: (phoneNumber:
|
|
35
|
-
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined
|
|
36
|
-
sendWAMBuffer: (wamBuffer: Buffer) => Promise<
|
|
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>;
|
|
37
36
|
};
|
package/lib/Store/index.d.ts
CHANGED
package/lib/Store/index.js
CHANGED
|
@@ -3,8 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
const make_cache_manager_store_1 = __importDefault(require("./make-cache-manager-store"));
|
|
8
|
-
exports.makeCacheManagerAuthState = make_cache_manager_store_1.default;
|
|
6
|
+
exports.makeInMemoryStore = void 0;
|
|
9
7
|
const make_in_memory_store_1 = __importDefault(require("./make-in-memory-store"));
|
|
10
8
|
exports.makeInMemoryStore = make_in_memory_store_1.default;
|
|
@@ -27,16 +27,16 @@ declare const _default: (config: BaileysInMemoryStoreConfig) => {
|
|
|
27
27
|
};
|
|
28
28
|
messages: {
|
|
29
29
|
[_: string]: {
|
|
30
|
-
array:
|
|
31
|
-
get: (id: string) =>
|
|
32
|
-
upsert: (item:
|
|
33
|
-
update: (item:
|
|
34
|
-
remove: (item:
|
|
35
|
-
updateAssign: (id: string, update: Partial<
|
|
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
36
|
clear: () => void;
|
|
37
|
-
filter: (contain: (item:
|
|
38
|
-
toJSON: () =>
|
|
39
|
-
fromJSON: (newItems:
|
|
37
|
+
filter: (contain: (item: WAMessage) => boolean) => void;
|
|
38
|
+
toJSON: () => WAMessage[];
|
|
39
|
+
fromJSON: (newItems: WAMessage[]) => void;
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
42
|
groupMetadata: {
|
|
@@ -52,7 +52,7 @@ declare const _default: (config: BaileysInMemoryStoreConfig) => {
|
|
|
52
52
|
labelAssociations: KeyedDB<LabelAssociation, string>;
|
|
53
53
|
bind: (ev: BaileysEventEmitter) => void;
|
|
54
54
|
/** loads messages from the store, if not found -- uses the legacy connection */
|
|
55
|
-
loadMessages: (jid: string, count: number, cursor: WAMessageCursor) => Promise<
|
|
55
|
+
loadMessages: (jid: string, count: number, cursor: WAMessageCursor) => Promise<WAMessage[]>;
|
|
56
56
|
/**
|
|
57
57
|
* Get all available labels for profile
|
|
58
58
|
*
|
|
@@ -72,8 +72,8 @@ declare const _default: (config: BaileysInMemoryStoreConfig) => {
|
|
|
72
72
|
* @returns Label IDs
|
|
73
73
|
**/
|
|
74
74
|
getMessageLabels: (messageId: string) => string[];
|
|
75
|
-
loadMessage: (jid: string, id: string) => Promise<
|
|
76
|
-
mostRecentMessage: (jid: string) => Promise<
|
|
75
|
+
loadMessage: (jid: string, id: string) => Promise<WAMessage | undefined>;
|
|
76
|
+
mostRecentMessage: (jid: string) => Promise<WAMessage>;
|
|
77
77
|
fetchImageUrl: (jid: string, sock: WASocket | undefined) => Promise<string | null | undefined>;
|
|
78
78
|
fetchGroupMetadata: (jid: string, sock: WASocket | undefined) => Promise<GroupMetadata>;
|
|
79
79
|
fetchMessageReceipts: ({ remoteJid, id }: WAMessageKey) => Promise<proto.IUserReceipt[] | null | undefined>;
|
|
@@ -84,16 +84,16 @@ declare const _default: (config: BaileysInMemoryStoreConfig) => {
|
|
|
84
84
|
};
|
|
85
85
|
messages: {
|
|
86
86
|
[_: string]: {
|
|
87
|
-
array:
|
|
88
|
-
get: (id: string) =>
|
|
89
|
-
upsert: (item:
|
|
90
|
-
update: (item:
|
|
91
|
-
remove: (item:
|
|
92
|
-
updateAssign: (id: string, update: Partial<
|
|
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
93
|
clear: () => void;
|
|
94
|
-
filter: (contain: (item:
|
|
95
|
-
toJSON: () =>
|
|
96
|
-
fromJSON: (newItems:
|
|
94
|
+
filter: (contain: (item: WAMessage) => boolean) => void;
|
|
95
|
+
toJSON: () => WAMessage[];
|
|
96
|
+
fromJSON: (newItems: WAMessage[]) => void;
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
99
|
labels: ObjectRepository<Label>;
|
|
@@ -105,7 +105,7 @@ declare const _default: (config: BaileysInMemoryStoreConfig) => {
|
|
|
105
105
|
[id: string]: Contact;
|
|
106
106
|
};
|
|
107
107
|
messages: {
|
|
108
|
-
[id: string]:
|
|
108
|
+
[id: string]: WAMessage[];
|
|
109
109
|
};
|
|
110
110
|
labels: {
|
|
111
111
|
[labelId: string]: Label;
|