@queenanya/baileys 6.7.0 → 6.7.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/WASignalGroup/readme.md +6 -0
- package/lib/Defaults/baileys-version.json +3 -3
- package/lib/Defaults/index.d.ts +284 -284
- package/lib/Defaults/index.js +120 -120
- package/lib/Defaults/phonenumber-mcc.json +223 -223
- package/lib/Signal/libsignal.d.ts +3 -3
- package/lib/Signal/libsignal.js +152 -152
- package/lib/Socket/Client/abstract-socket-client.d.ts +17 -17
- package/lib/Socket/Client/abstract-socket-client.js +13 -13
- package/lib/Socket/Client/index.d.ts +3 -3
- package/lib/Socket/Client/index.js +19 -19
- package/lib/Socket/Client/mobile-socket-client.d.ts +13 -13
- package/lib/Socket/Client/mobile-socket-client.js +65 -65
- package/lib/Socket/Client/web-socket-client.d.ts +12 -12
- package/lib/Socket/Client/web-socket-client.js +62 -62
- package/lib/Socket/business.d.ts +135 -135
- package/lib/Socket/business.js +259 -259
- package/lib/Socket/chats.d.ts +79 -79
- package/lib/Socket/chats.js +854 -854
- package/lib/Socket/groups.d.ts +113 -113
- package/lib/Socket/groups.js +302 -302
- package/lib/Socket/index.d.ts +137 -137
- package/lib/Socket/index.js +10 -10
- package/lib/Socket/messages-recv.d.ts +124 -124
- package/lib/Socket/messages-recv.js +756 -747
- package/lib/Socket/messages-send.d.ts +119 -119
- package/lib/Socket/messages-send.js +663 -663
- package/lib/Socket/registration.d.ts +232 -232
- package/lib/Socket/registration.js +166 -166
- package/lib/Socket/socket.d.ts +42 -42
- package/lib/Socket/socket.js +588 -588
- package/lib/Store/index.d.ts +3 -3
- package/lib/Store/index.js +10 -10
- package/lib/Store/make-cache-manager-store.d.ts +13 -13
- package/lib/Store/make-cache-manager-store.js +83 -83
- package/lib/Store/make-in-memory-store.d.ts +117 -117
- package/lib/Store/make-in-memory-store.js +437 -437
- package/lib/Store/make-ordered-dictionary.d.ts +13 -13
- package/lib/Store/make-ordered-dictionary.js +81 -81
- package/lib/Store/object-repository.d.ts +10 -10
- package/lib/Store/object-repository.js +27 -27
- package/lib/Types/Auth.d.ts +108 -108
- package/lib/Types/Auth.js +2 -2
- package/lib/Types/Call.d.ts +13 -13
- package/lib/Types/Call.js +2 -2
- package/lib/Types/Chat.d.ts +102 -102
- package/lib/Types/Chat.js +4 -4
- package/lib/Types/Contact.d.ts +19 -19
- package/lib/Types/Contact.js +2 -2
- package/lib/Types/Events.d.ts +157 -157
- package/lib/Types/Events.js +2 -2
- package/lib/Types/GroupMetadata.d.ts +52 -52
- package/lib/Types/GroupMetadata.js +2 -2
- package/lib/Types/Label.d.ts +35 -35
- package/lib/Types/Label.js +27 -27
- package/lib/Types/LabelAssociation.d.ts +29 -29
- package/lib/Types/LabelAssociation.js +9 -9
- package/lib/Types/Message.d.ts +261 -261
- package/lib/Types/Message.js +9 -9
- package/lib/Types/Product.d.ts +78 -78
- package/lib/Types/Product.js +2 -2
- package/lib/Types/Signal.d.ts +57 -57
- package/lib/Types/Signal.js +2 -2
- package/lib/Types/Socket.d.ts +111 -111
- package/lib/Types/Socket.js +2 -2
- package/lib/Types/State.d.ts +27 -27
- package/lib/Types/State.js +2 -2
- package/lib/Types/index.d.ts +56 -56
- package/lib/Types/index.js +41 -41
- package/lib/Utils/auth-utils.d.ts +18 -18
- package/lib/Utils/auth-utils.js +204 -204
- package/lib/Utils/baileys-event-stream.d.ts +16 -16
- package/lib/Utils/baileys-event-stream.js +63 -63
- package/lib/Utils/business.d.ts +22 -22
- package/lib/Utils/business.js +234 -234
- package/lib/Utils/chat-utils.d.ts +71 -71
- package/lib/Utils/chat-utils.js +724 -724
- package/lib/Utils/crypto.d.ts +41 -41
- package/lib/Utils/crypto.js +151 -151
- package/lib/Utils/decode-wa-message.d.ts +19 -19
- package/lib/Utils/decode-wa-message.js +174 -174
- package/lib/Utils/event-buffer.d.ts +35 -35
- package/lib/Utils/event-buffer.js +514 -514
- package/lib/Utils/generics.d.ts +94 -94
- package/lib/Utils/generics.js +367 -367
- package/lib/Utils/history.d.ts +15 -15
- package/lib/Utils/history.js +91 -91
- package/lib/Utils/index.d.ts +17 -17
- package/lib/Utils/index.js +33 -33
- package/lib/Utils/link-preview.d.ts +21 -21
- package/lib/Utils/link-preview.js +93 -93
- package/lib/Utils/logger.d.ts +4 -4
- package/lib/Utils/logger.js +7 -7
- package/lib/Utils/lt-hash.d.ts +12 -12
- package/lib/Utils/lt-hash.js +51 -51
- package/lib/Utils/make-mutex.d.ts +7 -7
- package/lib/Utils/make-mutex.js +43 -43
- package/lib/Utils/messages-media.d.ts +107 -107
- package/lib/Utils/messages-media.js +680 -680
- package/lib/Utils/messages.d.ts +76 -76
- package/lib/Utils/messages.js +768 -768
- package/lib/Utils/noise-handler.d.ts +20 -20
- package/lib/Utils/noise-handler.js +142 -142
- package/lib/Utils/process-message.d.ts +41 -41
- package/lib/Utils/process-message.js +320 -320
- package/lib/Utils/signal.d.ts +32 -32
- package/lib/Utils/signal.js +151 -151
- package/lib/Utils/use-multi-file-auth-state.d.ts +12 -12
- package/lib/Utils/use-multi-file-auth-state.js +80 -80
- package/lib/Utils/validate-connection.d.ts +11 -11
- package/lib/Utils/validate-connection.js +205 -222
- package/lib/WABinary/constants.d.ts +27 -27
- package/lib/WABinary/constants.js +40 -40
- package/lib/WABinary/decode.d.ts +7 -7
- package/lib/WABinary/decode.js +252 -252
- package/lib/WABinary/encode.d.ts +3 -3
- package/lib/WABinary/encode.js +228 -228
- package/lib/WABinary/generic-utils.d.ts +15 -15
- package/lib/WABinary/generic-utils.js +110 -110
- package/lib/WABinary/index.d.ts +5 -5
- package/lib/WABinary/index.js +21 -21
- package/lib/WABinary/jid-utils.d.ts +29 -29
- package/lib/WABinary/jid-utils.js +59 -59
- package/lib/WABinary/types.d.ts +18 -18
- package/lib/WABinary/types.js +2 -2
- package/lib/index.d.ts +10 -10
- package/lib/index.js +29 -29
- package/package.json +4 -1
- package/CHANGELOG.md +0 -4
|
@@ -1,222 +1,205 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.encodeSignedDeviceIdentity = exports.configureSuccessfulPairing = exports.generateRegistrationNode = exports.generateLoginNode = exports.generateMobileNode = void 0;
|
|
4
|
-
const boom_1 = require("@hapi/boom");
|
|
5
|
-
const crypto_1 = require("crypto");
|
|
6
|
-
const WAProto_1 = require("../../WAProto");
|
|
7
|
-
const Defaults_1 = require("../Defaults");
|
|
8
|
-
const WABinary_1 = require("../WABinary");
|
|
9
|
-
const crypto_2 = require("./crypto");
|
|
10
|
-
const generics_1 = require("./generics");
|
|
11
|
-
const signal_1 = require("./signal");
|
|
12
|
-
const getUserAgent = (config) => {
|
|
13
|
-
var _a, _b;
|
|
14
|
-
const osVersion = config.mobile ? '15.3.1' : '0.1';
|
|
15
|
-
const version = config.mobile ? [2,
|
|
16
|
-
const device = config.mobile ? 'iPhone_7' : 'Desktop';
|
|
17
|
-
const manufacturer = config.mobile ? 'Apple' : '';
|
|
18
|
-
const platform = config.mobile ? WAProto_1.proto.ClientPayload.UserAgent.Platform.IOS : WAProto_1.proto.ClientPayload.UserAgent.Platform.
|
|
19
|
-
const phoneId = config.mobile ? { phoneId: config.auth.creds.phoneId } : {};
|
|
20
|
-
return {
|
|
21
|
-
appVersion: {
|
|
22
|
-
primary: version[0],
|
|
23
|
-
secondary: version[1],
|
|
24
|
-
tertiary: version[2],
|
|
25
|
-
},
|
|
26
|
-
platform,
|
|
27
|
-
releaseChannel: WAProto_1.proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
|
28
|
-
mcc: ((_a = config.auth.creds.registration) === null || _a === void 0 ? void 0 : _a.phoneNumberMobileCountryCode) || '000',
|
|
29
|
-
mnc: ((_b = config.auth.creds.registration) === null || _b === void 0 ? void 0 : _b.phoneNumberMobileNetworkCode) || '000',
|
|
30
|
-
osVersion: osVersion,
|
|
31
|
-
manufacturer,
|
|
32
|
-
device,
|
|
33
|
-
osBuildNumber: osVersion,
|
|
34
|
-
localeLanguageIso6391: 'en',
|
|
35
|
-
localeCountryIso31661Alpha2: 'US',
|
|
36
|
-
...phoneId
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const payload = {
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const
|
|
155
|
-
const
|
|
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
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
reply
|
|
207
|
-
};
|
|
208
|
-
};
|
|
209
|
-
exports.configureSuccessfulPairing = configureSuccessfulPairing;
|
|
210
|
-
const encodeSignedDeviceIdentity = (account, includeSignatureKey) => {
|
|
211
|
-
var _a;
|
|
212
|
-
account = { ...account };
|
|
213
|
-
// set to null if we are not to include the signature key
|
|
214
|
-
// or if we are including the signature key but it is empty
|
|
215
|
-
if (!includeSignatureKey || !((_a = account.accountSignatureKey) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
216
|
-
account.accountSignatureKey = null;
|
|
217
|
-
}
|
|
218
|
-
return WAProto_1.proto.ADVSignedDeviceIdentity
|
|
219
|
-
.encode(account)
|
|
220
|
-
.finish();
|
|
221
|
-
};
|
|
222
|
-
exports.encodeSignedDeviceIdentity = encodeSignedDeviceIdentity;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeSignedDeviceIdentity = exports.configureSuccessfulPairing = exports.generateRegistrationNode = exports.generateLoginNode = exports.generateMobileNode = void 0;
|
|
4
|
+
const boom_1 = require("@hapi/boom");
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
6
|
+
const WAProto_1 = require("../../WAProto");
|
|
7
|
+
const Defaults_1 = require("../Defaults");
|
|
8
|
+
const WABinary_1 = require("../WABinary");
|
|
9
|
+
const crypto_2 = require("./crypto");
|
|
10
|
+
const generics_1 = require("./generics");
|
|
11
|
+
const signal_1 = require("./signal");
|
|
12
|
+
const getUserAgent = (config) => {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
const osVersion = config.mobile ? '15.3.1' : '0.1';
|
|
15
|
+
const version = config.mobile ? [2, 24, 5] : config.version;
|
|
16
|
+
const device = config.mobile ? 'iPhone_7' : 'Desktop';
|
|
17
|
+
const manufacturer = config.mobile ? 'Apple' : '';
|
|
18
|
+
const platform = config.mobile ? WAProto_1.proto.ClientPayload.UserAgent.Platform.IOS : WAProto_1.proto.ClientPayload.UserAgent.Platform.WEB;
|
|
19
|
+
const phoneId = config.mobile ? { phoneId: config.auth.creds.phoneId } : {};
|
|
20
|
+
return {
|
|
21
|
+
appVersion: {
|
|
22
|
+
primary: version[0],
|
|
23
|
+
secondary: version[1],
|
|
24
|
+
tertiary: version[2],
|
|
25
|
+
},
|
|
26
|
+
platform,
|
|
27
|
+
releaseChannel: WAProto_1.proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
|
28
|
+
mcc: ((_a = config.auth.creds.registration) === null || _a === void 0 ? void 0 : _a.phoneNumberMobileCountryCode) || '000',
|
|
29
|
+
mnc: ((_b = config.auth.creds.registration) === null || _b === void 0 ? void 0 : _b.phoneNumberMobileNetworkCode) || '000',
|
|
30
|
+
osVersion: osVersion,
|
|
31
|
+
manufacturer,
|
|
32
|
+
device,
|
|
33
|
+
osBuildNumber: osVersion,
|
|
34
|
+
localeLanguageIso6391: 'en',
|
|
35
|
+
localeCountryIso31661Alpha2: 'US',
|
|
36
|
+
...phoneId
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const PLATFORM_MAP = {
|
|
40
|
+
'Mac OS': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
|
|
41
|
+
'Windows': WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WIN32
|
|
42
|
+
};
|
|
43
|
+
const getWebInfo = (config) => {
|
|
44
|
+
let webSubPlatform = WAProto_1.proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER;
|
|
45
|
+
if (config.syncFullHistory && PLATFORM_MAP[config.browser[0]]) {
|
|
46
|
+
webSubPlatform = PLATFORM_MAP[config.browser[0]];
|
|
47
|
+
}
|
|
48
|
+
return { webSubPlatform };
|
|
49
|
+
};
|
|
50
|
+
const getClientPayload = (config) => {
|
|
51
|
+
const payload = {
|
|
52
|
+
connectType: WAProto_1.proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
|
|
53
|
+
connectReason: WAProto_1.proto.ClientPayload.ConnectReason.USER_ACTIVATED,
|
|
54
|
+
userAgent: getUserAgent(config),
|
|
55
|
+
};
|
|
56
|
+
if (!config.mobile) {
|
|
57
|
+
payload.webInfo = getWebInfo(config);
|
|
58
|
+
}
|
|
59
|
+
return payload;
|
|
60
|
+
};
|
|
61
|
+
const generateMobileNode = (config) => {
|
|
62
|
+
if (!config.auth.creds) {
|
|
63
|
+
throw new boom_1.Boom('No registration data found', { data: config });
|
|
64
|
+
}
|
|
65
|
+
const payload = {
|
|
66
|
+
...getClientPayload(config),
|
|
67
|
+
sessionId: Math.floor(Math.random() * 999999999 + 1),
|
|
68
|
+
shortConnect: true,
|
|
69
|
+
connectAttemptCount: 0,
|
|
70
|
+
device: 0,
|
|
71
|
+
dnsSource: {
|
|
72
|
+
appCached: false,
|
|
73
|
+
dnsMethod: WAProto_1.proto.ClientPayload.DNSSource.DNSResolutionMethod.SYSTEM,
|
|
74
|
+
},
|
|
75
|
+
passive: false,
|
|
76
|
+
pushName: 'test',
|
|
77
|
+
username: Number(`${config.auth.creds.registration.phoneNumberCountryCode}${config.auth.creds.registration.phoneNumberNationalNumber}`),
|
|
78
|
+
};
|
|
79
|
+
return WAProto_1.proto.ClientPayload.fromObject(payload);
|
|
80
|
+
};
|
|
81
|
+
exports.generateMobileNode = generateMobileNode;
|
|
82
|
+
const generateLoginNode = (userJid, config) => {
|
|
83
|
+
const { user, device } = (0, WABinary_1.jidDecode)(userJid);
|
|
84
|
+
const payload = {
|
|
85
|
+
...getClientPayload(config),
|
|
86
|
+
passive: true,
|
|
87
|
+
username: +user,
|
|
88
|
+
device: device,
|
|
89
|
+
};
|
|
90
|
+
return WAProto_1.proto.ClientPayload.fromObject(payload);
|
|
91
|
+
};
|
|
92
|
+
exports.generateLoginNode = generateLoginNode;
|
|
93
|
+
const getPlatformType = (platform) => {
|
|
94
|
+
const platformType = platform.toUpperCase();
|
|
95
|
+
return WAProto_1.proto.DeviceProps.PlatformType[platformType] || WAProto_1.proto.DeviceProps.PlatformType.DESKTOP;
|
|
96
|
+
};
|
|
97
|
+
const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentityKey }, config) => {
|
|
98
|
+
// the app version needs to be md5 hashed
|
|
99
|
+
// and passed in
|
|
100
|
+
const appVersionBuf = (0, crypto_1.createHash)('md5')
|
|
101
|
+
.update(config.version.join('.')) // join as string
|
|
102
|
+
.digest();
|
|
103
|
+
const companion = {
|
|
104
|
+
os: config.browser[0],
|
|
105
|
+
platformType: getPlatformType(config.browser[1]),
|
|
106
|
+
requireFullSync: config.syncFullHistory,
|
|
107
|
+
};
|
|
108
|
+
const companionProto = WAProto_1.proto.DeviceProps.encode(companion).finish();
|
|
109
|
+
const registerPayload = {
|
|
110
|
+
...getClientPayload(config),
|
|
111
|
+
passive: false,
|
|
112
|
+
devicePairingData: {
|
|
113
|
+
buildHash: appVersionBuf,
|
|
114
|
+
deviceProps: companionProto,
|
|
115
|
+
eRegid: (0, generics_1.encodeBigEndian)(registrationId),
|
|
116
|
+
eKeytype: Defaults_1.KEY_BUNDLE_TYPE,
|
|
117
|
+
eIdent: signedIdentityKey.public,
|
|
118
|
+
eSkeyId: (0, generics_1.encodeBigEndian)(signedPreKey.keyId, 3),
|
|
119
|
+
eSkeyVal: signedPreKey.keyPair.public,
|
|
120
|
+
eSkeySig: signedPreKey.signature,
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
return WAProto_1.proto.ClientPayload.fromObject(registerPayload);
|
|
124
|
+
};
|
|
125
|
+
exports.generateRegistrationNode = generateRegistrationNode;
|
|
126
|
+
const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, signalIdentities }) => {
|
|
127
|
+
const msgId = stanza.attrs.id;
|
|
128
|
+
const pairSuccessNode = (0, WABinary_1.getBinaryNodeChild)(stanza, 'pair-success');
|
|
129
|
+
const deviceIdentityNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'device-identity');
|
|
130
|
+
const platformNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'platform');
|
|
131
|
+
const deviceNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'device');
|
|
132
|
+
const businessNode = (0, WABinary_1.getBinaryNodeChild)(pairSuccessNode, 'biz');
|
|
133
|
+
if (!deviceIdentityNode || !deviceNode) {
|
|
134
|
+
throw new boom_1.Boom('Missing device-identity or device in pair success node', { data: stanza });
|
|
135
|
+
}
|
|
136
|
+
const bizName = businessNode === null || businessNode === void 0 ? void 0 : businessNode.attrs.name;
|
|
137
|
+
const jid = deviceNode.attrs.jid;
|
|
138
|
+
const { details, hmac } = WAProto_1.proto.ADVSignedDeviceIdentityHMAC.decode(deviceIdentityNode.content);
|
|
139
|
+
// check HMAC matches
|
|
140
|
+
const advSign = (0, crypto_2.hmacSign)(details, Buffer.from(advSecretKey, 'base64'));
|
|
141
|
+
if (Buffer.compare(hmac, advSign) !== 0) {
|
|
142
|
+
throw new boom_1.Boom('Invalid account signature');
|
|
143
|
+
}
|
|
144
|
+
const account = WAProto_1.proto.ADVSignedDeviceIdentity.decode(details);
|
|
145
|
+
const { accountSignatureKey, accountSignature, details: deviceDetails } = account;
|
|
146
|
+
// verify the device signature matches
|
|
147
|
+
const accountMsg = Buffer.concat([Buffer.from([6, 0]), deviceDetails, signedIdentityKey.public]);
|
|
148
|
+
if (!crypto_2.Curve.verify(accountSignatureKey, accountMsg, accountSignature)) {
|
|
149
|
+
throw new boom_1.Boom('Failed to verify account signature');
|
|
150
|
+
}
|
|
151
|
+
// sign the details with our identity key
|
|
152
|
+
const deviceMsg = Buffer.concat([Buffer.from([6, 1]), deviceDetails, signedIdentityKey.public, accountSignatureKey]);
|
|
153
|
+
account.deviceSignature = crypto_2.Curve.sign(signedIdentityKey.private, deviceMsg);
|
|
154
|
+
const identity = (0, signal_1.createSignalIdentity)(jid, accountSignatureKey);
|
|
155
|
+
const accountEnc = (0, exports.encodeSignedDeviceIdentity)(account, false);
|
|
156
|
+
const deviceIdentity = WAProto_1.proto.ADVDeviceIdentity.decode(account.details);
|
|
157
|
+
const reply = {
|
|
158
|
+
tag: 'iq',
|
|
159
|
+
attrs: {
|
|
160
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
161
|
+
type: 'result',
|
|
162
|
+
id: msgId,
|
|
163
|
+
},
|
|
164
|
+
content: [
|
|
165
|
+
{
|
|
166
|
+
tag: 'pair-device-sign',
|
|
167
|
+
attrs: {},
|
|
168
|
+
content: [
|
|
169
|
+
{
|
|
170
|
+
tag: 'device-identity',
|
|
171
|
+
attrs: { 'key-index': deviceIdentity.keyIndex.toString() },
|
|
172
|
+
content: accountEnc
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
};
|
|
178
|
+
const authUpdate = {
|
|
179
|
+
account,
|
|
180
|
+
me: { id: jid, name: bizName },
|
|
181
|
+
signalIdentities: [
|
|
182
|
+
...(signalIdentities || []),
|
|
183
|
+
identity
|
|
184
|
+
],
|
|
185
|
+
platform: platformNode === null || platformNode === void 0 ? void 0 : platformNode.attrs.name
|
|
186
|
+
};
|
|
187
|
+
return {
|
|
188
|
+
creds: authUpdate,
|
|
189
|
+
reply
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
exports.configureSuccessfulPairing = configureSuccessfulPairing;
|
|
193
|
+
const encodeSignedDeviceIdentity = (account, includeSignatureKey) => {
|
|
194
|
+
var _a;
|
|
195
|
+
account = { ...account };
|
|
196
|
+
// set to null if we are not to include the signature key
|
|
197
|
+
// or if we are including the signature key but it is empty
|
|
198
|
+
if (!includeSignatureKey || !((_a = account.accountSignatureKey) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
199
|
+
account.accountSignatureKey = null;
|
|
200
|
+
}
|
|
201
|
+
return WAProto_1.proto.ADVSignedDeviceIdentity
|
|
202
|
+
.encode(account)
|
|
203
|
+
.finish();
|
|
204
|
+
};
|
|
205
|
+
exports.encodeSignedDeviceIdentity = encodeSignedDeviceIdentity;
|
|
@@ -1,27 +1,27 @@
|
|
|
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
|
-
AD_JID: number;
|
|
8
|
-
LIST_8: number;
|
|
9
|
-
LIST_16: number;
|
|
10
|
-
JID_PAIR: number;
|
|
11
|
-
HEX_8: number;
|
|
12
|
-
BINARY_8: number;
|
|
13
|
-
BINARY_20: number;
|
|
14
|
-
BINARY_32: number;
|
|
15
|
-
NIBBLE_8: number;
|
|
16
|
-
PACKED_MAX: number;
|
|
17
|
-
SINGLE_BYTE_MAX: number;
|
|
18
|
-
STREAM_END: number;
|
|
19
|
-
};
|
|
20
|
-
export declare const DOUBLE_BYTE_TOKENS: string[][];
|
|
21
|
-
export declare const SINGLE_BYTE_TOKENS: (string | null)[];
|
|
22
|
-
export declare const TOKEN_MAP: {
|
|
23
|
-
[token: string]: {
|
|
24
|
-
dict?: number;
|
|
25
|
-
index: number;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
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
|
+
AD_JID: number;
|
|
8
|
+
LIST_8: number;
|
|
9
|
+
LIST_16: number;
|
|
10
|
+
JID_PAIR: number;
|
|
11
|
+
HEX_8: number;
|
|
12
|
+
BINARY_8: number;
|
|
13
|
+
BINARY_20: number;
|
|
14
|
+
BINARY_32: number;
|
|
15
|
+
NIBBLE_8: number;
|
|
16
|
+
PACKED_MAX: number;
|
|
17
|
+
SINGLE_BYTE_MAX: number;
|
|
18
|
+
STREAM_END: number;
|
|
19
|
+
};
|
|
20
|
+
export declare const DOUBLE_BYTE_TOKENS: string[][];
|
|
21
|
+
export declare const SINGLE_BYTE_TOKENS: (string | null)[];
|
|
22
|
+
export declare const TOKEN_MAP: {
|
|
23
|
+
[token: string]: {
|
|
24
|
+
dict?: number;
|
|
25
|
+
index: number;
|
|
26
|
+
};
|
|
27
|
+
};
|