@open-e2ee/signal-protocol-sdk 7.2.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 +54 -7
- package/ARCHITECTURE.md +1 -0
- package/CHANGELOG.md +503 -0
- package/README.md +9 -5
- package/SECURITY.md +2 -2
- package/THIRD_PARTY_NOTICES.md +429 -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-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 +19 -11
- package/dist/client/signal-service-cipher.d.ts.map +1 -1
- package/dist/client/signal-service-cipher.js +48 -46
- 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/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/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 +16 -3
- package/dist/internal/sesame/device-registry.d.ts.map +1 -1
- package/dist/internal/sesame/device-registry.js +10 -7
- 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 +6 -6
- package/dist/local/store/key-value/backend-conformance.d.ts.map +1 -0
- package/dist/local/store/{react-native → key-value}/backend-conformance.js +3 -3
- 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 -274
- package/dist/local/store/react-native/adapter.d.ts.map +1 -1
- package/dist/local/store/react-native/adapter.js +80 -1406
- 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 +80 -8
- package/docs/CLIENT_COMPOSITION.md +1 -2
- package/docs/DEVIATIONS.md +1 -1
- 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 -37
- package/local/store/expo/README.md +67 -47
- package/local/store/key-value/README.md +278 -0
- package/local/store/node/README.md +206 -46
- package/local/store/react-native/README.md +120 -61
- 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 +42 -23
- 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
|
@@ -1,653 +1,96 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Expo Signal Protocol Store
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
|
|
4
|
+
* The SDK owns the database file. One call opens it in the expo-sqlite default
|
|
5
|
+
* directory, gets or creates its key through the local secret vault, applies
|
|
6
|
+
* the SDK migrations, and returns the store.
|
|
7
|
+
*/
|
|
8
|
+
import { ExpoSecureStoreSignalProtocolSecretVault } from '../../vault/expo-secure-store.js';
|
|
9
|
+
import { openSqliteStore, resetSqliteStore, } from '../sqlite/open-store.js';
|
|
10
|
+
import { SqliteSignalProtocolStore } from '../sqlite/store.js';
|
|
11
|
+
import { createExpoSqliteDriver } from './driver.js';
|
|
12
|
+
/** The database file name when the options name none. */
|
|
13
|
+
const DEFAULT_DATABASE_NAME = 'open-e2ee-signal-protocol.db';
|
|
14
|
+
function storeOptions(options) {
|
|
15
|
+
return {
|
|
16
|
+
...options,
|
|
17
|
+
driver: createExpoSqliteDriver(),
|
|
18
|
+
name: options.name ?? DEFAULT_DATABASE_NAME,
|
|
19
|
+
vault: options.vault ?? new ExpoSecureStoreSignalProtocolSecretVault(),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** The database of each open store, for the helpers of this entry. */
|
|
23
|
+
const databases = new WeakMap();
|
|
24
|
+
/** The executor of an open store. Not exported from the entry. */
|
|
25
|
+
export function expoStoreDatabase(store) {
|
|
26
|
+
const database = databases.get(store);
|
|
27
|
+
if (!database)
|
|
28
|
+
throw new TypeError('Open the store with expoStore().');
|
|
29
|
+
return database;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Local Signal Protocol state for Expo, in an SDK-owned SQLCipher database.
|
|
8
33
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
34
|
+
* Open it with {@link expoStore}. The store holds the database file until
|
|
35
|
+
* {@link ExpoSignalProtocolStore.close}. A second open of the same name in
|
|
36
|
+
* the process fails with `INVALID_STATE`.
|
|
37
|
+
*
|
|
38
|
+
* Every table holds material that must not leave the device, including the
|
|
39
|
+
* group sender keys. SQLCipher encrypts the whole file, so the database key
|
|
40
|
+
* in the vault is the only thing that protects it.
|
|
41
|
+
*
|
|
42
|
+
* @category Key Storage
|
|
43
|
+
* @see {@link SignalProtocolLocalStore} for interface documentation
|
|
11
44
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export class ExpoSignalProtocolStore {
|
|
17
|
-
storage;
|
|
18
|
-
logger;
|
|
19
|
-
constructor(providedLogger) {
|
|
20
|
-
this.logger = resolveSignalProtocolLogger(providedLogger);
|
|
21
|
-
this.storage = new KeyStorage(this.logger);
|
|
22
|
-
}
|
|
23
|
-
setLogger(providedLogger) {
|
|
24
|
-
this.logger = resolveSignalProtocolLogger(providedLogger);
|
|
25
|
-
this.storage.setLogger(this.logger);
|
|
26
|
-
}
|
|
27
|
-
// ============================================================================
|
|
28
|
-
// Identity Key Management (Own Keys)
|
|
29
|
-
// ============================================================================
|
|
30
|
-
async storeIdentityKey(keyPair, identityType) {
|
|
31
|
-
await this.storage.storeIdentityKey(keyPair, identityType);
|
|
32
|
-
}
|
|
33
|
-
async getIdentityKey(identityType) {
|
|
34
|
-
return await this.storage.getIdentityKey(identityType);
|
|
35
|
-
}
|
|
36
|
-
async deleteIdentityKey(identityType) {
|
|
37
|
-
await this.storage.deleteIdentityKey(identityType);
|
|
38
|
-
}
|
|
39
|
-
async hasIdentityKey(identityType) {
|
|
40
|
-
return await this.storage.hasIdentityKey(identityType);
|
|
41
|
-
}
|
|
42
|
-
async getLocalRegistrationId(identityType) {
|
|
43
|
-
return await this.storage.getLocalRegistrationId(identityType);
|
|
44
|
-
}
|
|
45
|
-
async setLocalRegistrationId(id, identityType) {
|
|
46
|
-
await this.storage.setLocalRegistrationId(id, identityType);
|
|
47
|
-
}
|
|
48
|
-
// ============================================================================
|
|
49
|
-
// Identity Verification (Contact Identity Keys)
|
|
50
|
-
// ============================================================================
|
|
51
|
-
async saveContactIdentity(address, identity, identityType, suppliedCommitment) {
|
|
52
|
-
return await this.storage.saveContactIdentity(address, identity, identityType, suppliedCommitment);
|
|
53
|
-
}
|
|
54
|
-
async getContactIdentity(address, identityType) {
|
|
55
|
-
return await this.storage.getContactIdentity(address, identityType);
|
|
56
|
-
}
|
|
57
|
-
async acceptContactIdentityRotation(address, identity, identityType, suppliedCommitment) {
|
|
58
|
-
return await this.storage.acceptContactIdentityRotationAndDeleteSessions(address, identity, identityType, suppliedCommitment);
|
|
59
|
-
}
|
|
60
|
-
async acceptContactIdentityRotationAndDeleteSessions(address, identity, identityType, suppliedCommitment) {
|
|
61
|
-
return await this.storage.acceptContactIdentityRotationAndDeleteSessions(address, identity, identityType, suppliedCommitment);
|
|
62
|
-
}
|
|
63
|
-
async verifyContactIdentity(address, identity, identityType, suppliedCommitment) {
|
|
64
|
-
return await this.storage.verifyContactIdentity(address, identity, identityType, suppliedCommitment);
|
|
65
|
-
}
|
|
66
|
-
async isTrustedIdentity(address, identity, direction, identityType) {
|
|
67
|
-
return await this.storage.isTrustedIdentity(address, identity, direction, identityType);
|
|
68
|
-
}
|
|
69
|
-
// ============================================================================
|
|
70
|
-
// PreKey Management
|
|
71
|
-
// ============================================================================
|
|
72
|
-
async storeEcSignedPreKey(signedPreKey, identityType) {
|
|
73
|
-
await this.storage.storeEcSignedPreKey(signedPreKey, identityType);
|
|
74
|
-
}
|
|
75
|
-
async getEcSignedPreKey(keyId, identityType) {
|
|
76
|
-
return await this.storage.getEcSignedPreKey(keyId, identityType);
|
|
77
|
-
}
|
|
78
|
-
async getAllEcSignedPreKeys(identityType) {
|
|
79
|
-
return await this.storage.getAllEcSignedPreKeys(identityType);
|
|
80
|
-
}
|
|
81
|
-
async removeEcSignedPreKey(keyId, identityType) {
|
|
82
|
-
return await this.storage.removeEcSignedPreKey(keyId, identityType);
|
|
83
|
-
}
|
|
84
|
-
async storeEcOneTimePreKeys(prekeys, identityType) {
|
|
85
|
-
await this.storage.storeEcOneTimePreKeys(prekeys, identityType);
|
|
86
|
-
}
|
|
87
|
-
async getEcOneTimePreKeys(identityType) {
|
|
88
|
-
return await this.storage.getEcOneTimePreKeys(identityType);
|
|
89
|
-
}
|
|
90
|
-
async removeEcOneTimePreKey(preKeyId, identityType) {
|
|
91
|
-
await this.storage.removeEcOneTimePreKey(preKeyId, identityType);
|
|
92
|
-
}
|
|
93
|
-
async storeKyberPreKey(kyberPreKey, identityType) {
|
|
94
|
-
await this.storage.storeKyberPreKey(kyberPreKey, identityType);
|
|
95
|
-
}
|
|
96
|
-
async getKyberPreKey(identityType) {
|
|
97
|
-
const result = await this.storage.getKyberPreKey(identityType);
|
|
98
|
-
return result;
|
|
99
|
-
}
|
|
100
|
-
async getKyberPreKeyById(keyId, identityType) {
|
|
101
|
-
return await this.storage.getKyberPreKeyById(keyId, identityType);
|
|
102
|
-
}
|
|
103
|
-
async markKyberPreKeyUsed(kyberPreKeyId, signedPreKeyId, baseKeyBytes, identityType) {
|
|
104
|
-
await this.storage.markKyberPreKeyUsed(kyberPreKeyId, signedPreKeyId, baseKeyBytes, identityType);
|
|
105
|
-
}
|
|
106
|
-
// ============================================================================
|
|
107
|
-
// KEM One-Time PreKey Management (Per-Session Post-Quantum Forward Secrecy)
|
|
108
|
-
// ============================================================================
|
|
109
|
-
async storeKemOneTimePreKeys(prekeys, identityType) {
|
|
110
|
-
await this.storage.storeKemOneTimePreKeys(prekeys, identityType);
|
|
111
|
-
}
|
|
112
|
-
async getKemOneTimePreKeys(identityType) {
|
|
113
|
-
return await this.storage.getKemOneTimePreKeys(identityType);
|
|
114
|
-
}
|
|
115
|
-
async getKemOneTimePreKey(keyId, identityType) {
|
|
116
|
-
return await this.storage.getKemOneTimePreKey(keyId, identityType);
|
|
117
|
-
}
|
|
118
|
-
async removeKemOneTimePreKey(keyId, identityType) {
|
|
119
|
-
await this.storage.removeKemOneTimePreKey(keyId, identityType);
|
|
120
|
-
}
|
|
121
|
-
async getKemOneTimePreKeyCount(identityType) {
|
|
122
|
-
return await this.storage.getKemOneTimePreKeyCount(identityType);
|
|
123
|
-
}
|
|
124
|
-
// ============================================================================
|
|
125
|
-
// Session Management (New API)
|
|
126
|
-
// ============================================================================
|
|
127
|
-
async storeSessionRecord(address, record) {
|
|
128
|
-
await this.storage.storeSessionRecord(address, record);
|
|
129
|
-
}
|
|
130
|
-
async commitSessionTrust(commit) {
|
|
131
|
-
await this.storage.commitSessionTrust(commit);
|
|
132
|
-
}
|
|
133
|
-
async getSessionRecord(address) {
|
|
134
|
-
const result = await this.storage.getSessionRecord(address);
|
|
135
|
-
return result;
|
|
136
|
-
}
|
|
137
|
-
async deleteSessionRecord(address) {
|
|
138
|
-
await this.storage.deleteSessionRecord(address);
|
|
139
|
-
}
|
|
140
|
-
async archiveCurrentSession(address, newSession) {
|
|
141
|
-
// Convert null to undefined for KeyStorage
|
|
142
|
-
await this.storage.archiveCurrentSession(address, newSession ?? undefined);
|
|
143
|
-
}
|
|
144
|
-
async getSessionsForUser(userId) {
|
|
145
|
-
return await this.storage.getSessionsForUser(userId);
|
|
146
|
-
}
|
|
147
|
-
async hasSession(address) {
|
|
148
|
-
return await this.storage.hasSession(address);
|
|
149
|
-
}
|
|
150
|
-
// ============================================================================
|
|
151
|
-
// Legacy Session API (Deprecated)
|
|
152
|
-
// ============================================================================
|
|
153
|
-
async storeSession(sessionId, session) {
|
|
154
|
-
await this.storage.storeSession(sessionId, session);
|
|
155
|
-
}
|
|
156
|
-
async getSession(sessionId) {
|
|
157
|
-
return await this.storage.getSession(sessionId);
|
|
158
|
-
}
|
|
159
|
-
async deleteSession(sessionId) {
|
|
160
|
-
await this.storage.deleteSession(sessionId);
|
|
161
|
-
}
|
|
162
|
-
// ============================================================================
|
|
163
|
-
// Database Encryption
|
|
164
|
-
// ============================================================================
|
|
165
|
-
async getDatabaseKey() {
|
|
166
|
-
const dbKeyManager = getDatabaseKeyManager(this.logger);
|
|
167
|
-
return await dbKeyManager.getKeyOrThrow();
|
|
168
|
-
}
|
|
169
|
-
// ============================================================================
|
|
170
|
-
// Utility
|
|
171
|
-
// ============================================================================
|
|
172
|
-
async getSessionCount() {
|
|
173
|
-
// Delegate to underlying storage implementation
|
|
174
|
-
return await this.storage.getSessionCount();
|
|
175
|
-
}
|
|
176
|
-
async clearAllKeys() {
|
|
177
|
-
await this.storage.clearAllKeys();
|
|
178
|
-
}
|
|
179
|
-
async getMetadata(key) {
|
|
180
|
-
return this.storage.getMetadata(key);
|
|
181
|
-
}
|
|
182
|
-
async setMetadata(key, value) {
|
|
183
|
-
return this.storage.setMetadata(key, value);
|
|
184
|
-
}
|
|
185
|
-
async deleteMetadata(key) {
|
|
186
|
-
return this.storage.deleteMetadata(key);
|
|
187
|
-
}
|
|
188
|
-
async compareAndSetMetadata(key, expected, value) {
|
|
189
|
-
return this.storage.compareAndSetMetadata(key, expected, value);
|
|
190
|
-
}
|
|
191
|
-
// ============================================================================
|
|
192
|
-
// SESAME Multi-Device Session Management
|
|
193
|
-
// ============================================================================
|
|
194
|
-
// SESAME sessions are stored locally, following the Signal Protocol SESAME specification.
|
|
195
|
-
// The server only stores device registry, prekeys, and message mailbox.
|
|
196
|
-
/**
|
|
197
|
-
* Helper to get a contact's pinned identity as canonical DeviceRecord bytes.
|
|
198
|
-
*
|
|
199
|
-
* Returns the whole composite tuple, not the X25519 half. A device pinned to
|
|
200
|
-
* the DH key alone would accept a peer that swapped its Ed25519 signing key.
|
|
201
|
-
* It would also compare unequal against every other producer of these bytes.
|
|
202
|
-
*/
|
|
203
|
-
async getContactIdentityBytes(address) {
|
|
204
|
-
const record = await this.getContactIdentity(address);
|
|
205
|
-
if (!record)
|
|
206
|
-
return null;
|
|
207
|
-
return encodeCompositeIdentityV1(record.identity);
|
|
208
|
-
}
|
|
209
|
-
async getUserRecord(userId) {
|
|
210
|
-
// UserRecords are stored locally - get all sessions for this user
|
|
211
|
-
const sessions = await this.getSessionsForUser(userId);
|
|
212
|
-
if (sessions.length === 0)
|
|
213
|
-
return null;
|
|
214
|
-
// Build devices map from sessions
|
|
215
|
-
const devices = new Map();
|
|
216
|
-
const now = Date.now();
|
|
217
|
-
for (const session of sessions) {
|
|
218
|
-
// Extract deviceId from session's remoteAddress
|
|
219
|
-
const deviceId = session.currentSession?.remoteAddress?.deviceId;
|
|
220
|
-
if (deviceId === undefined)
|
|
221
|
-
continue;
|
|
222
|
-
// Build DeviceRecord from session (similar to getDeviceRecord())
|
|
223
|
-
const address = { userId, deviceId };
|
|
224
|
-
const identityKey = await this.getContactIdentityBytes(address);
|
|
225
|
-
devices.set(deviceId, {
|
|
226
|
-
userId,
|
|
227
|
-
deviceId,
|
|
228
|
-
identityKey: identityKey ?? UNPINNED_DEVICE_IDENTITY_KEY,
|
|
229
|
-
session,
|
|
230
|
-
createdAt: session.metadata?.createdAt ?? now,
|
|
231
|
-
updatedAt: now,
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
return { userId, devices, createdAt: now, updatedAt: now };
|
|
235
|
-
}
|
|
236
|
-
async setUserRecord(_userId, _record) {
|
|
237
|
-
// UserRecords are aggregates of DeviceRecords - store via setDeviceRecord
|
|
238
|
-
// This is intentionally a no-op as individual devices are stored separately
|
|
239
|
-
}
|
|
240
|
-
async getDeviceRecord(userId, deviceId) {
|
|
241
|
-
// DeviceRecords are stored locally via session storage
|
|
242
|
-
const address = { userId, deviceId };
|
|
243
|
-
const sessionRecord = await this.getSessionRecord(address);
|
|
244
|
-
if (!sessionRecord)
|
|
245
|
-
return null;
|
|
246
|
-
// Load actual identity key from contact identity storage
|
|
247
|
-
const identityKey = await this.getContactIdentityBytes(address);
|
|
248
|
-
const now = Date.now();
|
|
249
|
-
return {
|
|
250
|
-
userId,
|
|
251
|
-
deviceId,
|
|
252
|
-
identityKey: identityKey ?? UNPINNED_DEVICE_IDENTITY_KEY,
|
|
253
|
-
session: sessionRecord,
|
|
254
|
-
createdAt: sessionRecord.metadata?.createdAt ?? now,
|
|
255
|
-
updatedAt: now,
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
async setDeviceRecord(userId, deviceId, record) {
|
|
259
|
-
const address = { userId, deviceId };
|
|
260
|
-
// Store session locally
|
|
261
|
-
if (record.session) {
|
|
262
|
-
await this.storeSessionRecord(address, record.session);
|
|
263
|
-
}
|
|
264
|
-
// Generic SESAME DeviceRecord identity bytes do not carry the Ed25519
|
|
265
|
-
// component, so they cannot mutate composite trust storage.
|
|
266
|
-
}
|
|
267
|
-
async deleteDeviceRecord(userId, deviceId) {
|
|
268
|
-
// Delete local session for this device
|
|
269
|
-
const address = { userId, deviceId };
|
|
270
|
-
await this.deleteSessionRecord(address);
|
|
271
|
-
}
|
|
272
|
-
async getDeviceSession(userId, deviceId) {
|
|
273
|
-
// Sessions are stored locally via ProtocolAddress
|
|
274
|
-
const address = { userId, deviceId };
|
|
275
|
-
return this.getSessionRecord(address);
|
|
45
|
+
export class ExpoSignalProtocolStore extends SqliteSignalProtocolStore {
|
|
46
|
+
constructor(database, logger) {
|
|
47
|
+
super(database, { logger });
|
|
48
|
+
databases.set(this, database);
|
|
276
49
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
const
|
|
280
|
-
|
|
50
|
+
/** @internal Use {@link expoStore}. */
|
|
51
|
+
static async open(options) {
|
|
52
|
+
const database = await openSqliteStore(storeOptions(options));
|
|
53
|
+
return new ExpoSignalProtocolStore(database, options.logger);
|
|
281
54
|
}
|
|
282
|
-
/**
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
* 1. It has no active session AND no archived sessions
|
|
287
|
-
* 2. Its age exceeds maxLatency
|
|
288
|
-
*
|
|
289
|
-
* @param maxLatency - Maximum age in milliseconds (default: 30 days)
|
|
290
|
-
* @returns Number of device records deleted
|
|
291
|
-
*/
|
|
292
|
-
async deleteStaleRecords(maxLatency) {
|
|
293
|
-
// Delete device records with no active sessions and age > maxLatency
|
|
294
|
-
const now = Date.now();
|
|
295
|
-
let deletedCount = 0;
|
|
296
|
-
const userIds = await this.getAllUserIds();
|
|
297
|
-
for (const userId of userIds) {
|
|
298
|
-
const deviceIds = await this.getSesameDeviceIds(userId);
|
|
299
|
-
for (const deviceId of deviceIds) {
|
|
300
|
-
try {
|
|
301
|
-
const deviceRecord = await this.getDeviceRecord(userId, deviceId);
|
|
302
|
-
if (!deviceRecord)
|
|
303
|
-
continue;
|
|
304
|
-
// Device is stale if:
|
|
305
|
-
// 1. No active session AND no archived sessions
|
|
306
|
-
// 2. Age > maxLatency
|
|
307
|
-
const hasNoSessions = !deviceRecord.session?.currentSession &&
|
|
308
|
-
Object.keys(deviceRecord.session?.archivedSessions ?? {}).length === 0;
|
|
309
|
-
const deviceAge = now - deviceRecord.createdAt;
|
|
310
|
-
if (hasNoSessions && deviceAge > maxLatency) {
|
|
311
|
-
await this.deleteDeviceRecord(userId, deviceId);
|
|
312
|
-
deletedCount++;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
catch {
|
|
316
|
-
// Continue processing other devices on error
|
|
317
|
-
continue;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
return deletedCount;
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Delete expired sessions based on age.
|
|
325
|
-
*
|
|
326
|
-
* Sessions are considered expired if their age exceeds maxRecv.
|
|
327
|
-
* Following SESAME spec, default maxRecv is 180 days.
|
|
328
|
-
*
|
|
329
|
-
* @param maxRecv - Maximum session age in milliseconds (default: 180 days)
|
|
330
|
-
* @returns Number of sessions deleted
|
|
331
|
-
*/
|
|
332
|
-
async cleanupExpiredSessions(maxRecv) {
|
|
333
|
-
// Delete sessions older than maxRecv (default 180 days)
|
|
334
|
-
const now = Date.now();
|
|
335
|
-
let deletedCount = 0;
|
|
336
|
-
const userIds = await this.getAllUserIds();
|
|
337
|
-
for (const userId of userIds) {
|
|
338
|
-
const deviceIds = await this.getSesameDeviceIds(userId);
|
|
339
|
-
for (const deviceId of deviceIds) {
|
|
340
|
-
try {
|
|
341
|
-
const address = { userId, deviceId };
|
|
342
|
-
const sessionRecord = await this.getSessionRecord(address);
|
|
343
|
-
if (!sessionRecord)
|
|
344
|
-
continue;
|
|
345
|
-
const createdAt = sessionRecord.metadata?.createdAt ?? now;
|
|
346
|
-
const sessionAge = now - createdAt;
|
|
347
|
-
if (sessionAge > maxRecv) {
|
|
348
|
-
// Delete the expired session
|
|
349
|
-
await this.deleteSessionRecord(address);
|
|
350
|
-
deletedCount++;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
catch {
|
|
354
|
-
// Continue processing other devices on error
|
|
355
|
-
continue;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
return deletedCount;
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* Get all unique user IDs that have sessions in local storage.
|
|
363
|
-
*
|
|
364
|
-
* Extracts user IDs from session IDs stored in Signal Protocol format (userId:deviceId).
|
|
365
|
-
* Only includes entries where the deviceId portion is a valid non-negative integer.
|
|
366
|
-
*
|
|
367
|
-
* @returns Array of unique user IDs
|
|
368
|
-
*/
|
|
369
|
-
async getAllUserIds() {
|
|
370
|
-
// Get all sessions and extract unique user IDs
|
|
371
|
-
// Uses Signal Protocol standard colon separator (userId:deviceId)
|
|
372
|
-
const allSessionIds = await this.storage.getAllSessionIds();
|
|
373
|
-
const userIds = new Set();
|
|
374
|
-
for (const sessionId of allSessionIds) {
|
|
375
|
-
// Session IDs use Signal Protocol format: "userId:deviceId"
|
|
376
|
-
const colonIndex = sessionId.lastIndexOf(':');
|
|
377
|
-
if (colonIndex > 0) {
|
|
378
|
-
// Validate that the portion after colon is a valid deviceId (numeric)
|
|
379
|
-
const deviceIdStr = sessionId.substring(colonIndex + 1);
|
|
380
|
-
const deviceId = parseInt(deviceIdStr, 10);
|
|
381
|
-
if (!isNaN(deviceId) && deviceId >= 0) {
|
|
382
|
-
userIds.add(sessionId.substring(0, colonIndex));
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
return Array.from(userIds);
|
|
55
|
+
/** @internal Use {@link resetExpoStore}. */
|
|
56
|
+
static async reset(options) {
|
|
57
|
+
const database = await resetSqliteStore(storeOptions(options));
|
|
58
|
+
return new ExpoSignalProtocolStore(database, options.logger);
|
|
387
59
|
}
|
|
388
60
|
/**
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
* Queries sessions matching the user ID and extracts unique device IDs.
|
|
392
|
-
* Session IDs follow Signal Protocol format (userId:deviceId).
|
|
393
|
-
*
|
|
394
|
-
* @param userId - User ID to query devices for
|
|
395
|
-
* @returns Array of device IDs (unique, non-negative integers)
|
|
61
|
+
* Wait for the queued work, then close the database. Every later call
|
|
62
|
+
* rejects with `SqliteStoreClosedError`.
|
|
396
63
|
*/
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
// Uses Signal Protocol standard colon separator (userId:deviceId)
|
|
400
|
-
const sessionIds = await this.storage.getSessionIdsForUser(userId);
|
|
401
|
-
const deviceIds = [];
|
|
402
|
-
for (const sessionId of sessionIds) {
|
|
403
|
-
// Session IDs use Signal Protocol format: "userId:deviceId"
|
|
404
|
-
const colonIndex = sessionId.lastIndexOf(':');
|
|
405
|
-
if (colonIndex > 0) {
|
|
406
|
-
const deviceIdStr = sessionId.substring(colonIndex + 1);
|
|
407
|
-
const deviceId = parseInt(deviceIdStr, 10);
|
|
408
|
-
if (!isNaN(deviceId) && !deviceIds.includes(deviceId)) {
|
|
409
|
-
deviceIds.push(deviceId);
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
return deviceIds;
|
|
414
|
-
}
|
|
415
|
-
// ============================================================================
|
|
416
|
-
// Sender Keys Management (Group Messaging)
|
|
417
|
-
// ============================================================================
|
|
418
|
-
// Sender key state is device-local. The chain key and the sender's private
|
|
419
|
-
// signature key are enough to read and to forge every message on that chain.
|
|
420
|
-
// They never leave the device. The reference keeps its sender key store
|
|
421
|
-
// local for the same reason. SQLCipher encrypts the database file that holds
|
|
422
|
-
// them.
|
|
423
|
-
async storeSenderKey(groupId, userId, deviceId, state) {
|
|
424
|
-
await this.storeSenderKeyRecord(groupId, userId, deviceId, [state]);
|
|
425
|
-
}
|
|
426
|
-
async getSenderKey(groupId, userId, deviceId) {
|
|
427
|
-
const record = await this.getSenderKeyRecord(groupId, userId, deviceId);
|
|
428
|
-
return record?.[0] ?? null;
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* Store a sender key record (current state first, then the superseded states
|
|
432
|
-
* the rotation window still needs).
|
|
433
|
-
*
|
|
434
|
-
* The whole record is one row, so current and previous states can never be
|
|
435
|
-
* written apart from one another.
|
|
436
|
-
*/
|
|
437
|
-
async storeSenderKeyRecord(groupId, userId, deviceId, states, receive) {
|
|
438
|
-
if (states.length === 0)
|
|
439
|
-
return;
|
|
440
|
-
const { getRawDatabase } = await import('./db.js');
|
|
441
|
-
const { createSenderKey } = await import('./models/sender-key.js');
|
|
442
|
-
const db = getRawDatabase();
|
|
443
|
-
await db.withTransactionAsync(async () => {
|
|
444
|
-
await createSenderKey({ groupId, senderId: userId, deviceId, states }).save();
|
|
445
|
-
if (receive) {
|
|
446
|
-
await this.storage.setMetadata(`received-content:${receive.content.id}`, JSON.stringify(receive.content));
|
|
447
|
-
if (receive.consumedChainIndex !== undefined)
|
|
448
|
-
await this.deleteSkippedSenderKey(groupId, userId, deviceId, receive.consumedChainIndex);
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
async getReceivedContent(id) {
|
|
453
|
-
return this.storage.getReceivedContent(id);
|
|
454
|
-
}
|
|
455
|
-
async deleteReceivedContent(id) {
|
|
456
|
-
await this.storage.deleteReceivedContent(id);
|
|
457
|
-
}
|
|
458
|
-
async deleteExpiredReceivedContent(before) {
|
|
459
|
-
return this.storage.deleteExpiredReceivedContent(before);
|
|
460
|
-
}
|
|
461
|
-
async getSenderKeyRecord(groupId, userId, deviceId) {
|
|
462
|
-
const { getSenderKey } = await import('./models/sender-key.js');
|
|
463
|
-
const row = await getSenderKey(groupId, userId, deviceId);
|
|
464
|
-
if (!row)
|
|
465
|
-
return null;
|
|
466
|
-
const states = row.states;
|
|
467
|
-
if (states.length === 0) {
|
|
468
|
-
// The record column failed to parse. Report "no sender key" so the
|
|
469
|
-
// caller asks for a fresh distribution message instead of throwing.
|
|
470
|
-
this.logger.warn('Corrupted sender key record', { groupId, userId, deviceId });
|
|
471
|
-
return null;
|
|
472
|
-
}
|
|
473
|
-
return states;
|
|
474
|
-
}
|
|
475
|
-
async resolveGroupForSenderKeyId(senderKeyId, userId, deviceId) {
|
|
476
|
-
const { findGroupBySenderKeyId } = await import('./models/sender-key.js');
|
|
477
|
-
return findGroupBySenderKeyId(senderKeyId, userId, deviceId);
|
|
478
|
-
}
|
|
479
|
-
async deleteSenderKey(groupId, userId, deviceId) {
|
|
480
|
-
const { deleteSenderKey } = await import('./models/sender-key.js');
|
|
481
|
-
await deleteSenderKey(groupId, userId, deviceId);
|
|
482
|
-
}
|
|
483
|
-
async getAllSenderKeysForGroup(groupId) {
|
|
484
|
-
const { getSenderKeysByGroup } = await import('./models/sender-key.js');
|
|
485
|
-
const rows = await getSenderKeysByGroup(groupId);
|
|
486
|
-
const states = [];
|
|
487
|
-
for (const row of rows) {
|
|
488
|
-
const current = row.currentState;
|
|
489
|
-
if (current)
|
|
490
|
-
states.push(current);
|
|
491
|
-
}
|
|
492
|
-
return states;
|
|
493
|
-
}
|
|
494
|
-
async deleteAllSenderKeysForGroup(groupId) {
|
|
495
|
-
const { deleteSenderKeysByGroup } = await import('./models/sender-key.js');
|
|
496
|
-
return deleteSenderKeysByGroup(groupId);
|
|
497
|
-
}
|
|
498
|
-
// ============================================================================
|
|
499
|
-
// Skipped Sender Keys (Out-of-Order Message Support)
|
|
500
|
-
// ============================================================================
|
|
501
|
-
// These are the message keys themselves. Same rule as the chain key above:
|
|
502
|
-
// device-local only.
|
|
503
|
-
async storeSkippedSenderKey(groupId, senderId, senderDeviceId, chainIndex, messageKey) {
|
|
504
|
-
const { getDrizzle, skippedSenderKeys } = await import('./db.js');
|
|
505
|
-
const db = await getDrizzle();
|
|
506
|
-
await db
|
|
507
|
-
.insert(skippedSenderKeys)
|
|
508
|
-
.values({
|
|
509
|
-
groupId,
|
|
510
|
-
senderId,
|
|
511
|
-
senderDeviceId,
|
|
512
|
-
chainIndex,
|
|
513
|
-
cipherKey: messageKey.cipherKey,
|
|
514
|
-
iv: messageKey.iv,
|
|
515
|
-
createdAt: Date.now(),
|
|
516
|
-
})
|
|
517
|
-
.onConflictDoUpdate({
|
|
518
|
-
target: [
|
|
519
|
-
skippedSenderKeys.groupId,
|
|
520
|
-
skippedSenderKeys.senderId,
|
|
521
|
-
skippedSenderKeys.senderDeviceId,
|
|
522
|
-
skippedSenderKeys.chainIndex,
|
|
523
|
-
],
|
|
524
|
-
set: { cipherKey: messageKey.cipherKey, iv: messageKey.iv },
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
async getSkippedSenderKey(groupId, senderId, senderDeviceId, chainIndex) {
|
|
528
|
-
const { getDrizzle, skippedSenderKeys, eq, and } = await import('./db.js');
|
|
529
|
-
const db = await getDrizzle();
|
|
530
|
-
const results = await db
|
|
531
|
-
.select({ iv: skippedSenderKeys.iv, cipherKey: skippedSenderKeys.cipherKey })
|
|
532
|
-
.from(skippedSenderKeys)
|
|
533
|
-
.where(and(eq(skippedSenderKeys.groupId, groupId), eq(skippedSenderKeys.senderId, senderId), eq(skippedSenderKeys.senderDeviceId, senderDeviceId), eq(skippedSenderKeys.chainIndex, chainIndex)))
|
|
534
|
-
.limit(1);
|
|
535
|
-
const row = results[0];
|
|
536
|
-
return row ? { iv: row.iv, cipherKey: row.cipherKey } : null;
|
|
537
|
-
}
|
|
538
|
-
async deleteSkippedSenderKey(groupId, senderId, senderDeviceId, chainIndex) {
|
|
539
|
-
const { getDrizzle, skippedSenderKeys, eq, and } = await import('./db.js');
|
|
540
|
-
const db = await getDrizzle();
|
|
541
|
-
await db
|
|
542
|
-
.delete(skippedSenderKeys)
|
|
543
|
-
.where(and(eq(skippedSenderKeys.groupId, groupId), eq(skippedSenderKeys.senderId, senderId), eq(skippedSenderKeys.senderDeviceId, senderDeviceId), eq(skippedSenderKeys.chainIndex, chainIndex)));
|
|
544
|
-
}
|
|
545
|
-
async countSkippedSenderKeys(groupId, senderId, senderDeviceId) {
|
|
546
|
-
const { getDrizzle, skippedSenderKeys, eq, and, count } = await import('./db.js');
|
|
547
|
-
const db = await getDrizzle();
|
|
548
|
-
const results = await db
|
|
549
|
-
.select({ count: count() })
|
|
550
|
-
.from(skippedSenderKeys)
|
|
551
|
-
.where(and(eq(skippedSenderKeys.groupId, groupId), eq(skippedSenderKeys.senderId, senderId), eq(skippedSenderKeys.senderDeviceId, senderDeviceId)));
|
|
552
|
-
return results[0]?.count ?? 0;
|
|
553
|
-
}
|
|
554
|
-
/**
|
|
555
|
-
* Evict the oldest skipped keys for a sender, so a peer cannot grow this
|
|
556
|
-
* table without bound by sending messages that skip ever further ahead.
|
|
557
|
-
*
|
|
558
|
-
* Oldest by chain index, not by insertion time. Index order is the order the
|
|
559
|
-
* sender ratcheted. The lowest index is therefore the key least likely to
|
|
560
|
-
* still have a message in flight behind it.
|
|
561
|
-
*/
|
|
562
|
-
async deleteOldestSkippedSenderKeys(groupId, senderId, senderDeviceId, count) {
|
|
563
|
-
if (count <= 0)
|
|
564
|
-
return 0;
|
|
565
|
-
const { getDrizzle, skippedSenderKeys, eq, and, asc, inArray } = await import('./db.js');
|
|
566
|
-
const db = await getDrizzle();
|
|
567
|
-
const oldest = await db
|
|
568
|
-
.select({ chainIndex: skippedSenderKeys.chainIndex })
|
|
569
|
-
.from(skippedSenderKeys)
|
|
570
|
-
.where(and(eq(skippedSenderKeys.groupId, groupId), eq(skippedSenderKeys.senderId, senderId), eq(skippedSenderKeys.senderDeviceId, senderDeviceId)))
|
|
571
|
-
.orderBy(asc(skippedSenderKeys.chainIndex))
|
|
572
|
-
.limit(count);
|
|
573
|
-
if (oldest.length === 0)
|
|
574
|
-
return 0;
|
|
575
|
-
await db.delete(skippedSenderKeys).where(and(eq(skippedSenderKeys.groupId, groupId), eq(skippedSenderKeys.senderId, senderId), eq(skippedSenderKeys.senderDeviceId, senderDeviceId), inArray(skippedSenderKeys.chainIndex, oldest.map((row) => row.chainIndex))));
|
|
576
|
-
return oldest.length;
|
|
577
|
-
}
|
|
578
|
-
// ============================================================================
|
|
579
|
-
// Message Record Storage (SESAME Retry Request Support)
|
|
580
|
-
// ============================================================================
|
|
581
|
-
// Retry records are indexed by the client timestamp assigned before encryption.
|
|
582
|
-
// The primary lookup method is getMessageRecord(sessionId, timestamp).
|
|
583
|
-
async storeMessageRecord(record) {
|
|
584
|
-
await this.storage.storeMessageRecord(record);
|
|
585
|
-
}
|
|
586
|
-
/**
|
|
587
|
-
* Get a message record by session and timestamp (PRIMARY method).
|
|
588
|
-
* Per Signal Protocol, messages are identified by client timestamp.
|
|
589
|
-
*/
|
|
590
|
-
async getMessageRecord(sessionId, timestamp) {
|
|
591
|
-
return await this.storage.getMessageRecord(sessionId, timestamp);
|
|
592
|
-
}
|
|
593
|
-
/**
|
|
594
|
-
* Delete a message record by session and timestamp (PRIMARY method).
|
|
595
|
-
* Called when processing delivery receipts to clean up confirmed messages.
|
|
596
|
-
*/
|
|
597
|
-
async deleteMessageRecord(sessionId, timestamp) {
|
|
598
|
-
await this.storage.deleteMessageRecord(sessionId, timestamp);
|
|
599
|
-
}
|
|
600
|
-
async deleteExpiredMessageRecords(maxAgeMs) {
|
|
601
|
-
return await this.storage.deleteExpiredMessageRecords(maxAgeMs);
|
|
602
|
-
}
|
|
603
|
-
async clearAllMessageRecords() {
|
|
604
|
-
return await this.storage.clearAllMessageRecords();
|
|
605
|
-
}
|
|
606
|
-
async deleteMessageRecordsForSession(sessionId) {
|
|
607
|
-
return await this.storage.deleteMessageRecordsForSession(sessionId);
|
|
608
|
-
}
|
|
609
|
-
// ============================================================================
|
|
610
|
-
// Key Recovery Methods (Bug #7 - Identifier Collision Recovery)
|
|
611
|
-
// ============================================================================
|
|
612
|
-
/**
|
|
613
|
-
* Get the maximum EC signed prekey ID in storage.
|
|
614
|
-
* Used to generate new keyIds that will not collide with existing ones.
|
|
615
|
-
*
|
|
616
|
-
* @returns The highest EC signed prekey ID, or 0 if none exist
|
|
617
|
-
*/
|
|
618
|
-
async getEcSignedPreKeyMaxId(identityType) {
|
|
619
|
-
return await this.storage.getEcSignedPreKeyMaxId(identityType);
|
|
620
|
-
}
|
|
621
|
-
/**
|
|
622
|
-
* Get the maximum Kyber prekey ID in storage.
|
|
623
|
-
* Used to generate new keyIds that will not collide with existing ones.
|
|
624
|
-
*
|
|
625
|
-
* @returns The highest Kyber prekey ID, or 0 if none exist
|
|
626
|
-
*/
|
|
627
|
-
async getKyberPreKeyMaxId(identityType) {
|
|
628
|
-
return await this.storage.getKyberPreKeyMaxId(identityType);
|
|
629
|
-
}
|
|
630
|
-
/**
|
|
631
|
-
* Delete all prekeys from storage (preserves identity keys and sessions).
|
|
632
|
-
* Used for recovery from identifier collision per PQXDH §4.13.
|
|
633
|
-
*
|
|
634
|
-
* @returns Counts of deleted prekeys by type
|
|
635
|
-
*/
|
|
636
|
-
async deleteAllPreKeys(identityType) {
|
|
637
|
-
return await this.storage.deleteAllPreKeys(identityType);
|
|
638
|
-
}
|
|
639
|
-
/**
|
|
640
|
-
* Clear all sessions from storage.
|
|
641
|
-
* Used during force key reset.
|
|
642
|
-
*/
|
|
643
|
-
async clearAllSessions() {
|
|
644
|
-
return await this.storage.clearAllSessions();
|
|
645
|
-
}
|
|
646
|
-
/**
|
|
647
|
-
* Get detailed statistics about stored data.
|
|
648
|
-
*/
|
|
649
|
-
async getDetailedStats() {
|
|
650
|
-
return await this.storage.getDetailedStats();
|
|
64
|
+
close() {
|
|
65
|
+
return expoStoreDatabase(this).close();
|
|
651
66
|
}
|
|
652
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Open the store. On first use it creates the database key in the vault, then
|
|
70
|
+
* the database file. With `encryptionAtRest: false` it does not use the vault.
|
|
71
|
+
*
|
|
72
|
+
* @throws EncryptionError with `LOCAL_STORE_KEY_LOST` when the database file
|
|
73
|
+
* exists and the vault holds no key for it. Restore the vault entry, or call
|
|
74
|
+
* {@link resetExpoStore}.
|
|
75
|
+
* @throws EncryptionError with `KEY_STORAGE_ERROR` when the vault fails or
|
|
76
|
+
* holds a key of the wrong size, when the key does not open the file, when
|
|
77
|
+
* the file was created with the other `encryptionAtRest` setting, when the
|
|
78
|
+
* binding has no cipher, or when another connection holds the file.
|
|
79
|
+
* @throws EncryptionError with `INVALID_STATE` when the name is not valid,
|
|
80
|
+
* when a store of this process holds the name, or when a newer SDK wrote
|
|
81
|
+
* the file.
|
|
82
|
+
*/
|
|
83
|
+
export function expoStore(options = {}) {
|
|
84
|
+
return ExpoSignalProtocolStore.open(options);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Delete the database file, then create a new key, and return the open, empty
|
|
88
|
+
* store. This is the only way to open a store whose key is lost.
|
|
89
|
+
*
|
|
90
|
+
* @throws EncryptionError with `INVALID_STATE` when the name is not valid, or
|
|
91
|
+
* when a store of this process holds the name. Close that store first.
|
|
92
|
+
*/
|
|
93
|
+
export function resetExpoStore(options = {}) {
|
|
94
|
+
return ExpoSignalProtocolStore.reset(options);
|
|
95
|
+
}
|
|
653
96
|
//# sourceMappingURL=adapter.js.map
|