@open-e2ee/signal-protocol-sdk 7.1.0 → 8.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 +55 -6
- package/ARCHITECTURE.md +1 -0
- package/CHANGELOG.md +565 -0
- package/README.md +19 -5
- package/SECURITY.md +2 -2
- package/THIRD_PARTY_NOTICES.md +429 -0
- package/TROUBLESHOOTING.md +10 -0
- package/client/README.md +1 -2
- package/device/README.md +50 -19
- package/dist/client/client.d.ts +31 -5
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +149 -90
- package/dist/client/client.js.map +1 -1
- package/dist/client/event-hooks.d.ts.map +1 -1
- package/dist/client/event-hooks.js +2 -0
- package/dist/client/event-hooks.js.map +1 -1
- package/dist/client/files.d.ts.map +1 -1
- package/dist/client/files.js +19 -2
- package/dist/client/files.js.map +1 -1
- package/dist/client/headless.d.ts +1 -1
- package/dist/client/headless.js +1 -1
- package/dist/client/hosted-anonymous-delivery.d.ts.map +1 -1
- package/dist/client/hosted-anonymous-delivery.js +2 -1
- package/dist/client/hosted-anonymous-delivery.js.map +1 -1
- package/dist/client/hosted-connection.d.ts +1 -1
- package/dist/client/hosted-connection.d.ts.map +1 -1
- package/dist/client/hosted-connection.js +8 -12
- package/dist/client/hosted-connection.js.map +1 -1
- package/dist/client/hosted-group-authority.d.ts.map +1 -1
- package/dist/client/hosted-group-authority.js +2 -1
- package/dist/client/hosted-group-authority.js.map +1 -1
- package/dist/client/hosted-groups.d.ts.map +1 -1
- package/dist/client/hosted-groups.js +2 -1
- package/dist/client/hosted-groups.js.map +1 -1
- package/dist/client/hosted-push.d.ts.map +1 -1
- package/dist/client/hosted-push.js +2 -1
- package/dist/client/hosted-push.js.map +1 -1
- package/dist/client/hosted-transport.d.ts.map +1 -1
- package/dist/client/hosted-transport.js +10 -11
- package/dist/client/hosted-transport.js.map +1 -1
- package/dist/client/hosted-trust.d.ts +11 -11
- package/dist/client/hosted-trust.d.ts.map +1 -1
- package/dist/client/hosted-trust.js +12 -12
- package/dist/client/hosted-trust.js.map +1 -1
- package/dist/client/messages.d.ts.map +1 -1
- package/dist/client/messages.js +6 -1
- package/dist/client/messages.js.map +1 -1
- package/dist/client/multi-device.d.ts.map +1 -1
- package/dist/client/multi-device.js +2 -1
- package/dist/client/multi-device.js.map +1 -1
- package/dist/client/relay-lifecycle.d.ts +6 -2
- package/dist/client/relay-lifecycle.d.ts.map +1 -1
- package/dist/client/relay-lifecycle.js.map +1 -1
- package/dist/client/relay-work.d.ts +30 -0
- package/dist/client/relay-work.d.ts.map +1 -0
- package/dist/client/relay-work.js +189 -0
- package/dist/client/relay-work.js.map +1 -0
- package/dist/client/retry.d.ts.map +1 -1
- package/dist/client/retry.js +2 -0
- package/dist/client/retry.js.map +1 -1
- package/dist/client/sessions.d.ts.map +1 -1
- package/dist/client/sessions.js +3 -0
- package/dist/client/sessions.js.map +1 -1
- package/dist/client/signal-service-cipher.d.ts +39 -16
- package/dist/client/signal-service-cipher.d.ts.map +1 -1
- package/dist/client/signal-service-cipher.js +100 -60
- package/dist/client/signal-service-cipher.js.map +1 -1
- package/dist/client/state.d.ts +8 -0
- package/dist/client/state.d.ts.map +1 -1
- package/dist/client/state.js +11 -0
- package/dist/client/state.js.map +1 -1
- package/dist/client/types.d.ts +5 -1
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/types.js.map +1 -1
- package/dist/device/connection.d.ts +1 -1
- package/dist/device/connection.d.ts.map +1 -1
- package/dist/device/connection.js +4 -11
- package/dist/device/connection.js.map +1 -1
- package/dist/device/device-id.d.ts +10 -4
- package/dist/device/device-id.d.ts.map +1 -1
- package/dist/device/device-id.js +15 -9
- package/dist/device/device-id.js.map +1 -1
- package/dist/device/device-name-crypto.d.ts.map +1 -1
- package/dist/device/device-name-crypto.js +2 -2
- package/dist/device/device-name-crypto.js.map +1 -1
- package/dist/device/expo/index.d.ts +25 -8
- package/dist/device/expo/index.d.ts.map +1 -1
- package/dist/device/expo/index.js +58 -8
- package/dist/device/expo/index.js.map +1 -1
- package/dist/device/index.d.ts +2 -2
- package/dist/device/index.d.ts.map +1 -1
- package/dist/device/index.js +3 -2
- package/dist/device/index.js.map +1 -1
- package/dist/device/lifecycle/index.d.ts +4 -2
- package/dist/device/lifecycle/index.d.ts.map +1 -1
- package/dist/device/lifecycle/index.js.map +1 -1
- package/dist/device/lifecycle/manager.d.ts +12 -14
- package/dist/device/lifecycle/manager.d.ts.map +1 -1
- package/dist/device/lifecycle/manager.js +52 -97
- package/dist/device/lifecycle/manager.js.map +1 -1
- package/dist/device/lifecycle/types.d.ts +26 -16
- package/dist/device/lifecycle/types.d.ts.map +1 -1
- package/dist/device/lifecycle/utils.d.ts +8 -4
- package/dist/device/lifecycle/utils.d.ts.map +1 -1
- package/dist/device/lifecycle/utils.js +12 -16
- package/dist/device/lifecycle/utils.js.map +1 -1
- package/dist/device/provisioning.d.ts.map +1 -1
- package/dist/device/provisioning.js +6 -8
- package/dist/device/provisioning.js.map +1 -1
- package/dist/device/react-native/index.d.ts +40 -0
- package/dist/device/react-native/index.d.ts.map +1 -0
- package/dist/device/react-native/index.js +74 -0
- package/dist/device/react-native/index.js.map +1 -0
- package/dist/device/transfer.d.ts +15 -7
- package/dist/device/transfer.d.ts.map +1 -1
- package/dist/device/transfer.js +30 -22
- package/dist/device/transfer.js.map +1 -1
- package/dist/device/types.d.ts +15 -7
- package/dist/device/types.d.ts.map +1 -1
- package/dist/device/types.js.map +1 -1
- package/dist/device/vault-text.d.ts +13 -0
- package/dist/device/vault-text.d.ts.map +1 -0
- package/dist/device/vault-text.js +17 -0
- package/dist/device/vault-text.js.map +1 -0
- package/dist/hooks/use-key-rotation.d.ts.map +1 -1
- package/dist/hooks/use-key-rotation.js +2 -1
- package/dist/hooks/use-key-rotation.js.map +1 -1
- package/dist/index.d.ts +9 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/internal/crypto/index.d.ts +3 -3
- package/dist/internal/crypto/index.d.ts.map +1 -1
- package/dist/internal/crypto/index.js +3 -3
- package/dist/internal/crypto/index.js.map +1 -1
- package/dist/internal/crypto/random-host.d.ts +1 -1
- package/dist/internal/crypto/random-host.d.ts.map +1 -1
- package/dist/internal/crypto/random-host.js +3 -2
- package/dist/internal/crypto/random-host.js.map +1 -1
- package/dist/internal/crypto/random-host.native.d.ts +6 -1
- package/dist/internal/crypto/random-host.native.d.ts.map +1 -1
- package/dist/internal/crypto/random-host.native.js +14 -10
- package/dist/internal/crypto/random-host.native.js.map +1 -1
- package/dist/internal/crypto/random-host.node.d.ts +1 -1
- package/dist/internal/crypto/random-host.node.d.ts.map +1 -1
- package/dist/internal/crypto/random-host.node.js +1 -1
- package/dist/internal/crypto/random-host.node.js.map +1 -1
- package/dist/internal/crypto/random.d.ts +12 -3
- package/dist/internal/crypto/random.d.ts.map +1 -1
- package/dist/internal/crypto/random.js +14 -3
- package/dist/internal/crypto/random.js.map +1 -1
- package/dist/internal/crypto/utils.d.ts.map +1 -1
- package/dist/internal/crypto/utils.js +10 -6
- package/dist/internal/crypto/utils.js.map +1 -1
- package/dist/internal/encoding/proto/primitives.d.ts +2 -0
- package/dist/internal/encoding/proto/primitives.d.ts.map +1 -1
- package/dist/internal/encoding/proto/primitives.js +2 -1
- package/dist/internal/encoding/proto/primitives.js.map +1 -1
- package/dist/internal/encoding/proto/signal-message.d.ts +1 -0
- package/dist/internal/encoding/proto/signal-message.d.ts.map +1 -1
- package/dist/internal/encoding/proto/signal-message.js +2 -1
- package/dist/internal/encoding/proto/signal-message.js.map +1 -1
- package/dist/internal/groups/authority-certificate.d.ts.map +1 -1
- package/dist/internal/groups/authority-certificate.js +2 -1
- package/dist/internal/groups/authority-certificate.js.map +1 -1
- package/dist/internal/groups/encrypted-state.d.ts.map +1 -1
- package/dist/internal/groups/encrypted-state.js +9 -7
- package/dist/internal/groups/encrypted-state.js.map +1 -1
- package/dist/internal/groups/invite-link.d.ts.map +1 -1
- package/dist/internal/groups/invite-link.js +2 -1
- package/dist/internal/groups/invite-link.js.map +1 -1
- package/dist/internal/groups/manager.d.ts.map +1 -1
- package/dist/internal/groups/manager.js +5 -5
- package/dist/internal/groups/manager.js.map +1 -1
- package/dist/internal/groups/sdk-store.d.ts.map +1 -1
- package/dist/internal/groups/sdk-store.js +4 -3
- package/dist/internal/groups/sdk-store.js.map +1 -1
- package/dist/internal/groups/server-engine.d.ts +6 -1
- package/dist/internal/groups/server-engine.d.ts.map +1 -1
- package/dist/internal/groups/server-engine.js +11 -15
- package/dist/internal/groups/server-engine.js.map +1 -1
- package/dist/internal/groups/wire.d.ts.map +1 -1
- package/dist/internal/groups/wire.js +2 -1
- package/dist/internal/groups/wire.js.map +1 -1
- package/dist/internal/platform/blob.d.ts +10 -0
- package/dist/internal/platform/blob.d.ts.map +1 -0
- package/dist/internal/platform/blob.js +30 -0
- package/dist/internal/platform/blob.js.map +1 -0
- package/dist/internal/platform/env.d.ts +13 -0
- package/dist/internal/platform/env.d.ts.map +1 -0
- package/dist/internal/platform/env.js +17 -0
- package/dist/internal/platform/env.js.map +1 -0
- package/dist/internal/platform/index.d.ts +5 -0
- package/dist/internal/platform/index.d.ts.map +1 -0
- package/dist/internal/platform/index.js +5 -0
- package/dist/internal/platform/index.js.map +1 -0
- package/dist/internal/platform/url.d.ts +72 -0
- package/dist/internal/platform/url.d.ts.map +1 -0
- package/dist/internal/platform/url.js +275 -0
- package/dist/internal/platform/url.js.map +1 -0
- package/dist/internal/platform/utf8.d.ts +28 -0
- package/dist/internal/platform/utf8.d.ts.map +1 -0
- package/dist/internal/platform/utf8.js +167 -0
- package/dist/internal/platform/utf8.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/delivery-token.d.ts +1 -1
- package/dist/internal/protocol/sealed-sender/delivery-token.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/delivery-token.js +5 -10
- package/dist/internal/protocol/sealed-sender/delivery-token.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/proto/index.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/proto/index.js +2 -4
- package/dist/internal/protocol/sealed-sender/proto/index.js.map +1 -1
- package/dist/internal/protocol/sender-keys/manager.d.ts.map +1 -1
- package/dist/internal/protocol/sender-keys/manager.js +4 -3
- package/dist/internal/protocol/sender-keys/manager.js.map +1 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.d.ts +4 -4
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.js +8 -10
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.js.map +1 -1
- package/dist/internal/protocol/username/hash.d.ts.map +1 -1
- package/dist/internal/protocol/username/hash.js +18 -3
- package/dist/internal/protocol/username/hash.js.map +1 -1
- package/dist/internal/protocol/username/link.d.ts.map +1 -1
- package/dist/internal/protocol/username/link.js +2 -1
- package/dist/internal/protocol/username/link.js.map +1 -1
- package/dist/internal/protocol/username/proof.d.ts.map +1 -1
- package/dist/internal/protocol/username/proof.js +2 -1
- package/dist/internal/protocol/username/proof.js.map +1 -1
- package/dist/internal/sesame/device-registry.d.ts +22 -6
- package/dist/internal/sesame/device-registry.d.ts.map +1 -1
- package/dist/internal/sesame/device-registry.js +18 -12
- package/dist/internal/sesame/device-registry.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/manager.d.ts.map +1 -1
- package/dist/internal/sesame/manager.js +3 -2
- package/dist/internal/sesame/manager.js.map +1 -1
- package/dist/internal/session/index.d.ts +1 -2
- package/dist/internal/session/index.d.ts.map +1 -1
- package/dist/internal/session/index.js +1 -1
- package/dist/internal/session/index.js.map +1 -1
- package/dist/internal/session/validation.d.ts +0 -80
- package/dist/internal/session/validation.d.ts.map +1 -1
- package/dist/internal/session/validation.js +0 -134
- package/dist/internal/session/validation.js.map +1 -1
- package/dist/local/store/device-record.d.ts +18 -0
- package/dist/local/store/device-record.d.ts.map +1 -0
- package/dist/local/store/device-record.js +34 -0
- package/dist/local/store/device-record.js.map +1 -0
- package/dist/local/store/expo/adapter.d.ts +59 -238
- package/dist/local/store/expo/adapter.d.ts.map +1 -1
- package/dist/local/store/expo/adapter.js +83 -640
- package/dist/local/store/expo/adapter.js.map +1 -1
- package/dist/local/store/expo/driver.d.ts +16 -0
- package/dist/local/store/expo/driver.d.ts.map +1 -0
- package/dist/local/store/expo/driver.js +141 -0
- package/dist/local/store/expo/driver.js.map +1 -0
- package/dist/local/store/expo/index.d.ts +3 -12
- package/dist/local/store/expo/index.d.ts.map +1 -1
- package/dist/local/store/expo/index.js +1 -8
- package/dist/local/store/expo/index.js.map +1 -1
- package/dist/local/store/expo/maintenance.d.ts +3 -2
- package/dist/local/store/expo/maintenance.d.ts.map +1 -1
- package/dist/local/store/expo/maintenance.js +5 -34
- package/dist/local/store/expo/maintenance.js.map +1 -1
- package/dist/local/store/index.d.ts +10 -5
- package/dist/local/store/index.d.ts.map +1 -1
- package/dist/local/store/index.js +10 -5
- package/dist/local/store/index.js.map +1 -1
- package/dist/local/store/key-value/adapter.d.ts +326 -0
- package/dist/local/store/key-value/adapter.d.ts.map +1 -0
- package/dist/local/store/key-value/adapter.js +1472 -0
- package/dist/local/store/key-value/adapter.js.map +1 -0
- package/dist/local/store/{react-native → key-value}/backend-conformance.d.ts +7 -8
- package/dist/local/store/key-value/backend-conformance.d.ts.map +1 -0
- package/dist/local/store/{react-native → key-value}/backend-conformance.js +4 -5
- package/dist/local/store/key-value/backend-conformance.js.map +1 -0
- package/dist/local/store/key-value/batch.d.ts +41 -0
- package/dist/local/store/key-value/batch.d.ts.map +1 -0
- package/dist/local/store/key-value/batch.js +77 -0
- package/dist/local/store/key-value/batch.js.map +1 -0
- package/dist/local/store/key-value/device-record.d.ts +23 -0
- package/dist/local/store/key-value/device-record.d.ts.map +1 -0
- package/dist/local/store/key-value/device-record.js +33 -0
- package/dist/local/store/key-value/device-record.js.map +1 -0
- package/dist/local/store/key-value/index.d.ts +24 -0
- package/dist/local/store/key-value/index.d.ts.map +1 -0
- package/dist/local/store/key-value/index.js +8 -0
- package/dist/local/store/key-value/index.js.map +1 -0
- package/dist/local/store/key-value/realm/index.d.ts +83 -0
- package/dist/local/store/key-value/realm/index.d.ts.map +1 -0
- package/dist/local/store/key-value/realm/index.js +102 -0
- package/dist/local/store/key-value/realm/index.js.map +1 -0
- package/dist/local/store/{react-native → key-value}/storage.d.ts +6 -6
- package/dist/local/store/key-value/storage.d.ts.map +1 -0
- package/dist/local/store/key-value/storage.js.map +1 -0
- package/dist/local/store/key-value/transactional-backend.d.ts +50 -0
- package/dist/local/store/key-value/transactional-backend.d.ts.map +1 -0
- package/dist/local/store/key-value/transactional-backend.js +90 -0
- package/dist/local/store/key-value/transactional-backend.js.map +1 -0
- package/dist/local/store/key-value/value-key.d.ts +34 -0
- package/dist/local/store/key-value/value-key.d.ts.map +1 -0
- package/dist/local/store/key-value/value-key.js +83 -0
- package/dist/local/store/key-value/value-key.js.map +1 -0
- package/dist/local/store/memory/adapter.d.ts +8 -0
- package/dist/local/store/memory/adapter.d.ts.map +1 -1
- package/dist/local/store/memory/adapter.js +60 -75
- package/dist/local/store/memory/adapter.js.map +1 -1
- package/dist/local/store/node/adapter.d.ts +74 -130
- package/dist/local/store/node/adapter.d.ts.map +1 -1
- package/dist/local/store/node/adapter.js +83 -727
- package/dist/local/store/node/adapter.js.map +1 -1
- package/dist/local/store/node/index.d.ts +8 -6
- package/dist/local/store/node/index.d.ts.map +1 -1
- package/dist/local/store/node/index.js +3 -7
- package/dist/local/store/node/index.js.map +1 -1
- package/dist/local/store/node/maintenance.d.ts +5 -0
- package/dist/local/store/node/maintenance.d.ts.map +1 -0
- package/dist/local/store/node/maintenance.js +7 -0
- package/dist/local/store/node/maintenance.js.map +1 -0
- package/dist/local/store/node/owner-lock.d.ts +26 -0
- package/dist/local/store/node/owner-lock.d.ts.map +1 -0
- package/dist/local/store/node/owner-lock.js +88 -0
- package/dist/local/store/node/owner-lock.js.map +1 -0
- package/dist/local/store/react-native/adapter.d.ts +63 -273
- package/dist/local/store/react-native/adapter.d.ts.map +1 -1
- package/dist/local/store/react-native/adapter.js +80 -1405
- package/dist/local/store/react-native/adapter.js.map +1 -1
- package/dist/local/store/react-native/index.d.ts +7 -19
- package/dist/local/store/react-native/index.d.ts.map +1 -1
- package/dist/local/store/react-native/index.js +2 -7
- package/dist/local/store/react-native/index.js.map +1 -1
- package/dist/local/store/react-native/maintenance.d.ts +5 -0
- package/dist/local/store/react-native/maintenance.d.ts.map +1 -0
- package/dist/local/store/react-native/maintenance.js +7 -0
- package/dist/local/store/react-native/maintenance.js.map +1 -0
- package/dist/local/store/sqlite/better-sqlite3-multiple-ciphers-driver.d.ts +38 -0
- package/dist/local/store/sqlite/better-sqlite3-multiple-ciphers-driver.d.ts.map +1 -0
- package/dist/local/store/sqlite/better-sqlite3-multiple-ciphers-driver.js +196 -0
- package/dist/local/store/sqlite/better-sqlite3-multiple-ciphers-driver.js.map +1 -0
- package/dist/local/store/sqlite/database.d.ts +20 -0
- package/dist/local/store/sqlite/database.d.ts.map +1 -0
- package/dist/local/store/sqlite/database.js +41 -0
- package/dist/local/store/sqlite/database.js.map +1 -0
- package/dist/local/store/sqlite/driver.d.ts +138 -0
- package/dist/local/store/sqlite/driver.d.ts.map +1 -0
- package/dist/local/store/sqlite/driver.js +10 -0
- package/dist/local/store/sqlite/driver.js.map +1 -0
- package/dist/local/store/sqlite/encryption.d.ts +61 -0
- package/dist/local/store/sqlite/encryption.d.ts.map +1 -0
- package/dist/local/store/sqlite/encryption.js +98 -0
- package/dist/local/store/sqlite/encryption.js.map +1 -0
- package/dist/local/store/sqlite/errors.d.ts +70 -0
- package/dist/local/store/sqlite/errors.d.ts.map +1 -0
- package/dist/local/store/sqlite/errors.js +101 -0
- package/dist/local/store/sqlite/errors.js.map +1 -0
- package/dist/local/store/sqlite/executor.d.ts +22 -0
- package/dist/local/store/sqlite/executor.d.ts.map +1 -0
- package/dist/local/store/sqlite/executor.js +129 -0
- package/dist/local/store/sqlite/executor.js.map +1 -0
- package/dist/local/store/sqlite/index.d.ts +20 -0
- package/dist/local/store/sqlite/index.d.ts.map +1 -0
- package/dist/local/store/sqlite/index.js +18 -0
- package/dist/local/store/sqlite/index.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/account.d.ts +45 -0
- package/dist/local/store/sqlite/key-storage/account.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/account.js +125 -0
- package/dist/local/store/sqlite/key-storage/account.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/contact-identities.d.ts +19 -0
- package/dist/local/store/sqlite/key-storage/contact-identities.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/contact-identities.js +85 -0
- package/dist/local/store/sqlite/key-storage/contact-identities.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/context.d.ts +19 -0
- package/dist/local/store/sqlite/key-storage/context.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/context.js +18 -0
- package/dist/local/store/sqlite/key-storage/context.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/identity-keys.d.ts +18 -0
- package/dist/local/store/sqlite/key-storage/identity-keys.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/identity-keys.js +88 -0
- package/dist/local/store/sqlite/key-storage/identity-keys.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/index.d.ts +108 -0
- package/dist/local/store/sqlite/key-storage/index.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/index.js +241 -0
- package/dist/local/store/sqlite/key-storage/index.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/message-records.d.ts +41 -0
- package/dist/local/store/sqlite/key-storage/message-records.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/message-records.js +133 -0
- package/dist/local/store/sqlite/key-storage/message-records.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/metadata.d.ts +16 -0
- package/dist/local/store/sqlite/key-storage/metadata.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/metadata.js +53 -0
- package/dist/local/store/sqlite/key-storage/metadata.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/one-time-prekeys.d.ts +36 -0
- package/dist/local/store/sqlite/key-storage/one-time-prekeys.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/one-time-prekeys.js +129 -0
- package/dist/local/store/sqlite/key-storage/one-time-prekeys.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/session-trust.d.ts +10 -0
- package/dist/local/store/sqlite/key-storage/session-trust.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/session-trust.js +88 -0
- package/dist/local/store/sqlite/key-storage/session-trust.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/sessions.d.ts +50 -0
- package/dist/local/store/sqlite/key-storage/sessions.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/sessions.js +209 -0
- package/dist/local/store/sqlite/key-storage/sessions.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/signed-prekeys.d.ts +69 -0
- package/dist/local/store/sqlite/key-storage/signed-prekeys.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/signed-prekeys.js +219 -0
- package/dist/local/store/sqlite/key-storage/signed-prekeys.js.map +1 -0
- package/dist/local/store/sqlite/maintenance.d.ts +7 -0
- package/dist/local/store/sqlite/maintenance.d.ts.map +1 -0
- package/dist/local/store/sqlite/maintenance.js +32 -0
- package/dist/local/store/sqlite/maintenance.js.map +1 -0
- package/dist/local/store/sqlite/migrations.d.ts +31 -0
- package/dist/local/store/sqlite/migrations.d.ts.map +1 -0
- package/dist/local/store/sqlite/migrations.js +232 -0
- package/dist/local/store/sqlite/migrations.js.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/ec-one-time-prekey.d.ts +17 -22
- package/dist/local/store/sqlite/models/ec-one-time-prekey.d.ts.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/ec-one-time-prekey.js +61 -99
- package/dist/local/store/sqlite/models/ec-one-time-prekey.js.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/ec-signed-prekey.d.ts +22 -25
- package/dist/local/store/sqlite/models/ec-signed-prekey.d.ts.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/ec-signed-prekey.js +82 -128
- package/dist/local/store/sqlite/models/ec-signed-prekey.js.map +1 -0
- package/dist/local/store/sqlite/models/identity-key-id.d.ts.map +1 -0
- package/dist/local/store/sqlite/models/identity-key-id.js.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/index.d.ts +5 -5
- package/dist/local/store/sqlite/models/index.d.ts.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/index.js +12 -5
- package/dist/local/store/sqlite/models/index.js.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/kyber-one-time-prekey.d.ts +17 -20
- package/dist/local/store/sqlite/models/kyber-one-time-prekey.d.ts.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/kyber-one-time-prekey.js +65 -105
- package/dist/local/store/sqlite/models/kyber-one-time-prekey.js.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/kyber-prekey-used.d.ts +3 -3
- package/dist/local/store/sqlite/models/kyber-prekey-used.d.ts.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/kyber-prekey-used.js +13 -25
- package/dist/local/store/sqlite/models/kyber-prekey-used.js.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/kyber-prekey.d.ts +16 -19
- package/dist/local/store/sqlite/models/kyber-prekey.d.ts.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/kyber-prekey.js +67 -111
- package/dist/local/store/sqlite/models/kyber-prekey.js.map +1 -0
- package/dist/local/store/sqlite/models/local-identity.d.ts +51 -0
- package/dist/local/store/sqlite/models/local-identity.d.ts.map +1 -0
- package/dist/local/store/sqlite/models/local-identity.js +150 -0
- package/dist/local/store/sqlite/models/local-identity.js.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/message-record.d.ts +15 -44
- package/dist/local/store/sqlite/models/message-record.d.ts.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/message-record.js +43 -109
- package/dist/local/store/sqlite/models/message-record.js.map +1 -0
- package/dist/local/store/sqlite/models/recipient-identity.d.ts +21 -0
- package/dist/local/store/sqlite/models/recipient-identity.d.ts.map +1 -0
- package/dist/local/store/sqlite/models/recipient-identity.js +59 -0
- package/dist/local/store/sqlite/models/recipient-identity.js.map +1 -0
- package/dist/local/store/sqlite/models/replaced-prekeys.d.ts +23 -0
- package/dist/local/store/sqlite/models/replaced-prekeys.d.ts.map +1 -0
- package/dist/local/store/sqlite/models/replaced-prekeys.js +42 -0
- package/dist/local/store/sqlite/models/replaced-prekeys.js.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/sender-key.d.ts +22 -23
- package/dist/local/store/sqlite/models/sender-key.d.ts.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/sender-key.js +66 -94
- package/dist/local/store/sqlite/models/sender-key.js.map +1 -0
- package/dist/local/store/sqlite/models/sesame-user-record.d.ts +32 -0
- package/dist/local/store/sqlite/models/sesame-user-record.d.ts.map +1 -0
- package/dist/local/store/sqlite/models/sesame-user-record.js +78 -0
- package/dist/local/store/sqlite/models/sesame-user-record.js.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/session.d.ts +24 -20
- package/dist/local/store/sqlite/models/session.d.ts.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/session.js +54 -72
- package/dist/local/store/sqlite/models/session.js.map +1 -0
- package/dist/local/store/sqlite/models/skipped-sender-key.d.ts +24 -0
- package/dist/local/store/sqlite/models/skipped-sender-key.d.ts.map +1 -0
- package/dist/local/store/sqlite/models/skipped-sender-key.js +62 -0
- package/dist/local/store/sqlite/models/skipped-sender-key.js.map +1 -0
- package/dist/local/store/sqlite/op-sqlite-driver.d.ts +14 -0
- package/dist/local/store/sqlite/op-sqlite-driver.d.ts.map +1 -0
- package/dist/local/store/sqlite/op-sqlite-driver.js +180 -0
- package/dist/local/store/sqlite/op-sqlite-driver.js.map +1 -0
- package/dist/local/store/sqlite/open-store.d.ts +83 -0
- package/dist/local/store/sqlite/open-store.d.ts.map +1 -0
- package/dist/local/store/sqlite/open-store.js +177 -0
- package/dist/local/store/sqlite/open-store.js.map +1 -0
- package/dist/local/store/sqlite/schema.d.ts +102 -0
- package/dist/local/store/sqlite/schema.d.ts.map +1 -0
- package/dist/local/store/sqlite/schema.js +61 -0
- package/dist/local/store/sqlite/schema.js.map +1 -0
- package/dist/local/store/sqlite/store.d.ts +199 -0
- package/dist/local/store/sqlite/store.d.ts.map +1 -0
- package/dist/local/store/sqlite/store.js +494 -0
- package/dist/local/store/sqlite/store.js.map +1 -0
- package/dist/local/store/sqlite/web/driver.d.ts +50 -0
- package/dist/local/store/sqlite/web/driver.d.ts.map +1 -0
- package/dist/local/store/sqlite/web/driver.js +169 -0
- package/dist/local/store/sqlite/web/driver.js.map +1 -0
- package/dist/local/store/sqlite/web/protocol.d.ts +80 -0
- package/dist/local/store/sqlite/web/protocol.d.ts.map +1 -0
- package/dist/local/store/sqlite/web/protocol.js +13 -0
- package/dist/local/store/sqlite/web/protocol.js.map +1 -0
- package/dist/local/store/sqlite/web/sqlite3mc/sqlite3.mjs +14526 -0
- package/dist/local/store/sqlite/web/sqlite3mc/sqlite3.wasm +0 -0
- package/dist/local/store/sqlite/web/worker.d.ts +36 -0
- package/dist/local/store/sqlite/web/worker.d.ts.map +1 -0
- package/dist/local/store/sqlite/web/worker.js +616 -0
- package/dist/local/store/sqlite/web/worker.js.map +1 -0
- package/dist/local/store/web/adapter.d.ts +5 -14
- package/dist/local/store/web/adapter.d.ts.map +1 -1
- package/dist/local/store/web/adapter.js +119 -106
- package/dist/local/store/web/adapter.js.map +1 -1
- package/dist/local/store/web/device-record.d.ts +23 -0
- package/dist/local/store/web/device-record.d.ts.map +1 -0
- package/dist/local/store/web/device-record.js +31 -0
- package/dist/local/store/web/device-record.js.map +1 -0
- package/dist/local/store/web-sqlite/adapter.d.ts +98 -0
- package/dist/local/store/web-sqlite/adapter.d.ts.map +1 -0
- package/dist/local/store/web-sqlite/adapter.js +151 -0
- package/dist/local/store/web-sqlite/adapter.js.map +1 -0
- package/dist/local/store/web-sqlite/index.d.ts +14 -0
- package/dist/local/store/web-sqlite/index.d.ts.map +1 -0
- package/dist/local/store/web-sqlite/index.js +3 -0
- package/dist/local/store/web-sqlite/index.js.map +1 -0
- package/dist/local/store/web-sqlite/maintenance.d.ts +5 -0
- package/dist/local/store/web-sqlite/maintenance.d.ts.map +1 -0
- package/dist/local/store/web-sqlite/maintenance.js +7 -0
- package/dist/local/store/web-sqlite/maintenance.js.map +1 -0
- package/dist/local/store/web-sqlite/store-locks.d.ts +33 -0
- package/dist/local/store/web-sqlite/store-locks.d.ts.map +1 -0
- package/dist/local/store/web-sqlite/store-locks.js +60 -0
- package/dist/local/store/web-sqlite/store-locks.js.map +1 -0
- package/dist/local/vault/electron-safe-storage.d.ts +45 -0
- package/dist/local/vault/electron-safe-storage.d.ts.map +1 -0
- package/dist/local/vault/electron-safe-storage.js +212 -0
- package/dist/local/vault/electron-safe-storage.js.map +1 -0
- package/dist/local/vault/index.d.ts +4 -2
- package/dist/local/vault/index.d.ts.map +1 -1
- package/dist/local/vault/indexed-db.d.ts +37 -0
- package/dist/local/vault/indexed-db.d.ts.map +1 -0
- package/dist/local/vault/indexed-db.js +102 -0
- package/dist/local/vault/indexed-db.js.map +1 -0
- package/dist/local/vault/react-native-keychain.d.ts +12 -0
- package/dist/local/vault/react-native-keychain.d.ts.map +1 -0
- package/dist/local/vault/react-native-keychain.js +71 -0
- package/dist/local/vault/react-native-keychain.js.map +1 -0
- package/dist/local/vault/require.d.ts +10 -0
- package/dist/local/vault/require.d.ts.map +1 -0
- package/dist/local/vault/require.js +16 -0
- package/dist/local/vault/require.js.map +1 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +2 -1
- package/dist/logger.js.map +1 -1
- package/dist/media/index.d.ts.map +1 -1
- package/dist/media/index.js +2 -1
- package/dist/media/index.js.map +1 -1
- package/dist/profile/contact-state.d.ts.map +1 -1
- package/dist/profile/contact-state.js +2 -4
- package/dist/profile/contact-state.js.map +1 -1
- package/dist/profile/index.d.ts +0 -1
- package/dist/profile/index.d.ts.map +1 -1
- package/dist/profile/index.js +0 -2
- package/dist/profile/index.js.map +1 -1
- package/dist/profile/profile-key.d.ts +16 -11
- package/dist/profile/profile-key.d.ts.map +1 -1
- package/dist/profile/profile-key.js +29 -29
- package/dist/profile/profile-key.js.map +1 -1
- package/dist/profile/update-service.d.ts +6 -0
- package/dist/profile/update-service.d.ts.map +1 -1
- package/dist/profile/update-service.js +3 -1
- package/dist/profile/update-service.js.map +1 -1
- package/dist/remote/object-store/validation.d.ts.map +1 -1
- package/dist/remote/object-store/validation.js +2 -1
- package/dist/remote/object-store/validation.js.map +1 -1
- package/dist/remote/relay/memory/adapter.d.ts +2 -3
- package/dist/remote/relay/memory/adapter.d.ts.map +1 -1
- package/dist/remote/relay/memory/adapter.js +22 -30
- package/dist/remote/relay/memory/adapter.js.map +1 -1
- package/dist/remote/relay/memory/failures.d.ts.map +1 -1
- package/dist/remote/relay/memory/failures.js +2 -1
- package/dist/remote/relay/memory/failures.js.map +1 -1
- package/dist/remote/relay/memory/group-server.d.ts +5 -1
- package/dist/remote/relay/memory/group-server.d.ts.map +1 -1
- package/dist/remote/relay/memory/group-server.js +11 -1
- package/dist/remote/relay/memory/group-server.js.map +1 -1
- package/dist/safety/url.d.ts.map +1 -1
- package/dist/safety/url.js +21 -26
- package/dist/safety/url.js.map +1 -1
- package/dist/types/api.d.ts +15 -2
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/errors.d.ts +97 -1
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +105 -1
- package/dist/types/errors.js.map +1 -1
- package/dist/types/session.d.ts.map +1 -1
- package/dist/types/session.js +2 -1
- package/dist/types/session.js.map +1 -1
- package/dist/utils/retry.d.ts +2 -0
- package/dist/utils/retry.d.ts.map +1 -1
- package/dist/utils/retry.js +4 -2
- package/dist/utils/retry.js.map +1 -1
- package/docs/ASSURANCE.md +81 -8
- package/docs/CLIENT_COMPOSITION.md +1 -2
- package/docs/DEVIATIONS.md +27 -3
- package/docs/ERROR_HANDLING.md +6 -0
- package/docs/GETTING_STARTED.md +1 -2
- package/docs/PACKAGE_SURFACE.md +29 -11
- package/docs/RECIPES.md +1 -2
- package/examples/browser/index.html +1 -1
- package/local/store/README.md +117 -34
- package/local/store/expo/README.md +67 -47
- package/local/store/key-value/README.md +278 -0
- package/local/store/node/README.md +206 -45
- package/local/store/react-native/README.md +121 -52
- package/local/store/web/README.md +9 -0
- package/local/store/web-sqlite/README.md +202 -0
- package/local/vault/README.md +115 -2
- package/package.json +61 -42
- package/profile/README.md +9 -11
- package/remote/README.md +1 -2
- package/dist/local/store/expo/database-key.d.ts +0 -142
- package/dist/local/store/expo/database-key.d.ts.map +0 -1
- package/dist/local/store/expo/database-key.js +0 -312
- package/dist/local/store/expo/database-key.js.map +0 -1
- package/dist/local/store/expo/db.d.ts +0 -95
- package/dist/local/store/expo/db.d.ts.map +0 -1
- package/dist/local/store/expo/db.js +0 -147
- package/dist/local/store/expo/db.js.map +0 -1
- package/dist/local/store/expo/key-storage.d.ts +0 -429
- package/dist/local/store/expo/key-storage.d.ts.map +0 -1
- package/dist/local/store/expo/key-storage.js +0 -1361
- package/dist/local/store/expo/key-storage.js.map +0 -1
- package/dist/local/store/expo/models/ec-one-time-prekey.d.ts.map +0 -1
- package/dist/local/store/expo/models/ec-one-time-prekey.js.map +0 -1
- package/dist/local/store/expo/models/ec-signed-prekey.d.ts.map +0 -1
- package/dist/local/store/expo/models/ec-signed-prekey.js.map +0 -1
- package/dist/local/store/expo/models/identity-key-id.d.ts.map +0 -1
- package/dist/local/store/expo/models/identity-key-id.js.map +0 -1
- package/dist/local/store/expo/models/index.d.ts.map +0 -1
- package/dist/local/store/expo/models/index.js.map +0 -1
- package/dist/local/store/expo/models/kyber-one-time-prekey.d.ts.map +0 -1
- package/dist/local/store/expo/models/kyber-one-time-prekey.js.map +0 -1
- package/dist/local/store/expo/models/kyber-prekey-used.d.ts.map +0 -1
- package/dist/local/store/expo/models/kyber-prekey-used.js.map +0 -1
- package/dist/local/store/expo/models/kyber-prekey.d.ts.map +0 -1
- package/dist/local/store/expo/models/kyber-prekey.js.map +0 -1
- package/dist/local/store/expo/models/local-identity.d.ts +0 -52
- package/dist/local/store/expo/models/local-identity.d.ts.map +0 -1
- package/dist/local/store/expo/models/local-identity.js +0 -166
- package/dist/local/store/expo/models/local-identity.js.map +0 -1
- package/dist/local/store/expo/models/message-record.d.ts.map +0 -1
- package/dist/local/store/expo/models/message-record.js.map +0 -1
- package/dist/local/store/expo/models/recipient-identity.d.ts +0 -21
- package/dist/local/store/expo/models/recipient-identity.d.ts.map +0 -1
- package/dist/local/store/expo/models/recipient-identity.js +0 -66
- package/dist/local/store/expo/models/recipient-identity.js.map +0 -1
- package/dist/local/store/expo/models/replaced-prekey-utils.d.ts +0 -33
- package/dist/local/store/expo/models/replaced-prekey-utils.d.ts.map +0 -1
- package/dist/local/store/expo/models/replaced-prekey-utils.js +0 -54
- package/dist/local/store/expo/models/replaced-prekey-utils.js.map +0 -1
- package/dist/local/store/expo/models/sender-key.d.ts.map +0 -1
- package/dist/local/store/expo/models/sender-key.js.map +0 -1
- package/dist/local/store/expo/models/session.d.ts.map +0 -1
- package/dist/local/store/expo/models/session.js.map +0 -1
- package/dist/local/store/expo/schema.d.ts +0 -1917
- package/dist/local/store/expo/schema.d.ts.map +0 -1
- package/dist/local/store/expo/schema.js +0 -197
- package/dist/local/store/expo/schema.js.map +0 -1
- package/dist/local/store/node/database-encryption.d.ts +0 -109
- package/dist/local/store/node/database-encryption.d.ts.map +0 -1
- package/dist/local/store/node/database-encryption.js +0 -202
- package/dist/local/store/node/database-encryption.js.map +0 -1
- package/dist/local/store/node/database-file-commit.d.ts +0 -8
- package/dist/local/store/node/database-file-commit.d.ts.map +0 -1
- package/dist/local/store/node/database-file-commit.js +0 -62
- package/dist/local/store/node/database-file-commit.js.map +0 -1
- package/dist/local/store/node/database-key.d.ts +0 -129
- package/dist/local/store/node/database-key.d.ts.map +0 -1
- package/dist/local/store/node/database-key.js +0 -293
- package/dist/local/store/node/database-key.js.map +0 -1
- package/dist/local/store/node/database-lock.d.ts +0 -8
- package/dist/local/store/node/database-lock.d.ts.map +0 -1
- package/dist/local/store/node/database-lock.js +0 -44
- package/dist/local/store/node/database-lock.js.map +0 -1
- package/dist/local/store/node/database.d.ts +0 -226
- package/dist/local/store/node/database.d.ts.map +0 -1
- package/dist/local/store/node/database.js +0 -813
- package/dist/local/store/node/database.js.map +0 -1
- package/dist/local/store/react-native/backend-conformance.d.ts.map +0 -1
- package/dist/local/store/react-native/backend-conformance.js.map +0 -1
- package/dist/local/store/react-native/reference-backend.d.ts +0 -43
- package/dist/local/store/react-native/reference-backend.d.ts.map +0 -1
- package/dist/local/store/react-native/reference-backend.js +0 -178
- package/dist/local/store/react-native/reference-backend.js.map +0 -1
- package/dist/local/store/react-native/storage.d.ts.map +0 -1
- package/dist/local/store/react-native/storage.js.map +0 -1
- package/dist/profile/storage.d.ts +0 -61
- package/dist/profile/storage.d.ts.map +0 -1
- package/dist/profile/storage.js +0 -145
- package/dist/profile/storage.js.map +0 -1
- /package/dist/local/store/{react-native → key-value}/storage.js +0 -0
- /package/dist/local/store/{expo → sqlite}/models/identity-key-id.d.ts +0 -0
- /package/dist/local/store/{expo → sqlite}/models/identity-key-id.js +0 -0
|
@@ -24,6 +24,12 @@ import type { PreparedAttachmentUpload, SendOptions, SendResult } from './types.
|
|
|
24
24
|
import { type BlockedRecipientsSyncInput, type ConfigurationSyncInput, type MediaAttachmentDeleteSyncInput, type ReadSyncEntryInput, type RecipientUsernameSyncInput, type SignalProtocolContentAdapter, type TaskNotificationAckSyncInput, type UsernameStateSyncInput, type VerificationStateSyncInput, type ViewOnceOpenSyncInput } from './content-adapter.js';
|
|
25
25
|
import { type SealedSenderProvider as SealedSenderProviderContract } from './sealed-sender.js';
|
|
26
26
|
import { type ContactProfileStateStore } from '../profile/contact-state.js';
|
|
27
|
+
/**
|
|
28
|
+
* How long a recipient's relay device list stays current before a send reads
|
|
29
|
+
* it again. A device linked or removed inside this window is found by the
|
|
30
|
+
* first send after it ends.
|
|
31
|
+
*/
|
|
32
|
+
export declare const RECIPIENT_DEVICE_LIST_FRESH_MILLISECONDS = 60000;
|
|
27
33
|
export declare function sortEnvelopesForDecryption<T extends {
|
|
28
34
|
messageType?: string;
|
|
29
35
|
}>(envelopes: T[]): T[];
|
|
@@ -38,10 +44,12 @@ export declare function sortEnvelopesForDecryption<T extends {
|
|
|
38
44
|
*/
|
|
39
45
|
export type SealedSenderProvider = SealedSenderProviderContract;
|
|
40
46
|
/**
|
|
41
|
-
* Callback for
|
|
47
|
+
* Callback for reconciling a recipient's sessions with the relay's device list
|
|
42
48
|
* Allows SignalProtocolClient to inject its session establishment logic
|
|
43
49
|
*/
|
|
44
50
|
export type SessionEstablisher = (recipientUserId: string) => Promise<{
|
|
51
|
+
/** Device IDs the relay lists as receiving for the recipient */
|
|
52
|
+
activeDevices: number[];
|
|
45
53
|
establishedDevices: number[];
|
|
46
54
|
failedDevices: number[];
|
|
47
55
|
failedDeviceErrors: Array<{
|
|
@@ -62,6 +70,14 @@ export type SessionEstablisher = (recipientUserId: string) => Promise<{
|
|
|
62
70
|
* @returns True if session was successfully refreshed
|
|
63
71
|
*/
|
|
64
72
|
export type StaleSessionRefresher = (recipientUserId: string, recipientDeviceId: number) => Promise<boolean>;
|
|
73
|
+
/**
|
|
74
|
+
* The session callbacks of a send. The client binds them to the hooks of the
|
|
75
|
+
* work that sends, so a resend in relay work calls the app through that work.
|
|
76
|
+
*/
|
|
77
|
+
export interface SendSessionCallbacks {
|
|
78
|
+
establishSessions: SessionEstablisher;
|
|
79
|
+
refreshStaleSession: StaleSessionRefresher;
|
|
80
|
+
}
|
|
65
81
|
/**
|
|
66
82
|
* Callback for refreshing group send endorsements before V2 sealed sender send.
|
|
67
83
|
*
|
|
@@ -106,8 +122,8 @@ export declare class SignalProtocolServiceCipher {
|
|
|
106
122
|
private readonly contentAdapter?;
|
|
107
123
|
private readonly logger;
|
|
108
124
|
private readonly lock;
|
|
109
|
-
private
|
|
110
|
-
private
|
|
125
|
+
private sessionCallbacks?;
|
|
126
|
+
private readonly recipientDeviceListCheckedAt;
|
|
111
127
|
private sealedSenderProvider?;
|
|
112
128
|
private sealedSenderDeliveryMode;
|
|
113
129
|
private sealedSenderIdentifiedFallback?;
|
|
@@ -135,17 +151,13 @@ export declare class SignalProtocolServiceCipher {
|
|
|
135
151
|
sendTaskNotificationAckSyncToLocalOtherDevices(ack: TaskNotificationAckSyncInput): Promise<void>;
|
|
136
152
|
sendBlockedRecipientsSyncToLocalOtherDevices(blocked: BlockedRecipientsSyncInput): Promise<void>;
|
|
137
153
|
/**
|
|
138
|
-
* Set the session
|
|
154
|
+
* Set the session callbacks of a send that passes none
|
|
139
155
|
* Called by SignalProtocolClient after construction to inject session establishment logic
|
|
140
|
-
*/
|
|
141
|
-
setSessionEstablisher(establisher: SessionEstablisher): void;
|
|
142
|
-
/**
|
|
143
|
-
* Set the stale session refresher callback
|
|
144
|
-
* Called by SignalProtocolClient after construction to inject session refresh logic
|
|
145
156
|
*
|
|
146
|
-
*
|
|
157
|
+
* The stale-session refresher runs when the server returns STALE_DEVICE
|
|
158
|
+
* errors (device reinstalled).
|
|
147
159
|
*/
|
|
148
|
-
|
|
160
|
+
setSessionCallbacks(callbacks: SendSessionCallbacks): void;
|
|
149
161
|
/**
|
|
150
162
|
* Set the sealed sender provider callback
|
|
151
163
|
* Called by SignalProtocolClient after construction to inject sealed sender support.
|
|
@@ -214,11 +226,16 @@ export declare class SignalProtocolServiceCipher {
|
|
|
214
226
|
* @param recipientId - User ID or group ID (groups use the package group ID prefix)
|
|
215
227
|
* @param content - Uint8Array bytes to encrypt and send
|
|
216
228
|
* @param options - Optional send options (mimeType for binary content, etc.)
|
|
229
|
+
* @param sessions - Session callbacks of this send. Default: the callbacks
|
|
230
|
+
* that setSessionCallbacks set
|
|
231
|
+
* @param stopSignal - The stop signal of the relay work that sends. When it
|
|
232
|
+
* aborts while the send waits for the recipient's lock, the send throws
|
|
233
|
+
* RelayWorkStopped. Default: none, and the send waits
|
|
217
234
|
* @returns SendResult with messageId, timestamp, and device count
|
|
218
235
|
*
|
|
219
236
|
* @see https://signal.org/docs/specifications/sesame/
|
|
220
237
|
*/
|
|
221
|
-
encrypt(recipientId: string, content: Uint8Array, options?: SendOptions): Promise<SendResult>;
|
|
238
|
+
encrypt(recipientId: string, content: Uint8Array, options?: SendOptions, sessions?: SendSessionCallbacks | undefined, stopSignal?: AbortSignal): Promise<SendResult>;
|
|
222
239
|
/**
|
|
223
240
|
* Encrypt and upload attachment data without sending a standalone message.
|
|
224
241
|
*/
|
|
@@ -249,10 +266,16 @@ export declare class SignalProtocolServiceCipher {
|
|
|
249
266
|
*/
|
|
250
267
|
private decryptGroup;
|
|
251
268
|
/**
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
269
|
+
* Reconcile a recipient's sessions with the relay's device list
|
|
270
|
+
*
|
|
271
|
+
* A send must reach every device the relay lists for the recipient, and no
|
|
272
|
+
* device the relay no longer lists. The session establisher reads that list
|
|
273
|
+
* again when the last read is older than
|
|
274
|
+
* RECIPIENT_DEVICE_LIST_FRESH_MILLISECONDS, creates a session for each listed
|
|
275
|
+
* device that has none, and this method removes each local device that is not
|
|
276
|
+
* listed. Inside the window, a recipient with an active session is sent to
|
|
277
|
+
* without a relay read. The relay gives no device-set version, so the window
|
|
278
|
+
* is the only bound on how long a linked or removed device goes unseen.
|
|
256
279
|
*
|
|
257
280
|
* @throws {EncryptionError} SESSION_NOT_FOUND if sessions cannot be established
|
|
258
281
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signal-service-cipher.d.ts","sourceRoot":"","sources":["../../client/signal-service-cipher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"signal-service-cipher.d.ts","sourceRoot":"","sources":["../../client/signal-service-cipher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,KAAK,EACV,yBAAyB,EACzB,QAAQ,EAIT,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,KAAK,EAAE,wBAAwB,EAA2B,MAAM,UAAU,CAAC;AAIlF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGvD,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAwB,MAAM,0BAA0B,CAAC;AACnG,OAAO,EAA+B,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,wBAAwB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGjF,OAAO,EACL,KAAK,0BAA0B,EAE/B,KAAK,sBAAsB,EAC3B,KAAK,8BAA8B,EACnC,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAC/B,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,EACjC,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAC/B,KAAK,qBAAqB,EAC3B,MAAM,mBAAmB,CAAC;AAe3B,OAAO,EAIL,KAAK,oBAAoB,IAAI,4BAA4B,EAC1D,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAEL,KAAK,wBAAwB,EAE9B,MAAM,0BAA0B,CAAC;AAElC;;;;GAIG;AACH,eAAO,MAAM,wCAAwC,QAAS,CAAC;AAgB/D,wBAAgB,0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ACW,YAAY;IA0F1B;;;;;;;;;;;;;OAaG;YACW,qBAAqB;IA8HnC;;OAEG;YACW,aAAa;YAQb,uBAAuB;YAWvB,6BAA6B;YAyG7B,gCAAgC;YAqChC,iCAAiC;YA6CjC,6BAA6B;YAqC7B,sBAAsB;YAgEtB,wBAAwB;YA8GxB,+BAA+B;YAkC/B,6BAA6B;YAkC7B,kCAAkC;IAmBhD;;;;;;;;;;;;;;;;;;;;;;;OAuBG;YACW,0BAA0B;IA+BxC;;;;;;;;;;;;;;;;OAgBG;YACW,YAAY;IAuJ1B;;;;;;;;OAQG;YACW,yBAAyB;YAmBzB,4BAA4B;IAwG1C;;;;;OAKG;YACW,cAAc;IAU5B;;;;;;;;;;;;;;;;OAgBG;YACW,uBAAuB;YAqCvB,uBAAuB;CAmCtC"}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @see https://signal.org/docs/specifications/sesame/
|
|
14
14
|
*/
|
|
15
|
+
import { utf8Decode } from '../internal/platform/index.js';
|
|
15
16
|
import AsyncLock from 'async-lock';
|
|
16
17
|
import { EncryptionError, EncryptionErrorCode } from '../types/index.js';
|
|
17
18
|
import { SealedSenderAuthError } from '../types/errors.js';
|
|
@@ -24,11 +25,18 @@ import { createDefaultSignalProtocolContentAdapter, } from './content-adapter.js
|
|
|
24
25
|
import * as CryptoUtils from '../internal/crypto/index.js';
|
|
25
26
|
import { completeOutgoingMessageIntent, getOutgoingMessageIntent, replaceOutgoingDirectDeviceMessage, storeOutgoingMessageIntent, withOutgoingMessageIntentLock, } from '../local/store/reliability.js';
|
|
26
27
|
import { withRetry } from '../utils/retry.js';
|
|
28
|
+
import { acquireUntilStopped, RelayWorkStopped, rethrowRelayWorkStopped } from './relay-work.js';
|
|
27
29
|
import { prepareGroupSharedMessage } from './group-sealed-sender.js';
|
|
28
30
|
import { sendGroupWithExactOutbox } from './group-outbox.js';
|
|
29
31
|
import { resolveSealedSenderContext as resolveSealedSenderSendContext, serializeDirectSealedSenderMessage as serializeDirectSealedSenderTransport, } from './sealed-sender.js';
|
|
30
32
|
import { prepareMediaAttachmentUpload, serializeMediaAttachmentMessage } from '../media/index.js';
|
|
31
33
|
import { UnidentifiedAccessMode, } from '../profile/contact-state.js';
|
|
34
|
+
/**
|
|
35
|
+
* How long a recipient's relay device list stays current before a send reads
|
|
36
|
+
* it again. A device linked or removed inside this window is found by the
|
|
37
|
+
* first send after it ends.
|
|
38
|
+
*/
|
|
39
|
+
export const RECIPIENT_DEVICE_LIST_FRESH_MILLISECONDS = 60_000;
|
|
32
40
|
export function sortEnvelopesForDecryption(envelopes) {
|
|
33
41
|
return [...envelopes].sort((a, b) => {
|
|
34
42
|
// Treat undefined messageType as non-prekey (ciphertext comes after prekey_bundle)
|
|
@@ -47,7 +55,7 @@ export function sortEnvelopesForDecryption(envelopes) {
|
|
|
47
55
|
* @returns 'prekey_bundle' for PreKeyMessages, 'ciphertext' for regular messages
|
|
48
56
|
*/
|
|
49
57
|
function getEnvelopeMessageType(ciphertext) {
|
|
50
|
-
const text = typeof ciphertext === 'string' ? ciphertext :
|
|
58
|
+
const text = typeof ciphertext === 'string' ? ciphertext : utf8Decode(ciphertext);
|
|
51
59
|
// Binary protobuf format: base64 decode, check first protobuf tag
|
|
52
60
|
try {
|
|
53
61
|
const bytes = CryptoUtils.base64ToBytes(text);
|
|
@@ -146,8 +154,8 @@ export class SignalProtocolServiceCipher {
|
|
|
146
154
|
contentAdapter;
|
|
147
155
|
logger;
|
|
148
156
|
lock = new AsyncLock();
|
|
149
|
-
|
|
150
|
-
|
|
157
|
+
sessionCallbacks;
|
|
158
|
+
recipientDeviceListCheckedAt = new Map();
|
|
151
159
|
sealedSenderProvider;
|
|
152
160
|
sealedSenderDeliveryMode = 'preferred';
|
|
153
161
|
sealedSenderIdentifiedFallback;
|
|
@@ -185,7 +193,7 @@ export class SignalProtocolServiceCipher {
|
|
|
185
193
|
});
|
|
186
194
|
}
|
|
187
195
|
encodeLosslessPlaintext(plaintextBytes) {
|
|
188
|
-
const text =
|
|
196
|
+
const text = utf8Decode(plaintextBytes);
|
|
189
197
|
const roundTrip = new TextEncoder().encode(text);
|
|
190
198
|
if (roundTrip.length === plaintextBytes.length &&
|
|
191
199
|
roundTrip.every((byte, index) => byte === plaintextBytes[index])) {
|
|
@@ -266,20 +274,14 @@ export class SignalProtocolServiceCipher {
|
|
|
266
274
|
await this.sendSyncPayloadToLocalOtherDevices(payloadBytes, blocked.syncedAt);
|
|
267
275
|
}
|
|
268
276
|
/**
|
|
269
|
-
* Set the session
|
|
277
|
+
* Set the session callbacks of a send that passes none
|
|
270
278
|
* Called by SignalProtocolClient after construction to inject session establishment logic
|
|
271
|
-
*/
|
|
272
|
-
setSessionEstablisher(establisher) {
|
|
273
|
-
this.sessionEstablisher = establisher;
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Set the stale session refresher callback
|
|
277
|
-
* Called by SignalProtocolClient after construction to inject session refresh logic
|
|
278
279
|
*
|
|
279
|
-
*
|
|
280
|
+
* The stale-session refresher runs when the server returns STALE_DEVICE
|
|
281
|
+
* errors (device reinstalled).
|
|
280
282
|
*/
|
|
281
|
-
|
|
282
|
-
this.
|
|
283
|
+
setSessionCallbacks(callbacks) {
|
|
284
|
+
this.sessionCallbacks = callbacks;
|
|
283
285
|
}
|
|
284
286
|
/**
|
|
285
287
|
* Set the sealed sender provider callback
|
|
@@ -510,27 +512,32 @@ export class SignalProtocolServiceCipher {
|
|
|
510
512
|
* @param recipientId - User ID or group ID (groups use the package group ID prefix)
|
|
511
513
|
* @param content - Uint8Array bytes to encrypt and send
|
|
512
514
|
* @param options - Optional send options (mimeType for binary content, etc.)
|
|
515
|
+
* @param sessions - Session callbacks of this send. Default: the callbacks
|
|
516
|
+
* that setSessionCallbacks set
|
|
517
|
+
* @param stopSignal - The stop signal of the relay work that sends. When it
|
|
518
|
+
* aborts while the send waits for the recipient's lock, the send throws
|
|
519
|
+
* RelayWorkStopped. Default: none, and the send waits
|
|
513
520
|
* @returns SendResult with messageId, timestamp, and device count
|
|
514
521
|
*
|
|
515
522
|
* @see https://signal.org/docs/specifications/sesame/
|
|
516
523
|
*/
|
|
517
|
-
async encrypt(recipientId, content, options) {
|
|
524
|
+
async encrypt(recipientId, content, options, sessions = this.sessionCallbacks, stopSignal) {
|
|
518
525
|
const clientMessageId = options?.clientMessageId ?? (await CryptoUtils.generateUuidV4());
|
|
519
526
|
const durableOptions = { ...options, clientMessageId };
|
|
520
527
|
const lockKey = `encrypt:${recipientId}`;
|
|
521
528
|
try {
|
|
522
|
-
return await this.lock
|
|
529
|
+
return await acquireUntilStopped(this.lock, lockKey, async () => {
|
|
523
530
|
// 1. Route binary file data (Uint8Array with isBinary flag) to blob encryption
|
|
524
531
|
if (durableOptions.isBinary) {
|
|
525
|
-
return this.encryptBinaryAttachment(recipientId, content, durableOptions);
|
|
532
|
+
return this.encryptBinaryAttachment(recipientId, content, durableOptions, sessions);
|
|
526
533
|
}
|
|
527
534
|
// 2. Detect recipient type (group vs user)
|
|
528
535
|
if (isGroupId(recipientId)) {
|
|
529
|
-
return this.encryptToGroup(recipientId, content, durableOptions);
|
|
536
|
+
return this.encryptToGroup(recipientId, content, durableOptions, sessions);
|
|
530
537
|
}
|
|
531
538
|
// 3. Send to user (existing SESAME path)
|
|
532
|
-
return this.encryptToUser(recipientId, content, durableOptions);
|
|
533
|
-
});
|
|
539
|
+
return this.encryptToUser(recipientId, content, durableOptions, sessions);
|
|
540
|
+
}, stopSignal);
|
|
534
541
|
}
|
|
535
542
|
catch (error) {
|
|
536
543
|
throw attachClientMessageId(error, clientMessageId);
|
|
@@ -659,39 +666,48 @@ export class SignalProtocolServiceCipher {
|
|
|
659
666
|
// PRIVATE - Encryption
|
|
660
667
|
// ============================================================================
|
|
661
668
|
/**
|
|
662
|
-
*
|
|
669
|
+
* Reconcile a recipient's sessions with the relay's device list
|
|
663
670
|
*
|
|
664
|
-
*
|
|
665
|
-
*
|
|
671
|
+
* A send must reach every device the relay lists for the recipient, and no
|
|
672
|
+
* device the relay no longer lists. The session establisher reads that list
|
|
673
|
+
* again when the last read is older than
|
|
674
|
+
* RECIPIENT_DEVICE_LIST_FRESH_MILLISECONDS, creates a session for each listed
|
|
675
|
+
* device that has none, and this method removes each local device that is not
|
|
676
|
+
* listed. Inside the window, a recipient with an active session is sent to
|
|
677
|
+
* without a relay read. The relay gives no device-set version, so the window
|
|
678
|
+
* is the only bound on how long a linked or removed device goes unseen.
|
|
666
679
|
*
|
|
667
680
|
* @throws {EncryptionError} SESSION_NOT_FOUND if sessions cannot be established
|
|
668
681
|
*/
|
|
669
|
-
async ensureSessionsForUser(recipientUserId) {
|
|
670
|
-
// Check if we have any session with this user via SESAME UserRecord
|
|
682
|
+
async ensureSessionsForUser(recipientUserId, sessions) {
|
|
671
683
|
const userRecord = await this.sesameManager.getUserRecord(recipientUserId);
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
684
|
+
const hasActiveSession = !!userRecord &&
|
|
685
|
+
Array.from(userRecord.devices.values()).some((device) => device.session?.currentSession != null);
|
|
686
|
+
const checkedAt = this.recipientDeviceListCheckedAt.get(recipientUserId);
|
|
687
|
+
if (hasActiveSession &&
|
|
688
|
+
checkedAt !== undefined &&
|
|
689
|
+
Date.now() - checkedAt < RECIPIENT_DEVICE_LIST_FRESH_MILLISECONDS) {
|
|
690
|
+
return;
|
|
678
691
|
}
|
|
679
|
-
|
|
680
|
-
this.logger.debug('No session exists, auto-establishing', {
|
|
692
|
+
this.logger.debug('Reconciling recipient devices with the relay', {
|
|
681
693
|
category: 'E2EE',
|
|
682
|
-
data: { recipientUserId,
|
|
694
|
+
data: { recipientUserId, hasActiveSession },
|
|
683
695
|
});
|
|
684
|
-
if (!
|
|
696
|
+
if (!sessions) {
|
|
697
|
+
if (hasActiveSession)
|
|
698
|
+
return;
|
|
685
699
|
throw new EncryptionError(`No session with ${recipientUserId} and auto-establishment not configured`, EncryptionErrorCode.SESSION_NOT_FOUND, { recipientUserId });
|
|
686
700
|
}
|
|
687
701
|
if (!this.relay) {
|
|
702
|
+
if (hasActiveSession)
|
|
703
|
+
return;
|
|
688
704
|
throw new EncryptionError('Cannot auto-establish session: relay server not configured', EncryptionErrorCode.INITIALIZATION_FAILED, { recipientUserId });
|
|
689
705
|
}
|
|
690
706
|
let result;
|
|
691
707
|
try {
|
|
692
708
|
// Use retry logic for transient network failures
|
|
693
709
|
result = await withRetry(async () => {
|
|
694
|
-
const attempt = await
|
|
710
|
+
const attempt = await sessions.establishSessions(recipientUserId);
|
|
695
711
|
if (attempt.establishedDevices.length === 0 && attempt.failedDeviceErrors.length > 0) {
|
|
696
712
|
throw attempt.failedDeviceErrors[0].error;
|
|
697
713
|
}
|
|
@@ -700,9 +716,20 @@ export class SignalProtocolServiceCipher {
|
|
|
700
716
|
operationName: 'establishSession',
|
|
701
717
|
maxRetries: 2,
|
|
702
718
|
baseDelay: 500,
|
|
719
|
+
shouldRetry: (error) => !(error instanceof RelayWorkStopped),
|
|
703
720
|
});
|
|
704
721
|
}
|
|
705
722
|
catch (error) {
|
|
723
|
+
rethrowRelayWorkStopped(error);
|
|
724
|
+
if (hasActiveSession) {
|
|
725
|
+
// The known devices still receive; the next send reads the list again.
|
|
726
|
+
this.logger.warn('Recipient device list refresh failed, sending to known devices', {
|
|
727
|
+
category: 'E2EE',
|
|
728
|
+
error: error,
|
|
729
|
+
data: { recipientUserId },
|
|
730
|
+
});
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
706
733
|
// Re-throw EncryptionErrors, wrap others
|
|
707
734
|
if (error instanceof EncryptionError) {
|
|
708
735
|
throw error;
|
|
@@ -714,28 +741,41 @@ export class SignalProtocolServiceCipher {
|
|
|
714
741
|
}
|
|
715
742
|
throw new EncryptionError(`Failed to establish session with ${recipientUserId} after retries`, EncryptionErrorCode.SESSION_ESTABLISHMENT_FAILED, { originalError: error, recipientUserId });
|
|
716
743
|
}
|
|
744
|
+
const listedDevices = new Set(result.activeDevices);
|
|
745
|
+
const removedDevices = [];
|
|
746
|
+
const reconciledRecord = await this.sesameManager.getUserRecord(recipientUserId);
|
|
747
|
+
for (const deviceId of Array.from(reconciledRecord?.devices.keys() ?? [])) {
|
|
748
|
+
if (listedDevices.has(deviceId))
|
|
749
|
+
continue;
|
|
750
|
+
await this.sesameManager.removeDevice(recipientUserId, deviceId);
|
|
751
|
+
removedDevices.push(deviceId);
|
|
752
|
+
}
|
|
717
753
|
if (result.establishedDevices.length === 0) {
|
|
718
754
|
throw new EncryptionError(`Recipient ${recipientUserId} has no available prekey bundles - they may not have registered encryption keys`, EncryptionErrorCode.RECIPIENT_NOT_REGISTERED, { recipientUserId, failedDevices: result.failedDevices });
|
|
719
755
|
}
|
|
720
|
-
|
|
756
|
+
// A device that failed stays unreached until the window ends, which keeps
|
|
757
|
+
// a recipient with a broken device from costing a relay read on every send.
|
|
758
|
+
this.recipientDeviceListCheckedAt.set(recipientUserId, Date.now());
|
|
759
|
+
this.logger.info('Reconciled recipient devices', {
|
|
721
760
|
category: 'E2EE',
|
|
722
761
|
data: {
|
|
723
762
|
recipientUserId,
|
|
724
763
|
establishedDevices: result.establishedDevices,
|
|
725
764
|
failedDevices: result.failedDevices,
|
|
765
|
+
removedDevices,
|
|
726
766
|
},
|
|
727
767
|
});
|
|
728
768
|
}
|
|
729
769
|
/**
|
|
730
770
|
* Encrypt to a single user (all their devices) via SESAME
|
|
731
771
|
*/
|
|
732
|
-
async encryptToUser(recipientUserId, plaintextBytes, options) {
|
|
733
|
-
return this.encryptToUserWithOutbox(recipientUserId, plaintextBytes, options);
|
|
772
|
+
async encryptToUser(recipientUserId, plaintextBytes, options, sessions) {
|
|
773
|
+
return this.encryptToUserWithOutbox(recipientUserId, plaintextBytes, options, sessions);
|
|
734
774
|
}
|
|
735
|
-
async encryptToUserWithOutbox(recipientUserId, plaintextBytes, options) {
|
|
736
|
-
return withOutgoingMessageIntentLock(this.storage, options.clientMessageId, () => this.encryptToUserWithOutboxLocked(recipientUserId, plaintextBytes, options));
|
|
775
|
+
async encryptToUserWithOutbox(recipientUserId, plaintextBytes, options, sessions) {
|
|
776
|
+
return withOutgoingMessageIntentLock(this.storage, options.clientMessageId, () => this.encryptToUserWithOutboxLocked(recipientUserId, plaintextBytes, options, sessions));
|
|
737
777
|
}
|
|
738
|
-
async encryptToUserWithOutboxLocked(recipientUserId, plaintextBytes, options) {
|
|
778
|
+
async encryptToUserWithOutboxLocked(recipientUserId, plaintextBytes, options, sessions) {
|
|
739
779
|
const plaintextDigest = CryptoUtils.bytesToBase64(await CryptoUtils.sha256(plaintextBytes));
|
|
740
780
|
const existing = await getOutgoingMessageIntent(this.storage, options.clientMessageId);
|
|
741
781
|
if (existing) {
|
|
@@ -747,9 +787,9 @@ export class SignalProtocolServiceCipher {
|
|
|
747
787
|
}
|
|
748
788
|
if (existing.result)
|
|
749
789
|
return existing.result;
|
|
750
|
-
return this.sendStoredDirectIntent(existing, plaintextBytes);
|
|
790
|
+
return this.sendStoredDirectIntent(existing, plaintextBytes, sessions);
|
|
751
791
|
}
|
|
752
|
-
await this.ensureSessionsForUser(recipientUserId);
|
|
792
|
+
await this.ensureSessionsForUser(recipientUserId, sessions);
|
|
753
793
|
const sealedSender = this.relay ? await this.resolveSealedSenderContext(recipientUserId) : null;
|
|
754
794
|
const directSealedSender = sealedSender && this.relay?.sendMultiRecipientUnidentified ? sealedSender : null;
|
|
755
795
|
const transportMode = directSealedSender
|
|
@@ -810,7 +850,7 @@ export class SignalProtocolServiceCipher {
|
|
|
810
850
|
syncMessages,
|
|
811
851
|
};
|
|
812
852
|
await storeOutgoingMessageIntent(this.storage, intent);
|
|
813
|
-
return this.sendStoredDirectIntent(intent, plaintextBytes);
|
|
853
|
+
return this.sendStoredDirectIntent(intent, plaintextBytes, sessions);
|
|
814
854
|
}
|
|
815
855
|
async prepareStoredDirectDeviceMessage(message, sealedSender) {
|
|
816
856
|
const messageType = getEnvelopeMessageType(message.ciphertext);
|
|
@@ -834,10 +874,10 @@ export class SignalProtocolServiceCipher {
|
|
|
834
874
|
}
|
|
835
875
|
return storedMessage;
|
|
836
876
|
}
|
|
837
|
-
async repairRejectedDirectDeviceMessage(intent, rejected, plaintextBytes) {
|
|
838
|
-
if (!
|
|
877
|
+
async repairRejectedDirectDeviceMessage(intent, rejected, plaintextBytes, sessions) {
|
|
878
|
+
if (!sessions)
|
|
839
879
|
throw new Error('Stale-session refresh is not configured');
|
|
840
|
-
const refreshed = await
|
|
880
|
+
const refreshed = await sessions.refreshStaleSession(rejected.recipientUserId, rejected.recipientDeviceId);
|
|
841
881
|
if (!refreshed) {
|
|
842
882
|
throw new EncryptionError('Failed to refresh a rejected recipient device', EncryptionErrorCode.SESSION_ESTABLISHMENT_FAILED, { recipientUserId: rejected.recipientUserId });
|
|
843
883
|
}
|
|
@@ -866,7 +906,7 @@ export class SignalProtocolServiceCipher {
|
|
|
866
906
|
deliveryMode: intent.transportMode === 'sealed_sender_required' ? 'required' : 'preferred',
|
|
867
907
|
});
|
|
868
908
|
}
|
|
869
|
-
async sendStoredDirectIntent(intent, plaintextBytes) {
|
|
909
|
+
async sendStoredDirectIntent(intent, plaintextBytes, sessions) {
|
|
870
910
|
if (intent.kind !== 'direct')
|
|
871
911
|
throw new Error('Expected a direct outbox intent');
|
|
872
912
|
if (!this.relay) {
|
|
@@ -889,7 +929,7 @@ export class SignalProtocolServiceCipher {
|
|
|
889
929
|
catch (error) {
|
|
890
930
|
if (!isConclusiveDeviceRejection(error))
|
|
891
931
|
throw error;
|
|
892
|
-
const replacement = await this.repairRejectedDirectDeviceMessage(intent, msg, plaintextBytes);
|
|
932
|
+
const replacement = await this.repairRejectedDirectDeviceMessage(intent, msg, plaintextBytes, sessions);
|
|
893
933
|
result = await this.sendStoredDirectDeviceMessage(intent, replacement);
|
|
894
934
|
}
|
|
895
935
|
if (messageId.startsWith('local-')) {
|
|
@@ -919,7 +959,7 @@ export class SignalProtocolServiceCipher {
|
|
|
919
959
|
await completeOutgoingMessageIntent(this.storage, intent.clientMessageId, result);
|
|
920
960
|
return result;
|
|
921
961
|
}
|
|
922
|
-
async encryptToGroupWithOutbox(actualGroupId, plaintextBytes, options) {
|
|
962
|
+
async encryptToGroupWithOutbox(actualGroupId, plaintextBytes, options, sessions) {
|
|
923
963
|
return sendGroupWithExactOutbox({
|
|
924
964
|
storage: this.storage,
|
|
925
965
|
...(this.relay && { relay: this.relay }),
|
|
@@ -927,7 +967,7 @@ export class SignalProtocolServiceCipher {
|
|
|
927
967
|
senderDeviceId: this.deviceId,
|
|
928
968
|
deliveryMode: this.sealedSenderDeliveryMode,
|
|
929
969
|
preparePayload: async (groupId, bytes, sendOptions) => {
|
|
930
|
-
const prepared = await this.prepareGroupSenderKeyPayload(groupId, bytes, sendOptions);
|
|
970
|
+
const prepared = await this.prepareGroupSenderKeyPayload(groupId, bytes, sendOptions, sessions);
|
|
931
971
|
return {
|
|
932
972
|
ciphertext: CryptoUtils.bytesToBase64(prepared.ciphertext),
|
|
933
973
|
preMessages: prepared.preMessages,
|
|
@@ -1221,7 +1261,7 @@ export class SignalProtocolServiceCipher {
|
|
|
1221
1261
|
const deviceResults = await Promise.all(options.groupMemberUserIds.map((userId) => this.relay.getActiveDevices(userId)));
|
|
1222
1262
|
return deviceResults.flat();
|
|
1223
1263
|
}
|
|
1224
|
-
async prepareGroupSenderKeyPayload(actualGroupId, plaintextBytes, options) {
|
|
1264
|
+
async prepareGroupSenderKeyPayload(actualGroupId, plaintextBytes, options, sessions) {
|
|
1225
1265
|
const existingKey = await this.storage.getSenderKey(actualGroupId, this.userId, this.deviceId);
|
|
1226
1266
|
if (!existingKey) {
|
|
1227
1267
|
throw new EncryptionError(`No sender key for group ${actualGroupId}. Call createGroupSenderKey() first to create and distribute the key.`, EncryptionErrorCode.SESSION_NOT_FOUND, {
|
|
@@ -1256,7 +1296,7 @@ export class SignalProtocolServiceCipher {
|
|
|
1256
1296
|
const otherMembers = members.filter((member) => member.userId !== this.userId);
|
|
1257
1297
|
const recipientUserIds = [...new Set(otherMembers.map((member) => member.userId))];
|
|
1258
1298
|
for (const recipientUserId of recipientUserIds) {
|
|
1259
|
-
await this.ensureSessionsForUser(recipientUserId);
|
|
1299
|
+
await this.ensureSessionsForUser(recipientUserId, sessions);
|
|
1260
1300
|
const skdmBytes = this.contentAdapter
|
|
1261
1301
|
? this.contentAdapter.serializeSenderKeyDistributionBytes(actualGroupId, distributionMessage)
|
|
1262
1302
|
: new TextEncoder().encode(JSON.stringify({
|
|
@@ -1288,10 +1328,10 @@ export class SignalProtocolServiceCipher {
|
|
|
1288
1328
|
* Uses the multi-recipient sealed-sender transport when anonymous delivery
|
|
1289
1329
|
* is available, with exact per-device identified delivery otherwise.
|
|
1290
1330
|
*/
|
|
1291
|
-
async encryptToGroup(groupId, plaintextBytes, options) {
|
|
1331
|
+
async encryptToGroup(groupId, plaintextBytes, options, sessions) {
|
|
1292
1332
|
const actualGroupId = extractGroupId(groupId);
|
|
1293
1333
|
await this.groupSendBarrierChecker?.(actualGroupId);
|
|
1294
|
-
return this.encryptToGroupWithOutbox(actualGroupId, plaintextBytes, options);
|
|
1334
|
+
return this.encryptToGroupWithOutbox(actualGroupId, plaintextBytes, options, sessions);
|
|
1295
1335
|
}
|
|
1296
1336
|
/**
|
|
1297
1337
|
* Encrypt binary attachment with two-layer encryption
|
|
@@ -1310,7 +1350,7 @@ export class SignalProtocolServiceCipher {
|
|
|
1310
1350
|
*
|
|
1311
1351
|
* @see https://developers.google.com/tink/streaming-aead/aes_gcm_hkdf_streaming
|
|
1312
1352
|
*/
|
|
1313
|
-
async encryptBinaryAttachment(recipientId, data, options) {
|
|
1353
|
+
async encryptBinaryAttachment(recipientId, data, options, sessions) {
|
|
1314
1354
|
if (!this.relay) {
|
|
1315
1355
|
throw new EncryptionError('Relay server not configured. Cannot send attachments without server connection.', EncryptionErrorCode.INITIALIZATION_FAILED);
|
|
1316
1356
|
}
|
|
@@ -1322,10 +1362,10 @@ export class SignalProtocolServiceCipher {
|
|
|
1322
1362
|
const attachmentBytes = new TextEncoder().encode(attachmentPayload);
|
|
1323
1363
|
let result;
|
|
1324
1364
|
if (isGroupId(recipientId)) {
|
|
1325
|
-
result = await this.encryptToGroup(recipientId, attachmentBytes, options);
|
|
1365
|
+
result = await this.encryptToGroup(recipientId, attachmentBytes, options, sessions);
|
|
1326
1366
|
}
|
|
1327
1367
|
else {
|
|
1328
|
-
result = await this.encryptToUser(recipientId, attachmentBytes, options);
|
|
1368
|
+
result = await this.encryptToUser(recipientId, attachmentBytes, options, sessions);
|
|
1329
1369
|
}
|
|
1330
1370
|
return {
|
|
1331
1371
|
...result,
|