riftcore 1.4.5 → 1.4.7

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 (115) hide show
  1. package/README.md +422 -0
  2. package/WAProto/index.js +79296 -118676
  3. package/example.js +13 -0
  4. package/lib/Defaults/baileys-version.json +2 -2
  5. package/lib/Defaults/index.d.ts +7 -16
  6. package/lib/Defaults/index.js +103 -90
  7. package/lib/Defaults/phonenumber-mcc.json +223 -0
  8. package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +2 -1
  9. package/lib/Socket/Client/index.d.ts +3 -2
  10. package/lib/Socket/Client/index.js +3 -2
  11. package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
  12. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  13. package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -2
  14. package/lib/Socket/Client/{websocket.js → web-socket-client.js} +5 -54
  15. package/lib/Socket/business.d.ts +58 -59
  16. package/lib/Socket/chats.d.ts +27 -29
  17. package/lib/Socket/chats.js +90 -97
  18. package/lib/Socket/erlanggaofficial.d.ts +219 -0
  19. package/lib/Socket/erlanggaofficial.js +439 -0
  20. package/lib/Socket/groups.d.ts +32 -41
  21. package/lib/Socket/groups.js +5 -20
  22. package/lib/Socket/index.d.ts +64 -63
  23. package/lib/Socket/index.js +2 -2
  24. package/lib/Socket/messages-recv.js +65 -9
  25. package/lib/Socket/messages-send.d.ts +47 -49
  26. package/lib/Socket/messages-send.js +377 -541
  27. package/lib/Socket/newsletter.d.ts +37 -39
  28. package/lib/Socket/newsletter.js +41 -73
  29. package/lib/Socket/registration.d.ts +267 -0
  30. package/lib/Socket/registration.js +166 -0
  31. package/lib/Socket/socket.d.ts +43 -270
  32. package/lib/Socket/socket.js +38 -62
  33. package/lib/Socket/usync.d.ts +3 -3
  34. package/lib/Store/index.d.ts +2 -1
  35. package/lib/Store/index.js +3 -1
  36. package/lib/Store/make-cache-manager-store.d.ts +13 -0
  37. package/lib/Store/make-cache-manager-store.js +83 -0
  38. package/lib/Store/make-in-memory-store.d.ts +24 -24
  39. package/lib/Store/make-in-memory-store.js +15 -27
  40. package/lib/Store/make-ordered-dictionary.d.ts +1 -1
  41. package/lib/Store/make-ordered-dictionary.js +2 -2
  42. package/lib/Types/Auth.d.ts +7 -0
  43. package/lib/Types/Call.d.ts +1 -1
  44. package/lib/Types/Chat.d.ts +7 -14
  45. package/lib/Types/Contact.d.ts +1 -5
  46. package/lib/Types/Events.d.ts +2 -44
  47. package/lib/Types/GroupMetadata.d.ts +2 -11
  48. package/lib/Types/Label.js +1 -1
  49. package/lib/Types/LabelAssociation.js +1 -1
  50. package/lib/Types/Message.d.ts +21 -148
  51. package/lib/Types/Message.js +2 -0
  52. package/lib/Types/Newsletter.d.ts +13 -0
  53. package/lib/Types/Newsletter.js +17 -3
  54. package/lib/Types/Socket.d.ts +9 -17
  55. package/lib/Types/index.d.ts +1 -8
  56. package/lib/Types/index.js +2 -2
  57. package/lib/Utils/auth-utils.d.ts +3 -3
  58. package/lib/Utils/auth-utils.js +13 -6
  59. package/lib/Utils/business.js +2 -2
  60. package/lib/Utils/chat-utils.d.ts +16 -15
  61. package/lib/Utils/chat-utils.js +35 -36
  62. package/lib/Utils/crypto.d.ts +16 -15
  63. package/lib/Utils/crypto.js +29 -71
  64. package/lib/Utils/decode-wa-message.d.ts +6 -22
  65. package/lib/Utils/decode-wa-message.js +56 -65
  66. package/lib/Utils/event-buffer.d.ts +2 -2
  67. package/lib/Utils/event-buffer.js +7 -11
  68. package/lib/Utils/generics.d.ts +20 -17
  69. package/lib/Utils/generics.js +23 -73
  70. package/lib/Utils/history.d.ts +0 -4
  71. package/lib/Utils/history.js +6 -4
  72. package/lib/Utils/link-preview.d.ts +2 -2
  73. package/lib/Utils/link-preview.js +1 -34
  74. package/lib/Utils/logger.d.ts +3 -10
  75. package/lib/Utils/lt-hash.d.ts +2 -2
  76. package/lib/Utils/lt-hash.js +6 -6
  77. package/lib/Utils/make-mutex.d.ts +2 -2
  78. package/lib/Utils/messages-media.d.ts +24 -28
  79. package/lib/Utils/messages-media.js +157 -406
  80. package/lib/Utils/messages.d.ts +10 -13
  81. package/lib/Utils/messages.js +48 -345
  82. package/lib/Utils/noise-handler.d.ts +12 -10
  83. package/lib/Utils/noise-handler.js +23 -18
  84. package/lib/Utils/process-message.d.ts +4 -5
  85. package/lib/Utils/process-message.js +25 -108
  86. package/lib/Utils/signal.d.ts +1 -2
  87. package/lib/Utils/signal.js +35 -37
  88. package/lib/Utils/use-multi-file-auth-state.d.ts +1 -0
  89. package/lib/Utils/use-multi-file-auth-state.js +6 -51
  90. package/lib/Utils/validate-connection.d.ts +4 -3
  91. package/lib/Utils/validate-connection.js +66 -90
  92. package/lib/WABinary/constants.d.ts +4 -4
  93. package/lib/WABinary/constants.js +13 -1276
  94. package/lib/WABinary/decode.d.ts +4 -3
  95. package/lib/WABinary/decode.js +13 -26
  96. package/lib/WABinary/encode.d.ts +2 -1
  97. package/lib/WABinary/encode.js +17 -39
  98. package/lib/WABinary/generic-utils.d.ts +3 -1
  99. package/lib/WABinary/generic-utils.js +10 -2
  100. package/lib/WABinary/jid-utils.d.ts +5 -11
  101. package/lib/WABinary/jid-utils.js +5 -28
  102. package/lib/WAM/BinaryInfo.d.ts +11 -2
  103. package/lib/WAM/encode.d.ts +2 -1
  104. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +1 -1
  105. package/lib/index.d.ts +2 -6
  106. package/lib/index.js +15 -31
  107. package/package.json +51 -39
  108. package/WAProto/GenerateStatics.sh +0 -4
  109. package/WAProto/WAProto.proto +0 -4775
  110. package/WAProto/index.d.ts +0 -55057
  111. package/WAProto/index.ts.ts +0 -53473
  112. package/lib/Socket/setup.js +0 -481
  113. package/lib/Socket/setup.ts +0 -623
  114. package/lib/WABinary/jid-utils.js.bak +0 -83
  115. /package/lib/Socket/Client/{types.js → abstract-socket-client.js} +0 -0
