@periskope/baileys 6.7.18-alpha.4 → 6.7.18-alpha.5
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/README.md +1 -1
- package/WAProto/GenerateStatics.sh +2 -0
- package/WAProto/WAProto.proto +4633 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/ciphertext-message.js +15 -0
- package/lib/Signal/Group/group-session-builder.d.ts +14 -0
- package/lib/Signal/Group/group-session-builder.js +64 -0
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.js +96 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/index.js +57 -0
- package/lib/Signal/Group/keyhelper.d.ts +10 -0
- package/lib/Signal/Group/keyhelper.js +55 -0
- 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 +13 -0
- package/lib/Signal/Group/sender-chain-key.js +34 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-message.js +69 -0
- package/lib/Signal/Group/sender-key-name.d.ts +17 -0
- package/lib/Signal/Group/sender-key-name.js +51 -0
- package/lib/Signal/Group/sender-key-record.d.ts +30 -0
- package/lib/Signal/Group/sender-key-record.js +53 -0
- package/lib/Signal/Group/sender-key-state.d.ts +38 -0
- package/lib/Signal/Group/sender-key-state.js +99 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/{WASignalGroup/sender_message_key.js → lib/Signal/Group/sender-message-key.js} +29 -39
- package/lib/Signal/libsignal.js +28 -15
- package/lib/Socket/business.d.ts +29 -3
- package/lib/Socket/chats.d.ts +7 -5
- package/lib/Socket/chats.js +6 -4
- package/lib/Socket/groups.d.ts +7 -3
- package/lib/Socket/index.d.ts +29 -3
- package/lib/Socket/messages-recv.d.ts +29 -3
- package/lib/Socket/messages-recv.js +140 -0
- package/lib/Socket/messages-send.d.ts +29 -3
- package/lib/Socket/messages-send.js +28 -2
- package/lib/Socket/mex.d.ts +2 -0
- package/lib/Socket/mex.js +46 -0
- package/lib/Socket/newsletter.d.ts +139 -0
- package/lib/Socket/newsletter.js +183 -0
- package/lib/Socket/socket.d.ts +1 -1
- package/lib/Socket/socket.js +6 -2
- package/lib/Socket/usync.d.ts +1 -1
- package/lib/Types/Events.d.ts +26 -0
- package/lib/Types/Message.d.ts +8 -2
- package/lib/Types/Newsletter.d.ts +134 -0
- package/lib/Types/Newsletter.js +33 -0
- package/lib/Types/index.d.ts +1 -0
- package/lib/Types/index.js +1 -0
- package/lib/Utils/decode-wa-message.d.ts +3 -4
- package/lib/Utils/decode-wa-message.js +7 -2
- package/lib/Utils/generics.d.ts +1 -0
- package/lib/Utils/generics.js +4 -0
- package/lib/Utils/messages-media.d.ts +9 -1
- package/lib/Utils/messages-media.js +63 -28
- package/lib/Utils/messages.d.ts +2 -2
- package/lib/Utils/messages.js +39 -9
- package/package.json +2 -4
- package/WASignalGroup/GroupProtocol.js +0 -1697
- package/WASignalGroup/ciphertext_message.js +0 -16
- package/WASignalGroup/group_cipher.js +0 -120
- package/WASignalGroup/group_session_builder.js +0 -46
- package/WASignalGroup/index.js +0 -5
- package/WASignalGroup/keyhelper.js +0 -21
- package/WASignalGroup/protobufs.js +0 -3
- package/WASignalGroup/queue_job.js +0 -69
- package/WASignalGroup/sender_chain_key.js +0 -50
- package/WASignalGroup/sender_key_distribution_message.js +0 -78
- package/WASignalGroup/sender_key_message.js +0 -92
- package/WASignalGroup/sender_key_name.js +0 -70
- package/WASignalGroup/sender_key_record.js +0 -56
- package/WASignalGroup/sender_key_state.js +0 -129
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeNewsletterSocket = void 0;
|
|
4
|
+
const Types_1 = require("../Types");
|
|
5
|
+
const messages_media_1 = require("../Utils/messages-media");
|
|
6
|
+
const WABinary_1 = require("../WABinary");
|
|
7
|
+
const mex_1 = require("./mex");
|
|
8
|
+
const parseNewsletterCreateResponse = (response) => {
|
|
9
|
+
const { id, thread_metadata: thread, viewer_metadata: viewer } = response;
|
|
10
|
+
return {
|
|
11
|
+
id: id,
|
|
12
|
+
owner: undefined,
|
|
13
|
+
name: thread.name.text,
|
|
14
|
+
creation_time: parseInt(thread.creation_time, 10),
|
|
15
|
+
description: thread.description.text,
|
|
16
|
+
invite: thread.invite,
|
|
17
|
+
subscribers: parseInt(thread.subscribers_count, 10),
|
|
18
|
+
verification: thread.verification,
|
|
19
|
+
picture: {
|
|
20
|
+
id: thread.picture.id,
|
|
21
|
+
directPath: thread.picture.direct_path
|
|
22
|
+
},
|
|
23
|
+
mute_state: viewer.mute
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const parseNewsletterMetadata = (result) => {
|
|
27
|
+
if (typeof result !== 'object' || result === null) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
if ('id' in result && typeof result.id === 'string') {
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
if ('result' in result && typeof result.result === 'object' && result.result !== null && 'id' in result.result) {
|
|
34
|
+
return result.result;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
};
|
|
38
|
+
const makeNewsletterSocket = (sock) => {
|
|
39
|
+
const { query, generateMessageTag } = sock;
|
|
40
|
+
const executeWMexQuery = (variables, queryId, dataPath) => {
|
|
41
|
+
return (0, mex_1.executeWMexQuery)(variables, queryId, dataPath, query, generateMessageTag);
|
|
42
|
+
};
|
|
43
|
+
const newsletterUpdate = async (jid, updates) => {
|
|
44
|
+
const variables = {
|
|
45
|
+
newsletter_id: jid,
|
|
46
|
+
updates: {
|
|
47
|
+
...updates,
|
|
48
|
+
settings: null
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
return executeWMexQuery(variables, Types_1.QueryIds.UPDATE_METADATA, 'xwa2_newsletter_update');
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
...sock,
|
|
55
|
+
newsletterCreate: async (name, description) => {
|
|
56
|
+
const variables = {
|
|
57
|
+
input: {
|
|
58
|
+
name,
|
|
59
|
+
description: description !== null && description !== void 0 ? description : null
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const rawResponse = await executeWMexQuery(variables, Types_1.QueryIds.CREATE, Types_1.XWAPaths.xwa2_newsletter_create);
|
|
63
|
+
return parseNewsletterCreateResponse(rawResponse);
|
|
64
|
+
},
|
|
65
|
+
newsletterUpdate,
|
|
66
|
+
newsletterSubscribers: async (jid) => {
|
|
67
|
+
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.SUBSCRIBERS, Types_1.XWAPaths.xwa2_newsletter_subscribers);
|
|
68
|
+
},
|
|
69
|
+
newsletterMetadata: async (type, key) => {
|
|
70
|
+
const variables = {
|
|
71
|
+
fetch_creation_time: true,
|
|
72
|
+
fetch_full_image: true,
|
|
73
|
+
fetch_viewer_metadata: true,
|
|
74
|
+
input: {
|
|
75
|
+
key,
|
|
76
|
+
type: type.toUpperCase()
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const result = await executeWMexQuery(variables, Types_1.QueryIds.METADATA, Types_1.XWAPaths.xwa2_newsletter_metadata);
|
|
80
|
+
return parseNewsletterMetadata(result);
|
|
81
|
+
},
|
|
82
|
+
newsletterFollow: (jid) => {
|
|
83
|
+
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.FOLLOW, Types_1.XWAPaths.xwa2_newsletter_follow);
|
|
84
|
+
},
|
|
85
|
+
newsletterUnfollow: (jid) => {
|
|
86
|
+
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.UNFOLLOW, Types_1.XWAPaths.xwa2_newsletter_unfollow);
|
|
87
|
+
},
|
|
88
|
+
newsletterMute: (jid) => {
|
|
89
|
+
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.MUTE, Types_1.XWAPaths.xwa2_newsletter_mute_v2);
|
|
90
|
+
},
|
|
91
|
+
newsletterUnmute: (jid) => {
|
|
92
|
+
return executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.UNMUTE, Types_1.XWAPaths.xwa2_newsletter_unmute_v2);
|
|
93
|
+
},
|
|
94
|
+
newsletterUpdateName: async (jid, name) => {
|
|
95
|
+
return await newsletterUpdate(jid, { name });
|
|
96
|
+
},
|
|
97
|
+
newsletterUpdateDescription: async (jid, description) => {
|
|
98
|
+
return await newsletterUpdate(jid, { description });
|
|
99
|
+
},
|
|
100
|
+
newsletterUpdatePicture: async (jid, content) => {
|
|
101
|
+
const { img } = await (0, messages_media_1.generateProfilePicture)(content);
|
|
102
|
+
return await newsletterUpdate(jid, { picture: img.toString('base64') });
|
|
103
|
+
},
|
|
104
|
+
newsletterRemovePicture: async (jid) => {
|
|
105
|
+
return await newsletterUpdate(jid, { picture: '' });
|
|
106
|
+
},
|
|
107
|
+
newsletterReactMessage: async (jid, serverId, reaction) => {
|
|
108
|
+
await query({
|
|
109
|
+
tag: 'message',
|
|
110
|
+
attrs: {
|
|
111
|
+
to: jid,
|
|
112
|
+
...(reaction ? {} : { edit: '7' }),
|
|
113
|
+
type: 'reaction',
|
|
114
|
+
server_id: serverId,
|
|
115
|
+
id: generateMessageTag()
|
|
116
|
+
},
|
|
117
|
+
content: [
|
|
118
|
+
{
|
|
119
|
+
tag: 'reaction',
|
|
120
|
+
attrs: reaction ? { code: reaction } : {}
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
newsletterFetchMessages: async (jid, count, since, after) => {
|
|
126
|
+
const messageUpdateAttrs = {
|
|
127
|
+
count: count.toString()
|
|
128
|
+
};
|
|
129
|
+
if (typeof since === 'number') {
|
|
130
|
+
messageUpdateAttrs.since = since.toString();
|
|
131
|
+
}
|
|
132
|
+
if (after) {
|
|
133
|
+
messageUpdateAttrs.after = after.toString();
|
|
134
|
+
}
|
|
135
|
+
const result = await query({
|
|
136
|
+
tag: 'iq',
|
|
137
|
+
attrs: {
|
|
138
|
+
id: generateMessageTag(),
|
|
139
|
+
type: 'get',
|
|
140
|
+
xmlns: 'newsletter',
|
|
141
|
+
to: jid
|
|
142
|
+
},
|
|
143
|
+
content: [
|
|
144
|
+
{
|
|
145
|
+
tag: 'message_updates',
|
|
146
|
+
attrs: messageUpdateAttrs
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
});
|
|
150
|
+
return result;
|
|
151
|
+
},
|
|
152
|
+
subscribeNewsletterUpdates: async (jid) => {
|
|
153
|
+
var _a;
|
|
154
|
+
const result = await query({
|
|
155
|
+
tag: 'iq',
|
|
156
|
+
attrs: {
|
|
157
|
+
id: generateMessageTag(),
|
|
158
|
+
type: 'set',
|
|
159
|
+
xmlns: 'newsletter',
|
|
160
|
+
to: jid
|
|
161
|
+
},
|
|
162
|
+
content: [{ tag: 'live_updates', attrs: {}, content: [] }]
|
|
163
|
+
});
|
|
164
|
+
const liveUpdatesNode = (0, WABinary_1.getBinaryNodeChild)(result, 'live_updates');
|
|
165
|
+
const duration = (_a = liveUpdatesNode === null || liveUpdatesNode === void 0 ? void 0 : liveUpdatesNode.attrs) === null || _a === void 0 ? void 0 : _a.duration;
|
|
166
|
+
return duration ? { duration: duration } : null;
|
|
167
|
+
},
|
|
168
|
+
newsletterAdminCount: async (jid) => {
|
|
169
|
+
const response = await executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.ADMIN_COUNT, Types_1.XWAPaths.xwa2_newsletter_admin_count);
|
|
170
|
+
return response.admin_count;
|
|
171
|
+
},
|
|
172
|
+
newsletterChangeOwner: async (jid, newOwnerJid) => {
|
|
173
|
+
await executeWMexQuery({ newsletter_id: jid, user_id: newOwnerJid }, Types_1.QueryIds.CHANGE_OWNER, Types_1.XWAPaths.xwa2_newsletter_change_owner);
|
|
174
|
+
},
|
|
175
|
+
newsletterDemote: async (jid, userJid) => {
|
|
176
|
+
await executeWMexQuery({ newsletter_id: jid, user_id: userJid }, Types_1.QueryIds.DEMOTE, Types_1.XWAPaths.xwa2_newsletter_demote);
|
|
177
|
+
},
|
|
178
|
+
newsletterDelete: async (jid) => {
|
|
179
|
+
await executeWMexQuery({ newsletter_id: jid }, Types_1.QueryIds.DELETE, Types_1.XWAPaths.xwa2_newsletter_delete_v2);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
exports.makeNewsletterSocket = makeNewsletterSocket;
|
package/lib/Socket/socket.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export declare const makeSocket: (config: SocketConfig) => {
|
|
|
35
35
|
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
36
36
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
37
37
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
38
|
-
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
38
|
+
requestPairingCode: (phoneNumber: string, customPairingCode?: string) => Promise<string>;
|
|
39
39
|
/** Waits for the connection to WA to reach a state */
|
|
40
40
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
41
41
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
package/lib/Socket/socket.js
CHANGED
|
@@ -355,8 +355,12 @@ const makeSocket = (config) => {
|
|
|
355
355
|
}
|
|
356
356
|
end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }));
|
|
357
357
|
};
|
|
358
|
-
const requestPairingCode = async (phoneNumber) => {
|
|
359
|
-
|
|
358
|
+
const requestPairingCode = async (phoneNumber, customPairingCode) => {
|
|
359
|
+
const pairingCode = customPairingCode !== null && customPairingCode !== void 0 ? customPairingCode : (0, Utils_1.bytesToCrockford)((0, crypto_1.randomBytes)(5));
|
|
360
|
+
if (customPairingCode && (customPairingCode === null || customPairingCode === void 0 ? void 0 : customPairingCode.length) !== 8) {
|
|
361
|
+
throw new Error('Custom pairing code must be exactly 8 chars');
|
|
362
|
+
}
|
|
363
|
+
authState.creds.pairingCode = pairingCode;
|
|
360
364
|
authState.creds.me = {
|
|
361
365
|
id: (0, WABinary_1.jidEncode)(phoneNumber, 's.whatsapp.net'),
|
|
362
366
|
name: '~'
|
package/lib/Socket/usync.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare const makeUSyncSocket: (config: SocketConfig) => {
|
|
|
30
30
|
onUnexpectedError: (err: Error | Boom, msg: string) => void;
|
|
31
31
|
uploadPreKeys: (count?: number) => Promise<void>;
|
|
32
32
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
|
33
|
-
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
|
33
|
+
requestPairingCode: (phoneNumber: string, customPairingCode?: string) => Promise<string>;
|
|
34
34
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
|
|
35
35
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
|
|
36
36
|
};
|
package/lib/Types/Events.d.ts
CHANGED
|
@@ -118,6 +118,32 @@ export type BaileysEventMap = {
|
|
|
118
118
|
broadcast: string;
|
|
119
119
|
type: 'read' | 'delivered';
|
|
120
120
|
};
|
|
121
|
+
/** Newsletter-related events */
|
|
122
|
+
'newsletter.reaction': {
|
|
123
|
+
id: string;
|
|
124
|
+
server_id: string;
|
|
125
|
+
reaction: {
|
|
126
|
+
code?: string;
|
|
127
|
+
count?: number;
|
|
128
|
+
removed?: boolean;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
'newsletter.view': {
|
|
132
|
+
id: string;
|
|
133
|
+
server_id: string;
|
|
134
|
+
count: number;
|
|
135
|
+
};
|
|
136
|
+
'newsletter-participants.update': {
|
|
137
|
+
id: string;
|
|
138
|
+
author: string;
|
|
139
|
+
user: string;
|
|
140
|
+
new_role: string;
|
|
141
|
+
action: string;
|
|
142
|
+
};
|
|
143
|
+
'newsletter-settings.update': {
|
|
144
|
+
id: string;
|
|
145
|
+
update: any;
|
|
146
|
+
};
|
|
121
147
|
};
|
|
122
148
|
export type BufferedEventData = {
|
|
123
149
|
historySets: {
|
package/lib/Types/Message.d.ts
CHANGED
|
@@ -7,14 +7,19 @@ import { BinaryNode } from '../WABinary';
|
|
|
7
7
|
import type { GroupMetadata } from './GroupMetadata';
|
|
8
8
|
import { CacheStore } from './Socket';
|
|
9
9
|
export { proto as WAProto };
|
|
10
|
-
export type WAMessage = proto.IWebMessageInfo
|
|
10
|
+
export type WAMessage = proto.IWebMessageInfo & {
|
|
11
|
+
key: WAMessageKey;
|
|
12
|
+
};
|
|
11
13
|
export type WAMessageContent = proto.IMessage;
|
|
12
14
|
export type WAContactMessage = proto.Message.IContactMessage;
|
|
13
15
|
export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage;
|
|
14
16
|
export type WAMessageKey = proto.IMessageKey & {
|
|
15
17
|
senderLid?: string;
|
|
16
|
-
|
|
18
|
+
server_id?: string;
|
|
17
19
|
senderPn?: string;
|
|
20
|
+
participantLid?: string;
|
|
21
|
+
participantPn?: string;
|
|
22
|
+
isViewOnce?: boolean;
|
|
18
23
|
};
|
|
19
24
|
export type WATextMessage = proto.Message.IExtendedTextMessage;
|
|
20
25
|
export type WAContextInfo = proto.IContextInfo;
|
|
@@ -241,6 +246,7 @@ export type MediaGenerationOptions = {
|
|
|
241
246
|
export type MessageContentGenerationOptions = MediaGenerationOptions & {
|
|
242
247
|
getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>;
|
|
243
248
|
getProfilePicUrl?: (jid: string, type: 'image' | 'preview') => Promise<string | undefined>;
|
|
249
|
+
jid?: string;
|
|
244
250
|
};
|
|
245
251
|
export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent;
|
|
246
252
|
/**
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
export declare enum XWAPaths {
|
|
2
|
+
xwa2_newsletter_create = "xwa2_newsletter_create",
|
|
3
|
+
xwa2_newsletter_subscribers = "xwa2_newsletter_subscribers",
|
|
4
|
+
xwa2_newsletter_view = "xwa2_newsletter_view",
|
|
5
|
+
xwa2_newsletter_metadata = "xwa2_newsletter",
|
|
6
|
+
xwa2_newsletter_admin_count = "xwa2_newsletter_admin",
|
|
7
|
+
xwa2_newsletter_mute_v2 = "xwa2_newsletter_mute_v2",
|
|
8
|
+
xwa2_newsletter_unmute_v2 = "xwa2_newsletter_unmute_v2",
|
|
9
|
+
xwa2_newsletter_follow = "xwa2_newsletter_follow",
|
|
10
|
+
xwa2_newsletter_unfollow = "xwa2_newsletter_unfollow",
|
|
11
|
+
xwa2_newsletter_change_owner = "xwa2_newsletter_change_owner",
|
|
12
|
+
xwa2_newsletter_demote = "xwa2_newsletter_demote",
|
|
13
|
+
xwa2_newsletter_delete_v2 = "xwa2_newsletter_delete_v2"
|
|
14
|
+
}
|
|
15
|
+
export declare enum QueryIds {
|
|
16
|
+
CREATE = "8823471724422422",
|
|
17
|
+
UPDATE_METADATA = "24250201037901610",
|
|
18
|
+
METADATA = "6563316087068696",
|
|
19
|
+
SUBSCRIBERS = "9783111038412085",
|
|
20
|
+
FOLLOW = "7871414976211147",
|
|
21
|
+
UNFOLLOW = "7238632346214362",
|
|
22
|
+
MUTE = "29766401636284406",
|
|
23
|
+
UNMUTE = "9864994326891137",
|
|
24
|
+
ADMIN_COUNT = "7130823597031706",
|
|
25
|
+
CHANGE_OWNER = "7341777602580933",
|
|
26
|
+
DEMOTE = "6551828931592903",
|
|
27
|
+
DELETE = "30062808666639665"
|
|
28
|
+
}
|
|
29
|
+
export type NewsletterUpdate = {
|
|
30
|
+
name?: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
picture?: string;
|
|
33
|
+
};
|
|
34
|
+
export interface NewsletterCreateResponse {
|
|
35
|
+
id: string;
|
|
36
|
+
state: {
|
|
37
|
+
type: string;
|
|
38
|
+
};
|
|
39
|
+
thread_metadata: {
|
|
40
|
+
creation_time: string;
|
|
41
|
+
description: {
|
|
42
|
+
id: string;
|
|
43
|
+
text: string;
|
|
44
|
+
update_time: string;
|
|
45
|
+
};
|
|
46
|
+
handle: string | null;
|
|
47
|
+
invite: string;
|
|
48
|
+
name: {
|
|
49
|
+
id: string;
|
|
50
|
+
text: string;
|
|
51
|
+
update_time: string;
|
|
52
|
+
};
|
|
53
|
+
picture: {
|
|
54
|
+
direct_path: string;
|
|
55
|
+
id: string;
|
|
56
|
+
type: string;
|
|
57
|
+
};
|
|
58
|
+
preview: {
|
|
59
|
+
direct_path: string;
|
|
60
|
+
id: string;
|
|
61
|
+
type: string;
|
|
62
|
+
};
|
|
63
|
+
subscribers_count: string;
|
|
64
|
+
verification: 'VERIFIED' | 'UNVERIFIED';
|
|
65
|
+
};
|
|
66
|
+
viewer_metadata: {
|
|
67
|
+
mute: 'ON' | 'OFF';
|
|
68
|
+
role: NewsletterViewRole;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export interface NewsletterCreateResponse {
|
|
72
|
+
id: string;
|
|
73
|
+
state: {
|
|
74
|
+
type: string;
|
|
75
|
+
};
|
|
76
|
+
thread_metadata: {
|
|
77
|
+
creation_time: string;
|
|
78
|
+
description: {
|
|
79
|
+
id: string;
|
|
80
|
+
text: string;
|
|
81
|
+
update_time: string;
|
|
82
|
+
};
|
|
83
|
+
handle: string | null;
|
|
84
|
+
invite: string;
|
|
85
|
+
name: {
|
|
86
|
+
id: string;
|
|
87
|
+
text: string;
|
|
88
|
+
update_time: string;
|
|
89
|
+
};
|
|
90
|
+
picture: {
|
|
91
|
+
direct_path: string;
|
|
92
|
+
id: string;
|
|
93
|
+
type: string;
|
|
94
|
+
};
|
|
95
|
+
preview: {
|
|
96
|
+
direct_path: string;
|
|
97
|
+
id: string;
|
|
98
|
+
type: string;
|
|
99
|
+
};
|
|
100
|
+
subscribers_count: string;
|
|
101
|
+
verification: 'VERIFIED' | 'UNVERIFIED';
|
|
102
|
+
};
|
|
103
|
+
viewer_metadata: {
|
|
104
|
+
mute: 'ON' | 'OFF';
|
|
105
|
+
role: NewsletterViewRole;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export type NewsletterViewRole = 'ADMIN' | 'GUEST' | 'OWNER' | 'SUBSCRIBER';
|
|
109
|
+
export interface NewsletterMetadata {
|
|
110
|
+
id: string;
|
|
111
|
+
owner?: string;
|
|
112
|
+
name: string;
|
|
113
|
+
description?: string;
|
|
114
|
+
invite?: string;
|
|
115
|
+
creation_time?: number;
|
|
116
|
+
subscribers?: number;
|
|
117
|
+
picture?: {
|
|
118
|
+
url?: string;
|
|
119
|
+
directPath?: string;
|
|
120
|
+
mediaKey?: string;
|
|
121
|
+
id?: string;
|
|
122
|
+
};
|
|
123
|
+
verification?: 'VERIFIED' | 'UNVERIFIED';
|
|
124
|
+
reaction_codes?: {
|
|
125
|
+
code: string;
|
|
126
|
+
count: number;
|
|
127
|
+
}[];
|
|
128
|
+
mute_state?: 'ON' | 'OFF';
|
|
129
|
+
thread_metadata?: {
|
|
130
|
+
creation_time?: number;
|
|
131
|
+
name?: string;
|
|
132
|
+
description?: string;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueryIds = exports.XWAPaths = void 0;
|
|
4
|
+
var XWAPaths;
|
|
5
|
+
(function (XWAPaths) {
|
|
6
|
+
XWAPaths["xwa2_newsletter_create"] = "xwa2_newsletter_create";
|
|
7
|
+
XWAPaths["xwa2_newsletter_subscribers"] = "xwa2_newsletter_subscribers";
|
|
8
|
+
XWAPaths["xwa2_newsletter_view"] = "xwa2_newsletter_view";
|
|
9
|
+
XWAPaths["xwa2_newsletter_metadata"] = "xwa2_newsletter";
|
|
10
|
+
XWAPaths["xwa2_newsletter_admin_count"] = "xwa2_newsletter_admin";
|
|
11
|
+
XWAPaths["xwa2_newsletter_mute_v2"] = "xwa2_newsletter_mute_v2";
|
|
12
|
+
XWAPaths["xwa2_newsletter_unmute_v2"] = "xwa2_newsletter_unmute_v2";
|
|
13
|
+
XWAPaths["xwa2_newsletter_follow"] = "xwa2_newsletter_follow";
|
|
14
|
+
XWAPaths["xwa2_newsletter_unfollow"] = "xwa2_newsletter_unfollow";
|
|
15
|
+
XWAPaths["xwa2_newsletter_change_owner"] = "xwa2_newsletter_change_owner";
|
|
16
|
+
XWAPaths["xwa2_newsletter_demote"] = "xwa2_newsletter_demote";
|
|
17
|
+
XWAPaths["xwa2_newsletter_delete_v2"] = "xwa2_newsletter_delete_v2";
|
|
18
|
+
})(XWAPaths || (exports.XWAPaths = XWAPaths = {}));
|
|
19
|
+
var QueryIds;
|
|
20
|
+
(function (QueryIds) {
|
|
21
|
+
QueryIds["CREATE"] = "8823471724422422";
|
|
22
|
+
QueryIds["UPDATE_METADATA"] = "24250201037901610";
|
|
23
|
+
QueryIds["METADATA"] = "6563316087068696";
|
|
24
|
+
QueryIds["SUBSCRIBERS"] = "9783111038412085";
|
|
25
|
+
QueryIds["FOLLOW"] = "7871414976211147";
|
|
26
|
+
QueryIds["UNFOLLOW"] = "7238632346214362";
|
|
27
|
+
QueryIds["MUTE"] = "29766401636284406";
|
|
28
|
+
QueryIds["UNMUTE"] = "9864994326891137";
|
|
29
|
+
QueryIds["ADMIN_COUNT"] = "7130823597031706";
|
|
30
|
+
QueryIds["CHANGE_OWNER"] = "7341777602580933";
|
|
31
|
+
QueryIds["DEMOTE"] = "6551828931592903";
|
|
32
|
+
QueryIds["DELETE"] = "30062808666639665";
|
|
33
|
+
})(QueryIds || (exports.QueryIds = QueryIds = {}));
|
package/lib/Types/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from './Events';
|
|
|
9
9
|
export * from './Product';
|
|
10
10
|
export * from './Call';
|
|
11
11
|
export * from './Signal';
|
|
12
|
+
export * from './Newsletter';
|
|
12
13
|
import { AuthenticationState } from './Auth';
|
|
13
14
|
import { SocketConfig } from './Socket';
|
|
14
15
|
export type UserFacingSocketConfig = Partial<SocketConfig> & {
|
package/lib/Types/index.js
CHANGED
|
@@ -26,6 +26,7 @@ __exportStar(require("./Events"), exports);
|
|
|
26
26
|
__exportStar(require("./Product"), exports);
|
|
27
27
|
__exportStar(require("./Call"), exports);
|
|
28
28
|
__exportStar(require("./Signal"), exports);
|
|
29
|
+
__exportStar(require("./Newsletter"), exports);
|
|
29
30
|
var DisconnectReason;
|
|
30
31
|
(function (DisconnectReason) {
|
|
31
32
|
DisconnectReason[DisconnectReason["connectionClosed"] = 428] = "connectionClosed";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SignalRepository } from '../Types';
|
|
1
|
+
import { SignalRepository, WAMessage } from '../Types';
|
|
3
2
|
import { BinaryNode } from '../WABinary';
|
|
4
3
|
import { ILogger } from './logger';
|
|
5
4
|
export declare const NO_MESSAGE_FOUND_ERROR_TEXT = "Message absent from node";
|
|
@@ -24,12 +23,12 @@ export declare const NACK_REASONS: {
|
|
|
24
23
|
* @note this will only parse the message, not decrypt it
|
|
25
24
|
*/
|
|
26
25
|
export declare function decodeMessageNode(stanza: BinaryNode, meId: string, meLid: string): {
|
|
27
|
-
fullMessage:
|
|
26
|
+
fullMessage: WAMessage;
|
|
28
27
|
author: string;
|
|
29
28
|
sender: string;
|
|
30
29
|
};
|
|
31
30
|
export declare const decryptMessageNode: (stanza: BinaryNode, meId: string, meLid: string, repository: SignalRepository, logger: ILogger) => {
|
|
32
|
-
fullMessage:
|
|
31
|
+
fullMessage: WAMessage;
|
|
33
32
|
category: string;
|
|
34
33
|
author: string;
|
|
35
34
|
decrypt(): Promise<void>;
|
|
@@ -28,7 +28,7 @@ exports.NACK_REASONS = {
|
|
|
28
28
|
* @note this will only parse the message, not decrypt it
|
|
29
29
|
*/
|
|
30
30
|
function decodeMessageNode(stanza, meId, meLid) {
|
|
31
|
-
var _a, _b, _c, _d;
|
|
31
|
+
var _a, _b, _c, _d, _e;
|
|
32
32
|
let msgType;
|
|
33
33
|
let chatId;
|
|
34
34
|
let author;
|
|
@@ -90,7 +90,9 @@ function decodeMessageNode(stanza, meId, meLid) {
|
|
|
90
90
|
senderLid: (_b = stanza === null || stanza === void 0 ? void 0 : stanza.attrs) === null || _b === void 0 ? void 0 : _b.sender_lid,
|
|
91
91
|
senderPn: (_c = stanza === null || stanza === void 0 ? void 0 : stanza.attrs) === null || _c === void 0 ? void 0 : _c.sender_pn,
|
|
92
92
|
participant,
|
|
93
|
-
|
|
93
|
+
participantPn: (_d = stanza === null || stanza === void 0 ? void 0 : stanza.attrs) === null || _d === void 0 ? void 0 : _d.participant_pn,
|
|
94
|
+
participantLid: (_e = stanza === null || stanza === void 0 ? void 0 : stanza.attrs) === null || _e === void 0 ? void 0 : _e.participant_lid,
|
|
95
|
+
...(msgType === 'newsletter' && stanza.attrs.server_id ? { server_id: stanza.attrs.server_id } : {})
|
|
94
96
|
};
|
|
95
97
|
const fullMessage = {
|
|
96
98
|
key,
|
|
@@ -123,6 +125,9 @@ const decryptMessageNode = (stanza, meId, meLid, repository, logger) => {
|
|
|
123
125
|
const details = WAProto_1.proto.VerifiedNameCertificate.Details.decode(cert.details);
|
|
124
126
|
fullMessage.verifiedBizName = details.verifiedName;
|
|
125
127
|
}
|
|
128
|
+
if (tag === 'unavailable' && attrs.type === 'view_once') {
|
|
129
|
+
fullMessage.key.isViewOnce = true;
|
|
130
|
+
}
|
|
126
131
|
if (tag !== 'enc' && tag !== 'plaintext') {
|
|
127
132
|
continue;
|
|
128
133
|
}
|
package/lib/Utils/generics.d.ts
CHANGED
package/lib/Utils/generics.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.promiseTimeout = promiseTimeout;
|
|
|
8
8
|
exports.bindWaitForEvent = bindWaitForEvent;
|
|
9
9
|
exports.trimUndefined = trimUndefined;
|
|
10
10
|
exports.bytesToCrockford = bytesToCrockford;
|
|
11
|
+
exports.encodeNewsletterMessage = encodeNewsletterMessage;
|
|
11
12
|
const boom_1 = require("@hapi/boom");
|
|
12
13
|
const axios_1 = __importDefault(require("axios"));
|
|
13
14
|
const crypto_1 = require("crypto");
|
|
@@ -394,3 +395,6 @@ function bytesToCrockford(buffer) {
|
|
|
394
395
|
}
|
|
395
396
|
return crockford.join('');
|
|
396
397
|
}
|
|
398
|
+
function encodeNewsletterMessage(message) {
|
|
399
|
+
return WAProto_1.proto.Message.encode(message).finish();
|
|
400
|
+
}
|
|
@@ -8,6 +8,11 @@ import { BinaryNode } from '../WABinary';
|
|
|
8
8
|
import { ILogger } from './logger';
|
|
9
9
|
export declare const hkdfInfoKey: (type: MediaType) => string;
|
|
10
10
|
export declare function processImage(imageUrl: string): Promise<Buffer<ArrayBufferLike> | null>;
|
|
11
|
+
export declare const getRawMediaUploadData: (media: WAMediaUpload, mediaType: MediaType, logger?: ILogger) => Promise<{
|
|
12
|
+
filePath: string;
|
|
13
|
+
fileSha256: Buffer<ArrayBufferLike>;
|
|
14
|
+
fileLength: number;
|
|
15
|
+
}>;
|
|
11
16
|
/** generates all the keys required to encrypt/decrypt & sign a media message */
|
|
12
17
|
export declare function getMediaKeys(buffer: Uint8Array | string | null | undefined, mediaType: MediaType): Promise<MediaDecryptionKeyInfo>;
|
|
13
18
|
export declare const extractImageThumb: (bufferOrFilePath: Readable | Buffer | string, width?: number) => Promise<{
|
|
@@ -18,7 +23,10 @@ export declare const extractImageThumb: (bufferOrFilePath: Readable | Buffer | s
|
|
|
18
23
|
};
|
|
19
24
|
}>;
|
|
20
25
|
export declare const encodeBase64EncodedStringForUpload: (b64: string) => string;
|
|
21
|
-
export declare const generateProfilePicture: (mediaUpload: WAMediaUpload
|
|
26
|
+
export declare const generateProfilePicture: (mediaUpload: WAMediaUpload, dimensions?: {
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
}) => Promise<{
|
|
22
30
|
img: Buffer<ArrayBufferLike>;
|
|
23
31
|
}>;
|
|
24
32
|
/** gets the SHA256 of the given media message */
|