@hbmodsofc/baileys 2.4.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/README.MD +220 -1198
- package/WAProto/GenerateStatics.sh +4 -0
- package/WAProto/WAProto.proto +5619 -0
- package/engine-requirements.js +1 -1
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.js +97 -122
- package/lib/Defaults/phonenumber_mcc.json +223 -0
- package/lib/Socket/Client/index.js +2 -3
- package/lib/Socket/Client/{web-socket-client.js → websocket.js} +54 -5
- package/lib/Socket/business.js +8 -2
- package/lib/Socket/chats.js +455 -288
- package/lib/Socket/communities.js +441 -0
- package/lib/Socket/groups.js +38 -23
- package/lib/Socket/hbmods.js +374 -406
- package/lib/Socket/index.js +43 -11
- package/lib/Socket/messages-recv.js +24 -69
- package/lib/Socket/messages-send.js +391 -419
- package/lib/Socket/newsletter.js +104 -190
- package/lib/Socket/socket.js +40 -54
- package/lib/Store/index.js +1 -3
- package/lib/Store/make-in-memory-store.js +27 -15
- package/lib/Store/make-ordered-dictionary.js +2 -2
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Message.js +0 -2
- package/lib/Types/Newsletter.js +18 -38
- package/lib/Types/index.js +2 -2
- package/lib/Utils/async-iterable.js +41 -0
- package/lib/Utils/audioToBuffer.js +29 -0
- package/lib/Utils/auth-utils.js +6 -13
- package/lib/Utils/baileys-event-stream.js +1 -1
- package/lib/Utils/browser-utils.js +35 -0
- package/lib/Utils/business.js +2 -2
- package/lib/Utils/chat-utils.js +36 -35
- package/lib/Utils/crypto.js +71 -29
- package/lib/Utils/decode-wa-message.js +65 -56
- package/lib/Utils/event-buffer.js +13 -9
- package/lib/Utils/generics.js +88 -84
- package/lib/Utils/history.js +4 -6
- package/lib/Utils/index.js +3 -0
- package/lib/Utils/link-preview.js +34 -1
- package/lib/Utils/lt-hash.js +6 -6
- package/lib/Utils/message-retry-manager.js +128 -0
- package/lib/Utils/messages-media.js +340 -246
- package/lib/Utils/messages.js +329 -192
- package/lib/Utils/noise-handler.js +18 -23
- package/lib/Utils/process-message.js +108 -25
- package/lib/Utils/resolveJid.js +52 -0
- package/lib/Utils/signal.js +26 -26
- package/lib/Utils/streamToBuffer.js +15 -0
- package/lib/Utils/use-multi-file-auth-state.js +3 -0
- package/lib/Utils/validate-connection.js +1 -3
- package/lib/WABinary/constants.js +1276 -13
- package/lib/WABinary/decode.js +26 -13
- package/lib/WABinary/encode.js +137 -152
- package/lib/WABinary/generic-utils.js +37 -125
- package/lib/WABinary/jid-utils.js +28 -5
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
- package/lib/index.js +53 -7
- package/package.json +112 -104
- package/lib/Defaults/index.d.ts +0 -53
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
- package/lib/Signal/Group/group-session-builder.d.ts +0 -14
- package/lib/Signal/Group/group_cipher.d.ts +0 -17
- package/lib/Signal/Group/index.d.ts +0 -11
- package/lib/Signal/Group/keyhelper.d.ts +0 -10
- package/lib/Signal/Group/queue-job.d.ts +0 -1
- package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
- package/lib/Signal/Group/sender-key-message.d.ts +0 -18
- package/lib/Signal/Group/sender-key-name.d.ts +0 -17
- package/lib/Signal/Group/sender-key-record.d.ts +0 -30
- package/lib/Signal/Group/sender-key-state.d.ts +0 -38
- package/lib/Signal/Group/sender-message-key.d.ts +0 -11
- package/lib/Signal/libsignal.d.ts +0 -3
- package/lib/Socket/Client/abstract-socket-client.d.ts +0 -17
- package/lib/Socket/Client/index.d.ts +0 -3
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/Client/web-socket-client.d.ts +0 -12
- package/lib/Socket/business.d.ts +0 -171
- package/lib/Socket/chats.d.ts +0 -267
- package/lib/Socket/groups.d.ts +0 -115
- package/lib/Socket/hbmods.d.ts +0 -254
- package/lib/Socket/index.d.ts +0 -173
- package/lib/Socket/messages-recv.d.ts +0 -161
- package/lib/Socket/messages-send.d.ts +0 -149
- package/lib/Socket/newsletter.d.ts +0 -134
- package/lib/Socket/registration.d.ts +0 -267
- package/lib/Socket/registration.js +0 -166
- package/lib/Socket/socket.d.ts +0 -43
- package/lib/Socket/usync.d.ts +0 -36
- package/lib/Store/index.d.ts +0 -3
- package/lib/Store/make-cache-manager-store.d.ts +0 -13
- package/lib/Store/make-cache-manager-store.js +0 -83
- package/lib/Store/make-in-memory-store.d.ts +0 -118
- package/lib/Store/make-ordered-dictionary.d.ts +0 -13
- package/lib/Store/object-repository.d.ts +0 -10
- package/lib/Types/Auth.d.ts +0 -110
- package/lib/Types/Call.d.ts +0 -13
- package/lib/Types/Chat.d.ts +0 -102
- package/lib/Types/Contact.d.ts +0 -19
- package/lib/Types/Events.d.ts +0 -157
- package/lib/Types/GroupMetadata.d.ts +0 -55
- package/lib/Types/Label.d.ts +0 -35
- package/lib/Types/LabelAssociation.d.ts +0 -29
- package/lib/Types/Message.d.ts +0 -273
- package/lib/Types/Newsletter.d.ts +0 -103
- package/lib/Types/Product.d.ts +0 -78
- package/lib/Types/Signal.d.ts +0 -57
- package/lib/Types/Socket.d.ts +0 -111
- package/lib/Types/State.d.ts +0 -27
- package/lib/Types/USync.d.ts +0 -25
- package/lib/Types/index.d.ts +0 -57
- package/lib/Utils/auth-utils.d.ts +0 -18
- package/lib/Utils/baileys-event-stream.d.ts +0 -16
- package/lib/Utils/business.d.ts +0 -22
- package/lib/Utils/chat-utils.d.ts +0 -71
- package/lib/Utils/crypto.d.ts +0 -41
- package/lib/Utils/decode-wa-message.d.ts +0 -19
- package/lib/Utils/event-buffer.d.ts +0 -35
- package/lib/Utils/generics.d.ts +0 -92
- package/lib/Utils/generics.js.bak +0 -433
- package/lib/Utils/history.d.ts +0 -15
- package/lib/Utils/index.d.ts +0 -17
- package/lib/Utils/link-preview.d.ts +0 -21
- package/lib/Utils/logger.d.ts +0 -4
- package/lib/Utils/lt-hash.d.ts +0 -12
- package/lib/Utils/make-mutex.d.ts +0 -7
- package/lib/Utils/messages-media.d.ts +0 -116
- package/lib/Utils/messages.d.ts +0 -77
- package/lib/Utils/noise-handler.d.ts +0 -21
- package/lib/Utils/process-message.d.ts +0 -41
- package/lib/Utils/signal.d.ts +0 -32
- package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
- package/lib/Utils/validate-connection.d.ts +0 -11
- package/lib/Utils/validate-connection.js.bak +0 -237
- package/lib/WABinary/constants.d.ts +0 -30
- package/lib/WABinary/decode.d.ts +0 -7
- package/lib/WABinary/encode.d.ts +0 -3
- package/lib/WABinary/generic-utils.d.ts +0 -17
- package/lib/WABinary/index.d.ts +0 -5
- package/lib/WABinary/jid-utils.d.ts +0 -31
- package/lib/WABinary/types.d.ts +0 -18
- package/lib/WAM/BinaryInfo.d.ts +0 -17
- package/lib/WAM/constants.d.ts +0 -38
- package/lib/WAM/encode.d.ts +0 -3
- package/lib/WAM/index.d.ts +0 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
- package/lib/WAUSync/Protocols/index.d.ts +0 -4
- package/lib/WAUSync/USyncQuery.d.ts +0 -28
- package/lib/WAUSync/USyncUser.d.ts +0 -12
- package/lib/WAUSync/index.d.ts +0 -3
- package/lib/index.d.ts +0 -12
- /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
package/engine-requirements.js
CHANGED
package/lib/Defaults/index.js
CHANGED
|
@@ -1,147 +1,122 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
3
4
|
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
const PHONENUMBER_MCC = require("./phonenumber_mcc.json");
|
|
8
|
+
exports.PHONENUMBER_MCC = PHONENUMBER_MCC;
|
|
6
9
|
|
|
7
|
-
exports.DEFAULT_CACHE_TTLS =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.MEDIA_PATH_MAP =
|
|
13
|
-
exports.DEFAULT_CONNECTION_CONFIG =
|
|
14
|
-
exports.PROCESSABLE_HISTORY_TYPES =
|
|
15
|
-
exports.WA_CERT_DETAILS =
|
|
16
|
-
exports.URL_REGEX =
|
|
17
|
-
exports.NOISE_WA_HEADER =
|
|
18
|
-
exports.KEY_BUNDLE_TYPE =
|
|
19
|
-
exports.DICT_VERSION =
|
|
20
|
-
exports.NOISE_MODE =
|
|
21
|
-
exports.WA_DEFAULT_EPHEMERAL =
|
|
22
|
-
exports.PHONE_CONNECTION_CB =
|
|
23
|
-
exports.DEF_TAG_PREFIX =
|
|
24
|
-
exports.DEF_CALLBACK_PREFIX =
|
|
25
|
-
exports.DEFAULT_ORIGIN =
|
|
26
|
-
exports.UNAUTHORIZED_CODES =
|
|
27
|
-
void 0;
|
|
28
|
-
|
|
29
|
-
const crypto_1 = require("crypto");
|
|
30
|
-
const WAProto_1 = require("../../WAProto"),
|
|
31
|
-
libsignal_1 = require("../Signal/libsignal"),
|
|
32
|
-
Utils_1 = require("../Utils"),
|
|
33
|
-
logger_1 = __importDefault(require("../Utils/logger")),
|
|
34
|
-
baileys_version_json_1 = require("./baileys-version.json"),
|
|
35
|
-
phonenumber_mcc_json_1 = __importDefault(require("./phonenumber-mcc.json"));
|
|
36
|
-
|
|
37
|
-
exports.UNAUTHORIZED_CODES = [401, 403, 419];
|
|
10
|
+
exports.DEFAULT_CACHE_TTLS = exports.MIN_UPLOAD_INTERVAL = exports.UPLOAD_TIMEOUT = exports.INITIAL_PREKEY_COUNT = exports.MIN_PREKEY_COUNT = exports.MEDIA_KEYS = exports.MEDIA_HKDF_KEY_MAPPING = exports.MEDIA_PATH_MAP = exports.DEFAULT_CONNECTION_CONFIG = exports.PROCESSABLE_HISTORY_TYPES = exports.WA_CERT_DETAILS = exports.URL_REGEX = exports.NOISE_WA_HEADER = exports.KEY_BUNDLE_TYPE = exports.DICT_VERSION = exports.NOISE_MODE = exports.WA_DEFAULT_EPHEMERAL = exports.WA_ADV_HOSTED_DEVICE_SIG_PREFIX = exports.WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = exports.WA_ADV_DEVICE_SIG_PREFIX = exports.WA_ADV_ACCOUNT_SIG_PREFIX = exports.UNAUTHORIZED_CODES = exports.version = void 0;
|
|
11
|
+
const WAProto_1 = require("../../WAProto");
|
|
12
|
+
const libsignal_1 = require("../Signal/libsignal");
|
|
13
|
+
const browser_utils_1 = require("../Utils/browser-utils");
|
|
14
|
+
const logger_1 = __importDefault(require("../Utils/logger"));
|
|
38
15
|
exports.version = [2, 3000, 1027934701];
|
|
39
|
-
exports.
|
|
40
|
-
exports.DEFAULT_ORIGIN =
|
|
41
|
-
exports.
|
|
42
|
-
exports.
|
|
43
|
-
exports.DEF_CALLBACK_PREFIX =
|
|
44
|
-
exports.DEF_TAG_PREFIX =
|
|
45
|
-
exports.PHONE_CONNECTION_CB =
|
|
46
|
-
exports.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
exports.
|
|
50
|
-
exports.
|
|
51
|
-
exports.
|
|
52
|
-
exports.
|
|
53
|
-
5, 142, 140, 15, 116, 195, 235, 197, 215, 166, 134, 92, 108, 60, 132, 56, 86, 176, 97, 33, 204, 232, 234, 119, 77,
|
|
54
|
-
34, 251, 111, 18, 37, 18, 48, 45,
|
|
55
|
-
]);
|
|
56
|
-
exports.NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\x00\x00\x00\x00";
|
|
57
|
-
exports.DICT_VERSION = 2;
|
|
16
|
+
exports.UNAUTHORIZED_CODES = [401, 403, 419];
|
|
17
|
+
exports.DEFAULT_ORIGIN = 'https://web.whatsapp.com';
|
|
18
|
+
exports.CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/';
|
|
19
|
+
exports.CALL_AUDIO_PREFIX = 'https://call.whatsapp.com/voice/';
|
|
20
|
+
exports.DEF_CALLBACK_PREFIX = 'CB:';
|
|
21
|
+
exports.DEF_TAG_PREFIX = 'TAG:';
|
|
22
|
+
exports.PHONE_CONNECTION_CB = 'CB:Pong';
|
|
23
|
+
exports.WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0]);
|
|
24
|
+
exports.WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1]);
|
|
25
|
+
exports.WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5]);
|
|
26
|
+
exports.WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6]);
|
|
27
|
+
exports.WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60;
|
|
28
|
+
exports.NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0';
|
|
29
|
+
exports.DICT_VERSION = 3;
|
|
58
30
|
exports.KEY_BUNDLE_TYPE = Buffer.from([5]);
|
|
59
31
|
exports.NOISE_WA_HEADER = Buffer.from([87, 65, 6, exports.DICT_VERSION]);
|
|
60
|
-
exports.PROTOCOL_VERSION = [5, 2];
|
|
61
|
-
exports.MOBILE_NOISE_HEADER = Buffer.concat([Buffer.from('WA'), Buffer.from(exports.PROTOCOL_VERSION)]);
|
|
62
|
-
|
|
63
32
|
exports.URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
|
|
64
|
-
exports.WA_CERT_DETAILS = {
|
|
65
|
-
|
|
33
|
+
exports.WA_CERT_DETAILS = {
|
|
34
|
+
SERIAL: 0
|
|
35
|
+
};
|
|
66
36
|
exports.PROCESSABLE_HISTORY_TYPES = [
|
|
67
|
-
WAProto_1.proto.
|
|
68
|
-
WAProto_1.proto.
|
|
69
|
-
WAProto_1.proto.
|
|
70
|
-
WAProto_1.proto.
|
|
71
|
-
WAProto_1.proto.
|
|
37
|
+
WAProto_1.proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP,
|
|
38
|
+
WAProto_1.proto.HistorySync.HistorySyncType.PUSH_NAME,
|
|
39
|
+
WAProto_1.proto.HistorySync.HistorySyncType.RECENT,
|
|
40
|
+
WAProto_1.proto.HistorySync.HistorySyncType.FULL,
|
|
41
|
+
WAProto_1.proto.HistorySync.HistorySyncType.ON_DEMAND,
|
|
42
|
+
WAProto_1.proto.HistorySync.HistorySyncType.NON_BLOCKING_DATA,
|
|
43
|
+
WAProto_1.proto.HistorySync.HistorySyncType.INITIAL_STATUS_V3,
|
|
72
44
|
];
|
|
73
|
-
|
|
74
45
|
exports.DEFAULT_CONNECTION_CONFIG = {
|
|
75
|
-
version:
|
|
76
|
-
browser:
|
|
77
|
-
waWebSocketUrl:
|
|
78
|
-
connectTimeoutMs:
|
|
79
|
-
keepAliveIntervalMs:
|
|
80
|
-
logger: logger_1.default.child({ class:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
defaultQueryTimeoutMs: 6E4,
|
|
46
|
+
version: exports.version,
|
|
47
|
+
browser: (0, browser_utils_1.Browsers)('Chrome'),
|
|
48
|
+
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
|
49
|
+
connectTimeoutMs: 20_000,
|
|
50
|
+
keepAliveIntervalMs: 30_000,
|
|
51
|
+
logger: logger_1.default.child({ class: 'baileys' }),
|
|
52
|
+
emitOwnEvents: true,
|
|
53
|
+
defaultQueryTimeoutMs: 60_000,
|
|
84
54
|
customUploadHosts: [],
|
|
85
55
|
retryRequestDelayMs: 250,
|
|
86
56
|
maxMsgRetryCount: 5,
|
|
87
|
-
fireInitQueries:
|
|
88
|
-
auth:
|
|
89
|
-
markOnlineOnConnect:
|
|
90
|
-
syncFullHistory:
|
|
91
|
-
patchMessageBeforeSending:
|
|
92
|
-
shouldSyncHistoryMessage: () =>
|
|
93
|
-
shouldIgnoreJid: () =>
|
|
57
|
+
fireInitQueries: true,
|
|
58
|
+
auth: undefined,
|
|
59
|
+
markOnlineOnConnect: true,
|
|
60
|
+
syncFullHistory: true,
|
|
61
|
+
patchMessageBeforeSending: msg => msg,
|
|
62
|
+
shouldSyncHistoryMessage: () => true,
|
|
63
|
+
shouldIgnoreJid: () => false,
|
|
94
64
|
linkPreviewImageThumbnailWidth: 192,
|
|
95
|
-
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs:
|
|
96
|
-
generateHighQualityLinkPreview:
|
|
65
|
+
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
|
|
66
|
+
generateHighQualityLinkPreview: false,
|
|
67
|
+
enableAutoSessionRecreation: true,
|
|
68
|
+
enableRecentMessageCache: true,
|
|
97
69
|
options: {},
|
|
98
|
-
appStateMacVerification: {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
70
|
+
appStateMacVerification: {
|
|
71
|
+
patch: false,
|
|
72
|
+
snapshot: false
|
|
73
|
+
},
|
|
74
|
+
countryCode: 'US',
|
|
75
|
+
getMessage: async () => undefined,
|
|
76
|
+
cachedGroupMetadata: async () => undefined,
|
|
102
77
|
makeSignalRepository: libsignal_1.makeLibSignalRepository
|
|
103
78
|
};
|
|
104
|
-
|
|
105
79
|
exports.MEDIA_PATH_MAP = {
|
|
106
|
-
image:
|
|
107
|
-
video:
|
|
108
|
-
document:
|
|
109
|
-
audio:
|
|
110
|
-
sticker:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
80
|
+
image: '/mms/image',
|
|
81
|
+
video: '/mms/video',
|
|
82
|
+
document: '/mms/document',
|
|
83
|
+
audio: '/mms/audio',
|
|
84
|
+
sticker: '/mms/image',
|
|
85
|
+
'thumbnail-link': '/mms/image',
|
|
86
|
+
'product-catalog-image': '/product/image',
|
|
87
|
+
'md-app-state': '',
|
|
88
|
+
'md-msg-hist': '/mms/md-app-state',
|
|
89
|
+
'biz-cover-photo': '/pps/biz-cover-photo'
|
|
115
90
|
};
|
|
116
|
-
|
|
117
91
|
exports.MEDIA_HKDF_KEY_MAPPING = {
|
|
118
|
-
audio:
|
|
119
|
-
document:
|
|
120
|
-
gif:
|
|
121
|
-
image:
|
|
122
|
-
ppic:
|
|
123
|
-
product:
|
|
124
|
-
ptt:
|
|
125
|
-
sticker:
|
|
126
|
-
video:
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
ptv:
|
|
92
|
+
audio: 'Audio',
|
|
93
|
+
document: 'Document',
|
|
94
|
+
gif: 'Video',
|
|
95
|
+
image: 'Image',
|
|
96
|
+
ppic: '',
|
|
97
|
+
product: 'Image',
|
|
98
|
+
ptt: 'Audio',
|
|
99
|
+
sticker: 'Image',
|
|
100
|
+
video: 'Video',
|
|
101
|
+
'thumbnail-document': 'Document Thumbnail',
|
|
102
|
+
'thumbnail-image': 'Image Thumbnail',
|
|
103
|
+
'thumbnail-video': 'Video Thumbnail',
|
|
104
|
+
'thumbnail-link': 'Link Thumbnail',
|
|
105
|
+
'md-msg-hist': 'History',
|
|
106
|
+
'md-app-state': 'App State',
|
|
107
|
+
'product-catalog-image': '',
|
|
108
|
+
'payment-bg-image': 'Payment Background',
|
|
109
|
+
ptv: 'Video',
|
|
110
|
+
'biz-cover-photo': 'Image'
|
|
136
111
|
};
|
|
137
|
-
|
|
138
112
|
exports.MEDIA_KEYS = Object.keys(exports.MEDIA_PATH_MAP);
|
|
139
113
|
exports.MIN_PREKEY_COUNT = 5;
|
|
140
|
-
exports.INITIAL_PREKEY_COUNT =
|
|
141
|
-
|
|
114
|
+
exports.INITIAL_PREKEY_COUNT = 812;
|
|
115
|
+
exports.UPLOAD_TIMEOUT = 30000;
|
|
116
|
+
exports.MIN_UPLOAD_INTERVAL = 5000;
|
|
142
117
|
exports.DEFAULT_CACHE_TTLS = {
|
|
143
|
-
SIGNAL_STORE:
|
|
144
|
-
MSG_RETRY:
|
|
145
|
-
CALL_OFFER:
|
|
146
|
-
USER_DEVICES:
|
|
118
|
+
SIGNAL_STORE: 5 * 60,
|
|
119
|
+
MSG_RETRY: 60 * 60,
|
|
120
|
+
CALL_OFFER: 5 * 60,
|
|
121
|
+
USER_DEVICES: 5 * 60
|
|
147
122
|
};
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
{
|
|
2
|
+
"93": 412,
|
|
3
|
+
"355": 276,
|
|
4
|
+
"213": 603,
|
|
5
|
+
"1-684": 544,
|
|
6
|
+
"376": 213,
|
|
7
|
+
"244": 631,
|
|
8
|
+
"1-264": 365,
|
|
9
|
+
"1-268": 344,
|
|
10
|
+
"54": 722,
|
|
11
|
+
"374": 283,
|
|
12
|
+
"297": 363,
|
|
13
|
+
"61": 505,
|
|
14
|
+
"43": 232,
|
|
15
|
+
"994": 400,
|
|
16
|
+
"1-242": 364,
|
|
17
|
+
"973": 426,
|
|
18
|
+
"880": 470,
|
|
19
|
+
"1-246": 342,
|
|
20
|
+
"375": 257,
|
|
21
|
+
"32": 206,
|
|
22
|
+
"501": 702,
|
|
23
|
+
"229": 616,
|
|
24
|
+
"1-441": 350,
|
|
25
|
+
"975": 402,
|
|
26
|
+
"591": 736,
|
|
27
|
+
"387": 218,
|
|
28
|
+
"267": 652,
|
|
29
|
+
"55": 724,
|
|
30
|
+
"1-284": 348,
|
|
31
|
+
"673": 528,
|
|
32
|
+
"359": 284,
|
|
33
|
+
"226": 613,
|
|
34
|
+
"257": 642,
|
|
35
|
+
"855": 456,
|
|
36
|
+
"237": 624,
|
|
37
|
+
"238": 625,
|
|
38
|
+
"1-345": 346,
|
|
39
|
+
"236": 623,
|
|
40
|
+
"235": 622,
|
|
41
|
+
"56": 730,
|
|
42
|
+
"86": 454,
|
|
43
|
+
"57": 732,
|
|
44
|
+
"269": 654,
|
|
45
|
+
"682": 548,
|
|
46
|
+
"506": 712,
|
|
47
|
+
"385": 219,
|
|
48
|
+
"53": 368,
|
|
49
|
+
"357": 280,
|
|
50
|
+
"420": 230,
|
|
51
|
+
"243": 630,
|
|
52
|
+
"45": 238,
|
|
53
|
+
"253": 638,
|
|
54
|
+
"1-767": 366,
|
|
55
|
+
"1-809": 370,
|
|
56
|
+
"1-849": 370,
|
|
57
|
+
"1-829": 370,
|
|
58
|
+
"593": 740,
|
|
59
|
+
"20": 602,
|
|
60
|
+
"503": 706,
|
|
61
|
+
"240": 627,
|
|
62
|
+
"291": 657,
|
|
63
|
+
"372": 248,
|
|
64
|
+
"251": 636,
|
|
65
|
+
"500": 750,
|
|
66
|
+
"298": 288,
|
|
67
|
+
"679": 542,
|
|
68
|
+
"358": 244,
|
|
69
|
+
"33": 208,
|
|
70
|
+
"689": 547,
|
|
71
|
+
"241": 628,
|
|
72
|
+
"220": 607,
|
|
73
|
+
"995": 282,
|
|
74
|
+
"49": 262,
|
|
75
|
+
"233": 620,
|
|
76
|
+
"350": 266,
|
|
77
|
+
"30": 202,
|
|
78
|
+
"299": 290,
|
|
79
|
+
"1-473": 352,
|
|
80
|
+
"1-671": 535,
|
|
81
|
+
"502": 704,
|
|
82
|
+
"224": 537,
|
|
83
|
+
"592": 738,
|
|
84
|
+
"509": 372,
|
|
85
|
+
"504": 708,
|
|
86
|
+
"852": 454,
|
|
87
|
+
"36": 216,
|
|
88
|
+
"354": 274,
|
|
89
|
+
"91": 404,
|
|
90
|
+
"62": 510,
|
|
91
|
+
"98": 432,
|
|
92
|
+
"964": 418,
|
|
93
|
+
"353": 234,
|
|
94
|
+
"972": 425,
|
|
95
|
+
"39": 222,
|
|
96
|
+
"225": 612,
|
|
97
|
+
"1-876": 338,
|
|
98
|
+
"81": 440,
|
|
99
|
+
"962": 416,
|
|
100
|
+
"254": 639,
|
|
101
|
+
"686": 545,
|
|
102
|
+
"383": 221,
|
|
103
|
+
"965": 419,
|
|
104
|
+
"371": 247,
|
|
105
|
+
"961": 415,
|
|
106
|
+
"266": 651,
|
|
107
|
+
"231": 618,
|
|
108
|
+
"218": 606,
|
|
109
|
+
"423": 295,
|
|
110
|
+
"370": 246,
|
|
111
|
+
"352": 270,
|
|
112
|
+
"389": 294,
|
|
113
|
+
"261": 646,
|
|
114
|
+
"265": 650,
|
|
115
|
+
"60": 502,
|
|
116
|
+
"960": 472,
|
|
117
|
+
"223": 610,
|
|
118
|
+
"356": 278,
|
|
119
|
+
"692": 551,
|
|
120
|
+
"222": 609,
|
|
121
|
+
"230": 617,
|
|
122
|
+
"52": 334,
|
|
123
|
+
"691": 550,
|
|
124
|
+
"373": 259,
|
|
125
|
+
"377": 212,
|
|
126
|
+
"976": 428,
|
|
127
|
+
"382": 297,
|
|
128
|
+
"1-664": 354,
|
|
129
|
+
"212": 604,
|
|
130
|
+
"258": 643,
|
|
131
|
+
"95": 414,
|
|
132
|
+
"264": 649,
|
|
133
|
+
"674": 536,
|
|
134
|
+
"977": 429,
|
|
135
|
+
"31": 204,
|
|
136
|
+
"687": 546,
|
|
137
|
+
"64": 530,
|
|
138
|
+
"505": 710,
|
|
139
|
+
"227": 614,
|
|
140
|
+
"234": 621,
|
|
141
|
+
"683": 555,
|
|
142
|
+
"1-670": 534,
|
|
143
|
+
"47": 242,
|
|
144
|
+
"968": 226,
|
|
145
|
+
"92": 410,
|
|
146
|
+
"680": 552,
|
|
147
|
+
"970": 423,
|
|
148
|
+
"507": 714,
|
|
149
|
+
"675": 537,
|
|
150
|
+
"595": 744,
|
|
151
|
+
"51": 716,
|
|
152
|
+
"63": 515,
|
|
153
|
+
"48": 260,
|
|
154
|
+
"351": 268,
|
|
155
|
+
"1-787, 1-939": 330,
|
|
156
|
+
"974": 427,
|
|
157
|
+
"242": 630,
|
|
158
|
+
"40": 226,
|
|
159
|
+
"7": 250,
|
|
160
|
+
"250": 635,
|
|
161
|
+
"290": 658,
|
|
162
|
+
"1-869": 356,
|
|
163
|
+
"1-758": 358,
|
|
164
|
+
"508": 308,
|
|
165
|
+
"1-784": 360,
|
|
166
|
+
"685": 544,
|
|
167
|
+
"378": 292,
|
|
168
|
+
"239": 626,
|
|
169
|
+
"966": 420,
|
|
170
|
+
"221": 608,
|
|
171
|
+
"381": 220,
|
|
172
|
+
"248": 633,
|
|
173
|
+
"232": 619,
|
|
174
|
+
"65": 525,
|
|
175
|
+
"386": 293,
|
|
176
|
+
"677": 540,
|
|
177
|
+
"27": 655,
|
|
178
|
+
"211": 659,
|
|
179
|
+
"34": 214,
|
|
180
|
+
"94": 413,
|
|
181
|
+
"249": 634,
|
|
182
|
+
"597": 746,
|
|
183
|
+
"268": 653,
|
|
184
|
+
"46": 240,
|
|
185
|
+
"41": 228,
|
|
186
|
+
"963": 417,
|
|
187
|
+
"886": 466,
|
|
188
|
+
"992": 436,
|
|
189
|
+
"255": 640,
|
|
190
|
+
"66": 520,
|
|
191
|
+
"228": 615,
|
|
192
|
+
"690": 554,
|
|
193
|
+
"676": 539,
|
|
194
|
+
"1-868": 374,
|
|
195
|
+
"216": 605,
|
|
196
|
+
"90": 286,
|
|
197
|
+
"993": 438,
|
|
198
|
+
"1-649": 376,
|
|
199
|
+
"688": 553,
|
|
200
|
+
"1-340": 332,
|
|
201
|
+
"256": 641,
|
|
202
|
+
"380": 255,
|
|
203
|
+
"971": 424,
|
|
204
|
+
"44": 234,
|
|
205
|
+
"1": 310,
|
|
206
|
+
"598": 748,
|
|
207
|
+
"998": 434,
|
|
208
|
+
"678": 541,
|
|
209
|
+
"379": 225,
|
|
210
|
+
"58": 734,
|
|
211
|
+
"681": 543,
|
|
212
|
+
"967": 421,
|
|
213
|
+
"260": 645,
|
|
214
|
+
"263": 648,
|
|
215
|
+
"670": 514,
|
|
216
|
+
"245": 632,
|
|
217
|
+
"856": 457,
|
|
218
|
+
"599": 362,
|
|
219
|
+
"850": 467,
|
|
220
|
+
"262": 647,
|
|
221
|
+
"82": 450,
|
|
222
|
+
"84": 452
|
|
223
|
+
}
|
|
@@ -14,6 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./web-socket-client"), exports);
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./websocket"), exports);
|
|
@@ -6,11 +6,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.WebSocketClient = void 0;
|
|
7
7
|
const ws_1 = __importDefault(require("ws"));
|
|
8
8
|
const Defaults_1 = require("../../Defaults");
|
|
9
|
-
const
|
|
10
|
-
class WebSocketClient extends
|
|
9
|
+
const types_1 = require("./types");
|
|
10
|
+
class WebSocketClient extends types_1.AbstractSocketClient {
|
|
11
11
|
constructor() {
|
|
12
12
|
super(...arguments);
|
|
13
13
|
this.socket = null;
|
|
14
|
+
// queue & dispatch variables for throttling outgoing messages to avoid rate limits
|
|
15
|
+
this._queue = [];
|
|
16
|
+
this._isDispatching = false;
|
|
17
|
+
this._lastDispatch = 0;
|
|
18
|
+
this._minSendIntervalMs = (Defaults_1.DEFAULT_CONNECTION_CONFIG && Defaults_1.DEFAULT_CONNECTION_CONFIG.minSendIntervalMs) || 50;
|
|
14
19
|
}
|
|
15
20
|
get isOpen() {
|
|
16
21
|
var _a;
|
|
@@ -53,10 +58,54 @@ class WebSocketClient extends abstract_socket_client_1.AbstractSocketClient {
|
|
|
53
58
|
this.socket.close();
|
|
54
59
|
this.socket = null;
|
|
55
60
|
}
|
|
61
|
+
async restart() {
|
|
62
|
+
if (this.socket) {
|
|
63
|
+
await new Promise(resolve => {
|
|
64
|
+
this.socket.once('close', resolve);
|
|
65
|
+
this.socket.terminate();
|
|
66
|
+
});
|
|
67
|
+
this.socket = null;
|
|
68
|
+
}
|
|
69
|
+
await this.connect();
|
|
70
|
+
}
|
|
56
71
|
send(str, cb) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
72
|
+
// throttle sends to reduce rate-limit likelihood
|
|
73
|
+
const doSend = () => {
|
|
74
|
+
var _a;
|
|
75
|
+
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.send(str, cb);
|
|
76
|
+
return Boolean(this.socket);
|
|
77
|
+
};
|
|
78
|
+
this._queue.push(doSend);
|
|
79
|
+
this._dispatch();
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
_dispatch() {
|
|
84
|
+
if (this._isDispatching) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
this._isDispatching = true;
|
|
88
|
+
const tick = () => {
|
|
89
|
+
const now = Date.now();
|
|
90
|
+
if (this._queue.length === 0) {
|
|
91
|
+
this._isDispatching = false;
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const delta = now - this._lastDispatch;
|
|
95
|
+
const wait = Math.max(0, this._minSendIntervalMs - delta);
|
|
96
|
+
setTimeout(() => {
|
|
97
|
+
const fn = this._queue.shift();
|
|
98
|
+
this._lastDispatch = Date.now();
|
|
99
|
+
try {
|
|
100
|
+
fn && fn();
|
|
101
|
+
}
|
|
102
|
+
catch (_err) {
|
|
103
|
+
// ignore send errors here; they'll surface elsewhere
|
|
104
|
+
}
|
|
105
|
+
tick();
|
|
106
|
+
}, wait);
|
|
107
|
+
};
|
|
108
|
+
tick();
|
|
60
109
|
}
|
|
61
110
|
}
|
|
62
111
|
exports.WebSocketClient = WebSocketClient;
|
package/lib/Socket/business.js
CHANGED
|
@@ -6,8 +6,13 @@ const WABinary_1 = require("../WABinary");
|
|
|
6
6
|
const generic_utils_1 = require("../WABinary/generic-utils");
|
|
7
7
|
const messages_recv_1 = require("./messages-recv");
|
|
8
8
|
const makeBusinessSocket = (config) => {
|
|
9
|
-
const sock = (0, messages_recv_1.makeMessagesRecvSocket)(
|
|
10
|
-
|
|
9
|
+
const sock = (0, messages_recv_1.makeMessagesRecvSocket)({
|
|
10
|
+
...config,
|
|
11
|
+
forceNewConnection: true,
|
|
12
|
+
syncFullHistory: false,
|
|
13
|
+
shouldIgnoreJid: () => false
|
|
14
|
+
});
|
|
15
|
+
const { authState, query, waUploadToServer, refreshMediaConn } = sock;
|
|
11
16
|
const getCatalog = async ({ jid, limit, cursor }) => {
|
|
12
17
|
var _a;
|
|
13
18
|
jid = jid || ((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id);
|
|
@@ -249,6 +254,7 @@ const makeBusinessSocket = (config) => {
|
|
|
249
254
|
return {
|
|
250
255
|
...sock,
|
|
251
256
|
logger: config.logger,
|
|
257
|
+
refreshMediaConn,
|
|
252
258
|
getOrderDetails,
|
|
253
259
|
getCatalog,
|
|
254
260
|
getCollections,
|