@hbmodsofc/baileys 1.7.8 → 2.2.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.
- package/LICENSE +1 -1
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.d.ts +8 -12
- package/lib/Defaults/index.js +124 -90
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/Group/group_cipher.d.ts +1 -0
- package/lib/Signal/Group/group_cipher.js +39 -28
- package/lib/Signal/Group/queue-job.d.ts +1 -0
- package/lib/Signal/Group/queue-job.js +57 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
- package/lib/Signal/Group/sender-chain-key.js +2 -9
- package/lib/Signal/Group/sender-key-distribution-message.js +3 -3
- package/lib/Signal/Group/sender-key-message.js +3 -3
- package/lib/Signal/Group/sender-key-state.d.ts +4 -4
- package/lib/Signal/Group/sender-key-state.js +16 -47
- package/lib/Signal/libsignal.d.ts +3 -7
- package/lib/Signal/libsignal.js +39 -224
- package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +3 -1
- package/lib/Socket/Client/index.d.ts +3 -2
- package/lib/Socket/Client/index.js +3 -2
- package/lib/Socket/Client/mobile-socket-client.d.ts +13 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -1
- package/lib/Socket/Client/{websocket.js → web-socket-client.js} +16 -10
- package/lib/Socket/business.d.ts +78 -94
- package/lib/Socket/business.js +11 -130
- package/lib/Socket/chats.d.ts +233 -63
- package/lib/Socket/chats.js +184 -234
- package/lib/Socket/groups.d.ts +41 -62
- package/lib/Socket/groups.js +64 -76
- package/lib/Socket/hbmods.d.ts +253 -0
- package/lib/Socket/hbmods.js +1 -0
- package/lib/Socket/index.d.ts +83 -129
- package/lib/Socket/index.js +6 -13
- package/lib/Socket/messages-recv.d.ts +48 -59
- package/lib/Socket/messages-recv.js +371 -516
- package/lib/Socket/messages-send.d.ts +67 -86
- package/lib/Socket/messages-send.js +1 -1091
- package/lib/Socket/newsletter.d.ts +64 -76
- package/lib/Socket/newsletter.js +1 -184
- package/lib/Socket/registration.d.ts +267 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +13 -19
- package/lib/Socket/socket.js +1 -805
- package/lib/Socket/usync.d.ts +36 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Types/Auth.d.ts +10 -4
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +9 -29
- package/lib/Types/Chat.js +1 -7
- package/lib/Types/Contact.d.ts +1 -5
- package/lib/Types/Events.d.ts +14 -55
- package/lib/Types/GroupMetadata.d.ts +5 -15
- package/lib/Types/Label.d.ts +0 -11
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Message.d.ts +49 -75
- package/lib/Types/Message.js +7 -10
- package/lib/Types/Newsletter.d.ts +98 -129
- package/lib/Types/Newsletter.js +38 -33
- package/lib/Types/Product.d.ts +1 -1
- package/lib/Types/Signal.d.ts +1 -29
- package/lib/Types/Socket.d.ts +22 -48
- package/lib/Types/State.d.ts +2 -13
- package/lib/Types/State.js +0 -12
- package/lib/Types/USync.d.ts +1 -1
- package/lib/Types/index.d.ts +3 -10
- package/lib/Types/index.js +2 -2
- package/lib/Utils/auth-utils.d.ts +3 -3
- package/lib/Utils/auth-utils.js +102 -378
- package/lib/Utils/baileys-event-stream.js +1 -1
- package/lib/Utils/business.d.ts +2 -2
- package/lib/Utils/business.js +13 -19
- package/lib/Utils/chat-utils.d.ts +22 -21
- package/lib/Utils/chat-utils.js +154 -201
- package/lib/Utils/crypto.d.ts +19 -18
- package/lib/Utils/crypto.js +37 -78
- package/lib/Utils/decode-wa-message.d.ts +7 -34
- package/lib/Utils/decode-wa-message.js +66 -138
- package/lib/Utils/event-buffer.d.ts +8 -6
- package/lib/Utils/event-buffer.js +43 -81
- package/lib/Utils/generics.d.ts +27 -27
- package/lib/Utils/generics.js +133 -128
- package/lib/Utils/history.d.ts +5 -9
- package/lib/Utils/history.js +23 -17
- package/lib/Utils/index.d.ts +0 -2
- package/lib/Utils/index.js +0 -2
- package/lib/Utils/link-preview.d.ts +4 -4
- package/lib/Utils/link-preview.js +12 -40
- package/lib/Utils/logger.d.ts +3 -11
- package/lib/Utils/lt-hash.d.ts +8 -8
- package/lib/Utils/lt-hash.js +24 -23
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/make-mutex.js +2 -3
- package/lib/Utils/messages-media.d.ts +41 -37
- package/lib/Utils/messages-media.js +368 -252
- package/lib/Utils/messages.d.ts +15 -13
- package/lib/Utils/messages.js +261 -274
- package/lib/Utils/noise-handler.d.ts +15 -13
- package/lib/Utils/noise-handler.js +26 -20
- package/lib/Utils/process-message.d.ts +8 -9
- package/lib/Utils/process-message.js +93 -157
- package/lib/Utils/signal.d.ts +5 -6
- package/lib/Utils/signal.js +29 -37
- package/lib/Utils/use-multi-file-auth-state.d.ts +2 -1
- package/lib/Utils/use-multi-file-auth-state.js +7 -12
- package/lib/Utils/validate-connection.d.ts +6 -5
- package/lib/Utils/validate-connection.js +97 -39
- package/lib/WABinary/constants.d.ts +27 -24
- package/lib/WABinary/constants.js +13 -1276
- package/lib/WABinary/decode.d.ts +4 -3
- package/lib/WABinary/decode.js +14 -28
- package/lib/WABinary/encode.d.ts +2 -1
- package/lib/WABinary/encode.js +147 -134
- package/lib/WABinary/generic-utils.d.ts +7 -4
- package/lib/WABinary/generic-utils.js +125 -40
- package/lib/WABinary/jid-utils.d.ts +8 -13
- package/lib/WABinary/jid-utils.js +16 -27
- package/lib/WAM/BinaryInfo.d.ts +11 -2
- package/lib/WAM/constants.d.ts +2 -3
- package/lib/WAM/constants.js +2359 -2252
- package/lib/WAM/encode.d.ts +2 -1
- package/lib/WAM/encode.js +11 -8
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +4 -3
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +5 -5
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +5 -5
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +6 -5
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +3 -4
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +3 -11
- package/lib/WAUSync/USyncQuery.d.ts +2 -2
- package/lib/WAUSync/USyncQuery.js +15 -19
- package/lib/WAUSync/USyncUser.d.ts +5 -5
- package/lib/WAUSync/index.d.ts +1 -1
- package/lib/WAUSync/index.js +1 -1
- package/package.json +102 -104
- package/WAProto/index.js +0 -37306
- package/lib/Signal/lid-mapping.d.ts +0 -26
- package/lib/Signal/lid-mapping.js +0 -146
- package/lib/Socket/communities.d.ts +0 -232
- package/lib/Socket/communities.js +0 -402
- package/lib/Socket/mex.d.ts +0 -2
- package/lib/Socket/mex.js +0 -45
- package/lib/Types/Bussines.d.ts +0 -24
- package/lib/Types/Bussines.js +0 -2
- package/lib/Utils/lidToJid-test.d.ts +0 -11
- package/lib/Utils/lidToJid-test.js +0 -27
- package/lib/Utils/message-retry-manager.d.ts +0 -81
- package/lib/Utils/message-retry-manager.js +0 -152
- /package/lib/Socket/Client/{types.js → abstract-socket-client.js} +0 -0
|
@@ -1,86 +1,81 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBinaryNodeMessages = exports.reduceBinaryNodeToDictionary = exports.assertNodeErrorFree = exports.getBinaryNodeChildUInt = exports.getBinaryNodeChildString = exports.getBinaryNodeChildBuffer = exports.getBinaryNodeChild = exports.getAllBinaryNodeChildren = exports.getBinaryNodeChildren = void 0;
|
|
4
|
-
exports.binaryNodeToString = binaryNodeToString;
|
|
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;
|
|
5
4
|
const boom_1 = require("@hapi/boom");
|
|
6
|
-
const
|
|
5
|
+
const WAProto_1 = require("../../WAProto");
|
|
6
|
+
const Utils_1 = require("../Utils")
|
|
7
7
|
// some extra useful utilities
|
|
8
8
|
const getBinaryNodeChildren = (node, childTag) => {
|
|
9
9
|
if (Array.isArray(node?.content)) {
|
|
10
|
-
return node.content.filter(item => item.tag === childTag)
|
|
10
|
+
return node.content.filter(item => item.tag === childTag)
|
|
11
11
|
}
|
|
12
|
-
return []
|
|
13
|
-
}
|
|
12
|
+
return []
|
|
13
|
+
}
|
|
14
14
|
exports.getBinaryNodeChildren = getBinaryNodeChildren;
|
|
15
15
|
const getAllBinaryNodeChildren = ({ content }) => {
|
|
16
16
|
if (Array.isArray(content)) {
|
|
17
|
-
return content
|
|
17
|
+
return content
|
|
18
18
|
}
|
|
19
|
-
return []
|
|
20
|
-
}
|
|
19
|
+
return []
|
|
20
|
+
}
|
|
21
21
|
exports.getAllBinaryNodeChildren = getAllBinaryNodeChildren;
|
|
22
22
|
const getBinaryNodeChild = (node, childTag) => {
|
|
23
23
|
if (Array.isArray(node?.content)) {
|
|
24
|
-
return node?.content.find(item => item.tag === childTag)
|
|
24
|
+
return node?.content.find(item => item.tag === childTag)
|
|
25
25
|
}
|
|
26
|
-
}
|
|
26
|
+
}
|
|
27
27
|
exports.getBinaryNodeChild = getBinaryNodeChild;
|
|
28
28
|
const getBinaryNodeChildBuffer = (node, childTag) => {
|
|
29
|
-
const child =
|
|
29
|
+
const child = getBinaryNodeChild(node, childTag)?.content
|
|
30
30
|
if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
|
|
31
|
-
return child
|
|
31
|
+
return child
|
|
32
32
|
}
|
|
33
|
-
}
|
|
33
|
+
}
|
|
34
34
|
exports.getBinaryNodeChildBuffer = getBinaryNodeChildBuffer;
|
|
35
35
|
const getBinaryNodeChildString = (node, childTag) => {
|
|
36
|
-
const child =
|
|
36
|
+
const child = getBinaryNodeChild(node, childTag)?.content
|
|
37
37
|
if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
|
|
38
|
-
return Buffer.from(child).toString('utf-8')
|
|
38
|
+
return Buffer.from(child).toString('utf-8')
|
|
39
39
|
}
|
|
40
40
|
else if (typeof child === 'string') {
|
|
41
|
-
return child
|
|
41
|
+
return child
|
|
42
42
|
}
|
|
43
|
-
}
|
|
43
|
+
}
|
|
44
44
|
exports.getBinaryNodeChildString = getBinaryNodeChildString;
|
|
45
45
|
const getBinaryNodeChildUInt = (node, childTag, length) => {
|
|
46
|
-
const buff =
|
|
46
|
+
const buff = getBinaryNodeChildBuffer(node, childTag)
|
|
47
47
|
if (buff) {
|
|
48
|
-
return bufferToUInt(buff, length)
|
|
48
|
+
return bufferToUInt(buff, length)
|
|
49
49
|
}
|
|
50
|
-
}
|
|
50
|
+
}
|
|
51
51
|
exports.getBinaryNodeChildUInt = getBinaryNodeChildUInt;
|
|
52
52
|
const assertNodeErrorFree = (node) => {
|
|
53
|
-
const errNode =
|
|
53
|
+
const errNode = getBinaryNodeChild(node, 'error')
|
|
54
54
|
if (errNode) {
|
|
55
|
-
throw new boom_1.Boom(errNode.attrs.text || 'Unknown error', { data: +errNode.attrs.code })
|
|
55
|
+
throw new boom_1.Boom(errNode.attrs.text || 'Unknown error', { data: +errNode.attrs.code })
|
|
56
56
|
}
|
|
57
|
-
}
|
|
57
|
+
}
|
|
58
58
|
exports.assertNodeErrorFree = assertNodeErrorFree;
|
|
59
59
|
const reduceBinaryNodeToDictionary = (node, tag) => {
|
|
60
|
-
const nodes =
|
|
60
|
+
const nodes = getBinaryNodeChildren(node, tag)
|
|
61
61
|
const dict = nodes.reduce((dict, { attrs }) => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
return dict;
|
|
69
|
-
}, {});
|
|
70
|
-
return dict;
|
|
71
|
-
};
|
|
62
|
+
dict[attrs.name || attrs.config_code] = attrs.value || attrs.config_value
|
|
63
|
+
return dict
|
|
64
|
+
}, {})
|
|
65
|
+
return dict
|
|
66
|
+
}
|
|
72
67
|
exports.reduceBinaryNodeToDictionary = reduceBinaryNodeToDictionary;
|
|
73
68
|
const getBinaryNodeMessages = ({ content }) => {
|
|
74
|
-
const msgs = []
|
|
69
|
+
const msgs = []
|
|
75
70
|
if (Array.isArray(content)) {
|
|
76
71
|
for (const item of content) {
|
|
77
72
|
if (item.tag === 'message') {
|
|
78
|
-
msgs.push(
|
|
73
|
+
msgs.push(WAProto_1.proto.WebMessageInfo.decode(item.content))
|
|
79
74
|
}
|
|
80
75
|
}
|
|
81
76
|
}
|
|
82
|
-
return msgs
|
|
83
|
-
}
|
|
77
|
+
return msgs
|
|
78
|
+
}
|
|
84
79
|
exports.getBinaryNodeMessages = getBinaryNodeMessages;
|
|
85
80
|
function bufferToUInt(e, t) {
|
|
86
81
|
let a = 0;
|
|
@@ -101,7 +96,7 @@ function binaryNodeToString(node, i = 0) {
|
|
|
101
96
|
return tabs(i) + Buffer.from(node).toString('hex');
|
|
102
97
|
}
|
|
103
98
|
if (Array.isArray(node)) {
|
|
104
|
-
return node.map(x => tabs(i + 1) + binaryNodeToString(x, i + 1)).join('\n');
|
|
99
|
+
return node.map((x) => tabs(i + 1) + binaryNodeToString(x, i + 1)).join('\n');
|
|
105
100
|
}
|
|
106
101
|
const children = binaryNodeToString(node.content, i + 1);
|
|
107
102
|
const tag = `<${node.tag} ${Object.entries(node.attrs || {})
|
|
@@ -111,3 +106,93 @@ function binaryNodeToString(node, i = 0) {
|
|
|
111
106
|
const content = children ? `>\n${children}\n${tabs(i)}</${node.tag}>` : '/>';
|
|
112
107
|
return tag + content;
|
|
113
108
|
}
|
|
109
|
+
exports.binaryNodeToString = binaryNodeToString;
|
|
110
|
+
const getBinaryNodeFilter = (node) => {
|
|
111
|
+
if (!Array.isArray(node)) return false
|
|
112
|
+
|
|
113
|
+
return node.some(item =>
|
|
114
|
+
['native_flow'].includes(item?.content?.[0]?.content?.[0]?.tag) ||
|
|
115
|
+
['interactive', 'buttons', 'list'].includes(item?.content?.[0]?.tag) ||
|
|
116
|
+
['hsm', 'biz'].includes(item?.tag) ||
|
|
117
|
+
['bot'].includes(item?.tag) && item?.attrs?.biz_bot === '1'
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
exports.getBinaryNodeFilter = getBinaryNodeFilter;
|
|
121
|
+
const getAdditionalNode = (name) => {
|
|
122
|
+
if (name) name = name.toLowerCase()
|
|
123
|
+
const ts = Utils_1.unixTimestampSeconds(new Date()) - 77980457
|
|
124
|
+
|
|
125
|
+
const order_response_name = {
|
|
126
|
+
review_and_pay: 'order_details',
|
|
127
|
+
review_order: 'order_status',
|
|
128
|
+
payment_info: 'payment_info',
|
|
129
|
+
payment_status: 'payment_status',
|
|
130
|
+
payment_method: 'payment_method'
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const flow_name = {
|
|
134
|
+
cta_catalog: 'cta_catalog',
|
|
135
|
+
mpm: 'mpm',
|
|
136
|
+
call_request: 'call_permission_request',
|
|
137
|
+
view_catalog: 'automated_greeting_message_view_catalog',
|
|
138
|
+
wa_pay_detail: 'wa_payment_transaction_details',
|
|
139
|
+
send_location: 'send_location',
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if(order_response_name[name]) {
|
|
143
|
+
return [{
|
|
144
|
+
tag: 'biz',
|
|
145
|
+
attrs: {
|
|
146
|
+
native_flow_name: order_response_name[name]
|
|
147
|
+
},
|
|
148
|
+
content: []
|
|
149
|
+
}]
|
|
150
|
+
} else if (flow_name[name] || name === 'interactive' || name === 'buttons') {
|
|
151
|
+
return [{
|
|
152
|
+
tag: 'biz',
|
|
153
|
+
attrs: {
|
|
154
|
+
actual_actors: '2',
|
|
155
|
+
host_storage: '2',
|
|
156
|
+
privacy_mode_ts: `${ts}`
|
|
157
|
+
},
|
|
158
|
+
content: [{
|
|
159
|
+
tag: 'engagement',
|
|
160
|
+
attrs: {
|
|
161
|
+
customer_service_state: 'open',
|
|
162
|
+
conversation_state: 'open'
|
|
163
|
+
}
|
|
164
|
+
}, {
|
|
165
|
+
tag: 'interactive',
|
|
166
|
+
attrs: {
|
|
167
|
+
type: 'native_flow',
|
|
168
|
+
v: '1'
|
|
169
|
+
},
|
|
170
|
+
content: [{
|
|
171
|
+
tag: 'native_flow',
|
|
172
|
+
attrs: {
|
|
173
|
+
v: '9',
|
|
174
|
+
name: flow_name[name] ?? 'mixed',
|
|
175
|
+
},
|
|
176
|
+
content: []
|
|
177
|
+
}]
|
|
178
|
+
}]
|
|
179
|
+
}]
|
|
180
|
+
} else {
|
|
181
|
+
return [{
|
|
182
|
+
tag: 'biz',
|
|
183
|
+
attrs: {
|
|
184
|
+
actual_actors: '2',
|
|
185
|
+
host_storage: '2',
|
|
186
|
+
privacy_mode_ts: `${ts}`
|
|
187
|
+
},
|
|
188
|
+
content: [{
|
|
189
|
+
tag: 'engagement',
|
|
190
|
+
attrs: {
|
|
191
|
+
customer_service_state: 'open',
|
|
192
|
+
conversation_state: 'open'
|
|
193
|
+
}
|
|
194
|
+
}]
|
|
195
|
+
}]
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
exports.getAdditionalNode = getAdditionalNode;
|
|
@@ -3,34 +3,29 @@ export declare const OFFICIAL_BIZ_JID = "16505361212@c.us";
|
|
|
3
3
|
export declare const SERVER_JID = "server@c.us";
|
|
4
4
|
export declare const PSA_WID = "0@c.us";
|
|
5
5
|
export declare const STORIES_JID = "status@broadcast";
|
|
6
|
-
export
|
|
7
|
-
export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call' | 'lid' | 'newsletter' | 'bot';
|
|
6
|
+
export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call' | 'lid' | 'newsletter';
|
|
8
7
|
export type JidWithDevice = {
|
|
9
8
|
user: string;
|
|
10
9
|
device?: number;
|
|
11
10
|
};
|
|
12
11
|
export type FullJid = JidWithDevice & {
|
|
13
|
-
server: JidServer;
|
|
12
|
+
server: JidServer | string;
|
|
14
13
|
domainType?: number;
|
|
15
14
|
};
|
|
16
15
|
export declare const jidEncode: (user: string | number | null, server: JidServer, device?: number, agent?: number) => string;
|
|
17
16
|
export declare const jidDecode: (jid: string | undefined) => FullJid | undefined;
|
|
18
17
|
/** is the jid a user */
|
|
19
18
|
export declare const areJidsSameUser: (jid1: string | undefined, jid2: string | undefined) => boolean;
|
|
20
|
-
/** is the jid
|
|
21
|
-
export declare const
|
|
22
|
-
/** is the jid a
|
|
23
|
-
export declare const isPnUser: (jid: string | undefined) => boolean | undefined;
|
|
24
|
-
/** is the jid a LID */
|
|
19
|
+
/** is the jid a user */
|
|
20
|
+
export declare const isJidUser: (jid: string | undefined) => boolean | undefined;
|
|
21
|
+
/** is the jid a group */
|
|
25
22
|
export declare const isLidUser: (jid: string | undefined) => boolean | undefined;
|
|
26
23
|
/** is the jid a broadcast */
|
|
27
24
|
export declare const isJidBroadcast: (jid: string | undefined) => boolean | undefined;
|
|
28
25
|
/** is the jid a group */
|
|
29
26
|
export declare const isJidGroup: (jid: string | undefined) => boolean | undefined;
|
|
30
27
|
/** is the jid the status broadcast */
|
|
31
|
-
export declare const isJidStatusBroadcast: (jid: string) =>
|
|
32
|
-
/** is the jid
|
|
33
|
-
export declare const
|
|
34
|
-
export declare const isJidBot: (jid: string | undefined) => boolean | "" | undefined;
|
|
28
|
+
export declare const isJidStatusBroadcast: (jid: string) => boolean;
|
|
29
|
+
/** is the jid the newsletter */
|
|
30
|
+
export declare const isJidNewsLetter: (jid: string | undefined) => boolean | undefined;
|
|
35
31
|
export declare const jidNormalizedUser: (jid: string | undefined) => string;
|
|
36
|
-
export declare const transferDevice: (fromJid: string, toJid: string) => string;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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
4
|
exports.S_WHATSAPP_NET = '@s.whatsapp.net';
|
|
5
5
|
exports.OFFICIAL_BIZ_JID = '16505361212@c.us';
|
|
6
6
|
exports.SERVER_JID = 'server@c.us';
|
|
7
7
|
exports.PSA_WID = '0@c.us';
|
|
8
8
|
exports.STORIES_JID = 'status@broadcast';
|
|
9
|
-
exports.META_AI_JID = '13135550002@c.us';
|
|
10
9
|
const jidEncode = (user, server, device, agent) => {
|
|
11
10
|
return `${user || ''}${!!agent ? `_${agent}` : ''}${!!device ? `:${device}` : ''}@${server}`;
|
|
12
11
|
};
|
|
@@ -21,7 +20,7 @@ const jidDecode = (jid) => {
|
|
|
21
20
|
const [userAgent, device] = userCombined.split(':');
|
|
22
21
|
const user = userAgent.split('_')[0];
|
|
23
22
|
return {
|
|
24
|
-
server
|
|
23
|
+
server,
|
|
25
24
|
user,
|
|
26
25
|
domainType: server === 'lid' ? 1 : 0,
|
|
27
26
|
device: device ? +device : undefined
|
|
@@ -29,32 +28,29 @@ const jidDecode = (jid) => {
|
|
|
29
28
|
};
|
|
30
29
|
exports.jidDecode = jidDecode;
|
|
31
30
|
/** is the jid a user */
|
|
32
|
-
const areJidsSameUser = (jid1, jid2) =>
|
|
31
|
+
const areJidsSameUser = (jid1, jid2) => {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
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));
|
|
34
|
+
};
|
|
33
35
|
exports.areJidsSameUser = areJidsSameUser;
|
|
34
|
-
/** is the jid
|
|
35
|
-
const
|
|
36
|
-
exports.
|
|
37
|
-
/** is the jid a
|
|
38
|
-
const
|
|
39
|
-
exports.isPnUser = isPnUser;
|
|
40
|
-
/** is the jid a LID */
|
|
41
|
-
const isLidUser = (jid) => jid?.endsWith('@lid');
|
|
36
|
+
/** is the jid a user */
|
|
37
|
+
const isJidUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@s.whatsapp.net'));
|
|
38
|
+
exports.isJidUser = isJidUser;
|
|
39
|
+
/** is the jid a group */
|
|
40
|
+
const isLidUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@lid'));
|
|
42
41
|
exports.isLidUser = isLidUser;
|
|
43
42
|
/** is the jid a broadcast */
|
|
44
|
-
const isJidBroadcast = (jid) => jid
|
|
43
|
+
const isJidBroadcast = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@broadcast'));
|
|
45
44
|
exports.isJidBroadcast = isJidBroadcast;
|
|
46
45
|
/** is the jid a group */
|
|
47
|
-
const isJidGroup = (jid) => jid
|
|
46
|
+
const isJidGroup = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@g.us'));
|
|
48
47
|
exports.isJidGroup = isJidGroup;
|
|
49
48
|
/** is the jid the status broadcast */
|
|
50
49
|
const isJidStatusBroadcast = (jid) => jid === 'status@broadcast';
|
|
51
50
|
exports.isJidStatusBroadcast = isJidStatusBroadcast;
|
|
52
|
-
/** is the jid
|
|
53
|
-
const
|
|
54
|
-
exports.
|
|
55
|
-
const botRegexp = /^1313555\d{4}$|^131655500\d{2}$/;
|
|
56
|
-
const isJidBot = (jid) => jid && botRegexp.test(jid.split('@')[0]) && jid.endsWith('@c.us');
|
|
57
|
-
exports.isJidBot = isJidBot;
|
|
51
|
+
/** is the jid the newsletter */
|
|
52
|
+
const isJidNewsLetter = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('newsletter'));
|
|
53
|
+
exports.isJidNewsLetter = isJidNewsLetter;
|
|
58
54
|
const jidNormalizedUser = (jid) => {
|
|
59
55
|
const result = (0, exports.jidDecode)(jid);
|
|
60
56
|
if (!result) {
|
|
@@ -64,10 +60,3 @@ const jidNormalizedUser = (jid) => {
|
|
|
64
60
|
return (0, exports.jidEncode)(user, server === 'c.us' ? 's.whatsapp.net' : server);
|
|
65
61
|
};
|
|
66
62
|
exports.jidNormalizedUser = jidNormalizedUser;
|
|
67
|
-
const transferDevice = (fromJid, toJid) => {
|
|
68
|
-
const fromDecoded = (0, exports.jidDecode)(fromJid);
|
|
69
|
-
const deviceId = fromDecoded?.device || 0;
|
|
70
|
-
const { server, user } = (0, exports.jidDecode)(toJid);
|
|
71
|
-
return (0, exports.jidEncode)(user, server, deviceId);
|
|
72
|
-
};
|
|
73
|
-
exports.transferDevice = transferDevice;
|
package/lib/WAM/BinaryInfo.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
2
|
export declare class BinaryInfo {
|
|
3
3
|
protocolVersion: number;
|
|
4
4
|
sequence: number;
|
|
5
|
-
events:
|
|
5
|
+
events: {
|
|
6
|
+
[x: string]: {
|
|
7
|
+
props: {
|
|
8
|
+
[x: string]: any;
|
|
9
|
+
};
|
|
10
|
+
globals: {
|
|
11
|
+
[x: string]: any;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}[];
|
|
6
15
|
buffer: Buffer[];
|
|
7
16
|
constructor(options?: Partial<BinaryInfo>);
|
|
8
17
|
}
|
package/lib/WAM/constants.d.ts
CHANGED
|
@@ -28,12 +28,11 @@ type EventByName<T extends Event['name']> = Extract<Event, {
|
|
|
28
28
|
export type EventInputType = {
|
|
29
29
|
[key in Event['name']]: {
|
|
30
30
|
props: {
|
|
31
|
-
[k in keyof EventByName<key>['props']]:
|
|
31
|
+
[k in keyof EventByName<key>['props']]: any;
|
|
32
32
|
};
|
|
33
33
|
globals: {
|
|
34
|
-
[x: string]:
|
|
34
|
+
[x: string]: any;
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
37
|
} & {};
|
|
38
|
-
export type Value = number | null | string;
|
|
39
38
|
export {};
|