@queenanya/baileys 7.4.10 → 7.4.13
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 +26 -26
- package/WAProto/index.js +97194 -67957
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +231 -1
- package/lib/Defaults/index.js +23 -11
- package/lib/Defaults/phonenumber-mcc.json +223 -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/{websocket.d.ts → web-socket-client.d.ts} +1 -1
- package/lib/Socket/Client/{websocket.js → web-socket-client.js} +2 -2
- package/lib/Socket/business.d.ts +28 -31
- package/lib/Socket/chats.d.ts +9 -17
- package/lib/Socket/chats.js +116 -115
- package/lib/Socket/groups.d.ts +10 -23
- package/lib/Socket/groups.js +1 -12
- package/lib/Socket/index.d.ts +38 -69
- package/lib/Socket/index.js +2 -2
- package/lib/Socket/messages-recv.d.ts +28 -30
- package/lib/Socket/messages-recv.js +180 -291
- package/lib/Socket/messages-send.d.ts +19 -25
- package/lib/Socket/messages-send.js +76 -110
- package/lib/Socket/newsletter.d.ts +13 -19
- package/lib/Socket/newsletter.js +54 -67
- package/lib/Socket/{communities.d.ts → registration.d.ts} +145 -94
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +1 -3
- package/lib/Socket/socket.js +17 -15
- package/lib/Store/make-cache-manager-store.d.ts +1 -2
- package/lib/Store/make-in-memory-store.js +11 -13
- package/lib/Store/make-ordered-dictionary.js +2 -2
- package/lib/Types/Auth.d.ts +6 -1
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +7 -15
- package/lib/Types/Contact.d.ts +1 -6
- package/lib/Types/Events.d.ts +2 -44
- package/lib/Types/GroupMetadata.d.ts +1 -3
- package/lib/Types/Label.d.ts +0 -11
- package/lib/Types/Message.d.ts +30 -37
- package/lib/Types/Newsletter.d.ts +13 -0
- package/lib/Types/Newsletter.js +15 -1
- package/lib/Types/Socket.d.ts +3 -10
- package/lib/Types/index.d.ts +0 -8
- package/lib/Utils/auth-utils.js +7 -1
- package/lib/Utils/chat-utils.d.ts +4 -5
- package/lib/Utils/chat-utils.js +20 -52
- package/lib/Utils/crypto.d.ts +1 -2
- package/lib/Utils/crypto.js +2 -4
- package/lib/Utils/decode-wa-message.d.ts +0 -1
- package/lib/Utils/decode-wa-message.js +14 -34
- package/lib/Utils/event-buffer.js +8 -14
- package/lib/Utils/generics.d.ts +13 -37
- package/lib/Utils/generics.js +18 -103
- package/lib/Utils/history.d.ts +2 -6
- package/lib/Utils/history.js +0 -3
- package/lib/Utils/index.d.ts +0 -1
- package/lib/Utils/index.js +0 -1
- package/lib/Utils/link-preview.js +1 -24
- package/lib/Utils/logger.d.ts +3 -1
- package/lib/Utils/make-mutex.js +0 -1
- package/lib/Utils/messages-media.d.ts +2 -3
- package/lib/Utils/messages-media.js +32 -17
- package/lib/Utils/messages.d.ts +0 -1
- package/lib/Utils/messages.js +72 -67
- package/lib/Utils/noise-handler.d.ts +3 -3
- package/lib/Utils/noise-handler.js +12 -7
- package/lib/Utils/process-message.d.ts +2 -3
- package/lib/Utils/process-message.js +21 -55
- package/lib/Utils/signal.js +16 -23
- package/lib/Utils/use-multi-file-auth-state.js +3 -17
- package/lib/Utils/validate-connection.d.ts +1 -0
- package/lib/Utils/validate-connection.js +44 -10
- package/lib/WABinary/constants.js +5 -5
- package/lib/WABinary/decode.d.ts +2 -3
- package/lib/WABinary/decode.js +4 -6
- package/lib/WABinary/encode.d.ts +2 -1
- package/lib/WABinary/encode.js +6 -8
- package/lib/WABinary/generic-utils.d.ts +0 -1
- package/lib/WABinary/jid-utils.d.ts +3 -3
- package/lib/WABinary/jid-utils.js +5 -5
- package/lib/WAM/BinaryInfo.d.ts +2 -3
- package/lib/WAM/constants.d.ts +2 -3
- package/lib/WAM/encode.d.ts +0 -1
- package/lib/WAM/encode.js +2 -2
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/package.json +37 -39
- package/lib/Socket/communities.js +0 -354
- package/lib/Socket/usync.d.ts +0 -38
- package/lib/Socket/usync.js +0 -70
- package/lib/Types/USync.d.ts +0 -25
- package/lib/Types/USync.js +0 -2
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +0 -32
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +0 -57
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -30
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +0 -42
- package/lib/WAUSync/Protocols/index.d.ts +0 -4
- package/lib/WAUSync/Protocols/index.js +0 -20
- package/lib/WAUSync/USyncQuery.d.ts +0 -26
- package/lib/WAUSync/USyncQuery.js +0 -79
- package/lib/WAUSync/USyncUser.d.ts +0 -10
- package/lib/WAUSync/USyncUser.js +0 -22
- package/lib/WAUSync/index.d.ts +0 -3
- package/lib/WAUSync/index.js +0 -19
- /package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +0 -0
- /package/lib/Socket/Client/{types.js → abstract-socket-client.js} +0 -0
package/lib/Types/Message.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
/// <reference types="node" />
|
|
4
|
-
/// <reference types="node" />
|
|
5
4
|
import { AxiosRequestConfig } from 'axios';
|
|
6
5
|
import type { Logger } from 'pino';
|
|
7
6
|
import type { Readable } from 'stream';
|
|
8
7
|
import type { URL } from 'url';
|
|
8
|
+
import { BinaryNode } from '../WABinary';
|
|
9
9
|
import { proto } from '../../WAProto';
|
|
10
10
|
import { MEDIA_HKDF_KEY_MAPPING } from '../Defaults';
|
|
11
|
-
import { BinaryNode } from '../WABinary';
|
|
12
11
|
import type { GroupMetadata } from './GroupMetadata';
|
|
13
12
|
import { CacheStore } from './Socket';
|
|
14
13
|
export { proto as WAProto };
|
|
@@ -16,22 +15,18 @@ export type WAMessage = proto.IWebMessageInfo;
|
|
|
16
15
|
export type WAMessageContent = proto.IMessage;
|
|
17
16
|
export type WAContactMessage = proto.Message.IContactMessage;
|
|
18
17
|
export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage;
|
|
19
|
-
export type WAMessageKey = proto.IMessageKey
|
|
20
|
-
server_id?: string;
|
|
21
|
-
};
|
|
18
|
+
export type WAMessageKey = proto.IMessageKey;
|
|
22
19
|
export type WATextMessage = proto.Message.IExtendedTextMessage;
|
|
23
20
|
export type WAContextInfo = proto.IContextInfo;
|
|
24
21
|
export type WALocationMessage = proto.Message.ILocationMessage;
|
|
25
22
|
export type WAGenericMediaMessage = proto.Message.IVideoMessage | proto.Message.IImageMessage | proto.Message.IAudioMessage | proto.Message.IDocumentMessage | proto.Message.IStickerMessage;
|
|
26
23
|
export import WAMessageStubType = proto.WebMessageInfo.StubType;
|
|
27
24
|
export import WAMessageStatus = proto.WebMessageInfo.Status;
|
|
28
|
-
export type
|
|
25
|
+
export type WAMediaUpload = Buffer | {
|
|
29
26
|
url: URL | string;
|
|
30
|
-
}
|
|
31
|
-
export type WAMediaPayloadStream = {
|
|
27
|
+
} | {
|
|
32
28
|
stream: Readable;
|
|
33
29
|
};
|
|
34
|
-
export type WAMediaUpload = Buffer | WAMediaPayloadStream | WAMediaPayloadURL;
|
|
35
30
|
/** Set of message types that are supported by the library */
|
|
36
31
|
export type MessageType = keyof proto.Message;
|
|
37
32
|
export type DownloadableMessage = {
|
|
@@ -69,9 +64,26 @@ type Contextable = {
|
|
|
69
64
|
type ViewOnce = {
|
|
70
65
|
viewOnce?: boolean;
|
|
71
66
|
};
|
|
67
|
+
type Buttonable = {
|
|
68
|
+
/** add buttons to the message */
|
|
69
|
+
buttons?: proto.Message.ButtonsMessage.IButton[];
|
|
70
|
+
};
|
|
71
|
+
type Templatable = {
|
|
72
|
+
/** add buttons to the message (conflicts with normal buttons)*/
|
|
73
|
+
templateButtons?: proto.IHydratedTemplateButton[];
|
|
74
|
+
footer?: string;
|
|
75
|
+
};
|
|
72
76
|
type Editable = {
|
|
73
77
|
edit?: WAMessageKey;
|
|
74
78
|
};
|
|
79
|
+
type Listable = {
|
|
80
|
+
/** Sections of the List */
|
|
81
|
+
sections?: proto.Message.ListMessage.ISection[];
|
|
82
|
+
/** Title of a List Message only */
|
|
83
|
+
title?: string;
|
|
84
|
+
/** Text of the bnutton on the list (required) */
|
|
85
|
+
buttonText?: string;
|
|
86
|
+
};
|
|
75
87
|
type WithDimensions = {
|
|
76
88
|
width?: number;
|
|
77
89
|
height?: number;
|
|
@@ -82,7 +94,6 @@ export type PollMessageOptions = {
|
|
|
82
94
|
values: string[];
|
|
83
95
|
/** 32 byte message secret to encrypt poll selections */
|
|
84
96
|
messageSecret?: Uint8Array;
|
|
85
|
-
toAnnouncementGroup?: boolean;
|
|
86
97
|
};
|
|
87
98
|
type SharePhoneNumber = {
|
|
88
99
|
sharePhoneNumber: boolean;
|
|
@@ -95,14 +106,14 @@ export type AnyMediaMessageContent = (({
|
|
|
95
106
|
image: WAMediaUpload;
|
|
96
107
|
caption?: string;
|
|
97
108
|
jpegThumbnail?: string;
|
|
98
|
-
} & Mentionable & Contextable & WithDimensions) | ({
|
|
109
|
+
} & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | ({
|
|
99
110
|
video: WAMediaUpload;
|
|
100
111
|
caption?: string;
|
|
101
112
|
gifPlayback?: boolean;
|
|
102
113
|
jpegThumbnail?: string;
|
|
103
114
|
/** if set to true, will send as a `video note` */
|
|
104
115
|
ptv?: boolean;
|
|
105
|
-
} & Mentionable & Contextable & WithDimensions) | {
|
|
116
|
+
} & Mentionable & Contextable & Buttonable & Templatable & WithDimensions) | {
|
|
106
117
|
audio: WAMediaUpload;
|
|
107
118
|
/** if set to true, will send as a `voice note` */
|
|
108
119
|
ptt?: boolean;
|
|
@@ -116,7 +127,7 @@ export type AnyMediaMessageContent = (({
|
|
|
116
127
|
mimetype: string;
|
|
117
128
|
fileName?: string;
|
|
118
129
|
caption?: string;
|
|
119
|
-
} & Contextable)) & {
|
|
130
|
+
} & Contextable & Buttonable & Templatable)) & {
|
|
120
131
|
mimetype?: string;
|
|
121
132
|
} & Editable;
|
|
122
133
|
export type ButtonReplyInfo = {
|
|
@@ -124,22 +135,15 @@ export type ButtonReplyInfo = {
|
|
|
124
135
|
id: string;
|
|
125
136
|
index: number;
|
|
126
137
|
};
|
|
127
|
-
export type GroupInviteInfo = {
|
|
128
|
-
inviteCode: string;
|
|
129
|
-
inviteExpiration: number;
|
|
130
|
-
text: string;
|
|
131
|
-
jid: string;
|
|
132
|
-
subject: string;
|
|
133
|
-
};
|
|
134
138
|
export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
|
|
135
139
|
productImage: WAMediaUpload;
|
|
136
140
|
};
|
|
137
141
|
export type AnyRegularMessageContent = (({
|
|
138
142
|
text: string;
|
|
139
143
|
linkPreview?: WAUrlInfo | null;
|
|
140
|
-
} & Mentionable & Contextable & Editable) | AnyMediaMessageContent | ({
|
|
144
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Listable & Editable) | AnyMediaMessageContent | ({
|
|
141
145
|
poll: PollMessageOptions;
|
|
142
|
-
} & Mentionable & Contextable & Editable) | {
|
|
146
|
+
} & Mentionable & Contextable & Buttonable & Templatable & Editable) | {
|
|
143
147
|
contacts: {
|
|
144
148
|
displayName?: string;
|
|
145
149
|
contacts: proto.Message.IContactMessage[];
|
|
@@ -151,19 +155,8 @@ export type AnyRegularMessageContent = (({
|
|
|
151
155
|
} | {
|
|
152
156
|
buttonReply: ButtonReplyInfo;
|
|
153
157
|
type: 'template' | 'plain';
|
|
154
|
-
} | {
|
|
155
|
-
groupInvite: GroupInviteInfo;
|
|
156
158
|
} | {
|
|
157
159
|
listReply: Omit<proto.Message.IListResponseMessage, 'contextInfo'>;
|
|
158
|
-
} | {
|
|
159
|
-
pin: WAMessageKey;
|
|
160
|
-
type: proto.PinInChat.Type;
|
|
161
|
-
/**
|
|
162
|
-
* 24 hours, 7 days, 30 days
|
|
163
|
-
*/
|
|
164
|
-
time?: 86400 | 604800 | 2592000;
|
|
165
|
-
} | {
|
|
166
|
-
unpin: WAMessageKey;
|
|
167
160
|
} | {
|
|
168
161
|
product: WASendableProduct;
|
|
169
162
|
businessOwnerJid?: string;
|
|
@@ -183,8 +176,8 @@ export type GroupMetadataParticipants = Pick<GroupMetadata, 'participants'>;
|
|
|
183
176
|
type MinimalRelayOptions = {
|
|
184
177
|
/** override the message ID with a custom provided string */
|
|
185
178
|
messageId?: string;
|
|
186
|
-
/**
|
|
187
|
-
|
|
179
|
+
/** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
|
|
180
|
+
cachedGroupMetadata?: (jid: string) => Promise<GroupMetadataParticipants | undefined>;
|
|
188
181
|
};
|
|
189
182
|
export type MessageRelayOptions = MinimalRelayOptions & {
|
|
190
183
|
/** only send to a specific participant; used when a message decryption fails for a single user */
|
|
@@ -207,6 +200,7 @@ export type MiscMessageGenerationOptions = MinimalRelayOptions & {
|
|
|
207
200
|
timestamp?: Date;
|
|
208
201
|
/** the message you want to quote */
|
|
209
202
|
quoted?: WAMessage;
|
|
203
|
+
additionalNodes?: BinaryNode[];
|
|
210
204
|
/** disappearing messages settings */
|
|
211
205
|
ephemeralExpiration?: number | string;
|
|
212
206
|
/** timeout for media upload to WA server */
|
|
@@ -243,13 +237,12 @@ export type MediaGenerationOptions = {
|
|
|
243
237
|
mediaUploadTimeoutMs?: number;
|
|
244
238
|
options?: AxiosRequestConfig;
|
|
245
239
|
backgroundColor?: string;
|
|
240
|
+
font?: number;
|
|
246
241
|
/** The message is for newsletter? */
|
|
247
242
|
newsletter?: boolean;
|
|
248
|
-
font?: number;
|
|
249
243
|
};
|
|
250
244
|
export type MessageContentGenerationOptions = MediaGenerationOptions & {
|
|
251
245
|
getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
|
|
252
|
-
getProfilePicUrl?: (jid: string, type: 'image' | 'preview') => Promise<string | undefined>;
|
|
253
246
|
};
|
|
254
247
|
export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
|
|
255
248
|
/**
|
|
@@ -77,3 +77,16 @@ export declare enum XWAPaths {
|
|
|
77
77
|
NEWSLETTER = "xwa2_newsletter",
|
|
78
78
|
METADATA_UPDATE = "xwa2_notify_newsletter_on_metadata_update"
|
|
79
79
|
}
|
|
80
|
+
export declare enum QueryIds {
|
|
81
|
+
JOB_MUTATION = "7150902998257522",
|
|
82
|
+
METADATA = "6620195908089573",
|
|
83
|
+
UNFOLLOW = "7238632346214362",
|
|
84
|
+
FOLLOW = "7871414976211147",
|
|
85
|
+
UNMUTE = "7337137176362961",
|
|
86
|
+
MUTE = "25151904754424642",
|
|
87
|
+
CREATE = "6996806640408138",
|
|
88
|
+
ADMIN_COUNT = "7130823597031706",
|
|
89
|
+
CHANGE_OWNER = "7341777602580933",
|
|
90
|
+
DELETE = "8316537688363079",
|
|
91
|
+
DEMOTE = "6551828931592903"
|
|
92
|
+
}
|
package/lib/Types/Newsletter.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.XWAPaths = exports.MexOperations = void 0;
|
|
3
|
+
exports.QueryIds = exports.XWAPaths = exports.MexOperations = void 0;
|
|
4
4
|
var MexOperations;
|
|
5
5
|
(function (MexOperations) {
|
|
6
6
|
MexOperations["PROMOTE"] = "NotificationNewsletterAdminPromote";
|
|
@@ -16,3 +16,17 @@ var XWAPaths;
|
|
|
16
16
|
XWAPaths["NEWSLETTER"] = "xwa2_newsletter";
|
|
17
17
|
XWAPaths["METADATA_UPDATE"] = "xwa2_notify_newsletter_on_metadata_update";
|
|
18
18
|
})(XWAPaths = exports.XWAPaths || (exports.XWAPaths = {}));
|
|
19
|
+
var QueryIds;
|
|
20
|
+
(function (QueryIds) {
|
|
21
|
+
QueryIds["JOB_MUTATION"] = "7150902998257522";
|
|
22
|
+
QueryIds["METADATA"] = "6620195908089573";
|
|
23
|
+
QueryIds["UNFOLLOW"] = "7238632346214362";
|
|
24
|
+
QueryIds["FOLLOW"] = "7871414976211147";
|
|
25
|
+
QueryIds["UNMUTE"] = "7337137176362961";
|
|
26
|
+
QueryIds["MUTE"] = "25151904754424642";
|
|
27
|
+
QueryIds["CREATE"] = "6996806640408138";
|
|
28
|
+
QueryIds["ADMIN_COUNT"] = "7130823597031706";
|
|
29
|
+
QueryIds["CHANGE_OWNER"] = "7341777602580933";
|
|
30
|
+
QueryIds["DELETE"] = "8316537688363079";
|
|
31
|
+
QueryIds["DEMOTE"] = "6551828931592903";
|
|
32
|
+
})(QueryIds = exports.QueryIds || (exports.QueryIds = {}));
|
package/lib/Types/Socket.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ import type { Logger } from 'pino';
|
|
|
6
6
|
import type { URL } from 'url';
|
|
7
7
|
import { proto } from '../../WAProto';
|
|
8
8
|
import { AuthenticationState, SignalAuthState, TransactionCapabilityOptions } from './Auth';
|
|
9
|
-
import { GroupMetadata } from './GroupMetadata';
|
|
10
9
|
import { MediaConnInfo } from './Message';
|
|
11
10
|
import { SignalRepository } from './Signal';
|
|
12
11
|
export type WAVersion = [number, number, number];
|
|
@@ -30,9 +29,7 @@ export type SocketConfig = {
|
|
|
30
29
|
defaultQueryTimeoutMs: number | undefined;
|
|
31
30
|
/** ping-pong interval for WS connection */
|
|
32
31
|
keepAliveIntervalMs: number;
|
|
33
|
-
/** should baileys use the mobile api instead of the multi device api
|
|
34
|
-
* @deprecated This feature has been removed
|
|
35
|
-
*/
|
|
32
|
+
/** should baileys use the mobile api instead of the multi device api */
|
|
36
33
|
mobile?: boolean;
|
|
37
34
|
/** proxy agent */
|
|
38
35
|
agent?: Agent;
|
|
@@ -74,14 +71,10 @@ export type SocketConfig = {
|
|
|
74
71
|
userDevicesCache?: CacheStore;
|
|
75
72
|
/** cache to store call offers */
|
|
76
73
|
callOfferCache?: CacheStore;
|
|
77
|
-
/** cache to track placeholder resends */
|
|
78
|
-
placeholderResendCache?: CacheStore;
|
|
79
74
|
/** width for link preview images */
|
|
80
75
|
linkPreviewImageThumbnailWidth: number;
|
|
81
76
|
/** Should Baileys ask the phone for full history, will be received async */
|
|
82
77
|
syncFullHistory: boolean;
|
|
83
|
-
/** Ignore Message when offline, default is false */
|
|
84
|
-
ignoreMsgLoading: boolean;
|
|
85
78
|
/** Should baileys fire init queries automatically, default true */
|
|
86
79
|
fireInitQueries: boolean;
|
|
87
80
|
/**
|
|
@@ -112,7 +105,7 @@ export type SocketConfig = {
|
|
|
112
105
|
* (solves the "this message can take a while" issue) can be retried
|
|
113
106
|
* */
|
|
114
107
|
getMessage: (key: proto.IMessageKey) => Promise<proto.IMessage | undefined>;
|
|
115
|
-
/** cached group metadata, use to prevent redundant requests to WA & speed up msg sending */
|
|
116
|
-
cachedGroupMetadata: (jid: string) => Promise<GroupMetadata | undefined>;
|
|
117
108
|
makeSignalRepository: (auth: SignalAuthState) => SignalRepository;
|
|
109
|
+
/** Socket passthrough */
|
|
110
|
+
socket?: any;
|
|
118
111
|
};
|
package/lib/Types/index.d.ts
CHANGED
|
@@ -15,14 +15,6 @@ import { SocketConfig } from './Socket';
|
|
|
15
15
|
export type UserFacingSocketConfig = Partial<SocketConfig> & {
|
|
16
16
|
auth: AuthenticationState;
|
|
17
17
|
};
|
|
18
|
-
/** Other Browser Support for Paircode */
|
|
19
|
-
export type BrowsersMap = {
|
|
20
|
-
ubuntu(browser: string): [string, string, string];
|
|
21
|
-
macOS(browser: string): [string, string, string];
|
|
22
|
-
baileys(browser: string): [string, string, string];
|
|
23
|
-
windows(browser: string): [string, string, string];
|
|
24
|
-
appropriate(browser: string): [string, string, string];
|
|
25
|
-
};
|
|
26
18
|
export declare enum DisconnectReason {
|
|
27
19
|
connectionClosed = 428,
|
|
28
20
|
connectionLost = 408,
|
package/lib/Utils/auth-utils.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.initAuthCreds = exports.addTransactionCapability = exports.makeCacheableSignalKeyStore = void 0;
|
|
7
7
|
const crypto_1 = require("crypto");
|
|
8
8
|
const node_cache_1 = __importDefault(require("node-cache"));
|
|
9
|
+
const uuid_1 = require("uuid");
|
|
9
10
|
const Defaults_1 = require("../Defaults");
|
|
10
11
|
const crypto_2 = require("./crypto");
|
|
11
12
|
const generics_1 = require("./generics");
|
|
@@ -142,7 +143,6 @@ const addTransactionCapability = (state, logger, { maxCommitRetries, delayBetwee
|
|
|
142
143
|
let tries = maxCommitRetries;
|
|
143
144
|
while (tries) {
|
|
144
145
|
tries -= 1;
|
|
145
|
-
//eslint-disable-next-line max-depth
|
|
146
146
|
try {
|
|
147
147
|
await state.set(mutations);
|
|
148
148
|
logger.trace({ dbQueriesInTransaction }, 'committed transaction');
|
|
@@ -191,7 +191,13 @@ const initAuthCreds = () => {
|
|
|
191
191
|
accountSettings: {
|
|
192
192
|
unarchiveChats: false
|
|
193
193
|
},
|
|
194
|
+
// mobile creds
|
|
195
|
+
deviceId: Buffer.from((0, uuid_1.v4)().replace(/-/g, ''), 'hex').toString('base64url'),
|
|
196
|
+
phoneId: (0, uuid_1.v4)(),
|
|
197
|
+
identityId: (0, crypto_1.randomBytes)(20),
|
|
194
198
|
registered: false,
|
|
199
|
+
backupToken: (0, crypto_1.randomBytes)(20),
|
|
200
|
+
registration: {},
|
|
195
201
|
pairingCode: undefined,
|
|
196
202
|
lastPropHash: undefined,
|
|
197
203
|
routingInfo: undefined,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
2
|
import { AxiosRequestConfig } from 'axios';
|
|
4
3
|
import type { Logger } from 'pino';
|
|
5
4
|
import { proto } from '../../WAProto';
|
|
@@ -30,7 +29,7 @@ export declare const decodeSyncdPatch: (msg: proto.ISyncdPatch, name: WAPatchNam
|
|
|
30
29
|
};
|
|
31
30
|
};
|
|
32
31
|
}>;
|
|
33
|
-
export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosRequestConfig<
|
|
32
|
+
export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosRequestConfig<any>) => Promise<{
|
|
34
33
|
critical_block: {
|
|
35
34
|
patches: proto.ISyncdPatch[];
|
|
36
35
|
hasMorePatches: boolean;
|
|
@@ -57,13 +56,13 @@ export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosReq
|
|
|
57
56
|
snapshot?: proto.ISyncdSnapshot | undefined;
|
|
58
57
|
};
|
|
59
58
|
}>;
|
|
60
|
-
export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<
|
|
61
|
-
export declare const downloadExternalPatch: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<
|
|
59
|
+
export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<any>) => Promise<Buffer>;
|
|
60
|
+
export declare const downloadExternalPatch: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<any>) => Promise<proto.SyncdMutations>;
|
|
62
61
|
export declare const decodeSyncdSnapshot: (name: WAPatchName, snapshot: proto.ISyncdSnapshot, getAppStateSyncKey: FetchAppStateSyncKey, minimumVersionNumber: number | undefined, validateMacs?: boolean) => Promise<{
|
|
63
62
|
state: LTHashState;
|
|
64
63
|
mutationMap: ChatMutationMap;
|
|
65
64
|
}>;
|
|
66
|
-
export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatch[], initial: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, options: AxiosRequestConfig<
|
|
65
|
+
export declare const decodePatches: (name: WAPatchName, syncds: proto.ISyncdPatch[], initial: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, options: AxiosRequestConfig<any>, minimumVersionNumber?: number, logger?: Logger, validateMacs?: boolean) => Promise<{
|
|
67
66
|
state: LTHashState;
|
|
68
67
|
mutationMap: ChatMutationMap;
|
|
69
68
|
}>;
|
package/lib/Utils/chat-utils.js
CHANGED
|
@@ -305,7 +305,8 @@ const decodePatches = async (name, syncds, initial, getAppStateSyncKey, options,
|
|
|
305
305
|
indexValueMap: { ...initial.indexValueMap }
|
|
306
306
|
};
|
|
307
307
|
const mutationMap = {};
|
|
308
|
-
for (
|
|
308
|
+
for (let i = 0; i < syncds.length; i++) {
|
|
309
|
+
const syncd = syncds[i];
|
|
309
310
|
const { version, keyId, snapshotMac } = syncd;
|
|
310
311
|
if (syncd.externalMutations) {
|
|
311
312
|
logger === null || logger === void 0 ? void 0 : logger.trace({ name, version }, 'downloading external patch');
|
|
@@ -417,31 +418,25 @@ const chatModificationToAppPatch = (mod, jid) => {
|
|
|
417
418
|
operation: OP.SET
|
|
418
419
|
};
|
|
419
420
|
}
|
|
420
|
-
else if ('deleteForMe' in mod) {
|
|
421
|
-
const { timestamp, key, deleteMedia } = mod.deleteForMe;
|
|
422
|
-
patch = {
|
|
423
|
-
syncAction: {
|
|
424
|
-
deleteMessageForMeAction: {
|
|
425
|
-
deleteMedia,
|
|
426
|
-
messageTimestamp: timestamp
|
|
427
|
-
}
|
|
428
|
-
},
|
|
429
|
-
index: ['deleteMessageForMe', jid, key.id, key.fromMe ? '1' : '0', '0'],
|
|
430
|
-
type: 'regular_high',
|
|
431
|
-
apiVersion: 3,
|
|
432
|
-
operation: OP.SET
|
|
433
|
-
};
|
|
434
|
-
}
|
|
435
421
|
else if ('clear' in mod) {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
422
|
+
if (mod.clear === 'all') {
|
|
423
|
+
throw new boom_1.Boom('not supported');
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
const key = mod.clear.messages[0];
|
|
427
|
+
patch = {
|
|
428
|
+
syncAction: {
|
|
429
|
+
deleteMessageForMeAction: {
|
|
430
|
+
deleteMedia: false,
|
|
431
|
+
messageTimestamp: key.timestamp
|
|
432
|
+
}
|
|
433
|
+
},
|
|
434
|
+
index: ['deleteMessageForMe', jid, key.id, key.fromMe ? '1' : '0', '0'],
|
|
435
|
+
type: 'regular_high',
|
|
436
|
+
apiVersion: 3,
|
|
437
|
+
operation: OP.SET
|
|
438
|
+
};
|
|
439
|
+
}
|
|
445
440
|
}
|
|
446
441
|
else if ('pin' in mod) {
|
|
447
442
|
patch = {
|
|
@@ -456,17 +451,6 @@ const chatModificationToAppPatch = (mod, jid) => {
|
|
|
456
451
|
operation: OP.SET
|
|
457
452
|
};
|
|
458
453
|
}
|
|
459
|
-
else if ('contact' in mod) {
|
|
460
|
-
patch = {
|
|
461
|
-
syncAction: {
|
|
462
|
-
contactAction: mod.contact || {}
|
|
463
|
-
},
|
|
464
|
-
index: ['contact', jid],
|
|
465
|
-
type: 'critical_unblock_low',
|
|
466
|
-
apiVersion: 2,
|
|
467
|
-
operation: mod.contact ? OP.SET : OP.REMOVE
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
454
|
else if ('star' in mod) {
|
|
471
455
|
const key = mod.star.messages[0];
|
|
472
456
|
patch = {
|
|
@@ -507,22 +491,6 @@ const chatModificationToAppPatch = (mod, jid) => {
|
|
|
507
491
|
operation: OP.SET,
|
|
508
492
|
};
|
|
509
493
|
}
|
|
510
|
-
else if ('addLabel' in mod) {
|
|
511
|
-
patch = {
|
|
512
|
-
syncAction: {
|
|
513
|
-
labelEditAction: {
|
|
514
|
-
name: mod.addLabel.name,
|
|
515
|
-
color: mod.addLabel.color,
|
|
516
|
-
predefinedId: mod.addLabel.predefinedId,
|
|
517
|
-
deleted: mod.addLabel.deleted
|
|
518
|
-
}
|
|
519
|
-
},
|
|
520
|
-
index: ['label_edit', mod.addLabel.id],
|
|
521
|
-
type: 'regular',
|
|
522
|
-
apiVersion: 3,
|
|
523
|
-
operation: OP.SET,
|
|
524
|
-
};
|
|
525
|
-
}
|
|
526
494
|
else if ('addChatLabel' in mod) {
|
|
527
495
|
patch = {
|
|
528
496
|
syncAction: {
|
package/lib/Utils/crypto.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
2
|
import { KeyPair } from '../Types';
|
|
4
3
|
/** prefix version byte to the pub keys, required for some curve crypto functions */
|
|
5
4
|
export declare const generateSignalPubKey: (pubKey: Uint8Array | Buffer) => Uint8Array | Buffer;
|
|
@@ -39,4 +38,4 @@ export declare function hkdf(buffer: Uint8Array | Buffer, expandedLength: number
|
|
|
39
38
|
salt?: Buffer;
|
|
40
39
|
info?: string;
|
|
41
40
|
}): Buffer;
|
|
42
|
-
export declare function derivePairingCodeKey(pairingCode: string, salt: Buffer):
|
|
41
|
+
export declare function derivePairingCodeKey(pairingCode: string, salt: Buffer): Buffer;
|
package/lib/Utils/crypto.js
CHANGED
|
@@ -30,9 +30,7 @@ exports.derivePairingCodeKey = exports.hkdf = exports.md5 = exports.sha256 = exp
|
|
|
30
30
|
const crypto_1 = require("crypto");
|
|
31
31
|
const futoin_hkdf_1 = __importDefault(require("futoin-hkdf"));
|
|
32
32
|
const libsignal = __importStar(require("libsignal"));
|
|
33
|
-
const util_1 = require("util");
|
|
34
33
|
const Defaults_1 = require("../Defaults");
|
|
35
|
-
const pbkdf2Promise = (0, util_1.promisify)(crypto_1.pbkdf2);
|
|
36
34
|
/** prefix version byte to the pub keys, required for some curve crypto functions */
|
|
37
35
|
const generateSignalPubKey = (pubKey) => (pubKey.length === 33
|
|
38
36
|
? pubKey
|
|
@@ -147,7 +145,7 @@ function hkdf(buffer, expandedLength, info) {
|
|
|
147
145
|
return (0, futoin_hkdf_1.default)(!Buffer.isBuffer(buffer) ? Buffer.from(buffer) : buffer, expandedLength, info);
|
|
148
146
|
}
|
|
149
147
|
exports.hkdf = hkdf;
|
|
150
|
-
|
|
151
|
-
return
|
|
148
|
+
function derivePairingCodeKey(pairingCode, salt) {
|
|
149
|
+
return (0, crypto_1.pbkdf2Sync)(pairingCode, salt, 2 << 16, 32, 'sha256');
|
|
152
150
|
}
|
|
153
151
|
exports.derivePairingCodeKey = derivePairingCodeKey;
|
|
@@ -2,7 +2,6 @@ import { Logger } from 'pino';
|
|
|
2
2
|
import { proto } from '../../WAProto';
|
|
3
3
|
import { SignalRepository } from '../Types';
|
|
4
4
|
import { BinaryNode } from '../WABinary';
|
|
5
|
-
export declare const NO_MESSAGE_FOUND_ERROR_TEXT = "Message absent from node";
|
|
6
5
|
/**
|
|
7
6
|
* Decode the received node as a message.
|
|
8
7
|
* @note this will only parse the message, not decrypt it
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decryptMessageNode = exports.decodeMessageNode =
|
|
3
|
+
exports.decryptMessageNode = exports.decodeMessageNode = void 0;
|
|
4
4
|
const boom_1 = require("@hapi/boom");
|
|
5
5
|
const WAProto_1 = require("../../WAProto");
|
|
6
6
|
const WABinary_1 = require("../WABinary");
|
|
7
7
|
const generics_1 = require("./generics");
|
|
8
|
-
|
|
8
|
+
const NO_MESSAGE_FOUND_ERROR_TEXT = 'Message absent from node';
|
|
9
9
|
/**
|
|
10
10
|
* Decode the received node as a message.
|
|
11
11
|
* @note this will only parse the message, not decrypt it
|
|
12
12
|
*/
|
|
13
13
|
function decodeMessageNode(stanza, meId, meLid) {
|
|
14
|
-
var _a, _b
|
|
14
|
+
var _a, _b;
|
|
15
15
|
let msgType;
|
|
16
16
|
let chatId;
|
|
17
17
|
let author;
|
|
@@ -55,11 +55,6 @@ function decodeMessageNode(stanza, meId, meLid) {
|
|
|
55
55
|
author = participant;
|
|
56
56
|
chatId = from;
|
|
57
57
|
}
|
|
58
|
-
else if ((0, WABinary_1.isJidNewsletter)(from)) {
|
|
59
|
-
msgType = 'newsletter';
|
|
60
|
-
author = from;
|
|
61
|
-
chatId = from;
|
|
62
|
-
}
|
|
63
58
|
else if ((0, WABinary_1.isJidBroadcast)(from)) {
|
|
64
59
|
if (!participant) {
|
|
65
60
|
throw new boom_1.Boom('No participant in group message');
|
|
@@ -74,7 +69,7 @@ function decodeMessageNode(stanza, meId, meLid) {
|
|
|
74
69
|
chatId = from;
|
|
75
70
|
author = participant;
|
|
76
71
|
}
|
|
77
|
-
else if ((0, WABinary_1.
|
|
72
|
+
else if ((0, WABinary_1.isJidNewsLetter)(from)) {
|
|
78
73
|
msgType = 'newsletter';
|
|
79
74
|
author = from;
|
|
80
75
|
chatId = from;
|
|
@@ -82,14 +77,13 @@ function decodeMessageNode(stanza, meId, meLid) {
|
|
|
82
77
|
else {
|
|
83
78
|
throw new boom_1.Boom('Unknown message type', { data: stanza });
|
|
84
79
|
}
|
|
85
|
-
const fromMe = (0, WABinary_1.
|
|
86
|
-
const pushname =
|
|
80
|
+
const fromMe = (0, WABinary_1.isJidNewsLetter)(from) ? !!((_a = stanza.attrs) === null || _a === void 0 ? void 0 : _a.is_sender) : ((0, WABinary_1.isLidUser)(from) ? isMeLid : isMe)(stanza.attrs.participant || stanza.attrs.from);
|
|
81
|
+
const pushname = stanza.attrs.notify;
|
|
87
82
|
const key = {
|
|
88
83
|
remoteJid: chatId,
|
|
89
84
|
fromMe,
|
|
90
85
|
id: msgId,
|
|
91
|
-
participant
|
|
92
|
-
server_id: (_c = stanza.attrs) === null || _c === void 0 ? void 0 : _c.server_id
|
|
86
|
+
participant
|
|
93
87
|
};
|
|
94
88
|
const fullMessage = {
|
|
95
89
|
key,
|
|
@@ -98,7 +92,7 @@ function decodeMessageNode(stanza, meId, meLid) {
|
|
|
98
92
|
broadcast: (0, WABinary_1.isJidBroadcast)(from)
|
|
99
93
|
};
|
|
100
94
|
if (msgType === 'newsletter') {
|
|
101
|
-
fullMessage.newsletterServerId = +((
|
|
95
|
+
fullMessage.newsletterServerId = +((_b = stanza.attrs) === null || _b === void 0 ? void 0 : _b.server_id);
|
|
102
96
|
}
|
|
103
97
|
if (key.fromMe) {
|
|
104
98
|
fullMessage.status = WAProto_1.proto.WebMessageInfo.Status.SERVER_ACK;
|
|
@@ -132,7 +126,7 @@ const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
|
|
|
132
126
|
}
|
|
133
127
|
}
|
|
134
128
|
}
|
|
135
|
-
if ((0, WABinary_1.
|
|
129
|
+
if ((0, WABinary_1.isJidNewsLetter)(fullMessage.key.remoteJid)) {
|
|
136
130
|
const node = (0, WABinary_1.getBinaryNodeChild)(stanza, 'plaintext');
|
|
137
131
|
const msg = WAProto_1.proto.Message.decode(node === null || node === void 0 ? void 0 : node.content);
|
|
138
132
|
await processSenderKeyDistribution(msg);
|
|
@@ -146,7 +140,7 @@ const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
|
|
|
146
140
|
const details = WAProto_1.proto.VerifiedNameCertificate.Details.decode(cert.details);
|
|
147
141
|
fullMessage.verifiedBizName = details.verifiedName;
|
|
148
142
|
}
|
|
149
|
-
if (tag !== 'enc'
|
|
143
|
+
if (tag !== 'enc') {
|
|
150
144
|
continue;
|
|
151
145
|
}
|
|
152
146
|
if (!(content instanceof Uint8Array)) {
|
|
@@ -155,7 +149,7 @@ const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
|
|
|
155
149
|
decryptables += 1;
|
|
156
150
|
let msgBuffer;
|
|
157
151
|
try {
|
|
158
|
-
const e2eType =
|
|
152
|
+
const e2eType = attrs.type;
|
|
159
153
|
switch (e2eType) {
|
|
160
154
|
case 'skmsg':
|
|
161
155
|
msgBuffer = await repository.decryptGroupMessage({
|
|
@@ -173,26 +167,12 @@ const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
|
|
|
173
167
|
ciphertext: content
|
|
174
168
|
});
|
|
175
169
|
break;
|
|
176
|
-
case 'plaintext':
|
|
177
|
-
msgBuffer = content;
|
|
178
|
-
break;
|
|
179
170
|
default:
|
|
180
171
|
throw new Error(`Unknown e2e type: ${e2eType}`);
|
|
181
172
|
}
|
|
182
|
-
let msg = WAProto_1.proto.Message.decode(
|
|
173
|
+
let msg = WAProto_1.proto.Message.decode((0, generics_1.unpadRandomMax16)(msgBuffer));
|
|
183
174
|
msg = ((_a = msg.deviceSentMessage) === null || _a === void 0 ? void 0 : _a.message) || msg;
|
|
184
|
-
|
|
185
|
-
//eslint-disable-next-line max-depth
|
|
186
|
-
try {
|
|
187
|
-
await repository.processSenderKeyDistributionMessage({
|
|
188
|
-
authorJid: author,
|
|
189
|
-
item: msg.senderKeyDistributionMessage
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
catch (err) {
|
|
193
|
-
logger.error({ key: fullMessage.key, err }, 'failed to decrypt message');
|
|
194
|
-
}
|
|
195
|
-
}
|
|
175
|
+
await processSenderKeyDistribution(msg);
|
|
196
176
|
if (fullMessage.message) {
|
|
197
177
|
Object.assign(fullMessage.message, msg);
|
|
198
178
|
}
|
|
@@ -210,7 +190,7 @@ const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
|
|
|
210
190
|
// if nothing was found to decrypt
|
|
211
191
|
if (!decryptables) {
|
|
212
192
|
fullMessage.messageStubType = WAProto_1.proto.WebMessageInfo.StubType.CIPHERTEXT;
|
|
213
|
-
fullMessage.messageStubParameters = [
|
|
193
|
+
fullMessage.messageStubParameters = [NO_MESSAGE_FOUND_ERROR_TEXT, JSON.stringify(stanza, generics_1.BufferJSON.replacer)];
|
|
214
194
|
}
|
|
215
195
|
}
|
|
216
196
|
};
|