@zannstore/baileys 2.2.6

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 (108) hide show
  1. package/README.md +13 -0
  2. package/WAProto/index.js +169661 -0
  3. package/engine-requirements.js +10 -0
  4. package/lib/Defaults/baileys-version.json +3 -0
  5. package/lib/Defaults/index.js +147 -0
  6. package/lib/Defaults/phonenumber-mcc.json +223 -0
  7. package/lib/Function/Download/tiktok.js +19 -0
  8. package/lib/Function/Tools/bypass.js +19 -0
  9. package/lib/Function/index.js +13 -0
  10. package/lib/Signal/Group/ciphertext-message.js +15 -0
  11. package/lib/Signal/Group/group-session-builder.js +64 -0
  12. package/lib/Signal/Group/group_cipher.js +96 -0
  13. package/lib/Signal/Group/index.js +57 -0
  14. package/lib/Signal/Group/keyhelper.js +55 -0
  15. package/lib/Signal/Group/queue-job.js +57 -0
  16. package/lib/Signal/Group/sender-chain-key.js +34 -0
  17. package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
  18. package/lib/Signal/Group/sender-key-message.js +69 -0
  19. package/lib/Signal/Group/sender-key-name.js +51 -0
  20. package/lib/Signal/Group/sender-key-record.js +53 -0
  21. package/lib/Signal/Group/sender-key-state.js +99 -0
  22. package/lib/Signal/Group/sender-message-key.js +29 -0
  23. package/lib/Signal/libsignal.js +360 -0
  24. package/lib/Signal/lid-mapping.js +166 -0
  25. package/lib/Socket/Client/abstract-socket-client.js +13 -0
  26. package/lib/Socket/Client/index.js +19 -0
  27. package/lib/Socket/Client/mobile-socket-client.js +65 -0
  28. package/lib/Socket/Client/web-socket-client.js +62 -0
  29. package/lib/Socket/business.js +310 -0
  30. package/lib/Socket/chats.js +1145 -0
  31. package/lib/Socket/community.js +392 -0
  32. package/lib/Socket/dugong.js +658 -0
  33. package/lib/Socket/groups.js +317 -0
  34. package/lib/Socket/index.js +11 -0
  35. package/lib/Socket/messages-recv.js +1145 -0
  36. package/lib/Socket/messages-send.js +936 -0
  37. package/lib/Socket/newsletter.js +437 -0
  38. package/lib/Socket/registration.js +167 -0
  39. package/lib/Socket/socket.js +733 -0
  40. package/lib/Socket/usync.js +70 -0
  41. package/lib/Store/index.js +10 -0
  42. package/lib/Store/make-cache-manager-store.js +83 -0
  43. package/lib/Store/make-in-memory-store.js +427 -0
  44. package/lib/Store/make-ordered-dictionary.js +81 -0
  45. package/lib/Store/object-repository.js +27 -0
  46. package/lib/Types/Auth.js +2 -0
  47. package/lib/Types/Call.js +2 -0
  48. package/lib/Types/Chat.js +4 -0
  49. package/lib/Types/Contact.js +2 -0
  50. package/lib/Types/Events.js +2 -0
  51. package/lib/Types/GroupMetadata.js +2 -0
  52. package/lib/Types/Label.js +27 -0
  53. package/lib/Types/LabelAssociation.js +9 -0
  54. package/lib/Types/Message.js +10 -0
  55. package/lib/Types/MexUpdates.js +15 -0
  56. package/lib/Types/Newsletter.js +38 -0
  57. package/lib/Types/Product.js +2 -0
  58. package/lib/Types/Signal.js +2 -0
  59. package/lib/Types/Socket.js +2 -0
  60. package/lib/Types/State.js +2 -0
  61. package/lib/Types/USync.js +2 -0
  62. package/lib/Types/index.js +45 -0
  63. package/lib/Utils/auth-utils.js +206 -0
  64. package/lib/Utils/baileys-event-stream.js +63 -0
  65. package/lib/Utils/bot-toolkit.js +455 -0
  66. package/lib/Utils/business.js +234 -0
  67. package/lib/Utils/chat-utils.js +729 -0
  68. package/lib/Utils/crypto.js +151 -0
  69. package/lib/Utils/decode-wa-message.js +286 -0
  70. package/lib/Utils/event-buffer.js +530 -0
  71. package/lib/Utils/generics.js +527 -0
  72. package/lib/Utils/history.js +96 -0
  73. package/lib/Utils/index.js +34 -0
  74. package/lib/Utils/link-preview.js +93 -0
  75. package/lib/Utils/logger.js +7 -0
  76. package/lib/Utils/lt-hash.js +51 -0
  77. package/lib/Utils/make-mutex.js +43 -0
  78. package/lib/Utils/messages-media.js +819 -0
  79. package/lib/Utils/messages.js +787 -0
  80. package/lib/Utils/noise-handler.js +155 -0
  81. package/lib/Utils/process-message.js +321 -0
  82. package/lib/Utils/signal.js +153 -0
  83. package/lib/Utils/tc-token-utils.js +114 -0
  84. package/lib/Utils/use-multi-file-auth-state.js +124 -0
  85. package/lib/Utils/validate-connection.js +229 -0
  86. package/lib/WABinary/constants.js +40 -0
  87. package/lib/WABinary/decode.js +252 -0
  88. package/lib/WABinary/encode.js +265 -0
  89. package/lib/WABinary/generic-utils.js +240 -0
  90. package/lib/WABinary/index.js +21 -0
  91. package/lib/WABinary/jid-utils.js +122 -0
  92. package/lib/WABinary/types.js +2 -0
  93. package/lib/WAM/BinaryInfo.js +13 -0
  94. package/lib/WAM/constants.js +15350 -0
  95. package/lib/WAM/encode.js +155 -0
  96. package/lib/WAM/index.js +19 -0
  97. package/lib/WAUSync/Protocols/USyncContactProtocol.js +40 -0
  98. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
  99. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
  100. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
  101. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
  102. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
  103. package/lib/WAUSync/Protocols/index.js +20 -0
  104. package/lib/WAUSync/USyncQuery.js +89 -0
  105. package/lib/WAUSync/USyncUser.js +32 -0
  106. package/lib/WAUSync/index.js +19 -0
  107. package/lib/index.js +52 -0
  108. package/package.json +117 -0
