@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,281 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LIDMappingStore = void 0;
|
|
4
|
+
const lru_cache_1 = require("lru-cache");
|
|
5
|
+
const index_js_1 = require("../WABinary/index.cjs");
|
|
6
|
+
class LIDMappingStore {
|
|
7
|
+
constructor(keys, logger, pnToLIDFunc) {
|
|
8
|
+
this.mappingCache = new lru_cache_1.LRUCache({
|
|
9
|
+
ttl: 3 * 24 * 60 * 60 * 1000, // 7 days
|
|
10
|
+
ttlAutopurge: true,
|
|
11
|
+
updateAgeOnGet: true
|
|
12
|
+
});
|
|
13
|
+
this.inflightLIDLookups = new Map();
|
|
14
|
+
this.inflightPNLookups = new Map();
|
|
15
|
+
this.keys = keys;
|
|
16
|
+
this.pnToLIDFunc = pnToLIDFunc;
|
|
17
|
+
this.logger = logger;
|
|
18
|
+
}
|
|
19
|
+
async storeLIDPNMappings(pairs) {
|
|
20
|
+
if (pairs.length === 0)
|
|
21
|
+
return;
|
|
22
|
+
const validatedPairs = [];
|
|
23
|
+
for (const { lid, pn } of pairs) {
|
|
24
|
+
if (!(((0, index_js_1.isLidUser)(lid) && (0, index_js_1.isPnUser)(pn)) || ((0, index_js_1.isPnUser)(lid) && (0, index_js_1.isLidUser)(pn)))) {
|
|
25
|
+
this.logger.warn(`Invalid LID-PN mapping: ${lid}, ${pn}`);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const lidDecoded = (0, index_js_1.jidDecode)(lid);
|
|
29
|
+
const pnDecoded = (0, index_js_1.jidDecode)(pn);
|
|
30
|
+
if (!lidDecoded || !pnDecoded)
|
|
31
|
+
continue;
|
|
32
|
+
validatedPairs.push({ pnUser: pnDecoded.user, lidUser: lidDecoded.user });
|
|
33
|
+
}
|
|
34
|
+
if (validatedPairs.length === 0)
|
|
35
|
+
return;
|
|
36
|
+
const cacheMissSet = new Set();
|
|
37
|
+
const existingMappings = new Map();
|
|
38
|
+
for (const { pnUser } of validatedPairs) {
|
|
39
|
+
const cached = this.mappingCache.get(`pn:${pnUser}`);
|
|
40
|
+
if (cached) {
|
|
41
|
+
existingMappings.set(pnUser, cached);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
cacheMissSet.add(pnUser);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (cacheMissSet.size > 0) {
|
|
48
|
+
const cacheMisses = [...cacheMissSet];
|
|
49
|
+
this.logger.trace(`Batch fetching ${cacheMisses.length} LID mappings from database`);
|
|
50
|
+
const stored = await this.keys.get('lid-mapping', cacheMisses);
|
|
51
|
+
for (const pnUser of cacheMisses) {
|
|
52
|
+
const existingLidUser = stored[pnUser];
|
|
53
|
+
if (existingLidUser) {
|
|
54
|
+
existingMappings.set(pnUser, existingLidUser);
|
|
55
|
+
this.mappingCache.set(`pn:${pnUser}`, existingLidUser);
|
|
56
|
+
this.mappingCache.set(`lid:${existingLidUser}`, pnUser);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const pairMap = {};
|
|
61
|
+
for (const { pnUser, lidUser } of validatedPairs) {
|
|
62
|
+
const existingLidUser = existingMappings.get(pnUser);
|
|
63
|
+
if (existingLidUser === lidUser) {
|
|
64
|
+
this.logger.debug({ pnUser, lidUser }, 'LID mapping already exists, skipping');
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
pairMap[pnUser] = lidUser;
|
|
68
|
+
}
|
|
69
|
+
if (Object.keys(pairMap).length === 0)
|
|
70
|
+
return;
|
|
71
|
+
this.logger.trace({ pairMap }, `Storing ${Object.keys(pairMap).length} pn mappings`);
|
|
72
|
+
const batchData = {};
|
|
73
|
+
for (const [pnUser, lidUser] of Object.entries(pairMap)) {
|
|
74
|
+
batchData[pnUser] = lidUser;
|
|
75
|
+
batchData[`${lidUser}_reverse`] = pnUser;
|
|
76
|
+
}
|
|
77
|
+
await this.keys.transaction(async () => {
|
|
78
|
+
await this.keys.set({ 'lid-mapping': batchData });
|
|
79
|
+
}, 'lid-mapping');
|
|
80
|
+
// Update cache after successful DB write
|
|
81
|
+
for (const [pnUser, lidUser] of Object.entries(pairMap)) {
|
|
82
|
+
this.mappingCache.set(`pn:${pnUser}`, lidUser);
|
|
83
|
+
this.mappingCache.set(`lid:${lidUser}`, pnUser);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async getLIDForPN(pn) {
|
|
87
|
+
return (await this.getLIDsForPNs([pn]))?.[0]?.lid || null;
|
|
88
|
+
}
|
|
89
|
+
async getLIDsForPNs(pns) {
|
|
90
|
+
if (pns.length === 0)
|
|
91
|
+
return null;
|
|
92
|
+
const sortedPns = [...new Set(pns)].sort();
|
|
93
|
+
const cacheKey = sortedPns.join(',');
|
|
94
|
+
const inflight = this.inflightLIDLookups.get(cacheKey);
|
|
95
|
+
if (inflight) {
|
|
96
|
+
this.logger.trace(`Coalescing getLIDsForPNs request for ${sortedPns.length} PNs`);
|
|
97
|
+
return inflight;
|
|
98
|
+
}
|
|
99
|
+
const promise = this._getLIDsForPNsImpl(pns);
|
|
100
|
+
this.inflightLIDLookups.set(cacheKey, promise);
|
|
101
|
+
try {
|
|
102
|
+
return await promise;
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
this.inflightLIDLookups.delete(cacheKey);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async _getLIDsForPNsImpl(pns) {
|
|
109
|
+
const usyncFetch = {};
|
|
110
|
+
const successfulPairs = {};
|
|
111
|
+
const pending = [];
|
|
112
|
+
const addResolvedPair = (pn, decoded, lidUser) => {
|
|
113
|
+
const normalizedLidUser = lidUser.toString();
|
|
114
|
+
if (!normalizedLidUser) {
|
|
115
|
+
this.logger.warn(`Invalid or empty LID user for PN ${pn}: lidUser = "${lidUser}"`);
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
// Push the PN device ID to the LID to maintain device separation
|
|
119
|
+
const pnDevice = decoded.device !== undefined ? decoded.device : 0;
|
|
120
|
+
const deviceSpecificLid = `${normalizedLidUser}${!!pnDevice ? `:${pnDevice}` : ``}@${decoded.server === 'hosted' ? 'hosted.lid' : 'lid'}`;
|
|
121
|
+
this.logger.trace(`getLIDForPN: ${pn} → ${deviceSpecificLid} (user mapping with device ${pnDevice})`);
|
|
122
|
+
successfulPairs[pn] = { lid: deviceSpecificLid, pn };
|
|
123
|
+
return true;
|
|
124
|
+
};
|
|
125
|
+
for (const pn of pns) {
|
|
126
|
+
if (!(0, index_js_1.isPnUser)(pn) && !(0, index_js_1.isHostedPnUser)(pn))
|
|
127
|
+
continue;
|
|
128
|
+
const decoded = (0, index_js_1.jidDecode)(pn);
|
|
129
|
+
if (!decoded)
|
|
130
|
+
continue;
|
|
131
|
+
const pnUser = decoded.user;
|
|
132
|
+
const cached = this.mappingCache.get(`pn:${pnUser}`);
|
|
133
|
+
if (cached && typeof cached === 'string') {
|
|
134
|
+
if (!addResolvedPair(pn, decoded, cached)) {
|
|
135
|
+
this.logger.warn(`Invalid entry for ${pn} (pair not resolved)`);
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
pending.push({ pn, pnUser, decoded });
|
|
141
|
+
}
|
|
142
|
+
if (pending.length) {
|
|
143
|
+
const pnUsers = [...new Set(pending.map(item => item.pnUser))];
|
|
144
|
+
const stored = await this.keys.get('lid-mapping', pnUsers);
|
|
145
|
+
for (const pnUser of pnUsers) {
|
|
146
|
+
const lidUser = stored[pnUser];
|
|
147
|
+
if (lidUser && typeof lidUser === 'string') {
|
|
148
|
+
this.mappingCache.set(`pn:${pnUser}`, lidUser);
|
|
149
|
+
this.mappingCache.set(`lid:${lidUser}`, pnUser);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
for (const { pn, pnUser, decoded } of pending) {
|
|
153
|
+
const cached = this.mappingCache.get(`pn:${pnUser}`);
|
|
154
|
+
if (cached && typeof cached === 'string') {
|
|
155
|
+
if (!addResolvedPair(pn, decoded, cached)) {
|
|
156
|
+
this.logger.warn(`Invalid entry for ${pn} (pair not resolved)`);
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
this.logger.trace(`No LID mapping found for PN user ${pnUser}; batch getting from USync`);
|
|
162
|
+
const device = decoded.device || 0;
|
|
163
|
+
let normalizedPn = (0, index_js_1.jidNormalizedUser)(pn);
|
|
164
|
+
if ((0, index_js_1.isHostedPnUser)(normalizedPn)) {
|
|
165
|
+
normalizedPn = `${pnUser}@s.whatsapp.net`;
|
|
166
|
+
}
|
|
167
|
+
if (!usyncFetch[normalizedPn]) {
|
|
168
|
+
usyncFetch[normalizedPn] = [device];
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
usyncFetch[normalizedPn]?.push(device);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (Object.keys(usyncFetch).length > 0) {
|
|
177
|
+
const result = await this.pnToLIDFunc?.(Object.keys(usyncFetch)); // this function already adds LIDs to mapping
|
|
178
|
+
if (result && result.length > 0) {
|
|
179
|
+
await this.storeLIDPNMappings(result);
|
|
180
|
+
for (const pair of result) {
|
|
181
|
+
const pnDecoded = (0, index_js_1.jidDecode)(pair.pn);
|
|
182
|
+
const pnUser = pnDecoded?.user;
|
|
183
|
+
if (!pnUser)
|
|
184
|
+
continue;
|
|
185
|
+
const lidUser = (0, index_js_1.jidDecode)(pair.lid)?.user;
|
|
186
|
+
if (!lidUser)
|
|
187
|
+
continue;
|
|
188
|
+
for (const device of usyncFetch[pair.pn]) {
|
|
189
|
+
const deviceSpecificLid = `${lidUser}${!!device ? `:${device}` : ``}@${device === 99 ? 'hosted.lid' : 'lid'}`;
|
|
190
|
+
this.logger.trace(`getLIDForPN: USYNC success for ${pair.pn} → ${deviceSpecificLid} (user mapping with device ${device})`);
|
|
191
|
+
const deviceSpecificPn = `${pnUser}${!!device ? `:${device}` : ``}@${device === 99 ? 'hosted' : 's.whatsapp.net'}`;
|
|
192
|
+
successfulPairs[deviceSpecificPn] = { lid: deviceSpecificLid, pn: deviceSpecificPn };
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
this.logger.warn('USync fetch yielded no results for pending PNs');
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return Object.values(successfulPairs).length > 0 ? Object.values(successfulPairs) : null;
|
|
201
|
+
}
|
|
202
|
+
async getPNForLID(lid) {
|
|
203
|
+
return (await this.getPNsForLIDs([lid]))?.[0]?.pn || null;
|
|
204
|
+
}
|
|
205
|
+
async getPNsForLIDs(lids) {
|
|
206
|
+
if (lids.length === 0)
|
|
207
|
+
return null;
|
|
208
|
+
const sortedLids = [...new Set(lids)].sort();
|
|
209
|
+
const cacheKey = sortedLids.join(',');
|
|
210
|
+
const inflight = this.inflightPNLookups.get(cacheKey);
|
|
211
|
+
if (inflight) {
|
|
212
|
+
this.logger.trace(`Coalescing getPNsForLIDs request for ${sortedLids.length} LIDs`);
|
|
213
|
+
return inflight;
|
|
214
|
+
}
|
|
215
|
+
const promise = this._getPNsForLIDsImpl(lids);
|
|
216
|
+
this.inflightPNLookups.set(cacheKey, promise);
|
|
217
|
+
try {
|
|
218
|
+
return await promise;
|
|
219
|
+
}
|
|
220
|
+
finally {
|
|
221
|
+
this.inflightPNLookups.delete(cacheKey);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
async _getPNsForLIDsImpl(lids) {
|
|
225
|
+
const successfulPairs = {};
|
|
226
|
+
const pending = [];
|
|
227
|
+
const addResolvedPair = (lid, decoded, pnUser) => {
|
|
228
|
+
if (!pnUser || typeof pnUser !== 'string') {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
const lidDevice = decoded.device !== undefined ? decoded.device : 0;
|
|
232
|
+
const pnJid = `${pnUser}:${lidDevice}@${decoded.domainType === index_js_1.WAJIDDomains.HOSTED_LID ? 'hosted' : 's.whatsapp.net'}`;
|
|
233
|
+
this.logger.trace(`Found reverse mapping: ${lid} → ${pnJid}`);
|
|
234
|
+
successfulPairs[lid] = { lid, pn: pnJid };
|
|
235
|
+
return true;
|
|
236
|
+
};
|
|
237
|
+
for (const lid of lids) {
|
|
238
|
+
if (!(0, index_js_1.isLidUser)(lid))
|
|
239
|
+
continue;
|
|
240
|
+
const decoded = (0, index_js_1.jidDecode)(lid);
|
|
241
|
+
if (!decoded)
|
|
242
|
+
continue;
|
|
243
|
+
const lidUser = decoded.user;
|
|
244
|
+
const cached = this.mappingCache.get(`lid:${lidUser}`);
|
|
245
|
+
if (cached && typeof cached === 'string') {
|
|
246
|
+
addResolvedPair(lid, decoded, cached);
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
pending.push({ lid, lidUser, decoded });
|
|
250
|
+
}
|
|
251
|
+
if (pending.length) {
|
|
252
|
+
const reverseKeys = [...new Set(pending.map(item => `${item.lidUser}_reverse`))];
|
|
253
|
+
const stored = await this.keys.get('lid-mapping', reverseKeys);
|
|
254
|
+
for (const { lid, lidUser, decoded } of pending) {
|
|
255
|
+
let pnUser = this.mappingCache.get(`lid:${lidUser}`);
|
|
256
|
+
if (!pnUser || typeof pnUser !== 'string') {
|
|
257
|
+
pnUser = stored[`${lidUser}_reverse`];
|
|
258
|
+
if (pnUser && typeof pnUser === 'string') {
|
|
259
|
+
this.mappingCache.set(`lid:${lidUser}`, pnUser);
|
|
260
|
+
this.mappingCache.set(`pn:${pnUser}`, lidUser);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (pnUser && typeof pnUser === 'string') {
|
|
264
|
+
addResolvedPair(lid, decoded, pnUser);
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
this.logger.trace(`No reverse mapping found for LID user: ${lidUser}`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return Object.values(successfulPairs).length ? Object.values(successfulPairs) : null;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Close the cache and release resources
|
|
275
|
+
*/
|
|
276
|
+
close() {
|
|
277
|
+
this.mappingCache.clear();
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
exports.LIDMappingStore = LIDMappingStore;
|
|
281
|
+
//# sourceMappingURL=lid-mapping.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types.cjs"), exports);
|
|
18
|
+
__exportStar(require("./websocket.cjs"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbstractSocketClient = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
const url_1 = require("url");
|
|
6
|
+
class AbstractSocketClient extends events_1.EventEmitter {
|
|
7
|
+
constructor(url, config) {
|
|
8
|
+
super();
|
|
9
|
+
this.url = url;
|
|
10
|
+
this.config = config;
|
|
11
|
+
this.setMaxListeners(0);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.AbstractSocketClient = AbstractSocketClient;
|
|
15
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,61 @@
|
|
|
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.WebSocketClient = void 0;
|
|
7
|
+
const ws_1 = __importDefault(require("ws"));
|
|
8
|
+
const index_js_1 = require("../../Defaults/index.cjs");
|
|
9
|
+
const types_js_1 = require("./types.cjs");
|
|
10
|
+
class WebSocketClient extends types_js_1.AbstractSocketClient {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.socket = null;
|
|
14
|
+
}
|
|
15
|
+
get isOpen() {
|
|
16
|
+
return this.socket?.readyState === ws_1.default.OPEN;
|
|
17
|
+
}
|
|
18
|
+
get isClosed() {
|
|
19
|
+
return this.socket === null || this.socket?.readyState === ws_1.default.CLOSED;
|
|
20
|
+
}
|
|
21
|
+
get isClosing() {
|
|
22
|
+
return this.socket === null || this.socket?.readyState === ws_1.default.CLOSING;
|
|
23
|
+
}
|
|
24
|
+
get isConnecting() {
|
|
25
|
+
return this.socket?.readyState === ws_1.default.CONNECTING;
|
|
26
|
+
}
|
|
27
|
+
connect() {
|
|
28
|
+
if (this.socket) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
this.socket = new ws_1.default(this.url, {
|
|
32
|
+
origin: index_js_1.DEFAULT_ORIGIN,
|
|
33
|
+
headers: this.config.options?.headers,
|
|
34
|
+
handshakeTimeout: this.config.connectTimeoutMs,
|
|
35
|
+
timeout: this.config.connectTimeoutMs,
|
|
36
|
+
agent: this.config.agent
|
|
37
|
+
});
|
|
38
|
+
this.socket.setMaxListeners(0);
|
|
39
|
+
const events = ['close', 'error', 'upgrade', 'message', 'open', 'ping', 'pong', 'unexpected-response'];
|
|
40
|
+
for (const event of events) {
|
|
41
|
+
this.socket?.on(event, (...args) => this.emit(event, ...args));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async close() {
|
|
45
|
+
if (!this.socket) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const closePromise = new Promise(resolve => {
|
|
49
|
+
this.socket?.once('close', resolve);
|
|
50
|
+
});
|
|
51
|
+
this.socket.close();
|
|
52
|
+
await closePromise;
|
|
53
|
+
this.socket = null;
|
|
54
|
+
}
|
|
55
|
+
send(str, cb) {
|
|
56
|
+
this.socket?.send(str, cb);
|
|
57
|
+
return Boolean(this.socket);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.WebSocketClient = WebSocketClient;
|
|
61
|
+
//# sourceMappingURL=websocket.js.map
|