@vanzxy/baileys 1.4.8 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (113) hide show
  1. package/README.md +10 -0
  2. package/lib/Utils/MessageBuilder.js +56 -28
  3. package/package.json +3 -5
  4. package/cjs/WAProto/index.js +0 -106053
  5. package/cjs/lib/Defaults/index.js +0 -168
  6. package/cjs/lib/Signal/Group/ciphertext-message.js +0 -16
  7. package/cjs/lib/Signal/Group/group-session-builder.js +0 -67
  8. package/cjs/lib/Signal/Group/group_cipher.js +0 -86
  9. package/cjs/lib/Signal/Group/index.js +0 -58
  10. package/cjs/lib/Signal/Group/keyhelper.js +0 -56
  11. package/cjs/lib/Signal/Group/sender-chain-key.js +0 -30
  12. package/cjs/lib/Signal/Group/sender-key-distribution-message.js +0 -67
  13. package/cjs/lib/Signal/Group/sender-key-message.js +0 -70
  14. package/cjs/lib/Signal/Group/sender-key-name.js +0 -52
  15. package/cjs/lib/Signal/Group/sender-key-record.js +0 -45
  16. package/cjs/lib/Signal/Group/sender-key-state.js +0 -88
  17. package/cjs/lib/Signal/Group/sender-message-key.js +0 -30
  18. package/cjs/lib/Signal/libsignal.js +0 -467
  19. package/cjs/lib/Signal/lid-mapping.js +0 -281
  20. package/cjs/lib/Socket/Client/index.js +0 -19
  21. package/cjs/lib/Socket/Client/types.js +0 -15
  22. package/cjs/lib/Socket/Client/websocket.js +0 -61
  23. package/cjs/lib/Socket/business.js +0 -384
  24. package/cjs/lib/Socket/chats.js +0 -1257
  25. package/cjs/lib/Socket/communities.js +0 -442
  26. package/cjs/lib/Socket/dugong.js +0 -753
  27. package/cjs/lib/Socket/groups.js +0 -360
  28. package/cjs/lib/Socket/index.js +0 -30
  29. package/cjs/lib/Socket/messages-recv.js +0 -1790
  30. package/cjs/lib/Socket/messages-send.js +0 -1390
  31. package/cjs/lib/Socket/mex.js +0 -46
  32. package/cjs/lib/Socket/newsletter.js +0 -340
  33. package/cjs/lib/Socket/socket.js +0 -1007
  34. package/cjs/lib/Store/index.js +0 -20
  35. package/cjs/lib/Store/make-in-memory-store.js +0 -438
  36. package/cjs/lib/Store/make-ordered-dictionary.js +0 -82
  37. package/cjs/lib/Store/object-repository.js +0 -28
  38. package/cjs/lib/Types/Auth.js +0 -3
  39. package/cjs/lib/Types/Bussines.js +0 -3
  40. package/cjs/lib/Types/Call.js +0 -3
  41. package/cjs/lib/Types/Chat.js +0 -11
  42. package/cjs/lib/Types/Contact.js +0 -3
  43. package/cjs/lib/Types/Events.js +0 -4
  44. package/cjs/lib/Types/GroupMetadata.js +0 -3
  45. package/cjs/lib/Types/Label.js +0 -26
  46. package/cjs/lib/Types/LabelAssociation.js +0 -8
  47. package/cjs/lib/Types/Message.js +0 -19
  48. package/cjs/lib/Types/Mex.js +0 -40
  49. package/cjs/lib/Types/Product.js +0 -3
  50. package/cjs/lib/Types/RichType.js +0 -24
  51. package/cjs/lib/Types/Signal.js +0 -4
  52. package/cjs/lib/Types/Socket.js +0 -4
  53. package/cjs/lib/Types/State.js +0 -54
  54. package/cjs/lib/Types/USync.js +0 -4
  55. package/cjs/lib/Types/index.js +0 -42
  56. package/cjs/lib/Utils/MessageBuilder.js +0 -2684
  57. package/cjs/lib/Utils/auth-utils.js +0 -312
  58. package/cjs/lib/Utils/browser-utils.js +0 -32
  59. package/cjs/lib/Utils/business.js +0 -245
  60. package/cjs/lib/Utils/chat-utils.js +0 -940
  61. package/cjs/lib/Utils/companion-reg-client-utils.js +0 -45
  62. package/cjs/lib/Utils/crypto.js +0 -202
  63. package/cjs/lib/Utils/decode-wa-message.js +0 -324
  64. package/cjs/lib/Utils/event-buffer.js +0 -643
  65. package/cjs/lib/Utils/generics.js +0 -429
  66. package/cjs/lib/Utils/history.js +0 -151
  67. package/cjs/lib/Utils/identity-change-handler.js +0 -56
  68. package/cjs/lib/Utils/index.js +0 -42
  69. package/cjs/lib/Utils/link-preview.js +0 -122
  70. package/cjs/lib/Utils/logger.js +0 -8
  71. package/cjs/lib/Utils/lt-hash.js +0 -64
  72. package/cjs/lib/Utils/make-mutex.js +0 -38
  73. package/cjs/lib/Utils/message-retry-manager.js +0 -267
  74. package/cjs/lib/Utils/messages-media.js +0 -933
  75. package/cjs/lib/Utils/messages.js +0 -2180
  76. package/cjs/lib/Utils/noise-handler.js +0 -205
  77. package/cjs/lib/Utils/offline-node-processor.js +0 -43
  78. package/cjs/lib/Utils/pre-key-manager.js +0 -113
  79. package/cjs/lib/Utils/process-message.js +0 -772
  80. package/cjs/lib/Utils/reporting-utils.js +0 -263
  81. package/cjs/lib/Utils/rich-message-utils.js +0 -439
  82. package/cjs/lib/Utils/signal.js +0 -214
  83. package/cjs/lib/Utils/stanza-ack.js +0 -41
  84. package/cjs/lib/Utils/sync-action-utils.js +0 -54
  85. package/cjs/lib/Utils/tc-token-utils.js +0 -174
  86. package/cjs/lib/Utils/use-multi-file-auth-state.js +0 -125
  87. package/cjs/lib/Utils/use-single-file-auth-state.js +0 -121
  88. package/cjs/lib/Utils/use-sqlite-auth-state.js +0 -182
  89. package/cjs/lib/Utils/validate-connection.js +0 -210
  90. package/cjs/lib/WABinary/constants.js +0 -1470
  91. package/cjs/lib/WABinary/decode.js +0 -301
  92. package/cjs/lib/WABinary/encode.js +0 -257
  93. package/cjs/lib/WABinary/generic-utils.js +0 -275
  94. package/cjs/lib/WABinary/index.js +0 -22
  95. package/cjs/lib/WABinary/jid-utils.js +0 -114
  96. package/cjs/lib/WABinary/types.js +0 -37
  97. package/cjs/lib/WAM/BinaryInfo.js +0 -14
  98. package/cjs/lib/WAM/constants.js +0 -22856
  99. package/cjs/lib/WAM/encode.js +0 -154
  100. package/cjs/lib/WAM/index.js +0 -20
  101. package/cjs/lib/WAUSync/Protocols/USyncContactProtocol.js +0 -56
  102. package/cjs/lib/WAUSync/Protocols/USyncDeviceProtocol.js +0 -67
  103. package/cjs/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +0 -31
  104. package/cjs/lib/WAUSync/Protocols/USyncStatusProtocol.js +0 -42
  105. package/cjs/lib/WAUSync/Protocols/USyncUsernameProtocol.js +0 -29
  106. package/cjs/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +0 -55
  107. package/cjs/lib/WAUSync/Protocols/UsyncLIDProtocol.js +0 -33
  108. package/cjs/lib/WAUSync/Protocols/index.js +0 -24
  109. package/cjs/lib/WAUSync/USyncQuery.js +0 -126
  110. package/cjs/lib/WAUSync/USyncUser.js +0 -35
  111. package/cjs/lib/WAUSync/index.js +0 -20
  112. package/cjs/lib/index.js +0 -34
  113. package/cjs/package.json +0 -1
