@d0v3riz/baileys 6.7.9 → 6.7.12

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.
Files changed (46) hide show
  1. package/README.md +1022 -635
  2. package/lib/Defaults/baileys-version.json +1 -1
  3. package/lib/Defaults/index.js +1 -0
  4. package/lib/Socket/business.d.ts +6 -7
  5. package/lib/Socket/chats.d.ts +6 -6
  6. package/lib/Socket/chats.js +34 -68
  7. package/lib/Socket/groups.d.ts +5 -6
  8. package/lib/Socket/index.d.ts +6 -7
  9. package/lib/Socket/messages-recv.d.ts +6 -7
  10. package/lib/Socket/messages-recv.js +72 -23
  11. package/lib/Socket/messages-send.d.ts +6 -6
  12. package/lib/Socket/messages-send.js +32 -51
  13. package/lib/Socket/socket.js +8 -0
  14. package/lib/Socket/usync.d.ts +38 -0
  15. package/lib/Socket/usync.js +70 -0
  16. package/lib/Types/Socket.d.ts +2 -0
  17. package/lib/Types/USync.d.ts +25 -0
  18. package/lib/Types/USync.js +2 -0
  19. package/lib/Utils/decode-wa-message.d.ts +16 -0
  20. package/lib/Utils/decode-wa-message.js +17 -1
  21. package/lib/Utils/messages.js +8 -6
  22. package/lib/Utils/process-message.js +16 -0
  23. package/lib/Utils/signal.d.ts +2 -1
  24. package/lib/Utils/signal.js +11 -21
  25. package/lib/Utils/validate-connection.js +6 -2
  26. package/lib/WABinary/encode.js +1 -1
  27. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
  28. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  29. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
  30. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  31. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  32. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  33. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  34. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  35. package/lib/WAUSync/Protocols/index.d.ts +4 -0
  36. package/lib/WAUSync/Protocols/index.js +20 -0
  37. package/lib/WAUSync/USyncQuery.d.ts +26 -0
  38. package/lib/WAUSync/USyncQuery.js +79 -0
  39. package/lib/WAUSync/USyncUser.d.ts +10 -0
  40. package/lib/WAUSync/USyncUser.js +22 -0
  41. package/lib/WAUSync/index.d.ts +3 -0
  42. package/lib/WAUSync/index.js +19 -0
  43. package/lib/index.d.ts +1 -0
  44. package/lib/index.js +1 -0
  45. package/package.json +1 -1
  46. package/WASignalGroup/readme.md +0 -6
@@ -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,10 @@
1
+ export declare class USyncUser {
2
+ id: string;
3
+ lid: string;
4
+ phone: string;
5
+ type: string;
6
+ withId(id: string): this;
7
+ withLid(lid: string): this;
8
+ withPhone(phone: string): this;
9
+ withType(type: string): this;
10
+ }
@@ -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,3 @@
1
+ export * from './Protocols';
2
+ export * from './USyncQuery';
3
+ export * from './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
@@ -6,6 +6,7 @@ export * from './Store';
6
6
  export * from './Defaults';
7
7
  export * from './WABinary';
8
8
  export * from './WAM';
9
+ export * from './WAUSync';
9
10
  export type WASocket = ReturnType<typeof makeWASocket>;
10
11
  export { makeWASocket };
11
12
  export default makeWASocket;
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@d0v3riz/baileys",
3
- "version": "6.7.9",
3
+ "version": "6.7.12",
4
4
  "description": "WhatsApp API",
5
5
  "keywords": [
6
6
  "whatsapp",
@@ -1,6 +0,0 @@
1
- # Signal-Group
2
-
3
- This contains the code to decrypt/encrypt WA group messages.
4
- Originally from [pokearaujo/libsignal-node](https://github.com/pokearaujo/libsignal-node)
5
-
6
- The code has been moved outside the signal package as I felt it didn't belong in ths signal package, as it isn't inherently a part of signal but of WA.