@pontalabs/baileys 1.0.6 → 1.0.8

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 (185) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +839 -267
  3. package/WAProto/GenerateStatics.sh +4 -3
  4. package/WAProto/WAProto.proto +511 -1215
  5. package/WAProto/index.d.ts +55 -14017
  6. package/WAProto/index.js +29 -97689
  7. package/lib/Defaults/index.d.ts +74 -72
  8. package/lib/Defaults/index.js +108 -94
  9. package/lib/Signal/Group/ciphertext-message.d.ts +7 -8
  10. package/lib/Signal/Group/ciphertext-message.js +16 -9
  11. package/lib/Signal/Group/group-session-builder.d.ts +13 -11
  12. package/lib/Signal/Group/group-session-builder.js +61 -19
  13. package/lib/Signal/Group/group_cipher.d.ts +16 -14
  14. package/lib/Signal/Group/group_cipher.js +70 -41
  15. package/lib/Signal/Group/index.d.ts +11 -12
  16. package/lib/Signal/Group/index.js +61 -12
  17. package/lib/Signal/Group/keyhelper.d.ts +14 -9
  18. package/lib/Signal/Group/keyhelper.js +58 -10
  19. package/lib/Signal/Group/sender-chain-key.d.ts +13 -13
  20. package/lib/Signal/Group/sender-chain-key.js +34 -13
  21. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -16
  22. package/lib/Signal/Group/sender-key-distribution-message.js +36 -28
  23. package/lib/Signal/Group/sender-key-message.d.ts +18 -18
  24. package/lib/Signal/Group/sender-key-message.js +45 -38
  25. package/lib/Signal/Group/sender-key-name.d.ts +15 -14
  26. package/lib/Signal/Group/sender-key-name.js +31 -20
  27. package/lib/Signal/Group/sender-key-record.d.ts +25 -24
  28. package/lib/Signal/Group/sender-key-record.js +35 -18
  29. package/lib/Signal/Group/sender-key-state.d.ts +34 -29
  30. package/lib/Signal/Group/sender-key-state.js +100 -37
  31. package/lib/Signal/Group/sender-message-key.d.ts +10 -11
  32. package/lib/Signal/Group/sender-message-key.js +22 -15
  33. package/lib/Signal/libsignal.d.ts +8 -5
  34. package/lib/Signal/libsignal.js +142 -288
  35. package/lib/Signal/lid-mapping.d.ts +28 -23
  36. package/lib/Signal/lid-mapping.js +184 -277
  37. package/lib/Socket/Client/index.d.ts +2 -3
  38. package/lib/Socket/Client/index.js +22 -3
  39. package/lib/Socket/Client/types.d.ts +15 -15
  40. package/lib/Socket/Client/types.js +15 -8
  41. package/lib/Socket/Client/websocket.d.ts +12 -12
  42. package/lib/Socket/Client/websocket.js +37 -29
  43. package/lib/Socket/business.d.ts +178 -208
  44. package/lib/Socket/business.js +127 -91
  45. package/lib/Socket/chats.d.ts +93 -120
  46. package/lib/Socket/chats.js +652 -727
  47. package/lib/Socket/community.js +10 -2
  48. package/lib/Socket/groups.d.ts +111 -143
  49. package/lib/Socket/groups.js +186 -165
  50. package/lib/Socket/index.d.ts +183 -252
  51. package/lib/Socket/index.js +18 -38
  52. package/lib/Socket/messages-recv.d.ts +167 -196
  53. package/lib/Socket/messages-recv.js +1567 -1443
  54. package/lib/Socket/messages-send.d.ts +158 -192
  55. package/lib/Socket/messages-send.js +1208 -1102
  56. package/lib/Socket/newsletter.d.ts +138 -163
  57. package/lib/Socket/newsletter.js +249 -153
  58. package/lib/Socket/socket.d.ts +36 -50
  59. package/lib/Socket/socket.js +820 -749
  60. package/lib/Store/index.d.ts +4 -4
  61. package/lib/Store/index.js +24 -4
  62. package/lib/Store/make-in-memory-store.d.ts +104 -44
  63. package/lib/Store/make-in-memory-store.js +213 -199
  64. package/lib/Store/make-ordered-dictionary.d.ts +12 -13
  65. package/lib/Store/make-ordered-dictionary.js +45 -38
  66. package/lib/Store/object-repository.d.ts +10 -11
  67. package/lib/Store/object-repository.js +16 -9
  68. package/lib/Types/Auth.d.ts +97 -93
  69. package/lib/Types/Auth.js +3 -2
  70. package/lib/Types/Bussines.js +3 -2
  71. package/lib/Types/Call.d.ts +13 -14
  72. package/lib/Types/Call.js +3 -2
  73. package/lib/Types/Chat.d.ts +97 -78
  74. package/lib/Types/Chat.js +9 -8
  75. package/lib/Types/Contact.d.ts +9 -12
  76. package/lib/Types/Contact.js +3 -2
  77. package/lib/Types/Events.d.ts +176 -206
  78. package/lib/Types/Events.js +3 -2
  79. package/lib/Types/GroupMetadata.d.ts +48 -53
  80. package/lib/Types/GroupMetadata.js +3 -2
  81. package/lib/Types/Label.d.ts +14 -13
  82. package/lib/Types/Label.js +30 -24
  83. package/lib/Types/LabelAssociation.d.ts +20 -15
  84. package/lib/Types/LabelAssociation.js +12 -6
  85. package/lib/Types/Message.d.ts +412 -248
  86. package/lib/Types/Message.js +19 -17
  87. package/lib/Types/Product.d.ts +71 -58
  88. package/lib/Types/Product.js +3 -2
  89. package/lib/Types/Signal.d.ts +82 -71
  90. package/lib/Types/Signal.js +3 -2
  91. package/lib/Types/Socket.d.ts +81 -76
  92. package/lib/Types/Socket.js +3 -3
  93. package/lib/Types/State.d.ts +19 -75
  94. package/lib/Types/State.js +14 -56
  95. package/lib/Types/USync.d.ts +8 -8
  96. package/lib/Types/USync.js +3 -2
  97. package/lib/Types/index.d.ts +62 -47
  98. package/lib/Types/index.js +50 -26
  99. package/lib/Utils/auth-utils.d.ts +10 -13
  100. package/lib/Utils/auth-utils.js +472 -213
  101. package/lib/Utils/business.d.ts +20 -14
  102. package/lib/Utils/business.js +134 -110
  103. package/lib/Utils/chat-utils.d.ts +70 -88
  104. package/lib/Utils/chat-utils.js +403 -466
  105. package/lib/Utils/crypto.d.ts +46 -27
  106. package/lib/Utils/crypto.js +188 -117
  107. package/lib/Utils/decode-wa-message.d.ts +45 -58
  108. package/lib/Utils/decode-wa-message.js +311 -212
  109. package/lib/Utils/event-buffer.d.ts +17 -14
  110. package/lib/Utils/event-buffer.js +296 -321
  111. package/lib/Utils/generics.d.ts +92 -66
  112. package/lib/Utils/generics.js +436 -270
  113. package/lib/Utils/history.d.ts +23 -24
  114. package/lib/Utils/history.js +76 -106
  115. package/lib/Utils/index.d.ts +21 -24
  116. package/lib/Utils/index.js +41 -24
  117. package/lib/Utils/link-preview.d.ts +14 -12
  118. package/lib/Utils/link-preview.js +75 -40
  119. package/lib/Utils/logger.d.ts +11 -10
  120. package/lib/Utils/logger.js +7 -3
  121. package/lib/Utils/lt-hash.d.ts +14 -8
  122. package/lib/Utils/lt-hash.js +53 -3
  123. package/lib/Utils/make-mutex.d.ts +7 -7
  124. package/lib/Utils/make-mutex.js +44 -28
  125. package/lib/Utils/message-retry-manager.d.ts +88 -115
  126. package/lib/Utils/message-retry-manager.js +160 -265
  127. package/lib/Utils/messages-media.d.ts +107 -105
  128. package/lib/Utils/messages-media.js +619 -548
  129. package/lib/Utils/messages.d.ts +66 -52
  130. package/lib/Utils/messages.js +1558 -1730
  131. package/lib/Utils/noise-handler.d.ts +18 -18
  132. package/lib/Utils/noise-handler.js +130 -176
  133. package/lib/Utils/process-message.d.ts +32 -43
  134. package/lib/Utils/process-message.js +282 -484
  135. package/lib/Utils/rich-message-utils.js +724 -1220
  136. package/lib/Utils/signal.d.ts +32 -37
  137. package/lib/Utils/signal.js +105 -140
  138. package/lib/Utils/use-multi-file-auth-state.d.ts +5 -5
  139. package/lib/Utils/use-multi-file-auth-state.js +120 -70
  140. package/lib/Utils/use-single-file-auth-state.d.ts +13 -11
  141. package/lib/Utils/use-single-file-auth-state.js +66 -92
  142. package/lib/Utils/validate-connection.d.ts +13 -11
  143. package/lib/Utils/validate-connection.js +113 -128
  144. package/lib/WABinary/constants.d.ts +27 -25
  145. package/lib/WABinary/constants.js +1292 -1451
  146. package/lib/WABinary/decode.d.ts +9 -7
  147. package/lib/WABinary/decode.js +189 -163
  148. package/lib/WABinary/encode.d.ts +3 -3
  149. package/lib/WABinary/encode.js +155 -110
  150. package/lib/WABinary/generic-utils.d.ts +27 -14
  151. package/lib/WABinary/generic-utils.js +105 -177
  152. package/lib/WABinary/index.d.ts +5 -6
  153. package/lib/WABinary/index.js +25 -6
  154. package/lib/WABinary/jid-utils.d.ts +54 -41
  155. package/lib/WABinary/jid-utils.js +152 -83
  156. package/lib/WABinary/types.d.ts +13 -10
  157. package/lib/WABinary/types.js +3 -2
  158. package/lib/WAM/BinaryInfo.d.ts +15 -8
  159. package/lib/WAM/BinaryInfo.js +14 -7
  160. package/lib/WAM/constants.d.ts +37 -30
  161. package/lib/WAM/constants.js +11983 -19465
  162. package/lib/WAM/encode.d.ts +3 -3
  163. package/lib/WAM/encode.js +109 -95
  164. package/lib/WAM/index.d.ts +3 -4
  165. package/lib/WAM/index.js +23 -4
  166. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -9
  167. package/lib/WAUSync/Protocols/USyncContactProtocol.js +21 -37
  168. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -19
  169. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +26 -18
  170. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -11
  171. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +20 -12
  172. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -11
  173. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +24 -16
  174. package/lib/WAUSync/Protocols/index.d.ts +6 -6
  175. package/lib/WAUSync/Protocols/index.js +26 -6
  176. package/lib/WAUSync/USyncQuery.d.ts +28 -27
  177. package/lib/WAUSync/USyncQuery.js +62 -68
  178. package/lib/WAUSync/USyncUser.d.ts +10 -15
  179. package/lib/WAUSync/USyncUser.js +19 -20
  180. package/lib/WAUSync/index.d.ts +3 -4
  181. package/lib/WAUSync/index.js +23 -4
  182. package/lib/index.d.ts +12 -11
  183. package/lib/index.js +39 -12
  184. package/package.json +43 -87
  185. package/engine-requirements.js +0 -10
