@neelegirl/baileys 1.5.2 → 1.5.3
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 -21
- package/README.md +195 -187
- package/WAProto/WAProto.proto +537 -236
- package/WAProto/index.d.ts +5971 -2388
- package/WAProto/index.js +17298 -6513
- package/lib/Defaults/baileys-version.json +3 -3
- package/lib/Defaults/index.d.ts +77 -67
- package/lib/Defaults/index.js +148 -136
- package/lib/Defaults/phonenumber-mcc.json +223 -223
- package/lib/Signal/WASignalGroup/GroupProtocol.js +1908 -1908
- package/lib/Signal/WASignalGroup/ciphertext-message.d.ts +9 -0
- package/lib/Signal/WASignalGroup/ciphertext-message.js +19 -0
- package/lib/Signal/WASignalGroup/ciphertext_message.js +15 -15
- package/lib/Signal/WASignalGroup/group-session-builder.d.ts +17 -0
- package/lib/Signal/WASignalGroup/group-session-builder.js +72 -0
- package/lib/Signal/WASignalGroup/group.proto +41 -41
- package/lib/Signal/WASignalGroup/group_cipher.d.ts +19 -0
- package/lib/Signal/WASignalGroup/group_cipher.js +101 -110
- package/lib/Signal/WASignalGroup/group_session_builder.js +45 -45
- package/lib/Signal/WASignalGroup/index.d.ts +11 -0
- package/lib/Signal/WASignalGroup/index.js +61 -6
- package/lib/Signal/WASignalGroup/keyhelper.d.ts +16 -0
- package/lib/Signal/WASignalGroup/keyhelper.js +58 -13
- package/lib/Signal/WASignalGroup/protobufs.js +2 -2
- package/lib/Signal/WASignalGroup/queue_job.js +68 -68
- package/lib/Signal/WASignalGroup/readme.md +5 -5
- package/lib/Signal/WASignalGroup/sender-chain-key.d.ts +14 -0
- package/lib/Signal/WASignalGroup/sender-chain-key.js +47 -0
- package/lib/Signal/WASignalGroup/sender-key-distribution-message.d.ts +17 -0
- package/lib/Signal/WASignalGroup/sender-key-distribution-message.js +71 -0
- package/lib/Signal/WASignalGroup/sender-key-message.d.ts +19 -0
- package/lib/Signal/WASignalGroup/sender-key-message.js +73 -0
- package/lib/Signal/WASignalGroup/sender-key-name.d.ts +19 -0
- package/lib/Signal/WASignalGroup/sender-key-name.js +59 -0
- package/lib/Signal/WASignalGroup/sender-key-record.d.ts +32 -0
- package/lib/Signal/WASignalGroup/sender-key-record.js +58 -0
- package/lib/Signal/WASignalGroup/sender-key-state.d.ts +44 -0
- package/lib/Signal/WASignalGroup/sender-key-state.js +147 -0
- package/lib/Signal/WASignalGroup/sender-message-key.d.ts +11 -0
- package/lib/Signal/WASignalGroup/sender-message-key.js +33 -0
- package/lib/Signal/WASignalGroup/sender_chain_key.js +49 -49
- package/lib/Signal/WASignalGroup/sender_key_distribution_message.js +77 -77
- package/lib/Signal/WASignalGroup/sender_key_message.js +91 -91
- package/lib/Signal/WASignalGroup/sender_key_name.js +69 -69
- package/lib/Signal/WASignalGroup/sender_key_record.js +55 -55
- package/lib/Signal/WASignalGroup/sender_key_state.js +128 -128
- package/lib/Signal/WASignalGroup/sender_message_key.js +38 -38
- package/lib/Signal/libsignal.d.ts +5 -1
- package/lib/Signal/libsignal.js +390 -161
- package/lib/Signal/lid-mapping.d.ts +28 -0
- package/lib/Signal/lid-mapping.js +184 -0
- package/lib/Socket/Client/abstract-socket-client.d.ts +15 -15
- package/lib/Socket/Client/abstract-socket-client.js +13 -13
- package/lib/Socket/Client/index.d.ts +2 -2
- package/lib/Socket/Client/mobile-socket-client.d.ts +12 -12
- package/lib/Socket/Client/mobile-socket-client.js +65 -65
- package/lib/Socket/Client/types.d.ts +1 -1
- package/lib/Socket/Client/websocket.d.ts +1 -1
- package/lib/Socket/business.d.ts +6 -6
- package/lib/Socket/business.js +152 -5
- package/lib/Socket/chats.d.ts +3 -4
- package/lib/Socket/chats.js +31 -26
- package/lib/Socket/communities.d.ts +223 -223
- package/lib/Socket/communities.js +432 -432
- package/lib/Socket/groups.d.ts +2 -4
- package/lib/Socket/groups.js +22 -14
- package/lib/Socket/index.d.ts +69 -69
- package/lib/Socket/index.js +3 -2
- package/lib/Socket/messages-recv.d.ts +3 -6
- package/lib/Socket/messages-recv.js +1449 -1707
- package/lib/Socket/messages-send.d.ts +2 -4
- package/lib/Socket/messages-send.js +617 -126
- package/lib/Socket/mex.d.ts +2 -2
- package/lib/Socket/mex.js +46 -46
- package/lib/Socket/newsletter.d.ts +2 -4
- package/lib/Socket/newsletter.js +294 -285
- package/lib/Socket/socket.js +318 -132
- package/lib/Socket/usync.js +3 -3
- package/lib/Store/index.d.ts +4 -4
- package/lib/Store/index.js +23 -23
- package/lib/Store/make-cache-manager-store.d.ts +13 -13
- package/lib/Store/make-cache-manager-store.js +89 -89
- package/lib/Store/make-in-memory-store.d.ts +122 -122
- package/lib/Store/make-in-memory-store.js +428 -428
- package/lib/Store/make-ordered-dictionary.d.ts +11 -11
- package/lib/Store/make-ordered-dictionary.js +85 -85
- package/lib/Store/object-repository.d.ts +9 -9
- package/lib/Store/object-repository.js +30 -30
- package/lib/Types/Auth.d.ts +5 -4
- package/lib/Types/Bussines.js +3 -0
- package/lib/Types/Bussiness.d.ts +28 -0
- package/lib/Types/Chat.d.ts +13 -8
- package/lib/Types/Contact.d.ts +4 -1
- package/lib/Types/Events.d.ts +13 -16
- package/lib/Types/GroupMetadata.d.ts +1 -1
- package/lib/Types/Message.d.ts +18 -7
- package/lib/Types/Message.js +7 -1
- package/lib/Types/MexUpdates.d.ts +8 -8
- package/lib/Types/MexUpdates.js +17 -17
- package/lib/Types/Newsletter.d.ts +1 -1
- package/lib/Types/Product.d.ts +1 -1
- package/lib/Types/Signal.d.ts +31 -1
- package/lib/Types/Socket.d.ts +34 -13
- package/lib/Types/State.d.ts +1 -1
- package/lib/Types/USync.d.ts +2 -2
- package/lib/Types/index.d.ts +16 -15
- package/lib/Types/index.js +4 -2
- package/lib/Utils/auth-utils.d.ts +20 -20
- package/lib/Utils/auth-utils.js +527 -204
- package/lib/Utils/baileys-event-stream.d.ts +17 -17
- package/lib/Utils/baileys-event-stream.js +69 -69
- package/lib/Utils/business.d.ts +28 -28
- package/lib/Utils/business.js +254 -254
- package/lib/Utils/chat-utils.d.ts +81 -81
- package/lib/Utils/chat-utils.js +808 -780
- package/lib/Utils/crypto.d.ts +55 -55
- package/lib/Utils/crypto.js +188 -178
- package/lib/Utils/decode-wa-message.d.ts +52 -40
- package/lib/Utils/decode-wa-message.js +322 -252
- package/lib/Utils/event-buffer.d.ts +38 -38
- package/lib/Utils/event-buffer.js +594 -564
- package/lib/Utils/generics.d.ts +131 -129
- package/lib/Utils/generics.js +629 -623
- package/lib/Utils/history.d.ts +22 -22
- package/lib/Utils/history.js +103 -109
- package/lib/Utils/index.d.ts +20 -19
- package/lib/Utils/index.js +39 -38
- package/lib/Utils/link-preview.d.ts +22 -22
- package/lib/Utils/link-preview.js +119 -119
- package/lib/Utils/logger.d.ts +13 -13
- package/lib/Utils/logger.js +7 -7
- package/lib/Utils/lt-hash.d.ts +13 -13
- package/lib/Utils/lt-hash.js +57 -57
- package/lib/Utils/make-mutex.d.ts +8 -8
- package/lib/Utils/make-mutex.js +48 -48
- package/lib/Utils/message-retry-manager.d.ts +88 -0
- package/lib/Utils/message-retry-manager.js +160 -0
- package/lib/Utils/messages-media.d.ts +134 -128
- package/lib/Utils/messages-media.js +868 -805
- package/lib/Utils/messages.d.ts +104 -102
- package/lib/Utils/messages.js +1744 -1578
- package/lib/Utils/noise-handler.d.ts +20 -19
- package/lib/Utils/noise-handler.js +164 -154
- package/lib/Utils/process-message.d.ts +48 -48
- package/lib/Utils/process-message.js +427 -428
- package/lib/Utils/signal.d.ts +41 -41
- package/lib/Utils/signal.js +165 -165
- package/lib/Utils/use-mongo-file-auth-state.d.ts +5 -5
- package/lib/Utils/use-mongo-file-auth-state.js +83 -83
- package/lib/Utils/use-multi-file-auth-state.d.ts +17 -17
- package/lib/Utils/use-multi-file-auth-state.js +237 -237
- package/lib/Utils/use-single-file-auth-state.d.ts +12 -12
- package/lib/Utils/use-single-file-auth-state.js +79 -79
- package/lib/Utils/validate-connection.d.ts +12 -12
- package/lib/Utils/validate-connection.js +219 -186
- package/lib/WABinary/constants.d.ts +29 -29
- package/lib/WABinary/constants.js +1315 -1315
- package/lib/WABinary/decode.d.ts +8 -8
- package/lib/WABinary/decode.js +287 -287
- package/lib/WABinary/encode.d.ts +2 -2
- package/lib/WABinary/encode.js +264 -264
- package/lib/WABinary/generic-utils.d.ts +27 -27
- package/lib/WABinary/generic-utils.js +141 -141
- package/lib/WABinary/index.d.ts +5 -5
- package/lib/WABinary/index.js +24 -24
- package/lib/WABinary/jid-utils.d.ts +58 -53
- package/lib/WABinary/jid-utils.js +103 -91
- package/lib/WABinary/types.d.ts +21 -21
- package/lib/WABinary/types.js +2 -2
- package/lib/WAM/BinaryInfo.d.ts +15 -15
- package/lib/WAM/BinaryInfo.js +16 -16
- package/lib/WAM/constants.d.ts +46 -46
- package/lib/WAM/constants.js +15370 -15370
- package/lib/WAM/encode.d.ts +2 -2
- package/lib/WAM/encode.js +163 -164
- package/lib/WAM/index.d.ts +3 -3
- package/lib/WAM/index.js +22 -22
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +27 -27
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +68 -68
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +3 -3
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +9 -8
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +37 -29
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/index.d.ts +6 -6
- package/lib/WAUSync/USyncQuery.d.ts +3 -3
- package/lib/WAUSync/index.d.ts +3 -3
- package/lib/index.d.ts +13 -13
- package/lib/index.js +33 -33
- package/package.json +96 -94
- package/lib/Socket/registration.d.ts +0 -266
- package/lib/Socket/registration.js +0 -166
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { proto } from '
|
|
2
|
-
import type { AuthenticationCreds, SignalCreds, SocketConfig } from '
|
|
3
|
-
import { BinaryNode } from '
|
|
4
|
-
|
|
5
|
-
export declare const generateLoginNode: (userJid: string, config: SocketConfig) => proto.IClientPayload
|
|
6
|
-
|
|
7
|
-
export declare const generateRegistrationNode: ({ registrationId, signedPreKey, signedIdentityKey }: SignalCreds, config: SocketConfig) => proto.ClientPayload
|
|
8
|
-
|
|
9
|
-
export declare const configureSuccessfulPairing: (stanza: BinaryNode, { advSecretKey, signedIdentityKey, signalIdentities }: Pick<AuthenticationCreds, 'advSecretKey' | 'signedIdentityKey' | 'signalIdentities'>) => {
|
|
10
|
-
creds: Partial<AuthenticationCreds>
|
|
11
|
-
reply: BinaryNode
|
|
12
|
-
}
|
|
1
|
+
import { proto } from '@neelegirl/baileys/WAProto'
|
|
2
|
+
import type { AuthenticationCreds, SignalCreds, SocketConfig } from '@neelegirl/baileys/lib/Types'
|
|
3
|
+
import { BinaryNode } from '@neelegirl/baileys/lib/WABinary'
|
|
4
|
+
|
|
5
|
+
export declare const generateLoginNode: (userJid: string, config: SocketConfig) => proto.IClientPayload
|
|
6
|
+
export declare const generateMobileNode: (config: SocketConfig) => proto.IClientPayload
|
|
7
|
+
export declare const generateRegistrationNode: ({ registrationId, signedPreKey, signedIdentityKey }: SignalCreds, config: SocketConfig) => proto.ClientPayload
|
|
8
|
+
|
|
9
|
+
export declare const configureSuccessfulPairing: (stanza: BinaryNode, { advSecretKey, signedIdentityKey, signalIdentities }: Pick<AuthenticationCreds, 'advSecretKey' | 'signedIdentityKey' | 'signalIdentities'>) => {
|
|
10
|
+
creds: Partial<AuthenticationCreds>
|
|
11
|
+
reply: BinaryNode
|
|
12
|
+
}
|
|
13
13
|
export declare const encodeSignedDeviceIdentity: (account: proto.IADVSignedDeviceIdentity, includeSignatureKey: boolean) => Uint8Array
|
|
@@ -1,187 +1,220 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
-
|
|
5
|
-
const boom_1 = require("@hapi/boom")
|
|
6
|
-
const crypto_1 = require("crypto")
|
|
7
|
-
const WAProto_1 = require("../../WAProto")
|
|
8
|
-
const Defaults_1 = require("../Defaults")
|
|
9
|
-
const WABinary_1 = require("../WABinary")
|
|
10
|
-
const crypto_2 = require("./crypto")
|
|
11
|
-
const generics_1 = require("./generics")
|
|
12
|
-
const signal_1 = require("./signal")
|
|
13
|
-
|
|
14
|
-
const getUserAgent = (config) => {
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const payload = {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
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
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
|
+
|
|
5
|
+
const boom_1 = require("@hapi/boom")
|
|
6
|
+
const crypto_1 = require("crypto")
|
|
7
|
+
const WAProto_1 = require("../../WAProto")
|
|
8
|
+
const Defaults_1 = require("../Defaults")
|
|
9
|
+
const WABinary_1 = require("../WABinary")
|
|
10
|
+
const crypto_2 = require("./crypto")
|
|
11
|
+
const generics_1 = require("./generics")
|
|
12
|
+
const signal_1 = require("./signal")
|
|
13
|
+
|
|
14
|
+
const getUserAgent = (config) => {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
|
|
17
|
+
const osVersion = config.mobile ? '16.7.10' : '0.1';
|
|
18
|
+
const version = config.mobile ? [2, 25, 15, 75] : config.version;
|
|
19
|
+
const device = config.mobile ? 'iPhone_X' : 'Desktop';
|
|
20
|
+
const manufacturer = config.mobile ? 'Apple' : '';
|
|
21
|
+
const platform = config.mobile ? WAProto_1.proto.ClientPayload.UserAgent.Platform.IOS : WAProto_1.proto.ClientPayload.UserAgent.Platform.WEB;
|
|
22
|
+
const phoneId = config.mobile ? { phoneId: config.auth.creds.phoneId } : {};
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
appVersion: {
|
|
26
|
+
primary: version[0],
|
|
27
|
+
secondary: version[1],
|
|
28
|
+
tertiary: version[2],
|
|
29
|
+
},
|
|
30
|
+
platform,
|
|
31
|
+
releaseChannel: WAProto_1.proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
|
32
|
+
osVersion: osVersion,
|
|
33
|
+
manufacturer,
|
|
34
|
+
device,
|
|
35
|
+
deviceType: WAProto_1.proto.ClientPayload.UserAgent.DeviceType.DESKTOP,
|
|
36
|
+
osBuildNumber: '0.1',
|
|
37
|
+
localeLanguageIso6391: 'en',
|
|
38
|
+
mcc: ((_a = config.auth.creds.registration) === null || _a === void 0 ? void 0 : _a.phoneNumberMobileCountryCode) || '000',
|
|
39
|
+
mnc: ((_b = config.auth.creds.registration) === null || _b === void 0 ? void 0 : _b.phoneNumberMobileNetworkCode) || '000',
|
|
40
|
+
localeCountryIso31661Alpha2: config.countryCode,
|
|
41
|
+
...phoneId
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const PLATFORM_MAP = {
|
|
46
|
+
'Mac OS': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
|
|
47
|
+
'Windows': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WIN32,
|
|
48
|
+
'Android': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WIN_HYBRID
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const getWebInfo = (config) => {
|
|
52
|
+
let webSubPlatform = WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER
|
|
53
|
+
if (config.syncFullHistory && PLATFORM_MAP[config.browser[0]]) {
|
|
54
|
+
webSubPlatform = PLATFORM_MAP[config.browser[0]]
|
|
55
|
+
}
|
|
56
|
+
return { webSubPlatform }
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const getClientPayload = (config) => {
|
|
60
|
+
const payload = {
|
|
61
|
+
connectType: WAProto_1.proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
|
|
62
|
+
connectReason: WAProto_1.proto.ClientPayload.ConnectReason.USER_ACTIVATED,
|
|
63
|
+
userAgent: getUserAgent(config),
|
|
64
|
+
}
|
|
65
|
+
if (!config.mobile) {
|
|
66
|
+
payload.webInfo = getWebInfo(config);
|
|
67
|
+
}
|
|
68
|
+
return payload
|
|
69
|
+
}
|
|
70
|
+
const generateMobileNode = (config) => {
|
|
71
|
+
if (!config.auth.creds) {
|
|
72
|
+
throw new boom_1.Boom('No registration data found', { data: config });
|
|
73
|
+
}
|
|
74
|
+
const payload = {
|
|
75
|
+
...getClientPayload(config),
|
|
76
|
+
sessionId: Math.floor(Math.random() * 999999999 + 1),
|
|
77
|
+
shortConnect: true,
|
|
78
|
+
connectAttemptCount: 0,
|
|
79
|
+
device: 0,
|
|
80
|
+
dnsSource: {
|
|
81
|
+
appCached: false,
|
|
82
|
+
dnsMethod: WAProto_1.proto.ClientPayload.DNSSource.DNSResolutionMethod.SYSTEM,
|
|
83
|
+
},
|
|
84
|
+
passive: false,
|
|
85
|
+
pushName: 'test',
|
|
86
|
+
username: Number(`${config.auth.creds.registration.phoneNumberCountryCode}${config.auth.creds.registration.phoneNumberNationalNumber}`),
|
|
87
|
+
};
|
|
88
|
+
return WAProto_1.proto.ClientPayload.fromObject(payload);
|
|
89
|
+
};
|
|
90
|
+
const generateLoginNode = (userJid, config) => {
|
|
91
|
+
const { user, device } = WABinary_1.jidDecode(userJid)
|
|
92
|
+
const payload = {
|
|
93
|
+
...getClientPayload(config),
|
|
94
|
+
passive: false,
|
|
95
|
+
pull: true,
|
|
96
|
+
username: +user,
|
|
97
|
+
device: device,
|
|
98
|
+
}
|
|
99
|
+
return WAProto_1.proto.ClientPayload.fromObject(payload)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const getPlatformType = (platform) => {
|
|
103
|
+
const platformType = platform.toUpperCase()
|
|
104
|
+
return WAProto_1.proto.DeviceProps.PlatformType[platformType] || WAProto_1.proto.DeviceProps.PlatformType.DESKTOP
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentityKey }, config) => {
|
|
108
|
+
// the app version needs to be md5 hashed
|
|
109
|
+
// and passed in
|
|
110
|
+
const appVersionBuf = crypto_1.createHash('md5')
|
|
111
|
+
.update(config.version.join('.')) // join as string
|
|
112
|
+
.digest()
|
|
113
|
+
const companion = {
|
|
114
|
+
os: config.browser[0],
|
|
115
|
+
platformType: getPlatformType(config.browser[1]),
|
|
116
|
+
requireFullSync: config.syncFullHistory,
|
|
117
|
+
}
|
|
118
|
+
const companionProto = WAProto_1.proto.DeviceProps.encode(companion).finish()
|
|
119
|
+
const registerPayload = {
|
|
120
|
+
...getClientPayload(config),
|
|
121
|
+
passive: false,
|
|
122
|
+
pull: false,
|
|
123
|
+
devicePairingData: {
|
|
124
|
+
buildHash: appVersionBuf,
|
|
125
|
+
deviceProps: companionProto,
|
|
126
|
+
eRegid: generics_1.encodeBigEndian(registrationId),
|
|
127
|
+
eKeytype: Defaults_1.KEY_BUNDLE_TYPE,
|
|
128
|
+
eIdent: signedIdentityKey.public,
|
|
129
|
+
eSkeyId: generics_1.encodeBigEndian(signedPreKey.keyId, 3),
|
|
130
|
+
eSkeyVal: signedPreKey.keyPair.public,
|
|
131
|
+
eSkeySig: signedPreKey.signature,
|
|
132
|
+
},
|
|
133
|
+
}
|
|
134
|
+
return WAProto_1.proto.ClientPayload.fromObject(registerPayload)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, signalIdentities }) => {
|
|
138
|
+
const msgId = stanza.attrs.id
|
|
139
|
+
const pairSuccessNode = WABinary_1.getBinaryNodeChild(stanza, 'pair-success')
|
|
140
|
+
const deviceIdentityNode = WABinary_1.getBinaryNodeChild(pairSuccessNode, 'device-identity')
|
|
141
|
+
const platformNode = WABinary_1.getBinaryNodeChild(pairSuccessNode, 'platform')
|
|
142
|
+
const deviceNode = WABinary_1.getBinaryNodeChild(pairSuccessNode, 'device')
|
|
143
|
+
const businessNode = WABinary_1.getBinaryNodeChild(pairSuccessNode, 'biz')
|
|
144
|
+
if (!deviceIdentityNode || !deviceNode) {
|
|
145
|
+
throw new boom_1.Boom('Missing device-identity or device in pair success node', { data: stanza })
|
|
146
|
+
}
|
|
147
|
+
const bizName = businessNode?.attrs?.name
|
|
148
|
+
const jid = deviceNode.attrs.jid
|
|
149
|
+
const { details, hmac, accountType } = WAProto_1.proto.ADVSignedDeviceIdentityHMAC.decode(deviceIdentityNode.content)
|
|
150
|
+
const isHostedAccount = accountType !== undefined && accountType === WAProto_1.proto.ADVEncryptionType.HOSTED
|
|
151
|
+
const hmacPrefix = isHostedAccount ? Buffer.from([6, 5]) : Buffer.alloc(0)
|
|
152
|
+
const advSign = crypto_2.hmacSign(Buffer.concat([hmacPrefix, details]), Buffer.from(advSecretKey, 'base64'))
|
|
153
|
+
if (Buffer.compare(hmac, advSign) !== 0) {
|
|
154
|
+
throw new boom_1.Boom('Invalid account signature')
|
|
155
|
+
}
|
|
156
|
+
const account = WAProto_1.proto.ADVSignedDeviceIdentity.decode(details)
|
|
157
|
+
const { accountSignatureKey, accountSignature, details: deviceDetails } = account
|
|
158
|
+
const accountMsg = Buffer.concat([Buffer.from([6, 0]), deviceDetails, signedIdentityKey.public])
|
|
159
|
+
if (!crypto_2.Curve.verify(accountSignatureKey, accountMsg, accountSignature)) {
|
|
160
|
+
throw new boom_1.Boom('Failed to verify account signature')
|
|
161
|
+
}
|
|
162
|
+
const devicePrefix = isHostedAccount ? Buffer.from([6, 6]) : Buffer.from([6, 1])
|
|
163
|
+
const deviceMsg = Buffer.concat([devicePrefix, deviceDetails, signedIdentityKey.public, accountSignatureKey])
|
|
164
|
+
account.deviceSignature = crypto_2.Curve.sign(signedIdentityKey.private, deviceMsg)
|
|
165
|
+
const identity = signal_1.createSignalIdentity(jid, accountSignatureKey)
|
|
166
|
+
const accountEnc = encodeSignedDeviceIdentity(account, false)
|
|
167
|
+
const deviceIdentity = WAProto_1.proto.ADVDeviceIdentity.decode(account.details)
|
|
168
|
+
const reply = {
|
|
169
|
+
tag: 'iq',
|
|
170
|
+
attrs: {
|
|
171
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
172
|
+
type: 'result',
|
|
173
|
+
id: msgId,
|
|
174
|
+
},
|
|
175
|
+
content: [
|
|
176
|
+
{
|
|
177
|
+
tag: 'pair-device-sign',
|
|
178
|
+
attrs: {},
|
|
179
|
+
content: [
|
|
180
|
+
{
|
|
181
|
+
tag: 'device-identity',
|
|
182
|
+
attrs: { 'key-index': deviceIdentity.keyIndex.toString() },
|
|
183
|
+
content: accountEnc
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
]
|
|
188
|
+
}
|
|
189
|
+
const authUpdate = {
|
|
190
|
+
account,
|
|
191
|
+
me: { id: jid, name: bizName },
|
|
192
|
+
signalIdentities: [
|
|
193
|
+
...(signalIdentities || []),
|
|
194
|
+
identity
|
|
195
|
+
],
|
|
196
|
+
platform: platformNode?.attrs?.name
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
creds: authUpdate,
|
|
200
|
+
reply
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const encodeSignedDeviceIdentity = (account, includeSignatureKey) => {
|
|
205
|
+
account = { ...account }
|
|
206
|
+
// set to null if we are not to include the signature key
|
|
207
|
+
// or if we are including the signature key but it is empty
|
|
208
|
+
if (!includeSignatureKey || !account.accountSignatureKey?.length) {
|
|
209
|
+
account.accountSignatureKey = null
|
|
210
|
+
}
|
|
211
|
+
return WAProto_1.proto.ADVSignedDeviceIdentity.encode(account).finish()
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
module.exports = {
|
|
215
|
+
generateLoginNode,
|
|
216
|
+
generateRegistrationNode,
|
|
217
|
+
configureSuccessfulPairing,
|
|
218
|
+
encodeSignedDeviceIdentity,
|
|
219
|
+
generateMobileNode
|
|
187
220
|
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
export declare const TAGS: {
|
|
2
|
-
LIST_EMPTY: number
|
|
3
|
-
DICTIONARY_0: number
|
|
4
|
-
DICTIONARY_1: number
|
|
5
|
-
DICTIONARY_2: number
|
|
6
|
-
DICTIONARY_3: number
|
|
7
|
-
INTEROP_JID: number
|
|
8
|
-
FB_JID: number
|
|
9
|
-
AD_JID: number
|
|
10
|
-
LIST_8: number
|
|
11
|
-
LIST_16: number
|
|
12
|
-
JID_PAIR: number
|
|
13
|
-
HEX_8: number
|
|
14
|
-
BINARY_8: number
|
|
15
|
-
BINARY_20: number
|
|
16
|
-
BINARY_32: number
|
|
17
|
-
NIBBLE_8: number
|
|
18
|
-
PACKED_MAX: number
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export declare const DOUBLE_BYTE_TOKENS: string[][]
|
|
22
|
-
|
|
23
|
-
export declare const SINGLE_BYTE_TOKENS: (string | null)[]
|
|
24
|
-
|
|
25
|
-
export declare const TOKEN_MAP: {
|
|
26
|
-
[token: string]: {
|
|
27
|
-
dict?: number
|
|
28
|
-
index: number
|
|
29
|
-
}
|
|
1
|
+
export declare const TAGS: {
|
|
2
|
+
LIST_EMPTY: number
|
|
3
|
+
DICTIONARY_0: number
|
|
4
|
+
DICTIONARY_1: number
|
|
5
|
+
DICTIONARY_2: number
|
|
6
|
+
DICTIONARY_3: number
|
|
7
|
+
INTEROP_JID: number
|
|
8
|
+
FB_JID: number
|
|
9
|
+
AD_JID: number
|
|
10
|
+
LIST_8: number
|
|
11
|
+
LIST_16: number
|
|
12
|
+
JID_PAIR: number
|
|
13
|
+
HEX_8: number
|
|
14
|
+
BINARY_8: number
|
|
15
|
+
BINARY_20: number
|
|
16
|
+
BINARY_32: number
|
|
17
|
+
NIBBLE_8: number
|
|
18
|
+
PACKED_MAX: number
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export declare const DOUBLE_BYTE_TOKENS: string[][]
|
|
22
|
+
|
|
23
|
+
export declare const SINGLE_BYTE_TOKENS: (string | null)[]
|
|
24
|
+
|
|
25
|
+
export declare const TOKEN_MAP: {
|
|
26
|
+
[token: string]: {
|
|
27
|
+
dict?: number
|
|
28
|
+
index: number
|
|
29
|
+
}
|
|
30
30
|
}
|