@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
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import { utf8Decode } from '../platform/index.js';
|
|
19
19
|
import { defaultSignalProtocolLogger } from '../../logger.js';
|
|
20
20
|
import { getErrorMessage } from '../../utils/errors.js';
|
|
21
|
-
import { RetryReason, DEFAULT_SESAME_CONFIG, SesameError, SesameDeviceNotFoundError, NoActiveSessionError, DecryptionFailedError, StaleDeviceListError, MIN_DEVICE_ID, MAX_DEVICE_ID,
|
|
21
|
+
import { RetryReason, DEFAULT_SESAME_CONFIG, SesameError, SesameDeviceNotFoundError, NoActiveSessionError, DecryptionFailedError, StaleDeviceListError, MIN_DEVICE_ID, MAX_DEVICE_ID, isRemovedDevice, isExpiredRemovedDevice,
|
|
22
22
|
// Session record helpers
|
|
23
23
|
updateSessionRecordAfterSend, updateSessionRecordAfterReceive, } from './types.js';
|
|
24
24
|
import { validateSesameConfig } from './validation.js';
|
|
@@ -93,6 +93,7 @@ export class DefaultSesameManager {
|
|
|
93
93
|
* Per SESAME Specification Section 6.2.
|
|
94
94
|
*/
|
|
95
95
|
messageRecordStore = null;
|
|
96
|
+
messageRecordPlaintext = (plaintext) => plaintext;
|
|
96
97
|
/**
|
|
97
98
|
* O(1) session lookup index: sessionId -> { userId, deviceId }
|
|
98
99
|
*
|
|
@@ -145,8 +146,9 @@ export class DefaultSesameManager {
|
|
|
145
146
|
*
|
|
146
147
|
* When set, sent messages are stored so they can be resent on retry request.
|
|
147
148
|
*/
|
|
148
|
-
setMessageRecordStore(store) {
|
|
149
|
+
setMessageRecordStore(store, recordPlaintext = (plaintext) => plaintext) {
|
|
149
150
|
this.messageRecordStore = store;
|
|
151
|
+
this.messageRecordPlaintext = recordPlaintext;
|
|
150
152
|
}
|
|
151
153
|
/**
|
|
152
154
|
* Set event callbacks for session lifecycle events.
|
|
@@ -246,13 +248,19 @@ export class DefaultSesameManager {
|
|
|
246
248
|
this.events.onDeviceAdded?.(userId, deviceId);
|
|
247
249
|
}
|
|
248
250
|
/**
|
|
249
|
-
* Remove a device from a user. The removal
|
|
250
|
-
*
|
|
251
|
+
* Remove a device from a user. The removal archives the current session of
|
|
252
|
+
* the device, marks the record removed, and keeps the record, so a message
|
|
253
|
+
* that the device sent earlier still decrypts. The removal writes the
|
|
254
|
+
* session, so it waits for a session write that is in progress for the
|
|
255
|
+
* device. A device that is already removed stays as it is.
|
|
251
256
|
*/
|
|
252
257
|
async removeDevice(userId, deviceId) {
|
|
253
258
|
await this.withDeviceLocks(userId, deviceId, () => this.removeDeviceLocked(userId, deviceId));
|
|
254
259
|
}
|
|
255
260
|
async removeDeviceLocked(userId, deviceId) {
|
|
261
|
+
const deviceRecord = await this.storage.getDeviceRecord(userId, deviceId);
|
|
262
|
+
if (!deviceRecord || isRemovedDevice(deviceRecord))
|
|
263
|
+
return;
|
|
256
264
|
this.logger.debug('SESAME: Removing device', {
|
|
257
265
|
category: 'E2EE',
|
|
258
266
|
data: {
|
|
@@ -261,23 +269,54 @@ export class DefaultSesameManager {
|
|
|
261
269
|
deviceId,
|
|
262
270
|
},
|
|
263
271
|
});
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
//
|
|
268
|
-
this.
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
// Update user record (or clean up if empty)
|
|
275
|
-
if (userRecord.devices.size > 0) {
|
|
276
|
-
await this.storage.setUserRecord(userId, userRecord);
|
|
277
|
-
}
|
|
278
|
-
// Emit device removed event
|
|
272
|
+
const now = Date.now();
|
|
273
|
+
// One Signal client archives the session of a device that the
|
|
274
|
+
// server no longer lists, and keeps the session for receive. The marker
|
|
275
|
+
// write carries the handoff invalidation with or without a session.
|
|
276
|
+
await this.storage.setDeviceRecord(userId, deviceId, {
|
|
277
|
+
...deviceRecord,
|
|
278
|
+
session: this.archiveCurrentIndexed(userId, deviceId, deviceRecord.session),
|
|
279
|
+
removedAt: now,
|
|
280
|
+
updatedAt: now,
|
|
281
|
+
}, { senderKeyHandoffInvalidation: { userId, deviceId } });
|
|
279
282
|
this.events.onDeviceRemoved?.(userId, deviceId);
|
|
280
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* Return a removed device to the fan-out set after its device list names
|
|
286
|
+
* it again. The marker clears, and the device has no current session until
|
|
287
|
+
* a send starts one. The archived sessions stay. A device that is not
|
|
288
|
+
* removed stays as it is.
|
|
289
|
+
*/
|
|
290
|
+
async relistDevice(userId, deviceId) {
|
|
291
|
+
await this.withUserLock(userId, async () => {
|
|
292
|
+
const deviceRecord = await this.storage.getDeviceRecord(userId, deviceId);
|
|
293
|
+
if (deviceRecord)
|
|
294
|
+
await this.relistDeviceLocked(deviceRecord);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Clear the removed marker of a record under the user lock. The write
|
|
299
|
+
* carries no session, so the stored session stays.
|
|
300
|
+
*
|
|
301
|
+
* @returns false when the record is not removed
|
|
302
|
+
*/
|
|
303
|
+
async relistDeviceLocked(deviceRecord) {
|
|
304
|
+
if (!isRemovedDevice(deviceRecord))
|
|
305
|
+
return false;
|
|
306
|
+
const { userId, deviceId } = deviceRecord;
|
|
307
|
+
const { removedAt: _removedAt, ...listed } = deviceRecord;
|
|
308
|
+
await this.storage.setDeviceRecord(userId, deviceId, {
|
|
309
|
+
...listed,
|
|
310
|
+
session: null,
|
|
311
|
+
updatedAt: Date.now(),
|
|
312
|
+
});
|
|
313
|
+
this.logger.debug('SESAME: Relisted device', {
|
|
314
|
+
category: 'E2EE',
|
|
315
|
+
data: { operation: 'sesame-relist-device', userId, deviceId },
|
|
316
|
+
});
|
|
317
|
+
this.events.onDeviceAdded?.(userId, deviceId);
|
|
318
|
+
return true;
|
|
319
|
+
}
|
|
281
320
|
/**
|
|
282
321
|
* Clear pending verification flag for a device after user verifies safety numbers.
|
|
283
322
|
* This unblocks messaging to the device.
|
|
@@ -327,6 +366,14 @@ export class DefaultSesameManager {
|
|
|
327
366
|
const sessionRecord = await this.getSession(userId, deviceId);
|
|
328
367
|
return sessionRecord?.currentSession ?? null;
|
|
329
368
|
}
|
|
369
|
+
/**
|
|
370
|
+
* Get the registration ID of the remote device in the current session.
|
|
371
|
+
* Returns undefined if no current session exists.
|
|
372
|
+
*/
|
|
373
|
+
async getRemoteRegistrationId(userId, deviceId) {
|
|
374
|
+
const session = await this.getActiveSession(userId, deviceId);
|
|
375
|
+
return session?.remoteRegistrationId;
|
|
376
|
+
}
|
|
330
377
|
/**
|
|
331
378
|
* Set the session record for a device (internal helper).
|
|
332
379
|
* Uses SessionRecord.archiveCurrent() to move the previous active session to archived.
|
|
@@ -493,15 +540,21 @@ export class DefaultSesameManager {
|
|
|
493
540
|
const clientTimestamp = options?.clientTimestamp ?? Date.now();
|
|
494
541
|
// Store MessageRecord for retry request support (SESAME spec §6.2)
|
|
495
542
|
// "Each MessageRecord stores the plaintext of the encrypted message"
|
|
496
|
-
|
|
543
|
+
// The policy can keep less than the sent plaintext, or no record.
|
|
544
|
+
const recordPlaintext = this.messageRecordStore
|
|
545
|
+
? this.messageRecordPlaintext(plaintextString)
|
|
546
|
+
: null;
|
|
547
|
+
if (this.messageRecordStore && recordPlaintext !== null) {
|
|
497
548
|
try {
|
|
498
549
|
await this.messageRecordStore.storeMessageRecord({
|
|
499
550
|
sessionId,
|
|
500
551
|
timestamp: clientTimestamp,
|
|
501
552
|
recipientUserId,
|
|
502
553
|
recipientDeviceId,
|
|
503
|
-
plaintext:
|
|
504
|
-
createdAt
|
|
554
|
+
plaintext: recordPlaintext,
|
|
555
|
+
// The store sets createdAt from its clock at the first write.
|
|
556
|
+
// Retention reads it, so the client timestamp never moves it.
|
|
557
|
+
createdAt: Date.now(),
|
|
505
558
|
// store sender's
|
|
506
559
|
// current ratchet key (DHs) for retry session matching. Detects intra-session
|
|
507
560
|
// ratchet advancement, not just cross-session changes.
|
|
@@ -687,10 +740,14 @@ export class DefaultSesameManager {
|
|
|
687
740
|
if (!localUserRecord) {
|
|
688
741
|
return [];
|
|
689
742
|
}
|
|
743
|
+
const { listedDeviceIds, ...sendOptions } = options;
|
|
690
744
|
const syncMessages = [];
|
|
691
|
-
for (const
|
|
745
|
+
for (const deviceId of new Set(listedDeviceIds)) {
|
|
692
746
|
if (deviceId === this.localDeviceId)
|
|
693
747
|
continue;
|
|
748
|
+
const deviceRecord = localUserRecord.devices.get(deviceId);
|
|
749
|
+
if (!deviceRecord || isRemovedDevice(deviceRecord))
|
|
750
|
+
continue;
|
|
694
751
|
try {
|
|
695
752
|
const activeSession = deviceRecord.session?.currentSession;
|
|
696
753
|
if (!activeSession)
|
|
@@ -699,7 +756,7 @@ export class DefaultSesameManager {
|
|
|
699
756
|
const canSend = await this.canSendOnSession(sessionId);
|
|
700
757
|
if (!canSend)
|
|
701
758
|
continue;
|
|
702
|
-
const syncMessage = await this.sendMessage(this.localUserId, deviceId, plaintext,
|
|
759
|
+
const syncMessage = await this.sendMessage(this.localUserId, deviceId, plaintext, sendOptions);
|
|
703
760
|
syncMessages.push(syncMessage);
|
|
704
761
|
}
|
|
705
762
|
catch {
|
|
@@ -741,7 +798,10 @@ export class DefaultSesameManager {
|
|
|
741
798
|
if (!userRecord) {
|
|
742
799
|
throw new SesameError(`No user record found for ${recipientUserId}`, 'USER_NOT_FOUND');
|
|
743
800
|
}
|
|
744
|
-
|
|
801
|
+
// A removed device gets no fan-out. A listed device with no current
|
|
802
|
+
// session is still attempted, and fails with NoActiveSessionError.
|
|
803
|
+
const devices = Array.from(userRecord.devices.entries()).filter(([, deviceRecord]) => !isRemovedDevice(deviceRecord));
|
|
804
|
+
if (devices.length === 0) {
|
|
745
805
|
throw new SesameError(`User ${recipientUserId} has no devices`, 'NO_DEVICES');
|
|
746
806
|
}
|
|
747
807
|
const timestamp = Date.now();
|
|
@@ -754,12 +814,12 @@ export class DefaultSesameManager {
|
|
|
754
814
|
data: {
|
|
755
815
|
operation: 'sesame-send-user',
|
|
756
816
|
recipientUserId,
|
|
757
|
-
deviceCount:
|
|
817
|
+
deviceCount: devices.length,
|
|
758
818
|
includeSyncMessages,
|
|
759
819
|
},
|
|
760
820
|
});
|
|
761
821
|
// Phase 1 & 2: Encrypt message for each recipient device
|
|
762
|
-
for (const [deviceId, deviceRecord] of
|
|
822
|
+
for (const [deviceId, deviceRecord] of devices) {
|
|
763
823
|
attemptedDevices++;
|
|
764
824
|
try {
|
|
765
825
|
// Check if device has an active session
|
|
@@ -807,16 +867,26 @@ export class DefaultSesameManager {
|
|
|
807
867
|
if (deviceMessages.length === 0 && failures.length > 0) {
|
|
808
868
|
throw new SesameError(`Failed to send message to all ${failures.length} devices: ${failures.map((f) => `${f.deviceId}: ${f.error.message}`).join(', ')}`, 'ALL_DEVICES_FAILED');
|
|
809
869
|
}
|
|
810
|
-
// Encrypt sync messages for our own other devices (multi-device sync)
|
|
870
|
+
// Encrypt sync messages for our own other devices (multi-device sync).
|
|
871
|
+
// This batch reads no device list, so the copies go to the known devices.
|
|
811
872
|
if (includeSyncMessages) {
|
|
873
|
+
const knownDeviceIds = [];
|
|
812
874
|
if (this.localUserId) {
|
|
813
875
|
const localUserRecord = await this.getUserRecord(this.localUserId);
|
|
814
876
|
if (localUserRecord) {
|
|
815
|
-
|
|
877
|
+
for (const [deviceId, deviceRecord] of localUserRecord.devices) {
|
|
878
|
+
if (deviceId !== this.localDeviceId && !isRemovedDevice(deviceRecord)) {
|
|
879
|
+
knownDeviceIds.push(deviceId);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
attemptedDevices += knownDeviceIds.length;
|
|
816
883
|
}
|
|
817
884
|
}
|
|
818
885
|
const syncPayload = options?.syncPlaintext ?? plaintext;
|
|
819
|
-
const localSyncMessages = await this.sendToLocalOtherDevices(syncPayload,
|
|
886
|
+
const localSyncMessages = await this.sendToLocalOtherDevices(syncPayload, {
|
|
887
|
+
...options,
|
|
888
|
+
listedDeviceIds: knownDeviceIds,
|
|
889
|
+
});
|
|
820
890
|
syncMessages.push(...localSyncMessages);
|
|
821
891
|
}
|
|
822
892
|
// Log partial failures
|
|
@@ -853,7 +923,7 @@ export class DefaultSesameManager {
|
|
|
853
923
|
*
|
|
854
924
|
* @see https://signal.org/docs/specifications/sesame/
|
|
855
925
|
*/
|
|
856
|
-
async receive(message,
|
|
926
|
+
async receive(message, receiveWork) {
|
|
857
927
|
if (!this.localUserId || !this.localDeviceId) {
|
|
858
928
|
throw new SesameError('DefaultSesameManager not initialized', 'NOT_INITIALIZED');
|
|
859
929
|
}
|
|
@@ -885,7 +955,7 @@ export class DefaultSesameManager {
|
|
|
885
955
|
// session establishment for first messages from new senders
|
|
886
956
|
if (candidates.length === 0) {
|
|
887
957
|
try {
|
|
888
|
-
const result = await this.handlePreKeyMessage(message, senderAddress, ciphertext,
|
|
958
|
+
const result = await this.handlePreKeyMessage(message, senderAddress, ciphertext, receiveWork);
|
|
889
959
|
// TRANSACTIONAL: Only persist after successful decrypt
|
|
890
960
|
// This prevents session state corruption if decryption fails
|
|
891
961
|
await this.persistPreKeyResult(senderAddress, result);
|
|
@@ -922,7 +992,7 @@ export class DefaultSesameManager {
|
|
|
922
992
|
let successfulCandidate = null;
|
|
923
993
|
for (const candidate of candidates) {
|
|
924
994
|
try {
|
|
925
|
-
const plaintextString = await this.protocol.decrypt(senderAddress, ciphertext,
|
|
995
|
+
const plaintextString = await this.protocol.decrypt(senderAddress, ciphertext, receiveWork);
|
|
926
996
|
decryptedPlaintext = new TextEncoder().encode(plaintextString);
|
|
927
997
|
successfulCandidate = candidate;
|
|
928
998
|
break;
|
|
@@ -981,7 +1051,7 @@ export class DefaultSesameManager {
|
|
|
981
1051
|
},
|
|
982
1052
|
});
|
|
983
1053
|
try {
|
|
984
|
-
const result = await this.handlePreKeyMessage(message, senderAddress, ciphertext,
|
|
1054
|
+
const result = await this.handlePreKeyMessage(message, senderAddress, ciphertext, receiveWork);
|
|
985
1055
|
// TRANSACTIONAL: Only persist after successful decrypt
|
|
986
1056
|
// This prevents session state corruption if decryption fails
|
|
987
1057
|
await this.persistPreKeyResult(senderAddress, result);
|
|
@@ -1016,7 +1086,7 @@ export class DefaultSesameManager {
|
|
|
1016
1086
|
/**
|
|
1017
1087
|
* Create a retry request for a failed message
|
|
1018
1088
|
*/
|
|
1019
|
-
async createRetryRequest(failedMessage, reason) {
|
|
1089
|
+
async createRetryRequest(failedMessage, reason, options) {
|
|
1020
1090
|
if (!this.config.enableRetryRequests) {
|
|
1021
1091
|
throw new SesameError('Retry requests are disabled in configuration', 'RETRY_DISABLED');
|
|
1022
1092
|
}
|
|
@@ -1028,7 +1098,11 @@ export class DefaultSesameManager {
|
|
|
1028
1098
|
if (failedMessage.timestamp === undefined) {
|
|
1029
1099
|
throw new SesameError('Cannot create retry request: message has no timestamp', 'MISSING_TIMESTAMP');
|
|
1030
1100
|
}
|
|
1031
|
-
|
|
1101
|
+
// A sender-key ciphertext has no ratchet key, and its bytes can parse as
|
|
1102
|
+
// one. A request without a ratchet key names a sender-key failure.
|
|
1103
|
+
const ratchetKey = options?.senderKey
|
|
1104
|
+
? undefined
|
|
1105
|
+
: this.extractRetryRatchetKey(failedMessage.ciphertext);
|
|
1032
1106
|
const retryRequest = {
|
|
1033
1107
|
requesterUserId: this.localUserId,
|
|
1034
1108
|
requesterDeviceId: this.localDeviceId,
|
|
@@ -1123,7 +1197,7 @@ export class DefaultSesameManager {
|
|
|
1123
1197
|
if (retryRequest.reason === RetryReason.DECRYPTION_FAILED) {
|
|
1124
1198
|
const activeSession = await this.getActiveSession(requesterUserId, requesterDeviceId);
|
|
1125
1199
|
const currentRatchetKey = activeSession?.DHs?.publicKey;
|
|
1126
|
-
//
|
|
1200
|
+
// Two Signal clients reset a session on retry only if the ratchet
|
|
1127
1201
|
// key from DecryptionErrorMessage matches the current active session.
|
|
1128
1202
|
if (!retryRequest.ratchetKey ||
|
|
1129
1203
|
!currentRatchetKey ||
|
|
@@ -1280,7 +1354,7 @@ export class DefaultSesameManager {
|
|
|
1280
1354
|
* @returns Decrypted plaintext as Uint8Array
|
|
1281
1355
|
* @throws DecryptionFailedError if decryption fails
|
|
1282
1356
|
*/
|
|
1283
|
-
async handlePreKeyMessage(message, senderAddress, ciphertext,
|
|
1357
|
+
async handlePreKeyMessage(message, senderAddress, ciphertext, receiveWork) {
|
|
1284
1358
|
this.logger.debug('SESAME: No existing sessions, trying PreKeyMessage handling', {
|
|
1285
1359
|
category: 'E2EE',
|
|
1286
1360
|
data: {
|
|
@@ -1295,7 +1369,7 @@ export class DefaultSesameManager {
|
|
|
1295
1369
|
// brand-new session appear pre-existing and archive it into itself.
|
|
1296
1370
|
const previousDeviceRecord = await this.getDeviceRecord(message.senderUserId, message.senderDeviceId);
|
|
1297
1371
|
// Note: this.protocol is guaranteed non-null because receive() checks it before calling this method
|
|
1298
|
-
const plaintextString = await this.protocol.decrypt(senderAddress, ciphertext,
|
|
1372
|
+
const plaintextString = await this.protocol.decrypt(senderAddress, ciphertext, receiveWork);
|
|
1299
1373
|
const decryptedPlaintext = new TextEncoder().encode(plaintextString);
|
|
1300
1374
|
// Parse PreKeyMessage to get sender's identity key (binary protobuf format)
|
|
1301
1375
|
// This is needed for both new senders AND existing senders (to detect identity key changes)
|
|
@@ -1402,7 +1476,12 @@ export class DefaultSesameManager {
|
|
|
1402
1476
|
// Update session index for the newly established session
|
|
1403
1477
|
this.removeDeviceFromSessionIndex(userId, deviceId);
|
|
1404
1478
|
this.indexSessionRecord(userId, deviceId, deviceRecord.session);
|
|
1405
|
-
|
|
1479
|
+
// The PreKey session can come from a new install of the device, which
|
|
1480
|
+
// holds no own sender key. The same write deletes the handoff rows of
|
|
1481
|
+
// the device in every group.
|
|
1482
|
+
await this.storage.setDeviceRecord(userId, deviceId, deviceRecord, {
|
|
1483
|
+
senderKeyHandoffInvalidation: { userId, deviceId },
|
|
1484
|
+
});
|
|
1406
1485
|
// A store joins a device that has no pin with the identity of its
|
|
1407
1486
|
// session, and the decrypt committed that session. A device that had no
|
|
1408
1487
|
// pin before the decrypt is a first-contact pin.
|
|
@@ -1509,6 +1588,19 @@ export class DefaultSesameManager {
|
|
|
1509
1588
|
}
|
|
1510
1589
|
});
|
|
1511
1590
|
}
|
|
1591
|
+
/**
|
|
1592
|
+
* Archive the session of one device in the protocol store and in its
|
|
1593
|
+
* device record, so the next send to the device starts a new session.
|
|
1594
|
+
* Both writes run under one hold of the session lock of the device and
|
|
1595
|
+
* the user lock: `archiveProtocolSession` first, and then the device
|
|
1596
|
+
* record. A device record with no current session stays as it is.
|
|
1597
|
+
*/
|
|
1598
|
+
async archiveSession(userId, deviceId, archiveProtocolSession) {
|
|
1599
|
+
await this.withDeviceLocks(userId, deviceId, async () => {
|
|
1600
|
+
await archiveProtocolSession();
|
|
1601
|
+
await this.archiveSessionForDeviceLocked(userId, deviceId);
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1512
1604
|
/**
|
|
1513
1605
|
* Archive the active session for a specific device
|
|
1514
1606
|
*
|
|
@@ -1518,6 +1610,20 @@ export class DefaultSesameManager {
|
|
|
1518
1610
|
async archiveSessionForDevice(userId, deviceId) {
|
|
1519
1611
|
await this.withDeviceLocks(userId, deviceId, () => this.archiveSessionForDeviceLocked(userId, deviceId));
|
|
1520
1612
|
}
|
|
1613
|
+
/**
|
|
1614
|
+
* Move the current session of a device record to its archived sessions,
|
|
1615
|
+
* and index the result. The caller holds the device locks and writes the
|
|
1616
|
+
* returned session. A record with no current session is returned as it is.
|
|
1617
|
+
*/
|
|
1618
|
+
archiveCurrentIndexed(userId, deviceId, session) {
|
|
1619
|
+
if (!session?.currentSession)
|
|
1620
|
+
return session;
|
|
1621
|
+
const archived = SessionResolver.archiveCurrentSession(session, this.config.maxInactiveSessions);
|
|
1622
|
+
// The session moved from current to archived.
|
|
1623
|
+
this.removeDeviceFromSessionIndex(userId, deviceId);
|
|
1624
|
+
this.indexSessionRecord(userId, deviceId, archived);
|
|
1625
|
+
return archived;
|
|
1626
|
+
}
|
|
1521
1627
|
async archiveSessionForDeviceLocked(userId, deviceId) {
|
|
1522
1628
|
const deviceRecord = await this.storage.getDeviceRecord(userId, deviceId);
|
|
1523
1629
|
if (!deviceRecord?.session?.currentSession) {
|
|
@@ -1525,12 +1631,13 @@ export class DefaultSesameManager {
|
|
|
1525
1631
|
return;
|
|
1526
1632
|
}
|
|
1527
1633
|
const sessionId = ProtocolAddress.toString(deviceRecord.session.currentSession.remoteAddress);
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
//
|
|
1531
|
-
|
|
1532
|
-
this.
|
|
1533
|
-
|
|
1634
|
+
deviceRecord.session = this.archiveCurrentIndexed(userId, deviceId, deviceRecord.session);
|
|
1635
|
+
// An archive follows a sign that the device lost its session, so it can
|
|
1636
|
+
// also have lost the own sender keys. The same write deletes the handoff
|
|
1637
|
+
// rows of the device in every group.
|
|
1638
|
+
await this.storage.setDeviceRecord(userId, deviceId, deviceRecord, {
|
|
1639
|
+
senderKeyHandoffInvalidation: { userId, deviceId },
|
|
1640
|
+
});
|
|
1534
1641
|
this.logger.debug('SESAME: Session archived', {
|
|
1535
1642
|
category: 'E2EE',
|
|
1536
1643
|
data: {
|
|
@@ -1547,12 +1654,17 @@ export class DefaultSesameManager {
|
|
|
1547
1654
|
* Retry metadata includes the sender ratchet key for one-to-one
|
|
1548
1655
|
* SignalProtocolMessage/PreKeySignalProtocolMessage failures and omits it for
|
|
1549
1656
|
* sender-key messages.
|
|
1657
|
+
*
|
|
1658
|
+
* The failed message holds the stored wire form of the ciphertext: the
|
|
1659
|
+
* UTF-8 bytes of the base64 text of the framed message. A sealed or
|
|
1660
|
+
* malformed ciphertext gives no key.
|
|
1550
1661
|
*/
|
|
1551
|
-
extractRetryRatchetKey(
|
|
1552
|
-
if (
|
|
1662
|
+
extractRetryRatchetKey(wire) {
|
|
1663
|
+
if (wire.length < 2) {
|
|
1553
1664
|
return undefined;
|
|
1554
1665
|
}
|
|
1555
1666
|
try {
|
|
1667
|
+
const ciphertext = base64ToBytes(utf8Decode(wire));
|
|
1556
1668
|
let signalMessageProtobuf;
|
|
1557
1669
|
const firstTag = ciphertext[1];
|
|
1558
1670
|
const isPreKey = firstTag === 0x08 || firstTag === 0x12;
|
|
@@ -1688,7 +1800,9 @@ export class DefaultSesameManager {
|
|
|
1688
1800
|
return count;
|
|
1689
1801
|
}
|
|
1690
1802
|
/**
|
|
1691
|
-
*
|
|
1803
|
+
* Delete the stale device records: a record with no session that is older
|
|
1804
|
+
* than maxLatency, and a removed record whose removal is older than
|
|
1805
|
+
* maxLatency. The client runs it at start, after the receive queue resume.
|
|
1692
1806
|
*/
|
|
1693
1807
|
async cleanupStaleRecords() {
|
|
1694
1808
|
if (!this.config.enableStaleRecordCleanup) {
|
|
@@ -1746,32 +1860,45 @@ export class DefaultSesameManager {
|
|
|
1746
1860
|
}
|
|
1747
1861
|
return null;
|
|
1748
1862
|
}
|
|
1749
|
-
// Devices that no longer exist on server
|
|
1750
|
-
|
|
1863
|
+
// Devices that no longer exist on server. A device that is already
|
|
1864
|
+
// removed stays as it is.
|
|
1865
|
+
const replaced = Array.from(userRecord.devices.entries())
|
|
1866
|
+
.filter(([deviceId, device]) => !devices.has(deviceId) && !isRemovedDevice(device))
|
|
1867
|
+
.map(([deviceId]) => deviceId);
|
|
1751
1868
|
// Add or update devices from server
|
|
1752
1869
|
for (const [deviceId, identityKey] of devices) {
|
|
1753
1870
|
const existingDevice = await this.getDeviceRecord(userId, deviceId);
|
|
1754
1871
|
if (!existingDevice) {
|
|
1755
1872
|
await this.addDeviceLocked(userId, deviceId, identityKey);
|
|
1873
|
+
continue;
|
|
1756
1874
|
}
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1875
|
+
// Only a device list that actually carries an identity key can tell us
|
|
1876
|
+
// the identity changed. A response that omits it carries no
|
|
1877
|
+
// information about identity, and must not be read as a change.
|
|
1878
|
+
// Reading it as a change would drop every live session and raise a
|
|
1879
|
+
// security event on each sync.
|
|
1880
|
+
const comparison = identityKey.length > 0
|
|
1881
|
+
? compareDeviceIdentityKeys(existingDevice.identityKey, identityKey)
|
|
1882
|
+
: undefined;
|
|
1883
|
+
if (comparison === 'changed') {
|
|
1884
|
+
// The replacement also clears a removed marker.
|
|
1885
|
+
replaced.push(deviceId);
|
|
1886
|
+
}
|
|
1887
|
+
else if (comparison === 'unpinned') {
|
|
1888
|
+
// Device was tracked before its identity was known - TOFU-pin it.
|
|
1889
|
+
// The same write clears a removed marker.
|
|
1890
|
+
const { removedAt: _removedAt, ...listed } = existingDevice;
|
|
1891
|
+
await this.storage.setDeviceRecord(userId, deviceId, {
|
|
1892
|
+
...listed,
|
|
1893
|
+
identityKey,
|
|
1894
|
+
session: null,
|
|
1895
|
+
...(isRemovedDevice(existingDevice) && { updatedAt: Date.now() }),
|
|
1896
|
+
});
|
|
1897
|
+
if (isRemovedDevice(existingDevice))
|
|
1898
|
+
this.events.onDeviceAdded?.(userId, deviceId);
|
|
1899
|
+
}
|
|
1900
|
+
else {
|
|
1901
|
+
await this.relistDeviceLocked(existingDevice);
|
|
1775
1902
|
}
|
|
1776
1903
|
}
|
|
1777
1904
|
return replaced;
|
|
@@ -1802,10 +1929,15 @@ export class DefaultSesameManager {
|
|
|
1802
1929
|
}
|
|
1803
1930
|
}
|
|
1804
1931
|
/**
|
|
1805
|
-
* Remove a device that the device list no longer lists, or replace
|
|
1806
|
-
* device whose listed identity key changed. Another write can
|
|
1807
|
-
* the device since the list was compared under the user lock,
|
|
1808
|
-
* decision is made again here.
|
|
1932
|
+
* Remove a device that the device list no longer lists, or replace the
|
|
1933
|
+
* identity of a device whose listed identity key changed. Another write can
|
|
1934
|
+
* have changed the device since the list was compared under the user lock,
|
|
1935
|
+
* so the decision is made again here.
|
|
1936
|
+
*
|
|
1937
|
+
* The identity change archives the current session, so a message under the
|
|
1938
|
+
* old session still decrypts. The record takes the new identity key and
|
|
1939
|
+
* pending verification, and it is not marked removed. A removed device is
|
|
1940
|
+
* relisted.
|
|
1809
1941
|
*
|
|
1810
1942
|
* @param identityKey - The listed identity key, or undefined when the list
|
|
1811
1943
|
* does not list the device
|
|
@@ -1822,19 +1954,20 @@ export class DefaultSesameManager {
|
|
|
1822
1954
|
if (compareDeviceIdentityKeys(existingDevice.identityKey, identityKey) !== 'changed') {
|
|
1823
1955
|
return false;
|
|
1824
1956
|
}
|
|
1825
|
-
// Identity key changed - security event
|
|
1826
|
-
//
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1957
|
+
// Identity key changed - security event. Pending verification blocks
|
|
1958
|
+
// messaging until the user verifies. The handoff invalidation goes with
|
|
1959
|
+
// the archive, as for every other archive.
|
|
1960
|
+
const { removedAt: _removedAt, ...listed } = existingDevice;
|
|
1961
|
+
await this.storage.setDeviceRecord(userId, deviceId, {
|
|
1962
|
+
...listed,
|
|
1963
|
+
identityKey,
|
|
1964
|
+
session: this.archiveCurrentIndexed(userId, deviceId, existingDevice.session),
|
|
1965
|
+
pendingVerification: true,
|
|
1966
|
+
updatedAt: Date.now(),
|
|
1967
|
+
}, { senderKeyHandoffInvalidation: { userId, deviceId } });
|
|
1968
|
+
// The replacement relists a removed device, as the other relist paths do.
|
|
1969
|
+
if (isRemovedDevice(existingDevice))
|
|
1970
|
+
this.events.onDeviceAdded?.(userId, deviceId);
|
|
1838
1971
|
return true;
|
|
1839
1972
|
}
|
|
1840
1973
|
/**
|
|
@@ -1863,7 +1996,8 @@ export class DefaultSesameManager {
|
|
|
1863
1996
|
: 0;
|
|
1864
1997
|
const hasNoSessions = !hasCurrentSession && archivedSessionCount === 0;
|
|
1865
1998
|
const isOld = now - deviceRecord.createdAt > this.config.maxLatency;
|
|
1866
|
-
if (hasNoSessions && isOld)
|
|
1999
|
+
if ((hasNoSessions && isOld) ||
|
|
2000
|
+
isExpiredRemovedDevice(deviceRecord, now, this.config.maxLatency)) {
|
|
1867
2001
|
staleRecords++;
|
|
1868
2002
|
}
|
|
1869
2003
|
// Count active session and check if expired
|