@xbibzlibrary/whatsbibz 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +93 -0
- package/LICENSE +22 -0
- package/LICENSE.upstream +21 -0
- package/README.md +280 -0
- package/VERIFIKASI-IDENTITAS-2026-09-03.md +138 -0
- package/WAProto/GenerateStatics.sh +3 -0
- package/WAProto/WAProto.proto +6035 -0
- package/WAProto/fix-imports.js +81 -0
- package/WAProto/index.d.ts +15314 -0
- package/WAProto/index.js +132326 -0
- package/assets/logo/README.md +21 -0
- package/assets/logo/png/banner-1200x360.png +0 -0
- package/assets/logo/png/icon-1024.png +0 -0
- package/assets/logo/png/icon-128.png +0 -0
- package/assets/logo/png/icon-16.png +0 -0
- package/assets/logo/png/icon-24.png +0 -0
- package/assets/logo/png/icon-256.png +0 -0
- package/assets/logo/png/icon-32.png +0 -0
- package/assets/logo/png/icon-48.png +0 -0
- package/assets/logo/png/icon-512.png +0 -0
- package/assets/logo/png/icon-64.png +0 -0
- package/assets/logo/png/mark-512.png +0 -0
- package/assets/logo/preview.png +0 -0
- package/assets/logo/whatsbibz.ico +0 -0
- package/lib/BibzWhats/client.d.ts +95 -0
- package/lib/BibzWhats/client.js +501 -0
- package/lib/BibzWhats/device-identity.d.ts +60 -0
- package/lib/BibzWhats/device-identity.js +234 -0
- package/lib/BibzWhats/extract.d.ts +29 -0
- package/lib/BibzWhats/extract.js +115 -0
- package/lib/BibzWhats/index.d.ts +7 -0
- package/lib/BibzWhats/index.js +8 -0
- package/lib/BibzWhats/jid.d.ts +22 -0
- package/lib/BibzWhats/jid.js +98 -0
- package/lib/BibzWhats/pairing.d.ts +35 -0
- package/lib/BibzWhats/pairing.js +186 -0
- package/lib/BibzWhats/send.d.ts +9 -0
- package/lib/BibzWhats/send.js +107 -0
- package/lib/BibzWhats/version.d.ts +6 -0
- package/lib/BibzWhats/version.js +7 -0
- package/lib/Defaults/index.d.ts +73 -0
- package/lib/Defaults/index.js +141 -0
- package/lib/Modded/message_builder.d.ts +15 -0
- package/lib/Modded/message_builder.js +2330 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
- package/lib/Signal/Group/ciphertext-message.js +11 -0
- package/lib/Signal/Group/group-session-builder.d.ts +14 -0
- package/lib/Signal/Group/group-session-builder.js +29 -0
- package/lib/Signal/Group/group_cipher.d.ts +16 -0
- package/lib/Signal/Group/group_cipher.js +81 -0
- package/lib/Signal/Group/index.d.ts +11 -0
- package/lib/Signal/Group/index.js +11 -0
- package/lib/Signal/Group/keyhelper.d.ts +10 -0
- package/lib/Signal/Group/keyhelper.js +17 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
- package/lib/Signal/Group/sender-chain-key.js +25 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +62 -0
- package/lib/Signal/Group/sender-key-message.d.ts +18 -0
- package/lib/Signal/Group/sender-key-message.js +65 -0
- package/lib/Signal/Group/sender-key-name.d.ts +17 -0
- package/lib/Signal/Group/sender-key-name.js +47 -0
- package/lib/Signal/Group/sender-key-record.d.ts +30 -0
- package/lib/Signal/Group/sender-key-record.js +40 -0
- package/lib/Signal/Group/sender-key-state.d.ts +38 -0
- package/lib/Signal/Group/sender-key-state.js +83 -0
- package/lib/Signal/Group/sender-message-key.d.ts +11 -0
- package/lib/Signal/Group/sender-message-key.js +25 -0
- package/lib/Signal/libsignal.d.ts +4 -0
- package/lib/Signal/libsignal.js +406 -0
- package/lib/Signal/lid-mapping.d.ts +18 -0
- package/lib/Signal/lid-mapping.js +276 -0
- package/lib/Socket/Client/index.d.ts +2 -0
- package/lib/Socket/Client/index.js +2 -0
- package/lib/Socket/Client/types.d.ts +15 -0
- package/lib/Socket/Client/types.js +10 -0
- package/lib/Socket/Client/websocket.d.ts +12 -0
- package/lib/Socket/Client/websocket.js +53 -0
- package/lib/Socket/business.d.ts +537 -0
- package/lib/Socket/business.js +421 -0
- package/lib/Socket/chats.d.ts +110 -0
- package/lib/Socket/chats.js +1006 -0
- package/lib/Socket/communities.d.ts +646 -0
- package/lib/Socket/communities.js +430 -0
- package/lib/Socket/engine.d.ts +129 -0
- package/lib/Socket/engine.js +767 -0
- package/lib/Socket/groups.d.ts +149 -0
- package/lib/Socket/groups.js +326 -0
- package/lib/Socket/index.d.ts +637 -0
- package/lib/Socket/index.js +14 -0
- package/lib/Socket/messages-recv.d.ts +239 -0
- package/lib/Socket/messages-recv.js +1307 -0
- package/lib/Socket/messages-send.d.ts +580 -0
- package/lib/Socket/messages-send.js +1639 -0
- package/lib/Socket/mex.d.ts +2 -0
- package/lib/Socket/mex.js +47 -0
- package/lib/Socket/newsletter.d.ts +176 -0
- package/lib/Socket/newsletter.js +456 -0
- package/lib/Socket/socket.d.ts +56 -0
- package/lib/Socket/socket.js +998 -0
- package/lib/Types/Auth.d.ts +115 -0
- package/lib/Types/Auth.js +1 -0
- package/lib/Types/Bussines.d.ts +36 -0
- package/lib/Types/Bussines.js +1 -0
- package/lib/Types/Call.d.ts +14 -0
- package/lib/Types/Call.js +1 -0
- package/lib/Types/Chat.d.ts +124 -0
- package/lib/Types/Chat.js +7 -0
- package/lib/Types/Contact.d.ts +23 -0
- package/lib/Types/Contact.js +1 -0
- package/lib/Types/Events.d.ts +241 -0
- package/lib/Types/Events.js +1 -0
- package/lib/Types/GroupMetadata.d.ts +67 -0
- package/lib/Types/GroupMetadata.js +1 -0
- package/lib/Types/Label.d.ts +46 -0
- package/lib/Types/Label.js +24 -0
- package/lib/Types/LabelAssociation.d.ts +29 -0
- package/lib/Types/LabelAssociation.js +6 -0
- package/lib/Types/Message.d.ts +427 -0
- package/lib/Types/Message.js +10 -0
- package/lib/Types/Newsletter.d.ts +134 -0
- package/lib/Types/Newsletter.js +30 -0
- package/lib/Types/Product.d.ts +78 -0
- package/lib/Types/Product.js +1 -0
- package/lib/Types/Signal.d.ts +77 -0
- package/lib/Types/Signal.js +1 -0
- package/lib/Types/Socket.d.ts +173 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/State.d.ts +38 -0
- package/lib/Types/State.js +12 -0
- package/lib/Types/USync.d.ts +25 -0
- package/lib/Types/USync.js +1 -0
- package/lib/Types/index.d.ts +75 -0
- package/lib/Types/index.js +32 -0
- package/lib/Utils/auth-utils.d.ts +18 -0
- package/lib/Utils/auth-utils.js +289 -0
- package/lib/Utils/browser-utils.d.ts +3 -0
- package/lib/Utils/browser-utils.js +47 -0
- package/lib/Utils/business.d.ts +22 -0
- package/lib/Utils/business.js +230 -0
- package/lib/Utils/chat-utils.d.ts +69 -0
- package/lib/Utils/chat-utils.js +811 -0
- package/lib/Utils/companion-reg-client-utils.d.ts +20 -0
- package/lib/Utils/companion-reg-client-utils.js +66 -0
- package/lib/Utils/crypto.d.ts +41 -0
- package/lib/Utils/crypto.js +117 -0
- package/lib/Utils/decode-wa-message.d.ts +47 -0
- package/lib/Utils/decode-wa-message.js +282 -0
- package/lib/Utils/event-buffer.d.ts +35 -0
- package/lib/Utils/event-buffer.js +590 -0
- package/lib/Utils/generics.d.ts +90 -0
- package/lib/Utils/generics.js +384 -0
- package/lib/Utils/history.d.ts +21 -0
- package/lib/Utils/history.js +130 -0
- package/lib/Utils/identity-change-handler.d.ts +36 -0
- package/lib/Utils/identity-change-handler.js +48 -0
- package/lib/Utils/index.d.ts +25 -0
- package/lib/Utils/index.js +24 -0
- package/lib/Utils/link-preview.d.ts +20 -0
- package/lib/Utils/link-preview.js +84 -0
- package/lib/Utils/logger.d.ts +12 -0
- package/lib/Utils/logger.js +2 -0
- package/lib/Utils/lt-hash.d.ts +10 -0
- package/lib/Utils/lt-hash.js +7 -0
- package/lib/Utils/make-mutex.d.ts +8 -0
- package/lib/Utils/make-mutex.js +32 -0
- package/lib/Utils/message-retry-manager.d.ts +109 -0
- package/lib/Utils/message-retry-manager.js +224 -0
- package/lib/Utils/messages-media.d.ts +129 -0
- package/lib/Utils/messages-media.js +784 -0
- package/lib/Utils/messages.d.ts +90 -0
- package/lib/Utils/messages.js +1240 -0
- package/lib/Utils/noise-handler.d.ts +19 -0
- package/lib/Utils/noise-handler.js +200 -0
- package/lib/Utils/offline-node-processor.d.ts +16 -0
- package/lib/Utils/offline-node-processor.js +39 -0
- package/lib/Utils/platform-identity.d.ts +14 -0
- package/lib/Utils/platform-identity.js +148 -0
- package/lib/Utils/pre-key-manager.d.ts +27 -0
- package/lib/Utils/pre-key-manager.js +105 -0
- package/lib/Utils/process-message.d.ts +59 -0
- package/lib/Utils/process-message.js +544 -0
- package/lib/Utils/reporting-utils.d.ts +10 -0
- package/lib/Utils/reporting-utils.js +257 -0
- package/lib/Utils/rich-messages.d.ts +276 -0
- package/lib/Utils/rich-messages.js +1143 -0
- package/lib/Utils/signal.d.ts +33 -0
- package/lib/Utils/signal.js +158 -0
- package/lib/Utils/stanza-ack.d.ts +10 -0
- package/lib/Utils/stanza-ack.js +37 -0
- package/lib/Utils/sticker-pack.d.ts +10 -0
- package/lib/Utils/sticker-pack.js +111 -0
- package/lib/Utils/sync-action-utils.d.ts +18 -0
- package/lib/Utils/sync-action-utils.js +47 -0
- package/lib/Utils/tc-token-utils.d.ts +8 -0
- package/lib/Utils/tc-token-utils.js +45 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +12 -0
- package/lib/Utils/use-multi-file-auth-state.js +120 -0
- package/lib/Utils/validate-connection.d.ts +10 -0
- package/lib/Utils/validate-connection.js +222 -0
- package/lib/VoIP/audio-feeder.d.ts +15 -0
- package/lib/VoIP/audio-feeder.js +136 -0
- package/lib/VoIP/index.d.ts +12 -0
- package/lib/VoIP/index.js +282 -0
- package/lib/VoIP/relay-transport.d.ts +43 -0
- package/lib/VoIP/relay-transport.js +559 -0
- package/lib/VoIP/signaling.js +603 -0
- package/lib/VoIP/types.d.ts +69 -0
- package/lib/VoIP/types.js +17 -0
- package/lib/VoIP/wasm-engine.d.ts +103 -0
- package/lib/VoIP/wasm-engine.js +1214 -0
- package/lib/VoIP/worker-bootstrap.js +1042 -0
- package/lib/WABinary/constants.d.ts +27 -0
- package/lib/WABinary/constants.js +1300 -0
- package/lib/WABinary/decode.d.ts +6 -0
- package/lib/WABinary/decode.js +261 -0
- package/lib/WABinary/encode.d.ts +2 -0
- package/lib/WABinary/encode.js +219 -0
- package/lib/WABinary/generic-utils.d.ts +16 -0
- package/lib/WABinary/generic-utils.js +190 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/index.js +5 -0
- package/lib/WABinary/jid-utils.d.ts +47 -0
- package/lib/WABinary/jid-utils.js +95 -0
- package/lib/WABinary/types.d.ts +18 -0
- package/lib/WABinary/types.js +1 -0
- package/lib/WAM/BinaryInfo.d.ts +8 -0
- package/lib/WAM/BinaryInfo.js +9 -0
- package/lib/WAM/constants.d.ts +39 -0
- package/lib/WAM/constants.js +22852 -0
- package/lib/WAM/encode.d.ts +2 -0
- package/lib/WAM/encode.js +149 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAM/index.js +3 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +28 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +53 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +37 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +28 -0
- package/lib/WAUSync/Protocols/index.d.ts +4 -0
- package/lib/WAUSync/Protocols/index.js +4 -0
- package/lib/WAUSync/USyncQuery.d.ts +28 -0
- package/lib/WAUSync/USyncQuery.js +93 -0
- package/lib/WAUSync/USyncUser.d.ts +12 -0
- package/lib/WAUSync/USyncUser.js +22 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/WAUSync/index.js +3 -0
- package/lib/assets/wasm/loader.js +5 -0
- package/lib/assets/wasm/whatsapp.wasm +0 -0
- package/lib/assets/wasm/worker-modules.js +273 -0
- package/lib/index.d.ts +21 -0
- package/lib/index.js +22 -0
- package/package.json +111 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { createHmac } from 'crypto';
|
|
2
|
+
import { proto } from '../../WAProto/index.js';
|
|
3
|
+
import { hkdf } from './crypto.js';
|
|
4
|
+
const reportingFields = [
|
|
5
|
+
{ f: 1 },
|
|
6
|
+
{
|
|
7
|
+
f: 3,
|
|
8
|
+
s: [{ f: 2 }, { f: 3 }, { f: 8 }, { f: 11 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }, { f: 25 }]
|
|
9
|
+
},
|
|
10
|
+
{ f: 4, s: [{ f: 1 }, { f: 16 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }] },
|
|
11
|
+
{ f: 5, s: [{ f: 3 }, { f: 4 }, { f: 5 }, { f: 16 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }] },
|
|
12
|
+
{ f: 6, s: [{ f: 1 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }, { f: 30 }] },
|
|
13
|
+
{ f: 7, s: [{ f: 2 }, { f: 7 }, { f: 10 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }, { f: 20 }] },
|
|
14
|
+
{ f: 8, s: [{ f: 2 }, { f: 7 }, { f: 9 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }, { f: 21 }] },
|
|
15
|
+
{ f: 9, s: [{ f: 2 }, { f: 6 }, { f: 7 }, { f: 13 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }, { f: 20 }] },
|
|
16
|
+
{ f: 12, s: [{ f: 1 }, { f: 2 }, { f: 14, m: true }, { f: 15 }] },
|
|
17
|
+
{ f: 18, s: [{ f: 6 }, { f: 16 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }] },
|
|
18
|
+
{ f: 26, s: [{ f: 4 }, { f: 5 }, { f: 8 }, { f: 13 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }] },
|
|
19
|
+
{ f: 28, s: [{ f: 1 }, { f: 2 }, { f: 4 }, { f: 5 }, { f: 6 }, { f: 7, s: [{ f: 21 }, { f: 22 }] }] },
|
|
20
|
+
{ f: 37, s: [{ f: 1, m: true }] },
|
|
21
|
+
{
|
|
22
|
+
f: 49,
|
|
23
|
+
s: [
|
|
24
|
+
{ f: 2 },
|
|
25
|
+
{ f: 3, s: [{ f: 1 }, { f: 2 }] },
|
|
26
|
+
{ f: 5, s: [{ f: 21 }, { f: 22 }] },
|
|
27
|
+
{ f: 8, s: [{ f: 1 }, { f: 2 }] }
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
{ f: 53, s: [{ f: 1, m: true }] },
|
|
31
|
+
{ f: 55, s: [{ f: 1, m: true }] },
|
|
32
|
+
{ f: 58, s: [{ f: 1, m: true }] },
|
|
33
|
+
{ f: 59, s: [{ f: 1, m: true }] },
|
|
34
|
+
{
|
|
35
|
+
f: 60,
|
|
36
|
+
s: [
|
|
37
|
+
{ f: 2 },
|
|
38
|
+
{ f: 3, s: [{ f: 1 }, { f: 2 }] },
|
|
39
|
+
{ f: 5, s: [{ f: 21 }, { f: 22 }] },
|
|
40
|
+
{ f: 8, s: [{ f: 1 }, { f: 2 }] }
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
f: 64,
|
|
45
|
+
s: [
|
|
46
|
+
{ f: 2 },
|
|
47
|
+
{ f: 3, s: [{ f: 1 }, { f: 2 }] },
|
|
48
|
+
{ f: 5, s: [{ f: 21 }, { f: 22 }] },
|
|
49
|
+
{ f: 8, s: [{ f: 1 }, { f: 2 }] }
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
{ f: 66, s: [{ f: 2 }, { f: 6 }, { f: 7 }, { f: 13 }, { f: 17, s: [{ f: 21 }, { f: 22 }] }, { f: 20 }] },
|
|
53
|
+
{ f: 74, s: [{ f: 1, m: true }] },
|
|
54
|
+
{ f: 87, s: [{ f: 1, m: true }] },
|
|
55
|
+
{ f: 88, s: [{ f: 1 }, { f: 2, s: [{ f: 1 }] }, { f: 3, s: [{ f: 21 }, { f: 22 }] }] },
|
|
56
|
+
{ f: 92, s: [{ f: 1, m: true }] },
|
|
57
|
+
{ f: 93, s: [{ f: 1, m: true }] },
|
|
58
|
+
{ f: 94, s: [{ f: 1, m: true }] }
|
|
59
|
+
];
|
|
60
|
+
const compileReportingFields = (fields) => {
|
|
61
|
+
const map = new Map();
|
|
62
|
+
for (const f of fields) {
|
|
63
|
+
map.set(f.f, {
|
|
64
|
+
m: f.m,
|
|
65
|
+
children: f.s ? compileReportingFields(f.s) : undefined
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return map;
|
|
69
|
+
};
|
|
70
|
+
const compiledReportingFields = compileReportingFields(reportingFields);
|
|
71
|
+
const EMPTY_MAP = new Map();
|
|
72
|
+
const ENC_SECRET_REPORT_TOKEN = 'Report Token';
|
|
73
|
+
const WIRE = {
|
|
74
|
+
VARINT: 0,
|
|
75
|
+
FIXED64: 1,
|
|
76
|
+
BYTES: 2,
|
|
77
|
+
FIXED32: 5
|
|
78
|
+
};
|
|
79
|
+
export const shouldIncludeReportingToken = (message) => !message.reactionMessage &&
|
|
80
|
+
!message.encReactionMessage &&
|
|
81
|
+
!message.encEventResponseMessage &&
|
|
82
|
+
!message.pollUpdateMessage;
|
|
83
|
+
const generateMsgSecretKey = (modificationType, origMsgId, origMsgSender, modificationSender, origMsgSecret) => {
|
|
84
|
+
const useCaseSecret = Buffer.concat([
|
|
85
|
+
Buffer.from(origMsgId, 'utf8'),
|
|
86
|
+
Buffer.from(origMsgSender, 'utf8'),
|
|
87
|
+
Buffer.from(modificationSender, 'utf8'),
|
|
88
|
+
Buffer.from(modificationType, 'utf8')
|
|
89
|
+
]);
|
|
90
|
+
return hkdf(origMsgSecret, 32, { info: useCaseSecret.toString('latin1') });
|
|
91
|
+
};
|
|
92
|
+
const extractReportingTokenContent = (data, cfg) => {
|
|
93
|
+
const out = [];
|
|
94
|
+
let i = 0;
|
|
95
|
+
while (i < data.length) {
|
|
96
|
+
const tag = decodeVarint(data, i);
|
|
97
|
+
if (!tag.ok) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
const fieldNum = tag.value >> 3;
|
|
101
|
+
const wireType = tag.value & 0x7;
|
|
102
|
+
const fieldStart = i;
|
|
103
|
+
i += tag.bytes;
|
|
104
|
+
const fieldCfg = cfg.get(fieldNum);
|
|
105
|
+
const pushSlice = (end) => {
|
|
106
|
+
if (end > data.length) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
out.push({ num: fieldNum, bytes: data.subarray(fieldStart, end) });
|
|
110
|
+
i = end;
|
|
111
|
+
return true;
|
|
112
|
+
};
|
|
113
|
+
const skip = (end) => {
|
|
114
|
+
if (end > data.length) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
i = end;
|
|
118
|
+
return true;
|
|
119
|
+
};
|
|
120
|
+
if (wireType === WIRE.VARINT) {
|
|
121
|
+
const v = decodeVarint(data, i);
|
|
122
|
+
if (!v.ok) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
const end = i + v.bytes;
|
|
126
|
+
if (!fieldCfg) {
|
|
127
|
+
if (!skip(end)) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
if (!pushSlice(end)) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (wireType === WIRE.FIXED64) {
|
|
138
|
+
const end = i + 8;
|
|
139
|
+
if (!fieldCfg) {
|
|
140
|
+
if (!skip(end)) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (!pushSlice(end)) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (wireType === WIRE.FIXED32) {
|
|
151
|
+
const end = i + 4;
|
|
152
|
+
if (!fieldCfg) {
|
|
153
|
+
if (!skip(end)) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (!pushSlice(end)) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (wireType === WIRE.BYTES) {
|
|
164
|
+
const len = decodeVarint(data, i);
|
|
165
|
+
if (!len.ok) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
const valStart = i + len.bytes;
|
|
169
|
+
const valEnd = valStart + len.value;
|
|
170
|
+
if (valEnd > data.length) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
if (!fieldCfg) {
|
|
174
|
+
i = valEnd;
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (fieldCfg.m || fieldCfg.children) {
|
|
178
|
+
const sub = extractReportingTokenContent(data.subarray(valStart, valEnd), fieldCfg.children ?? EMPTY_MAP);
|
|
179
|
+
if (sub === null) {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
if (sub.length > 0) {
|
|
183
|
+
const newTag = encodeVarint(tag.value);
|
|
184
|
+
const newLen = encodeVarint(sub.length);
|
|
185
|
+
out.push({
|
|
186
|
+
num: fieldNum,
|
|
187
|
+
bytes: Buffer.concat([newTag, newLen, sub])
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
i = valEnd;
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
out.push({ num: fieldNum, bytes: data.subarray(fieldStart, valEnd) });
|
|
194
|
+
i = valEnd;
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
if (out.length === 0) {
|
|
200
|
+
return Buffer.alloc(0);
|
|
201
|
+
}
|
|
202
|
+
out.sort((a, b) => a.num - b.num);
|
|
203
|
+
return Buffer.concat(out.map(f => f.bytes));
|
|
204
|
+
};
|
|
205
|
+
const decodeVarint = (buffer, offset) => {
|
|
206
|
+
let value = 0;
|
|
207
|
+
let bytes = 0;
|
|
208
|
+
let shift = 0;
|
|
209
|
+
while (offset + bytes < buffer.length) {
|
|
210
|
+
const current = buffer[offset + bytes];
|
|
211
|
+
value |= (current & 0x7f) << shift;
|
|
212
|
+
bytes++;
|
|
213
|
+
if ((current & 0x80) === 0) {
|
|
214
|
+
return { value, bytes, ok: true };
|
|
215
|
+
}
|
|
216
|
+
shift += 7;
|
|
217
|
+
if (shift > 35) {
|
|
218
|
+
return { value: 0, bytes: 0, ok: false };
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return { value: 0, bytes: 0, ok: false };
|
|
222
|
+
};
|
|
223
|
+
const encodeVarint = (value) => {
|
|
224
|
+
const parts = [];
|
|
225
|
+
let remaining = value >>> 0;
|
|
226
|
+
while (remaining > 0x7f) {
|
|
227
|
+
parts.push((remaining & 0x7f) | 0x80);
|
|
228
|
+
remaining >>>= 7;
|
|
229
|
+
}
|
|
230
|
+
parts.push(remaining);
|
|
231
|
+
return Buffer.from(parts);
|
|
232
|
+
};
|
|
233
|
+
export const getMessageReportingToken = async (msgProtobuf, message, key) => {
|
|
234
|
+
const msgSecret = message.messageContextInfo?.messageSecret;
|
|
235
|
+
if (!msgSecret || !key.id) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
const from = key.fromMe ? key.remoteJid : key.participant || key.remoteJid;
|
|
239
|
+
const to = key.fromMe ? key.participant || key.remoteJid : key.remoteJid;
|
|
240
|
+
const reportingSecret = generateMsgSecretKey(ENC_SECRET_REPORT_TOKEN, key.id, from, to, msgSecret);
|
|
241
|
+
const content = extractReportingTokenContent(msgProtobuf, compiledReportingFields);
|
|
242
|
+
if (!content || content.length === 0) {
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
const reportingToken = createHmac('sha256', reportingSecret).update(content).digest().subarray(0, 16);
|
|
246
|
+
return {
|
|
247
|
+
tag: 'reporting',
|
|
248
|
+
attrs: {},
|
|
249
|
+
content: [
|
|
250
|
+
{
|
|
251
|
+
tag: 'reporting_token',
|
|
252
|
+
attrs: { v: '2' },
|
|
253
|
+
content: reportingToken
|
|
254
|
+
}
|
|
255
|
+
]
|
|
256
|
+
};
|
|
257
|
+
};
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { proto } from "../../WAProto/index.js";
|
|
2
|
+
export declare const JS_KEYWORDS: Set<string>;
|
|
3
|
+
export declare const PYTHON_KEYWORDS: Set<string>;
|
|
4
|
+
export declare const GO_KEYWORDS: Set<string>;
|
|
5
|
+
export declare const LUA_KEYWORDS: Set<string>;
|
|
6
|
+
export declare const BASH_KEYWORDS: Set<string>;
|
|
7
|
+
export declare const LANGUAGE_KEYWORDS: Record<string, Set<string>>;
|
|
8
|
+
export declare enum CodeHighlightType {
|
|
9
|
+
DEFAULT = 0,
|
|
10
|
+
KEYWORD = 1,
|
|
11
|
+
METHOD = 2,
|
|
12
|
+
STRING = 3,
|
|
13
|
+
NUMBER = 4,
|
|
14
|
+
COMMENT = 5,
|
|
15
|
+
}
|
|
16
|
+
export declare enum RichSubMessageType {
|
|
17
|
+
UNKNOWN = 0,
|
|
18
|
+
GRID_IMAGE = 1,
|
|
19
|
+
TEXT = 2,
|
|
20
|
+
INLINE_IMAGE = 3,
|
|
21
|
+
TABLE = 4,
|
|
22
|
+
CODE = 5,
|
|
23
|
+
DYNAMIC = 6,
|
|
24
|
+
MAP = 7,
|
|
25
|
+
LATEX = 8,
|
|
26
|
+
CONTENT_ITEMS = 9,
|
|
27
|
+
}
|
|
28
|
+
export interface RichMessageOptions {
|
|
29
|
+
headerText?: string;
|
|
30
|
+
footer?: string;
|
|
31
|
+
title?: string;
|
|
32
|
+
language?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface CodeBlockOptions extends RichMessageOptions {
|
|
35
|
+
language?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface LatexExpression {
|
|
38
|
+
latexExpression: string;
|
|
39
|
+
url: string;
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
fontHeight?: number;
|
|
43
|
+
imageTopPadding?: number;
|
|
44
|
+
imageLeadingPadding?: number;
|
|
45
|
+
imageBottomPadding?: number;
|
|
46
|
+
imageTrailingPadding?: number;
|
|
47
|
+
}
|
|
48
|
+
export interface LatexOptions extends RichMessageOptions {
|
|
49
|
+
text?: string;
|
|
50
|
+
expressions: LatexExpression[];
|
|
51
|
+
}
|
|
52
|
+
export interface LatexImageOptions extends RichMessageOptions {
|
|
53
|
+
text?: string;
|
|
54
|
+
expressions: {
|
|
55
|
+
latexExpression: string;
|
|
56
|
+
}[];
|
|
57
|
+
}
|
|
58
|
+
export type LatexRenderFn = (latex: string) => Promise<{
|
|
59
|
+
buffer: Buffer;
|
|
60
|
+
width: number;
|
|
61
|
+
height: number;
|
|
62
|
+
}>;
|
|
63
|
+
export type MediaUploadFn = (
|
|
64
|
+
imageBuffer: Buffer,
|
|
65
|
+
mediaType: string,
|
|
66
|
+
) => Promise<{
|
|
67
|
+
url: string;
|
|
68
|
+
directPath: string;
|
|
69
|
+
}>;
|
|
70
|
+
export interface UnifiedResponseOptions {
|
|
71
|
+
data: Buffer | Uint8Array;
|
|
72
|
+
headerText?: string;
|
|
73
|
+
footer?: string;
|
|
74
|
+
}
|
|
75
|
+
export interface CapturedUnifiedResponse {
|
|
76
|
+
unifiedResponse: {
|
|
77
|
+
data: Uint8Array;
|
|
78
|
+
};
|
|
79
|
+
submessages: any[];
|
|
80
|
+
contextInfo: any;
|
|
81
|
+
}
|
|
82
|
+
export interface QuotedMessage {
|
|
83
|
+
key: {
|
|
84
|
+
id?: string | null;
|
|
85
|
+
participant?: string | null;
|
|
86
|
+
remoteJid?: string | null;
|
|
87
|
+
fromMe?: boolean | null;
|
|
88
|
+
};
|
|
89
|
+
sender?: string;
|
|
90
|
+
message?: proto.IMessage | null;
|
|
91
|
+
}
|
|
92
|
+
interface CodeToken {
|
|
93
|
+
highlightType: number;
|
|
94
|
+
codeContent: string;
|
|
95
|
+
}
|
|
96
|
+
export declare const tokenizeCode: (
|
|
97
|
+
codeStr: string,
|
|
98
|
+
language?: string,
|
|
99
|
+
) => CodeToken[];
|
|
100
|
+
export declare const buildRichContextInfo: (
|
|
101
|
+
quoted?: QuotedMessage | null,
|
|
102
|
+
) => Record<string, any>;
|
|
103
|
+
export declare const buildBotForwardedMessage: (
|
|
104
|
+
submessages: any[],
|
|
105
|
+
contextInfo: Record<string, any>,
|
|
106
|
+
unifiedResponse?: {
|
|
107
|
+
data: Buffer | Uint8Array;
|
|
108
|
+
} | null,
|
|
109
|
+
) => any;
|
|
110
|
+
export declare const generateTableContent: (
|
|
111
|
+
title: string,
|
|
112
|
+
headers: string[],
|
|
113
|
+
rows: string[][],
|
|
114
|
+
quoted?: QuotedMessage | null,
|
|
115
|
+
options?: RichMessageOptions,
|
|
116
|
+
) => {
|
|
117
|
+
message: any;
|
|
118
|
+
messageId: string;
|
|
119
|
+
};
|
|
120
|
+
export declare const generateListContent: (
|
|
121
|
+
title: string,
|
|
122
|
+
items: (string | string[])[],
|
|
123
|
+
quoted?: QuotedMessage | null,
|
|
124
|
+
options?: RichMessageOptions,
|
|
125
|
+
) => {
|
|
126
|
+
message: any;
|
|
127
|
+
messageId: string;
|
|
128
|
+
};
|
|
129
|
+
export declare const generateCodeBlockContent: (
|
|
130
|
+
code: string,
|
|
131
|
+
quoted?: QuotedMessage | null,
|
|
132
|
+
options?: CodeBlockOptions,
|
|
133
|
+
) => {
|
|
134
|
+
message: any;
|
|
135
|
+
messageId: string;
|
|
136
|
+
};
|
|
137
|
+
export declare const generateLatexContent: (
|
|
138
|
+
quoted: QuotedMessage | null | undefined,
|
|
139
|
+
options: LatexOptions,
|
|
140
|
+
) => {
|
|
141
|
+
message: any;
|
|
142
|
+
messageId: string;
|
|
143
|
+
};
|
|
144
|
+
export declare const generateLatexImageContent: (
|
|
145
|
+
quoted: QuotedMessage | null | undefined,
|
|
146
|
+
options: LatexImageOptions,
|
|
147
|
+
uploadFn: MediaUploadFn,
|
|
148
|
+
renderLatexToPng: LatexRenderFn,
|
|
149
|
+
) => Promise<{
|
|
150
|
+
message: any;
|
|
151
|
+
messageId: string;
|
|
152
|
+
}>;
|
|
153
|
+
export declare const generateLatexInlineImageContent: (
|
|
154
|
+
quoted: QuotedMessage | null | undefined,
|
|
155
|
+
options: LatexImageOptions,
|
|
156
|
+
uploadFn: MediaUploadFn,
|
|
157
|
+
renderLatexToPng: LatexRenderFn,
|
|
158
|
+
) => Promise<{
|
|
159
|
+
message: any;
|
|
160
|
+
messageId: string;
|
|
161
|
+
}>;
|
|
162
|
+
export declare const captureUnifiedResponse: (
|
|
163
|
+
msg: proto.IMessage,
|
|
164
|
+
) => CapturedUnifiedResponse | null;
|
|
165
|
+
export declare const generateUnifiedResponseContent: (
|
|
166
|
+
quoted: QuotedMessage | null | undefined,
|
|
167
|
+
captured: CapturedUnifiedResponse,
|
|
168
|
+
) => {
|
|
169
|
+
message: any;
|
|
170
|
+
messageId: string;
|
|
171
|
+
};
|
|
172
|
+
export declare const generateRichMessageContent: (
|
|
173
|
+
submessages: any[],
|
|
174
|
+
quoted?: QuotedMessage | null,
|
|
175
|
+
) => {
|
|
176
|
+
message: any;
|
|
177
|
+
messageId: string;
|
|
178
|
+
};
|
|
179
|
+
export interface CodeBlockV2Options extends RichMessageOptions {
|
|
180
|
+
language?: string;
|
|
181
|
+
text?: string;
|
|
182
|
+
}
|
|
183
|
+
interface UnifiedCodeToken {
|
|
184
|
+
content: string;
|
|
185
|
+
type: "DEFAULT" | "KEYWORD" | "METHOD" | "STR" | "NUMBER" | "COMMENT";
|
|
186
|
+
}
|
|
187
|
+
interface TokenizeCodeV2Result {
|
|
188
|
+
codeBlock: CodeToken[];
|
|
189
|
+
unified_codeBlock: UnifiedCodeToken[];
|
|
190
|
+
}
|
|
191
|
+
export declare const tokenizeCodeV2: (
|
|
192
|
+
code: string,
|
|
193
|
+
language?: string,
|
|
194
|
+
) => TokenizeCodeV2Result;
|
|
195
|
+
interface UnifiedTableRow {
|
|
196
|
+
is_header: boolean;
|
|
197
|
+
cells: string[];
|
|
198
|
+
}
|
|
199
|
+
interface TableMetadataV2Result {
|
|
200
|
+
title: string;
|
|
201
|
+
rows: {
|
|
202
|
+
items: string[];
|
|
203
|
+
isHeading?: boolean;
|
|
204
|
+
}[];
|
|
205
|
+
unified_rows: UnifiedTableRow[];
|
|
206
|
+
}
|
|
207
|
+
export declare const toTableMetadataV2: (
|
|
208
|
+
arr: string[],
|
|
209
|
+
) => TableMetadataV2Result;
|
|
210
|
+
export interface TableV2Options extends RichMessageOptions {
|
|
211
|
+
text?: string;
|
|
212
|
+
}
|
|
213
|
+
export declare const generateTableContentV2: (
|
|
214
|
+
table: string[],
|
|
215
|
+
quoted?: QuotedMessage | null,
|
|
216
|
+
options?: TableV2Options,
|
|
217
|
+
) => {
|
|
218
|
+
message: any;
|
|
219
|
+
messageId: string;
|
|
220
|
+
};
|
|
221
|
+
export declare const generateCodeBlockContentV2: (
|
|
222
|
+
code: string,
|
|
223
|
+
quoted?: QuotedMessage | null,
|
|
224
|
+
options?: CodeBlockV2Options,
|
|
225
|
+
) => {
|
|
226
|
+
message: any;
|
|
227
|
+
messageId: string;
|
|
228
|
+
};
|
|
229
|
+
export interface Citation {
|
|
230
|
+
sourceQuery?: string;
|
|
231
|
+
faviconCdnUrl?: string;
|
|
232
|
+
citationNumber?: number;
|
|
233
|
+
sourceTitle?: string;
|
|
234
|
+
}
|
|
235
|
+
export interface Proof {
|
|
236
|
+
version?: number;
|
|
237
|
+
useCase?: number;
|
|
238
|
+
signature?: string;
|
|
239
|
+
certificateChain?: string[];
|
|
240
|
+
}
|
|
241
|
+
export interface LinkMessageOptions extends RichMessageOptions {
|
|
242
|
+
botJid?: string;
|
|
243
|
+
forwardingScore?: number;
|
|
244
|
+
citations?: Citation[];
|
|
245
|
+
proofs?: Proof[];
|
|
246
|
+
}
|
|
247
|
+
export interface LinkV2MessageOptions extends RichMessageOptions {
|
|
248
|
+
searchEngine?: string;
|
|
249
|
+
}
|
|
250
|
+
export declare const generateLinkContent: (
|
|
251
|
+
text: string,
|
|
252
|
+
links: (string | { url: string; displayName?: string })[],
|
|
253
|
+
quoted?: QuotedMessage | null,
|
|
254
|
+
options?: LinkMessageOptions,
|
|
255
|
+
) => {
|
|
256
|
+
message: any;
|
|
257
|
+
messageId: string;
|
|
258
|
+
};
|
|
259
|
+
export declare const generateLinkContentV2: (
|
|
260
|
+
text: string,
|
|
261
|
+
links: (
|
|
262
|
+
| string
|
|
263
|
+
| {
|
|
264
|
+
url: string;
|
|
265
|
+
displayName?: string;
|
|
266
|
+
sourceDisplayName?: string;
|
|
267
|
+
sourceSubtitle?: string;
|
|
268
|
+
}
|
|
269
|
+
)[],
|
|
270
|
+
quoted?: QuotedMessage | null,
|
|
271
|
+
options?: LinkV2MessageOptions,
|
|
272
|
+
) => {
|
|
273
|
+
message: any;
|
|
274
|
+
messageId: string;
|
|
275
|
+
};
|
|
276
|
+
export {};
|