lordceaser-baileys 2.0.12 → 2.0.13

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 (173) hide show
  1. package/package.json +1 -1
  2. package/lib/Defaults/baileys-version.json +0 -3
  3. package/lib/Defaults/index.d.ts +0 -284
  4. package/lib/Defaults/index.js +0 -121
  5. package/lib/Defaults/phonenumber-mcc.json +0 -223
  6. package/lib/Signal/libsignal.d.ts +0 -4
  7. package/lib/Signal/libsignal.js +0 -162
  8. package/lib/Socket/Client/abstract-socket-client.d.ts +0 -15
  9. package/lib/Socket/Client/abstract-socket-client.js +0 -13
  10. package/lib/Socket/Client/index.d.ts +0 -2
  11. package/lib/Socket/Client/index.js +0 -22
  12. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -12
  13. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  14. package/lib/Socket/Client/types.d.ts +0 -16
  15. package/lib/Socket/Client/types.js +0 -18
  16. package/lib/Socket/Client/web-socket-client.js +0 -62
  17. package/lib/Socket/Client/websocket.d.ts +0 -13
  18. package/lib/Socket/Client/websocket.js +0 -62
  19. package/lib/Socket/business.d.ts +0 -182
  20. package/lib/Socket/business.js +0 -268
  21. package/lib/Socket/chats.d.ts +0 -96
  22. package/lib/Socket/chats.js +0 -1026
  23. package/lib/Socket/groups.d.ts +0 -130
  24. package/lib/Socket/groups.js +0 -338
  25. package/lib/Socket/index.d.ts +0 -185
  26. package/lib/Socket/index.js +0 -14
  27. package/lib/Socket/messages-recv.d.ts +0 -171
  28. package/lib/Socket/messages-recv.js +0 -1182
  29. package/lib/Socket/messages-send.d.ts +0 -162
  30. package/lib/Socket/messages-send.js +0 -1006
  31. package/lib/Socket/newsletter.d.ts +0 -142
  32. package/lib/Socket/newsletter.js +0 -256
  33. package/lib/Socket/registration.d.ts +0 -264
  34. package/lib/Socket/registration.js +0 -166
  35. package/lib/Socket/socket.d.ts +0 -45
  36. package/lib/Socket/socket.js +0 -751
  37. package/lib/Socket/socket.js.bak +0 -751
  38. package/lib/Socket/usync.d.ts +0 -37
  39. package/lib/Socket/usync.js +0 -83
  40. package/lib/Store/index.d.ts +0 -4
  41. package/lib/Store/index.js +0 -24
  42. package/lib/Store/make-cache-manager-store.d.ts +0 -14
  43. package/lib/Store/make-cache-manager-store.js +0 -90
  44. package/lib/Store/make-in-memory-store.d.ts +0 -123
  45. package/lib/Store/make-in-memory-store.js +0 -429
  46. package/lib/Store/make-ordered-dictionary.d.ts +0 -12
  47. package/lib/Store/make-ordered-dictionary.js +0 -86
  48. package/lib/Store/object-repository.d.ts +0 -10
  49. package/lib/Store/object-repository.js +0 -31
  50. package/lib/Types/Auth.d.ts +0 -120
  51. package/lib/Types/Auth.js +0 -3
  52. package/lib/Types/Call.d.ts +0 -14
  53. package/lib/Types/Call.js +0 -3
  54. package/lib/Types/Chat.d.ts +0 -134
  55. package/lib/Types/Chat.js +0 -9
  56. package/lib/Types/Contact.d.ts +0 -25
  57. package/lib/Types/Contact.js +0 -3
  58. package/lib/Types/Events.d.ts +0 -212
  59. package/lib/Types/Events.js +0 -3
  60. package/lib/Types/GroupMetadata.d.ts +0 -64
  61. package/lib/Types/GroupMetadata.js +0 -3
  62. package/lib/Types/Label.d.ts +0 -48
  63. package/lib/Types/Label.js +0 -31
  64. package/lib/Types/LabelAssociation.d.ts +0 -35
  65. package/lib/Types/LabelAssociation.js +0 -13
  66. package/lib/Types/Message.d.ts +0 -459
  67. package/lib/Types/Message.js +0 -13
  68. package/lib/Types/Newsletter.d.ts +0 -107
  69. package/lib/Types/Newsletter.js +0 -38
  70. package/lib/Types/Product.d.ts +0 -92
  71. package/lib/Types/Product.js +0 -3
  72. package/lib/Types/Signal.d.ts +0 -68
  73. package/lib/Types/Signal.js +0 -3
  74. package/lib/Types/Socket.d.ts +0 -120
  75. package/lib/Types/Socket.js +0 -3
  76. package/lib/Types/State.d.ts +0 -29
  77. package/lib/Types/State.js +0 -3
  78. package/lib/Types/USync.d.ts +0 -26
  79. package/lib/Types/USync.js +0 -3
  80. package/lib/Types/index.d.ts +0 -78
  81. package/lib/Types/index.js +0 -47
  82. package/lib/Utils/auth-utils.d.ts +0 -21
  83. package/lib/Utils/auth-utils.js +0 -205
  84. package/lib/Utils/baileys-event-stream.d.ts +0 -18
  85. package/lib/Utils/baileys-event-stream.js +0 -70
  86. package/lib/Utils/business.d.ts +0 -29
  87. package/lib/Utils/business.js +0 -247
  88. package/lib/Utils/chat-utils.d.ts +0 -82
  89. package/lib/Utils/chat-utils.js +0 -774
  90. package/lib/Utils/crypto.d.ts +0 -56
  91. package/lib/Utils/crypto.js +0 -179
  92. package/lib/Utils/decode-wa-message.d.ts +0 -41
  93. package/lib/Utils/decode-wa-message.js +0 -236
  94. package/lib/Utils/event-buffer.d.ts +0 -39
  95. package/lib/Utils/event-buffer.js +0 -548
  96. package/lib/Utils/generics.d.ts +0 -129
  97. package/lib/Utils/generics.js +0 -485
  98. package/lib/Utils/history.d.ts +0 -23
  99. package/lib/Utils/history.js +0 -100
  100. package/lib/Utils/index.d.ts +0 -20
  101. package/lib/Utils/index.js +0 -40
  102. package/lib/Utils/link-preview.d.ts +0 -23
  103. package/lib/Utils/link-preview.js +0 -120
  104. package/lib/Utils/logger.d.ts +0 -13
  105. package/lib/Utils/logger.js +0 -7
  106. package/lib/Utils/lt-hash.d.ts +0 -14
  107. package/lib/Utils/lt-hash.js +0 -58
  108. package/lib/Utils/make-mutex.d.ts +0 -9
  109. package/lib/Utils/make-mutex.js +0 -49
  110. package/lib/Utils/messages-media.d.ts +0 -129
  111. package/lib/Utils/messages-media.js +0 -782
  112. package/lib/Utils/messages.d.ts +0 -103
  113. package/lib/Utils/messages.js +0 -1631
  114. package/lib/Utils/noise-handler.d.ts +0 -20
  115. package/lib/Utils/noise-handler.js +0 -155
  116. package/lib/Utils/process-message.d.ts +0 -49
  117. package/lib/Utils/process-message.js +0 -387
  118. package/lib/Utils/signal.d.ts +0 -42
  119. package/lib/Utils/signal.js +0 -166
  120. package/lib/Utils/use-mongo-file-auth-state.d.ts +0 -6
  121. package/lib/Utils/use-mongo-file-auth-state.js +0 -84
  122. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -13
  123. package/lib/Utils/use-multi-file-auth-state.js +0 -131
  124. package/lib/Utils/use-single-file-auth-state.d.ts +0 -13
  125. package/lib/Utils/use-single-file-auth-state.js +0 -80
  126. package/lib/Utils/use-sql-file-auth-state.d.ts +0 -6
  127. package/lib/Utils/use-sql-file-auth-state.js +0 -143
  128. package/lib/Utils/validate-connection.d.ts +0 -13
  129. package/lib/Utils/validate-connection.js +0 -186
  130. package/lib/WABinary/constants.d.ts +0 -30
  131. package/lib/WABinary/constants.js +0 -53
  132. package/lib/WABinary/decode.d.ts +0 -9
  133. package/lib/WABinary/decode.js +0 -288
  134. package/lib/WABinary/encode.d.ts +0 -3
  135. package/lib/WABinary/encode.js +0 -256
  136. package/lib/WABinary/generic-utils.d.ts +0 -28
  137. package/lib/WABinary/generic-utils.js +0 -150
  138. package/lib/WABinary/index.d.ts +0 -5
  139. package/lib/WABinary/index.js +0 -25
  140. package/lib/WABinary/jid-utils.d.ts +0 -53
  141. package/lib/WABinary/jid-utils.js +0 -92
  142. package/lib/WABinary/types.d.ts +0 -22
  143. package/lib/WABinary/types.js +0 -3
  144. package/lib/WAM/BinaryInfo.d.ts +0 -16
  145. package/lib/WAM/BinaryInfo.js +0 -17
  146. package/lib/WAM/constants.d.ts +0 -47
  147. package/lib/WAM/constants.js +0 -15371
  148. package/lib/WAM/encode.d.ts +0 -3
  149. package/lib/WAM/encode.js +0 -165
  150. package/lib/WAM/index.d.ts +0 -3
  151. package/lib/WAM/index.js +0 -23
  152. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +0 -28
  153. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +0 -69
  154. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -10
  155. package/lib/WAUSync/Protocols/USyncContactProtocol.js +0 -36
  156. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -26
  157. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +0 -62
  158. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -14
  159. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -35
  160. package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +0 -9
  161. package/lib/WAUSync/Protocols/USyncLIDProtocol.js +0 -30
  162. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -14
  163. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +0 -46
  164. package/lib/WAUSync/Protocols/index.d.ts +0 -6
  165. package/lib/WAUSync/Protocols/index.js +0 -26
  166. package/lib/WAUSync/USyncQuery.d.ts +0 -31
  167. package/lib/WAUSync/USyncQuery.js +0 -92
  168. package/lib/WAUSync/USyncUser.d.ts +0 -12
  169. package/lib/WAUSync/USyncUser.js +0 -30
  170. package/lib/WAUSync/index.d.ts +0 -3
  171. package/lib/WAUSync/index.js +0 -23
  172. package/lib/index.d.ts +0 -13
  173. package/lib/index.js +0 -33
