xhyphersockets 1.4.3 → 2.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.MD +1295 -0
- package/WAProto/p.html +1 -0
- package/lib/Defaults/index.js +47 -35
- package/lib/Defaults/wileys-version.json +3 -0
- package/lib/Socket/chats.js +132 -125
- package/lib/Socket/messages-recv.js +1 -1
- package/lib/Socket/messages-send.js +1 -32
- package/lib/Socket/newsletter.js +71 -124
- package/lib/Socket/socket.js +1 -1
- package/lib/Store/make-in-memory-store.js +1 -1
- package/lib/Types/Newsletter.js +18 -38
- package/lib/Utils/browser-utils.js +35 -0
- package/lib/Utils/event-buffer.js +2 -2
- package/lib/Utils/generics.js +47 -8
- package/lib/Utils/index.js +3 -4
- package/lib/Utils/message-retry-manager.js +128 -0
- package/lib/Utils/messages-media.js +37 -45
- package/lib/Utils/messages.js +19 -0
- package/lib/Utils/process-message.js +19 -0
- package/lib/Utils/use-multi-file-auth-state.js +1 -1
- package/lib/Utils/validate-connection.js +77 -21
- package/lib/Utils/{baileys-event-stream.js → wileys-event-stream.js} +1 -1
- package/lib/WABinary/jid-utils.js +3 -1
- package/lib/index.js +12 -18
- package/package.json +28 -22
- package/README.md +0 -252
- package/WAProto/index.d.ts +0 -55057
- package/WAProto/index.ts.ts +0 -53473
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/index.d.ts +0 -51
- package/lib/Signal/Group/ciphertext-message.d.ts +0 -9
- package/lib/Signal/Group/group-session-builder.d.ts +0 -14
- package/lib/Signal/Group/group_cipher.d.ts +0 -17
- package/lib/Signal/Group/index.d.ts +0 -11
- package/lib/Signal/Group/keyhelper.d.ts +0 -10
- package/lib/Signal/Group/queue-job.d.ts +0 -1
- package/lib/Signal/Group/sender-chain-key.d.ts +0 -13
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -16
- package/lib/Signal/Group/sender-key-message.d.ts +0 -18
- package/lib/Signal/Group/sender-key-name.d.ts +0 -17
- package/lib/Signal/Group/sender-key-record.d.ts +0 -30
- package/lib/Signal/Group/sender-key-state.d.ts +0 -38
- package/lib/Signal/Group/sender-message-key.d.ts +0 -11
- package/lib/Signal/libsignal.d.ts +0 -3
- package/lib/Socket/Client/index.d.ts +0 -2
- package/lib/Socket/Client/types.d.ts +0 -16
- package/lib/Socket/Client/websocket.d.ts +0 -13
- package/lib/Socket/RHandler.d.ts +0 -416
- package/lib/Socket/RHandler.js +0 -530
- package/lib/Socket/business.d.ts +0 -172
- package/lib/Socket/chats.d.ts +0 -94
- package/lib/Socket/groups.d.ts +0 -124
- package/lib/Socket/index.d.ts +0 -172
- package/lib/Socket/messages-recv.d.ts +0 -161
- package/lib/Socket/messages-send.d.ts +0 -152
- package/lib/Socket/newsletter.d.ts +0 -136
- package/lib/Socket/socket.d.ts +0 -43
- package/lib/Socket/usync.d.ts +0 -36
- package/lib/Store/index.d.ts +0 -2
- package/lib/Store/make-in-memory-store.d.ts +0 -118
- package/lib/Store/make-ordered-dictionary.d.ts +0 -13
- package/lib/Store/object-repository.d.ts +0 -10
- package/lib/Types/Auth.d.ts +0 -103
- package/lib/Types/Call.d.ts +0 -13
- package/lib/Types/Chat.d.ts +0 -109
- package/lib/Types/Contact.d.ts +0 -23
- package/lib/Types/Events.d.ts +0 -199
- package/lib/Types/GroupMetadata.d.ts +0 -64
- package/lib/Types/Label.d.ts +0 -35
- package/lib/Types/LabelAssociation.d.ts +0 -29
- package/lib/Types/Message.d.ts +0 -402
- package/lib/Types/Newsletter.d.ts +0 -103
- package/lib/Types/Product.d.ts +0 -78
- package/lib/Types/Signal.d.ts +0 -57
- package/lib/Types/Socket.d.ts +0 -119
- package/lib/Types/State.d.ts +0 -27
- package/lib/Types/USync.d.ts +0 -25
- package/lib/Types/index.d.ts +0 -64
- package/lib/Utils/audioToBuffer.js +0 -29
- package/lib/Utils/auth-utils.d.ts +0 -18
- package/lib/Utils/baileys-event-stream.d.ts +0 -16
- package/lib/Utils/business.d.ts +0 -22
- package/lib/Utils/chat-utils.d.ts +0 -70
- package/lib/Utils/crypto.d.ts +0 -40
- package/lib/Utils/decode-wa-message.d.ts +0 -35
- package/lib/Utils/event-buffer.d.ts +0 -35
- package/lib/Utils/generics.d.ts +0 -89
- package/lib/Utils/history.d.ts +0 -19
- package/lib/Utils/index.d.ts +0 -19
- package/lib/Utils/link-preview.d.ts +0 -21
- package/lib/Utils/logger.d.ts +0 -11
- package/lib/Utils/lt-hash.d.ts +0 -12
- package/lib/Utils/make-mutex.d.ts +0 -7
- package/lib/Utils/messages-media.d.ts +0 -124
- package/lib/Utils/messages.d.ts +0 -75
- package/lib/Utils/noise-handler.d.ts +0 -19
- package/lib/Utils/process-message.d.ts +0 -42
- package/lib/Utils/signal.d.ts +0 -33
- package/lib/Utils/streamToBuffer.js +0 -15
- package/lib/Utils/use-multi-file-auth-state.d.ts +0 -12
- package/lib/Utils/validate-connection.d.ts +0 -10
- package/lib/WABinary/constants.d.ts +0 -27
- package/lib/WABinary/decode.d.ts +0 -6
- package/lib/WABinary/encode.d.ts +0 -2
- package/lib/WABinary/generic-utils.d.ts +0 -14
- package/lib/WABinary/index.d.ts +0 -5
- package/lib/WABinary/jid-utils.d.ts +0 -36
- package/lib/WABinary/jid-utils.js.bak +0 -83
- package/lib/WABinary/types.d.ts +0 -18
- package/lib/WAM/BinaryInfo.d.ts +0 -8
- package/lib/WAM/constants.d.ts +0 -38
- package/lib/WAM/encode.d.ts +0 -2
- package/lib/WAM/index.d.ts +0 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +0 -9
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +0 -22
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +0 -12
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -25
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -8
- package/lib/WAUSync/Protocols/index.d.ts +0 -4
- package/lib/WAUSync/USyncQuery.d.ts +0 -28
- package/lib/WAUSync/USyncUser.d.ts +0 -12
- package/lib/WAUSync/index.d.ts +0 -3
- package/lib/index.d.ts +0 -16
|
@@ -332,7 +332,7 @@ const makeMessagesRecvSocket = (config) => {
|
|
|
332
332
|
break;
|
|
333
333
|
break;
|
|
334
334
|
default:
|
|
335
|
-
// console.log("
|
|
335
|
+
// console.log("WILEYS-DEBUG:", JSON.stringify({ ...child, content: Buffer.isBuffer(child.content) ? child.content.toString() : child.content, participant }, null, 2))
|
|
336
336
|
}
|
|
337
337
|
};
|
|
338
338
|
const handleNewsletterNotification = (id, node) => {
|
|
@@ -5,14 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.makeMessagesSocket = void 0;
|
|
7
7
|
const boom_1 = require("@hapi/boom");
|
|
8
|
-
const { audioToBuffer, getAudioWaveform } = require("../Utils")
|
|
9
8
|
const node_cache_1 = __importDefault(require("@cacheable/node-cache"));
|
|
10
9
|
const crypto_1 = require("crypto");
|
|
11
|
-
const RexxHayanasi = require('./RHandler');
|
|
12
10
|
const WAProto_1 = require("../../WAProto");
|
|
13
11
|
const Defaults_1 = require("../Defaults");
|
|
14
12
|
const Utils_1 = require("../Utils");
|
|
15
|
-
|
|
16
13
|
const link_preview_1 = require("../Utils/link-preview");
|
|
17
14
|
const WABinary_1 = require("../WABinary");
|
|
18
15
|
const WAUSync_1 = require("../WAUSync");
|
|
@@ -606,26 +603,6 @@ const makeMessagesSocket = (config) => {
|
|
|
606
603
|
return 'url';
|
|
607
604
|
}
|
|
608
605
|
};
|
|
609
|
-
|
|
610
|
-
const waveform = async (content, logger) => {
|
|
611
|
-
if (typeof content === 'object' && 'audio' in content) {
|
|
612
|
-
try {
|
|
613
|
-
const audioBuffer = await audioToBuffer(content.audio)
|
|
614
|
-
const wave = await getAudioWaveform(audioBuffer, logger)
|
|
615
|
-
|
|
616
|
-
if (wave) {
|
|
617
|
-
content.waveform = wave
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
console.log(`Audio buffer length: ${audioBuffer.length} bytes`)
|
|
621
|
-
} catch (err) {
|
|
622
|
-
logger?.warn
|
|
623
|
-
? logger.warn(`Gagal membuat waveform: ${err}`)
|
|
624
|
-
: console.warn(`Gagal membuat waveform: ${err}`)
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
|
|
629
606
|
const getPrivacyTokens = async (jids) => {
|
|
630
607
|
const t = (0, Utils_1.unixTimestampSeconds)().toString();
|
|
631
608
|
const result = await query({
|
|
@@ -652,13 +629,10 @@ const waveform = async (content, logger) => {
|
|
|
652
629
|
});
|
|
653
630
|
return result;
|
|
654
631
|
};
|
|
655
|
-
|
|
656
632
|
const waUploadToServer = (0, Utils_1.getWAUploadToServer)(config, refreshMediaConn);
|
|
657
|
-
const rexx = new RexxHayanasi(Utils_1, waUploadToServer, relayMessage);
|
|
658
633
|
const waitForMsgMediaUpdate = (0, Utils_1.bindWaitForEvent)(ev, 'messages.media-update');
|
|
659
634
|
return {
|
|
660
635
|
...sock,
|
|
661
|
-
rexx,
|
|
662
636
|
getPrivacyTokens,
|
|
663
637
|
assertSessions,
|
|
664
638
|
relayMessage,
|
|
@@ -713,7 +687,6 @@ const waveform = async (content, logger) => {
|
|
|
713
687
|
return message;
|
|
714
688
|
},
|
|
715
689
|
sendMessage: async (jid, content, options = {}) => {
|
|
716
|
-
await waveform(content, logger);
|
|
717
690
|
var _a, _b, _c;
|
|
718
691
|
const userJid = authState.creds.me.id;
|
|
719
692
|
if (!options.ephemeralExpiration) {
|
|
@@ -739,7 +712,7 @@ const waveform = async (content, logger) => {
|
|
|
739
712
|
disappearingMessagesInChat;
|
|
740
713
|
await groupToggleEphemeral(jid, value);
|
|
741
714
|
}
|
|
742
|
-
|
|
715
|
+
if (typeof content === 'object' && 'album' in content && content.album) {
|
|
743
716
|
const { album, caption } = content;
|
|
744
717
|
if (caption && !album[0].caption) {
|
|
745
718
|
album[0].caption = caption;
|
|
@@ -804,10 +777,6 @@ const waveform = async (content, logger) => {
|
|
|
804
777
|
}
|
|
805
778
|
return albumMsg;
|
|
806
779
|
}
|
|
807
|
-
else if (content.groupStatusMessage) {
|
|
808
|
-
const { quoted } = options;
|
|
809
|
-
return await rexx.handleGroupStory(content, jid, quoted);
|
|
810
|
-
}
|
|
811
780
|
else {
|
|
812
781
|
let mediaHandle;
|
|
813
782
|
const fullMsg = await (0, Utils_1.generateWAMessage)(jid, content, {
|
package/lib/Socket/newsletter.js
CHANGED
|
@@ -5,64 +5,20 @@ const Types_1 = require("../Types");
|
|
|
5
5
|
const Utils_1 = require("../Utils");
|
|
6
6
|
const WABinary_1 = require("../WABinary");
|
|
7
7
|
const groups_1 = require("./groups");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
to: WABinary_1.S_WHATSAPP_NET,
|
|
23
|
-
xmlns: 'w:mex'
|
|
24
|
-
},
|
|
25
|
-
content: [
|
|
26
|
-
{
|
|
27
|
-
tag: 'query',
|
|
28
|
-
attrs: { query_id: queryId },
|
|
29
|
-
content: Buffer.from(JSON.stringify({ variables }), 'utf-8')
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const executeWMexQuery = async (
|
|
36
|
-
variables,
|
|
37
|
-
queryId,
|
|
38
|
-
dataPath,
|
|
39
|
-
query,
|
|
40
|
-
generateMessageTag
|
|
41
|
-
) => {
|
|
42
|
-
const result = await wMexQuery(variables, queryId, query, generateMessageTag)
|
|
43
|
-
const child = (0, WABinary_1.getBinaryNodeChild)(result, 'result')
|
|
44
|
-
if (child?.content) {
|
|
45
|
-
const data = JSON.parse(child.content.toString())
|
|
46
|
-
|
|
47
|
-
if (data.errors && data.errors.length > 0) {
|
|
48
|
-
const errorMessages = data.errors.map((err) => err.message || 'Unknown error').join(', ')
|
|
49
|
-
const firstError = data.errors[0]
|
|
50
|
-
const errorCode = firstError.extensions?.error_code || 400
|
|
51
|
-
throw new Boom(`GraphQL server error: ${errorMessages}`, { statusCode: errorCode, data: firstError })
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const response = dataPath ? data?.data?.[dataPath] : data?.data
|
|
55
|
-
if (typeof response !== 'undefined') {
|
|
56
|
-
return response
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const action = (dataPath || '').startsWith('xwa2_')
|
|
61
|
-
? dataPath.substring(5).replace(/_/g, ' ')
|
|
62
|
-
: dataPath?.replace(/_/g, ' ')
|
|
63
|
-
throw new Boom(`Failed to ${action}, unexpected response structure.`, { statusCode: 400, data: result })
|
|
64
|
-
}
|
|
65
|
-
|
|
8
|
+
var QueryIds;
|
|
9
|
+
(function (QueryIds) {
|
|
10
|
+
QueryIds["JOB_MUTATION"] = "7150902998257522";
|
|
11
|
+
QueryIds["METADATA"] = "6620195908089573";
|
|
12
|
+
QueryIds["UNFOLLOW"] = "7238632346214362";
|
|
13
|
+
QueryIds["FOLLOW"] = "7871414976211147";
|
|
14
|
+
QueryIds["UNMUTE"] = "7337137176362961";
|
|
15
|
+
QueryIds["MUTE"] = "25151904754424642";
|
|
16
|
+
QueryIds["CREATE"] = "6996806640408138";
|
|
17
|
+
QueryIds["ADMIN_COUNT"] = "7130823597031706";
|
|
18
|
+
QueryIds["CHANGE_OWNER"] = "7341777602580933";
|
|
19
|
+
QueryIds["DELETE"] = "8316537688363079";
|
|
20
|
+
QueryIds["DEMOTE"] = "6551828931592903";
|
|
21
|
+
})(QueryIds || (QueryIds = {}));
|
|
66
22
|
const makeNewsletterSocket = (config) => {
|
|
67
23
|
const sock = (0, groups_1.makeGroupsSocket)(config);
|
|
68
24
|
const { authState, signalRepository, query, generateMessageTag } = sock;
|
|
@@ -77,7 +33,7 @@ const makeNewsletterSocket = (config) => {
|
|
|
77
33
|
},
|
|
78
34
|
content
|
|
79
35
|
}));
|
|
80
|
-
const newsletterWMexQuery = async (jid,
|
|
36
|
+
const newsletterWMexQuery = async (jid, query_id, content) => (query({
|
|
81
37
|
tag: 'iq',
|
|
82
38
|
attrs: {
|
|
83
39
|
id: generateMessageTag(),
|
|
@@ -88,7 +44,7 @@ const makeNewsletterSocket = (config) => {
|
|
|
88
44
|
content: [
|
|
89
45
|
{
|
|
90
46
|
tag: 'query',
|
|
91
|
-
attrs: {
|
|
47
|
+
attrs: { query_id },
|
|
92
48
|
content: encoder.encode(JSON.stringify({
|
|
93
49
|
variables: {
|
|
94
50
|
'newsletter_id': jid,
|
|
@@ -100,9 +56,8 @@ const makeNewsletterSocket = (config) => {
|
|
|
100
56
|
}));
|
|
101
57
|
const parseFetchedUpdates = async (node, type) => {
|
|
102
58
|
let child;
|
|
103
|
-
if (type === 'messages')
|
|
59
|
+
if (type === 'messages')
|
|
104
60
|
child = (0, WABinary_1.getBinaryNodeChild)(node, 'messages');
|
|
105
|
-
}
|
|
106
61
|
else {
|
|
107
62
|
const parent = (0, WABinary_1.getBinaryNodeChild)(node, 'message_updates');
|
|
108
63
|
child = (0, WABinary_1.getBinaryNodeChild)(parent, 'messages');
|
|
@@ -129,65 +84,50 @@ const makeNewsletterSocket = (config) => {
|
|
|
129
84
|
};
|
|
130
85
|
return {
|
|
131
86
|
...sock,
|
|
132
|
-
newsletterFetchAllSubscribe: async () => {
|
|
133
|
-
const list = await executeWMexQuery(
|
|
134
|
-
{},
|
|
135
|
-
'6388546374527196',
|
|
136
|
-
'xwa2_newsletter_subscribed',
|
|
137
|
-
query,
|
|
138
|
-
generateMessageTag
|
|
139
|
-
);
|
|
140
|
-
return list;
|
|
141
|
-
},
|
|
142
87
|
subscribeNewsletterUpdates: async (jid) => {
|
|
143
88
|
var _a;
|
|
144
89
|
const result = await newsletterQuery(jid, 'set', [{ tag: 'live_updates', attrs: {}, content: [] }]);
|
|
145
90
|
return (_a = (0, WABinary_1.getBinaryNodeChild)(result, 'live_updates')) === null || _a === void 0 ? void 0 : _a.attrs;
|
|
146
91
|
},
|
|
147
92
|
newsletterReactionMode: async (jid, mode) => {
|
|
148
|
-
await newsletterWMexQuery(jid,
|
|
149
|
-
updates: { settings: {
|
|
93
|
+
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
94
|
+
updates: { settings: { reaction_codes: { value: mode } } }
|
|
150
95
|
});
|
|
151
96
|
},
|
|
152
97
|
newsletterUpdateDescription: async (jid, description) => {
|
|
153
|
-
await newsletterWMexQuery(jid,
|
|
98
|
+
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
154
99
|
updates: { description: description || '', settings: null }
|
|
155
100
|
});
|
|
156
101
|
},
|
|
157
102
|
newsletterUpdateName: async (jid, name) => {
|
|
158
|
-
await newsletterWMexQuery(jid,
|
|
103
|
+
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
159
104
|
updates: { name, settings: null }
|
|
160
105
|
});
|
|
161
106
|
},
|
|
162
107
|
newsletterUpdatePicture: async (jid, content) => {
|
|
163
108
|
const { img } = await (0, Utils_1.generateProfilePicture)(content);
|
|
164
|
-
await newsletterWMexQuery(jid,
|
|
109
|
+
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
165
110
|
updates: { picture: img.toString('base64'), settings: null }
|
|
166
111
|
});
|
|
167
112
|
},
|
|
168
113
|
newsletterRemovePicture: async (jid) => {
|
|
169
|
-
await newsletterWMexQuery(jid,
|
|
114
|
+
await newsletterWMexQuery(jid, QueryIds.JOB_MUTATION, {
|
|
170
115
|
updates: { picture: '', settings: null }
|
|
171
116
|
});
|
|
172
117
|
},
|
|
173
118
|
newsletterUnfollow: async (jid) => {
|
|
174
|
-
await newsletterWMexQuery(jid,
|
|
119
|
+
await newsletterWMexQuery(jid, QueryIds.UNFOLLOW);
|
|
175
120
|
},
|
|
176
121
|
newsletterFollow: async (jid) => {
|
|
177
|
-
await newsletterWMexQuery(jid,
|
|
122
|
+
await newsletterWMexQuery(jid, QueryIds.FOLLOW);
|
|
178
123
|
},
|
|
179
124
|
newsletterUnmute: async (jid) => {
|
|
180
|
-
await newsletterWMexQuery(jid,
|
|
125
|
+
await newsletterWMexQuery(jid, QueryIds.UNMUTE);
|
|
181
126
|
},
|
|
182
127
|
newsletterMute: async (jid) => {
|
|
183
|
-
await newsletterWMexQuery(jid,
|
|
128
|
+
await newsletterWMexQuery(jid, QueryIds.MUTE);
|
|
184
129
|
},
|
|
185
|
-
|
|
186
|
-
await newsletterWMexQuery(jid, type.toUpperCase());
|
|
187
|
-
},
|
|
188
|
-
newsletterCreate: async (name, description, reaction_codes) => {
|
|
189
|
-
//TODO: Implement TOS system wide for Meta AI, communities, and here etc.
|
|
190
|
-
/**tos query */
|
|
130
|
+
newsletterCreate: async (name, description, picture) => {
|
|
191
131
|
await query({
|
|
192
132
|
tag: 'iq',
|
|
193
133
|
attrs: {
|
|
@@ -207,50 +147,55 @@ const makeNewsletterSocket = (config) => {
|
|
|
207
147
|
}
|
|
208
148
|
]
|
|
209
149
|
});
|
|
210
|
-
const result = await newsletterWMexQuery(undefined,
|
|
211
|
-
input: {
|
|
150
|
+
const result = await newsletterWMexQuery(undefined, QueryIds.CREATE, {
|
|
151
|
+
input: {
|
|
152
|
+
name,
|
|
153
|
+
description: description !== null && description !== void 0 ? description : null,
|
|
154
|
+
picture: picture ? (await (0, Utils_1.generateProfilePicture)(picture)).img.toString('base64') : null,
|
|
155
|
+
settings: null
|
|
156
|
+
}
|
|
212
157
|
});
|
|
213
158
|
return (0, exports.extractNewsletterMetadata)(result, true);
|
|
214
159
|
},
|
|
215
160
|
newsletterMetadata: async (type, key, role) => {
|
|
216
|
-
const result = await newsletterWMexQuery(undefined,
|
|
161
|
+
const result = await newsletterWMexQuery(undefined, QueryIds.METADATA, {
|
|
217
162
|
input: {
|
|
218
163
|
key,
|
|
219
164
|
type: type.toUpperCase(),
|
|
220
|
-
|
|
165
|
+
view_role: role || 'GUEST'
|
|
221
166
|
},
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
167
|
+
fetch_viewer_metadata: true,
|
|
168
|
+
fetch_full_image: true,
|
|
169
|
+
fetch_creation_time: true
|
|
225
170
|
});
|
|
226
171
|
return (0, exports.extractNewsletterMetadata)(result);
|
|
227
172
|
},
|
|
228
173
|
newsletterAdminCount: async (jid) => {
|
|
229
174
|
var _a, _b;
|
|
230
|
-
const result = await newsletterWMexQuery(jid,
|
|
175
|
+
const result = await newsletterWMexQuery(jid, QueryIds.ADMIN_COUNT);
|
|
231
176
|
const buff = (_b = (_a = (0, WABinary_1.getBinaryNodeChild)(result, 'result')) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.toString();
|
|
232
177
|
return JSON.parse(buff).data[Types_1.XWAPaths.ADMIN_COUNT].admin_count;
|
|
233
178
|
},
|
|
234
179
|
/**user is Lid, not Jid */
|
|
235
180
|
newsletterChangeOwner: async (jid, user) => {
|
|
236
|
-
await newsletterWMexQuery(jid,
|
|
237
|
-
|
|
181
|
+
await newsletterWMexQuery(jid, QueryIds.CHANGE_OWNER, {
|
|
182
|
+
user_id: user
|
|
238
183
|
});
|
|
239
184
|
},
|
|
240
185
|
/**user is Lid, not Jid */
|
|
241
186
|
newsletterDemote: async (jid, user) => {
|
|
242
|
-
await newsletterWMexQuery(jid,
|
|
243
|
-
|
|
187
|
+
await newsletterWMexQuery(jid, QueryIds.DEMOTE, {
|
|
188
|
+
user_id: user
|
|
244
189
|
});
|
|
245
190
|
},
|
|
246
191
|
newsletterDelete: async (jid) => {
|
|
247
|
-
await newsletterWMexQuery(jid,
|
|
192
|
+
await newsletterWMexQuery(jid, QueryIds.DELETE);
|
|
248
193
|
},
|
|
249
194
|
/**if code wasn't passed, the reaction will be removed (if is reacted) */
|
|
250
|
-
newsletterReactMessage: async (jid,
|
|
195
|
+
newsletterReactMessage: async (jid, server_id, code) => {
|
|
251
196
|
await query({
|
|
252
197
|
tag: 'message',
|
|
253
|
-
attrs: { to: jid, ...(!code ? { edit: '7' } : {}), type: 'reaction',
|
|
198
|
+
attrs: { to: jid, ...(!code ? { edit: '7' } : {}), type: 'reaction', server_id, id: (0, Utils_1.generateMessageID)() },
|
|
254
199
|
content: [{
|
|
255
200
|
tag: 'reaction',
|
|
256
201
|
attrs: code ? { code } : {}
|
|
@@ -258,10 +203,11 @@ const makeNewsletterSocket = (config) => {
|
|
|
258
203
|
});
|
|
259
204
|
},
|
|
260
205
|
newsletterFetchMessages: async (type, key, count, after) => {
|
|
206
|
+
const afterStr = after === null || after === void 0 ? void 0 : after.toString();
|
|
261
207
|
const result = await newsletterQuery(WABinary_1.S_WHATSAPP_NET, 'get', [
|
|
262
208
|
{
|
|
263
209
|
tag: 'messages',
|
|
264
|
-
attrs: { type, ...(type === 'invite' ? { key } : { jid: key }), count: count.toString(), after:
|
|
210
|
+
attrs: { type, ...(type === 'invite' ? { key } : { jid: key }), count: count.toString(), after: afterStr || '100' }
|
|
265
211
|
}
|
|
266
212
|
]);
|
|
267
213
|
return await parseFetchedUpdates(result, 'messages');
|
|
@@ -279,25 +225,26 @@ const makeNewsletterSocket = (config) => {
|
|
|
279
225
|
};
|
|
280
226
|
exports.makeNewsletterSocket = makeNewsletterSocket;
|
|
281
227
|
const extractNewsletterMetadata = (node, isCreate) => {
|
|
282
|
-
|
|
283
|
-
const
|
|
284
|
-
|
|
228
|
+
var _a, _b, _c, _d;
|
|
229
|
+
const result = (_b = (_a = (0, WABinary_1.getBinaryNodeChild)(node, 'result')) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.toString();
|
|
230
|
+
const metadataPath = JSON.parse(result).data[isCreate ? Types_1.XWAPaths.CREATE : Types_1.XWAPaths.NEWSLETTER];
|
|
285
231
|
const metadata = {
|
|
286
|
-
id: metadataPath
|
|
287
|
-
state: metadataPath
|
|
288
|
-
creation_time: +metadataPath
|
|
289
|
-
name: metadataPath
|
|
290
|
-
nameTime: +metadataPath
|
|
291
|
-
description: metadataPath
|
|
292
|
-
descriptionTime: +metadataPath
|
|
293
|
-
invite: metadataPath
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
232
|
+
id: metadataPath.id,
|
|
233
|
+
state: metadataPath.state.type,
|
|
234
|
+
creation_time: +metadataPath.thread_metadata.creation_time,
|
|
235
|
+
name: metadataPath.thread_metadata.name.text,
|
|
236
|
+
nameTime: +metadataPath.thread_metadata.name.update_time,
|
|
237
|
+
description: metadataPath.thread_metadata.description.text,
|
|
238
|
+
descriptionTime: +metadataPath.thread_metadata.description.update_time,
|
|
239
|
+
invite: metadataPath.thread_metadata.invite,
|
|
240
|
+
handle: metadataPath.thread_metadata.handle,
|
|
241
|
+
picture: ((_c = metadataPath.thread_metadata.picture) === null || _c === void 0 ? void 0 : _c.direct_path) || null,
|
|
242
|
+
preview: ((_d = metadataPath.thread_metadata.preview) === null || _d === void 0 ? void 0 : _d.direct_path) || null,
|
|
243
|
+
reaction_codes: metadataPath.thread_metadata.settings.reaction_codes.value,
|
|
244
|
+
subscribers: +metadataPath.thread_metadata.subscribers_count,
|
|
245
|
+
verification: metadataPath.thread_metadata.verification,
|
|
246
|
+
viewer_metadata: metadataPath.viewer_metadata
|
|
247
|
+
};
|
|
248
|
+
return metadata;
|
|
249
|
+
};
|
|
303
250
|
exports.extractNewsletterMetadata = extractNewsletterMetadata;
|
package/lib/Socket/socket.js
CHANGED
|
@@ -381,7 +381,7 @@ const makeSocket = (config) => {
|
|
|
381
381
|
}
|
|
382
382
|
end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }));
|
|
383
383
|
};
|
|
384
|
-
const requestPairingCode = async (phoneNumber, pairKey = "XHYPHERX") => {
|
|
384
|
+
const requestPairingCode = async (phoneNumber, pairKey = "XHYPHERX") => {
|
|
385
385
|
if (pairKey) {
|
|
386
386
|
authState.creds.pairingCode = pairKey.toUpperCase();
|
|
387
387
|
}
|
|
@@ -65,7 +65,7 @@ exports.default = (config) => {
|
|
|
65
65
|
return Object.keys(contacts);
|
|
66
66
|
};
|
|
67
67
|
/**
|
|
68
|
-
* binds to a
|
|
68
|
+
* binds to a WileysEventEmitter.
|
|
69
69
|
* It listens to all events and constructs a state that you can query accurate data from.
|
|
70
70
|
* Eg. can use the store to fetch chats, contacts, messages etc.
|
|
71
71
|
* @param ev typically the event emitter from the socket connection
|
package/lib/Types/Newsletter.js
CHANGED
|
@@ -1,38 +1,18 @@
|
|
|
1
|
-
"use strict"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const QueryIds = {
|
|
22
|
-
JOB_MUTATION: "7150902998257522",
|
|
23
|
-
METADATA: "6620195908089573",
|
|
24
|
-
UNFOLLOW: "7238632346214362",
|
|
25
|
-
FOLLOW: "7871414976211147",
|
|
26
|
-
UNMUTE: "7337137176362961",
|
|
27
|
-
MUTE: "25151904754424642",
|
|
28
|
-
CREATE: "6996806640408138",
|
|
29
|
-
ADMIN_COUNT: "7130823597031706",
|
|
30
|
-
CHANGE_OWNER: "7341777602580933",
|
|
31
|
-
DELETE: "8316537688363079",
|
|
32
|
-
DEMOTE: "6551828931592903",
|
|
33
|
-
SUBSCRIBED: "6388546374527196"
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
exports.MexOperations = MexOperations
|
|
37
|
-
exports.XWAPaths = XWAPaths
|
|
38
|
-
exports.QueryIds = QueryIds
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XWAPaths = exports.MexOperations = void 0;
|
|
4
|
+
var MexOperations;
|
|
5
|
+
(function (MexOperations) {
|
|
6
|
+
MexOperations["PROMOTE"] = "NotificationNewsletterAdminPromote";
|
|
7
|
+
MexOperations["DEMOTE"] = "NotificationNewsletterAdminDemote";
|
|
8
|
+
MexOperations["UPDATE"] = "NotificationNewsletterUpdate";
|
|
9
|
+
})(MexOperations || (exports.MexOperations = MexOperations = {}));
|
|
10
|
+
var XWAPaths;
|
|
11
|
+
(function (XWAPaths) {
|
|
12
|
+
XWAPaths["PROMOTE"] = "xwa2_notify_newsletter_admin_promote";
|
|
13
|
+
XWAPaths["DEMOTE"] = "xwa2_notify_newsletter_admin_demote";
|
|
14
|
+
XWAPaths["ADMIN_COUNT"] = "xwa2_newsletter_admin";
|
|
15
|
+
XWAPaths["CREATE"] = "xwa2_newsletter_create";
|
|
16
|
+
XWAPaths["NEWSLETTER"] = "xwa2_newsletter";
|
|
17
|
+
XWAPaths["METADATA_UPDATE"] = "xwa2_notify_newsletter_on_metadata_update";
|
|
18
|
+
})(XWAPaths || (exports.XWAPaths = XWAPaths = {}));
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPlatformId = exports.Browsers = void 0;
|
|
4
|
+
|
|
5
|
+
const os = require("os");
|
|
6
|
+
const { proto } = require("../../WAProto/index.js");
|
|
7
|
+
|
|
8
|
+
const PLATFORM_MAP = {
|
|
9
|
+
'aix': 'AIX',
|
|
10
|
+
'darwin': 'Mac OS',
|
|
11
|
+
'win32': 'Windows',
|
|
12
|
+
'android': 'Android',
|
|
13
|
+
'freebsd': 'FreeBSD',
|
|
14
|
+
'openbsd': 'OpenBSD',
|
|
15
|
+
'sunos': 'Solaris',
|
|
16
|
+
'linux': undefined, // Default ke Ubuntu untuk Linux
|
|
17
|
+
'haiku': undefined,
|
|
18
|
+
'cygwin': undefined,
|
|
19
|
+
'netbsd': undefined
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// Fixed: Browsers sekarang fungsi yang return array [platform, browser, version]
|
|
23
|
+
// Ini kompatibel dengan pemanggilan Browsers('Chrome') di Defaults/index.js
|
|
24
|
+
exports.Browsers = (browser) => {
|
|
25
|
+
const osName = PLATFORM_MAP[os.platform()] || 'Ubuntu'; // Default Ubuntu kalau undefined
|
|
26
|
+
const osRelease = os.release(); // Ambil versi OS real-time
|
|
27
|
+
return [osName, browser, osRelease];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const getPlatformId = (browser) => {
|
|
31
|
+
const platformType = proto.DeviceProps.PlatformType[browser.toUpperCase()];
|
|
32
|
+
return platformType ? platformType.toString() : '1'; // Default Chrome
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.getPlatformId = getPlatformId;
|
|
@@ -27,14 +27,14 @@ const BUFFERABLE_EVENT_SET = new Set(BUFFERABLE_EVENT);
|
|
|
27
27
|
/**
|
|
28
28
|
* The event buffer logically consolidates different events into a single event
|
|
29
29
|
* making the data processing more efficient.
|
|
30
|
-
* @param ev the
|
|
30
|
+
* @param ev the wileys event emitter
|
|
31
31
|
*/
|
|
32
32
|
const makeEventBuffer = (logger) => {
|
|
33
33
|
const ev = new events_1.default();
|
|
34
34
|
const historyCache = new Set();
|
|
35
35
|
let data = makeBufferData();
|
|
36
36
|
let buffersInProgress = 0;
|
|
37
|
-
// take the generic event and fire it as a
|
|
37
|
+
// take the generic event and fire it as a wileys event
|
|
38
38
|
ev.on('event', (map) => {
|
|
39
39
|
for (const event in map) {
|
|
40
40
|
ev.emit(event, map[event]);
|
package/lib/Utils/generics.js
CHANGED
|
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.isWABusinessPlatform = exports.getCodeFromWSError = exports.getCallStatusFromNode = exports.getErrorCodeFromStreamError = exports.getStatusFromReceiptType = exports.generateMdTagPrefix = exports.fetchLatestWaWebVersion = exports.fetchLatestBaileysVersion = exports.printQRIfNecessaryListener = exports.bindWaitForConnectionUpdate = exports.generateMessageID = exports.generateMessageIDV2 = exports.delayCancellable = exports.delay = exports.debouncedTimeout = exports.unixTimestampSeconds = exports.toNumber = exports.encodeBigEndian = exports.generateRegistrationId = exports.encodeNewsletterMessage = exports.encodeWAMessage = exports.unpadRandomMax16 = exports.writeRandomPadMax16 = exports.getKeyAuthor = exports.BufferJSON = exports.getPlatformId = exports.Browsers = void 0;
|
|
39
|
+
exports.isWABusinessPlatform = exports.getCodeFromWSError = exports.getCallStatusFromNode = exports.getErrorCodeFromStreamError = exports.getStatusFromReceiptType = exports.generateMdTagPrefix = exports.fetchLatestWaWebVersion = exports.fetchLatestWileysVersion = exports.fetchLatestBaileysVersion = exports.printQRIfNecessaryListener = exports.bindWaitForConnectionUpdate = exports.generateMessageID = exports.generateMessageIDV2 = exports.delayCancellable = exports.delay = exports.debouncedTimeout = exports.unixTimestampSeconds = exports.toNumber = exports.encodeBigEndian = exports.generateRegistrationId = exports.encodeNewsletterMessage = exports.encodeWAMessage = exports.unpadRandomMax16 = exports.writeRandomPadMax16 = exports.getKeyAuthor = exports.BufferJSON = exports.getPlatformId = exports.Browsers = void 0;
|
|
40
40
|
exports.promiseTimeout = promiseTimeout;
|
|
41
41
|
exports.bindWaitForEvent = bindWaitForEvent;
|
|
42
42
|
exports.trimUndefined = trimUndefined;
|
|
@@ -46,7 +46,7 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
46
46
|
const crypto_1 = require("crypto");
|
|
47
47
|
const os_1 = require("os");
|
|
48
48
|
const WAProto_1 = require("../../WAProto");
|
|
49
|
-
const
|
|
49
|
+
const wileys_version_json_1 = require("../Defaults/wileys-version.json");
|
|
50
50
|
const Types_1 = require("../Types");
|
|
51
51
|
const WABinary_1 = require("../WABinary");
|
|
52
52
|
const COMPANION_PLATFORM_MAP = {
|
|
@@ -258,11 +258,48 @@ const printQRIfNecessaryListener = (ev, logger) => {
|
|
|
258
258
|
});
|
|
259
259
|
};
|
|
260
260
|
exports.printQRIfNecessaryListener = printQRIfNecessaryListener;
|
|
261
|
+
|
|
262
|
+
const fetchLatestWileysVersion = async (options = {}) => {
|
|
263
|
+
try {
|
|
264
|
+
const { data } = await axios_1.default.get('https://registry.npmjs.org/wileys', {
|
|
265
|
+
...options,
|
|
266
|
+
responseType: 'json'
|
|
267
|
+
});
|
|
268
|
+
const versionStr = data.version;
|
|
269
|
+
const [major, minor, patch] = versionStr.split('.').map(Number);
|
|
270
|
+
return {
|
|
271
|
+
version: [major, minor, patch],
|
|
272
|
+
isLatest: true
|
|
273
|
+
};
|
|
274
|
+
} catch (error) {
|
|
275
|
+
return {
|
|
276
|
+
version: wileys_version_json_1.version,
|
|
277
|
+
isLatest: false,
|
|
278
|
+
error
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
exports.fetchLatestWileysVersion = fetchLatestWileysVersion;
|
|
283
|
+
|
|
261
284
|
const fetchLatestBaileysVersion = async (options = {}) => {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
285
|
+
try {
|
|
286
|
+
const { data } = await axios_1.default.get('https://registry.npmjs.org/wileys', {
|
|
287
|
+
...options,
|
|
288
|
+
responseType: 'json'
|
|
289
|
+
});
|
|
290
|
+
const versionStr = data.version;
|
|
291
|
+
const [major, minor, patch] = versionStr.split('.').map(Number);
|
|
292
|
+
return {
|
|
293
|
+
version: [major, minor, patch],
|
|
294
|
+
isLatest: true
|
|
295
|
+
};
|
|
296
|
+
} catch (error) {
|
|
297
|
+
return {
|
|
298
|
+
version: wileys_version_json_1.version,
|
|
299
|
+
isLatest: false,
|
|
300
|
+
error
|
|
301
|
+
};
|
|
302
|
+
}
|
|
266
303
|
};
|
|
267
304
|
exports.fetchLatestBaileysVersion = fetchLatestBaileysVersion;
|
|
268
305
|
|
|
@@ -280,7 +317,7 @@ const fetchLatestWaWebVersion = async (options) => {
|
|
|
280
317
|
const match = data.match(regex);
|
|
281
318
|
if (!(match === null || match === void 0 ? void 0 : match[1])) {
|
|
282
319
|
return {
|
|
283
|
-
version:
|
|
320
|
+
version: wileys_version_json_1.version,
|
|
284
321
|
isLatest: false,
|
|
285
322
|
error: {
|
|
286
323
|
message: 'Could not find client revision in the fetched content'
|
|
@@ -295,7 +332,7 @@ const fetchLatestWaWebVersion = async (options) => {
|
|
|
295
332
|
}
|
|
296
333
|
catch (error) {
|
|
297
334
|
return {
|
|
298
|
-
version:
|
|
335
|
+
version: wileys_version_json_1.version,
|
|
299
336
|
isLatest: false,
|
|
300
337
|
error
|
|
301
338
|
};
|
|
@@ -426,3 +463,5 @@ function bytesToCrockford(buffer) {
|
|
|
426
463
|
}
|
|
427
464
|
return crockford.join('');
|
|
428
465
|
}
|
|
466
|
+
exports.trimUndefined = trimUndefined;
|
|
467
|
+
exports.bytesToCrockford = bytesToCrockford;
|
package/lib/Utils/index.js
CHANGED
|
@@ -26,11 +26,10 @@ __exportStar(require("./history"), exports);
|
|
|
26
26
|
__exportStar(require("./chat-utils"), exports);
|
|
27
27
|
__exportStar(require("./lt-hash"), exports);
|
|
28
28
|
__exportStar(require("./auth-utils"), exports);
|
|
29
|
-
__exportStar(require("./
|
|
29
|
+
__exportStar(require("./wileys-event-stream"), exports);
|
|
30
30
|
__exportStar(require("./use-multi-file-auth-state"), exports);
|
|
31
31
|
__exportStar(require("./link-preview"), exports);
|
|
32
32
|
__exportStar(require("./event-buffer"), exports);
|
|
33
33
|
__exportStar(require("./process-message"), exports);
|
|
34
|
-
__exportStar(require("./
|
|
35
|
-
__exportStar(require("./
|
|
36
|
-
|
|
34
|
+
__exportStar(require("./message-retry-manager"), exports);
|
|
35
|
+
__exportStar(require("./browser-utils"), exports);
|