@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/index.js
CHANGED
|
@@ -1,26 +1,39 @@
|
|
|
1
1
|
import { Buffer } from 'node:buffer';
|
|
2
2
|
import { randomBytes } from 'node:crypto';
|
|
3
|
-
import { EventEmitter } from 'node:events';
|
|
4
3
|
import { createWhatsAppClient, encodeProto, initWasmEngine } from 'whatsapp-rust-bridge';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
4
|
+
import { normalizeSocketAuthenticationState } from '../Compatibility/internal/auth-state.js';
|
|
5
|
+
import { makeMutex } from '../Compatibility/internal/make-mutex.js';
|
|
6
|
+
import { isNativeMemoryStore } from '../Compatibility/internal/native-memory-store.js';
|
|
7
|
+
import { makeLazyTransactionKeyStore } from '../Compatibility/internal/signal-key-store.js';
|
|
8
|
+
import { toBridgeMediaType } from '../Compatibility/media-type.js';
|
|
9
|
+
import { bindSignalRepositoryContext, makeDefaultSignalRepository } from '../Compatibility/signal-repository.js';
|
|
10
|
+
import { bridgeBusinessProfileToBaileys } from '../Compatibility/socket-results.js';
|
|
11
|
+
import { makeStanzaResponseMethods } from '../Compatibility/stanza-responses.js';
|
|
12
|
+
import { makeParticipatingRefreshHandler } from '../Compatibility/participating-refresh.js';
|
|
13
|
+
import { makeTaggedMessageWaiter } from '../Compatibility/tagged-message-waiter.js';
|
|
14
|
+
import { isRawNodeForwardingEnabled, WebSocketClient } from '../Compatibility/websocket-client.js';
|
|
15
|
+
import { DEFAULT_CONNECTION_CONFIG } from '../Defaults/index.js';
|
|
16
|
+
import { DisconnectReason } from '../Types/index.js';
|
|
17
|
+
import { Boom } from '../Utils/boom.js';
|
|
18
|
+
import { makeEventBuffer } from '../Utils/event-buffer.js';
|
|
19
|
+
import { _registerActiveBridgeClient, downloadMediaMessage } from '../Utils/messages.js';
|
|
20
|
+
import { makeNativeCryptoProvider } from '../Utils/native-crypto-provider.js';
|
|
21
|
+
import { wrapLegacyStore } from '../Utils/wrap-legacy-store.js';
|
|
22
|
+
import { assertNodeErrorFree } from '../WABinary/generic-utils.js';
|
|
23
|
+
import { makeBlockingMethods } from './blocking.js';
|
|
24
|
+
import { makeChatActionMethods } from './chat-actions.js';
|
|
25
|
+
import { makeContactMethods } from './contacts.js';
|
|
26
|
+
import { makeCommunityMethods } from './communities.js';
|
|
27
|
+
import { makeEventHandlers } from './events.js';
|
|
28
|
+
import { makeGroupMethods } from './groups.js';
|
|
29
|
+
import { makeMessageMethods } from './messages.js';
|
|
30
|
+
import { makeNewsletterMethods } from './newsletter.js';
|
|
31
|
+
import { makePreKeyMethods } from './prekeys.js';
|
|
32
|
+
import { makePresenceMethods } from './presence.js';
|
|
33
|
+
import { makeProfileMethods } from './profile.js';
|
|
34
|
+
import { mapReachoutTimelock } from './reachout.js';
|
|
35
|
+
import { makeHttpClient, makeTransport } from './transport.js';
|
|
36
|
+
import { makeUSyncMethods } from './usync.js';
|
|
24
37
|
let wasmInitialized = false;
|
|
25
38
|
/**
|
|
26
39
|
* Default mapping for the legacy `browser[1]` slot — preserved so users on the
|
|
@@ -48,207 +61,21 @@ const browserToPlatformType = (browser) => {
|
|
|
48
61
|
return 'CHROME';
|
|
49
62
|
}
|
|
50
63
|
};
|
|
51
|
-
/**
|
|
52
|
-
* Returns a no-op `SignalKeyStore`-shaped facade. baileyrs hands this out from
|
|
53
|
-
* `sock.authState.keys` when no legacy `auth.keys` was provided so that
|
|
54
|
-
* upstream-Baileys code paths (typically post-error cleanup like
|
|
55
|
-
* `keys.set({ 'sender-key': { [groupId]: null } })`) don't crash on a missing
|
|
56
|
-
* `.set` method. The Rust bridge owns the real Signal state — this facade is
|
|
57
|
-
* deliberately inert; reads come back empty and writes are dropped after a
|
|
58
|
-
* `debug` log so the call site stays traceable.
|
|
59
|
-
*/
|
|
60
|
-
function noopKeyStore(logger) {
|
|
61
|
-
return {
|
|
62
|
-
get: async () => ({}),
|
|
63
|
-
set: async (data) => {
|
|
64
|
-
const types = Object.keys(data).filter(k => data[k]);
|
|
65
|
-
if (types.length) {
|
|
66
|
-
logger.debug({ types }, 'authState.keys.set called — bridge owns Signal state, dropping no-op');
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
clear: async () => {
|
|
70
|
-
logger.debug('authState.keys.clear called — no-op (bridge state is not cleared from JS)');
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
/** Build the signalRepository object that delegates to the bridge */
|
|
75
|
-
function makeSignalRepository(ctx) {
|
|
76
|
-
return {
|
|
77
|
-
decryptMessage: async (opts) => {
|
|
78
|
-
return (await ctx.getClient()).signalDecryptMessage(opts.jid, opts.type, opts.ciphertext);
|
|
79
|
-
},
|
|
80
|
-
encryptMessage: async (opts) => {
|
|
81
|
-
return (await ctx.getClient()).signalEncryptMessage(opts.jid, opts.data);
|
|
82
|
-
},
|
|
83
|
-
decryptGroupMessage: async (opts) => {
|
|
84
|
-
return (await ctx.getClient()).signalDecryptGroupMessage(opts.group, opts.authorJid, opts.msg);
|
|
85
|
-
},
|
|
86
|
-
encryptGroupMessage: async (opts) => {
|
|
87
|
-
return (await ctx.getClient()).signalEncryptGroupMessage(opts.group, opts.data, opts.meId);
|
|
88
|
-
},
|
|
89
|
-
processSenderKeyDistributionMessage: async () => { },
|
|
90
|
-
injectE2ESession: async () => { },
|
|
91
|
-
validateSession: async (jid) => {
|
|
92
|
-
const exists = await (await ctx.getClient()).signalValidateSession(jid);
|
|
93
|
-
return { exists };
|
|
94
|
-
},
|
|
95
|
-
jidToSignalProtocolAddress: (jid) => {
|
|
96
|
-
try {
|
|
97
|
-
return ctx.getClientSync().jidToSignalProtocolAddress(jid);
|
|
98
|
-
}
|
|
99
|
-
catch {
|
|
100
|
-
return `${jid}.0`;
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
migrateSession: async () => {
|
|
104
|
-
return { migrated: 0, skipped: 0, total: 0 };
|
|
105
|
-
},
|
|
106
|
-
deleteSession: async (jids) => {
|
|
107
|
-
return (await ctx.getClient()).signalDeleteSessions(jids);
|
|
108
|
-
},
|
|
109
|
-
/**
|
|
110
|
-
* Bidirectional LID ↔ PN lookup. Mirrors the upstream Baileys
|
|
111
|
-
* `signalRepository.lidMapping` API.
|
|
112
|
-
*
|
|
113
|
-
* Pure passthrough to the bridge — `client.lidForPn` / `client.pnForLid`
|
|
114
|
-
* delegate to the core's `get_lid_pn_entry`, which is cache-aside as
|
|
115
|
-
* of whatsapp-rust PR #565: hits the in-memory `lid_pn_cache` first
|
|
116
|
-
* and falls through to `backend.get_pn_mapping` / `get_lid_mapping`
|
|
117
|
-
* (so JsStoreCallbacks-backed sessions resolve every persisted
|
|
118
|
-
* mapping without warm-up needing a list primitive).
|
|
119
|
-
*/
|
|
120
|
-
lidMapping: {
|
|
121
|
-
getLIDForPN: async (pn) => {
|
|
122
|
-
const client = await ctx.getClient();
|
|
123
|
-
return (await client.lidForPn(pn)) ?? null;
|
|
124
|
-
},
|
|
125
|
-
getPNForLID: async (lid) => {
|
|
126
|
-
const client = await ctx.getClient();
|
|
127
|
-
return (await client.pnForLid(lid)) ?? null;
|
|
128
|
-
},
|
|
129
|
-
/**
|
|
130
|
-
* Batch variant of `getLIDForPN`. Upstream Baileys' equivalent
|
|
131
|
-
* coalesces in-flight requests and de-duplicates inputs; we run
|
|
132
|
-
* the lookups in parallel and return the same `LIDMapping[]`
|
|
133
|
-
* shape so callers (e.g. `process-message.ts`) keep working.
|
|
134
|
-
*
|
|
135
|
-
* Uses `Promise.allSettled` so one bridge-side failure (e.g.
|
|
136
|
-
* malformed JID, transient cache miss) doesn't reject the
|
|
137
|
-
* whole batch and lose every successful lookup. Failures are
|
|
138
|
-
* logged at debug and skipped.
|
|
139
|
-
*
|
|
140
|
-
* Returns `null` (not `[]`) when the input list is empty, to
|
|
141
|
-
* mirror upstream's "absent" sentinel.
|
|
142
|
-
*/
|
|
143
|
-
getLIDsForPNs: async (pns) => {
|
|
144
|
-
if (pns.length === 0)
|
|
145
|
-
return null;
|
|
146
|
-
const client = await ctx.getClient();
|
|
147
|
-
const unique = [...new Set(pns)];
|
|
148
|
-
const settled = await Promise.allSettled(unique.map(async (pn) => {
|
|
149
|
-
const lid = (await client.lidForPn(pn)) ?? null;
|
|
150
|
-
return lid ? { pn, lid } : null;
|
|
151
|
-
}));
|
|
152
|
-
const resolved = [];
|
|
153
|
-
for (const r of settled) {
|
|
154
|
-
if (r.status === 'fulfilled') {
|
|
155
|
-
if (r.value)
|
|
156
|
-
resolved.push(r.value);
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
ctx.logger.debug({ err: r.reason }, 'getLIDsForPNs: lookup rejected — skipping');
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return resolved;
|
|
163
|
-
},
|
|
164
|
-
getPNsForLIDs: async (lids) => {
|
|
165
|
-
if (lids.length === 0)
|
|
166
|
-
return null;
|
|
167
|
-
const client = await ctx.getClient();
|
|
168
|
-
const unique = [...new Set(lids)];
|
|
169
|
-
const settled = await Promise.allSettled(unique.map(async (lid) => {
|
|
170
|
-
const pn = (await client.pnForLid(lid)) ?? null;
|
|
171
|
-
return pn ? { pn, lid } : null;
|
|
172
|
-
}));
|
|
173
|
-
const resolved = [];
|
|
174
|
-
for (const r of settled) {
|
|
175
|
-
if (r.status === 'fulfilled') {
|
|
176
|
-
if (r.value)
|
|
177
|
-
resolved.push(r.value);
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
ctx.logger.debug({ err: r.reason }, 'getPNsForLIDs: lookup rejected — skipping');
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return resolved;
|
|
184
|
-
},
|
|
185
|
-
/**
|
|
186
|
-
* No-op shim. The Rust bridge auto-learns LID↔PN mappings inside
|
|
187
|
-
* `decode_message` / `usync` and persists them through
|
|
188
|
-
* `JsStoreCallbacks` — upstream Baileys callers (notably
|
|
189
|
-
* `process-message.ts` re-feeding mappings from `historySync`)
|
|
190
|
-
* keep type-checking, but we don't need to write back.
|
|
191
|
-
*
|
|
192
|
-
* Logs at debug so unexpected paths stay traceable.
|
|
193
|
-
*/
|
|
194
|
-
storeLIDPNMappings: async (pairs) => {
|
|
195
|
-
if (pairs.length === 0)
|
|
196
|
-
return;
|
|
197
|
-
ctx.logger.debug({ count: pairs.length }, 'lidMapping.storeLIDPNMappings — bridge auto-learns, no-op');
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
64
|
/** Build the ws EventEmitter with auto-enable raw node forwarding */
|
|
203
|
-
function makeWsEmitter(getClient) {
|
|
204
|
-
const ws = new EventEmitter();
|
|
205
|
-
let rawNodeEnabled = false;
|
|
206
|
-
const originalOn = ws.on.bind(ws);
|
|
207
|
-
ws.on = (event, listener) => {
|
|
208
|
-
if (typeof event === 'string' && event.startsWith('CB:') && !rawNodeEnabled) {
|
|
209
|
-
rawNodeEnabled = true;
|
|
210
|
-
try {
|
|
211
|
-
getClient()?.setRawNodeForwarding(true);
|
|
212
|
-
}
|
|
213
|
-
catch {
|
|
214
|
-
// bridge not ready yet — will enable when it initializes
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
return originalOn(event, listener);
|
|
218
|
-
};
|
|
219
|
-
Object.defineProperty(ws, 'isOpen', {
|
|
220
|
-
get: () => getClient()?.isConnected() ?? false,
|
|
221
|
-
enumerable: true
|
|
222
|
-
});
|
|
223
|
-
// Upstream Baileys exposes `sock.ws.socket.readyState` (the underlying
|
|
224
|
-
// WebSocket's standard property) and a lot of bots — keep-alive timers,
|
|
225
|
-
// reconnect heuristics, "is the link up?" checks — read it directly.
|
|
226
|
-
// baileyrs has no JS-side WebSocket (the noise socket lives inside the
|
|
227
|
-
// Rust core), but the only thing those callers care about is the same
|
|
228
|
-
// two-value answer the standard WebSocket constants encode:
|
|
229
|
-
// 1 = OPEN, 3 = CLOSED — same numeric values WHATWG defines.
|
|
230
|
-
// Anything other than 1 means "not usable", so collapsing the
|
|
231
|
-
// CONNECTING/CLOSING transitional states to CLOSED preserves the
|
|
232
|
-
// branching every realistic caller does (`readyState === 1`).
|
|
233
|
-
const socketShim = {};
|
|
234
|
-
Object.defineProperty(socketShim, 'readyState', {
|
|
235
|
-
get: () => (getClient()?.isConnected() ? 1 : 3),
|
|
236
|
-
enumerable: true
|
|
237
|
-
});
|
|
238
|
-
Object.defineProperty(ws, 'socket', {
|
|
239
|
-
value: socketShim,
|
|
240
|
-
enumerable: true,
|
|
241
|
-
configurable: true
|
|
242
|
-
});
|
|
243
|
-
return { ws, isRawNodeEnabled: () => rawNodeEnabled };
|
|
244
|
-
}
|
|
245
65
|
const makeWASocket = (config) => {
|
|
246
66
|
const fullConfig = { ...DEFAULT_CONNECTION_CONFIG, ...config };
|
|
247
|
-
const {
|
|
248
|
-
const
|
|
67
|
+
const { logger } = fullConfig;
|
|
68
|
+
const auth = normalizeSocketAuthenticationState(fullConfig.auth);
|
|
69
|
+
const getExposedKeys = makeLazyTransactionKeyStore(auth.keys, logger, fullConfig.transactionOpts);
|
|
70
|
+
const ev = makeEventBuffer(logger);
|
|
71
|
+
// Upstream mutates authState.creds before notifying user listeners. Register
|
|
72
|
+
// this first so `ev.on('creds.update', saveCreds)` persists the merged state
|
|
73
|
+
// rather than the pre-pair placeholder.
|
|
74
|
+
ev.on('creds.update', update => Object.assign(auth.creds, update));
|
|
249
75
|
let client;
|
|
76
|
+
let readyClient;
|
|
250
77
|
let user;
|
|
251
|
-
const
|
|
78
|
+
const ws = new WebSocketClient(fullConfig.waWebSocketUrl, fullConfig, () => client);
|
|
252
79
|
let tagEpoch = 0;
|
|
253
80
|
// Per-socket random prefix avoids collisions between sockets created
|
|
254
81
|
// in the same millisecond. Date.now()-based prefixes (the previous
|
|
@@ -270,17 +97,27 @@ const makeWASocket = (config) => {
|
|
|
270
97
|
fullConfig,
|
|
271
98
|
ws,
|
|
272
99
|
getUser: () => user,
|
|
100
|
+
getMe: () => {
|
|
101
|
+
const me = auth.creds.me;
|
|
102
|
+
const id = user?.id ?? me?.id;
|
|
103
|
+
if (!id)
|
|
104
|
+
return undefined;
|
|
105
|
+
return { ...me, id, ...(user?.lid ? { lid: user.lid } : {}) };
|
|
106
|
+
},
|
|
273
107
|
setUser: u => {
|
|
274
108
|
user = u;
|
|
275
109
|
},
|
|
276
|
-
getClient:
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
110
|
+
getClient: () => {
|
|
111
|
+
if (readyClient)
|
|
112
|
+
return readyClient;
|
|
113
|
+
return initPromise.then(() => {
|
|
114
|
+
if (initError) {
|
|
115
|
+
throw new Boom('Bridge client failed to initialize: ' + initError.message, { statusCode: 500 });
|
|
116
|
+
}
|
|
117
|
+
if (!client)
|
|
118
|
+
throw new Boom('Client not initialized', { statusCode: 500 });
|
|
119
|
+
return client;
|
|
120
|
+
});
|
|
284
121
|
},
|
|
285
122
|
getClientSync: () => {
|
|
286
123
|
if (!client)
|
|
@@ -288,7 +125,28 @@ const makeWASocket = (config) => {
|
|
|
288
125
|
return client;
|
|
289
126
|
}
|
|
290
127
|
};
|
|
291
|
-
|
|
128
|
+
// The native repository delegates Signal state directly to the core and does
|
|
129
|
+
// not need the standalone transaction facade. Keep that facade lazy for the
|
|
130
|
+
// public authState and custom repository contracts that can observe it.
|
|
131
|
+
const signalAuthState = {
|
|
132
|
+
creds: auth.creds,
|
|
133
|
+
keys: fullConfig.makeSignalRepository === makeDefaultSignalRepository ? auth.keys : getExposedKeys()
|
|
134
|
+
};
|
|
135
|
+
bindSignalRepositoryContext(signalAuthState, ctx);
|
|
136
|
+
const signalRepository = fullConfig.makeSignalRepository(signalAuthState, logger);
|
|
137
|
+
const devicesMutex = makeMutex();
|
|
138
|
+
const messageMutex = makeMutex();
|
|
139
|
+
const receiptMutex = makeMutex();
|
|
140
|
+
const appStatePatchMutex = makeMutex();
|
|
141
|
+
const notificationMutex = makeMutex();
|
|
142
|
+
const activeCallContexts = new Map();
|
|
143
|
+
const groupMethods = makeGroupMethods(ctx);
|
|
144
|
+
const communityMethods = makeCommunityMethods(ctx, groupMethods);
|
|
145
|
+
const refreshParticipating = makeParticipatingRefreshHandler(ctx, {
|
|
146
|
+
groupFetchAllParticipating: groupMethods.groupFetchAllParticipating,
|
|
147
|
+
communityFetchAllParticipating: communityMethods.communityFetchAllParticipating
|
|
148
|
+
});
|
|
149
|
+
const eventHandlers = makeEventHandlers(ctx, {
|
|
292
150
|
onPairSuccess: data => {
|
|
293
151
|
pairedAccount = data;
|
|
294
152
|
client
|
|
@@ -297,7 +155,17 @@ const makeWASocket = (config) => {
|
|
|
297
155
|
cachedAccount = acc ?? undefined;
|
|
298
156
|
})
|
|
299
157
|
.catch(() => { });
|
|
300
|
-
}
|
|
158
|
+
},
|
|
159
|
+
onIncomingCall: event => {
|
|
160
|
+
const { callId, callCreator, type } = event.action;
|
|
161
|
+
if (type === 'reject' || type === 'accept' || type === 'timeout' || type === 'terminate') {
|
|
162
|
+
activeCallContexts.delete(callId);
|
|
163
|
+
}
|
|
164
|
+
else if (callCreator) {
|
|
165
|
+
activeCallContexts.set(callId, { peer: event.from, callCreator });
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
onDirtyState: event => refreshParticipating(event.dirtyType)
|
|
301
169
|
});
|
|
302
170
|
const init = async () => {
|
|
303
171
|
if (!wasmInitialized) {
|
|
@@ -315,15 +183,20 @@ const makeWASocket = (config) => {
|
|
|
315
183
|
// got to enter, then crash when the next state ('open' / 'close')
|
|
316
184
|
// references prerequisites that the missed event was supposed to set
|
|
317
185
|
// up.
|
|
318
|
-
queueMicrotask(() => ev.emit('connection.update', {
|
|
186
|
+
queueMicrotask(() => ev.emit('connection.update', {
|
|
187
|
+
connection: 'connecting',
|
|
188
|
+
receivedPendingNotifications: false,
|
|
189
|
+
qr: undefined
|
|
190
|
+
}));
|
|
319
191
|
// Auto-promote upstream-Baileys-style `auth: { creds, keys }` to a
|
|
320
192
|
// `JsStoreCallbacks`-shaped store via `wrapLegacyStore`. The synthetic
|
|
321
193
|
// `saveCreds` callback re-emits `creds.update` so the bot's existing
|
|
322
194
|
// `ev.on('creds.update', saveCreds)` listener handles persistence —
|
|
323
195
|
// matches the lifecycle hook every upstream-Baileys setup already
|
|
324
196
|
// wires, so migration needs zero changes to the auth block.
|
|
325
|
-
|
|
326
|
-
|
|
197
|
+
const useNativeMemory = auth.store ? isNativeMemoryStore(auth.store) : false;
|
|
198
|
+
let bridgeStore = useNativeMemory ? null : (auth.store ?? null);
|
|
199
|
+
if (!bridgeStore && !useNativeMemory && auth.creds && auth.keys) {
|
|
327
200
|
const legacyState = { creds: auth.creds, keys: auth.keys };
|
|
328
201
|
const wrapped = await wrapLegacyStore(legacyState, async () => {
|
|
329
202
|
ev.emit('creds.update', auth.creds);
|
|
@@ -336,7 +209,12 @@ const makeWASocket = (config) => {
|
|
|
336
209
|
autoWrappedStore = wrapped;
|
|
337
210
|
logger.debug('auth: auto-wrapped legacy {creds, keys} via wrapLegacyStore');
|
|
338
211
|
}
|
|
339
|
-
|
|
212
|
+
if (useNativeMemory)
|
|
213
|
+
logger.debug('auth: using socket-local native memory backend');
|
|
214
|
+
client = await createWhatsAppClient(makeTransport(fullConfig), makeHttpClient(fullConfig), eventHandlers, bridgeStore, fullConfig.cache ?? null, fullConfig.version, fullConfig.wantedPreKeyCount ?? null);
|
|
215
|
+
if (fullConfig.pushName) {
|
|
216
|
+
await client.setInitialPushName(fullConfig.pushName);
|
|
217
|
+
}
|
|
340
218
|
// Make this client the fallback for standalone helpers like
|
|
341
219
|
// downloadContentFromMessage that have no socket reference.
|
|
342
220
|
_registerActiveBridgeClient(client, logger);
|
|
@@ -364,7 +242,7 @@ const makeWASocket = (config) => {
|
|
|
364
242
|
if (browserName === 'Android') {
|
|
365
243
|
await client.setClientProfile({ preset: 'android', osVersion: osName });
|
|
366
244
|
}
|
|
367
|
-
if (
|
|
245
|
+
if (isRawNodeForwardingEnabled(ws)) {
|
|
368
246
|
client.setRawNodeForwarding(true);
|
|
369
247
|
}
|
|
370
248
|
// `run()` is fire-and-forget by design (the bridge runs the read
|
|
@@ -393,20 +271,35 @@ const makeWASocket = (config) => {
|
|
|
393
271
|
}
|
|
394
272
|
};
|
|
395
273
|
let initError;
|
|
396
|
-
const initPromise = init()
|
|
274
|
+
const initPromise = init()
|
|
275
|
+
.then(() => {
|
|
276
|
+
if (client)
|
|
277
|
+
readyClient = Promise.resolve(client);
|
|
278
|
+
})
|
|
279
|
+
.catch(err => {
|
|
397
280
|
initError = err instanceof Error ? err : new Error(String(err));
|
|
398
281
|
logger.error({ err }, 'failed to initialize bridge client');
|
|
399
282
|
});
|
|
400
|
-
|
|
283
|
+
let ended = false;
|
|
284
|
+
const socketEndHandlers = [
|
|
285
|
+
() => activeCallContexts.clear()
|
|
286
|
+
];
|
|
287
|
+
const end = async (error) => {
|
|
288
|
+
if (ended) {
|
|
289
|
+
logger.trace({ trace: error?.stack }, 'connection already closed');
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
ended = true;
|
|
401
293
|
const c = client;
|
|
402
|
-
client = undefined;
|
|
403
294
|
if (c) {
|
|
404
295
|
try {
|
|
405
|
-
await
|
|
296
|
+
await ws.close();
|
|
406
297
|
}
|
|
407
298
|
catch {
|
|
408
299
|
/* ignore */
|
|
409
300
|
}
|
|
301
|
+
client = undefined;
|
|
302
|
+
readyClient = undefined;
|
|
410
303
|
// Barrier: bridge cleanup paths fired during `disconnect()` may
|
|
411
304
|
// emit `set()` calls that are still queued as microtasks /
|
|
412
305
|
// `setImmediate` callbacks at this point. Two yields to the
|
|
@@ -442,6 +335,14 @@ const makeWASocket = (config) => {
|
|
|
442
335
|
if (firstFlushError)
|
|
443
336
|
throw firstFlushError;
|
|
444
337
|
}
|
|
338
|
+
for (const handler of socketEndHandlers) {
|
|
339
|
+
try {
|
|
340
|
+
await handler(error);
|
|
341
|
+
}
|
|
342
|
+
catch (handlerError) {
|
|
343
|
+
logger.error({ err: handlerError }, 'error in socket end handler');
|
|
344
|
+
}
|
|
345
|
+
}
|
|
445
346
|
};
|
|
446
347
|
const logout = async (msg) => {
|
|
447
348
|
user = undefined;
|
|
@@ -453,30 +354,49 @@ const makeWASocket = (config) => {
|
|
|
453
354
|
/* ignore */
|
|
454
355
|
}
|
|
455
356
|
}
|
|
357
|
+
const logoutError = new Boom(msg || 'Logged out', { statusCode: DisconnectReason.loggedOut });
|
|
456
358
|
ev.emit('connection.update', {
|
|
457
359
|
connection: 'close',
|
|
458
360
|
lastDisconnect: {
|
|
459
|
-
error:
|
|
361
|
+
error: logoutError,
|
|
460
362
|
date: new Date()
|
|
461
363
|
}
|
|
462
364
|
});
|
|
463
|
-
await end();
|
|
365
|
+
await end(logoutError);
|
|
366
|
+
};
|
|
367
|
+
const registerSocketEndHandler = (handler) => {
|
|
368
|
+
socketEndHandlers.push(handler);
|
|
464
369
|
};
|
|
465
370
|
const waitForConnectionUpdate = (check, timeoutMs) => {
|
|
466
371
|
return new Promise((resolve, reject) => {
|
|
467
372
|
let timeout;
|
|
468
|
-
const
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
373
|
+
const cleanup = () => {
|
|
374
|
+
ev.off('connection.update', listener);
|
|
375
|
+
if (timeout)
|
|
376
|
+
clearTimeout(timeout);
|
|
377
|
+
};
|
|
378
|
+
const listener = async (update) => {
|
|
379
|
+
if (update.connection === 'close') {
|
|
380
|
+
cleanup();
|
|
381
|
+
reject(update.lastDisconnect?.error ??
|
|
382
|
+
new Boom('Connection Closed', { statusCode: DisconnectReason.connectionClosed }));
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
try {
|
|
386
|
+
if (!(await check(update)))
|
|
387
|
+
return;
|
|
388
|
+
cleanup();
|
|
473
389
|
resolve();
|
|
474
390
|
}
|
|
391
|
+
catch (error) {
|
|
392
|
+
cleanup();
|
|
393
|
+
reject(error);
|
|
394
|
+
}
|
|
475
395
|
};
|
|
476
396
|
ev.on('connection.update', listener);
|
|
477
397
|
if (timeoutMs) {
|
|
478
398
|
timeout = setTimeout(() => {
|
|
479
|
-
|
|
399
|
+
cleanup();
|
|
480
400
|
reject(new Boom('Timed out waiting for connection update', { statusCode: 408 }));
|
|
481
401
|
}, timeoutMs);
|
|
482
402
|
// Don't keep the process alive if the caller has already stopped
|
|
@@ -485,6 +405,24 @@ const makeWASocket = (config) => {
|
|
|
485
405
|
}
|
|
486
406
|
});
|
|
487
407
|
};
|
|
408
|
+
const fetchReachoutTimelock = async () => {
|
|
409
|
+
const payload = await (await ctx.getClient()).fetchReachoutTimelock();
|
|
410
|
+
const state = mapReachoutTimelock(payload) ?? { isActive: false };
|
|
411
|
+
ev.emit('connection.update', { reachoutTimeLock: state });
|
|
412
|
+
return state;
|
|
413
|
+
};
|
|
414
|
+
const query = async (node, timeoutMs) => {
|
|
415
|
+
if (!node.attrs.id)
|
|
416
|
+
node.attrs.id = generateMessageTag();
|
|
417
|
+
const result = (await (await ctx.getClient()).queryNode(node, timeoutMs));
|
|
418
|
+
assertNodeErrorFree(result);
|
|
419
|
+
return result;
|
|
420
|
+
};
|
|
421
|
+
const waitForMessage = makeTaggedMessageWaiter(ws, logger, fullConfig.defaultQueryTimeoutMs);
|
|
422
|
+
const usyncMethods = makeUSyncMethods({
|
|
423
|
+
queryNode: query,
|
|
424
|
+
queryUsync: async (typedQuery) => (await ctx.getClient()).queryUsync(typedQuery)
|
|
425
|
+
});
|
|
488
426
|
const sock = {
|
|
489
427
|
ev,
|
|
490
428
|
logger,
|
|
@@ -520,22 +458,18 @@ const makeWASocket = (config) => {
|
|
|
520
458
|
return {
|
|
521
459
|
creds: {
|
|
522
460
|
...auth.creds,
|
|
523
|
-
|
|
524
|
-
account: cachedAccount,
|
|
525
|
-
platform: pairedAccount
|
|
461
|
+
...(user ? { me: { ...auth.creds.me, id: user.id, lid: user.lid } } : {}),
|
|
462
|
+
...(cachedAccount ? { account: cachedAccount } : {}),
|
|
463
|
+
...(pairedAccount?.platform ? { platform: pairedAccount.platform } : {})
|
|
526
464
|
},
|
|
527
|
-
|
|
528
|
-
// at the legacy SignalKeyStore (e.g. clearing sender-keys after a
|
|
529
|
-
// decrypt error: `keys.set({ 'sender-key': { [groupId]: null } })`).
|
|
530
|
-
// In baileyrs the bridge owns all Signal state, so writes here
|
|
531
|
-
// would silently no-op even if we delegated them — the real
|
|
532
|
-
// sender-key store is internal to Rust. We expose stable methods
|
|
533
|
-
// that don't crash, log at debug for traceability, and return
|
|
534
|
-
// empty results from `.get` so callers fall through to whatever
|
|
535
|
-
// regen path they already have.
|
|
536
|
-
keys: auth.keys ?? noopKeyStore(logger)
|
|
465
|
+
keys: getExposedKeys()
|
|
537
466
|
};
|
|
538
467
|
},
|
|
468
|
+
devicesMutex,
|
|
469
|
+
messageMutex,
|
|
470
|
+
receiptMutex,
|
|
471
|
+
appStatePatchMutex,
|
|
472
|
+
notificationMutex,
|
|
539
473
|
generateMessageTag,
|
|
540
474
|
sendNode: async (frame) => {
|
|
541
475
|
return (await ctx.getClient()).sendNode(frame);
|
|
@@ -546,67 +480,8 @@ const makeWASocket = (config) => {
|
|
|
546
480
|
getUSyncDevices: async (jids, useCache, ignoreZeroDevices) => {
|
|
547
481
|
return (await ctx.getClient()).getUSyncDevices(jids, useCache, ignoreZeroDevices);
|
|
548
482
|
},
|
|
549
|
-
waitForMessage
|
|
550
|
-
|
|
551
|
-
const timeout = timeoutMs ?? fullConfig.defaultQueryTimeoutMs;
|
|
552
|
-
let timer;
|
|
553
|
-
const tag = `TAG:${msgId}`;
|
|
554
|
-
// Use `on`+explicit `off` instead of `once`. Two callers
|
|
555
|
-
// awaiting the same id (rare but legal — can happen when an
|
|
556
|
-
// id is reused for retries, or when both an `<ack>` and an
|
|
557
|
-
// `<iq result>` carry the same id) would otherwise have the
|
|
558
|
-
// second listener silently consumed by the first emit.
|
|
559
|
-
const onRecv = (data) => {
|
|
560
|
-
if (timer)
|
|
561
|
-
clearTimeout(timer);
|
|
562
|
-
ws.off(tag, listener);
|
|
563
|
-
resolve(data);
|
|
564
|
-
};
|
|
565
|
-
const listener = onRecv;
|
|
566
|
-
ws.on(tag, listener);
|
|
567
|
-
if (timeout) {
|
|
568
|
-
timer = setTimeout(() => {
|
|
569
|
-
ws.off(tag, listener);
|
|
570
|
-
reject(new Boom('Timed out waiting for message', { statusCode: DisconnectReason.timedOut }));
|
|
571
|
-
}, timeout);
|
|
572
|
-
// Query timers shouldn't keep the process alive past sock.end()
|
|
573
|
-
// if the caller has given up — same pattern as use-bridge-store.
|
|
574
|
-
timer.unref();
|
|
575
|
-
}
|
|
576
|
-
});
|
|
577
|
-
},
|
|
578
|
-
query: async (node, timeoutMs) => {
|
|
579
|
-
if (!node.attrs.id) {
|
|
580
|
-
node.attrs.id = generateMessageTag();
|
|
581
|
-
}
|
|
582
|
-
const msgId = node.attrs.id;
|
|
583
|
-
const tag = `TAG:${msgId}`;
|
|
584
|
-
// Snapshot the listeners on this tag BEFORE attaching ours so a
|
|
585
|
-
// sendNode failure can remove only what we added — never another
|
|
586
|
-
// caller's listener. `removeAllListeners(tag)` was the prior
|
|
587
|
-
// behavior; it could nuke a parallel `waitForMessage` belonging
|
|
588
|
-
// to a different consumer.
|
|
589
|
-
const before = ws.listeners(tag);
|
|
590
|
-
const resultPromise = sock.waitForMessage(msgId, timeoutMs);
|
|
591
|
-
try {
|
|
592
|
-
await sock.sendNode(node);
|
|
593
|
-
}
|
|
594
|
-
catch (err) {
|
|
595
|
-
const ours = ws.listeners(tag).filter(l => !before.includes(l));
|
|
596
|
-
for (const l of ours)
|
|
597
|
-
ws.off(tag, l);
|
|
598
|
-
throw err;
|
|
599
|
-
}
|
|
600
|
-
const result = await resultPromise;
|
|
601
|
-
// Mirror upstream `Socket/socket.ts:217-220`: a stanza with an
|
|
602
|
-
// `<error>` child is a server-rejection. Throw a Boom carrying
|
|
603
|
-
// the error code so consumers branching on
|
|
604
|
-
// `lastDisconnect.error.statusCode` / `.data` can react. Without
|
|
605
|
-
// this, code expecting upstream semantics treats a 403 / 405
|
|
606
|
-
// error response as success and reads garbage attrs.
|
|
607
|
-
assertNodeErrorFree(result);
|
|
608
|
-
return result;
|
|
609
|
-
},
|
|
483
|
+
waitForMessage,
|
|
484
|
+
query,
|
|
610
485
|
sendRawMessage: async (data) => {
|
|
611
486
|
return (await ctx.getClient()).sendRawMessage(data instanceof Uint8Array ? data : new Uint8Array(data));
|
|
612
487
|
},
|
|
@@ -614,13 +489,11 @@ const makeWASocket = (config) => {
|
|
|
614
489
|
const bytes = encodeProto('Message', message);
|
|
615
490
|
return (await ctx.getClient()).createParticipantNodesBytes(jids, bytes, extraAttrs ?? {});
|
|
616
491
|
},
|
|
617
|
-
signalRepository
|
|
618
|
-
|
|
619
|
-
uploadPreKeys: async () => { },
|
|
620
|
-
/** @deprecated Pre-key management is handled by the Rust bridge. */
|
|
621
|
-
uploadPreKeysToServerIfRequired: async () => { },
|
|
492
|
+
signalRepository,
|
|
493
|
+
...makePreKeyMethods(ctx),
|
|
622
494
|
end,
|
|
623
495
|
logout,
|
|
496
|
+
registerSocketEndHandler,
|
|
624
497
|
waitForConnectionUpdate,
|
|
625
498
|
setAutoReconnect: (enabled) => {
|
|
626
499
|
client?.setAutoReconnect(enabled);
|
|
@@ -632,15 +505,15 @@ const makeWASocket = (config) => {
|
|
|
632
505
|
* caller hears about the protocol mistake instead of the bridge silently
|
|
633
506
|
* sending nothing.
|
|
634
507
|
*/
|
|
635
|
-
sendPresenceUpdate: async (
|
|
508
|
+
sendPresenceUpdate: async (type, toJid) => {
|
|
636
509
|
const c = await ctx.getClient();
|
|
637
|
-
if (
|
|
638
|
-
return c.sendPresence(
|
|
510
|
+
if (type === 'available' || type === 'unavailable') {
|
|
511
|
+
return c.sendPresence(type);
|
|
639
512
|
}
|
|
640
513
|
if (!toJid) {
|
|
641
|
-
throw new Boom(`sendPresenceUpdate('${
|
|
514
|
+
throw new Boom(`sendPresenceUpdate('${type}') requires a target jid`, { statusCode: 400 });
|
|
642
515
|
}
|
|
643
|
-
return c.sendChatState(toJid,
|
|
516
|
+
return c.sendChatState(toJid, type);
|
|
644
517
|
},
|
|
645
518
|
/**
|
|
646
519
|
* Plaintext media upload helper, source-compatible with the upstream
|
|
@@ -650,9 +523,10 @@ const makeWASocket = (config) => {
|
|
|
650
523
|
*/
|
|
651
524
|
waUploadToServer: async (data, opts) => {
|
|
652
525
|
const bytes = data instanceof Uint8Array && !Buffer.isBuffer(data) ? data : new Uint8Array(data);
|
|
653
|
-
return (await ctx.getClient()).uploadMedia(bytes, opts.mediaType);
|
|
526
|
+
return (await ctx.getClient()).uploadMedia(bytes, toBridgeMediaType(opts.mediaType));
|
|
654
527
|
},
|
|
655
|
-
fetchPrivacySettings: async () => {
|
|
528
|
+
fetchPrivacySettings: async (force) => {
|
|
529
|
+
void force;
|
|
656
530
|
return (await ctx.getClient()).fetchPrivacySettings();
|
|
657
531
|
},
|
|
658
532
|
updatePrivacySetting: async (category, value) => {
|
|
@@ -680,10 +554,9 @@ const makeWASocket = (config) => {
|
|
|
680
554
|
await (await ctx.getClient()).updateDefaultDisappearingMode(duration);
|
|
681
555
|
},
|
|
682
556
|
rejectCall: async (callId, callFrom) => {
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
return (await ctx.getClient()).fetchStatus(jids);
|
|
557
|
+
const context = activeCallContexts.get(callId);
|
|
558
|
+
await (await ctx.getClient()).rejectCall(callId, context?.peer ?? callFrom, context?.callCreator ?? callFrom);
|
|
559
|
+
activeCallContexts.delete(callId);
|
|
687
560
|
},
|
|
688
561
|
/**
|
|
689
562
|
* Fetch the account's current reachout-timelock state from the server.
|
|
@@ -698,30 +571,27 @@ const makeWASocket = (config) => {
|
|
|
698
571
|
* effect for parity with the push path. Returns the same state for
|
|
699
572
|
* callers that prefer awaiting.
|
|
700
573
|
*/
|
|
701
|
-
fetchReachoutTimelock
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
ev.emit('connection.update', { reachoutTimeLock: state });
|
|
705
|
-
return state;
|
|
706
|
-
},
|
|
574
|
+
fetchReachoutTimelock,
|
|
575
|
+
/** Upstream Baileys-compatible name. */
|
|
576
|
+
fetchAccountReachoutTimelock: fetchReachoutTimelock,
|
|
707
577
|
getBusinessProfile: async (jid) => {
|
|
708
|
-
return (await ctx.getClient()).getBusinessProfile(jid);
|
|
578
|
+
return bridgeBusinessProfileToBaileys(await (await ctx.getClient()).getBusinessProfile(jid));
|
|
709
579
|
},
|
|
710
580
|
fetchMessageHistory: async (count, oldestMsgKey, oldestMsgTimestamp) => {
|
|
711
|
-
return (await ctx.getClient()).fetchMessageHistory(count, oldestMsgKey.remoteJid || '', oldestMsgKey.id || '', oldestMsgKey.fromMe || false, oldestMsgTimestamp);
|
|
712
|
-
},
|
|
713
|
-
groupMemberAddMode: async (jid, mode) => {
|
|
714
|
-
await (await ctx.getClient()).groupMemberAddMode(jid, mode);
|
|
581
|
+
return (await ctx.getClient()).fetchMessageHistory(count, oldestMsgKey.remoteJid || '', oldestMsgKey.id || '', oldestMsgKey.fromMe || false, typeof oldestMsgTimestamp === 'number' ? oldestMsgTimestamp : oldestMsgTimestamp.toNumber());
|
|
715
582
|
},
|
|
716
583
|
sendStatusMessage: async (message, recipients) => {
|
|
717
584
|
const bytes = encodeProto('Message', message);
|
|
718
585
|
return (await ctx.getClient()).sendStatusMessageBytes(bytes, recipients);
|
|
719
586
|
},
|
|
720
587
|
...makeMessageMethods(ctx),
|
|
721
|
-
...
|
|
588
|
+
...groupMethods,
|
|
589
|
+
...communityMethods,
|
|
722
590
|
...makeContactMethods(ctx),
|
|
723
591
|
...makeProfileMethods(ctx),
|
|
724
592
|
...makeChatActionMethods(ctx),
|
|
593
|
+
...usyncMethods,
|
|
594
|
+
...makeStanzaResponseMethods(ctx),
|
|
725
595
|
...makePresenceMethods(ctx),
|
|
726
596
|
...makeBlockingMethods(ctx),
|
|
727
597
|
...makeNewsletterMethods(ctx),
|