vialeys 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -5
- package/WAProto/AICommon/AICommon.js +13991 -9169
- package/WAProto/AICommon/AICommon.proto +110 -3
- package/WAProto/CompanionReg/CompanionReg.js +114 -0
- package/WAProto/CompanionReg/CompanionReg.proto +3 -0
- package/WAProto/DeviceCapabilities/DeviceCapabilities.js +652 -0
- package/WAProto/DeviceCapabilities/DeviceCapabilities.proto +19 -0
- package/WAProto/E2E/E2E.js +77193 -51248
- package/WAProto/E2E/E2E.proto +68 -12
- package/WAProto/HistorySync/HistorySync.js +3375 -178
- package/WAProto/HistorySync/HistorySync.proto +3 -3
- package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.js +98 -49
- package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.proto +2 -2
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.js +75226 -48422
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.proto +6 -0
- package/WAProto/StatusAttributions/StatusAttributions.js +21 -0
- package/WAProto/StatusAttributions/StatusAttributions.proto +3 -0
- package/WAProto/SyncAction/SyncAction.js +9423 -2023
- package/WAProto/SyncAction/SyncAction.proto +208 -15
- package/WAProto/Wa6/Wa6.js +83 -0
- package/WAProto/Wa6/Wa6.proto +3 -0
- package/WAProto/Web/Web.js +92664 -63403
- package/WAProto/Web/Web.proto +31 -13
- package/engine-requirements.js +9 -7
- package/lib/Defaults/baileys-version.json +2 -2
- package/lib/Defaults/connection.js +51 -0
- package/lib/Defaults/constants.js +62 -0
- package/lib/Defaults/history.js +17 -0
- package/lib/Defaults/index.js +36 -142
- package/lib/Defaults/media.js +48 -0
- package/lib/Defaults/prefix.js +18 -0
- package/lib/Signal/Group/group-session-builder.js +10 -42
- package/lib/Signal/Group/group_cipher.js +9 -6
- package/lib/Signal/Group/index.js +39 -53
- package/lib/Signal/Group/keyhelper.js +8 -41
- package/lib/Signal/Group/sender-chain-key.js +4 -4
- package/lib/Signal/Group/sender-key-distribution-message.js +5 -5
- package/lib/Signal/Group/sender-key-message.js +12 -8
- package/lib/Signal/Group/sender-key-state.js +4 -4
- package/lib/Signal/Group/sender-message-key.js +2 -2
- package/lib/Signal/libsignal.js +45 -69
- package/lib/Signal/lid-mapping.js +15 -11
- package/lib/Socket/Client/types.js +2 -2
- package/lib/Socket/Client/websocket.js +16 -14
- package/lib/Socket/business.js +41 -32
- package/lib/Socket/chats.js +123 -98
- package/lib/Socket/community.js +50 -40
- package/lib/Socket/groups.js +59 -47
- package/lib/Socket/index.js +4 -4
- package/lib/Socket/messages-recv.js +226 -171
- package/lib/Socket/messages-send.js +187 -143
- package/lib/Socket/newsletter.js +61 -47
- package/lib/Socket/socket.js +133 -90
- package/lib/Socket/usync.js +6 -6
- package/lib/Store/index.js +27 -11
- package/lib/Store/make-cache-manager-store.js +14 -15
- package/lib/Store/make-in-memory-store.js +28 -24
- package/lib/Types/LabelAssociation.js +2 -2
- package/lib/Types/Message.js +6 -6
- package/lib/Types/MexUpdates.js +5 -4
- package/lib/Types/State.js +4 -4
- package/lib/Types/index.js +28 -12
- package/lib/Utils/auth-utils.js +28 -26
- package/lib/Utils/baileys-event-stream.js +68 -69
- package/lib/Utils/business.js +63 -53
- package/lib/Utils/chat-utils.js +81 -71
- package/lib/Utils/crypto.js +25 -45
- package/lib/Utils/decode-wa-message.js +319 -311
- package/lib/Utils/event-buffer.js +21 -22
- package/lib/Utils/generics.js +103 -73
- package/lib/Utils/history.js +21 -21
- package/lib/Utils/index.js +27 -13
- package/lib/Utils/link-preview.js +7 -30
- package/lib/Utils/logger.js +5 -5
- package/lib/Utils/lt-hash.js +3 -3
- package/lib/Utils/message-retry-manager.js +4 -4
- package/lib/Utils/messages-media.js +104 -109
- package/lib/Utils/messages.js +203 -171
- package/lib/Utils/noise-handler.js +28 -19
- package/lib/Utils/process-message.js +370 -136
- package/lib/Utils/signal.js +36 -25
- package/lib/Utils/use-multi-file-auth-state.js +18 -22
- package/lib/Utils/validate-connection.js +52 -45
- package/lib/WABinary/decode.js +6 -32
- package/lib/WABinary/encode.js +3 -29
- package/lib/WABinary/generic-utils.js +4 -4
- package/lib/WABinary/index.js +27 -11
- package/lib/WAM/encode.js +16 -8
- package/lib/WAM/index.js +27 -11
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +20 -16
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +7 -4
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +0 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -2
- package/lib/WAUSync/Protocols/index.js +27 -11
- package/lib/WAUSync/USyncQuery.js +17 -10
- package/lib/WAUSync/index.js +27 -11
- package/lib/index.js +62 -37
- package/package.json +1 -1
- package/WAProto/index.d.ts +0 -55
- package/lib/index.d.ts +0 -13
package/WAProto/Web/Web.proto
CHANGED
|
@@ -4,25 +4,33 @@ package Web;
|
|
|
4
4
|
import "../E2E/E2E.proto";
|
|
5
5
|
import "../Protocol/Protocol.proto";
|
|
6
6
|
|
|
7
|
-
message
|
|
8
|
-
optional
|
|
7
|
+
message QuarantinedMessage {
|
|
8
|
+
optional bytes originalData = 1;
|
|
9
|
+
optional string extractedText = 2;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
message GroupHistoryBundleInfo {
|
|
13
|
+
optional E2E.Message.MessageHistoryBundle deprecatedMessageHistoryBundle = 1;
|
|
9
14
|
optional ProcessState processState = 2;
|
|
10
15
|
enum ProcessState {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
NOT_INJECTED = 0;
|
|
17
|
+
INJECTED = 1;
|
|
18
|
+
INJECTED_PARTIAL = 2;
|
|
19
|
+
INJECTION_FAILED = 3;
|
|
20
|
+
INJECTION_FAILED_NO_RETRY = 4;
|
|
14
21
|
}
|
|
15
22
|
}
|
|
16
23
|
|
|
17
24
|
message GroupHistoryIndividualMessageInfo {
|
|
18
25
|
optional Protocol.MessageKey bundleMessageKey = 1;
|
|
26
|
+
optional bool editedAfterReceivedAsHistory = 2;
|
|
19
27
|
}
|
|
20
28
|
|
|
21
29
|
message Citation {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
optional string title = 1;
|
|
31
|
+
optional string subtitle = 2;
|
|
32
|
+
optional string cmsId = 3;
|
|
33
|
+
optional string imageUrl = 4;
|
|
26
34
|
}
|
|
27
35
|
|
|
28
36
|
message StatusMentionMessage {
|
|
@@ -94,6 +102,10 @@ message EventAdditionalMetadata {
|
|
|
94
102
|
optional bool isStale = 1;
|
|
95
103
|
}
|
|
96
104
|
|
|
105
|
+
message InteractiveMessageAdditionalMetadata {
|
|
106
|
+
optional bool isGalaxyFlowCompleted = 1;
|
|
107
|
+
}
|
|
108
|
+
|
|
97
109
|
message PollAdditionalMetadata {
|
|
98
110
|
optional bool pollInvalidated = 1;
|
|
99
111
|
}
|
|
@@ -115,7 +127,7 @@ message Reaction {
|
|
|
115
127
|
}
|
|
116
128
|
|
|
117
129
|
message UserReceipt {
|
|
118
|
-
|
|
130
|
+
optional string userJid = 1;
|
|
119
131
|
optional int64 receiptTimestamp = 2;
|
|
120
132
|
optional int64 readTimestamp = 3;
|
|
121
133
|
optional int64 playedTimestamp = 4;
|
|
@@ -124,7 +136,7 @@ message UserReceipt {
|
|
|
124
136
|
}
|
|
125
137
|
|
|
126
138
|
message StatusPSA {
|
|
127
|
-
|
|
139
|
+
optional uint64 campaignId = 44;
|
|
128
140
|
optional uint64 campaignExpirationTimestamp = 45;
|
|
129
141
|
}
|
|
130
142
|
|
|
@@ -284,7 +296,7 @@ message CommentMetadata {
|
|
|
284
296
|
}
|
|
285
297
|
|
|
286
298
|
message WebMessageInfo {
|
|
287
|
-
|
|
299
|
+
optional Protocol.MessageKey key = 1;
|
|
288
300
|
optional E2E.Message message = 2;
|
|
289
301
|
optional uint64 messageTimestamp = 3;
|
|
290
302
|
optional Status status = 4;
|
|
@@ -347,7 +359,9 @@ message WebMessageInfo {
|
|
|
347
359
|
repeated Citation supportAiCitations = 72;
|
|
348
360
|
optional string botTargetId = 73;
|
|
349
361
|
optional GroupHistoryIndividualMessageInfo groupHistoryIndividualMessageInfo = 74;
|
|
350
|
-
optional
|
|
362
|
+
optional GroupHistoryBundleInfo groupHistoryBundleInfo = 75;
|
|
363
|
+
optional InteractiveMessageAdditionalMetadata interactiveMessageAdditionalMetadata = 76;
|
|
364
|
+
optional QuarantinedMessage quarantinedMessage = 77;
|
|
351
365
|
enum BizPrivacyStatus {
|
|
352
366
|
E2EE = 0;
|
|
353
367
|
FB = 2;
|
|
@@ -583,5 +597,9 @@ message WebMessageInfo {
|
|
|
583
597
|
GROUP_MEMBER_LINK_MODE = 217;
|
|
584
598
|
BIZ_AUTOMATICALLY_LABELED_CHAT_SYSTEM_MESSAGE = 218;
|
|
585
599
|
PHONE_NUMBER_HIDING_CHAT_DEPRECATED_MESSAGE = 219;
|
|
600
|
+
QUARANTINED_MESSAGE = 220;
|
|
601
|
+
GROUP_MEMBER_SHARE_GROUP_HISTORY_MODE = 221;
|
|
602
|
+
GROUP_OPEN_BOT_ADDED = 222;
|
|
603
|
+
GROUP_TEE_BOT_ADDED = 223;
|
|
586
604
|
}
|
|
587
605
|
}
|
package/engine-requirements.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
parseInt(process.versions.node.split('.')[0],10)
|
|
1
|
+
const major = parseInt(process.versions.node.split('.')[0], 10);
|
|
2
|
+
|
|
3
|
+
if (major < 20) {
|
|
2
4
|
console.error(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
`\n❌ This package requires Node.js 20+ to run reliably.\n` +
|
|
6
|
+
` You are using Node.js ${process.versions.node}.\n` +
|
|
7
|
+
` Please upgrade to Node.js 20+ to proceed.\n`
|
|
8
|
+
);
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": [2, 3000,
|
|
3
|
-
}
|
|
2
|
+
"version": [2, 3000, 1030003753]
|
|
3
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
+
|
|
5
|
+
const { Browsers } = require("../Utils")
|
|
6
|
+
const { default: logger } = require("../Utils/logger")
|
|
7
|
+
const { makeLibSignalRepository } = require("../Signal/libsignal")
|
|
8
|
+
const { version } = require("./baileys-version.json")
|
|
9
|
+
|
|
10
|
+
const DEFAULT_CONNECTION_CONFIG = {
|
|
11
|
+
version,
|
|
12
|
+
browser: Browsers.windows('Chrome'),
|
|
13
|
+
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
|
14
|
+
connectTimeoutMs: 20000,
|
|
15
|
+
keepAliveIntervalMs: 30000,
|
|
16
|
+
logger: logger.child({ class: 'baileys' }),
|
|
17
|
+
printQRInTerminal: false,
|
|
18
|
+
emitOwnEvents: true,
|
|
19
|
+
defaultQueryTimeoutMs: 60000,
|
|
20
|
+
customUploadHosts: [],
|
|
21
|
+
retryRequestDelayMs: 250,
|
|
22
|
+
maxMsgRetryCount: 5,
|
|
23
|
+
fireInitQueries: true,
|
|
24
|
+
auth: undefined,
|
|
25
|
+
markOnlineOnConnect: true,
|
|
26
|
+
syncFullHistory: false,
|
|
27
|
+
patchMessageBeforeSending: msg => msg,
|
|
28
|
+
shouldSyncHistoryMessage: () => true,
|
|
29
|
+
shouldIgnoreJid: () => false,
|
|
30
|
+
linkPreviewImageThumbnailWidth: 192,
|
|
31
|
+
transactionOpts: {
|
|
32
|
+
maxCommitRetries: 10,
|
|
33
|
+
delayBetweenTriesMs: 3000
|
|
34
|
+
},
|
|
35
|
+
generateHighQualityLinkPreview: false,
|
|
36
|
+
enableAutoSessionRecreation: true,
|
|
37
|
+
enableRecentMessageCache: true,
|
|
38
|
+
options: {},
|
|
39
|
+
appStateMacVerification: {
|
|
40
|
+
patch: false,
|
|
41
|
+
snapshot: false,
|
|
42
|
+
},
|
|
43
|
+
countryCode: 'EN',
|
|
44
|
+
getMessage: async () => undefined,
|
|
45
|
+
cachedGroupMetadata: async () => undefined,
|
|
46
|
+
makeSignalRepository: makeLibSignalRepository
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module.exports = {
|
|
50
|
+
DEFAULT_CONNECTION_CONFIG
|
|
51
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
+
|
|
5
|
+
const UNAUTHORIZED_CODES = [401, 403, 419]
|
|
6
|
+
|
|
7
|
+
const PHONENUMBER_MCC = require("./phonenumber-mcc.json")
|
|
8
|
+
|
|
9
|
+
const DEFAULT_ORIGIN = 'https://web.whatsapp.com'
|
|
10
|
+
|
|
11
|
+
const PHONE_CONNECTION_CB = 'CB:Pong'
|
|
12
|
+
|
|
13
|
+
const WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60
|
|
14
|
+
|
|
15
|
+
const NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0'
|
|
16
|
+
|
|
17
|
+
const DICT_VERSION = 3
|
|
18
|
+
|
|
19
|
+
const KEY_BUNDLE_TYPE = Buffer.from([5])
|
|
20
|
+
|
|
21
|
+
const NOISE_WA_HEADER = Buffer.from([87, 65, 6, DICT_VERSION]) // last is "DICT_VERSION"
|
|
22
|
+
|
|
23
|
+
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
24
|
+
const URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g
|
|
25
|
+
|
|
26
|
+
const MIN_PREKEY_COUNT = 5
|
|
27
|
+
|
|
28
|
+
const INITIAL_PREKEY_COUNT = 30
|
|
29
|
+
|
|
30
|
+
const UPLOAD_TIMEOUT = 30000 // 30 seconds
|
|
31
|
+
|
|
32
|
+
const MIN_UPLOAD_INTERVAL = 5000 // seconds minimum between uploads
|
|
33
|
+
|
|
34
|
+
const WA_CERT_DETAILS = {
|
|
35
|
+
SERIAL: 0
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const DEFAULT_CACHE_TTLS = {
|
|
39
|
+
SIGNAL_STORE: 5 * 60,
|
|
40
|
+
MSG_RETRY: 60 * 60,
|
|
41
|
+
CALL_OFFER: 5 * 60,
|
|
42
|
+
USER_DEVICES: 5 * 60, // 5 minutes
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = {
|
|
46
|
+
UNAUTHORIZED_CODES,
|
|
47
|
+
PHONENUMBER_MCC,
|
|
48
|
+
DEFAULT_ORIGIN,
|
|
49
|
+
PHONE_CONNECTION_CB,
|
|
50
|
+
WA_DEFAULT_EPHEMERAL,
|
|
51
|
+
NOISE_MODE,
|
|
52
|
+
DICT_VERSION,
|
|
53
|
+
KEY_BUNDLE_TYPE,
|
|
54
|
+
NOISE_WA_HEADER,
|
|
55
|
+
URL_REGEX,
|
|
56
|
+
MIN_PREKEY_COUNT,
|
|
57
|
+
MIN_UPLOAD_INTERVAL,
|
|
58
|
+
INITIAL_PREKEY_COUNT,
|
|
59
|
+
UPLOAD_TIMEOUT,
|
|
60
|
+
WA_CERT_DETAILS,
|
|
61
|
+
DEFAULT_CACHE_TTLS
|
|
62
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
+
|
|
5
|
+
const { proto } = require("../../WAProto")
|
|
6
|
+
|
|
7
|
+
const PROCESSABLE_HISTORY_TYPES = [
|
|
8
|
+
proto.Message.HistorySyncType.INITIAL_BOOTSTRAP,
|
|
9
|
+
proto.Message.HistorySyncType.PUSH_NAME,
|
|
10
|
+
proto.Message.HistorySyncType.RECENT,
|
|
11
|
+
proto.Message.HistorySyncType.FULL,
|
|
12
|
+
proto.Message.HistorySyncType.ON_DEMAND
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
module.exports = {
|
|
16
|
+
PROCESSABLE_HISTORY_TYPES
|
|
17
|
+
}
|
package/lib/Defaults/index.js
CHANGED
|
@@ -1,147 +1,41 @@
|
|
|
1
1
|
"use strict"
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k
|
|
5
|
+
|
|
6
|
+
let desc = Object.getOwnPropertyDescriptor(m, k)
|
|
7
|
+
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return m[k]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
Object.defineProperty(o, k2, desc)
|
|
18
|
+
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k
|
|
21
|
+
o[k2] = m[k]
|
|
22
|
+
}
|
|
23
|
+
))
|
|
24
|
+
|
|
25
|
+
const __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
+
for (var p in m) {
|
|
27
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) {
|
|
28
|
+
__createBinding(exports, m, p)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
5
31
|
}
|
|
6
32
|
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
33
|
+
Object.defineProperty(exports, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
})
|
|
8
36
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const logger_1 = __importDefault(require("../Utils/logger"));
|
|
15
|
-
const baileys_version_json_1 = require("./baileys-version.json");
|
|
16
|
-
const phonenumber_mcc_json_1 = __importDefault(require("./phonenumber-mcc.json"))
|
|
17
|
-
|
|
18
|
-
exports.UNAUTHORIZED_CODES = [401, 403, 419]
|
|
19
|
-
|
|
20
|
-
exports.PHONENUMBER_MCC = phonenumber_mcc_json_1.default
|
|
21
|
-
|
|
22
|
-
exports.DEFAULT_ORIGIN = 'https://web.whatsapp.com'
|
|
23
|
-
|
|
24
|
-
exports.CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/'
|
|
25
|
-
|
|
26
|
-
exports.CALL_AUDIO_PREFIX = 'https://call.whatsapp.com/voice/'
|
|
27
|
-
|
|
28
|
-
exports.DEF_CALLBACK_PREFIX = 'CB:'
|
|
29
|
-
|
|
30
|
-
exports.DEF_TAG_PREFIX = 'TAG:'
|
|
31
|
-
|
|
32
|
-
exports.PHONE_CONNECTION_CB = 'CB:Pong'
|
|
33
|
-
|
|
34
|
-
exports.WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60
|
|
35
|
-
|
|
36
|
-
exports.NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0'
|
|
37
|
-
|
|
38
|
-
exports.DICT_VERSION = 3
|
|
39
|
-
|
|
40
|
-
exports.KEY_BUNDLE_TYPE = Buffer.from([5])
|
|
41
|
-
|
|
42
|
-
exports.NOISE_WA_HEADER = Buffer.from([87, 65, 6, exports.DICT_VERSION]) // last is "DICT_VERSION"
|
|
43
|
-
|
|
44
|
-
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
45
|
-
exports.URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g
|
|
46
|
-
|
|
47
|
-
exports.WA_CERT_DETAILS = {
|
|
48
|
-
SERIAL: 0,
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
exports.PROCESSABLE_HISTORY_TYPES = [
|
|
52
|
-
WAProto_1.proto.Message.HistorySyncType.INITIAL_BOOTSTRAP,
|
|
53
|
-
WAProto_1.proto.Message.HistorySyncType.PUSH_NAME,
|
|
54
|
-
WAProto_1.proto.Message.HistorySyncType.RECENT,
|
|
55
|
-
WAProto_1.proto.Message.HistorySyncType.FULL,
|
|
56
|
-
WAProto_1.proto.Message.HistorySyncType.ON_DEMAND
|
|
57
|
-
]
|
|
58
|
-
|
|
59
|
-
exports.DEFAULT_CONNECTION_CONFIG = {
|
|
60
|
-
version: baileys_version_json_1.version,
|
|
61
|
-
browser: Utils_1.Browsers.windows('Chrome'),
|
|
62
|
-
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
|
63
|
-
connectTimeoutMs: 20000,
|
|
64
|
-
keepAliveIntervalMs: 30000,
|
|
65
|
-
logger: logger_1.default.child({ class: 'baileys' }),
|
|
66
|
-
printQRInTerminal: false,
|
|
67
|
-
emitOwnEvents: true,
|
|
68
|
-
defaultQueryTimeoutMs: 60000,
|
|
69
|
-
customUploadHosts: [],
|
|
70
|
-
retryRequestDelayMs: 250,
|
|
71
|
-
maxMsgRetryCount: 5,
|
|
72
|
-
fireInitQueries: true,
|
|
73
|
-
auth: undefined,
|
|
74
|
-
markOnlineOnConnect: true,
|
|
75
|
-
syncFullHistory: false,
|
|
76
|
-
patchMessageBeforeSending: msg => msg,
|
|
77
|
-
shouldSyncHistoryMessage: () => true,
|
|
78
|
-
shouldIgnoreJid: () => false,
|
|
79
|
-
linkPreviewImageThumbnailWidth: 192,
|
|
80
|
-
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
|
|
81
|
-
generateHighQualityLinkPreview: false,
|
|
82
|
-
enableAutoSessionRecreation: true,
|
|
83
|
-
enableRecentMessageCache: true,
|
|
84
|
-
options: {},
|
|
85
|
-
appStateMacVerification: {
|
|
86
|
-
patch: false,
|
|
87
|
-
snapshot: false,
|
|
88
|
-
},
|
|
89
|
-
countryCode: 'EN',
|
|
90
|
-
getMessage: async () => undefined,
|
|
91
|
-
cachedGroupMetadata: async () => undefined,
|
|
92
|
-
makeSignalRepository: libsignal_1.makeLibSignalRepository
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
exports.MEDIA_PATH_MAP = {
|
|
96
|
-
image: '/mms/image',
|
|
97
|
-
video: '/mms/video',
|
|
98
|
-
document: '/mms/document',
|
|
99
|
-
audio: '/mms/audio',
|
|
100
|
-
sticker: '/mms/image',
|
|
101
|
-
'sticker-pack': '/mms/sticker',
|
|
102
|
-
'thumbnail-link': '/mms/image',
|
|
103
|
-
'product-catalog-image': '/product/image',
|
|
104
|
-
'md-app-state': '',
|
|
105
|
-
'md-msg-hist': '/mms/md-app-state',
|
|
106
|
-
'biz-cover-photo': '/pps/biz-cover-photo'
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
exports.MEDIA_HKDF_KEY_MAPPING = {
|
|
110
|
-
'audio': 'Audio',
|
|
111
|
-
'document': 'Document',
|
|
112
|
-
'gif': 'Video',
|
|
113
|
-
'image': 'Image',
|
|
114
|
-
'ppic': '',
|
|
115
|
-
'product': 'Image',
|
|
116
|
-
'ptt': 'Audio',
|
|
117
|
-
'video': 'Video',
|
|
118
|
-
'sticker': 'Image',
|
|
119
|
-
'sticker-pack': 'Sticker Pack',
|
|
120
|
-
'thumbnail-document': 'Document Thumbnail',
|
|
121
|
-
'thumbnail-image': 'Image Thumbnail',
|
|
122
|
-
'thumbnail-video': 'Video Thumbnail',
|
|
123
|
-
'thumbnail-link': 'Link Thumbnail',
|
|
124
|
-
'md-msg-hist': 'History',
|
|
125
|
-
'md-app-state': 'App State',
|
|
126
|
-
'product-catalog-image': '',
|
|
127
|
-
'payment-bg-image': 'Payment Background',
|
|
128
|
-
'ptv': 'Video',
|
|
129
|
-
'biz-cover-photo': 'Image'
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
exports.MEDIA_KEYS = Object.keys(exports.MEDIA_PATH_MAP)
|
|
133
|
-
|
|
134
|
-
exports.MIN_PREKEY_COUNT = 5
|
|
135
|
-
|
|
136
|
-
exports.INITIAL_PREKEY_COUNT = 30
|
|
137
|
-
|
|
138
|
-
exports.UPLOAD_TIMEOUT = 30000 // 30 seconds
|
|
139
|
-
|
|
140
|
-
exports.MIN_UPLOAD_INTERVAL = 5000 // seconds minimum between uploads
|
|
141
|
-
|
|
142
|
-
exports.DEFAULT_CACHE_TTLS = {
|
|
143
|
-
SIGNAL_STORE: 5 * 60,
|
|
144
|
-
MSG_RETRY: 60 * 60,
|
|
145
|
-
CALL_OFFER: 5 * 60,
|
|
146
|
-
USER_DEVICES: 5 * 60, // 5 minutes
|
|
147
|
-
}
|
|
37
|
+
__exportStar(require("./connection"), exports)
|
|
38
|
+
__exportStar(require("./constants"), exports)
|
|
39
|
+
__exportStar(require("./history"), exports)
|
|
40
|
+
__exportStar(require("./media"), exports)
|
|
41
|
+
__exportStar(require("./prefix"), exports)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
+
|
|
5
|
+
const MEDIA_PATH_MAP = {
|
|
6
|
+
image: '/mms/image',
|
|
7
|
+
video: '/mms/video',
|
|
8
|
+
document: '/mms/document',
|
|
9
|
+
audio: '/mms/audio',
|
|
10
|
+
sticker: '/mms/image',
|
|
11
|
+
'sticker-pack': '/mms/sticker',
|
|
12
|
+
'thumbnail-link': '/mms/image',
|
|
13
|
+
'product-catalog-image': '/product/image',
|
|
14
|
+
'md-app-state': '',
|
|
15
|
+
'md-msg-hist': '/mms/md-app-state',
|
|
16
|
+
'biz-cover-photo': '/pps/biz-cover-photo'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const MEDIA_HKDF_KEY_MAPPING = {
|
|
20
|
+
'audio': 'Audio',
|
|
21
|
+
'document': 'Document',
|
|
22
|
+
'gif': 'Video',
|
|
23
|
+
'image': 'Image',
|
|
24
|
+
'ppic': '',
|
|
25
|
+
'product': 'Image',
|
|
26
|
+
'ptt': 'Audio',
|
|
27
|
+
'video': 'Video',
|
|
28
|
+
'sticker': 'Image',
|
|
29
|
+
'sticker-pack': 'Sticker Pack',
|
|
30
|
+
'thumbnail-document': 'Document Thumbnail',
|
|
31
|
+
'thumbnail-image': 'Image Thumbnail',
|
|
32
|
+
'thumbnail-video': 'Video Thumbnail',
|
|
33
|
+
'thumbnail-link': 'Link Thumbnail',
|
|
34
|
+
'md-msg-hist': 'History',
|
|
35
|
+
'md-app-state': 'App State',
|
|
36
|
+
'product-catalog-image': '',
|
|
37
|
+
'payment-bg-image': 'Payment Background',
|
|
38
|
+
'ptv': 'Video',
|
|
39
|
+
'biz-cover-photo': 'Image'
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const MEDIA_KEYS = Object.keys(MEDIA_PATH_MAP)
|
|
43
|
+
|
|
44
|
+
module.exports = {
|
|
45
|
+
MEDIA_KEYS,
|
|
46
|
+
MEDIA_PATH_MAP,
|
|
47
|
+
MEDIA_HKDF_KEY_MAPPING
|
|
48
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
+
|
|
5
|
+
const DEF_TAG_PREFIX = 'TAG:'
|
|
6
|
+
|
|
7
|
+
const DEF_CALLBACK_PREFIX = 'CB:'
|
|
8
|
+
|
|
9
|
+
const CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/'
|
|
10
|
+
|
|
11
|
+
const CALL_AUDIO_PREFIX = 'https://call.whatsapp.com/voice/'
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
DEF_TAG_PREFIX,
|
|
15
|
+
DEF_CALLBACK_PREFIX,
|
|
16
|
+
CALL_VIDEO_PREFIX,
|
|
17
|
+
CALL_AUDIO_PREFIX
|
|
18
|
+
}
|
|
@@ -1,45 +1,13 @@
|
|
|
1
1
|
"use strict"
|
|
2
2
|
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k)
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k] } }
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc)
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k
|
|
12
|
-
o[k2] = m[k]
|
|
13
|
-
}))
|
|
14
|
-
|
|
15
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v })
|
|
17
|
-
}) : function(o, v) {
|
|
18
|
-
o["default"] = v
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
-
var ownKeys = function(o) {
|
|
23
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
-
var ar = []
|
|
25
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k
|
|
26
|
-
return ar
|
|
27
|
-
}
|
|
28
|
-
return ownKeys(o)
|
|
29
|
-
}
|
|
30
|
-
return function (mod) {
|
|
31
|
-
if (mod && mod.__esModule) return mod
|
|
32
|
-
var result = {}
|
|
33
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i])
|
|
34
|
-
__setModuleDefault(result, mod)
|
|
35
|
-
return result
|
|
36
|
-
}
|
|
37
|
-
})()
|
|
38
|
-
|
|
39
3
|
Object.defineProperty(exports, "__esModule", { value: true })
|
|
40
4
|
|
|
41
|
-
const
|
|
42
|
-
|
|
5
|
+
const {
|
|
6
|
+
generateSenderKey,
|
|
7
|
+
generateSenderKeyId,
|
|
8
|
+
generateSenderSigningKey
|
|
9
|
+
} = require("./keyhelper")
|
|
10
|
+
const { SenderKeyDistributionMessage } = require("./sender-key-distribution-message")
|
|
43
11
|
|
|
44
12
|
class GroupSessionBuilder {
|
|
45
13
|
constructor(senderKeyStore) {
|
|
@@ -53,9 +21,9 @@ class GroupSessionBuilder {
|
|
|
53
21
|
async create(senderKeyName) {
|
|
54
22
|
const senderKeyRecord = await this.senderKeyStore.loadSenderKey(senderKeyName)
|
|
55
23
|
if (senderKeyRecord.isEmpty()) {
|
|
56
|
-
const keyId =
|
|
57
|
-
const senderKey =
|
|
58
|
-
const signingKey =
|
|
24
|
+
const keyId = generateSenderKeyId()
|
|
25
|
+
const senderKey = generateSenderKey()
|
|
26
|
+
const signingKey = generateSenderSigningKey()
|
|
59
27
|
senderKeyRecord.setSenderKeyState(keyId, 0, senderKey, signingKey)
|
|
60
28
|
await this.senderKeyStore.storeSenderKey(senderKeyName, senderKeyRecord)
|
|
61
29
|
}
|
|
@@ -63,7 +31,7 @@ class GroupSessionBuilder {
|
|
|
63
31
|
if (!state) {
|
|
64
32
|
throw new Error('No session state available')
|
|
65
33
|
}
|
|
66
|
-
return new
|
|
34
|
+
return new SenderKeyDistributionMessage(state.getKeyId(), state.getSenderChainKey().getIteration(), state.getSenderChainKey().getSeed(), state.getSigningKeyPublic())
|
|
67
35
|
}
|
|
68
36
|
}
|
|
69
37
|
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const {
|
|
6
|
+
decrypt,
|
|
7
|
+
encrypt
|
|
8
|
+
} = require("libsignal-node/src/crypto")
|
|
9
|
+
const { SenderKeyMessage } = require("./sender-key-message")
|
|
7
10
|
|
|
8
11
|
class GroupCipher {
|
|
9
12
|
constructor(senderKeyStore, senderKeyName) {
|
|
@@ -26,7 +29,7 @@ class GroupCipher {
|
|
|
26
29
|
const iteration = senderKeyState.getSenderChainKey().getIteration()
|
|
27
30
|
const senderKey = this.getSenderKey(senderKeyState, iteration === 0 ? 0 : iteration + 1)
|
|
28
31
|
const ciphertext = await this.getCipherText(senderKey.getIv(), senderKey.getCipherKey(), paddedPlaintext)
|
|
29
|
-
const senderKeyMessage = new
|
|
32
|
+
const senderKeyMessage = new SenderKeyMessage(senderKeyState.getKeyId(), senderKey.getIteration(), ciphertext, senderKeyState.getSigningKeyPrivate())
|
|
30
33
|
|
|
31
34
|
await this.senderKeyStore.storeSenderKey(this.senderKeyName, record)
|
|
32
35
|
|
|
@@ -39,7 +42,7 @@ class GroupCipher {
|
|
|
39
42
|
throw new Error('No SenderKeyRecord found for decryption')
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
const senderKeyMessage = new
|
|
45
|
+
const senderKeyMessage = new SenderKeyMessage(null, null, null, null, senderKeyMessageBytes)
|
|
43
46
|
const senderKeyState = record.getSenderKeyState(senderKeyMessage.getKeyId())
|
|
44
47
|
|
|
45
48
|
if (!senderKeyState) {
|
|
@@ -87,7 +90,7 @@ class GroupCipher {
|
|
|
87
90
|
}
|
|
88
91
|
async getPlainText(iv, key, ciphertext) {
|
|
89
92
|
try {
|
|
90
|
-
return
|
|
93
|
+
return decrypt(key, ciphertext, iv)
|
|
91
94
|
}
|
|
92
95
|
catch (e) {
|
|
93
96
|
throw new Error('InvalidMessageException')
|
|
@@ -98,7 +101,7 @@ class GroupCipher {
|
|
|
98
101
|
const ivBuffer = typeof iv === 'string' ? Buffer.from(iv, 'base64') : iv
|
|
99
102
|
const keyBuffer = typeof key === 'string' ? Buffer.from(key, 'base64') : key
|
|
100
103
|
const plaintextBuffer = typeof plaintext === 'string' ? Buffer.from(plaintext) : plaintext
|
|
101
|
-
return
|
|
104
|
+
return encrypt(keyBuffer, plaintextBuffer, ivBuffer)
|
|
102
105
|
}
|
|
103
106
|
catch (e) {
|
|
104
107
|
throw new Error('InvalidMessageException')
|