@sgintokic/baileys 0.0.2

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.

Potentially problematic release.


This version of @sgintokic/baileys might be problematic. Click here for more details.

Files changed (106) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +1097 -0
  3. package/WAProto/index.js +2 -0
  4. package/engine-requirements.js +1 -0
  5. package/lib/Defaults/index.js +155 -0
  6. package/lib/Signal/Group/ciphertext-message.js +11 -0
  7. package/lib/Signal/Group/group-session-builder.js +41 -0
  8. package/lib/Signal/Group/group_cipher.js +108 -0
  9. package/lib/Signal/Group/index.js +11 -0
  10. package/lib/Signal/Group/keyhelper.js +14 -0
  11. package/lib/Signal/Group/sender-chain-key.js +31 -0
  12. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  13. package/lib/Signal/Group/sender-key-message.js +79 -0
  14. package/lib/Signal/Group/sender-key-name.js +49 -0
  15. package/lib/Signal/Group/sender-key-record.js +46 -0
  16. package/lib/Signal/Group/sender-key-state.js +104 -0
  17. package/lib/Signal/Group/sender-message-key.js +29 -0
  18. package/lib/Signal/libsignal.js +485 -0
  19. package/lib/Signal/lid-mapping.js +291 -0
  20. package/lib/Socket/Client/index.js +2 -0
  21. package/lib/Socket/Client/types.js +10 -0
  22. package/lib/Socket/Client/websocket.js +64 -0
  23. package/lib/Socket/business.js +293 -0
  24. package/lib/Socket/chats.js +1068 -0
  25. package/lib/Socket/communities.js +476 -0
  26. package/lib/Socket/groups.js +383 -0
  27. package/lib/Socket/index.js +8 -0
  28. package/lib/Socket/messages-recv.js +1830 -0
  29. package/lib/Socket/messages-send.js +1462 -0
  30. package/lib/Socket/mex.js +55 -0
  31. package/lib/Socket/newsletter.js +277 -0
  32. package/lib/Socket/socket.js +1087 -0
  33. package/lib/Store/index.js +3 -0
  34. package/lib/Store/make-in-memory-store.js +517 -0
  35. package/lib/Store/make-ordered-dictionary.js +75 -0
  36. package/lib/Store/object-repository.js +23 -0
  37. package/lib/Types/Auth.js +1 -0
  38. package/lib/Types/Bussines.js +1 -0
  39. package/lib/Types/Call.js +1 -0
  40. package/lib/Types/Chat.js +7 -0
  41. package/lib/Types/Contact.js +1 -0
  42. package/lib/Types/Events.js +1 -0
  43. package/lib/Types/GroupMetadata.js +1 -0
  44. package/lib/Types/Label.js +24 -0
  45. package/lib/Types/LabelAssociation.js +6 -0
  46. package/lib/Types/Message.js +18 -0
  47. package/lib/Types/Newsletter.js +33 -0
  48. package/lib/Types/Product.js +1 -0
  49. package/lib/Types/Signal.js +1 -0
  50. package/lib/Types/Socket.js +2 -0
  51. package/lib/Types/State.js +15 -0
  52. package/lib/Types/USync.js +1 -0
  53. package/lib/Types/index.js +31 -0
  54. package/lib/Utils/auth-utils.js +293 -0
  55. package/lib/Utils/browser-utils.js +32 -0
  56. package/lib/Utils/business.js +245 -0
  57. package/lib/Utils/chat-utils.js +959 -0
  58. package/lib/Utils/crypto.js +133 -0
  59. package/lib/Utils/decode-wa-message.js +376 -0
  60. package/lib/Utils/event-buffer.js +620 -0
  61. package/lib/Utils/generics.js +417 -0
  62. package/lib/Utils/history.js +150 -0
  63. package/lib/Utils/identity-change-handler.js +63 -0
  64. package/lib/Utils/index.js +21 -0
  65. package/lib/Utils/link-preview.js +91 -0
  66. package/lib/Utils/logger.js +2 -0
  67. package/lib/Utils/lt-hash.js +6 -0
  68. package/lib/Utils/make-mutex.js +31 -0
  69. package/lib/Utils/message-retry-manager.js +240 -0
  70. package/lib/Utils/messages-media.js +901 -0
  71. package/lib/Utils/messages.js +2052 -0
  72. package/lib/Utils/noise-handler.js +229 -0
  73. package/lib/Utils/offline-node-processor.js +50 -0
  74. package/lib/Utils/pre-key-manager.js +119 -0
  75. package/lib/Utils/process-message.js +641 -0
  76. package/lib/Utils/reporting-utils.js +346 -0
  77. package/lib/Utils/signal.js +188 -0
  78. package/lib/Utils/stanza-ack.js +33 -0
  79. package/lib/Utils/sync-action-utils.js +53 -0
  80. package/lib/Utils/tc-token-utils.js +15 -0
  81. package/lib/Utils/use-multi-file-auth-state.js +116 -0
  82. package/lib/Utils/use-single-file-auth-state.js +94 -0
  83. package/lib/Utils/validate-connection.js +235 -0
  84. package/lib/WABinary/constants.js +1300 -0
  85. package/lib/WABinary/decode.js +258 -0
  86. package/lib/WABinary/encode.js +219 -0
  87. package/lib/WABinary/generic-utils.js +203 -0
  88. package/lib/WABinary/index.js +5 -0
  89. package/lib/WABinary/jid-utils.js +93 -0
  90. package/lib/WABinary/types.js +1 -0
  91. package/lib/WAM/BinaryInfo.js +9 -0
  92. package/lib/WAM/constants.js +20669 -0
  93. package/lib/WAM/encode.js +151 -0
  94. package/lib/WAM/index.js +3 -0
  95. package/lib/WAUSync/Protocols/USyncContactProtocol.js +21 -0
  96. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +50 -0
  97. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +20 -0
  98. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +29 -0
  99. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +59 -0
  100. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +21 -0
  101. package/lib/WAUSync/Protocols/index.js +4 -0
  102. package/lib/WAUSync/USyncQuery.js +103 -0
  103. package/lib/WAUSync/USyncUser.js +22 -0
  104. package/lib/WAUSync/index.js +3 -0
  105. package/lib/index.js +11 -0
  106. package/package.json +58 -0
