@hbmodsofc/baileys 1.7.8 → 2.2.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/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.d.ts +8 -12
- package/lib/Defaults/index.js +124 -90
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/Group/group_cipher.d.ts +1 -0
- package/lib/Signal/Group/group_cipher.js +39 -28
- package/lib/Signal/Group/queue-job.d.ts +1 -0
- package/lib/Signal/Group/queue-job.js +57 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
- package/lib/Signal/Group/sender-chain-key.js +2 -9
- package/lib/Signal/Group/sender-key-distribution-message.js +3 -3
- package/lib/Signal/Group/sender-key-message.js +3 -3
- package/lib/Signal/Group/sender-key-state.d.ts +4 -4
- package/lib/Signal/Group/sender-key-state.js +16 -47
- package/lib/Signal/libsignal.d.ts +3 -7
- package/lib/Signal/libsignal.js +39 -224
- package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +3 -1
- 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} +16 -10
- package/lib/Socket/business.d.ts +78 -94
- package/lib/Socket/business.js +11 -130
- package/lib/Socket/chats.d.ts +233 -63
- package/lib/Socket/chats.js +184 -234
- package/lib/Socket/groups.d.ts +41 -62
- package/lib/Socket/groups.js +64 -76
- package/lib/Socket/hbmods.d.ts +253 -0
- package/lib/Socket/hbmods.js +1 -0
- package/lib/Socket/index.d.ts +83 -129
- package/lib/Socket/index.js +6 -13
- package/lib/Socket/messages-recv.d.ts +48 -59
- package/lib/Socket/messages-recv.js +371 -516
- package/lib/Socket/messages-send.d.ts +67 -86
- package/lib/Socket/messages-send.js +1 -1091
- package/lib/Socket/newsletter.d.ts +64 -76
- package/lib/Socket/newsletter.js +1 -184
- package/lib/Socket/registration.d.ts +267 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +13 -19
- package/lib/Socket/socket.js +1 -805
- package/lib/Socket/usync.d.ts +36 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Types/Auth.d.ts +10 -4
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +9 -29
- package/lib/Types/Chat.js +1 -7
- package/lib/Types/Contact.d.ts +1 -5
- package/lib/Types/Events.d.ts +14 -55
- package/lib/Types/GroupMetadata.d.ts +5 -15
- 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 +49 -75
- package/lib/Types/Message.js +7 -10
- package/lib/Types/Newsletter.d.ts +98 -129
- package/lib/Types/Newsletter.js +38 -33
- package/lib/Types/Product.d.ts +1 -1
- package/lib/Types/Signal.d.ts +1 -29
- package/lib/Types/Socket.d.ts +22 -48
- package/lib/Types/State.d.ts +2 -13
- package/lib/Types/State.js +0 -12
- package/lib/Types/USync.d.ts +1 -1
- package/lib/Types/index.d.ts +3 -10
- package/lib/Types/index.js +2 -2
- package/lib/Utils/auth-utils.d.ts +3 -3
- package/lib/Utils/auth-utils.js +102 -378
- package/lib/Utils/baileys-event-stream.js +1 -1
- package/lib/Utils/business.d.ts +2 -2
- package/lib/Utils/business.js +13 -19
- package/lib/Utils/chat-utils.d.ts +22 -21
- package/lib/Utils/chat-utils.js +154 -201
- package/lib/Utils/crypto.d.ts +19 -18
- package/lib/Utils/crypto.js +37 -78
- package/lib/Utils/decode-wa-message.d.ts +7 -34
- package/lib/Utils/decode-wa-message.js +66 -138
- package/lib/Utils/event-buffer.d.ts +8 -6
- package/lib/Utils/event-buffer.js +43 -81
- package/lib/Utils/generics.d.ts +27 -27
- package/lib/Utils/generics.js +133 -128
- package/lib/Utils/history.d.ts +5 -9
- package/lib/Utils/history.js +23 -17
- package/lib/Utils/index.d.ts +0 -2
- package/lib/Utils/index.js +0 -2
- package/lib/Utils/link-preview.d.ts +4 -4
- package/lib/Utils/link-preview.js +12 -40
- package/lib/Utils/logger.d.ts +3 -11
- package/lib/Utils/lt-hash.d.ts +8 -8
- package/lib/Utils/lt-hash.js +24 -23
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/make-mutex.js +2 -3
- package/lib/Utils/messages-media.d.ts +41 -37
- package/lib/Utils/messages-media.js +368 -252
- package/lib/Utils/messages.d.ts +15 -13
- package/lib/Utils/messages.js +261 -274
- package/lib/Utils/noise-handler.d.ts +15 -13
- package/lib/Utils/noise-handler.js +26 -20
- package/lib/Utils/process-message.d.ts +8 -9
- package/lib/Utils/process-message.js +93 -157
- package/lib/Utils/signal.d.ts +5 -6
- package/lib/Utils/signal.js +29 -37
- package/lib/Utils/use-multi-file-auth-state.d.ts +2 -1
- package/lib/Utils/use-multi-file-auth-state.js +7 -12
- package/lib/Utils/validate-connection.d.ts +6 -5
- package/lib/Utils/validate-connection.js +97 -39
- 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 +14 -28
- package/lib/WABinary/encode.d.ts +2 -1
- package/lib/WABinary/encode.js +147 -134
- package/lib/WABinary/generic-utils.d.ts +7 -4
- package/lib/WABinary/generic-utils.js +125 -40
- package/lib/WABinary/jid-utils.d.ts +8 -13
- package/lib/WABinary/jid-utils.js +16 -27
- package/lib/WAM/BinaryInfo.d.ts +11 -2
- package/lib/WAM/constants.d.ts +2 -3
- package/lib/WAM/constants.js +2359 -2252
- package/lib/WAM/encode.d.ts +2 -1
- package/lib/WAM/encode.js +11 -8
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +4 -3
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +5 -5
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +5 -5
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +6 -5
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +3 -4
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +3 -11
- package/lib/WAUSync/USyncQuery.d.ts +2 -2
- package/lib/WAUSync/USyncQuery.js +15 -19
- package/lib/WAUSync/USyncUser.d.ts +5 -5
- package/lib/WAUSync/index.d.ts +1 -1
- package/lib/WAUSync/index.js +1 -1
- package/package.json +102 -104
- package/WAProto/index.js +0 -37306
- package/lib/Signal/lid-mapping.d.ts +0 -26
- package/lib/Signal/lid-mapping.js +0 -146
- package/lib/Socket/communities.d.ts +0 -232
- package/lib/Socket/communities.js +0 -402
- package/lib/Socket/mex.d.ts +0 -2
- package/lib/Socket/mex.js +0 -45
- package/lib/Types/Bussines.d.ts +0 -24
- package/lib/Types/Bussines.js +0 -2
- package/lib/Utils/lidToJid-test.d.ts +0 -11
- package/lib/Utils/lidToJid-test.js +0 -27
- package/lib/Utils/message-retry-manager.d.ts +0 -81
- package/lib/Utils/message-retry-manager.js +0 -152
- /package/lib/Socket/Client/{types.js → abstract-socket-client.js} +0 -0
package/lib/Utils/business.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.uploadingNecessaryImages = exports.parseProductNode = exports.toProductNode = exports.parseOrderDetailsNode = exports.parseCollectionsNode = exports.parseCatalogNode = void 0;
|
|
4
|
-
exports.uploadingNecessaryImagesOfProduct = uploadingNecessaryImagesOfProduct;
|
|
3
|
+
exports.uploadingNecessaryImages = exports.uploadingNecessaryImagesOfProduct = exports.parseProductNode = exports.toProductNode = exports.parseOrderDetailsNode = exports.parseCollectionsNode = exports.parseCatalogNode = void 0;
|
|
5
4
|
const boom_1 = require("@hapi/boom");
|
|
6
5
|
const crypto_1 = require("crypto");
|
|
7
|
-
const fs_1 = require("fs");
|
|
8
|
-
const os_1 = require("os");
|
|
9
|
-
const path_1 = require("path");
|
|
10
6
|
const WABinary_1 = require("../WABinary");
|
|
11
|
-
const generics_1 = require("./generics");
|
|
12
7
|
const messages_media_1 = require("./messages-media");
|
|
13
8
|
const parseCatalogNode = (node) => {
|
|
14
9
|
const catalogNode = (0, WABinary_1.getBinaryNodeChild)(node, 'product_catalog');
|
|
@@ -16,7 +11,9 @@ const parseCatalogNode = (node) => {
|
|
|
16
11
|
const paging = (0, WABinary_1.getBinaryNodeChild)(catalogNode, 'paging');
|
|
17
12
|
return {
|
|
18
13
|
products,
|
|
19
|
-
nextPageCursor: paging
|
|
14
|
+
nextPageCursor: paging
|
|
15
|
+
? (0, WABinary_1.getBinaryNodeChildString)(paging, 'after')
|
|
16
|
+
: undefined
|
|
20
17
|
};
|
|
21
18
|
};
|
|
22
19
|
exports.parseCatalogNode = parseCatalogNode;
|
|
@@ -55,7 +52,7 @@ const parseOrderDetailsNode = (node) => {
|
|
|
55
52
|
const orderDetails = {
|
|
56
53
|
price: {
|
|
57
54
|
total: +(0, WABinary_1.getBinaryNodeChildString)(priceNode, 'total'),
|
|
58
|
-
currency: (0, WABinary_1.getBinaryNodeChildString)(priceNode, 'currency')
|
|
55
|
+
currency: (0, WABinary_1.getBinaryNodeChildString)(priceNode, 'currency'),
|
|
59
56
|
},
|
|
60
57
|
products
|
|
61
58
|
};
|
|
@@ -167,7 +164,7 @@ const parseProductNode = (productNode) => {
|
|
|
167
164
|
id,
|
|
168
165
|
imageUrls: parseImageUrls(mediaNode),
|
|
169
166
|
reviewStatus: {
|
|
170
|
-
whatsapp: (0, WABinary_1.getBinaryNodeChildString)(statusInfoNode, 'status')
|
|
167
|
+
whatsapp: (0, WABinary_1.getBinaryNodeChildString)(statusInfoNode, 'status'),
|
|
171
168
|
},
|
|
172
169
|
availability: 'in stock',
|
|
173
170
|
name: (0, WABinary_1.getBinaryNodeChildString)(productNode, 'name'),
|
|
@@ -176,7 +173,7 @@ const parseProductNode = (productNode) => {
|
|
|
176
173
|
description: (0, WABinary_1.getBinaryNodeChildString)(productNode, 'description'),
|
|
177
174
|
price: +(0, WABinary_1.getBinaryNodeChildString)(productNode, 'price'),
|
|
178
175
|
currency: (0, WABinary_1.getBinaryNodeChildString)(productNode, 'currency'),
|
|
179
|
-
isHidden
|
|
176
|
+
isHidden,
|
|
180
177
|
};
|
|
181
178
|
return product;
|
|
182
179
|
};
|
|
@@ -187,12 +184,11 @@ exports.parseProductNode = parseProductNode;
|
|
|
187
184
|
async function uploadingNecessaryImagesOfProduct(product, waUploadToServer, timeoutMs = 30000) {
|
|
188
185
|
product = {
|
|
189
186
|
...product,
|
|
190
|
-
images: product.images
|
|
191
|
-
? await (0, exports.uploadingNecessaryImages)(product.images, waUploadToServer, timeoutMs)
|
|
192
|
-
: product.images
|
|
187
|
+
images: product.images ? await (0, exports.uploadingNecessaryImages)(product.images, waUploadToServer, timeoutMs) : product.images
|
|
193
188
|
};
|
|
194
189
|
return product;
|
|
195
190
|
}
|
|
191
|
+
exports.uploadingNecessaryImagesOfProduct = uploadingNecessaryImagesOfProduct;
|
|
196
192
|
/**
|
|
197
193
|
* Uploads images not already uploaded to WA's servers
|
|
198
194
|
*/
|
|
@@ -206,19 +202,17 @@ const uploadingNecessaryImages = async (images, waUploadToServer, timeoutMs = 30
|
|
|
206
202
|
}
|
|
207
203
|
const { stream } = await (0, messages_media_1.getStream)(img);
|
|
208
204
|
const hasher = (0, crypto_1.createHash)('sha256');
|
|
209
|
-
const
|
|
210
|
-
const encFileWriteStream = (0, fs_1.createWriteStream)(filePath);
|
|
205
|
+
const contentBlocks = [];
|
|
211
206
|
for await (const block of stream) {
|
|
212
207
|
hasher.update(block);
|
|
213
|
-
|
|
208
|
+
contentBlocks.push(block);
|
|
214
209
|
}
|
|
215
210
|
const sha = hasher.digest('base64');
|
|
216
|
-
const { directPath } = await waUploadToServer(
|
|
211
|
+
const { directPath } = await waUploadToServer((0, messages_media_1.toReadable)(Buffer.concat(contentBlocks)), {
|
|
217
212
|
mediaType: 'product-catalog-image',
|
|
218
213
|
fileEncSha256B64: sha,
|
|
219
214
|
timeoutMs
|
|
220
215
|
});
|
|
221
|
-
await fs_1.promises.unlink(filePath).catch(err => console.log('Error deleting temp file ', err));
|
|
222
216
|
return { url: (0, messages_media_1.getUrlFromDirectPath)(directPath) };
|
|
223
217
|
}));
|
|
224
218
|
return results;
|
|
@@ -235,6 +229,6 @@ const parseStatusInfo = (mediaNode) => {
|
|
|
235
229
|
const node = (0, WABinary_1.getBinaryNodeChild)(mediaNode, 'status_info');
|
|
236
230
|
return {
|
|
237
231
|
status: (0, WABinary_1.getBinaryNodeChildString)(node, 'status'),
|
|
238
|
-
canAppeal: (0, WABinary_1.getBinaryNodeChildString)(node, 'can_appeal') === 'true'
|
|
232
|
+
canAppeal: (0, WABinary_1.getBinaryNodeChildString)(node, 'can_appeal') === 'true',
|
|
239
233
|
};
|
|
240
234
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { AxiosRequestConfig } from 'axios';
|
|
3
|
+
import type { Logger } from 'pino';
|
|
4
|
+
import { proto } from '../../WAProto';
|
|
5
|
+
import { BaileysEventEmitter, ChatModification, ChatMutation, Contact, InitialAppStateSyncOptions, LTHashState, WAPatchCreate, WAPatchName } from '../Types';
|
|
6
|
+
import { BinaryNode } from '../WABinary';
|
|
6
7
|
type FetchAppStateSyncKey = (keyId: string) => Promise<proto.Message.IAppStateSyncKeyData | null | undefined>;
|
|
7
8
|
export type ChatMutationMap = {
|
|
8
9
|
[index: string]: ChatMutation;
|
|
@@ -13,7 +14,7 @@ export declare const encodeSyncdPatch: ({ type, index, syncAction, apiVersion, o
|
|
|
13
14
|
state: LTHashState;
|
|
14
15
|
}>;
|
|
15
16
|
export declare const decodeSyncdMutations: (msgMutations: (proto.ISyncdMutation | proto.ISyncdRecord)[], initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
|
|
16
|
-
hash: Buffer
|
|
17
|
+
hash: Buffer;
|
|
17
18
|
indexValueMap: {
|
|
18
19
|
[indexMacBase64: string]: {
|
|
19
20
|
valueMac: Uint8Array | Buffer;
|
|
@@ -21,50 +22,50 @@ export declare const decodeSyncdMutations: (msgMutations: (proto.ISyncdMutation
|
|
|
21
22
|
};
|
|
22
23
|
}>;
|
|
23
24
|
export declare const decodeSyncdPatch: (msg: proto.ISyncdPatch, name: WAPatchName, initialState: LTHashState, getAppStateSyncKey: FetchAppStateSyncKey, onMutation: (mutation: ChatMutation) => void, validateMacs: boolean) => Promise<{
|
|
24
|
-
hash: Buffer
|
|
25
|
+
hash: Buffer;
|
|
25
26
|
indexValueMap: {
|
|
26
27
|
[indexMacBase64: string]: {
|
|
27
28
|
valueMac: Uint8Array | Buffer;
|
|
28
29
|
};
|
|
29
30
|
};
|
|
30
31
|
}>;
|
|
31
|
-
export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosRequestConfig<
|
|
32
|
-
|
|
32
|
+
export declare const extractSyncdPatches: (result: BinaryNode, options: AxiosRequestConfig<any>) => Promise<{
|
|
33
|
+
critical_block: {
|
|
33
34
|
patches: proto.ISyncdPatch[];
|
|
34
35
|
hasMorePatches: boolean;
|
|
35
|
-
snapshot?: proto.ISyncdSnapshot;
|
|
36
|
+
snapshot?: proto.ISyncdSnapshot | undefined;
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
+
critical_unblock_low: {
|
|
38
39
|
patches: proto.ISyncdPatch[];
|
|
39
40
|
hasMorePatches: boolean;
|
|
40
|
-
snapshot?: proto.ISyncdSnapshot;
|
|
41
|
+
snapshot?: proto.ISyncdSnapshot | undefined;
|
|
41
42
|
};
|
|
42
|
-
|
|
43
|
+
regular_high: {
|
|
43
44
|
patches: proto.ISyncdPatch[];
|
|
44
45
|
hasMorePatches: boolean;
|
|
45
|
-
snapshot?: proto.ISyncdSnapshot;
|
|
46
|
+
snapshot?: proto.ISyncdSnapshot | undefined;
|
|
46
47
|
};
|
|
47
|
-
|
|
48
|
+
regular_low: {
|
|
48
49
|
patches: proto.ISyncdPatch[];
|
|
49
50
|
hasMorePatches: boolean;
|
|
50
|
-
snapshot?: proto.ISyncdSnapshot;
|
|
51
|
+
snapshot?: proto.ISyncdSnapshot | undefined;
|
|
51
52
|
};
|
|
52
53
|
regular: {
|
|
53
54
|
patches: proto.ISyncdPatch[];
|
|
54
55
|
hasMorePatches: boolean;
|
|
55
|
-
snapshot?: proto.ISyncdSnapshot;
|
|
56
|
+
snapshot?: proto.ISyncdSnapshot | undefined;
|
|
56
57
|
};
|
|
57
58
|
}>;
|
|
58
|
-
export declare const downloadExternalBlob: (blob: proto.IExternalBlobReference, options: AxiosRequestConfig<
|
|
59
|
-
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>;
|
|
60
61
|
export declare const decodeSyncdSnapshot: (name: WAPatchName, snapshot: proto.ISyncdSnapshot, getAppStateSyncKey: FetchAppStateSyncKey, minimumVersionNumber: number | undefined, validateMacs?: boolean) => Promise<{
|
|
61
62
|
state: LTHashState;
|
|
62
63
|
mutationMap: ChatMutationMap;
|
|
63
64
|
}>;
|
|
64
|
-
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<{
|
|
65
66
|
state: LTHashState;
|
|
66
67
|
mutationMap: ChatMutationMap;
|
|
67
68
|
}>;
|
|
68
69
|
export declare const chatModificationToAppPatch: (mod: ChatModification, jid: string) => WAPatchCreate;
|
|
69
|
-
export declare const processSyncAction: (syncAction: ChatMutation, ev: BaileysEventEmitter, me: Contact, initialSyncOpts?: InitialAppStateSyncOptions, logger?:
|
|
70
|
+
export declare const processSyncAction: (syncAction: ChatMutation, ev: BaileysEventEmitter, me: Contact, initialSyncOpts?: InitialAppStateSyncOptions, logger?: Logger) => void;
|
|
70
71
|
export {};
|