@pontalabs/baileys 1.0.6 → 1.0.7
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 +839 -267
- package/WAProto/GenerateStatics.sh +4 -3
- package/WAProto/WAProto.proto +511 -1215
- package/WAProto/index.d.ts +55 -14017
- package/WAProto/index.js +29 -97689
- package/lib/Defaults/index.d.ts +74 -72
- package/lib/Defaults/index.js +108 -94
- package/lib/Signal/Group/ciphertext-message.d.ts +7 -8
- package/lib/Signal/Group/ciphertext-message.js +16 -9
- package/lib/Signal/Group/group-session-builder.d.ts +13 -11
- package/lib/Signal/Group/group-session-builder.js +61 -19
- package/lib/Signal/Group/group_cipher.d.ts +16 -14
- package/lib/Signal/Group/group_cipher.js +70 -41
- package/lib/Signal/Group/index.d.ts +11 -12
- package/lib/Signal/Group/index.js +61 -12
- package/lib/Signal/Group/keyhelper.d.ts +14 -9
- package/lib/Signal/Group/keyhelper.js +58 -10
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -13
- package/lib/Signal/Group/sender-chain-key.js +34 -13
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -16
- package/lib/Signal/Group/sender-key-distribution-message.js +36 -28
- package/lib/Signal/Group/sender-key-message.d.ts +18 -18
- package/lib/Signal/Group/sender-key-message.js +45 -38
- package/lib/Signal/Group/sender-key-name.d.ts +15 -14
- package/lib/Signal/Group/sender-key-name.js +31 -20
- package/lib/Signal/Group/sender-key-record.d.ts +25 -24
- package/lib/Signal/Group/sender-key-record.js +35 -18
- package/lib/Signal/Group/sender-key-state.d.ts +34 -29
- package/lib/Signal/Group/sender-key-state.js +100 -37
- package/lib/Signal/Group/sender-message-key.d.ts +10 -11
- package/lib/Signal/Group/sender-message-key.js +22 -15
- package/lib/Signal/libsignal.d.ts +8 -5
- package/lib/Signal/libsignal.js +142 -288
- package/lib/Signal/lid-mapping.d.ts +28 -23
- package/lib/Signal/lid-mapping.js +184 -277
- package/lib/Socket/Client/index.d.ts +2 -3
- package/lib/Socket/Client/index.js +22 -3
- package/lib/Socket/Client/types.d.ts +15 -15
- package/lib/Socket/Client/types.js +15 -8
- package/lib/Socket/Client/websocket.d.ts +12 -12
- package/lib/Socket/Client/websocket.js +37 -29
- package/lib/Socket/business.d.ts +178 -208
- package/lib/Socket/business.js +127 -91
- package/lib/Socket/chats.d.ts +93 -120
- package/lib/Socket/chats.js +652 -727
- package/lib/Socket/community.js +10 -2
- package/lib/Socket/groups.d.ts +111 -143
- package/lib/Socket/groups.js +186 -165
- package/lib/Socket/index.d.ts +183 -252
- package/lib/Socket/index.js +18 -38
- package/lib/Socket/messages-recv.d.ts +167 -196
- package/lib/Socket/messages-recv.js +1567 -1443
- package/lib/Socket/messages-send.d.ts +158 -192
- package/lib/Socket/messages-send.js +1208 -1102
- package/lib/Socket/newsletter.d.ts +138 -163
- package/lib/Socket/newsletter.js +249 -153
- package/lib/Socket/socket.d.ts +36 -50
- package/lib/Socket/socket.js +820 -749
- package/lib/Store/index.d.ts +4 -4
- package/lib/Store/index.js +24 -4
- package/lib/Store/make-in-memory-store.d.ts +104 -44
- package/lib/Store/make-in-memory-store.js +213 -199
- package/lib/Store/make-ordered-dictionary.d.ts +12 -13
- package/lib/Store/make-ordered-dictionary.js +45 -38
- package/lib/Store/object-repository.d.ts +10 -11
- package/lib/Store/object-repository.js +16 -9
- package/lib/Types/Auth.d.ts +97 -93
- package/lib/Types/Auth.js +3 -2
- package/lib/Types/Bussines.js +3 -2
- package/lib/Types/Call.d.ts +13 -14
- package/lib/Types/Call.js +3 -2
- package/lib/Types/Chat.d.ts +97 -78
- package/lib/Types/Chat.js +9 -8
- package/lib/Types/Contact.d.ts +9 -12
- package/lib/Types/Contact.js +3 -2
- package/lib/Types/Events.d.ts +176 -206
- package/lib/Types/Events.js +3 -2
- package/lib/Types/GroupMetadata.d.ts +48 -53
- package/lib/Types/GroupMetadata.js +3 -2
- package/lib/Types/Label.d.ts +14 -13
- package/lib/Types/Label.js +30 -24
- package/lib/Types/LabelAssociation.d.ts +20 -15
- package/lib/Types/LabelAssociation.js +12 -6
- package/lib/Types/Message.d.ts +412 -248
- package/lib/Types/Message.js +19 -17
- package/lib/Types/Product.d.ts +71 -58
- package/lib/Types/Product.js +3 -2
- package/lib/Types/Signal.d.ts +82 -71
- package/lib/Types/Signal.js +3 -2
- package/lib/Types/Socket.d.ts +81 -76
- package/lib/Types/Socket.js +3 -3
- package/lib/Types/State.d.ts +19 -75
- package/lib/Types/State.js +14 -56
- package/lib/Types/USync.d.ts +8 -8
- package/lib/Types/USync.js +3 -2
- package/lib/Types/index.d.ts +62 -47
- package/lib/Types/index.js +50 -26
- package/lib/Utils/auth-utils.d.ts +10 -13
- package/lib/Utils/auth-utils.js +472 -213
- package/lib/Utils/business.d.ts +20 -14
- package/lib/Utils/business.js +134 -110
- package/lib/Utils/chat-utils.d.ts +70 -88
- package/lib/Utils/chat-utils.js +403 -466
- package/lib/Utils/crypto.d.ts +46 -27
- package/lib/Utils/crypto.js +188 -117
- package/lib/Utils/decode-wa-message.d.ts +45 -58
- package/lib/Utils/decode-wa-message.js +311 -212
- package/lib/Utils/event-buffer.d.ts +17 -14
- package/lib/Utils/event-buffer.js +296 -321
- package/lib/Utils/generics.d.ts +92 -66
- package/lib/Utils/generics.js +436 -270
- package/lib/Utils/history.d.ts +23 -24
- package/lib/Utils/history.js +76 -106
- package/lib/Utils/index.d.ts +21 -24
- package/lib/Utils/index.js +41 -24
- package/lib/Utils/link-preview.d.ts +14 -12
- package/lib/Utils/link-preview.js +75 -40
- package/lib/Utils/logger.d.ts +11 -10
- package/lib/Utils/logger.js +7 -3
- package/lib/Utils/lt-hash.d.ts +14 -8
- package/lib/Utils/lt-hash.js +53 -3
- package/lib/Utils/make-mutex.d.ts +7 -7
- package/lib/Utils/make-mutex.js +44 -28
- package/lib/Utils/message-retry-manager.d.ts +88 -115
- package/lib/Utils/message-retry-manager.js +160 -265
- package/lib/Utils/messages-media.d.ts +107 -105
- package/lib/Utils/messages-media.js +619 -548
- package/lib/Utils/messages.d.ts +66 -52
- package/lib/Utils/messages.js +1558 -1730
- package/lib/Utils/noise-handler.d.ts +18 -18
- package/lib/Utils/noise-handler.js +130 -176
- package/lib/Utils/process-message.d.ts +32 -43
- package/lib/Utils/process-message.js +282 -484
- package/lib/Utils/rich-message-utils.js +724 -1220
- package/lib/Utils/signal.d.ts +32 -37
- package/lib/Utils/signal.js +105 -140
- package/lib/Utils/use-multi-file-auth-state.d.ts +5 -5
- package/lib/Utils/use-multi-file-auth-state.js +120 -70
- package/lib/Utils/use-single-file-auth-state.d.ts +13 -11
- package/lib/Utils/use-single-file-auth-state.js +66 -92
- package/lib/Utils/validate-connection.d.ts +13 -11
- package/lib/Utils/validate-connection.js +113 -128
- package/lib/WABinary/constants.d.ts +27 -25
- package/lib/WABinary/constants.js +1292 -1451
- package/lib/WABinary/decode.d.ts +9 -7
- package/lib/WABinary/decode.js +189 -163
- package/lib/WABinary/encode.d.ts +3 -3
- package/lib/WABinary/encode.js +155 -110
- package/lib/WABinary/generic-utils.d.ts +27 -14
- package/lib/WABinary/generic-utils.js +105 -177
- package/lib/WABinary/index.d.ts +5 -6
- package/lib/WABinary/index.js +25 -6
- package/lib/WABinary/jid-utils.d.ts +54 -41
- package/lib/WABinary/jid-utils.js +152 -83
- package/lib/WABinary/types.d.ts +13 -10
- package/lib/WABinary/types.js +3 -2
- package/lib/WAM/BinaryInfo.d.ts +15 -8
- package/lib/WAM/BinaryInfo.js +14 -7
- package/lib/WAM/constants.d.ts +37 -30
- package/lib/WAM/constants.js +11983 -19465
- package/lib/WAM/encode.d.ts +3 -3
- package/lib/WAM/encode.js +109 -95
- package/lib/WAM/index.d.ts +3 -4
- package/lib/WAM/index.js +23 -4
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -9
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +21 -37
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -19
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +26 -18
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -11
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +20 -12
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -11
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +24 -16
- package/lib/WAUSync/Protocols/index.d.ts +6 -6
- package/lib/WAUSync/Protocols/index.js +26 -6
- package/lib/WAUSync/USyncQuery.d.ts +28 -27
- package/lib/WAUSync/USyncQuery.js +62 -68
- package/lib/WAUSync/USyncUser.d.ts +10 -15
- package/lib/WAUSync/USyncUser.js +19 -20
- package/lib/WAUSync/index.d.ts +3 -4
- package/lib/WAUSync/index.js +23 -4
- package/lib/index.d.ts +12 -11
- package/lib/index.js +39 -12
- package/package.json +42 -86
- package/engine-requirements.js +0 -10
package/lib/Defaults/index.d.ts
CHANGED
|
@@ -1,75 +1,77 @@
|
|
|
1
|
-
import { proto } from '../../WAProto
|
|
2
|
-
import type { SocketConfig } from '../Types
|
|
3
|
-
|
|
4
|
-
export declare const
|
|
5
|
-
|
|
6
|
-
export declare const
|
|
7
|
-
|
|
8
|
-
export declare const
|
|
9
|
-
|
|
10
|
-
export declare const
|
|
11
|
-
|
|
12
|
-
export declare const
|
|
13
|
-
|
|
14
|
-
export declare const
|
|
15
|
-
|
|
16
|
-
export declare const
|
|
17
|
-
|
|
18
|
-
export declare const
|
|
19
|
-
|
|
20
|
-
export declare const DICT_VERSION
|
|
21
|
-
|
|
22
|
-
export declare const
|
|
23
|
-
|
|
24
|
-
export declare const
|
|
1
|
+
import { proto } from '../../WAProto'
|
|
2
|
+
import type { MediaType, SocketConfig } from '../Types'
|
|
3
|
+
|
|
4
|
+
export declare const UNAUTHORIZED_CODES: number[]
|
|
5
|
+
|
|
6
|
+
export declare const PHONENUMBER_MCC: Record<string, number>
|
|
7
|
+
|
|
8
|
+
export declare const DEFAULT_ORIGIN: "https://web.whatsapp.com"
|
|
9
|
+
|
|
10
|
+
export declare const DEF_CALLBACK_PREFIX: "CB:"
|
|
11
|
+
|
|
12
|
+
export declare const DEF_TAG_PREFIX: "TAG:"
|
|
13
|
+
|
|
14
|
+
export declare const PHONE_CONNECTION_CB: "CB:Pong"
|
|
15
|
+
|
|
16
|
+
export declare const WA_DEFAULT_EPHEMERAL: number
|
|
17
|
+
|
|
18
|
+
export declare const NOISE_MODE: "Noise_XX_25519_AESGCM_SHA256\0\0\0\0"
|
|
19
|
+
|
|
20
|
+
export declare const DICT_VERSION: 3
|
|
21
|
+
|
|
22
|
+
export declare const KEY_BUNDLE_TYPE: Buffer
|
|
23
|
+
|
|
24
|
+
export declare const NOISE_WA_HEADER: Buffer
|
|
25
|
+
|
|
26
|
+
export declare const URL_REGEX: RegExp
|
|
27
|
+
|
|
25
28
|
export declare const WA_CERT_DETAILS: {
|
|
26
|
-
SERIAL: number
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export declare const
|
|
32
|
-
|
|
33
|
-
MSG_RETRY: number;
|
|
34
|
-
CALL_OFFER: number;
|
|
35
|
-
USER_DEVICES: number;
|
|
36
|
-
};
|
|
37
|
-
export declare const DEFAULT_CONNECTION_CONFIG: SocketConfig;
|
|
29
|
+
SERIAL: number
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export declare const PROCESSABLE_HISTORY_TYPES: proto.Message.HistorySyncNotification.HistorySyncType[]
|
|
33
|
+
|
|
34
|
+
export declare const DEFAULT_CONNECTION_CONFIG: SocketConfig
|
|
35
|
+
|
|
38
36
|
export declare const MEDIA_PATH_MAP: {
|
|
39
|
-
[T in MediaType]?: string
|
|
40
|
-
}
|
|
37
|
+
[T in MediaType]?: string
|
|
38
|
+
}
|
|
39
|
+
|
|
41
40
|
export declare const MEDIA_HKDF_KEY_MAPPING: {
|
|
42
|
-
audio: string
|
|
43
|
-
document: string
|
|
44
|
-
gif: string
|
|
45
|
-
image: string
|
|
46
|
-
ppic: string
|
|
47
|
-
product: string
|
|
48
|
-
ptt: string
|
|
49
|
-
sticker: string
|
|
50
|
-
video: string
|
|
51
|
-
'thumbnail-document': string
|
|
52
|
-
'thumbnail-image': string
|
|
53
|
-
'thumbnail-video': string
|
|
54
|
-
'thumbnail-link': string
|
|
55
|
-
'md-msg-hist': string
|
|
56
|
-
'md-app-state': string
|
|
57
|
-
'product-catalog-image': string
|
|
58
|
-
'payment-bg-image': string
|
|
59
|
-
ptv: string
|
|
60
|
-
'biz-cover-photo': string
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export declare const MEDIA_KEYS:
|
|
64
|
-
|
|
65
|
-
export declare const
|
|
66
|
-
|
|
67
|
-
export declare const INITIAL_PREKEY_COUNT
|
|
68
|
-
|
|
69
|
-
export declare const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
41
|
+
'audio': string
|
|
42
|
+
'document': string
|
|
43
|
+
'gif': string
|
|
44
|
+
'image': string
|
|
45
|
+
'ppic': string
|
|
46
|
+
'product': string
|
|
47
|
+
'ptt': string
|
|
48
|
+
'sticker': string
|
|
49
|
+
'video': string
|
|
50
|
+
'thumbnail-document': string
|
|
51
|
+
'thumbnail-image': string
|
|
52
|
+
'thumbnail-video': string
|
|
53
|
+
'thumbnail-link': string
|
|
54
|
+
'md-msg-hist': string
|
|
55
|
+
'md-app-state': string
|
|
56
|
+
'product-catalog-image': string
|
|
57
|
+
'payment-bg-image': string
|
|
58
|
+
'ptv': string
|
|
59
|
+
'biz-cover-photo': string
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export declare const MEDIA_KEYS: (keyof typeof MEDIA_HKDF_KEY_MAPPING)[]
|
|
63
|
+
|
|
64
|
+
export declare const MIN_PREKEY_COUNT: 5
|
|
65
|
+
|
|
66
|
+
export declare const INITIAL_PREKEY_COUNT: 30
|
|
67
|
+
|
|
68
|
+
export declare const UPLOAD_TIMEOUT: 30000
|
|
69
|
+
|
|
70
|
+
export declare const MIN_UPLOAD_INTERVAL: 5000
|
|
71
|
+
|
|
72
|
+
export declare const DEFAULT_CACHE_TTLS: {
|
|
73
|
+
SIGNAL_STORE: number
|
|
74
|
+
MSG_RETRY: number
|
|
75
|
+
CALL_OFFER: number
|
|
76
|
+
USER_DEVICES: number
|
|
77
|
+
}
|
package/lib/Defaults/index.js
CHANGED
|
@@ -1,61 +1,73 @@
|
|
|
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
|
-
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
8
|
+
|
|
9
|
+
exports.DEFAULT_CACHE_TTLS = exports.UPLOAD_TIMEOUT = exports.MIN_UPLOAD_INTERVAL = 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.PHONE_CONNECTION_CB = exports.DEF_TAG_PREFIX = exports.DEF_CALLBACK_PREFIX = exports.CALL_AUDIO_PREFIX = exports.CALL_VIDEO_PREFIX = exports.DEFAULT_ORIGIN = exports.UNAUTHORIZED_CODES = null
|
|
10
|
+
|
|
11
|
+
const WAProto_1 = require("../../WAProto");
|
|
12
|
+
const libsignal_1 = require("../Signal/libsignal");
|
|
13
|
+
const Utils_1 = require("../Utils");
|
|
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.STATUS_EXPIRY_SECONDS = 24 * 60 * 60
|
|
37
|
+
|
|
38
|
+
exports.PLACEHOLDER_MAX_AGE_SECONDS = 14 * 24 * 60 * 60
|
|
39
|
+
|
|
40
|
+
exports.NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0'
|
|
41
|
+
|
|
42
|
+
exports.DICT_VERSION = 3
|
|
43
|
+
|
|
44
|
+
exports.KEY_BUNDLE_TYPE = Buffer.from([5])
|
|
45
|
+
|
|
46
|
+
exports.NOISE_WA_HEADER = Buffer.from([87, 65, 6, exports.DICT_VERSION]) // last is "DICT_VERSION"
|
|
47
|
+
|
|
30
48
|
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
|
|
31
|
-
|
|
32
|
-
|
|
49
|
+
exports.URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g
|
|
50
|
+
|
|
51
|
+
exports.WA_CERT_DETAILS = {
|
|
33
52
|
SERIAL: 0,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
proto.
|
|
39
|
-
proto.
|
|
40
|
-
proto.
|
|
41
|
-
proto.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
SIGNAL_STORE: 5 * 60, // 5 minutes
|
|
48
|
-
MSG_RETRY: 60 * 60, // 1 hour
|
|
49
|
-
CALL_OFFER: 5 * 60, // 5 minutes
|
|
50
|
-
USER_DEVICES: 5 * 60 // 5 minutes
|
|
51
|
-
};
|
|
52
|
-
export const DEFAULT_CONNECTION_CONFIG = {
|
|
53
|
-
version: version,
|
|
54
|
-
browser: Browsers.macOS('Chrome'),
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
exports.PROCESSABLE_HISTORY_TYPES = [
|
|
56
|
+
WAProto_1.proto.Message.HistorySyncType.INITIAL_BOOTSTRAP,
|
|
57
|
+
WAProto_1.proto.Message.HistorySyncType.PUSH_NAME,
|
|
58
|
+
WAProto_1.proto.Message.HistorySyncType.RECENT,
|
|
59
|
+
WAProto_1.proto.Message.HistorySyncType.FULL,
|
|
60
|
+
WAProto_1.proto.Message.HistorySyncType.ON_DEMAND
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
exports.DEFAULT_CONNECTION_CONFIG = {
|
|
64
|
+
version: baileys_version_json_1.version,
|
|
65
|
+
browser: Utils_1.Browsers.windows('Chrome'),
|
|
55
66
|
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
|
56
67
|
connectTimeoutMs: 20000,
|
|
57
68
|
keepAliveIntervalMs: 30000,
|
|
58
|
-
logger:
|
|
69
|
+
logger: logger_1.default.child({ class: 'baileys' }),
|
|
70
|
+
printQRInTerminal: false,
|
|
59
71
|
emitOwnEvents: true,
|
|
60
72
|
defaultQueryTimeoutMs: 60000,
|
|
61
73
|
customUploadHosts: [],
|
|
@@ -64,53 +76,51 @@ export const DEFAULT_CONNECTION_CONFIG = {
|
|
|
64
76
|
fireInitQueries: true,
|
|
65
77
|
auth: undefined,
|
|
66
78
|
markOnlineOnConnect: true,
|
|
67
|
-
syncFullHistory:
|
|
79
|
+
syncFullHistory: false,
|
|
68
80
|
patchMessageBeforeSending: msg => msg,
|
|
69
|
-
shouldSyncHistoryMessage: (
|
|
70
|
-
return syncType !== proto.HistorySync.HistorySyncType.FULL;
|
|
71
|
-
},
|
|
81
|
+
shouldSyncHistoryMessage: () => true,
|
|
72
82
|
shouldIgnoreJid: () => false,
|
|
73
83
|
linkPreviewImageThumbnailWidth: 192,
|
|
74
84
|
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
|
|
75
85
|
generateHighQualityLinkPreview: false,
|
|
76
|
-
enableAutoSessionRecreation: true,
|
|
77
|
-
enableRecentMessageCache:
|
|
86
|
+
enableAutoSessionRecreation: true,
|
|
87
|
+
enableRecentMessageCache: false,
|
|
78
88
|
options: {},
|
|
79
89
|
appStateMacVerification: {
|
|
80
90
|
patch: false,
|
|
81
|
-
snapshot: false
|
|
91
|
+
snapshot: false,
|
|
82
92
|
},
|
|
83
|
-
countryCode: '
|
|
93
|
+
countryCode: 'EN',
|
|
84
94
|
getMessage: async () => undefined,
|
|
85
95
|
cachedGroupMetadata: async () => undefined,
|
|
86
|
-
makeSignalRepository: makeLibSignalRepository
|
|
87
|
-
}
|
|
88
|
-
|
|
96
|
+
makeSignalRepository: libsignal_1.makeLibSignalRepository
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
exports.MEDIA_PATH_MAP = {
|
|
89
100
|
image: '/mms/image',
|
|
90
101
|
video: '/mms/video',
|
|
91
102
|
document: '/mms/document',
|
|
92
103
|
audio: '/mms/audio',
|
|
93
104
|
sticker: '/mms/image',
|
|
94
|
-
'sticker-pack': '/mms/sticker
|
|
95
|
-
'thumbnail-sticker-pack': '/mms/thumbnail-sticker-pack',
|
|
105
|
+
'sticker-pack': '/mms/sticker',
|
|
96
106
|
'thumbnail-link': '/mms/image',
|
|
97
107
|
'product-catalog-image': '/product/image',
|
|
98
108
|
'md-app-state': '',
|
|
99
109
|
'md-msg-hist': '/mms/md-app-state',
|
|
100
110
|
'biz-cover-photo': '/pps/biz-cover-photo'
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
'
|
|
111
|
-
'
|
|
112
|
-
sticker: 'Image',
|
|
113
|
-
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
exports.MEDIA_HKDF_KEY_MAPPING = {
|
|
114
|
+
'audio': 'Audio',
|
|
115
|
+
'document': 'Document',
|
|
116
|
+
'gif': 'Video',
|
|
117
|
+
'image': 'Image',
|
|
118
|
+
'ppic': '',
|
|
119
|
+
'product': 'Image',
|
|
120
|
+
'ptt': 'Audio',
|
|
121
|
+
'video': 'Video',
|
|
122
|
+
'sticker': 'Image',
|
|
123
|
+
'sticker-pack': 'Sticker Pack',
|
|
114
124
|
'thumbnail-document': 'Document Thumbnail',
|
|
115
125
|
'thumbnail-image': 'Image Thumbnail',
|
|
116
126
|
'thumbnail-video': 'Video Thumbnail',
|
|
@@ -119,19 +129,23 @@ export const MEDIA_HKDF_KEY_MAPPING = {
|
|
|
119
129
|
'md-app-state': 'App State',
|
|
120
130
|
'product-catalog-image': '',
|
|
121
131
|
'payment-bg-image': 'Payment Background',
|
|
122
|
-
ptv: 'Video',
|
|
132
|
+
'ptv': 'Video',
|
|
123
133
|
'biz-cover-photo': 'Image'
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
exports.MEDIA_KEYS = Object.keys(exports.MEDIA_PATH_MAP)
|
|
137
|
+
|
|
138
|
+
exports.MIN_PREKEY_COUNT = 5
|
|
139
|
+
|
|
140
|
+
exports.INITIAL_PREKEY_COUNT = 30
|
|
141
|
+
|
|
142
|
+
exports.UPLOAD_TIMEOUT = 30000 // 30 seconds
|
|
143
|
+
|
|
144
|
+
exports.MIN_UPLOAD_INTERVAL = 5000 // seconds minimum between uploads
|
|
145
|
+
|
|
146
|
+
exports.DEFAULT_CACHE_TTLS = {
|
|
147
|
+
SIGNAL_STORE: 5 * 60,
|
|
148
|
+
MSG_RETRY: 60 * 60,
|
|
149
|
+
CALL_OFFER: 5 * 60,
|
|
150
|
+
USER_DEVICES: 5 * 60, // 5 minutes
|
|
151
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
export declare class CiphertextMessage {
|
|
2
|
-
readonly UNSUPPORTED_VERSION: number
|
|
3
|
-
readonly CURRENT_VERSION: number
|
|
4
|
-
readonly WHISPER_TYPE: number
|
|
5
|
-
readonly PREKEY_TYPE: number
|
|
6
|
-
readonly SENDERKEY_TYPE: number
|
|
7
|
-
readonly SENDERKEY_DISTRIBUTION_TYPE: number
|
|
8
|
-
readonly ENCRYPTED_MESSAGE_OVERHEAD: number
|
|
2
|
+
readonly UNSUPPORTED_VERSION: number
|
|
3
|
+
readonly CURRENT_VERSION: number
|
|
4
|
+
readonly WHISPER_TYPE: number
|
|
5
|
+
readonly PREKEY_TYPE: number
|
|
6
|
+
readonly SENDERKEY_TYPE: number
|
|
7
|
+
readonly SENDERKEY_DISTRIBUTION_TYPE: number
|
|
8
|
+
readonly ENCRYPTED_MESSAGE_OVERHEAD: number
|
|
9
9
|
}
|
|
10
|
-
//# sourceMappingURL=ciphertext-message.d.ts.map
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
+
|
|
5
|
+
class CiphertextMessage {
|
|
2
6
|
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
|
|
7
|
+
this.UNSUPPORTED_VERSION = 1
|
|
8
|
+
this.CURRENT_VERSION = 3
|
|
9
|
+
this.WHISPER_TYPE = 2
|
|
10
|
+
this.PREKEY_TYPE = 3
|
|
11
|
+
this.SENDERKEY_TYPE = 4
|
|
12
|
+
this.SENDERKEY_DISTRIBUTION_TYPE = 5
|
|
13
|
+
this.ENCRYPTED_MESSAGE_OVERHEAD = 53
|
|
10
14
|
}
|
|
11
15
|
}
|
|
12
|
-
|
|
16
|
+
|
|
17
|
+
module.exports = {
|
|
18
|
+
CiphertextMessage
|
|
19
|
+
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { SenderKeyDistributionMessage } from './sender-key-distribution-message
|
|
2
|
-
import { SenderKeyName } from './sender-key-name
|
|
3
|
-
import { SenderKeyRecord } from './sender-key-record
|
|
1
|
+
import { SenderKeyDistributionMessage } from './sender-key-distribution-message'
|
|
2
|
+
import { SenderKeyName } from './sender-key-name'
|
|
3
|
+
import { SenderKeyRecord } from './sender-key-record'
|
|
4
|
+
|
|
4
5
|
interface SenderKeyStore {
|
|
5
|
-
loadSenderKey(senderKeyName: SenderKeyName): Promise<SenderKeyRecord
|
|
6
|
-
storeSenderKey(senderKeyName: SenderKeyName, record: SenderKeyRecord): Promise<void
|
|
6
|
+
loadSenderKey(senderKeyName: SenderKeyName): Promise<SenderKeyRecord>
|
|
7
|
+
storeSenderKey(senderKeyName: SenderKeyName, record: SenderKeyRecord): Promise<void>
|
|
7
8
|
}
|
|
9
|
+
|
|
8
10
|
export declare class GroupSessionBuilder {
|
|
9
|
-
private readonly senderKeyStore
|
|
10
|
-
constructor(senderKeyStore: SenderKeyStore)
|
|
11
|
-
process(senderKeyName: SenderKeyName, senderKeyDistributionMessage: SenderKeyDistributionMessage): Promise<void
|
|
12
|
-
create(senderKeyName: SenderKeyName): Promise<SenderKeyDistributionMessage
|
|
11
|
+
private readonly senderKeyStore
|
|
12
|
+
constructor(senderKeyStore: SenderKeyStore)
|
|
13
|
+
process(senderKeyName: SenderKeyName, senderKeyDistributionMessage: SenderKeyDistributionMessage): Promise<void>
|
|
14
|
+
create(senderKeyName: SenderKeyName): Promise<SenderKeyDistributionMessage>
|
|
13
15
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
|
|
17
|
+
export {}
|
|
@@ -1,30 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict"
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
40
|
+
|
|
41
|
+
const keyhelper = __importStar(require("./keyhelper"))
|
|
42
|
+
const sender_key_distribution_message_1 = require("./sender-key-distribution-message")
|
|
43
|
+
|
|
44
|
+
class GroupSessionBuilder {
|
|
6
45
|
constructor(senderKeyStore) {
|
|
7
|
-
this.senderKeyStore = senderKeyStore
|
|
46
|
+
this.senderKeyStore = senderKeyStore
|
|
8
47
|
}
|
|
9
48
|
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)
|
|
49
|
+
const senderKeyRecord = await this.senderKeyStore.loadSenderKey(senderKeyName)
|
|
50
|
+
senderKeyRecord.addSenderKeyState(senderKeyDistributionMessage.getId(), senderKeyDistributionMessage.getIteration(), senderKeyDistributionMessage.getChainKey(), senderKeyDistributionMessage.getSignatureKey())
|
|
51
|
+
await this.senderKeyStore.storeSenderKey(senderKeyName, senderKeyRecord)
|
|
13
52
|
}
|
|
14
53
|
async create(senderKeyName) {
|
|
15
|
-
const senderKeyRecord = await this.senderKeyStore.loadSenderKey(senderKeyName)
|
|
54
|
+
const senderKeyRecord = await this.senderKeyStore.loadSenderKey(senderKeyName)
|
|
16
55
|
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)
|
|
56
|
+
const keyId = keyhelper.generateSenderKeyId()
|
|
57
|
+
const senderKey = keyhelper.generateSenderKey()
|
|
58
|
+
const signingKey = keyhelper.generateSenderSigningKey()
|
|
59
|
+
senderKeyRecord.setSenderKeyState(keyId, 0, senderKey, signingKey)
|
|
60
|
+
await this.senderKeyStore.storeSenderKey(senderKeyName, senderKeyRecord)
|
|
22
61
|
}
|
|
23
|
-
const state = senderKeyRecord.getSenderKeyState()
|
|
62
|
+
const state = senderKeyRecord.getSenderKeyState()
|
|
24
63
|
if (!state) {
|
|
25
|
-
throw new Error('No session state available')
|
|
64
|
+
throw new Error('No session state available')
|
|
26
65
|
}
|
|
27
|
-
return new SenderKeyDistributionMessage(state.getKeyId(), state.getSenderChainKey().getIteration(), state.getSenderChainKey().getSeed(), state.getSigningKeyPublic())
|
|
66
|
+
return new sender_key_distribution_message_1.SenderKeyDistributionMessage(state.getKeyId(), state.getSenderChainKey().getIteration(), state.getSenderChainKey().getSeed(), state.getSigningKeyPublic())
|
|
28
67
|
}
|
|
29
68
|
}
|
|
30
|
-
|
|
69
|
+
|
|
70
|
+
module.exports = {
|
|
71
|
+
GroupSessionBuilder
|
|
72
|
+
}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { SenderKeyName } from './sender-key-name
|
|
2
|
-
import { SenderKeyRecord } from './sender-key-record
|
|
1
|
+
import { SenderKeyName } from './sender-key-name'
|
|
2
|
+
import { SenderKeyRecord } from './sender-key-record'
|
|
3
|
+
|
|
3
4
|
export interface SenderKeyStore {
|
|
4
|
-
loadSenderKey(senderKeyName: SenderKeyName): Promise<SenderKeyRecord
|
|
5
|
-
storeSenderKey(senderKeyName: SenderKeyName, record: SenderKeyRecord): Promise<void
|
|
5
|
+
loadSenderKey(senderKeyName: SenderKeyName): Promise<SenderKeyRecord>
|
|
6
|
+
storeSenderKey(senderKeyName: SenderKeyName, record: SenderKeyRecord): Promise<void>
|
|
6
7
|
}
|
|
8
|
+
|
|
7
9
|
export declare class GroupCipher {
|
|
8
|
-
private readonly senderKeyStore
|
|
9
|
-
private readonly senderKeyName
|
|
10
|
-
constructor(senderKeyStore: SenderKeyStore, senderKeyName: SenderKeyName)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
private
|
|
15
|
-
private
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
private readonly senderKeyStore
|
|
11
|
+
private readonly senderKeyName
|
|
12
|
+
constructor(senderKeyStore: SenderKeyStore, senderKeyName: SenderKeyName)
|
|
13
|
+
private queueJob
|
|
14
|
+
encrypt(paddedPlaintext: Uint8Array | string): Promise<Uint8Array>
|
|
15
|
+
decrypt(senderKeyMessageBytes: Uint8Array): Promise<Uint8Array>
|
|
16
|
+
private getSenderKey
|
|
17
|
+
private getPlainText
|
|
18
|
+
private getCipherText
|
|
19
|
+
}
|