@@ -1,214 +1,142 @@
1
- import { randomBytes } from 'crypto';
2
- import { Boom } from '@hapi/boom';
3
- import { proto } from '../../WAProto/index.js';
4
- import {} from './types.js';
1
+ "use strict"
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true })
4
+
5
+ const boom_1 = require("@hapi/boom")
6
+ const WAProto_1 = require("../../WAProto")
7
+
5
8
  // some extra useful utilities
6
- const indexCache = new WeakMap();
7
- export const getBinaryNodeChildren = (node, childTag) => {
8
- if (!node || !Array.isArray(node.content))
9
- return [];
10
- let index = indexCache.get(node);
11
- // Build the index once per node
12
- if (!index) {
13
- index = new Map();
14
- for (const child of node.content) {
15
- let arr = index.get(child.tag);
16
- if (!arr)
17
- index.set(child.tag, (arr = []));
18
- arr.push(child);
19
- }
20
- indexCache.set(node, index);
9
+ const getBinaryNodeChildren = (node, childTag) => {
10
+ if (Array.isArray(node?.content)) {
11
+ return node.content.filter(item => item.tag === childTag)
21
12
  }
22
- // Return first matching child
23
- return index.get(childTag) || [];
24
- };
25
- export const getBinaryNodeChild = (node, childTag) => {
26
- return getBinaryNodeChildren(node, childTag)[0];
27
- };
28
- export const getAllBinaryNodeChildren = ({ content }) => {
13
+ return []
14
+ }
15
+
16
+ const getAllBinaryNodeChildren = ({ content }) => {
29
17
  if (Array.isArray(content)) {
30
- return content;
18
+ return content
19
+ }
20
+ return []
21
+ }
22
+
23
+ const getBinaryNodeChild = (node, childTag) => {
24
+ if (Array.isArray(node?.content)) {
25
+ return node?.content.find(item => item.tag === childTag)
31
26
  }
32
- return [];
33
- };
34
- export const getBinaryNodeChildBuffer = (node, childTag) => {
35
- const child = getBinaryNodeChild(node, childTag)?.content;
27
+ }
28
+
29
+ const getBinaryNodeChildBuffer = (node, childTag) => {
30
+ const child = getBinaryNodeChild(node, childTag)?.content
36
31
  if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
37
- return child;
32
+ return child
38
33
  }
39
- };
40
- export const getBinaryNodeChildString = (node, childTag) => {
41
- const child = getBinaryNodeChild(node, childTag)?.content;
34
+ }
35
+
36
+ const getBinaryNodeChildString = (node, childTag) => {
37
+ const child = getBinaryNodeChild(node, childTag)?.content
42
38
  if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
43
- return Buffer.from(child).toString('utf-8');
39
+ return Buffer.from(child).toString('utf-8')
44
40
  }
45
41
  else if (typeof child === 'string') {
46
- return child;
42
+ return child
47
43
  }
48
- };
49
- export const getBinaryNodeChildUInt = (node, childTag, length) => {
50
- const buff = getBinaryNodeChildBuffer(node, childTag);
44
+ }
45
+
46
+ const getBinaryNodeChildUInt = (node, childTag, length) => {
47
+ const buff = getBinaryNodeChildBuffer(node, childTag)
51
48
  if (buff) {
52
- return bufferToUInt(buff, length);
49
+ return bufferToUInt(buff, length)
53
50
  }
54
- };
55
- export const assertNodeErrorFree = (node) => {
56
- const errNode = getBinaryNodeChild(node, 'error');
51
+ }
52
+
53
+ const assertNodeErrorFree = (node) => {
54
+ const errNode = getBinaryNodeChild(node, 'error')
57
55
  if (errNode) {
58
- throw new Boom(errNode.attrs.text || 'Unknown error', { data: +errNode.attrs.code });
56
+ throw new boom_1.Boom(errNode.attrs.text || 'Unknown error', { data: +errNode.attrs.code })
59
57
  }
60
- };
61
- export const reduceBinaryNodeToDictionary = (node, tag) => {
62
- const nodes = getBinaryNodeChildren(node, tag);
58
+ }
59
+
60
+ const reduceBinaryNodeToDictionary = (node, tag) => {
61
+ const nodes = getBinaryNodeChildren(node, tag)
63
62
  const dict = nodes.reduce((dict, { attrs }) => {
64
- if (typeof attrs.name === 'string') {
65
- dict[attrs.name] = attrs.value || attrs.config_value;
66
- }
67
- else {
68
- dict[attrs.config_code] = attrs.value || attrs.config_value;
69
- }
70
- return dict;
71
- }, {});
72
- return dict;
73
- };
74
- export const getBinaryNodeMessages = ({ content }) => {
75
- const msgs = [];
63
+ dict[attrs.name || attrs.config_code] = attrs.value || attrs.config_value
64
+ return dict
65
+ }, {})
66
+ return dict
67
+ }
68
+
69
+ const getBinaryNodeMessages = ({ content }) => {
70
+ const msgs = []
76
71
  if (Array.isArray(content)) {
77
72
  for (const item of content) {
78
73
  if (item.tag === 'message') {
79
- msgs.push(proto.WebMessageInfo.decode(item.content).toJSON());
74
+ msgs.push(WAProto_1.proto.WebMessageInfo.decode(item.content))
80
75
  }
81
76
  }
82
77
  }
83
- return msgs;
84
- };
78
+ return msgs
79
+ }
80
+
81
+ const getBinaryFilteredButtons = (nodeContent) => {
82
+ if (!Array.isArray(nodeContent)) return false
83
+
84
+ return nodeContent.some(a =>
85
+ ['native_flow'].includes(a?.content?.[0]?.content?.[0]?.tag) ||
86
+ ['interactive', 'buttons', 'list'].includes(a?.content?.[0]?.tag) ||
87
+ ['hsm', 'biz'].includes(a?.tag)
88
+ )
89
+ }
90
+
91
+ const getBinaryFilteredBizBot = (nodeContent) => {
92
+ if (!Array.isArray(nodeContent)) return false
93
+
94
+ return nodeContent.some(b =>
95
+ ['bot'].includes(b?.tag) && b?.attrs?.biz_bot === '1'
96
+ )
97
+ }
98
+
85
99
  function bufferToUInt(e, t) {
86
- let a = 0;
100
+ let a = 0
87
101
  for (let i = 0; i < t; i++) {
88
- a = 256 * a + e[i];
102
+ a = 256 * a + e[i]
89
103
  }
90
- return a;
104
+ return a
91
105
  }
