@badzz88/baileys 8.5.7 → 8.5.8
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 +337 -1055
- package/WAProto/WAProto.proto +284 -264
- package/WAProto/index.js +5 -5
- package/engine-requirements.js +7 -15
- package/lib/Defaults/index.js +130 -187
- package/lib/Signal/Group/ciphertext-message.js +11 -14
- package/lib/Signal/Group/group-session-builder.js +29 -91
- package/lib/Signal/Group/group_cipher.js +81 -88
- package/lib/Signal/Group/index.js +12 -136
- package/lib/Signal/Group/keyhelper.js +15 -70
- package/lib/Signal/Group/sender-chain-key.js +25 -31
- package/lib/Signal/Group/sender-key-distribution-message.js +62 -65
- package/lib/Signal/Group/sender-key-message.js +65 -68
- package/lib/Signal/Group/sender-key-name.js +41 -43
- package/lib/Signal/Group/sender-key-record.js +40 -43
- package/lib/Signal/Group/sender-key-state.js +83 -96
- package/lib/Signal/Group/sender-message-key.js +25 -29
- package/lib/Signal/libsignal.js +425 -453
- package/lib/Signal/lid-mapping.js +276 -259
- package/lib/Socket/Client/index.js +3 -30
- package/lib/Socket/Client/types.js +10 -12
- package/lib/Socket/Client/websocket.js +53 -61
- package/lib/Socket/business.js +379 -422
- package/lib/Socket/chats.js +1193 -1816
- package/lib/Socket/communities.js +431 -549
- package/lib/Socket/graphql.js +672 -612
- package/lib/Socket/groups.js +374 -764
- package/lib/Socket/index.js +17 -38
- package/lib/Socket/interop.js +417 -503
- package/lib/Socket/messages-recv.js +1915 -2441
- package/lib/Socket/messages-send.js +1213 -1630
- package/lib/Socket/mex.js +9 -15
- package/lib/Socket/newsletter.js +747 -808
- package/lib/Socket/privacy.js +310 -441
- package/lib/Socket/socket.js +1025 -1022
- package/lib/Socket/username.js +8 -15
- package/lib/Store/index.js +10 -36
- package/lib/Store/make-cache-manager-store.js +80 -85
- package/lib/Store/make-in-memory-store.js +231 -591
- package/lib/Store/make-ordered-dictionary.js +72 -78
- package/lib/Store/object-repository.js +28 -25
- package/lib/Types/Auth.js +2 -38
- package/lib/Types/Bussines.js +2 -2
- package/lib/Types/Call.js +2 -2
- package/lib/Types/Chat.js +8 -4
- package/lib/Types/Contact.js +2 -2
- package/lib/Types/Events.js +2 -2
- package/lib/Types/GroupMetadata.js +2 -2
- package/lib/Types/Label.js +24 -26
- package/lib/Types/LabelAssociation.js +6 -8
- package/lib/Types/Message.js +11 -95
- package/lib/Types/Mex.js +111 -112
- package/lib/Types/Product.js +2 -2
- package/lib/Types/Signal.js +2 -2
- package/lib/Types/Socket.js +3 -2
- package/lib/Types/State.js +56 -70
- package/lib/Types/USync.js +2 -2
- package/lib/Types/index.js +26 -55
- package/lib/Utils/auth-utils.js +288 -292
- package/lib/Utils/browser-utils.js +47 -113
- package/lib/Utils/business.js +224 -240
- package/lib/Utils/chat-utils.js +869 -1205
- package/lib/Utils/companion-reg-client-utils.js +34 -41
- package/lib/Utils/crypto.js +107 -144
- package/lib/Utils/decode-wa-message.js +308 -518
- package/lib/Utils/event-buffer.js +611 -596
- package/lib/Utils/generics.js +355 -515
- package/lib/Utils/history.js +134 -244
- package/lib/Utils/identity-change-handler.js +49 -51
- package/lib/Utils/index.js +23 -57
- package/lib/Utils/link-preview.js +77 -135
- package/lib/Utils/logger.js +3 -9
- package/lib/Utils/lt-hash.js +6 -37
- package/lib/Utils/make-mutex.js +33 -36
- package/lib/Utils/message-composer.js +233 -439
- package/lib/Utils/message-retry-manager.js +260 -265
- package/lib/Utils/messages-media.js +829 -855
- package/lib/Utils/messages.js +961 -2528
- package/lib/Utils/noise-handler.js +200 -195
- package/lib/Utils/offline-node-processor.js +33 -35
- package/lib/Utils/pre-key-manager.js +102 -103
- package/lib/Utils/process-message.js +560 -978
- package/lib/Utils/reporting-utils.js +253 -257
- package/lib/Utils/signal.js +195 -218
- package/lib/Utils/stanza-ack.js +29 -31
- package/lib/Utils/sticker.js +109 -144
- package/lib/Utils/sync-action-utils.js +45 -50
- package/lib/Utils/tc-token-utils.js +139 -137
- package/lib/Utils/use-multi-file-auth-state.js +109 -109
- package/lib/Utils/validate-connection.js +202 -218
- package/lib/WABinary/constants.js +1299 -1302
- package/lib/WABinary/decode.js +262 -343
- package/lib/WABinary/encode.js +4 -12
- package/lib/WABinary/generic-utils.js +187 -223
- package/lib/WABinary/index.js +6 -33
- package/lib/WABinary/jid-utils.js +88 -351
- package/lib/WABinary/types.js +2 -2
- package/lib/WAM/BinaryInfo.js +9 -12
- package/lib/WAM/constants.js +22853 -39486
- package/lib/WAM/encode.js +140 -132
- package/lib/WAM/index.js +4 -31
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +21 -23
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +9 -9
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +7 -7
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +10 -10
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +7 -7
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +11 -12
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +4 -5
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +7 -7
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +7 -8
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +7 -7
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +8 -8
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +7 -7
- package/lib/WAUSync/Protocols/index.js +12 -39
- package/lib/WAUSync/USyncQuery.js +67 -49
- package/lib/WAUSync/USyncUser.js +11 -5
- package/lib/WAUSync/index.js +3 -31
- package/lib/index.js +15 -48
- package/package.json +129 -99
- package/LICENSE +0 -21
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Socket/aigroups.js +0 -240
- package/lib/Socket/interactive-handler.js +0 -522
- package/lib/Socket/managed-account.js +0 -183
- package/lib/Socket/registration.js +0 -427
- package/lib/Socket/text-router.js +0 -83
- package/lib/Types/Newsletter.js +0 -121
- package/lib/Utils/command-loader.d.ts +0 -31
- package/lib/Utils/command-loader.js +0 -100
- package/lib/Utils/consumer-application.js +0 -107
- package/lib/Utils/curve25519-js.js +0 -275
- package/lib/Utils/group-history.js +0 -60
- package/lib/Utils/jid-display-normalization.js +0 -218
- package/lib/Utils/meta-ai-msmsg.js +0 -262
- package/lib/Utils/native-bridge.js +0 -82
- package/lib/Utils/session-pool.d.ts +0 -16
- package/lib/Utils/session-pool.js +0 -94
- package/lib/Utils/sticker.d.ts +0 -17
- package/lib/Utils/view-once-cache.d.ts +0 -9
- package/lib/Utils/view-once-cache.js +0 -79
- package/lib/Utils/voip-rekey.js +0 -22
- package/lib/antiban.js +0 -4637
package/WAProto/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import $protobuf from "protobufjs/minimal.js";
|
|
5
5
|
|
|
6
6
|
// Common aliases
|
|
7
|
-
|
|
7
|
+
const $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
|
|
8
8
|
|
|
9
9
|
// Exported root namespace
|
|
10
|
-
|
|
10
|
+
const $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});
|
|
11
11
|
|
|
12
|
-
$root.proto = (
|
|
12
|
+
export const proto = $root.proto = (() => {
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Namespace proto.
|
|
@@ -242943,4 +242943,4 @@ $root.proto = (function() {
|
|
|
242943
242943
|
return proto;
|
|
242944
242944
|
})();
|
|
242945
242945
|
|
|
242946
|
-
|
|
242946
|
+
export { $root as default }
|
package/engine-requirements.js
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
const major = parseInt(process.versions.node.split(
|
|
1
|
+
const major = parseInt(process.versions.node.split('.')[0], 10);
|
|
2
2
|
|
|
3
3
|
if (major < 20) {
|
|
4
|
-
console.error(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
• Required : v20.0.0+
|
|
10
|
-
|
|
11
|
-
This package uses features available only in
|
|
12
|
-
Node.js 20 or newer.
|
|
13
|
-
|
|
14
|
-
Please update Node.js and try again.
|
|
15
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
16
|
-
`);
|
|
4
|
+
console.error(
|
|
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
|
+
);
|
|
17
9
|
process.exit(1);
|
|
18
|
-
}
|
|
10
|
+
}
|
package/lib/Defaults/index.js
CHANGED
|
@@ -1,187 +1,130 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
'thumbnail-link': '/mms/image',
|
|
132
|
-
'thumbnail-image': '/mms/image',
|
|
133
|
-
'thumbnail-video': '/mms/video',
|
|
134
|
-
'thumbnail-document': '/mms/document',
|
|
135
|
-
'product-catalog-image': '/product/image',
|
|
136
|
-
'md-app-state': '',
|
|
137
|
-
'md-msg-hist': '/mms/md-app-state',
|
|
138
|
-
'biz-cover-photo': '/pps/biz-cover-photo',
|
|
139
|
-
ptv: '/mms/video'
|
|
140
|
-
}
|
|
141
|
-
exports.MEDIA_HKDF_KEY_MAPPING = {
|
|
142
|
-
audio: 'Audio',
|
|
143
|
-
document: 'Document',
|
|
144
|
-
gif: 'Video',
|
|
145
|
-
image: 'Image',
|
|
146
|
-
ppic: '',
|
|
147
|
-
product: 'Image',
|
|
148
|
-
ptt: 'Audio',
|
|
149
|
-
sticker: 'Image',
|
|
150
|
-
video: 'Video',
|
|
151
|
-
'thumbnail-document': 'Document Thumbnail',
|
|
152
|
-
'thumbnail-image': 'Image Thumbnail',
|
|
153
|
-
'thumbnail-video': 'Video Thumbnail',
|
|
154
|
-
'thumbnail-link': 'Link Thumbnail',
|
|
155
|
-
'md-msg-hist': 'History',
|
|
156
|
-
'md-app-state': 'App State',
|
|
157
|
-
'product-catalog-image': 'Product Catalog Image',
|
|
158
|
-
'payment-bg-image': 'Payment Background',
|
|
159
|
-
ptv: 'Video',
|
|
160
|
-
'biz-cover-photo': 'Image',
|
|
161
|
-
location: 'Location',
|
|
162
|
-
contact: 'Contact',
|
|
163
|
-
'voip-token': 'Voip Token'
|
|
164
|
-
}
|
|
165
|
-
exports.MEDIA_KEYS = Object.keys(exports.MEDIA_PATH_MAP)
|
|
166
|
-
exports.MIN_PREKEY_COUNT = 5
|
|
167
|
-
exports.INITIAL_PREKEY_COUNT = 812
|
|
168
|
-
exports.UPLOAD_TIMEOUT = 30000
|
|
169
|
-
exports.MIN_UPLOAD_INTERVAL = 5000
|
|
170
|
-
exports.DEFAULT_CACHE_TTLS = {
|
|
171
|
-
SIGNAL_STORE: 5 * 60,
|
|
172
|
-
MSG_RETRY: 60 * 60,
|
|
173
|
-
CALL_OFFER: 5 * 60,
|
|
174
|
-
USER_DEVICES: 5 * 60,
|
|
175
|
-
GROUP_METADATA: 30 * 60,
|
|
176
|
-
CALL_SESSION: 10 * 60,
|
|
177
|
-
USYNC_RESULTS: 10 * 60,
|
|
178
|
-
IDENTITY_PROOF: 60 * 60
|
|
179
|
-
}
|
|
180
|
-
exports.TimeMs = {
|
|
181
|
-
Second: 1000,
|
|
182
|
-
Minute: 60 * 1000,
|
|
183
|
-
Hour: 60 * 60 * 1000,
|
|
184
|
-
Day: 24 * 60 * 60 * 1000,
|
|
185
|
-
Week: 7 * 24 * 60 * 60 * 1000,
|
|
186
|
-
Month: 30 * 24 * 60 * 60 * 1000
|
|
187
|
-
}
|
|
1
|
+
import { proto } from '../../WAProto/index.js';
|
|
2
|
+
import { makeLibSignalRepository } from '../Signal/libsignal.js';
|
|
3
|
+
import { Browsers } from '../Utils/browser-utils.js';
|
|
4
|
+
import logger from '../Utils/logger.js';
|
|
5
|
+
const version = [2, 3000, 1043857760];
|
|
6
|
+
export const UNAUTHORIZED_CODES = [401, 403, 419];
|
|
7
|
+
export const DEFAULT_ORIGIN = 'https://web.whatsapp.com';
|
|
8
|
+
export const CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/';
|
|
9
|
+
export const CALL_AUDIO_PREFIX = 'https://call.whatsapp.com/voice/';
|
|
10
|
+
export const DEF_CALLBACK_PREFIX = 'CB:';
|
|
11
|
+
export const DEF_TAG_PREFIX = 'TAG:';
|
|
12
|
+
export const PHONE_CONNECTION_CB = 'CB:Pong';
|
|
13
|
+
export const WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0]);
|
|
14
|
+
export const WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1]);
|
|
15
|
+
export const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5]);
|
|
16
|
+
export const WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6]);
|
|
17
|
+
export const WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60;
|
|
18
|
+
/** Status messages older than 24 hours are considered expired */
|
|
19
|
+
export const STATUS_EXPIRY_SECONDS = 24 * 60 * 60;
|
|
20
|
+
/** WA Web enforces a 14-day maximum age for placeholder resend requests */
|
|
21
|
+
export const PLACEHOLDER_MAX_AGE_SECONDS = 14 * 24 * 60 * 60;
|
|
22
|
+
export const NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0';
|
|
23
|
+
export const DICT_VERSION = 3;
|
|
24
|
+
export const KEY_BUNDLE_TYPE = Buffer.from([5]);
|
|
25
|
+
export const NOISE_WA_HEADER = Buffer.from([87, 65, 6, DICT_VERSION]); // last is "DICT_VERSION"
|
|
26
|
+
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
27
|
+
export const URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
|
|
28
|
+
export const WA_CERT_DETAILS = {
|
|
29
|
+
SERIAL: 0,
|
|
30
|
+
ISSUER: 'WhatsAppLongTerm1',
|
|
31
|
+
PUBLIC_KEY: Buffer.from('142375574d0a587166aae71ebe516437c4a28b73e3695c6ce1f7f9545da8ee6b', 'hex')
|
|
32
|
+
};
|
|
33
|
+
export const PROCESSABLE_HISTORY_TYPES = [
|
|
34
|
+
proto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP,
|
|
35
|
+
proto.HistorySync.HistorySyncType.PUSH_NAME,
|
|
36
|
+
proto.HistorySync.HistorySyncType.RECENT,
|
|
37
|
+
proto.HistorySync.HistorySyncType.FULL,
|
|
38
|
+
proto.HistorySync.HistorySyncType.ON_DEMAND,
|
|
39
|
+
proto.HistorySync.HistorySyncType.NON_BLOCKING_DATA,
|
|
40
|
+
proto.HistorySync.HistorySyncType.INITIAL_STATUS_V3
|
|
41
|
+
];
|
|
42
|
+
export const DEFAULT_CACHE_TTLS = {
|
|
43
|
+
SIGNAL_STORE: 5 * 60, // 5 minutes
|
|
44
|
+
MSG_RETRY: 60 * 60, // 1 hour
|
|
45
|
+
CALL_OFFER: 5 * 60, // 5 minutes
|
|
46
|
+
USER_DEVICES: 5 * 60 // 5 minutes
|
|
47
|
+
};
|
|
48
|
+
export const DEFAULT_CONNECTION_CONFIG = {
|
|
49
|
+
version: version,
|
|
50
|
+
browser: Browsers.macOS('Chrome'),
|
|
51
|
+
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
|
52
|
+
connectTimeoutMs: 20000,
|
|
53
|
+
keepAliveIntervalMs: 30000,
|
|
54
|
+
logger: logger.child({ class: 'baileys' }),
|
|
55
|
+
emitOwnEvents: true,
|
|
56
|
+
defaultQueryTimeoutMs: 60000,
|
|
57
|
+
customUploadHosts: [],
|
|
58
|
+
retryRequestDelayMs: 250,
|
|
59
|
+
maxMsgRetryCount: 5,
|
|
60
|
+
fireInitQueries: true,
|
|
61
|
+
auth: undefined,
|
|
62
|
+
markOnlineOnConnect: true,
|
|
63
|
+
aiLabel: true,
|
|
64
|
+
syncFullHistory: true,
|
|
65
|
+
patchMessageBeforeSending: msg => msg,
|
|
66
|
+
shouldSyncHistoryMessage: ({ syncType }) => {
|
|
67
|
+
return syncType !== proto.HistorySync.HistorySyncType.FULL;
|
|
68
|
+
},
|
|
69
|
+
shouldIgnoreJid: () => false,
|
|
70
|
+
linkPreviewImageThumbnailWidth: 192,
|
|
71
|
+
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
|
|
72
|
+
generateHighQualityLinkPreview: false,
|
|
73
|
+
enableAutoSessionRecreation: true,
|
|
74
|
+
enableRecentMessageCache: true,
|
|
75
|
+
options: {},
|
|
76
|
+
appStateMacVerification: {
|
|
77
|
+
patch: false,
|
|
78
|
+
snapshot: false
|
|
79
|
+
},
|
|
80
|
+
countryCode: 'US',
|
|
81
|
+
getMessage: async () => undefined,
|
|
82
|
+
cachedGroupMetadata: async () => undefined,
|
|
83
|
+
makeSignalRepository: makeLibSignalRepository
|
|
84
|
+
};
|
|
85
|
+
export const MEDIA_PATH_MAP = {
|
|
86
|
+
image: '/mms/image',
|
|
87
|
+
video: '/mms/video',
|
|
88
|
+
document: '/mms/document',
|
|
89
|
+
audio: '/mms/audio',
|
|
90
|
+
sticker: '/mms/image',
|
|
91
|
+
'thumbnail-link': '/mms/image',
|
|
92
|
+
'product-catalog-image': '/product/image',
|
|
93
|
+
'md-app-state': '',
|
|
94
|
+
'md-msg-hist': '/mms/md-app-state',
|
|
95
|
+
'biz-cover-photo': '/pps/biz-cover-photo'
|
|
96
|
+
};
|
|
97
|
+
export const MEDIA_HKDF_KEY_MAPPING = {
|
|
98
|
+
audio: 'Audio',
|
|
99
|
+
document: 'Document',
|
|
100
|
+
gif: 'Video',
|
|
101
|
+
image: 'Image',
|
|
102
|
+
ppic: '',
|
|
103
|
+
product: 'Image',
|
|
104
|
+
ptt: 'Audio',
|
|
105
|
+
sticker: 'Image',
|
|
106
|
+
video: 'Video',
|
|
107
|
+
'thumbnail-document': 'Document Thumbnail',
|
|
108
|
+
'thumbnail-image': 'Image Thumbnail',
|
|
109
|
+
'thumbnail-video': 'Video Thumbnail',
|
|
110
|
+
'thumbnail-link': 'Link Thumbnail',
|
|
111
|
+
'md-msg-hist': 'History',
|
|
112
|
+
'md-app-state': 'App State',
|
|
113
|
+
'product-catalog-image': '',
|
|
114
|
+
'payment-bg-image': 'Payment Background',
|
|
115
|
+
ptv: 'Video',
|
|
116
|
+
'biz-cover-photo': 'Image'
|
|
117
|
+
};
|
|
118
|
+
export const MEDIA_KEYS = Object.keys(MEDIA_PATH_MAP);
|
|
119
|
+
/** 120s timeout for history sync stall detection, same as WA Web's handleChunkProgress / restartPausedTimer (g = 120) */
|
|
120
|
+
export const HISTORY_SYNC_PAUSED_TIMEOUT_MS = 120000;
|
|
121
|
+
export const MIN_PREKEY_COUNT = 5;
|
|
122
|
+
export const INITIAL_PREKEY_COUNT = 812;
|
|
123
|
+
export const UPLOAD_TIMEOUT = 30000; // 30 seconds
|
|
124
|
+
export const TimeMs = {
|
|
125
|
+
Minute: 60 * 1000,
|
|
126
|
+
Hour: 60 * 60 * 1000,
|
|
127
|
+
Day: 24 * 60 * 60 * 1000,
|
|
128
|
+
Week: 7 * 24 * 60 * 60 * 1000
|
|
129
|
+
};
|
|
130
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this.SENDERKEY_DISTRIBUTION_TYPE = 5
|
|
12
|
-
this.ENCRYPTED_MESSAGE_OVERHEAD = 53
|
|
13
|
-
}
|
|
1
|
+
export class CiphertextMessage {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.UNSUPPORTED_VERSION = 1;
|
|
4
|
+
this.CURRENT_VERSION = 3;
|
|
5
|
+
this.WHISPER_TYPE = 2;
|
|
6
|
+
this.PREKEY_TYPE = 3;
|
|
7
|
+
this.SENDERKEY_TYPE = 4;
|
|
8
|
+
this.SENDERKEY_DISTRIBUTION_TYPE = 5;
|
|
9
|
+
this.ENCRYPTED_MESSAGE_OVERHEAD = 53;
|
|
10
|
+
}
|
|
14
11
|
}
|
|
15
|
-
|
|
12
|
+
//# sourceMappingURL=ciphertext-message.js.map
|
|
@@ -1,92 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
o['default'] = v
|
|
30
|
-
})
|
|
31
|
-
var __importStar =
|
|
32
|
-
(this && this.__importStar) ||
|
|
33
|
-
(function () {
|
|
34
|
-
var ownKeys = function (o) {
|
|
35
|
-
ownKeys =
|
|
36
|
-
Object.getOwnPropertyNames ||
|
|
37
|
-
function (o) {
|
|
38
|
-
var ar = []
|
|
39
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k
|
|
40
|
-
return ar
|
|
41
|
-
}
|
|
42
|
-
return ownKeys(o)
|
|
43
|
-
}
|
|
44
|
-
return function (mod) {
|
|
45
|
-
if (mod && mod.__esModule) return mod
|
|
46
|
-
var result = {}
|
|
47
|
-
if (mod != null)
|
|
48
|
-
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== 'default') __createBinding(result, mod, k[i])
|
|
49
|
-
__setModuleDefault(result, mod)
|
|
50
|
-
return result
|
|
51
|
-
}
|
|
52
|
-
})()
|
|
53
|
-
Object.defineProperty(exports, '__esModule', { value: true })
|
|
54
|
-
exports.GroupSessionBuilder = void 0
|
|
55
|
-
const keyhelper = __importStar(require('./keyhelper'))
|
|
56
|
-
const sender_key_distribution_message_1 = require('./sender-key-distribution-message')
|
|
57
|
-
class GroupSessionBuilder {
|
|
58
|
-
constructor(senderKeyStore) {
|
|
59
|
-
this.senderKeyStore = senderKeyStore
|
|
60
|
-
}
|
|
61
|
-
async process(senderKeyName, senderKeyDistributionMessage) {
|
|
62
|
-
const senderKeyRecord = await this.senderKeyStore.loadSenderKey(senderKeyName)
|
|
63
|
-
senderKeyRecord.addSenderKeyState(
|
|
64
|
-
senderKeyDistributionMessage.getId(),
|
|
65
|
-
senderKeyDistributionMessage.getIteration(),
|
|
66
|
-
senderKeyDistributionMessage.getChainKey(),
|
|
67
|
-
senderKeyDistributionMessage.getSignatureKey()
|
|
68
|
-
)
|
|
69
|
-
await this.senderKeyStore.storeSenderKey(senderKeyName, senderKeyRecord)
|
|
70
|
-
}
|
|
71
|
-
async create(senderKeyName) {
|
|
72
|
-
const senderKeyRecord = await this.senderKeyStore.loadSenderKey(senderKeyName)
|
|
73
|
-
if (senderKeyRecord.isEmpty()) {
|
|
74
|
-
const keyId = keyhelper.generateSenderKeyId()
|
|
75
|
-
const senderKey = keyhelper.generateSenderKey()
|
|
76
|
-
const signingKey = keyhelper.generateSenderSigningKey()
|
|
77
|
-
senderKeyRecord.setSenderKeyState(keyId, 0, senderKey, signingKey)
|
|
78
|
-
await this.senderKeyStore.storeSenderKey(senderKeyName, senderKeyRecord)
|
|
79
|
-
}
|
|
80
|
-
const state = senderKeyRecord.getSenderKeyState()
|
|
81
|
-
if (!state) {
|
|
82
|
-
throw new Error('No session state available')
|
|
83
|
-
}
|
|
84
|
-
return new sender_key_distribution_message_1.SenderKeyDistributionMessage(
|
|
85
|
-
state.getKeyId(),
|
|
86
|
-
state.getSenderChainKey().getIteration(),
|
|
87
|
-
state.getSenderChainKey().getSeed(),
|
|
88
|
-
state.getSigningKeyPublic()
|
|
89
|
-
)
|
|
90
|
-
}
|
|
1
|
+
import * as keyhelper from './keyhelper.js';
|
|
2
|
+
import { SenderKeyDistributionMessage } from './sender-key-distribution-message.js';
|
|
3
|
+
import { SenderKeyName } from './sender-key-name.js';
|
|
4
|
+
import { SenderKeyRecord } from './sender-key-record.js';
|
|
5
|
+
export class GroupSessionBuilder {
|
|
6
|
+
constructor(senderKeyStore) {
|
|
7
|
+
this.senderKeyStore = senderKeyStore;
|
|
8
|
+
}
|
|
9
|
+
async process(senderKeyName, senderKeyDistributionMessage) {
|
|
10
|
+
const senderKeyRecord = await this.senderKeyStore.loadSenderKey(senderKeyName);
|
|
11
|
+
senderKeyRecord.addSenderKeyState(senderKeyDistributionMessage.getId(), senderKeyDistributionMessage.getIteration(), senderKeyDistributionMessage.getChainKey(), senderKeyDistributionMessage.getSignatureKey());
|
|
12
|
+
await this.senderKeyStore.storeSenderKey(senderKeyName, senderKeyRecord);
|
|
13
|
+
}
|
|
14
|
+
async create(senderKeyName) {
|
|
15
|
+
const senderKeyRecord = await this.senderKeyStore.loadSenderKey(senderKeyName);
|
|
16
|
+
if (senderKeyRecord.isEmpty()) {
|
|
17
|
+
const keyId = keyhelper.generateSenderKeyId();
|
|
18
|
+
const senderKey = keyhelper.generateSenderKey();
|
|
19
|
+
const signingKey = keyhelper.generateSenderSigningKey();
|
|
20
|
+
senderKeyRecord.setSenderKeyState(keyId, 0, senderKey, signingKey);
|
|
21
|
+
await this.senderKeyStore.storeSenderKey(senderKeyName, senderKeyRecord);
|
|
22
|
+
}
|
|
23
|
+
const state = senderKeyRecord.getSenderKeyState();
|
|
24
|
+
if (!state) {
|
|
25
|
+
throw new Error('No session state available');
|
|
26
|
+
}
|
|
27
|
+
return new SenderKeyDistributionMessage(state.getKeyId(), state.getSenderChainKey().getIteration(), state.getSenderChainKey().getSeed(), state.getSigningKeyPublic());
|
|
28
|
+
}
|
|
91
29
|
}
|
|
92
|
-
|
|
30
|
+
//# sourceMappingURL=group-session-builder.js.map
|