package/example.js ADDED
@@ -0,0 +1,13 @@
1
+ const [currentMajor] = process.versions.node.split('.').map(Number);
2
+
3
+ if (currentMajor < 20) {
4
+ console.error(`
5
+ 🚫 Unsupported Node.js version detected!
6
+
7
+ • Required : Node.js v20 or newer
8
+ • Current : v${process.versions.node}
9
+
10
+ 👉 Please install Node.js 20+ to continue.
11
+ `);
12
+ process.exit(1);
13
+ }
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": [2, 3000, 1027934701]
3
- }
2
+ "version": [2, 3000, 1023223821]
3
+ }
@@ -1,24 +1,18 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
1
3
  import { proto } from '../../WAProto';
2
- import type { MediaType, SocketConfig, WAVersion } from '../Types';
3
-
4
+ import type { MediaType, SocketConfig } from '../Types';
4
5
  export declare const UNAUTHORIZED_CODES: number[];
5
6
  export declare const DEFAULT_ORIGIN = "https://web.whatsapp.com";
6
- export declare const CALL_VIDEO_PREFIX = "https://call.whatsapp.com/video/";
7
- export declare const CALL_AUDIO_PREFIX = "https://call.whatsapp.com/voice/";
8
7
  export declare const DEF_CALLBACK_PREFIX = "CB:";