@@ -1,162 +0,0 @@
1
- "use strict"
2
-
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k
5
- var desc = Object.getOwnPropertyDescriptor(m, k)
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k] } }
8
- }
9
- Object.defineProperty(o, k2, desc)
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k
12
- o[k2] = m[k]
13
- }))
14
-
15
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
- Object.defineProperty(o, "default", { enumerable: true, value: v })
17
- }) : function(o, v) {
18
- o["default"] = v
19
- })
20
-
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod
23
- var result = {}
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k)
25
- __setModuleDefault(result, mod)
26
- return result
27
- }
28
- Object.defineProperty(exports, "__esModule", { value: true })
29
-
30
- const libsignal = __importStar(require("libsignal"))
31
- const WASignalGroup_1 = require("../../WASignalGroup")
32
- const Utils_1 = require("../Utils")
33
- const WABinary_1 = require("../WABinary")
34
-
35
- function makeLibSignalRepository(auth) {
36
- const storage = signalStorage(auth)
37
- return {
38
- decryptGroupMessage({ group, authorJid, msg }) {
39
- const senderName = jidToSignalSenderKeyName(group, authorJid)
40
- const cipher = new WASignalGroup_1.GroupCipher(storage, senderName)
41
- return cipher.decrypt(msg)
42
- },
43
- async processSenderKeyDistributionMessage({ item, authorJid }) {
44
- const builder = new WASignalGroup_1.GroupSessionBuilder(storage)
45
- const senderName = jidToSignalSenderKeyName(item.groupId, authorJid)
46
- const senderMsg = new WASignalGroup_1.SenderKeyDistributionMessage(null, null, null, null, item.axolotlSenderKeyDistributionMessage)
47
- const { [senderName]: senderKey } = await auth.keys.get('sender-key', [senderName])
48
- if (!senderKey) {
49
- await storage.storeSenderKey(senderName, new WASignalGroup_1.SenderKeyRecord())
50
- }
51
- await builder.process(senderName, senderMsg)
52
- },
53
- async decryptMessage({ jid, type, ciphertext }) {
54
- const addr = jidToSignalProtocolAddress(jid)
55
- const session = new libsignal.SessionCipher(storage, addr)
56
- let result
57
- switch (type) {
58
- case 'pkmsg':
59
- result = await session.decryptPreKeyWhisperMessage(ciphertext)
60
- break
61
- case 'msg':
62
- result = await session.decryptWhisperMessage(ciphertext)
63
- break
64
- }
65
- return result
66
- },
67
- async encryptMessage({ jid, data }) {
68
- const addr = jidToSignalProtocolAddress(jid)
69
- const cipher = new libsignal.SessionCipher(storage, addr)
70
- const { type: sigType, body } = await cipher.encrypt(data)
71
- const type = sigType === 3 ? 'pkmsg' : 'msg'
72
- return { type, ciphertext: Buffer.from(body, 'binary') }
73
- },
74
- async encryptGroupMessage({ group, meId, data }) {
75
- const senderName = jidToSignalSenderKeyName(group, meId)
76
- const builder = new WASignalGroup_1.GroupSessionBuilder(storage)
77
- const { [senderName]: senderKey } = await auth.keys.get('sender-key', [senderName])
78
- if (!senderKey) {
79
- await storage.storeSenderKey(senderName, new WASignalGroup_1.SenderKeyRecord())
80
- }
81
- const senderKeyDistributionMessage = await builder.create(senderName)
82
- const session = new WASignalGroup_1.GroupCipher(storage, senderName)
83
- const ciphertext = await session.encrypt(data)
84
- return {
85
- ciphertext,
86
- senderKeyDistributionMessage: senderKeyDistributionMessage.serialize(),
87
- }
88
- },
89
- async injectE2ESession({ jid, session }) {
90
- const cipher = new libsignal.SessionBuilder(storage, jidToSignalProtocolAddress(jid))
91
- await cipher.initOutgoing(session)
92
- },
93
- jidToSignalProtocolAddress(jid) {
94
- return jidToSignalProtocolAddress(jid).toString()
95
- },
96
- }
97
- }
98
-
99
- const jidToSignalProtocolAddress = (jid) => {
100
- const { user, device } = WABinary_1.jidDecode(jid)
101
- return new libsignal.ProtocolAddress(user, device || 0)
102
- }
103
-
104
- const jidToSignalSenderKeyName = (group, user) => {
105
- return new WASignalGroup_1.SenderKeyName(group, jidToSignalProtocolAddress(user)).toString()
106
- }
107
-
108
- function signalStorage({ creds, keys }) {
109
- return {
110
- loadSession: async (id) => {
111
- const { [id]: sess } = await keys.get('session', [id])
112
- if (sess) {
113
- return libsignal.SessionRecord.deserialize(sess)
114
- }
115
- },
116
- storeSession: async (id, session) => {
117
- await keys.set({ 'session': { [id]: session.serialize() } })
118
- },
119
- isTrustedIdentity: () => {
120
- return true
121
- },
122
- loadPreKey: async (id) => {
123
- const keyId = id.toString()
124
- const { [keyId]: key } = await keys.get('pre-key', [keyId])
125
- if (key) {
126
- return {
127
- privKey: Buffer.from(key.private),
128
- pubKey: Buffer.from(key.public)
129
- }
130
- }
131
- },
132
- removePreKey: (id) => keys.set({ 'pre-key': { [id]: null } }),
133
- loadSignedPreKey: () => {
134
- const key = creds.signedPreKey
135
- return {
136
- privKey: Buffer.from(key.keyPair.private),
137
- pubKey: Buffer.from(key.keyPair.public)
138
- }
139
- },
140
- loadSenderKey: async (keyId) => {
141
- const { [keyId]: key } = await keys.get('sender-key', [keyId])
142
- if (key) {
143
- return new WASignalGroup_1.SenderKeyRecord(key)
144
- }
145
- },
146
- storeSenderKey: async (keyId, key) => {
147
- await keys.set({ 'sender-key': { [keyId]: key.serialize() } })
148
- },
149
- getOurRegistrationId: () => (creds.registrationId),
150
- getOurIdentity: () => {
151
- const { signedIdentityKey } = creds
152
- return {
153
- privKey: Buffer.from(signedIdentityKey.private),
154
- pubKey: Utils_1.generateSignalPubKey(signedIdentityKey.public),
155
- }
156
- }
157
- }
158
- }
159
-
160
- module.exports = {
161
- makeLibSignalRepository
162
- }
@@ -1,15 +0,0 @@
1
- import { EventEmitter } from 'events';
2
- import { URL } from 'url';
3
- import { SocketConfig } from '../../Types';
4
- export declare abstract class AbstractSocketClient extends EventEmitter {
5
- url: URL;
6
- config: SocketConfig;
7
- abstract get isOpen(): boolean;
8
- abstract get isClosed(): boolean;
9
- abstract get isClosing(): boolean;
10
- abstract get isConnecting(): boolean;
11
- constructor(url: URL, config: SocketConfig);
12
- abstract connect(): Promise<void>;
13
- abstract close(): Promise<void>;
14
- abstract send(str: Uint8Array | string, cb?: (err?: Error) => void): boolean;
15
- }
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AbstractSocketClient = void 0;
4
- const events_1 = require("events");
5
- class AbstractSocketClient extends events_1.EventEmitter {
6
- constructor(url, config) {
7
- super();
8
- this.url = url;
9
- this.config = config;
10
- this.setMaxListeners(0);
11
- }
12
- }
13
- exports.AbstractSocketClient = AbstractSocketClient;
@@ -1,2 +0,0 @@
1
- export * from './types'
2
- export * from './websocket'
@@ -1,22 +0,0 @@
1
- "use strict"
2
-
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k
5
- var desc = Object.getOwnPropertyDescriptor(m, k)
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k] } }
8
- }
9
- Object.defineProperty(o, k2, desc)
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k
12
- o[k2] = m[k]
13
- }))
14
-
15
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p)
17
- }
18
-
19
- Object.defineProperty(exports, "__esModule", { value: true })
20
-
21
- __exportStar(require("./types"), exports)
22
- __exportStar(require("./websocket"), exports)
@@ -1,12 +0,0 @@
1
- import { Socket } from 'net';
2
- import { AbstractSocketClient } from './abstract-socket-client';
3
- export declare class MobileSocketClient extends AbstractSocketClient {
4
- protected socket: Socket | null;
5
- get isOpen(): boolean;
6
- get isClosed(): boolean;
7
- get isClosing(): boolean;
8
- get isConnecting(): boolean;
9
- connect(): Promise<void>;
10
- close(): Promise<void>;
11
- send(str: string | Uint8Array, cb?: (err?: Error) => void): boolean;
12
- }
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MobileSocketClient = void 0;
4
- const net_1 = require("net");
5
- const abstract_socket_client_1 = require("./abstract-socket-client");
6
- class MobileSocketClient extends abstract_socket_client_1.AbstractSocketClient {
7
- constructor() {
8
- super(...arguments);
9
- this.socket = null;
10
- }
11
- get isOpen() {
12
- var _a;
13
- return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === 'open';
14
- }
15
- get isClosed() {
16
- var _a;
17
- return this.socket === null || ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === 'closed';
18
- }
19
- get isClosing() {
20
- var _a;
21
- return this.socket === null || ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === 'closed';
22
- }
23
- get isConnecting() {
24
- var _a;
25
- return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === 'opening';
26
- }
27
- async connect() {
28
- var _a;
29
- if (this.socket) {
30
- return;
31
- }
32
- if (this.config.agent) {
33
- throw new Error('There are not support for proxy agent for mobile connection');
34
- }
35
- else {
36
- this.socket = (0, net_1.connect)({
37
- host: this.url.hostname,
38
- port: Number(this.url.port) || 443
39
- });
40
- }
41
- this.socket.setMaxListeners(0);
42
- const events = ['close', 'connect', 'data', 'drain', 'end', 'error', 'lookup', 'ready', 'timeout'];
43
- for (const event of events) {
44
- (_a = this.socket) === null || _a === void 0 ? void 0 : _a.on(event, (...args) => this.emit(event, ...args));
45
- }
46
- this.socket.on('data', (...args) => this.emit('message', ...args));
47
- this.socket.on('ready', (...args) => this.emit('open', ...args));
48
- }
49
- async close() {
50
- if (!this.socket) {
51
- return;
52
- }
53
- return new Promise(resolve => {
54
- this.socket.end(resolve);
55
- this.socket = null;
56
- });
57
- }
58
- send(str, cb) {
59
- if (this.socket === null) {
60
- return false;
61
- }
62
- return this.socket.write(str, undefined, cb);
63
- }
64
- }
65
- exports.MobileSocketClient = MobileSocketClient;
@@ -1,16 +0,0 @@
1
- import { EventEmitter } from 'events'
2
- import { URL } from 'url'
3
- import { SocketConfig } from '../../Types'
4
-
5
- export declare abstract class AbstractSocketClient extends EventEmitter {
6
- url: URL
7
- config: SocketConfig
8
- abstract get isOpen(): boolean
9
- abstract get isClosed(): boolean
10
- abstract get isClosing(): boolean
11
- abstract get isConnecting(): boolean
12
- constructor(url: URL, config: SocketConfig)
13
- abstract connect(): Promise<void>
14
- abstract close(): Promise<void>
15
- abstract send(str: Uint8Array | string, cb?: (err?: Error) => void): boolean
16
- }
@@ -1,18 +0,0 @@
1
- "use strict"
2
-
3
- Object.defineProperty(exports, "__esModule", { value: true })
4
-
5
- const events_1 = require("events")
6
-
7
- class AbstractSocketClient extends events_1.EventEmitter {
8
- constructor(url, config) {
9
- super()
10
- this.url = url
11
- this.config = config
12
- this.setMaxListeners(0)
13
- }
14
- }
15
-
16
- module.exports = {
17
- AbstractSocketClient
18
- }
@@ -1,62 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.WebSocketClient = void 0;
7
- const ws_1 = __importDefault(require("ws"));
8
- const Defaults_1 = require("../../Defaults");
9
- const abstract_socket_client_1 = require("./abstract-socket-client");
10
- class WebSocketClient extends abstract_socket_client_1.AbstractSocketClient {
11
- constructor() {
12
- super(...arguments);
13
- this.socket = null;
14
- }
15
- get isOpen() {
16
- var _a;
17
- return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.OPEN;
18
- }
19
- get isClosed() {
20
- var _a;
21
- return this.socket === null || ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.CLOSED;
22
- }
23
- get isClosing() {
24
- var _a;
25
- return this.socket === null || ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.CLOSING;
26
- }
27
- get isConnecting() {
28
- var _a;
29
- return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.CONNECTING;
30
- }
31
- async connect() {
32
- var _a, _b;
33
- if (this.socket) {
34
- return;
35
- }
36
- this.socket = new ws_1.default(this.url, {
37
- origin: Defaults_1.DEFAULT_ORIGIN,
38
- headers: (_a = this.config.options) === null || _a === void 0 ? void 0 : _a.headers,
39
- handshakeTimeout: this.config.connectTimeoutMs,
40
- timeout: this.config.connectTimeoutMs,
41
- agent: this.config.agent,
42
- });
43
- this.socket.setMaxListeners(0);
44
- const events = ['close', 'error', 'upgrade', 'message', 'open', 'ping', 'pong', 'unexpected-response'];
45
- for (const event of events) {
46
- (_b = this.socket) === null || _b === void 0 ? void 0 : _b.on(event, (...args) => this.emit(event, ...args));
47
- }
48
- }
49
- async close() {
50
- if (!this.socket) {
51
- return;
52
- }
53
- this.socket.close();
54
- this.socket = null;
55
- }
56
- send(str, cb) {
57
- var _a;
58
- (_a = this.socket) === null || _a === void 0 ? void 0 : _a.send(str, cb);
59
- return Boolean(this.socket);
60
- }
61
- }
62
- exports.WebSocketClient = WebSocketClient;
@@ -1,13 +0,0 @@
1
- import WebSocket from 'ws'
2
- import { AbstractSocketClient } from './types'
3
-
4
- export declare class WebSocketClient extends AbstractSocketClient {
5
- protected socket: WebSocket | null
6
- get isOpen(): boolean
7
- get isClosed(): boolean
8
- get isClosing(): boolean
9
- get isConnecting(): boolean
10
- connect(): Promise<void>
11
- close(): Promise<void>
12
- send(str: string | Uint8Array, cb?: (err?: Error) => void): boolean
13
- }
@@ -1,62 +0,0 @@
1
- "use strict"
2
-
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod }
5
- }
6
-
7
- Object.defineProperty(exports, "__esModule", { value: true })
8
-
9
- const ws_1 = __importDefault(require("ws"))
10
- const Defaults_1 = require("../../Defaults")
11
- const types_1 = require("./types")
12
-
13
- class WebSocketClient extends types_1.AbstractSocketClient {
14
- constructor() {
15
- super(...arguments)
16
- this.socket = null
17
- }
18
- get isOpen() {
19
- return this.socket?.readyState === ws_1.default.OPEN
20
- }
21
- get isClosed() {
22
- return this.socket?.readyState === ws_1.default.CLOSED
23
- }
24
- get isClosing() {
25
- this.socket?.readyState === ws_1.default.CLOSING
26
- }
27
- get isConnecting() {
28
- this.socket?.readyState === ws_1.default.CONNECTING
29
- }
30
- async connect() {
31
- if (this.socket) {
32
- return
33
- }
34
- this.socket = new ws_1.default(this.url, {
35
- origin: Defaults_1.DEFAULT_ORIGIN,
36
- headers: this.config.options?.headers,
37
- handshakeTimeout: this.config.connectTimeoutMs,
38
- timeout: this.config.connectTimeoutMs,
39
- agent: this.config.agent,
40
- })
41
- this.socket.setMaxListeners(0)
42
- const events = ['close', 'error', 'upgrade', 'message', 'open', 'ping', 'pong', 'unexpected-response']
43
- for (const event of events) {
44
- this.socket?.on(event, (...args) => this.emit(event, ...args))
45
- }
46
- }
47
- async close() {
48
- if (!this.socket) {
49
- return
50
- }
51
- this.socket.close()
52
- this.socket = null
53
- }
54
- send(str, cb) {
55
- this.socket?.send(str, cb)
56
- return Boolean(this.socket)
57
- }
58
- }
59
-
60
- module.exports = {
61
- WebSocketClient
62
- }
@@ -1,182 +0,0 @@
1
- import { GetCatalogOptions, ProductCreate, ProductUpdate, SocketConfig } from '../Types'
2
- import { BinaryNode } from '../WABinary'
3
-
4
- export declare const makeBusinessSocket: (config: SocketConfig) => {
5
- logger: import("../Utils/logger").ILogger
6
- getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>
7
- getCatalog: ({ jid, limit, cursor }: GetCatalogOptions) => Promise<{
8
- products: import("../Types").Product[]
9
- nextPageCursor: string | undefined
10
- }>
11
- getCollections: (jid?: string, limit?: number) => Promise<{
12
- collections: import("../Types").CatalogCollection[]
13
- }>
14
- productCreate: (create: ProductCreate) => Promise<import("../Types").Product>
15
- productDelete: (productIds: string[]) => Promise<{
16
- deleted: number
17
- }>
18
- productUpdate: (productId: string, update: ProductUpdate) => Promise<import("../Types").Product>
19
- sendMessageAck: ({ tag, attrs, content }: BinaryNode, errorCode?: number | undefined) => Promise<void>
20
- sendRetryRequest: (node: BinaryNode, forceIncludeKeys?: boolean) => Promise<void>
21
- offerCall: (toJid: string, isVideo?: boolean) => Promise<{
22
- id: any
23
- to: string
24
- }>
25
- rejectCall: (callId: string, callFrom: string) => Promise<void>
26
- fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAProto.IMessageKey, oldestMsgTimestamp: number | import("long").Long) => Promise<string>
27
- requestPlaceholderResend: (messageKey: import("../Types").WAProto.IMessageKey) => Promise<string | undefined>
28
- getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>
29
- assertSessions: (jids: string[], force: boolean) => Promise<boolean>
30
- relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>
31
- sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>
32
- sendReceipts: (keys: import("../Types").WAProto.IMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>
33
- readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>
34
- refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>
35
- waUploadToServer: import("../Types").WAMediaUploadFunction
36
- fetchPrivacySettings: (force?: boolean) => Promise<{
37
- [_: string]: string
38
- }>
39
- sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>
40
- createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: {
41
- [key: string]: string
42
- } | undefined) => Promise<{
43
- nodes: BinaryNode[]
44
- shouldIncludeDeviceIdentity: boolean
45
- }>
46
- profilePictureUrl: (jid: string) => Promise<string>
47
- getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>
48
- updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>
49
- sendStatusMentions: (content: import("../Types").WAProto.IMessage, jid: string, Private?: boolean) => Promise<string>
50
- sendAlbumMessage: (jid: string, medias: import("../Types").WAProto.IMessage, options?: import("../Types").MiscMessageGenerationOptions) => Promise<string>
51
- sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>
52
- groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>
53
- groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>
54
- groupLeave: (id: string) => Promise<void>
55
- groupUpdateSubject: (jid: string, subject: string) => Promise<void>
56
- groupRequestParticipantsList: (jid: string) => Promise<{
57
- [key: string]: string
58
- }[]>
59
- groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "reject" | "approve") => Promise<{
60
- status: string
61
- jid: string
62
- }[]>
63
- groupParticipantsUpdate: (jid: string, participants: string[], action: import("../Types").ParticipantAction) => Promise<{
64
- status: string
65
- jid: string
66
- content: BinaryNode
67
- }[]>
68
- subscribeNewsletterUpdates: (jid: string) => Promise<{
69
- duration: string
70
- }>
71
- newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>
72
- newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>
73
- newsletterUpdateName: (jid: string, name: string) => Promise<void>
74
- newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>
75
- newsletterRemovePicture: (jid: string) => Promise<void>
76
- newsletterUnfollow: (jid: string) => Promise<void>
77
- newsletterFollow: (jid: string) => Promise<void>
78
- newsletterUnmute: (jid: string) => Promise<void>
79
- newsletterMute: (jid: string) => Promise<void>
80
- newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>
81
- newsletterQuery: (jid: string, type: string, content: BinaryNode) => Promise<BinaryNode>
82
- newsletterWMexQuery: (jid?: string | undefined, query_id: number, content: BinaryNode) => Promise<BinaryNode>
83
- newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>
84
- newsletterAdminCount: (jid: string) => Promise<number>
85
- newsletterChangeOwner: (jid: string, userLid: string) => Promise<void>
86
- newsletterDemote: (jid: string, userLid: string) => Promise<void>
87
- newsletterDelete: (jid: string) => Promise<void>
88
- newsletterReactMessage: (jid: string, server_id: string, code?: string | undefined) => Promise<void>
89
- newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>
90
- newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>
91
- groupQuery: (jid: string, type: string, content: BinaryNode) => Promise<BinaryNode>
92
- groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>
93
- groupInviteCode: (jid: string) => Promise<string | undefined>
94
- groupRevokeInvite: (jid: string) => Promise<string | undefined>
95
- groupAcceptInvite: (code: string) => Promise<string | undefined>
96
- groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>
97
- groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>
98
- groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>
99
- groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>
100
- groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>
101
- groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => Promise<void>
102
- groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>
103
- groupFetchAllParticipating: () => Promise<{
104
- [_: string]: import("../Types").GroupMetadata
105
- }>
106
- processingMutex: {
107
- mutex<T>(code: () => T | Promise<T>): Promise<T>
108
- }
109
- upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>
110
- appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>
111
- sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>
112
- presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>
113
- getBotListV2: () => Promise<BotListInfo[]>
114
- getLidUser: (jid: string) => Promise<{
115
- lid: string
116
- id: string
117
- }[] | undefined>
118
- onWhatsApp: (...jids: string[]) => Promise<{
119
- jid: string
120
- exists: unknown
121
- }[] | undefined>
122
- fetchBlocklist: () => Promise<string[]>
123
- fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>
124
- fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>
125
- updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>
126
- removeProfilePicture: (jid: string) => Promise<void>
127
- updateProfileStatus: (status: string) => Promise<void>
128
- updateProfileName: (name: string) => Promise<void>
129
- updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>
130
- updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>
131
- updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>
132
- updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>
133
- updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>
134
- updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>
135
- updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>
136
- updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>
137
- updateDefaultDisappearingMode: (duration: number) => Promise<void>
138
- getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>
139
- resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>
140
- chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>
141
- cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>
142
- addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>
143
- addChatLabel: (jid: string, labelId: string) => Promise<void>
144
- removeChatLabel: (jid: string, labelId: string) => Promise<void>
145
- addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>
146
- removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>
147
- clearMessage: (jid: string, key: import("../Types").WAProto.IMessageKey, timeStamp: number | import("long").Long) => Promise<void>
148
- star: (jid: string, messages: {
149
- id: string
150
- fromMe?: boolean | undefined
151
- }[], star: boolean) => Promise<void>
152
- executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>
153
- type: "md"
154
- ws: import("./Client").WebSocketClient
155
- ev: import("../Types").BaileysEventEmitter & {
156
- process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void
157
- buffer(): void
158
- createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>
159
- flush(force?: boolean | undefined): boolean
160
- isBuffering(): boolean
161
- }
162
- authState: {
163
- creds: import("../Types").AuthenticationCreds
164
- keys: import("../Types").SignalKeyStoreWithTransaction
165
- }
166
- signalRepository: import("../Types").SignalRepository
167
- user: import("../Types").Contact | undefined
168
- generateMessageTag: () => string
169
- query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>
170
- waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>
171
- waitForSocketOpen: () => Promise<void>
172
- sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>
173
- sendNode: (frame: BinaryNode) => Promise<void>
174
- logout: (msg?: string | undefined) => Promise<void>
175
- end: (error: Error | undefined) => void
176
- onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void
177
- uploadPreKeys: (count?: number) => Promise<void>
178
- uploadPreKeysToServerIfRequired: () => Promise<void>
179
- requestPairingCode: (phoneNumber: string, code?: string) => Promise<string>
180
- waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>
181
- sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>
182
- }