@open-e2ee/signal-protocol-sdk 14.1.0 → 14.3.0
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/ADAPTERS.md +5 -5
- package/CHANGELOG.md +505 -0
- package/README.md +24 -19
- package/SECURITY.md +2 -2
- package/TROUBLESHOOTING.md +1 -1
- package/client/README.md +30 -18
- package/device/README.md +6 -5
- package/dist/client/client.d.ts +49 -38
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +231 -155
- package/dist/client/client.js.map +1 -1
- package/dist/client/compose.d.ts +4 -2
- package/dist/client/compose.d.ts.map +1 -1
- package/dist/client/compose.js +6 -1
- package/dist/client/compose.js.map +1 -1
- package/dist/client/config.d.ts +15 -6
- package/dist/client/config.d.ts.map +1 -1
- package/dist/client/config.js.map +1 -1
- package/dist/client/content-adapter.d.ts +9 -0
- package/dist/client/content-adapter.d.ts.map +1 -1
- package/dist/client/content-adapter.js +6 -0
- package/dist/client/content-adapter.js.map +1 -1
- package/dist/client/delivery-status.d.ts +2 -2
- package/dist/client/delivery-status.d.ts.map +1 -1
- package/dist/client/delivery-status.js +10 -4
- package/dist/client/delivery-status.js.map +1 -1
- package/dist/client/device-set-reconciliation.d.ts +23 -15
- package/dist/client/device-set-reconciliation.d.ts.map +1 -1
- package/dist/client/device-set-reconciliation.js +16 -13
- package/dist/client/device-set-reconciliation.js.map +1 -1
- package/dist/client/event-hooks.d.ts +15 -5
- package/dist/client/event-hooks.d.ts.map +1 -1
- package/dist/client/event-hooks.js +39 -4
- package/dist/client/event-hooks.js.map +1 -1
- package/dist/client/group-device-set.d.ts +1 -1
- package/dist/client/group-device-set.d.ts.map +1 -1
- package/dist/client/group-key-sync.js +1 -1
- package/dist/client/group-key-sync.js.map +1 -1
- package/dist/client/group-outbox.d.ts +7 -7
- package/dist/client/group-outbox.d.ts.map +1 -1
- package/dist/client/group-outbox.js +24 -24
- package/dist/client/group-outbox.js.map +1 -1
- package/dist/client/group-sealed-sender.d.ts +1 -1
- package/dist/client/group-sealed-sender.d.ts.map +1 -1
- package/dist/client/group-sender-key-operations.js +1 -1
- package/dist/client/group-sender-key-operations.js.map +1 -1
- package/dist/client/headless.d.ts +6 -6
- package/dist/client/headless.d.ts.map +1 -1
- package/dist/client/headless.js +7 -7
- package/dist/client/headless.js.map +1 -1
- package/dist/client/hosted-anonymous-delivery.d.ts +6 -6
- package/dist/client/hosted-anonymous-delivery.d.ts.map +1 -1
- package/dist/client/hosted-anonymous-delivery.js +17 -17
- package/dist/client/hosted-anonymous-delivery.js.map +1 -1
- package/dist/client/hosted-assertion-id.d.ts +1 -1
- package/dist/client/hosted-assertion-id.d.ts.map +1 -1
- package/dist/client/hosted-assertion-id.js +1 -1
- package/dist/client/hosted-assertion-id.js.map +1 -1
- package/dist/client/hosted-connection.d.ts +5 -5
- package/dist/client/hosted-connection.d.ts.map +1 -1
- package/dist/client/hosted-connection.js +32 -32
- package/dist/client/hosted-connection.js.map +1 -1
- package/dist/client/hosted-device-link-transport.d.ts +2 -2
- package/dist/client/hosted-device-link-transport.d.ts.map +1 -1
- package/dist/client/hosted-device-link-transport.js +1 -1
- package/dist/client/hosted-device-link-transport.js.map +1 -1
- package/dist/client/hosted-device-link.d.ts +5 -1
- package/dist/client/hosted-device-link.d.ts.map +1 -1
- package/dist/client/hosted-device-link.js +7 -4
- package/dist/client/hosted-device-link.js.map +1 -1
- package/dist/client/hosted-device-standing.d.ts +13 -5
- package/dist/client/hosted-device-standing.d.ts.map +1 -1
- package/dist/client/hosted-device-standing.js +11 -6
- package/dist/client/hosted-device-standing.js.map +1 -1
- package/dist/client/hosted-group-authority.d.ts +2 -2
- package/dist/client/hosted-group-authority.d.ts.map +1 -1
- package/dist/client/hosted-group-authority.js +8 -8
- package/dist/client/hosted-group-authority.js.map +1 -1
- package/dist/client/hosted-groups.d.ts +4 -4
- package/dist/client/hosted-groups.d.ts.map +1 -1
- package/dist/client/hosted-groups.js +8 -8
- package/dist/client/hosted-groups.js.map +1 -1
- package/dist/client/hosted-http-error.d.ts +7 -3
- package/dist/client/hosted-http-error.d.ts.map +1 -1
- package/dist/client/hosted-http-error.js +6 -3
- package/dist/client/hosted-http-error.js.map +1 -1
- package/dist/client/hosted-mailbox-subscription.d.ts +10 -10
- package/dist/client/hosted-mailbox-subscription.d.ts.map +1 -1
- package/dist/client/hosted-mailbox-subscription.js +17 -17
- package/dist/client/hosted-mailbox-subscription.js.map +1 -1
- package/dist/client/hosted-prekey-publication.d.ts +9 -9
- package/dist/client/hosted-prekey-publication.d.ts.map +1 -1
- package/dist/client/hosted-prekey-publication.js.map +1 -1
- package/dist/client/hosted-presence-frames.d.ts +62 -38
- package/dist/client/hosted-presence-frames.d.ts.map +1 -1
- package/dist/client/hosted-presence-frames.js +4 -2
- package/dist/client/hosted-presence-frames.js.map +1 -1
- package/dist/client/hosted-presence.d.ts +22 -14
- package/dist/client/hosted-presence.d.ts.map +1 -1
- package/dist/client/hosted-presence.js +26 -17
- package/dist/client/hosted-presence.js.map +1 -1
- package/dist/client/hosted-profile-keys.d.ts +3 -1
- package/dist/client/hosted-profile-keys.d.ts.map +1 -1
- package/dist/client/hosted-profile-keys.js +19 -15
- package/dist/client/hosted-profile-keys.js.map +1 -1
- package/dist/client/hosted-push.d.ts +38 -16
- package/dist/client/hosted-push.d.ts.map +1 -1
- package/dist/client/hosted-push.js +11 -5
- package/dist/client/hosted-push.js.map +1 -1
- package/dist/client/hosted-resume-error.d.ts +21 -9
- package/dist/client/hosted-resume-error.d.ts.map +1 -1
- package/dist/client/hosted-resume-error.js +4 -1
- package/dist/client/hosted-resume-error.js.map +1 -1
- package/dist/client/hosted-resume.d.ts +3 -3
- package/dist/client/hosted-resume.d.ts.map +1 -1
- package/dist/client/hosted-resume.js +12 -12
- package/dist/client/hosted-resume.js.map +1 -1
- package/dist/client/hosted-sandbox-identity.d.ts +32 -18
- package/dist/client/hosted-sandbox-identity.d.ts.map +1 -1
- package/dist/client/hosted-sandbox-identity.js +46 -27
- package/dist/client/hosted-sandbox-identity.js.map +1 -1
- package/dist/client/hosted-store-records.d.ts +46 -0
- package/dist/client/hosted-store-records.d.ts.map +1 -0
- package/dist/client/hosted-store-records.js +32 -0
- package/dist/client/hosted-store-records.js.map +1 -0
- package/dist/client/hosted-transport.d.ts +41 -33
- package/dist/client/hosted-transport.d.ts.map +1 -1
- package/dist/client/hosted-transport.js +146 -101
- package/dist/client/hosted-transport.js.map +1 -1
- package/dist/client/hosted-trust.d.ts +1 -1
- package/dist/client/hosted-trust.d.ts.map +1 -1
- package/dist/client/hosted-trust.js +1 -1
- package/dist/client/hosted-trust.js.map +1 -1
- package/dist/client/hosted.d.ts +138 -72
- package/dist/client/hosted.d.ts.map +1 -1
- package/dist/client/hosted.js +102 -60
- package/dist/client/hosted.js.map +1 -1
- package/dist/client/index.d.ts +4 -4
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +4 -4
- package/dist/client/index.js.map +1 -1
- package/dist/client/key-rotation-core.d.ts +4 -4
- package/dist/client/key-rotation-core.d.ts.map +1 -1
- package/dist/client/key-rotation-core.js +8 -8
- package/dist/client/key-rotation-core.js.map +1 -1
- package/dist/client/key-rotation.js +2 -2
- package/dist/client/key-rotation.js.map +1 -1
- package/dist/client/messages.d.ts +3 -3
- package/dist/client/messages.d.ts.map +1 -1
- package/dist/client/messages.js +18 -18
- package/dist/client/messages.js.map +1 -1
- package/dist/client/one-time-prekey-refill.d.ts +1 -1
- package/dist/client/one-time-prekey-refill.d.ts.map +1 -1
- package/dist/client/prekeys.js +17 -17
- package/dist/client/prekeys.js.map +1 -1
- package/dist/client/receive-queue.d.ts +4 -4
- package/dist/client/receive-queue.d.ts.map +1 -1
- package/dist/client/receive-queue.js +29 -29
- package/dist/client/receive-queue.js.map +1 -1
- package/dist/client/receive-work-seed.d.ts +6 -2
- package/dist/client/receive-work-seed.d.ts.map +1 -1
- package/dist/client/receive-work-seed.js.map +1 -1
- package/dist/client/recovery-driver.js +7 -7
- package/dist/client/recovery-driver.js.map +1 -1
- package/dist/client/retry-request-envelope.d.ts +3 -3
- package/dist/client/retry-request-envelope.d.ts.map +1 -1
- package/dist/client/retry-request-envelope.js +10 -10
- package/dist/client/retry-request-envelope.js.map +1 -1
- package/dist/client/retry-request-lifecycle.d.ts +1 -1
- package/dist/client/retry-request-lifecycle.d.ts.map +1 -1
- package/dist/client/retry-request-lifecycle.js +8 -8
- package/dist/client/retry-request-lifecycle.js.map +1 -1
- package/dist/client/retry-terminal-recovery.js +2 -2
- package/dist/client/retry-terminal-recovery.js.map +1 -1
- package/dist/client/retry.js +13 -13
- package/dist/client/retry.js.map +1 -1
- package/dist/client/sealed-sender.d.ts +13 -4
- package/dist/client/sealed-sender.d.ts.map +1 -1
- package/dist/client/sealed-sender.js +27 -15
- package/dist/client/sealed-sender.js.map +1 -1
- package/dist/client/send-deadline.d.ts +6 -6
- package/dist/client/send-deadline.d.ts.map +1 -1
- package/dist/client/send-deadline.js +37 -23
- package/dist/client/send-deadline.js.map +1 -1
- package/dist/client/send-intent-driver.js +9 -9
- package/dist/client/send-intent-driver.js.map +1 -1
- package/dist/client/sessions.js +11 -11
- package/dist/client/sessions.js.map +1 -1
- package/dist/client/{relay-acceptance.d.ts → signal-relay-acceptance.d.ts} +9 -9
- package/dist/client/signal-relay-acceptance.d.ts.map +1 -0
- package/dist/client/{relay-acceptance.js → signal-relay-acceptance.js} +7 -7
- package/dist/client/signal-relay-acceptance.js.map +1 -0
- package/dist/client/{relay-device-refusal.d.ts → signal-relay-device-refusal.d.ts} +7 -7
- package/dist/client/signal-relay-device-refusal.d.ts.map +1 -0
- package/dist/client/{relay-device-refusal.js → signal-relay-device-refusal.js} +9 -9
- package/dist/client/signal-relay-device-refusal.js.map +1 -0
- package/dist/client/{relay-lifecycle.d.ts → signal-relay-lifecycle.d.ts} +18 -9
- package/dist/client/signal-relay-lifecycle.d.ts.map +1 -0
- package/dist/client/{relay-lifecycle.js → signal-relay-lifecycle.js} +16 -7
- package/dist/client/signal-relay-lifecycle.js.map +1 -0
- package/dist/client/{relay-period-close.d.ts → signal-relay-period-close.d.ts} +1 -1
- package/dist/client/signal-relay-period-close.d.ts.map +1 -0
- package/dist/client/{relay-period-close.js → signal-relay-period-close.js} +1 -1
- package/dist/client/signal-relay-period-close.js.map +1 -0
- package/dist/client/{relay-protocol.d.ts → signal-relay-protocol.d.ts} +12 -8
- package/dist/client/signal-relay-protocol.d.ts.map +1 -0
- package/dist/client/{relay-protocol.js → signal-relay-protocol.js} +13 -10
- package/dist/client/signal-relay-protocol.js.map +1 -0
- package/dist/client/{relay-receipt-intake.d.ts → signal-relay-receipt-intake.d.ts} +12 -12
- package/dist/client/signal-relay-receipt-intake.d.ts.map +1 -0
- package/dist/client/{relay-receipt-intake.js → signal-relay-receipt-intake.js} +9 -9
- package/dist/client/signal-relay-receipt-intake.js.map +1 -0
- package/dist/client/{relay-receipt-join.d.ts → signal-relay-receipt-join.d.ts} +8 -8
- package/dist/client/signal-relay-receipt-join.d.ts.map +1 -0
- package/dist/client/{relay-receipt-join.js → signal-relay-receipt-join.js} +11 -11
- package/dist/client/signal-relay-receipt-join.js.map +1 -0
- package/dist/client/{relay-request-deadline.d.ts → signal-relay-request-deadline.d.ts} +3 -3
- package/dist/client/signal-relay-request-deadline.d.ts.map +1 -0
- package/dist/client/{relay-request-deadline.js → signal-relay-request-deadline.js} +4 -4
- package/dist/client/signal-relay-request-deadline.js.map +1 -0
- package/dist/client/{relay-sealed-route.d.ts → signal-relay-sealed-route.d.ts} +1 -1
- package/dist/client/signal-relay-sealed-route.d.ts.map +1 -0
- package/dist/client/{relay-sealed-route.js → signal-relay-sealed-route.js} +1 -1
- package/dist/client/signal-relay-sealed-route.js.map +1 -0
- package/dist/client/{relay-subscription.d.ts → signal-relay-subscription.d.ts} +12 -12
- package/dist/client/signal-relay-subscription.d.ts.map +1 -0
- package/dist/client/{relay-subscription.js → signal-relay-subscription.js} +23 -23
- package/dist/client/signal-relay-subscription.js.map +1 -0
- package/dist/client/{relay-work.d.ts → signal-relay-work.d.ts} +7 -7
- package/dist/client/signal-relay-work.d.ts.map +1 -0
- package/dist/client/{relay-work.js → signal-relay-work.js} +13 -13
- package/dist/client/signal-relay-work.js.map +1 -0
- package/dist/client/signal-service-cipher.d.ts +10 -8
- package/dist/client/signal-service-cipher.d.ts.map +1 -1
- package/dist/client/signal-service-cipher.js +102 -97
- package/dist/client/signal-service-cipher.js.map +1 -1
- package/dist/client/state.d.ts +4 -4
- package/dist/client/state.d.ts.map +1 -1
- package/dist/client/state.js +3 -3
- package/dist/client/state.js.map +1 -1
- package/dist/client/types.d.ts +13 -4
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/types.js.map +1 -1
- package/dist/device/connection.d.ts +10 -4
- package/dist/device/connection.d.ts.map +1 -1
- package/dist/device/connection.js +8 -3
- package/dist/device/connection.js.map +1 -1
- package/dist/device/index.d.ts +2 -2
- package/dist/device/index.d.ts.map +1 -1
- package/dist/device/index.js +1 -1
- package/dist/device/index.js.map +1 -1
- package/dist/device/types.d.ts +3 -1
- package/dist/device/types.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +2 -2
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/use-signal-relay-connection-state.d.ts +39 -0
- package/dist/hooks/use-signal-relay-connection-state.d.ts.map +1 -0
- package/dist/hooks/use-signal-relay-connection-state.js +45 -0
- package/dist/hooks/use-signal-relay-connection-state.js.map +1 -0
- package/dist/hooks/use-signal-relay-lifecycle.d.ts +43 -0
- package/dist/hooks/use-signal-relay-lifecycle.d.ts.map +1 -0
- package/dist/hooks/use-signal-relay-lifecycle.js +38 -0
- package/dist/hooks/use-signal-relay-lifecycle.js.map +1 -0
- package/dist/index.d.ts +16 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/internal/groups/authority-certificate.d.ts +8 -1
- package/dist/internal/groups/authority-certificate.d.ts.map +1 -1
- package/dist/internal/groups/authority-certificate.js +29 -6
- package/dist/internal/groups/authority-certificate.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/certificate.js +2 -2
- package/dist/internal/protocol/sealed-sender/certificate.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/proto/index.d.ts +1 -1
- package/dist/internal/protocol/sealed-sender/proto/index.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/proto/index.js +5 -5
- package/dist/internal/protocol/sealed-sender/proto/index.js.map +1 -1
- package/dist/internal/sesame/device-registry.d.ts +13 -13
- package/dist/internal/sesame/device-registry.d.ts.map +1 -1
- package/dist/internal/sesame/device-registry.js +20 -20
- package/dist/internal/sesame/device-registry.js.map +1 -1
- package/dist/local/store/receive-work.d.ts +29 -0
- package/dist/local/store/receive-work.d.ts.map +1 -1
- package/dist/local/store/receive-work.js +58 -1
- package/dist/local/store/receive-work.js.map +1 -1
- package/dist/local/store/received-content.d.ts +1 -1
- package/dist/local/store/received-content.d.ts.map +1 -1
- package/dist/local/store/reliability.d.ts +11 -3
- package/dist/local/store/reliability.d.ts.map +1 -1
- package/dist/local/store/reliability.js +4 -0
- package/dist/local/store/reliability.js.map +1 -1
- package/dist/local/store/sqlite/key-storage/index.d.ts +3 -9
- package/dist/local/store/sqlite/key-storage/index.d.ts.map +1 -1
- package/dist/local/store/sqlite/key-storage/index.js.map +1 -1
- package/dist/local/store/sqlite/key-storage/signed-prekeys.d.ts +1 -7
- package/dist/local/store/sqlite/key-storage/signed-prekeys.d.ts.map +1 -1
- package/dist/local/store/sqlite/key-storage/signed-prekeys.js.map +1 -1
- package/dist/local/store/sqlite/models/kyber-prekey.d.ts +4 -9
- package/dist/local/store/sqlite/models/kyber-prekey.d.ts.map +1 -1
- package/dist/local/store/sqlite/models/kyber-prekey.js +4 -1
- package/dist/local/store/sqlite/models/kyber-prekey.js.map +1 -1
- package/dist/local/store/sqlite/store.d.ts.map +1 -1
- package/dist/local/store/sqlite/store.js +1 -2
- package/dist/local/store/sqlite/store.js.map +1 -1
- package/dist/remote/signal-relay/connection-state.d.ts +16 -0
- package/dist/remote/signal-relay/connection-state.d.ts.map +1 -0
- package/dist/remote/{relay → signal-relay}/connection-state.js +1 -1
- package/dist/remote/signal-relay/connection-state.js.map +1 -0
- package/dist/remote/{relay → signal-relay}/device-set.d.ts +3 -3
- package/dist/remote/signal-relay/device-set.d.ts.map +1 -0
- package/dist/remote/{relay → signal-relay}/device-set.js +7 -7
- package/dist/remote/signal-relay/device-set.js.map +1 -0
- package/dist/remote/{relay → signal-relay}/index.d.ts +3 -3
- package/dist/remote/signal-relay/index.d.ts.map +1 -0
- package/dist/remote/{relay → signal-relay}/index.js +2 -2
- package/dist/remote/signal-relay/index.js.map +1 -0
- package/dist/remote/{relay → signal-relay}/request-admission.d.ts +2 -2
- package/dist/remote/signal-relay/request-admission.d.ts.map +1 -0
- package/dist/remote/{relay → signal-relay}/request-admission.js +5 -5
- package/dist/remote/signal-relay/request-admission.js.map +1 -0
- package/dist/remote/{relay → signal-relay}/types.d.ts +29 -10
- package/dist/remote/signal-relay/types.d.ts.map +1 -0
- package/dist/remote/{relay → signal-relay}/types.js +1 -1
- package/dist/remote/signal-relay/types.js.map +1 -0
- package/dist/safety/core.d.ts +1 -1
- package/dist/safety/core.js +1 -1
- package/dist/types/api.d.ts +38 -15
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/errors.d.ts +62 -7
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +68 -8
- package/dist/types/errors.js.map +1 -1
- package/dist/types/renamed-member.d.ts +48 -0
- package/dist/types/renamed-member.d.ts.map +1 -0
- package/dist/types/renamed-member.js +78 -0
- package/dist/types/renamed-member.js.map +1 -0
- package/dist/utils/bounded-fan-out.d.ts +2 -2
- package/dist/utils/bounded-fan-out.d.ts.map +1 -1
- package/dist/utils/bounded-fan-out.js +2 -2
- package/dist/utils/bounded-fan-out.js.map +1 -1
- package/dist/utils/retry.d.ts +3 -3
- package/dist/utils/retry.d.ts.map +1 -1
- package/dist/utils/retry.js +4 -3
- package/dist/utils/retry.js.map +1 -1
- package/docs/ASSURANCE.md +9 -9
- package/docs/CLIENT_COMPOSITION.md +7 -5
- package/docs/DEVIATIONS.md +8 -5
- package/docs/ERROR_HANDLING.md +21 -21
- package/docs/GETTING_STARTED.md +22 -15
- package/docs/INTERFACES.md +3 -3
- package/docs/PACKAGE_SURFACE.md +14 -4
- package/docs/RECIPES.md +271 -11
- package/hooks/README.md +11 -11
- package/local/store/key-value/README.md +1 -1
- package/local/store/web-sqlite/README.md +1 -1
- package/package.json +16 -6
- package/remote/README.md +3 -3
- package/remote/{relay → signal-relay}/README.md +15 -6
- package/dist/client/relay-acceptance.d.ts.map +0 -1
- package/dist/client/relay-acceptance.js.map +0 -1
- package/dist/client/relay-device-refusal.d.ts.map +0 -1
- package/dist/client/relay-device-refusal.js.map +0 -1
- package/dist/client/relay-lifecycle.d.ts.map +0 -1
- package/dist/client/relay-lifecycle.js.map +0 -1
- package/dist/client/relay-period-close.d.ts.map +0 -1
- package/dist/client/relay-period-close.js.map +0 -1
- package/dist/client/relay-protocol.d.ts.map +0 -1
- package/dist/client/relay-protocol.js.map +0 -1
- package/dist/client/relay-receipt-intake.d.ts.map +0 -1
- package/dist/client/relay-receipt-intake.js.map +0 -1
- package/dist/client/relay-receipt-join.d.ts.map +0 -1
- package/dist/client/relay-receipt-join.js.map +0 -1
- package/dist/client/relay-request-deadline.d.ts.map +0 -1
- package/dist/client/relay-request-deadline.js.map +0 -1
- package/dist/client/relay-sealed-route.d.ts.map +0 -1
- package/dist/client/relay-sealed-route.js.map +0 -1
- package/dist/client/relay-subscription.d.ts.map +0 -1
- package/dist/client/relay-subscription.js.map +0 -1
- package/dist/client/relay-work.d.ts.map +0 -1
- package/dist/client/relay-work.js.map +0 -1
- package/dist/hooks/use-relay-connection-state.d.ts +0 -32
- package/dist/hooks/use-relay-connection-state.d.ts.map +0 -1
- package/dist/hooks/use-relay-connection-state.js +0 -31
- package/dist/hooks/use-relay-connection-state.js.map +0 -1
- package/dist/hooks/use-relay-lifecycle.d.ts +0 -36
- package/dist/hooks/use-relay-lifecycle.d.ts.map +0 -1
- package/dist/hooks/use-relay-lifecycle.js +0 -35
- package/dist/hooks/use-relay-lifecycle.js.map +0 -1
- package/dist/remote/relay/connection-state.d.ts +0 -16
- package/dist/remote/relay/connection-state.d.ts.map +0 -1
- package/dist/remote/relay/connection-state.js.map +0 -1
- package/dist/remote/relay/device-set.d.ts.map +0 -1
- package/dist/remote/relay/device-set.js.map +0 -1
- package/dist/remote/relay/index.d.ts.map +0 -1
- package/dist/remote/relay/index.js.map +0 -1
- package/dist/remote/relay/request-admission.d.ts.map +0 -1
- package/dist/remote/relay/request-admission.js.map +0 -1
- package/dist/remote/relay/types.d.ts.map +0 -1
- package/dist/remote/relay/types.js.map +0 -1
|
@@ -33,17 +33,18 @@ import { createDefaultSignalProtocolContentAdapter, } from './content-adapter.js
|
|
|
33
33
|
import * as CryptoUtils from '../internal/crypto/index.js';
|
|
34
34
|
import { withAcceptedSyncDevices, } from '../internal/groups/key-sync-ledger.js';
|
|
35
35
|
import { completeOutgoingMessageIntent, completeOutgoingSyncPhase, endOutgoingMessageIntent, getOutgoingMessageIntent, markOutgoingDeviceSetUnresolved, outgoingDestinationProgressKey, outgoingMessageDeadlineAt, outgoingMessageIntentResult, recordOutgoingDestinationProgress, repairOutgoingDeviceSet, getRetryResend, getSentClientMessageIds, reconcileOutgoingDirectDeviceMessages, reconcileOutgoingSyncMessages, replaceOutgoingDirectDeviceMessage, replaceOutgoingGroupPreMessages, retryAttemptClientMessageId, retryNullMessageClientMessageId, retryRequestAttempt, retryResendClientMessageId, storeOutgoingMessageIntent, storeRetryResend, withOutgoingMessageIntentLock, addOutgoingManualResend, endOutgoingManualResend, isOpenManualResend, manualResendMessageId, OUTGOING_POSTING_WINDOW_MS, outgoingManualResends, recordOutgoingManualResendProgress, RELIABILITY_RECORD_TTL_MS, } from '../local/store/reliability.js';
|
|
36
|
+
import { isSignalProtocolRelayOrigin } from '../local/store/receive-work.js';
|
|
36
37
|
import { FanOutError, firstItemError } from '../utils/bounded-fan-out.js';
|
|
37
38
|
import { withRetry } from '../utils/retry.js';
|
|
38
|
-
import { acquireUntilStopped,
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
39
|
+
import { acquireUntilStopped, createSignalProtocolRelayFanOut, RelayWorkStopped, signalRelaySendsSealedUnderItsBound, rethrowSignalProtocolRelayWorkStopped, } from './signal-relay-work.js';
|
|
40
|
+
import { markSignalProtocolRelayDeviceRefusal, refusesRemovedDevices, signalRelayDeviceRefusal, } from './signal-relay-device-refusal.js';
|
|
41
|
+
import { aggregateSignalProtocolRelayAcceptance, isConflictAcceptance, signalRelayHoldsMessageId, signalRelayOperationRefusal, sendResultAcceptance, } from './signal-relay-acceptance.js';
|
|
41
42
|
import { attachSendDeadline, isPostingDeadlineReached, provenRefused, recordDeadlineStop, SEND_END_REPORT, manualResendIntent, SendCallEvidence, sendDestinations, storedAcceptance, storedSendEndError, } from './send-deadline.js';
|
|
42
43
|
import { callerBytesMatch } from './send-intent-driver.js';
|
|
43
|
-
import { admitRequestsFor, followedRepeatedRequest, markAfterRepeatedRequest, } from '../remote/relay/request-admission.js';
|
|
44
|
-
import { forDirectSealedRoute, usedGroupRouteFallback } from './relay-sealed-route.js';
|
|
45
|
-
import { comparesDeviceSets, markDeviceSetRefusal } from '../remote/relay/device-set.js';
|
|
46
|
-
import { DeviceSetReconciliationError,
|
|
44
|
+
import { admitRequestsFor, followedRepeatedRequest, markAfterRepeatedRequest, } from '../remote/signal-relay/request-admission.js';
|
|
45
|
+
import { forDirectSealedRoute, usedGroupRouteFallback } from './signal-relay-sealed-route.js';
|
|
46
|
+
import { comparesDeviceSets, markDeviceSetRefusal } from '../remote/signal-relay/device-set.js';
|
|
47
|
+
import { DeviceSetReconciliationError, markSignalProtocolRelayProtocolError, runDeviceSetPhase, waitUnlessStopped, syncPostReceipts, uncheckedDeclaredPost, } from './device-set-reconciliation.js';
|
|
47
48
|
import { prepareGroupSharedMessage } from './group-sealed-sender.js';
|
|
48
49
|
import { attachFailedGroup } from './retry-terminal-recovery.js';
|
|
49
50
|
import { sendGroupWithExactOutbox, } from './group-outbox.js';
|
|
@@ -171,7 +172,7 @@ function manualResendResult(intent, resend, acceptances) {
|
|
|
171
172
|
messageId: first?.messageId ?? resend.manualMessageId,
|
|
172
173
|
timestamp: first?.serverTimestamp ?? intent.clientTimestamp,
|
|
173
174
|
recipientDeviceCount: resend.messages.length,
|
|
174
|
-
...
|
|
175
|
+
...aggregateSignalProtocolRelayAcceptance(acceptances),
|
|
175
176
|
...(intent.kind === 'group' && { groupId: intent.recipientId }),
|
|
176
177
|
};
|
|
177
178
|
}
|
|
@@ -342,11 +343,11 @@ class SealedSenderRecipientRejectedError extends Error {
|
|
|
342
343
|
function isConclusiveDeviceRejection(error) {
|
|
343
344
|
return (isStaleSessionError(error) ||
|
|
344
345
|
error instanceof SealedSenderRecipientRejectedError ||
|
|
345
|
-
|
|
346
|
+
signalRelayDeviceRefusal(error)?.code === 'STALE_DEVICE');
|
|
346
347
|
}
|
|
347
348
|
/** True when the relay refused this post because of the device that it names. */
|
|
348
349
|
function isRefusalOfDevice(error, message) {
|
|
349
|
-
const refusal =
|
|
350
|
+
const refusal = signalRelayDeviceRefusal(error);
|
|
350
351
|
return (refusal?.userId === message.recipientUserId && refusal.deviceId === message.recipientDeviceId);
|
|
351
352
|
}
|
|
352
353
|
/**
|
|
@@ -431,7 +432,7 @@ export class SignalProtocolServiceCipher {
|
|
|
431
432
|
sesameManager;
|
|
432
433
|
senderKeyManager;
|
|
433
434
|
storage;
|
|
434
|
-
|
|
435
|
+
signalProtocolRelay;
|
|
435
436
|
remoteObjectStore;
|
|
436
437
|
contentAdapter;
|
|
437
438
|
logger;
|
|
@@ -444,7 +445,7 @@ export class SignalProtocolServiceCipher {
|
|
|
444
445
|
sealedSenderProvider;
|
|
445
446
|
sealedSenderDeliveryMode = 'preferred';
|
|
446
447
|
sealedSenderIdentifiedFallback;
|
|
447
|
-
|
|
448
|
+
signalRelayProtocolErrorReporter;
|
|
448
449
|
ownDevicesFirstSeen;
|
|
449
450
|
groupKeySyncReceiver;
|
|
450
451
|
contactProfileStateStore;
|
|
@@ -455,13 +456,13 @@ export class SignalProtocolServiceCipher {
|
|
|
455
456
|
groupReceiveEvaluator;
|
|
456
457
|
groupSecretParamsProvider;
|
|
457
458
|
groupContextProvider;
|
|
458
|
-
constructor(userId, deviceId, sesameManager, senderKeyManager, storage,
|
|
459
|
+
constructor(userId, deviceId, sesameManager, senderKeyManager, storage, signalProtocolRelay, remoteObjectStore, contentAdapter, logger = defaultSignalProtocolLogger, fanOut = createSignalProtocolRelayFanOut()) {
|
|
459
460
|
this.userId = userId;
|
|
460
461
|
this.deviceId = deviceId;
|
|
461
462
|
this.sesameManager = sesameManager;
|
|
462
463
|
this.senderKeyManager = senderKeyManager;
|
|
463
464
|
this.storage = storage;
|
|
464
|
-
this.
|
|
465
|
+
this.signalProtocolRelay = signalProtocolRelay;
|
|
465
466
|
this.remoteObjectStore = remoteObjectStore;
|
|
466
467
|
this.contentAdapter = contentAdapter;
|
|
467
468
|
this.logger = logger;
|
|
@@ -509,8 +510,8 @@ export class SignalProtocolServiceCipher {
|
|
|
509
510
|
*/
|
|
510
511
|
async uploadSyncMessages(syncMessages, payloadBytes, timestamp, target) {
|
|
511
512
|
const stopSignal = target?.stopSignal;
|
|
512
|
-
const
|
|
513
|
-
if (!
|
|
513
|
+
const signalProtocolRelay = this.signalProtocolRelay;
|
|
514
|
+
if (!signalProtocolRelay || syncMessages.length === 0) {
|
|
514
515
|
return [];
|
|
515
516
|
}
|
|
516
517
|
const prepared = await Promise.all(syncMessages.map((message) => this.prepareStoredSyncMessage(message)));
|
|
@@ -532,7 +533,7 @@ export class SignalProtocolServiceCipher {
|
|
|
532
533
|
};
|
|
533
534
|
const posted = await this.sendPhase(prepared, async (message) => {
|
|
534
535
|
const control = stopSignal ? { stopSignal } : {};
|
|
535
|
-
if (!(await this.postSyncMessage(
|
|
536
|
+
if (!(await this.postSyncMessage(signalProtocolRelay, message, control, repair)))
|
|
536
537
|
return undefined;
|
|
537
538
|
const copy = replacements.get(message.recipientDeviceId) ?? message;
|
|
538
539
|
target?.accepted?.push(...acceptedSyncDevices([copy]));
|
|
@@ -580,10 +581,10 @@ export class SignalProtocolServiceCipher {
|
|
|
580
581
|
* fails or the rebuild gives the device no copy. The copy stays in the
|
|
581
582
|
* intent, so a replay posts it again.
|
|
582
583
|
*/
|
|
583
|
-
async postSyncMessage(
|
|
584
|
+
async postSyncMessage(signalProtocolRelay, message, control, repair, gate) {
|
|
584
585
|
const controlOf = (copy) => gate ? { ...control, beforeRequest: gate(copy.clientMessageId) } : control;
|
|
585
586
|
try {
|
|
586
|
-
return await this.postSyncCopy(
|
|
587
|
+
return await this.postSyncCopy(signalProtocolRelay, message, controlOf(message));
|
|
587
588
|
}
|
|
588
589
|
catch (error) {
|
|
589
590
|
if (!isConclusiveDeviceRejection(error))
|
|
@@ -598,7 +599,7 @@ export class SignalProtocolServiceCipher {
|
|
|
598
599
|
return undefined;
|
|
599
600
|
if (replacement) {
|
|
600
601
|
try {
|
|
601
|
-
return await this.postSyncCopy(
|
|
602
|
+
return await this.postSyncCopy(signalProtocolRelay, replacement, controlOf(replacement));
|
|
602
603
|
}
|
|
603
604
|
catch (error) {
|
|
604
605
|
if (!isConclusiveDeviceRejection(error))
|
|
@@ -659,20 +660,20 @@ export class SignalProtocolServiceCipher {
|
|
|
659
660
|
*
|
|
660
661
|
* @returns The relay receipt of the post
|
|
661
662
|
*/
|
|
662
|
-
async postSyncCopy(
|
|
663
|
+
async postSyncCopy(signalProtocolRelay, message, control) {
|
|
663
664
|
// The transport gates a repeat by the ID that the posted envelope carries.
|
|
664
665
|
const release = control.beforeRequest && message.clientMessageId !== undefined
|
|
665
|
-
? admitRequestsFor(
|
|
666
|
+
? admitRequestsFor(signalProtocolRelay, message.clientMessageId, control.beforeRequest)
|
|
666
667
|
: undefined;
|
|
667
668
|
try {
|
|
668
|
-
return await this.postSyncCopyRequest(
|
|
669
|
+
return await this.postSyncCopyRequest(signalProtocolRelay, message, control);
|
|
669
670
|
}
|
|
670
671
|
finally {
|
|
671
672
|
release?.();
|
|
672
673
|
}
|
|
673
674
|
}
|
|
674
|
-
postSyncCopyRequest(
|
|
675
|
-
return this.
|
|
675
|
+
postSyncCopyRequest(signalProtocolRelay, message, control) {
|
|
676
|
+
return this.postToSignalProtocolRelay(() => signalProtocolRelay.send({
|
|
676
677
|
targetUserId: message.recipientUserId,
|
|
677
678
|
targetDeviceId: message.recipientDeviceId,
|
|
678
679
|
senderUserId: this.userId,
|
|
@@ -725,14 +726,14 @@ export class SignalProtocolServiceCipher {
|
|
|
725
726
|
* bound. An adapter that bounds its own sealed-sender posts takes a slot of
|
|
726
727
|
* the same bound, so its sealed post runs without one here.
|
|
727
728
|
*/
|
|
728
|
-
|
|
729
|
+
postToSignalProtocolRelay(send, sealed, control) {
|
|
729
730
|
const post = async () => {
|
|
730
731
|
control.admit?.();
|
|
731
732
|
await control.beforeRequest?.();
|
|
732
733
|
control.onRequest?.();
|
|
733
734
|
return send();
|
|
734
735
|
};
|
|
735
|
-
if (sealed &&
|
|
736
|
+
if (sealed && signalRelaySendsSealedUnderItsBound(this.signalProtocolRelay)) {
|
|
736
737
|
if (control.stopSignal?.aborted)
|
|
737
738
|
return Promise.reject(new RelayWorkStopped());
|
|
738
739
|
return new Promise((resolve) => resolve(post()));
|
|
@@ -745,7 +746,7 @@ export class SignalProtocolServiceCipher {
|
|
|
745
746
|
* checks it first, as a new send checks its timestamp.
|
|
746
747
|
*/
|
|
747
748
|
async sendSyncPayloadToLocalOtherDevices(payloadBytes, timestamp, target) {
|
|
748
|
-
if (!this.
|
|
749
|
+
if (!this.signalProtocolRelay) {
|
|
749
750
|
return [];
|
|
750
751
|
}
|
|
751
752
|
if (this.declaresDeviceSets()) {
|
|
@@ -887,7 +888,11 @@ export class SignalProtocolServiceCipher {
|
|
|
887
888
|
* send result, so the reporter gives its error to the app.
|
|
888
889
|
*/
|
|
889
890
|
setRelayProtocolErrorReporter(report) {
|
|
890
|
-
this.
|
|
891
|
+
this.setSignalProtocolRelayProtocolErrorReporter(report);
|
|
892
|
+
}
|
|
893
|
+
/** @deprecated Use `setRelayProtocolErrorReporter`. SDK 15.0.0 removes this name. */
|
|
894
|
+
setSignalProtocolRelayProtocolErrorReporter(report) {
|
|
895
|
+
this.signalRelayProtocolErrorReporter = report;
|
|
891
896
|
}
|
|
892
897
|
/**
|
|
893
898
|
* Set the listener of own devices that this device sees for the first
|
|
@@ -1287,7 +1292,7 @@ export class SignalProtocolServiceCipher {
|
|
|
1287
1292
|
// it gives the distribution to the caller only.
|
|
1288
1293
|
const distribution = inspected.senderKeyDistribution;
|
|
1289
1294
|
let distributionGroupId = null;
|
|
1290
|
-
if (distribution && (record === null || record.origin
|
|
1295
|
+
if (distribution && (record === null || isSignalProtocolRelayOrigin(record.origin))) {
|
|
1291
1296
|
distributionGroupId = await this.installDistribution(envelope.senderUserId, envelope.senderDeviceId, distribution, stopSignal);
|
|
1292
1297
|
}
|
|
1293
1298
|
else if (distribution) {
|
|
@@ -1405,7 +1410,7 @@ export class SignalProtocolServiceCipher {
|
|
|
1405
1410
|
}
|
|
1406
1411
|
const distribution = inspected.senderKeyDistribution;
|
|
1407
1412
|
let distributionGroupId = null;
|
|
1408
|
-
if (distribution && record.origin
|
|
1413
|
+
if (distribution && isSignalProtocolRelayOrigin(record.origin)) {
|
|
1409
1414
|
distributionGroupId = await this.installDistribution(senderUserId, senderDeviceId, distribution, stopSignal);
|
|
1410
1415
|
}
|
|
1411
1416
|
else if (distribution) {
|
|
@@ -1615,7 +1620,7 @@ export class SignalProtocolServiceCipher {
|
|
|
1615
1620
|
* the retry ID. Nothing is posted
|
|
1616
1621
|
*/
|
|
1617
1622
|
async resendToDevice(recipientUserId, recipientDeviceId, content, options, stopSignal) {
|
|
1618
|
-
if (!this.
|
|
1623
|
+
if (!this.signalProtocolRelay)
|
|
1619
1624
|
throw new Error('Relay not configured - cannot resend');
|
|
1620
1625
|
const { retry } = options;
|
|
1621
1626
|
if (content === null && retry === undefined) {
|
|
@@ -1629,7 +1634,7 @@ export class SignalProtocolServiceCipher {
|
|
|
1629
1634
|
await this.postResend(resend, retryResendAttemptId(resend), stopSignal);
|
|
1630
1635
|
}
|
|
1631
1636
|
catch (error) {
|
|
1632
|
-
if (!
|
|
1637
|
+
if (!signalRelayHoldsMessageId(error))
|
|
1633
1638
|
throw error;
|
|
1634
1639
|
// Only this sender posts this ID, and it posts one encryption under
|
|
1635
1640
|
// each attempt ID. So a conflict means that the Relay holds that
|
|
@@ -1673,7 +1678,7 @@ export class SignalProtocolServiceCipher {
|
|
|
1673
1678
|
return true;
|
|
1674
1679
|
}
|
|
1675
1680
|
catch (error) {
|
|
1676
|
-
if (
|
|
1681
|
+
if (signalRelayOperationRefusal(error) !== 'OPERATION_EXPIRED')
|
|
1677
1682
|
throw error;
|
|
1678
1683
|
}
|
|
1679
1684
|
// The Relay no longer admits or replays the stored operation. It
|
|
@@ -1782,7 +1787,7 @@ export class SignalProtocolServiceCipher {
|
|
|
1782
1787
|
const sealedSender = groupId === undefined
|
|
1783
1788
|
? await this.resolveSealedSenderContext(recipientUserId)
|
|
1784
1789
|
: await this.resolveDistributionSealedSender(recipientUserId, groupId);
|
|
1785
|
-
const directSealedSender = sealedSender && this.
|
|
1790
|
+
const directSealedSender = sealedSender && this.signalProtocolRelay?.sendMultiRecipientUnidentified ? sealedSender : null;
|
|
1786
1791
|
let sealedSenderAuth;
|
|
1787
1792
|
if (directSealedSender?.auth.type === 'accessKey') {
|
|
1788
1793
|
sealedSenderAuth = { ...directSealedSender.auth };
|
|
@@ -2019,7 +2024,7 @@ export class SignalProtocolServiceCipher {
|
|
|
2019
2024
|
return false;
|
|
2020
2025
|
throw new EncryptionError(`No session with ${recipientUserId} and auto-establishment not configured`, EncryptionErrorCode.SESSION_NOT_FOUND, { recipientUserId });
|
|
2021
2026
|
}
|
|
2022
|
-
if (!this.
|
|
2027
|
+
if (!this.signalProtocolRelay) {
|
|
2023
2028
|
if (hasActiveSession)
|
|
2024
2029
|
return false;
|
|
2025
2030
|
throw new EncryptionError('Cannot auto-establish session: relay server not configured', EncryptionErrorCode.INITIALIZATION_FAILED, { recipientUserId });
|
|
@@ -2027,7 +2032,7 @@ export class SignalProtocolServiceCipher {
|
|
|
2027
2032
|
if (sendFirst &&
|
|
2028
2033
|
hasActiveSession &&
|
|
2029
2034
|
listAge < RECIPIENT_DEVICE_LIST_MAXIMUM_AGE_MILLISECONDS &&
|
|
2030
|
-
refusesRemovedDevices(this.
|
|
2035
|
+
refusesRemovedDevices(this.signalProtocolRelay)) {
|
|
2031
2036
|
return true;
|
|
2032
2037
|
}
|
|
2033
2038
|
await this.readRecipientDeviceList(recipientUserId, sessions, hasActiveSession, undefined, readDevices);
|
|
@@ -2073,7 +2078,7 @@ export class SignalProtocolServiceCipher {
|
|
|
2073
2078
|
});
|
|
2074
2079
|
}
|
|
2075
2080
|
catch (error) {
|
|
2076
|
-
|
|
2081
|
+
rethrowSignalProtocolRelayWorkStopped(error);
|
|
2077
2082
|
if (hasActiveSession) {
|
|
2078
2083
|
// The known devices still receive; the next send reads the list again.
|
|
2079
2084
|
this.logger.warn('Recipient device list refresh failed, sending to known devices', {
|
|
@@ -2134,10 +2139,10 @@ export class SignalProtocolServiceCipher {
|
|
|
2134
2139
|
* @returns The listed own devices other than this device, in list order
|
|
2135
2140
|
*/
|
|
2136
2141
|
async readOwnDeviceList(sessions, stopSignal) {
|
|
2137
|
-
const
|
|
2138
|
-
if (!
|
|
2142
|
+
const signalProtocolRelay = this.signalProtocolRelay;
|
|
2143
|
+
if (!signalProtocolRelay)
|
|
2139
2144
|
return [];
|
|
2140
|
-
const listed = await this.fanOut.request(() =>
|
|
2145
|
+
const listed = await this.fanOut.request(() => signalProtocolRelay.getActiveDevices(this.userId), stopSignal);
|
|
2141
2146
|
const others = listed.filter((device) => device.userId === this.userId && device.deviceId !== this.deviceId);
|
|
2142
2147
|
const recorded = this.ownDevicesFirstSeen
|
|
2143
2148
|
? new Set(unremovedDeviceIds(await this.sesameManager.getUserRecord(this.userId)))
|
|
@@ -2148,7 +2153,7 @@ export class SignalProtocolServiceCipher {
|
|
|
2148
2153
|
await sessions.establishSessions(this.userId, others);
|
|
2149
2154
|
}
|
|
2150
2155
|
catch (error) {
|
|
2151
|
-
|
|
2156
|
+
rethrowSignalProtocolRelayWorkStopped(error);
|
|
2152
2157
|
this.logger.warn('Could not start sessions with listed own devices', {
|
|
2153
2158
|
category: 'E2EE',
|
|
2154
2159
|
error: error,
|
|
@@ -2263,8 +2268,8 @@ export class SignalProtocolServiceCipher {
|
|
|
2263
2268
|
// and the read of a later pass would address the own devices again.
|
|
2264
2269
|
const ownAccount = recipientUserId === this.userId;
|
|
2265
2270
|
const sendFirst = await this.ensureSessionsForUser(recipientUserId, sessions, !ownAccount);
|
|
2266
|
-
const sealedSender = this.
|
|
2267
|
-
const directSealedSender = sealedSender && this.
|
|
2271
|
+
const sealedSender = this.signalProtocolRelay ? await this.resolveSealedSenderContext(recipientUserId) : null;
|
|
2272
|
+
const directSealedSender = sealedSender && this.signalProtocolRelay?.sendMultiRecipientUnidentified ? sealedSender : null;
|
|
2268
2273
|
const transportMode = directSealedSender
|
|
2269
2274
|
? directSealedSender.config.deliveryMode === 'required'
|
|
2270
2275
|
? 'sealed_sender_required'
|
|
@@ -2428,7 +2433,7 @@ export class SignalProtocolServiceCipher {
|
|
|
2428
2433
|
* transport starts for one destination of the body stores the request of
|
|
2429
2434
|
* that destination.
|
|
2430
2435
|
*/
|
|
2431
|
-
|
|
2436
|
+
postGroupSignalProtocolRelay(send, sealed, control, evidence, clientMessageId, destination) {
|
|
2432
2437
|
const ownRepeat = (repeat, { device }) => repeat.userId === device.userId && repeat.deviceId === device.deviceId;
|
|
2433
2438
|
if (!isDestinationList(destination)) {
|
|
2434
2439
|
const post = send;
|
|
@@ -2436,7 +2441,7 @@ export class SignalProtocolServiceCipher {
|
|
|
2436
2441
|
// The transport gates a repeat by the ID that the posted envelope
|
|
2437
2442
|
// carries. Other posts of the send carry the same ID, so the gate
|
|
2438
2443
|
// takes only a repeat of this device.
|
|
2439
|
-
const release = admitRequestsFor(this.
|
|
2444
|
+
const release = admitRequestsFor(this.signalProtocolRelay, clientMessageId, async (repeat) => {
|
|
2440
2445
|
if (ownRepeat(repeat, destination))
|
|
2441
2446
|
await posting.beforeRequest?.();
|
|
2442
2447
|
}, (repeat) => {
|
|
@@ -2444,7 +2449,7 @@ export class SignalProtocolServiceCipher {
|
|
|
2444
2449
|
posting.onRequest?.(repeat.after);
|
|
2445
2450
|
});
|
|
2446
2451
|
try {
|
|
2447
|
-
return await this.
|
|
2452
|
+
return await this.postToSignalProtocolRelay(post, sealed, posting);
|
|
2448
2453
|
}
|
|
2449
2454
|
finally {
|
|
2450
2455
|
release();
|
|
@@ -2458,7 +2463,7 @@ export class SignalProtocolServiceCipher {
|
|
|
2458
2463
|
// The transport gates a repeat of the body once for each destination
|
|
2459
2464
|
// device. Each gate stores the request of its device, and the repeat
|
|
2460
2465
|
// counts once, at the first destination.
|
|
2461
|
-
const release = admitRequestsFor(this.
|
|
2466
|
+
const release = admitRequestsFor(this.signalProtocolRelay, clientMessageId, async (repeat) => {
|
|
2462
2467
|
const target = destinations.filter((candidate) => ownRepeat(repeat, candidate));
|
|
2463
2468
|
await this.recordingRequests(clientMessageId, target, control)();
|
|
2464
2469
|
}, (repeat) => {
|
|
@@ -2466,7 +2471,7 @@ export class SignalProtocolServiceCipher {
|
|
|
2466
2471
|
onRequest(repeat.after);
|
|
2467
2472
|
});
|
|
2468
2473
|
try {
|
|
2469
|
-
return await this.
|
|
2474
|
+
return await this.postToSignalProtocolRelay(shared, sealed, { ...control, beforeRequest, onRequest });
|
|
2470
2475
|
}
|
|
2471
2476
|
finally {
|
|
2472
2477
|
release();
|
|
@@ -2547,7 +2552,7 @@ export class SignalProtocolServiceCipher {
|
|
|
2547
2552
|
recipientDeviceCount: group
|
|
2548
2553
|
? (intent.groupRecipientDeviceCount ?? intent.deviceMessages.length)
|
|
2549
2554
|
: intent.deviceMessages.length,
|
|
2550
|
-
...
|
|
2555
|
+
...aggregateSignalProtocolRelayAcceptance(acceptances),
|
|
2551
2556
|
...(group && { groupId: intent.recipientId }),
|
|
2552
2557
|
};
|
|
2553
2558
|
const syncPending = intent.syncMessages.some((message) => {
|
|
@@ -2624,7 +2629,7 @@ export class SignalProtocolServiceCipher {
|
|
|
2624
2629
|
* and the lock serializes the manual resends of one intent.
|
|
2625
2630
|
*/
|
|
2626
2631
|
async withManualResendOrderLock(clientMessageId, stopSignal, operation) {
|
|
2627
|
-
if (!this.
|
|
2632
|
+
if (!this.signalProtocolRelay)
|
|
2628
2633
|
throw new Error('Relay not configured - cannot resend');
|
|
2629
2634
|
const stored = await getOutgoingMessageIntent(this.storage, clientMessageId);
|
|
2630
2635
|
if (!stored)
|
|
@@ -2940,7 +2945,7 @@ export class SignalProtocolServiceCipher {
|
|
|
2940
2945
|
}
|
|
2941
2946
|
/** A replay whose first attempt posted before its read reads and reconciles first. */
|
|
2942
2947
|
async reconcilePendingDirectIntent(intent, plaintextBytes, sessions) {
|
|
2943
|
-
if (!intent.reconcilePending || !sessions || !this.
|
|
2948
|
+
if (!intent.reconcilePending || !sessions || !this.signalProtocolRelay)
|
|
2944
2949
|
return intent;
|
|
2945
2950
|
const list = await this.readRecipientDeviceList(intent.recipientId, sessions, await this.hasActiveSession(intent.recipientId));
|
|
2946
2951
|
return list ? this.reconcileDirectIntent(intent, list, plaintextBytes) : intent;
|
|
@@ -2992,7 +2997,7 @@ export class SignalProtocolServiceCipher {
|
|
|
2992
2997
|
* own device that the intent does not address.
|
|
2993
2998
|
*/
|
|
2994
2999
|
async reconcileDirectSyncDevices(intent, plaintextBytes, sessions, stopSignal) {
|
|
2995
|
-
if (!this.
|
|
3000
|
+
if (!this.signalProtocolRelay)
|
|
2996
3001
|
return intent;
|
|
2997
3002
|
const listed = await this.readOwnDeviceList(sessions, stopSignal);
|
|
2998
3003
|
const { unlisted, added } = listedOwnDeviceChange(intent.syncMessages, listed.map((device) => device.deviceId));
|
|
@@ -3125,7 +3130,7 @@ export class SignalProtocolServiceCipher {
|
|
|
3125
3130
|
async sendStoredDirectIntent(intent, plaintextBytes, sessions, stopSignal, evidence, posts) {
|
|
3126
3131
|
if (intent.kind !== 'direct')
|
|
3127
3132
|
throw new Error('Expected a direct outbox intent');
|
|
3128
|
-
if (!this.
|
|
3133
|
+
if (!this.signalProtocolRelay) {
|
|
3129
3134
|
const result = {
|
|
3130
3135
|
clientMessageId: intent.clientMessageId,
|
|
3131
3136
|
messageId: `local-${intent.clientTimestamp}`,
|
|
@@ -3135,7 +3140,7 @@ export class SignalProtocolServiceCipher {
|
|
|
3135
3140
|
await completeOutgoingMessageIntent(this.storage, intent.clientMessageId, result);
|
|
3136
3141
|
return { ...result, clientTimestamp: intent.clientTimestamp };
|
|
3137
3142
|
}
|
|
3138
|
-
const
|
|
3143
|
+
const signalProtocolRelay = this.signalProtocolRelay;
|
|
3139
3144
|
const control = this.postingControl(evidence, { ...(stopSignal && { stopSignal }) });
|
|
3140
3145
|
let results;
|
|
3141
3146
|
let skippedRefusal = false;
|
|
@@ -3172,7 +3177,7 @@ export class SignalProtocolServiceCipher {
|
|
|
3172
3177
|
const stop = recordDeadlineStop(control.beforeRequest);
|
|
3173
3178
|
const destination = syncDestination(intent.clientMessageId, message);
|
|
3174
3179
|
try {
|
|
3175
|
-
await evidence.postSync(destination, stop.check, (gate) => this.postSyncMessage(
|
|
3180
|
+
await evidence.postSync(destination, stop.check, (gate) => this.postSyncMessage(signalProtocolRelay, message, control, syncRepair, gate));
|
|
3176
3181
|
}
|
|
3177
3182
|
catch (error) {
|
|
3178
3183
|
if (!stop.stopped())
|
|
@@ -3185,7 +3190,7 @@ export class SignalProtocolServiceCipher {
|
|
|
3185
3190
|
messageId: first?.messageId ?? `local-${intent.clientTimestamp}`,
|
|
3186
3191
|
timestamp: first?.serverTimestamp ?? intent.clientTimestamp,
|
|
3187
3192
|
recipientDeviceCount: intent.deviceMessages.length,
|
|
3188
|
-
...
|
|
3193
|
+
...aggregateSignalProtocolRelayAcceptance(results),
|
|
3189
3194
|
};
|
|
3190
3195
|
await completeOutgoingMessageIntent(this.storage, intent.clientMessageId, result, {
|
|
3191
3196
|
syncPending,
|
|
@@ -3195,7 +3200,7 @@ export class SignalProtocolServiceCipher {
|
|
|
3195
3200
|
}
|
|
3196
3201
|
/** True when the relay compares declared device sets, so each send declares them. */
|
|
3197
3202
|
declaresDeviceSets() {
|
|
3198
|
-
return this.
|
|
3203
|
+
return this.signalProtocolRelay !== undefined && this.signalProtocolRelay !== null && comparesDeviceSets(this.signalProtocolRelay);
|
|
3199
3204
|
}
|
|
3200
3205
|
/**
|
|
3201
3206
|
* The own devices other than this device that have a local device record
|
|
@@ -3478,7 +3483,7 @@ export class SignalProtocolServiceCipher {
|
|
|
3478
3483
|
refreshed = await sessions.refreshStaleSession(userId, deviceId);
|
|
3479
3484
|
}
|
|
3480
3485
|
catch (error) {
|
|
3481
|
-
|
|
3486
|
+
rethrowSignalProtocolRelayWorkStopped(error);
|
|
3482
3487
|
this.logger.warn('Could not refresh the session of a stale device', {
|
|
3483
3488
|
category: 'E2EE',
|
|
3484
3489
|
error: error,
|
|
@@ -3508,12 +3513,12 @@ export class SignalProtocolServiceCipher {
|
|
|
3508
3513
|
const held = unremovedDeviceIds(record).filter((id) => !own(id));
|
|
3509
3514
|
const handled = new Set(ready.map((device) => device.deviceId));
|
|
3510
3515
|
const remainingIds = held.filter((id) => !handled.has(id));
|
|
3511
|
-
const
|
|
3516
|
+
const signalProtocolRelay = this.signalProtocolRelay;
|
|
3512
3517
|
if (remainingIds.length > 0) {
|
|
3513
3518
|
await establish(remainingIds, false);
|
|
3514
3519
|
}
|
|
3515
|
-
else if (
|
|
3516
|
-
const listed = await this.fanOut.request(() =>
|
|
3520
|
+
else if (signalProtocolRelay && held.length === 0) {
|
|
3521
|
+
const listed = await this.fanOut.request(() => signalProtocolRelay.getActiveDevices(userId), options.stopSignal);
|
|
3517
3522
|
const deviceIds = listed
|
|
3518
3523
|
.filter((device) => device.userId === userId && !own(device.deviceId))
|
|
3519
3524
|
.map((device) => device.deviceId);
|
|
@@ -3533,7 +3538,7 @@ export class SignalProtocolServiceCipher {
|
|
|
3533
3538
|
*/
|
|
3534
3539
|
markUncheckedDeclaredPosts(result, receipts, clientMessageId) {
|
|
3535
3540
|
const error = this.uncheckedDeclaredPostError(receipts, clientMessageId);
|
|
3536
|
-
return error ?
|
|
3541
|
+
return error ? markSignalProtocolRelayProtocolError(result, error) : result;
|
|
3537
3542
|
}
|
|
3538
3543
|
/**
|
|
3539
3544
|
* The protocol error of declared posts that the relay accepted without the
|
|
@@ -3658,7 +3663,7 @@ export class SignalProtocolServiceCipher {
|
|
|
3658
3663
|
messageId: first?.messageId ?? `local-${intent.clientTimestamp}`,
|
|
3659
3664
|
timestamp: first?.serverTimestamp ?? intent.clientTimestamp,
|
|
3660
3665
|
recipientDeviceCount: recipient.messages.length,
|
|
3661
|
-
...
|
|
3666
|
+
...aggregateSignalProtocolRelayAcceptance(accepted),
|
|
3662
3667
|
};
|
|
3663
3668
|
// The sync phase runs when a recipient receipt sets needsSync or the
|
|
3664
3669
|
// send holds an own device record. With needsSync and no own record,
|
|
@@ -3706,7 +3711,7 @@ export class SignalProtocolServiceCipher {
|
|
|
3706
3711
|
* sync copy, and the phase does not post a copy that the Relay accepted.
|
|
3707
3712
|
*/
|
|
3708
3713
|
async finishDeclaredSync(intent, encrypt, sessions, stopSignal, beforeRequest, evidence) {
|
|
3709
|
-
const
|
|
3714
|
+
const signalProtocolRelay = this.signalProtocolRelay;
|
|
3710
3715
|
const control = {
|
|
3711
3716
|
...(stopSignal && { stopSignal }),
|
|
3712
3717
|
...(beforeRequest && { beforeRequest }),
|
|
@@ -3723,10 +3728,10 @@ export class SignalProtocolServiceCipher {
|
|
|
3723
3728
|
post: async (message, declaredDeviceIds) => {
|
|
3724
3729
|
const copy = { ...control, declaredDeviceIds };
|
|
3725
3730
|
if (!evidence) {
|
|
3726
|
-
accepted.push(await this.postSyncCopy(
|
|
3731
|
+
accepted.push(await this.postSyncCopy(signalProtocolRelay, message, copy));
|
|
3727
3732
|
return;
|
|
3728
3733
|
}
|
|
3729
|
-
const acceptance = await evidence.postSync(syncDestination(intent.clientMessageId, message), beforeRequest ?? (async () => { }), (gate) => this.postSyncCopy(
|
|
3734
|
+
const acceptance = await evidence.postSync(syncDestination(intent.clientMessageId, message), beforeRequest ?? (async () => { }), (gate) => this.postSyncCopy(signalProtocolRelay, message, {
|
|
3730
3735
|
...copy,
|
|
3731
3736
|
beforeRequest: gate(message.clientMessageId),
|
|
3732
3737
|
}));
|
|
@@ -3769,7 +3774,7 @@ export class SignalProtocolServiceCipher {
|
|
|
3769
3774
|
* relay accepted before the failure.
|
|
3770
3775
|
*/
|
|
3771
3776
|
async sendDeclaredSyncPayload(payloadBytes, timestamp, target) {
|
|
3772
|
-
const
|
|
3777
|
+
const signalProtocolRelay = this.signalProtocolRelay;
|
|
3773
3778
|
let ownDevices = await this.localOwnDevices();
|
|
3774
3779
|
if (ownDevices.length === 0 && target?.readOwnListWithoutRecord) {
|
|
3775
3780
|
await this.readOwnDeviceList(this.sessionCallbacks, target.stopSignal);
|
|
@@ -3803,7 +3808,7 @@ export class SignalProtocolServiceCipher {
|
|
|
3803
3808
|
declaredDeviceIds,
|
|
3804
3809
|
...(target?.stopSignal && { stopSignal: target.stopSignal }),
|
|
3805
3810
|
};
|
|
3806
|
-
accepted.push(await this.postSyncCopy(
|
|
3811
|
+
accepted.push(await this.postSyncCopy(signalProtocolRelay, message, control));
|
|
3807
3812
|
delivered.set(message.recipientDeviceId, message);
|
|
3808
3813
|
target?.accepted?.push(...acceptedSyncDevices([message]));
|
|
3809
3814
|
},
|
|
@@ -3827,7 +3832,7 @@ export class SignalProtocolServiceCipher {
|
|
|
3827
3832
|
// phase fails. The app knows no clientMessageId for the payload.
|
|
3828
3833
|
const error = this.uncheckedDeclaredPostError(syncPostReceipts(accepted), undefined);
|
|
3829
3834
|
if (error)
|
|
3830
|
-
await this.
|
|
3835
|
+
await this.signalRelayProtocolErrorReporter?.(error);
|
|
3831
3836
|
}
|
|
3832
3837
|
return acceptedSyncDevices([...delivered.values()]);
|
|
3833
3838
|
}
|
|
@@ -3857,7 +3862,7 @@ export class SignalProtocolServiceCipher {
|
|
|
3857
3862
|
},
|
|
3858
3863
|
endRecipientPhase: (intent, error) => this.endOrRethrow(intent, boundGroupEvidence(), error),
|
|
3859
3864
|
storage: this.storage,
|
|
3860
|
-
...(this.
|
|
3865
|
+
...(this.signalProtocolRelay && { signalProtocolRelay: this.signalProtocolRelay }),
|
|
3861
3866
|
senderUserId: this.userId,
|
|
3862
3867
|
senderDeviceId: this.deviceId,
|
|
3863
3868
|
deliveryMode: this.sealedSenderDeliveryMode,
|
|
@@ -3883,7 +3888,7 @@ export class SignalProtocolServiceCipher {
|
|
|
3883
3888
|
this.sealedSenderDeliveryMode === 'disabled' ||
|
|
3884
3889
|
!this.sealedSenderProvider ||
|
|
3885
3890
|
!this.endorsementManager ||
|
|
3886
|
-
!this.
|
|
3891
|
+
!this.signalProtocolRelay?.sendMultiRecipientUnidentified) {
|
|
3887
3892
|
return undefined;
|
|
3888
3893
|
}
|
|
3889
3894
|
const prepared = await prepareGroupSharedMessage({
|
|
@@ -3905,7 +3910,7 @@ export class SignalProtocolServiceCipher {
|
|
|
3905
3910
|
prepareDeviceMessage: (member, groupId, ciphertext, timestamp, contentHint) => this.prepareStoredGroupDeviceMessage(member, groupId, ciphertext, timestamp, contentHint),
|
|
3906
3911
|
resolveOwnDevices: () => declared ? this.localOwnDevices() : this.readOwnDeviceList(sessions, stopSignal),
|
|
3907
3912
|
prepareSyncMessages: async (groupId, bytes, timestamp, clientMessageId, ownDevices) => {
|
|
3908
|
-
if (!this.
|
|
3913
|
+
if (!this.signalProtocolRelay || ownDevices.length === 0)
|
|
3909
3914
|
return [];
|
|
3910
3915
|
const syncPayload = this.buildSentSyncTranscript(groupId, bytes, timestamp);
|
|
3911
3916
|
const prepared = await this.sesameManager.sendToLocalOtherDevices(syncPayload, {
|
|
@@ -3919,7 +3924,7 @@ export class SignalProtocolServiceCipher {
|
|
|
3919
3924
|
// A copy that the posting deadline stopped stays pending.
|
|
3920
3925
|
const stop = recordDeadlineStop(control.beforeRequest);
|
|
3921
3926
|
try {
|
|
3922
|
-
await boundGroupEvidence().postSync(syncDestination(intent.clientMessageId, message), stop.check, (gate) => this.postSyncMessage(this.
|
|
3927
|
+
await boundGroupEvidence().postSync(syncDestination(intent.clientMessageId, message), stop.check, (gate) => this.postSyncMessage(this.signalProtocolRelay, message, control, { sessions: repair.sessions, intentId: intent.clientMessageId, rebuild }, gate));
|
|
3923
3928
|
}
|
|
3924
3929
|
catch (error) {
|
|
3925
3930
|
if (!stop.stopped())
|
|
@@ -3946,9 +3951,9 @@ export class SignalProtocolServiceCipher {
|
|
|
3946
3951
|
throw firstItemError(error);
|
|
3947
3952
|
}),
|
|
3948
3953
|
sendPhase: (messages, task, phase) => this.sendPhase(messages, task, phase, stopSignal),
|
|
3949
|
-
|
|
3950
|
-
? this.
|
|
3951
|
-
: this.
|
|
3954
|
+
postToSignalProtocolRelay: (send, sealed, destination) => destination === undefined
|
|
3955
|
+
? this.postToSignalProtocolRelay(send, sealed, control)
|
|
3956
|
+
: this.postGroupSignalProtocolRelay(send, sealed, control, boundGroupEvidence(), options.clientMessageId, destination),
|
|
3952
3957
|
...(declared && {
|
|
3953
3958
|
deviceSets: this.groupDeviceSetContext(sessions, stopSignal, boundGroupEvidence),
|
|
3954
3959
|
}),
|
|
@@ -4042,7 +4047,7 @@ export class SignalProtocolServiceCipher {
|
|
|
4042
4047
|
if (registrationId !== undefined)
|
|
4043
4048
|
stored.recipientRegistrationId = registrationId;
|
|
4044
4049
|
const sealedSender = await this.resolveSealedSenderContext(member.userId, groupId);
|
|
4045
|
-
if (!sealedSender || !this.
|
|
4050
|
+
if (!sealedSender || !this.signalProtocolRelay?.sendMultiRecipientUnidentified)
|
|
4046
4051
|
return stored;
|
|
4047
4052
|
return this.sealStoredDeviceMessage(stored, sealedSender, sealedSender.config.deliveryMode === 'required' ? 'required' : 'preferred', contentHint);
|
|
4048
4053
|
}
|
|
@@ -4089,7 +4094,7 @@ export class SignalProtocolServiceCipher {
|
|
|
4089
4094
|
*/
|
|
4090
4095
|
async authorizePreMessage(groupId, message, required) {
|
|
4091
4096
|
const sealedSender = await this.resolveDistributionSealedSender(message.recipientUserId, groupId);
|
|
4092
|
-
if (!sealedSender || !this.
|
|
4097
|
+
if (!sealedSender || !this.signalProtocolRelay?.sendMultiRecipientUnidentified) {
|
|
4093
4098
|
if (required) {
|
|
4094
4099
|
throw new EncryptionError('Required group sealed-sender authorization is unavailable', EncryptionErrorCode.SEALED_SENDER_REQUIRED, { recipientUserId: message.recipientUserId, groupId });
|
|
4095
4100
|
}
|
|
@@ -4217,7 +4222,7 @@ export class SignalProtocolServiceCipher {
|
|
|
4217
4222
|
}
|
|
4218
4223
|
catch (error) {
|
|
4219
4224
|
// The evidence did not accept this answer, so the post rejected.
|
|
4220
|
-
if (
|
|
4225
|
+
if (signalRelayHoldsMessageId(error)) {
|
|
4221
4226
|
return { message: transport.message, outcome: 'held' };
|
|
4222
4227
|
}
|
|
4223
4228
|
if (await this.isRemovedDeviceRefusal(error, transport.message, control)) {
|
|
@@ -4239,7 +4244,7 @@ export class SignalProtocolServiceCipher {
|
|
|
4239
4244
|
await post(repaired.transport);
|
|
4240
4245
|
}
|
|
4241
4246
|
catch (error) {
|
|
4242
|
-
if (
|
|
4247
|
+
if (signalRelayHoldsMessageId(error)) {
|
|
4243
4248
|
return { message: repaired.transport.message, outcome: 'held', refreshed: true };
|
|
4244
4249
|
}
|
|
4245
4250
|
if (!(await this.isRemovedDeviceRefusal(error, repaired.transport.message, control))) {
|
|
@@ -4294,10 +4299,10 @@ export class SignalProtocolServiceCipher {
|
|
|
4294
4299
|
* list still shows keeps the refusal as a failure.
|
|
4295
4300
|
*/
|
|
4296
4301
|
async isRemovedDeviceRefusal(error, message, control) {
|
|
4297
|
-
if (
|
|
4302
|
+
if (signalRelayDeviceRefusal(error)?.code !== 'NOT_FOUND' || !isRefusalOfDevice(error, message)) {
|
|
4298
4303
|
return false;
|
|
4299
4304
|
}
|
|
4300
|
-
const listed = await this.fanOut.request(() => this.
|
|
4305
|
+
const listed = await this.fanOut.request(() => this.signalProtocolRelay.getActiveDevices(message.recipientUserId), control.stopSignal);
|
|
4301
4306
|
if (listed.some(({ deviceId }) => deviceId === message.recipientDeviceId))
|
|
4302
4307
|
return false;
|
|
4303
4308
|
this.logger.info('Dropped the sender-key pre-message of a removed device', {
|
|
@@ -4471,7 +4476,7 @@ export class SignalProtocolServiceCipher {
|
|
|
4471
4476
|
async refreshPreMessageEndorsements(groupId, recipientUserIds) {
|
|
4472
4477
|
if (this.sealedSenderDeliveryMode === 'disabled' ||
|
|
4473
4478
|
!this.sealedSenderProvider ||
|
|
4474
|
-
!this.
|
|
4479
|
+
!this.signalProtocolRelay?.sendMultiRecipientUnidentified) {
|
|
4475
4480
|
return;
|
|
4476
4481
|
}
|
|
4477
4482
|
await this.refreshGroupSendEndorsements(groupId, recipientUserIds);
|
|
@@ -4524,7 +4529,7 @@ export class SignalProtocolServiceCipher {
|
|
|
4524
4529
|
return resolveSealedSenderSendContext({
|
|
4525
4530
|
storage: this.storage,
|
|
4526
4531
|
deliveryMode: this.sealedSenderDeliveryMode,
|
|
4527
|
-
|
|
4532
|
+
signalProtocolRelaySupportsUnidentified: Boolean(this.signalProtocolRelay?.sendMultiRecipientUnidentified),
|
|
4528
4533
|
...(this.sealedSenderProvider && {
|
|
4529
4534
|
provider: this.sealedSenderProvider,
|
|
4530
4535
|
}),
|
|
@@ -4627,7 +4632,7 @@ export class SignalProtocolServiceCipher {
|
|
|
4627
4632
|
const { beforeRequest, onRequest } = control;
|
|
4628
4633
|
const ownRepeat = (repeat) => repeat.userId === msg.recipientUserId && repeat.deviceId === msg.recipientDeviceId;
|
|
4629
4634
|
const release = (beforeRequest || onRequest) && effectiveClientMessageId !== undefined
|
|
4630
|
-
? admitRequestsFor(this.
|
|
4635
|
+
? admitRequestsFor(this.signalProtocolRelay, effectiveClientMessageId, beforeRequest
|
|
4631
4636
|
? (repeat) => (ownRepeat(repeat) ? beforeRequest() : Promise.resolve())
|
|
4632
4637
|
: async () => { }, onRequest &&
|
|
4633
4638
|
((repeat) => {
|
|
@@ -4640,7 +4645,7 @@ export class SignalProtocolServiceCipher {
|
|
|
4640
4645
|
let identifiedControl = control;
|
|
4641
4646
|
let fallbackFrom;
|
|
4642
4647
|
try {
|
|
4643
|
-
if (preparedSealedSender && !this.
|
|
4648
|
+
if (preparedSealedSender && !this.signalProtocolRelay.sendMultiRecipientUnidentified) {
|
|
4644
4649
|
if (preparedSealedSender.deliveryMode === 'required') {
|
|
4645
4650
|
throw new EncryptionError('Required sealed-sender relay capability is unavailable', EncryptionErrorCode.SEALED_SENDER_REQUIRED, { recipientUserId: msg.recipientUserId });
|
|
4646
4651
|
}
|
|
@@ -4648,7 +4653,7 @@ export class SignalProtocolServiceCipher {
|
|
|
4648
4653
|
// Sealed sender path: use the V2 upload format for one recipient. V2 has
|
|
4649
4654
|
// no two-recipient minimum; its recipient-count field permits this exact
|
|
4650
4655
|
// direct-delivery shape.
|
|
4651
|
-
if ((sealedSender || preparedSealedSender) && this.
|
|
4656
|
+
if ((sealedSender || preparedSealedSender) && this.signalProtocolRelay.sendMultiRecipientUnidentified) {
|
|
4652
4657
|
// The sealed body names the registration of its device, as the
|
|
4653
4658
|
// identified post does.
|
|
4654
4659
|
const prepared = preparedSealedSender ??
|
|
@@ -4680,9 +4685,9 @@ export class SignalProtocolServiceCipher {
|
|
|
4680
4685
|
};
|
|
4681
4686
|
const declaredDeviceIds = control.declaredDeviceIds;
|
|
4682
4687
|
try {
|
|
4683
|
-
const result = await this.
|
|
4684
|
-
? this.
|
|
4685
|
-
: this.
|
|
4688
|
+
const result = await this.postToSignalProtocolRelay(() => declaredDeviceIds
|
|
4689
|
+
? this.signalProtocolRelay.sendMultiRecipientUnidentified(prepared.sentMessageBase64, sealedAuth, msg.timestamp, control.deliveryClass ?? 'user-visible', [msg.recipientUserId], effectiveClientMessageId, control.operationEpochMilliseconds, undefined, [{ userId: msg.recipientUserId, deviceIds: declaredDeviceIds }])
|
|
4690
|
+
: this.signalProtocolRelay.sendMultiRecipientUnidentified(prepared.sentMessageBase64, sealedAuth, msg.timestamp, control.deliveryClass ?? 'user-visible', [msg.recipientUserId], effectiveClientMessageId, ...(control.operationEpochMilliseconds !== undefined
|
|
4686
4691
|
? [control.operationEpochMilliseconds]
|
|
4687
4692
|
: [])), true, control);
|
|
4688
4693
|
if (result.uuids404.length > 0) {
|
|
@@ -4708,7 +4713,7 @@ export class SignalProtocolServiceCipher {
|
|
|
4708
4713
|
if (result.refusals?.some((refusal) => refusal.code === 'STALE_DEVICE' &&
|
|
4709
4714
|
refusal.userId === msg.recipientUserId &&
|
|
4710
4715
|
refusal.deviceId === msg.recipientDeviceId)) {
|
|
4711
|
-
throw
|
|
4716
|
+
throw markSignalProtocolRelayDeviceRefusal(new Error('Recipient device registration changed'), {
|
|
4712
4717
|
code: 'STALE_DEVICE',
|
|
4713
4718
|
userId: msg.recipientUserId,
|
|
4714
4719
|
deviceId: msg.recipientDeviceId,
|
|
@@ -4735,7 +4740,7 @@ export class SignalProtocolServiceCipher {
|
|
|
4735
4740
|
}
|
|
4736
4741
|
// Identified sender path: standard relay send
|
|
4737
4742
|
try {
|
|
4738
|
-
return await this.
|
|
4743
|
+
return await this.postToSignalProtocolRelay(() => this.signalProtocolRelay.send({
|
|
4739
4744
|
targetUserId: msg.recipientUserId,
|
|
4740
4745
|
targetDeviceId: msg.recipientDeviceId,
|
|
4741
4746
|
senderUserId: this.userId,
|
|
@@ -4787,7 +4792,7 @@ export class SignalProtocolServiceCipher {
|
|
|
4787
4792
|
'from local group state and pass the member user IDs.', EncryptionErrorCode.ENCRYPTION_FAILED, { groupId });
|
|
4788
4793
|
}
|
|
4789
4794
|
const deviceResults = await this.fanOut
|
|
4790
|
-
.all(options.groupMemberUserIds, (userId) => this.fanOut.request(() => this.
|
|
4795
|
+
.all(options.groupMemberUserIds, (userId) => this.fanOut.request(() => this.signalProtocolRelay.getActiveDevices(userId), stopSignal), stopSignal)
|
|
4791
4796
|
.catch((error) => {
|
|
4792
4797
|
throw firstItemError(error);
|
|
4793
4798
|
});
|
|
@@ -4829,7 +4834,7 @@ export class SignalProtocolServiceCipher {
|
|
|
4829
4834
|
encrypted = await this.encryptWithCurrentDistribution(actualGroupId, plaintextBytes);
|
|
4830
4835
|
}
|
|
4831
4836
|
const { distribution, ciphertext } = encrypted;
|
|
4832
|
-
if (!this.
|
|
4837
|
+
if (!this.signalProtocolRelay)
|
|
4833
4838
|
return { ciphertext, preMessages: [] };
|
|
4834
4839
|
// The distribution is at the chain index of this message, so a device
|
|
4835
4840
|
// that installs it decrypts this message. The bytes hold the chain key:
|
|
@@ -4899,7 +4904,7 @@ export class SignalProtocolServiceCipher {
|
|
|
4899
4904
|
const sealedSenders = await this.fanOut
|
|
4900
4905
|
.all(recipientUserIds, async (recipientUserId) => {
|
|
4901
4906
|
await this.ensureSenderKeyHandoffSessions(recipientUserId, needing.filter((target) => target.userId === recipientUserId), otherMembers.filter((member) => member.userId === recipientUserId), sessions);
|
|
4902
|
-
return this.
|
|
4907
|
+
return this.signalProtocolRelay?.sendMultiRecipientUnidentified
|
|
4903
4908
|
? this.resolveDistributionSealedSender(recipientUserId, groupId)
|
|
4904
4909
|
: this.useIdentifiedDeliveryOrThrow(recipientUserId, 'anonymous relay capability is not configured');
|
|
4905
4910
|
}, stopSignal)
|
|
@@ -5030,7 +5035,7 @@ export class SignalProtocolServiceCipher {
|
|
|
5030
5035
|
* @see https://developers.google.com/tink/streaming-aead/aes_gcm_hkdf_streaming
|
|
5031
5036
|
*/
|
|
5032
5037
|
async encryptBinaryAttachment(recipientId, data, options, sessions, stopSignal) {
|
|
5033
|
-
if (!this.
|
|
5038
|
+
if (!this.signalProtocolRelay) {
|
|
5034
5039
|
throw new EncryptionError('Relay server not configured. Cannot send attachments without server connection.', EncryptionErrorCode.INITIALIZATION_FAILED);
|
|
5035
5040
|
}
|
|
5036
5041
|
const fileDigest = CryptoUtils.bytesToBase64(await CryptoUtils.sha256(data));
|