@jkt48connect-corp/baileys 7.2.7 → 7.2.9
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 +1 -1
- package/README.md +838 -94
- package/WAProto/WAProto.proto +969 -88
- package/WAProto/index.js +124901 -74525
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.js +5 -3
- package/lib/Defaults/phonenumber-mcc.json +221 -221
- package/lib/Signal/libsignal.js +18 -9
- package/lib/Socket/groups.js +1 -1
- package/lib/Socket/messages-recv.js +310 -151
- package/lib/Socket/messages-send.js +269 -36
- package/lib/Socket/newsletter.js +3 -3
- package/lib/Socket/registration.js +7 -7
- package/lib/Socket/socket.js +7 -3
- package/lib/Store/make-in-memory-store.js +13 -11
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Newsletter.js +3 -3
- package/lib/Types/index.js +1 -1
- package/lib/Utils/auth-utils.js +3 -3
- package/lib/Utils/business.js +2 -2
- package/lib/Utils/chat-utils.js +41 -20
- package/lib/Utils/crypto.js +35 -23
- package/lib/Utils/decode-wa-message.js +43 -15
- package/lib/Utils/generics.js +32 -16
- package/lib/Utils/history.js +3 -0
- package/lib/Utils/index.js +0 -1
- package/lib/Utils/messages-media.js +38 -47
- package/lib/Utils/messages.js +430 -12
- package/lib/Utils/process-message.js +2 -2
- package/lib/Utils/use-multi-file-auth-state.js +17 -3
- package/lib/Utils/validate-connection.js +12 -23
- package/lib/WABinary/decode.js +17 -7
- package/lib/WABinary/encode.js +33 -17
- package/lib/WABinary/generic-utils.js +2 -2
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
- package/lib/WAUSync/Protocols/index.js +20 -0
- package/lib/WAUSync/USyncQuery.js +79 -0
- package/lib/WAUSync/USyncUser.js +22 -0
- package/lib/WAUSync/index.js +19 -0
- package/lib/index.js +4 -1
- package/package.json +15 -10
- package/WAProto/index.d.ts +0 -37016
- package/lib/Defaults/index.d.ts +0 -283
- package/lib/Signal/libsignal.d.ts +0 -3
- package/lib/Socket/Client/abstract-socket-client.d.ts +0 -17
- package/lib/Socket/Client/index.d.ts +0 -3
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/web-socket-client.d.ts +0 -12
- package/lib/Socket/business.d.ts +0 -170
- package/lib/Socket/chats.d.ts +0 -80
- package/lib/Socket/community.d.ts +0 -219
- package/lib/Socket/community.js +0 -354
- package/lib/Socket/groups.d.ts +0 -114
- package/lib/Socket/index.d.ts +0 -172
- package/lib/Socket/messages-recv.d.ts +0 -158
- package/lib/Socket/messages-send.d.ts +0 -147
- package/lib/Socket/newsletter.d.ts +0 -133
- package/lib/Socket/registration.d.ts +0 -267
- package/lib/Socket/socket.d.ts +0 -43
- package/lib/Store/index.d.ts +0 -3
- package/lib/Store/make-cache-manager-store.d.ts +0 -13
- package/lib/Store/make-in-memory-store.d.ts +0 -118
- package/lib/Store/make-ordered-dictionary.d.ts +0 -13
- package/lib/Store/object-repository.d.ts +0 -10
- package/lib/Types/Auth.d.ts +0 -110
- package/lib/Types/Call.d.ts +0 -13
- package/lib/Types/Chat.d.ts +0 -102
- package/lib/Types/Contact.d.ts +0 -19
- package/lib/Types/Events.d.ts +0 -157
- package/lib/Types/GroupMetadata.d.ts +0 -54
- package/lib/Types/Label.d.ts +0 -35
- package/lib/Types/LabelAssociation.d.ts +0 -29
- package/lib/Types/Message.d.ts +0 -273
- package/lib/Types/Newsletter.d.ts +0 -92
- package/lib/Types/Product.d.ts +0 -78
- package/lib/Types/Signal.d.ts +0 -57
- package/lib/Types/Socket.d.ts +0 -111
- package/lib/Types/State.d.ts +0 -27
- package/lib/Types/index.d.ts +0 -57
- package/lib/Utils/auth-utils.d.ts +0 -18
- package/lib/Utils/baileys-event-stream.d.ts +0 -16
- package/lib/Utils/business.d.ts +0 -22
- package/lib/Utils/chat-utils.d.ts +0 -71
- package/lib/Utils/crypto.d.ts +0 -41
- package/lib/Utils/decode-wa-message.d.ts +0 -19
- package/lib/Utils/event-buffer.d.ts +0 -35
- package/lib/Utils/generics.d.ts +0 -97
- package/lib/Utils/history.d.ts +0 -15
- package/lib/Utils/index.d.ts +0 -18
- package/lib/Utils/link-preview.d.ts +0 -21
- package/lib/Utils/logger.d.ts +0 -4
- package/lib/Utils/lt-hash.d.ts +0 -12
- package/lib/Utils/make-mutex.d.ts +0 -7
- package/lib/Utils/messages-media.d.ts +0 -116
- package/lib/Utils/messages.d.ts +0 -77
- package/lib/Utils/noise-handler.d.ts +0 -21
- package/lib/Utils/process-message.d.ts +0 -41
- package/lib/Utils/signal.d.ts +0 -32
- package/lib/Utils/use-multi-file-auth-state.d.ts +0 -12
- package/lib/Utils/use-single-file-auth-statev2.d.ts +0 -12
- package/lib/Utils/use-single-file-auth-statev2.js +0 -75
- package/lib/Utils/validate-connection.d.ts +0 -11
- package/lib/WABinary/constants.d.ts +0 -27
- package/lib/WABinary/decode.d.ts +0 -7
- package/lib/WABinary/encode.d.ts +0 -3
- package/lib/WABinary/generic-utils.d.ts +0 -15
- package/lib/WABinary/index.d.ts +0 -5
- package/lib/WABinary/jid-utils.d.ts +0 -31
- package/lib/WABinary/types.d.ts +0 -18
- package/lib/WAM/BinaryInfo.d.ts +0 -17
- package/lib/WAM/constants.d.ts +0 -38
- package/lib/WAM/encode.d.ts +0 -3
- package/lib/WAM/index.d.ts +0 -3
- package/lib/index.d.ts +0 -11
@@ -10,30 +10,21 @@ const crypto_2 = require("./crypto");
|
|
10
10
|
const generics_1 = require("./generics");
|
11
11
|
const signal_1 = require("./signal");
|
12
12
|
const getUserAgent = (config) => {
|
13
|
-
var _a, _b;
|
14
|
-
const osVersion = config.mobile ? '15.3.1' : '0.1';
|
15
|
-
const version = config.mobile ? [2, 24, 6] : config.version;
|
16
|
-
const device = config.mobile ? 'iPhone_7' : 'Desktop';
|
17
|
-
const manufacturer = config.mobile ? 'Apple' : '';
|
18
|
-
const platform = config.mobile ? WAProto_1.proto.ClientPayload.UserAgent.Platform.IOS : WAProto_1.proto.ClientPayload.UserAgent.Platform.WEB;
|
19
|
-
const phoneId = config.mobile ? { phoneId: config.auth.creds.phoneId } : {};
|
20
13
|
return {
|
21
14
|
appVersion: {
|
22
|
-
primary: version[0],
|
23
|
-
secondary: version[1],
|
24
|
-
tertiary: version[2],
|
15
|
+
primary: config.version[0],
|
16
|
+
secondary: config.version[1],
|
17
|
+
tertiary: config.version[2],
|
25
18
|
},
|
26
|
-
platform,
|
19
|
+
platform: WAProto_1.proto.ClientPayload.UserAgent.Platform.WEB,
|
27
20
|
releaseChannel: WAProto_1.proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
manufacturer,
|
32
|
-
device,
|
33
|
-
osBuildNumber: osVersion,
|
21
|
+
osVersion: '0.1',
|
22
|
+
device: 'Desktop',
|
23
|
+
osBuildNumber: '0.1',
|
34
24
|
localeLanguageIso6391: 'en',
|
35
|
-
|
36
|
-
|
25
|
+
mnc: '000',
|
26
|
+
mcc: '000',
|
27
|
+
localeCountryIso31661Alpha2: config.countryCode,
|
37
28
|
};
|
38
29
|
};
|
39
30
|
const PLATFORM_MAP = {
|
@@ -53,9 +44,7 @@ const getClientPayload = (config) => {
|
|
53
44
|
connectReason: WAProto_1.proto.ClientPayload.ConnectReason.USER_ACTIVATED,
|
54
45
|
userAgent: getUserAgent(config),
|
55
46
|
};
|
56
|
-
|
57
|
-
payload.webInfo = getWebInfo(config);
|
58
|
-
}
|
47
|
+
payload.webInfo = getWebInfo(config);
|
59
48
|
return payload;
|
60
49
|
};
|
61
50
|
const generateMobileNode = (config) => {
|
@@ -72,7 +61,7 @@ const generateMobileNode = (config) => {
|
|
72
61
|
appCached: false,
|
73
62
|
dnsMethod: WAProto_1.proto.ClientPayload.DNSSource.DNSResolutionMethod.SYSTEM,
|
74
63
|
},
|
75
|
-
passive: false,
|
64
|
+
passive: false, // XMPP heartbeat setting (false: server actively pings) (true: client actively pings)
|
76
65
|
pushName: 'test',
|
77
66
|
username: Number(`${config.auth.creds.registration.phoneNumberCountryCode}${config.auth.creds.registration.phoneNumberNationalNumber}`),
|
78
67
|
};
|
package/lib/WABinary/decode.js
CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
15
15
|
}) : function(o, v) {
|
16
16
|
o["default"] = v;
|
17
17
|
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
};
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
36
|
exports.decodeBinaryNode = exports.decodeDecompressedBinaryNode = exports.decompressingIfRequired = void 0;
|
27
37
|
const zlib_1 = require("zlib");
|
package/lib/WABinary/encode.js
CHANGED
@@ -15,18 +15,33 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
15
15
|
}) : function(o, v) {
|
16
16
|
o["default"] = v;
|
17
17
|
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
};
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
36
|
exports.encodeBinaryNode = void 0;
|
27
37
|
const constants = __importStar(require("./constants"));
|
28
38
|
const jid_utils_1 = require("./jid-utils");
|
29
|
-
const encodeBinaryNode = (
|
39
|
+
const encodeBinaryNode = (node, opts = constants, buffer = [0]) => {
|
40
|
+
const encoded = encodeBinaryNodeInner(node, opts, buffer);
|
41
|
+
return Buffer.from(encoded);
|
42
|
+
};
|
43
|
+
exports.encodeBinaryNode = encodeBinaryNode;
|
44
|
+
const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
|
30
45
|
const { TAGS, TOKEN_MAP } = opts;
|
31
46
|
const pushByte = (value) => buffer.push(value & 0xff);
|
32
47
|
const pushInt = (value, n, littleEndian = false) => {
|
@@ -35,7 +50,11 @@ const encodeBinaryNode = ({ tag, attrs, content }, opts = constants, buffer = [0
|
|
35
50
|
buffer.push((value >> (curShift * 8)) & 0xff);
|
36
51
|
}
|
37
52
|
};
|
38
|
-
const pushBytes = (bytes) =>
|
53
|
+
const pushBytes = (bytes) => {
|
54
|
+
for (const b of bytes) {
|
55
|
+
buffer.push(b);
|
56
|
+
}
|
57
|
+
};
|
39
58
|
const pushInt16 = (value) => {
|
40
59
|
pushBytes([(value >> 8) & 0xff, value & 0xff]);
|
41
60
|
};
|
@@ -137,8 +156,7 @@ const encodeBinaryNode = ({ tag, attrs, content }, opts = constants, buffer = [0
|
|
137
156
|
if (str.length > TAGS.PACKED_MAX) {
|
138
157
|
return false;
|
139
158
|
}
|
140
|
-
for (
|
141
|
-
const char = str[i];
|
159
|
+
for (const char of str) {
|
142
160
|
const isInNibbleRange = char >= '0' && char <= '9';
|
143
161
|
if (!isInNibbleRange && char !== '-' && char !== '.') {
|
144
162
|
return false;
|
@@ -150,10 +168,9 @@ const encodeBinaryNode = ({ tag, attrs, content }, opts = constants, buffer = [0
|
|
150
168
|
if (str.length > TAGS.PACKED_MAX) {
|
151
169
|
return false;
|
152
170
|
}
|
153
|
-
for (
|
154
|
-
const char = str[i];
|
171
|
+
for (const char of str) {
|
155
172
|
const isInNibbleRange = char >= '0' && char <= '9';
|
156
|
-
if (!isInNibbleRange && !(char >= 'A' && char <= 'F')
|
173
|
+
if (!isInNibbleRange && !(char >= 'A' && char <= 'F')) {
|
157
174
|
return false;
|
158
175
|
}
|
159
176
|
}
|
@@ -214,7 +231,7 @@ const encodeBinaryNode = ({ tag, attrs, content }, opts = constants, buffer = [0
|
|
214
231
|
else if (Array.isArray(content)) {
|
215
232
|
writeListStart(content.length);
|
216
233
|
for (const item of content) {
|
217
|
-
(
|
234
|
+
encodeBinaryNodeInner(item, opts, buffer);
|
218
235
|
}
|
219
236
|
}
|
220
237
|
else if (typeof content === 'undefined') {
|
@@ -223,6 +240,5 @@ const encodeBinaryNode = ({ tag, attrs, content }, opts = constants, buffer = [0
|
|
223
240
|
else {
|
224
241
|
throw new Error(`invalid children for header "${tag}": ${content} (${typeof content})`);
|
225
242
|
}
|
226
|
-
return
|
243
|
+
return buffer;
|
227
244
|
};
|
228
|
-
exports.encodeBinaryNode = encodeBinaryNode;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.getBinaryNodeMessages = exports.reduceBinaryNodeToDictionary = exports.assertNodeErrorFree = exports.getBinaryNodeChildUInt = exports.getBinaryNodeChildString = exports.getBinaryNodeChildBuffer = exports.getBinaryNodeChild = exports.getAllBinaryNodeChildren = exports.getBinaryNodeChildren = void 0;
|
4
|
+
exports.binaryNodeToString = binaryNodeToString;
|
4
5
|
const boom_1 = require("@hapi/boom");
|
5
6
|
const WAProto_1 = require("../../WAProto");
|
6
7
|
// some extra useful utilities
|
@@ -107,4 +108,3 @@ function binaryNodeToString(node, i = 0) {
|
|
107
108
|
const content = children ? `>\n${children}\n${tabs(i)}</${node.tag}>` : '/>';
|
108
109
|
return tag + content;
|
109
110
|
}
|
110
|
-
exports.binaryNodeToString = binaryNodeToString;
|
@@ -0,0 +1,32 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.USyncContactProtocol = void 0;
|
4
|
+
const WABinary_1 = require("../../WABinary");
|
5
|
+
class USyncContactProtocol {
|
6
|
+
constructor() {
|
7
|
+
this.name = 'contact';
|
8
|
+
}
|
9
|
+
getQueryElement() {
|
10
|
+
return {
|
11
|
+
tag: 'contact',
|
12
|
+
attrs: {},
|
13
|
+
};
|
14
|
+
}
|
15
|
+
getUserElement(user) {
|
16
|
+
//TODO: Implement type / username fields (not yet supported)
|
17
|
+
return {
|
18
|
+
tag: 'contact',
|
19
|
+
attrs: {},
|
20
|
+
content: user.phone,
|
21
|
+
};
|
22
|
+
}
|
23
|
+
parser(node) {
|
24
|
+
var _a;
|
25
|
+
if (node.tag === 'contact') {
|
26
|
+
(0, WABinary_1.assertNodeErrorFree)(node);
|
27
|
+
return ((_a = node === null || node === void 0 ? void 0 : node.attrs) === null || _a === void 0 ? void 0 : _a.type) === 'in';
|
28
|
+
}
|
29
|
+
return false;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
exports.USyncContactProtocol = USyncContactProtocol;
|
@@ -0,0 +1,57 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.USyncDeviceProtocol = void 0;
|
4
|
+
const WABinary_1 = require("../../WABinary");
|
5
|
+
class USyncDeviceProtocol {
|
6
|
+
constructor() {
|
7
|
+
this.name = 'devices';
|
8
|
+
}
|
9
|
+
getQueryElement() {
|
10
|
+
return {
|
11
|
+
tag: 'devices',
|
12
|
+
attrs: {
|
13
|
+
version: '2',
|
14
|
+
},
|
15
|
+
};
|
16
|
+
}
|
17
|
+
getUserElement( /* user: USyncUser */) {
|
18
|
+
//TODO: Implement device phashing, ts and expectedTs
|
19
|
+
//TODO: if all are not present, return null <- current behavior
|
20
|
+
//TODO: otherwise return a node w tag 'devices' w those as attrs
|
21
|
+
return null;
|
22
|
+
}
|
23
|
+
parser(node) {
|
24
|
+
const deviceList = [];
|
25
|
+
let keyIndex = undefined;
|
26
|
+
if (node.tag === 'devices') {
|
27
|
+
(0, WABinary_1.assertNodeErrorFree)(node);
|
28
|
+
const deviceListNode = (0, WABinary_1.getBinaryNodeChild)(node, 'device-list');
|
29
|
+
const keyIndexNode = (0, WABinary_1.getBinaryNodeChild)(node, 'key-index-list');
|
30
|
+
if (Array.isArray(deviceListNode === null || deviceListNode === void 0 ? void 0 : deviceListNode.content)) {
|
31
|
+
for (const { tag, attrs } of deviceListNode.content) {
|
32
|
+
const id = +attrs.id;
|
33
|
+
const keyIndex = +attrs['key-index'];
|
34
|
+
if (tag === 'device') {
|
35
|
+
deviceList.push({
|
36
|
+
id,
|
37
|
+
keyIndex,
|
38
|
+
isHosted: !!(attrs['is_hosted'] && attrs['is_hosted'] === 'true')
|
39
|
+
});
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
if ((keyIndexNode === null || keyIndexNode === void 0 ? void 0 : keyIndexNode.tag) === 'key-index-list') {
|
44
|
+
keyIndex = {
|
45
|
+
timestamp: +keyIndexNode.attrs['ts'],
|
46
|
+
signedKeyIndex: keyIndexNode === null || keyIndexNode === void 0 ? void 0 : keyIndexNode.content,
|
47
|
+
expectedTimestamp: keyIndexNode.attrs['expected_ts'] ? +keyIndexNode.attrs['expected_ts'] : undefined
|
48
|
+
};
|
49
|
+
}
|
50
|
+
}
|
51
|
+
return {
|
52
|
+
deviceList,
|
53
|
+
keyIndex
|
54
|
+
};
|
55
|
+
}
|
56
|
+
}
|
57
|
+
exports.USyncDeviceProtocol = USyncDeviceProtocol;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.USyncDisappearingModeProtocol = void 0;
|
4
|
+
const WABinary_1 = require("../../WABinary");
|
5
|
+
class USyncDisappearingModeProtocol {
|
6
|
+
constructor() {
|
7
|
+
this.name = 'disappearing_mode';
|
8
|
+
}
|
9
|
+
getQueryElement() {
|
10
|
+
return {
|
11
|
+
tag: 'disappearing_mode',
|
12
|
+
attrs: {},
|
13
|
+
};
|
14
|
+
}
|
15
|
+
getUserElement() {
|
16
|
+
return null;
|
17
|
+
}
|
18
|
+
parser(node) {
|
19
|
+
if (node.tag === 'status') {
|
20
|
+
(0, WABinary_1.assertNodeErrorFree)(node);
|
21
|
+
const duration = +(node === null || node === void 0 ? void 0 : node.attrs.duration);
|
22
|
+
const setAt = new Date(+((node === null || node === void 0 ? void 0 : node.attrs.t) || 0) * 1000);
|
23
|
+
return {
|
24
|
+
duration,
|
25
|
+
setAt,
|
26
|
+
};
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
exports.USyncDisappearingModeProtocol = USyncDisappearingModeProtocol;
|
@@ -0,0 +1,42 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.USyncStatusProtocol = void 0;
|
4
|
+
const WABinary_1 = require("../../WABinary");
|
5
|
+
class USyncStatusProtocol {
|
6
|
+
constructor() {
|
7
|
+
this.name = 'status';
|
8
|
+
}
|
9
|
+
getQueryElement() {
|
10
|
+
return {
|
11
|
+
tag: 'status',
|
12
|
+
attrs: {},
|
13
|
+
};
|
14
|
+
}
|
15
|
+
getUserElement() {
|
16
|
+
return null;
|
17
|
+
}
|
18
|
+
parser(node) {
|
19
|
+
var _a;
|
20
|
+
if (node.tag === 'status') {
|
21
|
+
(0, WABinary_1.assertNodeErrorFree)(node);
|
22
|
+
let status = node === null || node === void 0 ? void 0 : node.content.toString();
|
23
|
+
const setAt = new Date(+((node === null || node === void 0 ? void 0 : node.attrs.t) || 0) * 1000);
|
24
|
+
if (!status) {
|
25
|
+
if (+((_a = node.attrs) === null || _a === void 0 ? void 0 : _a.code) === 401) {
|
26
|
+
status = '';
|
27
|
+
}
|
28
|
+
else {
|
29
|
+
status = null;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
else if (typeof status === 'string' && status.length === 0) {
|
33
|
+
status = null;
|
34
|
+
}
|
35
|
+
return {
|
36
|
+
status,
|
37
|
+
setAt,
|
38
|
+
};
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
exports.USyncStatusProtocol = USyncStatusProtocol;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./USyncDeviceProtocol"), exports);
|
18
|
+
__exportStar(require("./USyncContactProtocol"), exports);
|
19
|
+
__exportStar(require("./USyncStatusProtocol"), exports);
|
20
|
+
__exportStar(require("./USyncDisappearingModeProtocol"), exports);
|
@@ -0,0 +1,79 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.USyncQuery = void 0;
|
4
|
+
const WABinary_1 = require("../WABinary");
|
5
|
+
const Protocols_1 = require("./Protocols");
|
6
|
+
class USyncQuery {
|
7
|
+
constructor() {
|
8
|
+
this.protocols = [];
|
9
|
+
this.users = [];
|
10
|
+
this.context = 'interactive';
|
11
|
+
this.mode = 'query';
|
12
|
+
}
|
13
|
+
withMode(mode) {
|
14
|
+
this.mode = mode;
|
15
|
+
return this;
|
16
|
+
}
|
17
|
+
withContext(context) {
|
18
|
+
this.context = context;
|
19
|
+
return this;
|
20
|
+
}
|
21
|
+
withUser(user) {
|
22
|
+
this.users.push(user);
|
23
|
+
return this;
|
24
|
+
}
|
25
|
+
parseUSyncQueryResult(result) {
|
26
|
+
if (result.attrs.type !== 'result') {
|
27
|
+
return;
|
28
|
+
}
|
29
|
+
const protocolMap = Object.fromEntries(this.protocols.map((protocol) => {
|
30
|
+
return [protocol.name, protocol.parser];
|
31
|
+
}));
|
32
|
+
const queryResult = {
|
33
|
+
// TODO: implement errors etc.
|
34
|
+
list: [],
|
35
|
+
sideList: [],
|
36
|
+
};
|
37
|
+
const usyncNode = (0, WABinary_1.getBinaryNodeChild)(result, 'usync');
|
38
|
+
//TODO: implement error backoff, refresh etc.
|
39
|
+
//TODO: see if there are any errors in the result node
|
40
|
+
//const resultNode = getBinaryNodeChild(usyncNode, 'result')
|
41
|
+
const listNode = (0, WABinary_1.getBinaryNodeChild)(usyncNode, 'list');
|
42
|
+
if (Array.isArray(listNode === null || listNode === void 0 ? void 0 : listNode.content) && typeof listNode !== 'undefined') {
|
43
|
+
queryResult.list = listNode.content.map((node) => {
|
44
|
+
const id = node === null || node === void 0 ? void 0 : node.attrs.jid;
|
45
|
+
const data = Array.isArray(node === null || node === void 0 ? void 0 : node.content) ? Object.fromEntries(node.content.map((content) => {
|
46
|
+
const protocol = content.tag;
|
47
|
+
const parser = protocolMap[protocol];
|
48
|
+
if (parser) {
|
49
|
+
return [protocol, parser(content)];
|
50
|
+
}
|
51
|
+
else {
|
52
|
+
return [protocol, null];
|
53
|
+
}
|
54
|
+
}).filter(([, b]) => b !== null)) : {};
|
55
|
+
return { ...data, id };
|
56
|
+
});
|
57
|
+
}
|
58
|
+
//TODO: implement side list
|
59
|
+
//const sideListNode = getBinaryNodeChild(usyncNode, 'side_list')
|
60
|
+
return queryResult;
|
61
|
+
}
|
62
|
+
withDeviceProtocol() {
|
63
|
+
this.protocols.push(new Protocols_1.USyncDeviceProtocol());
|
64
|
+
return this;
|
65
|
+
}
|
66
|
+
withContactProtocol() {
|
67
|
+
this.protocols.push(new Protocols_1.USyncContactProtocol());
|
68
|
+
return this;
|
69
|
+
}
|
70
|
+
withStatusProtocol() {
|
71
|
+
this.protocols.push(new Protocols_1.USyncStatusProtocol());
|
72
|
+
return this;
|
73
|
+
}
|
74
|
+
withDisappearingModeProtocol() {
|
75
|
+
this.protocols.push(new Protocols_1.USyncDisappearingModeProtocol());
|
76
|
+
return this;
|
77
|
+
}
|
78
|
+
}
|
79
|
+
exports.USyncQuery = USyncQuery;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.USyncUser = void 0;
|
4
|
+
class USyncUser {
|
5
|
+
withId(id) {
|
6
|
+
this.id = id;
|
7
|
+
return this;
|
8
|
+
}
|
9
|
+
withLid(lid) {
|
10
|
+
this.lid = lid;
|
11
|
+
return this;
|
12
|
+
}
|
13
|
+
withPhone(phone) {
|
14
|
+
this.phone = phone;
|
15
|
+
return this;
|
16
|
+
}
|
17
|
+
withType(type) {
|
18
|
+
this.type = type;
|
19
|
+
return this;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
exports.USyncUser = USyncUser;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./Protocols"), exports);
|
18
|
+
__exportStar(require("./USyncQuery"), exports);
|
19
|
+
__exportStar(require("./USyncUser"), exports);
|
package/lib/index.js
CHANGED
@@ -17,7 +17,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
18
18
|
};
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
20
|
-
exports.makeWASocket = void 0;
|
20
|
+
exports.proto = exports.makeWASocket = void 0;
|
21
|
+
const WAProto_1 = require("../WAProto");
|
22
|
+
Object.defineProperty(exports, "proto", { enumerable: true, get: function () { return WAProto_1.proto; } });
|
21
23
|
const Socket_1 = __importDefault(require("./Socket"));
|
22
24
|
exports.makeWASocket = Socket_1.default;
|
23
25
|
__exportStar(require("../WAProto"), exports);
|
@@ -27,4 +29,5 @@ __exportStar(require("./Store"), exports);
|
|
27
29
|
__exportStar(require("./Defaults"), exports);
|
28
30
|
__exportStar(require("./WABinary"), exports);
|
29
31
|
__exportStar(require("./WAM"), exports);
|
32
|
+
__exportStar(require("./WAUSync"), exports);
|
30
33
|
exports.default = Socket_1.default;
|
package/package.json
CHANGED
@@ -1,22 +1,29 @@
|
|
1
1
|
{
|
2
2
|
"name": "@jkt48connect-corp/baileys",
|
3
|
-
"version": "7.2.
|
4
|
-
"description": "WhatsApp
|
3
|
+
"version": "7.2.9",
|
4
|
+
"description": "WhatsApp API",
|
5
5
|
"keywords": [
|
6
|
+
"Baileys",
|
7
|
+
"whiskeysockets/baileys",
|
8
|
+
"whatsapp",
|
9
|
+
"meta",
|
10
|
+
"valzyy",
|
11
|
+
"jkt48connect",
|
6
12
|
"whatsapp",
|
7
13
|
"js-whatsapp",
|
8
14
|
"whatsapp-api",
|
9
15
|
"whatsapp-web",
|
16
|
+
"whatsapp-chat",
|
17
|
+
"whatsapp-group",
|
18
|
+
"automation",
|
10
19
|
"multi-device",
|
11
|
-
"
|
12
|
-
"indraa"
|
20
|
+
"modder"
|
13
21
|
],
|
14
|
-
"homepage": "https://github.com/WhiskeySockets/Baileys",
|
15
22
|
"repository": {
|
16
|
-
"url": "
|
23
|
+
"url": ""
|
17
24
|
},
|
18
25
|
"license": "MIT",
|
19
|
-
"author": "
|
26
|
+
"author": "jkt48connect-corp",
|
20
27
|
"main": "lib/index.js",
|
21
28
|
"types": "lib/index.d.ts",
|
22
29
|
"files": [
|
@@ -36,14 +43,13 @@
|
|
36
43
|
"gen:protobuf": "sh WAProto/GenerateStatics.sh",
|
37
44
|
"lint": "eslint src --ext .js,.ts,.jsx,.tsx",
|
38
45
|
"lint:fix": "eslint src --fix --ext .js,.ts,.jsx,.tsx",
|
39
|
-
"prepack": "tsc",
|
40
|
-
"prepare": "tsc",
|
41
46
|
"release": "release-it",
|
42
47
|
"test": "jest"
|
43
48
|
},
|
44
49
|
"dependencies": {
|
45
50
|
"@adiwajshing/keyed-db": "^0.2.4",
|
46
51
|
"@hapi/boom": "^9.1.3",
|
52
|
+
"async-lock": "^1.4.1",
|
47
53
|
"audio-decode": "^2.1.3",
|
48
54
|
"axios": "^1.3.3",
|
49
55
|
"cache-manager": "4.0.1",
|
@@ -59,7 +65,6 @@
|
|
59
65
|
},
|
60
66
|
"devDependencies": {
|
61
67
|
"@adiwajshing/eslint-config": "github:adiwajshing/eslint-config",
|
62
|
-
"@jkt48connect/cli": "^3.0.12",
|
63
68
|
"@types/got": "^9.6.11",
|
64
69
|
"@types/jest": "^27.5.1",
|
65
70
|
"@types/node": "^16.0.0",
|