@oxidezap/baileyrs 0.0.26 → 0.0.28
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/README.md +31 -460
- package/lib/Bridge/adapt.d.ts +2 -0
- package/lib/Bridge/adapt.d.ts.map +1 -1
- package/lib/Bridge/adapt.js +2 -1
- package/lib/Bridge/adapt.js.map +1 -1
- package/lib/Bridge/history-sync-wire.d.ts +17 -0
- package/lib/Bridge/history-sync-wire.d.ts.map +1 -0
- package/lib/Bridge/history-sync-wire.js +61 -0
- package/lib/Bridge/history-sync-wire.js.map +1 -0
- package/lib/Bridge/index.d.ts +1 -1
- package/lib/Bridge/index.d.ts.map +1 -1
- package/lib/Bridge/index.js +3 -3
- package/lib/Bridge/index.js.map +1 -1
- package/lib/Bridge/primitives.d.ts +4 -0
- package/lib/Bridge/primitives.d.ts.map +1 -1
- package/lib/Bridge/primitives.js +14 -0
- package/lib/Bridge/primitives.js.map +1 -1
- package/lib/Bridge/schema.d.ts +9 -2
- package/lib/Bridge/schema.d.ts.map +1 -1
- package/lib/Bridge/schema.js +263 -35
- package/lib/Bridge/schema.js.map +1 -1
- package/lib/Bridge/types.d.ts +117 -3
- package/lib/Bridge/types.d.ts.map +1 -1
- package/lib/Compatibility/group-metadata.d.ts +9 -0
- package/lib/Compatibility/group-metadata.d.ts.map +1 -0
- package/lib/Compatibility/group-metadata.js +70 -0
- package/lib/Compatibility/group-metadata.js.map +1 -0
- package/lib/Compatibility/group-notifications.d.ts +22 -0
- package/lib/Compatibility/group-notifications.d.ts.map +1 -0
- package/lib/Compatibility/group-notifications.js +307 -0
- package/lib/Compatibility/group-notifications.js.map +1 -0
- package/lib/Compatibility/group-stub-params.d.ts +32 -0
- package/lib/Compatibility/group-stub-params.d.ts.map +1 -0
- package/lib/Compatibility/group-stub-params.js +57 -0
- package/lib/Compatibility/group-stub-params.js.map +1 -0
- package/lib/Compatibility/internal/async-primitives.d.ts +16 -0
- package/lib/Compatibility/internal/async-primitives.d.ts.map +1 -0
- package/lib/Compatibility/internal/async-primitives.js +42 -0
- package/lib/Compatibility/internal/async-primitives.js.map +1 -0
- package/lib/Compatibility/internal/auth-state.d.ts +15 -0
- package/lib/Compatibility/internal/auth-state.d.ts.map +1 -0
- package/lib/Compatibility/internal/auth-state.js +21 -0
- package/lib/Compatibility/internal/auth-state.js.map +1 -0
- package/lib/Compatibility/internal/cache-store.d.ts +7 -0
- package/lib/Compatibility/internal/cache-store.d.ts.map +1 -0
- package/lib/Compatibility/internal/cache-store.js +19 -0
- package/lib/Compatibility/internal/cache-store.js.map +1 -0
- package/lib/Compatibility/internal/expiring-lru-map.d.ts +21 -0
- package/lib/Compatibility/internal/expiring-lru-map.d.ts.map +1 -0
- package/lib/Compatibility/internal/expiring-lru-map.js +68 -0
- package/lib/Compatibility/internal/expiring-lru-map.js.map +1 -0
- package/lib/Compatibility/internal/make-mutex.d.ts +7 -0
- package/lib/Compatibility/internal/make-mutex.d.ts.map +1 -0
- package/lib/Compatibility/internal/make-mutex.js +31 -0
- package/lib/Compatibility/internal/make-mutex.js.map +1 -0
- package/lib/Compatibility/internal/native-memory-store.d.ts +6 -0
- package/lib/Compatibility/internal/native-memory-store.d.ts.map +1 -0
- package/lib/Compatibility/internal/native-memory-store.js +8 -0
- package/lib/Compatibility/internal/native-memory-store.js.map +1 -0
- package/lib/Compatibility/internal/numeric-enum.d.ts +8 -0
- package/lib/Compatibility/internal/numeric-enum.d.ts.map +1 -0
- package/lib/Compatibility/internal/numeric-enum.js +11 -0
- package/lib/Compatibility/internal/numeric-enum.js.map +1 -0
- package/lib/Compatibility/internal/signal-key-store.d.ts +9 -0
- package/lib/Compatibility/internal/signal-key-store.d.ts.map +1 -0
- package/lib/Compatibility/internal/signal-key-store.js +17 -0
- package/lib/Compatibility/internal/signal-key-store.js.map +1 -0
- package/lib/Compatibility/legacy-store/adapter.d.ts +4 -0
- package/lib/Compatibility/legacy-store/adapter.d.ts.map +1 -0
- package/lib/Compatibility/legacy-store/adapter.js +301 -0
- package/lib/Compatibility/legacy-store/adapter.js.map +1 -0
- package/lib/Compatibility/legacy-store/codecs/basic.d.ts +6 -0
- package/lib/Compatibility/legacy-store/codecs/basic.d.ts.map +1 -0
- package/lib/Compatibility/legacy-store/codecs/basic.js +184 -0
- package/lib/Compatibility/legacy-store/codecs/basic.js.map +1 -0
- package/lib/Compatibility/legacy-store/codecs/index.d.ts +6 -0
- package/lib/Compatibility/legacy-store/codecs/index.d.ts.map +1 -0
- package/lib/Compatibility/legacy-store/codecs/index.js +7 -0
- package/lib/Compatibility/legacy-store/codecs/index.js.map +1 -0
- package/lib/Compatibility/legacy-store/codecs/signal.d.ts +8 -0
- package/lib/Compatibility/legacy-store/codecs/signal.d.ts.map +1 -0
- package/lib/Compatibility/legacy-store/codecs/signal.js +219 -0
- package/lib/Compatibility/legacy-store/codecs/signal.js.map +1 -0
- package/lib/Compatibility/legacy-store/common.d.ts +25 -0
- package/lib/Compatibility/legacy-store/common.d.ts.map +1 -0
- package/lib/Compatibility/legacy-store/common.js +112 -0
- package/lib/Compatibility/legacy-store/common.js.map +1 -0
- package/lib/Compatibility/legacy-store/constants.d.ts +226 -0
- package/lib/Compatibility/legacy-store/constants.d.ts.map +1 -0
- package/lib/Compatibility/legacy-store/constants.js +199 -0
- package/lib/Compatibility/legacy-store/constants.js.map +1 -0
- package/lib/Compatibility/legacy-store/device.d.ts +9 -0
- package/lib/Compatibility/legacy-store/device.d.ts.map +1 -0
- package/lib/Compatibility/legacy-store/device.js +192 -0
- package/lib/Compatibility/legacy-store/device.js.map +1 -0
- package/lib/Compatibility/legacy-store/multi-file.d.ts +6 -0
- package/lib/Compatibility/legacy-store/multi-file.d.ts.map +1 -0
- package/lib/Compatibility/legacy-store/multi-file.js +84 -0
- package/lib/Compatibility/legacy-store/multi-file.js.map +1 -0
- package/lib/Compatibility/legacy-store/native-projection.d.ts +8 -0
- package/lib/Compatibility/legacy-store/native-projection.d.ts.map +1 -0
- package/lib/Compatibility/legacy-store/native-projection.js +109 -0
- package/lib/Compatibility/legacy-store/native-projection.js.map +1 -0
- package/lib/Compatibility/legacy-store/routing.d.ts +18 -0
- package/lib/Compatibility/legacy-store/routing.d.ts.map +1 -0
- package/lib/Compatibility/legacy-store/routing.js +162 -0
- package/lib/Compatibility/legacy-store/routing.js.map +1 -0
- package/lib/Compatibility/legacy-store/types.d.ts +41 -0
- package/lib/Compatibility/legacy-store/types.d.ts.map +1 -0
- package/lib/Compatibility/legacy-store/types.js +3 -0
- package/lib/Compatibility/legacy-store/types.js.map +1 -0
- package/lib/Compatibility/legacy-store/validation.d.ts +9 -0
- package/lib/Compatibility/legacy-store/validation.d.ts.map +1 -0
- package/lib/Compatibility/legacy-store/validation.js +49 -0
- package/lib/Compatibility/legacy-store/validation.js.map +1 -0
- package/lib/Compatibility/media-type.d.ts +10 -0
- package/lib/Compatibility/media-type.d.ts.map +1 -0
- package/lib/Compatibility/media-type.js +31 -0
- package/lib/Compatibility/media-type.js.map +1 -0
- package/lib/Compatibility/message-keys.d.ts +9 -0
- package/lib/Compatibility/message-keys.d.ts.map +1 -0
- package/lib/Compatibility/message-keys.js +15 -0
- package/lib/Compatibility/message-keys.js.map +1 -0
- package/lib/Compatibility/message-relay.d.ts +26 -0
- package/lib/Compatibility/message-relay.d.ts.map +1 -0
- package/lib/Compatibility/message-relay.js +61 -0
- package/lib/Compatibility/message-relay.js.map +1 -0
- package/lib/Compatibility/message-upsert.d.ts +11 -0
- package/lib/Compatibility/message-upsert.d.ts.map +1 -0
- package/lib/Compatibility/message-upsert.js +8 -0
- package/lib/Compatibility/message-upsert.js.map +1 -0
- package/lib/Compatibility/participating-refresh.d.ts +9 -0
- package/lib/Compatibility/participating-refresh.d.ts.map +1 -0
- package/lib/Compatibility/participating-refresh.js +14 -0
- package/lib/Compatibility/participating-refresh.js.map +1 -0
- package/lib/Compatibility/proto-runtime.d.ts +9 -0
- package/lib/Compatibility/proto-runtime.d.ts.map +1 -0
- package/lib/Compatibility/proto-runtime.js +567 -0
- package/lib/Compatibility/proto-runtime.js.map +1 -0
- package/lib/Compatibility/public-api/auth-utils.d.ts +6 -0
- package/lib/Compatibility/public-api/auth-utils.d.ts.map +1 -0
- package/lib/Compatibility/public-api/auth-utils.js +202 -0
- package/lib/Compatibility/public-api/auth-utils.js.map +1 -0
- package/lib/Compatibility/public-api/enum-types.d.ts +163 -0
- package/lib/Compatibility/public-api/enum-types.d.ts.map +1 -0
- package/lib/Compatibility/public-api/enum-types.js +10 -0
- package/lib/Compatibility/public-api/enum-types.js.map +1 -0
- package/lib/Compatibility/public-api/identity-change-handler.d.ts +42 -0
- package/lib/Compatibility/public-api/identity-change-handler.d.ts.map +1 -0
- package/lib/Compatibility/public-api/identity-change-handler.js +38 -0
- package/lib/Compatibility/public-api/identity-change-handler.js.map +1 -0
- package/lib/Compatibility/public-api/message-retry-manager.d.ts +62 -0
- package/lib/Compatibility/public-api/message-retry-manager.d.ts.map +1 -0
- package/lib/Compatibility/public-api/message-retry-manager.js +180 -0
- package/lib/Compatibility/public-api/message-retry-manager.js.map +1 -0
- package/lib/Compatibility/public-api/pre-key-manager.d.ts +14 -0
- package/lib/Compatibility/public-api/pre-key-manager.d.ts.map +1 -0
- package/lib/Compatibility/public-api/pre-key-manager.js +83 -0
- package/lib/Compatibility/public-api/pre-key-manager.js.map +1 -0
- package/lib/Compatibility/public-api/stanza-ack.d.ts +4 -0
- package/lib/Compatibility/public-api/stanza-ack.d.ts.map +1 -0
- package/lib/Compatibility/public-api/stanza-ack.js +20 -0
- package/lib/Compatibility/public-api/stanza-ack.js.map +1 -0
- package/lib/Compatibility/signal-repository.d.ts +12 -0
- package/lib/Compatibility/signal-repository.d.ts.map +1 -0
- package/lib/Compatibility/signal-repository.js +131 -0
- package/lib/Compatibility/signal-repository.js.map +1 -0
- package/lib/Compatibility/socket-results.d.ts +28 -0
- package/lib/Compatibility/socket-results.d.ts.map +1 -0
- package/lib/Compatibility/socket-results.js +72 -0
- package/lib/Compatibility/socket-results.js.map +1 -0
- package/lib/Compatibility/stanza-responses.d.ts +13 -0
- package/lib/Compatibility/stanza-responses.d.ts.map +1 -0
- package/lib/Compatibility/stanza-responses.js +16 -0
- package/lib/Compatibility/stanza-responses.js.map +1 -0
- package/lib/Compatibility/tagged-message-waiter.d.ts +5 -0
- package/lib/Compatibility/tagged-message-waiter.d.ts.map +1 -0
- package/lib/Compatibility/tagged-message-waiter.js +42 -0
- package/lib/Compatibility/tagged-message-waiter.js.map +1 -0
- package/lib/Compatibility/usync/adapter.d.ts +13 -0
- package/lib/Compatibility/usync/adapter.d.ts.map +1 -0
- package/lib/Compatibility/usync/adapter.js +291 -0
- package/lib/Compatibility/usync/adapter.js.map +1 -0
- package/lib/Compatibility/websocket-client.d.ts +40 -0
- package/lib/Compatibility/websocket-client.d.ts.map +1 -0
- package/lib/Compatibility/websocket-client.js +120 -0
- package/lib/Compatibility/websocket-client.js.map +1 -0
- package/lib/Defaults/index.d.ts +70 -3
- package/lib/Defaults/index.d.ts.map +1 -1
- package/lib/Defaults/index.js +107 -15
- package/lib/Defaults/index.js.map +1 -1
- package/lib/Platform/crypto.d.ts +6 -0
- package/lib/Platform/crypto.d.ts.map +1 -0
- package/lib/Platform/crypto.js +36 -0
- package/lib/Platform/crypto.js.map +1 -0
- package/lib/Socket/blocking.d.ts +2 -2
- package/lib/Socket/blocking.d.ts.map +1 -1
- package/lib/Socket/blocking.js +2 -1
- package/lib/Socket/blocking.js.map +1 -1
- package/lib/Socket/chat-actions.d.ts +2 -9
- package/lib/Socket/chat-actions.d.ts.map +1 -1
- package/lib/Socket/chat-actions.js +24 -13
- package/lib/Socket/chat-actions.js.map +1 -1
- package/lib/Socket/communities.d.ts +61 -0
- package/lib/Socket/communities.d.ts.map +1 -0
- package/lib/Socket/communities.js +72 -0
- package/lib/Socket/communities.js.map +1 -0
- package/lib/Socket/contacts.d.ts +4 -2
- package/lib/Socket/contacts.d.ts.map +1 -1
- package/lib/Socket/contacts.js +6 -4
- package/lib/Socket/contacts.js.map +1 -1
- package/lib/Socket/events.d.ts +13 -5
- package/lib/Socket/events.d.ts.map +1 -1
- package/lib/Socket/events.js +282 -57
- package/lib/Socket/events.js.map +1 -1
- package/lib/Socket/group-notifications.d.ts +1 -30
- package/lib/Socket/group-notifications.d.ts.map +1 -1
- package/lib/Socket/group-notifications.js +3 -268
- package/lib/Socket/group-notifications.js.map +1 -1
- package/lib/Socket/groups.d.ts +17 -36
- package/lib/Socket/groups.d.ts.map +1 -1
- package/lib/Socket/groups.js +111 -116
- package/lib/Socket/groups.js.map +1 -1
- package/lib/Socket/index.d.ts +140 -201
- package/lib/Socket/index.d.ts.map +1 -1
- package/lib/Socket/index.js +215 -345
- package/lib/Socket/index.js.map +1 -1
- package/lib/Socket/message-capping.d.ts +4 -0
- package/lib/Socket/message-capping.d.ts.map +1 -0
- package/lib/Socket/message-capping.js +22 -0
- package/lib/Socket/message-capping.js.map +1 -0
- package/lib/Socket/messages.d.ts +8 -14
- package/lib/Socket/messages.d.ts.map +1 -1
- package/lib/Socket/messages.js +74 -40
- package/lib/Socket/messages.js.map +1 -1
- package/lib/Socket/newsletter.d.ts +5 -0
- package/lib/Socket/newsletter.d.ts.map +1 -1
- package/lib/Socket/newsletter.js +7 -0
- package/lib/Socket/newsletter.js.map +1 -1
- package/lib/Socket/prekeys.d.ts +10 -0
- package/lib/Socket/prekeys.d.ts.map +1 -0
- package/lib/Socket/prekeys.js +21 -0
- package/lib/Socket/prekeys.js.map +1 -0
- package/lib/Socket/presence.d.ts +3 -3
- package/lib/Socket/presence.d.ts.map +1 -1
- package/lib/Socket/presence.js +2 -2
- package/lib/Socket/presence.js.map +1 -1
- package/lib/Socket/profile.d.ts +6 -8
- package/lib/Socket/profile.d.ts.map +1 -1
- package/lib/Socket/profile.js +18 -17
- package/lib/Socket/profile.js.map +1 -1
- package/lib/Socket/reachout.js +1 -1
- package/lib/Socket/transport.d.ts.map +1 -1
- package/lib/Socket/transport.js +13 -1
- package/lib/Socket/transport.js.map +1 -1
- package/lib/Socket/types.d.ts +4 -2
- package/lib/Socket/types.d.ts.map +1 -1
- package/lib/Socket/types.js.map +1 -1
- package/lib/Socket/usync.d.ts +12 -0
- package/lib/Socket/usync.d.ts.map +1 -0
- package/lib/Socket/usync.js +27 -0
- package/lib/Socket/usync.js.map +1 -0
- package/lib/Types/Auth.d.ts +28 -30
- package/lib/Types/Auth.d.ts.map +1 -1
- package/lib/Types/Auth.js +1 -1
- package/lib/Types/Auth.js.map +1 -1
- package/lib/Types/BinaryNode.d.ts +0 -4
- package/lib/Types/BinaryNode.d.ts.map +1 -1
- package/lib/Types/Bussines.d.ts +1 -1
- package/lib/Types/Bussines.d.ts.map +1 -1
- package/lib/Types/Call.d.ts +3 -1
- package/lib/Types/Call.d.ts.map +1 -1
- package/lib/Types/Chat.d.ts +2 -2
- package/lib/Types/Chat.d.ts.map +1 -1
- package/lib/Types/Events.d.ts +16 -5
- package/lib/Types/Events.d.ts.map +1 -1
- package/lib/Types/Events.js +1 -1
- package/lib/Types/Events.js.map +1 -1
- package/lib/Types/GroupMetadata.d.ts +4 -0
- package/lib/Types/GroupMetadata.d.ts.map +1 -1
- package/lib/Types/Label.d.ts +3 -23
- package/lib/Types/Label.d.ts.map +1 -1
- package/lib/Types/Label.js +24 -23
- package/lib/Types/Label.js.map +1 -1
- package/lib/Types/LabelAssociation.d.ts +5 -6
- package/lib/Types/LabelAssociation.d.ts.map +1 -1
- package/lib/Types/LabelAssociation.js +4 -5
- package/lib/Types/LabelAssociation.js.map +1 -1
- package/lib/Types/Message.d.ts +45 -10
- package/lib/Types/Message.d.ts.map +1 -1
- package/lib/Types/Message.js +5 -7
- package/lib/Types/Message.js.map +1 -1
- package/lib/Types/Newsletter.d.ts +5 -28
- package/lib/Types/Newsletter.d.ts.map +1 -1
- package/lib/Types/Newsletter.js +34 -30
- package/lib/Types/Newsletter.js.map +1 -1
- package/lib/Types/Product.d.ts +75 -0
- package/lib/Types/Product.d.ts.map +1 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/Product.js.map +1 -0
- package/lib/Types/Reachout.d.ts +3 -18
- package/lib/Types/Reachout.d.ts.map +1 -1
- package/lib/Types/Reachout.js +20 -19
- package/lib/Types/Reachout.js.map +1 -1
- package/lib/Types/Signal.d.ts +91 -0
- package/lib/Types/Signal.d.ts.map +1 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Signal.js.map +1 -0
- package/lib/Types/Socket.d.ts +76 -30
- package/lib/Types/Socket.d.ts.map +1 -1
- package/lib/Types/State.d.ts +19 -0
- package/lib/Types/State.d.ts.map +1 -1
- package/lib/Types/State.js +26 -1
- package/lib/Types/State.js.map +1 -1
- package/lib/Types/USync.d.ts +9 -0
- package/lib/Types/USync.d.ts.map +1 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/USync.js.map +1 -0
- package/lib/Types/index.d.ts +9 -12
- package/lib/Types/index.d.ts.map +1 -1
- package/lib/Types/index.js +30 -30
- package/lib/Types/index.js.map +1 -1
- package/lib/Utils/auth-utils.d.ts +2 -0
- package/lib/Utils/auth-utils.d.ts.map +1 -0
- package/lib/Utils/auth-utils.js +3 -0
- package/lib/Utils/auth-utils.js.map +1 -0
- package/lib/Utils/boom.d.ts +8 -32
- package/lib/Utils/boom.d.ts.map +1 -1
- package/lib/Utils/boom.js +7 -62
- package/lib/Utils/boom.js.map +1 -1
- package/lib/Utils/browser-utils.d.ts +1 -0
- package/lib/Utils/browser-utils.d.ts.map +1 -1
- package/lib/Utils/browser-utils.js +6 -0
- package/lib/Utils/browser-utils.js.map +1 -1
- package/lib/Utils/companion-reg-client-utils.d.ts +8 -0
- package/lib/Utils/companion-reg-client-utils.d.ts.map +1 -0
- package/lib/Utils/companion-reg-client-utils.js +32 -0
- package/lib/Utils/companion-reg-client-utils.js.map +1 -0
- package/lib/Utils/crypto.d.ts +31 -0
- package/lib/Utils/crypto.d.ts.map +1 -0
- package/lib/Utils/crypto.js +81 -0
- package/lib/Utils/crypto.js.map +1 -0
- package/lib/Utils/event-buffer.d.ts +15 -4
- package/lib/Utils/event-buffer.d.ts.map +1 -1
- package/lib/Utils/event-buffer.js +471 -34
- package/lib/Utils/event-buffer.js.map +1 -1
- package/lib/Utils/generics.d.ts +52 -15
- package/lib/Utils/generics.d.ts.map +1 -1
- package/lib/Utils/generics.js +269 -25
- package/lib/Utils/generics.js.map +1 -1
- package/lib/Utils/group-stub-params.d.ts +1 -28
- package/lib/Utils/group-stub-params.d.ts.map +1 -1
- package/lib/Utils/group-stub-params.js +2 -44
- package/lib/Utils/group-stub-params.js.map +1 -1
- package/lib/Utils/identity-change-handler.d.ts +2 -0
- package/lib/Utils/identity-change-handler.d.ts.map +1 -0
- package/lib/Utils/identity-change-handler.js +4 -0
- package/lib/Utils/identity-change-handler.js.map +1 -0
- package/lib/Utils/index.d.ts +9 -0
- package/lib/Utils/index.d.ts.map +1 -1
- package/lib/Utils/index.js +19 -10
- package/lib/Utils/index.js.map +1 -1
- package/lib/Utils/logger.d.ts.map +1 -1
- package/lib/Utils/message-retry-manager.d.ts +2 -0
- package/lib/Utils/message-retry-manager.d.ts.map +1 -0
- package/lib/Utils/message-retry-manager.js +4 -0
- package/lib/Utils/message-retry-manager.js.map +1 -0
- package/lib/Utils/messages-media.d.ts +28 -6
- package/lib/Utils/messages-media.d.ts.map +1 -1
- package/lib/Utils/messages-media.js +119 -1
- package/lib/Utils/messages-media.js.map +1 -1
- package/lib/Utils/messages.d.ts +33 -9
- package/lib/Utils/messages.d.ts.map +1 -1
- package/lib/Utils/messages.js +106 -33
- package/lib/Utils/messages.js.map +1 -1
- package/lib/Utils/native-crypto-provider.d.ts +10 -8
- package/lib/Utils/native-crypto-provider.d.ts.map +1 -1
- package/lib/Utils/native-crypto-provider.js +13 -56
- package/lib/Utils/native-crypto-provider.js.map +1 -1
- package/lib/Utils/pre-key-manager.d.ts +2 -0
- package/lib/Utils/pre-key-manager.d.ts.map +1 -0
- package/lib/Utils/pre-key-manager.js +3 -0
- package/lib/Utils/pre-key-manager.js.map +1 -0
- package/lib/Utils/process-history-message.d.ts +15 -4
- package/lib/Utils/process-history-message.d.ts.map +1 -1
- package/lib/Utils/process-history-message.js +162 -95
- package/lib/Utils/process-history-message.js.map +1 -1
- package/lib/Utils/process-message.d.ts +25 -0
- package/lib/Utils/process-message.d.ts.map +1 -0
- package/lib/Utils/process-message.js +79 -0
- package/lib/Utils/process-message.js.map +1 -0
- package/lib/Utils/signal.d.ts +29 -0
- package/lib/Utils/signal.d.ts.map +1 -0
- package/lib/Utils/signal.js +133 -0
- package/lib/Utils/signal.js.map +1 -0
- package/lib/Utils/sparse-array.d.ts +9 -0
- package/lib/Utils/sparse-array.d.ts.map +1 -0
- package/lib/Utils/sparse-array.js +12 -0
- package/lib/Utils/sparse-array.js.map +1 -0
- package/lib/Utils/stanza-ack.d.ts +2 -0
- package/lib/Utils/stanza-ack.d.ts.map +1 -0
- package/lib/Utils/stanza-ack.js +3 -0
- package/lib/Utils/stanza-ack.js.map +1 -0
- package/lib/Utils/use-bridge-store.d.ts.map +1 -1
- package/lib/Utils/use-bridge-store.js +191 -7
- package/lib/Utils/use-bridge-store.js.map +1 -1
- package/lib/Utils/use-memory-store.d.ts +8 -4
- package/lib/Utils/use-memory-store.d.ts.map +1 -1
- package/lib/Utils/use-memory-store.js +87 -10
- package/lib/Utils/use-memory-store.js.map +1 -1
- package/lib/Utils/use-multi-file-auth-state.d.ts +4 -2
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -1
- package/lib/Utils/use-multi-file-auth-state.js +13 -5
- package/lib/Utils/use-multi-file-auth-state.js.map +1 -1
- package/lib/Utils/wrap-legacy-store.d.ts +8 -32
- package/lib/Utils/wrap-legacy-store.d.ts.map +1 -1
- package/lib/Utils/wrap-legacy-store.js +7 -1214
- package/lib/Utils/wrap-legacy-store.js.map +1 -1
- package/lib/WABinary/generic-utils.d.ts +8 -0
- package/lib/WABinary/generic-utils.d.ts.map +1 -1
- package/lib/WABinary/generic-utils.js +63 -1
- package/lib/WABinary/generic-utils.js.map +1 -1
- package/lib/WABinary/index.js +2 -2
- package/lib/WABinary/jid-utils.d.ts +22 -10
- package/lib/WABinary/jid-utils.d.ts.map +1 -1
- package/lib/WABinary/jid-utils.js +40 -9
- package/lib/WABinary/jid-utils.js.map +1 -1
- package/lib/WAProto/compatibility-schema.d.ts +25 -0
- package/lib/WAProto/compatibility-schema.d.ts.map +1 -0
- package/lib/WAProto/compatibility-schema.js +6 -0
- package/lib/WAProto/compatibility-schema.js.map +1 -0
- package/lib/WAProto/runtime.d.ts +14019 -0
- package/lib/WAProto/runtime.js +17 -0
- package/lib/WAProto/runtime.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +27 -0
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +39 -0
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +33 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +41 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +19 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +15 -0
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +25 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +21 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/index.d.ts +6 -0
- package/lib/WAUSync/Protocols/index.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/index.js +6 -0
- package/lib/WAUSync/Protocols/index.js.map +1 -0
- package/lib/WAUSync/USyncQuery.d.ts +30 -0
- package/lib/WAUSync/USyncQuery.d.ts.map +1 -0
- package/lib/WAUSync/USyncQuery.js +78 -0
- package/lib/WAUSync/USyncQuery.js.map +1 -0
- package/lib/WAUSync/USyncUser.d.ts +17 -0
- package/lib/WAUSync/USyncUser.d.ts.map +1 -0
- package/lib/WAUSync/USyncUser.js +31 -0
- package/lib/WAUSync/USyncUser.js.map +1 -0
- package/lib/WAUSync/index.d.ts +4 -0
- package/lib/WAUSync/index.d.ts.map +1 -0
- package/lib/WAUSync/index.js +4 -0
- package/lib/WAUSync/index.js.map +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +9 -9
- package/lib/index.js.map +1 -1
- package/package.json +33 -15
- package/lib/Bridge/__tests__/adapt.test.d.ts +0 -2
- package/lib/Bridge/__tests__/adapt.test.d.ts.map +0 -1
- package/lib/Bridge/__tests__/adapt.test.js +0 -387
- package/lib/Bridge/__tests__/adapt.test.js.map +0 -1
- package/lib/Bridge/__tests__/dts-drift.test.d.ts +0 -13
- package/lib/Bridge/__tests__/dts-drift.test.d.ts.map +0 -1
- package/lib/Bridge/__tests__/dts-drift.test.js +0 -90
- package/lib/Bridge/__tests__/dts-drift.test.js.map +0 -1
- package/lib/Bridge/__tests__/fixtures.d.ts +0 -192
- package/lib/Bridge/__tests__/fixtures.d.ts.map +0 -1
- package/lib/Bridge/__tests__/fixtures.js +0 -99
- package/lib/Bridge/__tests__/fixtures.js.map +0 -1
- package/lib/Utils/__tests__/_legacy-store-fixtures.d.ts +0 -73
- package/lib/Utils/__tests__/_legacy-store-fixtures.d.ts.map +0 -1
- package/lib/Utils/__tests__/_legacy-store-fixtures.js +0 -113
- package/lib/Utils/__tests__/_legacy-store-fixtures.js.map +0 -1
- package/lib/Utils/__tests__/wrap-legacy-store-coverage.test.d.ts +0 -10
- package/lib/Utils/__tests__/wrap-legacy-store-coverage.test.d.ts.map +0 -1
- package/lib/Utils/__tests__/wrap-legacy-store-coverage.test.js +0 -291
- package/lib/Utils/__tests__/wrap-legacy-store-coverage.test.js.map +0 -1
- package/lib/Utils/__tests__/wrap-legacy-store-lid-mapping.test.d.ts +0 -8
- package/lib/Utils/__tests__/wrap-legacy-store-lid-mapping.test.d.ts.map +0 -1
- package/lib/Utils/__tests__/wrap-legacy-store-lid-mapping.test.js +0 -91
- package/lib/Utils/__tests__/wrap-legacy-store-lid-mapping.test.js.map +0 -1
- package/lib/Utils/__tests__/wrap-legacy-store-sender-key.test.d.ts +0 -10
- package/lib/Utils/__tests__/wrap-legacy-store-sender-key.test.d.ts.map +0 -1
- package/lib/Utils/__tests__/wrap-legacy-store-sender-key.test.js +0 -125
- package/lib/Utils/__tests__/wrap-legacy-store-sender-key.test.js.map +0 -1
- package/lib/Utils/__tests__/wrap-legacy-store-session-ratchet.test.d.ts +0 -2
- package/lib/Utils/__tests__/wrap-legacy-store-session-ratchet.test.d.ts.map +0 -1
- package/lib/Utils/__tests__/wrap-legacy-store-session-ratchet.test.js +0 -214
- package/lib/Utils/__tests__/wrap-legacy-store-session-ratchet.test.js.map +0 -1
- package/lib/Utils/__tests__/wrap-legacy-store-session.test.d.ts +0 -14
- package/lib/Utils/__tests__/wrap-legacy-store-session.test.d.ts.map +0 -1
- package/lib/Utils/__tests__/wrap-legacy-store-session.test.js +0 -305
- package/lib/Utils/__tests__/wrap-legacy-store-session.test.js.map +0 -1
- package/lib/Utils/bridge-call.d.ts +0 -22
- package/lib/Utils/bridge-call.d.ts.map +0 -1
- package/lib/Utils/bridge-call.js +0 -105
- package/lib/Utils/bridge-call.js.map +0 -1
- package/lib/Utils/lid-mapping-store.d.ts +0 -81
- package/lib/Utils/lid-mapping-store.d.ts.map +0 -1
- package/lib/Utils/lid-mapping-store.js +0 -126
- package/lib/Utils/lid-mapping-store.js.map +0 -1
- package/lib/__tests__/expect.d.ts +0 -44
- package/lib/__tests__/expect.d.ts.map +0 -1
- package/lib/__tests__/expect.js +0 -100
- package/lib/__tests__/expect.js.map +0 -1
package/lib/Socket/contacts.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
export const makeContactMethods = (ctx) => ({
|
|
2
|
-
onWhatsApp: async (...
|
|
2
|
+
onWhatsApp: async (...phoneNumber) => {
|
|
3
3
|
const client = await ctx.getClient();
|
|
4
4
|
// Single batched usync — the bridge splits PN/LID inputs internally and
|
|
5
5
|
// returns lid/pnJid/isBusiness in the same payload, so no secondary IQ.
|
|
6
|
-
const results = await client.isOnWhatsApp(
|
|
6
|
+
const results = await client.isOnWhatsApp(phoneNumber);
|
|
7
7
|
return results.map(r => {
|
|
8
8
|
const out = { exists: r.isRegistered, jid: r.jid, isBusiness: r.isBusiness };
|
|
9
9
|
if (r.lid)
|
|
10
10
|
out.lid = r.lid;
|
|
11
11
|
if (r.pnJid)
|
|
12
12
|
out.pnJid = r.pnJid;
|
|
13
|
+
if (r.verifiedName)
|
|
14
|
+
out.verifiedName = r.verifiedName;
|
|
13
15
|
return out;
|
|
14
16
|
});
|
|
15
17
|
},
|
|
16
|
-
profilePictureUrl: async (jid, type = 'preview') => {
|
|
17
|
-
const result = await (await ctx.getClient()).profilePictureUrl(jid, type);
|
|
18
|
+
profilePictureUrl: async (jid, type = 'preview', timeoutMs) => {
|
|
19
|
+
const result = await (await ctx.getClient()).profilePictureUrl(jid, type, timeoutMs);
|
|
18
20
|
return result?.url;
|
|
19
21
|
},
|
|
20
22
|
fetchUserInfo: async (...jids) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contacts.js","sourceRoot":"","sources":["../../src/Socket/contacts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"contacts.js","sourceRoot":"","sources":["../../src/Socket/contacts.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAkB,EAAE,EAAE,CAAC,CAAC;IAC1D,UAAU,EAAE,KAAK,EAAE,GAAG,WAAqB,EAA2C,EAAE;QACvF,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,SAAS,EAAE,CAAA;QACpC,wEAAwE;QACxE,wEAAwE;QACxE,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,CAAA;QACtD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YACtB,MAAM,GAAG,GAAqB,EAAE,MAAM,EAAE,CAAC,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE,CAAA;YAC9F,IAAI,CAAC,CAAC,GAAG;gBAAE,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAA;YAC1B,IAAI,CAAC,CAAC,KAAK;gBAAE,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAA;YAChC,IAAI,CAAC,CAAC,YAAY;gBAAE,GAAG,CAAC,YAAY,GAAG,CAAC,CAAC,YAAY,CAAA;YACrD,OAAO,GAAG,CAAA;QACX,CAAC,CAAC,CAAA;IACH,CAAC;IAED,iBAAiB,EAAE,KAAK,EAAE,GAAW,EAAE,IAAI,GAAwB,SAAS,EAAE,SAAkB,EAAE,EAAE;QACnG,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,iBAAiB,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;QACpF,OAAO,MAAM,EAAE,GAAG,CAAA;IACnB,CAAC;IAED,aAAa,EAAE,KAAK,EAAE,GAAG,IAAc,EAAE,EAAE;QAC1C,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;IACzD,CAAC;CACD,CAAC,CAAA"}
|
package/lib/Socket/events.d.ts
CHANGED
|
@@ -6,20 +6,28 @@
|
|
|
6
6
|
* mapped type so TS forces a handler per variant — a missing handler
|
|
7
7
|
* is a compile error.
|
|
8
8
|
*/
|
|
9
|
-
import type { WhatsAppEvent } from 'whatsapp-rust-bridge';
|
|
9
|
+
import type { WhatsAppEvent, WhatsAppEventCallbacks } from 'whatsapp-rust-bridge';
|
|
10
|
+
import type { CanonicalEvent } from '../Bridge/index.js';
|
|
10
11
|
import type { SocketContext } from './types.js';
|
|
11
12
|
interface EventCallbacks {
|
|
12
13
|
onPairSuccess?: (data: {
|
|
13
14
|
platform?: string;
|
|
14
15
|
businessName?: string;
|
|
15
16
|
}) => void | Promise<void>;
|
|
17
|
+
onIncomingCall?: (event: Extract<CanonicalEvent, {
|
|
18
|
+
type: 'incomingCall';
|
|
19
|
+
}>) => void;
|
|
20
|
+
onDirtyState?: (event: Extract<CanonicalEvent, {
|
|
21
|
+
type: 'dirtyState';
|
|
22
|
+
}>) => void;
|
|
16
23
|
}
|
|
17
24
|
/**
|
|
18
|
-
* Create
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* exclusively, so a downstream rename surfaces as a `tsc` failure.
|
|
25
|
+
* Create typed single and batch handlers for the bridge. The bridge only uses
|
|
26
|
+
* the batch capability when adjacent messages are already queued, while this
|
|
27
|
+
* layer owns all Baileys-specific translation and EventEmitter aggregation.
|
|
22
28
|
*/
|
|
29
|
+
export declare const makeEventHandlers: (ctx: SocketContext, callbacks?: EventCallbacks) => WhatsAppEventCallbacks;
|
|
30
|
+
/** Legacy single-event helper retained for direct consumers and tests. */
|
|
23
31
|
export declare const makeEventHandler: (ctx: SocketContext, callbacks?: EventCallbacks) => (event: WhatsAppEvent) => void;
|
|
24
32
|
export {};
|
|
25
33
|
//# sourceMappingURL=events.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/Socket/events.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/Socket/events.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAGX,aAAa,EACb,sBAAsB,EACtB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,cAAc,EAAoB,MAAM,oBAAoB,CAAA;AA8B1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAgF/C,UAAU,cAAc;IACvB,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5F,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,cAAc,EAAE;QAAE,IAAI,EAAE,cAAc,CAAA;KAAE,CAAC,KAAK,IAAI,CAAA;IACnF,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,cAAc,EAAE;QAAE,IAAI,EAAE,YAAY,CAAA;KAAE,CAAC,KAAK,IAAI,CAAA;CAC/E;AAuuBD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QAAS,aAAa,cAAc,cAAc,KAAG,sBA8DlF,CAAA;AAED,0EAA0E;AAC1E,eAAO,MAAM,gBAAgB,QAAS,aAAa,cAAc,cAAc,mCACrC,CAAA"}
|
package/lib/Socket/events.js
CHANGED
|
@@ -6,14 +6,25 @@
|
|
|
6
6
|
* mapped type so TS forces a handler per variant — a missing handler
|
|
7
7
|
* is a compile error.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
import { BinaryReader } from 'whatsapp-rust-bridge';
|
|
10
|
+
import { adaptBridgeEvent, adaptBridgeMessageWire } from '../Bridge/index.js';
|
|
11
|
+
import { decodeHistorySyncWireBatch } from '../Bridge/history-sync-wire.js';
|
|
12
|
+
import { bridgeGroupMetadataToBaileys } from '../Compatibility/group-metadata.js';
|
|
13
|
+
import { DEF_CALLBACK_PREFIX, DEF_TAG_PREFIX, HISTORY_SYNC_PAUSED_TIMEOUT_MS } from '../Defaults/index.js';
|
|
14
|
+
import { DisconnectReason, WAMessageStatus, WAProto } from '../Types/index.js';
|
|
15
|
+
import { LabelAssociationType } from '../Types/LabelAssociation.js';
|
|
16
|
+
import { Boom } from '../Utils/boom.js';
|
|
17
|
+
import { toNumber } from '../Utils/generics.js';
|
|
18
|
+
import { CONVERSATION_HISTORY_SYNC_TYPES } from '../Utils/process-history-message.js';
|
|
19
|
+
import { isJidGroup } from '../WABinary/jid-utils.js';
|
|
20
|
+
import { buildGroupCreateStubMessage, buildGroupJoinRequestEvents, buildGroupNotificationChatUpdates, buildGroupNotificationDomainEvent, buildGroupNotificationStubMessages } from '../Compatibility/group-notifications.js';
|
|
21
|
+
import { emitMessageUpsert } from '../Compatibility/message-upsert.js';
|
|
22
|
+
import { extractMessageCappingPayload } from './message-capping.js';
|
|
23
|
+
import { mapReachoutTimelock } from './reachout.js';
|
|
24
|
+
const CANONICAL_MESSAGE_EVENT = 'message';
|
|
25
|
+
const MESSAGE_UPSERT_APPEND = 'append';
|
|
26
|
+
const MESSAGE_UPSERT_NOTIFY = 'notify';
|
|
27
|
+
const MESSAGE_WIRE_OFFSET_SENTINEL_COUNT = 1;
|
|
17
28
|
/** Emit CB: pattern events on the ws EventEmitter for retrocompat. */
|
|
18
29
|
const emitCBEvents = (ctx, node) => {
|
|
19
30
|
const { ws } = ctx;
|
|
@@ -71,6 +82,17 @@ const canonicalMessageToWAMessage = (m) => {
|
|
|
71
82
|
wm.key.editAttribute = m.editAttribute;
|
|
72
83
|
return wm;
|
|
73
84
|
};
|
|
85
|
+
const messageUpsertMetadata = (message) => ({
|
|
86
|
+
type: message.isOffline ? MESSAGE_UPSERT_APPEND : MESSAGE_UPSERT_NOTIFY,
|
|
87
|
+
requestId: message.unavailableRequestId
|
|
88
|
+
});
|
|
89
|
+
const hasMessageSideEffects = (message) => message.messageProto.reactionMessage != null || message.messageProto.protocolMessage != null;
|
|
90
|
+
const hasSameUpsertMetadata = (left, right) => left.type === right.type && left.requestId === right.requestId;
|
|
91
|
+
const clearHistorySyncPausedTimeout = (state) => {
|
|
92
|
+
if (state.pausedTimeout)
|
|
93
|
+
clearTimeout(state.pausedTimeout);
|
|
94
|
+
state.pausedTimeout = undefined;
|
|
95
|
+
};
|
|
74
96
|
const emitClose = (ctx, reason, statusCode, data) => ctx.ev.emit('connection.update', {
|
|
75
97
|
connection: 'close',
|
|
76
98
|
lastDisconnect: { error: new Boom(reason, { statusCode, data }), date: new Date() }
|
|
@@ -132,7 +154,13 @@ const emitConnectionUpdate = (ctx, update) => ctx.ev.emit('connection.update', u
|
|
|
132
154
|
const DISPATCHERS = {
|
|
133
155
|
// ── Connection lifecycle ──
|
|
134
156
|
connected: (_, { ctx }) => emitConnectionUpdate(ctx, { connection: 'open' }),
|
|
135
|
-
|
|
157
|
+
offlineSyncCompleted: (_, { ctx }) => emitConnectionUpdate(ctx, {
|
|
158
|
+
receivedPendingNotifications: true
|
|
159
|
+
}),
|
|
160
|
+
disconnected: (_, { ctx, historySync }) => {
|
|
161
|
+
clearHistorySyncPausedTimeout(historySync);
|
|
162
|
+
emitClose(ctx, 'Connection closed', DisconnectReason.connectionClosed);
|
|
163
|
+
},
|
|
136
164
|
qr: (evt, { ctx }) => emitConnectionUpdate(ctx, { qr: evt.code }),
|
|
137
165
|
pairSuccess: (evt, { ctx, callbacks }) => {
|
|
138
166
|
const { id, lid, businessName, platform } = evt;
|
|
@@ -196,13 +224,7 @@ const DISPATCHERS = {
|
|
|
196
224
|
// succeeds, not to drop inbound `fromMe` messages from other linked
|
|
197
225
|
// devices.
|
|
198
226
|
const waMsg = canonicalMessageToWAMessage(evt);
|
|
199
|
-
|
|
200
|
-
messages: [waMsg],
|
|
201
|
-
type: evt.isOffline ? 'append' : 'notify'
|
|
202
|
-
};
|
|
203
|
-
if (evt.unavailableRequestId)
|
|
204
|
-
upsertPayload.requestId = evt.unavailableRequestId;
|
|
205
|
-
ctx.ev.emit('messages.upsert', upsertPayload);
|
|
227
|
+
emitMessageUpsert(ctx, [waMsg], messageUpsertMetadata(evt));
|
|
206
228
|
// Mirror upstream `process-message.ts:523-533`: when the inbound
|
|
207
229
|
// proto carries a `reactionMessage`, surface it on the dedicated
|
|
208
230
|
// `messages.reaction` channel as well. The `key` in the event
|
|
@@ -260,8 +282,11 @@ const DISPATCHERS = {
|
|
|
260
282
|
]);
|
|
261
283
|
}
|
|
262
284
|
else if (protocolMsg.type === WAProto.Message.ProtocolMessage.Type.MESSAGE_EDIT && protocolMsg.editedMessage) {
|
|
285
|
+
// `timestampMs` is an int64 proto field → a protobufjs `Long`
|
|
286
|
+
// object from the bridge; `toNumber` is Long-safe (plain
|
|
287
|
+
// `Number()` would yield NaN and corrupt the edit timestamp).
|
|
263
288
|
const tsMs = protocolMsg.timestampMs;
|
|
264
|
-
const editedTs = tsMs != null ? Math.floor(
|
|
289
|
+
const editedTs = tsMs != null ? Math.floor(toNumber(tsMs) / 1000) : (evt.timestamp ?? waMsg.messageTimestamp);
|
|
265
290
|
ctx.ev.emit('messages.update', [
|
|
266
291
|
{
|
|
267
292
|
key: { ...waMsg.key, id: protocolKeyId },
|
|
@@ -383,6 +408,42 @@ const DISPATCHERS = {
|
|
|
383
408
|
groupUpdate: (evt, { ctx }) => {
|
|
384
409
|
const user = ctx.getUser();
|
|
385
410
|
const fromMe = !!(evt.author && (evt.author === user?.id || evt.author === user?.lid));
|
|
411
|
+
if (evt.action.type === 'create') {
|
|
412
|
+
// The neutral bridge marker intentionally carries no Baileys-shaped
|
|
413
|
+
// metadata. Resolve it here, at the compatibility boundary, then emit
|
|
414
|
+
// the same complete lifecycle and ordering as upstream.
|
|
415
|
+
void (async () => {
|
|
416
|
+
try {
|
|
417
|
+
const bridgeMetadata = await (await ctx.getClient()).getGroupMetadata(evt.groupJid);
|
|
418
|
+
const metadata = bridgeGroupMetadataToBaileys(bridgeMetadata);
|
|
419
|
+
ctx.ev.emit('chats.upsert', [
|
|
420
|
+
{ id: metadata.id, name: metadata.subject, conversationTimestamp: metadata.creation }
|
|
421
|
+
]);
|
|
422
|
+
ctx.ev.emit('groups.upsert', [
|
|
423
|
+
{
|
|
424
|
+
...metadata,
|
|
425
|
+
author: evt.author,
|
|
426
|
+
authorPn: evt.authorPn,
|
|
427
|
+
authorUsername: evt.authorUsername
|
|
428
|
+
}
|
|
429
|
+
]);
|
|
430
|
+
ctx.ev.emit('messages.upsert', {
|
|
431
|
+
messages: [buildGroupCreateStubMessage(evt, metadata, fromMe)],
|
|
432
|
+
type: 'append'
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
catch (err) {
|
|
436
|
+
ctx.logger.warn({ err, groupJid: evt.groupJid }, 'group create notification: metadata resolution failed');
|
|
437
|
+
}
|
|
438
|
+
})();
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
// Upstream upserts the synthesized notification message before
|
|
442
|
+
// process-message derives high-level group/chat events from it.
|
|
443
|
+
const stubMessages = buildGroupNotificationStubMessages(evt, fromMe);
|
|
444
|
+
if (stubMessages.length > 0) {
|
|
445
|
+
ctx.ev.emit('messages.upsert', { messages: stubMessages, type: 'append' });
|
|
446
|
+
}
|
|
386
447
|
// Dispatch via discriminator instead of `as never` so TS validates
|
|
387
448
|
// payload ↔ event-name pairing.
|
|
388
449
|
const domainEvent = buildGroupNotificationDomainEvent(evt);
|
|
@@ -392,25 +453,15 @@ const DISPATCHERS = {
|
|
|
392
453
|
else
|
|
393
454
|
ctx.ev.emit('group-participants.update', domainEvent.payload);
|
|
394
455
|
}
|
|
395
|
-
// `groups.upsert` is intentionally NOT emitted from `<create>`. The
|
|
396
|
-
// bridge gives us only the creation marker — `participants` /
|
|
397
|
-
// `subject` / `creation` are unknown without an extra IQ. Upstream
|
|
398
|
-
// emits this only AFTER `groupMetadata` resolves (`messages-recv.ts:661`),
|
|
399
|
-
// so emitting `[{ id }]` here would feed consumers a broken
|
|
400
|
-
// `GroupMetadata` (participants undefined → `metadata.participants.map`
|
|
401
|
-
// throws). Bots that want the metadata should call
|
|
402
|
-
// `sock.groupMetadata(evt.groupJid)` from a `groups.update` listener
|
|
403
|
-
// or after the matching `messages.upsert` stub.
|
|
404
456
|
// Fan out `group.join-request` for membership_approval_request /
|
|
405
457
|
// created_membership_requests / revoked_membership_requests.
|
|
406
458
|
// Upstream emits one event per affected participant.
|
|
407
459
|
for (const joinReq of buildGroupJoinRequestEvents(evt)) {
|
|
408
460
|
ctx.ev.emit('group.join-request', joinReq);
|
|
409
461
|
}
|
|
410
|
-
const
|
|
411
|
-
if (
|
|
412
|
-
ctx.ev.emit('
|
|
413
|
-
}
|
|
462
|
+
const chatUpdates = buildGroupNotificationChatUpdates(evt);
|
|
463
|
+
if (chatUpdates.length > 0)
|
|
464
|
+
ctx.ev.emit('chats.update', chatUpdates);
|
|
414
465
|
},
|
|
415
466
|
// ── Chat state ──
|
|
416
467
|
archiveUpdate: (evt, { ctx }) => ctx.ev.emit('chats.update', [{ id: evt.jid, archived: evt.archived }]),
|
|
@@ -435,16 +486,34 @@ const DISPATCHERS = {
|
|
|
435
486
|
// Mirrors upstream `chat-utils.ts:852`: read=true → unreadCount=0,
|
|
436
487
|
// read=false (mark as unread) → -1 sentinel.
|
|
437
488
|
ctx.ev.emit('chats.update', [{ id: evt.jid, unreadCount: evt.read ? 0 : -1 }]),
|
|
489
|
+
labelEdit: (evt, { ctx }) =>
|
|
490
|
+
// Upstream `labels.edit` carries a `Label`. A delete arrives with
|
|
491
|
+
// `deleted: true` (consumers remove it from their store).
|
|
492
|
+
ctx.ev.emit('labels.edit', {
|
|
493
|
+
id: evt.labelId,
|
|
494
|
+
name: evt.name,
|
|
495
|
+
color: evt.color,
|
|
496
|
+
deleted: evt.deleted,
|
|
497
|
+
predefinedId: evt.predefinedId
|
|
498
|
+
}),
|
|
499
|
+
labelAssociation: (evt, { ctx }) =>
|
|
500
|
+
// Inbound sync only ever carries chat associations (the bridge event
|
|
501
|
+
// has a `chat_jid`); message-label associations are a separate path.
|
|
502
|
+
ctx.ev.emit('labels.association', {
|
|
503
|
+
association: { type: LabelAssociationType.Chat, chatId: evt.chatJid, labelId: evt.labelId },
|
|
504
|
+
type: evt.labeled ? 'add' : 'remove'
|
|
505
|
+
}),
|
|
438
506
|
// ── Calls ──
|
|
439
|
-
incomingCall: (evt, { ctx }) => {
|
|
507
|
+
incomingCall: (evt, { ctx, callbacks }) => {
|
|
508
|
+
callbacks?.onIncomingCall?.(evt);
|
|
440
509
|
const isGroup = isJidGroup(evt.from);
|
|
441
|
-
//
|
|
442
|
-
//
|
|
443
|
-
|
|
444
|
-
const status = evt.action.type === 'preAccept' ? 'ringing' : evt.action.type;
|
|
510
|
+
// Canonical call actions use the exact public Baileys status spelling;
|
|
511
|
+
// missed-call notifications are normalized to `timeout` by the adapter.
|
|
512
|
+
const status = evt.action.type;
|
|
445
513
|
const callEvt = {
|
|
446
514
|
chatId: evt.from,
|
|
447
|
-
from: evt.from,
|
|
515
|
+
from: evt.action.callCreator ?? evt.from,
|
|
516
|
+
...(evt.action.callCreator ? { callCreator: evt.action.callCreator } : {}),
|
|
448
517
|
id: evt.action.callId,
|
|
449
518
|
date: new Date(evt.timestamp * 1000),
|
|
450
519
|
status,
|
|
@@ -472,6 +541,7 @@ const DISPATCHERS = {
|
|
|
472
541
|
ctx.ev.emit('call', [callEvt]);
|
|
473
542
|
},
|
|
474
543
|
// ── Raw passthrough ──
|
|
544
|
+
dirtyState: (evt, { callbacks }) => callbacks?.onDirtyState?.(evt),
|
|
475
545
|
rawNode: (evt, { ctx }) => emitCBEvents(ctx, evt.node),
|
|
476
546
|
notification: (evt, { ctx }) => ctx.logger.trace({ tag: evt.tag, attrs: evt.attrs }, 'bridge generic notification (no Baileys mapping)'),
|
|
477
547
|
mexNotification: (evt, { ctx }) => {
|
|
@@ -485,8 +555,35 @@ const DISPATCHERS = {
|
|
|
485
555
|
ctx.logger.warn({ payload: evt.payload }, 'reachout-timelock push: payload missing expected fields');
|
|
486
556
|
return;
|
|
487
557
|
}
|
|
558
|
+
if (evt.opName === 'MessageCappingInfoNotification') {
|
|
559
|
+
const payload = extractMessageCappingPayload(evt.payload);
|
|
560
|
+
if (payload)
|
|
561
|
+
ctx.ev.emit('message-capping.update', payload);
|
|
562
|
+
else
|
|
563
|
+
ctx.logger.warn({ payload: evt.payload }, 'message-capping push: payload missing expected fields');
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
488
566
|
ctx.logger.trace({ opName: evt.opName, offline: evt.offline }, 'bridge mex notification with no Baileys mapping (drop)');
|
|
489
567
|
},
|
|
568
|
+
serverAck: (evt, { ctx }) => {
|
|
569
|
+
// The public CB surface comes exclusively from Event::RawNode. Rebuilding
|
|
570
|
+
// an ACK from this semantic event would drop optional wire attributes and
|
|
571
|
+
// emit the same stanza twice whenever raw forwarding is enabled.
|
|
572
|
+
if (evt.class === 'message' && evt.error) {
|
|
573
|
+
ctx.logger.warn({ msgId: evt.id, from: evt.from, error: evt.error }, 'outgoing message was rejected by the server');
|
|
574
|
+
ctx.ev.emit('messages.update', [
|
|
575
|
+
{
|
|
576
|
+
key: { remoteJid: evt.from, fromMe: true, id: evt.id },
|
|
577
|
+
update: {
|
|
578
|
+
status: WAMessageStatus.ERROR,
|
|
579
|
+
messageStubParameters: [evt.error]
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
]);
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
ctx.logger.debug({ msgId: evt.id, class: evt.class, from: evt.from, timestamp: evt.timestamp }, 'server acknowledged outgoing stanza');
|
|
586
|
+
},
|
|
490
587
|
noop: (evt, { ctx }) => ctx.logger.trace({ bridgeType: evt.bridgeType, detail: evt.detail }, 'bridge event acknowledged (no Baileys equivalent)'),
|
|
491
588
|
lidMappingUpdate: (evt, { ctx }) => {
|
|
492
589
|
// Mirror upstream `messages-recv.ts:287`: one `lid-mapping.update`
|
|
@@ -496,6 +593,7 @@ const DISPATCHERS = {
|
|
|
496
593
|
}
|
|
497
594
|
},
|
|
498
595
|
chatDelete: (evt, { ctx }) => ctx.ev.emit('chats.delete', [evt.jid]),
|
|
596
|
+
chatClear: (evt, { ctx }) => ctx.ev.emit('messages.delete', { jid: evt.jid, all: true }),
|
|
499
597
|
messageDelete: (evt, { ctx }) =>
|
|
500
598
|
// Upstream `chat-utils.ts:857` shape: `{ keys: WAMessageKey[] }` for
|
|
501
599
|
// per-message delete (not the `{ jid, all: true }` chat-clear case
|
|
@@ -541,7 +639,7 @@ const DISPATCHERS = {
|
|
|
541
639
|
ephemeralSettingTimestamp: evt.settingTimestamp
|
|
542
640
|
}
|
|
543
641
|
]),
|
|
544
|
-
historySync: (evt, { ctx }) => {
|
|
642
|
+
historySync: (evt, { ctx, historySync }) => {
|
|
545
643
|
// 1:1 with upstream `process-message.ts:371-376`. `isLatest` is true
|
|
546
644
|
// when this is the first history sync the bot has seen since
|
|
547
645
|
// pairing — upstream tracks it in `creds.processedHistoryMessages`,
|
|
@@ -550,13 +648,49 @@ const DISPATCHERS = {
|
|
|
550
648
|
// gating "first hydrate" logic on `isLatest` see the same boolean.
|
|
551
649
|
const HSType = WAProto.HistorySync.HistorySyncType;
|
|
552
650
|
const isInitial = evt.syncType === HSType.INITIAL_BOOTSTRAP;
|
|
651
|
+
// The bridge may split one chunk into bounded batches (isFinalBatch=false
|
|
652
|
+
// on all but the last). `isLatest`/`progress` are chunk-level signals, so
|
|
653
|
+
// they only fire on the final batch — intermediate batches just append
|
|
654
|
+
// data. A non-batched bridge omits the flag → `!== false` keeps the old
|
|
655
|
+
// single-event behavior.
|
|
656
|
+
const isFinalBatch = evt.isFinalBatch !== false;
|
|
657
|
+
if (isFinalBatch && isInitial && !historySync.initialBootstrapComplete) {
|
|
658
|
+
historySync.initialBootstrapComplete = true;
|
|
659
|
+
ctx.ev.emit('messaging-history.status', {
|
|
660
|
+
syncType: HSType.INITIAL_BOOTSTRAP,
|
|
661
|
+
status: 'complete',
|
|
662
|
+
explicit: true
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
if (isFinalBatch && evt.syncType === HSType.RECENT && !historySync.recentSyncComplete) {
|
|
666
|
+
clearHistorySyncPausedTimeout(historySync);
|
|
667
|
+
if (evt.progress === 100) {
|
|
668
|
+
historySync.recentSyncComplete = true;
|
|
669
|
+
ctx.ev.emit('messaging-history.status', { syncType: HSType.RECENT, status: 'complete', explicit: true });
|
|
670
|
+
}
|
|
671
|
+
else {
|
|
672
|
+
historySync.pausedTimeout = setTimeout(() => {
|
|
673
|
+
if (!historySync.recentSyncComplete) {
|
|
674
|
+
historySync.recentSyncComplete = true;
|
|
675
|
+
ctx.ev.emit('messaging-history.status', {
|
|
676
|
+
syncType: HSType.RECENT,
|
|
677
|
+
status: 'paused',
|
|
678
|
+
explicit: false
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
historySync.pausedTimeout = undefined;
|
|
682
|
+
}, HISTORY_SYNC_PAUSED_TIMEOUT_MS);
|
|
683
|
+
historySync.pausedTimeout.unref?.();
|
|
684
|
+
}
|
|
685
|
+
}
|
|
553
686
|
const payload = {
|
|
554
687
|
chats: evt.chats,
|
|
555
688
|
contacts: evt.contacts,
|
|
556
689
|
messages: evt.messages,
|
|
557
|
-
isLatest: evt.syncType === HSType.ON_DEMAND ? undefined : isInitial,
|
|
558
|
-
progress: evt.progress,
|
|
690
|
+
isLatest: evt.syncType === HSType.ON_DEMAND ? undefined : isInitial && isFinalBatch,
|
|
691
|
+
progress: isFinalBatch ? evt.progress : undefined,
|
|
559
692
|
syncType: evt.syncType,
|
|
693
|
+
pastParticipants: evt.pastParticipants,
|
|
560
694
|
chunkOrder: evt.chunkOrder,
|
|
561
695
|
peerDataRequestSessionId: evt.peerDataRequestSessionId,
|
|
562
696
|
lidPnMappings: evt.lidPnMappings.length > 0 ? evt.lidPnMappings : undefined
|
|
@@ -573,30 +707,121 @@ const DISPATCHERS = {
|
|
|
573
707
|
ctx.ev.emit('contacts.upsert', evt.contacts);
|
|
574
708
|
}
|
|
575
709
|
};
|
|
710
|
+
const dispatchCanonicalEvent = (canonical, dispatchCtx) => {
|
|
711
|
+
// Type-safe table lookup. The runtime cast through `DispatcherFn` is a
|
|
712
|
+
// no-op TS-wise (the table is exhaustively typed) — needed only because TS
|
|
713
|
+
// cannot follow the discriminator across an indexed mapped type.
|
|
714
|
+
const dispatcher = DISPATCHERS[canonical.type];
|
|
715
|
+
try {
|
|
716
|
+
dispatcher(canonical, dispatchCtx);
|
|
717
|
+
}
|
|
718
|
+
catch (err) {
|
|
719
|
+
// One bad event must not poison the rest of the pipeline.
|
|
720
|
+
dispatchCtx.ctx.logger.error({ err, type: canonical.type }, 'dispatcher threw — dropping event');
|
|
721
|
+
}
|
|
722
|
+
};
|
|
723
|
+
/** Aggregate adjacent ordinary messages while preserving every side-effecting
|
|
724
|
+
* event boundary. Both bridge object events and protobuf-wire batches enter
|
|
725
|
+
* through this single state machine. */
|
|
726
|
+
const dispatchCanonicalBatch = (ctx, dispatchCtx, count, canonicalAt) => {
|
|
727
|
+
let pending;
|
|
728
|
+
for (let index = 0; index < count; index++) {
|
|
729
|
+
const canonical = canonicalAt(index);
|
|
730
|
+
if (!canonical)
|
|
731
|
+
continue;
|
|
732
|
+
// Only ordinary messages can share one messages.upsert emission.
|
|
733
|
+
// Flush before every other event or a message with secondary
|
|
734
|
+
// channels (reaction, revoke, edit, member-label) to preserve the
|
|
735
|
+
// exact observable order of those side effects.
|
|
736
|
+
if (canonical.type !== CANONICAL_MESSAGE_EVENT || hasMessageSideEffects(canonical)) {
|
|
737
|
+
if (pending) {
|
|
738
|
+
emitMessageUpsert(ctx, pending.messages, pending);
|
|
739
|
+
pending = undefined;
|
|
740
|
+
}
|
|
741
|
+
dispatchCanonicalEvent(canonical, dispatchCtx);
|
|
742
|
+
continue;
|
|
743
|
+
}
|
|
744
|
+
if (ctx.fullConfig.shouldIgnoreJid?.(canonical.chatJid))
|
|
745
|
+
continue;
|
|
746
|
+
try {
|
|
747
|
+
const metadata = messageUpsertMetadata(canonical);
|
|
748
|
+
const message = canonicalMessageToWAMessage(canonical);
|
|
749
|
+
if (pending && hasSameUpsertMetadata(pending, metadata)) {
|
|
750
|
+
pending.messages.push(message);
|
|
751
|
+
}
|
|
752
|
+
else {
|
|
753
|
+
if (pending)
|
|
754
|
+
emitMessageUpsert(ctx, pending.messages, pending);
|
|
755
|
+
pending = { ...metadata, messages: [message] };
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
catch (err) {
|
|
759
|
+
ctx.logger.error({ err, type: CANONICAL_MESSAGE_EVENT }, 'dispatcher threw — dropping event');
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
if (pending)
|
|
763
|
+
emitMessageUpsert(ctx, pending.messages, pending);
|
|
764
|
+
};
|
|
576
765
|
/**
|
|
577
|
-
* Create
|
|
578
|
-
*
|
|
579
|
-
*
|
|
580
|
-
* exclusively, so a downstream rename surfaces as a `tsc` failure.
|
|
766
|
+
* Create typed single and batch handlers for the bridge. The bridge only uses
|
|
767
|
+
* the batch capability when adjacent messages are already queued, while this
|
|
768
|
+
* layer owns all Baileys-specific translation and EventEmitter aggregation.
|
|
581
769
|
*/
|
|
582
|
-
export const
|
|
583
|
-
const dispatchCtx = {
|
|
584
|
-
|
|
770
|
+
export const makeEventHandlers = (ctx, callbacks) => {
|
|
771
|
+
const dispatchCtx = {
|
|
772
|
+
ctx,
|
|
773
|
+
callbacks,
|
|
774
|
+
historySync: { initialBootstrapComplete: false, recentSyncComplete: false }
|
|
775
|
+
};
|
|
776
|
+
const onEvent = (event) => {
|
|
585
777
|
const canonical = adaptBridgeEvent(event, ctx.logger);
|
|
586
|
-
if (
|
|
778
|
+
if (canonical)
|
|
779
|
+
dispatchCanonicalEvent(canonical, dispatchCtx);
|
|
780
|
+
};
|
|
781
|
+
const onMessageBatch = (batch) => {
|
|
782
|
+
if (batch.messageOffsets.length < MESSAGE_WIRE_OFFSET_SENTINEL_COUNT) {
|
|
783
|
+
ctx.logger.error('message wire batch is missing its leading offset');
|
|
587
784
|
return;
|
|
588
|
-
// Type-safe table lookup. The runtime cast through `DispatcherFn`
|
|
589
|
-
// is a no-op TS-wise (the table is exhaustively typed) — needed
|
|
590
|
-
// only because TS can't follow the discriminator across the
|
|
591
|
-
// indexed-access into the mapped type.
|
|
592
|
-
const dispatcher = DISPATCHERS[canonical.type];
|
|
593
|
-
try {
|
|
594
|
-
dispatcher(canonical, dispatchCtx);
|
|
595
785
|
}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
ctx.logger.error({
|
|
786
|
+
const messageCount = batch.messageOffsets.length - MESSAGE_WIRE_OFFSET_SENTINEL_COUNT;
|
|
787
|
+
if (batch.infos.length !== messageCount) {
|
|
788
|
+
ctx.logger.error({ infoCount: batch.infos.length, messageCount }, 'message wire batch metadata count does not match its payload count');
|
|
789
|
+
return;
|
|
599
790
|
}
|
|
791
|
+
// Decode through the runtime facade so each payload materializes as a
|
|
792
|
+
// hydrated runtime instance: `WebMessageInfo.fromObject` then keeps the
|
|
793
|
+
// message subtree via its instanceof short-circuit instead of walking
|
|
794
|
+
// and reallocating the whole tree — the dominant per-message allocation
|
|
795
|
+
// cost on the hot path. Lenient like the history-sync decoder: one
|
|
796
|
+
// malformed payload is skipped, not fatal to the batch.
|
|
797
|
+
const messages = new Array(messageCount);
|
|
798
|
+
const reader = new BinaryReader(batch.messageData);
|
|
799
|
+
for (let index = 0; index < messageCount; index++) {
|
|
800
|
+
try {
|
|
801
|
+
const start = batch.messageOffsets[index];
|
|
802
|
+
const end = batch.messageOffsets[index + 1];
|
|
803
|
+
reader.pos = start;
|
|
804
|
+
messages[index] = WAProto.Message.decode(reader, end - start);
|
|
805
|
+
}
|
|
806
|
+
catch (err) {
|
|
807
|
+
messages[index] = null;
|
|
808
|
+
ctx.logger.warn({ err, index }, 'skipping malformed wire message');
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
dispatchCanonicalBatch(ctx, dispatchCtx, messageCount, index => adaptBridgeMessageWire(messages[index], batch.infos[index], ctx.logger));
|
|
812
|
+
};
|
|
813
|
+
const onHistorySyncBatch = (batch) => {
|
|
814
|
+
const decoded = decodeHistorySyncWireBatch(batch, ctx.logger);
|
|
815
|
+
onEvent(decoded.event);
|
|
816
|
+
return decoded.skippedConversations;
|
|
817
|
+
};
|
|
818
|
+
return {
|
|
819
|
+
onEvent,
|
|
820
|
+
onMessageBatch,
|
|
821
|
+
onHistorySyncBatch,
|
|
822
|
+
historySyncConversationTypes: CONVERSATION_HISTORY_SYNC_TYPES
|
|
600
823
|
};
|
|
601
824
|
};
|
|
825
|
+
/** Legacy single-event helper retained for direct consumers and tests. */
|
|
826
|
+
export const makeEventHandler = (ctx, callbacks) => makeEventHandlers(ctx, callbacks).onEvent;
|
|
602
827
|
//# sourceMappingURL=events.js.map
|