xhyphersockets 1.4.3

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 (195) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +252 -0
  3. package/WAProto/GenerateStatics.sh +4 -0
  4. package/WAProto/WAProto.proto +4775 -0
  5. package/WAProto/index.d.ts +55057 -0
  6. package/WAProto/index.js +169661 -0
  7. package/WAProto/index.ts.ts +53473 -0
  8. package/engine-requirements.js +10 -0
  9. package/lib/Defaults/baileys-version.json +3 -0
  10. package/lib/Defaults/index.d.ts +51 -0
  11. package/lib/Defaults/index.js +106 -0
  12. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  13. package/lib/Signal/Group/ciphertext-message.js +15 -0
  14. package/lib/Signal/Group/group-session-builder.d.ts +14 -0
  15. package/lib/Signal/Group/group-session-builder.js +64 -0
  16. package/lib/Signal/Group/group_cipher.d.ts +17 -0
  17. package/lib/Signal/Group/group_cipher.js +96 -0
  18. package/lib/Signal/Group/index.d.ts +11 -0
  19. package/lib/Signal/Group/index.js +57 -0
  20. package/lib/Signal/Group/keyhelper.d.ts +10 -0
  21. package/lib/Signal/Group/keyhelper.js +55 -0
  22. package/lib/Signal/Group/queue-job.d.ts +1 -0
  23. package/lib/Signal/Group/queue-job.js +57 -0
  24. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  25. package/lib/Signal/Group/sender-chain-key.js +34 -0
  26. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  27. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  28. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  29. package/lib/Signal/Group/sender-key-message.js +69 -0
  30. package/lib/Signal/Group/sender-key-name.d.ts +17 -0
  31. package/lib/Signal/Group/sender-key-name.js +51 -0
  32. package/lib/Signal/Group/sender-key-record.d.ts +30 -0
  33. package/lib/Signal/Group/sender-key-record.js +53 -0
  34. package/lib/Signal/Group/sender-key-state.d.ts +38 -0
  35. package/lib/Signal/Group/sender-key-state.js +99 -0
  36. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  37. package/lib/Signal/Group/sender-message-key.js +29 -0
  38. package/lib/Signal/libsignal.d.ts +3 -0
  39. package/lib/Signal/libsignal.js +174 -0
  40. package/lib/Socket/Client/index.d.ts +2 -0
  41. package/lib/Socket/Client/index.js +18 -0
  42. package/lib/Socket/Client/types.d.ts +16 -0
  43. package/lib/Socket/Client/types.js +13 -0
  44. package/lib/Socket/Client/websocket.d.ts +13 -0
  45. package/lib/Socket/Client/websocket.js +111 -0
  46. package/lib/Socket/RHandler.d.ts +416 -0
  47. package/lib/Socket/RHandler.js +530 -0
  48. package/lib/Socket/business.d.ts +172 -0
  49. package/lib/Socket/business.js +260 -0
  50. package/lib/Socket/chats.d.ts +94 -0
  51. package/lib/Socket/chats.js +908 -0
  52. package/lib/Socket/groups.d.ts +124 -0
  53. package/lib/Socket/groups.js +332 -0
  54. package/lib/Socket/index.d.ts +172 -0
  55. package/lib/Socket/index.js +10 -0
  56. package/lib/Socket/messages-recv.d.ts +161 -0
  57. package/lib/Socket/messages-recv.js +1054 -0
  58. package/lib/Socket/messages-send.d.ts +152 -0
  59. package/lib/Socket/messages-send.js +903 -0
  60. package/lib/Socket/newsletter.d.ts +136 -0
  61. package/lib/Socket/newsletter.js +303 -0
  62. package/lib/Socket/socket.d.ts +43 -0
  63. package/lib/Socket/socket.js +654 -0
  64. package/lib/Socket/usync.d.ts +36 -0
  65. package/lib/Socket/usync.js +70 -0
  66. package/lib/Store/index.d.ts +2 -0
  67. package/lib/Store/index.js +8 -0
  68. package/lib/Store/make-in-memory-store.d.ts +118 -0
  69. package/lib/Store/make-in-memory-store.js +439 -0
  70. package/lib/Store/make-ordered-dictionary.d.ts +13 -0
  71. package/lib/Store/make-ordered-dictionary.js +81 -0
  72. package/lib/Store/object-repository.d.ts +10 -0
  73. package/lib/Store/object-repository.js +27 -0
  74. package/lib/Types/Auth.d.ts +103 -0
  75. package/lib/Types/Auth.js +2 -0
  76. package/lib/Types/Call.d.ts +13 -0
  77. package/lib/Types/Call.js +2 -0
  78. package/lib/Types/Chat.d.ts +109 -0
  79. package/lib/Types/Chat.js +4 -0
  80. package/lib/Types/Contact.d.ts +23 -0
  81. package/lib/Types/Contact.js +2 -0
  82. package/lib/Types/Events.d.ts +199 -0
  83. package/lib/Types/Events.js +2 -0
  84. package/lib/Types/GroupMetadata.d.ts +64 -0
  85. package/lib/Types/GroupMetadata.js +2 -0
  86. package/lib/Types/Label.d.ts +35 -0
  87. package/lib/Types/Label.js +27 -0
  88. package/lib/Types/LabelAssociation.d.ts +29 -0
  89. package/lib/Types/LabelAssociation.js +9 -0
  90. package/lib/Types/Message.d.ts +402 -0
  91. package/lib/Types/Message.js +7 -0
  92. package/lib/Types/Newsletter.d.ts +103 -0
  93. package/lib/Types/Newsletter.js +38 -0
  94. package/lib/Types/Product.d.ts +78 -0
  95. package/lib/Types/Product.js +2 -0
  96. package/lib/Types/Signal.d.ts +57 -0
  97. package/lib/Types/Signal.js +2 -0
  98. package/lib/Types/Socket.d.ts +119 -0
  99. package/lib/Types/Socket.js +2 -0
  100. package/lib/Types/State.d.ts +27 -0
  101. package/lib/Types/State.js +2 -0
  102. package/lib/Types/USync.d.ts +25 -0
  103. package/lib/Types/USync.js +2 -0
  104. package/lib/Types/index.d.ts +64 -0
  105. package/lib/Types/index.js +42 -0
  106. package/lib/Utils/audioToBuffer.js +29 -0
  107. package/lib/Utils/auth-utils.d.ts +18 -0
  108. package/lib/Utils/auth-utils.js +199 -0
  109. package/lib/Utils/baileys-event-stream.d.ts +16 -0
  110. package/lib/Utils/baileys-event-stream.js +63 -0
  111. package/lib/Utils/business.d.ts +22 -0
  112. package/lib/Utils/business.js +234 -0
  113. package/lib/Utils/chat-utils.d.ts +70 -0
  114. package/lib/Utils/chat-utils.js +730 -0
  115. package/lib/Utils/crypto.d.ts +40 -0
  116. package/lib/Utils/crypto.js +193 -0
  117. package/lib/Utils/decode-wa-message.d.ts +35 -0
  118. package/lib/Utils/decode-wa-message.js +207 -0
  119. package/lib/Utils/event-buffer.d.ts +35 -0
  120. package/lib/Utils/event-buffer.js +518 -0
  121. package/lib/Utils/generics.d.ts +89 -0
  122. package/lib/Utils/generics.js +428 -0
  123. package/lib/Utils/history.d.ts +19 -0
  124. package/lib/Utils/history.js +94 -0
  125. package/lib/Utils/index.d.ts +19 -0
  126. package/lib/Utils/index.js +36 -0
  127. package/lib/Utils/link-preview.d.ts +21 -0
  128. package/lib/Utils/link-preview.js +126 -0
  129. package/lib/Utils/logger.d.ts +11 -0
  130. package/lib/Utils/logger.js +7 -0
  131. package/lib/Utils/lt-hash.d.ts +12 -0
  132. package/lib/Utils/lt-hash.js +51 -0
  133. package/lib/Utils/make-mutex.d.ts +7 -0
  134. package/lib/Utils/make-mutex.js +43 -0
  135. package/lib/Utils/messages-media.d.ts +124 -0
  136. package/lib/Utils/messages-media.js +887 -0
  137. package/lib/Utils/messages.d.ts +75 -0
  138. package/lib/Utils/messages.js +1030 -0
  139. package/lib/Utils/noise-handler.d.ts +19 -0
  140. package/lib/Utils/noise-handler.js +150 -0
  141. package/lib/Utils/process-message.d.ts +42 -0
  142. package/lib/Utils/process-message.js +385 -0
  143. package/lib/Utils/signal.d.ts +33 -0
  144. package/lib/Utils/signal.js +153 -0
  145. package/lib/Utils/streamToBuffer.js +15 -0
  146. package/lib/Utils/use-multi-file-auth-state.d.ts +12 -0
  147. package/lib/Utils/use-multi-file-auth-state.js +125 -0
  148. package/lib/Utils/validate-connection.d.ts +10 -0
  149. package/lib/Utils/validate-connection.js +173 -0
  150. package/lib/WABinary/constants.d.ts +27 -0
  151. package/lib/WABinary/constants.js +1303 -0
  152. package/lib/WABinary/decode.d.ts +6 -0
  153. package/lib/WABinary/decode.js +265 -0
  154. package/lib/WABinary/encode.d.ts +2 -0
  155. package/lib/WABinary/encode.js +250 -0
  156. package/lib/WABinary/generic-utils.d.ts +14 -0
  157. package/lib/WABinary/generic-utils.js +110 -0
  158. package/lib/WABinary/index.d.ts +5 -0
  159. package/lib/WABinary/index.js +21 -0
  160. package/lib/WABinary/jid-utils.d.ts +36 -0
  161. package/lib/WABinary/jid-utils.js +83 -0
  162. package/lib/WABinary/jid-utils.js.bak +83 -0
  163. package/lib/WABinary/types.d.ts +18 -0
  164. package/lib/WABinary/types.js +2 -0
  165. package/lib/WAM/BinaryInfo.d.ts +8 -0
  166. package/lib/WAM/BinaryInfo.js +13 -0
  167. package/lib/WAM/constants.d.ts +38 -0
  168. package/lib/WAM/constants.js +15350 -0
  169. package/lib/WAM/encode.d.ts +2 -0
  170. package/lib/WAM/encode.js +155 -0
  171. package/lib/WAM/index.d.ts +3 -0
  172. package/lib/WAM/index.js +19 -0
  173. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
  174. package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
  175. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
  176. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  177. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  178. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  179. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  180. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  181. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
  182. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  183. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
  184. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  185. package/lib/WAUSync/Protocols/index.d.ts +4 -0
  186. package/lib/WAUSync/Protocols/index.js +20 -0
  187. package/lib/WAUSync/USyncQuery.d.ts +28 -0
  188. package/lib/WAUSync/USyncQuery.js +89 -0
  189. package/lib/WAUSync/USyncUser.d.ts +12 -0
  190. package/lib/WAUSync/USyncUser.js +26 -0
  191. package/lib/WAUSync/index.d.ts +3 -0
  192. package/lib/WAUSync/index.js +19 -0
  193. package/lib/index.d.ts +16 -0
  194. package/lib/index.js +75 -0
  195. package/package.json +110 -0
