wolfsocket 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.
- package/README.md +144 -144
- package/WAProto/WAProto.proto +10 -1
- package/WAProto/index.d.ts +26 -0
- package/WAProto/index.js +18415 -8908
- package/lib/Defaults/index.d.ts +6 -0
- package/lib/Defaults/index.d.ts.map +1 -1
- package/lib/Defaults/index.js +18 -1
- package/lib/Defaults/index.js.map +1 -1
- package/lib/Signal/lid-mapping.js +1 -1
- package/lib/Signal/lid-mapping.js.map +1 -1
- package/lib/Socket/business.d.ts +174 -6
- package/lib/Socket/business.d.ts.map +1 -1
- package/lib/Socket/channelPollVote.d.ts +44 -0
- package/lib/Socket/channelPollVote.d.ts.map +1 -0
- package/lib/Socket/channelPollVote.js +65 -0
- package/lib/Socket/channelPollVote.js.map +1 -0
- package/lib/Socket/channelSchedule.d.ts +229 -0
- package/lib/Socket/channelSchedule.d.ts.map +1 -0
- package/lib/Socket/channelSchedule.js +465 -0
- package/lib/Socket/channelSchedule.js.map +1 -0
- package/lib/Socket/channelStatus.d.ts +317 -0
- package/lib/Socket/channelStatus.d.ts.map +1 -0
- package/lib/Socket/channelStatus.js +479 -0
- package/lib/Socket/channelStatus.js.map +1 -0
- package/lib/Socket/chats.d.ts +30 -5
- package/lib/Socket/chats.d.ts.map +1 -1
- package/lib/Socket/chats.js +117 -2
- package/lib/Socket/chats.js.map +1 -1
- package/lib/Socket/communities.d.ts +176 -7
- package/lib/Socket/communities.d.ts.map +1 -1
- package/lib/Socket/communities.js +22 -6
- package/lib/Socket/communities.js.map +1 -1
- package/lib/Socket/groupHistory.d.ts +38 -0
- package/lib/Socket/groupHistory.d.ts.map +1 -0
- package/lib/Socket/groupHistory.js +88 -0
- package/lib/Socket/groupHistory.js.map +1 -0
- package/lib/Socket/groupStatus.d.ts +6 -0
- package/lib/Socket/groupStatus.d.ts.map +1 -1
- package/lib/Socket/groupStatus.js +19 -3
- package/lib/Socket/groupStatus.js.map +1 -1
- package/lib/Socket/groups.d.ts +11 -5
- package/lib/Socket/groups.d.ts.map +1 -1
- package/lib/Socket/groups.js +9 -2
- package/lib/Socket/groups.js.map +1 -1
- package/lib/Socket/index.d.ts +174 -6
- package/lib/Socket/index.d.ts.map +1 -1
- package/lib/Socket/messages-recv.d.ts +174 -6
- package/lib/Socket/messages-recv.d.ts.map +1 -1
- package/lib/Socket/messages-recv.js +152 -34
- package/lib/Socket/messages-recv.js.map +1 -1
- package/lib/Socket/messages-send.d.ts +211 -8
- package/lib/Socket/messages-send.d.ts.map +1 -1
- package/lib/Socket/messages-send.js +510 -133
- package/lib/Socket/messages-send.js.map +1 -1
- package/lib/Socket/newsletter.d.ts +11 -5
- package/lib/Socket/newsletter.d.ts.map +1 -1
- package/lib/Socket/newsletterDirectory.d.ts +201 -0
- package/lib/Socket/newsletterDirectory.d.ts.map +1 -0
- package/lib/Socket/newsletterDirectory.js +291 -0
- package/lib/Socket/newsletterDirectory.js.map +1 -0
- package/lib/Socket/payment.d.ts +37 -0
- package/lib/Socket/payment.d.ts.map +1 -0
- package/lib/Socket/payment.js +124 -0
- package/lib/Socket/payment.js.map +1 -0
- package/lib/Socket/report.d.ts +70 -0
- package/lib/Socket/report.d.ts.map +1 -0
- package/lib/Socket/report.js +265 -0
- package/lib/Socket/report.js.map +1 -0
- package/lib/Socket/socket.d.ts.map +1 -1
- package/lib/Socket/socket.js +17 -5
- package/lib/Socket/socket.js.map +1 -1
- package/lib/Socket/stickerPack.d.ts +29 -0
- package/lib/Socket/stickerPack.d.ts.map +1 -0
- package/lib/Socket/stickerPack.js +130 -0
- package/lib/Socket/stickerPack.js.map +1 -0
- package/lib/Socket/username.d.ts +55 -0
- package/lib/Socket/username.d.ts.map +1 -0
- package/lib/Socket/username.js +114 -0
- package/lib/Socket/username.js.map +1 -0
- package/lib/Types/ChannelStatus.d.ts +34 -0
- package/lib/Types/ChannelStatus.d.ts.map +1 -0
- package/lib/Types/ChannelStatus.js +2 -0
- package/lib/Types/ChannelStatus.js.map +1 -0
- package/lib/Types/Chat.d.ts +17 -0
- package/lib/Types/Chat.d.ts.map +1 -1
- package/lib/Types/Chat.js.map +1 -1
- package/lib/Types/Events.d.ts +4 -0
- package/lib/Types/Events.d.ts.map +1 -1
- package/lib/Types/GroupMetadata.d.ts +2 -0
- package/lib/Types/GroupMetadata.d.ts.map +1 -1
- package/lib/Types/Message.d.ts +123 -3
- package/lib/Types/Message.d.ts.map +1 -1
- package/lib/Types/Payment.d.ts +47 -0
- package/lib/Types/Payment.d.ts.map +1 -0
- package/lib/Types/Payment.js +2 -0
- package/lib/Types/Payment.js.map +1 -0
- package/lib/Types/Report.d.ts +219 -0
- package/lib/Types/Report.d.ts.map +1 -0
- package/lib/Types/Report.js +166 -0
- package/lib/Types/Report.js.map +1 -0
- package/lib/Types/StickerPack.d.ts +52 -0
- package/lib/Types/StickerPack.d.ts.map +1 -0
- package/lib/Types/StickerPack.js +2 -0
- package/lib/Types/StickerPack.js.map +1 -0
- package/lib/Types/Username.d.ts +19 -0
- package/lib/Types/Username.d.ts.map +1 -0
- package/lib/Types/Username.js +2 -0
- package/lib/Types/Username.js.map +1 -0
- package/lib/Types/index.d.ts +5 -0
- package/lib/Types/index.d.ts.map +1 -1
- package/lib/Types/index.js +5 -0
- package/lib/Types/index.js.map +1 -1
- package/lib/Utils/chat-utils.d.ts.map +1 -1
- package/lib/Utils/chat-utils.js +19 -1
- package/lib/Utils/chat-utils.js.map +1 -1
- package/lib/Utils/decode-wa-message.d.ts.map +1 -1
- package/lib/Utils/decode-wa-message.js +4 -1
- package/lib/Utils/decode-wa-message.js.map +1 -1
- package/lib/Utils/event-buffer.js +21 -1
- package/lib/Utils/event-buffer.js.map +1 -1
- package/lib/Utils/generics.js +1 -1
- package/lib/Utils/group-history.d.ts +37 -0
- package/lib/Utils/group-history.d.ts.map +1 -0
- package/lib/Utils/group-history.js +55 -0
- package/lib/Utils/group-history.js.map +1 -0
- package/lib/Utils/index.d.ts +3 -0
- package/lib/Utils/index.d.ts.map +1 -1
- package/lib/Utils/index.js +3 -0
- package/lib/Utils/index.js.map +1 -1
- package/lib/Utils/link-preview.d.ts.map +1 -1
- package/lib/Utils/link-preview.js +21 -7
- package/lib/Utils/link-preview.js.map +1 -1
- package/lib/Utils/message-retry-manager.d.ts +4 -0
- package/lib/Utils/message-retry-manager.d.ts.map +1 -1
- package/lib/Utils/message-retry-manager.js +11 -0
- package/lib/Utils/message-retry-manager.js.map +1 -1
- package/lib/Utils/messages-media.d.ts +25 -9
- package/lib/Utils/messages-media.d.ts.map +1 -1
- package/lib/Utils/messages-media.js +114 -27
- package/lib/Utils/messages-media.js.map +1 -1
- package/lib/Utils/messages.d.ts +89 -2
- package/lib/Utils/messages.d.ts.map +1 -1
- package/lib/Utils/messages.js +414 -15
- package/lib/Utils/messages.js.map +1 -1
- package/lib/Utils/offline-node-processor.d.ts +1 -1
- package/lib/Utils/offline-node-processor.d.ts.map +1 -1
- package/lib/Utils/process-message.d.ts +25 -0
- package/lib/Utils/process-message.d.ts.map +1 -1
- package/lib/Utils/process-message.js +60 -2
- package/lib/Utils/process-message.js.map +1 -1
- package/lib/Utils/reporting-utils.d.ts +7 -0
- package/lib/Utils/reporting-utils.d.ts.map +1 -1
- package/lib/Utils/reporting-utils.js +7 -0
- package/lib/Utils/reporting-utils.js.map +1 -1
- package/lib/Utils/sync-key-auto-resolve.d.ts +10 -0
- package/lib/Utils/sync-key-auto-resolve.d.ts.map +1 -0
- package/lib/Utils/sync-key-auto-resolve.js +33 -0
- package/lib/Utils/sync-key-auto-resolve.js.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -1
- package/lib/Utils/use-multi-file-auth-state.js +34 -2
- package/lib/Utils/use-multi-file-auth-state.js.map +1 -1
- package/lib/Utils/validate-connection.d.ts.map +1 -1
- package/lib/Utils/validate-connection.js +3 -2
- package/lib/Utils/validate-connection.js.map +1 -1
- package/lib/Utils/zip.d.ts +11 -0
- package/lib/Utils/zip.d.ts.map +1 -0
- package/lib/Utils/zip.js +88 -0
- package/lib/Utils/zip.js.map +1 -0
- package/lib/WABinary/generic-utils.d.ts +7 -0
- package/lib/WABinary/generic-utils.d.ts.map +1 -1
- package/lib/WABinary/generic-utils.js +88 -0
- package/lib/WABinary/generic-utils.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
import { executeWMexQuery } from './mex.js';
|
|
3
|
+
/**
|
|
4
|
+
* Channel directory (search + browse) — the directory the WhatsApp app shows
|
|
5
|
+
* under Channels > Explore. This is search/discovery only: it does not create,
|
|
6
|
+
* follow or manage channels (that is newsletter.ts) and it is not the
|
|
7
|
+
* `channelsPersonalisedRecommendation` privacy setting (app-state sync) —
|
|
8
|
+
* that setting only decides whether the list below is personalised.
|
|
9
|
+
*
|
|
10
|
+
* APK evidence (decompiled WhatsApp APK on the dev VM):
|
|
11
|
+
*
|
|
12
|
+
* - Jobs: `NewsletterDirectoryV2SearchGraphqlJob` and
|
|
13
|
+
* `NewsletterDirectoryV2ListGraphqlJob`
|
|
14
|
+
* (`com/whatsapp/newsletter/directory/job/`), GraphQL operations
|
|
15
|
+
* `NewsletterDirectorySearch` / `NewsletterDirectoryList`, app id
|
|
16
|
+
* `whatsapp-android-mex`. Both go through the same `w:mex` IQ mechanism
|
|
17
|
+
* as the rest of the fork (mex.ts): an `<iq type="get" xmlns="w:mex">`
|
|
18
|
+
* with a `<query query_id>` child carrying `{ variables }` as JSON.
|
|
19
|
+
* - Persisted query ids, from this APK's
|
|
20
|
+
* `assets/whatsapp-android-mex_client_persist_ids.json` (`doc_id`):
|
|
21
|
+
* search `27887355094203575`, list `27480627564903390`.
|
|
22
|
+
* - Variables, from the job code:
|
|
23
|
+
* - search `input` (`XWA2NewsletterDirectorySearchInput`): `search_text`,
|
|
24
|
+
* `categories` (null, or a one-element list with the category name),
|
|
25
|
+
* `limit`, `start_cursor` (null to start), optional `session_fields`
|
|
26
|
+
* (app analytics; not sent here — Baileys has no such session).
|
|
27
|
+
* - list `input`: `filters: { categories, country_codes }` (each null or
|
|
28
|
+
* a one-element list), `limit`, `start_cursor`, `use_personalization`
|
|
29
|
+
* (app: on unless the user disabled it), `view` (see below).
|
|
30
|
+
* - both queries also carry top-level `fetch_*` flags, exactly as the
|
|
31
|
+
* app sets them (`C6ip.A09(r, false)` + `C6in.A0X(r, false)`):
|
|
32
|
+
* `fetch_state: false`, `fetch_creation_time/name/preview/invite/
|
|
33
|
+
* followers_count/verification: true`, `fetch_image/description/handle/
|
|
34
|
+
* viewer_metadata/settings/wamo_sub/pinned_messages: false`, and
|
|
35
|
+
* `fetch_status_metadata` / `fetch_refresh_after_interval`, which the
|
|
36
|
+
* app overrides from its status-infra config (`C6in.A0k`) — the fork
|
|
37
|
+
* defaults both to false (see `fetchStatusMetadata` option).
|
|
38
|
+
* - Response, from the generated models (`C6v7`/`C6v1` -> `C6v6`/`C6v0` ->
|
|
39
|
+
* `C6v5`, `C6v2`/`C6v3`/`C6v4`, `C02696vc`, `C6vZ`) and the flatbuffer
|
|
40
|
+
* (`XWA2NewsletterSearchResponse`): the data path is
|
|
41
|
+
* `xwa2_newsletters_directory_search` / `xwa2_newsletters_directory_list`,
|
|
42
|
+
* holding `{ page_info: { endCursor }, result: [...],
|
|
43
|
+
* vertical_metadata: [...] }`. Each `result` entry is a newsletter:
|
|
44
|
+
* `id`, `thread_metadata` (`name`/`description` as `{ text }`,
|
|
45
|
+
* `followers_count` + `creation_time` as strings, `handle`, `invite`,
|
|
46
|
+
* `picture`/`preview` as `{ direct_path, id }`, `verification`),
|
|
47
|
+
* `viewer_metadata` (`role`), `state` (`type`), `status_metadata`
|
|
48
|
+
* (`last_status_sent_time`, `last_status_server_id`),
|
|
49
|
+
* `refresh_after_interval_sec`. A `vertical_metadata` entry is
|
|
50
|
+
* `{ vertical, vertical_title, newsletter_ids }`.
|
|
51
|
+
* - Categories (`EnumC08147Tk`): BUSINESS, ENTERTAINMENT, LIFESTYLE, NEWS,
|
|
52
|
+
* ORGANIZATIONS, PEOPLE, SPORTS, SPECIAL_EVENTS, SPECIAL_EVENTS_2..5,
|
|
53
|
+
* EXPLORE. List views (`EnumC08077Td`): FEATURED, NEW, POPULAR,
|
|
54
|
+
* RECOMMENDED, TRENDING.
|
|
55
|
+
*
|
|
56
|
+
* Caveats — read before trusting this live:
|
|
57
|
+
* - Query ids rotate server-side when the query text changes (username.ts
|
|
58
|
+
* already notes this). These ids are from the APK on the dev VM; the
|
|
59
|
+
* fork's older newsletter ids do NOT match this APK's registry for the
|
|
60
|
+
* same operations (e.g. NewsletterCreate: fork `8823471724422422` vs this
|
|
61
|
+
* APK `27009199332109318` — only UsernameSet/UsernamePinSet match), so
|
|
62
|
+
* the ids here are the currently-registered Android ones and the
|
|
63
|
+
* `w:mex` gateway accepting them from a Web socket still needs a live
|
|
64
|
+
* check. If the server rejects them, patch at runtime with
|
|
65
|
+
* `setNewsletterDirectoryQueryIds` (same pattern as username.ts) instead
|
|
66
|
+
* of waiting for a release.
|
|
67
|
+
* - `limit` has no fixed value in the app (it comes from an ab-prop), so
|
|
68
|
+
* the fork defaults to 50; pass `limit` to page differently.
|
|
69
|
+
* - Not built here: `NewsletterDirectoryCategoryPreview` (doc id
|
|
70
|
+
* `27432651036395658`) and the recommended feed
|
|
71
|
+
* `NewsletterRecommended` (`GetDirectoryNewslettersGraphqlJob`, doc id
|
|
72
|
+
* `29094080403564923`, default limit 500) — same mechanism, separate
|
|
73
|
+
* functions if the directory UI needs them.
|
|
74
|
+
*/
|
|
75
|
+
/** Directory categories, exactly as the app's `EnumC08147Tk`. */
|
|
76
|
+
export const NEWSLETTER_DIRECTORY_CATEGORIES = [
|
|
77
|
+
'BUSINESS',
|
|
78
|
+
'ENTERTAINMENT',
|
|
79
|
+
'LIFESTYLE',
|
|
80
|
+
'NEWS',
|
|
81
|
+
'ORGANIZATIONS',
|
|
82
|
+
'PEOPLE',
|
|
83
|
+
'SPORTS',
|
|
84
|
+
'SPECIAL_EVENTS',
|
|
85
|
+
'SPECIAL_EVENTS_2',
|
|
86
|
+
'SPECIAL_EVENTS_3',
|
|
87
|
+
'SPECIAL_EVENTS_4',
|
|
88
|
+
'SPECIAL_EVENTS_5',
|
|
89
|
+
'EXPLORE'
|
|
90
|
+
];
|
|
91
|
+
/** List views, exactly as the app's `EnumC08077Td`. */
|
|
92
|
+
export const NEWSLETTER_DIRECTORY_VIEWS = ['FEATURED', 'NEW', 'POPULAR', 'RECOMMENDED', 'TRENDING'];
|
|
93
|
+
/**
|
|
94
|
+
* Persisted GraphQL query ids for the directory operations, from this APK's
|
|
95
|
+
* `whatsapp-android-mex_client_persist_ids.json` (`doc_id`).
|
|
96
|
+
* WhatsApp rotates these server-side, so they can go stale.
|
|
97
|
+
* Patch them at runtime with setNewsletterDirectoryQueryIds (see below).
|
|
98
|
+
*/
|
|
99
|
+
export const NEWSLETTER_DIRECTORY_QUERY_IDS = {
|
|
100
|
+
SEARCH: '27887355094203575',
|
|
101
|
+
LIST: '27480627564903390'
|
|
102
|
+
};
|
|
103
|
+
/** MEX data paths for the directory operations (see the header comment). */
|
|
104
|
+
export const NEWSLETTER_DIRECTORY_DATA_PATHS = {
|
|
105
|
+
SEARCH: 'xwa2_newsletters_directory_search',
|
|
106
|
+
LIST: 'xwa2_newsletters_directory_list'
|
|
107
|
+
};
|
|
108
|
+
/** Default page size. The app takes it from an ab-prop; 50 is the fork's choice. */
|
|
109
|
+
export const NEWSLETTER_DIRECTORY_DEFAULT_LIMIT = 50;
|
|
110
|
+
/** Default list view. */
|
|
111
|
+
export const NEWSLETTER_DIRECTORY_DEFAULT_VIEW = 'FEATURED';
|
|
112
|
+
/** Replace one or more directory query IDs at runtime (they rotate server-side). */
|
|
113
|
+
export const setNewsletterDirectoryQueryIds = (ids) => {
|
|
114
|
+
Object.assign(NEWSLETTER_DIRECTORY_QUERY_IDS, ids);
|
|
115
|
+
return NEWSLETTER_DIRECTORY_QUERY_IDS;
|
|
116
|
+
};
|
|
117
|
+
const mexQuery = (variables, queryId, dataPath, deps) => executeWMexQuery(variables, queryId, dataPath, deps.query, deps.generateMessageTag);
|
|
118
|
+
const asInt = (value) => {
|
|
119
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
120
|
+
return value;
|
|
121
|
+
}
|
|
122
|
+
if (typeof value === 'string' && value !== '') {
|
|
123
|
+
const parsed = parseInt(value, 10);
|
|
124
|
+
return Number.isNaN(parsed) ? undefined : parsed;
|
|
125
|
+
}
|
|
126
|
+
return undefined;
|
|
127
|
+
};
|
|
128
|
+
const asText = (value) => typeof value?.text === 'string' ? value.text : undefined;
|
|
129
|
+
const asString = (value) => (typeof value === 'string' ? value : undefined);
|
|
130
|
+
/**
|
|
131
|
+
* The `fetch_*` flags both directory queries carry, exactly as the app sets
|
|
132
|
+
* them (see the header comment). `fetchStatusMetadata` drives the two flags
|
|
133
|
+
* the app takes from its status-infra config.
|
|
134
|
+
*/
|
|
135
|
+
const directoryFetchFlags = (fetchStatusMetadata) => ({
|
|
136
|
+
fetch_state: false,
|
|
137
|
+
fetch_creation_time: true,
|
|
138
|
+
fetch_name: true,
|
|
139
|
+
fetch_image: false,
|
|
140
|
+
fetch_preview: true,
|
|
141
|
+
fetch_description: false,
|
|
142
|
+
fetch_invite: true,
|
|
143
|
+
fetch_handle: false,
|
|
144
|
+
fetch_followers_count: true,
|
|
145
|
+
fetch_verification: true,
|
|
146
|
+
fetch_viewer_metadata: false,
|
|
147
|
+
fetch_settings: false,
|
|
148
|
+
fetch_wamo_sub: false,
|
|
149
|
+
fetch_status_metadata: fetchStatusMetadata,
|
|
150
|
+
fetch_refresh_after_interval: fetchStatusMetadata,
|
|
151
|
+
fetch_pinned_messages: false
|
|
152
|
+
});
|
|
153
|
+
const assertValidLimit = (limit) => {
|
|
154
|
+
if (!Number.isInteger(limit) || limit <= 0) {
|
|
155
|
+
throw new Boom('newsletter directory limit must be a positive integer', { statusCode: 400 });
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
const assertValidCategory = (category) => {
|
|
159
|
+
if (category !== undefined && !NEWSLETTER_DIRECTORY_CATEGORIES.includes(category)) {
|
|
160
|
+
throw new Boom(`unknown newsletter directory category: ${category}`, { statusCode: 400 });
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
const assertValidView = (view) => {
|
|
164
|
+
if (view !== undefined && !NEWSLETTER_DIRECTORY_VIEWS.includes(view)) {
|
|
165
|
+
throw new Boom(`unknown newsletter directory view: ${view}`, { statusCode: 400 });
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
/** Parse one raw directory entry (see the header comment for the shape). */
|
|
169
|
+
export const parseNewsletterDirectoryEntry = (raw) => {
|
|
170
|
+
if (typeof raw !== 'object' || raw === null) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
const entry = raw;
|
|
174
|
+
if (typeof entry.id !== 'string' || !entry.id) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
const thread = entry.thread_metadata ?? {};
|
|
178
|
+
const viewer = entry.viewer_metadata ?? {};
|
|
179
|
+
const status = entry.status_metadata ?? {};
|
|
180
|
+
return {
|
|
181
|
+
id: entry.id,
|
|
182
|
+
name: asText(thread.name),
|
|
183
|
+
description: asText(thread.description),
|
|
184
|
+
handle: asString(thread.handle),
|
|
185
|
+
invite: asString(thread.invite),
|
|
186
|
+
followersCount: asInt(thread.followers_count),
|
|
187
|
+
creationTime: asInt(thread.creation_time),
|
|
188
|
+
verification: asString(thread.verification),
|
|
189
|
+
picture: thread.picture
|
|
190
|
+
? {
|
|
191
|
+
id: asString(thread.picture.id),
|
|
192
|
+
directPath: asString(thread.picture.direct_path),
|
|
193
|
+
url: asString(thread.picture.url)
|
|
194
|
+
}
|
|
195
|
+
: undefined,
|
|
196
|
+
preview: thread.preview
|
|
197
|
+
? {
|
|
198
|
+
id: asString(thread.preview.id),
|
|
199
|
+
directPath: asString(thread.preview.direct_path)
|
|
200
|
+
}
|
|
201
|
+
: undefined,
|
|
202
|
+
viewerRole: asString(viewer.role),
|
|
203
|
+
state: asString(entry.state?.type),
|
|
204
|
+
refreshAfterIntervalSec: asInt(entry.refresh_after_interval_sec),
|
|
205
|
+
lastStatusSentTime: asInt(status.last_status_sent_time),
|
|
206
|
+
lastStatusServerId: asString(status.last_status_server_id)
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
/** Parse a raw directory page (`page_info` / `result` / `vertical_metadata`). */
|
|
210
|
+
export const parseNewsletterDirectoryResult = (raw) => {
|
|
211
|
+
const data = (typeof raw === 'object' && raw !== null ? raw : {});
|
|
212
|
+
const entries = Array.isArray(data.result)
|
|
213
|
+
? data.result.map(parseNewsletterDirectoryEntry).filter((entry) => entry !== null)
|
|
214
|
+
: [];
|
|
215
|
+
const verticals = Array.isArray(data.vertical_metadata)
|
|
216
|
+
? data.vertical_metadata
|
|
217
|
+
.map((vertical) => {
|
|
218
|
+
if (typeof vertical !== 'object' || vertical === null) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
const rawVertical = vertical;
|
|
222
|
+
if (typeof rawVertical.vertical !== 'string' || !rawVertical.vertical) {
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
return {
|
|
226
|
+
vertical: rawVertical.vertical,
|
|
227
|
+
title: asString(rawVertical.vertical_title),
|
|
228
|
+
newsletterIds: Array.isArray(rawVertical.newsletter_ids)
|
|
229
|
+
? rawVertical.newsletter_ids.filter((id) => typeof id === 'string')
|
|
230
|
+
: []
|
|
231
|
+
};
|
|
232
|
+
})
|
|
233
|
+
.filter((vertical) => vertical !== null)
|
|
234
|
+
: [];
|
|
235
|
+
return {
|
|
236
|
+
entries,
|
|
237
|
+
endCursor: asString(data.page_info?.endCursor),
|
|
238
|
+
verticals
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Search the channel directory by text, like the app's Channels > Explore
|
|
243
|
+
* search. Page with `startCursor` from the previous result's `endCursor`.
|
|
244
|
+
*/
|
|
245
|
+
export const newsletterDirectorySearch = async (query, options = {}, deps) => {
|
|
246
|
+
if (typeof query !== 'string' || query.trim() === '') {
|
|
247
|
+
throw new Boom('newsletterDirectorySearch requires a non-empty query', { statusCode: 400 });
|
|
248
|
+
}
|
|
249
|
+
assertValidCategory(options.category);
|
|
250
|
+
const limit = options.limit ?? NEWSLETTER_DIRECTORY_DEFAULT_LIMIT;
|
|
251
|
+
assertValidLimit(limit);
|
|
252
|
+
const variables = {
|
|
253
|
+
input: {
|
|
254
|
+
search_text: query,
|
|
255
|
+
categories: options.category ? [options.category] : null,
|
|
256
|
+
limit,
|
|
257
|
+
start_cursor: options.startCursor ?? null
|
|
258
|
+
},
|
|
259
|
+
...directoryFetchFlags(options.fetchStatusMetadata ?? false)
|
|
260
|
+
};
|
|
261
|
+
const raw = await mexQuery(variables, NEWSLETTER_DIRECTORY_QUERY_IDS.SEARCH, NEWSLETTER_DIRECTORY_DATA_PATHS.SEARCH, deps);
|
|
262
|
+
return parseNewsletterDirectoryResult(raw);
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Browse (list) the channel directory — the Explore page — for one view
|
|
266
|
+
* (FEATURED / NEW / POPULAR / RECOMMENDED / TRENDING), optionally narrowed
|
|
267
|
+
* by category and/or country. Page with `startCursor` from the previous
|
|
268
|
+
* result's `endCursor`.
|
|
269
|
+
*/
|
|
270
|
+
export const newsletterDirectoryList = async (options = {}, deps) => {
|
|
271
|
+
assertValidView(options.view);
|
|
272
|
+
assertValidCategory(options.category);
|
|
273
|
+
const limit = options.limit ?? NEWSLETTER_DIRECTORY_DEFAULT_LIMIT;
|
|
274
|
+
assertValidLimit(limit);
|
|
275
|
+
const variables = {
|
|
276
|
+
input: {
|
|
277
|
+
filters: {
|
|
278
|
+
categories: options.category ? [options.category] : null,
|
|
279
|
+
country_codes: options.countryCode ? [options.countryCode] : null
|
|
280
|
+
},
|
|
281
|
+
limit,
|
|
282
|
+
start_cursor: options.startCursor ?? null,
|
|
283
|
+
use_personalization: options.usePersonalization ?? true,
|
|
284
|
+
view: options.view ?? NEWSLETTER_DIRECTORY_DEFAULT_VIEW
|
|
285
|
+
},
|
|
286
|
+
...directoryFetchFlags(options.fetchStatusMetadata ?? false)
|
|
287
|
+
};
|
|
288
|
+
const raw = await mexQuery(variables, NEWSLETTER_DIRECTORY_QUERY_IDS.LIST, NEWSLETTER_DIRECTORY_DATA_PATHS.LIST, deps);
|
|
289
|
+
return parseNewsletterDirectoryResult(raw);
|
|
290
|
+
};
|
|
291
|
+
//# sourceMappingURL=newsletterDirectory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"newsletterDirectory.js","sourceRoot":"","sources":["../../src/Socket/newsletterDirectory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AAEH,iEAAiE;AACjE,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC9C,UAAU;IACV,eAAe;IACf,WAAW;IACX,MAAM;IACN,eAAe;IACf,QAAQ;IACR,QAAQ;IACR,gBAAgB;IAChB,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAClB,SAAS;CACA,CAAA;AAIV,uDAAuD;AACvD,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,CAAU,CAAA;AAI5G;;;;;GAKG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC7C,MAAM,EAAE,mBAAmB;IAC3B,IAAI,EAAE,mBAAmB;CACzB,CAAA;AAID,4EAA4E;AAC5E,MAAM,CAAC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AAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI;gBACxD,aAAa,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI;aACjE;YACD,KAAK;YACL,YAAY,EAAE,OAAO,CAAC,WAAW,IAAI,IAAI;YACzC,mBAAmB,EAAE,OAAO,CAAC,kBAAkB,IAAI,IAAI;YACvD,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,iCAAiC;SACvD;QACD,GAAG,mBAAmB,CAAC,OAAO,CAAC,mBAAmB,IAAI,KAAK,CAAC;KAC5D,CAAA;IACD,MAAM,GAAG,GAAG,MAAM,QAAQ,CACzB,SAAS,EACT,8BAA8B,CAAC,IAAI,EACnC,+BAA+B,CAAC,IAAI,EACpC,IAAI,CACJ,CAAA;IACD,OAAO,8BAA8B,CAAC,GAAG,CAAC,CAAA;AAC3C,CAAC,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { proto } from '../../WAProto/index.js';
|
|
2
|
+
import type { PaymentInviteOptions, PaymentResult, RequestPaymentOptions, SendPaymentOptions } from '../Types/index.js';
|
|
3
|
+
import type { WAMessageKey } from '../Types/index.js';
|
|
4
|
+
export type PaymentDeps = {
|
|
5
|
+
relayMessage: (jid: string, message: proto.IMessage, opts: {
|
|
6
|
+
messageId: string;
|
|
7
|
+
}) => Promise<unknown>;
|
|
8
|
+
userJid?: string;
|
|
9
|
+
meJid?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Request a payment — sends a `requestPaymentMessage` card with the amount,
|
|
13
|
+
* currency and an optional note. The amount is given in the currency's
|
|
14
|
+
* major units (500 = 500 KES); it is sent as `amount1000` (thousandths)
|
|
15
|
+
* and as a `Money` value in the currency's minor units.
|
|
16
|
+
*
|
|
17
|
+
* This only sends the request message. Moving money still needs a payment
|
|
18
|
+
* provider (WhatsApp Pay / UPI / M-Pesa); the library does not settle it.
|
|
19
|
+
*/
|
|
20
|
+
export declare const requestPayment: (jid: string, options: RequestPaymentOptions, deps: PaymentDeps) => Promise<PaymentResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Mark a payment as sent against a request — a `sendPaymentMessage`
|
|
23
|
+
* referencing the request's key. `transactionData` is the opaque data
|
|
24
|
+
* from the payment provider; without a provider it is just a note that
|
|
25
|
+
* the payment was made.
|
|
26
|
+
*/
|
|
27
|
+
export declare const sendPayment: (jid: string, options: SendPaymentOptions, deps: PaymentDeps) => Promise<PaymentResult>;
|
|
28
|
+
/** Decline a payment request, referencing it by its message key. */
|
|
29
|
+
export declare const declinePaymentRequest: (jid: string, requestMessageKey: WAMessageKey, deps: PaymentDeps) => Promise<PaymentResult>;
|
|
30
|
+
/** Cancel your own payment request, referencing it by its message key. */
|
|
31
|
+
export declare const cancelPaymentRequest: (jid: string, requestMessageKey: WAMessageKey, deps: PaymentDeps) => Promise<PaymentResult>;
|
|
32
|
+
/**
|
|
33
|
+
* Invite someone to a payment service — a `paymentInviteMessage` card.
|
|
34
|
+
* serviceType: 1 = FBPAY, 2 = NOVI, 3 = UPI.
|
|
35
|
+
*/
|
|
36
|
+
export declare const sendPaymentInvite: (jid: string, options: PaymentInviteOptions | undefined, deps: PaymentDeps) => Promise<PaymentResult>;
|
|
37
|
+
//# sourceMappingURL=payment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../../src/Socket/payment.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAC9C,OAAO,KAAK,EAEX,oBAAoB,EACpB,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGrD,MAAM,MAAM,WAAW,GAAG;IACzB,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IACrG,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AA4CD;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAC1B,KAAK,MAAM,EACX,SAAS,qBAAqB,EAC9B,MAAM,WAAW,KACf,OAAO,CAAC,aAAa,CAgCvB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GACvB,KAAK,MAAM,EACX,SAAS,kBAAkB,EAC3B,MAAM,WAAW,KACf,OAAO,CAAC,aAAa,CAiBvB,CAAA;AAED,oEAAoE;AACpE,eAAO,MAAM,qBAAqB,GACjC,KAAK,MAAM,EACX,mBAAmB,YAAY,EAC/B,MAAM,WAAW,KACf,OAAO,CAAC,aAAa,CAMvB,CAAA;AAED,0EAA0E;AAC1E,eAAO,MAAM,oBAAoB,GAChC,KAAK,MAAM,EACX,mBAAmB,YAAY,EAC/B,MAAM,WAAW,KACf,OAAO,CAAC,aAAa,CAMvB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC7B,KAAK,MAAM,EACX,SAAS,oBAAoB,YAAK,EAClC,MAAM,WAAW,KACf,OAAO,CAAC,aAAa,CAavB,CAAA"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
import crypto from 'crypto';
|
|
3
|
+
import { proto } from '../../WAProto/index.js';
|
|
4
|
+
import { generateWAMessageFromContent, unixTimestampSeconds } from '../Utils/index.js';
|
|
5
|
+
/** Currencies with no minor unit (0 decimals) or three decimals; everything else defaults to 2. */
|
|
6
|
+
const CURRENCY_DECIMALS = {
|
|
7
|
+
JPY: 0,
|
|
8
|
+
KRW: 0,
|
|
9
|
+
VND: 0,
|
|
10
|
+
CLP: 0,
|
|
11
|
+
ISK: 0,
|
|
12
|
+
UGX: 0,
|
|
13
|
+
XAF: 0,
|
|
14
|
+
XOF: 0,
|
|
15
|
+
BHD: 3,
|
|
16
|
+
IQD: 3,
|
|
17
|
+
JOD: 3,
|
|
18
|
+
KWD: 3,
|
|
19
|
+
LYD: 3,
|
|
20
|
+
OMR: 3,
|
|
21
|
+
TND: 3
|
|
22
|
+
};
|
|
23
|
+
const decimalsFor = (currency) => CURRENCY_DECIMALS[currency.toUpperCase()] ?? 2;
|
|
24
|
+
/** The app lets a payment request live for 7 days. */
|
|
25
|
+
const PAYMENT_REQUEST_TTL_MS = 7 * 24 * 60 * 60 * 1000;
|
|
26
|
+
const toUnixSeconds = (value, fallbackMs) => {
|
|
27
|
+
if (value instanceof Date)
|
|
28
|
+
return Math.floor(value.getTime() / 1000);
|
|
29
|
+
if (typeof value === 'number')
|
|
30
|
+
return Math.floor(value / 1000);
|
|
31
|
+
return Math.floor(fallbackMs / 1000);
|
|
32
|
+
};
|
|
33
|
+
const defaultBackground = (background) => background ?? { id: 'DEFAULT', placeholderArgb: 0xfff0f0f0 };
|
|
34
|
+
const send = async (jid, content, deps) => {
|
|
35
|
+
const messageSecret = crypto.randomBytes(32);
|
|
36
|
+
const wrapped = generateWAMessageFromContent(jid, { messageContextInfo: { messageSecret }, ...content }, {
|
|
37
|
+
userJid: deps.userJid
|
|
38
|
+
});
|
|
39
|
+
await deps.relayMessage(jid, wrapped.message, { messageId: wrapped.key.id });
|
|
40
|
+
return { message: wrapped };
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Request a payment — sends a `requestPaymentMessage` card with the amount,
|
|
44
|
+
* currency and an optional note. The amount is given in the currency's
|
|
45
|
+
* major units (500 = 500 KES); it is sent as `amount1000` (thousandths)
|
|
46
|
+
* and as a `Money` value in the currency's minor units.
|
|
47
|
+
*
|
|
48
|
+
* This only sends the request message. Moving money still needs a payment
|
|
49
|
+
* provider (WhatsApp Pay / UPI / M-Pesa); the library does not settle it.
|
|
50
|
+
*/
|
|
51
|
+
export const requestPayment = async (jid, options, deps) => {
|
|
52
|
+
if (!options.amount || options.amount <= 0) {
|
|
53
|
+
throw new Boom('payment request needs an amount greater than 0', { statusCode: 400 });
|
|
54
|
+
}
|
|
55
|
+
if (!options.currency) {
|
|
56
|
+
throw new Boom('payment request needs a currency code', { statusCode: 400 });
|
|
57
|
+
}
|
|
58
|
+
const decimals = decimalsFor(options.currency);
|
|
59
|
+
const currencyCode = options.currency.toUpperCase();
|
|
60
|
+
const noteMessage = options.note ? { extendedTextMessage: { text: options.note } } : undefined;
|
|
61
|
+
return send(jid, {
|
|
62
|
+
requestPaymentMessage: {
|
|
63
|
+
currencyCodeIso4217: currencyCode,
|
|
64
|
+
amount1000: Math.round(options.amount * 1000),
|
|
65
|
+
requestFrom: options.from || deps.meJid || deps.userJid || '',
|
|
66
|
+
expiryTimestamp: toUnixSeconds(options.expiry, Date.now() + PAYMENT_REQUEST_TTL_MS),
|
|
67
|
+
amount: {
|
|
68
|
+
value: Math.round(options.amount * 10 ** decimals),
|
|
69
|
+
offset: decimals,
|
|
70
|
+
currencyCode
|
|
71
|
+
},
|
|
72
|
+
noteMessage,
|
|
73
|
+
background: defaultBackground(options.background)
|
|
74
|
+
}
|
|
75
|
+
}, deps);
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Mark a payment as sent against a request — a `sendPaymentMessage`
|
|
79
|
+
* referencing the request's key. `transactionData` is the opaque data
|
|
80
|
+
* from the payment provider; without a provider it is just a note that
|
|
81
|
+
* the payment was made.
|
|
82
|
+
*/
|
|
83
|
+
export const sendPayment = async (jid, options, deps) => {
|
|
84
|
+
if (!options.requestMessageKey?.id) {
|
|
85
|
+
throw new Boom('sendPayment needs the key of the payment request', { statusCode: 400 });
|
|
86
|
+
}
|
|
87
|
+
return send(jid, {
|
|
88
|
+
sendPaymentMessage: {
|
|
89
|
+
requestMessageKey: options.requestMessageKey,
|
|
90
|
+
noteMessage: options.note ? { extendedTextMessage: { text: options.note } } : undefined,
|
|
91
|
+
background: defaultBackground(options.background),
|
|
92
|
+
transactionData: options.transactionData
|
|
93
|
+
}
|
|
94
|
+
}, deps);
|
|
95
|
+
};
|
|
96
|
+
/** Decline a payment request, referencing it by its message key. */
|
|
97
|
+
export const declinePaymentRequest = async (jid, requestMessageKey, deps) => {
|
|
98
|
+
if (!requestMessageKey?.id) {
|
|
99
|
+
throw new Boom('declinePaymentRequest needs the key of the payment request', { statusCode: 400 });
|
|
100
|
+
}
|
|
101
|
+
return send(jid, { declinePaymentRequestMessage: { key: requestMessageKey } }, deps);
|
|
102
|
+
};
|
|
103
|
+
/** Cancel your own payment request, referencing it by its message key. */
|
|
104
|
+
export const cancelPaymentRequest = async (jid, requestMessageKey, deps) => {
|
|
105
|
+
if (!requestMessageKey?.id) {
|
|
106
|
+
throw new Boom('cancelPaymentRequest needs the key of the payment request', { statusCode: 400 });
|
|
107
|
+
}
|
|
108
|
+
return send(jid, { cancelPaymentRequestMessage: { key: requestMessageKey } }, deps);
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Invite someone to a payment service — a `paymentInviteMessage` card.
|
|
112
|
+
* serviceType: 1 = FBPAY, 2 = NOVI, 3 = UPI.
|
|
113
|
+
*/
|
|
114
|
+
export const sendPaymentInvite = async (jid, options = {}, deps) => {
|
|
115
|
+
return send(jid, {
|
|
116
|
+
paymentInviteMessage: {
|
|
117
|
+
serviceType: options.serviceType ?? 3,
|
|
118
|
+
expiryTimestamp: options.expiry
|
|
119
|
+
? toUnixSeconds(options.expiry, 0)
|
|
120
|
+
: unixTimestampSeconds() + Math.floor(PAYMENT_REQUEST_TTL_MS / 1000)
|
|
121
|
+
}
|
|
122
|
+
}, deps);
|
|
123
|
+
};
|
|
124
|
+
//# sourceMappingURL=payment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment.js","sourceRoot":"","sources":["../../src/Socket/payment.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,MAAM;gBAC9B,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;gBAClC,CAAC,CAAC,oBAAoB,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,sBAAsB,GAAG,IAAI,CAAC;SACrE;KACD,EACD,IAAI,CACJ,CAAA;AACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { WAMessage } from '../Types/Message.js';
|
|
2
|
+
import { type SpamReportOptions, type SpamReportResult, type SpamReportTargetResult } from '../Types/Report.js';
|
|
3
|
+
import { type BinaryNode } from '../WABinary/index.js';
|
|
4
|
+
export type ReportDeps = {
|
|
5
|
+
query: (node: BinaryNode) => Promise<BinaryNode>;
|
|
6
|
+
meJid?: string;
|
|
7
|
+
updateBlockStatus?: (jid: string, action: 'block' | 'unblock') => Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Build the report IQ for one message. Shape from whatsapp-rust (the only
|
|
11
|
+
* public client that sends one) plus the official app's flow strings and
|
|
12
|
+
* `wi_trace_id`:
|
|
13
|
+
*
|
|
14
|
+
* <iq xmlns="spam" type="set" to="s.whatsapp.net">
|
|
15
|
+
* <spam_list spam_flow="…" wi_trace_id="…" [jid="…"] [source="…"] [subject="…"]>
|
|
16
|
+
* <message id="…" t="…" from="…">
|
|
17
|
+
* <raw v="3" mediatype="…">…</raw>
|
|
18
|
+
* </message>
|
|
19
|
+
* </spam_list>
|
|
20
|
+
* </iq>
|
|
21
|
+
*
|
|
22
|
+
* The `<raw>` bytes are the whitelisted-field content the reporting token is
|
|
23
|
+
* an HMAC over, so the server can verify the reported content. The token
|
|
24
|
+
* itself is NOT sent here — it was attached to the original message.
|
|
25
|
+
* The `source` attribute (the reported member inside a group) and the `jid`
|
|
26
|
+
* attribute come from the app's own spam report builder (`J9G`).
|
|
27
|
+
*/
|
|
28
|
+
export declare const buildSpamReportNode: (message: WAMessage, options: SpamReportOptions, meJid?: string) => BinaryNode;
|
|
29
|
+
/**
|
|
30
|
+
* Build the report IQ for a target JID (contact, group, channel) with no
|
|
31
|
+
* fixed message list: the `spam_list` carries the target `jid` plus the
|
|
32
|
+
* flow, `source` (reported member inside a group) and `subject`, and any
|
|
33
|
+
* messages passed in `options.messages`. This is the shape the app sends
|
|
34
|
+
* for an overflow-menu report, whose default flow is `overflow_menu_report`.
|
|
35
|
+
*/
|
|
36
|
+
export declare const buildTargetReportNode: (jid: string, options?: SpamReportOptions, meJid?: string) => BinaryNode;
|
|
37
|
+
/**
|
|
38
|
+
* Report one or more messages (one spam IQ per message — the only shape
|
|
39
|
+
* demonstrated in public code). Returns the server's `report_id` per
|
|
40
|
+
* message. The reported account receives nothing; the report goes only to
|
|
41
|
+
* the server for review.
|
|
42
|
+
*/
|
|
43
|
+
export declare const reportSpam: (messages: WAMessage[], deps: ReportDeps, options?: SpamReportOptions) => Promise<SpamReportResult[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Report a target by JID (contact, group, channel) in a single IQ — the
|
|
46
|
+
* overflow-menu report shape. `options.flow` picks the flow (default
|
|
47
|
+
* `overflow_menu_report`); `options.source` names the reported member
|
|
48
|
+
* inside a group; `options.messages` attaches messages to the report.
|
|
49
|
+
* Returns one summary: the target, the flow, whether the server accepted
|
|
50
|
+
* it, the `report_id`, and the stanza that was sent.
|
|
51
|
+
*/
|
|
52
|
+
export declare const reportTarget: (jid: string, deps: ReportDeps, options?: SpamReportOptions) => Promise<SpamReportTargetResult>;
|
|
53
|
+
/** Report a 1:1 contact (flow `chat`). */
|
|
54
|
+
export declare const reportContact: (jid: string, messages: WAMessage[], deps: ReportDeps, options?: SpamReportOptions) => Promise<SpamReportResult[]>;
|
|
55
|
+
/** Report a group (flow `group_info_report`). */
|
|
56
|
+
export declare const reportGroup: (jid: string, messages: WAMessage[], deps: ReportDeps, options?: SpamReportOptions) => Promise<SpamReportResult[]>;
|
|
57
|
+
/** Report a personal status post (flow `status_post_report`). */
|
|
58
|
+
export declare const reportStatus: (jid: string, messages: WAMessage[], deps: ReportDeps, options?: SpamReportOptions) => Promise<SpamReportResult[]>;
|
|
59
|
+
/** Report a channel / newsletter (flow `newsletter_info_report`). */
|
|
60
|
+
export declare const reportNewsletter: (jid: string, messages: WAMessage[], deps: ReportDeps, options?: SpamReportOptions) => Promise<SpamReportResult[]>;
|
|
61
|
+
/** Report a channel status (flow `channel_status_report`). */
|
|
62
|
+
export declare const reportChannelStatus: (jid: string, messages: WAMessage[], deps: ReportDeps, options?: SpamReportOptions) => Promise<SpamReportResult[]>;
|
|
63
|
+
/** Report an event (flow `event_info_report`). */
|
|
64
|
+
export declare const reportEvent: (jid: string, messages: WAMessage[], deps: ReportDeps, options?: SpamReportOptions) => Promise<SpamReportResult[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Report a contact and block them — the "Report and block" dialog action.
|
|
67
|
+
* The report and the block are separate IQs; reporting alone blocks nobody.
|
|
68
|
+
*/
|
|
69
|
+
export declare const reportAndBlock: (jid: string, messages: WAMessage[], deps: ReportDeps, options?: SpamReportOptions) => Promise<SpamReportResult[]>;
|
|
70
|
+
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../src/Socket/report.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAGN,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAAE,KAAK,UAAU,EAAkD,MAAM,aAAa,CAAA;AAE7F,MAAM,MAAM,UAAU,GAAG;IACxB,KAAK,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;IAChD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM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