@vinzsocket/baileys 2.8.10 → 2.8.30
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/lib/Defaults/index.js +75 -73
- package/lib/Signal/Group/ciphertext-message.js +9 -9
- package/lib/Signal/Group/group-session-builder.js +21 -21
- package/lib/Signal/Group/group_cipher.js +79 -81
- package/lib/Signal/Group/index.js +2 -2
- package/lib/Signal/Group/keyhelper.js +9 -9
- package/lib/Signal/Group/queue-job.js +43 -46
- package/lib/Signal/Group/sender-chain-key.js +24 -25
- package/lib/Signal/Group/sender-key-distribution-message.js +50 -58
- package/lib/Signal/Group/sender-key-message.js +55 -60
- package/lib/Signal/Group/sender-key-name.js +38 -39
- package/lib/Signal/Group/sender-key-record.js +39 -41
- package/lib/Signal/Group/sender-key-state.js +85 -89
- package/lib/Signal/Group/sender-message-key.js +22 -22
- package/lib/Signal/libsignal.js +387 -292
- package/lib/Signal/lid-mapping.js +98 -93
- package/lib/Socket/Client/types.js +6 -6
- package/lib/Socket/Client/websocket.js +44 -44
- package/lib/Socket/business.js +350 -365
- package/lib/Socket/chats.js +1019 -914
- package/lib/Socket/communities.js +454 -376
- package/lib/Socket/groups.js +378 -310
- package/lib/Socket/index.js +11 -11
- package/lib/Socket/messages-recv.js +1355 -1182
- package/lib/Socket/messages-send.js +1224 -1081
- package/lib/Socket/mex.js +40 -34
- package/lib/Socket/newsletter.js +212 -169
- package/lib/Socket/socket.js +896 -757
- package/lib/Store/index.js +1 -1
- package/lib/Store/make-cache-manager-store.js +75 -79
- package/lib/Store/make-in-memory-store.js +450 -389
- package/lib/Store/make-ordered-dictionary.js +73 -76
- package/lib/Store/object-repository.js +24 -22
- package/lib/Types/Chat.js +1 -7
- package/lib/Types/Label.js +20 -20
- package/lib/Types/LabelAssociation.js +2 -2
- package/lib/Types/Message.js +2 -2
- package/lib/Types/Newsletter.js +24 -24
- package/lib/Types/Socket.js +1 -1
- package/lib/Types/State.js +8 -8
- package/lib/Types/index.js +10 -10
- package/lib/Utils/auth-utils.js +408 -401
- package/lib/Utils/baileys-event-stream.js +44 -35
- package/lib/Utils/business.js +200 -197
- package/lib/Utils/chat-utils.js +775 -708
- package/lib/Utils/crypto.js +97 -85
- package/lib/Utils/decode-wa-message.js +240 -227
- package/lib/Utils/event-buffer.js +547 -518
- package/lib/Utils/extended-messages.js +250 -203
- package/lib/Utils/generics.js +300 -289
- package/lib/Utils/history.js +76 -69
- package/lib/Utils/lid-resolver.js +47 -42
- package/lib/Utils/link-preview.js +75 -65
- package/lib/Utils/logger.js +3 -1
- package/lib/Utils/lt-hash.js +38 -34
- package/lib/Utils/make-mutex.js +32 -34
- package/lib/Utils/mention.js +79 -86
- package/lib/Utils/message-retry-manager.js +148 -136
- package/lib/Utils/messages-media.js +652 -562
- package/lib/Utils/messages.js +753 -707
- package/lib/Utils/noise-handler.js +156 -135
- package/lib/Utils/process-message.js +404 -341
- package/lib/Utils/signal.js +180 -118
- package/lib/Utils/use-multi-file-auth-state.js +87 -91
- package/lib/Utils/validate-connection.js +167 -142
- package/lib/WABinary/constants.js +28 -1293
- package/lib/WABinary/decode.js +220 -218
- package/lib/WABinary/encode.js +199 -201
- package/lib/WABinary/generic-utils.js +80 -77
- package/lib/WABinary/jid-utils.js +41 -35
- package/lib/WAM/BinaryInfo.js +7 -7
- package/lib/WAM/constants.js +1 -15241
- package/lib/WAM/encode.js +124 -131
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +23 -23
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +51 -47
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +22 -22
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +30 -32
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +19 -19
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -43
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +17 -17
- package/lib/WAUSync/USyncQuery.js +82 -84
- package/lib/WAUSync/USyncUser.js +20 -20
- package/package.json +4 -2
package/lib/WAM/encode.js
CHANGED
|
@@ -1,150 +1,143 @@
|
|
|
1
1
|
import { BinaryInfo } from './BinaryInfo.js';
|
|
2
2
|
import { FLAG_BYTE, FLAG_EVENT, FLAG_EXTENDED, FLAG_FIELD, FLAG_GLOBAL, WEB_EVENTS, WEB_GLOBALS } from './constants.js';
|
|
3
|
-
const getHeaderBitLength =
|
|
4
|
-
export const encodeWAM =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
const getHeaderBitLength = key => key < 256 ? 2 : 3;
|
|
4
|
+
export const encodeWAM = binaryInfo => {
|
|
5
|
+
binaryInfo.buffer = [];
|
|
6
|
+
encodeWAMHeader(binaryInfo);
|
|
7
|
+
encodeEvents(binaryInfo);
|
|
8
|
+
const totalSize = binaryInfo.buffer.map(a => a.length).reduce((a, b) => a + b);
|
|
9
|
+
const buffer = Buffer.alloc(totalSize);
|
|
10
|
+
let offset = 0;
|
|
11
|
+
for (const buffer_ of binaryInfo.buffer) {
|
|
12
|
+
buffer_.copy(buffer, offset);
|
|
13
|
+
offset += buffer_.length;
|
|
14
|
+
}
|
|
15
|
+
return buffer;
|
|
16
16
|
};
|
|
17
17
|
function encodeWAMHeader(binaryInfo) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
const headerBuffer = Buffer.alloc(8); // starting buffer
|
|
19
|
+
headerBuffer.write('WAM', 0, 'utf8');
|
|
20
|
+
headerBuffer.writeUInt8(binaryInfo.protocolVersion, 3);
|
|
21
|
+
headerBuffer.writeUInt8(1, 4); //random flag
|
|
22
|
+
headerBuffer.writeUInt16BE(binaryInfo.sequence, 5);
|
|
23
|
+
headerBuffer.writeUInt8(0, 7); // regular channel
|
|
24
|
+
binaryInfo.buffer.push(headerBuffer);
|
|
25
25
|
}
|
|
26
26
|
function encodeGlobalAttributes(binaryInfo, globals) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
binaryInfo.buffer.push(serializeData(id, value, FLAG_GLOBAL));
|
|
27
|
+
for (const [key, _value] of Object.entries(globals)) {
|
|
28
|
+
const id = WEB_GLOBALS.find(a => a?.name === key).id;
|
|
29
|
+
let value = _value;
|
|
30
|
+
if (typeof value === 'boolean') {
|
|
31
|
+
value = value ? 1 : 0;
|
|
34
32
|
}
|
|
33
|
+
binaryInfo.buffer.push(serializeData(id, value, FLAG_GLOBAL));
|
|
34
|
+
}
|
|
35
35
|
}
|
|
36
36
|
function encodeEvents(binaryInfo) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
for (let i = 0; i < props_.length; i++) {
|
|
48
|
-
const [key, _value] = props_[i];
|
|
49
|
-
const id = event.props[key]?.[0];
|
|
50
|
-
extended = i < props_.length - 1;
|
|
51
|
-
let value = _value;
|
|
52
|
-
if (typeof value === 'boolean') {
|
|
53
|
-
value = value ? 1 : 0;
|
|
54
|
-
}
|
|
55
|
-
const fieldFlag = extended ? FLAG_EVENT : FLAG_FIELD | FLAG_EXTENDED;
|
|
56
|
-
binaryInfo.buffer.push(serializeData(id, value, fieldFlag));
|
|
57
|
-
}
|
|
37
|
+
for (const [name, {
|
|
38
|
+
props,
|
|
39
|
+
globals
|
|
40
|
+
}] of binaryInfo.events.map(a => Object.entries(a)[0])) {
|
|
41
|
+
encodeGlobalAttributes(binaryInfo, globals);
|
|
42
|
+
const event = WEB_EVENTS.find(a => a.name === name);
|
|
43
|
+
const props_ = Object.entries(props);
|
|
44
|
+
let extended = false;
|
|
45
|
+
for (const [, value] of props_) {
|
|
46
|
+
extended || (extended = value !== null);
|
|
58
47
|
}
|
|
48
|
+
const eventFlag = extended ? FLAG_EVENT : FLAG_EVENT | FLAG_EXTENDED;
|
|
49
|
+
binaryInfo.buffer.push(serializeData(event.id, -event.weight, eventFlag));
|
|
50
|
+
for (let i = 0; i < props_.length; i++) {
|
|
51
|
+
const [key, _value] = props_[i];
|
|
52
|
+
const id = event.props[key]?.[0];
|
|
53
|
+
extended = i < props_.length - 1;
|
|
54
|
+
let value = _value;
|
|
55
|
+
if (typeof value === 'boolean') {
|
|
56
|
+
value = value ? 1 : 0;
|
|
57
|
+
}
|
|
58
|
+
const fieldFlag = extended ? FLAG_EVENT : FLAG_FIELD | FLAG_EXTENDED;
|
|
59
|
+
binaryInfo.buffer.push(serializeData(id, value, fieldFlag));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
59
62
|
}
|
|
60
63
|
function serializeData(key, value, flag) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
else if (typeof value === 'number' && Number.isInteger(value)) {
|
|
72
|
-
// is number
|
|
73
|
-
if (value === 0 || value === 1) {
|
|
74
|
-
buffer = Buffer.alloc(bufferLength);
|
|
75
|
-
offset = serializeHeader(buffer, offset, key, flag | ((value + 1) << 4));
|
|
76
|
-
return buffer;
|
|
77
|
-
}
|
|
78
|
-
else if (-128 <= value && value < 128) {
|
|
79
|
-
buffer = Buffer.alloc(bufferLength + 1);
|
|
80
|
-
offset = serializeHeader(buffer, offset, key, flag | (3 << 4));
|
|
81
|
-
buffer.writeInt8(value, offset);
|
|
82
|
-
return buffer;
|
|
83
|
-
}
|
|
84
|
-
else if (-32768 <= value && value < 32768) {
|
|
85
|
-
buffer = Buffer.alloc(bufferLength + 2);
|
|
86
|
-
offset = serializeHeader(buffer, offset, key, flag | (4 << 4));
|
|
87
|
-
buffer.writeInt16LE(value, offset);
|
|
88
|
-
return buffer;
|
|
89
|
-
}
|
|
90
|
-
else if (-2147483648 <= value && value < 2147483648) {
|
|
91
|
-
buffer = Buffer.alloc(bufferLength + 4);
|
|
92
|
-
offset = serializeHeader(buffer, offset, key, flag | (5 << 4));
|
|
93
|
-
buffer.writeInt32LE(value, offset);
|
|
94
|
-
return buffer;
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
buffer = Buffer.alloc(bufferLength + 8);
|
|
98
|
-
offset = serializeHeader(buffer, offset, key, flag | (7 << 4));
|
|
99
|
-
buffer.writeDoubleLE(value, offset);
|
|
100
|
-
return buffer;
|
|
101
|
-
}
|
|
64
|
+
const bufferLength = getHeaderBitLength(key);
|
|
65
|
+
let buffer;
|
|
66
|
+
let offset = 0;
|
|
67
|
+
if (value === null) {
|
|
68
|
+
if (flag === FLAG_GLOBAL) {
|
|
69
|
+
buffer = Buffer.alloc(bufferLength);
|
|
70
|
+
offset = serializeHeader(buffer, offset, key, flag);
|
|
71
|
+
return buffer;
|
|
102
72
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
73
|
+
} else if (typeof value === 'number' && Number.isInteger(value)) {
|
|
74
|
+
// is number
|
|
75
|
+
if (value === 0 || value === 1) {
|
|
76
|
+
buffer = Buffer.alloc(bufferLength);
|
|
77
|
+
offset = serializeHeader(buffer, offset, key, flag | value + 1 << 4);
|
|
78
|
+
return buffer;
|
|
79
|
+
} else if (-128 <= value && value < 128) {
|
|
80
|
+
buffer = Buffer.alloc(bufferLength + 1);
|
|
81
|
+
offset = serializeHeader(buffer, offset, key, flag | 3 << 4);
|
|
82
|
+
buffer.writeInt8(value, offset);
|
|
83
|
+
return buffer;
|
|
84
|
+
} else if (-32768 <= value && value < 32768) {
|
|
85
|
+
buffer = Buffer.alloc(bufferLength + 2);
|
|
86
|
+
offset = serializeHeader(buffer, offset, key, flag | 4 << 4);
|
|
87
|
+
buffer.writeInt16LE(value, offset);
|
|
88
|
+
return buffer;
|
|
89
|
+
} else if (-2147483648 <= value && value < 2147483648) {
|
|
90
|
+
buffer = Buffer.alloc(bufferLength + 4);
|
|
91
|
+
offset = serializeHeader(buffer, offset, key, flag | 5 << 4);
|
|
92
|
+
buffer.writeInt32LE(value, offset);
|
|
93
|
+
return buffer;
|
|
94
|
+
} else {
|
|
95
|
+
buffer = Buffer.alloc(bufferLength + 8);
|
|
96
|
+
offset = serializeHeader(buffer, offset, key, flag | 7 << 4);
|
|
97
|
+
buffer.writeDoubleLE(value, offset);
|
|
98
|
+
return buffer;
|
|
109
99
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
100
|
+
} else if (typeof value === 'number') {
|
|
101
|
+
// is float
|
|
102
|
+
buffer = Buffer.alloc(bufferLength + 8);
|
|
103
|
+
offset = serializeHeader(buffer, offset, key, flag | 7 << 4);
|
|
104
|
+
buffer.writeDoubleLE(value, offset);
|
|
105
|
+
return buffer;
|
|
106
|
+
} else if (typeof value === 'string') {
|
|
107
|
+
// is string
|
|
108
|
+
const utf8Bytes = Buffer.byteLength(value, 'utf8');
|
|
109
|
+
if (utf8Bytes < 256) {
|
|
110
|
+
buffer = Buffer.alloc(bufferLength + 1 + utf8Bytes);
|
|
111
|
+
offset = serializeHeader(buffer, offset, key, flag | 8 << 4);
|
|
112
|
+
buffer.writeUint8(utf8Bytes, offset++);
|
|
113
|
+
} else if (utf8Bytes < 65536) {
|
|
114
|
+
buffer = Buffer.alloc(bufferLength + 2 + utf8Bytes);
|
|
115
|
+
offset = serializeHeader(buffer, offset, key, flag | 9 << 4);
|
|
116
|
+
buffer.writeUInt16LE(utf8Bytes, offset);
|
|
117
|
+
offset += 2;
|
|
118
|
+
} else {
|
|
119
|
+
buffer = Buffer.alloc(bufferLength + 4 + utf8Bytes);
|
|
120
|
+
offset = serializeHeader(buffer, offset, key, flag | 10 << 4);
|
|
121
|
+
buffer.writeUInt32LE(utf8Bytes, offset);
|
|
122
|
+
offset += 4;
|
|
132
123
|
}
|
|
133
|
-
|
|
124
|
+
buffer.write(value, offset, 'utf8');
|
|
125
|
+
return buffer;
|
|
126
|
+
}
|
|
127
|
+
throw 'missing';
|
|
134
128
|
}
|
|
135
129
|
function serializeHeader(buffer, offset, key, flag) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return offset;
|
|
130
|
+
if (key < 256) {
|
|
131
|
+
buffer.writeUInt8(flag, offset);
|
|
132
|
+
offset += 1;
|
|
133
|
+
buffer.writeUInt8(key, offset);
|
|
134
|
+
offset += 1;
|
|
135
|
+
} else {
|
|
136
|
+
buffer.writeUInt8(flag | FLAG_BYTE, offset);
|
|
137
|
+
offset += 1;
|
|
138
|
+
buffer.writeUInt16LE(key, offset);
|
|
139
|
+
offset += 2;
|
|
140
|
+
}
|
|
141
|
+
return offset;
|
|
149
142
|
}
|
|
150
143
|
//# sourceMappingURL=encode.js.map
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { assertNodeErrorFree } from '../../WABinary/index.js';
|
|
2
2
|
import { USyncUser } from '../USyncUser.js';
|
|
3
3
|
export class USyncContactProtocol {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
return false;
|
|
4
|
+
constructor() {
|
|
5
|
+
this.name = 'contact';
|
|
6
|
+
}
|
|
7
|
+
getQueryElement() {
|
|
8
|
+
return {
|
|
9
|
+
tag: 'contact',
|
|
10
|
+
attrs: {}
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
getUserElement(user) {
|
|
14
|
+
//TODO: Implement type / username fields (not yet supported)
|
|
15
|
+
return {
|
|
16
|
+
tag: 'contact',
|
|
17
|
+
attrs: {},
|
|
18
|
+
content: user.phone
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
parser(node) {
|
|
22
|
+
if (node.tag === 'contact') {
|
|
23
|
+
assertNodeErrorFree(node);
|
|
24
|
+
return node?.attrs?.type === 'in';
|
|
27
25
|
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
28
|
}
|
|
29
29
|
//# sourceMappingURL=USyncContactProtocol.js.map
|
|
@@ -1,54 +1,58 @@
|
|
|
1
1
|
import { assertNodeErrorFree, getBinaryNodeChild } from '../../WABinary/index.js';
|
|
2
2
|
export class USyncDeviceProtocol {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
timestamp: +keyIndexNode.attrs['ts'],
|
|
43
|
-
signedKeyIndex: keyIndexNode?.content,
|
|
44
|
-
expectedTimestamp: keyIndexNode.attrs['expected_ts'] ? +keyIndexNode.attrs['expected_ts'] : undefined
|
|
45
|
-
};
|
|
46
|
-
}
|
|
3
|
+
constructor() {
|
|
4
|
+
this.name = 'devices';
|
|
5
|
+
}
|
|
6
|
+
getQueryElement() {
|
|
7
|
+
return {
|
|
8
|
+
tag: 'devices',
|
|
9
|
+
attrs: {
|
|
10
|
+
version: '2'
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
getUserElement(/* user: USyncUser */
|
|
15
|
+
) {
|
|
16
|
+
//TODO: Implement device phashing, ts and expectedTs
|
|
17
|
+
//TODO: if all are not present, return null <- current behavior
|
|
18
|
+
//TODO: otherwise return a node w tag 'devices' w those as attrs
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
parser(node) {
|
|
22
|
+
const deviceList = [];
|
|
23
|
+
let keyIndex = undefined;
|
|
24
|
+
if (node.tag === 'devices') {
|
|
25
|
+
assertNodeErrorFree(node);
|
|
26
|
+
const deviceListNode = getBinaryNodeChild(node, 'device-list');
|
|
27
|
+
const keyIndexNode = getBinaryNodeChild(node, 'key-index-list');
|
|
28
|
+
if (Array.isArray(deviceListNode?.content)) {
|
|
29
|
+
for (const {
|
|
30
|
+
tag,
|
|
31
|
+
attrs
|
|
32
|
+
} of deviceListNode.content) {
|
|
33
|
+
const id = +attrs.id;
|
|
34
|
+
const keyIndex = +attrs['key-index'];
|
|
35
|
+
if (tag === 'device') {
|
|
36
|
+
deviceList.push({
|
|
37
|
+
id,
|
|
38
|
+
keyIndex,
|
|
39
|
+
isHosted: !!(attrs['is_hosted'] && attrs['is_hosted'] === 'true')
|
|
40
|
+
});
|
|
41
|
+
}
|
|
47
42
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
}
|
|
44
|
+
if (keyIndexNode?.tag === 'key-index-list') {
|
|
45
|
+
keyIndex = {
|
|
46
|
+
timestamp: +keyIndexNode.attrs['ts'],
|
|
47
|
+
signedKeyIndex: keyIndexNode?.content,
|
|
48
|
+
expectedTimestamp: keyIndexNode.attrs['expected_ts'] ? +keyIndexNode.attrs['expected_ts'] : undefined
|
|
51
49
|
};
|
|
50
|
+
}
|
|
52
51
|
}
|
|
52
|
+
return {
|
|
53
|
+
deviceList,
|
|
54
|
+
keyIndex
|
|
55
|
+
};
|
|
56
|
+
}
|
|
53
57
|
}
|
|
54
58
|
//# sourceMappingURL=USyncDeviceProtocol.js.map
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { assertNodeErrorFree } from '../../WABinary/index.js';
|
|
2
2
|
export class USyncDisappearingModeProtocol {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
3
|
+
constructor() {
|
|
4
|
+
this.name = 'disappearing_mode';
|
|
5
|
+
}
|
|
6
|
+
getQueryElement() {
|
|
7
|
+
return {
|
|
8
|
+
tag: 'disappearing_mode',
|
|
9
|
+
attrs: {}
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
getUserElement() {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
parser(node) {
|
|
16
|
+
if (node.tag === 'disappearing_mode') {
|
|
17
|
+
assertNodeErrorFree(node);
|
|
18
|
+
const duration = +node?.attrs.duration;
|
|
19
|
+
const setAt = new Date(+(node?.attrs.t || 0) * 1000);
|
|
20
|
+
return {
|
|
21
|
+
duration,
|
|
22
|
+
setAt
|
|
23
|
+
};
|
|
25
24
|
}
|
|
25
|
+
}
|
|
26
26
|
}
|
|
27
27
|
//# sourceMappingURL=USyncDisappearingModeProtocol.js.map
|
|
@@ -1,38 +1,36 @@
|
|
|
1
1
|
import { assertNodeErrorFree } from '../../WABinary/index.js';
|
|
2
2
|
export class USyncStatusProtocol {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
status = null;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
else if (typeof status === 'string' && status.length === 0) {
|
|
29
|
-
status = null;
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
status,
|
|
33
|
-
setAt
|
|
34
|
-
};
|
|
3
|
+
constructor() {
|
|
4
|
+
this.name = 'status';
|
|
5
|
+
}
|
|
6
|
+
getQueryElement() {
|
|
7
|
+
return {
|
|
8
|
+
tag: 'status',
|
|
9
|
+
attrs: {}
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
getUserElement() {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
parser(node) {
|
|
16
|
+
if (node.tag === 'status') {
|
|
17
|
+
assertNodeErrorFree(node);
|
|
18
|
+
let status = node?.content?.toString() ?? null;
|
|
19
|
+
const setAt = new Date(+(node?.attrs.t || 0) * 1000);
|
|
20
|
+
if (!status) {
|
|
21
|
+
if (node.attrs?.code && +node.attrs.code === 401) {
|
|
22
|
+
status = '';
|
|
23
|
+
} else {
|
|
24
|
+
status = null;
|
|
35
25
|
}
|
|
26
|
+
} else if (typeof status === 'string' && status.length === 0) {
|
|
27
|
+
status = null;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
status,
|
|
31
|
+
setAt
|
|
32
|
+
};
|
|
36
33
|
}
|
|
34
|
+
}
|
|
37
35
|
}
|
|
38
36
|
//# sourceMappingURL=USyncStatusProtocol.js.map
|
|
@@ -2,23 +2,23 @@ import { assertNodeErrorFree } from '../../WABinary/index.js';
|
|
|
2
2
|
// Look up a user's WhatsApp username via a USync query.
|
|
3
3
|
// Mirrors the existing protocol files (UsyncLIDProtocol.js etc) in this folder.
|
|
4
4
|
export class USyncUsernameProtocol {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'username';
|
|
7
|
+
}
|
|
8
|
+
getQueryElement() {
|
|
9
|
+
return {
|
|
10
|
+
tag: 'username',
|
|
11
|
+
attrs: {}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
getUserElement() {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
parser(node) {
|
|
18
|
+
if (node.tag === 'username') {
|
|
19
|
+
assertNodeErrorFree(node);
|
|
20
|
+
return typeof node.content === 'string' ? node.content : null;
|
|
7
21
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
attrs: {}
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
getUserElement() {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
parser(node) {
|
|
18
|
-
if (node.tag === 'username') {
|
|
19
|
-
assertNodeErrorFree(node);
|
|
20
|
-
return typeof node.content === 'string' ? node.content : null;
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|