@vinzsocket/baileys 2.8.30 → 3.0.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/WAProto/fix-imports.js +7 -16
- package/WAProto/index.js +1 -37306
- package/lib/Defaults/index.js +37 -33
- package/lib/Signal/Group/ciphertext-message.js +6 -2
- package/lib/Signal/Group/group-session-builder.js +12 -7
- package/lib/Signal/Group/group_cipher.js +18 -13
- package/lib/Signal/Group/index.js +77 -12
- package/lib/Signal/Group/keyhelper.js +15 -8
- package/lib/Signal/Group/queue-job.js +7 -2
- package/lib/Signal/Group/sender-chain-key.js +11 -6
- package/lib/Signal/Group/sender-key-distribution-message.js +10 -6
- package/lib/Signal/Group/sender-key-message.js +14 -9
- package/lib/Signal/Group/sender-key-name.js +6 -2
- package/lib/Signal/Group/sender-key-record.js +13 -9
- package/lib/Signal/Group/sender-key-state.js +10 -6
- package/lib/Signal/Group/sender-message-key.js +9 -4
- package/lib/Signal/libsignal.js +34 -28
- package/lib/Signal/lid-mapping.js +24 -19
- package/lib/Socket/Client/index.js +25 -3
- package/lib/Socket/Client/types.js +8 -4
- package/lib/Socket/Client/websocket.js +16 -11
- package/lib/Socket/business.js +38 -34
- package/lib/Socket/chats.js +100 -95
- package/lib/Socket/communities.js +55 -49
- package/lib/Socket/groups.js +56 -51
- package/lib/Socket/index.js +9 -6
- package/lib/Socket/messages-recv.js +150 -145
- package/lib/Socket/messages-send.js +109 -104
- package/lib/Socket/mex.js +12 -8
- package/lib/Socket/newsletter.js +27 -23
- package/lib/Socket/socket.js +111 -107
- package/lib/Store/index.js +47 -4
- package/lib/Store/make-cache-manager-store.js +17 -11
- package/lib/Store/make-in-memory-store.js +31 -29
- package/lib/Store/make-ordered-dictionary.js +7 -2
- package/lib/Store/object-repository.js +7 -2
- package/lib/Types/Auth.js +3 -2
- package/lib/Types/Bussines.js +3 -2
- package/lib/Types/Call.js +3 -2
- package/lib/Types/Chat.js +5 -2
- package/lib/Types/Contact.js +3 -2
- package/lib/Types/Events.js +1 -2
- package/lib/Types/GroupMetadata.js +3 -2
- package/lib/Types/Label.js +6 -3
- package/lib/Types/LabelAssociation.js +6 -3
- package/lib/Types/Message.js +16 -7
- package/lib/Types/Newsletter.js +8 -5
- package/lib/Types/Product.js +3 -2
- package/lib/Types/Signal.js +1 -2
- package/lib/Types/Socket.js +2 -3
- package/lib/Types/State.js +7 -4
- package/lib/Types/USync.js +1 -2
- package/lib/Types/index.js +153 -15
- package/lib/Utils/auth-utils.js +32 -25
- package/lib/Utils/baileys-event-stream.js +21 -15
- package/lib/Utils/business.js +71 -61
- package/lib/Utils/chat-utils.js +91 -77
- package/lib/Utils/crypto.js +54 -32
- package/lib/Utils/decode-wa-message.js +46 -39
- package/lib/Utils/event-buffer.js +24 -19
- package/lib/Utils/extended-messages.js +14 -9
- package/lib/Utils/generics.js +100 -64
- package/lib/Utils/history.js +30 -23
- package/lib/Utils/index.js +234 -22
- package/lib/Utils/lid-resolver.js +12 -5
- package/lib/Utils/link-preview.js +11 -7
- package/lib/Utils/logger.js +8 -4
- package/lib/Utils/lt-hash.js +8 -5
- package/lib/Utils/make-mutex.js +8 -3
- package/lib/Utils/mention.js +12 -4
- package/lib/Utils/message-retry-manager.js +10 -6
- package/lib/Utils/messages-media.js +127 -95
- package/lib/Utils/messages.js +122 -98
- package/lib/Utils/noise-handler.js +25 -21
- package/lib/Utils/process-message.js +72 -63
- package/lib/Utils/signal.js +45 -33
- package/lib/Utils/use-multi-file-auth-state.js +24 -20
- package/lib/Utils/validate-connection.js +54 -47
- package/lib/WABinary/constants.js +9 -6
- package/lib/WABinary/decode.js +17 -10
- package/lib/WABinary/encode.js +11 -6
- package/lib/WABinary/generic-utils.js +31 -17
- package/lib/WABinary/index.js +58 -6
- package/lib/WABinary/jid-utils.js +36 -20
- package/lib/WABinary/types.js +2 -2
- package/lib/WAM/BinaryInfo.js +6 -2
- package/lib/WAM/constants.js +1 -1
- package/lib/WAM/encode.js +16 -12
- package/lib/WAM/index.js +36 -4
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +9 -5
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +10 -6
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +8 -4
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +8 -4
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +9 -4
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +23 -19
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +6 -2
- package/lib/WAUSync/Protocols/index.js +58 -6
- package/lib/WAUSync/USyncQuery.js +21 -17
- package/lib/WAUSync/USyncUser.js +6 -2
- package/lib/WAUSync/index.js +36 -4
- package/lib/index.js +112 -12
- package/package.json +8 -6
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2
|
+
value: true
|
|
3
|
+
});
|
|
4
|
+
exports.useMultiFileAuthState = void 0;
|
|
5
|
+
var _asyncMutex = require("async-mutex");
|
|
6
|
+
var _promises = require("fs/promises");
|
|
7
|
+
var _path = require("path");
|
|
8
|
+
var _index = require("../../WAProto/index.js");
|
|
9
|
+
var _authUtils = require("./auth-utils.js");
|
|
10
|
+
var _generics = require("./generics.js");
|
|
7
11
|
// We need to lock files due to the fact that we are using async functions to read and write files
|
|
8
12
|
// https://github.com/WhiskeySockets/Baileys/issues/794
|
|
9
13
|
// https://github.com/nodejs/node/issues/26338
|
|
@@ -13,7 +17,7 @@ const fileLocks = new Map();
|
|
|
13
17
|
const getFileLock = path => {
|
|
14
18
|
let mutex = fileLocks.get(path);
|
|
15
19
|
if (!mutex) {
|
|
16
|
-
mutex = new Mutex();
|
|
20
|
+
mutex = new _asyncMutex.Mutex();
|
|
17
21
|
fileLocks.set(path, mutex);
|
|
18
22
|
}
|
|
19
23
|
return mutex;
|
|
@@ -25,14 +29,14 @@ const getFileLock = path => {
|
|
|
25
29
|
* Again, I wouldn't endorse this for any production level use other than perhaps a bot.
|
|
26
30
|
* Would recommend writing an auth state for use with a proper SQL or No-SQL DB
|
|
27
31
|
* */
|
|
28
|
-
|
|
32
|
+
const useMultiFileAuthState = async folder => {
|
|
29
33
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
34
|
const writeData = async (data, file) => {
|
|
31
|
-
const filePath = join(folder, fixFileName(file));
|
|
35
|
+
const filePath = (0, _path.join)(folder, fixFileName(file));
|
|
32
36
|
const mutex = getFileLock(filePath);
|
|
33
37
|
return mutex.acquire().then(async release => {
|
|
34
38
|
try {
|
|
35
|
-
await writeFile(filePath, JSON.stringify(data, BufferJSON.replacer));
|
|
39
|
+
await (0, _promises.writeFile)(filePath, JSON.stringify(data, _generics.BufferJSON.replacer));
|
|
36
40
|
} finally {
|
|
37
41
|
release();
|
|
38
42
|
}
|
|
@@ -40,14 +44,14 @@ export const useMultiFileAuthState = async folder => {
|
|
|
40
44
|
};
|
|
41
45
|
const readData = async file => {
|
|
42
46
|
try {
|
|
43
|
-
const filePath = join(folder, fixFileName(file));
|
|
47
|
+
const filePath = (0, _path.join)(folder, fixFileName(file));
|
|
44
48
|
const mutex = getFileLock(filePath);
|
|
45
49
|
return await mutex.acquire().then(async release => {
|
|
46
50
|
try {
|
|
47
|
-
const data = await readFile(filePath, {
|
|
51
|
+
const data = await (0, _promises.readFile)(filePath, {
|
|
48
52
|
encoding: 'utf-8'
|
|
49
53
|
});
|
|
50
|
-
return JSON.parse(data, BufferJSON.reviver);
|
|
54
|
+
return JSON.parse(data, _generics.BufferJSON.reviver);
|
|
51
55
|
} finally {
|
|
52
56
|
release();
|
|
53
57
|
}
|
|
@@ -58,29 +62,29 @@ export const useMultiFileAuthState = async folder => {
|
|
|
58
62
|
};
|
|
59
63
|
const removeData = async file => {
|
|
60
64
|
try {
|
|
61
|
-
const filePath = join(folder, fixFileName(file));
|
|
65
|
+
const filePath = (0, _path.join)(folder, fixFileName(file));
|
|
62
66
|
const mutex = getFileLock(filePath);
|
|
63
67
|
return mutex.acquire().then(async release => {
|
|
64
68
|
try {
|
|
65
|
-
await unlink(filePath);
|
|
69
|
+
await (0, _promises.unlink)(filePath);
|
|
66
70
|
} catch {} finally {
|
|
67
71
|
release();
|
|
68
72
|
}
|
|
69
73
|
});
|
|
70
74
|
} catch {}
|
|
71
75
|
};
|
|
72
|
-
const folderInfo = await stat(folder).catch(() => {});
|
|
76
|
+
const folderInfo = await (0, _promises.stat)(folder).catch(() => {});
|
|
73
77
|
if (folderInfo) {
|
|
74
78
|
if (!folderInfo.isDirectory()) {
|
|
75
79
|
throw new Error(`found something that is not a directory at ${folder}, either delete it or specify a different location`);
|
|
76
80
|
}
|
|
77
81
|
} else {
|
|
78
|
-
await mkdir(folder, {
|
|
82
|
+
await (0, _promises.mkdir)(folder, {
|
|
79
83
|
recursive: true
|
|
80
84
|
});
|
|
81
85
|
}
|
|
82
86
|
const fixFileName = file => file?.replace(/\//g, '__')?.replace(/:/g, '-');
|
|
83
|
-
const creds = (await readData('creds.json')) || initAuthCreds();
|
|
87
|
+
const creds = (await readData('creds.json')) || (0, _authUtils.initAuthCreds)();
|
|
84
88
|
return {
|
|
85
89
|
state: {
|
|
86
90
|
creds,
|
|
@@ -90,7 +94,7 @@ export const useMultiFileAuthState = async folder => {
|
|
|
90
94
|
await Promise.all(ids.map(async id => {
|
|
91
95
|
let value = await readData(`${type}-${id}.json`);
|
|
92
96
|
if (type === 'app-state-sync-key' && value) {
|
|
93
|
-
value = proto.Message.AppStateSyncKeyData.create(value);
|
|
97
|
+
value = _index.proto.Message.AppStateSyncKeyData.create(value);
|
|
94
98
|
}
|
|
95
99
|
data[id] = value;
|
|
96
100
|
}));
|
|
@@ -114,4 +118,4 @@ export const useMultiFileAuthState = async folder => {
|
|
|
114
118
|
}
|
|
115
119
|
};
|
|
116
120
|
};
|
|
117
|
-
|
|
121
|
+
exports.useMultiFileAuthState = useMultiFileAuthState;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2
|
+
value: true
|
|
3
|
+
});
|
|
4
|
+
exports.generateRegistrationNode = exports.generateLoginNode = exports.encodeSignedDeviceIdentity = exports.configureSuccessfulPairing = void 0;
|
|
5
|
+
var _boom = require("@hapi/boom");
|
|
6
|
+
var _crypto = require("crypto");
|
|
7
|
+
var _index = require("../../WAProto/index.js");
|
|
8
|
+
var _index2 = require("../Defaults/index.js");
|
|
9
|
+
var _index3 = require("../WABinary/index.js");
|
|
10
|
+
var _crypto2 = require("./crypto.js");
|
|
11
|
+
var _generics = require("./generics.js");
|
|
12
|
+
var _signal = require("./signal.js");
|
|
9
13
|
const getUserAgent = config => {
|
|
10
14
|
return {
|
|
11
15
|
appVersion: {
|
|
@@ -13,8 +17,8 @@ const getUserAgent = config => {
|
|
|
13
17
|
secondary: config.version[1],
|
|
14
18
|
tertiary: config.version[2]
|
|
15
19
|
},
|
|
16
|
-
platform: proto.ClientPayload.UserAgent.Platform.WEB,
|
|
17
|
-
releaseChannel: proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
|
20
|
+
platform: _index.proto.ClientPayload.UserAgent.Platform.WEB,
|
|
21
|
+
releaseChannel: _index.proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
|
18
22
|
osVersion: '0.1',
|
|
19
23
|
device: 'Desktop',
|
|
20
24
|
osBuildNumber: '0.1',
|
|
@@ -25,11 +29,11 @@ const getUserAgent = config => {
|
|
|
25
29
|
};
|
|
26
30
|
};
|
|
27
31
|
const PLATFORM_MAP = {
|
|
28
|
-
'Mac OS': proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
|
|
29
|
-
Windows: proto.ClientPayload.WebInfo.WebSubPlatform.WIN32
|
|
32
|
+
'Mac OS': _index.proto.ClientPayload.WebInfo.WebSubPlatform.DARWIN,
|
|
33
|
+
Windows: _index.proto.ClientPayload.WebInfo.WebSubPlatform.WIN32
|
|
30
34
|
};
|
|
31
35
|
const getWebInfo = config => {
|
|
32
|
-
let webSubPlatform = proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER;
|
|
36
|
+
let webSubPlatform = _index.proto.ClientPayload.WebInfo.WebSubPlatform.WEB_BROWSER;
|
|
33
37
|
if (config.syncFullHistory && PLATFORM_MAP[config.browser[0]]) {
|
|
34
38
|
webSubPlatform = PLATFORM_MAP[config.browser[0]];
|
|
35
39
|
}
|
|
@@ -39,18 +43,18 @@ const getWebInfo = config => {
|
|
|
39
43
|
};
|
|
40
44
|
const getClientPayload = config => {
|
|
41
45
|
const payload = {
|
|
42
|
-
connectType: proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
|
|
43
|
-
connectReason: proto.ClientPayload.ConnectReason.USER_ACTIVATED,
|
|
46
|
+
connectType: _index.proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
|
|
47
|
+
connectReason: _index.proto.ClientPayload.ConnectReason.USER_ACTIVATED,
|
|
44
48
|
userAgent: getUserAgent(config)
|
|
45
49
|
};
|
|
46
50
|
payload.webInfo = getWebInfo(config);
|
|
47
51
|
return payload;
|
|
48
52
|
};
|
|
49
|
-
|
|
53
|
+
const generateLoginNode = (userJid, config) => {
|
|
50
54
|
const {
|
|
51
55
|
user,
|
|
52
56
|
device
|
|
53
|
-
} = jidDecode(userJid);
|
|
57
|
+
} = (0, _index3.jidDecode)(userJid);
|
|
54
58
|
const payload = {
|
|
55
59
|
...getClientPayload(config),
|
|
56
60
|
passive: false,
|
|
@@ -58,27 +62,28 @@ export const generateLoginNode = (userJid, config) => {
|
|
|
58
62
|
username: +user,
|
|
59
63
|
device: device
|
|
60
64
|
};
|
|
61
|
-
return proto.ClientPayload.create(payload);
|
|
65
|
+
return _index.proto.ClientPayload.create(payload);
|
|
62
66
|
};
|
|
67
|
+
exports.generateLoginNode = generateLoginNode;
|
|
63
68
|
const getPlatformType = platform => {
|
|
64
69
|
const platformType = platform.toUpperCase();
|
|
65
|
-
return proto.DeviceProps.PlatformType[platformType] || proto.DeviceProps.PlatformType.DESKTOP;
|
|
70
|
+
return _index.proto.DeviceProps.PlatformType[platformType] || _index.proto.DeviceProps.PlatformType.DESKTOP;
|
|
66
71
|
};
|
|
67
|
-
|
|
72
|
+
const generateRegistrationNode = ({
|
|
68
73
|
registrationId,
|
|
69
74
|
signedPreKey,
|
|
70
75
|
signedIdentityKey
|
|
71
76
|
}, config) => {
|
|
72
77
|
// the app version needs to be md5 hashed
|
|
73
78
|
// and passed in
|
|
74
|
-
const appVersionBuf = createHash('md5').update(config.version.join('.')) // join as string
|
|
79
|
+
const appVersionBuf = (0, _crypto.createHash)('md5').update(config.version.join('.')) // join as string
|
|
75
80
|
.digest();
|
|
76
81
|
const companion = {
|
|
77
82
|
os: config.browser[0],
|
|
78
83
|
platformType: getPlatformType(config.browser[1]),
|
|
79
84
|
requireFullSync: config.syncFullHistory
|
|
80
85
|
};
|
|
81
|
-
const companionProto = proto.DeviceProps.encode(companion).finish();
|
|
86
|
+
const companionProto = _index.proto.DeviceProps.encode(companion).finish();
|
|
82
87
|
const registerPayload = {
|
|
83
88
|
...getClientPayload(config),
|
|
84
89
|
passive: false,
|
|
@@ -86,29 +91,30 @@ export const generateRegistrationNode = ({
|
|
|
86
91
|
devicePairingData: {
|
|
87
92
|
buildHash: appVersionBuf,
|
|
88
93
|
deviceProps: companionProto,
|
|
89
|
-
eRegid: encodeBigEndian(registrationId),
|
|
90
|
-
eKeytype: KEY_BUNDLE_TYPE,
|
|
94
|
+
eRegid: (0, _generics.encodeBigEndian)(registrationId),
|
|
95
|
+
eKeytype: _index2.KEY_BUNDLE_TYPE,
|
|
91
96
|
eIdent: signedIdentityKey.public,
|
|
92
|
-
eSkeyId: encodeBigEndian(signedPreKey.keyId, 3),
|
|
97
|
+
eSkeyId: (0, _generics.encodeBigEndian)(signedPreKey.keyId, 3),
|
|
93
98
|
eSkeyVal: signedPreKey.keyPair.public,
|
|
94
99
|
eSkeySig: signedPreKey.signature
|
|
95
100
|
}
|
|
96
101
|
};
|
|
97
|
-
return proto.ClientPayload.create(registerPayload);
|
|
102
|
+
return _index.proto.ClientPayload.create(registerPayload);
|
|
98
103
|
};
|
|
99
|
-
|
|
104
|
+
exports.generateRegistrationNode = generateRegistrationNode;
|
|
105
|
+
const configureSuccessfulPairing = (stanza, {
|
|
100
106
|
advSecretKey,
|
|
101
107
|
signedIdentityKey,
|
|
102
108
|
signalIdentities
|
|
103
109
|
}) => {
|
|
104
110
|
const msgId = stanza.attrs.id;
|
|
105
|
-
const pairSuccessNode = getBinaryNodeChild(stanza, 'pair-success');
|
|
106
|
-
const deviceIdentityNode = getBinaryNodeChild(pairSuccessNode, 'device-identity');
|
|
107
|
-
const platformNode = getBinaryNodeChild(pairSuccessNode, 'platform');
|
|
108
|
-
const deviceNode = getBinaryNodeChild(pairSuccessNode, 'device');
|
|
109
|
-
const businessNode = getBinaryNodeChild(pairSuccessNode, 'biz');
|
|
111
|
+
const pairSuccessNode = (0, _index3.getBinaryNodeChild)(stanza, 'pair-success');
|
|
112
|
+
const deviceIdentityNode = (0, _index3.getBinaryNodeChild)(pairSuccessNode, 'device-identity');
|
|
113
|
+
const platformNode = (0, _index3.getBinaryNodeChild)(pairSuccessNode, 'platform');
|
|
114
|
+
const deviceNode = (0, _index3.getBinaryNodeChild)(pairSuccessNode, 'device');
|
|
115
|
+
const businessNode = (0, _index3.getBinaryNodeChild)(pairSuccessNode, 'biz');
|
|
110
116
|
if (!deviceIdentityNode || !deviceNode) {
|
|
111
|
-
throw new Boom('Missing device-identity or device in pair success node', {
|
|
117
|
+
throw new _boom.Boom('Missing device-identity or device in pair success node', {
|
|
112
118
|
data: stanza
|
|
113
119
|
});
|
|
114
120
|
}
|
|
@@ -119,33 +125,33 @@ export const configureSuccessfulPairing = (stanza, {
|
|
|
119
125
|
details,
|
|
120
126
|
hmac,
|
|
121
127
|
accountType
|
|
122
|
-
} = proto.ADVSignedDeviceIdentityHMAC.decode(deviceIdentityNode.content);
|
|
123
|
-
const isHostedAccount = accountType !== undefined && accountType === proto.ADVEncryptionType.HOSTED;
|
|
128
|
+
} = _index.proto.ADVSignedDeviceIdentityHMAC.decode(deviceIdentityNode.content);
|
|
129
|
+
const isHostedAccount = accountType !== undefined && accountType === _index.proto.ADVEncryptionType.HOSTED;
|
|
124
130
|
const hmacPrefix = isHostedAccount ? Buffer.from([6, 5]) : Buffer.alloc(0);
|
|
125
|
-
const advSign = hmacSign(Buffer.concat([hmacPrefix, details]), Buffer.from(advSecretKey, 'base64'));
|
|
131
|
+
const advSign = (0, _crypto2.hmacSign)(Buffer.concat([hmacPrefix, details]), Buffer.from(advSecretKey, 'base64'));
|
|
126
132
|
if (Buffer.compare(hmac, advSign) !== 0) {
|
|
127
|
-
throw new Boom('Invalid account signature');
|
|
133
|
+
throw new _boom.Boom('Invalid account signature');
|
|
128
134
|
}
|
|
129
|
-
const account = proto.ADVSignedDeviceIdentity.decode(details);
|
|
135
|
+
const account = _index.proto.ADVSignedDeviceIdentity.decode(details);
|
|
130
136
|
const {
|
|
131
137
|
accountSignatureKey,
|
|
132
138
|
accountSignature,
|
|
133
139
|
details: deviceDetails
|
|
134
140
|
} = account;
|
|
135
141
|
const accountMsg = Buffer.concat([Buffer.from([6, 0]), deviceDetails, signedIdentityKey.public]);
|
|
136
|
-
if (!Curve.verify(accountSignatureKey, accountMsg, accountSignature)) {
|
|
137
|
-
throw new Boom('Failed to verify account signature');
|
|
142
|
+
if (!_crypto2.Curve.verify(accountSignatureKey, accountMsg, accountSignature)) {
|
|
143
|
+
throw new _boom.Boom('Failed to verify account signature');
|
|
138
144
|
}
|
|
139
145
|
const devicePrefix = isHostedAccount ? Buffer.from([6, 6]) : Buffer.from([6, 1]);
|
|
140
146
|
const deviceMsg = Buffer.concat([devicePrefix, deviceDetails, signedIdentityKey.public, accountSignatureKey]);
|
|
141
|
-
account.deviceSignature = Curve.sign(signedIdentityKey.private, deviceMsg);
|
|
142
|
-
const identity = createSignalIdentity(lid, accountSignatureKey);
|
|
147
|
+
account.deviceSignature = _crypto2.Curve.sign(signedIdentityKey.private, deviceMsg);
|
|
148
|
+
const identity = (0, _signal.createSignalIdentity)(lid, accountSignatureKey);
|
|
143
149
|
const accountEnc = encodeSignedDeviceIdentity(account, false);
|
|
144
|
-
const deviceIdentity = proto.ADVDeviceIdentity.decode(account.details);
|
|
150
|
+
const deviceIdentity = _index.proto.ADVDeviceIdentity.decode(account.details);
|
|
145
151
|
const reply = {
|
|
146
152
|
tag: 'iq',
|
|
147
153
|
attrs: {
|
|
148
|
-
to: S_WHATSAPP_NET,
|
|
154
|
+
to: _index3.S_WHATSAPP_NET,
|
|
149
155
|
type: 'result',
|
|
150
156
|
id: msgId
|
|
151
157
|
},
|
|
@@ -176,7 +182,8 @@ export const configureSuccessfulPairing = (stanza, {
|
|
|
176
182
|
reply
|
|
177
183
|
};
|
|
178
184
|
};
|
|
179
|
-
|
|
185
|
+
exports.configureSuccessfulPairing = configureSuccessfulPairing;
|
|
186
|
+
const encodeSignedDeviceIdentity = (account, includeSignatureKey) => {
|
|
180
187
|
account = {
|
|
181
188
|
...account
|
|
182
189
|
};
|
|
@@ -185,6 +192,6 @@ export const encodeSignedDeviceIdentity = (account, includeSignatureKey) => {
|
|
|
185
192
|
if (!includeSignatureKey || !account.accountSignatureKey?.length) {
|
|
186
193
|
account.accountSignatureKey = null;
|
|
187
194
|
}
|
|
188
|
-
return proto.ADVSignedDeviceIdentity.encode(account).finish();
|
|
195
|
+
return _index.proto.ADVSignedDeviceIdentity.encode(account).finish();
|
|
189
196
|
};
|
|
190
|
-
|
|
197
|
+
exports.encodeSignedDeviceIdentity = encodeSignedDeviceIdentity;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2
|
+
value: true
|
|
3
|
+
});
|
|
4
|
+
exports.TOKEN_MAP = exports.TAGS = exports.SINGLE_BYTE_TOKENS = exports.DOUBLE_BYTE_TOKENS = void 0;
|
|
5
|
+
const TAGS = exports.TAGS = {
|
|
2
6
|
LIST_EMPTY: 0,
|
|
3
7
|
DICTIONARY_0: 236,
|
|
4
8
|
DICTIONARY_1: 237,
|
|
@@ -17,9 +21,9 @@ export const TAGS = {
|
|
|
17
21
|
NIBBLE_8: 255,
|
|
18
22
|
PACKED_MAX: 127
|
|
19
23
|
};
|
|
20
|
-
export const DOUBLE_BYTE_TOKENS = [['read-self', 'active', 'fbns', 'protocol', 'reaction', 'screen_width', 'heartbeat', 'deviceid', '2:47DEQpj8', 'uploadfieldstat', 'voip_settings', 'retry', 'priority', 'longitude', 'conflict', 'false', 'ig_professional', 'replaced', 'preaccept', 'cover_photo', 'uncompressed', 'encopt', 'ppic', '04', 'passive', 'status-revoke-drop', 'keygen', '540', 'offer', 'rate', 'opus', 'latitude', 'w:gp2', 'ver', '4', 'business_profile', 'medium', 'sender', 'prev_v_id', 'email', 'website', 'invited', 'sign_credential', '05', 'transport', 'skey', 'reason', 'peer_abtest_bucket', 'America/Sao_Paulo', 'appid', 'refresh', '100', '06', '404', '101', '104', '107', '102', '109', '103', 'member_add_mode', '105', 'transaction-id', '110', '106', 'outgoing', '108', '111', 'tokens', 'followers', 'ig_handle', 'self_pid', 'tue', 'dec', 'thu', 'joinable', 'peer_pid', 'mon', 'features', 'wed', 'peer_device_presence', 'pn', 'delete', '07', 'fri', 'audio_duration', 'admin', 'connected', 'delta', 'rcat', 'disable', 'collection', '08', '480', 'sat', 'phash', 'all', 'invite', 'accept', 'critical_unblock_low', 'group_update', 'signed_credential', 'blinded_credential', 'eph_setting', 'net', '09', 'background_location', 'refresh_id', 'Asia/Kolkata', 'privacy_mode_ts', 'account_sync', 'voip_payload_type', 'service_areas', 'acs_public_key', 'v_id', '0a', 'fallback_class', 'relay', 'actual_actors', 'metadata', 'w:biz', '5', 'connected-limit', 'notice', '0b', 'host_storage', 'fb_page', 'subject', 'privatestats', 'invis', 'groupadd', '010', 'note.m4r', 'uuid', '0c', '8000', 'sun', '372', '1020', 'stage', '1200', '720', 'canonical', 'fb', '011', 'video_duration', '0d', '1140', 'superadmin', '012', 'Opening.m4r', 'keystore_attestation', 'dleq_proof', '013', 'timestamp', 'ab_key', 'w:sync:app:state', '0e', 'vertical', '600', 'p_v_id', '6', 'likes', '014', '500', '1260', 'creator', '0f', 'rte', 'destination', 'group', 'group_info', 'syncd_anti_tampering_fatal_exception_enabled', '015', 'dl_bw', 'Asia/Jakarta', 'vp8/h.264', 'online', '1320', 'fb:multiway', '10', 'timeout', '016', 'nse_retry', 'urn:xmpp:whatsapp:dirty', '017', 'a_v_id', 'web_shops_chat_header_button_enabled', 'nse_call', 'inactive-upgrade', 'none', 'web', 'groups', '2250', 'mms_hot_content_timespan_in_seconds', 'contact_blacklist', 'nse_read', 'suspended_group_deletion_notification', 'binary_version', '018', 'https://www.whatsapp.com/otp/copy/', 'reg_push', 'shops_hide_catalog_attachment_entrypoint', 'server_sync', '.', 'ephemeral_messages_allowed_values', '019', 'mms_vcache_aggregation_enabled', 'iphone', 'America/Argentina/Buenos_Aires', '01a', 'mms_vcard_autodownload_size_kb', 'nse_ver', 'shops_header_dropdown_menu_item', 'dhash', 'catalog_status', 'communities_mvp_new_iqs_serverprop', 'blocklist', 'default', '11', 'ephemeral_messages_enabled', '01b', 'original_dimensions', '8', 'mms4_media_retry_notification_encryption_enabled', 'mms4_server_error_receipt_encryption_enabled', 'original_image_url', 'sync', 'multiway', '420', 'companion_enc_static', 'shops_profile_drawer_entrypoint', '01c', 'vcard_as_document_size_kb', 'status_video_max_duration', 'request_image_url', '01d', 'regular_high', 's_t', 'abt', 'share_ext_min_preliminary_image_quality', '01e', '32', 'syncd_key_rotation_enabled', 'data_namespace', 'md_downgrade_read_receipts2', 'patch', 'polltype', 'ephemeral_messages_setting', 'userrate', '15', 'partial_pjpeg_bw_threshold', 'played-self', 'catalog_exists', '01f', 'mute_v2'], ['reject', 'dirty', 'announcement', '020', '13', '9', 'status_video_max_bitrate', 'fb:thrift_iq', 'offline_batch', '022', 'full', 'ctwa_first_business_reply_logging', 'h.264', 'smax_id', 'group_description_length', 'https://www.whatsapp.com/otp/code', 'status_image_max_edge', 'smb_upsell_business_profile_enabled', '021', 'web_upgrade_to_md_modal', '14', '023', 's_o', 'smaller_video_thumbs_status_enabled', 'media_max_autodownload', '960', 'blocking_status', 'peer_msg', 'joinable_group_call_client_version', 'group_call_video_maximization_enabled', 'return_snapshot', 'high', 'America/Mexico_City', 'entry_point_block_logging_enabled', 'pop', '024', '1050', '16', '1380', 'one_tap_calling_in_group_chat_size', 'regular_low', 'inline_joinable_education_enabled', 'hq_image_max_edge', 'locked', 'America/Bogota', 'smb_biztools_deeplink_enabled', 'status_image_quality', '1088', '025', 'payments_upi_intent_transaction_limit', 'voip', 'w:g2', '027', 'md_pin_chat_enabled', '026', 'multi_scan_pjpeg_download_enabled', 'shops_product_grid', 'transaction_id', 'ctwa_context_enabled', '20', 'fna', 'hq_image_quality', 'alt_jpeg_doc_detection_quality', 'group_call_max_participants', 'pkey', 'America/Belem', 'image_max_kbytes', 'web_cart_v1_1_order_message_changes_enabled', 'ctwa_context_enterprise_enabled', 'urn:xmpp:whatsapp:account', '840', 'Asia/Kuala_Lumpur', 'max_participants', 'video_remux_after_repair_enabled', 'stella_addressbook_restriction_type', '660', '900', '780', 'context_menu_ios13_enabled', 'mute-state', 'ref', 'payments_request_messages', '029', 'frskmsg', 'vcard_max_size_kb', 'sample_buffer_gif_player_enabled', 'match_last_seen', '510', '4983', 'video_max_bitrate', '028', 'w:comms:chat', '17', 'frequently_forwarded_max', 'groups_privacy_blacklist', 'Asia/Karachi', '02a', 'web_download_document_thumb_mms_enabled', '02b', 'hist_sync', 'biz_block_reasons_version', '1024', '18', 'web_is_direct_connection_for_plm_transparent', 'view_once_write', 'file_max_size', 'paid_convo_id', 'online_privacy_setting', 'video_max_edge', 'view_once_read', 'enhanced_storage_management', 'multi_scan_pjpeg_encoding_enabled', 'ctwa_context_forward_enabled', 'video_transcode_downgrade_enable', 'template_doc_mime_types', 'hq_image_bw_threshold', '30', 'body', 'u_aud_limit_sil_restarts_ctrl', 'other', 'participating', 'w:biz:directory', '1110', 'vp8', '4018', 'meta', 'doc_detection_image_max_edge', 'image_quality', '1170', '02c', 'smb_upsell_chat_banner_enabled', 'key_expiry_time_second', 'pid', 'stella_interop_enabled', '19', 'linked_device_max_count', 'md_device_sync_enabled', '02d', '02e', '360', 'enhanced_block_enabled', 'ephemeral_icon_in_forwarding', 'paid_convo_status', 'gif_provider', 'project_name', 'server-error', 'canonical_url_validation_enabled', 'wallpapers_v2', 'syncd_clear_chat_delete_chat_enabled', 'medianotify', '02f', 'shops_required_tos_version', 'vote', 'reset_skey_on_id_change', '030', 'image_max_edge', 'multicast_limit_global', 'ul_bw', '21', '25', '5000', 'poll', '570', '22', '031', '1280', 'WhatsApp', '032', 'bloks_shops_enabled', '50', 'upload_host_switching_enabled', 'web_ctwa_context_compose_enabled', 'ptt_forwarded_features_enabled', 'unblocked', 'partial_pjpeg_enabled', 'fbid:devices', 'height', 'ephemeral_group_query_ts', 'group_join_permissions', 'order', '033', 'alt_jpeg_status_quality', 'migrate', 'popular-bank', 'win_uwp_deprecation_killswitch_enabled', 'web_download_status_thumb_mms_enabled', 'blocking', 'url_text', '035', 'web_forwarding_limit_to_groups', '1600', 'val', '1000', 'syncd_msg_date_enabled', 'bank-ref-id', 'max_subject', 'payments_web_enabled', 'web_upload_document_thumb_mms_enabled', 'size', 'request', 'ephemeral', '24', 'receipt_agg', 'ptt_remember_play_position', 'sampling_weight', 'enc_rekey', 'mute_always', '037', '034', '23', '036', 'action', 'click_to_chat_qr_enabled', 'width', 'disabled', '038', 'md_blocklist_v2', 'played_self_enabled', 'web_buttons_message_enabled', 'flow_id', 'clear', '450', 'fbid:thread', 'bloks_session_state', 'America/Lima', 'attachment_picker_refresh', 'download_host_switching_enabled', '1792', 'u_aud_limit_sil_restarts_test2', 'custom_urls', 'device_fanout', 'optimistic_upload', '2000', 'key_cipher_suite', 'web_smb_upsell_in_biz_profile_enabled', 'e', '039', 'siri_post_status_shortcut', 'pair-device', 'lg', 'lc', 'stream_attribution_url', 'model', 'mspjpeg_phash_gen', 'catalog_send_all', 'new_multi_vcards_ui', 'share_biz_vcard_enabled', '-', 'clean', '200', 'md_blocklist_v2_server', '03b', '03a', 'web_md_migration_experience', 'ptt_conversation_waveform', 'u_aud_limit_sil_restarts_test1'], ['64', 'ptt_playback_speed_enabled', 'web_product_list_message_enabled', 'paid_convo_ts', '27', 'manufacturer', 'psp-routing', 'grp_uii_cleanup', 'ptt_draft_enabled', '03c', 'business_initiated', 'web_catalog_products_onoff', 'web_upload_link_thumb_mms_enabled', '03e', 'mediaretry', '35', 'hfm_string_changes', '28', 'America/Fortaleza', 'max_keys', 'md_mhfs_days', 'streaming_upload_chunk_size', '5541', '040', '03d', '2675', '03f', '...', '512', 'mute', '48', '041', 'alt_jpeg_quality', '60', '042', 'md_smb_quick_reply', '5183', 'c', '1343', '40', '1230', '043', '044', 'mms_cat_v1_forward_hot_override_enabled', 'user_notice', 'ptt_waveform_send', '047', 'Asia/Calcutta', '250', 'md_privacy_v2', '31', '29', '128', 'md_messaging_enabled', '046', 'crypto', '690', '045', 'enc_iv', '75', 'failure', 'ptt_oot_playback', 'AIzaSyDR5yfaG7OG8sMTUj8kfQEb8T9pN8BM6Lk', 'w', '048', '2201', 'web_large_files_ui', 'Asia/Makassar', '812', 'status_collapse_muted', '1334', '257', '2HP4dm', '049', 'patches', '1290', '43cY6T', 'America/Caracas', 'web_sticker_maker', 'campaign', 'ptt_pausable_enabled', '33', '42', 'attestation', 'biz', '04b', 'query_linked', 's', '125', '04a', '810', 'availability', '1411', 'responsiveness_v2_m1', 'catalog_not_created', '34', 'America/Santiago', '1465', 'enc_p', '04d', 'status_info', '04f', 'key_version', '..', '04c', '04e', 'md_group_notification', '1598', '1215', 'web_cart_enabled', '37', '630', '1920', '2394', '-1', 'vcard', '38', 'elapsed', '36', '828', 'peer', 'pricing_category', '1245', 'invalid', 'stella_ios_enabled', '2687', '45', '1528', '39', 'u_is_redial_audio_1104_ctrl', '1025', '1455', '58', '2524', '2603', '054', 'bsp_system_message_enabled', 'web_pip_redesign', '051', 'verify_apps', '1974', '1272', '1322', '1755', '052', '70', '050', '1063', '1135', '1361', '80', '1096', '1828', '1851', '1251', '1921', 'key_config_id', '1254', '1566', '1252', '2525', 'critical_block', '1669', 'max_available', 'w:auth:backup:token', 'product', '2530', '870', '1022', 'participant_uuid', 'web_cart_on_off', '1255', '1432', '1867', '41', '1415', '1440', '240', '1204', '1608', '1690', '1846', '1483', '1687', '1749', '69', 'url_number', '053', '1325', '1040', '365', '59', 'Asia/Riyadh', '1177', 'test_recommended', '057', '1612', '43', '1061', '1518', '1635', '055', '1034', '1375', '750', '1430', 'event_code', '1682', '503', '55', '865', '78', '1309', '1365', '44', 'America/Guayaquil', '535', 'LIMITED', '1377', '1613', '1420', '1599', '1822', '05a', '1681', 'password', '1111', '1214', '1376', '1478', '47', '1082', '4282', 'Europe/Istanbul', '1307', '46', '058', '1124', '256', 'rate-overlimit', 'retail', 'u_a_socket_err_fix_succ_test', '1292', '1370', '1388', '520', '861', 'psa', 'regular', '1181', '1766', '05b', '1183', '1213', '1304', '1537'], ['1724', 'profile_picture', '1071', '1314', '1605', '407', '990', '1710', '746', 'pricing_model', '056', '059', '061', '1119', '6027', '65', '877', '1607', '05d', '917', 'seen', '1516', '49', '470', '973', '1037', '1350', '1394', '1480', '1796', 'keys', '794', '1536', '1594', '2378', '1333', '1524', '1825', '116', '309', '52', '808', '827', '909', '495', '1660', '361', '957', 'google', '1357', '1565', '1967', '996', '1775', '586', '736', '1052', '1670', 'bank', '177', '1416', '2194', '2222', '1454', '1839', '1275', '53', '997', '1629', '6028', 'smba', '1378', '1410', '05c', '1849', '727', 'create', '1559', '536', '1106', '1310', '1944', '670', '1297', '1316', '1762', 'en', '1148', '1295', '1551', '1853', '1890', '1208', '1784', '7200', '05f', '178', '1283', '1332', '381', '643', '1056', '1238', '2024', '2387', '179', '981', '1547', '1705', '05e', '290', '903', '1069', '1285', '2436', '062', '251', '560', '582', '719', '56', '1700', '2321', '325', '448', '613', '777', '791', '51', '488', '902', 'Asia/Almaty', 'is_hidden', '1398', '1527', '1893', '1999', '2367', '2642', '237', 'busy', '065', '067', '233', '590', '993', '1511', '54', '723', '860', '363', '487', '522', '605', '995', '1321', '1691', '1865', '2447', '2462', 'NON_TRANSACTIONAL', '433', '871', '432', '1004', '1207', '2032', '2050', '2379', '2446', '279', '636', '703', '904', '248', '370', '691', '700', '1068', '1655', '2334', '060', '063', '364', '533', '534', '567', '1191', '1210', '1473', '1827', '069', '701', '2531', '514', 'prev_dhash', '064', '496', '790', '1046', '1139', '1505', '1521', '1108', '207', '544', '637', 'final', '1173', '1293', '1694', '1939', '1951', '1993', '2353', '2515', '504', '601', '857', 'modify', 'spam_request', 'p_121_aa_1101_test4', '866', '1427', '1502', '1638', '1744', '2153', '068', '382', '725', '1704', '1864', '1990', '2003', 'Asia/Dubai', '508', '531', '1387', '1474', '1632', '2307', '2386', '819', '2014', '066', '387', '1468', '1706', '2186', '2261', '471', '728', '1147', '1372', '1961']];
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
const DOUBLE_BYTE_TOKENS = exports.DOUBLE_BYTE_TOKENS = [['read-self', 'active', 'fbns', 'protocol', 'reaction', 'screen_width', 'heartbeat', 'deviceid', '2:47DEQpj8', 'uploadfieldstat', 'voip_settings', 'retry', 'priority', 'longitude', 'conflict', 'false', 'ig_professional', 'replaced', 'preaccept', 'cover_photo', 'uncompressed', 'encopt', 'ppic', '04', 'passive', 'status-revoke-drop', 'keygen', '540', 'offer', 'rate', 'opus', 'latitude', 'w:gp2', 'ver', '4', 'business_profile', 'medium', 'sender', 'prev_v_id', 'email', 'website', 'invited', 'sign_credential', '05', 'transport', 'skey', 'reason', 'peer_abtest_bucket', 'America/Sao_Paulo', 'appid', 'refresh', '100', '06', '404', '101', '104', '107', '102', '109', '103', 'member_add_mode', '105', 'transaction-id', '110', '106', 'outgoing', '108', '111', 'tokens', 'followers', 'ig_handle', 'self_pid', 'tue', 'dec', 'thu', 'joinable', 'peer_pid', 'mon', 'features', 'wed', 'peer_device_presence', 'pn', 'delete', '07', 'fri', 'audio_duration', 'admin', 'connected', 'delta', 'rcat', 'disable', 'collection', '08', '480', 'sat', 'phash', 'all', 'invite', 'accept', 'critical_unblock_low', 'group_update', 'signed_credential', 'blinded_credential', 'eph_setting', 'net', '09', 'background_location', 'refresh_id', 'Asia/Kolkata', 'privacy_mode_ts', 'account_sync', 'voip_payload_type', 'service_areas', 'acs_public_key', 'v_id', '0a', 'fallback_class', 'relay', 'actual_actors', 'metadata', 'w:biz', '5', 'connected-limit', 'notice', '0b', 'host_storage', 'fb_page', 'subject', 'privatestats', 'invis', 'groupadd', '010', 'note.m4r', 'uuid', '0c', '8000', 'sun', '372', '1020', 'stage', '1200', '720', 'canonical', 'fb', '011', 'video_duration', '0d', '1140', 'superadmin', '012', 'Opening.m4r', 'keystore_attestation', 'dleq_proof', '013', 'timestamp', 'ab_key', 'w:sync:app:state', '0e', 'vertical', '600', 'p_v_id', '6', 'likes', '014', '500', '1260', 'creator', '0f', 'rte', 'destination', 'group', 'group_info', 'syncd_anti_tampering_fatal_exception_enabled', '015', 'dl_bw', 'Asia/Jakarta', 'vp8/h.264', 'online', '1320', 'fb:multiway', '10', 'timeout', '016', 'nse_retry', 'urn:xmpp:whatsapp:dirty', '017', 'a_v_id', 'web_shops_chat_header_button_enabled', 'nse_call', 'inactive-upgrade', 'none', 'web', 'groups', '2250', 'mms_hot_content_timespan_in_seconds', 'contact_blacklist', 'nse_read', 'suspended_group_deletion_notification', 'binary_version', '018', 'https://www.whatsapp.com/otp/copy/', 'reg_push', 'shops_hide_catalog_attachment_entrypoint', 'server_sync', '.', 'ephemeral_messages_allowed_values', '019', 'mms_vcache_aggregation_enabled', 'iphone', 'America/Argentina/Buenos_Aires', '01a', 'mms_vcard_autodownload_size_kb', 'nse_ver', 'shops_header_dropdown_menu_item', 'dhash', 'catalog_status', 'communities_mvp_new_iqs_serverprop', 'blocklist', 'default', '11', 'ephemeral_messages_enabled', '01b', 'original_dimensions', '8', 'mms4_media_retry_notification_encryption_enabled', 'mms4_server_error_receipt_encryption_enabled', 'original_image_url', 'sync', 'multiway', '420', 'companion_enc_static', 'shops_profile_drawer_entrypoint', '01c', 'vcard_as_document_size_kb', 'status_video_max_duration', 'request_image_url', '01d', 'regular_high', 's_t', 'abt', 'share_ext_min_preliminary_image_quality', '01e', '32', 'syncd_key_rotation_enabled', 'data_namespace', 'md_downgrade_read_receipts2', 'patch', 'polltype', 'ephemeral_messages_setting', 'userrate', '15', 'partial_pjpeg_bw_threshold', 'played-self', 'catalog_exists', '01f', 'mute_v2'], ['reject', 'dirty', 'announcement', '020', '13', '9', 'status_video_max_bitrate', 'fb:thrift_iq', 'offline_batch', '022', 'full', 'ctwa_first_business_reply_logging', 'h.264', 'smax_id', 'group_description_length', 'https://www.whatsapp.com/otp/code', 'status_image_max_edge', 'smb_upsell_business_profile_enabled', '021', 'web_upgrade_to_md_modal', '14', '023', 's_o', 'smaller_video_thumbs_status_enabled', 'media_max_autodownload', '960', 'blocking_status', 'peer_msg', 'joinable_group_call_client_version', 'group_call_video_maximization_enabled', 'return_snapshot', 'high', 'America/Mexico_City', 'entry_point_block_logging_enabled', 'pop', '024', '1050', '16', '1380', 'one_tap_calling_in_group_chat_size', 'regular_low', 'inline_joinable_education_enabled', 'hq_image_max_edge', 'locked', 'America/Bogota', 'smb_biztools_deeplink_enabled', 'status_image_quality', '1088', '025', 'payments_upi_intent_transaction_limit', 'voip', 'w:g2', '027', 'md_pin_chat_enabled', '026', 'multi_scan_pjpeg_download_enabled', 'shops_product_grid', 'transaction_id', 'ctwa_context_enabled', '20', 'fna', 'hq_image_quality', 'alt_jpeg_doc_detection_quality', 'group_call_max_participants', 'pkey', 'America/Belem', 'image_max_kbytes', 'web_cart_v1_1_order_message_changes_enabled', 'ctwa_context_enterprise_enabled', 'urn:xmpp:whatsapp:account', '840', 'Asia/Kuala_Lumpur', 'max_participants', 'video_remux_after_repair_enabled', 'stella_addressbook_restriction_type', '660', '900', '780', 'context_menu_ios13_enabled', 'mute-state', 'ref', 'payments_request_messages', '029', 'frskmsg', 'vcard_max_size_kb', 'sample_buffer_gif_player_enabled', 'match_last_seen', '510', '4983', 'video_max_bitrate', '028', 'w:comms:chat', '17', 'frequently_forwarded_max', 'groups_privacy_blacklist', 'Asia/Karachi', '02a', 'web_download_document_thumb_mms_enabled', '02b', 'hist_sync', 'biz_block_reasons_version', '1024', '18', 'web_is_direct_connection_for_plm_transparent', 'view_once_write', 'file_max_size', 'paid_convo_id', 'online_privacy_setting', 'video_max_edge', 'view_once_read', 'enhanced_storage_management', 'multi_scan_pjpeg_encoding_enabled', 'ctwa_context_forward_enabled', 'video_transcode_downgrade_enable', 'template_doc_mime_types', 'hq_image_bw_threshold', '30', 'body', 'u_aud_limit_sil_restarts_ctrl', 'other', 'participating', 'w:biz:directory', '1110', 'vp8', '4018', 'meta', 'doc_detection_image_max_edge', 'image_quality', '1170', '02c', 'smb_upsell_chat_banner_enabled', 'key_expiry_time_second', 'pid', 'stella_interop_enabled', '19', 'linked_device_max_count', 'md_device_sync_enabled', '02d', '02e', '360', 'enhanced_block_enabled', 'ephemeral_icon_in_forwarding', 'paid_convo_status', 'gif_provider', 'project_name', 'server-error', 'canonical_url_validation_enabled', 'wallpapers_v2', 'syncd_clear_chat_delete_chat_enabled', 'medianotify', '02f', 'shops_required_tos_version', 'vote', 'reset_skey_on_id_change', '030', 'image_max_edge', 'multicast_limit_global', 'ul_bw', '21', '25', '5000', 'poll', '570', '22', '031', '1280', 'WhatsApp', '032', 'bloks_shops_enabled', '50', 'upload_host_switching_enabled', 'web_ctwa_context_compose_enabled', 'ptt_forwarded_features_enabled', 'unblocked', 'partial_pjpeg_enabled', 'fbid:devices', 'height', 'ephemeral_group_query_ts', 'group_join_permissions', 'order', '033', 'alt_jpeg_status_quality', 'migrate', 'popular-bank', 'win_uwp_deprecation_killswitch_enabled', 'web_download_status_thumb_mms_enabled', 'blocking', 'url_text', '035', 'web_forwarding_limit_to_groups', '1600', 'val', '1000', 'syncd_msg_date_enabled', 'bank-ref-id', 'max_subject', 'payments_web_enabled', 'web_upload_document_thumb_mms_enabled', 'size', 'request', 'ephemeral', '24', 'receipt_agg', 'ptt_remember_play_position', 'sampling_weight', 'enc_rekey', 'mute_always', '037', '034', '23', '036', 'action', 'click_to_chat_qr_enabled', 'width', 'disabled', '038', 'md_blocklist_v2', 'played_self_enabled', 'web_buttons_message_enabled', 'flow_id', 'clear', '450', 'fbid:thread', 'bloks_session_state', 'America/Lima', 'attachment_picker_refresh', 'download_host_switching_enabled', '1792', 'u_aud_limit_sil_restarts_test2', 'custom_urls', 'device_fanout', 'optimistic_upload', '2000', 'key_cipher_suite', 'web_smb_upsell_in_biz_profile_enabled', 'e', '039', 'siri_post_status_shortcut', 'pair-device', 'lg', 'lc', 'stream_attribution_url', 'model', 'mspjpeg_phash_gen', 'catalog_send_all', 'new_multi_vcards_ui', 'share_biz_vcard_enabled', '-', 'clean', '200', 'md_blocklist_v2_server', '03b', '03a', 'web_md_migration_experience', 'ptt_conversation_waveform', 'u_aud_limit_sil_restarts_test1'], ['64', 'ptt_playback_speed_enabled', 'web_product_list_message_enabled', 'paid_convo_ts', '27', 'manufacturer', 'psp-routing', 'grp_uii_cleanup', 'ptt_draft_enabled', '03c', 'business_initiated', 'web_catalog_products_onoff', 'web_upload_link_thumb_mms_enabled', '03e', 'mediaretry', '35', 'hfm_string_changes', '28', 'America/Fortaleza', 'max_keys', 'md_mhfs_days', 'streaming_upload_chunk_size', '5541', '040', '03d', '2675', '03f', '...', '512', 'mute', '48', '041', 'alt_jpeg_quality', '60', '042', 'md_smb_quick_reply', '5183', 'c', '1343', '40', '1230', '043', '044', 'mms_cat_v1_forward_hot_override_enabled', 'user_notice', 'ptt_waveform_send', '047', 'Asia/Calcutta', '250', 'md_privacy_v2', '31', '29', '128', 'md_messaging_enabled', '046', 'crypto', '690', '045', 'enc_iv', '75', 'failure', 'ptt_oot_playback', 'AIzaSyDR5yfaG7OG8sMTUj8kfQEb8T9pN8BM6Lk', 'w', '048', '2201', 'web_large_files_ui', 'Asia/Makassar', '812', 'status_collapse_muted', '1334', '257', '2HP4dm', '049', 'patches', '1290', '43cY6T', 'America/Caracas', 'web_sticker_maker', 'campaign', 'ptt_pausable_enabled', '33', '42', 'attestation', 'biz', '04b', 'query_linked', 's', '125', '04a', '810', 'availability', '1411', 'responsiveness_v2_m1', 'catalog_not_created', '34', 'America/Santiago', '1465', 'enc_p', '04d', 'status_info', '04f', 'key_version', '..', '04c', '04e', 'md_group_notification', '1598', '1215', 'web_cart_enabled', '37', '630', '1920', '2394', '-1', 'vcard', '38', 'elapsed', '36', '828', 'peer', 'pricing_category', '1245', 'invalid', 'stella_ios_enabled', '2687', '45', '1528', '39', 'u_is_redial_audio_1104_ctrl', '1025', '1455', '58', '2524', '2603', '054', 'bsp_system_message_enabled', 'web_pip_redesign', '051', 'verify_apps', '1974', '1272', '1322', '1755', '052', '70', '050', '1063', '1135', '1361', '80', '1096', '1828', '1851', '1251', '1921', 'key_config_id', '1254', '1566', '1252', '2525', 'critical_block', '1669', 'max_available', 'w:auth:backup:token', 'product', '2530', '870', '1022', 'participant_uuid', 'web_cart_on_off', '1255', '1432', '1867', '41', '1415', '1440', '240', '1204', '1608', '1690', '1846', '1483', '1687', '1749', '69', 'url_number', '053', '1325', '1040', '365', '59', 'Asia/Riyadh', '1177', 'test_recommended', '057', '1612', '43', '1061', '1518', '1635', '055', '1034', '1375', '750', '1430', 'event_code', '1682', '503', '55', '865', '78', '1309', '1365', '44', 'America/Guayaquil', '535', 'LIMITED', '1377', '1613', '1420', '1599', '1822', '05a', '1681', 'password', '1111', '1214', '1376', '1478', '47', '1082', '4282', 'Europe/Istanbul', '1307', '46', '058', '1124', '256', 'rate-overlimit', 'retail', 'u_a_socket_err_fix_succ_test', '1292', '1370', '1388', '520', '861', 'psa', 'regular', '1181', '1766', '05b', '1183', '1213', '1304', '1537'], ['1724', 'profile_picture', '1071', '1314', '1605', '407', '990', '1710', '746', 'pricing_model', '056', '059', '061', '1119', '6027', '65', '877', '1607', '05d', '917', 'seen', '1516', '49', '470', '973', '1037', '1350', '1394', '1480', '1796', 'keys', '794', '1536', '1594', '2378', '1333', '1524', '1825', '116', '309', '52', '808', '827', '909', '495', '1660', '361', '957', 'google', '1357', '1565', '1967', '996', '1775', '586', '736', '1052', '1670', 'bank', '177', '1416', '2194', '2222', '1454', '1839', '1275', '53', '997', '1629', '6028', 'smba', '1378', '1410', '05c', '1849', '727', 'create', '1559', '536', '1106', '1310', '1944', '670', '1297', '1316', '1762', 'en', '1148', '1295', '1551', '1853', '1890', '1208', '1784', '7200', '05f', '178', '1283', '1332', '381', '643', '1056', '1238', '2024', '2387', '179', '981', '1547', '1705', '05e', '290', '903', '1069', '1285', '2436', '062', '251', '560', '582', '719', '56', '1700', '2321', '325', '448', '613', '777', '791', '51', '488', '902', 'Asia/Almaty', 'is_hidden', '1398', '1527', '1893', '1999', '2367', '2642', '237', 'busy', '065', '067', '233', '590', '993', '1511', '54', '723', '860', '363', '487', '522', '605', '995', '1321', '1691', '1865', '2447', '2462', 'NON_TRANSACTIONAL', '433', '871', '432', '1004', '1207', '2032', '2050', '2379', '2446', '279', '636', '703', '904', '248', '370', '691', '700', '1068', '1655', '2334', '060', '063', '364', '533', '534', '567', '1191', '1210', '1473', '1827', '069', '701', '2531', '514', 'prev_dhash', '064', '496', '790', '1046', '1139', '1505', '1521', '1108', '207', '544', '637', 'final', '1173', '1293', '1694', '1939', '1951', '1993', '2353', '2515', '504', '601', '857', 'modify', 'spam_request', 'p_121_aa_1101_test4', '866', '1427', '1502', '1638', '1744', '2153', '068', '382', '725', '1704', '1864', '1990', '2003', 'Asia/Dubai', '508', '531', '1387', '1474', '1632', '2307', '2386', '819', '2014', '066', '387', '1468', '1706', '2186', '2261', '471', '728', '1147', '1372', '1961']];
|
|
25
|
+
const SINGLE_BYTE_TOKENS = exports.SINGLE_BYTE_TOKENS = ['', 'xmlstreamstart', 'xmlstreamend', 's.whatsapp.net', 'type', 'participant', 'from', 'receipt', 'id', 'notification', 'disappearing_mode', 'status', 'jid', 'broadcast', 'user', 'devices', 'device_hash', 'to', 'offline', 'message', 'result', 'class', 'xmlns', 'duration', 'notify', 'iq', 't', 'ack', 'g.us', 'enc', 'urn:xmpp:whatsapp:push', 'presence', 'config_value', 'picture', 'verified_name', 'config_code', 'key-index-list', 'contact', 'mediatype', 'routing_info', 'edge_routing', 'get', 'read', 'urn:xmpp:ping', 'fallback_hostname', '0', 'chatstate', 'business_hours_config', 'unavailable', 'download_buckets', 'skmsg', 'verified_level', 'composing', 'handshake', 'device-list', 'media', 'text', 'fallback_ip4', 'media_conn', 'device', 'creation', 'location', 'config', 'item', 'fallback_ip6', 'count', 'w:profile:picture', 'image', 'business', '2', 'hostname', 'call-creator', 'display_name', 'relaylatency', 'platform', 'abprops', 'success', 'msg', 'offline_preview', 'prop', 'key-index', 'v', 'day_of_week', 'pkmsg', 'version', '1', 'ping', 'w:p', 'download', 'video', 'set', 'specific_hours', 'props', 'primary', 'unknown', 'hash', 'commerce_experience', 'last', 'subscribe', 'max_buckets', 'call', 'profile', 'member_since_text', 'close_time', 'call-id', 'sticker', 'mode', 'participants', 'value', 'query', 'profile_options', 'open_time', 'code', 'list', 'host', 'ts', 'contacts', 'upload', 'lid', 'preview', 'update', 'usync', 'w:stats', 'delivery', 'auth_ttl', 'context', 'fail', 'cart_enabled', 'appdata', 'category', 'atn', 'direct_connection', 'decrypt-fail', 'relay_id', 'mmg-fallback.whatsapp.net', 'target', 'available', 'name', 'last_id', 'mmg.whatsapp.net', 'categories', '401', 'is_new', 'index', 'tctoken', 'ip4', 'token_id', 'latency', 'recipient', 'edit', 'ip6', 'add', 'thumbnail-document', '26', 'paused', 'true', 'identity', 'stream:error', 'key', 'sidelist', 'background', 'audio', '3', 'thumbnail-image', 'biz-cover-photo', 'cat', 'gcm', 'thumbnail-video', 'error', 'auth', 'deny', 'serial', 'in', 'registration', 'thumbnail-link', 'remove', '00', 'gif', 'thumbnail-gif', 'tag', 'capability', 'multicast', 'item-not-found', 'description', 'business_hours', 'config_expo_key', 'md-app-state', 'expiration', 'fallback', 'ttl', '300', 'md-msg-hist', 'device_orientation', 'out', 'w:m', 'open_24h', 'side_list', 'token', 'inactive', '01', 'document', 'te2', 'played', 'encrypt', 'msgr', 'hide', 'direct_path', '12', 'state', 'not-authorized', 'url', 'terminate', 'signature', 'status-revoke-delay', '02', 'te', 'linked_accounts', 'trusted_contact', 'timezone', 'ptt', 'kyc-id', 'privacy_token', 'readreceipts', 'appointment_only', 'address', 'expected_ts', 'privacy', '7', 'android', 'interactive', 'device-identity', 'enabled', 'attribute_padding', '1080', '03', 'screen_height'];
|
|
26
|
+
const TOKEN_MAP = exports.TOKEN_MAP = {};
|
|
23
27
|
for (const [i, SINGLE_BYTE_TOKEN] of SINGLE_BYTE_TOKENS.entries()) {
|
|
24
28
|
TOKEN_MAP[SINGLE_BYTE_TOKEN] = {
|
|
25
29
|
index: i
|
|
@@ -32,5 +36,4 @@ for (const [i, DOUBLE_BYTE_TOKEN] of DOUBLE_BYTE_TOKENS.entries()) {
|
|
|
32
36
|
index: j
|
|
33
37
|
};
|
|
34
38
|
}
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=constants.js.map
|
|
39
|
+
}
|
package/lib/WABinary/decode.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2
|
+
value: true
|
|
3
|
+
});
|
|
4
|
+
exports.decompressingIfRequired = exports.decodeDecompressedBinaryNode = exports.decodeBinaryNode = void 0;
|
|
5
|
+
var _util = require("util");
|
|
6
|
+
var _zlib = require("zlib");
|
|
7
|
+
var constants = _interopRequireWildcard(require("./constants.js"));
|
|
8
|
+
var _jidUtils = require("./jid-utils.js");
|
|
9
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
10
|
+
const inflatePromise = (0, _util.promisify)(_zlib.inflate);
|
|
11
|
+
const decompressingIfRequired = async buffer => {
|
|
7
12
|
if (2 & buffer.readUInt8()) {
|
|
8
13
|
buffer = await inflatePromise(buffer.slice(1));
|
|
9
14
|
} else {
|
|
@@ -12,7 +17,8 @@ export const decompressingIfRequired = async buffer => {
|
|
|
12
17
|
}
|
|
13
18
|
return buffer;
|
|
14
19
|
};
|
|
15
|
-
|
|
20
|
+
exports.decompressingIfRequired = decompressingIfRequired;
|
|
21
|
+
const decodeDecompressedBinaryNode = (buffer, opts, indexRef = {
|
|
16
22
|
index: 0
|
|
17
23
|
}) => {
|
|
18
24
|
const {
|
|
@@ -127,7 +133,7 @@ export const decodeDecompressedBinaryNode = (buffer, opts, indexRef = {
|
|
|
127
133
|
const domainType = Number(rawDomainType);
|
|
128
134
|
const device = readByte();
|
|
129
135
|
const user = readString(readByte());
|
|
130
|
-
return jidEncode(user, domainType === 0 || domainType === 128 ? 's.whatsapp.net' : 'lid', device);
|
|
136
|
+
return (0, _jidUtils.jidEncode)(user, domainType === 0 || domainType === 128 ? 's.whatsapp.net' : 'lid', device);
|
|
131
137
|
};
|
|
132
138
|
const readString = tag => {
|
|
133
139
|
if (tag >= 1 && tag < SINGLE_BYTE_TOKENS.length) {
|
|
@@ -223,8 +229,9 @@ export const decodeDecompressedBinaryNode = (buffer, opts, indexRef = {
|
|
|
223
229
|
content: data
|
|
224
230
|
};
|
|
225
231
|
};
|
|
226
|
-
|
|
232
|
+
exports.decodeDecompressedBinaryNode = decodeDecompressedBinaryNode;
|
|
233
|
+
const decodeBinaryNode = async buff => {
|
|
227
234
|
const decompBuff = await decompressingIfRequired(buff);
|
|
228
235
|
return decodeDecompressedBinaryNode(decompBuff, constants);
|
|
229
236
|
};
|
|
230
|
-
|
|
237
|
+
exports.decodeBinaryNode = decodeBinaryNode;
|
package/lib/WABinary/encode.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
Object.defineProperty(exports, "__esModule", {
|
|
2
|
+
value: true
|
|
3
|
+
});
|
|
4
|
+
exports.encodeBinaryNode = void 0;
|
|
5
|
+
var constants = _interopRequireWildcard(require("./constants.js"));
|
|
6
|
+
var _jidUtils = require("./jid-utils.js");
|
|
7
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
8
|
+
const encodeBinaryNode = (node, opts = constants, buffer = [0]) => {
|
|
4
9
|
const encoded = encodeBinaryNodeInner(node, opts, buffer);
|
|
5
10
|
return Buffer.from(encoded);
|
|
6
11
|
};
|
|
12
|
+
exports.encodeBinaryNode = encodeBinaryNode;
|
|
7
13
|
const encodeBinaryNodeInner = ({
|
|
8
14
|
tag,
|
|
9
15
|
attrs,
|
|
@@ -163,7 +169,7 @@ const encodeBinaryNodeInner = ({
|
|
|
163
169
|
} else if (isHex(str)) {
|
|
164
170
|
writePackedBytes(str, 'hex');
|
|
165
171
|
} else if (str) {
|
|
166
|
-
const decodedJid = jidDecode(str);
|
|
172
|
+
const decodedJid = (0, _jidUtils.jidDecode)(str);
|
|
167
173
|
if (decodedJid) {
|
|
168
174
|
writeJid(decodedJid);
|
|
169
175
|
} else {
|
|
@@ -210,5 +216,4 @@ const encodeBinaryNodeInner = ({
|
|
|
210
216
|
throw new Error(`invalid children for header "${tag}": ${content} (${typeof content})`);
|
|
211
217
|
}
|
|
212
218
|
return buffer;
|
|
213
|
-
};
|
|
214
|
-
//# sourceMappingURL=encode.js.map
|
|
219
|
+
};
|