@@ -0,0 +1,18 @@
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("./types"), exports);
18
+ __exportStar(require("./websocket"), exports);
@@ -0,0 +1,16 @@
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 restart(): Promise<void>;
15
+ abstract send(str: Uint8Array | string, cb?: (err?: Error) => void): boolean;
16
+ }
@@ -0,0 +1,13 @@
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;
@@ -0,0 +1,13 @@
1
+ import WebSocket from 'ws';
2
+ import { AbstractSocketClient } from './types';
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
+ restart(): Promise<void>;
12
+ send(str: string | Uint8Array, cb?: (err?: Error) => void): boolean;
13
+ }
@@ -0,0 +1,111 @@
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 types_1 = require("./types");
10
+ class WebSocketClient extends types_1.AbstractSocketClient {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.socket = null;
14
+ // queue & dispatch variables for throttling outgoing messages to avoid rate limits
15
+ this._queue = [];
16
+ this._isDispatching = false;
17
+ this._lastDispatch = 0;
18
+ this._minSendIntervalMs = (Defaults_1.DEFAULT_CONNECTION_CONFIG && Defaults_1.DEFAULT_CONNECTION_CONFIG.minSendIntervalMs) || 50;
19
+ }
20
+ get isOpen() {
21
+ var _a;
22
+ return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.OPEN;
23
+ }
24
+ get isClosed() {
25
+ var _a;
26
+ return this.socket === null || ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.CLOSED;
27
+ }
28
+ get isClosing() {
29
+ var _a;
30
+ return this.socket === null || ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.CLOSING;
31
+ }
32
+ get isConnecting() {
33
+ var _a;
34
+ return ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.readyState) === ws_1.default.CONNECTING;
35
+ }
36
+ async connect() {
37
+ var _a, _b;
38
+ if (this.socket) {
39
+ return;
40
+ }
41
+ this.socket = new ws_1.default(this.url, {
42
+ origin: Defaults_1.DEFAULT_ORIGIN,
43
+ headers: (_a = this.config.options) === null || _a === void 0 ? void 0 : _a.headers,
44
+ handshakeTimeout: this.config.connectTimeoutMs,
45
+ timeout: this.config.connectTimeoutMs,
46
+ agent: this.config.agent,
47
+ });
48
+ this.socket.setMaxListeners(0);
49
+ const events = ['close', 'error', 'upgrade', 'message', 'open', 'ping', 'pong', 'unexpected-response'];
50
+ for (const event of events) {
51
+ (_b = this.socket) === null || _b === void 0 ? void 0 : _b.on(event, (...args) => this.emit(event, ...args));
52
+ }
53
+ }
54
+ async close() {
55
+ if (!this.socket) {
56
+ return;
57
+ }
58
+ this.socket.close();
59
+ this.socket = null;
60
+ }
61
+ async restart() {
62
+ if (this.socket) {
63
+ await new Promise(resolve => {
64
+ this.socket.once('close', resolve);
65
+ this.socket.terminate();
66
+ });
67
+ this.socket = null;
68
+ }
69
+ await this.connect();
70
+ }
71
+ send(str, cb) {
72
+ // throttle sends to reduce rate-limit likelihood
73
+ const doSend = () => {
74
+ var _a;
75
+ (_a = this.socket) === null || _a === void 0 ? void 0 : _a.send(str, cb);
76
+ return Boolean(this.socket);
77
+ };
78
+ this._queue.push(doSend);
79
+ this._dispatch();
80
+ return true;
81
+ }
82
+
83
+ _dispatch() {
84
+ if (this._isDispatching) {
85
+ return;
86
+ }
87
+ this._isDispatching = true;
88
+ const tick = () => {
89
+ const now = Date.now();
90
+ if (this._queue.length === 0) {
91
+ this._isDispatching = false;
92
+ return;
93
+ }
94
+ const delta = now - this._lastDispatch;
95
+ const wait = Math.max(0, this._minSendIntervalMs - delta);
96
+ setTimeout(() => {
97
+ const fn = this._queue.shift();
98
+ this._lastDispatch = Date.now();
99
+ try {
100
+ fn && fn();
101
+ }
102
+ catch (_err) {
103
+ // ignore send errors here; they'll surface elsewhere
104
+ }
105
+ tick();
106
+ }, wait);
107
+ };
108
+ tick();
109
+ }
110
+ }
111
+ exports.WebSocketClient = WebSocketClient;
@@ -0,0 +1,416 @@
1
+ import { proto } from '../../WAProto';
2
+
3
+ declare namespace RexxHayanasi {
4
+ interface MediaUploadOptions {
5
+ fileEncSha256?: Buffer;
6
+ mediaType?: string;
7
+ newsletter?: boolean;
8
+ }
9
+
10
+ type WAMediaUploadFunction = (
11
+ stream: Buffer | NodeJS.ReadableStream,
12
+ options?: MediaUploadOptions
13
+ ) => Promise<{ url: string; directPath: string }>;
14
+
15
+ interface WAMessageContentGenerationOptions {
16
+ upload?: WAMediaUploadFunction;
17
+ mediaCache?: any;
18
+ options?: any;
19
+ logger?: any;
20
+ }
21
+
22
+ interface StickerMessage {
23
+ url: string;
24
+ fileSha256: Buffer | string;
25
+ fileEncSha256: Buffer | string;
26
+ mediaKey: Buffer | string;
27
+ mimetype: string;
28
+ directPath: string;
29
+ fileLength: number | string;
30
+ mediaKeyTimestamp: number | string;
31
+ isAnimated?: boolean;
32
+ stickerSentTs?: number | string;
33
+ isAvatar?: boolean;
34
+ isAiSticker?: boolean;
35
+ isLottie?: boolean;
36
+ }
37
+
38
+ interface PaymentMessage {
39
+ amount: number;
40
+ currency?: string;
41
+ from?: string;
42
+ expiry?: number;
43
+ sticker?: { stickerMessage: StickerMessage };
44
+ note?: string;
45
+ background?: {
46
+ id?: string;
47
+ fileLength?: string;
48
+ width?: number;
49
+ height?: number;
50
+ mimetype?: string;
51
+ placeholderArgb?: number;
52
+ textArgb?: number;
53
+ subtextArgb?: number;
54
+ };
55
+ }
56
+
57
+ interface ProductMessage {
58
+ title: string;
59
+ description: string;
60
+ thumbnail: Buffer | { url: string };
61
+ productId: string;
62
+ retailerId: string;
63
+ url: string;
64
+ body?: string;
65
+ footer?: string;
66
+ buttons?: proto.Message.InteractiveMessage.INativeFlowButton[];
67
+ priceAmount1000?: number | null;
68
+ currencyCode?: string;
69
+ }
70
+
71
+ interface InteractiveMessage {
72
+ header?: string;
73
+ title: string;
74
+ footer?: string;
75
+ thumbnail?: string;
76
+ image?: string | Buffer | { url: string };
77
+ video?: string | Buffer | { url: string };
78
+ document?: string | Buffer | { url: string };
79
+ mimetype?: string;
80
+ fileName?: string;
81
+ jpegThumbnail?: string | Buffer | { url: string };
82
+ contextInfo?: {
83
+ mentionedJid?: string[];
84
+ forwardingScore?: number;
85
+ isForwarded?: boolean;
86
+ externalAdReply?: {
87
+ title?: string;
88
+ body?: string;
89
+ mediaType?: number;
90
+ thumbnailUrl?: string;
91
+ mediaUrl?: string;
92
+ sourceUrl?: string;
93
+ showAdAttribution?: boolean;
94
+ renderLargerThumbnail?: boolean;
95
+ [key: string]: any;
96
+ };
97
+ [key: string]: any;
98
+ };
99
+ externalAdReply?: {
100
+ title?: string;
101
+ body?: string;
102
+ mediaType?: number;
103
+ thumbnailUrl?: string;
104
+ mediaUrl?: string;
105
+ sourceUrl?: string;
106
+ showAdAttribution?: boolean;
107
+ renderLargerThumbnail?: boolean;
108
+ [key: string]: any;
109
+ };
110
+ buttons?: proto.Message.InteractiveMessage.INativeFlowButton[];
111
+ nativeFlowMessage?: {
112
+ messageParamsJson?: string;
113
+ buttons?: proto.Message.InteractiveMessage.INativeFlowButton[];
114
+ [key: string]: any;
115
+ };
116
+ }
117
+
118
+ interface AlbumItem {
119
+ image?: string | Buffer | { url: string; caption?: string };
120
+ video?: string | Buffer | { url: string; caption?: string };
121
+ }
122
+
123
+ interface EventMessageLocation {
124
+ degreesLatitude: number;
125
+ degreesLongitude: number;
126
+ name: string;
127
+ }
128
+
129
+ interface EventMessage {
130
+ isCanceled?: boolean;
131
+ name: string;
132
+ description: string;
133
+ location?: EventMessageLocation;
134
+ joinLink?: string;
135
+ startTime?: string | number;
136
+ endTime?: string | number;
137
+ extraGuestsAllowed?: boolean;
138
+ }
139
+
140
+ interface PollVote {
141
+ optionName: string;
142
+ optionVoteCount: string | number;
143
+ }
144
+
145
+ interface PollResultMessage {
146
+ name: string;
147
+ pollVotes: PollVote[];
148
+ }
149
+
150
+ interface GroupStatusMessage {
151
+ message?: any;
152
+ image?: string | Buffer | { url: string };
153
+ video?: string | Buffer | { url: string };
154
+ text?: string;
155
+ caption?: string;
156
+ document?: string | Buffer | { url: string };
157
+ [key: string]: any;
158
+ }
159
+
160
+ interface MessageContent {
161
+ requestPaymentMessage?: PaymentMessage;
162
+ productMessage?: ProductMessage;
163
+ interactiveMessage?: InteractiveMessage;
164
+ import { proto } from '../../WAProto';
165
+
166
+ declare namespace RexxHayanasi {
167
+ interface MediaUploadOptions {
168
+ fileEncSha256?: Buffer;
169
+ mediaType?: string;
170
+ newsletter?: boolean;
171
+ }
172
+
173
+ type WAMediaUploadFunction = (
174
+ stream: Buffer | NodeJS.ReadableStream,
175
+ options?: MediaUploadOptions
176
+ ) => Promise<{ url: string; directPath: string }>;
177
+
178
+ interface WAMessageContentGenerationOptions {
179
+ upload?: WAMediaUploadFunction;
180
+ mediaCache?: any;
181
+ options?: any;
182
+ logger?: any;
183
+ }
184
+
185
+ interface StickerMessage {
186
+ url: string;
187
+ fileSha256: Buffer | string;
188
+ fileEncSha256: Buffer | string;
189
+ mediaKey: Buffer | string;
190
+ mimetype: string;
191
+ directPath: string;
192
+ fileLength: number | string;
193
+ mediaKeyTimestamp: number | string;
194
+ isAnimated?: boolean;
195
+ stickerSentTs?: number | string;
196
+ isAvatar?: boolean;
197
+ isAiSticker?: boolean;
198
+ isLottie?: boolean;
199
+ }
200
+
201
+ interface PaymentMessage {
202
+ amount: number;
203
+ currency?: string;
204
+ from?: string;
205
+ expiry?: number;
206
+ sticker?: { stickerMessage: StickerMessage };
207
+ note?: string;
208
+ background?: {
209
+ id?: string;
210
+ fileLength?: string;
211
+ width?: number;
212
+ height?: number;
213
+ mimetype?: string;
214
+ placeholderArgb?: number;
215
+ textArgb?: number;
216
+ subtextArgb?: number;
217
+ };
218
+ }
219
+
220
+ interface ProductMessage {
221
+ title: string;
222
+ description: string;
223
+ thumbnail: Buffer | { url: string };
224
+ productId: string;
225
+ retailerId: string;
226
+ url: string;
227
+ body?: string;
228
+ footer?: string;
229
+ buttons?: proto.Message.InteractiveMessage.INativeFlowButton[];
230
+ priceAmount1000?: number | null;
231
+ currencyCode?: string;
232
+ }
233
+
234
+ interface InteractiveMessage {
235
+ header?: string;
236
+ title: string;
237
+ footer?: string;
238
+ thumbnail?: string;
239
+ image?: string | Buffer | { url: string };
240
+ video?: string | Buffer | { url: string };
241
+ document?: string | Buffer | { url: string };
242
+ mimetype?: string;
243
+ fileName?: string;
244
+ jpegThumbnail?: string | Buffer | { url: string };
245
+ contextInfo?: {
246
+ mentionedJid?: string[];
247
+ forwardingScore?: number;
248
+ isForwarded?: boolean;
249
+ externalAdReply?: {
250
+ title?: string;
251
+ body?: string;
252
+ mediaType?: number;
253
+ thumbnailUrl?: string;
254
+ mediaUrl?: string;
255
+ sourceUrl?: string;
256
+ showAdAttribution?: boolean;
257
+ renderLargerThumbnail?: boolean;
258
+ [key: string]: any;
259
+ };
260
+ [key: string]: any;
261
+ };
262
+ externalAdReply?: {
263
+ title?: string;
264
+ body?: string;
265
+ mediaType?: number;
266
+ thumbnailUrl?: string;
267
+ mediaUrl?: string;
268
+ sourceUrl?: string;
269
+ showAdAttribution?: boolean;
270
+ renderLargerThumbnail?: boolean;
271
+ [key: string]: any;
272
+ };
273
+ buttons?: proto.Message.InteractiveMessage.INativeFlowButton[];
274
+ nativeFlowMessage?: {
275
+ messageParamsJson?: string;
276
+ buttons?: proto.Message.InteractiveMessage.INativeFlowButton[];
277
+ [key: string]: any;
278
+ };
279
+ }
280
+
281
+ interface AlbumItem {
282
+ image?: string | Buffer | { url: string; caption?: string };
283
+ video?: string | Buffer | { url: string; caption?: string };
284
+ }
285
+
286
+ interface EventMessageLocation {
287
+ degreesLatitude: number;
288
+ degreesLongitude: number;
289
+ name: string;
290
+ }
291
+
292
+ interface EventMessage {
293
+ isCanceled?: boolean;
294
+ name: string;
295
+ description: string;
296
+ location?: EventMessageLocation;
297
+ joinLink?: string;
298
+ startTime?: string | number;
299
+ endTime?: string | number;
300
+ extraGuestsAllowed?: boolean;
301
+ }
302
+
303
+ interface PollVote {
304
+ optionName: string;
305
+ optionVoteCount: string | number;
306
+ }
307
+
308
+ interface PollResultMessage {
309
+ name: string;
310
+ pollVotes: PollVote[];
311
+ }
312
+
313
+ interface GroupStatusMessage {
314
+ message?: any;
315
+ image?: string | Buffer | { url: string };
316
+ video?: string | Buffer | { url: string };
317
+ text?: string;
318
+ caption?: string;
319
+ document?: string | Buffer | { url: string };
320
+ [key: string]: any;
321
+ }
322
+
323
+ interface MessageContent {
324
+ requestPaymentMessage?: PaymentMessage;
325
+ productMessage?: ProductMessage;
326
+ interactiveMessage?: InteractiveMessage;
327
+ albumMessage?: AlbumItem[];
328
+ eventMessage?: EventMessage;
329
+ pollResultMessage?: PollResultMessage;
330
+ groupStatusMessage?: GroupStatusMessage;
331
+ sender?: string;
332
+ }
333
+
334
+ interface MessageOptions {
335
+ quoted?: proto.IWebMessageInfo;
336
+ filter?: boolean;
337
+ }
338
+
339
+ interface Utils {
340
+ prepareWAMessageMedia: (media: any, options: WAMessageContentGenerationOptions) => Promise<any>;
341
+ generateWAMessageContent: (content: any, options: WAMessageContentGenerationOptions) => Promise<any>;
342
+ generateWAMessageFromContent: (jid: string, content: any, options?: any) => Promise<any>;
343
+ generateWAMessage: (jid: string, content: any, options?: any) => Promise<any>;
344
+ generateMessageID: () => string;
345
+ prepareMessageContent?: (content: any, options?: any) => Promise<any>;
346
+ }
347
+
348
+ interface BailUtils {
349
+ generateWAMessageContent?: (content: any, options: WAMessageContentGenerationOptions) => Promise<any>;
350
+ generateMessageID: () => string;
351
+ getContentType: (msg: any) => string;
352
+ }
353
+ }
354
+
355
+ declare class RexxHayanasi {
356
+ constructor(
357
+ utils: RexxHayanasi.Utils,
358
+ waUploadToServer: RexxHayanasi.WAMediaUploadFunction,
359
+ relayMessageFn?: (jid: string, content: any, options?: any) => Promise<any>
360
+ );
361
+
362
+ detectType(content: RexxHayanasi.MessageContent): 'PAYMENT' | 'PRODUCT' | 'INTERACTIVE' | 'ALBUM' | 'EVENT' | 'POLL_RESULT' | 'GROUP_STORY' | null;
363
+
364
+ handlePayment(
365
+ content: { requestPaymentMessage: RexxHayanasi.PaymentMessage },
366
+ quoted?: proto.IWebMessageInfo
367
+ ): Promise<{ requestPaymentMessage: proto.Message.RequestPaymentMessage }>;
368
+
369
+ handleProduct(
370
+ content: { productMessage: RexxHayanasi.ProductMessage },
371
+ jid: string,
372
+ quoted?: proto.IWebMessageInfo
373
+ ): Promise<{ viewOnceMessage: proto.Message.ViewOnceMessage }>;
374
+
375
+ handleInteractive(
376
+ content: { interactiveMessage: RexxHayanasi.InteractiveMessage },
377
+ jid: string,
378
+ quoted?: proto.IWebMessageInfo
379
+ ): Promise<{ interactiveMessage: proto.Message.InteractiveMessage }>;
380
+
381
+ handleAlbum(
382
+ content: { albumMessage: RexxHayanasi.AlbumItem[] },
383
+ jid: string,
384
+ quoted?: proto.IWebMessageInfo
385
+ ): Promise<any>;
386
+
387
+ handleEvent(
388
+ content: { eventMessage: RexxHayanasi.EventMessage },
389
+ jid: string,
390
+ quoted?: proto.IWebMessageInfo
391
+ ): Promise<any>;
392
+
393
+ handlePollResult(
394
+ content: { pollResultMessage: RexxHayanasi.PollResultMessage },
395
+ jid: string,
396
+ quoted?: proto.IWebMessageInfo
397
+ ): Promise<any>;
398
+
399
+ handleGroupStory(
400
+ content: { groupStatusMessage: RexxHayanasi.GroupStatusMessage },
401
+ jid: string,
402
+ quoted?: proto.IWebMessageInfo
403
+ ): Promise<any>;
404
+
405
+ buildMessageContent(
406
+ content: any,
407
+ opts?: RexxHayanasi.WAMessageContentGenerationOptions
408
+ ): Promise<any>;
409
+
410
+ utils: RexxHayanasi.Utils;
411
+ relayMessage: (jid: string, content: any, options?: any) => Promise<any>;
412
+ waUploadToServer: RexxHayanasi.WAMediaUploadFunction;
413
+ bail: RexxHayanasi.BailUtils;
414
+ }
415
+
416
+ export = RexxHayanasi;