@jkt48connect-corp/baileys 7.3.2 → 7.3.4
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/README.md +459 -143
- package/WAProto/WAProto.proto +227 -2
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +9 -7
- package/lib/Defaults/index.js +6 -4
- package/lib/Socket/Client/index.d.ts +2 -3
- package/lib/Socket/Client/index.js +2 -3
- package/lib/Socket/Client/types.d.ts +17 -0
- package/lib/Socket/Client/types.js +13 -0
- package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +1 -1
- package/lib/Socket/Client/{web-socket-client.js → websocket.js} +2 -2
- package/lib/Socket/business.d.ts +8 -3
- package/lib/Socket/chats.d.ts +21 -19
- package/lib/Socket/chats.js +51 -48
- package/lib/Socket/groups.d.ts +28 -26
- package/lib/Socket/groups.js +2 -1
- package/lib/Socket/index.d.ts +6 -3
- package/lib/Socket/messages-recv.d.ts +8 -3
- package/lib/Socket/messages-recv.js +308 -149
- package/lib/Socket/messages-send.d.ts +23 -26
- package/lib/Socket/messages-send.js +193 -166
- package/lib/Socket/newsletter.d.ts +2 -2
- package/lib/Socket/newsletter.js +3 -3
- package/lib/Socket/registration.d.ts +8 -3
- package/lib/Socket/socket.d.ts +8 -6
- package/lib/Socket/socket.js +19 -14
- package/lib/Socket/usync.d.ts +37 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Store/make-cache-manager-store.d.ts +2 -2
- package/lib/Store/make-ordered-dictionary.d.ts +1 -1
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +12 -7
- package/lib/Types/Events.d.ts +17 -2
- package/lib/Types/GroupMetadata.d.ts +3 -1
- package/lib/Types/Label.d.ts +11 -0
- package/lib/Types/Message.d.ts +324 -328
- package/lib/Types/Socket.d.ts +7 -0
- package/lib/Types/USync.d.ts +25 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/index.d.ts +9 -0
- package/lib/Utils/chat-utils.d.ts +4 -4
- package/lib/Utils/chat-utils.js +41 -20
- package/lib/Utils/crypto.d.ts +1 -1
- package/lib/Utils/crypto.js +4 -2
- package/lib/Utils/decode-wa-message.d.ts +17 -0
- package/lib/Utils/decode-wa-message.js +42 -14
- package/lib/Utils/generics.d.ts +4 -10
- package/lib/Utils/generics.js +30 -14
- package/lib/Utils/history.d.ts +6 -2
- package/lib/Utils/history.js +3 -0
- package/lib/Utils/messages.d.ts +0 -1
- package/lib/Utils/messages.js +247 -39
- package/lib/Utils/signal.d.ts +2 -1
- package/lib/Utils/signal.js +11 -19
- package/lib/Utils/use-multi-file-auth-state.js +11 -3
- package/lib/Utils/validate-connection.d.ts +2 -2
- package/lib/Utils/validate-connection.js +1 -1
- package/lib/WABinary/encode.d.ts +1 -1
- package/lib/WABinary/encode.js +16 -10
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
- package/lib/WAUSync/Protocols/index.d.ts +4 -0
- package/lib/WAUSync/Protocols/index.js +20 -0
- package/lib/WAUSync/USyncQuery.d.ts +26 -0
- package/lib/WAUSync/USyncQuery.js +79 -0
- package/lib/WAUSync/USyncUser.d.ts +10 -0
- package/lib/WAUSync/USyncUser.js +22 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/WAUSync/index.js +19 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/package.json +23 -18
- package/LICENSE +0 -21
- package/lib/index.ts +0 -13
package/lib/WABinary/encode.js
CHANGED
@@ -36,7 +36,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.encodeBinaryNode = void 0;
|
37
37
|
const constants = __importStar(require("./constants"));
|
38
38
|
const jid_utils_1 = require("./jid-utils");
|
39
|
-
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) => {
|
40
45
|
const { TAGS, TOKEN_MAP } = opts;
|
41
46
|
const pushByte = (value) => buffer.push(value & 0xff);
|
42
47
|
const pushInt = (value, n, littleEndian = false) => {
|
@@ -45,7 +50,11 @@ const encodeBinaryNode = ({ tag, attrs, content }, opts = constants, buffer = [0
|
|
45
50
|
buffer.push((value >> (curShift * 8)) & 0xff);
|
46
51
|
}
|
47
52
|
};
|
48
|
-
const pushBytes = (bytes) =>
|
53
|
+
const pushBytes = (bytes) => {
|
54
|
+
for (const b of bytes) {
|
55
|
+
buffer.push(b);
|
56
|
+
}
|
57
|
+
};
|
49
58
|
const pushInt16 = (value) => {
|
50
59
|
pushBytes([(value >> 8) & 0xff, value & 0xff]);
|
51
60
|
};
|
@@ -147,8 +156,7 @@ const encodeBinaryNode = ({ tag, attrs, content }, opts = constants, buffer = [0
|
|
147
156
|
if (str.length > TAGS.PACKED_MAX) {
|
148
157
|
return false;
|
149
158
|
}
|
150
|
-
for (
|
151
|
-
const char = str[i];
|
159
|
+
for (const char of str) {
|
152
160
|
const isInNibbleRange = char >= '0' && char <= '9';
|
153
161
|
if (!isInNibbleRange && char !== '-' && char !== '.') {
|
154
162
|
return false;
|
@@ -160,10 +168,9 @@ const encodeBinaryNode = ({ tag, attrs, content }, opts = constants, buffer = [0
|
|
160
168
|
if (str.length > TAGS.PACKED_MAX) {
|
161
169
|
return false;
|
162
170
|
}
|
163
|
-
for (
|
164
|
-
const char = str[i];
|
171
|
+
for (const char of str) {
|
165
172
|
const isInNibbleRange = char >= '0' && char <= '9';
|
166
|
-
if (!isInNibbleRange && !(char >= 'A' && char <= 'F')
|
173
|
+
if (!isInNibbleRange && !(char >= 'A' && char <= 'F')) {
|
167
174
|
return false;
|
168
175
|
}
|
169
176
|
}
|
@@ -224,7 +231,7 @@ const encodeBinaryNode = ({ tag, attrs, content }, opts = constants, buffer = [0
|
|
224
231
|
else if (Array.isArray(content)) {
|
225
232
|
writeListStart(content.length);
|
226
233
|
for (const item of content) {
|
227
|
-
(
|
234
|
+
encodeBinaryNodeInner(item, opts, buffer);
|
228
235
|
}
|
229
236
|
}
|
230
237
|
else if (typeof content === 'undefined') {
|
@@ -233,6 +240,5 @@ const encodeBinaryNode = ({ tag, attrs, content }, opts = constants, buffer = [0
|
|
233
240
|
else {
|
234
241
|
throw new Error(`invalid children for header "${tag}": ${content} (${typeof content})`);
|
235
242
|
}
|
236
|
-
return
|
243
|
+
return buffer;
|
237
244
|
};
|
238
|
-
exports.encodeBinaryNode = encodeBinaryNode;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { USyncQueryProtocol } from '../../Types/USync';
|
2
|
+
import { BinaryNode } from '../../WABinary';
|
3
|
+
import { USyncUser } from '../USyncUser';
|
4
|
+
export declare class USyncContactProtocol implements USyncQueryProtocol {
|
5
|
+
name: string;
|
6
|
+
getQueryElement(): BinaryNode;
|
7
|
+
getUserElement(user: USyncUser): BinaryNode;
|
8
|
+
parser(node: BinaryNode): boolean;
|
9
|
+
}
|
@@ -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,22 @@
|
|
1
|
+
import { USyncQueryProtocol } from '../../Types/USync';
|
2
|
+
import { BinaryNode } from '../../WABinary';
|
3
|
+
export type KeyIndexData = {
|
4
|
+
timestamp: number;
|
5
|
+
signedKeyIndex?: Uint8Array;
|
6
|
+
expectedTimestamp?: number;
|
7
|
+
};
|
8
|
+
export type DeviceListData = {
|
9
|
+
id: number;
|
10
|
+
keyIndex?: number;
|
11
|
+
isHosted?: boolean;
|
12
|
+
};
|
13
|
+
export type ParsedDeviceInfo = {
|
14
|
+
deviceList?: DeviceListData[];
|
15
|
+
keyIndex?: KeyIndexData;
|
16
|
+
};
|
17
|
+
export declare class USyncDeviceProtocol implements USyncQueryProtocol {
|
18
|
+
name: string;
|
19
|
+
getQueryElement(): BinaryNode;
|
20
|
+
getUserElement(): BinaryNode | null;
|
21
|
+
parser(node: BinaryNode): ParsedDeviceInfo;
|
22
|
+
}
|
@@ -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,12 @@
|
|
1
|
+
import { USyncQueryProtocol } from '../../Types/USync';
|
2
|
+
import { BinaryNode } from '../../WABinary';
|
3
|
+
export type DisappearingModeData = {
|
4
|
+
duration: number;
|
5
|
+
setAt?: Date;
|
6
|
+
};
|
7
|
+
export declare class USyncDisappearingModeProtocol implements USyncQueryProtocol {
|
8
|
+
name: string;
|
9
|
+
getQueryElement(): BinaryNode;
|
10
|
+
getUserElement(): null;
|
11
|
+
parser(node: BinaryNode): DisappearingModeData | undefined;
|
12
|
+
}
|
@@ -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,12 @@
|
|
1
|
+
import { USyncQueryProtocol } from '../../Types/USync';
|
2
|
+
import { BinaryNode } from '../../WABinary';
|
3
|
+
export type StatusData = {
|
4
|
+
status?: string | null;
|
5
|
+
setAt?: Date;
|
6
|
+
};
|
7
|
+
export declare class USyncStatusProtocol implements USyncQueryProtocol {
|
8
|
+
name: string;
|
9
|
+
getQueryElement(): BinaryNode;
|
10
|
+
getUserElement(): null;
|
11
|
+
parser(node: BinaryNode): StatusData | undefined;
|
12
|
+
}
|
@@ -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,26 @@
|
|
1
|
+
import { USyncQueryProtocol } from '../Types/USync';
|
2
|
+
import { BinaryNode } from '../WABinary';
|
3
|
+
import { USyncUser } from './USyncUser';
|
4
|
+
export type USyncQueryResultList = {
|
5
|
+
[protocol: string]: unknown;
|
6
|
+
id: string;
|
7
|
+
};
|
8
|
+
export type USyncQueryResult = {
|
9
|
+
list: USyncQueryResultList[];
|
10
|
+
sideList: USyncQueryResultList[];
|
11
|
+
};
|
12
|
+
export declare class USyncQuery {
|
13
|
+
protocols: USyncQueryProtocol[];
|
14
|
+
users: USyncUser[];
|
15
|
+
context: string;
|
16
|
+
mode: string;
|
17
|
+
constructor();
|
18
|
+
withMode(mode: string): this;
|
19
|
+
withContext(context: string): this;
|
20
|
+
withUser(user: USyncUser): this;
|
21
|
+
parseUSyncQueryResult(result: BinaryNode): USyncQueryResult | undefined;
|
22
|
+
withDeviceProtocol(): this;
|
23
|
+
withContactProtocol(): this;
|
24
|
+
withStatusProtocol(): this;
|
25
|
+
withDisappearingModeProtocol(): this;
|
26
|
+
}
|
@@ -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.d.ts
CHANGED
package/lib/index.js
CHANGED
@@ -27,4 +27,5 @@ __exportStar(require("./Store"), exports);
|
|
27
27
|
__exportStar(require("./Defaults"), exports);
|
28
28
|
__exportStar(require("./WABinary"), exports);
|
29
29
|
__exportStar(require("./WAM"), exports);
|
30
|
+
__exportStar(require("./WAUSync"), exports);
|
30
31
|
exports.default = Socket_1.default;
|
package/package.json
CHANGED
@@ -1,30 +1,22 @@
|
|
1
1
|
{
|
2
2
|
"name": "@jkt48connect-corp/baileys",
|
3
|
-
"version": "7.3.
|
3
|
+
"version": "7.3.4",
|
4
4
|
"description": "WhatsApp API",
|
5
5
|
"keywords": [
|
6
|
-
"Baileys",
|
7
|
-
"whiskeysockets/baileys",
|
8
|
-
"whatsapp",
|
9
|
-
"meta",
|
10
|
-
"valzyy",
|
11
|
-
"jkt48connect",
|
12
6
|
"whatsapp",
|
13
7
|
"js-whatsapp",
|
14
8
|
"whatsapp-api",
|
15
9
|
"whatsapp-web",
|
16
|
-
"whatsapp-chat",
|
17
|
-
"whatsapp-group",
|
18
|
-
"automation",
|
19
10
|
"multi-device",
|
20
|
-
"
|
11
|
+
"newsletter",
|
12
|
+
"whatsapp-bot"
|
21
13
|
],
|
22
|
-
"homepage": "https://
|
14
|
+
"homepage": "https://github.com/J-Forces/Baileyss",
|
23
15
|
"repository": {
|
24
|
-
"url": ""
|
16
|
+
"url": "git+ssh://git@github.com/J-Forces/Baileyss.git"
|
25
17
|
},
|
26
18
|
"license": "MIT",
|
27
|
-
"author": "
|
19
|
+
"author": "Adhiraj Singh",
|
28
20
|
"main": "lib/index.js",
|
29
21
|
"types": "lib/index.d.ts",
|
30
22
|
"files": [
|
@@ -33,6 +25,20 @@
|
|
33
25
|
"WASignalGroup/*.js"
|
34
26
|
],
|
35
27
|
"scripts": {
|
28
|
+
"build:all": "tsc && typedoc",
|
29
|
+
"build:docs": "typedoc",
|
30
|
+
"build:tsc": "tsc",
|
31
|
+
"changelog:last": "conventional-changelog -p angular -r 2",
|
32
|
+
"changelog:preview": "conventional-changelog -p angular -u",
|
33
|
+
"changelog:update": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
|
34
|
+
"example": "node --inspect -r ts-node/register Example/example.ts",
|
35
|
+
"example:mobile": "node --inspect -r ts-node/register Example/example.ts --mobile",
|
36
|
+
"gen:protobuf": "sh WAProto/GenerateStatics.sh",
|
37
|
+
"lint": "eslint src --ext .js,.ts,.jsx,.tsx",
|
38
|
+
"lint:fix": "eslint src --fix --ext .js,.ts,.jsx,.tsx",
|
39
|
+
"prepack": "tsc",
|
40
|
+
"prepare": "tsc",
|
41
|
+
"release": "release-it",
|
36
42
|
"test": "jest"
|
37
43
|
},
|
38
44
|
"dependencies": {
|
@@ -41,11 +47,10 @@
|
|
41
47
|
"async-lock": "^1.4.1",
|
42
48
|
"audio-decode": "^2.1.3",
|
43
49
|
"axios": "^1.6.0",
|
44
|
-
"child_process": "^1.0.2",
|
45
50
|
"cache-manager": "4.0.1",
|
46
51
|
"futoin-hkdf": "^1.5.1",
|
47
52
|
"libphonenumber-js": "^1.10.20",
|
48
|
-
"libsignal": "
|
53
|
+
"libsignal": "github:nstar-y/libsignal",
|
49
54
|
"lodash": "^4.17.21",
|
50
55
|
"music-metadata": "^7.12.3",
|
51
56
|
"node-cache": "^5.1.2",
|
@@ -55,7 +60,7 @@
|
|
55
60
|
"ws": "^8.13.0"
|
56
61
|
},
|
57
62
|
"devDependencies": {
|
58
|
-
"@adiwajshing/eslint-config": "
|
63
|
+
"@adiwajshing/eslint-config": "github:adiwajshing/eslint-config",
|
59
64
|
"@types/got": "^9.6.11",
|
60
65
|
"@types/jest": "^27.5.1",
|
61
66
|
"@types/node": "^16.0.0",
|
@@ -78,7 +83,7 @@
|
|
78
83
|
},
|
79
84
|
"peerDependencies": {
|
80
85
|
"jimp": "^0.16.1",
|
81
|
-
"link-preview-js": "^3.0.
|
86
|
+
"link-preview-js": "^3.0.0",
|
82
87
|
"qrcode-terminal": "^0.12.0",
|
83
88
|
"sharp": "^0.32.6"
|
84
89
|
},
|
package/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2024 Meta Platforms, Inc.
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
package/lib/index.ts
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
import makeWASocket from './Socket'
|
2
|
-
|
3
|
-
export * from '../WAProto'
|
4
|
-
export * from './Utils'
|
5
|
-
export * from './Types'
|
6
|
-
export * from './Store'
|
7
|
-
export * from './Defaults'
|
8
|
-
export * from './WABinary'
|
9
|
-
export * from './WAM'
|
10
|
-
|
11
|
-
export type WASocket = ReturnType<typeof makeWASocket>
|
12
|
-
export { makeWASocket }
|
13
|
-
export default makeWASocket
|