lordceaser-baileys 2.0.39 → 2.0.41

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 (155) hide show
  1. package/index.js +59 -412
  2. package/package.json +8 -3
  3. package/WAProto/GenerateStatics.sh +0 -4
  4. package/WAProto/WAProto.proto +0 -3344
  5. package/WAProto/index.d.ts +0 -37016
  6. package/WAProto/index.js +0 -101044
  7. package/WASignalGroup/GroupProtocol.js +0 -1697
  8. package/WASignalGroup/ciphertext_message.js +0 -16
  9. package/WASignalGroup/group_cipher.js +0 -120
  10. package/WASignalGroup/group_session_builder.js +0 -46
  11. package/WASignalGroup/index.js +0 -5
  12. package/WASignalGroup/keyhelper.js +0 -21
  13. package/WASignalGroup/protobufs.js +0 -3
  14. package/WASignalGroup/queue_job.js +0 -69
  15. package/WASignalGroup/sender_chain_key.js +0 -50
  16. package/WASignalGroup/sender_key_distribution_message.js +0 -78
  17. package/WASignalGroup/sender_key_message.js +0 -92
  18. package/WASignalGroup/sender_key_name.js +0 -70
  19. package/WASignalGroup/sender_key_record.js +0 -56
  20. package/WASignalGroup/sender_key_state.js +0 -129
  21. package/WASignalGroup/sender_message_key.js +0 -39
  22. package/lib/Defaults/baileys-version.json +0 -3
  23. package/lib/Defaults/index.d.ts +0 -283
  24. package/lib/Defaults/index.js +0 -121
  25. package/lib/Defaults/phonenumber-mcc.json +0 -223
  26. package/lib/Signal/libsignal.d.ts +0 -3
  27. package/lib/Signal/libsignal.js +0 -152
  28. package/lib/Socket/Client/abstract-socket-client.d.ts +0 -17
  29. package/lib/Socket/Client/abstract-socket-client.js +0 -13
  30. package/lib/Socket/Client/index.d.ts +0 -3
  31. package/lib/Socket/Client/index.js +0 -19
  32. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
  33. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  34. package/lib/Socket/Client/web-socket-client.d.ts +0 -12
  35. package/lib/Socket/Client/web-socket-client.js +0 -62
  36. package/lib/Socket/business.d.ts +0 -148
  37. package/lib/Socket/business.js +0 -260
  38. package/lib/Socket/chats.d.ts +0 -83
  39. package/lib/Socket/chats.js +0 -879
  40. package/lib/Socket/groups.d.ts +0 -123
  41. package/lib/Socket/groups.js +0 -314
  42. package/lib/Socket/index.d.ts +0 -150
  43. package/lib/Socket/index.js +0 -10
  44. package/lib/Socket/messages-recv.d.ts +0 -135
  45. package/lib/Socket/messages-recv.js +0 -867
  46. package/lib/Socket/messages-send.d.ts +0 -128
  47. package/lib/Socket/messages-send.js +0 -677
  48. package/lib/Socket/registration.d.ts +0 -242
  49. package/lib/Socket/registration.js +0 -166
  50. package/lib/Socket/socket.d.ts +0 -43
  51. package/lib/Socket/socket.js +0 -619
  52. package/lib/Store/index.d.ts +0 -3
  53. package/lib/Store/index.js +0 -10
  54. package/lib/Store/make-cache-manager-store.d.ts +0 -14
  55. package/lib/Store/make-cache-manager-store.js +0 -83
  56. package/lib/Store/make-in-memory-store.d.ts +0 -118
  57. package/lib/Store/make-in-memory-store.js +0 -422
  58. package/lib/Store/make-ordered-dictionary.d.ts +0 -13
  59. package/lib/Store/make-ordered-dictionary.js +0 -81
  60. package/lib/Store/object-repository.d.ts +0 -10
  61. package/lib/Store/object-repository.js +0 -27
  62. package/lib/Types/Auth.d.ts +0 -110
  63. package/lib/Types/Auth.js +0 -2
  64. package/lib/Types/Call.d.ts +0 -13
  65. package/lib/Types/Call.js +0 -2
  66. package/lib/Types/Chat.d.ts +0 -107
  67. package/lib/Types/Chat.js +0 -4
  68. package/lib/Types/Contact.d.ts +0 -19
  69. package/lib/Types/Contact.js +0 -2
  70. package/lib/Types/Events.d.ts +0 -172
  71. package/lib/Types/Events.js +0 -2
  72. package/lib/Types/GroupMetadata.d.ts +0 -56
  73. package/lib/Types/GroupMetadata.js +0 -2
  74. package/lib/Types/Label.d.ts +0 -46
  75. package/lib/Types/Label.js +0 -27
  76. package/lib/Types/LabelAssociation.d.ts +0 -29
  77. package/lib/Types/LabelAssociation.js +0 -9
  78. package/lib/Types/Message.d.ts +0 -268
  79. package/lib/Types/Message.js +0 -9
  80. package/lib/Types/Product.d.ts +0 -78
  81. package/lib/Types/Product.js +0 -2
  82. package/lib/Types/Signal.d.ts +0 -57
  83. package/lib/Types/Signal.js +0 -2
  84. package/lib/Types/Socket.d.ts +0 -116
  85. package/lib/Types/Socket.js +0 -2
  86. package/lib/Types/State.d.ts +0 -27
  87. package/lib/Types/State.js +0 -2
  88. package/lib/Types/index.d.ts +0 -63
  89. package/lib/Types/index.js +0 -41
  90. package/lib/Utils/auth-utils.d.ts +0 -18
  91. package/lib/Utils/auth-utils.js +0 -206
  92. package/lib/Utils/baileys-event-stream.d.ts +0 -16
  93. package/lib/Utils/baileys-event-stream.js +0 -63
  94. package/lib/Utils/business.d.ts +0 -22
  95. package/lib/Utils/business.js +0 -234
  96. package/lib/Utils/chat-utils.d.ts +0 -71
  97. package/lib/Utils/chat-utils.js +0 -740
  98. package/lib/Utils/crypto.d.ts +0 -41
  99. package/lib/Utils/crypto.js +0 -153
  100. package/lib/Utils/decode-wa-message.d.ts +0 -20
  101. package/lib/Utils/decode-wa-message.js +0 -188
  102. package/lib/Utils/event-buffer.d.ts +0 -35
  103. package/lib/Utils/event-buffer.js +0 -520
  104. package/lib/Utils/generics.d.ts +0 -89
  105. package/lib/Utils/generics.js +0 -394
  106. package/lib/Utils/history.d.ts +0 -19
  107. package/lib/Utils/history.js +0 -94
  108. package/lib/Utils/index.d.ts +0 -17
  109. package/lib/Utils/index.js +0 -33
  110. package/lib/Utils/link-preview.d.ts +0 -21
  111. package/lib/Utils/link-preview.js +0 -93
  112. package/lib/Utils/logger.d.ts +0 -4
  113. package/lib/Utils/logger.js +0 -7
  114. package/lib/Utils/lt-hash.d.ts +0 -12
  115. package/lib/Utils/lt-hash.js +0 -51
  116. package/lib/Utils/make-mutex.d.ts +0 -7
  117. package/lib/Utils/make-mutex.js +0 -43
  118. package/lib/Utils/messages-media.d.ts +0 -107
  119. package/lib/Utils/messages-media.js +0 -674
  120. package/lib/Utils/messages.d.ts +0 -77
  121. package/lib/Utils/messages.js +0 -758
  122. package/lib/Utils/noise-handler.d.ts +0 -21
  123. package/lib/Utils/noise-handler.js +0 -155
  124. package/lib/Utils/process-message.d.ts +0 -42
  125. package/lib/Utils/process-message.js +0 -354
  126. package/lib/Utils/signal.d.ts +0 -32
  127. package/lib/Utils/signal.js +0 -161
  128. package/lib/Utils/use-multi-file-auth-state.d.ts +0 -12
  129. package/lib/Utils/use-multi-file-auth-state.js +0 -93
  130. package/lib/Utils/validate-connection.d.ts +0 -11
  131. package/lib/Utils/validate-connection.js +0 -205
  132. package/lib/WABinary/constants.d.ts +0 -27
  133. package/lib/WABinary/constants.js +0 -40
  134. package/lib/WABinary/decode.d.ts +0 -7
  135. package/lib/WABinary/decode.js +0 -254
  136. package/lib/WABinary/encode.d.ts +0 -3
  137. package/lib/WABinary/encode.js +0 -232
  138. package/lib/WABinary/generic-utils.d.ts +0 -15
  139. package/lib/WABinary/generic-utils.js +0 -110
  140. package/lib/WABinary/index.d.ts +0 -5
  141. package/lib/WABinary/index.js +0 -21
  142. package/lib/WABinary/jid-utils.d.ts +0 -31
  143. package/lib/WABinary/jid-utils.js +0 -62
  144. package/lib/WABinary/types.d.ts +0 -18
  145. package/lib/WABinary/types.js +0 -2
  146. package/lib/WAM/BinaryInfo.d.ts +0 -17
  147. package/lib/WAM/BinaryInfo.js +0 -13
  148. package/lib/WAM/constants.d.ts +0 -38
  149. package/lib/WAM/constants.js +0 -15350
  150. package/lib/WAM/encode.d.ts +0 -3
  151. package/lib/WAM/encode.js +0 -155
  152. package/lib/WAM/index.d.ts +0 -3
  153. package/lib/WAM/index.js +0 -19
  154. package/lib/index.d.ts +0 -11
  155. package/lib/index.js +0 -30
