@genuxofficial/baileys 2.0.0 → 3.0.0
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 +1 -1
- package/WAProto/WAProto.proto +4633 -0
- package/engine-requirements.js +1 -1
- package/lib/Defaults/index.d.ts +5 -3
- package/lib/Defaults/index.js +7 -7
- package/lib/Signal/libsignal.js +9 -18
- package/lib/Socket/Client/types.d.ts +2 -0
- package/lib/Socket/Client/websocket.js +1 -1
- package/lib/Socket/business.d.ts +40 -38
- package/lib/Socket/chats.d.ts +17 -20
- package/lib/Socket/chats.js +1 -85
- package/lib/Socket/groups.d.ts +25 -28
- package/lib/Socket/groups.js +9 -10
- package/lib/Socket/index.d.ts +46 -44
- package/lib/Socket/messages-recv.d.ts +37 -36
- package/lib/Socket/messages-recv.js +14 -26
- package/lib/Socket/messages-send.d.ts +35 -33
- package/lib/Socket/messages-send.js +10 -8
- package/lib/Socket/newsletter.d.ts +28 -31
- package/lib/Socket/newsletter.js +21 -17
- package/lib/Socket/socket.d.ts +7 -5
- package/lib/Socket/socket.js +1 -1
- package/lib/Socket/usync.d.ts +11 -9
- package/lib/Socket/usync.js +15 -10
- package/lib/Store/make-in-memory-store.d.ts +1 -1
- package/lib/Store/make-ordered-dictionary.d.ts +1 -1
- package/lib/Types/Auth.d.ts +2 -0
- package/lib/Types/Chat.d.ts +2 -8
- package/lib/Types/Contact.d.ts +0 -5
- package/lib/Types/GroupMetadata.d.ts +4 -5
- package/lib/Types/Label.d.ts +0 -11
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Message.d.ts +27 -2
- package/lib/Types/Newsletter.js +2 -2
- package/lib/Types/Socket.d.ts +2 -0
- package/lib/Types/index.js +1 -1
- package/lib/Utils/auth-utils.js +3 -3
- package/lib/Utils/business.js +17 -5
- package/lib/Utils/chat-utils.d.ts +10 -8
- package/lib/Utils/chat-utils.js +0 -27
- package/lib/Utils/crypto.d.ts +16 -14
- package/lib/Utils/crypto.js +22 -34
- package/lib/Utils/decode-wa-message.d.ts +1 -1
- package/lib/Utils/decode-wa-message.js +16 -31
- package/lib/Utils/generics.d.ts +8 -33
- package/lib/Utils/generics.js +12 -98
- package/lib/Utils/link-preview.js +1 -34
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/messages-media.d.ts +19 -29
- package/lib/Utils/messages-media.js +87 -151
- package/lib/Utils/messages.d.ts +8 -5
- package/lib/Utils/messages.js +20 -28
- package/lib/Utils/noise-handler.d.ts +6 -4
- package/lib/Utils/process-message.js +2 -2
- package/lib/Utils/validate-connection.d.ts +2 -2
- package/lib/WABinary/decode.d.ts +4 -2
- package/lib/WABinary/decode.js +7 -17
- package/lib/WABinary/encode.d.ts +3 -1
- package/lib/WABinary/encode.js +7 -17
- package/lib/WABinary/generic-utils.d.ts +6 -6
- package/lib/WABinary/generic-utils.js +36 -21
- package/lib/WABinary/jid-utils.d.ts +6 -2
- package/lib/WABinary/jid-utils.js +5 -1
- package/lib/WAM/BinaryInfo.d.ts +12 -2
- package/lib/WAM/encode.d.ts +3 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +23 -14
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -2
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +1 -1
- package/lib/WAUSync/USyncQuery.js +13 -17
- package/package.json +59 -53
- package/lib/Store/make-cache-manager-store.d.ts +0 -14
- package/lib/Store/make-cache-manager-store.js +0 -83
package/engine-requirements.js
CHANGED
package/lib/Defaults/index.d.ts
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
/// <reference types="node" />
|
1
3
|
import { proto } from '../../WAProto';
|
2
4
|
import type { MediaType, SocketConfig } from '../Types';
|
3
5
|
export declare const UNAUTHORIZED_CODES: number[];
|
@@ -8,8 +10,8 @@ export declare const PHONE_CONNECTION_CB = "CB:Pong";
|
|
8
10
|
export declare const WA_DEFAULT_EPHEMERAL: number;
|
9
11
|
export declare const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
|
10
12
|
export declare const DICT_VERSION = 2;
|
11
|
-
export declare const KEY_BUNDLE_TYPE: Buffer
|
12
|
-
export declare const NOISE_WA_HEADER: Buffer
|
13
|
+
export declare const KEY_BUNDLE_TYPE: Buffer;
|
14
|
+
export declare const NOISE_WA_HEADER: Buffer;
|
13
15
|
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
14
16
|
export declare const URL_REGEX: RegExp;
|
15
17
|
export declare const WA_CERT_DETAILS: {
|
@@ -40,7 +42,7 @@ export declare const MEDIA_HKDF_KEY_MAPPING: {
|
|
40
42
|
'payment-bg-image': string;
|
41
43
|
ptv: string;
|
42
44
|
};
|
43
|
-
export declare const MEDIA_KEYS:
|
45
|
+
export declare const MEDIA_KEYS: ("ppic" | "product" | "image" | "video" | "sticker" | "audio" | "gif" | "ptt" | "thumbnail-document" | "thumbnail-image" | "thumbnail-link" | "thumbnail-video" | "md-app-state" | "md-msg-hist" | "document" | "product-catalog-image" | "payment-bg-image" | "ptv")[];
|
44
46
|
export declare const MIN_PREKEY_COUNT = 5;
|
45
47
|
export declare const INITIAL_PREKEY_COUNT = 30;
|
46
48
|
export declare const DEFAULT_CACHE_TTLS: {
|
package/lib/Defaults/index.js
CHANGED
@@ -33,19 +33,19 @@ exports.PROCESSABLE_HISTORY_TYPES = [
|
|
33
33
|
];
|
34
34
|
exports.DEFAULT_CONNECTION_CONFIG = {
|
35
35
|
version: baileys_version_json_1.version,
|
36
|
-
browser: Utils_1.Browsers.ubuntu('
|
36
|
+
browser: Utils_1.Browsers.ubuntu('Chrome'),
|
37
37
|
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
38
38
|
connectTimeoutMs: 20000,
|
39
39
|
keepAliveIntervalMs: 30000,
|
40
40
|
logger: logger_1.default.child({ class: 'baileys' }),
|
41
41
|
printQRInTerminal: false,
|
42
42
|
emitOwnEvents: true,
|
43
|
-
defaultQueryTimeoutMs:
|
43
|
+
defaultQueryTimeoutMs: 60000,
|
44
44
|
customUploadHosts: [],
|
45
45
|
retryRequestDelayMs: 250,
|
46
46
|
maxMsgRetryCount: 5,
|
47
|
-
fireInitQueries: true,
|
48
47
|
ignoreMsgLoading: false,
|
48
|
+
fireInitQueries: true,
|
49
49
|
auth: undefined,
|
50
50
|
markOnlineOnConnect: true,
|
51
51
|
syncFullHistory: false,
|
@@ -54,7 +54,7 @@ exports.DEFAULT_CONNECTION_CONFIG = {
|
|
54
54
|
shouldIgnoreJid: () => false,
|
55
55
|
linkPreviewImageThumbnailWidth: 192,
|
56
56
|
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
|
57
|
-
generateHighQualityLinkPreview:
|
57
|
+
generateHighQualityLinkPreview: false,
|
58
58
|
options: {},
|
59
59
|
appStateMacVerification: {
|
60
60
|
patch: false,
|
@@ -100,8 +100,8 @@ exports.MEDIA_KEYS = Object.keys(exports.MEDIA_PATH_MAP);
|
|
100
100
|
exports.MIN_PREKEY_COUNT = 5;
|
101
101
|
exports.INITIAL_PREKEY_COUNT = 30;
|
102
102
|
exports.DEFAULT_CACHE_TTLS = {
|
103
|
-
SIGNAL_STORE: 5 * 60,
|
104
|
-
MSG_RETRY: 60 * 60,
|
105
|
-
CALL_OFFER: 5 * 60,
|
103
|
+
SIGNAL_STORE: 5 * 60,
|
104
|
+
MSG_RETRY: 60 * 60,
|
105
|
+
CALL_OFFER: 5 * 60,
|
106
106
|
USER_DEVICES: 5 * 60, // 5 minutes
|
107
107
|
};
|
package/lib/Signal/libsignal.js
CHANGED
@@ -15,25 +15,15 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
15
15
|
}) : function(o, v) {
|
16
16
|
o["default"] = v;
|
17
17
|
});
|
18
|
-
var __importStar = (this && this.__importStar) ||
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
return ownKeys(o);
|
26
|
-
};
|
27
|
-
return function (mod) {
|
28
|
-
if (mod && mod.__esModule) return mod;
|
29
|
-
var result = {};
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
-
__setModuleDefault(result, mod);
|
32
|
-
return result;
|
33
|
-
};
|
34
|
-
})();
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
35
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
36
|
-
exports.makeLibSignalRepository =
|
26
|
+
exports.makeLibSignalRepository = void 0;
|
37
27
|
const libsignal = __importStar(require("libsignal"));
|
38
28
|
const WASignalGroup_1 = require("../../WASignalGroup");
|
39
29
|
const Utils_1 = require("../Utils");
|
@@ -101,6 +91,7 @@ function makeLibSignalRepository(auth) {
|
|
101
91
|
},
|
102
92
|
};
|
103
93
|
}
|
94
|
+
exports.makeLibSignalRepository = makeLibSignalRepository;
|
104
95
|
const jidToSignalProtocolAddress = (jid) => {
|
105
96
|
const { user, device } = (0, WABinary_1.jidDecode)(jid);
|
106
97
|
return new libsignal.ProtocolAddress(user, device || 0);
|
@@ -38,7 +38,7 @@ class WebSocketClient extends types_1.AbstractSocketClient {
|
|
38
38
|
headers: (_a = this.config.options) === null || _a === void 0 ? void 0 : _a.headers,
|
39
39
|
handshakeTimeout: this.config.connectTimeoutMs,
|
40
40
|
timeout: this.config.connectTimeoutMs,
|
41
|
-
agent: this.config.agent
|
41
|
+
agent: this.config.agent,
|
42
42
|
});
|
43
43
|
this.socket.setMaxListeners(0);
|
44
44
|
const events = ['close', 'error', 'upgrade', 'message', 'open', 'ping', 'pong', 'unexpected-response'];
|
package/lib/Socket/business.d.ts
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
/// <reference types="long" />
|
2
|
+
/// <reference types="node" />
|
3
|
+
/// <reference types="node" />
|
1
4
|
import { GetCatalogOptions, ProductCreate, ProductUpdate, SocketConfig } from '../Types';
|
2
5
|
import { BinaryNode } from '../WABinary';
|
3
6
|
export declare const makeBusinessSocket: (config: SocketConfig) => {
|
@@ -15,7 +18,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
15
18
|
deleted: number;
|
16
19
|
}>;
|
17
20
|
productUpdate: (productId: string, update: ProductUpdate) => Promise<import("../Types").Product>;
|
18
|
-
sendMessageAck: ({ tag, attrs, content }: BinaryNode, errorCode?: number) => Promise<void>;
|
21
|
+
sendMessageAck: ({ tag, attrs, content }: BinaryNode, errorCode?: number | undefined) => Promise<void>;
|
19
22
|
sendRetryRequest: (node: BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
|
20
23
|
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
21
24
|
offerCall: (toJid: string, isVideo?: boolean) => Promise<{
|
@@ -23,14 +26,16 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
23
26
|
toJid: string;
|
24
27
|
isVideo: boolean;
|
25
28
|
}>;
|
26
|
-
fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | Long) => Promise<string>;
|
29
|
+
fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | import("long").Long) => Promise<string>;
|
27
30
|
requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
|
28
31
|
getPrivacyTokens: (jids: string[]) => Promise<any>;
|
29
32
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
30
33
|
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
31
34
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
32
35
|
sendReceipts: (keys: import("../Types").WAMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
33
|
-
getButtonArgs: (message: import("../Types").WAProto.IMessage) =>
|
36
|
+
getButtonArgs: (message: import("../Types").WAProto.IMessage) => {
|
37
|
+
[key: string]: string;
|
38
|
+
};
|
34
39
|
readMessages: (keys: import("../Types").WAMessageKey[]) => Promise<void>;
|
35
40
|
refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
|
36
41
|
waUploadToServer: import("../Types").WAMediaUploadFunction;
|
@@ -38,7 +43,9 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
38
43
|
[_: string]: string;
|
39
44
|
}>;
|
40
45
|
getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
|
41
|
-
createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?:
|
46
|
+
createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: {
|
47
|
+
[key: string]: string;
|
48
|
+
} | undefined) => Promise<{
|
42
49
|
nodes: BinaryNode[];
|
43
50
|
shouldIncludeDeviceIdentity: boolean;
|
44
51
|
}>;
|
@@ -49,7 +56,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
49
56
|
duration: string;
|
50
57
|
}>;
|
51
58
|
newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
|
52
|
-
newsletterUpdateDescription: (jid: string, description?: string) => Promise<void>;
|
59
|
+
newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
|
53
60
|
newsletterUpdateName: (jid: string, name: string) => Promise<void>;
|
54
61
|
newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
55
62
|
newsletterRemovePicture: (jid: string) => Promise<void>;
|
@@ -57,15 +64,15 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
57
64
|
newsletterFollow: (jid: string) => Promise<void>;
|
58
65
|
newsletterUnmute: (jid: string) => Promise<void>;
|
59
66
|
newsletterMute: (jid: string) => Promise<void>;
|
60
|
-
newsletterCreate: (name: string, description?: string, picture?: import("../Types").WAMediaUpload) => Promise<import("../Types").NewsletterMetadata>;
|
61
|
-
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole) => Promise<import("../Types").NewsletterMetadata>;
|
67
|
+
newsletterCreate: (name: string, description?: string | undefined, picture?: import("../Types").WAMediaUpload | undefined) => Promise<import("../Types").NewsletterMetadata>;
|
68
|
+
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
|
62
69
|
newsletterAdminCount: (jid: string) => Promise<number>;
|
63
70
|
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
64
71
|
newsletterDemote: (jid: string, user: string) => Promise<void>;
|
65
72
|
newsletterDelete: (jid: string) => Promise<void>;
|
66
|
-
newsletterReactMessage: (jid: string, server_id: string, code?: string) => Promise<void>;
|
67
|
-
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
68
|
-
newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
73
|
+
newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>;
|
74
|
+
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
75
|
+
newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
69
76
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
70
77
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
71
78
|
groupLeave: (id: string) => Promise<void>;
|
@@ -73,7 +80,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
73
80
|
groupRequestParticipantsList: (jid: string) => Promise<{
|
74
81
|
[key: string]: string;
|
75
82
|
}[]>;
|
76
|
-
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "
|
83
|
+
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "reject" | "approve") => Promise<{
|
77
84
|
status: string;
|
78
85
|
jid: string;
|
79
86
|
}[]>;
|
@@ -82,7 +89,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
82
89
|
jid: string;
|
83
90
|
content: BinaryNode;
|
84
91
|
}[]>;
|
85
|
-
groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
|
92
|
+
groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
|
86
93
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
87
94
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
88
95
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
@@ -90,32 +97,30 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
90
97
|
groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<any>;
|
91
98
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
92
99
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
93
|
-
groupSettingUpdate: (jid: string, setting: "announcement" | "
|
94
|
-
groupMemberAddMode: (jid: string, mode: "
|
100
|
+
groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
|
101
|
+
groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>;
|
95
102
|
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
|
96
103
|
groupFetchAllParticipating: () => Promise<{
|
97
104
|
[_: string]: import("../Types").GroupMetadata;
|
98
105
|
}>;
|
99
106
|
getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
|
100
107
|
processingMutex: {
|
101
|
-
mutex<T>(code: () =>
|
108
|
+
mutex<T>(code: () => T | Promise<T>): Promise<T>;
|
102
109
|
};
|
103
110
|
upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
|
104
111
|
appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
|
105
|
-
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
|
106
|
-
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
|
107
|
-
profilePictureUrl: (jid: string, type?: "
|
112
|
+
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
|
113
|
+
presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
|
114
|
+
profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;
|
108
115
|
onWhatsApp: (...jids: string[]) => Promise<{
|
109
116
|
jid: string;
|
110
117
|
exists: unknown;
|
111
118
|
lid: unknown;
|
112
119
|
}[] | undefined>;
|
113
120
|
fetchBlocklist: () => Promise<string[]>;
|
114
|
-
fetchDisappearingDuration: (...jids: string[]) => Promise<import("
|
115
|
-
fetchStatus: (...jids: string[]) => Promise<import("
|
121
|
+
fetchDisappearingDuration: (...jids: string[]) => Promise<import("../index").USyncQueryResultList[] | undefined>;
|
122
|
+
fetchStatus: (...jids: string[]) => Promise<import("../index").USyncQueryResultList[] | undefined>;
|
116
123
|
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
117
|
-
updateProfilePictureFull: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
118
|
-
updateProfilePictureFull2: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
119
124
|
removeProfilePicture: (jid: string) => Promise<void>;
|
120
125
|
updateProfileStatus: (status: string) => Promise<void>;
|
121
126
|
updateProfileName: (name: string) => Promise<void>;
|
@@ -129,29 +134,26 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
129
134
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
130
135
|
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
131
136
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
132
|
-
getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile
|
137
|
+
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
|
133
138
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
134
139
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
135
|
-
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number |
|
136
|
-
addOrEditContact: (jid: string, contact: import("../Types").ContactAction) => Promise<void>;
|
137
|
-
removeContact: (jid: string) => Promise<void>;
|
138
|
-
addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
|
140
|
+
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
|
139
141
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
140
142
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
141
143
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
142
144
|
removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
143
145
|
star: (jid: string, messages: {
|
144
146
|
id: string;
|
145
|
-
fromMe?: boolean;
|
147
|
+
fromMe?: boolean | undefined;
|
146
148
|
}[], star: boolean) => Promise<void>;
|
147
|
-
executeUSyncQuery: (usyncQuery: import("
|
149
|
+
executeUSyncQuery: (usyncQuery: import("../index").USyncQuery) => Promise<import("../index").USyncQueryResult | undefined>;
|
148
150
|
type: "md";
|
149
|
-
ws: import("./Client").WebSocketClient;
|
151
|
+
ws: import("./Client/websocket").WebSocketClient;
|
150
152
|
ev: import("../Types").BaileysEventEmitter & {
|
151
|
-
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (
|
153
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
152
154
|
buffer(): void;
|
153
|
-
createBufferedFunction<A extends any[],
|
154
|
-
flush(force?: boolean): boolean;
|
155
|
+
createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>;
|
156
|
+
flush(force?: boolean | undefined): boolean;
|
155
157
|
isBuffering(): boolean;
|
156
158
|
};
|
157
159
|
authState: {
|
@@ -161,17 +163,17 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
161
163
|
signalRepository: import("../Types").SignalRepository;
|
162
164
|
user: import("../Types").Contact | undefined;
|
163
165
|
generateMessageTag: () => string;
|
164
|
-
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
165
|
-
waitForMessage: <
|
166
|
+
query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<any>;
|
167
|
+
waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
166
168
|
waitForSocketOpen: () => Promise<void>;
|
167
169
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
168
170
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
169
|
-
logout: (msg?: string) => Promise<void>;
|
171
|
+
logout: (msg?: string | undefined) => Promise<void>;
|
170
172
|
end: (error: Error | undefined) => void;
|
171
|
-
onUnexpectedError: (err: Error | import("@hapi/boom").Boom
|
173
|
+
onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
|
172
174
|
uploadPreKeys: (count?: number) => Promise<void>;
|
173
175
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
174
176
|
requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
|
175
|
-
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
177
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number | undefined) => Promise<void>;
|
176
178
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
177
179
|
};
|
package/lib/Socket/chats.d.ts
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
/// <reference types="node" />
|
1
3
|
import { Boom } from '@hapi/boom';
|
2
4
|
import { proto } from '../../WAProto';
|
3
|
-
import { BotListInfo, ChatModification,
|
4
|
-
import { LabelActionBody } from '../Types/Label';
|
5
|
+
import { BotListInfo, ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAPatchCreate, WAPresence, WAPrivacyCallValue, WAPrivacyGroupAddValue, WAPrivacyMessagesValue, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types';
|
5
6
|
import { BinaryNode } from '../WABinary';
|
6
7
|
import { USyncQuery } from '../WAUSync';
|
7
8
|
export declare const makeChatsSocket: (config: SocketConfig) => {
|
8
9
|
getBotListV2: () => Promise<BotListInfo[]>;
|
9
10
|
processingMutex: {
|
10
|
-
mutex<T>(code: () =>
|
11
|
+
mutex<T>(code: () => T | Promise<T>): Promise<T>;
|
11
12
|
};
|
12
13
|
fetchPrivacySettings: (force?: boolean) => Promise<{
|
13
14
|
[_: string]: string;
|
@@ -16,7 +17,7 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
16
17
|
appPatch: (patchCreate: WAPatchCreate) => Promise<void>;
|
17
18
|
sendPresenceUpdate: (type: WAPresence, toJid?: string) => Promise<void>;
|
18
19
|
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
|
19
|
-
profilePictureUrl: (jid: string, type?:
|
20
|
+
profilePictureUrl: (jid: string, type?: 'preview' | 'image', timeoutMs?: number) => Promise<string | undefined>;
|
20
21
|
onWhatsApp: (...jids: string[]) => Promise<{
|
21
22
|
jid: string;
|
22
23
|
exists: unknown;
|
@@ -26,12 +27,10 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
26
27
|
fetchDisappearingDuration: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
|
27
28
|
fetchStatus: (...jids: string[]) => Promise<import("../WAUSync").USyncQueryResultList[] | undefined>;
|
28
29
|
updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>;
|
29
|
-
updateProfilePictureFull: (jid: string, content: WAMediaUpload) => Promise<void>;
|
30
|
-
updateProfilePictureFull2: (jid: string, content: WAMediaUpload) => Promise<void>;
|
31
30
|
removeProfilePicture: (jid: string) => Promise<void>;
|
32
31
|
updateProfileStatus: (status: string) => Promise<void>;
|
33
32
|
updateProfileName: (name: string) => Promise<void>;
|
34
|
-
updateBlockStatus: (jid: string, action:
|
33
|
+
updateBlockStatus: (jid: string, action: 'block' | 'unblock') => Promise<void>;
|
35
34
|
updateCallPrivacy: (value: WAPrivacyCallValue) => Promise<void>;
|
36
35
|
updateMessagesPrivacy: (value: WAPrivacyMessagesValue) => Promise<void>;
|
37
36
|
updateLastSeenPrivacy: (value: WAPrivacyValue) => Promise<void>;
|
@@ -44,10 +43,7 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
44
43
|
getBusinessProfile: (jid: string) => Promise<WABusinessProfile | void>;
|
45
44
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
46
45
|
chatModify: (mod: ChatModification, jid: string) => Promise<void>;
|
47
|
-
cleanDirtyBits: (type:
|
48
|
-
addOrEditContact: (jid: string, contact: ContactAction) => Promise<void>;
|
49
|
-
removeContact: (jid: string) => Promise<void>;
|
50
|
-
addLabel: (jid: string, labels: LabelActionBody) => Promise<void>;
|
46
|
+
cleanDirtyBits: (type: 'account_sync' | 'groups', fromTimestamp?: number | string) => Promise<void>;
|
51
47
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
52
48
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
53
49
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
@@ -58,12 +54,12 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
58
54
|
}[], star: boolean) => Promise<void>;
|
59
55
|
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
|
60
56
|
type: "md";
|
61
|
-
ws: import("./Client").WebSocketClient;
|
57
|
+
ws: import("./Client/websocket").WebSocketClient;
|
62
58
|
ev: import("../Types").BaileysEventEmitter & {
|
63
|
-
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (
|
59
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
64
60
|
buffer(): void;
|
65
|
-
createBufferedFunction<A extends any[],
|
66
|
-
flush(force?: boolean): boolean;
|
61
|
+
createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>;
|
62
|
+
flush(force?: boolean | undefined): boolean;
|
67
63
|
isBuffering(): boolean;
|
68
64
|
};
|
69
65
|
authState: {
|
@@ -73,17 +69,18 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
73
69
|
signalRepository: import("../Types").SignalRepository;
|
74
70
|
user: import("../Types").Contact | undefined;
|
75
71
|
generateMessageTag: () => string;
|
76
|
-
query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
|
77
|
-
waitForMessage: <
|
72
|
+
query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<any>;
|
73
|
+
waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<any>;
|
78
74
|
waitForSocketOpen: () => Promise<void>;
|
79
75
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
76
|
+
/** sending non-abt props may fix QR scan fail if server expects */
|
80
77
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
81
|
-
logout: (msg?: string) => Promise<void>;
|
78
|
+
logout: (msg?: string | undefined) => Promise<void>;
|
82
79
|
end: (error: Error | undefined) => void;
|
83
|
-
onUnexpectedError: (err: Error | Boom
|
80
|
+
onUnexpectedError: (err: Error | Boom<any>, msg: string) => void;
|
84
81
|
uploadPreKeys: (count?: number) => Promise<void>;
|
85
82
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
86
83
|
requestPairingCode: (phoneNumber: string, pairCode: string) => Promise<string>;
|
87
|
-
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
84
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number | undefined) => Promise<void>;
|
88
85
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
89
86
|
};
|
package/lib/Socket/chats.js
CHANGED
@@ -26,7 +26,7 @@ const makeChatsSocket = (config) => {
|
|
26
26
|
/** this mutex ensures that the notifications (receipts, messages etc.) are processed in order */
|
27
27
|
const processingMutex = (0, make_mutex_1.makeMutex)();
|
28
28
|
const placeholderResendCache = config.placeholderResendCache || new node_cache_1.default({
|
29
|
-
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
|
29
|
+
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
|
30
30
|
useClones: false
|
31
31
|
});
|
32
32
|
if (!config.placeholderResendCache) {
|
@@ -206,59 +206,6 @@ const makeChatsSocket = (config) => {
|
|
206
206
|
]
|
207
207
|
});
|
208
208
|
};
|
209
|
-
/** update the profile picture for yourself or a group as Full */
|
210
|
-
const updateProfilePictureFull = async (jid, content) => {
|
211
|
-
let targetJid;
|
212
|
-
if (!jid) {
|
213
|
-
throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
|
214
|
-
}
|
215
|
-
if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
|
216
|
-
targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
|
217
|
-
}
|
218
|
-
const { img } = await (0, Utils_1.generateProfilePictureFull)(content);
|
219
|
-
await query({
|
220
|
-
tag: 'iq',
|
221
|
-
attrs: {
|
222
|
-
target: targetJid,
|
223
|
-
to: WABinary_1.S_WHATSAPP_NET,
|
224
|
-
type: 'set',
|
225
|
-
xmlns: 'w:profile:picture'
|
226
|
-
},
|
227
|
-
content: [
|
228
|
-
{
|
229
|
-
tag: 'picture',
|
230
|
-
attrs: { type: 'image' },
|
231
|
-
content: img
|
232
|
-
}
|
233
|
-
]
|
234
|
-
});
|
235
|
-
};
|
236
|
-
const updateProfilePictureFull2 = async (jid, content) => {
|
237
|
-
let targetJid;
|
238
|
-
if (!jid) {
|
239
|
-
throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
|
240
|
-
}
|
241
|
-
if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
|
242
|
-
targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
|
243
|
-
}
|
244
|
-
const { preview } = await (0, Utils_1.generateProfilePictureFP)(content);
|
245
|
-
await query({
|
246
|
-
tag: 'iq',
|
247
|
-
attrs: {
|
248
|
-
target: targetJid,
|
249
|
-
to: WABinary_1.S_WHATSAPP_NET,
|
250
|
-
type: 'set',
|
251
|
-
xmlns: 'w:profile:picture'
|
252
|
-
},
|
253
|
-
content: [
|
254
|
-
{
|
255
|
-
tag: 'picture',
|
256
|
-
attrs: { type: 'image' },
|
257
|
-
content: preview
|
258
|
-
}
|
259
|
-
]
|
260
|
-
});
|
261
|
-
};
|
262
209
|
/** remove the profile picture for yourself or a group */
|
263
210
|
const removeProfilePicture = async (jid) => {
|
264
211
|
let targetJid;
|
@@ -725,32 +672,6 @@ const makeChatsSocket = (config) => {
|
|
725
672
|
}
|
726
673
|
}, jid);
|
727
674
|
};
|
728
|
-
/**
|
729
|
-
* Add or Edit Contact
|
730
|
-
*/
|
731
|
-
const addOrEditContact = (jid, contact) => {
|
732
|
-
return chatModify({
|
733
|
-
contact
|
734
|
-
}, jid);
|
735
|
-
};
|
736
|
-
/**
|
737
|
-
* Remove Contact
|
738
|
-
*/
|
739
|
-
const removeContact = (jid) => {
|
740
|
-
return chatModify({
|
741
|
-
contact: null
|
742
|
-
}, jid);
|
743
|
-
};
|
744
|
-
/**
|
745
|
-
* Adds label
|
746
|
-
*/
|
747
|
-
const addLabel = (jid, labels) => {
|
748
|
-
return chatModify({
|
749
|
-
addLabel: {
|
750
|
-
...labels
|
751
|
-
}
|
752
|
-
}, jid);
|
753
|
-
};
|
754
675
|
/**
|
755
676
|
* Adds label for the chats
|
756
677
|
*/
|
@@ -922,8 +843,6 @@ const makeChatsSocket = (config) => {
|
|
922
843
|
fetchDisappearingDuration,
|
923
844
|
fetchStatus,
|
924
845
|
updateProfilePicture,
|
925
|
-
updateProfilePictureFull,
|
926
|
-
updateProfilePictureFull2,
|
927
846
|
removeProfilePicture,
|
928
847
|
updateProfileStatus,
|
929
848
|
updateProfileName,
|
@@ -941,9 +860,6 @@ const makeChatsSocket = (config) => {
|
|
941
860
|
resyncAppState,
|
942
861
|
chatModify,
|
943
862
|
cleanDirtyBits,
|
944
|
-
addOrEditContact,
|
945
|
-
removeContact,
|
946
|
-
addLabel,
|
947
863
|
addChatLabel,
|
948
864
|
removeChatLabel,
|
949
865
|
addMessageLabel,
|