@open-e2ee/signal-protocol-sdk 14.1.0 → 14.2.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/ARCHITECTURE.md +1 -1
- package/CHANGELOG.md +415 -0
- package/README.md +19 -14
- package/SECURITY.md +2 -2
- package/TROUBLESHOOTING.md +1 -1
- package/client/README.md +32 -21
- package/device/README.md +5 -5
- package/dist/client/client.d.ts +44 -34
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +221 -146
- package/dist/client/client.js.map +1 -1
- package/dist/client/compose.d.ts +7 -5
- package/dist/client/compose.d.ts.map +1 -1
- package/dist/client/compose.js +7 -2
- package/dist/client/compose.js.map +1 -1
- package/dist/client/config.d.ts +23 -14
- 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 +24 -16
- package/dist/client/device-set-reconciliation.d.ts.map +1 -1
- package/dist/client/device-set-reconciliation.js +17 -14
- package/dist/client/device-set-reconciliation.js.map +1 -1
- package/dist/client/event-hooks.d.ts +22 -7
- package/dist/client/event-hooks.d.ts.map +1 -1
- package/dist/client/event-hooks.js +35 -5
- 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 +8 -4
- package/dist/client/hosted-http-error.d.ts.map +1 -1
- package/dist/client/hosted-http-error.js +7 -4
- 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 +140 -74
- 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 +7 -7
- package/dist/client/send-deadline.d.ts.map +1 -1
- package/dist/client/send-deadline.js +37 -24
- 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} +21 -11
- package/dist/client/signal-relay-lifecycle.d.ts.map +1 -0
- package/dist/client/{relay-lifecycle.js → signal-relay-lifecycle.js} +19 -9
- 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 +11 -9
- package/dist/client/signal-service-cipher.d.ts.map +1 -1
- package/dist/client/signal-service-cipher.js +103 -98
- 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 +40 -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 +18 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/internal/groups/authority-certificate.d.ts +7 -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 -11
- 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 +43 -20
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/errors.d.ts +55 -7
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +61 -8
- package/dist/types/errors.js.map +1 -1
- package/dist/types/renamed-member.d.ts +41 -0
- package/dist/types/renamed-member.d.ts.map +1 -0
- package/dist/types/renamed-member.js +73 -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 +5 -5
- package/docs/CLIENT_COMPOSITION.md +10 -8
- package/docs/DEVIATIONS.md +10 -7
- package/docs/ERROR_HANDLING.md +24 -24
- package/docs/GETTING_STARTED.md +22 -16
- package/docs/INTERFACES.md +5 -5
- package/docs/PACKAGE_SURFACE.md +14 -4
- package/docs/PROTOCOL_POLICY.md +4 -4
- package/docs/RECIPES.md +274 -15
- package/hooks/README.md +11 -11
- package/local/store/expo/README.md +1 -1
- package/local/store/key-value/README.md +2 -2
- package/local/store/node/README.md +1 -1
- package/local/store/react-native/README.md +1 -1
- package/local/store/web/README.md +1 -1
- package/local/store/web-sqlite/README.md +2 -2
- package/package.json +16 -6
- package/remote/README.md +4 -4
- package/remote/object-store/convex-r2/README.md +1 -1
- package/remote/{relay → signal-relay}/README.md +14 -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
|
@@ -1,29 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HostedSignalProtocolRelayResumeError } from './hosted-resume-error.js';
|
|
2
2
|
import { hostedAssertionIdentifier } from "./hosted-assertion-id.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { HostedSignalProtocolRelayHttpError } from "./hosted-http-error.js";
|
|
4
|
+
import { submitHostedSignalProtocolRelayDeviceLink } from "./hosted-device-link-transport.js";
|
|
5
5
|
import { utf8Decode, websocketUrl } from "../internal/platform/index.js";
|
|
6
6
|
import AsyncLock from "async-lock";
|
|
7
7
|
import { createCompositeIdentityV1, decodeCompositeIdentityV1, encodeCompositeIdentityV1, } from "../keys/identity.js";
|
|
8
8
|
import { base64ToBytes, bytesToBase64, bytesToUrlSafeBase64, concatBytes, generateRandomBytes, generateUuidV4, sha256, stringToBytes, urlSafeToBase64, } from "../internal/crypto/index.js";
|
|
9
9
|
import { RemoteObjectUploadError } from "../remote/object-store/index.js";
|
|
10
|
-
import {
|
|
10
|
+
import { SignalProtocolRelayConnectionStateOwner } from "../remote/signal-relay/connection-state.js";
|
|
11
11
|
import { presenceHttpBody, } from "./hosted-presence-frames.js";
|
|
12
12
|
import { subscribeHostedMailbox, } from "./hosted-mailbox-subscription.js";
|
|
13
13
|
import { HostedGroupServer } from "./hosted-groups.js";
|
|
14
|
-
import { RELAY_PROTOCOL_VERSION,
|
|
15
|
-
import {
|
|
14
|
+
import { RELAY_PROTOCOL_VERSION, markSignalProtocolRelayAnswerVersion, signalRelayProtocolHeadersFor, throwIfUpgradeRequired, } from "./signal-relay-protocol.js";
|
|
15
|
+
import { HostedSignalProtocolRelayDeviceUnknownError, throwIfDeviceRevoked, } from "./hosted-device-standing.js";
|
|
16
16
|
import { HostedAnonymousDelivery, HostedAnonymousDeliveryError, decodeHostedAnonymousEnvelope, } from "./hosted-anonymous-delivery.js";
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
17
|
+
import { createAdapterSignalProtocolRelayFanOut, rethrowSignalProtocolRelayWorkStopped } from "./signal-relay-work.js";
|
|
18
|
+
import { withSignalProtocolRelayRequestDeadline } from "./signal-relay-request-deadline.js";
|
|
19
19
|
import { applyPreKeyUploads, parseHostedPreKeyStatus, parseStoredPendingPublication, parseStoredPublication, publicationMatchesStatus, registrationPreKey, statusPreKeys, storedPreKey, storedPublication, } from "./hosted-prekey-publication.js";
|
|
20
|
-
import { declareRefusesRemovedDevices,
|
|
21
|
-
import { onePeriodClosedRetry } from "./relay-period-close.js";
|
|
22
|
-
import { declareComparesDeviceSets, deviceSetRefusal, markDeviceSetRefusal, parseDeviceSetRefusal, } from "../remote/relay/device-set.js";
|
|
23
|
-
import { admitRepeatRequest, markAfterRepeatedRequest, } from "../remote/relay/request-admission.js";
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
|
|
20
|
+
import { declareRefusesRemovedDevices, markSignalProtocolRelayDeviceRefusal, } from "./signal-relay-device-refusal.js";
|
|
21
|
+
import { onePeriodClosedRetry } from "./signal-relay-period-close.js";
|
|
22
|
+
import { declareComparesDeviceSets, deviceSetRefusal, markDeviceSetRefusal, parseDeviceSetRefusal, } from "../remote/signal-relay/device-set.js";
|
|
23
|
+
import { admitRepeatRequest, markAfterRepeatedRequest, } from "../remote/signal-relay/request-admission.js";
|
|
24
|
+
import { SignalProtocolRelayReceiptInbox, declareSignalProtocolRelayReceiptIntake, decodeSignalProtocolRelayDeliveryReceipts, } from "./signal-relay-receipt-intake.js";
|
|
25
|
+
import { SignalProtocolRelayReceiptJoin, declareSignalProtocolRelayReceiptJoin, } from "./signal-relay-receipt-join.js";
|
|
26
|
+
import { hostedStoreRecordKey, readHostedStoreRecord, writeHostedStoreRecord, } from "./hosted-store-records.js";
|
|
27
|
+
const SESSION_METADATA_PREFIX = {
|
|
28
|
+
current: "signalRelay.session.v2:",
|
|
29
|
+
earlier: "hostedRelay.session.v1:",
|
|
30
|
+
};
|
|
27
31
|
const DEVICE_TOKEN_REFRESH_SECONDS = 60;
|
|
28
32
|
const MAXIMUM_RESPONSE_BYTES = 1024 * 1024;
|
|
29
33
|
const PREKEY_EXPIRY_MILLISECONDS = 30 * 24 * 60 * 60 * 1000;
|
|
@@ -70,7 +74,7 @@ const CONCLUSIVE_REFUSAL_CODES = new Set([
|
|
|
70
74
|
* outage, is not conclusive.
|
|
71
75
|
*/
|
|
72
76
|
function isConclusiveRefusal(error) {
|
|
73
|
-
return (error instanceof
|
|
77
|
+
return (error instanceof HostedSignalProtocolRelayHttpError &&
|
|
74
78
|
!error.retryable &&
|
|
75
79
|
CONCLUSIVE_REFUSAL_CODES.has(error.code));
|
|
76
80
|
}
|
|
@@ -88,7 +92,7 @@ async function withOneUncertainRetry(deliveryClass, post, beforeRepeat) {
|
|
|
88
92
|
}
|
|
89
93
|
catch (error) {
|
|
90
94
|
if (deliveryClass === "ephemeral" ||
|
|
91
|
-
!(error instanceof
|
|
95
|
+
!(error instanceof HostedSignalProtocolRelayHttpError) ||
|
|
92
96
|
error.code !== "DELIVERY_UNCERTAIN") {
|
|
93
97
|
throw error;
|
|
94
98
|
}
|
|
@@ -152,7 +156,7 @@ function decodeBase64Url(value, label) {
|
|
|
152
156
|
throw new Error(`${label} is invalid`);
|
|
153
157
|
}
|
|
154
158
|
}
|
|
155
|
-
function
|
|
159
|
+
function signalProtocolRelayScopeId(connection) {
|
|
156
160
|
return bytesToUrlSafeBase64(connection.relayScopeId);
|
|
157
161
|
}
|
|
158
162
|
function identifiedEndpoint(connection) {
|
|
@@ -160,10 +164,10 @@ function identifiedEndpoint(connection) {
|
|
|
160
164
|
}
|
|
161
165
|
/**
|
|
162
166
|
* Read the body of a Relay answer. An error answer throws, and the error
|
|
163
|
-
* records `
|
|
167
|
+
* records `signalRelayProtocolVersion`, the protocol version of the request that
|
|
164
168
|
* it answers.
|
|
165
169
|
*/
|
|
166
|
-
async function parseResponse(response,
|
|
170
|
+
async function parseResponse(response, signalRelayProtocolVersion) {
|
|
167
171
|
const body = await response.text();
|
|
168
172
|
if (body.length > MAXIMUM_RESPONSE_BYTES) {
|
|
169
173
|
throw new Error("Signal Protocol Relay response is too large");
|
|
@@ -184,11 +188,11 @@ async function parseResponse(response, relayProtocolVersion) {
|
|
|
184
188
|
if (!response.ok) {
|
|
185
189
|
// `UPGRADE_REQUIRED` and `DEVICE_REVOKED` are terminal at any error
|
|
186
190
|
// status, so `authenticatedPost` and every other retry, which matches only
|
|
187
|
-
// a `
|
|
188
|
-
// stays a `
|
|
191
|
+
// a `HostedSignalProtocolRelayHttpError`, never repeat them. `PROTOCOL_UNSUPPORTED`
|
|
192
|
+
// stays a `HostedSignalProtocolRelayHttpError` whose `retryable` is true: the Relay
|
|
189
193
|
// sends it for a version above the newest one that it serves, which
|
|
190
194
|
// happens only after a Relay rollback.
|
|
191
|
-
throwIfUpgradeRequired(response.status, parsed,
|
|
195
|
+
throwIfUpgradeRequired(response.status, parsed, signalRelayProtocolVersion);
|
|
192
196
|
throwIfDeviceRevoked(response.status, parsed);
|
|
193
197
|
const error = record(parsed) && record(parsed.error) ? parsed.error : {};
|
|
194
198
|
const code = typeof error.code === "string" ? error.code : "UNKNOWN";
|
|
@@ -197,10 +201,10 @@ async function parseResponse(response, relayProtocolVersion) {
|
|
|
197
201
|
: "Signal Protocol Relay request failed";
|
|
198
202
|
// A refused declared post names the devices of each account in
|
|
199
203
|
// `details`. The error keeps them for the device-set reconciliation.
|
|
200
|
-
throw
|
|
204
|
+
throw markSignalProtocolRelayAnswerVersion(new HostedSignalProtocolRelayHttpError(response.status, code, message, {
|
|
201
205
|
...(record(error.details) ? { data: { details: error.details } } : {}),
|
|
202
206
|
retryable: error.retryable === true,
|
|
203
|
-
}),
|
|
207
|
+
}), signalRelayProtocolVersion);
|
|
204
208
|
}
|
|
205
209
|
return parsed;
|
|
206
210
|
}
|
|
@@ -209,17 +213,17 @@ async function parseResponse(response, relayProtocolVersion) {
|
|
|
209
213
|
* generation names it. The Relay refuses such a device as NOT_FOUND.
|
|
210
214
|
*/
|
|
211
215
|
function missingDestination(userId, deviceId) {
|
|
212
|
-
return
|
|
216
|
+
return markSignalProtocolRelayDeviceRefusal(new Error("Signal Protocol Relay destination device does not exist"), { code: "NOT_FOUND", userId, deviceId });
|
|
213
217
|
}
|
|
214
|
-
async function postJson(connection,
|
|
218
|
+
async function postJson(connection, signalRelayProtocolVersion, path, body, token) {
|
|
215
219
|
const headers = new Headers({
|
|
216
220
|
accept: "application/json",
|
|
217
221
|
"content-type": "application/json",
|
|
218
|
-
...
|
|
222
|
+
...signalRelayProtocolHeadersFor(signalRelayProtocolVersion),
|
|
219
223
|
});
|
|
220
224
|
if (token !== undefined)
|
|
221
225
|
headers.set("authorization", `Bearer ${token}`);
|
|
222
|
-
return
|
|
226
|
+
return withSignalProtocolRelayRequestDeadline(async (signal) => {
|
|
223
227
|
let response;
|
|
224
228
|
try {
|
|
225
229
|
response = await fetch(`${identifiedEndpoint(connection)}${path}`, {
|
|
@@ -234,7 +238,7 @@ async function postJson(connection, relayProtocolVersion, path, body, token) {
|
|
|
234
238
|
catch (cause) {
|
|
235
239
|
throw new Error("Signal Protocol Relay request could not be completed", { cause });
|
|
236
240
|
}
|
|
237
|
-
return parseResponse(response,
|
|
241
|
+
return parseResponse(response, signalRelayProtocolVersion);
|
|
238
242
|
});
|
|
239
243
|
}
|
|
240
244
|
function serializedPreKey(prekey) {
|
|
@@ -277,10 +281,10 @@ async function registrationMaterialFingerprint(identity, registrationId, prekeys
|
|
|
277
281
|
async function registrationChallenge(request) {
|
|
278
282
|
return sha256(concatBytes(request.assertionPurpose === "recover"
|
|
279
283
|
? RECOVERY_CHALLENGE_LABEL
|
|
280
|
-
: REGISTRATION_CHALLENGE_LABEL, text(
|
|
284
|
+
: REGISTRATION_CHALLENGE_LABEL, text(signalProtocolRelayScopeId(request.connection)), text(await hostedAssertionIdentifier(request.assertion, request.assertionPurpose, request.operationId)), text(request.operationId), text(await registrationMaterialFingerprint(request.signalIdentity, request.registrationId, request.registrationPreKeys))));
|
|
281
285
|
}
|
|
282
286
|
async function sessionMetadataKey(connection) {
|
|
283
|
-
return
|
|
287
|
+
return hostedStoreRecordKey(SESSION_METADATA_PREFIX, bytesToUrlSafeBase64(await sha256(concatBytes(stringToBytes(connection.publishableKey), new Uint8Array([0]), connection.relayScopeId))));
|
|
284
288
|
}
|
|
285
289
|
function parseSession(value, connection) {
|
|
286
290
|
let parsed;
|
|
@@ -303,7 +307,7 @@ function parseSession(value, connection) {
|
|
|
303
307
|
parsed.generation < 0 ||
|
|
304
308
|
!Number.isSafeInteger(parsed.mailboxGeneration) ||
|
|
305
309
|
parsed.mailboxGeneration < 0 ||
|
|
306
|
-
parsed.relayScopeId !==
|
|
310
|
+
parsed.relayScopeId !== signalProtocolRelayScopeId(connection)) {
|
|
307
311
|
throw new Error("Stored Signal Protocol Relay session is invalid");
|
|
308
312
|
}
|
|
309
313
|
return {
|
|
@@ -317,6 +321,19 @@ function parseSession(value, connection) {
|
|
|
317
321
|
relayScopeId: parsed.relayScopeId,
|
|
318
322
|
};
|
|
319
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* The scope claim of a device token. Protocol version 3 names the claim
|
|
326
|
+
* `signal_relay_scope_id`, and protocol versions 1 and 2 name it
|
|
327
|
+
* `relay_scope_id`. A token that carries both claims with different values
|
|
328
|
+
* has no scope.
|
|
329
|
+
*/
|
|
330
|
+
function deviceTokenScopeId(claims) {
|
|
331
|
+
const scope = claims.signal_relay_scope_id;
|
|
332
|
+
const earlierScope = claims.relay_scope_id;
|
|
333
|
+
if (scope === undefined)
|
|
334
|
+
return earlierScope;
|
|
335
|
+
return earlierScope === undefined || earlierScope === scope ? scope : undefined;
|
|
336
|
+
}
|
|
320
337
|
function tokenExpiration(token, session) {
|
|
321
338
|
const parts = token.split(".");
|
|
322
339
|
if (parts.length !== 3)
|
|
@@ -328,7 +345,7 @@ function tokenExpiration(token, session) {
|
|
|
328
345
|
claims.device_id !== session.deviceId ||
|
|
329
346
|
claims.generation !== session.generation ||
|
|
330
347
|
claims.mailbox_generation !== session.mailboxGeneration ||
|
|
331
|
-
claims
|
|
348
|
+
deviceTokenScopeId(claims) !== session.relayScopeId ||
|
|
332
349
|
!Number.isSafeInteger(claims.exp)) {
|
|
333
350
|
return 0;
|
|
334
351
|
}
|
|
@@ -338,6 +355,18 @@ function tokenExpiration(token, session) {
|
|
|
338
355
|
return 0;
|
|
339
356
|
}
|
|
340
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* The issuer and audience pairs of a device token. Protocol versions 1 and 2
|
|
360
|
+
* issue the first pair, and protocol version 3 issues the second. The SDK
|
|
361
|
+
* accepts each pair until the Relay retires versions 1 and 2.
|
|
362
|
+
*/
|
|
363
|
+
const SIGNAL_RELAY_DEVICE_TOKEN_ISSUERS = [
|
|
364
|
+
{ issuer: 'open-e2ee-relay', audience: 'open-e2ee-relay-device' },
|
|
365
|
+
{ issuer: 'signal-relay', audience: 'signal-relay-device' },
|
|
366
|
+
];
|
|
367
|
+
function isSignalRelayDeviceTokenIssuer(issuer, audience) {
|
|
368
|
+
return SIGNAL_RELAY_DEVICE_TOKEN_ISSUERS.some((pair) => pair.issuer === issuer && pair.audience === audience);
|
|
369
|
+
}
|
|
341
370
|
function assertLinkToken(session) {
|
|
342
371
|
const parts = session.deviceToken.split('.');
|
|
343
372
|
if (parts.length !== 3)
|
|
@@ -348,7 +377,7 @@ function assertLinkToken(session) {
|
|
|
348
377
|
header.alg !== 'EdDSA' || header.typ !== 'JWT' || typeof header.kid !== 'string' || !header.kid ||
|
|
349
378
|
decodeBase64Url(parts[2], 'Device token signature').length !== 64 ||
|
|
350
379
|
!record(claims) || typeof claims.jti !== 'string' || !claims.jti ||
|
|
351
|
-
claims.iss
|
|
380
|
+
!isSignalRelayDeviceTokenIssuer(claims.iss, claims.aud) || claims.token_use !== 'device' ||
|
|
352
381
|
typeof claims.account_state_id !== 'string' || !claims.account_state_id ||
|
|
353
382
|
!Number.isSafeInteger(claims.iat) || claims.iat < 0 ||
|
|
354
383
|
tokenExpiration(session.deviceToken, session) <= claims.iat)
|
|
@@ -418,13 +447,13 @@ function decodeDeliveryWire(value) {
|
|
|
418
447
|
version: DELIVERY_WIRE_VERSION,
|
|
419
448
|
};
|
|
420
449
|
}
|
|
421
|
-
export class
|
|
450
|
+
export class HostedSignalProtocolRelayHttpTransport {
|
|
422
451
|
connection;
|
|
423
452
|
storage;
|
|
424
453
|
deviceAuthentication;
|
|
425
454
|
session;
|
|
426
455
|
persistRefreshedToken;
|
|
427
|
-
|
|
456
|
+
signalRelayProtocolVersion;
|
|
428
457
|
groups;
|
|
429
458
|
groupServer;
|
|
430
459
|
anonymousDelivery;
|
|
@@ -436,22 +465,22 @@ export class HostedRelayHttpTransport {
|
|
|
436
465
|
ephemeralAcknowledgments = new Set();
|
|
437
466
|
subscription;
|
|
438
467
|
subscriptionGeneration = 0;
|
|
439
|
-
connectionState = new
|
|
468
|
+
connectionState = new SignalProtocolRelayConnectionStateOwner();
|
|
440
469
|
presenceListeners = new Set();
|
|
441
|
-
receiptInbox = new
|
|
442
|
-
receiptJoin = new
|
|
470
|
+
receiptInbox = new SignalProtocolRelayReceiptInbox();
|
|
471
|
+
receiptJoin = new SignalProtocolRelayReceiptJoin();
|
|
443
472
|
constructor(connection, storage, deviceAuthentication, session, persistRefreshedToken = true,
|
|
444
473
|
/**
|
|
445
474
|
* @internal The Relay protocol version of the client that owns this
|
|
446
475
|
* transport. Every carrier of the client sends it.
|
|
447
476
|
*/
|
|
448
|
-
|
|
477
|
+
signalRelayProtocolVersion = RELAY_PROTOCOL_VERSION) {
|
|
449
478
|
this.connection = connection;
|
|
450
479
|
this.storage = storage;
|
|
451
480
|
this.deviceAuthentication = deviceAuthentication;
|
|
452
481
|
this.session = session;
|
|
453
482
|
this.persistRefreshedToken = persistRefreshedToken;
|
|
454
|
-
this.
|
|
483
|
+
this.signalRelayProtocolVersion = signalRelayProtocolVersion;
|
|
455
484
|
// The Relay refuses a removed device's mailbox on every send path before
|
|
456
485
|
// its device list shows the removal, so a direct send may post first.
|
|
457
486
|
declareRefusesRemovedDevices(this);
|
|
@@ -461,16 +490,16 @@ export class HostedRelayHttpTransport {
|
|
|
461
490
|
declareComparesDeviceSets(this);
|
|
462
491
|
// The Relay sends Relay delivery receipts to the sender, and replies to
|
|
463
492
|
// each acknowledgment with the messages whose receipt it owns.
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
this.groups = new HostedGroupServer(connection,
|
|
493
|
+
declareSignalProtocolRelayReceiptIntake(this, this.receiptInbox);
|
|
494
|
+
declareSignalProtocolRelayReceiptJoin(this, this.receiptJoin);
|
|
495
|
+
this.groups = new HostedGroupServer(connection, signalRelayProtocolVersion);
|
|
467
496
|
this.groupServer = {
|
|
468
497
|
server: this.groups,
|
|
469
498
|
issueAuthCredential: (userId, authorityKeyId) => this.issueAuthCredential(userId, authorityKeyId),
|
|
470
499
|
issueProfileKeyCredential: (userId, request, authorityKeyId) => this.issueProfileKeyCredential(userId, request, authorityKeyId),
|
|
471
500
|
setUnidentifiedAccessKey: (userId, accessKey) => this.setUnidentifiedAccessKey(userId, accessKey),
|
|
472
501
|
};
|
|
473
|
-
this.fanOut =
|
|
502
|
+
this.fanOut = createAdapterSignalProtocolRelayFanOut(this);
|
|
474
503
|
this.anonymousDelivery = new HostedAnonymousDelivery(connection, this.fanOut, async (accountAddress, deviceId, declaredDeviceIds) => {
|
|
475
504
|
const key = `${accountAddress}\0${deviceId}`;
|
|
476
505
|
if (!this.destinationGenerations.has(key))
|
|
@@ -483,7 +512,7 @@ export class HostedRelayHttpTransport {
|
|
|
483
512
|
if (generation === undefined)
|
|
484
513
|
throw missingDestination(accountAddress, deviceId);
|
|
485
514
|
return { accountAddress, deviceId, generation };
|
|
486
|
-
}, (clientMessageId, request) => admitRepeatRequest(this, clientMessageId, request),
|
|
515
|
+
}, (clientMessageId, request) => admitRepeatRequest(this, clientMessageId, request), signalRelayProtocolVersion, ({ accountAddress, deviceId, generation }) => this.destinationRecovered(accountAddress, deviceId, generation, true));
|
|
487
516
|
}
|
|
488
517
|
get accountId() {
|
|
489
518
|
return this.session.canonicalAccountId;
|
|
@@ -525,7 +554,7 @@ export class HostedRelayHttpTransport {
|
|
|
525
554
|
return await this.commitObjectUpload(objectId);
|
|
526
555
|
}
|
|
527
556
|
catch (error) {
|
|
528
|
-
if (error instanceof
|
|
557
|
+
if (error instanceof HostedSignalProtocolRelayHttpError &&
|
|
529
558
|
error.code === "UPLOAD_INCOMPLETE")
|
|
530
559
|
return null;
|
|
531
560
|
throw this.uploadError(error, "settlement");
|
|
@@ -539,7 +568,7 @@ export class HostedRelayHttpTransport {
|
|
|
539
568
|
},
|
|
540
569
|
};
|
|
541
570
|
uploadError(error, phase) {
|
|
542
|
-
if (!(error instanceof
|
|
571
|
+
if (!(error instanceof HostedSignalProtocolRelayHttpError))
|
|
543
572
|
return error;
|
|
544
573
|
switch (error.code) {
|
|
545
574
|
case "UPLOAD_EXPIRED":
|
|
@@ -564,7 +593,7 @@ export class HostedRelayHttpTransport {
|
|
|
564
593
|
}
|
|
565
594
|
}
|
|
566
595
|
async persistSession() {
|
|
567
|
-
await this.storage
|
|
596
|
+
await writeHostedStoreRecord(this.storage, await sessionMetadataKey(this.connection), JSON.stringify(this.session));
|
|
568
597
|
}
|
|
569
598
|
async commitObjectUpload(objectId) {
|
|
570
599
|
const value = await this.authenticatedPost("/objects/commit-upload", {
|
|
@@ -592,7 +621,7 @@ export class HostedRelayHttpTransport {
|
|
|
592
621
|
const proof = await this.deviceAuthentication.signChallenge(challenge);
|
|
593
622
|
let value;
|
|
594
623
|
try {
|
|
595
|
-
value = await postJson(this.connection, this.
|
|
624
|
+
value = await postJson(this.connection, this.signalRelayProtocolVersion, "/identity/token", {
|
|
596
625
|
accountAddress: this.session.canonicalAccountId,
|
|
597
626
|
// The Relay checks this key against the keys that a recovery revoked.
|
|
598
627
|
deviceAuthenticationPublicKey: bytesToBase64(this.deviceAuthentication.publicKey),
|
|
@@ -605,10 +634,10 @@ export class HostedRelayHttpTransport {
|
|
|
605
634
|
}
|
|
606
635
|
catch (error) {
|
|
607
636
|
// A token refusal names this device, so it is not a
|
|
608
|
-
// `
|
|
637
|
+
// `HostedSignalProtocolRelayHttpError`. A catch that reads `NOT_FOUND` as a missing
|
|
609
638
|
// destination cannot take it.
|
|
610
|
-
if (error instanceof
|
|
611
|
-
throw new
|
|
639
|
+
if (error instanceof HostedSignalProtocolRelayHttpError && error.code === "NOT_FOUND")
|
|
640
|
+
throw new HostedSignalProtocolRelayDeviceUnknownError(error.status, error.message);
|
|
612
641
|
throw error;
|
|
613
642
|
}
|
|
614
643
|
if (!record(value) || typeof value.deviceToken !== "string") {
|
|
@@ -648,20 +677,20 @@ export class HostedRelayHttpTransport {
|
|
|
648
677
|
throw new Error('Signal Protocol Relay returned an invalid device token');
|
|
649
678
|
return body(claims.jti);
|
|
650
679
|
};
|
|
651
|
-
const value = await
|
|
680
|
+
const value = await submitHostedSignalProtocolRelayDeviceLink(request, {
|
|
652
681
|
relayScopeId: this.session.relayScopeId,
|
|
653
682
|
materialFingerprint,
|
|
654
683
|
signalRegistration: signalRegistration(request.signalIdentity, request.registrationId, request.registrationPreKeys),
|
|
655
684
|
post: async (body) => {
|
|
656
685
|
let token = await this.token();
|
|
657
686
|
try {
|
|
658
|
-
return await postJson(this.connection, this.
|
|
687
|
+
return await postJson(this.connection, this.signalRelayProtocolVersion, '/identity/devices/link', await bodyFor(body, token), token);
|
|
659
688
|
}
|
|
660
689
|
catch (error) {
|
|
661
|
-
if (!(error instanceof
|
|
690
|
+
if (!(error instanceof HostedSignalProtocolRelayHttpError) || error.code !== 'TOKEN_INVALID')
|
|
662
691
|
throw error;
|
|
663
692
|
token = await this.token(true);
|
|
664
|
-
return postJson(this.connection, this.
|
|
693
|
+
return postJson(this.connection, this.signalRelayProtocolVersion, '/identity/devices/link', await bodyFor(body, token), token);
|
|
665
694
|
}
|
|
666
695
|
},
|
|
667
696
|
});
|
|
@@ -685,7 +714,7 @@ export class HostedRelayHttpTransport {
|
|
|
685
714
|
throw new Error('Signal Protocol Relay returned an invalid managed device link');
|
|
686
715
|
assertLinkToken(session);
|
|
687
716
|
const key = await sessionMetadataKey(this.connection);
|
|
688
|
-
const stored = await storage
|
|
717
|
+
const stored = await readHostedStoreRecord(storage, key);
|
|
689
718
|
if (stored !== null) {
|
|
690
719
|
const existing = parseSession(stored, this.connection);
|
|
691
720
|
assertLinkToken(existing);
|
|
@@ -699,22 +728,24 @@ export class HostedRelayHttpTransport {
|
|
|
699
728
|
throw new Error('Stored Signal Protocol Relay link session conflicts with the retained attempt');
|
|
700
729
|
session = existing;
|
|
701
730
|
}
|
|
702
|
-
const transport = new
|
|
731
|
+
const transport = new HostedSignalProtocolRelayHttpTransport(this.connection, storage, request.newDeviceAuthentication, session, true, this.signalRelayProtocolVersion);
|
|
703
732
|
// Persist the complete shape before synchronization or token renewal can fail.
|
|
704
733
|
try {
|
|
705
|
-
await storage
|
|
734
|
+
await writeHostedStoreRecord(storage, key, JSON.stringify(session));
|
|
706
735
|
await transport.ensureAuthenticated();
|
|
707
736
|
}
|
|
708
737
|
catch (error) {
|
|
709
738
|
// A renewal refusal cannot prove that the accepted link had no effect.
|
|
710
|
-
if (error instanceof
|
|
739
|
+
if (error instanceof HostedSignalProtocolRelayHttpError && !error.retryable &&
|
|
711
740
|
(error.code === 'KEY_PROOF_INVALID' || error.code === 'CONFLICT'))
|
|
712
741
|
throw new Error('Signal Protocol Relay accepted the link but session adoption failed', { cause: error });
|
|
713
742
|
throw error;
|
|
714
743
|
}
|
|
744
|
+
const scopeId = this.connection.relayScopeId.slice();
|
|
715
745
|
return {
|
|
716
746
|
canonicalAccountId: session.canonicalAccountId, deviceId: session.deviceId,
|
|
717
|
-
|
|
747
|
+
signalProtocolRelayScopeId: scopeId, relayScopeId: scopeId,
|
|
748
|
+
signalProtocolRelay: transport, relay: transport,
|
|
718
749
|
remoteObjectStore: transport.objectStore, transport,
|
|
719
750
|
accountPreserved: true, protocolStateCopied: false,
|
|
720
751
|
};
|
|
@@ -727,10 +758,10 @@ export class HostedRelayHttpTransport {
|
|
|
727
758
|
async authenticatedPost(path, body, beforeRepeat) {
|
|
728
759
|
let token = await this.token();
|
|
729
760
|
try {
|
|
730
|
-
return await postJson(this.connection, this.
|
|
761
|
+
return await postJson(this.connection, this.signalRelayProtocolVersion, path, body, token);
|
|
731
762
|
}
|
|
732
763
|
catch (error) {
|
|
733
|
-
if (!(error instanceof
|
|
764
|
+
if (!(error instanceof HostedSignalProtocolRelayHttpError) ||
|
|
734
765
|
error.code !== "TOKEN_INVALID") {
|
|
735
766
|
throw error;
|
|
736
767
|
}
|
|
@@ -741,7 +772,7 @@ export class HostedRelayHttpTransport {
|
|
|
741
772
|
catch {
|
|
742
773
|
throw error;
|
|
743
774
|
}
|
|
744
|
-
return postJson(this.connection, this.
|
|
775
|
+
return postJson(this.connection, this.signalRelayProtocolVersion, path, body, token);
|
|
745
776
|
}
|
|
746
777
|
}
|
|
747
778
|
assertCurrentIdentity(userId, deviceId, identityType = "aci") {
|
|
@@ -783,7 +814,7 @@ export class HostedRelayHttpTransport {
|
|
|
783
814
|
: this.directory(userId));
|
|
784
815
|
}
|
|
785
816
|
catch (error) {
|
|
786
|
-
|
|
817
|
+
rethrowSignalProtocolRelayWorkStopped(error);
|
|
787
818
|
return false;
|
|
788
819
|
}
|
|
789
820
|
const listed = this.destinationGenerations.get(`${userId}\0${String(deviceId)}`);
|
|
@@ -847,7 +878,7 @@ export class HostedRelayHttpTransport {
|
|
|
847
878
|
? this.session.mailboxGeneration
|
|
848
879
|
: this.destinationGenerations.get(key);
|
|
849
880
|
if (generation === undefined) {
|
|
850
|
-
throw new
|
|
881
|
+
throw new HostedSignalProtocolRelayHttpError(404, "NOT_FOUND", "Signal Protocol Relay destination device does not exist");
|
|
851
882
|
}
|
|
852
883
|
return this.authenticatedPost(path, {
|
|
853
884
|
accountAddress: userId,
|
|
@@ -862,7 +893,7 @@ export class HostedRelayHttpTransport {
|
|
|
862
893
|
}
|
|
863
894
|
catch (error) {
|
|
864
895
|
if (!cached ||
|
|
865
|
-
!(error instanceof
|
|
896
|
+
!(error instanceof HostedSignalProtocolRelayHttpError) ||
|
|
866
897
|
error.code !== "NOT_FOUND") {
|
|
867
898
|
throw error;
|
|
868
899
|
}
|
|
@@ -896,7 +927,7 @@ export class HostedRelayHttpTransport {
|
|
|
896
927
|
* publication returns after that one read.
|
|
897
928
|
*/
|
|
898
929
|
async publishCurrentPrekeys(plan) {
|
|
899
|
-
await hostedPreKeyPublicationLock.acquire(await sessionMetadataKey(this.connection), async () => {
|
|
930
|
+
await hostedPreKeyPublicationLock.acquire((await sessionMetadataKey(this.connection)).current, async () => {
|
|
900
931
|
const current = await this.currentIdentity();
|
|
901
932
|
let status = await this.prekeyStatus(this.session.canonicalAccountId, this.session.deviceId);
|
|
902
933
|
if (status.authorityGeneration !== this.session.generation ||
|
|
@@ -1013,7 +1044,7 @@ export class HostedRelayHttpTransport {
|
|
|
1013
1044
|
messages: value.messages.map((candidate) => this.incomingEnvelope(candidate)),
|
|
1014
1045
|
receipts: value.receipts === undefined
|
|
1015
1046
|
? []
|
|
1016
|
-
:
|
|
1047
|
+
: decodeSignalProtocolRelayDeliveryReceipts(value.receipts),
|
|
1017
1048
|
...(value.nextCursor === undefined
|
|
1018
1049
|
? {}
|
|
1019
1050
|
: { nextCursor: value.nextCursor }),
|
|
@@ -1081,7 +1112,7 @@ export class HostedRelayHttpTransport {
|
|
|
1081
1112
|
if (proof.byteLength !== 64)
|
|
1082
1113
|
throw new Error("Signal Protocol Relay certificate proof is invalid");
|
|
1083
1114
|
try {
|
|
1084
|
-
const result = await postJson(this.connection, this.
|
|
1115
|
+
const result = await postJson(this.connection, this.signalRelayProtocolVersion, "/certificates/issue", {
|
|
1085
1116
|
publishableKey: this.connection.publishableKey,
|
|
1086
1117
|
nonce,
|
|
1087
1118
|
deviceProof: bytesToBase64(proof),
|
|
@@ -1095,7 +1126,7 @@ export class HostedRelayHttpTransport {
|
|
|
1095
1126
|
}
|
|
1096
1127
|
catch (error) {
|
|
1097
1128
|
if (attempt > 0 ||
|
|
1098
|
-
!(error instanceof
|
|
1129
|
+
!(error instanceof HostedSignalProtocolRelayHttpError) ||
|
|
1099
1130
|
error.code !== "TOKEN_INVALID")
|
|
1100
1131
|
throw error;
|
|
1101
1132
|
}
|
|
@@ -1258,7 +1289,7 @@ export class HostedRelayHttpTransport {
|
|
|
1258
1289
|
for (let start = MAXIMUM_ACKNOWLEDGMENT_IDS; start < receiptIds.length; start += MAXIMUM_ACKNOWLEDGMENT_IDS)
|
|
1259
1290
|
await this.acknowledge([], receiptIds.slice(start, start + MAXIMUM_ACKNOWLEDGMENT_IDS));
|
|
1260
1291
|
}
|
|
1261
|
-
|
|
1292
|
+
receiveSignalProtocolRelayReceipt(receipt) {
|
|
1262
1293
|
return this.receiptInbox.handOff(receipt);
|
|
1263
1294
|
}
|
|
1264
1295
|
async createObjectUpload(input) {
|
|
@@ -1298,7 +1329,7 @@ export class HostedRelayHttpTransport {
|
|
|
1298
1329
|
expiresAt: tokenExpiration(token, this.session) * 1_000,
|
|
1299
1330
|
headers: {
|
|
1300
1331
|
authorization: `Bearer ${token}`,
|
|
1301
|
-
...
|
|
1332
|
+
...signalRelayProtocolHeadersFor(this.signalRelayProtocolVersion),
|
|
1302
1333
|
"x-open-e2ee-publishable-key": this.connection.publishableKey,
|
|
1303
1334
|
"x-open-e2ee-object-id": input.objectId,
|
|
1304
1335
|
"x-open-e2ee-attachment-capability": input.readCapability,
|
|
@@ -1319,7 +1350,7 @@ export class HostedRelayHttpTransport {
|
|
|
1319
1350
|
generation = this.destinationGenerations.get(key);
|
|
1320
1351
|
}
|
|
1321
1352
|
if (generation === undefined && envelope.declaredDeviceIds !== undefined) {
|
|
1322
|
-
throw markDeviceSetRefusal(new
|
|
1353
|
+
throw markDeviceSetRefusal(new HostedSignalProtocolRelayHttpError(409, "DEVICE_SET_MISMATCH", "The declared device set differs from the device directory"), this.directoryDeviceSetRefusal(envelope.targetUserId, envelope.declaredDeviceIds));
|
|
1323
1354
|
}
|
|
1324
1355
|
if (generation === undefined)
|
|
1325
1356
|
throw missingDestination(envelope.targetUserId, envelope.targetDeviceId);
|
|
@@ -1375,14 +1406,14 @@ export class HostedRelayHttpTransport {
|
|
|
1375
1406
|
userId: envelope.targetUserId,
|
|
1376
1407
|
deviceId: envelope.targetDeviceId,
|
|
1377
1408
|
};
|
|
1378
|
-
if (deviceSets !== undefined && error instanceof
|
|
1409
|
+
if (deviceSets !== undefined && error instanceof HostedSignalProtocolRelayHttpError) {
|
|
1379
1410
|
const refusal = parseDeviceSetRefusal(error.code, error.data?.details);
|
|
1380
1411
|
if (refusal !== undefined) {
|
|
1381
1412
|
this.forgetDestinationGenerations(refusal.accounts);
|
|
1382
1413
|
throw answer(markDeviceSetRefusal(error, refusal));
|
|
1383
1414
|
}
|
|
1384
1415
|
}
|
|
1385
|
-
const staleDevice = (stale) => answer(
|
|
1416
|
+
const staleDevice = (stale) => answer(markSignalProtocolRelayDeviceRefusal(new HostedSignalProtocolRelayHttpError(stale.status, "STALE_DEVICE", stale.message, {
|
|
1386
1417
|
data: {
|
|
1387
1418
|
code: "STALE_DEVICE",
|
|
1388
1419
|
message: stale.message,
|
|
@@ -1391,13 +1422,13 @@ export class HostedRelayHttpTransport {
|
|
|
1391
1422
|
},
|
|
1392
1423
|
retryable: stale.retryable,
|
|
1393
1424
|
}), { code: "STALE_DEVICE", ...device }));
|
|
1394
|
-
if (error instanceof
|
|
1425
|
+
if (error instanceof HostedSignalProtocolRelayHttpError &&
|
|
1395
1426
|
error.code === "STALE_DEVICE") {
|
|
1396
1427
|
throw staleDevice(error);
|
|
1397
1428
|
}
|
|
1398
1429
|
// Only the Relay's own error body names NOT_FOUND. A 404 without it
|
|
1399
1430
|
// fails to parse or carries no code, so it is not a device refusal.
|
|
1400
|
-
if (error instanceof
|
|
1431
|
+
if (error instanceof HostedSignalProtocolRelayHttpError && error.code === "NOT_FOUND") {
|
|
1401
1432
|
// A recovery retired the posted generation. As for a stale device,
|
|
1402
1433
|
// the send archives the session and posts to the recovered device.
|
|
1403
1434
|
// A declared post gets the declared STALE_DEVICE that the Relay
|
|
@@ -1416,7 +1447,7 @@ export class HostedRelayHttpTransport {
|
|
|
1416
1447
|
],
|
|
1417
1448
|
});
|
|
1418
1449
|
}
|
|
1419
|
-
throw answer(
|
|
1450
|
+
throw answer(markSignalProtocolRelayDeviceRefusal(error, { code: "NOT_FOUND", ...device }));
|
|
1420
1451
|
}
|
|
1421
1452
|
throw answer(error);
|
|
1422
1453
|
}
|
|
@@ -1457,7 +1488,7 @@ export class HostedRelayHttpTransport {
|
|
|
1457
1488
|
const generation = ++this.subscriptionGeneration;
|
|
1458
1489
|
const subscription = subscribeHostedMailbox({
|
|
1459
1490
|
...options,
|
|
1460
|
-
|
|
1491
|
+
signalRelayProtocolVersion: this.signalRelayProtocolVersion,
|
|
1461
1492
|
onConnectionState: (state, reason) => {
|
|
1462
1493
|
if (generation === this.subscriptionGeneration)
|
|
1463
1494
|
this.connectionState.move(state, reason);
|
|
@@ -1531,12 +1562,20 @@ export class HostedRelayHttpTransport {
|
|
|
1531
1562
|
subscription.unsubscribe();
|
|
1532
1563
|
};
|
|
1533
1564
|
}
|
|
1534
|
-
get
|
|
1565
|
+
get signalProtocolRelayConnectionState() {
|
|
1535
1566
|
return this.connectionState.current;
|
|
1536
1567
|
}
|
|
1537
|
-
|
|
1568
|
+
subscribeSignalProtocolRelayConnectionState(listener) {
|
|
1538
1569
|
return this.connectionState.subscribe(listener);
|
|
1539
1570
|
}
|
|
1571
|
+
/** @deprecated Use `signalProtocolRelayConnectionState`. SDK 15.0.0 removes this name. */
|
|
1572
|
+
get relayConnectionState() {
|
|
1573
|
+
return this.signalProtocolRelayConnectionState;
|
|
1574
|
+
}
|
|
1575
|
+
/** @deprecated Use `subscribeSignalProtocolRelayConnectionState`. SDK 15.0.0 removes this name. */
|
|
1576
|
+
subscribeRelayConnectionState(listener) {
|
|
1577
|
+
return this.subscribeSignalProtocolRelayConnectionState(listener);
|
|
1578
|
+
}
|
|
1540
1579
|
/**
|
|
1541
1580
|
* Acknowledges over the live mailbox socket when one exists, in one frame per
|
|
1542
1581
|
* drained burst, and over HTTP otherwise.
|
|
@@ -1581,7 +1620,7 @@ export class HostedRelayHttpTransport {
|
|
|
1581
1620
|
.identityPublicMaterial);
|
|
1582
1621
|
}
|
|
1583
1622
|
catch (error) {
|
|
1584
|
-
if (error instanceof
|
|
1623
|
+
if (error instanceof HostedSignalProtocolRelayHttpError && error.code === "NOT_FOUND")
|
|
1585
1624
|
return null;
|
|
1586
1625
|
throw error;
|
|
1587
1626
|
}
|
|
@@ -1598,7 +1637,7 @@ export class HostedRelayHttpTransport {
|
|
|
1598
1637
|
value = await this.prekeyPost("/prekeys/consume", userId, deviceId, identityType);
|
|
1599
1638
|
}
|
|
1600
1639
|
catch (error) {
|
|
1601
|
-
if (error instanceof
|
|
1640
|
+
if (error instanceof HostedSignalProtocolRelayHttpError && error.code === "NOT_FOUND")
|
|
1602
1641
|
return null;
|
|
1603
1642
|
throw error;
|
|
1604
1643
|
}
|
|
@@ -1750,7 +1789,7 @@ export class HostedRelayHttpTransport {
|
|
|
1750
1789
|
}
|
|
1751
1790
|
}
|
|
1752
1791
|
}
|
|
1753
|
-
export async function
|
|
1792
|
+
export async function bootstrapHostedSignalProtocolRelayTransport(request) {
|
|
1754
1793
|
const proof = await request.deviceAuthentication.signChallenge(await registrationChallenge(request));
|
|
1755
1794
|
// A new client starts at the default version, which the transport built
|
|
1756
1795
|
// below also takes.
|
|
@@ -1781,7 +1820,7 @@ export async function bootstrapHostedRelayTransport(request) {
|
|
|
1781
1820
|
preKeyPublication: storedPublication(generation, materialFingerprint, request.operationId, 0, request.registrationPreKeys),
|
|
1782
1821
|
relayScopeId: requiredString(value, "relayScopeId"),
|
|
1783
1822
|
};
|
|
1784
|
-
if (session.relayScopeId !==
|
|
1823
|
+
if (session.relayScopeId !== signalProtocolRelayScopeId(request.connection) ||
|
|
1785
1824
|
session.deviceId < 1 ||
|
|
1786
1825
|
session.generation < 0 ||
|
|
1787
1826
|
session.mailboxGeneration < 0 ||
|
|
@@ -1789,31 +1828,34 @@ export async function bootstrapHostedRelayTransport(request) {
|
|
|
1789
1828
|
Math.floor(Date.now() / 1_000)) {
|
|
1790
1829
|
throw new Error("Signal Protocol Relay returned an invalid registration");
|
|
1791
1830
|
}
|
|
1792
|
-
await request.storage
|
|
1793
|
-
const transport = new
|
|
1831
|
+
await writeHostedStoreRecord(request.storage, await sessionMetadataKey(request.connection), JSON.stringify(session));
|
|
1832
|
+
const transport = new HostedSignalProtocolRelayHttpTransport(request.connection, request.storage, request.deviceAuthentication, session);
|
|
1833
|
+
const scopeId = request.connection.relayScopeId.slice();
|
|
1794
1834
|
return {
|
|
1795
1835
|
canonicalAccountId: session.canonicalAccountId,
|
|
1796
1836
|
deviceId: session.deviceId,
|
|
1837
|
+
signalProtocolRelay: transport,
|
|
1797
1838
|
relay: transport,
|
|
1798
|
-
|
|
1839
|
+
signalProtocolRelayScopeId: scopeId,
|
|
1840
|
+
relayScopeId: scopeId,
|
|
1799
1841
|
remoteObjectStore: transport.objectStore,
|
|
1800
1842
|
transport,
|
|
1801
1843
|
};
|
|
1802
1844
|
}
|
|
1803
|
-
export async function
|
|
1845
|
+
export async function resumeHostedSignalProtocolRelayTransport(options) {
|
|
1804
1846
|
let stored;
|
|
1805
1847
|
try {
|
|
1806
|
-
stored = await options.storage
|
|
1848
|
+
stored = await readHostedStoreRecord(options.storage, await sessionMetadataKey(options.connection));
|
|
1807
1849
|
}
|
|
1808
1850
|
catch (cause) {
|
|
1809
1851
|
if (options.requireExisting) {
|
|
1810
|
-
throw new
|
|
1852
|
+
throw new HostedSignalProtocolRelayResumeError('RETAINED_STATE_UNREADABLE', 'reading-local-state', { cause });
|
|
1811
1853
|
}
|
|
1812
1854
|
throw cause;
|
|
1813
1855
|
}
|
|
1814
1856
|
if (!stored) {
|
|
1815
1857
|
if (options.requireExisting) {
|
|
1816
|
-
throw new
|
|
1858
|
+
throw new HostedSignalProtocolRelayResumeError('RETAINED_SESSION_UNAVAILABLE', 'reading-local-state');
|
|
1817
1859
|
}
|
|
1818
1860
|
return undefined;
|
|
1819
1861
|
}
|
|
@@ -1823,28 +1865,31 @@ export async function resumeHostedRelayTransport(options) {
|
|
|
1823
1865
|
}
|
|
1824
1866
|
catch (cause) {
|
|
1825
1867
|
if (options.requireExisting) {
|
|
1826
|
-
throw new
|
|
1868
|
+
throw new HostedSignalProtocolRelayResumeError('RETAINED_SESSION_UNAVAILABLE', 'reading-local-state', { cause });
|
|
1827
1869
|
}
|
|
1828
1870
|
throw cause;
|
|
1829
1871
|
}
|
|
1830
|
-
const transport = new
|
|
1872
|
+
const transport = new HostedSignalProtocolRelayHttpTransport(options.connection, options.storage, options.deviceAuthentication, session);
|
|
1831
1873
|
options.onAuthenticating?.();
|
|
1832
1874
|
await transport.ensureAuthenticated(true);
|
|
1875
|
+
const scopeId = options.connection.relayScopeId.slice();
|
|
1833
1876
|
return {
|
|
1834
1877
|
canonicalAccountId: session.canonicalAccountId,
|
|
1835
1878
|
deviceId: session.deviceId,
|
|
1879
|
+
signalProtocolRelay: transport,
|
|
1836
1880
|
relay: transport,
|
|
1837
|
-
|
|
1881
|
+
signalProtocolRelayScopeId: scopeId,
|
|
1882
|
+
relayScopeId: scopeId,
|
|
1838
1883
|
remoteObjectStore: transport.objectStore,
|
|
1839
1884
|
transport,
|
|
1840
1885
|
};
|
|
1841
1886
|
}
|
|
1842
1887
|
/** Compose a link using a detached active session without publication writes. */
|
|
1843
|
-
export async function
|
|
1844
|
-
const stored = await options.activeStorage
|
|
1888
|
+
export async function linkHostedSignalProtocolRelayTransport(options) {
|
|
1889
|
+
const stored = await readHostedStoreRecord(options.activeStorage, await sessionMetadataKey(options.connection));
|
|
1845
1890
|
if (!stored)
|
|
1846
1891
|
throw new Error('Signal Protocol Relay device link requires an active hosted session');
|
|
1847
|
-
const active = new
|
|
1892
|
+
const active = new HostedSignalProtocolRelayHttpTransport(options.connection, options.activeStorage, options.request.activeDeviceAuthentication, parseSession(stored, options.connection), false);
|
|
1848
1893
|
return active.linkDevice(options.request, options.storage);
|
|
1849
1894
|
}
|
|
1850
1895
|
//# sourceMappingURL=hosted-transport.js.map
|