@deffa5556/bail 1.0.6 → 1.0.9
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/cjs/WAProto/index.cjs +106053 -0
- package/cjs/deffa/config.cjs +14 -0
- package/cjs/deffa/plugins/ai/deepseekr1.cjs +35 -0
- package/cjs/deffa/plugins/ai/gita.cjs +26 -0
- package/cjs/deffa/plugins/ai/glm47flash.cjs +35 -0
- package/cjs/deffa/plugins/ai/gptoss120b.cjs +35 -0
- package/cjs/deffa/plugins/ai/qwq32b.cjs +35 -0
- package/cjs/deffa/plugins/berita/antara.cjs +25 -0
- package/cjs/deffa/plugins/berita/cnbcindonesia.cjs +25 -0
- package/cjs/deffa/plugins/berita/cnn.cjs +25 -0
- package/cjs/deffa/plugins/berita/kompas.cjs +25 -0
- package/cjs/deffa/plugins/berita/liputan6.cjs +25 -0
- package/cjs/deffa/plugins/berita/merdeka.cjs +25 -0
- package/cjs/deffa/plugins/berita/sindonews.cjs +25 -0
- package/cjs/deffa/plugins/berita/tribunnews.cjs +25 -0
- package/cjs/deffa/plugins/downloader/douyin.cjs +30 -0
- package/cjs/deffa/plugins/downloader/facebook.cjs +30 -0
- package/cjs/deffa/plugins/downloader/github.cjs +35 -0
- package/cjs/deffa/plugins/downloader/lahelu.cjs +30 -0
- package/cjs/deffa/plugins/downloader/snackvideo.cjs +30 -0
- package/cjs/deffa/plugins/downloader/soundcloud.cjs +30 -0
- package/cjs/deffa/plugins/downloader/tiktok.cjs +30 -0
- package/cjs/deffa/plugins/downloader/tiktokhd.cjs +30 -0
- package/cjs/deffa/plugins/downloader/twitter.cjs +30 -0
- package/cjs/deffa/plugins/downloader/ummy.cjs +36 -0
- package/cjs/deffa/plugins/index.cjs +213 -0
- package/cjs/deffa/plugins/info/bmkg.cjs +34 -0
- package/cjs/deffa/plugins/info/cuaca.cjs +31 -0
- package/cjs/deffa/plugins/info/jadwaltv.cjs +29 -0
- package/cjs/deffa/plugins/maker/brat.cjs +45 -0
- package/cjs/deffa/plugins/maker/bratvid.cjs +52 -0
- package/cjs/deffa/plugins/search/8font.cjs +28 -0
- package/cjs/deffa/plugins/search/applemusic.cjs +28 -0
- package/cjs/deffa/plugins/search/bimg.cjs +30 -0
- package/cjs/deffa/plugins/search/brave.cjs +34 -0
- package/cjs/deffa/plugins/search/duckduckgo.cjs +28 -0
- package/cjs/deffa/plugins/search/lahelu.cjs +28 -0
- package/cjs/deffa/plugins/search/mangatoon.cjs +28 -0
- package/cjs/deffa/plugins/search/mcpedl.cjs +28 -0
- package/cjs/deffa/plugins/search/myinstants.cjs +28 -0
- package/cjs/deffa/plugins/search/otakotaku.cjs +28 -0
- package/cjs/deffa/plugins/search/pinterest.cjs +30 -0
- package/cjs/deffa/plugins/search/resep.cjs +28 -0
- package/cjs/deffa/plugins/search/seegore.cjs +30 -0
- package/cjs/deffa/plugins/search/soundcloud.cjs +28 -0
- package/cjs/deffa/plugins/search/youtube.cjs +28 -0
- package/cjs/deffa/plugins/stalk/github.cjs +38 -0
- package/cjs/deffa/plugins/stalk/pinterest.cjs +37 -0
- package/cjs/deffa/plugins/stalk/threads.cjs +34 -0
- package/cjs/deffa/plugins/stalk/tiktok.cjs +37 -0
- package/cjs/deffa/plugins/stalk/twitter.cjs +37 -0
- package/cjs/deffa/plugins/stalk/youtube.cjs +37 -0
- package/cjs/lib/Defaults/index.cjs +158 -0
- package/cjs/lib/Discord/Client.cjs +263 -0
- package/cjs/lib/Discord/Constants.cjs +1842 -0
- package/cjs/lib/Discord/connect-dc.cjs +11 -0
- package/cjs/lib/Discord/esm-bridge.cjs +136 -0
- package/cjs/lib/Discord/gateway/Dispatcher.cjs +93 -0
- package/cjs/lib/Discord/gateway/Shard.cjs +695 -0
- package/cjs/lib/Discord/gateway/ShardManager.cjs +344 -0
- package/cjs/lib/Discord/gateway/compression/base.cjs +13 -0
- package/cjs/lib/Discord/gateway/compression/config.cjs +47 -0
- package/cjs/lib/Discord/gateway/compression/pako.cjs +44 -0
- package/cjs/lib/Discord/gateway/compression/zlib-native.cjs +47 -0
- package/cjs/lib/Discord/gateway/compression/zlib-sync.cjs +31 -0
- package/cjs/lib/Discord/gateway/compression/zstd-napi.cjs +80 -0
- package/cjs/lib/Discord/gateway/compression/zstd-native.cjs +46 -0
- package/cjs/lib/Discord/gateway/events.cjs +956 -0
- package/cjs/lib/Discord/index.cjs +238 -0
- package/cjs/lib/Discord/rest/Bucket.cjs +69 -0
- package/cjs/lib/Discord/rest/DiscordHTTPError.cjs +63 -0
- package/cjs/lib/Discord/rest/DiscordRESTError.cjs +84 -0
- package/cjs/lib/Discord/rest/OAuthHelper.cjs +226 -0
- package/cjs/lib/Discord/rest/RESTManager.cjs +116 -0
- package/cjs/lib/Discord/rest/RequestHandler.cjs +320 -0
- package/cjs/lib/Discord/rest/SequentialBucket.cjs +69 -0
- package/cjs/lib/Discord/routes/Applications.cjs +625 -0
- package/cjs/lib/Discord/routes/Channels.cjs +1199 -0
- package/cjs/lib/Discord/routes/Guilds.cjs +1792 -0
- package/cjs/lib/Discord/routes/Interactions.cjs +212 -0
- package/cjs/lib/Discord/routes/Lobbies.cjs +197 -0
- package/cjs/lib/Discord/routes/Miscellaneous.cjs +120 -0
- package/cjs/lib/Discord/routes/OAuth.cjs +350 -0
- package/cjs/lib/Discord/routes/Users.cjs +107 -0
- package/cjs/lib/Discord/routes/Webhooks.cjs +308 -0
- package/cjs/lib/Discord/structures/AnnouncementChannel.cjs +46 -0
- package/cjs/lib/Discord/structures/AnnouncementThreadChannel.cjs +28 -0
- package/cjs/lib/Discord/structures/Application.cjs +345 -0
- package/cjs/lib/Discord/structures/ApplicationCommand.cjs +109 -0
- package/cjs/lib/Discord/structures/Attachment.cjs +46 -0
- package/cjs/lib/Discord/structures/AuditLogEntry.cjs +41 -0
- package/cjs/lib/Discord/structures/AutoModerationRule.cjs +117 -0
- package/cjs/lib/Discord/structures/AutocompleteInteraction.cjs +90 -0
- package/cjs/lib/Discord/structures/Base.cjs +56 -0
- package/cjs/lib/Discord/structures/BaseEntitlement.cjs +40 -0
- package/cjs/lib/Discord/structures/CategoryChannel.cjs +102 -0
- package/cjs/lib/Discord/structures/Channel.cjs +89 -0
- package/cjs/lib/Discord/structures/ClientApplication.cjs +269 -0
- package/cjs/lib/Discord/structures/CommandInteraction.cjs +294 -0
- package/cjs/lib/Discord/structures/ComponentInteraction.cjs +306 -0
- package/cjs/lib/Discord/structures/Entitlement.cjs +24 -0
- package/cjs/lib/Discord/structures/ExtendedUser.cjs +48 -0
- package/cjs/lib/Discord/structures/ForumChannel.cjs +20 -0
- package/cjs/lib/Discord/structures/GroupChannel.cjs +160 -0
- package/cjs/lib/Discord/structures/Guild.cjs +1289 -0
- package/cjs/lib/Discord/structures/GuildChannel.cjs +82 -0
- package/cjs/lib/Discord/structures/GuildPreview.cjs +141 -0
- package/cjs/lib/Discord/structures/GuildScheduledEvent.cjs +166 -0
- package/cjs/lib/Discord/structures/GuildTemplate.cjs +96 -0
- package/cjs/lib/Discord/structures/Integration.cjs +123 -0
- package/cjs/lib/Discord/structures/Interaction.cjs +78 -0
- package/cjs/lib/Discord/structures/InteractionResolvedChannel.cjs +36 -0
- package/cjs/lib/Discord/structures/Invite.cjs +196 -0
- package/cjs/lib/Discord/structures/InviteGuild.cjs +117 -0
- package/cjs/lib/Discord/structures/InviteRole.cjs +88 -0
- package/cjs/lib/Discord/structures/Lobby.cjs +84 -0
- package/cjs/lib/Discord/structures/LobbyMember.cjs +30 -0
- package/cjs/lib/Discord/structures/MediaChannel.cjs +20 -0
- package/cjs/lib/Discord/structures/Member.cjs +300 -0
- package/cjs/lib/Discord/structures/Message.cjs +553 -0
- package/cjs/lib/Discord/structures/ModalSubmitInteraction.cjs +263 -0
- package/cjs/lib/Discord/structures/OAuthApplication.cjs +203 -0
- package/cjs/lib/Discord/structures/OAuthGuild.cjs +98 -0
- package/cjs/lib/Discord/structures/PartialApplication.cjs +97 -0
- package/cjs/lib/Discord/structures/Permission.cjs +61 -0
- package/cjs/lib/Discord/structures/PermissionOverwrite.cjs +46 -0
- package/cjs/lib/Discord/structures/PingInteraction.cjs +27 -0
- package/cjs/lib/Discord/structures/Poll.cjs +69 -0
- package/cjs/lib/Discord/structures/PrimaryGuild.cjs +93 -0
- package/cjs/lib/Discord/structures/PrivateChannel.cjs +131 -0
- package/cjs/lib/Discord/structures/PrivateThreadChannel.cjs +28 -0
- package/cjs/lib/Discord/structures/PublicThreadChannel.cjs +36 -0
- package/cjs/lib/Discord/structures/Role.cjs +126 -0
- package/cjs/lib/Discord/structures/SKU.cjs +58 -0
- package/cjs/lib/Discord/structures/Soundboard.cjs +58 -0
- package/cjs/lib/Discord/structures/StageChannel.cjs +45 -0
- package/cjs/lib/Discord/structures/StageInstance.cjs +80 -0
- package/cjs/lib/Discord/structures/Subscription.cjs +21 -0
- package/cjs/lib/Discord/structures/Team.cjs +70 -0
- package/cjs/lib/Discord/structures/TestEntitlement.cjs +22 -0
- package/cjs/lib/Discord/structures/TextChannel.cjs +48 -0
- package/cjs/lib/Discord/structures/TextableChannel.cjs +265 -0
- package/cjs/lib/Discord/structures/TextableVoiceChannel.cjs +70 -0
- package/cjs/lib/Discord/structures/ThreadChannel.cjs +276 -0
- package/cjs/lib/Discord/structures/ThreadOnlyChannel.cjs +205 -0
- package/cjs/lib/Discord/structures/ThreadableChannel.cjs +57 -0
- package/cjs/lib/Discord/structures/UnavailableGuild.cjs +21 -0
- package/cjs/lib/Discord/structures/User.cjs +223 -0
- package/cjs/lib/Discord/structures/VoiceChannel.cjs +34 -0
- package/cjs/lib/Discord/structures/VoiceState.cjs +113 -0
- package/cjs/lib/Discord/structures/Webhook.cjs +224 -0
- package/cjs/lib/Discord/util/Collection.cjs +77 -0
- package/cjs/lib/Discord/util/Errors.cjs +81 -0
- package/cjs/lib/Discord/util/QueryBuilder.cjs +20 -0
- package/cjs/lib/Discord/util/Routes.cjs +293 -0
- package/cjs/lib/Discord/util/SimpleCollection.cjs +78 -0
- package/cjs/lib/Discord/util/Time.cjs +92 -0
- package/cjs/lib/Discord/util/TypedCollection.cjs +78 -0
- package/cjs/lib/Discord/util/TypedEmitter.cjs +20 -0
- package/cjs/lib/Discord/util/Util.cjs +906 -0
- package/cjs/lib/Discord/util/interactions/InteractionOptionsWrapper.cjs +207 -0
- package/cjs/lib/Discord/util/interactions/MessageInteractionResponse.cjs +26 -0
- package/cjs/lib/Discord/util/interactions/ModalSubmitInteractionComponentsWrapper.cjs +98 -0
- package/cjs/lib/Discord/util/interactions/SelectMenuValuesWrapper.cjs +77 -0
- package/cjs/lib/Discord/util/interactions/shared.cjs +20 -0
- package/cjs/lib/Discord/util/warning.cjs +34 -0
- package/cjs/lib/Signal/Group/ciphertext-message.cjs +16 -0
- package/cjs/lib/Signal/Group/group-session-builder.cjs +67 -0
- package/cjs/lib/Signal/Group/group_cipher.cjs +86 -0
- package/cjs/lib/Signal/Group/index.cjs +58 -0
- package/cjs/lib/Signal/Group/keyhelper.cjs +56 -0
- package/cjs/lib/Signal/Group/sender-chain-key.cjs +30 -0
- package/cjs/lib/Signal/Group/sender-key-distribution-message.cjs +67 -0
- package/cjs/lib/Signal/Group/sender-key-message.cjs +70 -0
- package/cjs/lib/Signal/Group/sender-key-name.cjs +52 -0
- package/cjs/lib/Signal/Group/sender-key-record.cjs +45 -0
- package/cjs/lib/Signal/Group/sender-key-state.cjs +88 -0
- package/cjs/lib/Signal/Group/sender-message-key.cjs +30 -0
- package/cjs/lib/Signal/libsignal.cjs +467 -0
- package/cjs/lib/Signal/lid-mapping.cjs +281 -0
- package/cjs/lib/Socket/Client/index.cjs +19 -0
- package/cjs/lib/Socket/Client/types.cjs +15 -0
- package/cjs/lib/Socket/Client/websocket.cjs +61 -0
- package/cjs/lib/Socket/business.cjs +384 -0
- package/cjs/lib/Socket/chats.cjs +1221 -0
- package/cjs/lib/Socket/communities.cjs +440 -0
- package/cjs/lib/Socket/groups.cjs +353 -0
- package/cjs/lib/Socket/index.cjs +14 -0
- package/cjs/lib/Socket/messages-recv.cjs +1772 -0
- package/cjs/lib/Socket/messages-send.cjs +1376 -0
- package/cjs/lib/Socket/mex.cjs +46 -0
- package/cjs/lib/Socket/newsletter.cjs +230 -0
- package/cjs/lib/Socket/socket.cjs +976 -0
- package/cjs/lib/Store/index.cjs +20 -0
- package/cjs/lib/Store/make-in-memory-store.cjs +470 -0
- package/cjs/lib/Store/make-ordered-dictionary.cjs +82 -0
- package/cjs/lib/Store/object-repository.cjs +28 -0
- package/cjs/lib/Telegram/button.cjs +147 -0
- package/cjs/lib/Telegram/composer.cjs +582 -0
- package/cjs/lib/Telegram/context.cjs +853 -0
- package/cjs/lib/Telegram/core/helpers/args.cjs +57 -0
- package/cjs/lib/Telegram/core/helpers/check.cjs +55 -0
- package/cjs/lib/Telegram/core/helpers/compact.cjs +16 -0
- package/cjs/lib/Telegram/core/helpers/deunionize.cjs +12 -0
- package/cjs/lib/Telegram/core/helpers/formatting.cjs +91 -0
- package/cjs/lib/Telegram/core/helpers/util.cjs +50 -0
- package/cjs/lib/Telegram/core/network/client.cjs +338 -0
- package/cjs/lib/Telegram/core/network/error.cjs +21 -0
- package/cjs/lib/Telegram/core/network/multipart-stream.cjs +79 -0
- package/cjs/lib/Telegram/core/network/polling.cjs +87 -0
- package/cjs/lib/Telegram/core/network/webhook.cjs +54 -0
- package/cjs/lib/Telegram/core/types/typegram.cjs +31 -0
- package/cjs/lib/Telegram/deffa-telegraf.cjs +264 -0
- package/cjs/lib/Telegram/esm-bridge.cjs +20 -0
- package/cjs/lib/Telegram/filters.cjs +69 -0
- package/cjs/lib/Telegram/format.cjs +58 -0
- package/cjs/lib/Telegram/future.cjs +140 -0
- package/cjs/lib/Telegram/index.cjs +67 -0
- package/cjs/lib/Telegram/input.cjs +61 -0
- package/cjs/lib/Telegram/markup.cjs +129 -0
- package/cjs/lib/Telegram/middleware.cjs +2 -0
- package/cjs/lib/Telegram/reactions.cjs +84 -0
- package/cjs/lib/Telegram/router.cjs +46 -0
- package/cjs/lib/Telegram/scenes/base.cjs +39 -0
- package/cjs/lib/Telegram/scenes/context.cjs +104 -0
- package/cjs/lib/Telegram/scenes/index.cjs +21 -0
- package/cjs/lib/Telegram/scenes/stage.cjs +49 -0
- package/cjs/lib/Telegram/scenes/wizard/context.cjs +31 -0
- package/cjs/lib/Telegram/scenes/wizard/index.cjs +45 -0
- package/cjs/lib/Telegram/scenes.cjs +21 -0
- package/cjs/lib/Telegram/session.cjs +166 -0
- package/cjs/lib/Telegram/telegram-types.cjs +6 -0
- package/cjs/lib/Telegram/telegram.cjs +945 -0
- package/cjs/lib/Telegram/types.cjs +2 -0
- package/cjs/lib/Telegram/utils.cjs +5 -0
- package/cjs/lib/Types/Auth.cjs +3 -0
- package/cjs/lib/Types/Bussines.cjs +3 -0
- package/cjs/lib/Types/Call.cjs +3 -0
- package/cjs/lib/Types/Chat.cjs +11 -0
- package/cjs/lib/Types/Contact.cjs +3 -0
- package/cjs/lib/Types/Events.cjs +4 -0
- package/cjs/lib/Types/GroupMetadata.cjs +3 -0
- package/cjs/lib/Types/Label.cjs +26 -0
- package/cjs/lib/Types/LabelAssociation.cjs +8 -0
- package/cjs/lib/Types/Message.cjs +19 -0
- package/cjs/lib/Types/Mex.cjs +40 -0
- package/cjs/lib/Types/Product.cjs +3 -0
- package/cjs/lib/Types/RichType.cjs +24 -0
- package/cjs/lib/Types/Signal.cjs +4 -0
- package/cjs/lib/Types/Socket.cjs +4 -0
- package/cjs/lib/Types/State.cjs +54 -0
- package/cjs/lib/Types/USync.cjs +4 -0
- package/cjs/lib/Types/index.cjs +42 -0
- package/cjs/lib/Utils/auth-utils.cjs +312 -0
- package/cjs/lib/Utils/browser-utils.cjs +39 -0
- package/cjs/lib/Utils/business.cjs +241 -0
- package/cjs/lib/Utils/chat-utils.cjs +890 -0
- package/cjs/lib/Utils/companion-reg-client-utils.cjs +51 -0
- package/cjs/lib/Utils/crypto.cjs +170 -0
- package/cjs/lib/Utils/decode-wa-message.cjs +330 -0
- package/cjs/lib/Utils/event-buffer.cjs +629 -0
- package/cjs/lib/Utils/generics.cjs +427 -0
- package/cjs/lib/Utils/history.cjs +141 -0
- package/cjs/lib/Utils/identity-change-handler.cjs +56 -0
- package/cjs/lib/Utils/index.cjs +43 -0
- package/cjs/lib/Utils/link-preview.cjs +122 -0
- package/cjs/lib/Utils/logger.cjs +8 -0
- package/cjs/lib/Utils/lt-hash.cjs +11 -0
- package/cjs/lib/Utils/make-mutex.cjs +38 -0
- package/cjs/lib/Utils/message-retry-manager.cjs +267 -0
- package/cjs/lib/Utils/messages-media.cjs +906 -0
- package/cjs/lib/Utils/messages.cjs +1909 -0
- package/cjs/lib/Utils/noise-handler.cjs +205 -0
- package/cjs/lib/Utils/offline-node-processor.cjs +43 -0
- package/cjs/lib/Utils/pre-key-manager.cjs +113 -0
- package/cjs/lib/Utils/process-message.cjs +755 -0
- package/cjs/lib/Utils/reporting-utils.cjs +263 -0
- package/cjs/lib/Utils/rich-message-utils.cjs +434 -0
- package/cjs/lib/Utils/session-guard.cjs +163 -0
- package/cjs/lib/Utils/signal.cjs +214 -0
- package/cjs/lib/Utils/stanza-ack.cjs +41 -0
- package/cjs/lib/Utils/sync-action-utils.cjs +54 -0
- package/cjs/lib/Utils/tc-token-utils.cjs +174 -0
- package/cjs/lib/Utils/text-sticker.cjs +174 -0
- package/cjs/lib/Utils/use-multi-file-auth-state.cjs +125 -0
- package/cjs/lib/Utils/use-single-file-auth-state.cjs +113 -0
- package/cjs/lib/Utils/use-sqlite-auth-state.cjs +145 -0
- package/cjs/lib/Utils/validate-connection.cjs +210 -0
- package/cjs/lib/WABinary/constants.cjs +1470 -0
- package/cjs/lib/WABinary/decode.cjs +301 -0
- package/cjs/lib/WABinary/encode.cjs +257 -0
- package/cjs/lib/WABinary/generic-utils.cjs +240 -0
- package/cjs/lib/WABinary/index.cjs +22 -0
- package/cjs/lib/WABinary/jid-utils.cjs +114 -0
- package/cjs/lib/WABinary/types.cjs +37 -0
- package/cjs/lib/WAM/BinaryInfo.cjs +14 -0
- package/cjs/lib/WAM/constants.cjs +22856 -0
- package/cjs/lib/WAM/encode.cjs +154 -0
- package/cjs/lib/WAM/index.cjs +20 -0
- package/cjs/lib/WAUSync/Protocols/USyncContactProtocol.cjs +56 -0
- package/cjs/lib/WAUSync/Protocols/USyncDeviceProtocol.cjs +58 -0
- package/cjs/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.cjs +31 -0
- package/cjs/lib/WAUSync/Protocols/USyncStatusProtocol.cjs +42 -0
- package/cjs/lib/WAUSync/Protocols/USyncUsernameProtocol.cjs +29 -0
- package/cjs/lib/WAUSync/Protocols/UsyncBotProfileProtocol.cjs +55 -0
- package/cjs/lib/WAUSync/Protocols/UsyncLIDProtocol.cjs +33 -0
- package/cjs/lib/WAUSync/Protocols/index.cjs +22 -0
- package/cjs/lib/WAUSync/USyncQuery.cjs +102 -0
- package/cjs/lib/WAUSync/USyncUser.cjs +35 -0
- package/cjs/lib/WAUSync/index.cjs +20 -0
- package/cjs/lib/index.cjs +372 -0
- package/cjs/lib/plugins/loader.cjs +117 -0
- package/lib/Defaults/index.js +1 -1
- package/lib/Socket/socket.js +3 -3
- package/lib/Telegram/esm-bridge.mjs +1 -1
- package/package.json +11 -6
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeNoiseHandler = void 0;
|
|
4
|
+
const boom_1 = require("@hapi/boom");
|
|
5
|
+
const index_js_1 = require("../../WAProto/index.cjs");
|
|
6
|
+
const index_js_2 = require("../Defaults/index.cjs");
|
|
7
|
+
const index_js_3 = require("../WABinary/index.cjs");
|
|
8
|
+
const crypto_js_1 = require("./crypto.cjs");
|
|
9
|
+
const IV_LENGTH = 12;
|
|
10
|
+
const EMPTY_BUFFER = Buffer.alloc(0);
|
|
11
|
+
const generateIV = (counter) => {
|
|
12
|
+
const iv = new ArrayBuffer(IV_LENGTH);
|
|
13
|
+
new DataView(iv).setUint32(8, counter);
|
|
14
|
+
return new Uint8Array(iv);
|
|
15
|
+
};
|
|
16
|
+
class TransportState {
|
|
17
|
+
constructor(encKey, decKey) {
|
|
18
|
+
this.encKey = encKey;
|
|
19
|
+
this.decKey = decKey;
|
|
20
|
+
this.readCounter = 0;
|
|
21
|
+
this.writeCounter = 0;
|
|
22
|
+
this.iv = new Uint8Array(IV_LENGTH);
|
|
23
|
+
}
|
|
24
|
+
encrypt(plaintext) {
|
|
25
|
+
const c = this.writeCounter++;
|
|
26
|
+
this.iv[8] = (c >>> 24) & 0xff;
|
|
27
|
+
this.iv[9] = (c >>> 16) & 0xff;
|
|
28
|
+
this.iv[10] = (c >>> 8) & 0xff;
|
|
29
|
+
this.iv[11] = c & 0xff;
|
|
30
|
+
return (0, crypto_js_1.aesEncryptGCM)(plaintext, this.encKey, this.iv, EMPTY_BUFFER);
|
|
31
|
+
}
|
|
32
|
+
decrypt(ciphertext) {
|
|
33
|
+
const c = this.readCounter++;
|
|
34
|
+
this.iv[8] = (c >>> 24) & 0xff;
|
|
35
|
+
this.iv[9] = (c >>> 16) & 0xff;
|
|
36
|
+
this.iv[10] = (c >>> 8) & 0xff;
|
|
37
|
+
this.iv[11] = c & 0xff;
|
|
38
|
+
return (0, crypto_js_1.aesDecryptGCM)(ciphertext, this.decKey, this.iv, EMPTY_BUFFER);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey }, NOISE_HEADER, logger, routingInfo }) => {
|
|
42
|
+
logger = logger.child({ class: 'ns' });
|
|
43
|
+
const data = Buffer.from(index_js_2.NOISE_MODE);
|
|
44
|
+
let hash = data.byteLength === 32 ? data : (0, crypto_js_1.sha256)(data);
|
|
45
|
+
let salt = hash;
|
|
46
|
+
let encKey = hash;
|
|
47
|
+
let decKey = hash;
|
|
48
|
+
let counter = 0;
|
|
49
|
+
let sentIntro = false;
|
|
50
|
+
let inBytes = Buffer.alloc(0);
|
|
51
|
+
let transport = null;
|
|
52
|
+
let isWaitingForTransport = false;
|
|
53
|
+
let pendingOnFrame = null;
|
|
54
|
+
let introHeader;
|
|
55
|
+
if (routingInfo) {
|
|
56
|
+
introHeader = Buffer.alloc(7 + routingInfo.byteLength + NOISE_HEADER.length);
|
|
57
|
+
introHeader.write('ED', 0, 'utf8');
|
|
58
|
+
introHeader.writeUint8(0, 2);
|
|
59
|
+
introHeader.writeUint8(1, 3);
|
|
60
|
+
introHeader.writeUint8(routingInfo.byteLength >> 16, 4);
|
|
61
|
+
introHeader.writeUint16BE(routingInfo.byteLength & 65535, 5);
|
|
62
|
+
introHeader.set(routingInfo, 7);
|
|
63
|
+
introHeader.set(NOISE_HEADER, 7 + routingInfo.byteLength);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
introHeader = Buffer.from(NOISE_HEADER);
|
|
67
|
+
}
|
|
68
|
+
const authenticate = (data) => {
|
|
69
|
+
if (!transport) {
|
|
70
|
+
hash = (0, crypto_js_1.sha256)(Buffer.concat([hash, data]));
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const encrypt = (plaintext) => {
|
|
74
|
+
if (transport) {
|
|
75
|
+
return transport.encrypt(plaintext);
|
|
76
|
+
}
|
|
77
|
+
const result = (0, crypto_js_1.aesEncryptGCM)(plaintext, encKey, generateIV(counter++), hash);
|
|
78
|
+
authenticate(result);
|
|
79
|
+
return result;
|
|
80
|
+
};
|
|
81
|
+
const decrypt = (ciphertext) => {
|
|
82
|
+
if (transport) {
|
|
83
|
+
return transport.decrypt(ciphertext);
|
|
84
|
+
}
|
|
85
|
+
const result = (0, crypto_js_1.aesDecryptGCM)(ciphertext, decKey, generateIV(counter++), hash);
|
|
86
|
+
authenticate(ciphertext);
|
|
87
|
+
return result;
|
|
88
|
+
};
|
|
89
|
+
const localHKDF = (data) => {
|
|
90
|
+
const key = (0, crypto_js_1.hkdf)(Buffer.from(data), 64, { salt, info: '' });
|
|
91
|
+
return [key.subarray(0, 32), key.subarray(32)];
|
|
92
|
+
};
|
|
93
|
+
const mixIntoKey = (data) => {
|
|
94
|
+
const [write, read] = localHKDF(data);
|
|
95
|
+
salt = write;
|
|
96
|
+
encKey = read;
|
|
97
|
+
decKey = read;
|
|
98
|
+
counter = 0;
|
|
99
|
+
};
|
|
100
|
+
const finishInit = async () => {
|
|
101
|
+
isWaitingForTransport = true;
|
|
102
|
+
const [write, read] = localHKDF(new Uint8Array(0));
|
|
103
|
+
transport = new TransportState(write, read);
|
|
104
|
+
isWaitingForTransport = false;
|
|
105
|
+
logger.trace('Noise handler transitioned to Transport state');
|
|
106
|
+
if (pendingOnFrame) {
|
|
107
|
+
logger.trace({ length: inBytes.length }, 'Flushing buffered frames after transport ready');
|
|
108
|
+
await processData(pendingOnFrame);
|
|
109
|
+
pendingOnFrame = null;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const processData = async (onFrame) => {
|
|
113
|
+
let size;
|
|
114
|
+
while (true) {
|
|
115
|
+
if (inBytes.length < 3)
|
|
116
|
+
return;
|
|
117
|
+
size = (inBytes[0] << 16) | (inBytes[1] << 8) | inBytes[2];
|
|
118
|
+
if (inBytes.length < size + 3)
|
|
119
|
+
return;
|
|
120
|
+
let frame = inBytes.subarray(3, size + 3);
|
|
121
|
+
inBytes = inBytes.subarray(size + 3);
|
|
122
|
+
if (transport) {
|
|
123
|
+
const result = transport.decrypt(frame);
|
|
124
|
+
frame = await (0, index_js_3.decodeBinaryNode)(result);
|
|
125
|
+
}
|
|
126
|
+
if (logger.level === 'trace') {
|
|
127
|
+
logger.trace({ msg: frame?.attrs?.id }, 'recv frame');
|
|
128
|
+
}
|
|
129
|
+
onFrame(frame);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
authenticate(NOISE_HEADER);
|
|
133
|
+
authenticate(publicKey);
|
|
134
|
+
return {
|
|
135
|
+
encrypt,
|
|
136
|
+
decrypt,
|
|
137
|
+
authenticate,
|
|
138
|
+
mixIntoKey,
|
|
139
|
+
finishInit,
|
|
140
|
+
processHandshake: ({ serverHello }, noiseKey) => {
|
|
141
|
+
authenticate(serverHello.ephemeral);
|
|
142
|
+
mixIntoKey(crypto_js_1.Curve.sharedKey(privateKey, serverHello.ephemeral));
|
|
143
|
+
const decStaticContent = decrypt(serverHello.static);
|
|
144
|
+
mixIntoKey(crypto_js_1.Curve.sharedKey(privateKey, decStaticContent));
|
|
145
|
+
const certDecoded = decrypt(serverHello.payload);
|
|
146
|
+
const { intermediate: certIntermediate, leaf } = index_js_1.proto.CertChain.decode(certDecoded);
|
|
147
|
+
// leaf
|
|
148
|
+
if (!leaf?.details || !leaf?.signature) {
|
|
149
|
+
throw new boom_1.Boom('invalid noise leaf certificate', { statusCode: 400 });
|
|
150
|
+
}
|
|
151
|
+
if (!certIntermediate?.details || !certIntermediate?.signature) {
|
|
152
|
+
throw new boom_1.Boom('invalid noise intermediate certificate', { statusCode: 400 });
|
|
153
|
+
}
|
|
154
|
+
const details = index_js_1.proto.CertChain.NoiseCertificate.Details.decode(certIntermediate.details);
|
|
155
|
+
const { issuerSerial } = details;
|
|
156
|
+
const verify = crypto_js_1.Curve.verify(details.key, leaf.details, leaf.signature);
|
|
157
|
+
const verifyIntermediate = crypto_js_1.Curve.verify(index_js_2.WA_CERT_DETAILS.PUBLIC_KEY, certIntermediate.details, certIntermediate.signature);
|
|
158
|
+
if (!verify) {
|
|
159
|
+
throw new boom_1.Boom('noise certificate signature invalid', { statusCode: 400 });
|
|
160
|
+
}
|
|
161
|
+
if (!verifyIntermediate) {
|
|
162
|
+
throw new boom_1.Boom('noise intermediate certificate signature invalid', { statusCode: 400 });
|
|
163
|
+
}
|
|
164
|
+
if (issuerSerial !== index_js_2.WA_CERT_DETAILS.SERIAL) {
|
|
165
|
+
throw new boom_1.Boom('certification match failed', { statusCode: 400 });
|
|
166
|
+
}
|
|
167
|
+
const keyEnc = encrypt(noiseKey.public);
|
|
168
|
+
mixIntoKey(crypto_js_1.Curve.sharedKey(noiseKey.private, serverHello.ephemeral));
|
|
169
|
+
return keyEnc;
|
|
170
|
+
},
|
|
171
|
+
encodeFrame: (data) => {
|
|
172
|
+
if (transport) {
|
|
173
|
+
data = transport.encrypt(data);
|
|
174
|
+
}
|
|
175
|
+
const dataLen = data.byteLength;
|
|
176
|
+
const introSize = sentIntro ? 0 : introHeader.length;
|
|
177
|
+
const frame = Buffer.allocUnsafe(introSize + 3 + dataLen);
|
|
178
|
+
if (!sentIntro) {
|
|
179
|
+
frame.set(introHeader);
|
|
180
|
+
sentIntro = true;
|
|
181
|
+
}
|
|
182
|
+
frame[introSize] = (dataLen >>> 16) & 0xff;
|
|
183
|
+
frame[introSize + 1] = (dataLen >>> 8) & 0xff;
|
|
184
|
+
frame[introSize + 2] = dataLen & 0xff;
|
|
185
|
+
frame.set(data, introSize + 3);
|
|
186
|
+
return frame;
|
|
187
|
+
},
|
|
188
|
+
decodeFrame: async (newData, onFrame) => {
|
|
189
|
+
if (isWaitingForTransport) {
|
|
190
|
+
inBytes = Buffer.concat([inBytes, newData]);
|
|
191
|
+
pendingOnFrame = onFrame;
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (inBytes.length === 0) {
|
|
195
|
+
inBytes = Buffer.from(newData);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
inBytes = Buffer.concat([inBytes, newData]);
|
|
199
|
+
}
|
|
200
|
+
await processData(onFrame);
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
exports.makeNoiseHandler = makeNoiseHandler;
|
|
205
|
+
//# sourceMappingURL=noise-handler.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeOfflineNodeProcessor = makeOfflineNodeProcessor;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a processor for offline stanza nodes that:
|
|
6
|
+
* - Queues nodes for sequential processing
|
|
7
|
+
* - Yields to the event loop periodically to avoid blocking
|
|
8
|
+
* - Catches handler errors to prevent the processing loop from crashing
|
|
9
|
+
*/
|
|
10
|
+
function makeOfflineNodeProcessor(nodeProcessorMap, deps, batchSize = 10) {
|
|
11
|
+
const nodes = [];
|
|
12
|
+
let isProcessing = false;
|
|
13
|
+
const enqueue = (type, node) => {
|
|
14
|
+
nodes.push({ type, node });
|
|
15
|
+
if (isProcessing) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
isProcessing = true;
|
|
19
|
+
const promise = async () => {
|
|
20
|
+
let processedInBatch = 0;
|
|
21
|
+
while (nodes.length && deps.isWsOpen()) {
|
|
22
|
+
const { type, node } = nodes.shift();
|
|
23
|
+
const nodeProcessor = nodeProcessorMap.get(type);
|
|
24
|
+
if (!nodeProcessor) {
|
|
25
|
+
deps.onUnexpectedError(new Error(`unknown offline node type: ${type}`), 'processing offline node');
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
await nodeProcessor(node).catch(err => deps.onUnexpectedError(err, `processing offline ${type}`));
|
|
29
|
+
processedInBatch++;
|
|
30
|
+
// Yield to event loop after processing a batch
|
|
31
|
+
// This prevents blocking the event loop for too long when there are many offline nodes
|
|
32
|
+
if (processedInBatch >= batchSize) {
|
|
33
|
+
processedInBatch = 0;
|
|
34
|
+
await deps.yieldToEventLoop();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
isProcessing = false;
|
|
38
|
+
};
|
|
39
|
+
promise().catch(error => deps.onUnexpectedError(error, 'processing offline nodes'));
|
|
40
|
+
};
|
|
41
|
+
return { enqueue };
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=offline-node-processor.js.map
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PreKeyManager = void 0;
|
|
7
|
+
const p_queue_1 = __importDefault(require("p-queue"));
|
|
8
|
+
/**
|
|
9
|
+
* Manages pre-key operations with proper concurrency control
|
|
10
|
+
*/
|
|
11
|
+
class PreKeyManager {
|
|
12
|
+
constructor(store, logger) {
|
|
13
|
+
this.store = store;
|
|
14
|
+
this.logger = logger;
|
|
15
|
+
this.queues = new Map();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get or create a queue for a specific key type
|
|
19
|
+
*/
|
|
20
|
+
getQueue(keyType) {
|
|
21
|
+
if (!this.queues.has(keyType)) {
|
|
22
|
+
this.queues.set(keyType, new p_queue_1.default({ concurrency: 1 }));
|
|
23
|
+
}
|
|
24
|
+
return this.queues.get(keyType);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Process pre-key operations (updates and deletions)
|
|
28
|
+
*/
|
|
29
|
+
async processOperations(data, keyType, transactionCache, mutations, isInTransaction) {
|
|
30
|
+
const keyData = data[keyType];
|
|
31
|
+
if (!keyData)
|
|
32
|
+
return;
|
|
33
|
+
return this.getQueue(keyType).add(async () => {
|
|
34
|
+
// Ensure structures exist
|
|
35
|
+
transactionCache[keyType] = transactionCache[keyType] || {};
|
|
36
|
+
mutations[keyType] = mutations[keyType] || {};
|
|
37
|
+
// Separate deletions from updates
|
|
38
|
+
const deletions = [];
|
|
39
|
+
const updates = {};
|
|
40
|
+
for (const keyId in keyData) {
|
|
41
|
+
if (keyData[keyId] === null) {
|
|
42
|
+
deletions.push(keyId);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
updates[keyId] = keyData[keyId];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Process updates (no validation needed)
|
|
49
|
+
if (Object.keys(updates).length > 0) {
|
|
50
|
+
Object.assign(transactionCache[keyType], updates);
|
|
51
|
+
Object.assign(mutations[keyType], updates);
|
|
52
|
+
}
|
|
53
|
+
// Process deletions with validation
|
|
54
|
+
if (deletions.length > 0) {
|
|
55
|
+
await this.processDeletions(keyType, deletions, transactionCache, mutations, isInTransaction);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Process deletions with validation
|
|
61
|
+
*/
|
|
62
|
+
async processDeletions(keyType, ids, transactionCache, mutations, isInTransaction) {
|
|
63
|
+
if (isInTransaction) {
|
|
64
|
+
// In transaction, only allow deletion if key exists in cache
|
|
65
|
+
for (const keyId of ids) {
|
|
66
|
+
if (transactionCache[keyType]?.[keyId]) {
|
|
67
|
+
transactionCache[keyType][keyId] = null;
|
|
68
|
+
mutations[keyType][keyId] = null;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
this.logger.warn(`Skipping deletion of non-existent ${keyType} in transaction: ${keyId}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
// Outside transaction, validate against store
|
|
77
|
+
const existingKeys = await this.store.get(keyType, ids);
|
|
78
|
+
for (const keyId of ids) {
|
|
79
|
+
if (existingKeys[keyId]) {
|
|
80
|
+
transactionCache[keyType][keyId] = null;
|
|
81
|
+
mutations[keyType][keyId] = null;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
this.logger.warn(`Skipping deletion of non-existent ${keyType}: ${keyId}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Validate and process pre-key deletions outside transactions
|
|
91
|
+
*/
|
|
92
|
+
async validateDeletions(data, keyType) {
|
|
93
|
+
const keyData = data[keyType];
|
|
94
|
+
if (!keyData)
|
|
95
|
+
return;
|
|
96
|
+
return this.getQueue(keyType).add(async () => {
|
|
97
|
+
// Find all deletion requests
|
|
98
|
+
const deletionIds = Object.keys(keyData).filter(id => keyData[id] === null);
|
|
99
|
+
if (deletionIds.length === 0)
|
|
100
|
+
return;
|
|
101
|
+
// Validate deletions
|
|
102
|
+
const existingKeys = await this.store.get(keyType, deletionIds);
|
|
103
|
+
for (const keyId of deletionIds) {
|
|
104
|
+
if (!existingKeys[keyId]) {
|
|
105
|
+
this.logger.warn(`Skipping deletion of non-existent ${keyType}: ${keyId}`);
|
|
106
|
+
delete data[keyType][keyId];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.PreKeyManager = PreKeyManager;
|
|
113
|
+
//# sourceMappingURL=pre-key-manager.js.map
|