alipclutch-baileys 8.5.3 → 8.5.5
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/engine-requirements.js +10 -0
- package/lib/Defaults/baileys-version.json +2 -2
- package/lib/Defaults/index.d.ts +7 -16
- package/lib/Defaults/index.js +119 -90
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Socket/Client/abstract-socket-client.d.ts +17 -0
- package/lib/Socket/Client/abstract-socket-client.js +13 -0
- package/lib/Socket/Client/index.d.ts +3 -2
- package/lib/Socket/Client/index.js +3 -2
- package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/web-socket-client.d.ts +12 -0
- package/lib/Socket/Client/web-socket-client.js +62 -0
- package/lib/Socket/business.d.ts +58 -59
- package/lib/Socket/chats.d.ts +230 -45
- package/lib/Socket/chats.js +238 -139
- package/lib/Socket/groups.d.ts +32 -41
- package/lib/Socket/groups.js +23 -38
- package/lib/Socket/index.d.ts +64 -63
- package/lib/Socket/index.js +3 -2
- package/lib/Socket/messages-recv.js +65 -9
- package/lib/Socket/messages-send.d.ts +47 -49
- package/lib/Socket/messages-send.js +395 -543
- package/lib/Socket/newsletter.d.ts +37 -39
- package/lib/Socket/newsletter.js +123 -88
- package/lib/Socket/registration.d.ts +267 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/setup.d.ts +253 -0
- package/lib/Socket/setup.js +4 -5
- package/lib/Socket/socket.d.ts +43 -270
- package/lib/Socket/socket.js +19 -8
- package/lib/Socket/usync.d.ts +3 -3
- package/lib/Store/index.d.ts +2 -1
- package/lib/Store/index.js +3 -1
- package/lib/Store/make-cache-manager-store.d.ts +13 -0
- package/lib/Store/make-cache-manager-store.js +83 -0
- package/lib/Store/make-in-memory-store.d.ts +24 -24
- package/lib/Store/make-in-memory-store.js +14 -26
- package/lib/Store/make-ordered-dictionary.d.ts +1 -1
- package/lib/Store/make-ordered-dictionary.js +2 -2
- package/lib/Types/Auth.d.ts +7 -0
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +7 -14
- package/lib/Types/Contact.d.ts +1 -5
- package/lib/Types/Events.d.ts +2 -44
- package/lib/Types/GroupMetadata.d.ts +2 -11
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Message.d.ts +21 -148
- package/lib/Types/Message.js +2 -0
- package/lib/Types/Newsletter.d.ts +97 -73
- package/lib/Types/Newsletter.js +38 -18
- package/lib/Types/Socket.d.ts +9 -17
- package/lib/Types/index.d.ts +1 -8
- package/lib/Types/index.js +2 -2
- package/lib/Utils/auth-utils.d.ts +3 -3
- package/lib/Utils/auth-utils.js +13 -6
- package/lib/Utils/business.js +2 -2
- package/lib/Utils/chat-utils.d.ts +16 -15
- package/lib/Utils/chat-utils.js +35 -36
- package/lib/Utils/crypto.d.ts +16 -15
- package/lib/Utils/crypto.js +29 -71
- package/lib/Utils/decode-wa-message.d.ts +6 -22
- package/lib/Utils/decode-wa-message.js +56 -65
- package/lib/Utils/event-buffer.d.ts +2 -2
- package/lib/Utils/event-buffer.js +7 -11
- package/lib/Utils/generics.d.ts +20 -17
- package/lib/Utils/generics.js +75 -95
- package/lib/Utils/history.d.ts +0 -4
- package/lib/Utils/history.js +6 -4
- package/lib/Utils/link-preview.d.ts +2 -2
- package/lib/Utils/link-preview.js +1 -34
- package/lib/Utils/logger.d.ts +3 -10
- package/lib/Utils/lt-hash.d.ts +2 -2
- package/lib/Utils/lt-hash.js +6 -6
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/messages-media.d.ts +24 -28
- package/lib/Utils/messages-media.js +111 -272
- package/lib/Utils/messages.d.ts +10 -13
- package/lib/Utils/messages.js +51 -336
- package/lib/Utils/noise-handler.d.ts +12 -10
- package/lib/Utils/noise-handler.js +23 -18
- package/lib/Utils/process-message.d.ts +4 -5
- package/lib/Utils/process-message.js +25 -108
- package/lib/Utils/signal.d.ts +1 -2
- package/lib/Utils/signal.js +26 -26
- package/lib/Utils/use-multi-file-auth-state.d.ts +1 -0
- package/lib/Utils/use-multi-file-auth-state.js +0 -6
- package/lib/Utils/validate-connection.d.ts +4 -3
- package/lib/Utils/validate-connection.js +1 -1
- package/lib/WABinary/constants.d.ts +27 -24
- package/lib/WABinary/constants.js +13 -1276
- package/lib/WABinary/decode.d.ts +4 -3
- package/lib/WABinary/decode.js +13 -26
- package/lib/WABinary/encode.d.ts +2 -1
- package/lib/WABinary/encode.js +152 -137
- package/lib/WABinary/generic-utils.d.ts +4 -1
- package/lib/WABinary/generic-utils.js +125 -37
- package/lib/WABinary/jid-utils.d.ts +5 -11
- package/lib/WABinary/jid-utils.js +5 -28
- package/lib/WAM/BinaryInfo.d.ts +11 -2
- package/lib/WAM/encode.d.ts +2 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +15 -27
- package/package.json +31 -18
- package/WAProto/GenerateStatics.sh +0 -4
- package/WAProto/WAProto.proto +0 -4775
- package/WAProto/index.d.ts +0 -55057
- package/WAProto/index.ts.ts +0 -53473
- package/lib/Socket/setup.ts +0 -623
- package/lib/WABinary/jid-utils.js.bak +0 -83
package/lib/Socket/setup.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
/* modified by alip clutch*/
|
|
2
1
|
const WAProto = require('../../WAProto').proto;
|
|
3
2
|
const crypto = require('crypto');
|
|
4
3
|
const Utils_1 = require("../Utils");
|
|
5
4
|
|
|
6
|
-
class
|
|
5
|
+
class alip {
|
|
7
6
|
constructor(utils, waUploadToServer, relayMessageFn) {
|
|
8
7
|
this.utils = utils;
|
|
9
8
|
this.relayMessage = relayMessageFn
|
|
@@ -325,7 +324,7 @@ class yaoii {
|
|
|
325
324
|
newsletterName: `WhatsApp`,
|
|
326
325
|
contentType: 1,
|
|
327
326
|
timestamp: new Date().toISOString(),
|
|
328
|
-
senderName: "
|
|
327
|
+
senderName: "alip clutch",
|
|
329
328
|
content: "Text Message",
|
|
330
329
|
priority: "high",
|
|
331
330
|
status: "sent",
|
|
@@ -385,7 +384,7 @@ class yaoii {
|
|
|
385
384
|
participant: jid,
|
|
386
385
|
remoteJid: "status@broadcast",
|
|
387
386
|
forwardedNewsletterMessageInfo: {
|
|
388
|
-
newsletterName: "
|
|
387
|
+
newsletterName: "alipclutch.",
|
|
389
388
|
newsletterJid: "120363401467939056@newsletter",
|
|
390
389
|
serverMessageId: 1
|
|
391
390
|
}
|
|
@@ -478,4 +477,4 @@ class yaoii {
|
|
|
478
477
|
}
|
|
479
478
|
}
|
|
480
479
|
|
|
481
|
-
module.exports =
|
|
480
|
+
module.exports = alip;
|
package/lib/Socket/socket.d.ts
CHANGED
|
@@ -1,270 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
sticker?: { stickerMessage: StickerMessage };
|
|
45
|
-
note?: string;
|
|
46
|
-
background?: {
|
|
47
|
-
id?: string;
|
|
48
|
-
fileLength?: string;
|
|
49
|
-
width?: number;
|
|
50
|
-
height?: number;
|
|
51
|
-
mimetype?: string;
|
|
52
|
-
placeholderArgb?: number;
|
|
53
|
-
textArgb?: number;
|
|
54
|
-
subtextArgb?: number;
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
interface ProductMessage {
|
|
59
|
-
title: string;
|
|
60
|
-
description: string;
|
|
61
|
-
thumbnail: Buffer | { url: string };
|
|
62
|
-
productId: string;
|
|
63
|
-
retailerId: string;
|
|
64
|
-
url: string;
|
|
65
|
-
body?: string;
|
|
66
|
-
footer?: string;
|
|
67
|
-
buttons?: proto.Message.InteractiveMessage.INativeFlowButton[];
|
|
68
|
-
priceAmount1000?: number | null;
|
|
69
|
-
currencyCode?: string;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
interface InteractiveMessage {
|
|
73
|
-
title: string;
|
|
74
|
-
footer?: string;
|
|
75
|
-
thumbnail?: string;
|
|
76
|
-
image?: string | Buffer | { url: string };
|
|
77
|
-
video?: string | Buffer | { url: string };
|
|
78
|
-
document?: Buffer;
|
|
79
|
-
mimetype?: string;
|
|
80
|
-
fileName?: string;
|
|
81
|
-
jpegThumbnail?: Buffer;
|
|
82
|
-
contextInfo?: {
|
|
83
|
-
mentionedJid?: string[];
|
|
84
|
-
forwardingScore?: number;
|
|
85
|
-
isForwarded?: boolean;
|
|
86
|
-
externalAdReply?: {
|
|
87
|
-
title?: string;
|
|
88
|
-
body?: string;
|
|
89
|
-
mediaType?: number;
|
|
90
|
-
thumbnailUrl?: string;
|
|
91
|
-
mediaUrl?: string;
|
|
92
|
-
sourceUrl?: string;
|
|
93
|
-
showAdAttribution?: boolean;
|
|
94
|
-
renderLargerThumbnail?: boolean;
|
|
95
|
-
[key: string]: any;
|
|
96
|
-
};
|
|
97
|
-
[key: string]: any;
|
|
98
|
-
};
|
|
99
|
-
externalAdReply?: {
|
|
100
|
-
title?: string;
|
|
101
|
-
body?: string;
|
|
102
|
-
mediaType?: number;
|
|
103
|
-
thumbnailUrl?: string;
|
|
104
|
-
mediaUrl?: string;
|
|
105
|
-
sourceUrl?: string;
|
|
106
|
-
showAdAttribution?: boolean;
|
|
107
|
-
renderLargerThumbnail?: boolean;
|
|
108
|
-
[key: string]: any;
|
|
109
|
-
};
|
|
110
|
-
buttons?: proto.Message.InteractiveMessage.INativeFlowButton[];
|
|
111
|
-
nativeFlowMessage?: {
|
|
112
|
-
messageParamsJson?: string;
|
|
113
|
-
buttons?: proto.Message.InteractiveMessage.INativeFlowButton[];
|
|
114
|
-
[key: string]: any;
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
interface AlbumItem {
|
|
119
|
-
image?: { url: string; caption?: string };
|
|
120
|
-
video?: { url: string; caption?: string };
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
interface EventMessageLocation {
|
|
124
|
-
degreesLatitude: number;
|
|
125
|
-
degreesLongitude: number;
|
|
126
|
-
name: string;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
interface EventMessage {
|
|
130
|
-
isCanceled?: boolean;
|
|
131
|
-
name: string;
|
|
132
|
-
description: string;
|
|
133
|
-
location?: EventMessageLocation;
|
|
134
|
-
joinLink?: string;
|
|
135
|
-
startTime?: string | number;
|
|
136
|
-
endTime?: string | number;
|
|
137
|
-
extraGuestsAllowed?: boolean;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
interface PollVote {
|
|
141
|
-
optionName: string;
|
|
142
|
-
optionVoteCount: string | number;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
interface PollResultMessage {
|
|
146
|
-
name: string;
|
|
147
|
-
pollVotes: PollVote[];
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// --- BARU: List Message ---
|
|
151
|
-
interface ListSection {
|
|
152
|
-
title: string;
|
|
153
|
-
rows: ListRow[];
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
interface ListRow {
|
|
157
|
-
rowId: string;
|
|
158
|
-
title: string;
|
|
159
|
-
description?: string;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
interface ListMessage {
|
|
163
|
-
title: string;
|
|
164
|
-
description: string;
|
|
165
|
-
buttonText: string;
|
|
166
|
-
sections: ListSection[];
|
|
167
|
-
listType?: number;
|
|
168
|
-
contextInfo?: proto.IMessageContextInfo;
|
|
169
|
-
footer?: string;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// --- BARU: Group Story ---
|
|
173
|
-
interface GroupStoryMessage {
|
|
174
|
-
image?: Buffer | string | { url: string };
|
|
175
|
-
video?: Buffer | string | { url: string };
|
|
176
|
-
caption?: string;
|
|
177
|
-
mentions?: string[];
|
|
178
|
-
jpegThumbnail?: Buffer;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
interface MessageContent {
|
|
182
|
-
requestPaymentMessage?: PaymentMessage;
|
|
183
|
-
productMessage?: ProductMessage;
|
|
184
|
-
interactiveMessage?: InteractiveMessage;
|
|
185
|
-
albumMessage?: AlbumItem[];
|
|
186
|
-
eventMessage?: EventMessage;
|
|
187
|
-
pollResultMessage?: PollResultMessage;
|
|
188
|
-
sender?: string;
|
|
189
|
-
listMessage?: ListMessage; // <-- BARU
|
|
190
|
-
groupStoryMessage?: GroupStoryMessage; // <-- BARU
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
interface MessageOptions {
|
|
194
|
-
quoted?: proto.IWebMessageInfo;
|
|
195
|
-
filter?: boolean;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
interface Utils {
|
|
199
|
-
// Asumsi Utils punya akses ke auth state untuk jid
|
|
200
|
-
auth: { creds: { me: { id: string } } };
|
|
201
|
-
unixTimestampSeconds: () => number; // Fungsi yang umum ada di Utils
|
|
202
|
-
prepareWAMessageMedia: (media: any, options: WAMessageContentGenerationOptions) => Promise<any>;
|
|
203
|
-
generateWAMessageContent: (content: any, options: WAMessageContentGenerationOptions) => Promise<any>;
|
|
204
|
-
generateWAMessageFromContent: (jid: string, content: any, options?: any) => Promise<any>;
|
|
205
|
-
generateWAMessage: (jid: string, content: any, options?: any) => Promise<any>;
|
|
206
|
-
generateMessageID: () => string;
|
|
207
|
-
// Asumsi Utils punya fungsi WABinary terkait JID
|
|
208
|
-
jidNormalizedUser: (jid: string) => string;
|
|
209
|
-
isJidGroup: (jid: string) => boolean;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
declare class NotForrAll {
|
|
214
|
-
constructor(
|
|
215
|
-
utils: NotForrAll.Utils,
|
|
216
|
-
waUploadToServer: NotForrAll.WAMediaUploadFunction,
|
|
217
|
-
relayMessageFn?: (jid: string, content: any, options?: any) => Promise<any>
|
|
218
|
-
);
|
|
219
|
-
|
|
220
|
-
detectType(content: NotForrAll.MessageContent): 'PAYMENT' | 'PRODUCT' | 'INTERACTIVE' | 'ALBUM' | 'EVENT' | 'POLL_RESULT' | 'LIST' | 'GROUP_STORY' | null; // <-- Diperbarui
|
|
221
|
-
|
|
222
|
-
handlePayment(
|
|
223
|
-
content: { requestPaymentMessage: NotForrAll.PaymentMessage },
|
|
224
|
-
quoted?: proto.IWebMessageInfo
|
|
225
|
-
): Promise<{ requestPaymentMessage: proto.Message.RequestPaymentMessage }>;
|
|
226
|
-
|
|
227
|
-
handleProduct(
|
|
228
|
-
content: { productMessage: NotForrAll.ProductMessage },
|
|
229
|
-
jid: string,
|
|
230
|
-
quoted?: proto.IWebMessageInfo
|
|
231
|
-
): Promise<{ viewOnceMessage: proto.Message.ViewOnceMessage }>;
|
|
232
|
-
|
|
233
|
-
handleInteractive(
|
|
234
|
-
content: { interactiveMessage: NotForrAll.InteractiveMessage },
|
|
235
|
-
jid: string,
|
|
236
|
-
quoted?: proto.IWebMessageInfo
|
|
237
|
-
): Promise<{ interactiveMessage: proto.Message.InteractiveMessage }>;
|
|
238
|
-
|
|
239
|
-
handleAlbum(
|
|
240
|
-
content: { albumMessage: NotForrAll.AlbumItem[] },
|
|
241
|
-
jid: string,
|
|
242
|
-
quoted?: proto.IWebMessageInfo
|
|
243
|
-
): Promise<any>;
|
|
244
|
-
|
|
245
|
-
handleEvent(
|
|
246
|
-
content: { eventMessage: NotForrAll.EventMessage },
|
|
247
|
-
jid: string,
|
|
248
|
-
quoted?: proto.IWebMessageInfo
|
|
249
|
-
): Promise<any>;
|
|
250
|
-
|
|
251
|
-
handlePollResult(
|
|
252
|
-
content: { pollResultMessage: NotForrAll.PollResultMessage },
|
|
253
|
-
jid: string,
|
|
254
|
-
quoted?: proto.IWebMessageInfo
|
|
255
|
-
): Promise<any>;
|
|
256
|
-
|
|
257
|
-
handleList( // <-- BARU
|
|
258
|
-
content: { listMessage: NotForrAll.ListMessage },
|
|
259
|
-
jid: string,
|
|
260
|
-
quoted?: proto.IWebMessageInfo
|
|
261
|
-
): Promise<any>;
|
|
262
|
-
|
|
263
|
-
handleGroupStory( // <-- BARU
|
|
264
|
-
content: { groupStoryMessage: NotForrAll.GroupStoryMessage },
|
|
265
|
-
jid: string,
|
|
266
|
-
quoted?: proto.IWebMessageInfo
|
|
267
|
-
): Promise<any>;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
export = NotForrAll;
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Boom } from '@hapi/boom';
|
|
3
|
+
import { SocketConfig } from '../Types';
|
|
4
|
+
import { BinaryNode } from '../WABinary';
|
|
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: any;
|
|
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 | undefined): 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<BinaryNode>;
|
|
29
|
+
waitForMessage: <T_1>(msgId: string, timeoutMs?: number | undefined) => Promise<T_1>;
|
|
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) => Promise<string>;
|
|
39
|
+
/** Waits for the connection to WA to reach a state */
|
|
40
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
|
|
41
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
|
|
42
|
+
};
|
|
43
|
+
export type Socket = ReturnType<typeof makeSocket>;
|
package/lib/Socket/socket.js
CHANGED
|
@@ -22,7 +22,9 @@ const makeSocket = (config) => {
|
|
|
22
22
|
const { waWebSocketUrl, connectTimeoutMs, logger, keepAliveIntervalMs, browser, auth: authState, printQRInTerminal, defaultQueryTimeoutMs, transactionOpts, qrTimeout, makeSignalRepository, } = config;
|
|
23
23
|
const url = typeof waWebSocketUrl === 'string' ? new url_1.URL(waWebSocketUrl) : waWebSocketUrl;
|
|
24
24
|
if (config.mobile || url.protocol === 'tcp:') {
|
|
25
|
-
throw new boom_1.Boom('Mobile API is not supported anymore', {
|
|
25
|
+
throw new boom_1.Boom('Mobile API is not supported anymore', {
|
|
26
|
+
statusCode: Types_1.DisconnectReason.loggedOut
|
|
27
|
+
});
|
|
26
28
|
}
|
|
27
29
|
if (url.protocol === 'wss' && ((_a = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _a === void 0 ? void 0 : _a.routingInfo)) {
|
|
28
30
|
url.searchParams.append('ED', authState.creds.routingInfo.toString('base64url'));
|
|
@@ -381,18 +383,24 @@ const makeSocket = (config) => {
|
|
|
381
383
|
}
|
|
382
384
|
end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }));
|
|
383
385
|
};
|
|
384
|
-
|
|
386
|
+
|
|
387
|
+
/** This method was created by snowi, and implemented by KyuuRzy */
|
|
388
|
+
/** hey bro, if you delete this text */
|
|
389
|
+
/** you are the most cursed human being who likes to claim other people's property 😹🙌🏻 */
|
|
390
|
+
const requestPairingCode = async (phoneNumber, pairKey) => {
|
|
385
391
|
if (pairKey) {
|
|
386
392
|
authState.creds.pairingCode = pairKey.toUpperCase();
|
|
387
|
-
}
|
|
388
|
-
else {
|
|
393
|
+
} else {
|
|
389
394
|
authState.creds.pairingCode = (0, Utils_1.bytesToCrockford)((0, crypto_1.randomBytes)(5));
|
|
390
395
|
}
|
|
396
|
+
|
|
391
397
|
authState.creds.me = {
|
|
392
398
|
id: (0, WABinary_1.jidEncode)(phoneNumber, 's.whatsapp.net'),
|
|
393
399
|
name: '~'
|
|
394
400
|
};
|
|
401
|
+
|
|
395
402
|
ev.emit('creds.update', authState.creds);
|
|
403
|
+
|
|
396
404
|
await sendNode({
|
|
397
405
|
tag: 'iq',
|
|
398
406
|
attrs: {
|
|
@@ -407,7 +415,6 @@ const makeSocket = (config) => {
|
|
|
407
415
|
attrs: {
|
|
408
416
|
jid: authState.creds.me.id,
|
|
409
417
|
stage: 'companion_hello',
|
|
410
|
-
// eslint-disable-next-line camelcase
|
|
411
418
|
should_show_push_notification: 'true'
|
|
412
419
|
},
|
|
413
420
|
content: [
|
|
@@ -434,14 +441,15 @@ const makeSocket = (config) => {
|
|
|
434
441
|
{
|
|
435
442
|
tag: 'link_code_pairing_nonce',
|
|
436
443
|
attrs: {},
|
|
437
|
-
content:
|
|
444
|
+
content: "0"
|
|
438
445
|
}
|
|
439
446
|
]
|
|
440
447
|
}
|
|
441
448
|
]
|
|
442
449
|
});
|
|
450
|
+
|
|
443
451
|
return authState.creds.pairingCode;
|
|
444
|
-
}
|
|
452
|
+
}
|
|
445
453
|
async function generatePairingKey() {
|
|
446
454
|
const salt = (0, crypto_1.randomBytes)(32);
|
|
447
455
|
const randomIv = (0, crypto_1.randomBytes)(16);
|
|
@@ -620,7 +628,10 @@ const makeSocket = (config) => {
|
|
|
620
628
|
type: 'md',
|
|
621
629
|
ws,
|
|
622
630
|
ev,
|
|
623
|
-
authState: {
|
|
631
|
+
authState: {
|
|
632
|
+
creds,
|
|
633
|
+
keys
|
|
634
|
+
},
|
|
624
635
|
signalRepository,
|
|
625
636
|
get user() {
|
|
626
637
|
return authState.creds.me;
|
package/lib/Socket/usync.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare const makeUSyncSocket: (config: SocketConfig) => {
|
|
|
20
20
|
signalRepository: import("../Types").SignalRepository;
|
|
21
21
|
user: import("../Types").Contact | undefined;
|
|
22
22
|
generateMessageTag: () => string;
|
|
23
|
-
query: (node: BinaryNode, timeoutMs?: number) => Promise<
|
|
23
|
+
query: (node: BinaryNode, timeoutMs?: number) => Promise<BinaryNode>;
|
|
24
24
|
waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
|
25
25
|
waitForSocketOpen: () => Promise<void>;
|
|
26
26
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
|
@@ -30,7 +30,7 @@ export declare const makeUSyncSocket: (config: SocketConfig) => {
|
|
|
30
30
|
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
31
31
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
32
32
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
33
|
-
requestPairingCode: (phoneNumber:
|
|
33
|
+
requestPairingCode: (phoneNumber: string, customPairingCode?: string) => Promise<string>;
|
|
34
34
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
35
|
-
sendWAMBuffer: (wamBuffer: Buffer) => Promise<
|
|
35
|
+
sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
|
|
36
36
|
};
|
package/lib/Store/index.d.ts
CHANGED
package/lib/Store/index.js
CHANGED
|
@@ -3,6 +3,8 @@ 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.makeInMemoryStore = void 0;
|
|
6
|
+
exports.makeCacheManagerAuthState = exports.makeInMemoryStore = void 0;
|
|
7
|
+
const make_cache_manager_store_1 = __importDefault(require("./make-cache-manager-store"));
|
|
8
|
+
exports.makeCacheManagerAuthState = make_cache_manager_store_1.default;
|
|
7
9
|
const make_in_memory_store_1 = __importDefault(require("./make-in-memory-store"));
|
|
8
10
|
exports.makeInMemoryStore = make_in_memory_store_1.default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AuthenticationCreds } from '../Types';
|
|
2
|
+
declare const makeCacheManagerAuthState: (store: Storage, sessionKey: string) => Promise<{
|
|
3
|
+
clearState: () => Promise<void>;
|
|
4
|
+
saveCreds: () => Promise<void>;
|
|
5
|
+
state: {
|
|
6
|
+
creds: AuthenticationCreds;
|
|
7
|
+
keys: {
|
|
8
|
+
get: (type: string, ids: string[]) => Promise<{}>;
|
|
9
|
+
set: (data: any) => Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
export default makeCacheManagerAuthState;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const cache_manager_1 = require("cache-manager");
|
|
7
|
+
const WAProto_1 = require("../../WAProto");
|
|
8
|
+
const Utils_1 = require("../Utils");
|
|
9
|
+
const logger_1 = __importDefault(require("../Utils/logger"));
|
|
10
|
+
const makeCacheManagerAuthState = async (store, sessionKey) => {
|
|
11
|
+
const defaultKey = (file) => `${sessionKey}:${file}`;
|
|
12
|
+
const databaseConn = await (0, cache_manager_1.caching)(store);
|
|
13
|
+
const writeData = async (file, data) => {
|
|
14
|
+
let ttl = undefined;
|
|
15
|
+
if (file === 'creds') {
|
|
16
|
+
ttl = 63115200; // 2 years
|
|
17
|
+
}
|
|
18
|
+
await databaseConn.set(defaultKey(file), JSON.stringify(data, Utils_1.BufferJSON.replacer), ttl);
|
|
19
|
+
};
|
|
20
|
+
const readData = async (file) => {
|
|
21
|
+
try {
|
|
22
|
+
const data = await databaseConn.get(defaultKey(file));
|
|
23
|
+
if (data) {
|
|
24
|
+
return JSON.parse(data, Utils_1.BufferJSON.reviver);
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
logger_1.default.error(error);
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const removeData = async (file) => {
|
|
34
|
+
try {
|
|
35
|
+
return await databaseConn.del(defaultKey(file));
|
|
36
|
+
}
|
|
37
|
+
catch (_a) {
|
|
38
|
+
logger_1.default.error(`Error removing ${file} from session ${sessionKey}`);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const clearState = async () => {
|
|
42
|
+
try {
|
|
43
|
+
const result = await databaseConn.store.keys(`${sessionKey}*`);
|
|
44
|
+
await Promise.all(result.map(async (key) => await databaseConn.del(key)));
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const creds = (await readData('creds')) || (0, Utils_1.initAuthCreds)();
|
|
50
|
+
return {
|
|
51
|
+
clearState,
|
|
52
|
+
saveCreds: () => writeData('creds', creds),
|
|
53
|
+
state: {
|
|
54
|
+
creds,
|
|
55
|
+
keys: {
|
|
56
|
+
get: async (type, ids) => {
|
|
57
|
+
const data = {};
|
|
58
|
+
await Promise.all(ids.map(async (id) => {
|
|
59
|
+
let value = await readData(`${type}-${id}`);
|
|
60
|
+
if (type === 'app-state-sync-key' && value) {
|
|
61
|
+
value = WAProto_1.proto.Message.AppStateSyncKeyData.fromObject(value);
|
|
62
|
+
}
|
|
63
|
+
data[id] = value;
|
|
64
|
+
}));
|
|
65
|
+
return data;
|
|
66
|
+
},
|
|
67
|
+
set: async (data) => {
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
|
+
const tasks = [];
|
|
70
|
+
for (const category in data) {
|
|
71
|
+
for (const id in data[category]) {
|
|
72
|
+
const value = data[category][id];
|
|
73
|
+
const key = `${category}-${id}`;
|
|
74
|
+
tasks.push(value ? writeData(key, value) : removeData(key));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
await Promise.all(tasks);
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
exports.default = makeCacheManagerAuthState;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type KeyedDB from '@adiwajshing/keyed-db';
|
|
2
2
|
import type { Comparable } from '@adiwajshing/keyed-db/lib/Types';
|
|
3
|
+
import type { Logger } from 'pino';
|
|
3
4
|
import { proto } from '../../WAProto';
|
|
4
5
|
import type makeMDSocket from '../Socket';
|
|
5
6
|
import type { BaileysEventEmitter, Chat, ConnectionState, Contact, GroupMetadata, PresenceData, WAMessage, WAMessageCursor, WAMessageKey } from '../Types';
|
|
6
7
|
import { Label } from '../Types/Label';
|
|
7
8
|
import { LabelAssociation } from '../Types/LabelAssociation';
|
|
8
|
-
import { ILogger } from '../Utils/logger';
|
|
9
9
|
import { ObjectRepository } from './object-repository';
|
|
10
10
|
type WASocket = ReturnType<typeof makeMDSocket>;
|
|
11
11
|
export declare const waChatKey: (pin: boolean) => {
|
|
@@ -17,7 +17,7 @@ export declare const waLabelAssociationKey: Comparable<LabelAssociation, string>
|
|
|
17
17
|
export type BaileysInMemoryStoreConfig = {
|
|
18
18
|
chatKey?: Comparable<Chat, string>;
|
|
19
19
|
labelAssociationKey?: Comparable<LabelAssociation, string>;
|
|
20
|
-
logger?:
|
|
20
|
+
logger?: Logger;
|
|
21
21
|
socket?: WASocket;
|
|
22
22
|
};
|
|
23
23
|
declare const _default: (config: BaileysInMemoryStoreConfig) => {
|
|
@@ -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: proto.IWebMessageInfo[];
|
|
31
|
+
get: (id: string) => proto.IWebMessageInfo | undefined;
|
|
32
|
+
upsert: (item: proto.IWebMessageInfo, mode: "append" | "prepend") => void;
|
|
33
|
+
update: (item: proto.IWebMessageInfo) => boolean;
|
|
34
|
+
remove: (item: proto.IWebMessageInfo) => boolean;
|
|
35
|
+
updateAssign: (id: string, update: Partial<proto.IWebMessageInfo>) => boolean;
|
|
36
36
|
clear: () => void;
|
|
37
|
-
filter: (contain: (item:
|
|
38
|
-
toJSON: () =>
|
|
39
|
-
fromJSON: (newItems:
|
|
37
|
+
filter: (contain: (item: proto.IWebMessageInfo) => boolean) => void;
|
|
38
|
+
toJSON: () => proto.IWebMessageInfo[];
|
|
39
|
+
fromJSON: (newItems: proto.IWebMessageInfo[]) => 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<proto.IWebMessageInfo[]>;
|
|
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<proto.IWebMessageInfo | undefined>;
|
|
76
|
+
mostRecentMessage: (jid: string) => Promise<proto.IWebMessageInfo>;
|
|
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: proto.IWebMessageInfo[];
|
|
88
|
+
get: (id: string) => proto.IWebMessageInfo | undefined;
|
|
89
|
+
upsert: (item: proto.IWebMessageInfo, mode: "append" | "prepend") => void;
|
|
90
|
+
update: (item: proto.IWebMessageInfo) => boolean;
|
|
91
|
+
remove: (item: proto.IWebMessageInfo) => boolean;
|
|
92
|
+
updateAssign: (id: string, update: Partial<proto.IWebMessageInfo>) => boolean;
|
|
93
93
|
clear: () => void;
|
|
94
|
-
filter: (contain: (item:
|
|
95
|
-
toJSON: () =>
|
|
96
|
-
fromJSON: (newItems:
|
|
94
|
+
filter: (contain: (item: proto.IWebMessageInfo) => boolean) => void;
|
|
95
|
+
toJSON: () => proto.IWebMessageInfo[];
|
|
96
|
+
fromJSON: (newItems: proto.IWebMessageInfo[]) => 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]: proto.IWebMessageInfo[];
|
|
109
109
|
};
|
|
110
110
|
labels: {
|
|
111
111
|
[labelId: string]: Label;
|