@oxidezap/baileyrs 0.0.26 → 0.0.27
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/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 +45 -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 +273 -55
- 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 +32 -14
- 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/Utils/bridge-call.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Re-stamps the stack of a `WhatsAppError` thrown across the WASM boundary
|
|
3
|
-
* with the JS call site that originated the request. Without this, every
|
|
4
|
-
* bridge error shows only the opaque `wasm-function[NNN]` frames and the
|
|
5
|
-
* wbindgen helpers — useless for debugging.
|
|
6
|
-
*
|
|
7
|
-
* V8 (Node, Chromium) supports `Error.captureStackTrace(target, fn)` which
|
|
8
|
-
* replaces `target.stack` with the stack starting *above* `fn`. We capture
|
|
9
|
-
* a placeholder `Error` synchronously before crossing the boundary (cheap
|
|
10
|
-
* — only a stack walk, no allocation noise) and graft it onto the rejection
|
|
11
|
-
* that comes back from WASM, preserving the original WASM frames as a
|
|
12
|
-
* `--- bridge ---` tail for forensic value.
|
|
13
|
-
*
|
|
14
|
-
* Used by `wrapBridgeClient` (below). Could also be used directly for
|
|
15
|
-
* one-off calls outside the Proxy.
|
|
16
|
-
*/
|
|
17
|
-
function reStampStack(callerStack, e) {
|
|
18
|
-
if (!callerStack)
|
|
19
|
-
return;
|
|
20
|
-
if (!(e instanceof Error))
|
|
21
|
-
return;
|
|
22
|
-
// Only re-stamp errors that came from the bridge — leave native JS
|
|
23
|
-
// errors (TypeError, etc.) alone so their original stack still works.
|
|
24
|
-
if (e.name !== 'WhatsAppError')
|
|
25
|
-
return;
|
|
26
|
-
// `callerStack` looks like:
|
|
27
|
-
// "Error: bridge call\n at foo (...)\n at bar (...)"
|
|
28
|
-
// The first line is the placeholder's `Error: <message>` header, which
|
|
29
|
-
// would shadow the real error's name/message if we kept it. Drop it
|
|
30
|
-
// and prepend the real error's `<name>: <message>` so the output
|
|
31
|
-
// matches what V8 would have produced if the error originated in JS.
|
|
32
|
-
const callerFrames = callerStack.replace(/^[^\n]*\n/, '');
|
|
33
|
-
const realHeader = `${e.name}: ${e.message}`;
|
|
34
|
-
const wasmTail = e.stack ? `\n --- via bridge ---\n${e.stack}` : '';
|
|
35
|
-
e.stack = `${realHeader}\n${callerFrames}${wasmTail}`;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Wrap a bridge client so that any async method call captures the JS-side
|
|
39
|
-
* call stack and re-stamps it onto rejections. The wrapped client is
|
|
40
|
-
* indistinguishable from the unwrapped one for callers — same shape, same
|
|
41
|
-
* promises, same return values.
|
|
42
|
-
*
|
|
43
|
-
* Implementation:
|
|
44
|
-
* - `Proxy` intercepts every `get` for a method.
|
|
45
|
-
* - The intercepted function captures a placeholder `Error` *before*
|
|
46
|
-
* awaiting (synchronously in the JS event loop tick of the call site),
|
|
47
|
-
* calling `Error.captureStackTrace(_, fn)` to elide its own frame and
|
|
48
|
-
* pin the stack to the user's call site.
|
|
49
|
-
* - On rejection, `reStampStack` grafts the captured stack onto the
|
|
50
|
-
* `WhatsAppError`'s `stack` and rethrows.
|
|
51
|
-
* - On success / non-promise returns / non-function gets: passthrough.
|
|
52
|
-
*
|
|
53
|
-
* Cost: one `new Error()` + one `captureStackTrace` per async call. V8 has
|
|
54
|
-
* fast paths for both — sub-microsecond. Negligible for the rates the
|
|
55
|
-
* bridge sees in practice.
|
|
56
|
-
*/
|
|
57
|
-
export function wrapBridgeClient(client) {
|
|
58
|
-
return new Proxy(client, {
|
|
59
|
-
get(target, prop, receiver) {
|
|
60
|
-
const value = Reflect.get(target, prop, receiver);
|
|
61
|
-
if (typeof value !== 'function')
|
|
62
|
-
return value;
|
|
63
|
-
// Wrap each method on first access. Note: not cached per-prop
|
|
64
|
-
// because methods are usually accessed once per call site (the
|
|
65
|
-
// Proxy itself is cached at the boundary).
|
|
66
|
-
const wrapped = function (...args) {
|
|
67
|
-
// Capture the caller's stack BEFORE crossing into WASM. If we
|
|
68
|
-
// did this after `value.apply(...)`, a synchronous throw from
|
|
69
|
-
// the WASM-bindgen shim (e.g. argument validation, lock
|
|
70
|
-
// contention surfaced as `Err(JsValue)`) would skip the
|
|
71
|
-
// capture entirely and the resulting `WhatsAppError` would
|
|
72
|
-
// keep its raw WASM stack. Cost: one stack walk per call;
|
|
73
|
-
// V8 makes this sub-microsecond.
|
|
74
|
-
const placeholder = new Error('bridge call');
|
|
75
|
-
if (typeof Error.captureStackTrace === 'function') {
|
|
76
|
-
Error.captureStackTrace(placeholder, wrapped);
|
|
77
|
-
}
|
|
78
|
-
const callerStack = placeholder.stack;
|
|
79
|
-
let result;
|
|
80
|
-
try {
|
|
81
|
-
result = value.apply(target, args);
|
|
82
|
-
}
|
|
83
|
-
catch (err) {
|
|
84
|
-
// Sync throw — re-stamp and rethrow on the same tick so
|
|
85
|
-
// the consumer sees a `WhatsAppError` with the JS call
|
|
86
|
-
// site at the top, just like the async path.
|
|
87
|
-
reStampStack(callerStack, err);
|
|
88
|
-
throw err;
|
|
89
|
-
}
|
|
90
|
-
// Synchronous returns (non-promise): nothing to re-stamp,
|
|
91
|
-
// pass through. (Bridge methods that return primitives like
|
|
92
|
-
// `isConnected()` end up here.)
|
|
93
|
-
if (!result || typeof result.then !== 'function') {
|
|
94
|
-
return result;
|
|
95
|
-
}
|
|
96
|
-
return result.then(v => v, err => {
|
|
97
|
-
reStampStack(callerStack, err);
|
|
98
|
-
throw err;
|
|
99
|
-
});
|
|
100
|
-
};
|
|
101
|
-
return wrapped;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
//# sourceMappingURL=bridge-call.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bridge-call.js","sourceRoot":"","sources":["../../src/Utils/bridge-call.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,SAAS,YAAY,CAAC,WAA+B,EAAE,CAAU;IAChE,IAAI,CAAC,WAAW;QAAE,OAAM;IACxB,IAAI,CAAC,CAAC,CAAC,YAAY,KAAK,CAAC;QAAE,OAAM;IACjC,mEAAmE;IACnE,sEAAsE;IACtE,IAAI,CAAC,CAAC,IAAI,KAAK,eAAe;QAAE,OAAM;IAEtC,4BAA4B;IAC5B,6DAA6D;IAC7D,uEAAuE;IACvE,oEAAoE;IACpE,iEAAiE;IACjE,qEAAqE;IACrE,MAAM,YAAY,GAAG,WAAW,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;IACzD,MAAM,UAAU,GAAG,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAA;IAC5C,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;IACpE,CAAC,CAAC,KAAK,GAAG,GAAG,UAAU,KAAK,YAAY,GAAG,QAAQ,EAAE,CAAA;AACtD,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,gBAAgB,CAAmB,MAAS;IAC3D,OAAO,IAAI,KAAK,CAAC,MAAM,EAAE;QACxB,GAAG,CAAC,MAAM,EAA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,CAAA;oBAC9B,MAAM,GAAG,CAAA;gBACV,CAAC,CACD,CAAA;YACF,CAAC,CAAA;YACD,OAAO,OAAO,CAAA;QACf,CAAC;KACD,CAAM,CAAA;AACR,CAAC"}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Read-side helpers for the `lid-mapping` persistence bucket.
|
|
3
|
-
*
|
|
4
|
-
* The bridge (`whatsapp-rust-bridge`) writes every learned LID↔PN association
|
|
5
|
-
* through `JsStoreCallbacks.set('lid-mapping', key, bytes)` using the layout
|
|
6
|
-
* documented in {@link LidMappingStoreFormat}. The bridge core also keeps an
|
|
7
|
-
* in-memory `lid_pn_cache` populated by `warm_up_lid_pn_cache()` on boot, but
|
|
8
|
-
* that warm-up depends on `backend.get_all_lid_mappings()` — a *list*
|
|
9
|
-
* primitive that `JsStoreCallbacks` deliberately doesn't expose. So when
|
|
10
|
-
* baileyrs runs with a `wrapLegacyStore`-backed `auth.store`, the bridge's
|
|
11
|
-
* cache stays empty across process restarts even though every entry IS
|
|
12
|
-
* persisted on disk. Callers like `signalRepository.lidMapping` have to fall
|
|
13
|
-
* back to reading the bucket directly to recover the mapping.
|
|
14
|
-
*
|
|
15
|
-
* The JID/server constants and the entry shape mirror the bridge's
|
|
16
|
-
* serialization output — keep this module aligned with `wacore`'s
|
|
17
|
-
* `LidPnEntry`/`LidPnMappingEntry` if those structs ever change.
|
|
18
|
-
*/
|
|
19
|
-
import type { AuthenticationState } from '../Types/Auth.js';
|
|
20
|
-
/**
|
|
21
|
-
* Layout the bridge uses inside the `lid-mapping` bucket. Two keys per
|
|
22
|
-
* mapping: a forward entry (`lid:<user>`) holding the full JSON record, and a
|
|
23
|
-
* reverse index (`pn:<user>`) holding just the bare LID user string.
|
|
24
|
-
*/
|
|
25
|
-
export declare const LID_MAPPING_STORE: "lid-mapping";
|
|
26
|
-
export declare const LID_MAPPING_KEYS: {
|
|
27
|
-
/** Forward entry — full `LidPnEntry` JSON. Lookup via LID user part. */
|
|
28
|
-
readonly byLid: (user: string) => `lid:${string}`;
|
|
29
|
-
/** Reverse index — bare LID user string. Lookup via PN user part. */
|
|
30
|
-
readonly byPn: (user: string) => `pn:${string}`;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Subset of the Rust `LidPnEntry` struct's serde-JSON output that the resolver
|
|
34
|
-
* actually consumes. Keep optional everything except the two identity fields
|
|
35
|
-
* so older/leaner records still parse.
|
|
36
|
-
*/
|
|
37
|
-
export interface PersistedLidMappingEntry {
|
|
38
|
-
readonly lid: string;
|
|
39
|
-
readonly phone_number: string;
|
|
40
|
-
readonly created_at?: number;
|
|
41
|
-
readonly updated_at?: number;
|
|
42
|
-
readonly learning_source?: string;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Minimal slice of `JsStoreCallbacks` needed by the resolver. Restricted so
|
|
46
|
-
* the resolver can be exercised by tests without conjuring a full bridge
|
|
47
|
-
* store implementation.
|
|
48
|
-
*/
|
|
49
|
-
export interface LidMappingStoreReader {
|
|
50
|
-
get(store: string, key: string): Promise<Uint8Array | null>;
|
|
51
|
-
}
|
|
52
|
-
/** Bridge cache the resolver tries first before reaching for `auth.store`. */
|
|
53
|
-
export interface LidMappingBridgeCache {
|
|
54
|
-
lidForPn(jid: string): Promise<string | null | undefined>;
|
|
55
|
-
pnForLid(jid: string): Promise<string | null | undefined>;
|
|
56
|
-
}
|
|
57
|
-
/** Decode a `lid:<user>` entry's JSON bytes; returns `null` on malformed input. */
|
|
58
|
-
export declare const parseLidMappingEntry: (bytes: Uint8Array | Buffer | null | undefined) => PersistedLidMappingEntry | null;
|
|
59
|
-
/** Decode a `pn:<user>` reverse-index entry — just the bare LID user string. */
|
|
60
|
-
export declare const parseLidIndexEntry: (bytes: Uint8Array | Buffer | null | undefined) => string | null;
|
|
61
|
-
/**
|
|
62
|
-
* Public shape of `signalRepository.lidMapping`. Mirrors upstream Baileys.
|
|
63
|
-
*/
|
|
64
|
-
export interface LidMappingResolver {
|
|
65
|
-
getLIDForPN(pn: string): Promise<string | null>;
|
|
66
|
-
getPNForLID(lid: string): Promise<string | null>;
|
|
67
|
-
}
|
|
68
|
-
export interface LidMappingResolverDeps {
|
|
69
|
-
bridge: LidMappingBridgeCache;
|
|
70
|
-
auth?: Pick<AuthenticationState, 'store'>;
|
|
71
|
-
logger?: {
|
|
72
|
-
debug: (obj: unknown, msg?: string) => void;
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Build a resolver that prefers the bridge's in-memory cache and falls back to
|
|
77
|
-
* a direct read from the persisted `lid-mapping` bucket. Exported so unit
|
|
78
|
-
* tests can drive both paths without instantiating a full WASM client.
|
|
79
|
-
*/
|
|
80
|
-
export declare const makeLidMappingResolver: ({ bridge, auth, logger }: LidMappingResolverDeps) => LidMappingResolver;
|
|
81
|
-
//# sourceMappingURL=lid-mapping-store.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lid-mapping-store.d.ts","sourceRoot":"","sources":["../../src/Utils/lid-mapping-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAG3D;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAG,aAAsB,CAAA;AACvD,eAAO,MAAM,gBAAgB;IAC5B,wEAAwE;2BAC1D,MAAM;IACpB,qEAAqE;0BACxD,MAAM;CACV,CAAA;AAMV;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CACjC;AAED;;;;G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
|
1
|
-
/**
|
|
2
|
-
* Read-side helpers for the `lid-mapping` persistence bucket.
|
|
3
|
-
*
|
|
4
|
-
* The bridge (`whatsapp-rust-bridge`) writes every learned LID↔PN association
|
|
5
|
-
* through `JsStoreCallbacks.set('lid-mapping', key, bytes)` using the layout
|
|
6
|
-
* documented in {@link LidMappingStoreFormat}. The bridge core also keeps an
|
|
7
|
-
* in-memory `lid_pn_cache` populated by `warm_up_lid_pn_cache()` on boot, but
|
|
8
|
-
* that warm-up depends on `backend.get_all_lid_mappings()` — a *list*
|
|
9
|
-
* primitive that `JsStoreCallbacks` deliberately doesn't expose. So when
|
|
10
|
-
* baileyrs runs with a `wrapLegacyStore`-backed `auth.store`, the bridge's
|
|
11
|
-
* cache stays empty across process restarts even though every entry IS
|
|
12
|
-
* persisted on disk. Callers like `signalRepository.lidMapping` have to fall
|
|
13
|
-
* back to reading the bucket directly to recover the mapping.
|
|
14
|
-
*
|
|
15
|
-
* The JID/server constants and the entry shape mirror the bridge's
|
|
16
|
-
* serialization output — keep this module aligned with `wacore`'s
|
|
17
|
-
* `LidPnEntry`/`LidPnMappingEntry` if those structs ever change.
|
|
18
|
-
*/
|
|
19
|
-
import { jidDecode } from "../WABinary/jid-utils.js";
|
|
20
|
-
/**
|
|
21
|
-
* Layout the bridge uses inside the `lid-mapping` bucket. Two keys per
|
|
22
|
-
* mapping: a forward entry (`lid:<user>`) holding the full JSON record, and a
|
|
23
|
-
* reverse index (`pn:<user>`) holding just the bare LID user string.
|
|
24
|
-
*/
|
|
25
|
-
export const LID_MAPPING_STORE = 'lid-mapping';
|
|
26
|
-
export const LID_MAPPING_KEYS = {
|
|
27
|
-
/** Forward entry — full `LidPnEntry` JSON. Lookup via LID user part. */
|
|
28
|
-
byLid: (user) => `lid:${user}`,
|
|
29
|
-
/** Reverse index — bare LID user string. Lookup via PN user part. */
|
|
30
|
-
byPn: (user) => `pn:${user}`
|
|
31
|
-
};
|
|
32
|
-
/** WhatsApp JID server suffixes used by the lookup helpers. */
|
|
33
|
-
const PN_SERVER = 's.whatsapp.net';
|
|
34
|
-
const LID_SERVER = 'lid';
|
|
35
|
-
const TEXT_DECODER = new TextDecoder('utf-8');
|
|
36
|
-
/** Strip device suffix and server, returning the bare user identifier. */
|
|
37
|
-
const userPartOf = (jid) => {
|
|
38
|
-
const decoded = jidDecode(jid);
|
|
39
|
-
if (decoded?.user)
|
|
40
|
-
return decoded.user;
|
|
41
|
-
// Already bare (no `@`): tolerate both `123` and `123:45` shapes.
|
|
42
|
-
const trimmed = jid.split('@')[0] ?? '';
|
|
43
|
-
const head = trimmed.split(':')[0] ?? '';
|
|
44
|
-
return head.length > 0 ? head : null;
|
|
45
|
-
};
|
|
46
|
-
/** Decode a `lid:<user>` entry's JSON bytes; returns `null` on malformed input. */
|
|
47
|
-
export const parseLidMappingEntry = (bytes) => {
|
|
48
|
-
if (!bytes || bytes.length === 0)
|
|
49
|
-
return null;
|
|
50
|
-
const view = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
|
|
51
|
-
let parsed;
|
|
52
|
-
try {
|
|
53
|
-
parsed = JSON.parse(TEXT_DECODER.decode(view));
|
|
54
|
-
}
|
|
55
|
-
catch {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
if (typeof parsed !== 'object' || parsed === null)
|
|
59
|
-
return null;
|
|
60
|
-
const obj = parsed;
|
|
61
|
-
if (typeof obj.lid !== 'string' || typeof obj.phone_number !== 'string')
|
|
62
|
-
return null;
|
|
63
|
-
return {
|
|
64
|
-
lid: obj.lid,
|
|
65
|
-
phone_number: obj.phone_number,
|
|
66
|
-
...(typeof obj.created_at === 'number' ? { created_at: obj.created_at } : {}),
|
|
67
|
-
...(typeof obj.updated_at === 'number' ? { updated_at: obj.updated_at } : {}),
|
|
68
|
-
...(typeof obj.learning_source === 'string' ? { learning_source: obj.learning_source } : {})
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
/** Decode a `pn:<user>` reverse-index entry — just the bare LID user string. */
|
|
72
|
-
export const parseLidIndexEntry = (bytes) => {
|
|
73
|
-
if (!bytes || bytes.length === 0)
|
|
74
|
-
return null;
|
|
75
|
-
const view = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
|
|
76
|
-
let text;
|
|
77
|
-
try {
|
|
78
|
-
text = TEXT_DECODER.decode(view).trim();
|
|
79
|
-
}
|
|
80
|
-
catch {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
return text.length > 0 ? text : null;
|
|
84
|
-
};
|
|
85
|
-
const safeStoreGet = async (store, key, logger) => {
|
|
86
|
-
if (!store)
|
|
87
|
-
return null;
|
|
88
|
-
try {
|
|
89
|
-
return await store.get(LID_MAPPING_STORE, key);
|
|
90
|
-
}
|
|
91
|
-
catch (err) {
|
|
92
|
-
logger?.debug({ err, key }, 'lidMapping: auth.store.get failed');
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Build a resolver that prefers the bridge's in-memory cache and falls back to
|
|
98
|
-
* a direct read from the persisted `lid-mapping` bucket. Exported so unit
|
|
99
|
-
* tests can drive both paths without instantiating a full WASM client.
|
|
100
|
-
*/
|
|
101
|
-
export const makeLidMappingResolver = ({ bridge, auth, logger }) => {
|
|
102
|
-
const store = auth?.store;
|
|
103
|
-
return {
|
|
104
|
-
async getLIDForPN(pn) {
|
|
105
|
-
const cached = await bridge.lidForPn(pn);
|
|
106
|
-
if (cached)
|
|
107
|
-
return cached;
|
|
108
|
-
const user = userPartOf(pn);
|
|
109
|
-
if (!user)
|
|
110
|
-
return null;
|
|
111
|
-
const lidUser = parseLidIndexEntry(await safeStoreGet(store, LID_MAPPING_KEYS.byPn(user), logger));
|
|
112
|
-
return lidUser ? `${lidUser}@${LID_SERVER}` : null;
|
|
113
|
-
},
|
|
114
|
-
async getPNForLID(lid) {
|
|
115
|
-
const cached = await bridge.pnForLid(lid);
|
|
116
|
-
if (cached)
|
|
117
|
-
return cached;
|
|
118
|
-
const user = userPartOf(lid);
|
|
119
|
-
if (!user)
|
|
120
|
-
return null;
|
|
121
|
-
const entry = parseLidMappingEntry(await safeStoreGet(store, LID_MAPPING_KEYS.byLid(user), logger));
|
|
122
|
-
return entry ? `${entry.phone_number}@${PN_SERVER}` : null;
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
|
-
//# sourceMappingURL=lid-mapping-store.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lid-mapping-store.js","sourceRoot":"","sources":["../../src/Utils/lid-mapping-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,SAAS,EAAkB,MAAM,0BAA0B,CAAA;AAEpE;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAsB,CAAA;AACvD,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC/B,wEAAwE;IACxE,KAAK,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,OAAO,IAAI,EAAW;IAC/C,qEAAqE;IACrE,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,MAAM,IAAI,EAAW;CACpC,CAAA;AAEV,+DAA+D;AAC/D,MAAM,SAAS,GAAc,gBAAgB,CAAA;AAC7C,MAAM,UAAU,GAAc,KAAK,CAAA;AA8BnC,MAAM,YAAY,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAA;AAE7C,0EAA0E;AAC1E,MAAM,UAAU,GAAG,CAAC,GAAW,EAAiB,EAAE;IACjD,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,CAAA;IAC9B,IAAI,OAAO,EAAE,IAAI;QAAE,OAAO,OAAO,CAAC,IAAI,CAAA;IACtC,kEAAkE;IAClE,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;IACvC,MAAM,IAAI,GAAG,OAAO,CA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
|
|
|
1
|
-
import { type StubParticipantPayload } from '../Utils/group-stub-params.js';
|
|
2
|
-
type Ctor = new (...args: never[]) => unknown;
|
|
3
|
-
type ThrowMatcher = string | RegExp | Error | Ctor | ((err: Error) => boolean);
|
|
4
|
-
interface Matchers<T> {
|
|
5
|
-
toBe(expected: T): void;
|
|
6
|
-
toEqual(expected: unknown): void;
|
|
7
|
-
toBeDefined(): void;
|
|
8
|
-
toBeUndefined(): void;
|
|
9
|
-
toBeTruthy(): void;
|
|
10
|
-
toBeFalsy(): void;
|
|
11
|
-
toBeInstanceOf(ctor: Ctor): void;
|
|
12
|
-
toBeGreaterThan(n: number): void;
|
|
13
|
-
toBeGreaterThanOrEqual(n: number): void;
|
|
14
|
-
toBeLessThan(n: number): void;
|
|
15
|
-
toBeLessThanOrEqual(n: number): void;
|
|
16
|
-
toContain(item: unknown): void;
|
|
17
|
-
toHaveLength(n: number): void;
|
|
18
|
-
toHaveProperty(path: string): void;
|
|
19
|
-
toThrow(matcher?: ThrowMatcher): void;
|
|
20
|
-
/** Asserts the actual object contains all the given keys with deep-equal values (extra keys allowed). */
|
|
21
|
-
toMatchObject(expected: Partial<T> | Record<string, unknown>): void;
|
|
22
|
-
}
|
|
23
|
-
interface AsyncMatchers<T> {
|
|
24
|
-
toBe(expected: T): Promise<void>;
|
|
25
|
-
toBeUndefined(): Promise<void>;
|
|
26
|
-
toThrow(matcher?: ThrowMatcher): Promise<void>;
|
|
27
|
-
}
|
|
28
|
-
interface Expect<T> extends Matchers<T> {
|
|
29
|
-
readonly not: Pick<Matchers<T>, 'toBe' | 'toThrow'>;
|
|
30
|
-
readonly resolves: AsyncMatchers<Awaited<T>>;
|
|
31
|
-
readonly rejects: AsyncMatchers<unknown>;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Assert a `messageStubParameters[i]` raw string decodes to a participant
|
|
35
|
-
* payload that contains AT LEAST the expected fields. Extra fields on the
|
|
36
|
-
* decoded payload (e.g. a `phoneNumber` the bridge happens to include) do
|
|
37
|
-
* NOT fail the assert — callers state only what they care about. Fails
|
|
38
|
-
* loudly when the string is missing, not valid JSON, or has the wrong
|
|
39
|
-
* shape, which catches regressions where a raw JID leaks back in.
|
|
40
|
-
*/
|
|
41
|
-
export declare function expectStubParticipant(raw: string | null | undefined, expected: StubParticipantPayload): void;
|
|
42
|
-
export declare function expect<T>(actual: T): Expect<T>;
|
|
43
|
-
export {};
|
|
44
|
-
//# sourceMappingURL=expect.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expect.d.ts","sourceRoot":"","sources":["../../src/__tests__/expect.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AAElG,KAAK,IAAI,GAAG,KAAK,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAA;AAC7C,KAAK,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,KAAK,OAAO,CAAC,CAAA;AAE9E,UAAU,QAAQ,CAAC,CAAC;IACnB,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAA;IACvB,OAAO,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAA;IAChC,WAAW,IAAI,IAAI,CAAA;IACnB,aAAa,IAAI,IAAI,CAAA;IACrB,UAAU,IAAI,IAAI,CAAA;IAClB,SAAS,IAAI,IAAI,CAAA;IACjB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAA;IAChC,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,sBAAsB,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvC,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,mBAAmB,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpC,SAAS,CAAC,I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StubParticipant } from "../Utils/group-stub-params.js";
|
|
3
|
-
function toContainImpl(actual, item) {
|
|
4
|
-
if (typeof actual === 'string') {
|
|
5
|
-
assert.ok(actual.includes(String(item)), `expected string to contain ${String(item)}`);
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
if (Array.isArray(actual)) {
|
|
9
|
-
assert.ok(actual.includes(item), `expected array to contain ${String(item)}`);
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
throw new TypeError('toContain requires a string or array');
|
|
13
|
-
}
|
|
14
|
-
function toHavePropertyImpl(actual, path) {
|
|
15
|
-
const parts = path.split('.');
|
|
16
|
-
let cur = actual;
|
|
17
|
-
for (const p of parts) {
|
|
18
|
-
if (cur == null || typeof cur !== 'object' || !(p in cur)) {
|
|
19
|
-
assert.fail(`expected property at path "${path}"`);
|
|
20
|
-
}
|
|
21
|
-
cur = cur[p];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function toMatchObjectImpl(actual, expected) {
|
|
25
|
-
if (actual == null || typeof actual !== 'object') {
|
|
26
|
-
assert.fail(`expected object, got ${typeof actual}`);
|
|
27
|
-
}
|
|
28
|
-
if (expected == null || typeof expected !== 'object') {
|
|
29
|
-
assert.fail(`toMatchObject expects an object, got ${typeof expected}`);
|
|
30
|
-
}
|
|
31
|
-
for (const [key, expVal] of Object.entries(expected)) {
|
|
32
|
-
// Catches the case where `expVal === undefined` would otherwise let
|
|
33
|
-
// a missing key on `actual` pass silently.
|
|
34
|
-
assert.ok(Object.prototype.hasOwnProperty.call(actual, key), `missing property "${key}"`);
|
|
35
|
-
const actVal = actual[key];
|
|
36
|
-
if (expVal !== null && typeof expVal === 'object' && !Array.isArray(expVal)) {
|
|
37
|
-
toMatchObjectImpl(actVal, expVal);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
assert.deepStrictEqual(actVal, expVal, `mismatch at "${key}"`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Assert a `messageStubParameters[i]` raw string decodes to a participant
|
|
46
|
-
* payload that contains AT LEAST the expected fields. Extra fields on the
|
|
47
|
-
* decoded payload (e.g. a `phoneNumber` the bridge happens to include) do
|
|
48
|
-
* NOT fail the assert — callers state only what they care about. Fails
|
|
49
|
-
* loudly when the string is missing, not valid JSON, or has the wrong
|
|
50
|
-
* shape, which catches regressions where a raw JID leaks back in.
|
|
51
|
-
*/
|
|
52
|
-
export function expectStubParticipant(raw, expected) {
|
|
53
|
-
const decoded = decodeStubParticipant(raw);
|
|
54
|
-
assert.ok(decoded !== null, `expected stub participant payload, got ${JSON.stringify(raw)}`);
|
|
55
|
-
assert.strictEqual(decoded.id, expected.id, 'stub participant id mismatch');
|
|
56
|
-
if (expected.phoneNumber !== undefined) {
|
|
57
|
-
assert.strictEqual(decoded.phoneNumber, expected.phoneNumber, 'stub participant phoneNumber mismatch');
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
export function expect(actual) {
|
|
61
|
-
const throwsFn = actual;
|
|
62
|
-
const maybePromise = actual;
|
|
63
|
-
return {
|
|
64
|
-
toBe: e => assert.strictEqual(actual, e),
|
|
65
|
-
toEqual: e => assert.deepStrictEqual(actual, e),
|
|
66
|
-
toBeDefined: () => assert.notStrictEqual(actual, undefined),
|
|
67
|
-
toBeUndefined: () => assert.strictEqual(actual, undefined),
|
|
68
|
-
toBeTruthy: () => assert.ok(actual),
|
|
69
|
-
toBeFalsy: () => assert.ok(!actual),
|
|
70
|
-
toBeInstanceOf: c => assert.ok(actual instanceof c),
|
|
71
|
-
toBeGreaterThan: n => assert.ok(actual > n, `expected ${String(actual)} > ${n}`),
|
|
72
|
-
toBeGreaterThanOrEqual: n => assert.ok(actual >= n, `expected ${String(actual)} >= ${n}`),
|
|
73
|
-
toBeLessThan: n => assert.ok(actual < n, `expected ${String(actual)} < ${n}`),
|
|
74
|
-
toBeLessThanOrEqual: n => assert.ok(actual <= n, `expected ${String(actual)} <= ${n}`),
|
|
75
|
-
toContain: item => toContainImpl(actual, item),
|
|
76
|
-
toHaveLength: n => assert.strictEqual(actual.length, n),
|
|
77
|
-
toHaveProperty: p => toHavePropertyImpl(actual, p),
|
|
78
|
-
toMatchObject: e => toMatchObjectImpl(actual, e),
|
|
79
|
-
toThrow: m => assert.throws(throwsFn, m),
|
|
80
|
-
not: {
|
|
81
|
-
toBe: e => assert.notStrictEqual(actual, e),
|
|
82
|
-
toThrow: m => assert.doesNotThrow(throwsFn, m)
|
|
83
|
-
},
|
|
84
|
-
resolves: {
|
|
85
|
-
toBe: async (e) => assert.strictEqual(await maybePromise, e),
|
|
86
|
-
toBeUndefined: async () => assert.strictEqual(await maybePromise, undefined),
|
|
87
|
-
toThrow: async (m) => assert.rejects(maybePromise, m)
|
|
88
|
-
},
|
|
89
|
-
rejects: {
|
|
90
|
-
toBe: async () => {
|
|
91
|
-
throw new Error('rejects.toBe is not supported; use rejects.toThrow');
|
|
92
|
-
},
|
|
93
|
-
toBeUndefined: async () => {
|
|
94
|
-
throw new Error('rejects.toBeUndefined is not supported');
|
|
95
|
-
},
|
|
96
|
-
toThrow: async (m) => assert.rejects(maybePromise, m)
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=expect.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expect.js","sourceRoot":"","sources":["../../src/__tests__/expect.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAA;AACvC,OAAO,EAAE,qBAAqB,EAA+B,MAAM,+BAA+B,CAAA;AAqClG,SAAS,aAAa,CAAC,MAAe,EAAE,IAAa;IACpD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAChC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,8BAA8B,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,C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