@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
|
@@ -10,12 +10,21 @@
|
|
|
10
10
|
* are limited to swapping upstream imports for baileyrs equivalents and
|
|
11
11
|
* keeping the WAProto namespace as our re-export.
|
|
12
12
|
*/
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
13
|
+
import { pipeline } from 'node:stream/promises';
|
|
14
|
+
import { promisify } from 'node:util';
|
|
15
|
+
import { createInflate, inflate } from 'node:zlib';
|
|
16
|
+
import { proto } from '../WAProto/runtime.js';
|
|
17
|
+
import { WAProto } from '../Types/index.js';
|
|
18
|
+
import { isHostedLidUser, isHostedPnUser, isLidUser, isPnUser } from '../WABinary/jid-utils.js';
|
|
19
|
+
import { Boom } from './boom.js';
|
|
20
|
+
import { toNumber } from './generics.js';
|
|
21
|
+
import { downloadContentFromMessage, normalizeMessageContent } from './messages.js';
|
|
22
|
+
import { createSparseArray } from './sparse-array.js';
|
|
16
23
|
const STUB = WAProto.WebMessageInfo.StubType;
|
|
24
|
+
const inflatePromise = promisify(inflate);
|
|
17
25
|
const extractPnFromMessages = (messages) => {
|
|
18
|
-
for (
|
|
26
|
+
for (let index = 0; index < messages.length; index++) {
|
|
27
|
+
const msgItem = messages[index];
|
|
19
28
|
const message = msgItem.message;
|
|
20
29
|
// Only extract from outgoing messages (fromMe: true) in 1:1 chats —
|
|
21
30
|
// userReceipt.userJid is the recipient's JID, so it only makes sense
|
|
@@ -28,121 +37,179 @@ const extractPnFromMessages = (messages) => {
|
|
|
28
37
|
}
|
|
29
38
|
return undefined;
|
|
30
39
|
};
|
|
40
|
+
/** Sync types whose conversation records are part of the public history payload. */
|
|
41
|
+
export const CONVERSATION_HISTORY_SYNC_TYPES = Object.freeze([
|
|
42
|
+
WAProto.HistorySync.HistorySyncType.INITIAL_BOOTSTRAP,
|
|
43
|
+
WAProto.HistorySync.HistorySyncType.RECENT,
|
|
44
|
+
WAProto.HistorySync.HistorySyncType.FULL,
|
|
45
|
+
WAProto.HistorySync.HistorySyncType.ON_DEMAND
|
|
46
|
+
]);
|
|
47
|
+
export const isConversationHistorySync = (syncType) => syncType != null && CONVERSATION_HISTORY_SYNC_TYPES.includes(syncType);
|
|
31
48
|
/**
|
|
32
49
|
* Walk a decoded HistorySync proto and extract the upstream
|
|
33
50
|
* `messaging-history.set` payload. Mirrors upstream's behavior exactly,
|
|
34
51
|
* including the side-effect of removing `chat.messages` (kept only as a
|
|
35
52
|
* 1-element preview after the walk).
|
|
36
53
|
*/
|
|
37
|
-
export const processHistoryMessage = (item) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
54
|
+
export const processHistoryMessage = (item, logger) => {
|
|
55
|
+
let messages = [];
|
|
56
|
+
let contacts = [];
|
|
57
|
+
let chats = [];
|
|
58
|
+
const sourceMappings = item.phoneNumberToLidMappings || [];
|
|
59
|
+
const lidPnMappings = createSparseArray(sourceMappings.length);
|
|
60
|
+
let lidPnMappingCount = 0;
|
|
42
61
|
// LID-PN mappings flow on every sync type.
|
|
43
|
-
for (
|
|
62
|
+
for (let index = 0; index < sourceMappings.length; index++) {
|
|
63
|
+
const m = sourceMappings[index];
|
|
44
64
|
if (m.lidJid && m.pnJid)
|
|
45
|
-
lidPnMappings
|
|
65
|
+
lidPnMappings[lidPnMappingCount++] = { lid: m.lidJid, pn: m.pnJid };
|
|
46
66
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
lidPnMappings.length = lidPnMappingCount;
|
|
68
|
+
const syncType = item.syncType;
|
|
69
|
+
logger?.trace({ progress: item.progress }, 'processing history of type ' + syncType?.toString());
|
|
70
|
+
if (isConversationHistorySync(syncType)) {
|
|
71
|
+
const conversations = item.conversations || [];
|
|
72
|
+
let expectedMessages = 0;
|
|
73
|
+
for (let index = 0; index < conversations.length; index++) {
|
|
74
|
+
expectedMessages += conversations[index].messages?.length || 0;
|
|
75
|
+
}
|
|
76
|
+
// History arrives as many small bridge batches. Allocate each result
|
|
77
|
+
// backing store once instead of repeatedly growing it while walking the
|
|
78
|
+
// decoded conversations; invalid entries are compacted by the counters.
|
|
79
|
+
messages = createSparseArray(expectedMessages);
|
|
80
|
+
contacts = createSparseArray(conversations.length);
|
|
81
|
+
chats = createSparseArray(conversations.length);
|
|
82
|
+
lidPnMappings.length = lidPnMappingCount + conversations.length;
|
|
83
|
+
let messageCount = 0;
|
|
84
|
+
let contactCount = 0;
|
|
85
|
+
let chatCount = 0;
|
|
86
|
+
for (let conversationIndex = 0; conversationIndex < conversations.length; conversationIndex++) {
|
|
87
|
+
const conversation = conversations[conversationIndex];
|
|
88
|
+
// `Conversation` is widened to `Chat` because upstream's
|
|
89
|
+
// definition treats them as compatible — the runtime shape
|
|
90
|
+
// matches.
|
|
91
|
+
const chat = conversation;
|
|
92
|
+
const chatId = chat.id;
|
|
93
|
+
if (!chatId) {
|
|
94
|
+
// Server bug or malformed history blob — skip rather than
|
|
95
|
+
// propagate undefined ids that downstream consumers
|
|
96
|
+
// dereference unconditionally.
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
contacts[contactCount++] = {
|
|
100
|
+
id: chatId,
|
|
101
|
+
name: chat.displayName || chat.name || chat.username || undefined,
|
|
102
|
+
username: chat.username || undefined,
|
|
103
|
+
lid: chat.lidJid || chat.accountLid || undefined,
|
|
104
|
+
phoneNumber: chat.pnJid || undefined
|
|
105
|
+
};
|
|
106
|
+
const isLid = isLidUser(chatId) || isHostedLidUser(chatId);
|
|
107
|
+
const isPn = isPnUser(chatId) || isHostedPnUser(chatId);
|
|
108
|
+
if (isLid && chat.pnJid) {
|
|
109
|
+
lidPnMappings[lidPnMappingCount++] = { lid: chatId, pn: chat.pnJid };
|
|
110
|
+
}
|
|
111
|
+
else if (isPn && chat.lidJid) {
|
|
112
|
+
lidPnMappings[lidPnMappingCount++] = { lid: chat.lidJid, pn: chatId };
|
|
113
|
+
}
|
|
114
|
+
else if (isLid && !chat.pnJid) {
|
|
115
|
+
// Fallback: pull PN from a userReceipt on a fromMe message
|
|
116
|
+
// in this chat. Empty when the chat has no fromMe history.
|
|
117
|
+
const pnFromReceipt = extractPnFromMessages(chat.messages || []);
|
|
118
|
+
if (pnFromReceipt)
|
|
119
|
+
lidPnMappings[lidPnMappingCount++] = { lid: chatId, pn: pnFromReceipt };
|
|
120
|
+
}
|
|
121
|
+
const msgs = chat.messages || [];
|
|
122
|
+
// Upstream mutates the chat in place: drops the full message
|
|
123
|
+
// list, keeps only the latest as a preview. Consumers that
|
|
124
|
+
// keyed off `chat.messages` for full history previously broke
|
|
125
|
+
// after this call too — that's the upstream contract.
|
|
126
|
+
delete chat.messages;
|
|
127
|
+
for (let messageIndex = 0; messageIndex < msgs.length; messageIndex++) {
|
|
128
|
+
const histMsg = msgs[messageIndex];
|
|
129
|
+
const message = histMsg.message;
|
|
130
|
+
if (!message)
|
|
63
131
|
continue;
|
|
132
|
+
messages[messageCount++] = message;
|
|
133
|
+
if (!chat.messages?.length) {
|
|
134
|
+
// `chat.messages` is typed as `proto.IHistorySyncMsg[]`
|
|
135
|
+
// but we want to store the WAMessage we already
|
|
136
|
+
// extracted. The runtime shape `{ message }` matches
|
|
137
|
+
// IHistorySyncMsg's optional `message` slot — cast is
|
|
138
|
+
// intentional and isolated to this preview-only field.
|
|
139
|
+
chat.messages = [{ message }];
|
|
64
140
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
name: chat.displayName || chat.name || chat.username || undefined,
|
|
68
|
-
username: chat.username || undefined,
|
|
69
|
-
lid: chat.lidJid || chat.accountLid || undefined,
|
|
70
|
-
phoneNumber: chat.pnJid || undefined
|
|
71
|
-
});
|
|
72
|
-
const isLid = isLidUser(chatId) || isHostedLidUser(chatId);
|
|
73
|
-
const isPn = isPnUser(chatId) || isHostedPnUser(chatId);
|
|
74
|
-
if (isLid && chat.pnJid) {
|
|
75
|
-
lidPnMappings.push({ lid: chatId, pn: chat.pnJid });
|
|
76
|
-
}
|
|
77
|
-
else if (isPn && chat.lidJid) {
|
|
78
|
-
lidPnMappings.push({ lid: chat.lidJid, pn: chatId });
|
|
141
|
+
if (!message.key?.fromMe && !chat.lastMessageRecvTimestamp) {
|
|
142
|
+
chat.lastMessageRecvTimestamp = toNumber(message.messageTimestamp);
|
|
79
143
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
for (const histMsg of msgs) {
|
|
94
|
-
const message = histMsg.message;
|
|
95
|
-
if (!message)
|
|
96
|
-
continue;
|
|
97
|
-
messages.push(message);
|
|
98
|
-
if (!chat.messages?.length) {
|
|
99
|
-
// `chat.messages` is typed as `proto.IHistorySyncMsg[]`
|
|
100
|
-
// but we want to store the WAMessage we already
|
|
101
|
-
// extracted. The runtime shape `{ message }` matches
|
|
102
|
-
// IHistorySyncMsg's optional `message` slot — cast is
|
|
103
|
-
// intentional and isolated to this preview-only field.
|
|
104
|
-
chat.messages = [{ message }];
|
|
105
|
-
}
|
|
106
|
-
if (!message.key?.fromMe && !chat.lastMessageRecvTimestamp) {
|
|
107
|
-
chat.lastMessageRecvTimestamp = toNumber(message.messageTimestamp);
|
|
108
|
-
}
|
|
109
|
-
// Extract verifiedName side-channel when WhatsApp sent a
|
|
110
|
-
// privacy-mode stub for the participant. Skip when the
|
|
111
|
-
// stub carries no addressable target (defensive — server
|
|
112
|
-
// always populates one of the two slots in practice).
|
|
113
|
-
if ((message.messageStubType === STUB.BIZ_PRIVACY_MODE_TO_BSP ||
|
|
114
|
-
message.messageStubType === STUB.BIZ_PRIVACY_MODE_TO_FB) &&
|
|
115
|
-
message.messageStubParameters?.[0]) {
|
|
116
|
-
const verifiedNameId = message.key?.participant ?? message.key?.remoteJid;
|
|
117
|
-
if (verifiedNameId) {
|
|
118
|
-
contacts.push({
|
|
119
|
-
id: verifiedNameId,
|
|
120
|
-
verifiedName: message.messageStubParameters[0]
|
|
121
|
-
});
|
|
122
|
-
}
|
|
144
|
+
// Extract verifiedName side-channel when WhatsApp sent a
|
|
145
|
+
// privacy-mode stub for the participant. Skip when the
|
|
146
|
+
// stub carries no addressable target (defensive — server
|
|
147
|
+
// always populates one of the two slots in practice).
|
|
148
|
+
if ((message.messageStubType === STUB.BIZ_PRIVACY_MODE_TO_BSP ||
|
|
149
|
+
message.messageStubType === STUB.BIZ_PRIVACY_MODE_TO_FB) &&
|
|
150
|
+
message.messageStubParameters?.[0]) {
|
|
151
|
+
const verifiedNameId = message.key?.participant ?? message.key?.remoteJid;
|
|
152
|
+
if (verifiedNameId) {
|
|
153
|
+
contacts[contactCount++] = {
|
|
154
|
+
id: verifiedNameId,
|
|
155
|
+
verifiedName: message.messageStubParameters[0]
|
|
156
|
+
};
|
|
123
157
|
}
|
|
124
158
|
}
|
|
125
|
-
chats.push(chat);
|
|
126
159
|
}
|
|
127
|
-
|
|
160
|
+
chats[chatCount++] = chat;
|
|
128
161
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
162
|
+
messages.length = messageCount;
|
|
163
|
+
contacts.length = contactCount;
|
|
164
|
+
chats.length = chatCount;
|
|
165
|
+
lidPnMappings.length = lidPnMappingCount;
|
|
166
|
+
}
|
|
167
|
+
else if (syncType === WAProto.HistorySync.HistorySyncType.PUSH_NAME) {
|
|
168
|
+
const pushnames = item.pushnames || [];
|
|
169
|
+
contacts = createSparseArray(pushnames.length);
|
|
170
|
+
let contactCount = 0;
|
|
171
|
+
for (let index = 0; index < pushnames.length; index++) {
|
|
172
|
+
const c = pushnames[index];
|
|
173
|
+
if (c.id)
|
|
174
|
+
contacts[contactCount++] = { id: c.id, notify: c.pushname || undefined };
|
|
135
175
|
}
|
|
136
|
-
|
|
137
|
-
// arrays — upstream behaves the same.
|
|
176
|
+
contacts.length = contactCount;
|
|
138
177
|
}
|
|
178
|
+
// NON_BLOCKING_DATA / STATUS_V3 / etc. fall through with empty
|
|
179
|
+
// arrays — upstream behaves the same.
|
|
139
180
|
return {
|
|
140
181
|
chats,
|
|
141
182
|
contacts,
|
|
142
183
|
messages,
|
|
143
184
|
lidPnMappings,
|
|
144
185
|
syncType,
|
|
145
|
-
progress: item.progress
|
|
186
|
+
progress: item.progress,
|
|
187
|
+
pastParticipants: item.pastParticipants
|
|
146
188
|
};
|
|
147
189
|
};
|
|
190
|
+
/** Download, decrypt and inflate an external history-sync blob. */
|
|
191
|
+
export const downloadHistory = async (msg, options) => {
|
|
192
|
+
const stream = await downloadContentFromMessage(msg, 'md-msg-hist', { options });
|
|
193
|
+
const inflater = createInflate();
|
|
194
|
+
const chunks = [];
|
|
195
|
+
inflater.on('data', (chunk) => chunks.push(chunk));
|
|
196
|
+
await pipeline(stream, inflater);
|
|
197
|
+
return proto.HistorySync.decode(Buffer.concat(chunks));
|
|
198
|
+
};
|
|
199
|
+
/** Resolve inline or external history-sync content and normalize its public payload. */
|
|
200
|
+
export const downloadAndProcessHistorySyncNotification = async (msg, options, logger) => {
|
|
201
|
+
const historyMsg = msg.initialHistBootstrapInlinePayload
|
|
202
|
+
? proto.HistorySync.decode(await inflatePromise(msg.initialHistBootstrapInlinePayload))
|
|
203
|
+
: await downloadHistory(msg, options);
|
|
204
|
+
return processHistoryMessage(historyMsg, logger);
|
|
205
|
+
};
|
|
206
|
+
/** Extract a history-sync notification through the same wrapper normalization as upstream. */
|
|
207
|
+
export const getHistoryMsg = (message) => {
|
|
208
|
+
const normalizedContent = message ? normalizeMessageContent(message) : undefined;
|
|
209
|
+
const historySyncNotification = normalizedContent?.protocolMessage?.historySyncNotification;
|
|
210
|
+
if (!historySyncNotification) {
|
|
211
|
+
throw new Boom('Message does not contain a history sync notification', { statusCode: 400 });
|
|
212
|
+
}
|
|
213
|
+
return historySyncNotification;
|
|
214
|
+
};
|
|
148
215
|
//# sourceMappingURL=process-history-message.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-history-message.js","sourceRoot":"","sources":["../../src/Utils/process-history-message.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"process-history-message.js","sourceRoot":"","sources":["../../src/Utils/process-history-message.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAE7C,OAAO,EAAE,OA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AAE,uBAAuB,CAAA;IAC3F,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAC9B,MAAM,IAAI,IAAI,CAAC,sDAAsD,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,CAAA;IAC5F,CAAC;IACD,OAAO,uBAAuB,CAAA;AAC/B,CAAC,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { WAMessage, WAMessageKey } from '../Types/index.js';
|
|
2
|
+
import { proto } from '../WAProto/runtime.js';
|
|
3
|
+
/** Whether an envelope carries user-visible content rather than a control message. */
|
|
4
|
+
export declare const isRealMessage: (message: WAMessage) => boolean;
|
|
5
|
+
export declare const shouldIncrementChatUnread: (message: WAMessage) => boolean;
|
|
6
|
+
/** Normalize device/hosted JIDs and nested reaction/poll keys in place. */
|
|
7
|
+
export declare const cleanMessage: (message: WAMessage, meId: string, meLid: string) => void;
|
|
8
|
+
/** Return the conversation JID represented by a message key. */
|
|
9
|
+
export declare const getChatId: ({ remoteJid, participant, fromMe }: WAMessageKey) => string;
|
|
10
|
+
type PollContext = {
|
|
11
|
+
pollCreatorJid: string;
|
|
12
|
+
pollMsgId: string;
|
|
13
|
+
pollEncKey: Uint8Array;
|
|
14
|
+
voterJid: string;
|
|
15
|
+
};
|
|
16
|
+
type EventContext = {
|
|
17
|
+
eventCreatorJid: string;
|
|
18
|
+
eventMsgId: string;
|
|
19
|
+
eventEncKey: Uint8Array;
|
|
20
|
+
responderJid: string;
|
|
21
|
+
};
|
|
22
|
+
export declare function decryptPollVote({ encPayload, encIv }: proto.Message.IPollEncValue, { pollCreatorJid, pollMsgId, pollEncKey, voterJid }: PollContext): proto.Message.PollVoteMessage;
|
|
23
|
+
export declare function decryptEventResponse({ encPayload, encIv }: proto.Message.IPollEncValue, { eventCreatorJid, eventMsgId, eventEncKey, responderJid }: EventContext): proto.Message.EventResponseMessage;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=process-message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-message.d.ts","sourceRoot":"","sources":["../../src/Utils/process-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhE,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAwB7C,sFAAsF;AACtF,eAAO,MAAM,aAAa,YAAa,SAAS,KAAG,OAYlD,CAAA;AAED,eAAO,MAAM,yBAAyB,YAAa,SAAS,KAAG,OACf,CAAA;AAYhD,2EAA2E;AAC3E,eAAO,MAAM,YAAY,YAAa,SAAS,QAAQ,MAAM,SAAS,MAAM,SAkB3E,CAAA;AAED,gEAAgE;AAChE,eAAO,MAAM,SAAS,uCAAwC,YAAY,KAAG,MAe5E,CAAA;AAED,KAAK,WAAW,GAAG;IAClB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,KAAK,YAAY,GAAG;IACnB,eAAe,EAAE,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,UAAU,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,wBAAgB,eAAe,CAC9B,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,aAAa,EAClD,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,WAAW,iCAKhE;AAED,wBAAgB,oBAAoB,CACnC,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,aAAa,EAClD,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,YAAY,sCAKxE"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { WAMessageStubType } from '../Types/index.js';
|
|
2
|
+
import { proto } from '../WAProto/runtime.js';
|
|
3
|
+
import { decryptEventResponsePayload, decryptPollVotePayload } from 'whatsapp-rust-bridge';
|
|
4
|
+
import { areJidsSameUser, isHostedLidUser, isHostedPnUser, isJidBroadcast, isJidStatusBroadcast, jidDecode, jidEncode, jidNormalizedUser } from '../WABinary/index.js';
|
|
5
|
+
import { Boom } from './boom.js';
|
|
6
|
+
import { getContentType, normalizeMessageContent } from './messages.js';
|
|
7
|
+
const REAL_MSG_STUB_TYPES = new Set([
|
|
8
|
+
WAMessageStubType.CALL_MISSED_GROUP_VIDEO,
|
|
9
|
+
WAMessageStubType.CALL_MISSED_GROUP_VOICE,
|
|
10
|
+
WAMessageStubType.CALL_MISSED_VIDEO,
|
|
11
|
+
WAMessageStubType.CALL_MISSED_VOICE
|
|
12
|
+
]);
|
|
13
|
+
const REAL_MSG_REQ_ME_STUB_TYPES = new Set([WAMessageStubType.GROUP_PARTICIPANT_ADD]);
|
|
14
|
+
/** Whether an envelope carries user-visible content rather than a control message. */
|
|
15
|
+
export const isRealMessage = (message) => {
|
|
16
|
+
const normalizedContent = normalizeMessageContent(message.message);
|
|
17
|
+
const hasSomeContent = !!getContentType(normalizedContent);
|
|
18
|
+
return ((!!normalizedContent ||
|
|
19
|
+
REAL_MSG_STUB_TYPES.has(message.messageStubType) ||
|
|
20
|
+
REAL_MSG_REQ_ME_STUB_TYPES.has(message.messageStubType)) &&
|
|
21
|
+
hasSomeContent &&
|
|
22
|
+
!normalizedContent?.protocolMessage &&
|
|
23
|
+
!normalizedContent?.reactionMessage &&
|
|
24
|
+
!normalizedContent?.pollUpdateMessage);
|
|
25
|
+
};
|
|
26
|
+
export const shouldIncrementChatUnread = (message) => !message.key.fromMe && !message.messageStubType;
|
|
27
|
+
const normalizeMessageJid = (jid) => {
|
|
28
|
+
if (!jid)
|
|
29
|
+
return undefined;
|
|
30
|
+
const hostedPn = isHostedPnUser(jid);
|
|
31
|
+
if (!hostedPn && !isHostedLidUser(jid))
|
|
32
|
+
return jidNormalizedUser(jid);
|
|
33
|
+
const user = jidDecode(jid)?.user;
|
|
34
|
+
return user ? jidEncode(user, hostedPn ? 's.whatsapp.net' : 'lid') : jidNormalizedUser(jid);
|
|
35
|
+
};
|
|
36
|
+
/** Normalize device/hosted JIDs and nested reaction/poll keys in place. */
|
|
37
|
+
export const cleanMessage = (message, meId, meLid) => {
|
|
38
|
+
message.key.remoteJid = normalizeMessageJid(message.key.remoteJid);
|
|
39
|
+
message.key.participant = normalizeMessageJid(message.key.participant);
|
|
40
|
+
const content = normalizeMessageContent(message.message);
|
|
41
|
+
if (content?.reactionMessage)
|
|
42
|
+
normaliseKey(content.reactionMessage.key);
|
|
43
|
+
if (content?.pollUpdateMessage)
|
|
44
|
+
normaliseKey(content.pollUpdateMessage.pollCreationMessageKey);
|
|
45
|
+
function normaliseKey(msgKey) {
|
|
46
|
+
if (!message.key.fromMe) {
|
|
47
|
+
msgKey.fromMe = !msgKey.fromMe
|
|
48
|
+
? areJidsSameUser(msgKey.participant || msgKey.remoteJid, meId) ||
|
|
49
|
+
areJidsSameUser(msgKey.participant || msgKey.remoteJid, meLid)
|
|
50
|
+
: false;
|
|
51
|
+
msgKey.remoteJid = message.key.remoteJid;
|
|
52
|
+
msgKey.participant || (msgKey.participant = message.key.participant);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
/** Return the conversation JID represented by a message key. */
|
|
57
|
+
export const getChatId = ({ remoteJid, participant, fromMe }) => {
|
|
58
|
+
if (!remoteJid) {
|
|
59
|
+
throw new Boom('Cannot derive chat id: message key is missing remoteJid', {
|
|
60
|
+
data: { remoteJid, participant, fromMe }
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (isJidBroadcast(remoteJid) && !isJidStatusBroadcast(remoteJid) && !fromMe) {
|
|
64
|
+
if (!participant) {
|
|
65
|
+
throw new Boom('Cannot derive chat id: broadcast message key is missing participant', {
|
|
66
|
+
data: { remoteJid, fromMe }
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return participant;
|
|
70
|
+
}
|
|
71
|
+
return remoteJid;
|
|
72
|
+
};
|
|
73
|
+
export function decryptPollVote({ encPayload, encIv }, { pollCreatorJid, pollMsgId, pollEncKey, voterJid }) {
|
|
74
|
+
return proto.Message.PollVoteMessage.decode(decryptPollVotePayload(encPayload, encIv, pollEncKey, pollMsgId, pollCreatorJid, voterJid));
|
|
75
|
+
}
|
|
76
|
+
export function decryptEventResponse({ encPayload, encIv }, { eventCreatorJid, eventMsgId, eventEncKey, responderJid }) {
|
|
77
|
+
return proto.Message.EventResponseMessage.decode(decryptEventResponsePayload(encPayload, encIv, eventEncKey, eventMsgId, eventCreatorJid, responderJid));
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=process-message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-message.js","sourceRoot":"","sources":["../../src/Utils/process-message.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC7C,OAAO,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAC1F,OAAO,EACN,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,SAAS,EACT,SAAS,EACT,iBAAiB,EACjB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAEvE,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;IACnC,iBAAiB,CAAC,uBAAuB;IACzC,iBAAiB,CAAC,uBAAuB;IACzC,iBAAiB,CAAC,iBAAiB;IACnC,iBAAiB,CAAC,iBAAiB;CACnC,CAAC,CAAA;AAEF,MAAM,0BAA0B,GAAG,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, SignedKeyPair } from '../Types/Auth.js';
|
|
3
|
+
import type { FullJid } from '../WABinary/index.js';
|
|
4
|
+
import type { USyncQueryResultList } from '../WAUSync/USyncQuery.js';
|
|
5
|
+
export declare const createSignalIdentity: (wid: string, accountSignatureKey: Uint8Array) => SignalIdentity;
|
|
6
|
+
export declare const getPreKeys: ({ get }: SignalKeyStore, min: number, limit: number) => Promise<{
|
|
7
|
+
[id: string]: import("../index.js").KeyPair;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const xmppSignedPreKey: (key: SignedKeyPair) => BinaryNode;
|
|
10
|
+
export declare const xmppPreKey: (pair: {
|
|
11
|
+
public: Uint8Array;
|
|
12
|
+
private: Uint8Array;
|
|
13
|
+
}, id: number) => BinaryNode;
|
|
14
|
+
export declare const extractE2ESessionFromRetryReceipt: (receipt: BinaryNode) => {
|
|
15
|
+
registrationId: number;
|
|
16
|
+
identityKey: Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike>;
|
|
17
|
+
signedPreKey: {
|
|
18
|
+
keyId: number;
|
|
19
|
+
publicKey: Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike>;
|
|
20
|
+
signature: Uint8Array<ArrayBufferLike>;
|
|
21
|
+
};
|
|
22
|
+
preKey: {
|
|
23
|
+
keyId: number;
|
|
24
|
+
publicKey: Uint8Array;
|
|
25
|
+
} | undefined;
|
|
26
|
+
} | null;
|
|
27
|
+
export declare const parseAndInjectE2ESessions: (node: BinaryNode, repository: SignalRepositoryWithLIDStore) => Promise<void>;
|
|
28
|
+
export declare const extractDeviceJids: (result: USyncQueryResultList[], myJid: string, myLid: string, excludeZeroDevices: boolean) => FullJid[];
|
|
29
|
+
//# sourceMappingURL=signal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../../src/Utils/signal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAA;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACrF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAYnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAUpE,eAAO,MAAM,oBAAoB,QAAS,MAAM,uBAAuB,UAAU,KAAG,cAGlF,CAAA;AAEF,eAAO,MAAM,UAAU,YAAmB,cAAc,OAAO,MAAM,SAAS,MAAM;;EAInF,CAAA;AAED,eAAO,MAAM,gBAAgB,QAAS,aAAa,KAAG,UAQpD,CAAA;AAEF,eAAO,MAAM,UAAU,SAAU;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,UAAU,CAAA;CAAE,MAAM,MAAM,KAAG,UAOzF,CAAA;AAIF,eAAO,MAAM,iCAAiC,YAAa,UAAU;;;;QA4BlE,KAAK;QACL,SAAS;QACT,SAAS;;;eAdU,MAAM;mBAAa,UAAU;;QAkBlD,CAAA;AAED,eAAO,MAAM,yBAAyB,SAAgB,UAAU,cAAc,4BAA4B,kBA0BzG,CAAA;AAED,eAAO,MAAM,iBAAiB,WACrB,oBAAoB,EAAE,SACvB,MAAM,SACN,MAAM,sBACO,OAAO,cA4B3B,CAAA"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { KEY_BUNDLE_TYPE } from '../Defaults/index.js';
|
|
2
|
+
import { assertNodeErrorFree, getBinaryNodeChild, getBinaryNodeChildBuffer, getBinaryNodeChildren, getBinaryNodeChildUInt, getServerFromDomainType, jidDecode, WAJIDDomains } from '../WABinary/index.js';
|
|
3
|
+
import { generateSignalPubKey } from './crypto.js';
|
|
4
|
+
import { encodeBigEndian } from './generics.js';
|
|
5
|
+
const chunk = (array, size) => {
|
|
6
|
+
const chunks = [];
|
|
7
|
+
for (let index = 0; index < array.length; index += size)
|
|
8
|
+
chunks.push(array.slice(index, index + size));
|
|
9
|
+
return chunks;
|
|
10
|
+
};
|
|
11
|
+
export const createSignalIdentity = (wid, accountSignatureKey) => ({
|
|
12
|
+
identifier: { name: wid, deviceId: 0 },
|
|
13
|
+
identifierKey: generateSignalPubKey(accountSignatureKey)
|
|
14
|
+
});
|
|
15
|
+
export const getPreKeys = async ({ get }, min, limit) => {
|
|
16
|
+
const idList = [];
|
|
17
|
+
for (let id = min; id < limit; id++)
|
|
18
|
+
idList.push(id.toString());
|
|
19
|
+
return get('pre-key', idList);
|
|
20
|
+
};
|
|
21
|
+
export const xmppSignedPreKey = (key) => ({
|
|
22
|
+
tag: 'skey',
|
|
23
|
+
attrs: {},
|
|
24
|
+
content: [
|
|
25
|
+
{ tag: 'id', attrs: {}, content: encodeBigEndian(key.keyId, 3) },
|
|
26
|
+
{ tag: 'value', attrs: {}, content: key.keyPair.public },
|
|
27
|
+
{ tag: 'signature', attrs: {}, content: key.signature }
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
export const xmppPreKey = (pair, id) => ({
|
|
31
|
+
tag: 'key',
|
|
32
|
+
attrs: {},
|
|
33
|
+
content: [
|
|
34
|
+
{ tag: 'id', attrs: {}, content: encodeBigEndian(id, 3) },
|
|
35
|
+
{ tag: 'value', attrs: {}, content: pair.public }
|
|
36
|
+
]
|
|
37
|
+
});
|
|
38
|
+
const isValidUInt = (value) => typeof value === 'number' && Number.isInteger(value);
|
|
39
|
+
export const extractE2ESessionFromRetryReceipt = (receipt) => {
|
|
40
|
+
const keysNode = getBinaryNodeChild(receipt, 'keys');
|
|
41
|
+
if (!keysNode)
|
|
42
|
+
return null;
|
|
43
|
+
const typeBuffer = getBinaryNodeChildBuffer(keysNode, 'type');
|
|
44
|
+
if (!typeBuffer || typeBuffer.length !== 1 || typeBuffer[0] !== KEY_BUNDLE_TYPE[0])
|
|
45
|
+
return null;
|
|
46
|
+
const identity = getBinaryNodeChildBuffer(keysNode, 'identity');
|
|
47
|
+
const signedKey = getBinaryNodeChild(keysNode, 'skey');
|
|
48
|
+
if (!identity || identity.length !== 32 || !signedKey)
|
|
49
|
+
return null;
|
|
50
|
+
const registrationId = getBinaryNodeChildUInt(receipt, 'registration', 4);
|
|
51
|
+
if (!isValidUInt(registrationId))
|
|
52
|
+
return null;
|
|
53
|
+
const signedPublicKey = getBinaryNodeChildBuffer(signedKey, 'value');
|
|
54
|
+
const signedSignature = getBinaryNodeChildBuffer(signedKey, 'signature');
|
|
55
|
+
const signedKeyId = getBinaryNodeChildUInt(signedKey, 'id', 3);
|
|
56
|
+
if (!signedPublicKey || signedPublicKey.length !== 32 || !signedSignature || !isValidUInt(signedKeyId))
|
|
57
|
+
return null;
|
|
58
|
+
const preKeyNode = getBinaryNodeChild(keysNode, 'key');
|
|
59
|
+
let preKey;
|
|
60
|
+
if (preKeyNode) {
|
|
61
|
+
const publicKey = getBinaryNodeChildBuffer(preKeyNode, 'value');
|
|
62
|
+
const keyId = getBinaryNodeChildUInt(preKeyNode, 'id', 3);
|
|
63
|
+
if (!publicKey || publicKey.length !== 32 || !isValidUInt(keyId))
|
|
64
|
+
return null;
|
|
65
|
+
preKey = { keyId, publicKey: generateSignalPubKey(publicKey) };
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
registrationId,
|
|
69
|
+
identityKey: generateSignalPubKey(identity),
|
|
70
|
+
signedPreKey: {
|
|
71
|
+
keyId: signedKeyId,
|
|
72
|
+
publicKey: generateSignalPubKey(signedPublicKey),
|
|
73
|
+
signature: signedSignature
|
|
74
|
+
},
|
|
75
|
+
preKey
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
export const parseAndInjectE2ESessions = async (node, repository) => {
|
|
79
|
+
const extractKey = (key) => key
|
|
80
|
+
? {
|
|
81
|
+
keyId: getBinaryNodeChildUInt(key, 'id', 3),
|
|
82
|
+
publicKey: generateSignalPubKey(getBinaryNodeChildBuffer(key, 'value')),
|
|
83
|
+
signature: getBinaryNodeChildBuffer(key, 'signature')
|
|
84
|
+
}
|
|
85
|
+
: undefined;
|
|
86
|
+
const nodes = getBinaryNodeChildren(getBinaryNodeChild(node, 'list'), 'user');
|
|
87
|
+
for (const userNode of nodes)
|
|
88
|
+
assertNodeErrorFree(userNode);
|
|
89
|
+
for (const nodesChunk of chunk(nodes, 100)) {
|
|
90
|
+
for (const userNode of nodesChunk) {
|
|
91
|
+
const signedKey = getBinaryNodeChild(userNode, 'skey');
|
|
92
|
+
const key = getBinaryNodeChild(userNode, 'key');
|
|
93
|
+
await repository.injectE2ESession({
|
|
94
|
+
jid: userNode.attrs.jid,
|
|
95
|
+
session: {
|
|
96
|
+
registrationId: getBinaryNodeChildUInt(userNode, 'registration', 4),
|
|
97
|
+
identityKey: generateSignalPubKey(getBinaryNodeChildBuffer(userNode, 'identity')),
|
|
98
|
+
signedPreKey: extractKey(signedKey),
|
|
99
|
+
preKey: extractKey(key)
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
export const extractDeviceJids = (result, myJid, myLid, excludeZeroDevices) => {
|
|
106
|
+
const { user: myUser, device: myDevice } = jidDecode(myJid);
|
|
107
|
+
const extracted = [];
|
|
108
|
+
for (const userResult of result) {
|
|
109
|
+
const { devices, id } = userResult;
|
|
110
|
+
const decoded = jidDecode(id);
|
|
111
|
+
const { user, server } = decoded;
|
|
112
|
+
let { domainType } = decoded;
|
|
113
|
+
const deviceList = devices?.deviceList;
|
|
114
|
+
if (!Array.isArray(deviceList))
|
|
115
|
+
continue;
|
|
116
|
+
for (const { id: device, keyIndex, isHosted } of deviceList) {
|
|
117
|
+
if ((!excludeZeroDevices || device !== 0) &&
|
|
118
|
+
((myUser !== user && myLid !== user) || myDevice !== device) &&
|
|
119
|
+
(device === 0 || !!keyIndex)) {
|
|
120
|
+
if (isHosted)
|
|
121
|
+
domainType = domainType === WAJIDDomains.LID ? WAJIDDomains.HOSTED_LID : WAJIDDomains.HOSTED;
|
|
122
|
+
extracted.push({
|
|
123
|
+
user,
|
|
124
|
+
device,
|
|
125
|
+
domainType,
|
|
126
|
+
server: getServerFromDomainType(server, domainType)
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return extracted;
|
|
132
|
+
};
|
|
133
|
+
//# sourceMappingURL=signal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signal.js","sourceRoot":"","sources":["../../src/Utils/signal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAItD,OAAO,EACN,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,SAAS,EACT,YAAY,EACZ,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE/C,MAAM,KAAK,GAAG,CAAI,KAAU,EAAE,IAAY,EAAS,EAAE;IACpD,MAAM,MAAM,GAAU,EAAE,CAAA;IACxB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,IAAI;QAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC,CAAA;IACtG,OAAO,MAAM,CAAA;AACd,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAW,EAAE,mBAA+B,EAAkB,EAAE,CAAC,CAAC;IACtG,UAAU,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE;IACtC,aAAa,EAAE,oBAAoB,CAAC,mBAAmB,CAAC;CACxD,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,EAAE,GAAG,EAAkB,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