9
8
  export declare const DEF_TAG_PREFIX = "TAG:";
10
9
  export declare const PHONE_CONNECTION_CB = "CB:Pong";
11
-
12
- export declare const WA_ADV_ACCOUNT_SIG_PREFIX: Buffer;
13
- export declare const WA_ADV_DEVICE_SIG_PREFIX: Buffer;
14
- export declare const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX: Buffer;
15
- export declare const WA_ADV_HOSTED_DEVICE_SIG_PREFIX: Buffer;
16
-
17
10
  export declare const WA_DEFAULT_EPHEMERAL: number;
18
11
  export declare const NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\0\0\0\0";
19
- export declare const DICT_VERSION = 3;
12
+ export declare const DICT_VERSION = 2;
20
13
  export declare const KEY_BUNDLE_TYPE: Buffer;
21
14
  export declare const NOISE_WA_HEADER: Buffer;
15
+ /** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
22
16
  export declare const URL_REGEX: RegExp;
23
17
  export declare const WA_CERT_DETAILS: {
24
18
  SERIAL: number;
@@ -47,13 +41,10 @@ export declare const MEDIA_HKDF_KEY_MAPPING: {
47
41
  'product-catalog-image': string;
48
42
  'payment-bg-image': string;
49
43
  ptv: string;
50
- 'biz-cover-photo': string;
51
44
  };
52
- export declare const MEDIA_KEYS: MediaType[];
45
+ export declare const MEDIA_KEYS: ("ppic" | "product" | "image" | "video" | "sticker" | "audio" | "gif" | "ptt" | "thumbnail-document" | "thumbnail-image" | "thumbnail-link" | "thumbnail-video" | "md-app-state" | "md-msg-hist" | "document" | "product-catalog-image" | "payment-bg-image" | "ptv")[];
53
46
  export declare const MIN_PREKEY_COUNT = 5;
54
- export declare const INITIAL_PREKEY_COUNT = 812;
55
- export declare const UPLOAD_TIMEOUT = 30000;
56
- export declare const MIN_UPLOAD_INTERVAL = 5000;
47
+ export declare const INITIAL_PREKEY_COUNT = 30;
57
48
  export declare const DEFAULT_CACHE_TTLS: {
58
49
  SIGNAL_STORE: number;
59
50
  MSG_RETRY: number;
@@ -1,117 +1,130 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
1
+ var __importDefault = this && this.__importDefault || function (a) {
2
+ return a && a.__esModule ? a : { "default": a }
4
3
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DEFAULT_CACHE_TTLS = exports.MIN_UPLOAD_INTERVAL = exports.UPLOAD_TIMEOUT = exports.INITIAL_PREKEY_COUNT = exports.MIN_PREKEY_COUNT = exports.MEDIA_KEYS = exports.MEDIA_HKDF_KEY_MAPPING = exports.MEDIA_PATH_MAP = exports.DEFAULT_CONNECTION_CONFIG = exports.PROCESSABLE_HISTORY_TYPES = exports.WA_CERT_DETAILS = exports.URL_REGEX = exports.NOISE_WA_HEADER = exports.KEY_BUNDLE_TYPE = exports.DICT_VERSION = exports.NOISE_MODE = exports.WA_DEFAULT_EPHEMERAL = exports.PHONE_CONNECTION_CB = exports.DEF_TAG_PREFIX = exports.DEF_CALLBACK_PREFIX = exports.CALL_AUDIO_PREFIX = exports.CALL_VIDEO_PREFIX = exports.DEFAULT_ORIGIN = exports.WA_ADV_HOSTED_DEVICE_SIG_PREFIX = exports.WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = exports.WA_ADV_DEVICE_SIG_PREFIX = exports.WA_ADV_ACCOUNT_SIG_PREFIX = exports.UNAUTHORIZED_CODES = void 0;
7
- const WAProto_1 = require("../../WAProto");
8
- const libsignal_1 = require("../Signal/libsignal");
9
- const Utils_1 = require("../Utils");
10
- const logger_1 = __importDefault(require("../Utils/logger"));
11
- const version = [2, 3000, 1027934701];
4
+
5
+ Object.defineProperty(exports, "__esModule", { value: !0 });
6
+
7
+ exports.DEFAULT_CACHE_TTLS =
8
+ exports.INITIAL_PREKEY_COUNT =
9
+ exports.MIN_PREKEY_COUNT =
10
+ exports.MEDIA_KEYS =
11
+ exports.MEDIA_HKDF_KEY_MAPPING =
12
+ exports.MEDIA_PATH_MAP =
13
+ exports.DEFAULT_CONNECTION_CONFIG =
14
+ exports.PROCESSABLE_HISTORY_TYPES =
15
+ exports.WA_CERT_DETAILS =
16
+ exports.URL_REGEX =
17
+ exports.NOISE_WA_HEADER =
18
+ exports.KEY_BUNDLE_TYPE =
19
+ exports.DICT_VERSION =
20
+ exports.NOISE_MODE =
21
+ exports.WA_DEFAULT_EPHEMERAL =
22
+ exports.PHONE_CONNECTION_CB =
23
+ exports.DEF_TAG_PREFIX =
24
+ exports.DEF_CALLBACK_PREFIX =
25
+ exports.DEFAULT_ORIGIN =
26
+ exports.UNAUTHORIZED_CODES =
27
+ void 0;
28
+
29
+ const WAProto_1 = require("../../WAProto"),
30
+ libsignal_1 = require("../Signal/libsignal"),
31
+ Utils_1 = require("../Utils"),
32
+ logger_1 = __importDefault(require("../Utils/logger")),
33
+ baileys_version_json_1 = require("./baileys-version.json");
34
+
12
35
  exports.UNAUTHORIZED_CODES = [401, 403, 419];
13
- exports.DEFAULT_ORIGIN = 'https://web.whatsapp.com';
14
- exports.CALL_VIDEO_PREFIX = 'https://call.whatsapp.com/video/';
15
- exports.CALL_AUDIO_PREFIX = 'https://call.whatsapp.com/voice/';
16
- exports.DEF_CALLBACK_PREFIX = 'CB:';
17
- exports.DEF_TAG_PREFIX = 'TAG:';
18
- exports.PHONE_CONNECTION_CB = 'CB:Pong';
19
- exports.WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0]);
20
- exports.WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1]);
21
- exports.WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5]);
22
- exports.WA_ADV_HOSTED_DEVICE_SIG_PREFIX = Buffer.from([6, 6]);
23
- exports.WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60;
24
- exports.NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0';
25
- exports.DICT_VERSION = 3;
36
+ exports.DEFAULT_ORIGIN = "https://web.whatsapp.com";
37
+ exports.DEF_CALLBACK_PREFIX = "CB:";
38
+ exports.DEF_TAG_PREFIX = "TAG:";
39
+ exports.PHONE_CONNECTION_CB = "CB:Pong";
40
+ exports.WA_DEFAULT_EPHEMERAL = 604800;
41
+ exports.NOISE_MODE = "Noise_XX_25519_AESGCM_SHA256\x00\x00\x00\x00";
42
+ exports.DICT_VERSION = 2;
26
43
  exports.KEY_BUNDLE_TYPE = Buffer.from([5]);
27
44
  exports.NOISE_WA_HEADER = Buffer.from([87, 65, 6, exports.DICT_VERSION]);
45
+
28
46
  exports.URL_REGEX = /https:\/\/(?![^:@\/\s]+:[^:@\/\s]+@)[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^\s]*)?/g;
29
- exports.WA_CERT_DETAILS = {
30
- SERIAL: 0,
31
- };
47
+ exports.WA_CERT_DETAILS = { SERIAL: 0 };
48
+
32
49
  exports.PROCESSABLE_HISTORY_TYPES = [
33
50
  WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.INITIAL_BOOTSTRAP,
34
51
  WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.PUSH_NAME,
35
52
  WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.RECENT,
36
53
  WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.FULL,
37
- WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.ON_DEMAND,
54
+ WAProto_1.proto.Message.HistorySyncNotification.HistorySyncType.ON_DEMAND
38
55
  ];
56
+
39
57
  exports.DEFAULT_CONNECTION_CONFIG = {
40
- version: version,
41
- browser: Utils_1.Browsers.ubuntu('Chrome'),
42
- waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
43
- connectTimeoutMs: 20000,
44
- keepAliveIntervalMs: 30000,
45
- logger: logger_1.default.child({ class: 'baileys' }),
46
- printQRInTerminal: false,
47
- emitOwnEvents: true,
48
- defaultQueryTimeoutMs: 60000,
58
+ version: baileys_version_json_1.version,
59
+ browser: Utils_1.Browsers.ubuntu("Chrome"),
60
+ waWebSocketUrl: "wss://web.whatsapp.com/ws/chat",
61
+ connectTimeoutMs: 2E4,
62
+ keepAliveIntervalMs: 3E4,
63
+ logger: logger_1.default.child({ class: "baileys" }),
64
+ printQRInTerminal: !1,
65
+ emitOwnEvents: !0,
66
+ defaultQueryTimeoutMs: 6E4,
49
67
  customUploadHosts: [],
50
68
  retryRequestDelayMs: 250,
51
69
  maxMsgRetryCount: 5,
52
- fireInitQueries: true,
53
- auth: undefined,
54
- markOnlineOnConnect: true,
55
- syncFullHistory: true,
56
- patchMessageBeforeSending: msg => msg,
57
- shouldSyncHistoryMessage: () => true,
58
- shouldIgnoreJid: () => false,
70
+ fireInitQueries: !0,
71
+ auth: void 0,
72
+ markOnlineOnConnect: !0,
73
+ syncFullHistory: !1,
74
+ patchMessageBeforeSending: a => a,
75
+ shouldSyncHistoryMessage: () => !0,
76
+ shouldIgnoreJid: () => !1,
59
77
  linkPreviewImageThumbnailWidth: 192,
60
- transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
61
- generateHighQualityLinkPreview: false,
62
- enableAutoSessionRecreation: true,
63
- enableRecentMessageCache: true,
78
+ transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3E3 },
79
+ generateHighQualityLinkPreview: !1,
64
80
  options: {},
65
- appStateMacVerification: {
66
- patch: false,
67
- snapshot: false,
68
- },
69
- countryCode: 'US',
70
- getMessage: async () => undefined,
71
- cachedGroupMetadata: async () => undefined,
81
+ appStateMacVerification: { patch: !1, snapshot: !1 },
82
+ countryCode: "US",
83
+ getMessage: async () => { },
84
+ cachedGroupMetadata: async () => { },
72
85
  makeSignalRepository: libsignal_1.makeLibSignalRepository
73
86
  };
87
+
74
88
  exports.MEDIA_PATH_MAP = {
75
- image: '/mms/image',
76
- video: '/mms/video',
77
- document: '/mms/document',
78
- audio: '/mms/audio',
79
- sticker: '/mms/image',
80
- 'thumbnail-link': '/mms/image',
81
- 'product-catalog-image': '/product/image',
82
- 'md-app-state': '',
83
- 'md-msg-hist': '/mms/md-app-state',
84
- 'biz-cover-photo': '/pps/biz-cover-photo'
89
+ image: "/mms/image",
90
+ video: "/mms/video",
91
+ document: "/mms/document",
92
+ audio: "/mms/audio",
93
+ sticker: "/mms/image",
94
+ "thumbnail-link": "/mms/image",
95
+ "product-catalog-image": "/product/image",
96
+ "md-app-state": "",
97
+ "md-msg-hist": "/mms/md-app-state"
85
98
  };
99
+
86
100
  exports.MEDIA_HKDF_KEY_MAPPING = {
87
- 'audio': 'Audio',
88
- 'document': 'Document',
89
- 'gif': 'Video',
90
- 'image': 'Image',
91
- 'ppic': '',
92
- 'product': 'Image',
93
- 'ptt': 'Audio',
94
- 'sticker': 'Image',
95
- 'video': 'Video',
96
- 'thumbnail-document': 'Document Thumbnail',
97
- 'thumbnail-image': 'Image Thumbnail',
98
- 'thumbnail-video': 'Video Thumbnail',
99
- 'thumbnail-link': 'Link Thumbnail',
100
- 'md-msg-hist': 'History',
101
- 'md-app-state': 'App State',
102
- 'product-catalog-image': '',
103
- 'payment-bg-image': 'Payment Background',
104
- 'ptv': 'Video',
105
- 'biz-cover-photo': 'Image'
101
+ audio: "Audio",
102
+ document: "Document",
103
+ gif: "Video",
104
+ image: "Image",
105
+ ppic: "",
106
+ product: "Image",
107
+ ptt: "Audio",
108
+ sticker: "Image",
109
+ video: "Video",
110
+ "thumbnail-document": "Document Thumbnail",
111
+ "thumbnail-image": "Image Thumbnail",
112
+ "thumbnail-video": "Video Thumbnail",
113
+ "thumbnail-link": "Link Thumbnail",
114
+ "md-msg-hist": "History",
115
+ "md-app-state": "App State",
116
+ "product-catalog-image": "",
117
+ "payment-bg-image": "Payment Background",
118
+ ptv: "Video"
106
119
  };
120
+
107
121
  exports.MEDIA_KEYS = Object.keys(exports.MEDIA_PATH_MAP);
108
122
  exports.MIN_PREKEY_COUNT = 5;
109
- exports.INITIAL_PREKEY_COUNT = 812;
110
- exports.UPLOAD_TIMEOUT = 30000;
111
- exports.MIN_UPLOAD_INTERVAL = 5000;
123
+ exports.INITIAL_PREKEY_COUNT = 30;
124
+
112
125
  exports.DEFAULT_CACHE_TTLS = {
113
- SIGNAL_STORE: 5 * 60,
114
- MSG_RETRY: 60 * 60,
115
- CALL_OFFER: 5 * 60,
116
- USER_DEVICES: 5 * 60,
126
+ SIGNAL_STORE: 300,
127
+ MSG_RETRY: 3600,
128
+ CALL_OFFER: 300,
129
+ USER_DEVICES: 300
117
130
  };
@@ -0,0 +1,223 @@
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 +1,5 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
1
3
  import { EventEmitter } from 'events';
2
4
  import { URL } from 'url';
3
5
  import { SocketConfig } from '../../Types';
@@ -11,6 +13,5 @@ export declare abstract class AbstractSocketClient extends EventEmitter {
11
13
  constructor(url: URL, config: SocketConfig);
12
14
  abstract connect(): Promise<void>;
13
15
  abstract close(): Promise<void>;
14
- abstract restart(): Promise<void>;
15
16
  abstract send(str: Uint8Array | string, cb?: (err?: Error) => void): boolean;
16
17
  }
@@ -1,2 +1,3 @@
1
- export * from './types';
2
- export * from './websocket';
1
+ export * from './abstract-socket-client';
2
+ export * from './mobile-socket-client';
3
+ export * from './web-socket-client';
@@ -14,5 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types"), exports);
18
- __exportStar(require("./websocket"), exports);
17
+ __exportStar(require("./abstract-socket-client"), exports);
18
+ __exportStar(require("./mobile-socket-client"), exports);
19
+ __exportStar(require("./web-socket-client"), exports);
@@ -0,0 +1,13 @@
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
+ }
@@ -0,0 +1,65 @@
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,5 +1,5 @@
1
1
  import WebSocket from 'ws';
2
- import { AbstractSocketClient } from './types';
2
+ import { AbstractSocketClient } from './abstract-socket-client';
3
3
  export declare class WebSocketClient extends AbstractSocketClient {
4
4
  protected socket: WebSocket | null;
5
5
  get isOpen(): boolean;
@@ -8,6 +8,5 @@ export declare class WebSocketClient extends AbstractSocketClient {
8
8
  get isConnecting(): boolean;
9
9
  connect(): Promise<void>;
10
10
  close(): Promise<void>;
11
- restart(): Promise<void>;
12
11
  send(str: string | Uint8Array, cb?: (err?: Error) => void): boolean;
13
12
  }