@@ -1,223 +0,0 @@
1
- {
2
- "93": 412,
3
- "355": 276,
4
- "213": 603,
5
- "1-684": 544,
6
- "376": 213,
7
- "244": 631,
8
- "1-264": 365,
9
- "1-268": 344,
10
- "54": 722,
11
- "374": 283,
12
- "297": 363,
13
- "61": 505,
14
- "43": 232,
15
- "994": 400,
16
- "1-242": 364,
17
- "973": 426,
18
- "880": 470,
19
- "1-246": 342,
20
- "375": 257,
21
- "32": 206,
22
- "501": 702,
23
- "229": 616,
24
- "1-441": 350,
25
- "975": 402,
26
- "591": 736,
27
- "387": 218,
28
- "267": 652,
29
- "55": 724,
30
- "1-284": 348,
31
- "673": 528,
32
- "359": 284,
33
- "226": 613,
34
- "257": 642,
35
- "855": 456,
36
- "237": 624,
37
- "238": 625,
38
- "1-345": 346,
39
- "236": 623,
40
- "235": 622,
41
- "56": 730,
42
- "86": 454,
43
- "57": 732,
44
- "269": 654,
45
- "682": 548,
46
- "506": 712,
47
- "385": 219,
48
- "53": 368,
49
- "357": 280,
50
- "420": 230,
51
- "243": 630,
52
- "45": 238,
53
- "253": 638,
54
- "1-767": 366,
55
- "1-809": 370,
56
- "1-849": 370,
57
- "1-829": 370,
58
- "593": 740,
59
- "20": 602,
60
- "503": 706,
61
- "240": 627,
62
- "291": 657,
63
- "372": 248,
64
- "251": 636,
65
- "500": 750,
66
- "298": 288,
67
- "679": 542,
68
- "358": 244,
69
- "33": 208,
70
- "689": 547,
71
- "241": 628,
72
- "220": 607,
73
- "995": 282,
74
- "49": 262,
75
- "233": 620,
76
- "350": 266,
77
- "30": 202,
78
- "299": 290,
79
- "1-473": 352,
80
- "1-671": 535,
81
- "502": 704,
82
- "224": 537,
83
- "592": 738,
84
- "509": 372,
85
- "504": 708,
86
- "852": 454,
87
- "36": 216,
88
- "354": 274,
89
- "91": 404,
90
- "62": 510,
91
- "98": 432,
92
- "964": 418,
93
- "353": 234,
94
- "972": 425,
95
- "39": 222,
96
- "225": 612,
97
- "1-876": 338,
98
- "81": 440,
99
- "962": 416,
100
- "254": 639,
101
- "686": 545,
102
- "383": 221,
103
- "965": 419,
104
- "371": 247,
105
- "961": 415,
106
- "266": 651,
107
- "231": 618,
108
- "218": 606,
109
- "423": 295,
110
- "370": 246,
111
- "352": 270,
112
- "389": 294,
113
- "261": 646,
114
- "265": 650,
115
- "60": 502,
116
- "960": 472,
117
- "223": 610,
118
- "356": 278,
119
- "692": 551,
120
- "222": 609,
121
- "230": 617,
122
- "52": 334,
123
- "691": 550,
124
- "373": 259,
125
- "377": 212,
126
- "976": 428,
127
- "382": 297,
128
- "1-664": 354,
129
- "212": 604,
130
- "258": 643,
131
- "95": 414,
132
- "264": 649,
133
- "674": 536,
134
- "977": 429,
135
- "31": 204,
136
- "687": 546,
137
- "64": 530,
138
- "505": 710,
139
- "227": 614,
140
- "234": 621,
141
- "683": 555,
142
- "1-670": 534,
143
- "47": 242,
144
- "968": 226,
145
- "92": 410,
146
- "680": 552,
147
- "970": 423,
148
- "507": 714,
149
- "675": 537,
150
- "595": 744,
151
- "51": 716,
152
- "63": 515,
153
- "48": 260,
154
- "351": 268,
155
- "1-787, 1-939": 330,
156
- "974": 427,
157
- "242": 630,
158
- "40": 226,
159
- "7": 250,
160
- "250": 635,
161
- "290": 658,
162
- "1-869": 356,
163
- "1-758": 358,
164
- "508": 308,
165
- "1-784": 360,
166
- "685": 544,
167
- "378": 292,
168
- "239": 626,
169
- "966": 420,
170
- "221": 608,
171
- "381": 220,
172
- "248": 633,
173
- "232": 619,
174
- "65": 525,
175
- "386": 293,
176
- "677": 540,
177
- "27": 655,
178
- "211": 659,
179
- "34": 214,
180
- "94": 413,
181
- "249": 634,
182
- "597": 746,
183
- "268": 653,
184
- "46": 240,
185
- "41": 228,
186
- "963": 417,
187
- "886": 466,
188
- "992": 436,
189
- "255": 640,
190
- "66": 520,
191
- "228": 615,
192
- "690": 554,
193
- "676": 539,
194
- "1-868": 374,
195
- "216": 605,
196
- "90": 286,
197
- "993": 438,
198
- "1-649": 376,
199
- "688": 553,
200
- "1-340": 332,
201
- "256": 641,
202
- "380": 255,
203
- "971": 424,
204
- "44": 234,
205
- "1": 310,
206
- "598": 748,
207
- "998": 434,
208
- "678": 541,
209
- "379": 225,
210
- "58": 734,
211
- "681": 543,
212
- "967": 421,
213
- "260": 645,
214
- "263": 648,
215
- "670": 514,
216
- "245": 632,
217
- "856": 457,
218
- "599": 362,
219
- "850": 467,
220
- "262": 647,
221
- "82": 450,
222
- "84": 452
223
- }
@@ -1,3 +0,0 @@
1
- import { SignalAuthState } from '../Types';
2
- import { SignalRepository } from '../Types/Signal';
3
- export declare function makeLibSignalRepository(auth: SignalAuthState): SignalRepository;
@@ -1,152 +0,0 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.makeLibSignalRepository = void 0;
27
- const libsignal = __importStar(require("libsignal"));
28
- const WASignalGroup_1 = require("../../WASignalGroup");
29
- const Utils_1 = require("../Utils");
30
- const WABinary_1 = require("../WABinary");
31
- function makeLibSignalRepository(auth) {
32
- const storage = signalStorage(auth);
33
- return {
34
- decryptGroupMessage({ group, authorJid, msg }) {
35
- const senderName = jidToSignalSenderKeyName(group, authorJid);
36
- const cipher = new WASignalGroup_1.GroupCipher(storage, senderName);
37
- return cipher.decrypt(msg);
38
- },
39
- async processSenderKeyDistributionMessage({ item, authorJid }) {
40
- const builder = new WASignalGroup_1.GroupSessionBuilder(storage);
41
- const senderName = jidToSignalSenderKeyName(item.groupId, authorJid);
42
- const senderMsg = new WASignalGroup_1.SenderKeyDistributionMessage(null, null, null, null, item.axolotlSenderKeyDistributionMessage);
43
- const { [senderName]: senderKey } = await auth.keys.get('sender-key', [senderName]);
44
- if (!senderKey) {
45
- await storage.storeSenderKey(senderName, new WASignalGroup_1.SenderKeyRecord());
46
- }
47
- await builder.process(senderName, senderMsg);
48
- },
49
- async decryptMessage({ jid, type, ciphertext }) {
50
- const addr = jidToSignalProtocolAddress(jid);
51
- const session = new libsignal.SessionCipher(storage, addr);
52
- let result;
53
- switch (type) {
54
- case 'pkmsg':
55
- result = await session.decryptPreKeyWhisperMessage(ciphertext);
56
- break;
57
- case 'msg':
58
- result = await session.decryptWhisperMessage(ciphertext);
59
- break;
60
- }
61
- return result;
62
- },
63
- async encryptMessage({ jid, data }) {
64
- const addr = jidToSignalProtocolAddress(jid);
65
- const cipher = new libsignal.SessionCipher(storage, addr);
66
- const { type: sigType, body } = await cipher.encrypt(data);
67
- const type = sigType === 3 ? 'pkmsg' : 'msg';
68
- return { type, ciphertext: Buffer.from(body, 'binary') };
69
- },
70
- async encryptGroupMessage({ group, meId, data }) {
71
- const senderName = jidToSignalSenderKeyName(group, meId);
72
- const builder = new WASignalGroup_1.GroupSessionBuilder(storage);
73
- const { [senderName]: senderKey } = await auth.keys.get('sender-key', [senderName]);
74
- if (!senderKey) {
75
- await storage.storeSenderKey(senderName, new WASignalGroup_1.SenderKeyRecord());
76
- }
77
- const senderKeyDistributionMessage = await builder.create(senderName);
78
- const session = new WASignalGroup_1.GroupCipher(storage, senderName);
79
- const ciphertext = await session.encrypt(data);
80
- return {
81
- ciphertext,
82
- senderKeyDistributionMessage: senderKeyDistributionMessage.serialize(),
83
- };
84
- },
85
- async injectE2ESession({ jid, session }) {
86
- const cipher = new libsignal.SessionBuilder(storage, jidToSignalProtocolAddress(jid));
87
- await cipher.initOutgoing(session);
88
- },
89
- jidToSignalProtocolAddress(jid) {
90
- return jidToSignalProtocolAddress(jid).toString();
91
- },
92
- };
93
- }
94
- exports.makeLibSignalRepository = makeLibSignalRepository;
95
- const jidToSignalProtocolAddress = (jid) => {
96
- const { user, device } = (0, WABinary_1.jidDecode)(jid);
97
- return new libsignal.ProtocolAddress(user, device || 0);
98
- };
99
- const jidToSignalSenderKeyName = (group, user) => {
100
- return new WASignalGroup_1.SenderKeyName(group, jidToSignalProtocolAddress(user)).toString();
101
- };
102
- function signalStorage({ creds, keys }) {
103
- return {
104
- loadSession: async (id) => {
105
- const { [id]: sess } = await keys.get('session', [id]);
106
- if (sess) {
107
- return libsignal.SessionRecord.deserialize(sess);
108
- }
109
- },
110
- storeSession: async (id, session) => {
111
- await keys.set({ 'session': { [id]: session.serialize() } });
112
- },
113
- isTrustedIdentity: () => {
114
- return true;
115
- },
116
- loadPreKey: async (id) => {
117
- const keyId = id.toString();
118
- const { [keyId]: key } = await keys.get('pre-key', [keyId]);
119
- if (key) {
120
- return {
121
- privKey: Buffer.from(key.private),
122
- pubKey: Buffer.from(key.public)
123
- };
124
- }
125
- },
126
- removePreKey: (id) => keys.set({ 'pre-key': { [id]: null } }),
127
- loadSignedPreKey: () => {
128
- const key = creds.signedPreKey;
129
- return {
130
- privKey: Buffer.from(key.keyPair.private),
131
- pubKey: Buffer.from(key.keyPair.public)
132
- };
133
- },
134
- loadSenderKey: async (keyId) => {
135
- const { [keyId]: key } = await keys.get('sender-key', [keyId]);
136
- if (key) {
137
- return new WASignalGroup_1.SenderKeyRecord(key);
138
- }
139
- },
140
- storeSenderKey: async (keyId, key) => {
141
- await keys.set({ 'sender-key': { [keyId]: key.serialize() } });
142
- },
143
- getOurRegistrationId: () => (creds.registrationId),
144
- getOurIdentity: () => {
145
- const { signedIdentityKey } = creds;
146
- return {
147
- privKey: Buffer.from(signedIdentityKey.private),
148
- pubKey: (0, Utils_1.generateSignalPubKey)(signedIdentityKey.public),
149
- };
150
- }
151
- };
152
- }
@@ -1,17 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { EventEmitter } from 'events';
4
- import { URL } from 'url';
5
- import { SocketConfig } from '../../Types';
6
- export declare abstract class AbstractSocketClient extends EventEmitter {
7
- url: URL;
8
- config: SocketConfig;
9
- abstract get isOpen(): boolean;
10
- abstract get isClosed(): boolean;
11
- abstract get isClosing(): boolean;
12
- abstract get isConnecting(): boolean;
13
- constructor(url: URL, config: SocketConfig);
14
- abstract connect(): Promise<void>;
15
- abstract close(): Promise<void>;
16
- abstract send(str: Uint8Array | string, cb?: (err?: Error) => void): boolean;
17
- }
@@ -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,3 +0,0 @@
1
- export * from './abstract-socket-client';
2
- export * from './mobile-socket-client';
3
- export * from './web-socket-client';
@@ -1,19 +0,0 @@
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("./abstract-socket-client"), exports);
18
- __exportStar(require("./mobile-socket-client"), exports);
19
- __exportStar(require("./web-socket-client"), exports);
@@ -1,13 +0,0 @@
1
- /// <reference types="node" />
2
- import { Socket } from 'net';
3
- import { AbstractSocketClient } from './abstract-socket-client';
4
- export declare class MobileSocketClient extends AbstractSocketClient {
5
- protected socket: Socket | 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,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,12 +0,0 @@
1
- import WebSocket from 'ws';
2
- import { AbstractSocketClient } from './abstract-socket-client';
3
- export declare class WebSocketClient extends AbstractSocketClient {
4
- protected socket: WebSocket | 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,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;