92
- const tabs = (n) => '\t'.repeat(n);
93
- export function binaryNodeToString(node, i = 0) {
106
+ const tabs = (n) => '\t'.repeat(n)
107
+ function binaryNodeToString(node, i = 0) {
94
108
  if (!node) {
95
- return node;
109
+ return node
96
110
  }
97
111
  if (typeof node === 'string') {
98
- return tabs(i) + node;
112
+ return tabs(i) + node
99
113
  }
100
114
  if (node instanceof Uint8Array) {
101
- return tabs(i) + Buffer.from(node).toString('hex');
115
+ return tabs(i) + Buffer.from(node).toString('hex')
102
116
  }
103
117
  if (Array.isArray(node)) {
104
- return node.map(x => tabs(i + 1) + binaryNodeToString(x, i + 1)).join('\n');
118
+ return node.map((x) => tabs(i + 1) + binaryNodeToString(x, i + 1)).join('\n')
105
119
  }
106
- const children = binaryNodeToString(node.content, i + 1);
120
+ const children = binaryNodeToString(node.content, i + 1)
107
121
  const tag = `<${node.tag} ${Object.entries(node.attrs || {})
108
122
  .filter(([, v]) => v !== undefined)
109
123
  .map(([k, v]) => `${k}='${v}'`)
110
- .join(' ')}`;
111
- const content = children ? `>\n${children}\n${tabs(i)}</${node.tag}>` : '/>';
112
- return tag + content;
124
+ .join(' ')}`
125
+ const content = children ? `>\n${children}\n${tabs(i)}</${node.tag}>` : '/>'
126
+ return tag + content
113
127
  }
114
- const FLOWS_MAP = {
115
- mpm: true,
116
- cta_catalog: true,
117
- send_location: true,
118
- call_permission_request: true,
119
- wa_payment_transaction_details: true,
120
- automated_greeting_message_view_catalog: true
121
- };
122
- const DECISION_SOURCE_CONTENT = [
123
- {
124
- tag: 'decision_source',
125
- attrs: { value: 'df' }
126
- }
127
- ];
128
- const LIST_TYPE_CONTENT = {
129
- tag: 'list',
130
- attrs: { v: '2', type: 'product_list' }
131
- };
132
- const NATIVE_FLOW_ATTRIBUTE = { type: 'native_flow', v: '1' };
133
- const MIXED_NATIVE_FLOW = {
134
- tag: 'interactive',
135
- attrs: NATIVE_FLOW_ATTRIBUTE,
136
- content: [
137
- {
138
- tag: 'native_flow',
139
- attrs: { v: '9', name: 'mixed' }
140
- }
141
- ]
142
- };
143
- export const getBizBinaryNode = (message) => {
144
- const flowMsg = message.interactiveMessage?.nativeFlowMessage;
145
- const firstButtonName = flowMsg?.buttons?.[0]?.name;
146
- const qualityContent = {
147
- tag: 'quality_control',
148
- attrs: {
149
- decision_id: randomBytes(20).toString('hex'),
150
- source_type: 'third_party'
151
- },
152
- content: DECISION_SOURCE_CONTENT
153
- };
154
- const bizAttributes = {
155
- actual_actors: '2',
156
- host_storage: '2',
157
- privacy_mode_ts: `${Date.now() / 1_000 | 0}`
158
- };
159
- if (firstButtonName === 'review_and_pay' || firstButtonName === 'payment_info') {
160
- bizAttributes.native_flow_name = firstButtonName === 'review_and_pay' ?
161
- 'order_details' :
162
- firstButtonName;
163
- return {
164
- tag: 'biz',
165
- attrs: bizAttributes,
166
- content: [qualityContent]
167
- };
168
- }
169
- if (firstButtonName && FLOWS_MAP[firstButtonName]) {
170
- return {
171
- tag: 'biz',
172
- attrs: bizAttributes,
173
- content: [
174
- {
175
- tag: 'interactive',
176
- attrs: NATIVE_FLOW_ATTRIBUTE,
177
- content: [
178
- {
179
- tag: 'native_flow',
180
- attrs: { v: '2', name: firstButtonName }
181
- }
182
- ]
183
- },
184
- qualityContent
185
- ]
186
- };
187
- }
188
- if (flowMsg || message.buttonsMessage || message.templateMessage) {
189
- return {
190
- tag: 'biz',
191
- attrs: bizAttributes,
192
- content: [
193
- MIXED_NATIVE_FLOW,
194
- qualityContent
195
- ]
196
- };
197
- }
198
- if (message.listMessage) {
199
- return {
200
- tag: 'biz',
201
- attrs: bizAttributes,
202
- content: [
203
- LIST_TYPE_CONTENT,
204
- qualityContent
205
- ]
206
- };
207
- }
208
- return {
209
- tag: 'biz',
210
- attrs: bizAttributes,
211
- content: [qualityContent]
212
- };
213
- };
214
- //# sourceMappingURL=generic-utils.js.map
128
+
129
+ module.exports = {
130
+ getBinaryNodeChildren,
131
+ getAllBinaryNodeChildren,
132
+ getBinaryNodeChild,
133
+ getBinaryNodeChildBuffer,
134
+ getBinaryNodeChildString,
135
+ getBinaryNodeChildUInt,
136
+ assertNodeErrorFree,
137
+ reduceBinaryNodeToDictionary,
138
+ getBinaryNodeMessages,
139
+ getBinaryFilteredButtons,
140
+ getBinaryFilteredBizBot,
141
+ binaryNodeToString
142
+ }
@@ -1,6 +1,5 @@
1
- export * from './encode.js';
2
- export * from './decode.js';
3
- export * from './generic-utils.js';
4
- export * from './jid-utils.js';
5
- export * from './types.js';
6
- //# sourceMappingURL=index.d.ts.map
1
+ export * from './encode'
2
+ export * from './decode'
3
+ export * from './generic-utils'
4
+ export * from './jid-utils'
5
+ export * from './types'
@@ -1,6 +1,25 @@
1
- export * from './encode.js';
2
- export * from './decode.js';
3
- export * from './generic-utils.js';
4
- export * from './jid-utils.js';
5
- export * from './types.js';
6
- //# sourceMappingURL=index.js.map
1
+ "use strict"
2
+
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k
5
+ var desc = Object.getOwnPropertyDescriptor(m, k)
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k] } }
8
+ }
9
+ Object.defineProperty(o, k2, desc)
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k
12
+ o[k2] = m[k]
13
+ }))
14
+
15
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p)
17
+ }
18
+
19
+ Object.defineProperty(exports, "__esModule", { value: true })
20
+
21
+ __exportStar(require("./encode"), exports)
22
+ __exportStar(require("./decode"), exports)
23
+ __exportStar(require("./generic-utils"), exports)
24
+ __exportStar(require("./jid-utils"), exports)
25
+ __exportStar(require("./types"), exports)
@@ -1,48 +1,61 @@
1
- export declare const S_WHATSAPP_NET = "@s.whatsapp.net";
2
- export declare const OFFICIAL_BIZ_JID = "16505361212@c.us";
3
- export declare const SERVER_JID = "server@c.us";
4
- export declare const PSA_WID = "0@c.us";
5
- export declare const STORIES_JID = "status@broadcast";
6
- export declare const META_AI_JID = "13135550002@c.us";
7
- export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call' | 'lid' | 'newsletter' | 'bot' | 'hosted' | 'hosted.lid';
8
- export declare enum WAJIDDomains {
9
- WHATSAPP = 0,
10
- LID = 1,
11
- HOSTED = 128,
12
- HOSTED_LID = 129
13
- }
1
+ export declare const S_WHATSAPP_NET = "@s.whatsapp.net"
2
+
3
+ export declare const OFFICIAL_BIZ_JID = "16505361212@c.us"
4
+
5
+ export declare const SERVER_JID = "server@c.us"
6
+
7
+ export declare const PSA_WID = "0@c.us"
8
+
9
+ export declare const STORIES_JID = "status@broadcast"
10
+
11
+ export declare const META_AI_JID = '13135550002@c.us'
12
+
13
+ export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call' | 'lid' | 'newsletter' | 'bot'
14
+
14
15
  export type JidWithDevice = {
15
- user: string;
16
- device?: number;
17
- };
16
+ user: string
17
+ device?: number
18
+ }
19
+
18
20
  export type FullJid = JidWithDevice & {
19
- server: JidServer;
20
- domainType?: number;
21
- };
22
- export declare const getServerFromDomainType: (initialServer: string, domainType?: WAJIDDomains) => JidServer;
23
- export declare const jidEncode: (user: string | number | null, server: JidServer, device?: number, agent?: number) => string;
24
- export declare const jidDecode: (jid: string | undefined) => FullJid | undefined;
25
- /** is the jid a user */
26
- export declare const areJidsSameUser: (jid1: string | undefined, jid2: string | undefined) => boolean;
21
+ server: JidServer
22
+ domainType?: number
23
+ }
24
+
25
+ export declare const jidEncode: (user: string | number | null, server: JidServer, device?: number, agent?: number) => string
26
+
27
+ export declare const jidDecode: (jid: string | undefined) => FullJid | undefined
28
+
27
29
  /** is the jid Meta AI */
28
- export declare const isJidMetaAI: (jid: string | undefined) => boolean | undefined;
29
- /** is the jid a PN user */
30
- export declare const isPnUser: (jid: string | undefined) => boolean | undefined;
31
- /** is the jid a LID */
32
- export declare const isLidUser: (jid: string | undefined) => boolean | undefined;
30
+ export declare const isJidMetaAI: (jid: string | undefined) => boolean | undefined
31
+
32
+ /** is the jid a user */
33
+ export declare const areJidsSameUser: (jid1: string | undefined, jid2: string | undefined) => boolean
34
+
35
+ /** is the lid a user */
36
+ export declare const isJidUser: (jid: string | undefined) => boolean | undefined
37
+
38
+ /** is the jid a group */
39
+ export declare const isLidUser: (jid: string | undefined) => boolean | undefined
40
+
33
41
  /** is the jid a broadcast */
34
- export declare const isJidBroadcast: (jid: string | undefined) => boolean | undefined;
42
+ export declare const isJidBroadcast: (jid: string | undefined) => boolean | undefined
43
+
35
44
  /** is the jid a group */
36
- export declare const isJidGroup: (jid: string | undefined) => boolean | undefined;
45
+ export declare const isJidGroup: (jid: string | undefined) => boolean | undefined
46
+
37
47
  /** is the jid the status broadcast */
38
- export declare const isJidStatusBroadcast: (jid: string) => jid is "status@broadcast";
48
+ export declare const isJidStatusBroadcast: (jid: string) => boolean
49
+
39
50
  /** is the jid a newsletter */
40
- export declare const isJidNewsletter: (jid: string | undefined) => boolean | undefined;
41
- /** is the jid a hosted PN */
42
- export declare const isHostedPnUser: (jid: string | undefined) => boolean | undefined;
43
- /** is the jid a hosted LID */
44
- export declare const isHostedLidUser: (jid: string | undefined) => boolean | undefined;
45
- export declare const isJidBot: (jid: string | undefined) => boolean | "" | undefined;
46
- export declare const jidNormalizedUser: (jid: string | undefined) => string;
47
- export declare const transferDevice: (fromJid: string, toJid: string) => string;
48
- //# sourceMappingURL=jid-utils.d.ts.map
51
+ export declare const isJidNewsletter: (jid: string | undefined) => boolean | undefined
52
+
53
+ /** is the jid a bot */
54
+ export declare const isJidBot: (jid: string | undefined) => boolean | undefined
55
+
56
+ export declare const jidNormalizedUser: (jid: string | undefined) => string
57
+
58
+ export declare const transferDevice: (fromJid: string, toJid: string) => string
59
+
60
+ /** pisahkan dua kandidat identitas jadi { jid, lid } berdasarkan suffix domain-nya */
61
+ export declare const splitJidLid: (a: string | undefined, b: string | undefined) => { jid: string | undefined, lid: string | undefined }