@@ -0,0 +1,240 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAdditionalNode = exports.getBinaryNodeFilter = exports.binaryNodeToString = exports.getBinaryNodeMessages = exports.reduceBinaryNodeToDictionary = exports.assertNodeErrorFree = exports.getBinaryNodeChildUInt = exports.getBinaryNodeChildString = exports.getBinaryNodeChildBuffer = exports.getBinaryNodeChild = exports.getAllBinaryNodeChildren = exports.getBinaryNodeChildren = void 0;
4
+ const boom_1 = require("@hapi/boom");
5
+ const WAProto_1 = require("../../WAProto");
6
+ const Utils_1 = require("../Utils")
7
+ // some extra useful utilities
8
+ // caches children-by-tag lookups per node so repeatedly calling
9
+ // getBinaryNodeChildren/getBinaryNodeChild on the same node (very common when
10
+ // parsing a stanza with multiple helper calls) doesn't re-scan node.content
11
+ // every time. WeakMap means cached entries disappear once the node itself is
12
+ // garbage collected - no manual cleanup needed.
13
+ const childrenByTagCache = new WeakMap();
14
+ const getChildrenByTag = (node) => {
15
+ if (!Array.isArray(node?.content)) {
16
+ return null;
17
+ }
18
+ let byTag = childrenByTagCache.get(node);
19
+ if (!byTag) {
20
+ byTag = new Map();
21
+ for (const item of node.content) {
22
+ const tag = item?.tag;
23
+ if (!tag) {
24
+ continue;
25
+ }
26
+ let list = byTag.get(tag);
27
+ if (!list) {
28
+ list = [];
29
+ byTag.set(tag, list);
30
+ }
31
+ list.push(item);
32
+ }
33
+ childrenByTagCache.set(node, byTag);
34
+ }
35
+ return byTag;
36
+ };
37
+ const getBinaryNodeChildren = (node, childTag) => {
38
+ const byTag = getChildrenByTag(node);
39
+ return byTag?.get(childTag) || [];
40
+ }
41
+ exports.getBinaryNodeChildren = getBinaryNodeChildren;
42
+ const getAllBinaryNodeChildren = ({ content }) => {
43
+ if (Array.isArray(content)) {
44
+ return content
45
+ }
46
+ return []
47
+ }
48
+ exports.getAllBinaryNodeChildren = getAllBinaryNodeChildren;
49
+ const getBinaryNodeChild = (node, childTag) => {
50
+ const byTag = getChildrenByTag(node);
51
+ return byTag?.get(childTag)?.[0];
52
+ }
53
+ exports.getBinaryNodeChild = getBinaryNodeChild;
54
+ const getBinaryNodeChildBuffer = (node, childTag) => {
55
+ const child = getBinaryNodeChild(node, childTag)?.content
56
+ if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
57
+ return child
58
+ }
59
+ }
60
+ exports.getBinaryNodeChildBuffer = getBinaryNodeChildBuffer;
61
+ const getBinaryNodeChildString = (node, childTag) => {
62
+ const child = getBinaryNodeChild(node, childTag)?.content
63
+ if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
64
+ return Buffer.from(child).toString('utf-8')
65
+ }
66
+ else if (typeof child === 'string') {
67
+ return child
68
+ }
69
+ }
70
+ exports.getBinaryNodeChildString = getBinaryNodeChildString;
71
+ const getBinaryNodeChildUInt = (node, childTag, length) => {
72
+ const buff = getBinaryNodeChildBuffer(node, childTag)
73
+ if (buff) {
74
+ return bufferToUInt(buff, length)
75
+ }
76
+ }
77
+ exports.getBinaryNodeChildUInt = getBinaryNodeChildUInt;
78
+ const assertNodeErrorFree = (node) => {
79
+ const errNode = getBinaryNodeChild(node, 'error')
80
+ if (errNode) {
81
+ throw new boom_1.Boom(errNode.attrs.text || 'Unknown error', { data: +errNode.attrs.code })
82
+ }
83
+ }
84
+ exports.assertNodeErrorFree = assertNodeErrorFree;
85
+ const reduceBinaryNodeToDictionary = (node, tag) => {
86
+ const nodes = getBinaryNodeChildren(node, tag)
87
+ const dict = nodes.reduce((dict, { attrs }) => {
88
+ dict[attrs.name || attrs.config_code] = attrs.value || attrs.config_value
89
+ return dict
90
+ }, {})
91
+ return dict
92
+ }
93
+ exports.reduceBinaryNodeToDictionary = reduceBinaryNodeToDictionary;
94
+ const getBinaryNodeMessages = ({ content }) => {
95
+ const msgs = []
96
+ if (Array.isArray(content)) {
97
+ for (const item of content) {
98
+ if (item.tag === 'message') {
99
+ msgs.push(WAProto_1.proto.WebMessageInfo.decode(item.content))
100
+ }
101
+ }
102
+ }
103
+ return msgs
104
+ }
105
+ exports.getBinaryNodeMessages = getBinaryNodeMessages;
106
+ function bufferToUInt(e, t) {
107
+ let a = 0;
108
+ for (let i = 0; i < t; i++) {
109
+ a = 256 * a + e[i];
110
+ }
111
+ return a;
112
+ }
113
+ const tabs = (n) => '\t'.repeat(n);
114
+ function binaryNodeToString(node, i = 0) {
115
+ if (!node) {
116
+ return node;
117
+ }
118
+ if (typeof node === 'string') {
119
+ return tabs(i) + node;
120
+ }
121
+ if (node instanceof Uint8Array) {
122
+ return tabs(i) + Buffer.from(node).toString('hex');
123
+ }
124
+ if (Array.isArray(node)) {
125
+ return node.map((x) => tabs(i + 1) + binaryNodeToString(x, i + 1)).join('\n');
126
+ }
127
+ const children = binaryNodeToString(node.content, i + 1);
128
+ const tag = `<${node.tag} ${Object.entries(node.attrs || {})
129
+ .filter(([, v]) => v !== undefined)
130
+ .map(([k, v]) => `${k}='${v}'`)
131
+ .join(' ')}`;
132
+ const content = children ? `>\n${children}\n${tabs(i)}</${node.tag}>` : '/>';
133
+ return tag + content;
134
+ }
135
+ exports.binaryNodeToString = binaryNodeToString;
136
+ const getBinaryNodeFilter = (node) => {
137
+ if (!Array.isArray(node)) return false
138
+
139
+ return node.some(item =>
140
+ ['native_flow'].includes(item?.content?.[0]?.content?.[0]?.tag) ||
141
+ ['interactive', 'buttons', 'list'].includes(item?.content?.[0]?.tag) ||
142
+ ['hsm', 'biz'].includes(item?.tag) ||
143
+ ['bot'].includes(item?.tag) && item?.attrs?.biz_bot === '1'
144
+ )
145
+ }
146
+ exports.getBinaryNodeFilter = getBinaryNodeFilter;
147
+ const getAdditionalNode = (name) => {
148
+ if (name) name = name.toLowerCase()
149
+ const ts = Utils_1.unixTimestampSeconds(new Date()) - 77980457
150
+
151
+ const order_response_name = {
152
+ review_and_pay: 'order_details',
153
+ review_order: 'order_status',
154
+ payment_info: 'payment_info',
155
+ payment_status: 'payment_status',
156
+ payment_method: 'payment_method'
157
+ }
158
+
159
+ const flow_name = {
160
+ cta_catalog: 'cta_catalog',
161
+ mpm: 'mpm',
162
+ call_request: 'call_permission_request',
163
+ view_catalog: 'automated_greeting_message_view_catalog',
164
+ wa_pay_detail: 'wa_payment_transaction_details',
165
+ send_location: 'send_location',
166
+ // speculative - blm ada konfirmasi resmi nama native_flow-nya, tebakan berdasarkan pola yg udah ada
167
+ payment_key_info: 'wa_payment_key_info',
168
+ }
169
+
170
+ if (name === 'catalog_message') {
171
+ // list message isi produk katalog -> beda struktur dari native_flow, node <list> bukan <interactive>
172
+ return [{
173
+ tag: 'biz',
174
+ attrs: {},
175
+ content: [{
176
+ tag: 'list',
177
+ attrs: {
178
+ type: 'product_list',
179
+ v: '2'
180
+ },
181
+ content: []
182
+ }]
183
+ }]
184
+ } else if(order_response_name[name]) {
185
+ return [{
186
+ tag: 'biz',
187
+ attrs: {
188
+ native_flow_name: order_response_name[name]
189
+ },
190
+ content: []
191
+ }]
192
+ } else if (flow_name[name] || name === 'interactive' || name === 'buttons') {
193
+ return [{
194
+ tag: 'biz',
195
+ attrs: {
196
+ actual_actors: '2',
197
+ host_storage: '2',
198
+ privacy_mode_ts: `${ts}`
199
+ },
200
+ content: [{
201
+ tag: 'engagement',
202
+ attrs: {
203
+ customer_service_state: 'open',
204
+ conversation_state: 'open'
205
+ }
206
+ }, {
207
+ tag: 'interactive',
208
+ attrs: {
209
+ type: 'native_flow',
210
+ v: '1'
211
+ },
212
+ content: [{
213
+ tag: 'native_flow',
214
+ attrs: {
215
+ v: '9',
216
+ name: flow_name[name] ?? 'mixed',
217
+ },
218
+ content: []
219
+ }]
220
+ }]
221
+ }]
222
+ } else {
223
+ return [{
224
+ tag: 'biz',
225
+ attrs: {
226
+ actual_actors: '2',
227
+ host_storage: '2',
228
+ privacy_mode_ts: `${ts}`
229
+ },
230
+ content: [{
231
+ tag: 'engagement',
232
+ attrs: {
233
+ customer_service_state: 'open',
234
+ conversation_state: 'open'
235
+ }
236
+ }]
237
+ }]
238
+ }
239
+ }
240
+ exports.getAdditionalNode = getAdditionalNode;
@@ -0,0 +1,21 @@
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"), exports);
18
+ __exportStar(require("./decode"), exports);
19
+ __exportStar(require("./generic-utils"), exports);
20
+ __exportStar(require("./jid-utils"), exports);
21
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.jidNormalizedUser = exports.isJidNewsLetter = exports.isJidStatusBroadcast = exports.isJidGroup = exports.isJidBroadcast = exports.isLidUser = exports.isJidUser = exports.areJidsSameUser = exports.jidDecode = exports.jidEncode = exports.STORIES_JID = exports.PSA_WID = exports.SERVER_JID = exports.OFFICIAL_BIZ_JID = exports.S_WHATSAPP_NET = void 0;
4
+ exports.isPnUser = exports.isHostedPnUser = exports.isHostedLidUser = exports.WAJIDDomains = exports.getServerFromDomainType = exports.transferDevice = exports.isJidBot = void 0;
5
+ /** matches WA's official bot phone-number patterns (used to gate TC token issuance away from bots) */
6
+ const botRegexp = /^1313555\d{4}$|^131655500\d{2}$/;
7
+ const isJidBot = (jid) => !!(jid && botRegexp.test(jid.split('@')[0]) && jid.endsWith('@c.us'));
8
+ exports.isJidBot = isJidBot;
9
+ exports.S_WHATSAPP_NET = '@s.whatsapp.net';
10
+ exports.OFFICIAL_BIZ_JID = '16505361212@c.us';
11
+ exports.SERVER_JID = 'server@c.us';
12
+ exports.PSA_WID = '0@c.us';
13
+ exports.STORIES_JID = 'status@broadcast';
14
+ /** numeric domain-type codes used by newer WA clients for lid/hosted accounts */
15
+ const WAJIDDomains = { WHATSAPP: 0, LID: 1, HOSTED: 128, HOSTED_LID: 129 };
16
+ exports.WAJIDDomains = WAJIDDomains;
17
+ const getServerFromDomainType = (initialServer, domainType) => {
18
+ switch (domainType) {
19
+ case WAJIDDomains.LID:
20
+ return 'lid';
21
+ case WAJIDDomains.HOSTED:
22
+ return 'hosted';
23
+ case WAJIDDomains.HOSTED_LID:
24
+ return 'hosted.lid';
25
+ case WAJIDDomains.WHATSAPP:
26
+ default:
27
+ return initialServer;
28
+ }
29
+ };
30
+ exports.getServerFromDomainType = getServerFromDomainType;
31
+ const jidEncode = (user, server, device, agent) => {
32
+ return `${user || ''}${!!agent ? `_${agent}` : ''}${!!device ? `:${device}` : ''}@${server}`;
33
+ };
34
+ exports.jidEncode = jidEncode;
35
+ const jidDecode = (jid) => {
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 = userAgent.split('_')[0];
44
+ let domainType = WAJIDDomains.WHATSAPP;
45
+ if (server === 'lid') {
46
+ domainType = WAJIDDomains.LID;
47
+ } else if (server === 'hosted') {
48
+ domainType = WAJIDDomains.HOSTED;
49
+ } else if (server === 'hosted.lid') {
50
+ domainType = WAJIDDomains.HOSTED_LID;
51
+ }
52
+ return {
53
+ server,
54
+ user,
55
+ domainType,
56
+ device: device ? +device : undefined
57
+ };
58
+ };
59
+ exports.jidDecode = jidDecode;
60
+ /** transfers the device id from one jid onto another (used during lid<->pn swaps) */
61
+ const transferDevice = (fromJid, toJid) => {
62
+ const fromDecoded = jidDecode(fromJid);
63
+ const deviceId = (fromDecoded && fromDecoded.device) || 0;
64
+ const toDecoded = jidDecode(toJid);
65
+ return jidEncode(toDecoded.user, toDecoded.server, deviceId);
66
+ };
67
+ exports.transferDevice = transferDevice;
68
+ /** is the jid a user */
69
+ const areJidsSameUser = (jid1, jid2) => {
70
+ var _a, _b;
71
+ return (((_a = (0, exports.jidDecode)(jid1)) === null || _a === void 0 ? void 0 : _a.user) === ((_b = (0, exports.jidDecode)(jid2)) === null || _b === void 0 ? void 0 : _b.user));
72
+ };
73
+ exports.areJidsSameUser = areJidsSameUser;
74
+ /** is the jid a user */
75
+ const isJidUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@s.whatsapp.net'));
76
+ exports.isJidUser = isJidUser;
77
+ /** is the jid a group */
78
+ const isLidUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@lid'));
79
+ exports.isLidUser = isLidUser;
80
+ /** is the jid a regular phone-number user (alias of isJidUser, used by lid-mapping) */
81
+ const isPnUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@s.whatsapp.net'));
82
+ exports.isPnUser = isPnUser;
83
+ /** is the jid a "hosted" phone-number account */
84
+ const isHostedPnUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@hosted'));
85
+ exports.isHostedPnUser = isHostedPnUser;
86
+ /** is the jid a "hosted" lid account */
87
+ const isHostedLidUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@hosted.lid'));
88
+ exports.isHostedLidUser = isHostedLidUser;
89
+ /** is the jid a broadcast */
90
+ const isJidBroadcast = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@broadcast'));
91
+ exports.isJidBroadcast = isJidBroadcast;
92
+ /** is the jid a group */
93
+ const isJidGroup = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@g.us'));
94
+ exports.isJidGroup = isJidGroup;
95
+ /** is the jid the status broadcast */
96
+ const isJidStatusBroadcast = (jid) => jid === 'status@broadcast';
97
+ exports.isJidStatusBroadcast = isJidStatusBroadcast;
98
+ /** is the jid the newsletter */
99
+ const isJidNewsLetter = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('newsletter'));
100
+ exports.isJidNewsLetter = isJidNewsLetter;
101
+ /**
102
+ * SPECULATIVE - WA Username / BSUID support (rollout mulai Jul 2026, blm masuk ID, blm ada di protokol MD resmi).
103
+ * BSUID format yg kekonfirm sejauh ini (Cloud API): "US.13491208655302741918" -> kode negara + "." + digit panjang.
104
+ * Belum jelas apakah MD protocol bakal pake domain baru (mis. "@username"/"@bsuid") atau tetap "@s.whatsapp.net"
105
+ * dgn field tambahan. Ini cuma placeholder detector, JANGAN dipake buat encode/kirim sampe ada konfirmasi real traffic.
106
+ */
107
+ const bsuidRegexp = /^[A-Z]{2}\.\d{6,}$/;
108
+ /** cek apakah string berbentuk BSUID (country-code prefixed id), bukan jid biasa */
109
+ const isBsuid = (id) => !!(id && bsuidRegexp.test(id.split('@')[0]));
110
+ exports.isBsuid = isBsuid;
111
+ /** cek apakah jid pake domain "username" (tebakan, blm ada konfirmasi format resmi dari WA MD protocol) */
112
+ const isUsernameJid = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@username'));
113
+ exports.isUsernameJid = isUsernameJid;
114
+ const jidNormalizedUser = (jid) => {
115
+ const result = (0, exports.jidDecode)(jid);
116
+ if (!result) {
117
+ return '';
118
+ }
119
+ const { user, server } = result;
120
+ return (0, exports.jidEncode)(user, server === 'c.us' ? 's.whatsapp.net' : server);
121
+ };
122
+ exports.jidNormalizedUser = jidNormalizedUser;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
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;