@japofc/baileys 2.1.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/NOTICE.md +111 -0
- package/README.md +1254 -0
- package/WAProto/index.d.ts +9 -0
- package/WAProto/index.js +142276 -0
- package/engine-requirements.js +13 -0
- package/lib/Builders/A2UI.d.ts +242 -0
- package/lib/Builders/A2UI.js +308 -0
- package/lib/Builders/AIRich.d.ts +105 -0
- package/lib/Builders/AIRich.js +2286 -0
- package/lib/Builders/Button.d.ts +103 -0
- package/lib/Builders/Button.js +883 -0
- package/lib/Builders/ButtonV2.d.ts +28 -0
- package/lib/Builders/ButtonV2.js +144 -0
- package/lib/Builders/ButtonV3.d.ts +25 -0
- package/lib/Builders/ButtonV3.js +184 -0
- package/lib/Builders/Carousel.d.ts +22 -0
- package/lib/Builders/Carousel.js +111 -0
- package/lib/Builders/JapBaileys.d.ts +34 -0
- package/lib/Builders/JapBaileys.js +108 -0
- package/lib/Builders/Poll.d.ts +25 -0
- package/lib/Builders/Poll.js +128 -0
- package/lib/Builders/index.d.ts +17 -0
- package/lib/Builders/index.js +11 -0
- package/lib/Builders/shared.d.ts +67 -0
- package/lib/Builders/shared.js +652 -0
- package/lib/Defaults/index.d.ts +154 -0
- package/lib/Defaults/index.js +178 -0
- package/lib/Framework/Bot.d.ts +61 -0
- package/lib/Framework/Bot.js +248 -0
- package/lib/Framework/Context.d.ts +21 -0
- package/lib/Framework/Context.js +89 -0
- package/lib/Framework/MediaManager.d.ts +17 -0
- package/lib/Framework/MediaManager.js +151 -0
- package/lib/Framework/SessionManager.d.ts +13 -0
- package/lib/Framework/SessionManager.js +33 -0
- package/lib/Framework/StatsManager.d.ts +26 -0
- package/lib/Framework/StatsManager.js +119 -0
- package/lib/Framework/Store/SQLiteStore.d.ts +11 -0
- package/lib/Framework/Store/SQLiteStore.js +73 -0
- package/lib/Framework/index.d.ts +9 -0
- package/lib/Framework/index.js +10 -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 +7 -0
- package/lib/Signal/Group/group-session-builder.js +29 -0
- package/lib/Signal/Group/group_cipher.d.ts +10 -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 +6 -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 +11 -0
- package/lib/Signal/Group/sender-key-name.js +47 -0
- package/lib/Signal/Group/sender-key-record.d.ts +12 -0
- package/lib/Signal/Group/sender-key-record.js +40 -0
- package/lib/Signal/Group/sender-key-state.d.ts +16 -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 +54 -0
- package/lib/Signal/libsignal.js +430 -0
- package/lib/Signal/lid-mapping.d.ts +20 -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 +5 -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 +395 -0
- package/lib/Socket/business.js +379 -0
- package/lib/Socket/chats.d.ts +136 -0
- package/lib/Socket/chats.js +1327 -0
- package/lib/Socket/communities.d.ts +562 -0
- package/lib/Socket/communities.js +439 -0
- package/lib/Socket/dugong.d.ts +117 -0
- package/lib/Socket/dugong.js +798 -0
- package/lib/Socket/groups.d.ts +285 -0
- package/lib/Socket/groups.js +354 -0
- package/lib/Socket/index.d.ts +585 -0
- package/lib/Socket/index.js +52 -0
- package/lib/Socket/messages-recv.d.ts +333 -0
- package/lib/Socket/messages-recv.js +1781 -0
- package/lib/Socket/messages-send.d.ts +353 -0
- package/lib/Socket/messages-send.js +1524 -0
- package/lib/Socket/mex.d.ts +1 -0
- package/lib/Socket/mex.js +41 -0
- package/lib/Socket/newsletter.d.ts +286 -0
- package/lib/Socket/newsletter.js +364 -0
- package/lib/Socket/socket.d.ts +60 -0
- package/lib/Socket/socket.js +1012 -0
- package/lib/Socket/username.d.ts +82 -0
- package/lib/Socket/username.js +159 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/index.js +3 -0
- package/lib/Store/make-in-memory-store.d.ts +62 -0
- package/lib/Store/make-in-memory-store.js +428 -0
- package/lib/Store/make-ordered-dictionary.d.ts +12 -0
- package/lib/Store/make-ordered-dictionary.js +78 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Store/object-repository.js +23 -0
- package/lib/Types/Auth.d.ts +117 -0
- package/lib/Types/Auth.js +1 -0
- package/lib/Types/Bussines.d.ts +25 -0
- package/lib/Types/Call.d.ts +15 -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 +26 -0
- package/lib/Types/Contact.js +1 -0
- package/lib/Types/Events.d.ts +256 -0
- package/lib/Types/Events.js +1 -0
- package/lib/Types/GroupMetadata.d.ts +71 -0
- package/lib/Types/GroupMetadata.js +1 -0
- package/lib/Types/Label.d.ts +5 -0
- package/lib/Types/Label.js +24 -0
- package/lib/Types/LabelAssociation.d.ts +6 -0
- package/lib/Types/LabelAssociation.js +6 -0
- package/lib/Types/Message.d.ts +62 -0
- package/lib/Types/Message.js +17 -0
- package/lib/Types/Mex.d.ts +2 -0
- package/lib/Types/Mex.js +38 -0
- package/lib/Types/Product.d.ts +79 -0
- package/lib/Types/Product.js +1 -0
- package/lib/Types/RichType.d.ts +2 -0
- package/lib/Types/RichType.js +22 -0
- package/lib/Types/Signal.d.ts +87 -0
- package/lib/Types/Signal.js +1 -0
- package/lib/Types/Socket.d.ts +138 -0
- package/lib/Types/Socket.js +1 -0
- package/lib/Types/State.d.ts +8 -0
- package/lib/Types/State.js +55 -0
- package/lib/Types/USync.d.ts +26 -0
- package/lib/Types/index.d.ts +68 -0
- package/lib/Types/index.js +27 -0
- package/lib/Utils/MessageBuilder.d.ts +2 -0
- package/lib/Utils/MessageBuilder.js +2 -0
- package/lib/Utils/PersistentStore.d.ts +60 -0
- package/lib/Utils/PersistentStore.js +592 -0
- package/lib/Utils/anti-delete.d.ts +74 -0
- package/lib/Utils/anti-delete.js +221 -0
- package/lib/Utils/auth-secure.d.ts +86 -0
- package/lib/Utils/auth-secure.js +764 -0
- package/lib/Utils/auth-utils.d.ts +57 -0
- package/lib/Utils/auth-utils.js +306 -0
- package/lib/Utils/auto-reply.d.ts +47 -0
- package/lib/Utils/auto-reply.js +157 -0
- package/lib/Utils/baileys-event-stream.d.ts +8 -0
- package/lib/Utils/baileys-event-stream.js +62 -0
- package/lib/Utils/browser-utils.d.ts +8 -0
- package/lib/Utils/browser-utils.js +27 -0
- package/lib/Utils/business.d.ts +49 -0
- package/lib/Utils/business.js +239 -0
- package/lib/Utils/button-helper-utils.d.ts +53 -0
- package/lib/Utils/button-helper-utils.js +312 -0
- package/lib/Utils/button-sender.d.ts +54 -0
- package/lib/Utils/button-sender.js +822 -0
- package/lib/Utils/chat-control.d.ts +159 -0
- package/lib/Utils/chat-control.js +230 -0
- package/lib/Utils/chat-history-helpers.d.ts +21 -0
- package/lib/Utils/chat-history-helpers.js +70 -0
- package/lib/Utils/chat-utils.d.ts +407 -0
- package/lib/Utils/chat-utils.js +885 -0
- package/lib/Utils/companion-reg-client-utils.d.ts +4 -0
- package/lib/Utils/companion-reg-client-utils.js +39 -0
- package/lib/Utils/crypto.d.ts +41 -0
- package/lib/Utils/crypto.js +147 -0
- package/lib/Utils/decode-wa-message.d.ts +83 -0
- package/lib/Utils/decode-wa-message.js +316 -0
- package/lib/Utils/event-buffer.d.ts +12 -0
- package/lib/Utils/event-buffer.js +635 -0
- package/lib/Utils/generics.d.ts +69 -0
- package/lib/Utils/generics.js +438 -0
- package/lib/Utils/history-share.d.ts +11 -0
- package/lib/Utils/history-share.js +70 -0
- package/lib/Utils/history.d.ts +90 -0
- package/lib/Utils/history.js +146 -0
- package/lib/Utils/humanizer.d.ts +12 -0
- package/lib/Utils/humanizer.js +73 -0
- package/lib/Utils/identity-change-handler.d.ts +13 -0
- package/lib/Utils/identity-change-handler.js +49 -0
- package/lib/Utils/index.d.ts +57 -0
- package/lib/Utils/index.js +56 -0
- package/lib/Utils/jid-tools.d.ts +6 -0
- package/lib/Utils/jid-tools.js +77 -0
- package/lib/Utils/link-preview.d.ts +12 -0
- package/lib/Utils/link-preview.js +84 -0
- package/lib/Utils/logger.d.ts +4 -0
- package/lib/Utils/logger.js +2 -0
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/lt-hash.js +26 -0
- package/lib/Utils/make-mutex.d.ts +6 -0
- package/lib/Utils/make-mutex.js +32 -0
- package/lib/Utils/media-messages.d.ts +18 -0
- package/lib/Utils/media-messages.js +70 -0
- package/lib/Utils/media-set.d.ts +13 -0
- package/lib/Utils/media-set.js +171 -0
- package/lib/Utils/message-kind.d.ts +32 -0
- package/lib/Utils/message-kind.js +136 -0
- package/lib/Utils/message-retry-manager.d.ts +79 -0
- package/lib/Utils/message-retry-manager.js +264 -0
- package/lib/Utils/message-search.d.ts +44 -0
- package/lib/Utils/message-search.js +188 -0
- package/lib/Utils/messages-media.d.ts +135 -0
- package/lib/Utils/messages-media.js +868 -0
- package/lib/Utils/messages.d.ts +44 -0
- package/lib/Utils/messages.js +2326 -0
- package/lib/Utils/meta-ai.d.ts +13 -0
- package/lib/Utils/meta-ai.js +74 -0
- package/lib/Utils/mini-app.d.ts +35 -0
- package/lib/Utils/mini-app.js +213 -0
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/noise-handler.js +200 -0
- package/lib/Utils/offline-node-processor.d.ts +9 -0
- package/lib/Utils/offline-node-processor.js +39 -0
- package/lib/Utils/past-participants.d.ts +14 -0
- package/lib/Utils/past-participants.js +40 -0
- package/lib/Utils/pre-key-manager.d.ts +25 -0
- package/lib/Utils/pre-key-manager.js +105 -0
- package/lib/Utils/process-message.d.ts +82 -0
- package/lib/Utils/process-message.js +808 -0
- package/lib/Utils/qr-render.d.ts +59 -0
- package/lib/Utils/qr-render.js +179 -0
- package/lib/Utils/qrcodegen.d.ts +79 -0
- package/lib/Utils/qrcodegen.js +848 -0
- package/lib/Utils/reporting-utils.d.ts +12 -0
- package/lib/Utils/reporting-utils.js +257 -0
- package/lib/Utils/rich-message-utils.d.ts +48 -0
- package/lib/Utils/rich-message-utils.js +444 -0
- package/lib/Utils/router.d.ts +37 -0
- package/lib/Utils/router.js +165 -0
- package/lib/Utils/scheduled-posts.d.ts +30 -0
- package/lib/Utils/scheduled-posts.js +110 -0
- package/lib/Utils/scheduling.d.ts +42 -0
- package/lib/Utils/scheduling.js +139 -0
- package/lib/Utils/signal.d.ts +82 -0
- package/lib/Utils/signal.js +200 -0
- package/lib/Utils/stanza-ack.d.ts +16 -0
- package/lib/Utils/stanza-ack.js +37 -0
- package/lib/Utils/status.d.ts +50 -0
- package/lib/Utils/status.js +107 -0
- package/lib/Utils/stickerpack.d.ts +51 -0
- package/lib/Utils/stickerpack.js +274 -0
- package/lib/Utils/sync-action-utils.d.ts +2 -0
- package/lib/Utils/sync-action-utils.js +48 -0
- package/lib/Utils/tag.d.ts +12 -0
- package/lib/Utils/tag.js +44 -0
- package/lib/Utils/tc-token-utils.d.ts +29 -0
- package/lib/Utils/tc-token-utils.js +162 -0
- package/lib/Utils/templates.d.ts +76 -0
- package/lib/Utils/templates.js +150 -0
- package/lib/Utils/transcribe.d.ts +12 -0
- package/lib/Utils/transcribe.js +107 -0
- package/lib/Utils/use-cache-manager-auth-state.d.ts +13 -0
- package/lib/Utils/use-cache-manager-auth-state.js +81 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +10 -0
- package/lib/Utils/use-multi-file-auth-state.js +166 -0
- package/lib/Utils/use-single-file-auth-state.d.ts +10 -0
- package/lib/Utils/use-single-file-auth-state.js +113 -0
- package/lib/Utils/use-sqlite-auth-state.d.ts +11 -0
- package/lib/Utils/use-sqlite-auth-state.js +169 -0
- package/lib/Utils/validate-connection.d.ts +42 -0
- package/lib/Utils/validate-connection.js +198 -0
- package/lib/Utils/vcard.d.ts +58 -0
- package/lib/Utils/vcard.js +104 -0
- package/lib/Utils/voice-note.d.ts +15 -0
- package/lib/Utils/voice-note.js +63 -0
- package/lib/VoIP/audio-feeder.d.ts +18 -0
- package/lib/VoIP/audio-feeder.js +160 -0
- package/lib/VoIP/call-recorder.d.ts +13 -0
- package/lib/VoIP/call-recorder.js +73 -0
- package/lib/VoIP/index.d.ts +86 -0
- package/lib/VoIP/index.js +611 -0
- package/lib/VoIP/relay-transport.d.ts +43 -0
- package/lib/VoIP/relay-transport.js +563 -0
- package/lib/VoIP/signaling.d.ts +26 -0
- package/lib/VoIP/signaling.js +662 -0
- package/lib/VoIP/types.d.ts +69 -0
- package/lib/VoIP/types.js +17 -0
- package/lib/VoIP/wasm-engine.d.ts +120 -0
- package/lib/VoIP/wasm-engine.js +1358 -0
- package/lib/VoIP/worker-bootstrap.d.ts +4 -0
- package/lib/VoIP/worker-bootstrap.js +1046 -0
- package/lib/WABinary/constants.d.ts +61 -0
- package/lib/WABinary/constants.js +1466 -0
- package/lib/WABinary/decode.d.ts +9 -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 +74 -0
- package/lib/WABinary/generic-utils.js +276 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/index.js +5 -0
- package/lib/WABinary/jid-utils.d.ts +28 -0
- package/lib/WABinary/jid-utils.js +95 -0
- package/lib/WABinary/types.d.ts +19 -0
- package/lib/WABinary/types.js +1 -0
- package/lib/WAM/BinaryInfo.d.ts +7 -0
- package/lib/WAM/BinaryInfo.js +9 -0
- package/lib/WAM/constants.d.ts +34926 -0
- package/lib/WAM/constants.js +22852 -0
- package/lib/WAM/encode.d.ts +1 -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 +36 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +51 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +29 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +62 -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/USyncUsernameProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +24 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +38 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +14 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +28 -0
- package/lib/WAUSync/Protocols/index.d.ts +7 -0
- package/lib/WAUSync/Protocols/index.js +7 -0
- package/lib/WAUSync/USyncQuery.d.ts +20 -0
- package/lib/WAUSync/USyncQuery.js +121 -0
- package/lib/WAUSync/USyncUser.d.ts +16 -0
- package/lib/WAUSync/USyncUser.js +30 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/WAUSync/index.js +3 -0
- package/lib/assets/wasm/loader.d.ts +5 -0
- package/lib/assets/wasm/loader.js +5 -0
- package/lib/assets/wasm/whatsapp.wasm +0 -0
- package/lib/assets/wasm/worker-modules.d.ts +5 -0
- package/lib/assets/wasm/worker-modules.js +273 -0
- package/lib/index.d.ts +18 -0
- package/lib/index.js +23 -0
- package/package.json +180 -0
- package/postinstall-banner.js +82 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function shouldIncludeReportingToken(message: any): boolean;
|
|
2
|
+
export function getMessageReportingToken(msgProtobuf: any, message: any, key: any): Promise<{
|
|
3
|
+
tag: string;
|
|
4
|
+
attrs: {};
|
|
5
|
+
content: {
|
|
6
|
+
tag: string;
|
|
7
|
+
attrs: {
|
|
8
|
+
v: string;
|
|
9
|
+
};
|
|
10
|
+
content: any;
|
|
11
|
+
}[];
|
|
12
|
+
} | null>;
|
|
@@ -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,48 @@
|
|
|
1
|
+
export function tokenizeCode(code: any, language?: string): {
|
|
2
|
+
highlightType: any;
|
|
3
|
+
codeContent: string;
|
|
4
|
+
}[];
|
|
5
|
+
export function toUnified(submessages: any, uuid: any): {
|
|
6
|
+
response_id: any;
|
|
7
|
+
sections: any;
|
|
8
|
+
};
|
|
9
|
+
export function prepareRichResponseMessage(content: any): {
|
|
10
|
+
messageContextInfo: {
|
|
11
|
+
botMetadata: {
|
|
12
|
+
verificationMetadata: {
|
|
13
|
+
proofs: {
|
|
14
|
+
certificateChain: Uint8Array<ArrayBuffer>[];
|
|
15
|
+
version: number;
|
|
16
|
+
useCase: number;
|
|
17
|
+
signature: Uint8Array<ArrayBuffer>;
|
|
18
|
+
}[];
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
botForwardedMessage: {
|
|
23
|
+
message: {
|
|
24
|
+
richResponseMessage: any;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export function botMetadataSignature(): Uint8Array<ArrayBuffer>;
|
|
29
|
+
export function botMetadataCertificate(length?: number): Uint8Array<ArrayBuffer>;
|
|
30
|
+
export function wrapToBotForwardedMessage(richResponseMessage: any): {
|
|
31
|
+
messageContextInfo: {
|
|
32
|
+
botMetadata: {
|
|
33
|
+
verificationMetadata: {
|
|
34
|
+
proofs: {
|
|
35
|
+
certificateChain: Uint8Array<ArrayBuffer>[];
|
|
36
|
+
version: number;
|
|
37
|
+
useCase: number;
|
|
38
|
+
signature: Uint8Array<ArrayBuffer>;
|
|
39
|
+
}[];
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
botForwardedMessage: {
|
|
44
|
+
message: {
|
|
45
|
+
richResponseMessage: any;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
};
|