jagproject 26.3.22 → 26.3.25
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/WAProto/GenerateStatics.sh +3 -4
- package/WAProto/WAProto.proto +1215 -511
- package/WAProto/fix-imports.js +73 -0
- package/WAProto/index.d.ts +14017 -0
- package/WAProto/index.js +64857 -145167
- package/engine-requirements.js +4 -7
- package/lib/Defaults/index.d.ts +74 -0
- package/lib/Defaults/index.js +51 -33
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Defaults/wileys-version.json +2 -2
- package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
- package/lib/Signal/Group/group-session-builder.d.ts +15 -0
- package/lib/Signal/Group/group-session-builder.js +5 -3
- package/lib/Signal/Group/group_cipher.d.ts +17 -0
- package/lib/Signal/Group/group_cipher.js +35 -46
- package/lib/Signal/Group/index.d.ts +12 -0
- package/lib/Signal/Group/index.js +21 -21
- package/lib/Signal/Group/keyhelper.d.ts +11 -0
- package/lib/Signal/Group/keyhelper.js +2 -2
- package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
- package/lib/Signal/Group/sender-chain-key.js +5 -10
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +7 -7
- package/lib/Signal/Group/sender-key-message.d.ts +19 -0
- package/lib/Signal/Group/sender-key-message.js +8 -8
- package/lib/Signal/Group/sender-key-name.d.ts +18 -0
- package/lib/Signal/Group/sender-key-record.d.ts +31 -0
- package/lib/Signal/Group/sender-key-record.js +7 -16
- package/lib/Signal/Group/sender-key-state.d.ts +39 -0
- package/lib/Signal/Group/sender-key-state.js +25 -37
- package/lib/Signal/Group/sender-message-key.d.ts +12 -0
- package/lib/Signal/Group/sender-message-key.js +2 -2
- package/lib/Signal/libsignal.d.ts +5 -0
- package/lib/Signal/libsignal.js +358 -54
- package/lib/Signal/lid-mapping.d.ts +19 -0
- package/lib/Signal/lid-mapping.js +274 -0
- package/lib/Socket/Client/index.d.ts +3 -0
- package/lib/Socket/Client/index.js +2 -2
- package/lib/Socket/Client/types.d.ts +16 -0
- package/lib/Socket/Client/types.js +1 -0
- package/lib/Socket/Client/websocket.d.ts +13 -0
- package/lib/Socket/Client/websocket.js +18 -30
- package/lib/Socket/business.d.ts +202 -0
- package/lib/Socket/business.js +160 -38
- package/lib/Socket/chats.d.ts +111 -0
- package/lib/Socket/chats.js +497 -314
- package/lib/Socket/communities.d.ts +258 -0
- package/lib/Socket/communities.js +438 -0
- package/lib/Socket/community.js +333 -0
- package/lib/Socket/groups.d.ts +150 -0
- package/lib/Socket/groups.js +229 -91
- package/lib/Socket/index.d.ts +245 -0
- package/lib/Socket/index.js +9 -6
- package/lib/Socket/messages-recv.d.ts +187 -0
- package/lib/Socket/messages-recv.js +1105 -501
- package/lib/Socket/messages-send.d.ts +183 -0
- package/lib/Socket/messages-send.js +1184 -501
- package/lib/Socket/mex.d.ts +3 -0
- package/lib/Socket/mex.js +45 -0
- package/lib/Socket/newsletter.d.ts +160 -0
- package/lib/Socket/newsletter.js +227 -200
- package/lib/Socket/socket.d.ts +55 -0
- package/lib/Socket/socket.js +507 -206
- package/lib/Socket/usync.js +6 -6
- package/lib/Store/index.js +17 -5
- package/lib/Store/make-cache-manager-store.js +83 -0
- package/lib/Store/make-in-memory-store.js +48 -89
- package/lib/Store/make-ordered-dictionary.js +1 -1
- package/lib/Types/Auth.d.ts +116 -0
- package/lib/Types/Bussines.d.ts +25 -0
- package/lib/Types/Bussines.js +2 -0
- package/lib/Types/Call.d.ts +15 -0
- package/lib/Types/Chat.d.ts +123 -0
- package/lib/Types/Chat.js +7 -1
- package/lib/Types/Contact.d.ts +24 -0
- package/lib/Types/Events.d.ts +237 -0
- package/lib/Types/Events.js +1 -0
- package/lib/Types/GroupMetadata.d.ts +67 -0
- package/lib/Types/Label.d.ts +47 -0
- package/lib/Types/Label.js +1 -3
- package/lib/Types/LabelAssociation.d.ts +30 -0
- package/lib/Types/LabelAssociation.js +1 -3
- package/lib/Types/Message.d.ts +305 -0
- package/lib/Types/Message.js +9 -5
- package/lib/Types/MexUpdates.js +11 -0
- package/lib/Types/Newsletter.d.ts +135 -0
- package/lib/Types/Newsletter.js +36 -11
- package/lib/Types/Product.d.ts +79 -0
- package/lib/Types/Signal.d.ts +76 -0
- package/lib/Types/Signal.js +1 -0
- package/lib/Types/Socket.d.ts +133 -0
- package/lib/Types/Socket.js +1 -0
- package/lib/Types/State.d.ts +39 -0
- package/lib/Types/State.js +12 -0
- package/lib/Types/USync.d.ts +26 -0
- package/lib/Types/USync.js +1 -0
- package/lib/Types/index.d.ts +65 -0
- package/lib/Types/index.js +14 -14
- package/lib/Utils/audioToBuffer.js +31 -0
- package/lib/Utils/auth-utils.d.ts +19 -0
- package/lib/Utils/auth-utils.js +222 -123
- package/lib/Utils/baileys-event-stream.js +60 -0
- package/lib/Utils/browser-utils.d.ts +4 -0
- package/lib/Utils/browser-utils.js +38 -29
- package/lib/Utils/business.d.ts +23 -0
- package/lib/Utils/business.js +54 -48
- package/lib/Utils/chat-utils.d.ts +70 -0
- package/lib/Utils/chat-utils.js +284 -189
- package/lib/Utils/crypto.d.ts +37 -0
- package/lib/Utils/crypto.js +16 -41
- package/lib/Utils/decode-wa-message.d.ts +48 -0
- package/lib/Utils/decode-wa-message.js +128 -48
- package/lib/Utils/event-buffer.d.ts +34 -0
- package/lib/Utils/event-buffer.js +124 -62
- package/lib/Utils/generics.d.ts +91 -0
- package/lib/Utils/generics.js +154 -138
- package/lib/Utils/history.d.ts +22 -0
- package/lib/Utils/history.js +77 -34
- package/lib/Utils/identity-change-handler.d.ts +37 -0
- package/lib/Utils/identity-change-handler.js +54 -0
- package/lib/Utils/index.d.ts +22 -0
- package/lib/Utils/index.js +32 -19
- package/lib/Utils/link-preview.d.ts +21 -0
- package/lib/Utils/link-preview.js +12 -17
- package/lib/Utils/logger.d.ts +13 -0
- package/lib/Utils/lt-hash.d.ts +8 -0
- package/lib/Utils/lt-hash.js +2 -43
- package/lib/Utils/make-mutex.d.ts +9 -0
- package/lib/Utils/make-mutex.js +21 -27
- package/lib/Utils/message-retry-manager.d.ts +110 -0
- package/lib/Utils/message-retry-manager.js +143 -45
- package/lib/Utils/messages-media.d.ts +130 -0
- package/lib/Utils/messages-media.js +429 -502
- package/lib/Utils/messages-newsletter.d.ts +84 -0
- package/lib/Utils/messages-newsletter.js +295 -0
- package/lib/Utils/messages.d.ts +92 -0
- package/lib/Utils/messages.js +1099 -400
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/noise-handler.js +145 -91
- package/lib/Utils/pre-key-manager.d.ts +28 -0
- package/lib/Utils/pre-key-manager.js +112 -0
- package/lib/Utils/process-message.d.ts +60 -0
- package/lib/Utils/process-message.js +316 -184
- package/lib/Utils/reporting-utils.d.ts +11 -0
- package/lib/Utils/reporting-utils.js +262 -0
- package/lib/Utils/resolve-jid.d.ts +43 -0
- package/lib/Utils/resolve-jid.js +95 -0
- package/lib/Utils/serial-task-queue.js +29 -0
- package/lib/Utils/signal.d.ts +34 -0
- package/lib/Utils/signal.js +56 -39
- package/lib/Utils/streamToBuffer.js +17 -0
- package/lib/Utils/sync-action-utils.d.ts +19 -0
- package/lib/Utils/sync-action-utils.js +52 -0
- package/lib/Utils/tc-token-utils.d.ts +12 -0
- package/lib/Utils/tc-token-utils.js +20 -0
- package/lib/Utils/use-mongo-file-auth-state.js +71 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +13 -0
- package/lib/Utils/use-multi-file-auth-state.js +11 -12
- package/lib/Utils/use-single-file-auth-state.js +73 -0
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/lib/Utils/validate-connection.js +59 -82
- package/lib/Utils/wileys-event-stream.js +1 -61
- package/lib/WABinary/constants.d.ts +28 -0
- package/lib/WABinary/decode.d.ts +7 -0
- package/lib/WABinary/decode.js +39 -4
- package/lib/WABinary/encode.d.ts +3 -0
- package/lib/WABinary/encode.js +17 -11
- package/lib/WABinary/generic-utils.d.ts +15 -0
- package/lib/WABinary/generic-utils.js +46 -18
- package/lib/WABinary/index.d.ts +6 -0
- package/lib/WABinary/index.js +9 -5
- package/lib/WABinary/jid-utils.d.ts +48 -0
- package/lib/WABinary/jid-utils.js +67 -37
- package/lib/WABinary/types.d.ts +19 -0
- package/lib/WABinary/types.js +34 -0
- package/lib/WAM/BinaryInfo.d.ts +9 -0
- package/lib/WAM/constants.d.ts +40 -0
- package/lib/WAM/constants.js +19183 -11678
- package/lib/WAM/encode.d.ts +3 -0
- package/lib/WAM/encode.js +15 -17
- package/lib/WAM/index.d.ts +4 -0
- package/lib/WAM/index.js +3 -3
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +6 -6
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +9 -9
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +6 -6
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +7 -8
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +26 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +18 -17
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +11 -3
- package/lib/WAUSync/Protocols/index.d.ts +5 -0
- package/lib/WAUSync/Protocols/index.js +6 -4
- package/lib/WAUSync/USyncQuery.d.ts +29 -0
- package/lib/WAUSync/USyncQuery.js +38 -30
- package/lib/WAUSync/USyncUser.d.ts +13 -0
- package/lib/WAUSync/index.d.ts +4 -0
- package/lib/WAUSync/index.js +3 -3
- package/lib/index.d.ts +12 -0
- package/lib/index.js +3 -5
- package/package.json +10 -6
- package/readme.md +97 -0
- package/LICENSE +0 -21
|
@@ -1,63 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports
|
|
7
|
-
const events_1 = __importDefault(require("events"));
|
|
8
|
-
const fs_1 = require("fs");
|
|
9
|
-
const promises_1 = require("fs/promises");
|
|
10
|
-
const readline_1 = require("readline");
|
|
11
|
-
const generics_1 = require("./generics");
|
|
12
|
-
const make_mutex_1 = require("./make-mutex");
|
|
13
|
-
/**
|
|
14
|
-
* Captures events from a wileys event emitter & stores them in a file
|
|
15
|
-
* @param ev The event emitter to read events from
|
|
16
|
-
* @param filename File to save to
|
|
17
|
-
*/
|
|
18
|
-
const captureEventStream = (ev, filename) => {
|
|
19
|
-
const oldEmit = ev.emit;
|
|
20
|
-
// write mutex so data is appended in order
|
|
21
|
-
const writeMutex = (0, make_mutex_1.makeMutex)();
|
|
22
|
-
// monkey patch eventemitter to capture all events
|
|
23
|
-
ev.emit = function (...args) {
|
|
24
|
-
const content = JSON.stringify({ timestamp: Date.now(), event: args[0], data: args[1] }) + '\n';
|
|
25
|
-
const result = oldEmit.apply(ev, args);
|
|
26
|
-
writeMutex.mutex(async () => {
|
|
27
|
-
await (0, promises_1.writeFile)(filename, content, { flag: 'a' });
|
|
28
|
-
});
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
exports.captureEventStream = captureEventStream;
|
|
33
|
-
/**
|
|
34
|
-
* Read event file and emit events from there
|
|
35
|
-
* @param filename filename containing event data
|
|
36
|
-
* @param delayIntervalMs delay between each event emit
|
|
37
|
-
*/
|
|
38
|
-
const readAndEmitEventStream = (filename, delayIntervalMs = 0) => {
|
|
39
|
-
const ev = new events_1.default();
|
|
40
|
-
const fireEvents = async () => {
|
|
41
|
-
// from: https://stackoverflow.com/questions/6156501/read-a-file-one-line-at-a-time-in-node-js
|
|
42
|
-
const fileStream = (0, fs_1.createReadStream)(filename);
|
|
43
|
-
const rl = (0, readline_1.createInterface)({
|
|
44
|
-
input: fileStream,
|
|
45
|
-
crlfDelay: Infinity
|
|
46
|
-
});
|
|
47
|
-
// Note: we use the crlfDelay option to recognize all instances of CR LF
|
|
48
|
-
// ('\r\n') in input.txt as a single line break.
|
|
49
|
-
for await (const line of rl) {
|
|
50
|
-
if (line) {
|
|
51
|
-
const { event, data } = JSON.parse(line);
|
|
52
|
-
ev.emit(event, data);
|
|
53
|
-
delayIntervalMs && await (0, generics_1.delay)(delayIntervalMs);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
fileStream.close();
|
|
57
|
-
};
|
|
58
|
-
return {
|
|
59
|
-
ev,
|
|
60
|
-
task: fireEvents()
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
exports.readAndEmitEventStream = readAndEmitEventStream;
|
|
3
|
+
Object.assign(exports, require("./baileys-event-stream.js"));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const TAGS: {
|
|
2
|
+
LIST_EMPTY: number;
|
|
3
|
+
DICTIONARY_0: number;
|
|
4
|
+
DICTIONARY_1: number;
|
|
5
|
+
DICTIONARY_2: number;
|
|
6
|
+
DICTIONARY_3: number;
|
|
7
|
+
INTEROP_JID: number;
|
|
8
|
+
FB_JID: number;
|
|
9
|
+
AD_JID: number;
|
|
10
|
+
LIST_8: number;
|
|
11
|
+
LIST_16: number;
|
|
12
|
+
JID_PAIR: number;
|
|
13
|
+
HEX_8: number;
|
|
14
|
+
BINARY_8: number;
|
|
15
|
+
BINARY_20: number;
|
|
16
|
+
BINARY_32: number;
|
|
17
|
+
NIBBLE_8: number;
|
|
18
|
+
PACKED_MAX: number;
|
|
19
|
+
};
|
|
20
|
+
export declare const DOUBLE_BYTE_TOKENS: readonly [readonly ["read-self", "active", "fbns", "protocol", "reaction", "screen_width", "heartbeat", "deviceid", "2:47DEQpj8", "uploadfieldstat", "voip_settings", "retry", "priority", "longitude", "conflict", "false", "ig_professional", "replaced", "preaccept", "cover_photo", "uncompressed", "encopt", "ppic", "04", "passive", "status-revoke-drop", "keygen", "540", "offer", "rate", "opus", "latitude", "w:gp2", "ver", "4", "business_profile", "medium", "sender", "prev_v_id", "email", "website", "invited", "sign_credential", "05", "transport", "skey", "reason", "peer_abtest_bucket", "America/Sao_Paulo", "appid", "refresh", "100", "06", "404", "101", "104", "107", "102", "109", "103", "member_add_mode", "105", "transaction-id", "110", "106", "outgoing", "108", "111", "tokens", "followers", "ig_handle", "self_pid", "tue", "dec", "thu", "joinable", "peer_pid", "mon", "features", "wed", "peer_device_presence", "pn", "delete", "07", "fri", "audio_duration", "admin", "connected", "delta", "rcat", "disable", "collection", "08", "480", "sat", "phash", "all", "invite", "accept", "critical_unblock_low", "group_update", "signed_credential", "blinded_credential", "eph_setting", "net", "09", "background_location", "refresh_id", "Asia/Kolkata", "privacy_mode_ts", "account_sync", "voip_payload_type", "service_areas", "acs_public_key", "v_id", "0a", "fallback_class", "relay", "actual_actors", "metadata", "w:biz", "5", "connected-limit", "notice", "0b", "host_storage", "fb_page", "subject", "privatestats", "invis", "groupadd", "010", "note.m4r", "uuid", "0c", "8000", "sun", "372", "1020", "stage", "1200", "720", "canonical", "fb", "011", "video_duration", "0d", "1140", "superadmin", "012", "Opening.m4r", "keystore_attestation", "dleq_proof", "013", "timestamp", "ab_key", "w:sync:app:state", "0e", "vertical", "600", "p_v_id", "6", "likes", "014", "500", "1260", "creator", "0f", "rte", "destination", "group", "group_info", "syncd_anti_tampering_fatal_exception_enabled", "015", "dl_bw", "Asia/Jakarta", "vp8/h.264", "online", "1320", "fb:multiway", "10", "timeout", "016", "nse_retry", "urn:xmpp:whatsapp:dirty", "017", "a_v_id", "web_shops_chat_header_button_enabled", "nse_call", "inactive-upgrade", "none", "web", "groups", "2250", "mms_hot_content_timespan_in_seconds", "contact_blacklist", "nse_read", "suspended_group_deletion_notification", "binary_version", "018", "https://www.whatsapp.com/otp/copy/", "reg_push", "shops_hide_catalog_attachment_entrypoint", "server_sync", ".", "ephemeral_messages_allowed_values", "019", "mms_vcache_aggregation_enabled", "iphone", "America/Argentina/Buenos_Aires", "01a", "mms_vcard_autodownload_size_kb", "nse_ver", "shops_header_dropdown_menu_item", "dhash", "catalog_status", "communities_mvp_new_iqs_serverprop", "blocklist", "default", "11", "ephemeral_messages_enabled", "01b", "original_dimensions", "8", "mms4_media_retry_notification_encryption_enabled", "mms4_server_error_receipt_encryption_enabled", "original_image_url", "sync", "multiway", "420", "companion_enc_static", "shops_profile_drawer_entrypoint", "01c", "vcard_as_document_size_kb", "status_video_max_duration", "request_image_url", "01d", "regular_high", "s_t", "abt", "share_ext_min_preliminary_image_quality", "01e", "32", "syncd_key_rotation_enabled", "data_namespace", "md_downgrade_read_receipts2", "patch", "polltype", "ephemeral_messages_setting", "userrate", "15", "partial_pjpeg_bw_threshold", "played-self", "catalog_exists", "01f", "mute_v2"], readonly ["reject", "dirty", "announcement", "020", "13", "9", "status_video_max_bitrate", "fb:thrift_iq", "offline_batch", "022", "full", "ctwa_first_business_reply_logging", "h.264", "smax_id", "group_description_length", "https://www.whatsapp.com/otp/code", "status_image_max_edge", "smb_upsell_business_profile_enabled", "021", "web_upgrade_to_md_modal", "14", "023", "s_o", "smaller_video_thumbs_status_enabled", "media_max_autodownload", "960", "blocking_status", "peer_msg", "joinable_group_call_client_version", "group_call_video_maximization_enabled", "return_snapshot", "high", "America/Mexico_City", "entry_point_block_logging_enabled", "pop", "024", "1050", "16", "1380", "one_tap_calling_in_group_chat_size", "regular_low", "inline_joinable_education_enabled", "hq_image_max_edge", "locked", "America/Bogota", "smb_biztools_deeplink_enabled", "status_image_quality", "1088", "025", "payments_upi_intent_transaction_limit", "voip", "w:g2", "027", "md_pin_chat_enabled", "026", "multi_scan_pjpeg_download_enabled", "shops_product_grid", "transaction_id", "ctwa_context_enabled", "20", "fna", "hq_image_quality", "alt_jpeg_doc_detection_quality", "group_call_max_participants", "pkey", "America/Belem", "image_max_kbytes", "web_cart_v1_1_order_message_changes_enabled", "ctwa_context_enterprise_enabled", "urn:xmpp:whatsapp:account", "840", "Asia/Kuala_Lumpur", "max_participants", "video_remux_after_repair_enabled", "stella_addressbook_restriction_type", "660", "900", "780", "context_menu_ios13_enabled", "mute-state", "ref", "payments_request_messages", "029", "frskmsg", "vcard_max_size_kb", "sample_buffer_gif_player_enabled", "match_last_seen", "510", "4983", "video_max_bitrate", "028", "w:comms:chat", "17", "frequently_forwarded_max", "groups_privacy_blacklist", "Asia/Karachi", "02a", "web_download_document_thumb_mms_enabled", "02b", "hist_sync", "biz_block_reasons_version", "1024", "18", "web_is_direct_connection_for_plm_transparent", "view_once_write", "file_max_size", "paid_convo_id", "online_privacy_setting", "video_max_edge", "view_once_read", "enhanced_storage_management", "multi_scan_pjpeg_encoding_enabled", "ctwa_context_forward_enabled", "video_transcode_downgrade_enable", "template_doc_mime_types", "hq_image_bw_threshold", "30", "body", "u_aud_limit_sil_restarts_ctrl", "other", "participating", "w:biz:directory", "1110", "vp8", "4018", "meta", "doc_detection_image_max_edge", "image_quality", "1170", "02c", "smb_upsell_chat_banner_enabled", "key_expiry_time_second", "pid", "stella_interop_enabled", "19", "linked_device_max_count", "md_device_sync_enabled", "02d", "02e", "360", "enhanced_block_enabled", "ephemeral_icon_in_forwarding", "paid_convo_status", "gif_provider", "project_name", "server-error", "canonical_url_validation_enabled", "wallpapers_v2", "syncd_clear_chat_delete_chat_enabled", "medianotify", "02f", "shops_required_tos_version", "vote", "reset_skey_on_id_change", "030", "image_max_edge", "multicast_limit_global", "ul_bw", "21", "25", "5000", "poll", "570", "22", "031", "1280", "WhatsApp", "032", "bloks_shops_enabled", "50", "upload_host_switching_enabled", "web_ctwa_context_compose_enabled", "ptt_forwarded_features_enabled", "unblocked", "partial_pjpeg_enabled", "fbid:devices", "height", "ephemeral_group_query_ts", "group_join_permissions", "order", "033", "alt_jpeg_status_quality", "migrate", "popular-bank", "win_uwp_deprecation_killswitch_enabled", "web_download_status_thumb_mms_enabled", "blocking", "url_text", "035", "web_forwarding_limit_to_groups", "1600", "val", "1000", "syncd_msg_date_enabled", "bank-ref-id", "max_subject", "payments_web_enabled", "web_upload_document_thumb_mms_enabled", "size", "request", "ephemeral", "24", "receipt_agg", "ptt_remember_play_position", "sampling_weight", "enc_rekey", "mute_always", "037", "034", "23", "036", "action", "click_to_chat_qr_enabled", "width", "disabled", "038", "md_blocklist_v2", "played_self_enabled", "web_buttons_message_enabled", "flow_id", "clear", "450", "fbid:thread", "bloks_session_state", "America/Lima", "attachment_picker_refresh", "download_host_switching_enabled", "1792", "u_aud_limit_sil_restarts_test2", "custom_urls", "device_fanout", "optimistic_upload", "2000", "key_cipher_suite", "web_smb_upsell_in_biz_profile_enabled", "e", "039", "siri_post_status_shortcut", "pair-device", "lg", "lc", "stream_attribution_url", "model", "mspjpeg_phash_gen", "catalog_send_all", "new_multi_vcards_ui", "share_biz_vcard_enabled", "-", "clean", "200", "md_blocklist_v2_server", "03b", "03a", "web_md_migration_experience", "ptt_conversation_waveform", "u_aud_limit_sil_restarts_test1"], readonly ["64", "ptt_playback_speed_enabled", "web_product_list_message_enabled", "paid_convo_ts", "27", "manufacturer", "psp-routing", "grp_uii_cleanup", "ptt_draft_enabled", "03c", "business_initiated", "web_catalog_products_onoff", "web_upload_link_thumb_mms_enabled", "03e", "mediaretry", "35", "hfm_string_changes", "28", "America/Fortaleza", "max_keys", "md_mhfs_days", "streaming_upload_chunk_size", "5541", "040", "03d", "2675", "03f", "...", "512", "mute", "48", "041", "alt_jpeg_quality", "60", "042", "md_smb_quick_reply", "5183", "c", "1343", "40", "1230", "043", "044", "mms_cat_v1_forward_hot_override_enabled", "user_notice", "ptt_waveform_send", "047", "Asia/Calcutta", "250", "md_privacy_v2", "31", "29", "128", "md_messaging_enabled", "046", "crypto", "690", "045", "enc_iv", "75", "failure", "ptt_oot_playback", "AIzaSyDR5yfaG7OG8sMTUj8kfQEb8T9pN8BM6Lk", "w", "048", "2201", "web_large_files_ui", "Asia/Makassar", "812", "status_collapse_muted", "1334", "257", "2HP4dm", "049", "patches", "1290", "43cY6T", "America/Caracas", "web_sticker_maker", "campaign", "ptt_pausable_enabled", "33", "42", "attestation", "biz", "04b", "query_linked", "s", "125", "04a", "810", "availability", "1411", "responsiveness_v2_m1", "catalog_not_created", "34", "America/Santiago", "1465", "enc_p", "04d", "status_info", "04f", "key_version", "..", "04c", "04e", "md_group_notification", "1598", "1215", "web_cart_enabled", "37", "630", "1920", "2394", "-1", "vcard", "38", "elapsed", "36", "828", "peer", "pricing_category", "1245", "invalid", "stella_ios_enabled", "2687", "45", "1528", "39", "u_is_redial_audio_1104_ctrl", "1025", "1455", "58", "2524", "2603", "054", "bsp_system_message_enabled", "web_pip_redesign", "051", "verify_apps", "1974", "1272", "1322", "1755", "052", "70", "050", "1063", "1135", "1361", "80", "1096", "1828", "1851", "1251", "1921", "key_config_id", "1254", "1566", "1252", "2525", "critical_block", "1669", "max_available", "w:auth:backup:token", "product", "2530", "870", "1022", "participant_uuid", "web_cart_on_off", "1255", "1432", "1867", "41", "1415", "1440", "240", "1204", "1608", "1690", "1846", "1483", "1687", "1749", "69", "url_number", "053", "1325", "1040", "365", "59", "Asia/Riyadh", "1177", "test_recommended", "057", "1612", "43", "1061", "1518", "1635", "055", "1034", "1375", "750", "1430", "event_code", "1682", "503", "55", "865", "78", "1309", "1365", "44", "America/Guayaquil", "535", "LIMITED", "1377", "1613", "1420", "1599", "1822", "05a", "1681", "password", "1111", "1214", "1376", "1478", "47", "1082", "4282", "Europe/Istanbul", "1307", "46", "058", "1124", "256", "rate-overlimit", "retail", "u_a_socket_err_fix_succ_test", "1292", "1370", "1388", "520", "861", "psa", "regular", "1181", "1766", "05b", "1183", "1213", "1304", "1537"], readonly ["1724", "profile_picture", "1071", "1314", "1605", "407", "990", "1710", "746", "pricing_model", "056", "059", "061", "1119", "6027", "65", "877", "1607", "05d", "917", "seen", "1516", "49", "470", "973", "1037", "1350", "1394", "1480", "1796", "keys", "794", "1536", "1594", "2378", "1333", "1524", "1825", "116", "309", "52", "808", "827", "909", "495", "1660", "361", "957", "google", "1357", "1565", "1967", "996", "1775", "586", "736", "1052", "1670", "bank", "177", "1416", "2194", "2222", "1454", "1839", "1275", "53", "997", "1629", "6028", "smba", "1378", "1410", "05c", "1849", "727", "create", "1559", "536", "1106", "1310", "1944", "670", "1297", "1316", "1762", "en", "1148", "1295", "1551", "1853", "1890", "1208", "1784", "7200", "05f", "178", "1283", "1332", "381", "643", "1056", "1238", "2024", "2387", "179", "981", "1547", "1705", "05e", "290", "903", "1069", "1285", "2436", "062", "251", "560", "582", "719", "56", "1700", "2321", "325", "448", "613", "777", "791", "51", "488", "902", "Asia/Almaty", "is_hidden", "1398", "1527", "1893", "1999", "2367", "2642", "237", "busy", "065", "067", "233", "590", "993", "1511", "54", "723", "860", "363", "487", "522", "605", "995", "1321", "1691", "1865", "2447", "2462", "NON_TRANSACTIONAL", "433", "871", "432", "1004", "1207", "2032", "2050", "2379", "2446", "279", "636", "703", "904", "248", "370", "691", "700", "1068", "1655", "2334", "060", "063", "364", "533", "534", "567", "1191", "1210", "1473", "1827", "069", "701", "2531", "514", "prev_dhash", "064", "496", "790", "1046", "1139", "1505", "1521", "1108", "207", "544", "637", "final", "1173", "1293", "1694", "1939", "1951", "1993", "2353", "2515", "504", "601", "857", "modify", "spam_request", "p_121_aa_1101_test4", "866", "1427", "1502", "1638", "1744", "2153", "068", "382", "725", "1704", "1864", "1990", "2003", "Asia/Dubai", "508", "531", "1387", "1474", "1632", "2307", "2386", "819", "2014", "066", "387", "1468", "1706", "2186", "2261", "471", "728", "1147", "1372", "1961"]];
|
|
21
|
+
export declare const SINGLE_BYTE_TOKENS: string[];
|
|
22
|
+
export declare const TOKEN_MAP: {
|
|
23
|
+
[token: string]: {
|
|
24
|
+
dict?: number;
|
|
25
|
+
index: number;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BinaryNode, BinaryNodeCodingOptions } from './types.js';
|
|
2
|
+
export declare const decompressingIfRequired: (buffer: Buffer) => Promise<Buffer<ArrayBufferLike>>;
|
|
3
|
+
export declare const decodeDecompressedBinaryNode: (buffer: Buffer, opts: Pick<BinaryNodeCodingOptions, "DOUBLE_BYTE_TOKENS" | "SINGLE_BYTE_TOKENS" | "TAGS">, indexRef?: {
|
|
4
|
+
index: number;
|
|
5
|
+
}) => BinaryNode;
|
|
6
|
+
export declare const decodeBinaryNode: (buff: Buffer) => Promise<BinaryNode>;
|
|
7
|
+
//# sourceMappingURL=decode.d.ts.map
|
package/lib/WABinary/decode.js
CHANGED
|
@@ -36,14 +36,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.decodeBinaryNode = exports.decodeDecompressedBinaryNode = exports.decompressingIfRequired = void 0;
|
|
37
37
|
const util_1 = require("util");
|
|
38
38
|
const zlib_1 = require("zlib");
|
|
39
|
-
const constants = __importStar(require("./constants"));
|
|
40
|
-
const
|
|
39
|
+
const constants = __importStar(require("./constants.js"));
|
|
40
|
+
const jid_utils_js_1 = require("./jid-utils.js");
|
|
41
41
|
const inflatePromise = (0, util_1.promisify)(zlib_1.inflate);
|
|
42
42
|
const decompressingIfRequired = async (buffer) => {
|
|
43
43
|
if (2 & buffer.readUInt8()) {
|
|
44
44
|
buffer = await inflatePromise(buffer.slice(1));
|
|
45
45
|
}
|
|
46
|
-
else {
|
|
46
|
+
else {
|
|
47
|
+
// nodes with no compression have a 0x00 prefix, we remove that
|
|
47
48
|
buffer = buffer.slice(1);
|
|
48
49
|
}
|
|
49
50
|
return buffer;
|
|
@@ -160,7 +161,37 @@ const decodeDecompressedBinaryNode = (buffer, opts, indexRef = { index: 0 }) =>
|
|
|
160
161
|
const domainType = Number(rawDomainType);
|
|
161
162
|
const device = readByte();
|
|
162
163
|
const user = readString(readByte());
|
|
163
|
-
|
|
164
|
+
let server = 's.whatsapp.net'; // default whatsapp server
|
|
165
|
+
if (domainType === jid_utils_js_1.WAJIDDomains.LID) {
|
|
166
|
+
server = 'lid';
|
|
167
|
+
}
|
|
168
|
+
else if (domainType === jid_utils_js_1.WAJIDDomains.HOSTED) {
|
|
169
|
+
server = 'hosted';
|
|
170
|
+
}
|
|
171
|
+
else if (domainType === jid_utils_js_1.WAJIDDomains.HOSTED_LID) {
|
|
172
|
+
server = 'hosted.lid';
|
|
173
|
+
}
|
|
174
|
+
return (0, jid_utils_js_1.jidEncode)(user, server, device);
|
|
175
|
+
};
|
|
176
|
+
const readFbJid = () => {
|
|
177
|
+
const user = readString(readByte());
|
|
178
|
+
const device = readInt(2);
|
|
179
|
+
const server = readString(readByte());
|
|
180
|
+
return `${user}:${device}@${server}`;
|
|
181
|
+
};
|
|
182
|
+
const readInteropJid = () => {
|
|
183
|
+
const user = readString(readByte());
|
|
184
|
+
const device = readInt(2);
|
|
185
|
+
const integrator = readInt(2);
|
|
186
|
+
let server = 'interop';
|
|
187
|
+
const beforeServer = indexRef.index;
|
|
188
|
+
try {
|
|
189
|
+
server = readString(readByte());
|
|
190
|
+
}
|
|
191
|
+
catch (err) {
|
|
192
|
+
indexRef.index = beforeServer;
|
|
193
|
+
}
|
|
194
|
+
return `${integrator}-${user}:${device}@${server}`;
|
|
164
195
|
};
|
|
165
196
|
const readString = (tag) => {
|
|
166
197
|
if (tag >= 1 && tag < SINGLE_BYTE_TOKENS.length) {
|
|
@@ -182,6 +213,10 @@ const decodeDecompressedBinaryNode = (buffer, opts, indexRef = { index: 0 }) =>
|
|
|
182
213
|
return readStringFromChars(readInt(4));
|
|
183
214
|
case TAGS.JID_PAIR:
|
|
184
215
|
return readJidPair();
|
|
216
|
+
case TAGS.FB_JID:
|
|
217
|
+
return readFbJid();
|
|
218
|
+
case TAGS.INTEROP_JID:
|
|
219
|
+
return readInteropJid();
|
|
185
220
|
case TAGS.AD_JID:
|
|
186
221
|
return readAdJid();
|
|
187
222
|
case TAGS.HEX_8:
|
package/lib/WABinary/encode.js
CHANGED
|
@@ -34,8 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.encodeBinaryNode = void 0;
|
|
37
|
-
const constants = __importStar(require("./constants"));
|
|
38
|
-
const
|
|
37
|
+
const constants = __importStar(require("./constants.js"));
|
|
38
|
+
const jid_utils_js_1 = require("./jid-utils.js");
|
|
39
39
|
const encodeBinaryNode = (node, opts = constants, buffer = [0]) => {
|
|
40
40
|
const encoded = encodeBinaryNodeInner(node, opts, buffer);
|
|
41
41
|
return Buffer.from(encoded);
|
|
@@ -50,11 +50,15 @@ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
|
|
|
50
50
|
buffer.push((value >> (curShift * 8)) & 0xff);
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
-
const pushBytes = (bytes) =>
|
|
53
|
+
const pushBytes = (bytes) => {
|
|
54
|
+
for (const b of bytes) {
|
|
55
|
+
buffer.push(b);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
54
58
|
const pushInt16 = (value) => {
|
|
55
59
|
pushBytes([(value >> 8) & 0xff, value & 0xff]);
|
|
56
60
|
};
|
|
57
|
-
const pushInt20 = (value) =>
|
|
61
|
+
const pushInt20 = (value) => pushBytes([(value >> 16) & 0x0f, (value >> 8) & 0xff, value & 0xff]);
|
|
58
62
|
const writeByteLength = (length) => {
|
|
59
63
|
if (length >= 4294967296) {
|
|
60
64
|
throw new Error('string too large to encode: ' + length);
|
|
@@ -152,8 +156,7 @@ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
|
|
|
152
156
|
if (!str || str.length > TAGS.PACKED_MAX) {
|
|
153
157
|
return false;
|
|
154
158
|
}
|
|
155
|
-
for (
|
|
156
|
-
const char = str[i];
|
|
159
|
+
for (const char of str) {
|
|
157
160
|
const isInNibbleRange = char >= '0' && char <= '9';
|
|
158
161
|
if (!isInNibbleRange && char !== '-' && char !== '.') {
|
|
159
162
|
return false;
|
|
@@ -165,8 +168,7 @@ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
|
|
|
165
168
|
if (!str || str.length > TAGS.PACKED_MAX) {
|
|
166
169
|
return false;
|
|
167
170
|
}
|
|
168
|
-
for (
|
|
169
|
-
const char = str[i];
|
|
171
|
+
for (const char of str) {
|
|
170
172
|
const isInNibbleRange = char >= '0' && char <= '9';
|
|
171
173
|
if (!isInNibbleRange && !(char >= 'A' && char <= 'F')) {
|
|
172
174
|
return false;
|
|
@@ -179,6 +181,10 @@ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
|
|
|
179
181
|
pushByte(TAGS.LIST_EMPTY);
|
|
180
182
|
return;
|
|
181
183
|
}
|
|
184
|
+
if (str === '') {
|
|
185
|
+
writeStringRaw(str);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
182
188
|
const tokenIndex = TOKEN_MAP[str];
|
|
183
189
|
if (tokenIndex) {
|
|
184
190
|
if (typeof tokenIndex.dict === 'number') {
|
|
@@ -192,8 +198,8 @@ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
|
|
|
192
198
|
else if (isHex(str)) {
|
|
193
199
|
writePackedBytes(str, 'hex');
|
|
194
200
|
}
|
|
195
|
-
else
|
|
196
|
-
const decodedJid = (0,
|
|
201
|
+
else {
|
|
202
|
+
const decodedJid = (0, jid_utils_js_1.jidDecode)(str);
|
|
197
203
|
if (decodedJid) {
|
|
198
204
|
writeJid(decodedJid);
|
|
199
205
|
}
|
|
@@ -217,7 +223,7 @@ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
|
|
|
217
223
|
if (!tag) {
|
|
218
224
|
throw new Error('Invalid node: tag cannot be undefined');
|
|
219
225
|
}
|
|
220
|
-
const validAttributes = Object.keys(attrs || {}).filter(k =>
|
|
226
|
+
const validAttributes = Object.keys(attrs || {}).filter(k => typeof attrs[k] !== 'undefined' && attrs[k] !== null);
|
|
221
227
|
writeListStart(2 * validAttributes.length + 1 + (typeof content !== 'undefined' ? 1 : 0));
|
|
222
228
|
writeString(tag);
|
|
223
229
|
for (const key of validAttributes) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { proto } from '../../WAProto/index.js';
|
|
2
|
+
import { type BinaryNode } from './types.js';
|
|
3
|
+
export declare const getBinaryNodeChildren: (node: BinaryNode | undefined, childTag: string) => BinaryNode[];
|
|
4
|
+
export declare const getBinaryNodeChild: (node: BinaryNode | undefined, childTag: string) => BinaryNode | undefined;
|
|
5
|
+
export declare const getAllBinaryNodeChildren: ({ content }: BinaryNode) => BinaryNode[];
|
|
6
|
+
export declare const getBinaryNodeChildBuffer: (node: BinaryNode | undefined, childTag: string) => Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike> | undefined;
|
|
7
|
+
export declare const getBinaryNodeChildString: (node: BinaryNode | undefined, childTag: string) => string | undefined;
|
|
8
|
+
export declare const getBinaryNodeChildUInt: (node: BinaryNode, childTag: string, length: number) => number | undefined;
|
|
9
|
+
export declare const assertNodeErrorFree: (node: BinaryNode) => void;
|
|
10
|
+
export declare const reduceBinaryNodeToDictionary: (node: BinaryNode, tag: string) => {
|
|
11
|
+
[_: string]: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const getBinaryNodeMessages: ({ content }: BinaryNode) => proto.WebMessageInfo[];
|
|
14
|
+
export declare function binaryNodeToString(node: BinaryNode | BinaryNode['content'], i?: number): string;
|
|
15
|
+
//# sourceMappingURL=generic-utils.d.ts.map
|
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBinaryNodeMessages = exports.reduceBinaryNodeToDictionary = exports.assertNodeErrorFree = exports.getBinaryNodeChildUInt = exports.getBinaryNodeChildString = exports.getBinaryNodeChildBuffer = exports.
|
|
3
|
+
exports.getBinaryFilteredBizBot = exports.getBinaryFilteredButtons = exports.getBinaryNodeMessages = exports.reduceBinaryNodeToDictionary = exports.assertNodeErrorFree = exports.getBinaryNodeChildUInt = exports.getBinaryNodeChildString = exports.getBinaryNodeChildBuffer = exports.getAllBinaryNodeChildren = exports.getBinaryNodeChild = exports.getBinaryNodeChildren = void 0;
|
|
4
4
|
exports.binaryNodeToString = binaryNodeToString;
|
|
5
5
|
const boom_1 = require("@hapi/boom");
|
|
6
|
-
const
|
|
6
|
+
const index_js_1 = require("../../WAProto/index.js");
|
|
7
7
|
// some extra useful utilities
|
|
8
|
+
const indexCache = new WeakMap();
|
|
8
9
|
const getBinaryNodeChildren = (node, childTag) => {
|
|
9
|
-
if (Array.isArray(node
|
|
10
|
-
return
|
|
10
|
+
if (!node || !Array.isArray(node.content))
|
|
11
|
+
return [];
|
|
12
|
+
let index = indexCache.get(node);
|
|
13
|
+
// Build the index once per node
|
|
14
|
+
if (!index) {
|
|
15
|
+
index = new Map();
|
|
16
|
+
for (const child of node.content) {
|
|
17
|
+
let arr = index.get(child.tag);
|
|
18
|
+
if (!arr)
|
|
19
|
+
index.set(child.tag, (arr = []));
|
|
20
|
+
arr.push(child);
|
|
21
|
+
}
|
|
22
|
+
indexCache.set(node, index);
|
|
11
23
|
}
|
|
12
|
-
|
|
24
|
+
// Return first matching child
|
|
25
|
+
return index.get(childTag) || [];
|
|
13
26
|
};
|
|
14
27
|
exports.getBinaryNodeChildren = getBinaryNodeChildren;
|
|
28
|
+
const getBinaryNodeChild = (node, childTag) => {
|
|
29
|
+
return (0, exports.getBinaryNodeChildren)(node, childTag)[0];
|
|
30
|
+
};
|
|
31
|
+
exports.getBinaryNodeChild = getBinaryNodeChild;
|
|
15
32
|
const getAllBinaryNodeChildren = ({ content }) => {
|
|
16
33
|
if (Array.isArray(content)) {
|
|
17
34
|
return content;
|
|
@@ -19,23 +36,15 @@ const getAllBinaryNodeChildren = ({ content }) => {
|
|
|
19
36
|
return [];
|
|
20
37
|
};
|
|
21
38
|
exports.getAllBinaryNodeChildren = getAllBinaryNodeChildren;
|
|
22
|
-
const getBinaryNodeChild = (node, childTag) => {
|
|
23
|
-
if (Array.isArray(node === null || node === void 0 ? void 0 : node.content)) {
|
|
24
|
-
return node === null || node === void 0 ? void 0 : node.content.find(item => item.tag === childTag);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
exports.getBinaryNodeChild = getBinaryNodeChild;
|
|
28
39
|
const getBinaryNodeChildBuffer = (node, childTag) => {
|
|
29
|
-
|
|
30
|
-
const child = (_a = (0, exports.getBinaryNodeChild)(node, childTag)) === null || _a === void 0 ? void 0 : _a.content;
|
|
40
|
+
const child = (0, exports.getBinaryNodeChild)(node, childTag)?.content;
|
|
31
41
|
if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
|
|
32
42
|
return child;
|
|
33
43
|
}
|
|
34
44
|
};
|
|
35
45
|
exports.getBinaryNodeChildBuffer = getBinaryNodeChildBuffer;
|
|
36
46
|
const getBinaryNodeChildString = (node, childTag) => {
|
|
37
|
-
|
|
38
|
-
const child = (_a = (0, exports.getBinaryNodeChild)(node, childTag)) === null || _a === void 0 ? void 0 : _a.content;
|
|
47
|
+
const child = (0, exports.getBinaryNodeChild)(node, childTag)?.content;
|
|
39
48
|
if (Buffer.isBuffer(child) || child instanceof Uint8Array) {
|
|
40
49
|
return Buffer.from(child).toString('utf-8');
|
|
41
50
|
}
|
|
@@ -61,7 +70,12 @@ exports.assertNodeErrorFree = assertNodeErrorFree;
|
|
|
61
70
|
const reduceBinaryNodeToDictionary = (node, tag) => {
|
|
62
71
|
const nodes = (0, exports.getBinaryNodeChildren)(node, tag);
|
|
63
72
|
const dict = nodes.reduce((dict, { attrs }) => {
|
|
64
|
-
|
|
73
|
+
if (typeof attrs.name === 'string') {
|
|
74
|
+
dict[attrs.name] = attrs.value || attrs.config_value;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
dict[attrs.config_code] = attrs.value || attrs.config_value;
|
|
78
|
+
}
|
|
65
79
|
return dict;
|
|
66
80
|
}, {});
|
|
67
81
|
return dict;
|
|
@@ -72,7 +86,7 @@ const getBinaryNodeMessages = ({ content }) => {
|
|
|
72
86
|
if (Array.isArray(content)) {
|
|
73
87
|
for (const item of content) {
|
|
74
88
|
if (item.tag === 'message') {
|
|
75
|
-
msgs.push(
|
|
89
|
+
msgs.push(index_js_1.proto.WebMessageInfo.decode(item.content).toJSON());
|
|
76
90
|
}
|
|
77
91
|
}
|
|
78
92
|
}
|
|
@@ -98,7 +112,7 @@ function binaryNodeToString(node, i = 0) {
|
|
|
98
112
|
return tabs(i) + Buffer.from(node).toString('hex');
|
|
99
113
|
}
|
|
100
114
|
if (Array.isArray(node)) {
|
|
101
|
-
return node.map(
|
|
115
|
+
return node.map(x => tabs(i + 1) + binaryNodeToString(x, i + 1)).join('\n');
|
|
102
116
|
}
|
|
103
117
|
const children = binaryNodeToString(node.content, i + 1);
|
|
104
118
|
const tag = `<${node.tag} ${Object.entries(node.attrs || {})
|
|
@@ -108,3 +122,17 @@ function binaryNodeToString(node, i = 0) {
|
|
|
108
122
|
const content = children ? `>\n${children}\n${tabs(i)}</${node.tag}>` : '/>';
|
|
109
123
|
return tag + content;
|
|
110
124
|
}
|
|
125
|
+
const getBinaryFilteredButtons = (nodeContent) => {
|
|
126
|
+
if (!Array.isArray(nodeContent))
|
|
127
|
+
return false;
|
|
128
|
+
return nodeContent.some(a => ['native_flow'].includes(a?.content?.[0]?.content?.[0]?.tag) ||
|
|
129
|
+
['interactive', 'buttons', 'list'].includes(a?.content?.[0]?.tag) ||
|
|
130
|
+
['hsm', 'biz'].includes(a?.tag));
|
|
131
|
+
};
|
|
132
|
+
exports.getBinaryFilteredButtons = getBinaryFilteredButtons;
|
|
133
|
+
const getBinaryFilteredBizBot = (nodeContent) => {
|
|
134
|
+
if (!Array.isArray(nodeContent))
|
|
135
|
+
return false;
|
|
136
|
+
return nodeContent.some(b => ['bot'].includes(b?.tag) && b?.attrs?.biz_bot === '1');
|
|
137
|
+
};
|
|
138
|
+
exports.getBinaryFilteredBizBot = getBinaryFilteredBizBot;
|
package/lib/WABinary/index.js
CHANGED
|
@@ -14,8 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./
|
|
20
|
-
__exportStar(require("./
|
|
21
|
-
|
|
17
|
+
exports.getBinaryFilteredBizBot = exports.getBinaryFilteredButtons = void 0;
|
|
18
|
+
__exportStar(require("./encode.js"), exports);
|
|
19
|
+
__exportStar(require("./decode.js"), exports);
|
|
20
|
+
__exportStar(require("./generic-utils.js"), exports);
|
|
21
|
+
var generic_utils_js_1 = require("./generic-utils.js");
|
|
22
|
+
Object.defineProperty(exports, "getBinaryFilteredButtons", { enumerable: true, get: function () { return generic_utils_js_1.getBinaryFilteredButtons; } });
|
|
23
|
+
Object.defineProperty(exports, "getBinaryFilteredBizBot", { enumerable: true, get: function () { return generic_utils_js_1.getBinaryFilteredBizBot; } });
|
|
24
|
+
__exportStar(require("./jid-utils.js"), exports);
|
|
25
|
+
__exportStar(require("./types.js"), exports);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export declare const S_WHATSAPP_NET = "@s.whatsapp.net";
|
|
2
|
+
export declare const OFFICIAL_BIZ_JID = "16505361212@c.us";
|
|
3
|
+
export declare const SERVER_JID = "server@c.us";
|
|
4
|
+
export declare const PSA_WID = "0@c.us";
|
|
5
|
+
export declare const STORIES_JID = "status@broadcast";
|
|
6
|
+
export declare const META_AI_JID = "13135550002@c.us";
|
|
7
|
+
export type JidServer = 'c.us' | 'g.us' | 'broadcast' | 's.whatsapp.net' | 'call' | 'lid' | 'newsletter' | 'bot' | 'hosted' | 'hosted.lid';
|
|
8
|
+
export declare enum WAJIDDomains {
|
|
9
|
+
WHATSAPP = 0,
|
|
10
|
+
LID = 1,
|
|
11
|
+
HOSTED = 128,
|
|
12
|
+
HOSTED_LID = 129
|
|
13
|
+
}
|
|
14
|
+
export type JidWithDevice = {
|
|
15
|
+
user: string;
|
|
16
|
+
device?: number;
|
|
17
|
+
};
|
|
18
|
+
export type FullJid = JidWithDevice & {
|
|
19
|
+
server: JidServer;
|
|
20
|
+
domainType?: number;
|
|
21
|
+
};
|
|
22
|
+
export declare const getServerFromDomainType: (initialServer: string, domainType?: WAJIDDomains) => JidServer;
|
|
23
|
+
export declare const jidEncode: (user: string | number | null, server: JidServer, device?: number, agent?: number) => string;
|
|
24
|
+
export declare const jidDecode: (jid: string | undefined) => FullJid | undefined;
|
|
25
|
+
/** is the jid a user */
|
|
26
|
+
export declare const areJidsSameUser: (jid1: string | undefined, jid2: string | undefined) => boolean;
|
|
27
|
+
/** is the jid Meta AI */
|
|
28
|
+
export declare const isJidMetaAI: (jid: string | undefined) => boolean | undefined;
|
|
29
|
+
/** is the jid a PN user */
|
|
30
|
+
export declare const isPnUser: (jid: string | undefined) => boolean | undefined;
|
|
31
|
+
/** is the jid a LID */
|
|
32
|
+
export declare const isLidUser: (jid: string | undefined) => boolean | undefined;
|
|
33
|
+
/** is the jid a broadcast */
|
|
34
|
+
export declare const isJidBroadcast: (jid: string | undefined) => boolean | undefined;
|
|
35
|
+
/** is the jid a group */
|
|
36
|
+
export declare const isJidGroup: (jid: string | undefined) => boolean | undefined;
|
|
37
|
+
/** is the jid the status broadcast */
|
|
38
|
+
export declare const isJidStatusBroadcast: (jid: string) => jid is "status@broadcast";
|
|
39
|
+
/** is the jid a newsletter */
|
|
40
|
+
export declare const isJidNewsletter: (jid: string | undefined) => boolean | undefined;
|
|
41
|
+
/** is the jid a hosted PN */
|
|
42
|
+
export declare const isHostedPnUser: (jid: string | undefined) => boolean | undefined;
|
|
43
|
+
/** is the jid a hosted LID */
|
|
44
|
+
export declare const isHostedLidUser: (jid: string | undefined) => boolean | undefined;
|
|
45
|
+
export declare const isJidBot: (jid: string | undefined) => boolean | "" | undefined;
|
|
46
|
+
export declare const jidNormalizedUser: (jid: string | undefined) => string;
|
|
47
|
+
export declare const transferDevice: (fromJid: string, toJid: string) => string;
|
|
48
|
+
//# sourceMappingURL=jid-utils.d.ts.map
|