@sixcore/baileys 1.0.2 → 1.1.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 +21 -13
- package/WAProto/WAProto.proto +5311 -0
- package/WAProto/index.js +65813 -141372
- package/lib/Defaults/index.js +120 -133
- package/lib/KeyDB/BinarySearch.js +30 -0
- package/lib/KeyDB/KeyedDB.js +178 -0
- package/lib/KeyDB/index.js +14 -0
- package/lib/Signal/Group/ciphertext-message.js +22 -14
- package/lib/Signal/Group/group-session-builder.js +21 -42
- package/lib/Signal/Group/group_cipher.js +85 -87
- package/lib/Signal/Group/index.js +23 -57
- package/lib/Signal/Group/keyhelper.js +28 -52
- package/lib/Signal/Group/sender-chain-key.js +37 -33
- package/lib/Signal/Group/sender-key-distribution-message.js +73 -63
- package/lib/Signal/Group/sender-key-message.js +75 -66
- package/lib/Signal/Group/sender-key-name.js +55 -44
- package/lib/Signal/Group/sender-key-record.js +49 -49
- package/lib/Signal/Group/sender-key-state.js +90 -93
- package/lib/Signal/Group/sender-message-key.js +37 -28
- package/lib/Signal/libsignal.js +324 -163
- package/lib/Signal/lid-mapping.js +166 -0
- package/lib/Socket/Client/index.js +14 -19
- package/lib/Socket/Client/types.js +13 -0
- package/lib/Socket/Client/websocket.js +62 -0
- package/lib/Socket/business.js +359 -242
- package/lib/Socket/chats.js +850 -935
- package/lib/Socket/communities.js +413 -0
- package/lib/Socket/groups.js +304 -309
- package/lib/Socket/index.js +25 -10
- package/lib/Socket/messages-recv.js +1107 -1054
- package/lib/Socket/messages-send.js +639 -448
- package/lib/Socket/mex.js +45 -0
- package/lib/Socket/newsletter.js +244 -237
- package/lib/Socket/socket.js +803 -638
- package/lib/Store/index.js +18 -10
- package/lib/Store/make-cache-manager-store.js +73 -81
- package/lib/Store/make-in-memory-store.js +286 -423
- package/lib/Store/make-ordered-dictionary.js +77 -79
- package/lib/Store/object-repository.js +24 -26
- package/lib/Types/Auth.js +13 -2
- package/lib/Types/Bussines.js +13 -0
- package/lib/Types/Call.js +13 -2
- package/lib/Types/Chat.js +19 -4
- package/lib/Types/Contact.js +13 -2
- package/lib/Types/Events.js +13 -2
- package/lib/Types/GroupMetadata.js +13 -2
- package/lib/Types/Label.js +43 -26
- package/lib/Types/Label.js.bak +25 -0
- package/lib/Types/LabelAssociation.js +16 -8
- package/lib/Types/Message.js +22 -9
- package/lib/Types/Newsletter.js +42 -37
- package/lib/Types/Product.js +13 -2
- package/lib/Types/Signal.js +13 -2
- package/lib/Types/Socket.js +14 -2
- package/lib/Types/State.js +21 -2
- package/lib/Types/USync.js +13 -2
- package/lib/Types/index.js +37 -41
- package/lib/Utils/auth-utils.js +219 -196
- package/lib/Utils/baileys-event-stream.js +50 -59
- package/lib/Utils/browser-utils.js +25 -0
- package/lib/Utils/business.js +213 -214
- package/lib/Utils/chat-utils.js +710 -687
- package/lib/Utils/crypto.js +112 -133
- package/lib/Utils/decode-wa-message.js +252 -183
- package/lib/Utils/event-buffer.js +510 -496
- package/lib/Utils/generics.js +319 -387
- package/lib/Utils/history.js +83 -92
- package/lib/Utils/index.js +31 -33
- package/lib/Utils/link-preview.js +71 -83
- package/lib/Utils/logger.js +5 -7
- package/lib/Utils/lt-hash.js +40 -46
- package/lib/Utils/make-mutex.js +34 -41
- package/lib/Utils/message-retry-manager.js +113 -0
- package/lib/Utils/messages-media.js +553 -768
- package/lib/Utils/messages-media.js.bak2 +602 -0
- package/lib/Utils/messages.js +354 -263
- package/lib/Utils/noise-handler.js +138 -149
- package/lib/Utils/pre-key-manager.js +95 -0
- package/lib/Utils/process-message.js +333 -303
- package/lib/Utils/signal.js +159 -141
- package/lib/Utils/use-multi-file-auth-state.js +105 -103
- package/lib/Utils/validate-connection.js +184 -203
- package/lib/WABinary/constants.js +1308 -35
- package/lib/WABinary/decode.js +247 -249
- package/lib/WABinary/encode.js +221 -258
- package/lib/WABinary/generic-utils.js +68 -65
- package/lib/WABinary/index.js +17 -21
- package/lib/WABinary/jid-utils.js +99 -58
- package/lib/WABinary/types.js +13 -2
- package/lib/WAM/BinaryInfo.js +20 -12
- package/lib/WAM/constants.js +22863 -15348
- package/lib/WAM/encode.js +145 -136
- package/lib/WAM/index.js +15 -19
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +39 -31
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +61 -54
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +39 -29
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +48 -40
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +62 -51
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +38 -21
- package/lib/WAUSync/Protocols/index.js +17 -20
- package/lib/WAUSync/USyncQuery.js +98 -86
- package/lib/WAUSync/USyncUser.js +35 -26
- package/lib/WAUSync/index.js +16 -19
- package/lib/index.js +26 -94
- package/lib/index.js.bak +23 -0
- package/package.json +97 -113
- package/jessica.js +0 -91
- package/lib/Defaults/baileys-version.json +0 -3
- 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/queue-job.js +0 -57
- 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/abstract-socket-client.js +0 -13
- 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/Client/web-socket-client.js +0 -62
- package/lib/Socket/business.d.ts +0 -171
- package/lib/Socket/chats.d.ts +0 -267
- package/lib/Socket/dugong.d.ts +0 -254
- package/lib/Socket/dugong.js +0 -484
- package/lib/Socket/groups.d.ts +0 -115
- 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/Socket/usync.js +0 -70
- package/lib/Store/index.d.ts +0 -3
- package/lib/Store/make-cache-manager-store.d.ts +0 -13
- 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/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/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/Defaults/index.js
CHANGED
|
@@ -1,146 +1,133 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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;
|
|
1
|
+
//========================================//
|
|
2
|
+
/**
|
|
3
|
+
* @project @sixcore/baileys
|
|
4
|
+
* @author Sixx.js </>🌿
|
|
5
|
+
* @version 1.0.3
|
|
6
|
+
* @license MIT
|
|
7
|
+
* @country Mozambique 🇲🇿♥️
|
|
8
|
+
* @chamadas || sms +258860817689
|
|
9
|
+
* @whatsApp +55889616-2417 || +258851907875
|
|
10
|
+
* @description Biblioteca Node.js para integração e automação no WhatsApp usando Baileys
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
import { makeLibSignalRepository } from "../Signal/libsignal.js";
|
|
15
|
+
import { Browsers } from "../Utils/browser-utils.js";
|
|
16
|
+
import { proto } from "../../WAProto/index.js";
|
|
17
|
+
import logger from "../Utils/logger.js";
|
|
28
18
|
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
export const version = [2, 3000, 1029030078]
|
|
20
|
+
export const DICT_VERSION = 3;
|
|
21
|
+
export const NOISE_WA_HEADER = Buffer.from([87, 65, 6, DICT_VERSION]);
|
|
22
|
+
export const CALL_VIDEO_PREFIX = "https://call.whatsapp.com/video/";
|
|
23
|
+
export const CALL_AUDIO_PREFIX = "https://call.whatsapp.com/voice/";
|
|
24
|
+
export const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5]);
|
|
25
|
+
export const WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6]);
|
|
26
|
+
export const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
|
|
27
|
+
export const WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0]);
|
|
28
|
+
export const WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1]);
|
|
29
|
+
export const DEFAULT_ORIGIN = "https://web.whatsapp.com";
|
|
30
|
+
export const WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60;
|
|
31
|
+
export const UNAUTHORIZED_CODES = [401, 403, 419];
|
|
32
|
+
export const KEY_BUNDLE_TYPE = Buffer.from([5]);
|
|
33
|
+
export const PHONE_CONNECTION_CB = "CB:Pong";
|
|
34
|
+
export const DEF_CALLBACK_PREFIX = "CB:";
|
|
35
|
+
export const DEF_TAG_PREFIX = "TAG:";
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
exports.version = [2, 3000, 1027934701];
|
|
39
|
-
exports.PHONENUMBER_MCC = phonenumber_mcc_json_1.default;
|
|
40
|
-
exports.DEFAULT_ORIGIN = "https://web.whatsapp.com";
|
|
41
|
-
exports.MOBILE_ENDPOINT = 'g.whatsapp.net';
|
|
42
|
-
exports.MOBILE_PORT = 443;
|
|
43
|
-
exports.DEF_CALLBACK_PREFIX = "CB:";
|
|
44
|
-
exports.DEF_TAG_PREFIX = "TAG:";
|
|
45
|
-
exports.PHONE_CONNECTION_CB = "CB:Pong";
|
|
46
|
-
exports.WA_DEFAULT_EPHEMERAL = 604800;
|
|
47
|
-
const WA_VERSION = '2.25.23.24';
|
|
48
|
-
const WA_VERSION_HASH = (0, crypto_1.createHash)('md5').update(WA_VERSION).digest('hex');
|
|
49
|
-
exports.MOBILE_TOKEN = Buffer.from('0a1mLfGUIBVrMKF1RdvLI5lkRBvof6vn0fD2QRSM' + WA_VERSION_HASH);
|
|
50
|
-
exports.MOBILE_REGISTRATION_ENDPOINT = 'https://v.whatsapp.net/v2';
|
|
51
|
-
exports.MOBILE_USERAGENT = `WhatsApp/${WA_VERSION} iOS/17.5.1 Device/Apple-iPhone_13`;
|
|
52
|
-
exports.REGISTRATION_PUBLIC_KEY = Buffer.from([
|
|
53
|
-
8, 20, 20, 16, 19, 0, 23, 8, 1, 20, 19, 1, 16, 16, 0, 3, 15, 13, 0, 3, 8, 1, 14, 14, 5, 12, 0, 22, 1, 2, 15, 12, 19, 22, 0, 20, 5, 10, 12, 14, 20, 20, 5, 0, 4,
|
|
54
|
-
]);
|
|
55
|
-
exports.NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\x00\x00\x00\x00";
|
|
56
|
-
exports.DICT_VERSION = 2;
|
|
57
|
-
exports.KEY_BUNDLE_TYPE = Buffer.from([5]);
|
|
58
|
-
exports.NOISE_WA_HEADER = Buffer.from([87, 65, 6, exports.DICT_VERSION]);
|
|
59
|
-
exports.PROTOCOL_VERSION = [5, 2];
|
|
60
|
-
exports.MOBILE_NOISE_HEADER = Buffer.concat([Buffer.from('WA'), Buffer.from(exports.PROTOCOL_VERSION)]);
|
|
37
|
+
export const URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
|
|
61
38
|
|
|
62
|
-
|
|
63
|
-
|
|
39
|
+
export const WA_CERT_DETAILS = {
|
|
40
|
+
SERIAL: 0
|
|
41
|
+
};
|
|
64
42
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
43
|
+
export const PROCESSABLE_HISTORY_TYPES = [
|
|
44
|
+
proto.Message.HistorySyncNotification.HistorySyncType.INITIAL_BOOTSTRAP,
|
|
45
|
+
proto.Message.HistorySyncNotification.HistorySyncType.PUSH_NAME,
|
|
46
|
+
proto.Message.HistorySyncNotification.HistorySyncType.RECENT,
|
|
47
|
+
proto.Message.HistorySyncNotification.HistorySyncType.FULL,
|
|
48
|
+
proto.Message.HistorySyncNotification.HistorySyncType.ON_DEMAND,
|
|
49
|
+
proto.Message.HistorySyncNotification.HistorySyncType.NON_BLOCKING_DATA,
|
|
50
|
+
proto.Message.HistorySyncNotification.HistorySyncType.INITIAL_STATUS_V3
|
|
71
51
|
];
|
|
72
52
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
53
|
+
export const DEFAULT_CONNECTION_CONFIG = {
|
|
54
|
+
"version": version,
|
|
55
|
+
"browser": Browsers.iOS("Safari"),
|
|
56
|
+
"waWebSocketUrl": "wss://web.whatsapp.com/ws/chat",
|
|
57
|
+
"connectTimeoutMs": 20000,
|
|
58
|
+
"keepAliveIntervalMs": 30000,
|
|
59
|
+
"logger": logger.child({ "class": "baileys" }),
|
|
60
|
+
"emitOwnEvents": true,
|
|
61
|
+
"defaultQueryTimeoutMs": 60000,
|
|
62
|
+
"customUploadHosts": [],
|
|
63
|
+
"retryRequestDelayMs": 250,
|
|
64
|
+
"maxMsgRetryCount": 5,
|
|
65
|
+
"fireInitQueries": true,
|
|
66
|
+
"auth": undefined,
|
|
67
|
+
"markOnlineOnConnect": true,
|
|
68
|
+
"syncFullHistory": true,
|
|
69
|
+
"patchMessageBeforeSending": msg => msg,
|
|
70
|
+
"shouldSyncHistoryMessage": () => true,
|
|
71
|
+
"shouldIgnoreJid": () => false,
|
|
72
|
+
"linkPreviewImageThumbnailWidth": 192,
|
|
73
|
+
"transactionOpts": { "maxCommitRetries": 10, "delayBetweenTriesMs": 3000 },
|
|
74
|
+
"generateHighQualityLinkPreview": false,
|
|
75
|
+
"enableAutoSessionRecreation": true,
|
|
76
|
+
"enableRecentMessageCache": true,
|
|
77
|
+
"options": {},
|
|
78
|
+
"appStateMacVerification": {
|
|
79
|
+
"patch": false,
|
|
80
|
+
"snapshot": false
|
|
81
|
+
},
|
|
82
|
+
"countryCode": "US",
|
|
83
|
+
"getMessage": async () => undefined,
|
|
84
|
+
"cachedGroupMetadata": async () => undefined,
|
|
85
|
+
"makeSignalRepository": makeLibSignalRepository
|
|
102
86
|
};
|
|
103
87
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
88
|
+
export const MEDIA_PATH_MAP = {
|
|
89
|
+
"image": "/mms/image",
|
|
90
|
+
"video": "/mms/video",
|
|
91
|
+
"document": "/mms/document",
|
|
92
|
+
"audio": "/mms/audio",
|
|
93
|
+
"sticker": "/mms/image",
|
|
94
|
+
"thumbnail-link": "/mms/image",
|
|
95
|
+
"product-catalog-image": "/product/image",
|
|
96
|
+
"md-app-state": "",
|
|
97
|
+
"md-msg-hist": "/mms/md-app-state",
|
|
98
|
+
"biz-cover-photo": "/pps/biz-cover-photo"
|
|
114
99
|
};
|
|
115
100
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
101
|
+
export const MEDIA_HKDF_KEY_MAPPING = {
|
|
102
|
+
"audio": "Audio",
|
|
103
|
+
"document": "Document",
|
|
104
|
+
"gif": "Video",
|
|
105
|
+
"image": "Image",
|
|
106
|
+
"ppic": "",
|
|
107
|
+
"product": "Image",
|
|
108
|
+
"ptt": "Audio",
|
|
109
|
+
"sticker": "Image",
|
|
110
|
+
"video": "Video",
|
|
111
|
+
"thumbnail-document": "Document Thumbnail",
|
|
112
|
+
"thumbnail-image": "Image Thumbnail",
|
|
113
|
+
"thumbnail-video": "Video Thumbnail",
|
|
114
|
+
"thumbnail-link": "Link Thumbnail",
|
|
115
|
+
"md-msg-hist": "History",
|
|
116
|
+
"md-app-state": "App State",
|
|
117
|
+
"product-catalog-image": "",
|
|
118
|
+
"payment-bg-image": "Payment Background",
|
|
119
|
+
"ptv": "Video",
|
|
120
|
+
"biz-cover-photo": "Image"
|
|
135
121
|
};
|
|
136
122
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
123
|
+
export const MEDIA_KEYS = Object.keys(MEDIA_PATH_MAP);
|
|
124
|
+
export const MIN_PREKEY_COUNT = 5;
|
|
125
|
+
export const INITIAL_PREKEY_COUNT = 812;
|
|
126
|
+
export const UPLOAD_TIMEOUT = 30000;
|
|
127
|
+
export const MIN_UPLOAD_INTERVAL = 5000;
|
|
128
|
+
export const DEFAULT_CACHE_TTLS = {
|
|
129
|
+
SIGNAL_STORE: 5 * 60,
|
|
130
|
+
MSG_RETRY: 60 * 60,
|
|
131
|
+
CALL_OFFER: 5 * 60,
|
|
132
|
+
USER_DEVICES: 5 * 60
|
|
146
133
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//========================================//
|
|
2
|
+
/**
|
|
3
|
+
* @project @sixcore/baileys
|
|
4
|
+
* @author Sixx.js </>🌿
|
|
5
|
+
* @version 1.0.3
|
|
6
|
+
* @license MIT
|
|
7
|
+
* @country Mozambique 🇲🇿♥️
|
|
8
|
+
* @chamadas || sms +258860817689
|
|
9
|
+
* @whatsApp +55889616-2417 || +258851907875
|
|
10
|
+
* @description Biblioteca Node.js para integração e automação no WhatsApp usando Baileys
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export default function binarySearch(array, predicate) {
|
|
15
|
+
let low = 0
|
|
16
|
+
let high = array.length
|
|
17
|
+
|
|
18
|
+
if (high === 0) return -1
|
|
19
|
+
|
|
20
|
+
while (low < high) {
|
|
21
|
+
const Mafilzin = (low + high) >> 1
|
|
22
|
+
const ninja = predicate(array[Mafilzin])
|
|
23
|
+
|
|
24
|
+
if (ninja === 0) return Mafilzin
|
|
25
|
+
if (ninja < 0) high = Mafilzin
|
|
26
|
+
else low = Mafilzin + 1
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return -1
|
|
30
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
//========================================//
|
|
2
|
+
/**
|
|
3
|
+
* @project @sixcore/baileys
|
|
4
|
+
* @author Sixx.js </>🌿
|
|
5
|
+
* @version 1.0.3
|
|
6
|
+
* @license MIT
|
|
7
|
+
* @country Mozambique 🇲🇿♥️
|
|
8
|
+
* @chamadas || sms +258860817689
|
|
9
|
+
* @whatsApp +55889616-2417 || +258851907875
|
|
10
|
+
* @description Biblioteca Node.js para integração e automação no WhatsApp usando Baileys
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
import binarySearch from "./BinarySearch.js";
|
|
15
|
+
|
|
16
|
+
export default class KeyedDB {
|
|
17
|
+
constructor(key, id) {
|
|
18
|
+
this.key = key;
|
|
19
|
+
this.idGetter = id || (v => this.key.key(v).toString());
|
|
20
|
+
this.dict = {};
|
|
21
|
+
this.array = [];
|
|
22
|
+
}
|
|
23
|
+
get length() {
|
|
24
|
+
return this.array.length;
|
|
25
|
+
}
|
|
26
|
+
get first() {
|
|
27
|
+
return this.array[0];
|
|
28
|
+
}
|
|
29
|
+
get last() {
|
|
30
|
+
return this.array[this.array.length - 1];
|
|
31
|
+
}
|
|
32
|
+
toJSON() {
|
|
33
|
+
return this.array;
|
|
34
|
+
}
|
|
35
|
+
insert(...values) {
|
|
36
|
+
values.forEach(v => this._insertSingle(v));
|
|
37
|
+
}
|
|
38
|
+
upsert(...values) {
|
|
39
|
+
const updates = [];
|
|
40
|
+
values.forEach(v => {
|
|
41
|
+
if (!v) return;
|
|
42
|
+
const deleted = this.deleteById(this.idGetter(v), false);
|
|
43
|
+
this._insertSingle(v);
|
|
44
|
+
deleted && updates.push(v);
|
|
45
|
+
});
|
|
46
|
+
return updates;
|
|
47
|
+
}
|
|
48
|
+
insertIfAbsent(...values) {
|
|
49
|
+
const insertions = [];
|
|
50
|
+
values.forEach(v => {
|
|
51
|
+
if (!v) return;
|
|
52
|
+
const presentValue = this.get(this.idGetter(v));
|
|
53
|
+
if (presentValue) return;
|
|
54
|
+
const presentKey = this.firstIndex(v);
|
|
55
|
+
if (this.array[presentKey] && this.key.key(this.array[presentKey]) === this.key.key(v)) return;
|
|
56
|
+
this.insert(v);
|
|
57
|
+
insertions.push(v);
|
|
58
|
+
});
|
|
59
|
+
return insertions;
|
|
60
|
+
}
|
|
61
|
+
deleteById(id, assertPresent = true) {
|
|
62
|
+
const value = this.get(id);
|
|
63
|
+
if (!value) {
|
|
64
|
+
if (assertPresent) throw new Error(`Value not found`);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
return this.delete(value);
|
|
68
|
+
}
|
|
69
|
+
delete(value) {
|
|
70
|
+
const index = this.firstIndex(value);
|
|
71
|
+
if (index < 0 || index >= this.array.length || this.key.key(value) !== this.key.key(this.array[index])) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
delete this.dict[this.idGetter(value)];
|
|
75
|
+
return this.array.splice(index, 1)[0];
|
|
76
|
+
}
|
|
77
|
+
slice(start, end) {
|
|
78
|
+
const db = new KeyedDB(this.key, this.idGetter);
|
|
79
|
+
db.array = this.array.slice(start, end);
|
|
80
|
+
db.array.forEach(item => db.dict[this.idGetter(item)] = item);
|
|
81
|
+
return db;
|
|
82
|
+
}
|
|
83
|
+
clear() {
|
|
84
|
+
this.array = [];
|
|
85
|
+
this.dict = {};
|
|
86
|
+
}
|
|
87
|
+
get(id) {
|
|
88
|
+
return this.dict[id];
|
|
89
|
+
}
|
|
90
|
+
all() {
|
|
91
|
+
return this.array;
|
|
92
|
+
}
|
|
93
|
+
update(id, update) {
|
|
94
|
+
const value = this.get(id);
|
|
95
|
+
if (value) {
|
|
96
|
+
const idx = this.firstIndex(value);
|
|
97
|
+
if (idx >= 0 && idx < this.array.length && this.idGetter(this.array[idx]) === id) {
|
|
98
|
+
const oldKey = this.key.key(value);
|
|
99
|
+
update(value);
|
|
100
|
+
const newKey = this.key.key(value);
|
|
101
|
+
if (newKey !== oldKey) {
|
|
102
|
+
delete this.dict[id];
|
|
103
|
+
this.array.splice(idx, 1);
|
|
104
|
+
this._insertSingle(value);
|
|
105
|
+
return 2;
|
|
106
|
+
}
|
|
107
|
+
return 1;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
updateKey(value, update) {
|
|
112
|
+
return this.update(this.idGetter(value), update);
|
|
113
|
+
}
|
|
114
|
+
filter(predicate) {
|
|
115
|
+
const db = new KeyedDB(this.key, this.idGetter);
|
|
116
|
+
db.array = this.array.filter((value, index) => {
|
|
117
|
+
if (predicate(value, index)) {
|
|
118
|
+
db.dict[this.idGetter(value)] = value;
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
return db;
|
|
123
|
+
}
|
|
124
|
+
paginatedByValue(value, limit, predicate, mode = "after") {
|
|
125
|
+
return this.paginated(value && this.key.key(value), limit, predicate, mode);
|
|
126
|
+
}
|
|
127
|
+
paginated(cursor, limit, predicate, mode = "after") {
|
|
128
|
+
let index = mode === "after" ? 0 : this.array.length;
|
|
129
|
+
if (cursor !== null && typeof cursor !== "undefined") {
|
|
130
|
+
index = binarySearch(this.array, v => this.key.compare(cursor, this.key.key(v)));
|
|
131
|
+
if (index < 0) index = 0;
|
|
132
|
+
if (this.key.key(this.array[index]) === cursor) index += (mode === "after" ? 1 : 0);
|
|
133
|
+
}
|
|
134
|
+
return this.filtered(index, limit, mode, predicate);
|
|
135
|
+
}
|
|
136
|
+
_insertSingle(value) {
|
|
137
|
+
if (!value) throw new Error("falsey value");
|
|
138
|
+
const valueID = this.idGetter(value);
|
|
139
|
+
if (this.get(valueID)) throw new Error("duplicate ID being inserted: " + valueID);
|
|
140
|
+
|
|
141
|
+
if (this.array.length > 0) {
|
|
142
|
+
const index = this.firstIndex(value);
|
|
143
|
+
if (index >= this.array.length) this.array.push(value);
|
|
144
|
+
else if (index < 0) this.array.unshift(value);
|
|
145
|
+
else if (this.key.key(value) !== this.key.key(this.array[index])) this.array.splice(index, 0, value);
|
|
146
|
+
else throw new Error(`duplicate key: ${this.key.key(value)}, inserting: ${valueID}, present: ${this.idGetter(this.array[index])}`);
|
|
147
|
+
} else {
|
|
148
|
+
this.array.push(value);
|
|
149
|
+
}
|
|
150
|
+
this.dict[valueID] = value;
|
|
151
|
+
}
|
|
152
|
+
filtered(start, count, mode, predicate) {
|
|
153
|
+
let arr;
|
|
154
|
+
if (mode === "after") {
|
|
155
|
+
if (predicate) {
|
|
156
|
+
arr = [];
|
|
157
|
+
for (let item of this.array.slice(start)) {
|
|
158
|
+
predicate(item, start + arr.length) && arr.push(item);
|
|
159
|
+
if (arr.length >= count) break;
|
|
160
|
+
}
|
|
161
|
+
} else arr = this.array.slice(start, start + count);
|
|
162
|
+
} else if (mode === "before") {
|
|
163
|
+
if (predicate) {
|
|
164
|
+
arr = [];
|
|
165
|
+
for (let i = start - 1; i >= 0; i--) {
|
|
166
|
+
let item = this.array[i];
|
|
167
|
+
predicate(item, start + arr.length) && arr.unshift(item);
|
|
168
|
+
if (arr.length >= count) break;
|
|
169
|
+
}
|
|
170
|
+
} else arr = this.array.slice(Math.max(start - count, 0), start);
|
|
171
|
+
}
|
|
172
|
+
return arr;
|
|
173
|
+
}
|
|
174
|
+
firstIndex(value) {
|
|
175
|
+
const valueKey = this.key.key(value);
|
|
176
|
+
return binarySearch(this.array, v => this.key.compare(valueKey, this.key.key(v)));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//========================================//
|
|
2
|
+
/**
|
|
3
|
+
* @project @sixcore/baileys
|
|
4
|
+
* @author Sixx.js </>🌿
|
|
5
|
+
* @version 1.0.3
|
|
6
|
+
* @license MIT
|
|
7
|
+
* @country Mozambique 🇲🇿♥️
|
|
8
|
+
* @chamadas || sms +258860817689
|
|
9
|
+
* @whatsApp +55889616-2417 || +258851907875
|
|
10
|
+
* @description Biblioteca Node.js para integração e automação no WhatsApp usando Baileys
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export * from "./BinarySearch.js"
|
|
14
|
+
export * from "./KeyedDB.js"
|
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
//========================================//
|
|
2
|
+
/**
|
|
3
|
+
* @project @sixcore/baileys
|
|
4
|
+
* @author Sixx.js </>🌿
|
|
5
|
+
* @version 1.0.3
|
|
6
|
+
* @license MIT
|
|
7
|
+
* @country Mozambique 🇲🇿♥️
|
|
8
|
+
* @chamadas || sms +258860817689
|
|
9
|
+
* @whatsApp +55889616-2417 || +258851907875
|
|
10
|
+
* @description Biblioteca Node.js para integração e automação no WhatsApp usando Baileys
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export class CiphertextMessage {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.UNSUPPORTED_VERSION = 1;
|
|
16
|
+
this.CURRENT_VERSION = 3;
|
|
17
|
+
this.WHISPER_TYPE = 2;
|
|
18
|
+
this.PREKEY_TYPE = 3;
|
|
19
|
+
this.SENDERKEY_TYPE = 4;
|
|
20
|
+
this.SENDERKEY_DISTRIBUTION_TYPE = 5;
|
|
21
|
+
this.ENCRYPTED_MESSAGE_OVERHEAD = 53;
|
|
22
|
+
}
|
|
14
23
|
}
|
|
15
|
-
exports.CiphertextMessage = CiphertextMessage;
|
|
@@ -1,42 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
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
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.GroupSessionBuilder = void 0;
|
|
37
|
-
const keyhelper = __importStar(require("./keyhelper"));
|
|
38
|
-
const sender_key_distribution_message_1 = require("./sender-key-distribution-message");
|
|
39
|
-
class GroupSessionBuilder {
|
|
1
|
+
//========================================//
|
|
2
|
+
/**
|
|
3
|
+
* @project @sixcore/baileys
|
|
4
|
+
* @author Sixx.js </>🌿
|
|
5
|
+
* @version 1.0.3
|
|
6
|
+
* @license MIT
|
|
7
|
+
* @country Mozambique 🇲🇿♥️
|
|
8
|
+
* @chamadas || sms +258860817689
|
|
9
|
+
* @whatsApp +55889616-2417 || +258851907875
|
|
10
|
+
* @description Biblioteca Node.js para integração e automação no WhatsApp usando Baileys
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { SenderKeyDistributionMessage } from "./sender-key-distribution-message.js";
|
|
14
|
+
import { SenderKeyRecord } from "./sender-key-record.js";
|
|
15
|
+
import { SenderKeyName } from "./sender-key-name.js";
|
|
16
|
+
import * as keyhelper from "./keyhelper.js";
|
|
17
|
+
|
|
18
|
+
export class GroupSessionBuilder {
|
|
40
19
|
constructor(senderKeyStore) {
|
|
41
20
|
this.senderKeyStore = senderKeyStore;
|
|
42
21
|
}
|
|
@@ -56,9 +35,9 @@ class GroupSessionBuilder {
|
|
|
56
35
|
}
|
|
57
36
|
const state = senderKeyRecord.getSenderKeyState();
|
|
58
37
|
if (!state) {
|
|
59
|
-
throw new Error(
|
|
38
|
+
throw new Error("No session state available");
|
|
60
39
|
}
|
|
61
|
-
return new
|
|
40
|
+
return new SenderKeyDistributionMessage(state.getKeyId(), state.getSenderChainKey().getIteration(), state.getSenderChainKey().getSeed(), state.getSigningKeyPublic());
|
|
62
41
|
}
|
|
63
42
|
}
|
|
64
|
-
|
|
43
|
+
//# sourceMappingURL=group-session-builder.js.map
|