@@ -0,0 +1,151 @@
1
+ import { BinaryInfo } from "./BinaryInfo.js";
2
+ import {
3
+ FLAG_BYTE,
4
+ FLAG_EVENT,
5
+ FLAG_EXTENDED,
6
+ FLAG_FIELD,
7
+ FLAG_GLOBAL,
8
+ WEB_EVENTS,
9
+ WEB_GLOBALS,
10
+ } from "./constants.js";
11
+ const getHeaderBitLength = (key) => (key < 256 ? 2 : 3);
12
+ export const encodeWAM = (binaryInfo) => {
13
+ binaryInfo.buffer = [];
14
+ encodeWAMHeader(binaryInfo);
15
+ encodeEvents(binaryInfo);
16
+ const totalSize = binaryInfo.buffer
17
+ .map((a) => a.length)
18
+ .reduce((a, b) => a + b);
19
+ const buffer = Buffer.alloc(totalSize);
20
+ let offset = 0;
21
+ for (const buffer_ of binaryInfo.buffer) {
22
+ buffer_.copy(buffer, offset);
23
+ offset += buffer_.length;
24
+ }
25
+ return buffer;
26
+ };
27
+ function encodeWAMHeader(binaryInfo) {
28
+ const headerBuffer = Buffer.alloc(8); // starting buffer
29
+ headerBuffer.write("WAM", 0, "utf8");
30
+ headerBuffer.writeUInt8(binaryInfo.protocolVersion, 3);
31
+ headerBuffer.writeUInt8(1, 4); //random flag
32
+ headerBuffer.writeUInt16BE(binaryInfo.sequence, 5);
33
+ headerBuffer.writeUInt8(0, 7); // regular channel
34
+ binaryInfo.buffer.push(headerBuffer);
35
+ }
36
+ function encodeGlobalAttributes(binaryInfo, globals) {
37
+ for (const [key, _value] of Object.entries(globals)) {
38
+ const id = WEB_GLOBALS.find((a) => a?.name === key).id;
39
+ let value = _value;
40
+ if (typeof value === "boolean") {
41
+ value = value ? 1 : 0;
42
+ }
43
+ binaryInfo.buffer.push(serializeData(id, value, FLAG_GLOBAL));
44
+ }
45
+ }
46
+ function encodeEvents(binaryInfo) {
47
+ for (const [name, { props, globals }] of binaryInfo.events.map(
48
+ (a) => Object.entries(a)[0],
49
+ )) {
50
+ encodeGlobalAttributes(binaryInfo, globals);
51
+ const event = WEB_EVENTS.find((a) => a.name === name);
52
+ const props_ = Object.entries(props);
53
+ let extended = false;
54
+ for (const [, value] of props_) {
55
+ extended || (extended = value !== null);
56
+ }
57
+ const eventFlag = extended ? FLAG_EVENT : FLAG_EVENT | FLAG_EXTENDED;
58
+ binaryInfo.buffer.push(serializeData(event.id, -event.weight, eventFlag));
59
+ for (let i = 0; i < props_.length; i++) {
60
+ const [key, _value] = props_[i];
61
+ const id = event.props[key]?.[0];
62
+ extended = i < props_.length - 1;
63
+ let value = _value;
64
+ if (typeof value === "boolean") {
65
+ value = value ? 1 : 0;
66
+ }
67
+ const fieldFlag = extended ? FLAG_EVENT : FLAG_FIELD | FLAG_EXTENDED;
68
+ binaryInfo.buffer.push(serializeData(id, value, fieldFlag));
69
+ }
70
+ }
71
+ }
72
+ function serializeData(key, value, flag) {
73
+ const bufferLength = getHeaderBitLength(key);
74
+ let buffer;
75
+ let offset = 0;
76
+ if (value === null) {
77
+ if (flag === FLAG_GLOBAL) {
78
+ buffer = Buffer.alloc(bufferLength);
79
+ offset = serializeHeader(buffer, offset, key, flag);
80
+ return buffer;
81
+ }
82
+ } else if (typeof value === "number" && Number.isInteger(value)) {
83
+ // is number
84
+ if (value === 0 || value === 1) {
85
+ buffer = Buffer.alloc(bufferLength);
86
+ offset = serializeHeader(buffer, offset, key, flag | ((value + 1) << 4));
87
+ return buffer;
88
+ } else if (-128 <= value && value < 128) {
89
+ buffer = Buffer.alloc(bufferLength + 1);
90
+ offset = serializeHeader(buffer, offset, key, flag | (3 << 4));
91
+ buffer.writeInt8(value, offset);
92
+ return buffer;
93
+ } else if (-32768 <= value && value < 32768) {
94
+ buffer = Buffer.alloc(bufferLength + 2);
95
+ offset = serializeHeader(buffer, offset, key, flag | (4 << 4));
96
+ buffer.writeInt16LE(value, offset);
97
+ return buffer;
98
+ } else if (-2147483648 <= value && value < 2147483648) {
99
+ buffer = Buffer.alloc(bufferLength + 4);
100
+ offset = serializeHeader(buffer, offset, key, flag | (5 << 4));
101
+ buffer.writeInt32LE(value, offset);
102
+ return buffer;
103
+ } else {
104
+ buffer = Buffer.alloc(bufferLength + 8);
105
+ offset = serializeHeader(buffer, offset, key, flag | (7 << 4));
106
+ buffer.writeDoubleLE(value, offset);
107
+ return buffer;
108
+ }
109
+ } else if (typeof value === "number") {
110
+ // is float
111
+ buffer = Buffer.alloc(bufferLength + 8);
112
+ offset = serializeHeader(buffer, offset, key, flag | (7 << 4));
113
+ buffer.writeDoubleLE(value, offset);
114
+ return buffer;
115
+ } else if (typeof value === "string") {
116
+ // is string
117
+ const utf8Bytes = Buffer.byteLength(value, "utf8");
118
+ if (utf8Bytes < 256) {
119
+ buffer = Buffer.alloc(bufferLength + 1 + utf8Bytes);
120
+ offset = serializeHeader(buffer, offset, key, flag | (8 << 4));
121
+ buffer.writeUint8(utf8Bytes, offset++);
122
+ } else if (utf8Bytes < 65536) {
123
+ buffer = Buffer.alloc(bufferLength + 2 + utf8Bytes);
124
+ offset = serializeHeader(buffer, offset, key, flag | (9 << 4));
125
+ buffer.writeUInt16LE(utf8Bytes, offset);
126
+ offset += 2;
127
+ } else {
128
+ buffer = Buffer.alloc(bufferLength + 4 + utf8Bytes);
129
+ offset = serializeHeader(buffer, offset, key, flag | (10 << 4));
130
+ buffer.writeUInt32LE(utf8Bytes, offset);
131
+ offset += 4;
132
+ }
133
+ buffer.write(value, offset, "utf8");
134
+ return buffer;
135
+ }
136
+ throw "missing";
137
+ }
138
+ function serializeHeader(buffer, offset, key, flag) {
139
+ if (key < 256) {
140
+ buffer.writeUInt8(flag, offset);
141
+ offset += 1;
142
+ buffer.writeUInt8(key, offset);
143
+ offset += 1;
144
+ } else {
145
+ buffer.writeUInt8(flag | FLAG_BYTE, offset);
146
+ offset += 1;
147
+ buffer.writeUInt16LE(key, offset);
148
+ offset += 2;
149
+ }
150
+ return offset;
151
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./constants.js";
2
+ export * from "./encode.js";
3
+ export * from "./BinaryInfo.js";
@@ -0,0 +1,21 @@
1
+ import { assertNodeErrorFree } from "../../WABinary/index.js";
2
+ import { USyncUser } from "../USyncUser.js";
3
+ export class USyncContactProtocol {
4
+ constructor() {
5
+ this.name = "contact";
6
+ }
7
+ getQueryElement() {
8
+ return { tag: "contact", attrs: {} };
9
+ }
10
+ getUserElement(user) {
11
+ //TODO: Implement type / username fields (not yet supported)
12
+ return { tag: "contact", attrs: {}, content: user.phone };
13
+ }
14
+ parser(node) {
15
+ if (node.tag === "contact") {
16
+ assertNodeErrorFree(node);
17
+ return node?.attrs?.type === "in";
18
+ }
19
+ return false;
20
+ }
21
+ }
@@ -0,0 +1,50 @@
1
+ import {
2
+ assertNodeErrorFree,
3
+ getBinaryNodeChild,
4
+ } from "../../WABinary/index.js";
5
+ export class USyncDeviceProtocol {
6
+ constructor() {
7
+ this.name = "devices";
8
+ }
9
+ getQueryElement() {
10
+ return { tag: "devices", attrs: { version: "2" } };
11
+ }
12
+ getUserElement() {
13
+ //TODO: Implement device phashing, ts and expectedTs
14
+ //TODO: if all are not present, return null <- current behavior
15
+ //TODO: otherwise return a node w tag 'devices' w those as attrs
16
+ return null;
17
+ }
18
+ parser(node) {
19
+ const deviceList = [];
20
+ let keyIndex = undefined;
21
+ if (node.tag === "devices") {
22
+ assertNodeErrorFree(node);
23
+ const deviceListNode = getBinaryNodeChild(node, "device-list");
24
+ const keyIndexNode = getBinaryNodeChild(node, "key-index-list");
25
+ if (Array.isArray(deviceListNode?.content)) {
26
+ for (const { tag, attrs } of deviceListNode.content) {
27
+ const id = +attrs.id;
28
+ const keyIndex = +attrs["key-index"];
29
+ if (tag === "device") {
30
+ deviceList.push({
31
+ id: id,
32
+ keyIndex: keyIndex,
33
+ isHosted: !!(attrs["is_hosted"] && attrs["is_hosted"] === "true"),
34
+ });
35
+ }
36
+ }
37
+ }
38
+ if (keyIndexNode?.tag === "key-index-list") {
39
+ keyIndex = {
40
+ timestamp: +keyIndexNode.attrs["ts"],
41
+ signedKeyIndex: keyIndexNode?.content,
42
+ expectedTimestamp: keyIndexNode.attrs["expected_ts"]
43
+ ? +keyIndexNode.attrs["expected_ts"]
44
+ : undefined,
45
+ };
46
+ }
47
+ }
48
+ return { deviceList: deviceList, keyIndex: keyIndex };
49
+ }
50
+ }
@@ -0,0 +1,20 @@
1
+ import { assertNodeErrorFree } from "../../WABinary/index.js";
2
+ export class USyncDisappearingModeProtocol {
3
+ constructor() {
4
+ this.name = "disappearing_mode";
5
+ }
6
+ getQueryElement() {
7
+ return { tag: "disappearing_mode", attrs: {} };
8
+ }
9
+ getUserElement() {
10
+ return null;
11
+ }
12
+ parser(node) {
13
+ if (node.tag === "disappearing_mode") {
14
+ assertNodeErrorFree(node);
15
+ const duration = +node?.attrs.duration;
16
+ const setAt = new Date(+(node?.attrs.t || 0) * 1e3);
17
+ return { duration: duration, setAt: setAt };
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,29 @@
1
+ import { assertNodeErrorFree } from "../../WABinary/index.js";
2
+ export class USyncStatusProtocol {
3
+ constructor() {
4
+ this.name = "status";
5
+ }
6
+ getQueryElement() {
7
+ return { tag: "status", attrs: {} };
8
+ }
9
+ getUserElement() {
10
+ return null;
11
+ }
12
+ parser(node) {
13
+ if (node.tag === "status") {
14
+ assertNodeErrorFree(node);
15
+ let status = node?.content?.toString() ?? null;
16
+ const setAt = new Date(+(node?.attrs.t || 0) * 1e3);
17
+ if (!status) {
18
+ if (node.attrs?.code && +node.attrs.code === 401) {
19
+ status = "";
20
+ } else {
21
+ status = null;
22
+ }
23
+ } else if (typeof status === "string" && status.length === 0) {
24
+ status = null;
25
+ }
26
+ return { status: status, setAt: setAt };
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,59 @@
1
+ import {
2
+ getBinaryNodeChild,
3
+ getBinaryNodeChildren,
4
+ getBinaryNodeChildString,
5
+ } from "../../WABinary/index.js";
6
+ import { USyncUser } from "../USyncUser.js";
7
+ export class USyncBotProfileProtocol {
8
+ constructor() {
9
+ this.name = "bot";
10
+ }
11
+ getQueryElement() {
12
+ return {
13
+ tag: "bot",
14
+ attrs: {},
15
+ content: [{ tag: "profile", attrs: { v: "1" } }],
16
+ };
17
+ }
18
+ getUserElement(user) {
19
+ return {
20
+ tag: "bot",
21
+ attrs: {},
22
+ content: [{ tag: "profile", attrs: { persona_id: user.personaId } }],
23
+ };
24
+ }
25
+ parser(node) {
26
+ const botNode = getBinaryNodeChild(node, "bot");
27
+ const profile = getBinaryNodeChild(botNode, "profile");
28
+ const commandsNode = getBinaryNodeChild(profile, "commands");
29
+ const promptsNode = getBinaryNodeChild(profile, "prompts");
30
+ const commands = [];
31
+ const prompts = [];
32
+ for (const command of getBinaryNodeChildren(commandsNode, "command")) {
33
+ commands.push({
34
+ name: getBinaryNodeChildString(command, "name"),
35
+ description: getBinaryNodeChildString(command, "description"),
36
+ });
37
+ }
38
+ for (const prompt of getBinaryNodeChildren(promptsNode, "prompt")) {
39
+ prompts.push(
40
+ `${getBinaryNodeChildString(prompt, "emoji")} ${getBinaryNodeChildString(prompt, "text")}`,
41
+ );
42
+ }
43
+ return {
44
+ isDefault: !!getBinaryNodeChild(profile, "default"),
45
+ jid: node.attrs.jid,
46
+ name: getBinaryNodeChildString(profile, "name"),
47
+ attributes: getBinaryNodeChildString(profile, "attributes"),
48
+ description: getBinaryNodeChildString(profile, "description"),
49
+ category: getBinaryNodeChildString(profile, "category"),
50
+ personaId: profile.attrs["persona_id"],
51
+ commandsDescription: getBinaryNodeChildString(
52
+ commandsNode,
53
+ "description",
54
+ ),
55
+ commands: commands,
56
+ prompts: prompts,
57
+ };
58
+ }
59
+ }
@@ -0,0 +1,21 @@
1
+ export class USyncLIDProtocol {
2
+ constructor() {
3
+ this.name = "lid";
4
+ }
5
+ getQueryElement() {
6
+ return { tag: "lid", attrs: {} };
7
+ }
8
+ getUserElement(user) {
9
+ if (user.lid) {
10
+ return { tag: "lid", attrs: { jid: user.lid } };
11
+ } else {
12
+ return null;
13
+ }
14
+ }
15
+ parser(node) {
16
+ if (node.tag === "lid") {
17
+ return node.attrs.val;
18
+ }
19
+ return null;
20
+ }
21
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./USyncDeviceProtocol.js";
2
+ export * from "./USyncContactProtocol.js";
3
+ export * from "./USyncStatusProtocol.js";
4
+ export * from "./USyncDisappearingModeProtocol.js";
@@ -0,0 +1,103 @@
1
+ import { getBinaryNodeChild } from "../WABinary/index.js";
2
+ import { USyncBotProfileProtocol } from "./Protocols/UsyncBotProfileProtocol.js";
3
+ import { USyncLIDProtocol } from "./Protocols/UsyncLIDProtocol.js";
4
+ import {
5
+ USyncContactProtocol,
6
+ USyncDeviceProtocol,
7
+ USyncDisappearingModeProtocol,
8
+ USyncStatusProtocol,
9
+ } from "./Protocols/index.js";
10
+ import { USyncUser } from "./USyncUser.js";
11
+ export class USyncQuery {
12
+ constructor() {
13
+ this.protocols = [];
14
+ this.users = [];
15
+ this.context = "interactive";
16
+ this.mode = "query";
17
+ }
18
+ withMode(mode) {
19
+ this.mode = mode;
20
+ return this;
21
+ }
22
+ withContext(context) {
23
+ this.context = context;
24
+ return this;
25
+ }
26
+ withUser(user) {
27
+ this.users.push(user);
28
+ return this;
29
+ }
30
+ parseUSyncQueryResult(result) {
31
+ if (!result || result.attrs.type !== "result") {
32
+ return;
33
+ }
34
+ const protocolMap = Object.fromEntries(
35
+ this.protocols.map((protocol) => {
36
+ return [protocol.name, protocol.parser];
37
+ }),
38
+ );
39
+ const queryResult = {
40
+ // TODO: implement errors etc.
41
+ list: [],
42
+ sideList: [],
43
+ };
44
+ const usyncNode = getBinaryNodeChild(result, "usync");
45
+ //TODO: implement error backoff, refresh etc.
46
+ //TODO: see if there are any errors in the result node
47
+ //const resultNode = getBinaryNodeChild(usyncNode, 'result')
48
+ const listNode = usyncNode
49
+ ? getBinaryNodeChild(usyncNode, "list")
50
+ : undefined;
51
+ if (listNode?.content && Array.isArray(listNode.content)) {
52
+ queryResult.list = listNode.content.reduce((acc, node) => {
53
+ const id = node?.attrs.jid;
54
+ if (id) {
55
+ const data = Array.isArray(node?.content)
56
+ ? Object.fromEntries(
57
+ node.content
58
+ .map((content) => {
59
+ const protocol = content.tag;
60
+ const parser = protocolMap[protocol];
61
+ if (parser) {
62
+ return [protocol, parser(content)];
63
+ } else {
64
+ return [protocol, null];
65
+ }
66
+ })
67
+ .filter(([, b]) => b !== null),
68
+ )
69
+ : {};
70
+ acc.push({ ...data, id: id });
71
+ }
72
+ return acc;
73
+ }, []);
74
+ }
75
+ //TODO: implement side list
76
+ //const sideListNode = getBinaryNodeChild(usyncNode, 'side_list')
77
+ return queryResult;
78
+ }
79
+ withDeviceProtocol() {
80
+ this.protocols.push(new USyncDeviceProtocol());
81
+ return this;
82
+ }
83
+ withContactProtocol() {
84
+ this.protocols.push(new USyncContactProtocol());
85
+ return this;
86
+ }
87
+ withStatusProtocol() {
88
+ this.protocols.push(new USyncStatusProtocol());
89
+ return this;
90
+ }
91
+ withDisappearingModeProtocol() {
92
+ this.protocols.push(new USyncDisappearingModeProtocol());
93
+ return this;
94
+ }
95
+ withBotProfileProtocol() {
96
+ this.protocols.push(new USyncBotProfileProtocol());
97
+ return this;
98
+ }
99
+ withLIDProtocol() {
100
+ this.protocols.push(new USyncLIDProtocol());
101
+ return this;
102
+ }
103
+ }
@@ -0,0 +1,22 @@
1
+ export class USyncUser {
2
+ withId(id) {
3
+ this.id = id;
4
+ return this;
5
+ }
6
+ withLid(lid) {
7
+ this.lid = lid;
8
+ return this;
9
+ }
10
+ withPhone(phone) {
11
+ this.phone = phone;
12
+ return this;
13
+ }
14
+ withType(type) {
15
+ this.type = type;
16
+ return this;
17
+ }
18
+ withPersonaId(personaId) {
19
+ this.personaId = personaId;
20
+ return this;
21
+ }
22
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./Protocols/index.js";
2
+ export * from "./USyncQuery.js";
3
+ export * from "./USyncUser.js";
package/lib/index.js ADDED
@@ -0,0 +1,11 @@
1
+ import makeWASocket from "./Socket/index.js";
2
+ export * from "../WAProto/index.js";
3
+ export * from "./Utils/index.js";
4
+ export * from "./Types/index.js";
5
+ export * from "./Defaults/index.js";
6
+ export * from "./Store/index.js";
7
+ export * from "./WABinary/index.js";
8
+ export * from "./WAM/index.js";
9
+ export * from "./WAUSync/index.js";
10
+ export { makeWASocket };
11
+ export default makeWASocket;
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@sgintokic/baileys",
3
+ "version": "0.0.2",
4
+ "description": "A simple fork of Baileys for WhatsApp automation",
5
+ "main": "lib/index.js",
6
+ "type": "module",
7
+ "scripts": {
8
+ "preinstall": "node ./engine-requirements.js"
9
+ },
10
+ "engines": {
11
+ "node": ">=20.0.0"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/GSK-F/baileys.git"
16
+ },
17
+ "files": ["lib/**/*", "WAProto/**/*", "engine-requirements.js"],
18
+ "keywords": ["automation", "baileys", "baileys-fork", "baileys-mod", "js-whatsapp", "multi-device", "whatsapp", "whatsapp-api", "whatsapp-bot", "whatsapp-chat", "whatsapp-group", "whatsapp-web"],
19
+ "homepage": "https://github.com/GSK-F/baileys",
20
+ "author": "Sakata Gintoki",
21
+ "license": "MIT",
22
+ "dependencies": {
23
+ "@adiwajshing/keyed-db": "^0.2.4",
24
+ "@cacheable/node-cache": "^1.4.0",
25
+ "@hapi/boom": "^9.1.3",
26
+ "async-mutex": "^0.5.0",
27
+ "fflate": "^0.8.2",
28
+ "libsignal": "github:WhiskeySockets/libsignal-wasm#master",
29
+ "lru-cache": "^11.2.6",
30
+ "music-metadata": "^11.7.0",
31
+ "p-queue": "^9.1.0",
32
+ "pino": "^9.6.0",
33
+ "protobufjs": "^7.5.4",
34
+ "whatsapp-rust-bridge": "0.5.3",
35
+ "ws": "^8.19.0"
36
+ },
37
+ "peerDependencies": {
38
+ "@napi-rs/image": "~1.12.0",
39
+ "audio-decode": "^2.2.3",
40
+ "jimp": "*",
41
+ "link-preview-js": "^3.0.0",
42
+ "sharp": "*"
43
+ },
44
+ "peerDependenciesMeta": {
45
+ "@napi-rs/image": {
46
+ "optional": true
47
+ },
48
+ "audio-decode": {
49
+ "optional": true
50
+ },
51
+ "jimp": {
52
+ "optional": true
53
+ },
54
+ "link-preview-js": {
55
+ "optional": true
56
+ }
57
+ }
58
+ }