@rizzxdc/baileys 8.0.10 → 8.1.0
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 +4 -2
- package/README.md +107 -245
- package/WAProto/index.d.ts +15795 -0
- package/WAProto/index.js +25587 -4867
- package/lib/Defaults/index.d.ts +147 -0
- package/lib/Defaults/index.js +134 -104
- package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
- package/lib/Signal/Group/ciphertext-message.js +9 -11
- package/lib/Signal/Group/group-session-builder.d.ts +8 -0
- package/lib/Signal/Group/group-session-builder.js +5 -8
- package/lib/Signal/Group/group_cipher.d.ts +11 -0
- package/lib/Signal/Group/group_cipher.js +72 -75
- package/lib/Signal/Group/index.d.ts +12 -0
- package/lib/Signal/Group/index.js +11 -13
- package/lib/Signal/Group/keyhelper.d.ts +7 -0
- package/lib/Signal/Group/keyhelper.js +11 -14
- package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
- package/lib/Signal/Group/sender-chain-key.js +23 -26
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +58 -61
- package/lib/Signal/Group/sender-key-message.d.ts +19 -0
- package/lib/Signal/Group/sender-key-message.js +61 -64
- package/lib/Signal/Group/sender-key-name.d.ts +12 -0
- package/lib/Signal/Group/sender-key-name.js +39 -44
- package/lib/Signal/Group/sender-key-record.d.ts +13 -0
- package/lib/Signal/Group/sender-key-record.js +35 -38
- package/lib/Signal/Group/sender-key-state.d.ts +17 -0
- package/lib/Signal/Group/sender-key-state.js +76 -79
- package/lib/Signal/Group/sender-message-key.d.ts +12 -0
- package/lib/Signal/Group/sender-message-key.js +23 -26
- package/lib/Signal/libsignal.d.ts +55 -0
- package/lib/Signal/libsignal.js +414 -308
- package/lib/Signal/lid-mapping.d.ts +21 -0
- package/lib/Signal/lid-mapping.js +270 -149
- package/lib/Socket/Client/index.d.ts +3 -0
- package/lib/Socket/Client/index.js +2 -4
- package/lib/Socket/Client/types.d.ts +6 -0
- package/lib/Socket/Client/types.js +8 -11
- package/lib/Socket/Client/websocket.d.ts +13 -0
- package/lib/Socket/Client/websocket.js +51 -50
- package/lib/Socket/business.d.ts +395 -0
- package/lib/Socket/business.js +357 -355
- package/lib/Socket/chats.d.ts +137 -0
- package/lib/Socket/chats.js +1195 -867
- package/lib/Socket/communities.d.ts +562 -0
- package/lib/Socket/communities.js +416 -398
- package/lib/Socket/dugong.js +8 -1
- package/lib/Socket/groups.d.ts +286 -0
- package/lib/Socket/groups.js +336 -301
- package/lib/Socket/index.d.ts +530 -0
- package/lib/Socket/index.js +8 -13
- package/lib/Socket/messages-recv.d.ts +334 -0
- package/lib/Socket/messages-recv.js +1729 -1121
- package/lib/Socket/messages-send.d.ts +330 -0
- package/lib/Socket/messages-send.js +684 -462
- package/lib/Socket/mex.d.ts +2 -0
- package/lib/Socket/mex.js +36 -40
- package/lib/Socket/newsletter.d.ts +284 -0
- package/lib/Socket/newsletter.js +247 -237
- package/lib/Socket/socket.d.ts +61 -0
- package/lib/Socket/socket.js +968 -790
- package/lib/Store/index.d.ts +4 -0
- package/lib/Store/index.js +4 -6
- package/lib/Store/make-cache-manager-store.js +2 -2
- package/lib/Store/make-in-memory-store.d.ts +63 -0
- package/lib/Store/make-in-memory-store.js +414 -284
- package/lib/Store/make-ordered-dictionary.d.ts +13 -0
- package/lib/Store/make-ordered-dictionary.js +75 -76
- package/lib/Store/object-repository.d.ts +11 -0
- package/lib/Store/object-repository.js +21 -23
- package/lib/Types/Auth.d.ts +2 -0
- package/lib/Types/Auth.js +0 -2
- package/lib/Types/Bussines.d.ts +2 -0
- package/lib/Types/Bussines.js +0 -2
- package/lib/Types/Call.d.ts +2 -0
- package/lib/Types/Call.js +0 -2
- package/lib/Types/Chat.d.ts +2 -0
- package/lib/Types/Chat.js +5 -7
- package/lib/Types/Contact.d.ts +2 -0
- package/lib/Types/Contact.js +0 -2
- package/lib/Types/Events.d.ts +2 -0
- package/lib/Types/Events.js +1 -3
- package/lib/Types/GroupMetadata.d.ts +2 -0
- package/lib/Types/GroupMetadata.js +0 -2
- package/lib/Types/Label.d.ts +3 -0
- package/lib/Types/Label.js +21 -22
- package/lib/Types/LabelAssociation.d.ts +3 -0
- package/lib/Types/LabelAssociation.js +3 -4
- package/lib/Types/Message.d.ts +12 -0
- package/lib/Types/Message.js +11 -6
- package/lib/Types/Mex.d.ts +3 -0
- package/lib/Types/Mex.js +38 -0
- package/lib/Types/Product.d.ts +2 -0
- package/lib/Types/Product.js +0 -2
- package/lib/Types/RichType.d.ts +3 -0
- package/lib/Types/RichType.js +22 -0
- package/lib/Types/Signal.d.ts +2 -0
- package/lib/Types/Signal.js +1 -3
- package/lib/Types/Socket.d.ts +2 -0
- package/lib/Types/Socket.js +1 -4
- package/lib/Types/State.d.ts +6 -0
- package/lib/Types/State.js +52 -8
- package/lib/Types/USync.d.ts +2 -0
- package/lib/Types/USync.js +1 -3
- package/lib/Types/index.d.ts +14 -0
- package/lib/Types/index.js +22 -25
- package/lib/Utils/auth-utils.d.ts +58 -0
- package/lib/Utils/auth-utils.js +285 -203
- package/lib/Utils/browser-utils.d.ts +9 -0
- package/lib/Utils/browser-utils.js +21 -19
- package/lib/Utils/business.d.ts +50 -0
- package/lib/Utils/business.js +206 -209
- package/lib/Utils/chat-utils.d.ts +409 -0
- package/lib/Utils/chat-utils.js +825 -706
- package/lib/Utils/companion-reg-client-utils.d.ts +5 -0
- package/lib/Utils/companion-reg-client-utils.js +39 -0
- package/lib/Utils/crypto.d.ts +40 -0
- package/lib/Utils/crypto.js +88 -101
- package/lib/Utils/decode-wa-message.d.ts +84 -0
- package/lib/Utils/decode-wa-message.js +287 -238
- package/lib/Utils/event-buffer.d.ts +13 -0
- package/lib/Utils/event-buffer.js +602 -509
- package/lib/Utils/generics.d.ts +64 -0
- package/lib/Utils/generics.js +334 -295
- package/lib/Utils/history.d.ts +76 -0
- package/lib/Utils/history.js +125 -79
- package/lib/Utils/identity-change-handler.d.ts +14 -0
- package/lib/Utils/identity-change-handler.js +49 -0
- package/lib/Utils/index.d.ts +25 -0
- package/lib/Utils/index.js +25 -21
- package/lib/Utils/link-preview.d.ts +13 -0
- package/lib/Utils/link-preview.js +73 -70
- package/lib/Utils/logger.d.ts +3 -0
- package/lib/Utils/logger.js +1 -4
- package/lib/Utils/lt-hash.d.ts +7 -0
- package/lib/Utils/lt-hash.js +7 -45
- package/lib/Utils/make-mutex.d.ts +7 -0
- package/lib/Utils/make-mutex.js +27 -31
- package/lib/Utils/message-retry-manager.d.ts +80 -0
- package/lib/Utils/message-retry-manager.js +165 -14
- package/lib/Utils/messages-media.d.ts +137 -0
- package/lib/Utils/messages-media.js +768 -572
- package/lib/Utils/messages.d.ts +46 -0
- package/lib/Utils/messages.js +1082 -130
- package/lib/Utils/noise-handler.d.ts +21 -0
- package/lib/Utils/noise-handler.js +191 -135
- package/lib/Utils/offline-node-processor.d.ts +10 -0
- package/lib/Utils/offline-node-processor.js +39 -0
- package/lib/Utils/pre-key-manager.d.ts +26 -0
- package/lib/Utils/pre-key-manager.js +96 -76
- package/lib/Utils/process-message.d.ts +84 -0
- package/lib/Utils/process-message.js +718 -311
- package/lib/Utils/reporting-utils.d.ts +13 -0
- package/lib/Utils/reporting-utils.js +257 -0
- package/lib/Utils/rich-message-utils.d.ts +49 -0
- package/lib/Utils/rich-message-utils.js +257 -0
- package/lib/Utils/signal.d.ts +83 -0
- package/lib/Utils/signal.js +174 -135
- package/lib/Utils/stanza-ack.d.ts +17 -0
- package/lib/Utils/stanza-ack.js +37 -0
- package/lib/Utils/sync-action-utils.d.ts +3 -0
- package/lib/Utils/sync-action-utils.js +48 -0
- package/lib/Utils/tc-token-utils.d.ts +30 -0
- package/lib/Utils/tc-token-utils.js +162 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +11 -0
- package/lib/Utils/use-multi-file-auth-state.js +104 -95
- package/lib/Utils/use-single-file-auth-state.d.ts +11 -0
- package/lib/Utils/use-single-file-auth-state.js +108 -0
- package/lib/Utils/use-sqlite-auth-state.d.ts +11 -0
- package/lib/Utils/use-sqlite-auth-state.js +108 -0
- package/lib/Utils/validate-connection.d.ts +44 -0
- package/lib/Utils/validate-connection.js +182 -180
- package/lib/WABinary/constants.d.ts +62 -0
- package/lib/WABinary/constants.js +1455 -1292
- package/lib/WABinary/decode.d.ts +10 -0
- package/lib/WABinary/decode.js +249 -228
- package/lib/WABinary/encode.d.ts +3 -0
- package/lib/WABinary/encode.js +207 -206
- package/lib/WABinary/generic-utils.d.ts +77 -0
- package/lib/WABinary/generic-utils.js +135 -99
- package/lib/WABinary/index.d.ts +6 -0
- package/lib/WABinary/index.js +5 -7
- package/lib/WABinary/jid-utils.d.ts +29 -0
- package/lib/WABinary/jid-utils.js +80 -78
- package/lib/WABinary/types.d.ts +2 -0
- package/lib/WABinary/types.js +1 -3
- package/lib/WAM/BinaryInfo.d.ts +8 -0
- package/lib/WAM/BinaryInfo.js +7 -9
- package/lib/WAM/constants.d.ts +34927 -0
- package/lib/WAM/constants.js +22847 -22848
- package/lib/WAM/encode.d.ts +2 -0
- package/lib/WAM/encode.js +129 -134
- package/lib/WAM/index.d.ts +4 -0
- package/lib/WAM/index.js +3 -5
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +37 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +48 -27
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +48 -48
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +23 -26
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +33 -35
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +24 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +39 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +46 -49
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +15 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +23 -25
- package/lib/WAUSync/Protocols/index.d.ts +6 -0
- package/lib/WAUSync/Protocols/index.js +5 -6
- package/lib/WAUSync/USyncQuery.d.ts +21 -0
- package/lib/WAUSync/USyncQuery.js +92 -85
- package/lib/WAUSync/USyncUser.d.ts +17 -0
- package/lib/WAUSync/USyncUser.js +28 -22
- package/lib/WAUSync/index.d.ts +4 -0
- package/lib/WAUSync/index.js +3 -5
- package/lib/index.d.ts +12 -0
- package/lib/index.js +31 -19
- package/package.json +12 -6
- package/lib/Types/Newsletter.js +0 -33
|
@@ -1,200 +1,202 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { Boom } from "@hapi/boom";
|
|
10
|
-
//=======================================================//
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
import { createHash } from 'crypto';
|
|
3
|
+
import { proto } from '../../WAProto/index.js';
|
|
4
|
+
import { KEY_BUNDLE_TYPE, WA_ADV_ACCOUNT_SIG_PREFIX, WA_ADV_DEVICE_SIG_PREFIX, WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX } from '../Defaults/index.js';
|
|
5
|
+
import { getBinaryNodeChild, jidDecode, S_WHATSAPP_NET } from '../WABinary/index.js';
|
|
6
|
+
import { Curve, hmacSign } from './crypto.js';
|
|
7
|
+
import { encodeBigEndian } from './generics.js';
|
|
8
|
+
import { createSignalIdentity } from './signal.js';
|
|
11
9
|
const getUserAgent = (config) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
10
|
+
return {
|
|
11
|
+
appVersion: {
|
|
12
|
+
primary: config.version[0],
|
|
13
|
+
secondary: config.version[1],
|
|
14
|
+
tertiary: config.version[2]
|
|
15
|
+
},
|
|
16
|
+
platform: proto.ClientPayload.UserAgent.Platform.WEB,
|
|
17
|
+
releaseChannel: proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
|
18
|
+
osVersion: '0.1',
|
|
19
|
+
device: 'Desktop',
|
|
20
|
+
osBuildNumber: '0.1',
|
|
21
|
+
localeLanguageIso6391: 'en',
|
|
22
|
+
mnc: '000',
|
|
23
|
+
mcc: '000',
|
|
24
|
+
localeCountryIso31661Alpha2: config.countryCode
|
|
25
|
+
};
|
|
28
26
|
};
|
|
29
|
-
//=======================================================//
|
|
30
27
|
const PLATFORM_MAP = {
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
'Mac OS': proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
|
|
29
|
+
Windows: proto.ClientPayload.WebInfo.WebSubPlatform.WIN32
|
|
33
30
|
};
|
|
34
|
-
//=======================================================//
|
|
35
31
|
const getWebInfo = (config) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
let webSubPlatform = proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER;
|
|
33
|
+
if (config.syncFullHistory &&
|
|
34
|
+
PLATFORM_MAP[config.browser[0]] &&
|
|
35
|
+
config.browser[1] === 'Desktop') {
|
|
36
|
+
webSubPlatform = PLATFORM_MAP[config.browser[0]];
|
|
37
|
+
}
|
|
38
|
+
return { webSubPlatform };
|
|
43
39
|
};
|
|
44
|
-
//=======================================================//
|
|
45
40
|
const getClientPayload = (config) => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
const payload = {
|
|
42
|
+
connectType: proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
|
|
43
|
+
connectReason: proto.ClientPayload.ConnectReason.USER_ACTIVATED,
|
|
44
|
+
userAgent: getUserAgent(config)
|
|
45
|
+
};
|
|
46
|
+
payload.webInfo = getWebInfo(config);
|
|
47
|
+
if (config.pushName) {
|
|
48
|
+
payload.pushName = config.pushName;
|
|
49
|
+
}
|
|
50
|
+
return payload;
|
|
53
51
|
};
|
|
54
|
-
//=======================================================//
|
|
55
52
|
export const generateLoginNode = (userJid, config) => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
53
|
+
const { user, device } = jidDecode(userJid);
|
|
54
|
+
const payload = {
|
|
55
|
+
...getClientPayload(config),
|
|
56
|
+
passive: true,
|
|
57
|
+
pull: true,
|
|
58
|
+
username: +user,
|
|
59
|
+
device: device,
|
|
60
|
+
// TODO: investigate (hard set as false atm)
|
|
61
|
+
lidDbMigrated: false
|
|
62
|
+
};
|
|
63
|
+
return proto.ClientPayload.fromObject(payload);
|
|
66
64
|
};
|
|
67
|
-
//=======================================================//
|
|
68
65
|
const getPlatformType = (platform) => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
const platformType = platform.toUpperCase();
|
|
67
|
+
return (proto.DeviceProps.PlatformType[platformType] ||
|
|
68
|
+
proto.DeviceProps.PlatformType.CHROME);
|
|
72
69
|
};
|
|
73
|
-
//=======================================================//
|
|
74
70
|
export const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentityKey }, config) => {
|
|
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
|
-
|
|
71
|
+
// the app version needs to be md5 hashed
|
|
72
|
+
// and passed in
|
|
73
|
+
const appVersionBuf = createHash('md5')
|
|
74
|
+
.update(config.version.join('.')) // join as string
|
|
75
|
+
.digest();
|
|
76
|
+
const companion = {
|
|
77
|
+
os: config.browser[0],
|
|
78
|
+
platformType: getPlatformType(config.browser[1]),
|
|
79
|
+
requireFullSync: config.syncFullHistory,
|
|
80
|
+
historySyncConfig: {
|
|
81
|
+
storageQuotaMb: 10240,
|
|
82
|
+
inlineInitialPayloadInE2EeMsg: true,
|
|
83
|
+
recentSyncDaysLimit: undefined,
|
|
84
|
+
supportCallLogHistory: false,
|
|
85
|
+
supportBotUserAgentChatHistory: true,
|
|
86
|
+
supportCagReactionsAndPolls: true,
|
|
87
|
+
supportBizHostedMsg: true,
|
|
88
|
+
supportRecentSyncChunkMessageCountTuning: true,
|
|
89
|
+
supportHostedGroupMsg: true,
|
|
90
|
+
supportFbidBotChatHistory: true,
|
|
91
|
+
supportAddOnHistorySyncMigration: undefined,
|
|
92
|
+
supportMessageAssociation: true,
|
|
93
|
+
supportGroupHistory: false,
|
|
94
|
+
onDemandReady: undefined,
|
|
95
|
+
supportGuestChat: undefined
|
|
96
|
+
},
|
|
97
|
+
version: {
|
|
98
|
+
primary: 10,
|
|
99
|
+
secondary: 15,
|
|
100
|
+
tertiary: 7
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const companionProto = proto.DeviceProps.encode(companion).finish();
|
|
104
|
+
const registerPayload = {
|
|
105
|
+
...getClientPayload(config),
|
|
106
|
+
passive: false,
|
|
107
|
+
pull: false,
|
|
108
|
+
devicePairingData: {
|
|
109
|
+
buildHash: appVersionBuf,
|
|
110
|
+
deviceProps: companionProto,
|
|
111
|
+
eRegid: encodeBigEndian(registrationId),
|
|
112
|
+
eKeytype: KEY_BUNDLE_TYPE,
|
|
113
|
+
eIdent: signedIdentityKey.public,
|
|
114
|
+
eSkeyId: encodeBigEndian(signedPreKey.keyId, 3),
|
|
115
|
+
eSkeyVal: signedPreKey.keyPair.public,
|
|
116
|
+
eSkeySig: signedPreKey.signature
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
return proto.ClientPayload.fromObject(registerPayload);
|
|
117
120
|
};
|
|
118
|
-
//=======================================================//
|
|
119
121
|
export const configureSuccessfulPairing = (stanza, { advSecretKey, signedIdentityKey, signalIdentities }) => {
|
|
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
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
content: [
|
|
168
|
-
{
|
|
169
|
-
tag: "pair-device-sign",
|
|
170
|
-
attrs: {},
|
|
122
|
+
const msgId = stanza.attrs.id;
|
|
123
|
+
const pairSuccessNode = getBinaryNodeChild(stanza, 'pair-success');
|
|
124
|
+
const deviceIdentityNode = getBinaryNodeChild(pairSuccessNode, 'device-identity');
|
|
125
|
+
const platformNode = getBinaryNodeChild(pairSuccessNode, 'platform');
|
|
126
|
+
const deviceNode = getBinaryNodeChild(pairSuccessNode, 'device');
|
|
127
|
+
const businessNode = getBinaryNodeChild(pairSuccessNode, 'biz');
|
|
128
|
+
if (!deviceIdentityNode || !deviceNode) {
|
|
129
|
+
throw new Boom('Missing device-identity or device in pair success node', { data: stanza });
|
|
130
|
+
}
|
|
131
|
+
const bizName = businessNode?.attrs.name;
|
|
132
|
+
const jid = deviceNode.attrs.jid;
|
|
133
|
+
const lid = deviceNode.attrs.lid;
|
|
134
|
+
const { details, hmac, accountType } = proto.ADVSignedDeviceIdentityHMAC.decode(deviceIdentityNode.content);
|
|
135
|
+
let hmacPrefix = Buffer.from([]);
|
|
136
|
+
if (accountType !== undefined && accountType === proto.ADVEncryptionType.HOSTED) {
|
|
137
|
+
hmacPrefix = WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX;
|
|
138
|
+
}
|
|
139
|
+
const advSign = hmacSign(Buffer.concat([hmacPrefix, details]), Buffer.from(advSecretKey, 'base64'));
|
|
140
|
+
if (Buffer.compare(hmac, advSign) !== 0) {
|
|
141
|
+
throw new Boom('Invalid account signature');
|
|
142
|
+
}
|
|
143
|
+
const account = proto.ADVSignedDeviceIdentity.decode(details);
|
|
144
|
+
const { accountSignatureKey, accountSignature, details: deviceDetails } = account;
|
|
145
|
+
const deviceIdentity = proto.ADVDeviceIdentity.decode(deviceDetails);
|
|
146
|
+
const accountSignaturePrefix = deviceIdentity.deviceType === proto.ADVEncryptionType.HOSTED
|
|
147
|
+
? WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX
|
|
148
|
+
: WA_ADV_ACCOUNT_SIG_PREFIX;
|
|
149
|
+
const accountMsg = Buffer.concat([accountSignaturePrefix, deviceDetails, signedIdentityKey.public]);
|
|
150
|
+
if (!Curve.verify(accountSignatureKey, accountMsg, accountSignature)) {
|
|
151
|
+
throw new Boom('Failed to verify account signature');
|
|
152
|
+
}
|
|
153
|
+
const deviceMsg = Buffer.concat([
|
|
154
|
+
WA_ADV_DEVICE_SIG_PREFIX,
|
|
155
|
+
deviceDetails,
|
|
156
|
+
signedIdentityKey.public,
|
|
157
|
+
accountSignatureKey
|
|
158
|
+
]);
|
|
159
|
+
account.deviceSignature = Curve.sign(signedIdentityKey.private, deviceMsg);
|
|
160
|
+
const identity = createSignalIdentity(lid, accountSignatureKey);
|
|
161
|
+
const accountEnc = encodeSignedDeviceIdentity(account, false);
|
|
162
|
+
const reply = {
|
|
163
|
+
tag: 'iq',
|
|
164
|
+
attrs: {
|
|
165
|
+
to: S_WHATSAPP_NET,
|
|
166
|
+
type: 'result',
|
|
167
|
+
id: msgId
|
|
168
|
+
},
|
|
171
169
|
content: [
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
170
|
+
{
|
|
171
|
+
tag: 'pair-device-sign',
|
|
172
|
+
attrs: {},
|
|
173
|
+
content: [
|
|
174
|
+
{
|
|
175
|
+
tag: 'device-identity',
|
|
176
|
+
attrs: { 'key-index': deviceIdentity.keyIndex.toString() },
|
|
177
|
+
content: accountEnc
|
|
178
|
+
}
|
|
179
|
+
]
|
|
180
|
+
}
|
|
177
181
|
]
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
reply
|
|
190
|
-
};
|
|
182
|
+
};
|
|
183
|
+
const authUpdate = {
|
|
184
|
+
account,
|
|
185
|
+
me: { id: jid, name: bizName, lid },
|
|
186
|
+
signalIdentities: [...(signalIdentities || []), identity],
|
|
187
|
+
platform: platformNode?.attrs.name
|
|
188
|
+
};
|
|
189
|
+
return {
|
|
190
|
+
creds: authUpdate,
|
|
191
|
+
reply
|
|
192
|
+
};
|
|
191
193
|
};
|
|
192
|
-
//=======================================================//
|
|
193
194
|
export const encodeSignedDeviceIdentity = (account, includeSignatureKey) => {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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 || !account.accountSignatureKey?.length) {
|
|
199
|
+
account.accountSignatureKey = null;
|
|
200
|
+
}
|
|
201
|
+
return proto.ADVSignedDeviceIdentity.encode(account).finish();
|
|
199
202
|
};
|
|
200
|
-
//=======================================================//
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export namespace TAGS {
|
|
2
|
+
let LIST_EMPTY: number;
|
|
3
|
+
let DICTIONARY_0: number;
|
|
4
|
+
let DICTIONARY_1: number;
|
|
5
|
+
let DICTIONARY_2: number;
|
|
6
|
+
let DICTIONARY_3: number;
|
|
7
|
+
let INTEROP_JID: number;
|
|
8
|
+
let FB_JID: number;
|
|
9
|
+
let AD_JID: number;
|
|
10
|
+
let LIST_8: number;
|
|
11
|
+
let LIST_16: number;
|
|
12
|
+
let JID_PAIR: number;
|
|
13
|
+
let HEX_8: number;
|
|
14
|
+
let BINARY_8: number;
|
|
15
|
+
let BINARY_20: number;
|
|
16
|
+
let BINARY_32: number;
|
|
17
|
+
let NIBBLE_8: number;
|
|
18
|
+
let PACKED_MAX: number;
|
|
19
|
+
}
|
|
20
|
+
export const DOUBLE_BYTE_TOKENS: string[][];
|
|
21
|
+
export const SINGLE_BYTE_TOKENS: string[];
|
|
22
|
+
export const TOKEN_MAP: {};
|
|
23
|
+
export const CPP_KEYWORDS: Set<string>;
|
|
24
|
+
export const CSS_KEYWORDS: Set<string>;
|
|
25
|
+
export const GO_KEYWORDS: Set<string>;
|
|
26
|
+
export const HTML_KEYWORDS: Set<string>;
|
|
27
|
+
export const JS_KEYWORDS: Set<string>;
|
|
28
|
+
export const PYTHON_KEYWORDS: Set<string>;
|
|
29
|
+
export const RUST_KEYWORDS: Set<string>;
|
|
30
|
+
export const C_KEYWORDS: Set<string>;
|
|
31
|
+
export const CSHARP_KEYWORDS: Set<string>;
|
|
32
|
+
export const BASH_KEYWORDS: Set<string>;
|
|
33
|
+
export const CMD_KEYWORDS: Set<string>;
|
|
34
|
+
export const POWERSHELL_KEYWORDS: Set<string>;
|
|
35
|
+
export const LANGUAGE_KEYWORDS: {
|
|
36
|
+
css: Set<string>;
|
|
37
|
+
html: Set<string>;
|
|
38
|
+
javascript: Set<string>;
|
|
39
|
+
typescript: Set<string>;
|
|
40
|
+
js: Set<string>;
|
|
41
|
+
ts: Set<string>;
|
|
42
|
+
python: Set<string>;
|
|
43
|
+
py: Set<string>;
|
|
44
|
+
go: Set<string>;
|
|
45
|
+
golang: Set<string>;
|
|
46
|
+
cpp: Set<string>;
|
|
47
|
+
'c++': Set<string>;
|
|
48
|
+
rust: Set<string>;
|
|
49
|
+
rs: Set<string>;
|
|
50
|
+
c: Set<string>;
|
|
51
|
+
h: Set<string>;
|
|
52
|
+
csharp: Set<string>;
|
|
53
|
+
cs: Set<string>;
|
|
54
|
+
bash: Set<string>;
|
|
55
|
+
sh: Set<string>;
|
|
56
|
+
zsh: Set<string>;
|
|
57
|
+
cmd: Set<string>;
|
|
58
|
+
bat: Set<string>;
|
|
59
|
+
powershell: Set<string>;
|
|
60
|
+
ps1: Set<string>;
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=constants.d.ts.map
|