@open-e2ee/signal-protocol-sdk 10.1.0 → 12.0.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 +4 -4
- package/ARCHITECTURE.md +6 -8
- package/CHANGELOG.md +1413 -0
- package/README.md +1 -1
- package/SECURITY.md +2 -2
- package/TROUBLESHOOTING.md +1 -1
- package/client/README.md +84 -37
- package/device/README.md +39 -85
- package/dist/client/client.d.ts +342 -62
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +1195 -179
- package/dist/client/client.js.map +1 -1
- package/dist/client/config.d.ts +40 -32
- package/dist/client/config.d.ts.map +1 -1
- package/dist/client/config.js +1 -1
- package/dist/client/config.js.map +1 -1
- package/dist/client/constants.d.ts +42 -8
- package/dist/client/constants.d.ts.map +1 -1
- package/dist/client/constants.js +48 -3
- package/dist/client/constants.js.map +1 -1
- package/dist/client/content-adapter.d.ts +80 -0
- package/dist/client/content-adapter.d.ts.map +1 -1
- package/dist/client/content-adapter.js +225 -12
- package/dist/client/content-adapter.js.map +1 -1
- package/dist/client/delivery-error.d.ts +150 -0
- package/dist/client/delivery-error.d.ts.map +1 -0
- package/dist/client/delivery-error.js +226 -0
- package/dist/client/delivery-error.js.map +1 -0
- package/dist/client/delivery-status.d.ts +32 -6
- package/dist/client/delivery-status.d.ts.map +1 -1
- package/dist/client/delivery-status.js +61 -13
- package/dist/client/delivery-status.js.map +1 -1
- package/dist/client/device-set-reconciliation.d.ts +196 -0
- package/dist/client/device-set-reconciliation.d.ts.map +1 -0
- package/dist/client/device-set-reconciliation.js +282 -0
- package/dist/client/device-set-reconciliation.js.map +1 -0
- package/dist/client/distribution-records.d.ts +29 -0
- package/dist/client/distribution-records.d.ts.map +1 -0
- package/dist/client/distribution-records.js +33 -0
- package/dist/client/distribution-records.js.map +1 -0
- package/dist/client/event-hooks.d.ts +308 -6
- package/dist/client/event-hooks.d.ts.map +1 -1
- package/dist/client/event-hooks.js +9 -0
- package/dist/client/event-hooks.js.map +1 -1
- package/dist/client/group-device-set.d.ts +47 -0
- package/dist/client/group-device-set.d.ts.map +1 -0
- package/dist/client/group-device-set.js +65 -0
- package/dist/client/group-device-set.js.map +1 -0
- package/dist/client/group-fetcher.d.ts +116 -0
- package/dist/client/group-fetcher.d.ts.map +1 -0
- package/dist/client/group-fetcher.js +598 -0
- package/dist/client/group-fetcher.js.map +1 -0
- package/dist/client/group-outbox.d.ts +172 -10
- package/dist/client/group-outbox.d.ts.map +1 -1
- package/dist/client/group-outbox.js +915 -74
- package/dist/client/group-outbox.js.map +1 -1
- package/dist/client/group-receive-authorization.d.ts +127 -4
- package/dist/client/group-receive-authorization.d.ts.map +1 -1
- package/dist/client/group-receive-authorization.js +270 -20
- package/dist/client/group-receive-authorization.js.map +1 -1
- package/dist/client/group-sealed-sender.d.ts +3 -0
- package/dist/client/group-sealed-sender.d.ts.map +1 -1
- package/dist/client/group-sealed-sender.js +1 -0
- package/dist/client/group-sealed-sender.js.map +1 -1
- package/dist/client/group-sender-key-operations.d.ts +14 -3
- package/dist/client/group-sender-key-operations.d.ts.map +1 -1
- package/dist/client/group-sender-key-operations.js +26 -5
- package/dist/client/group-sender-key-operations.js.map +1 -1
- package/dist/client/groups.d.ts +5 -5
- package/dist/client/groups.d.ts.map +1 -1
- package/dist/client/groups.js +5 -4
- package/dist/client/groups.js.map +1 -1
- package/dist/client/hosted-anonymous-delivery.d.ts +61 -9
- package/dist/client/hosted-anonymous-delivery.d.ts.map +1 -1
- package/dist/client/hosted-anonymous-delivery.js +242 -48
- package/dist/client/hosted-anonymous-delivery.js.map +1 -1
- package/dist/client/hosted-assertion-id.d.ts +7 -0
- package/dist/client/hosted-assertion-id.d.ts.map +1 -0
- package/dist/client/hosted-assertion-id.js +51 -0
- package/dist/client/hosted-assertion-id.js.map +1 -0
- package/dist/client/hosted-device-standing.d.ts +52 -0
- package/dist/client/hosted-device-standing.d.ts.map +1 -0
- package/dist/client/hosted-device-standing.js +74 -0
- package/dist/client/hosted-device-standing.js.map +1 -0
- package/dist/client/hosted-mailbox-subscription.d.ts +48 -3
- package/dist/client/hosted-mailbox-subscription.d.ts.map +1 -1
- package/dist/client/hosted-mailbox-subscription.js +288 -74
- package/dist/client/hosted-mailbox-subscription.js.map +1 -1
- package/dist/client/hosted-push.d.ts +22 -4
- package/dist/client/hosted-push.d.ts.map +1 -1
- package/dist/client/hosted-push.js +75 -22
- package/dist/client/hosted-push.js.map +1 -1
- package/dist/client/hosted-transport.d.ts +22 -28
- package/dist/client/hosted-transport.d.ts.map +1 -1
- package/dist/client/hosted-transport.js +167 -69
- package/dist/client/hosted-transport.js.map +1 -1
- package/dist/client/hosted.d.ts +22 -5
- package/dist/client/hosted.d.ts.map +1 -1
- package/dist/client/hosted.js +122 -45
- package/dist/client/hosted.js.map +1 -1
- package/dist/client/index.d.ts +6 -4
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +3 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/messages.d.ts +25 -3
- package/dist/client/messages.d.ts.map +1 -1
- package/dist/client/messages.js +118 -17
- package/dist/client/messages.js.map +1 -1
- package/dist/client/one-time-prekey-refill.d.ts +7 -0
- package/dist/client/one-time-prekey-refill.d.ts.map +1 -1
- package/dist/client/one-time-prekey-refill.js +5 -1
- package/dist/client/one-time-prekey-refill.js.map +1 -1
- package/dist/client/receive-admission.d.ts +58 -0
- package/dist/client/receive-admission.d.ts.map +1 -0
- package/dist/client/receive-admission.js +78 -0
- package/dist/client/receive-admission.js.map +1 -0
- package/dist/client/receive-expiry.d.ts +31 -0
- package/dist/client/receive-expiry.d.ts.map +1 -0
- package/dist/client/receive-expiry.js +35 -0
- package/dist/client/receive-expiry.js.map +1 -0
- package/dist/client/receive-hook-bound.d.ts +50 -0
- package/dist/client/receive-hook-bound.d.ts.map +1 -0
- package/dist/client/receive-hook-bound.js +115 -0
- package/dist/client/receive-hook-bound.js.map +1 -0
- package/dist/client/receive-queue.d.ts +299 -0
- package/dist/client/receive-queue.d.ts.map +1 -0
- package/dist/client/receive-queue.js +1420 -0
- package/dist/client/receive-queue.js.map +1 -0
- package/dist/client/receive-work-seed.d.ts +54 -0
- package/dist/client/receive-work-seed.d.ts.map +1 -0
- package/dist/client/receive-work-seed.js +116 -0
- package/dist/client/receive-work-seed.js.map +1 -0
- package/dist/client/recovery-driver.d.ts +25 -0
- package/dist/client/recovery-driver.d.ts.map +1 -0
- package/dist/client/recovery-driver.js +121 -0
- package/dist/client/recovery-driver.js.map +1 -0
- package/dist/client/relay-acceptance.d.ts +30 -0
- package/dist/client/relay-acceptance.d.ts.map +1 -1
- package/dist/client/relay-acceptance.js +55 -0
- package/dist/client/relay-acceptance.js.map +1 -1
- package/dist/client/relay-device-refusal.d.ts +18 -0
- package/dist/client/relay-device-refusal.d.ts.map +1 -1
- package/dist/client/relay-device-refusal.js +31 -0
- package/dist/client/relay-device-refusal.js.map +1 -1
- package/dist/client/relay-sealed-route.d.ts +36 -0
- package/dist/client/relay-sealed-route.d.ts.map +1 -0
- package/dist/client/relay-sealed-route.js +45 -0
- package/dist/client/relay-sealed-route.js.map +1 -0
- package/dist/client/relay-subscription.d.ts +56 -13
- package/dist/client/relay-subscription.d.ts.map +1 -1
- package/dist/client/relay-subscription.js +220 -150
- package/dist/client/relay-subscription.js.map +1 -1
- package/dist/client/resendable-content.d.ts +98 -0
- package/dist/client/resendable-content.d.ts.map +1 -0
- package/dist/client/resendable-content.js +136 -0
- package/dist/client/resendable-content.js.map +1 -0
- package/dist/client/retry-family.d.ts +68 -19
- package/dist/client/retry-family.d.ts.map +1 -1
- package/dist/client/retry-family.js +59 -17
- package/dist/client/retry-family.js.map +1 -1
- package/dist/client/retry-request-envelope.d.ts +145 -18
- package/dist/client/retry-request-envelope.d.ts.map +1 -1
- package/dist/client/retry-request-envelope.js +301 -64
- package/dist/client/retry-request-envelope.js.map +1 -1
- package/dist/client/retry-request-lifecycle.d.ts +157 -0
- package/dist/client/retry-request-lifecycle.d.ts.map +1 -0
- package/dist/client/retry-request-lifecycle.js +437 -0
- package/dist/client/retry-request-lifecycle.js.map +1 -0
- package/dist/client/retry-terminal-recovery.d.ts +100 -0
- package/dist/client/retry-terminal-recovery.d.ts.map +1 -0
- package/dist/client/retry-terminal-recovery.js +164 -0
- package/dist/client/retry-terminal-recovery.js.map +1 -0
- package/dist/client/retry-utils.d.ts +27 -0
- package/dist/client/retry-utils.d.ts.map +1 -1
- package/dist/client/retry-utils.js +46 -0
- package/dist/client/retry-utils.js.map +1 -1
- package/dist/client/retry.d.ts +106 -18
- package/dist/client/retry.d.ts.map +1 -1
- package/dist/client/retry.js +687 -139
- package/dist/client/retry.js.map +1 -1
- package/dist/client/sealed-sender.d.ts +23 -6
- package/dist/client/sealed-sender.d.ts.map +1 -1
- package/dist/client/sealed-sender.js +30 -6
- package/dist/client/sealed-sender.js.map +1 -1
- package/dist/client/sessions.d.ts +2 -2
- package/dist/client/sessions.js +2 -2
- package/dist/client/signal-service-cipher.d.ts +726 -19
- package/dist/client/signal-service-cipher.d.ts.map +1 -1
- package/dist/client/signal-service-cipher.js +2265 -343
- package/dist/client/signal-service-cipher.js.map +1 -1
- package/dist/client/state.d.ts +5 -0
- package/dist/client/state.d.ts.map +1 -1
- package/dist/client/state.js +11 -1
- package/dist/client/state.js.map +1 -1
- package/dist/client/storage-protection.d.ts +64 -0
- package/dist/client/storage-protection.d.ts.map +1 -0
- package/dist/client/storage-protection.js +150 -0
- package/dist/client/storage-protection.js.map +1 -0
- package/dist/client/types.d.ts +149 -15
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/types.js +1 -1
- package/dist/client/types.js.map +1 -1
- package/dist/device/constants.d.ts +0 -5
- package/dist/device/constants.d.ts.map +1 -1
- package/dist/device/constants.js +0 -5
- package/dist/device/constants.js.map +1 -1
- package/dist/device/expo/index.d.ts +4 -17
- package/dist/device/expo/index.d.ts.map +1 -1
- package/dist/device/expo/index.js +4 -23
- package/dist/device/expo/index.js.map +1 -1
- package/dist/device/index.d.ts +0 -2
- package/dist/device/index.d.ts.map +1 -1
- package/dist/device/index.js +0 -7
- package/dist/device/index.js.map +1 -1
- package/dist/device/lifecycle/manager.d.ts +5 -4
- package/dist/device/lifecycle/manager.d.ts.map +1 -1
- package/dist/device/lifecycle/manager.js +16 -16
- package/dist/device/lifecycle/manager.js.map +1 -1
- package/dist/device/lifecycle/types.d.ts +2 -2
- package/dist/device/lifecycle/types.d.ts.map +1 -1
- package/dist/device/react-native/index.d.ts +4 -15
- package/dist/device/react-native/index.d.ts.map +1 -1
- package/dist/device/react-native/index.js +4 -21
- package/dist/device/react-native/index.js.map +1 -1
- package/dist/device/types.d.ts +1 -1
- package/dist/groups/index.d.ts +1 -1
- package/dist/groups/index.d.ts.map +1 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/crypto/ec/x25519-validation.d.ts +0 -1
- package/dist/internal/crypto/ec/x25519-validation.d.ts.map +1 -1
- package/dist/internal/crypto/ec/x25519-validation.js +0 -1
- package/dist/internal/crypto/ec/x25519-validation.js.map +1 -1
- package/dist/internal/crypto/validation.d.ts +2 -2
- package/dist/internal/groups/index.d.ts +1 -0
- package/dist/internal/groups/index.d.ts.map +1 -1
- package/dist/internal/groups/index.js +1 -0
- package/dist/internal/groups/index.js.map +1 -1
- package/dist/internal/groups/manager.d.ts +37 -16
- package/dist/internal/groups/manager.d.ts.map +1 -1
- package/dist/internal/groups/manager.js +46 -1
- package/dist/internal/groups/manager.js.map +1 -1
- package/dist/internal/groups/receive-record.d.ts +78 -0
- package/dist/internal/groups/receive-record.d.ts.map +1 -0
- package/dist/internal/groups/receive-record.js +43 -0
- package/dist/internal/groups/receive-record.js.map +1 -0
- package/dist/internal/groups/sdk-store.d.ts +27 -3
- package/dist/internal/groups/sdk-store.d.ts.map +1 -1
- package/dist/internal/groups/sdk-store.js +151 -19
- package/dist/internal/groups/sdk-store.js.map +1 -1
- package/dist/internal/groups/wire.d.ts +12 -1
- package/dist/internal/groups/wire.d.ts.map +1 -1
- package/dist/internal/groups/wire.js +36 -0
- package/dist/internal/groups/wire.js.map +1 -1
- package/dist/internal/manager/index.d.ts +1 -1
- package/dist/internal/manager/manager.d.ts +20 -19
- package/dist/internal/manager/manager.d.ts.map +1 -1
- package/dist/internal/manager/manager.js +56 -39
- package/dist/internal/manager/manager.js.map +1 -1
- package/dist/internal/protocol/double-ratchet/chains.d.ts +4 -18
- package/dist/internal/protocol/double-ratchet/chains.d.ts.map +1 -1
- package/dist/internal/protocol/double-ratchet/chains.js +23 -74
- package/dist/internal/protocol/double-ratchet/chains.js.map +1 -1
- package/dist/internal/protocol/double-ratchet/index.d.ts +1 -1
- package/dist/internal/protocol/double-ratchet/index.d.ts.map +1 -1
- package/dist/internal/protocol/double-ratchet/index.js +1 -1
- package/dist/internal/protocol/double-ratchet/index.js.map +1 -1
- package/dist/internal/protocol/double-ratchet/ratchet.d.ts +5 -7
- package/dist/internal/protocol/double-ratchet/ratchet.d.ts.map +1 -1
- package/dist/internal/protocol/double-ratchet/ratchet.js +4 -6
- package/dist/internal/protocol/double-ratchet/ratchet.js.map +1 -1
- package/dist/internal/protocol/pqxdh/pqxdh.d.ts.map +1 -1
- package/dist/internal/protocol/pqxdh/pqxdh.js +2 -1
- package/dist/internal/protocol/pqxdh/pqxdh.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/types.d.ts +6 -8
- package/dist/internal/protocol/sealed-sender/types.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/types.js +8 -9
- package/dist/internal/protocol/sealed-sender/types.js.map +1 -1
- package/dist/internal/protocol/sender-keys/handoff-ledger.d.ts +110 -0
- package/dist/internal/protocol/sender-keys/handoff-ledger.d.ts.map +1 -0
- package/dist/internal/protocol/sender-keys/handoff-ledger.js +124 -0
- package/dist/internal/protocol/sender-keys/handoff-ledger.js.map +1 -0
- package/dist/internal/protocol/sender-keys/manager.d.ts +71 -62
- package/dist/internal/protocol/sender-keys/manager.d.ts.map +1 -1
- package/dist/internal/protocol/sender-keys/manager.js +228 -175
- package/dist/internal/protocol/sender-keys/manager.js.map +1 -1
- package/dist/internal/protocol/spqr/index.d.ts +2 -2
- package/dist/internal/protocol/spqr/index.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/index.js +2 -2
- package/dist/internal/protocol/spqr/index.js.map +1 -1
- package/dist/internal/protocol/spqr/serialize.d.ts +9 -1
- package/dist/internal/protocol/spqr/serialize.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/serialize.js +56 -16
- package/dist/internal/protocol/spqr/serialize.js.map +1 -1
- package/dist/internal/protocol/spqr/spqr.d.ts +1 -14
- package/dist/internal/protocol/spqr/spqr.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/spqr.js +54 -42
- package/dist/internal/protocol/spqr/spqr.js.map +1 -1
- package/dist/internal/protocol/spqr/validate.d.ts +26 -6
- package/dist/internal/protocol/spqr/validate.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/validate.js +49 -21
- package/dist/internal/protocol/spqr/validate.js.map +1 -1
- package/dist/internal/sesame/index.d.ts +1 -1
- package/dist/internal/sesame/index.d.ts.map +1 -1
- package/dist/internal/sesame/index.js.map +1 -1
- package/dist/internal/sesame/manager.d.ts +66 -13
- package/dist/internal/sesame/manager.d.ts.map +1 -1
- package/dist/internal/sesame/manager.js +221 -87
- package/dist/internal/sesame/manager.js.map +1 -1
- package/dist/internal/sesame/types.d.ts +95 -17
- package/dist/internal/sesame/types.d.ts.map +1 -1
- package/dist/internal/sesame/types.js +17 -0
- package/dist/internal/sesame/types.js.map +1 -1
- package/dist/internal/session/builder.d.ts +5 -5
- package/dist/internal/session/builder.d.ts.map +1 -1
- package/dist/internal/session/builder.js +12 -17
- package/dist/internal/session/builder.js.map +1 -1
- package/dist/internal/session/cipher.d.ts +13 -11
- package/dist/internal/session/cipher.d.ts.map +1 -1
- package/dist/internal/session/cipher.js +40 -22
- package/dist/internal/session/cipher.js.map +1 -1
- package/dist/internal/session/factory.d.ts +5 -5
- package/dist/internal/session/factory.d.ts.map +1 -1
- package/dist/internal/session/factory.js +4 -4
- package/dist/internal/session/factory.js.map +1 -1
- package/dist/internal/session/handshake.d.ts +14 -16
- package/dist/internal/session/handshake.d.ts.map +1 -1
- package/dist/internal/session/handshake.js +18 -75
- package/dist/internal/session/handshake.js.map +1 -1
- package/dist/internal/session/index.d.ts +1 -1
- package/dist/internal/session/index.js +1 -1
- package/dist/internal/session/record-locks.d.ts +17 -6
- package/dist/internal/session/record-locks.d.ts.map +1 -1
- package/dist/internal/session/record-locks.js +43 -7
- package/dist/internal/session/record-locks.js.map +1 -1
- package/dist/internal/session/session-resolver.d.ts +1 -1
- package/dist/internal/session/session-resolver.js +1 -1
- package/dist/internal/session/state.d.ts +2 -2
- package/dist/internal/session/state.js +1 -1
- package/dist/internal/session/types.d.ts +4 -12
- package/dist/internal/session/types.d.ts.map +1 -1
- package/dist/internal/session/types.js +1 -1
- package/dist/keys/generation.d.ts +2 -2
- package/dist/keys/generation.js +2 -2
- package/dist/keys/types.d.ts +5 -5
- package/dist/keys/types.d.ts.map +1 -1
- package/dist/keys/types.js +1 -1
- package/dist/layers.d.ts +1 -1
- package/dist/layers.js +2 -2
- package/dist/layers.js.map +1 -1
- package/dist/local/store/expo/adapter.d.ts.map +1 -1
- package/dist/local/store/expo/adapter.js +12 -8
- package/dist/local/store/expo/adapter.js.map +1 -1
- package/dist/local/store/key-value/adapter.d.ts +76 -10
- package/dist/local/store/key-value/adapter.d.ts.map +1 -1
- package/dist/local/store/key-value/adapter.js +367 -61
- package/dist/local/store/key-value/adapter.js.map +1 -1
- package/dist/local/store/key-value/backend-conformance.d.ts.map +1 -1
- package/dist/local/store/key-value/backend-conformance.js +74 -0
- package/dist/local/store/key-value/backend-conformance.js.map +1 -1
- package/dist/local/store/key-value/batch.d.ts +2 -0
- package/dist/local/store/key-value/batch.d.ts.map +1 -1
- package/dist/local/store/key-value/batch.js +26 -0
- package/dist/local/store/key-value/batch.js.map +1 -1
- package/dist/local/store/key-value/receive-work.d.ts +55 -0
- package/dist/local/store/key-value/receive-work.d.ts.map +1 -0
- package/dist/local/store/key-value/receive-work.js +162 -0
- package/dist/local/store/key-value/receive-work.js.map +1 -0
- package/dist/local/store/key-value/send-log.d.ts +61 -0
- package/dist/local/store/key-value/send-log.d.ts.map +1 -0
- package/dist/local/store/key-value/send-log.js +430 -0
- package/dist/local/store/key-value/send-log.js.map +1 -0
- package/dist/local/store/key-value/sender-key-handoff.d.ts +68 -0
- package/dist/local/store/key-value/sender-key-handoff.d.ts.map +1 -0
- package/dist/local/store/key-value/sender-key-handoff.js +189 -0
- package/dist/local/store/key-value/sender-key-handoff.js.map +1 -0
- package/dist/local/store/key-value/storage.d.ts +15 -0
- package/dist/local/store/key-value/storage.d.ts.map +1 -1
- package/dist/local/store/keyed-index.d.ts +23 -0
- package/dist/local/store/keyed-index.d.ts.map +1 -0
- package/dist/local/store/keyed-index.js +41 -0
- package/dist/local/store/keyed-index.js.map +1 -0
- package/dist/local/store/memory/adapter.d.ts +44 -12
- package/dist/local/store/memory/adapter.d.ts.map +1 -1
- package/dist/local/store/memory/adapter.js +197 -46
- package/dist/local/store/memory/adapter.js.map +1 -1
- package/dist/local/store/memory/send-log.d.ts +42 -0
- package/dist/local/store/memory/send-log.d.ts.map +1 -0
- package/dist/local/store/memory/send-log.js +190 -0
- package/dist/local/store/memory/send-log.js.map +1 -0
- package/dist/local/store/node/adapter.d.ts.map +1 -1
- package/dist/local/store/node/adapter.js +8 -6
- package/dist/local/store/node/adapter.js.map +1 -1
- package/dist/local/store/react-native/adapter.d.ts.map +1 -1
- package/dist/local/store/react-native/adapter.js +12 -8
- package/dist/local/store/react-native/adapter.js.map +1 -1
- package/dist/local/store/receive-work.d.ts +87 -0
- package/dist/local/store/receive-work.d.ts.map +1 -0
- package/dist/local/store/receive-work.js +204 -0
- package/dist/local/store/receive-work.js.map +1 -0
- package/dist/local/store/received-content.d.ts +3 -3
- package/dist/local/store/received-content.d.ts.map +1 -1
- package/dist/local/store/received-content.js +2 -11
- package/dist/local/store/received-content.js.map +1 -1
- package/dist/local/store/reliability.d.ts +411 -14
- package/dist/local/store/reliability.d.ts.map +1 -1
- package/dist/local/store/reliability.js +532 -58
- package/dist/local/store/reliability.js.map +1 -1
- package/dist/local/store/send-log-order.d.ts +15 -0
- package/dist/local/store/send-log-order.d.ts.map +1 -0
- package/dist/local/store/send-log-order.js +24 -0
- package/dist/local/store/send-log-order.js.map +1 -0
- package/dist/local/store/sender-key-handoff-index.d.ts +38 -0
- package/dist/local/store/sender-key-handoff-index.d.ts.map +1 -0
- package/dist/local/store/sender-key-handoff-index.js +101 -0
- package/dist/local/store/sender-key-handoff-index.js.map +1 -0
- package/dist/local/store/sender-key-handoff-table.d.ts +29 -0
- package/dist/local/store/sender-key-handoff-table.d.ts.map +1 -0
- package/dist/local/store/sender-key-handoff-table.js +97 -0
- package/dist/local/store/sender-key-handoff-table.js.map +1 -0
- package/dist/local/store/sqlite/encryption.d.ts +8 -1
- package/dist/local/store/sqlite/encryption.d.ts.map +1 -1
- package/dist/local/store/sqlite/encryption.js +9 -0
- package/dist/local/store/sqlite/encryption.js.map +1 -1
- package/dist/local/store/sqlite/key-storage/index.d.ts +25 -4
- package/dist/local/store/sqlite/key-storage/index.d.ts.map +1 -1
- package/dist/local/store/sqlite/key-storage/index.js +68 -7
- package/dist/local/store/sqlite/key-storage/index.js.map +1 -1
- package/dist/local/store/sqlite/key-storage/message-records.d.ts +16 -4
- package/dist/local/store/sqlite/key-storage/message-records.d.ts.map +1 -1
- package/dist/local/store/sqlite/key-storage/message-records.js +49 -6
- package/dist/local/store/sqlite/key-storage/message-records.js.map +1 -1
- package/dist/local/store/sqlite/key-storage/metadata.d.ts +8 -7
- package/dist/local/store/sqlite/key-storage/metadata.d.ts.map +1 -1
- package/dist/local/store/sqlite/key-storage/metadata.js +17 -15
- package/dist/local/store/sqlite/key-storage/metadata.js.map +1 -1
- package/dist/local/store/sqlite/key-storage/receive-work.d.ts +27 -0
- package/dist/local/store/sqlite/key-storage/receive-work.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/receive-work.js +98 -0
- package/dist/local/store/sqlite/key-storage/receive-work.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/send-log.d.ts +27 -0
- package/dist/local/store/sqlite/key-storage/send-log.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/send-log.js +178 -0
- package/dist/local/store/sqlite/key-storage/send-log.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/sender-key-handoff.d.ts +27 -0
- package/dist/local/store/sqlite/key-storage/sender-key-handoff.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/sender-key-handoff.js +75 -0
- package/dist/local/store/sqlite/key-storage/sender-key-handoff.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/session-trust.d.ts +2 -2
- package/dist/local/store/sqlite/key-storage/session-trust.js +5 -5
- package/dist/local/store/sqlite/key-storage/session-trust.js.map +1 -1
- package/dist/local/store/sqlite/migrations.d.ts.map +1 -1
- package/dist/local/store/sqlite/migrations.js +101 -0
- package/dist/local/store/sqlite/migrations.js.map +1 -1
- package/dist/local/store/sqlite/models/index.d.ts +2 -1
- package/dist/local/store/sqlite/models/index.d.ts.map +1 -1
- package/dist/local/store/sqlite/models/index.js +5 -1
- package/dist/local/store/sqlite/models/index.js.map +1 -1
- package/dist/local/store/sqlite/models/message-record.d.ts +15 -0
- package/dist/local/store/sqlite/models/message-record.d.ts.map +1 -1
- package/dist/local/store/sqlite/models/message-record.js +24 -0
- package/dist/local/store/sqlite/models/message-record.js.map +1 -1
- package/dist/local/store/sqlite/models/send-log.d.ts +51 -0
- package/dist/local/store/sqlite/models/send-log.d.ts.map +1 -0
- package/dist/local/store/sqlite/models/send-log.js +206 -0
- package/dist/local/store/sqlite/models/send-log.js.map +1 -0
- package/dist/local/store/sqlite/open-store.d.ts +9 -1
- package/dist/local/store/sqlite/open-store.d.ts.map +1 -1
- package/dist/local/store/sqlite/open-store.js +20 -1
- package/dist/local/store/sqlite/open-store.js.map +1 -1
- package/dist/local/store/sqlite/schema.d.ts +34 -1
- package/dist/local/store/sqlite/schema.d.ts.map +1 -1
- package/dist/local/store/sqlite/schema.js +14 -0
- package/dist/local/store/sqlite/schema.js.map +1 -1
- package/dist/local/store/sqlite/store.d.ts +61 -11
- package/dist/local/store/sqlite/store.d.ts.map +1 -1
- package/dist/local/store/sqlite/store.js +191 -27
- package/dist/local/store/sqlite/store.js.map +1 -1
- package/dist/local/store/web/adapter.d.ts +76 -8
- package/dist/local/store/web/adapter.d.ts.map +1 -1
- package/dist/local/store/web/adapter.js +579 -127
- package/dist/local/store/web/adapter.js.map +1 -1
- package/dist/local/store/web/receive-work.d.ts +57 -0
- package/dist/local/store/web/receive-work.d.ts.map +1 -0
- package/dist/local/store/web/receive-work.js +99 -0
- package/dist/local/store/web/receive-work.js.map +1 -0
- package/dist/local/store/web/send-log.d.ts +92 -0
- package/dist/local/store/web/send-log.d.ts.map +1 -0
- package/dist/local/store/web/send-log.js +267 -0
- package/dist/local/store/web/send-log.js.map +1 -0
- package/dist/local/store/web/sender-key-handoff.d.ts +81 -0
- package/dist/local/store/web/sender-key-handoff.d.ts.map +1 -0
- package/dist/local/store/web/sender-key-handoff.js +156 -0
- package/dist/local/store/web/sender-key-handoff.js.map +1 -0
- package/dist/local/store/web-sqlite/adapter.d.ts +2 -0
- package/dist/local/store/web-sqlite/adapter.d.ts.map +1 -1
- package/dist/local/store/web-sqlite/adapter.js +12 -6
- package/dist/local/store/web-sqlite/adapter.js.map +1 -1
- package/dist/local/vault/custody.d.ts +8 -0
- package/dist/local/vault/custody.d.ts.map +1 -0
- package/dist/local/vault/custody.js +9 -0
- package/dist/local/vault/custody.js.map +1 -0
- package/dist/local/vault/electron-safe-storage.d.ts +3 -1
- package/dist/local/vault/electron-safe-storage.d.ts.map +1 -1
- package/dist/local/vault/electron-safe-storage.js +2 -0
- package/dist/local/vault/electron-safe-storage.js.map +1 -1
- package/dist/local/vault/expo-secure-store.d.ts +3 -1
- package/dist/local/vault/expo-secure-store.d.ts.map +1 -1
- package/dist/local/vault/expo-secure-store.js +2 -0
- package/dist/local/vault/expo-secure-store.js.map +1 -1
- package/dist/local/vault/indexed-db.d.ts +3 -1
- package/dist/local/vault/indexed-db.d.ts.map +1 -1
- package/dist/local/vault/indexed-db.js +2 -0
- package/dist/local/vault/indexed-db.js.map +1 -1
- package/dist/local/vault/react-native-keychain.d.ts +3 -1
- package/dist/local/vault/react-native-keychain.d.ts.map +1 -1
- package/dist/local/vault/react-native-keychain.js +2 -0
- package/dist/local/vault/react-native-keychain.js.map +1 -1
- package/dist/remote/relay/device-set.d.ts +94 -0
- package/dist/remote/relay/device-set.d.ts.map +1 -0
- package/dist/remote/relay/device-set.js +156 -0
- package/dist/remote/relay/device-set.js.map +1 -0
- package/dist/remote/relay/types.d.ts +104 -110
- package/dist/remote/relay/types.d.ts.map +1 -1
- package/dist/safety/core.d.ts +15 -6
- package/dist/safety/core.d.ts.map +1 -1
- package/dist/safety/core.js +41 -27
- package/dist/safety/core.js.map +1 -1
- package/dist/safety/index.d.ts +2 -1
- package/dist/safety/index.d.ts.map +1 -1
- package/dist/safety/index.js +12 -18
- package/dist/safety/index.js.map +1 -1
- package/dist/types/api.d.ts +707 -62
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/errors.d.ts +14 -33
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +14 -24
- package/dist/types/errors.js.map +1 -1
- package/dist/types/messages.d.ts +2 -2
- package/dist/types/messages.js +1 -1
- package/dist/types/protocol-config.d.ts +175 -42
- package/dist/types/protocol-config.d.ts.map +1 -1
- package/dist/types/protocol-config.js +19 -38
- package/dist/types/protocol-config.js.map +1 -1
- package/dist/types/protocol-constants.d.ts +6 -6
- package/dist/types/protocol-constants.js +6 -6
- package/dist/types/session.d.ts +7 -7
- package/dist/types/session.d.ts.map +1 -1
- package/dist/types/session.js +39 -21
- package/dist/types/session.js.map +1 -1
- package/dist/username/link.d.ts +2 -2
- package/dist/username/link.js +2 -2
- package/dist/utils/origin-lock.d.ts +45 -0
- package/dist/utils/origin-lock.d.ts.map +1 -0
- package/dist/utils/origin-lock.js +80 -0
- package/dist/utils/origin-lock.js.map +1 -0
- package/dist/utils/retry.d.ts +2 -0
- package/dist/utils/retry.d.ts.map +1 -1
- package/dist/utils/retry.js +7 -0
- package/dist/utils/retry.js.map +1 -1
- package/docs/ASSURANCE.md +6 -6
- package/docs/CLIENT_COMPOSITION.md +2 -2
- package/docs/DEVIATIONS.md +677 -182
- package/docs/E2EE.md +1 -1
- package/docs/ERROR_HANDLING.md +235 -2
- package/docs/GETTING_STARTED.md +7 -4
- package/docs/INTERFACES.md +1 -1
- package/docs/PACKAGE_SURFACE.md +6 -5
- package/docs/PROTOCOL_POLICY.md +102 -22
- package/docs/RECIPES.md +3 -15
- package/docs/SECURITY.md +90 -5
- package/keys/README.md +3 -3
- package/local/store/README.md +78 -14
- package/local/store/key-value/README.md +14 -3
- package/local/store/node/README.md +8 -3
- package/local/store/web/README.md +9 -0
- package/local/store/web-sqlite/README.md +14 -2
- package/local/vault/README.md +21 -0
- package/package.json +1 -6
- package/remote/README.md +0 -1
- package/remote/relay/README.md +2 -2
- package/dist/device/provisioning.d.ts +0 -242
- package/dist/device/provisioning.d.ts.map +0 -1
- package/dist/device/provisioning.js +0 -421
- package/dist/device/provisioning.js.map +0 -1
- package/dist/internal/protocol/x3dh/index.d.ts +0 -15
- package/dist/internal/protocol/x3dh/index.d.ts.map +0 -1
- package/dist/internal/protocol/x3dh/index.js +0 -13
- package/dist/internal/protocol/x3dh/index.js.map +0 -1
- package/dist/internal/protocol/x3dh/x3dh.d.ts +0 -131
- package/dist/internal/protocol/x3dh/x3dh.d.ts.map +0 -1
- package/dist/internal/protocol/x3dh/x3dh.js +0 -261
- package/dist/internal/protocol/x3dh/x3dh.js.map +0 -1
|
@@ -35,6 +35,9 @@
|
|
|
35
35
|
* });
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
|
+
import type { RetryTerminalClass } from '../local/store/reliability.js';
|
|
39
|
+
import type { RelayProtocolError } from './device-set-reconciliation.js';
|
|
40
|
+
export type { RetryTerminalClass };
|
|
38
41
|
/**
|
|
39
42
|
* Decrypted envelope passed to onMessageDecrypted hook
|
|
40
43
|
*
|
|
@@ -72,6 +75,131 @@ export interface DeliveredEvent {
|
|
|
72
75
|
/** The group ID, for a group message. */
|
|
73
76
|
groupId?: string;
|
|
74
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* The end of a retry request with no resend. The device that asked for the
|
|
80
|
+
* resend gets it for each class except `missing-prekey`. The device that
|
|
81
|
+
* sent the failed message gets `missing-prekey`, when it cannot start a new
|
|
82
|
+
* session with the requester. Each request ends once, and the hook runs once
|
|
83
|
+
* for it.
|
|
84
|
+
*/
|
|
85
|
+
export interface RetryTerminalEvent {
|
|
86
|
+
/** Why the request ended. */
|
|
87
|
+
class: RetryTerminalClass;
|
|
88
|
+
/** The Relay message ID of the envelope that the requester failed to decrypt. */
|
|
89
|
+
failedEnvelopeId: string;
|
|
90
|
+
/**
|
|
91
|
+
* The session reset of the requester. Only an `expired-content` end of a
|
|
92
|
+
* client with a Relay has it.
|
|
93
|
+
*/
|
|
94
|
+
recovery?: RetryTerminalRecoveryEvent;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The session reset of the requester after a retry request ends as
|
|
98
|
+
* `expired-content`.
|
|
99
|
+
*
|
|
100
|
+
* The requester archived its session with the device that sent the failed
|
|
101
|
+
* envelope, after each decrypt from that device in progress ended. The next
|
|
102
|
+
* message to or from the device starts a new session.
|
|
103
|
+
*/
|
|
104
|
+
export interface RetryTerminalRecoveryEvent {
|
|
105
|
+
/** The user ID of the device whose session the requester archived. */
|
|
106
|
+
userId: string;
|
|
107
|
+
/** The device ID of the device whose session the requester archived. */
|
|
108
|
+
deviceId: number;
|
|
109
|
+
/**
|
|
110
|
+
* `applied`: the failed message is a group message, and the requester has
|
|
111
|
+
* a sender key for that group. The reset does not rotate the key. A key
|
|
112
|
+
* older than `maxSenderKeyAge` rotates at the next send, as at any send,
|
|
113
|
+
* and the new key goes to each member.
|
|
114
|
+
* `skipped`: a pairwise message, a group message whose group the receive
|
|
115
|
+
* did not resolve, or a group with no local sender key.
|
|
116
|
+
*
|
|
117
|
+
* With each outcome, the reset deletes the handoff rows of each device of
|
|
118
|
+
* that account in every group. The next send to each of those groups
|
|
119
|
+
* gives the current key to each of those devices.
|
|
120
|
+
*/
|
|
121
|
+
senderKey: 'applied' | 'skipped';
|
|
122
|
+
/**
|
|
123
|
+
* `sent`: one null message went to the device and started the new session.
|
|
124
|
+
* `limited`: a null message went to the device in the last hour, so none
|
|
125
|
+
* was sent. `failed`: the send failed. With `limited` and `failed`, the
|
|
126
|
+
* next ordinary message starts the new session.
|
|
127
|
+
*/
|
|
128
|
+
nullMessage: 'sent' | 'limited' | 'failed';
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Why the client reports a delivery error for a failed envelope.
|
|
132
|
+
*
|
|
133
|
+
* - `content-hint`: the failed envelope has the `Default` content hint, or
|
|
134
|
+
* no hint, so the error comes at the first failure.
|
|
135
|
+
* - `deadline`: the failed envelope has the `Resendable` content hint, and
|
|
136
|
+
* its content did not come back within `RETRY_PLACEHOLDER_DEADLINE_MS`.
|
|
137
|
+
* - `rate-limit`: a rate limit refused the retry request of the envelope.
|
|
138
|
+
* - `request-ended`: the retry request ended with no resend, as
|
|
139
|
+
* `onRetryTerminal` reports.
|
|
140
|
+
*/
|
|
141
|
+
export type DeliveryErrorCause = 'content-hint' | 'deadline' | 'rate-limit' | 'request-ended';
|
|
142
|
+
/** The recovery of one failed incoming envelope that had a delivery error. */
|
|
143
|
+
export interface DeliveryRecoveredEvent {
|
|
144
|
+
/** The Relay message ID of the envelope that the local device failed to decrypt. */
|
|
145
|
+
failedEnvelopeId: string;
|
|
146
|
+
/** The client message ID of the failed envelope, when its relay delivered one. */
|
|
147
|
+
clientMessageId?: string;
|
|
148
|
+
/** The user that sent the failed envelope. */
|
|
149
|
+
senderUserId: string;
|
|
150
|
+
/** The device that sent the failed envelope. */
|
|
151
|
+
senderDeviceId: number;
|
|
152
|
+
/** True when the failed envelope is a sender-key group message. */
|
|
153
|
+
groupMessage: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* The group of a failed group message, in the form of
|
|
156
|
+
* `DecryptedEnvelope.conversationId`. A group envelope names no group, so
|
|
157
|
+
* the client knows it only when it holds the sender key that the message
|
|
158
|
+
* names. The error of a message that failed for a missing sender key has
|
|
159
|
+
* none. Its recovery has one when the decrypt that gave the content
|
|
160
|
+
* installed or used the sender key of the group. `processIncomingEnvelope`
|
|
161
|
+
* gives a resend's distribution to the caller and installs no key, so
|
|
162
|
+
* its recovery can have none.
|
|
163
|
+
*/
|
|
164
|
+
groupId?: string;
|
|
165
|
+
/** The time of the first failure of the envelope, in epoch milliseconds. */
|
|
166
|
+
receivedAt: number;
|
|
167
|
+
}
|
|
168
|
+
/** The delivery error of one failed incoming envelope. */
|
|
169
|
+
export interface DeliveryErrorEvent extends DeliveryRecoveredEvent {
|
|
170
|
+
/** Why the client reports the error now. */
|
|
171
|
+
cause: DeliveryErrorCause;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Received content that waited on this device for 30 days. The client
|
|
175
|
+
* drops it after the hook.
|
|
176
|
+
*/
|
|
177
|
+
export interface ReceiveExpiredEvent {
|
|
178
|
+
/** The receive record ID: the delivered fingerprint of the envelope. */
|
|
179
|
+
workId: string;
|
|
180
|
+
/** Why the content expired. */
|
|
181
|
+
reason: 'max-age';
|
|
182
|
+
/** When the device first admitted the content, in epoch milliseconds. */
|
|
183
|
+
receivedAt: number;
|
|
184
|
+
/**
|
|
185
|
+
* Where the content waited: `decrypted` for content that the client did
|
|
186
|
+
* not deliver yet, `awaiting-completion` for a helper receive that the
|
|
187
|
+
* application did not complete.
|
|
188
|
+
*/
|
|
189
|
+
stage: 'decrypted' | 'awaiting-completion';
|
|
190
|
+
/** `relay` for a Relay message, `caller` for a helper receive. */
|
|
191
|
+
origin: 'relay' | 'caller';
|
|
192
|
+
/** The message ID. Absent for content stored before the receive queue. */
|
|
193
|
+
messageId?: string;
|
|
194
|
+
/** The sender. Absent for content stored before the receive queue. */
|
|
195
|
+
senderId?: string;
|
|
196
|
+
/** The sender device. Absent for content stored before the receive queue. */
|
|
197
|
+
senderDeviceId?: number;
|
|
198
|
+
/** The raw group of the content, when known. */
|
|
199
|
+
groupId?: string;
|
|
200
|
+
/** The failed envelope that the content resends, for a resend. */
|
|
201
|
+
failedEnvelopeId?: string;
|
|
202
|
+
}
|
|
75
203
|
export interface DecryptedEnvelope {
|
|
76
204
|
/** Unique message ID (from server or generated) */
|
|
77
205
|
messageId: string;
|
|
@@ -85,11 +213,17 @@ export interface DecryptedEnvelope {
|
|
|
85
213
|
conversationId: string;
|
|
86
214
|
/** Decrypted plaintext content (typically JSON) */
|
|
87
215
|
content: string;
|
|
88
|
-
/**
|
|
216
|
+
/**
|
|
217
|
+
* The sender's timestamp from the content, which a receipt for the
|
|
218
|
+
* message names. Content with no timestamp gives `receivedAt`.
|
|
219
|
+
*/
|
|
89
220
|
timestamp: number;
|
|
90
221
|
/** Relay server timestamp when available */
|
|
91
222
|
serverTimestamp?: number;
|
|
92
|
-
/**
|
|
223
|
+
/**
|
|
224
|
+
* When the device first admitted the message locally, in epoch
|
|
225
|
+
* milliseconds. A retry and a restart give the same time.
|
|
226
|
+
*/
|
|
93
227
|
receivedAt: number;
|
|
94
228
|
/** Whether this is a group message */
|
|
95
229
|
isGroup: boolean;
|
|
@@ -144,7 +278,11 @@ export interface SignalProtocolClientHooks {
|
|
|
144
278
|
* Runs after the client archives a session (moved to inactive list)
|
|
145
279
|
*
|
|
146
280
|
* Stale-device recovery archives the session so delayed messages can still
|
|
147
|
-
* attempt decryption.
|
|
281
|
+
* attempt decryption. When the recovery refreshes the session of a receipt
|
|
282
|
+
* or a retry request, the new session archives the stale one in the same
|
|
283
|
+
* write, and the hook runs after that session start succeeds. A failure
|
|
284
|
+
* in the SESAME registration after that write keeps the new session and
|
|
285
|
+
* runs no hook.
|
|
148
286
|
* Per SESAME §3.2: "previously active session is moved to the head of the inactive sessions list"
|
|
149
287
|
*
|
|
150
288
|
* @param sessionId - The identifier of the archived session
|
|
@@ -197,6 +335,15 @@ export interface SignalProtocolClientHooks {
|
|
|
197
335
|
* The hook receives the full decrypted envelope with all metadata
|
|
198
336
|
* needed to store the message in the encrypted content database.
|
|
199
337
|
*
|
|
338
|
+
* Delivery is at least once. The client stores the content before it
|
|
339
|
+
* acknowledges the Relay message and runs the hook after that. A stop or
|
|
340
|
+
* a crash before the client records the delivery runs the hook again
|
|
341
|
+
* with the same `messageId`. Deduplicate on `messageId`.
|
|
342
|
+
*
|
|
343
|
+
* The hook must settle. The receive queue runs one hook call at a time,
|
|
344
|
+
* so a hook that never settles stops the queue and `processPendingReceives`
|
|
345
|
+
* until the process restarts.
|
|
346
|
+
*
|
|
200
347
|
* @param envelope - The decrypted message envelope
|
|
201
348
|
*
|
|
202
349
|
* @example
|
|
@@ -282,11 +429,20 @@ export interface SignalProtocolClientHooks {
|
|
|
282
429
|
* Runs when a recipient device gets one of this client's messages
|
|
283
430
|
*
|
|
284
431
|
* A message to one device goes from accepted (the send resolved) to
|
|
285
|
-
* delivered. The hook runs
|
|
432
|
+
* delivered. The hook runs for each source that reports the delivery:
|
|
286
433
|
* `'relay'` when the Relay hands the message to the device, and `'e2ee'`
|
|
287
434
|
* when the device decrypts it and sends an encrypted delivery receipt. A
|
|
288
|
-
*
|
|
289
|
-
*
|
|
435
|
+
* receipt that arrives before the send resolves runs the hook after the
|
|
436
|
+
* send resolves.
|
|
437
|
+
*
|
|
438
|
+
* The hook runs at least once for each source. The client marks a source
|
|
439
|
+
* announced only after the hook returns. An error from the hook fails the
|
|
440
|
+
* receipt, so the relay delivers it again. A hook that throws, a client
|
|
441
|
+
* stop during the hook, or a crash leaves the source unannounced, and the
|
|
442
|
+
* hook runs again for it with the next receipt for the message. A second
|
|
443
|
+
* report from the same source after the hook returned does not run the
|
|
444
|
+
* hook. Make the hook idempotent for one `clientMessageId`,
|
|
445
|
+
* `recipientDeviceId`, and `source`.
|
|
290
446
|
*
|
|
291
447
|
* @param event - The delivery and its sources so far
|
|
292
448
|
*
|
|
@@ -301,6 +457,152 @@ export interface SignalProtocolClientHooks {
|
|
|
301
457
|
* ```
|
|
302
458
|
*/
|
|
303
459
|
onDelivered?: (event: DeliveredEvent) => void | Promise<void>;
|
|
460
|
+
/**
|
|
461
|
+
* Runs when a retry request ends with no resend
|
|
462
|
+
*
|
|
463
|
+
* A failed decrypt asks the sender device for a resend. The request ends
|
|
464
|
+
* when the Relay gives a conclusive answer to its post, when it does not
|
|
465
|
+
* get its content before its deadline, 14 days after the first failure,
|
|
466
|
+
* when the resend of the fifth attempt also fails, when the sender used up
|
|
467
|
+
* its retry allowance, when the sender device has no prekey bundle of the
|
|
468
|
+
* requester, or when the sender device refuses group content to a
|
|
469
|
+
* requester that is not a current member of the group. The content of the
|
|
470
|
+
* failed envelope is then lost. The hook runs at least once for each
|
|
471
|
+
* request. The SDK marks the end emitted only after the hook returns. A
|
|
472
|
+
* hook that throws, a client stop during the hook, or a crash leaves the
|
|
473
|
+
* end not emitted, and the hook runs again at the next retry request pass,
|
|
474
|
+
* start, or redelivery. Make the hook idempotent for one
|
|
475
|
+
* `failedEnvelopeId`.
|
|
476
|
+
*
|
|
477
|
+
* Before the hook, an `expired-content` end resets the session with the
|
|
478
|
+
* device that sent the failed envelope, and `event.recovery` tells what
|
|
479
|
+
* the reset did. The other classes, and a post that fails and can be
|
|
480
|
+
* posted again, reset nothing. `onSessionArchived` runs for the archive.
|
|
481
|
+
*
|
|
482
|
+
* @param event - The class of the end, the failed envelope, and the reset
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* ```typescript
|
|
486
|
+
* onRetryTerminal: async (event) => {
|
|
487
|
+
* await messageStore.markUndecryptable(event.failedEnvelopeId, event.class);
|
|
488
|
+
* }
|
|
489
|
+
* ```
|
|
490
|
+
*/
|
|
491
|
+
onRetryTerminal?: (event: RetryTerminalEvent) => void | Promise<void>;
|
|
492
|
+
/**
|
|
493
|
+
* Runs when an incoming message failed to decrypt and its content did not
|
|
494
|
+
* come back
|
|
495
|
+
*
|
|
496
|
+
* A failed decrypt asks the sender device for a resend and acknowledges
|
|
497
|
+
* the failed envelope. The content hint of the envelope sets when the
|
|
498
|
+
* hook runs. With the `Default` hint, or no hint, it runs at the first
|
|
499
|
+
* failure. With the `Resendable` hint, it runs when the content did not
|
|
500
|
+
* come back within `RETRY_PLACEHOLDER_DEADLINE_MS`, one hour, of the
|
|
501
|
+
* first failure. With the `Implicit` hint, it never runs. A rate limit
|
|
502
|
+
* that refuses the retry request, and the end of the request, make it run
|
|
503
|
+
* at once. The client checks the time at each redelivery of the envelope
|
|
504
|
+
* and at each retry family write. With a relay, it also checks at
|
|
505
|
+
* create() and, while the client runs, at the time when the error is due.
|
|
506
|
+
*
|
|
507
|
+
* The hook runs at least once for each failed envelope, also across a
|
|
508
|
+
* restart. The client marks the error shown only after the hook returns.
|
|
509
|
+
* A hook that throws, a client stop during the hook, or a crash leaves the
|
|
510
|
+
* error not shown, and the hook runs again at the next retry request
|
|
511
|
+
* pass, start, or redelivery. The receive path does not acknowledge a
|
|
512
|
+
* failed envelope whose hook threw. Make the hook idempotent for one
|
|
513
|
+
* `failedEnvelopeId`. The error deletes nothing: the retry request
|
|
514
|
+
* continues, and when the content comes back, `onDeliveryRecovered` runs.
|
|
515
|
+
*
|
|
516
|
+
* @param event - The failed envelope, its sender and the cause
|
|
517
|
+
*
|
|
518
|
+
* @example
|
|
519
|
+
* ```typescript
|
|
520
|
+
* onDeliveryError: async (event) => {
|
|
521
|
+
* await messageStore.showUndelivered(event.failedEnvelopeId, event.senderUserId);
|
|
522
|
+
* }
|
|
523
|
+
* ```
|
|
524
|
+
*/
|
|
525
|
+
onDeliveryError?: (event: DeliveryErrorEvent) => void | Promise<void>;
|
|
526
|
+
/**
|
|
527
|
+
* Runs when the content of a failed incoming message comes back after
|
|
528
|
+
* `onDeliveryError` ran for it
|
|
529
|
+
*
|
|
530
|
+
* The content comes back in a resend from the sender device, or in a
|
|
531
|
+
* redelivery of the failed envelope that now decrypts. The application
|
|
532
|
+
* gets the content as for any message, and then this hook runs. Its
|
|
533
|
+
* event carries the time of the first failure, so the application can put
|
|
534
|
+
* the message back in its first place.
|
|
535
|
+
*
|
|
536
|
+
* The hook runs at least once for each failed envelope, also across a
|
|
537
|
+
* restart. The client marks the recovery only after the hook returns. A
|
|
538
|
+
* hook that throws, a client stop during the hook, or a crash leaves the
|
|
539
|
+
* recovery not marked, and the hook runs again at the next retry request
|
|
540
|
+
* pass, start, or receive of an envelope of the same retry family. An
|
|
541
|
+
* error from the hook after the content does not fail that receive. Make
|
|
542
|
+
* the hook idempotent for one `failedEnvelopeId`.
|
|
543
|
+
*
|
|
544
|
+
* @param event - The failed envelope and its sender
|
|
545
|
+
*
|
|
546
|
+
* @example
|
|
547
|
+
* ```typescript
|
|
548
|
+
* onDeliveryRecovered: async (event) => {
|
|
549
|
+
* await messageStore.clearUndelivered(event.failedEnvelopeId);
|
|
550
|
+
* }
|
|
551
|
+
* ```
|
|
552
|
+
*/
|
|
553
|
+
onDeliveryRecovered?: (event: DeliveryRecoveredEvent) => void | Promise<void>;
|
|
554
|
+
/**
|
|
555
|
+
* Runs when received content waited on this device for 30 days, before
|
|
556
|
+
* the client drops it.
|
|
557
|
+
*
|
|
558
|
+
* Content waits when its group state is not current, or when a helper
|
|
559
|
+
* receive is not completed. The hook runs at least once: a stop or a
|
|
560
|
+
* crash before the client records the expiry runs it again for the same
|
|
561
|
+
* `workId`. The client sends no delivery receipt and no retry request for
|
|
562
|
+
* expired content.
|
|
563
|
+
*
|
|
564
|
+
* @param event - The expired content, without its plaintext
|
|
565
|
+
*
|
|
566
|
+
* @example
|
|
567
|
+
* ```typescript
|
|
568
|
+
* onReceiveExpired: async (event) => {
|
|
569
|
+
* await messageStore.markLost(event.messageId ?? event.workId);
|
|
570
|
+
* }
|
|
571
|
+
* ```
|
|
572
|
+
*/
|
|
573
|
+
onReceiveExpired?: (event: ReceiveExpiredEvent) => void | Promise<void>;
|
|
574
|
+
/**
|
|
575
|
+
* Runs once for a completed send whose Relay accepted a declared post
|
|
576
|
+
* without the `deviceSetChecked` mark. A declared post is a post to a
|
|
577
|
+
* recipient device or a sync copy to another device of the own account.
|
|
578
|
+
*
|
|
579
|
+
* The client declares the device set of each recipient account only to a
|
|
580
|
+
* Relay that compares device sets. Such a Relay marks each post that it
|
|
581
|
+
* compared. An accepted post without the mark is a Relay defect: the Relay
|
|
582
|
+
* did not check the declared devices. The send is delivered, so its result
|
|
583
|
+
* does not change and the client does not post it again. The error carries
|
|
584
|
+
* the code `DEVICE_SET_UNCHECKED`, the `clientMessageId` of the send, and
|
|
585
|
+
* the route of the post. The route is `identified-direct`,
|
|
586
|
+
* `anonymous-direct`, or `anonymous-group`. A sync copy is an
|
|
587
|
+
* `identified-direct` post. The client also logs one warning with the code
|
|
588
|
+
* and the route.
|
|
589
|
+
*
|
|
590
|
+
* The hook also runs once for a sync payload of a method such as
|
|
591
|
+
* `syncReadToLinkedDevices`. That error has no `clientMessageId`.
|
|
592
|
+
*
|
|
593
|
+
* The hook runs after the send completes. An error from the hook does not
|
|
594
|
+
* change the send result. The client logs the error.
|
|
595
|
+
*
|
|
596
|
+
* @param error - The protocol error of the send
|
|
597
|
+
*
|
|
598
|
+
* @example
|
|
599
|
+
* ```typescript
|
|
600
|
+
* onRelayProtocolError: (error) => {
|
|
601
|
+
* monitoring.report('relay-protocol', { code: error.code, route: error.route });
|
|
602
|
+
* }
|
|
603
|
+
* ```
|
|
604
|
+
*/
|
|
605
|
+
onRelayProtocolError?: (error: RelayProtocolError) => void | Promise<void>;
|
|
304
606
|
/**
|
|
305
607
|
* Runs when the client receives a read receipt
|
|
306
608
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-hooks.d.ts","sourceRoot":"","sources":["../../client/event-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;
|
|
1
|
+
{"version":3,"file":"event-hooks.d.ts","sourceRoot":"","sources":["../../client/event-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,YAAY,EAAE,kBAAkB,EAAE,CAAC;AAInC;;;;;GAKG;AACH,OAAO,EAAE,CAAC;AAEV;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,MAAM,CAAC;AAE9C,oEAAoE;AACpE,MAAM,WAAW,cAAc;IAC7B,yCAAyC;IACzC,eAAe,EAAE,MAAM,CAAC;IACxB,iEAAiE;IACjE,WAAW,EAAE,MAAM,CAAC;IACpB,4BAA4B;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,0CAA0C;IAC1C,MAAM,EAAE,cAAc,CAAC;IACvB,mEAAmE;IACnE,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,+EAA+E;IAC/E,mBAAmB,EAAE,OAAO,CAAC;IAC7B,2DAA2D;IAC3D,WAAW,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,eAAe,EAAE,MAAM,CAAC;IACxB,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,6BAA6B;IAC7B,KAAK,EAAE,kBAAkB,CAAC;IAC1B,iFAAiF;IACjF,gBAAgB,EAAE,MAAM,CAAC;IACzB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|
* });
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
|
+
import { ReceiveHookTimeout } from './receive-hook-bound.js';
|
|
38
39
|
import { rethrowRelayWorkStopped } from './relay-work.js';
|
|
39
40
|
const HOOK_NAMES = {
|
|
40
41
|
onSessionEstablished: true,
|
|
@@ -47,6 +48,11 @@ const HOOK_NAMES = {
|
|
|
47
48
|
onEncryptionError: true,
|
|
48
49
|
onKeysCleanedUp: true,
|
|
49
50
|
onDelivered: true,
|
|
51
|
+
onRetryTerminal: true,
|
|
52
|
+
onDeliveryError: true,
|
|
53
|
+
onDeliveryRecovered: true,
|
|
54
|
+
onReceiveExpired: true,
|
|
55
|
+
onRelayProtocolError: true,
|
|
50
56
|
onReadReceiptReceived: true,
|
|
51
57
|
onViewedReceiptReceived: true,
|
|
52
58
|
onTypingIndicatorReceived: true,
|
|
@@ -80,6 +86,9 @@ export async function callHook(hooks, hookName, ...args) {
|
|
|
80
86
|
}
|
|
81
87
|
catch (error) {
|
|
82
88
|
rethrowRelayWorkStopped(error);
|
|
89
|
+
// The receive hook bound logged its timeout.
|
|
90
|
+
if (error instanceof ReceiveHookTimeout)
|
|
91
|
+
return;
|
|
83
92
|
// Log hook error but do not let it break core functionality
|
|
84
93
|
console.error(`Hook ${hookName} failed:`, error);
|
|
85
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-hooks.js","sourceRoot":"","sources":["../../client/event-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;
|
|
1
|
+
{"version":3,"file":"event-hooks.js","sourceRoot":"","sources":["../../client/event-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAKH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAypBvD,MAAM,UAAU,G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AAkB;YAAE,OAAO;QAChD,4DAA4D;QAC5D,OAAO,CAAC,KAAK,CAAC,QAAQ,QAAQ,UAAU,EAAE,KAAK,CAAC,CAAC;IACnD,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,KAA4C;IAIrE,MAAM,MAAM,GAAiC,EAAE,CAAC;IAChD,MAAM,QAAQ,GAAiD,EAAE,CAAC;IAClE,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC;QACvD,IAAI,OAAO,IAAI,KAAK,UAAU;YAAE,SAAS;QACzC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE;YAC3B,MAAM,CAAC,IAAI,CAAC,CAAC,IAAgB,EAAE,IAAI,CAAC,CAAC,CAAC;QACxC,CAAC,CAAC;IACJ,CAAC;IACD,MAAM,IAAI,GAAG,QAIK,CAAC;IACnB,OAAO;QACL,KAAK,EAAE,QAAqC;QAC5C,KAAK,CAAC,KAAK;YACT,KAAK,IAAI,IAAI,GAAG,MAAM,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;gBAC5D,MAAM,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACzC,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The listed device set of one send. A replay reads the device lists of the
|
|
3
|
+
* members and of the sender's own account again, and this module finds how
|
|
4
|
+
* the read changes the stored set: the stored targets that the read no longer
|
|
5
|
+
* lists, and the listed devices that the send does not reach yet. It does not
|
|
6
|
+
* post or encrypt.
|
|
7
|
+
*/
|
|
8
|
+
import type { OutgoingGroupDevice, StoredGroupSharedMessage, StoredOutgoingDeviceMessage, StoredOutgoingMessageIntent } from '../local/store/reliability.js';
|
|
9
|
+
import type { GroupMemberDevice } from '../remote/relay/types.js';
|
|
10
|
+
/** The change that a new read of the member device lists makes to a stored group send. */
|
|
11
|
+
export interface ListedGroupDeviceChange {
|
|
12
|
+
/**
|
|
13
|
+
* The devices of other members that a stored pre-message or device message
|
|
14
|
+
* targets, and that the read no longer lists.
|
|
15
|
+
*/
|
|
16
|
+
unlisted: OutgoingGroupDevice[];
|
|
17
|
+
/** The listed devices of other members that no stored device message targets. */
|
|
18
|
+
added: GroupMemberDevice[];
|
|
19
|
+
}
|
|
20
|
+
/** The change that a new read of the sender's own device list makes to the sync copies of a send. */
|
|
21
|
+
export interface ListedOwnDeviceChange {
|
|
22
|
+
/** The own devices that a stored sync copy targets, and that the read no longer lists. */
|
|
23
|
+
unlisted: number[];
|
|
24
|
+
/** The listed own devices that no stored sync copy targets, in list order. */
|
|
25
|
+
added: number[];
|
|
26
|
+
}
|
|
27
|
+
/** One key for each device of an account. */
|
|
28
|
+
export declare function groupDeviceKey({ userId, deviceId }: OutgoingGroupDevice): string;
|
|
29
|
+
/**
|
|
30
|
+
* The change that `listed` makes to the stored targets of `intent`. `listed`
|
|
31
|
+
* holds the complete device list of each member of the send. The devices of
|
|
32
|
+
* the sender's own account are not member targets.
|
|
33
|
+
*/
|
|
34
|
+
export declare function listedGroupDeviceChange(intent: StoredOutgoingMessageIntent, listed: readonly GroupMemberDevice[], senderUserId: string): ListedGroupDeviceChange;
|
|
35
|
+
/**
|
|
36
|
+
* The change that `listedDeviceIds` makes to the stored sync copies of a
|
|
37
|
+
* send. `listedDeviceIds` holds the sender's own listed devices other than
|
|
38
|
+
* the sending device.
|
|
39
|
+
*/
|
|
40
|
+
export declare function listedOwnDeviceChange(syncMessages: readonly StoredOutgoingDeviceMessage[], listedDeviceIds: readonly number[]): ListedOwnDeviceChange;
|
|
41
|
+
/**
|
|
42
|
+
* The devices that a stored shared body names, as keys, each with the
|
|
43
|
+
* registration that the body names for it. The body names the devices of
|
|
44
|
+
* each account in the order of `recipientUserIds`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function sharedBodyDevices(shared: StoredGroupSharedMessage): Map<string, number>;
|
|
47
|
+
//# sourceMappingURL=group-device-set.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-device-set.d.ts","sourceRoot":"","sources":["../../client/group-device-set.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,2BAA2B,EAC3B,2BAA2B,EAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG/D,0FAA0F;AAC1F,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,iFAAiF;IACjF,KAAK,EAAE,iBAAiB,EAAE,CAAC;CAC5B;AAED,qGAAqG;AACrG,MAAM,WAAW,qBAAqB;IACpC,0FAA0F;IAC1F,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,8EAA8E;IAC9E,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,6CAA6C;AAC7C,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,mBAAmB,GAAG,MAAM,CAEhF;AAOD;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,2BAA2B,EACnC,MAAM,EAAE,SAAS,iBAAiB,EAAE,EACpC,YAAY,EAAE,MAAM,GACnB,uBAAuB,CAezB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,SAAS,2BAA2B,EAAE,EACpD,eAAe,EAAE,SAAS,MAAM,EAAE,GACjC,qBAAqB,CAOvB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,wBAAwB,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAYvF"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The listed device set of one send. A replay reads the device lists of the
|
|
3
|
+
* members and of the sender's own account again, and this module finds how
|
|
4
|
+
* the read changes the stored set: the stored targets that the read no longer
|
|
5
|
+
* lists, and the listed devices that the send does not reach yet. It does not
|
|
6
|
+
* post or encrypt.
|
|
7
|
+
*/
|
|
8
|
+
import { base64ToBytes } from '../internal/crypto/index.js';
|
|
9
|
+
import { deserializeSentMessage } from '../internal/protocol/sealed-sender/multi-recipient-message.js';
|
|
10
|
+
import { asBase64 } from '../types/utils.js';
|
|
11
|
+
/** One key for each device of an account. */
|
|
12
|
+
export function groupDeviceKey({ userId, deviceId }) {
|
|
13
|
+
return `${userId}\u0000${String(deviceId)}`;
|
|
14
|
+
}
|
|
15
|
+
/** The key of the device that a stored message targets. */
|
|
16
|
+
function targetKey(message) {
|
|
17
|
+
return groupDeviceKey({ userId: message.recipientUserId, deviceId: message.recipientDeviceId });
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The change that `listed` makes to the stored targets of `intent`. `listed`
|
|
21
|
+
* holds the complete device list of each member of the send. The devices of
|
|
22
|
+
* the sender's own account are not member targets.
|
|
23
|
+
*/
|
|
24
|
+
export function listedGroupDeviceChange(intent, listed, senderUserId) {
|
|
25
|
+
const others = listed.filter((member) => member.userId !== senderUserId);
|
|
26
|
+
const listedKeys = new Set(others.map(groupDeviceKey));
|
|
27
|
+
const unlisted = new Map();
|
|
28
|
+
for (const message of [...(intent.preMessages ?? []), ...intent.deviceMessages]) {
|
|
29
|
+
const key = targetKey(message);
|
|
30
|
+
if (!listedKeys.has(key)) {
|
|
31
|
+
unlisted.set(key, { userId: message.recipientUserId, deviceId: message.recipientDeviceId });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const targeted = new Set(intent.deviceMessages.map(targetKey));
|
|
35
|
+
return {
|
|
36
|
+
unlisted: [...unlisted.values()],
|
|
37
|
+
added: others.filter((member) => !targeted.has(groupDeviceKey(member))),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The change that `listedDeviceIds` makes to the stored sync copies of a
|
|
42
|
+
* send. `listedDeviceIds` holds the sender's own listed devices other than
|
|
43
|
+
* the sending device.
|
|
44
|
+
*/
|
|
45
|
+
export function listedOwnDeviceChange(syncMessages, listedDeviceIds) {
|
|
46
|
+
const listed = new Set(listedDeviceIds);
|
|
47
|
+
const stored = new Set(syncMessages.map((message) => message.recipientDeviceId));
|
|
48
|
+
return {
|
|
49
|
+
unlisted: [...stored].filter((deviceId) => !listed.has(deviceId)),
|
|
50
|
+
added: [...listed].filter((deviceId) => !stored.has(deviceId)),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The devices that a stored shared body names, as keys, each with the
|
|
55
|
+
* registration that the body names for it. The body names the devices of
|
|
56
|
+
* each account in the order of `recipientUserIds`.
|
|
57
|
+
*/
|
|
58
|
+
export function sharedBodyDevices(shared) {
|
|
59
|
+
const { recipients } = deserializeSentMessage(base64ToBytes(asBase64(shared.sentMessageBase64)));
|
|
60
|
+
return new Map(recipients.flatMap(({ devices }, index) => devices.map(({ deviceId, registrationId }) => [
|
|
61
|
+
groupDeviceKey({ userId: shared.recipientUserIds[index], deviceId }),
|
|
62
|
+
registrationId,
|
|
63
|
+
])));
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=group-device-set.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-device-set.js","sourceRoot":"","sources":["../../client/group-device-set.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4DAA4D,CAAC;AAQpG,OAAO,EAAE,QAAQ,EAAE,MAAM,gBA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