@@ -1,275 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBizBinaryNode = exports.getBinaryNodeMessages = exports.reduceBinaryNodeToDictionary = exports.assertNodeErrorFree = exports.getBinaryNodeChildUInt = exports.getBinaryNodeChildString = exports.getBinaryNodeChildBuffer = exports.getAllBinaryNodeChildren = exports.getBinaryNodeChild = exports.getBinaryNodeChildren = void 0;
4
- exports.binaryNodeToString = binaryNodeToString;
5
- const boom_1 = require("@hapi/boom");
6
- const crypto_1 = require("crypto");
7
- const index_js_1 = require("../../WAProto/index.js");
8
- // some extra useful utilities
9
- const indexCache = new WeakMap();
10
- const getBinaryNodeChildren = (node, childTag) => {
11
- if (!node || !Array.isArray(node.content))
12
- return [];
13
- let index = indexCache.get(node);
14
- // Build the index once per node
15
- if (!index) {
16
- index = new Map();
17
- for (const child of node.content) {
18
- let arr = index.get(child.tag);
19
- if (!arr)
20
- index.set(child.tag, (arr = []));
21
- arr.push(child);
22
- }
23
- indexCache.set(node, index);
24
- }
25
- // Return first matching child
26
- return index.get(childTag) || [];
27
- };
28
- exports.getBinaryNodeChildren = getBinaryNodeChildren;
29
- const getBinaryNodeChild = (node, childTag) => {
30
- return (0, exports.getBinaryNodeChildren)(node, childTag)[0];
31
- };
32
- exports.getBinaryNodeChild = getBinaryNodeChild;
33
- const getAllBinaryNodeChildren = ({ content }) => {
34
- if (Array.isArray(content)) {
35
- return content;
36
- }
37
- return [];
38
- };
39
- exports.getAllBinaryNodeChildren = getAllBinaryNodeChildren;
40
- const getBinaryNodeChildBuffer = (node, childTag) => {
41
- const child = (0, exports.getBinaryNodeChild)(node, childTag)?.content;
42
- if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
43
- return child;
44
- }
45
- };
46
- exports.getBinaryNodeChildBuffer = getBinaryNodeChildBuffer;
47
- const getBinaryNodeChildString = (node, childTag) => {
48
- const child = (0, exports.getBinaryNodeChild)(node, childTag)?.content;
49
- if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
50
- return Buffer.from(child).toString('utf-8');
51
- }
52
- else if (typeof child === 'string') {
53
- return child;
54
- }
55
- };
56
- exports.getBinaryNodeChildString = getBinaryNodeChildString;
57
- const getBinaryNodeChildUInt = (node, childTag, length) => {
58
- const buff = (0, exports.getBinaryNodeChildBuffer)(node, childTag);
59
- if (buff) {
60
- return bufferToUInt(buff, length);
61
- }
62
- };
63
- exports.getBinaryNodeChildUInt = getBinaryNodeChildUInt;
64
- const assertNodeErrorFree = (node) => {
65
- const errNode = (0, exports.getBinaryNodeChild)(node, 'error');
66
- if (errNode) {
67
- throw new boom_1.Boom(errNode.attrs.text || 'Unknown error', { data: +errNode.attrs.code });
68
- }
69
- };
70
- exports.assertNodeErrorFree = assertNodeErrorFree;
71
- const reduceBinaryNodeToDictionary = (node, tag) => {
72
- const nodes = (0, exports.getBinaryNodeChildren)(node, tag);
73
- const dict = nodes.reduce((dict, { attrs }) => {
74
- if (typeof attrs.name === 'string') {
75
- dict[attrs.name] = attrs.value || attrs.config_value;
76
- }
77
- else {
78
- dict[attrs.config_code] = attrs.value || attrs.config_value;
79
- }
80
- return dict;
81
- }, {});
82
- return dict;
83
- };
84
- exports.reduceBinaryNodeToDictionary = reduceBinaryNodeToDictionary;
85
- const getBinaryNodeMessages = ({ content }) => {
86
- const msgs = [];
87
- if (Array.isArray(content)) {
88
- for (const item of content) {
89
- if (item.tag === 'message') {
90
- msgs.push(index_js_1.proto.WebMessageInfo.decode(item.content).toJSON());
91
- }
92
- }
93
- }
94
- return msgs;
95
- };
96
- exports.getBinaryNodeMessages = getBinaryNodeMessages;
97
- function bufferToUInt(e, t) {
98
- let a = 0;
99
- for (let i = 0; i < t; i++) {
100
- a = 256 * a + e[i];
101
- }
102
- return a;
103
- }
104
- const tabs = (n) => '\t'.repeat(n);
105
- function binaryNodeToString(node, i = 0) {
106
- if (!node) {
107
- return node;
108
- }
109
- if (typeof node === 'string') {
110
- return tabs(i) + node;
111
- }
112
- if (node instanceof Uint8Array) {
113
- return tabs(i) + Buffer.from(node).toString('hex');
114
- }
115
- if (Array.isArray(node)) {
116
- return node.map(x => tabs(i + 1) + binaryNodeToString(x, i + 1)).join('\n');
117
- }
118
- const children = binaryNodeToString(node.content, i + 1);
119
- const tag = `<${node.tag} ${Object.entries(node.attrs || {})
120
- .filter(([, v]) => v !== undefined)
121
- .map(([k, v]) => `${k}='${v}'`)
122
- .join(' ')}`;
123
- const content = children ? `>\n${children}\n${tabs(i)}</${node.tag}>` : '/>';
124
- return tag + content;
125
- }
126
- /**
127
- * Lia@Changes 30-01-26
128
- * ---
129
- * Produce the binary node (WABinary-like JSON shape) required for the specific
130
- * interactive button / list type.
131
- * compatible with observed official client traffic.
132
- *
133
- * NOTE: Returning different "v" (version) and "name" values influences how
134
- * WhatsApp renders & validates flows. The constants here are empirically derived.
135
- *
136
- * @param {object} message Normalized message content (after Baileys normalization).
137
- * @returns {object} A node with shape { tag, attrs, [content] } to inject into additionalNodes.
138
- */
139
- const FLOWS_MAP = {
140
- // Original flow types
141
- mpm: true,
142
- // Vanz@Fix (bug 44): the "catalog" nativeFlow shortcut generates a button
143
- // named 'catalog_message' (see prepareNativeFlowButtons in messages.js),
144
- // never 'cta_catalog' — the old key here never matched anything, so
145
- // catalog_message always fell through to the generic mixed-flow node
146
- // instead of getting its dedicated native_flow node.
147
- catalog_message: true,
148
- send_location: true,
149
- call_permission_request: true,
150
- wa_payment_transaction_details: true,
151
- automated_greeting_message_view_catalog: true,
152
- // Vanzxy extended button types
153
- card_message: true,
154
- order_status: true,
155
- track_order: true,
156
- reorder: true,
157
- cancel_order: true,
158
- clear_chat: true,
159
- navigateToScreen: true,
160
- payment_status: true,
161
- payment_method: true,
162
- flow_action: true,
163
- voice_call: true,
164
- video_call_button: true,
165
- otp_button: true,
166
- authentication_button: true,
167
- cta_reminder: true,
168
- cta_cancel_reminder: true,
169
- // Vanz@Fix (single_select never renders alone) --- see ESM copy for full note.
170
- // Removed on purpose so single_select always falls through to the mixed-flow branch.
171
- };
172
- const DECISION_SOURCE_CONTENT = [
173
- {
174
- tag: 'decision_source',
175
- attrs: { value: 'df' }
176
- }
177
- ];
178
- const LIST_TYPE_CONTENT = {
179
- tag: 'list',
180
- attrs: { v: '2', type: 'product_list' }
181
- };
182
- const NATIVE_FLOW_ATTRIBUTE = { type: 'native_flow', v: '1' };
183
- const MIXED_NATIVE_FLOW = {
184
- tag: 'interactive',
185
- attrs: NATIVE_FLOW_ATTRIBUTE,
186
- content: [
187
- {
188
- tag: 'native_flow',
189
- attrs: { v: '9', name: 'mixed' }
190
- }
191
- ]
192
- };
193
- const getBizBinaryNode = (message) => {
194
- const flowMsg = message.interactiveMessage?.nativeFlowMessage;
195
- const firstButtonName = flowMsg?.buttons?.[0]?.name;
196
- const qualityContent = {
197
- tag: 'quality_control',
198
- attrs: {
199
- decision_id: (0, crypto_1.randomBytes)(20).toString('hex'),
200
- source_type: 'third_party'
201
- },
202
- content: DECISION_SOURCE_CONTENT
203
- };
204
- const bizAttributes = {
205
- actual_actors: '2',
206
- host_storage: '2',
207
- privacy_mode_ts: `${Date.now() / 1_000 | 0}`
208
- };
209
- const ORDER_RESPONSE_ALIAS = {
210
- review_and_pay: 'order_details',
211
- review_order: 'order_status',
212
- payment_info: 'payment_info',
213
- payment_status: 'payment_status',
214
- payment_method: 'payment_method',
215
- order_details: 'order_details',
216
- order_status: 'order_status',
217
- track_order: 'track_order',
218
- reorder: 'reorder',
219
- cancel_order: 'cancel_order',
220
- };
221
- if (firstButtonName && ORDER_RESPONSE_ALIAS[firstButtonName]) {
222
- bizAttributes.native_flow_name = ORDER_RESPONSE_ALIAS[firstButtonName];
223
- return {
224
- tag: 'biz',
225
- attrs: bizAttributes,
226
- content: [qualityContent]
227
- };
228
- }
229
- if (firstButtonName && FLOWS_MAP[firstButtonName]) {
230
- return {
231
- tag: 'biz',
232
- attrs: bizAttributes,
233
- content: [
234
- {
235
- tag: 'interactive',
236
- attrs: NATIVE_FLOW_ATTRIBUTE,
237
- content: [
238
- {
239
- tag: 'native_flow',
240
- attrs: { v: '2', name: firstButtonName }
241
- }
242
- ]
243
- },
244
- qualityContent
245
- ]
246
- };
247
- }
248
- if (flowMsg || message.buttonsMessage || message.templateMessage) {
249
- return {
250
- tag: 'biz',
251
- attrs: bizAttributes,
252
- content: [
253
- MIXED_NATIVE_FLOW,
254
- qualityContent
255
- ]
256
- };
257
- }
258
- if (message.listMessage) {
259
- return {
260
- tag: 'biz',
261
- attrs: bizAttributes,
262
- content: [
263
- LIST_TYPE_CONTENT,
264
- qualityContent
265
- ]
266
- };
267
- }
268
- return {
269
- tag: 'biz',
270
- attrs: bizAttributes,
271
- content: [qualityContent]
272
- };
273
- };
274
- exports.getBizBinaryNode = getBizBinaryNode;
275
- //# sourceMappingURL=generic-utils.js.map
@@ -1,22 +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("./encode.js"), exports);
18
- __exportStar(require("./decode.js"), exports);
19
- __exportStar(require("./generic-utils.js"), exports);
20
- __exportStar(require("./jid-utils.js"), exports);
21
- __exportStar(require("./types.js"), exports);
22
- //# sourceMappingURL=index.js.map
@@ -1,114 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transferDevice = exports.jidNormalizedUser = exports.isJidBot = exports.isHostedLidUser = exports.isHostedPnUser = exports.isJidNewsletter = exports.isJidStatusBroadcast = exports.isJidGroup = exports.isJidBroadcast = exports.isLidUser = exports.isPnUser = exports.isJidMetaAI = exports.areJidsSameUser = exports.jidDecode = exports.jidEncode = exports.getServerFromDomainType = exports.WAJIDDomains = exports.META_AI_JID = exports.STORIES_JID = exports.PSA_WID = exports.SERVER_JID = exports.OFFICIAL_BIZ_JID = exports.S_WHATSAPP_NET = void 0;
4
- exports.S_WHATSAPP_NET = '@s.whatsapp.net';
5
- exports.OFFICIAL_BIZ_JID = '16505361212@c.us';
6
- exports.SERVER_JID = 'server@c.us';
7
- exports.PSA_WID = '0@c.us';
8
- exports.STORIES_JID = 'status@broadcast';
9
- exports.META_AI_JID = '13135550002@c.us';
10
- (function (WAJIDDomains) {
11
- WAJIDDomains[WAJIDDomains["WHATSAPP"] = 0] = "WHATSAPP";
12
- WAJIDDomains[WAJIDDomains["LID"] = 1] = "LID";
13
- WAJIDDomains[WAJIDDomains["HOSTED"] = 128] = "HOSTED";
14
- WAJIDDomains[WAJIDDomains["HOSTED_LID"] = 129] = "HOSTED_LID";
15
- })(exports.WAJIDDomains || (exports.WAJIDDomains = {}));
16
- const getServerFromDomainType = (initialServer, domainType) => {
17
- switch (domainType) {
18
- case exports.WAJIDDomains.LID:
19
- return 'lid';
20
- case exports.WAJIDDomains.HOSTED:
21
- return 'hosted';
22
- case exports.WAJIDDomains.HOSTED_LID:
23
- return 'hosted.lid';
24
- case exports.WAJIDDomains.WHATSAPP:
25
- default:
26
- return initialServer;
27
- }
28
- };
29
- exports.getServerFromDomainType = getServerFromDomainType;
30
- const jidEncode = (user, server, device, agent) => {
31
- return `${user || ''}${!!agent ? `_${agent}` : ''}${!!device ? `:${device}` : ''}@${server || 'lid'}`;
32
- };
33
- exports.jidEncode = jidEncode;
34
- const jidDecode = (jid) => {
35
- // todo: investigate how to implement hosted ids in this case
36
- const sepIdx = typeof jid === 'string' ? jid.indexOf('@') : -1;
37
- if (sepIdx < 0) {
38
- return undefined;
39
- }
40
- const server = jid.slice(sepIdx + 1);
41
- const userCombined = jid.slice(0, sepIdx);
42
- const [userAgent, device] = userCombined.split(':');
43
- const [user, agent] = userAgent.split('_');
44
- let domainType = exports.WAJIDDomains.WHATSAPP;
45
- if (server === 'lid') {
46
- domainType = exports.WAJIDDomains.LID;
47
- }
48
- else if (server === 'hosted') {
49
- domainType = exports.WAJIDDomains.HOSTED;
50
- }
51
- else if (server === 'hosted.lid') {
52
- domainType = exports.WAJIDDomains.HOSTED_LID;
53
- }
54
- else if (agent) {
55
- domainType = parseInt(agent);
56
- }
57
- return {
58
- server: server,
59
- user: user,
60
- domainType,
61
- device: device ? +device : undefined
62
- };
63
- };
64
- exports.jidDecode = jidDecode;
65
- /** is the jid a user */
66
- const areJidsSameUser = (jid1, jid2) => (0, exports.jidDecode)(jid1)?.user === (0, exports.jidDecode)(jid2)?.user;
67
- exports.areJidsSameUser = areJidsSameUser;
68
- /** is the jid Meta AI */
69
- const isJidMetaAI = (jid) => jid?.endsWith('@bot');
70
- exports.isJidMetaAI = isJidMetaAI;
71
- /** is the jid a PN user */
72
- const isPnUser = (jid) => jid?.endsWith('@s.whatsapp.net');
73
- exports.isPnUser = isPnUser;
74
- /** is the jid a LID */
75
- const isLidUser = (jid) => jid?.endsWith('@lid');
76
- exports.isLidUser = isLidUser;
77
- /** is the jid a broadcast */
78
- const isJidBroadcast = (jid) => jid?.endsWith('@broadcast');
79
- exports.isJidBroadcast = isJidBroadcast;
80
- /** is the jid a group */
81
- const isJidGroup = (jid) => jid?.endsWith('@g.us');
82
- exports.isJidGroup = isJidGroup;
83
- /** is the jid the status broadcast */
84
- const isJidStatusBroadcast = (jid) => jid === 'status@broadcast';
85
- exports.isJidStatusBroadcast = isJidStatusBroadcast;
86
- /** is the jid a newsletter */
87
- const isJidNewsletter = (jid) => jid?.endsWith('@newsletter');
88
- exports.isJidNewsletter = isJidNewsletter;
89
- /** is the jid a hosted PN */
90
- const isHostedPnUser = (jid) => jid?.endsWith('@hosted');
91
- exports.isHostedPnUser = isHostedPnUser;
92
- /** is the jid a hosted LID */
93
- const isHostedLidUser = (jid) => jid?.endsWith('@hosted.lid');
94
- exports.isHostedLidUser = isHostedLidUser;
95
- const botRegexp = /^1313555\d{4}$|^131655500\d{2}$/;
96
- const isJidBot = (jid) => jid && botRegexp.test(jid.split('@')[0]) && jid.endsWith('@c.us');
97
- exports.isJidBot = isJidBot;
98
- const jidNormalizedUser = (jid) => {
99
- const result = (0, exports.jidDecode)(jid);
100
- if (!result) {
101
- return '';
102
- }
103
- const { user, server } = result;
104
- return (0, exports.jidEncode)(user, server === 'c.us' ? 's.whatsapp.net' : server);
105
- };
106
- exports.jidNormalizedUser = jidNormalizedUser;
107
- const transferDevice = (fromJid, toJid) => {
108
- const fromDecoded = (0, exports.jidDecode)(fromJid);
109
- const deviceId = fromDecoded?.device || 0;
110
- const { server, user } = (0, exports.jidDecode)(toJid);
111
- return (0, exports.jidEncode)(user, server, deviceId);
112
- };
113
- exports.transferDevice = transferDevice;
114
- //# sourceMappingURL=jid-utils.js.map
@@ -1,37 +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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- const constants = __importStar(require("./constants.js"));
37
- //# sourceMappingURL=types.js.map
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BinaryInfo = void 0;
4
- class BinaryInfo {
5
- constructor(options = {}) {
6
- this.protocolVersion = 5;
7
- this.sequence = 0;
8
- this.events = [];
9
- this.buffer = [];
10
- Object.assign(this, options);
11
- }
12
- }
13
- exports.BinaryInfo = BinaryInfo;
14
- //# sourceMappingURL=BinaryInfo.js.map