@open-e2ee/signal-protocol-sdk 8.1.0 → 9.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 +13 -31
- package/ARCHITECTURE.md +5 -7
- package/CHANGELOG.md +258 -0
- package/README.md +36 -48
- package/SECURITY.md +2 -2
- package/client/README.md +9 -0
- package/device/README.md +16 -7
- package/dist/client/client.d.ts +25 -16
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +115 -95
- package/dist/client/client.js.map +1 -1
- package/dist/client/config.d.ts +10 -17
- package/dist/client/config.d.ts.map +1 -1
- package/dist/client/config.js.map +1 -1
- package/dist/client/event-hooks.js +27 -0
- package/dist/client/event-hooks.js.map +1 -1
- package/dist/client/group-outbox.d.ts +31 -1
- package/dist/client/group-outbox.d.ts.map +1 -1
- package/dist/client/group-outbox.js +67 -58
- package/dist/client/group-outbox.js.map +1 -1
- package/dist/client/group-receive-authorization.d.ts +5 -0
- package/dist/client/group-receive-authorization.d.ts.map +1 -0
- package/dist/client/group-receive-authorization.js +32 -0
- package/dist/client/group-receive-authorization.js.map +1 -0
- package/dist/client/group-sender-key-operations.d.ts +15 -0
- package/dist/client/group-sender-key-operations.d.ts.map +1 -0
- package/dist/client/group-sender-key-operations.js +31 -0
- package/dist/client/group-sender-key-operations.js.map +1 -0
- package/dist/client/groups.d.ts +3 -1
- package/dist/client/groups.d.ts.map +1 -1
- package/dist/client/groups.js +5 -2
- package/dist/client/groups.js.map +1 -1
- package/dist/client/hosted-anonymous-delivery.d.ts +9 -1
- package/dist/client/hosted-anonymous-delivery.d.ts.map +1 -1
- package/dist/client/hosted-anonymous-delivery.js +61 -22
- package/dist/client/hosted-anonymous-delivery.js.map +1 -1
- package/dist/client/hosted-transport.d.ts +7 -0
- package/dist/client/hosted-transport.d.ts.map +1 -1
- package/dist/client/hosted-transport.js +44 -6
- package/dist/client/hosted-transport.js.map +1 -1
- package/dist/client/key-rotation.d.ts.map +1 -1
- package/dist/client/key-rotation.js +2 -4
- package/dist/client/key-rotation.js.map +1 -1
- package/dist/client/prekeys.d.ts.map +1 -1
- package/dist/client/prekeys.js +1 -1
- package/dist/client/prekeys.js.map +1 -1
- package/dist/client/relay-device-refusal.d.ts +32 -0
- package/dist/client/relay-device-refusal.d.ts.map +1 -0
- package/dist/client/relay-device-refusal.js +36 -0
- package/dist/client/relay-device-refusal.js.map +1 -0
- package/dist/client/relay-subscription.d.ts +2 -0
- package/dist/client/relay-subscription.d.ts.map +1 -1
- package/dist/client/relay-subscription.js +3 -1
- package/dist/client/relay-subscription.js.map +1 -1
- package/dist/client/relay-work.d.ts +26 -0
- package/dist/client/relay-work.d.ts.map +1 -1
- package/dist/client/relay-work.js +37 -0
- package/dist/client/relay-work.js.map +1 -1
- package/dist/client/sealed-sender.d.ts.map +1 -1
- package/dist/client/sealed-sender.js +12 -17
- package/dist/client/sealed-sender.js.map +1 -1
- package/dist/client/sender-key-distribution.d.ts.map +1 -1
- package/dist/client/sender-key-distribution.js +4 -1
- package/dist/client/sender-key-distribution.js.map +1 -1
- package/dist/client/sessions.d.ts.map +1 -1
- package/dist/client/sessions.js +2 -4
- package/dist/client/sessions.js.map +1 -1
- package/dist/client/signal-service-cipher.d.ts +94 -6
- package/dist/client/signal-service-cipher.d.ts.map +1 -1
- package/dist/client/signal-service-cipher.js +483 -184
- package/dist/client/signal-service-cipher.js.map +1 -1
- package/dist/client/types.d.ts +7 -0
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/types.js.map +1 -1
- package/dist/index.d.ts +27 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -17
- package/dist/index.js.map +1 -1
- package/dist/internal/crypto/pq/kyber.d.ts +1 -1
- package/dist/internal/crypto/pq/kyber.js +1 -1
- package/dist/internal/encoding/proto/sender-key-message.d.ts +2 -2
- package/dist/internal/encoding/proto/sender-key-message.d.ts.map +1 -1
- package/dist/internal/encoding/proto/sender-key-message.js +5 -2
- package/dist/internal/encoding/proto/sender-key-message.js.map +1 -1
- package/dist/internal/groups/manager.d.ts.map +1 -1
- package/dist/internal/groups/manager.js +5 -2
- package/dist/internal/groups/manager.js.map +1 -1
- package/dist/internal/groups/wire.d.ts +0 -2
- package/dist/internal/groups/wire.d.ts.map +1 -1
- package/dist/internal/groups/wire.js +0 -6
- package/dist/internal/groups/wire.js.map +1 -1
- package/dist/internal/manager/manager.d.ts +8 -7
- package/dist/internal/manager/manager.d.ts.map +1 -1
- package/dist/internal/manager/manager.js +34 -37
- package/dist/internal/manager/manager.js.map +1 -1
- package/dist/internal/protocol/double-ratchet/ratchet.d.ts +0 -17
- package/dist/internal/protocol/double-ratchet/ratchet.d.ts.map +1 -1
- package/dist/internal/protocol/double-ratchet/ratchet.js +0 -4
- package/dist/internal/protocol/double-ratchet/ratchet.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/certificate.d.ts +2 -32
- package/dist/internal/protocol/sealed-sender/certificate.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/certificate.js +4 -85
- package/dist/internal/protocol/sealed-sender/certificate.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/index.d.ts +2 -2
- package/dist/internal/protocol/sealed-sender/index.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/index.js +2 -6
- package/dist/internal/protocol/sealed-sender/index.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/proto/index.d.ts +0 -19
- package/dist/internal/protocol/sealed-sender/proto/index.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/proto/index.js +1 -48
- package/dist/internal/protocol/sealed-sender/proto/index.js.map +1 -1
- package/dist/internal/protocol/sender-keys/manager.d.ts +9 -13
- package/dist/internal/protocol/sender-keys/manager.d.ts.map +1 -1
- package/dist/internal/protocol/sender-keys/manager.js +90 -95
- package/dist/internal/protocol/sender-keys/manager.js.map +1 -1
- package/dist/internal/protocol/spqr/index.d.ts +1 -1
- package/dist/internal/protocol/spqr/index.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/index.js +2 -2
- package/dist/internal/protocol/spqr/index.js.map +1 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/incremental-kem.d.ts +0 -2
- package/dist/internal/protocol/spqr/ml-kem-braid/incremental-kem.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/incremental-kem.js +4 -12
- package/dist/internal/protocol/spqr/ml-kem-braid/incremental-kem.js.map +1 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/codec.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/codec.js +1 -3
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/codec.js.map +1 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/types.d.ts +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/types.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/serialize.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/serialize.js +1 -4
- package/dist/internal/protocol/spqr/serialize.js.map +1 -1
- package/dist/internal/protocol/spqr/spqr.d.ts +1 -1
- package/dist/internal/protocol/spqr/spqr.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/spqr.js +2 -3
- package/dist/internal/protocol/spqr/spqr.js.map +1 -1
- package/dist/internal/protocol/x3dh/x3dh.d.ts.map +1 -1
- package/dist/internal/protocol/x3dh/x3dh.js +1 -1
- package/dist/internal/protocol/x3dh/x3dh.js.map +1 -1
- package/dist/internal/protocol/zk/credentials/credentials.d.ts +3 -54
- package/dist/internal/protocol/zk/credentials/credentials.d.ts.map +1 -1
- package/dist/internal/protocol/zk/credentials/credentials.js +4 -91
- package/dist/internal/protocol/zk/credentials/credentials.js.map +1 -1
- package/dist/internal/protocol/zk/credentials/endorsements.d.ts +3 -64
- package/dist/internal/protocol/zk/credentials/endorsements.d.ts.map +1 -1
- package/dist/internal/protocol/zk/credentials/endorsements.js +4 -134
- package/dist/internal/protocol/zk/credentials/endorsements.js.map +1 -1
- package/dist/internal/protocol/zk/credentials/index.d.ts +3 -3
- package/dist/internal/protocol/zk/credentials/index.d.ts.map +1 -1
- package/dist/internal/protocol/zk/credentials/index.js +3 -3
- package/dist/internal/protocol/zk/credentials/index.js.map +1 -1
- package/dist/internal/protocol/zk/credentials/issuance.d.ts +3 -26
- package/dist/internal/protocol/zk/credentials/issuance.d.ts.map +1 -1
- package/dist/internal/protocol/zk/credentials/issuance.js +3 -80
- package/dist/internal/protocol/zk/credentials/issuance.js.map +1 -1
- package/dist/internal/protocol/zk/credentials/presentation.d.ts +4 -73
- package/dist/internal/protocol/zk/credentials/presentation.d.ts.map +1 -1
- package/dist/internal/protocol/zk/credentials/presentation.js +4 -152
- package/dist/internal/protocol/zk/credentials/presentation.js.map +1 -1
- package/dist/internal/protocol/zk/groups/auth-credential.d.ts +1 -61
- package/dist/internal/protocol/zk/groups/auth-credential.d.ts.map +1 -1
- package/dist/internal/protocol/zk/groups/auth-credential.js +2 -196
- package/dist/internal/protocol/zk/groups/auth-credential.js.map +1 -1
- package/dist/internal/protocol/zk/groups/group-send-endorsement.d.ts +1 -86
- package/dist/internal/protocol/zk/groups/group-send-endorsement.d.ts.map +1 -1
- package/dist/internal/protocol/zk/groups/group-send-endorsement.js +1 -152
- package/dist/internal/protocol/zk/groups/group-send-endorsement.js.map +1 -1
- package/dist/internal/protocol/zk/groups/index.d.ts +4 -4
- package/dist/internal/protocol/zk/groups/index.d.ts.map +1 -1
- package/dist/internal/protocol/zk/groups/index.js +4 -4
- package/dist/internal/protocol/zk/groups/index.js.map +1 -1
- package/dist/internal/protocol/zk/groups/profile-key-credential.d.ts +2 -57
- package/dist/internal/protocol/zk/groups/profile-key-credential.d.ts.map +1 -1
- package/dist/internal/protocol/zk/groups/profile-key-credential.js +2 -174
- package/dist/internal/protocol/zk/groups/profile-key-credential.js.map +1 -1
- package/dist/internal/protocol/zk/groups/server-params.d.ts +8 -72
- package/dist/internal/protocol/zk/groups/server-params.d.ts.map +1 -1
- package/dist/internal/protocol/zk/groups/server-params.js +8 -108
- package/dist/internal/protocol/zk/groups/server-params.js.map +1 -1
- package/dist/internal/protocol/zk/proofs/sign.d.ts +1 -2
- package/dist/internal/protocol/zk/proofs/sign.d.ts.map +1 -1
- package/dist/internal/protocol/zk/proofs/sign.js +2 -11
- package/dist/internal/protocol/zk/proofs/sign.js.map +1 -1
- package/dist/internal/sesame/device-registry.d.ts +24 -4
- package/dist/internal/sesame/device-registry.d.ts.map +1 -1
- package/dist/internal/sesame/device-registry.js +55 -28
- package/dist/internal/sesame/device-registry.js.map +1 -1
- package/dist/internal/sesame/manager.d.ts +79 -11
- package/dist/internal/sesame/manager.d.ts.map +1 -1
- package/dist/internal/sesame/manager.js +381 -280
- package/dist/internal/sesame/manager.js.map +1 -1
- package/dist/internal/session/cipher.d.ts +0 -5
- package/dist/internal/session/cipher.d.ts.map +1 -1
- package/dist/internal/session/cipher.js +3 -9
- package/dist/internal/session/cipher.js.map +1 -1
- package/dist/internal/session/ratchet.d.ts.map +1 -1
- package/dist/internal/session/ratchet.js +0 -2
- package/dist/internal/session/ratchet.js.map +1 -1
- package/dist/internal/session/record-locks.d.ts +46 -0
- package/dist/internal/session/record-locks.d.ts.map +1 -0
- package/dist/internal/session/record-locks.js +72 -0
- package/dist/internal/session/record-locks.js.map +1 -0
- package/dist/local/store/expo/adapter.d.ts +8 -2
- package/dist/local/store/expo/adapter.d.ts.map +1 -1
- package/dist/local/store/expo/adapter.js +24 -3
- package/dist/local/store/expo/adapter.js.map +1 -1
- package/dist/local/store/expo/driver.d.ts +7 -0
- package/dist/local/store/expo/driver.d.ts.map +1 -1
- package/dist/local/store/expo/driver.js +16 -0
- package/dist/local/store/expo/driver.js.map +1 -1
- package/dist/local/store/key-value/adapter.d.ts +3 -3
- package/dist/local/store/key-value/adapter.d.ts.map +1 -1
- package/dist/local/store/key-value/adapter.js +91 -53
- package/dist/local/store/key-value/adapter.js.map +1 -1
- package/dist/local/store/key-value/backend-conformance.d.ts.map +1 -1
- package/dist/local/store/key-value/backend-conformance.js +25 -0
- package/dist/local/store/key-value/backend-conformance.js.map +1 -1
- package/dist/local/store/key-value/batch.d.ts +3 -1
- package/dist/local/store/key-value/batch.d.ts.map +1 -1
- package/dist/local/store/key-value/batch.js +9 -1
- package/dist/local/store/key-value/batch.js.map +1 -1
- package/dist/local/store/key-value/storage.d.ts +6 -0
- package/dist/local/store/key-value/storage.d.ts.map +1 -1
- package/dist/local/store/key-value/transactional-backend.d.ts +1 -1
- package/dist/local/store/key-value/transactional-backend.js +1 -1
- package/dist/local/store/memory/adapter.d.ts +13 -3
- package/dist/local/store/memory/adapter.d.ts.map +1 -1
- package/dist/local/store/memory/adapter.js +122 -73
- package/dist/local/store/memory/adapter.js.map +1 -1
- package/dist/local/store/reliability.d.ts +16 -0
- package/dist/local/store/reliability.d.ts.map +1 -1
- package/dist/local/store/reliability.js +58 -28
- package/dist/local/store/reliability.js.map +1 -1
- package/dist/local/store/sqlite/migrations.d.ts.map +1 -1
- package/dist/local/store/sqlite/migrations.js +18 -0
- package/dist/local/store/sqlite/migrations.js.map +1 -1
- package/dist/local/store/sqlite/models/skipped-sender-key.d.ts +3 -3
- package/dist/local/store/sqlite/models/skipped-sender-key.d.ts.map +1 -1
- package/dist/local/store/sqlite/models/skipped-sender-key.js +13 -17
- package/dist/local/store/sqlite/models/skipped-sender-key.js.map +1 -1
- package/dist/local/store/sqlite/store.d.ts +3 -3
- package/dist/local/store/sqlite/store.d.ts.map +1 -1
- package/dist/local/store/sqlite/store.js +53 -23
- package/dist/local/store/sqlite/store.js.map +1 -1
- package/dist/local/store/web/adapter.d.ts +3 -3
- package/dist/local/store/web/adapter.d.ts.map +1 -1
- package/dist/local/store/web/adapter.js +122 -73
- package/dist/local/store/web/adapter.js.map +1 -1
- package/dist/local/vault/electron-safe-storage.d.ts.map +1 -1
- package/dist/local/vault/electron-safe-storage.js +15 -2
- package/dist/local/vault/electron-safe-storage.js.map +1 -1
- package/dist/profile/index.d.ts +2 -1
- package/dist/profile/index.d.ts.map +1 -1
- package/dist/profile/index.js +2 -1
- package/dist/profile/index.js.map +1 -1
- package/dist/profile/own-profile-key.d.ts +42 -0
- package/dist/profile/own-profile-key.d.ts.map +1 -0
- package/dist/profile/own-profile-key.js +64 -0
- package/dist/profile/own-profile-key.js.map +1 -0
- package/dist/profile/profile-key.d.ts +1 -34
- package/dist/profile/profile-key.d.ts.map +1 -1
- package/dist/profile/profile-key.js +3 -63
- package/dist/profile/profile-key.js.map +1 -1
- package/dist/profile/update-service.js +1 -1
- package/dist/profile/update-service.js.map +1 -1
- package/dist/remote/relay/index.d.ts +4 -7
- package/dist/remote/relay/index.d.ts.map +1 -1
- package/dist/remote/relay/index.js +5 -7
- package/dist/remote/relay/index.js.map +1 -1
- package/dist/remote/relay/types.d.ts +3 -3
- package/dist/types/api.d.ts +29 -8
- package/dist/types/api.d.ts.map +1 -1
- package/dist/username/link.d.ts.map +1 -1
- package/dist/username/link.js +1 -5
- package/dist/username/link.js.map +1 -1
- package/dist/utils/bounded-fan-out.d.ts +99 -0
- package/dist/utils/bounded-fan-out.d.ts.map +1 -0
- package/dist/utils/bounded-fan-out.js +180 -0
- package/dist/utils/bounded-fan-out.js.map +1 -0
- package/dist/utils/keyed-lock.d.ts +16 -0
- package/dist/utils/keyed-lock.d.ts.map +1 -0
- package/dist/utils/keyed-lock.js +39 -0
- package/dist/utils/keyed-lock.js.map +1 -0
- package/dist/versions.d.ts +3 -3
- package/dist/versions.js +3 -3
- package/dist/zk/credentials.d.ts +2 -2
- package/dist/zk/credentials.js +2 -2
- package/dist/zk/groups.d.ts +3 -3
- package/dist/zk/groups.d.ts.map +1 -1
- package/dist/zk/groups.js +3 -3
- package/dist/zk/groups.js.map +1 -1
- package/docs/ASSURANCE.md +69 -28
- package/docs/CLIENT_COMPOSITION.md +9 -3
- package/docs/DEVIATIONS.md +45 -27
- package/docs/GETTING_STARTED.md +42 -320
- package/docs/INTERFACES.md +7 -7
- package/docs/PACKAGE_SURFACE.md +14 -16
- package/docs/RECIPES.md +6 -112
- package/groups/README.md +9 -1
- package/hooks/README.md +11 -2
- package/local/store/README.md +26 -6
- package/local/store/expo/README.md +18 -5
- package/local/store/key-value/README.md +5 -3
- package/local/store/node/README.md +2 -1
- package/local/store/web-sqlite/README.md +28 -8
- package/local/vault/README.md +21 -2
- package/package.json +1 -30
- package/remote/README.md +12 -78
- package/remote/object-store/convex-r2/README.md +20 -42
- package/remote/relay/README.md +21 -18
- package/zk/README.md +6 -7
- package/dist/client/dual-store.d.ts +0 -70
- package/dist/client/dual-store.d.ts.map +0 -1
- package/dist/client/dual-store.js +0 -123
- package/dist/client/dual-store.js.map +0 -1
- package/dist/client/multi-device.d.ts +0 -74
- package/dist/client/multi-device.d.ts.map +0 -1
- package/dist/client/multi-device.js +0 -105
- package/dist/client/multi-device.js.map +0 -1
- package/dist/groups/server.d.ts +0 -10
- package/dist/groups/server.d.ts.map +0 -1
- package/dist/groups/server.js +0 -6
- package/dist/groups/server.js.map +0 -1
- package/dist/internal/encoding/index.d.ts +0 -2
- package/dist/internal/encoding/index.d.ts.map +0 -1
- package/dist/internal/encoding/index.js +0 -2
- package/dist/internal/encoding/index.js.map +0 -1
- package/dist/internal/groups/server-engine.d.ts +0 -118
- package/dist/internal/groups/server-engine.d.ts.map +0 -1
- package/dist/internal/groups/server-engine.js +0 -1268
- package/dist/internal/groups/server-engine.js.map +0 -1
- package/dist/internal/protocol/index.d.ts +0 -24
- package/dist/internal/protocol/index.d.ts.map +0 -1
- package/dist/internal/protocol/index.js +0 -9
- package/dist/internal/protocol/index.js.map +0 -1
- package/dist/internal/protocol/sealed-sender/trust-root.d.ts +0 -56
- package/dist/internal/protocol/sealed-sender/trust-root.d.ts.map +0 -1
- package/dist/internal/protocol/sealed-sender/trust-root.js +0 -90
- package/dist/internal/protocol/sealed-sender/trust-root.js.map +0 -1
- package/dist/internal/protocol/triple-ratchet/index.d.ts +0 -21
- package/dist/internal/protocol/triple-ratchet/index.d.ts.map +0 -1
- package/dist/internal/protocol/triple-ratchet/index.js +0 -19
- package/dist/internal/protocol/triple-ratchet/index.js.map +0 -1
- package/dist/internal/protocol/triple-ratchet/ratchet.d.ts +0 -233
- package/dist/internal/protocol/triple-ratchet/ratchet.d.ts.map +0 -1
- package/dist/internal/protocol/triple-ratchet/ratchet.js +0 -254
- package/dist/internal/protocol/triple-ratchet/ratchet.js.map +0 -1
- package/dist/internal/protocol/zk/proofs/index.d.ts +0 -13
- package/dist/internal/protocol/zk/proofs/index.d.ts.map +0 -1
- package/dist/internal/protocol/zk/proofs/index.js +0 -7
- package/dist/internal/protocol/zk/proofs/index.js.map +0 -1
- package/dist/local/store/sqlite/index.d.ts +0 -20
- package/dist/local/store/sqlite/index.d.ts.map +0 -1
- package/dist/local/store/sqlite/index.js +0 -18
- package/dist/local/store/sqlite/index.js.map +0 -1
- package/dist/remote/object-store/convex-r2/server/index.d.ts +0 -2
- package/dist/remote/object-store/convex-r2/server/index.d.ts.map +0 -1
- package/dist/remote/object-store/convex-r2/server/index.js +0 -2
- package/dist/remote/object-store/convex-r2/server/index.js.map +0 -1
- package/dist/remote/object-store/convex-r2/server.d.ts +0 -129
- package/dist/remote/object-store/convex-r2/server.d.ts.map +0 -1
- package/dist/remote/object-store/convex-r2/server.js +0 -244
- package/dist/remote/object-store/convex-r2/server.js.map +0 -1
- package/dist/remote/relay/memory/adapter.d.ts +0 -252
- package/dist/remote/relay/memory/adapter.d.ts.map +0 -1
- package/dist/remote/relay/memory/adapter.js +0 -1058
- package/dist/remote/relay/memory/adapter.js.map +0 -1
- package/dist/remote/relay/memory/failures.d.ts +0 -58
- package/dist/remote/relay/memory/failures.d.ts.map +0 -1
- package/dist/remote/relay/memory/failures.js +0 -124
- package/dist/remote/relay/memory/failures.js.map +0 -1
- package/dist/remote/relay/memory/group-server.d.ts +0 -13
- package/dist/remote/relay/memory/group-server.d.ts.map +0 -1
- package/dist/remote/relay/memory/group-server.js +0 -19
- package/dist/remote/relay/memory/group-server.js.map +0 -1
- package/dist/remote/relay/memory/index.d.ts +0 -11
- package/dist/remote/relay/memory/index.d.ts.map +0 -1
- package/dist/remote/relay/memory/index.js +0 -7
- package/dist/remote/relay/memory/index.js.map +0 -1
- package/examples/browser/README.md +0 -35
- package/examples/browser/index.html +0 -27
- package/examples/browser/src/exchange.ts +0 -69
- package/examples/browser/src/main.ts +0 -63
- package/examples/browser/src/style.css +0 -9
- package/examples/browser/src/worker.ts +0 -10
- package/examples/browser/vite.config.ts +0 -9
- package/remote/relay/memory/README.md +0 -72
- package/scripts/oe-groups.mjs +0 -166
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The in-process locks that order writes of one remote device's records.
|
|
3
|
+
*
|
|
4
|
+
* The session lock orders every write of the session under one protocol
|
|
5
|
+
* address. The user lock orders every read-modify-write of one user's SESAME
|
|
6
|
+
* user record and device records. The device-list sync lock orders the
|
|
7
|
+
* device-list syncs of one user. The store object keys each lock, so every
|
|
8
|
+
* protocol manager, SESAME manager, and store sweep over one store shares
|
|
9
|
+
* them.
|
|
10
|
+
*
|
|
11
|
+
* Take the device-list sync lock first, the session lock second, and the
|
|
12
|
+
* user lock last. Only a device-list sync takes the device-list sync lock. An
|
|
13
|
+
* operation that holds a user lock must not take a session lock. No lock is
|
|
14
|
+
* reentrant: an operation that takes a lock that it holds waits for itself.
|
|
15
|
+
* A session lock or a device-list sync lock that waits longer than its
|
|
16
|
+
* timeout rejects.
|
|
17
|
+
*
|
|
18
|
+
* The locks order one JavaScript process only. They do not order two browser
|
|
19
|
+
* tabs, two workers, or two processes that share one store.
|
|
20
|
+
*/
|
|
21
|
+
import AsyncLock from 'async-lock';
|
|
22
|
+
import { ProtocolAddress } from '../../types/address.js';
|
|
23
|
+
import { createKeyedLocks, withKeyedLock } from '../../utils/keyed-lock.js';
|
|
24
|
+
const sessionLocks = new WeakMap();
|
|
25
|
+
const userRecordLocks = createKeyedLocks();
|
|
26
|
+
const deviceListSyncLocks = new WeakMap();
|
|
27
|
+
function asyncLockFor(locks, store) {
|
|
28
|
+
let lock = locks.get(store);
|
|
29
|
+
if (!lock) {
|
|
30
|
+
lock = new AsyncLock({
|
|
31
|
+
timeout: 5000, // 5 second timeout prevents deadlocks
|
|
32
|
+
maxPending: 1000, // Max 1000 queued operations per key
|
|
33
|
+
});
|
|
34
|
+
locks.set(store, lock);
|
|
35
|
+
}
|
|
36
|
+
return lock;
|
|
37
|
+
}
|
|
38
|
+
/** The session lock of `store`. Every caller with the same store gets one lock. */
|
|
39
|
+
export function sessionLockFor(store) {
|
|
40
|
+
return asyncLockFor(sessionLocks, store);
|
|
41
|
+
}
|
|
42
|
+
/** The session lock key of one protocol address. */
|
|
43
|
+
export function sessionLockKey(address) {
|
|
44
|
+
return `session:${ProtocolAddress.toString(address)}`;
|
|
45
|
+
}
|
|
46
|
+
/** Run `operation` under the session lock of `address`. */
|
|
47
|
+
export function withSessionLock(store, address, operation) {
|
|
48
|
+
return sessionLockFor(store).acquire(sessionLockKey(address), operation);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Run a read-modify-write of one user's SESAME records under the user lock.
|
|
52
|
+
* The operation must not write a session that it read before the lock.
|
|
53
|
+
*/
|
|
54
|
+
export function withUserRecordLock(store, userId, operation) {
|
|
55
|
+
return withKeyedLock(userRecordLocks, store, userId, operation);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Run a read-modify-write of one device record and its session under the
|
|
59
|
+
* session lock of the device and then the user lock of its user.
|
|
60
|
+
*/
|
|
61
|
+
export function withDeviceRecordLocks(store, userId, deviceId, operation) {
|
|
62
|
+
return withSessionLock(store, { userId, deviceId }, () => withUserRecordLock(store, userId, operation));
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Run one device-list sync of `userId` under the device-list sync lock, so
|
|
66
|
+
* two syncs of one user do not interleave. The operation can take the session
|
|
67
|
+
* lock and the user lock. Syncs of different users run in parallel.
|
|
68
|
+
*/
|
|
69
|
+
export function withDeviceListSyncLock(store, userId, operation) {
|
|
70
|
+
return asyncLockFor(deviceListSyncLocks, store).acquire(`device-list:${userId}`, operation);
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=record-locks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-locks.js","sourceRoot":"","sources":["../../../internal/session/record-locks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAIzE,MAAM,YAAY,GAAG,IAAI,OAAO,EAAqB,CAAC;AACtD,MAAM,eAAe,GAAG,gBAAgB,EAAE,CAAC;AAC3C,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAAqB,CAAC;AAE7D,SAAS,YAAY,CAAC,KAAiC,EAAE,KAAa;IACpE,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC5B,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,IAAI,GAAG,IAAI,SAAS,CAAC;YACnB,OAAO,EAAE,IAAI,EAAE,sCAAsC;YACrD,UAAU,EAAE,IAAI,EAAE,qCAAqC;SACxD,CAAC,CAAC;QACH,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAO,YAAY,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;AAC3C,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,cAAc,CAAC,OAAwB;IACrD,OAAO,WAAW,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;AACxD,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,eAAe,CAC7B,KAAa,EACb,OAAwB,EACxB,SAA2B;IAE3B,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC;AAC3E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,KAAa,EACb,MAAc,EACd,SAA2B;IAE3B,OAAO,aAAa,CAAC,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;AAClE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAa,EACb,MAAc,EACd,QAAgB,EAChB,SAA2B;IAE3B,OAAO,eAAe,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,CACvD,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAC7C,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,KAAa,EACb,MAAc,EACd,SAA2B;IAE3B,OAAO,YAAY,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,eAAe,MAAM,EAAE,EAAE,SAAS,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -54,10 +54,13 @@ export declare class ExpoSignalProtocolStore extends SqliteSignalProtocolStore {
|
|
|
54
54
|
* @throws EncryptionError with `LOCAL_STORE_KEY_LOST` when the database file
|
|
55
55
|
* exists and the vault holds no key for it. Restore the vault entry, or call
|
|
56
56
|
* {@link resetExpoStore}.
|
|
57
|
+
* @throws SqliteEncryptionUnavailableError (`KEY_STORAGE_ERROR`) when the
|
|
58
|
+
* expo-sqlite build has no SQLCipher, as on the web. The open then does not
|
|
59
|
+
* use the vault and creates no file.
|
|
57
60
|
* @throws EncryptionError with `KEY_STORAGE_ERROR` when the vault fails or
|
|
58
61
|
* holds a key of the wrong size, when the key does not open the file, when
|
|
59
|
-
* the file was created with the other `encryptionAtRest` setting, when
|
|
60
|
-
*
|
|
62
|
+
* the file was created with the other `encryptionAtRest` setting, or when
|
|
63
|
+
* another connection holds the file.
|
|
61
64
|
* @throws EncryptionError with `INVALID_STATE` when the name is not valid,
|
|
62
65
|
* when a store of this process holds the name, or when a newer SDK wrote
|
|
63
66
|
* the file.
|
|
@@ -67,6 +70,9 @@ export declare function expoStore(options?: ExpoSignalProtocolStoreOptions): Pro
|
|
|
67
70
|
* Delete the database file, then create a new key, and return the open, empty
|
|
68
71
|
* store. This is the only way to open a store whose key is lost.
|
|
69
72
|
*
|
|
73
|
+
* @throws SqliteEncryptionUnavailableError (`KEY_STORAGE_ERROR`) when the
|
|
74
|
+
* expo-sqlite build has no SQLCipher, as on the web. The reset then deletes
|
|
75
|
+
* nothing and does not use the vault.
|
|
70
76
|
* @throws EncryptionError with `INVALID_STATE` when the name is not valid, or
|
|
71
77
|
* when a store of this process holds the name. Close that store first.
|
|
72
78
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../local/store/expo/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAEzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../local/store/expo/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAEzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAO7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAM5D,MAAM,WAAW,8BAA+B,SAAQ,iBAAiB;IACvE;;;;OAIG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,8BAA8B,CAAC;CACjD;AAyBD,kEAAkE;AAClE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,uBAAuB,GAAG,kBAAkB,CAIpF;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,uBAAwB,SAAQ,yBAAyB;IACpE,OAAO,eAGN;IAgBD;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAErB;CACF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,CACvB,OAAO,GAAE,8BAAmC,GAC3C,OAAO,CAAC,uBAAuB,CAAC,CAElC;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,OAAO,GAAE,8BAAmC,GAC3C,OAAO,CAAC,uBAAuB,CAAC,CAElC"}
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { ExpoSecureStoreSignalProtocolSecretVault } from '../../vault/expo-secure-store.js';
|
|
9
9
|
import { openSqliteStore, resetSqliteStore, } from '../sqlite/open-store.js';
|
|
10
|
+
import { SqliteEncryptionUnavailableError } from '../sqlite/errors.js';
|
|
10
11
|
import { SqliteSignalProtocolStore } from '../sqlite/store.js';
|
|
11
|
-
import { createExpoSqliteDriver } from './driver.js';
|
|
12
|
+
import { createExpoSqliteDriver, expoSqliteHasCipher } from './driver.js';
|
|
12
13
|
/** The database file name when the options name none. */
|
|
13
14
|
const DEFAULT_DATABASE_NAME = 'open-e2ee-signal-protocol.db';
|
|
14
15
|
function storeOptions(options) {
|
|
@@ -19,6 +20,18 @@ function storeOptions(options) {
|
|
|
19
20
|
vault: options.vault ?? new ExpoSecureStoreSignalProtocolSecretVault(),
|
|
20
21
|
};
|
|
21
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Refuse an encrypted store when the expo-sqlite build has no SQLCipher, as
|
|
25
|
+
* on the web. The refusal comes before the vault and the file: on the web,
|
|
26
|
+
* Expo SecureStore has no implementation, and a key written to another vault
|
|
27
|
+
* would protect nothing.
|
|
28
|
+
*/
|
|
29
|
+
async function requireCipher(options) {
|
|
30
|
+
if (options.encryptionAtRest === false)
|
|
31
|
+
return;
|
|
32
|
+
if (!(await expoSqliteHasCipher()))
|
|
33
|
+
throw new SqliteEncryptionUnavailableError('expo-sqlite');
|
|
34
|
+
}
|
|
22
35
|
/** The database of each open store, for the helpers of this entry. */
|
|
23
36
|
const databases = new WeakMap();
|
|
24
37
|
/** The executor of an open store. Not exported from the entry. */
|
|
@@ -49,11 +62,13 @@ export class ExpoSignalProtocolStore extends SqliteSignalProtocolStore {
|
|
|
49
62
|
}
|
|
50
63
|
/** @internal Use {@link expoStore}. */
|
|
51
64
|
static async open(options) {
|
|
65
|
+
await requireCipher(options);
|
|
52
66
|
const database = await openSqliteStore(storeOptions(options));
|
|
53
67
|
return new ExpoSignalProtocolStore(database, options.logger);
|
|
54
68
|
}
|
|
55
69
|
/** @internal Use {@link resetExpoStore}. */
|
|
56
70
|
static async reset(options) {
|
|
71
|
+
await requireCipher(options);
|
|
57
72
|
const database = await resetSqliteStore(storeOptions(options));
|
|
58
73
|
return new ExpoSignalProtocolStore(database, options.logger);
|
|
59
74
|
}
|
|
@@ -72,10 +87,13 @@ export class ExpoSignalProtocolStore extends SqliteSignalProtocolStore {
|
|
|
72
87
|
* @throws EncryptionError with `LOCAL_STORE_KEY_LOST` when the database file
|
|
73
88
|
* exists and the vault holds no key for it. Restore the vault entry, or call
|
|
74
89
|
* {@link resetExpoStore}.
|
|
90
|
+
* @throws SqliteEncryptionUnavailableError (`KEY_STORAGE_ERROR`) when the
|
|
91
|
+
* expo-sqlite build has no SQLCipher, as on the web. The open then does not
|
|
92
|
+
* use the vault and creates no file.
|
|
75
93
|
* @throws EncryptionError with `KEY_STORAGE_ERROR` when the vault fails or
|
|
76
94
|
* 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
|
|
78
|
-
*
|
|
95
|
+
* the file was created with the other `encryptionAtRest` setting, or when
|
|
96
|
+
* another connection holds the file.
|
|
79
97
|
* @throws EncryptionError with `INVALID_STATE` when the name is not valid,
|
|
80
98
|
* when a store of this process holds the name, or when a newer SDK wrote
|
|
81
99
|
* the file.
|
|
@@ -87,6 +105,9 @@ export function expoStore(options = {}) {
|
|
|
87
105
|
* Delete the database file, then create a new key, and return the open, empty
|
|
88
106
|
* store. This is the only way to open a store whose key is lost.
|
|
89
107
|
*
|
|
108
|
+
* @throws SqliteEncryptionUnavailableError (`KEY_STORAGE_ERROR`) when the
|
|
109
|
+
* expo-sqlite build has no SQLCipher, as on the web. The reset then deletes
|
|
110
|
+
* nothing and does not use the vault.
|
|
90
111
|
* @throws EncryptionError with `INVALID_STATE` when the name is not valid, or
|
|
91
112
|
* when a store of this process holds the name. Close that store first.
|
|
92
113
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../../local/store/expo/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,wCAAwC,EAAE,MAAM,+BAA+B,CAAC;AAGzF,OAAO,EACL,eAAe,EACf,gBAAgB,GAEjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../../local/store/expo/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,wCAAwC,EAAE,MAAM,+BAA+B,CAAC;AAGzF,OAAO,EACL,eAAe,EACf,gBAAgB,GAEjB,MAAM,sBAAsB,CAAC;AAC9B,OA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MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAuC;QACvD,MAAM,aAAa,CAAC,OAAO,CAAC,CAAC;QAC7B,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;QAC9D,OAAO,IAAI,uBAAuB,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/D,CAAC;IAED,4CAA4C;IAC5C,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAuC;QACxD,MAAM,aAAa,CAAC,OAAO,CAAC,CAAC;QAC7B,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;QAC/D,OAAO,IAAI,uBAAuB,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/D,CAAC;IAED;;;OAGG;IACH,KAAK;QACH,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;IACzC,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,SAAS,CACvB,OAAO,GAAmC,EAAE;IAE5C,OAAO,uBAAuB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAO,GAAmC,EAAE;IAE5C,OAAO,uBAAuB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -12,5 +12,12 @@
|
|
|
12
12
|
* reads it, and deletes the file again when it is empty.
|
|
13
13
|
*/
|
|
14
14
|
import type { SqliteDriver } from '../sqlite/driver.js';
|
|
15
|
+
/**
|
|
16
|
+
* Whether this expo-sqlite build has SQLCipher. SQLCipher answers
|
|
17
|
+
* `PRAGMA cipher_version` on every connection, also on an in-memory database
|
|
18
|
+
* without a key. The web build of expo-sqlite and a native build without the
|
|
19
|
+
* `useSQLCipher` config-plugin option return no row.
|
|
20
|
+
*/
|
|
21
|
+
export declare function expoSqliteHasCipher(): Promise<boolean>;
|
|
15
22
|
export declare function createExpoSqliteDriver(): SqliteDriver;
|
|
16
23
|
//# sourceMappingURL=driver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../../../local/store/expo/driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAUH,OAAO,KAAK,EAEV,YAAY,EAIb,MAAM,kBAAkB,CAAC;AA2F1B,wBAAgB,sBAAsB,IAAI,YAAY,CAsCrD"}
|
|
1
|
+
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../../../local/store/expo/driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAUH,OAAO,KAAK,EAEV,YAAY,EAIb,MAAM,kBAAkB,CAAC;AA2F1B;;;;;GAKG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC,CAQ5D;AAED,wBAAgB,sBAAsB,IAAI,YAAY,CAsCrD"}
|
|
@@ -98,6 +98,22 @@ async function openDatabase(file, key) {
|
|
|
98
98
|
throw error;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Whether this expo-sqlite build has SQLCipher. SQLCipher answers
|
|
103
|
+
* `PRAGMA cipher_version` on every connection, also on an in-memory database
|
|
104
|
+
* without a key. The web build of expo-sqlite and a native build without the
|
|
105
|
+
* `useSQLCipher` config-plugin option return no row.
|
|
106
|
+
*/
|
|
107
|
+
export async function expoSqliteHasCipher() {
|
|
108
|
+
const database = await openConnection(':memory:');
|
|
109
|
+
try {
|
|
110
|
+
const row = await database.getFirstAsync('PRAGMA cipher_version');
|
|
111
|
+
return typeof row?.cipher_version === 'string' && row.cipher_version !== '';
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
await database.closeAsync();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
101
117
|
export function createExpoSqliteDriver() {
|
|
102
118
|
return {
|
|
103
119
|
name: 'expo-sqlite',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver.js","sourceRoot":"","sources":["../../../../local/store/expo/driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAGlB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAQnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB,MAAM,oBAAoB;IACK,QAAQ;IAArC,YAA6B,QAAwB;wBAAxB,QAAQ;IAAmB,CAAC;IAEzD,KAAK,CAAC,OAAO,CACX,GAAW,EACX,MAAM,GAA2B,EAAE;QAEnC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QACxD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,YAAY,CAAY,MAA2B,CAAC,CAAC;YACpF,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC;YACxC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;QAC3C,CAAC;gBAAS,CAAC;YACT,MAAM,SAAS,CAAC,aAAa,EAAE,CAAC;QAClC,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAW;QACf,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;QAC9D,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAC5C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;QAC7D,MAAM,OAA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AoB,CAAC,MAAM,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;QACjE,CAAC;QAED,KAAK,CAAC,MAAM,CAAC,IAAI;YACf,sEAAsE;YACtE,gEAAgE;YAChE,KAAK,MAAM,MAAM,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC;gBAAE,MAAM,UAAU,CAAC,GAAG,IAAI,GAAG,MAAM,EAAE,CAAC,CAAC;YACxF,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -294,9 +294,9 @@ export declare class KeyValueSignalProtocolStore implements SignalProtocolLocalS
|
|
|
294
294
|
deleteAllSenderKeysForGroup(groupId: string): Promise<number>;
|
|
295
295
|
storeSenderKeyRecord(groupId: string, userId: string, deviceId: number, states: SenderKeyState[], receive?: SenderKeyReceiveCommit): Promise<void>;
|
|
296
296
|
getSenderKeyRecord(groupId: string, userId: string, deviceId: number): Promise<SenderKeyState[] | null>;
|
|
297
|
-
storeSkippedSenderKey(groupId: string, senderId: string, senderDeviceId: number, chainIndex: number, messageKey: SkippedSenderMessageKey): Promise<void>;
|
|
298
|
-
getSkippedSenderKey(groupId: string, senderId: string, senderDeviceId: number, chainIndex: number): Promise<SkippedSenderMessageKey | null>;
|
|
299
|
-
deleteSkippedSenderKey(groupId: string, senderId: string, senderDeviceId: number, chainIndex: number): Promise<void>;
|
|
297
|
+
storeSkippedSenderKey(groupId: string, senderId: string, senderDeviceId: number, senderKeyId: string, chainIndex: number, messageKey: SkippedSenderMessageKey): Promise<void>;
|
|
298
|
+
getSkippedSenderKey(groupId: string, senderId: string, senderDeviceId: number, senderKeyId: string, chainIndex: number): Promise<SkippedSenderMessageKey | null>;
|
|
299
|
+
deleteSkippedSenderKey(groupId: string, senderId: string, senderDeviceId: number, senderKeyId: string, chainIndex: number): Promise<void>;
|
|
300
300
|
countSkippedSenderKeys(groupId: string, senderId: string, senderDeviceId: number): Promise<number>;
|
|
301
301
|
deleteOldestSkippedSenderKeys(groupId: string, senderId: string, senderDeviceId: number, count: number): Promise<number>;
|
|
302
302
|
storeMessageRecord(record: MessageRecord): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../local/store/key-value/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAG9E,OAAO,KAAK,EACV,wBAAwB,EACxB,aAAa,EACb,UAAU,EACV,YAAY,EACZ,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAA8B,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACxF,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,eAAe,EACf,WAAW,EACX,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAQpG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAA6B,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC9F,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAGzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AACrF,OAAO,KAAK,EAAqB,eAAe,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../local/store/key-value/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,sBA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K,EAAE,MAAM,CAAC;KACf,CAAC,CAkBD;CACF"}
|
|
@@ -36,6 +36,7 @@ import { ProtocolAddress } from '../../../types/address.js';
|
|
|
36
36
|
import { IdentityKeyChange, StorageQuotaExceededError } from '../../../types/index.js';
|
|
37
37
|
import { requireSecretVault } from '../../vault/require.js';
|
|
38
38
|
import { asBase64 } from '../../../types/utils.js';
|
|
39
|
+
import { withDeviceRecordLocks } from '../../../internal/session/record-locks.js';
|
|
39
40
|
import { withSession } from '../device-record.js';
|
|
40
41
|
import { decodeUserRecord, encodeUserRecord } from './device-record.js';
|
|
41
42
|
import { deleteDataThenReplaceValueKey, openValueKey } from './value-key.js';
|
|
@@ -941,8 +942,8 @@ export class KeyValueSignalProtocolStore {
|
|
|
941
942
|
getSkippedSenderKeyGroupPrefix(groupId) {
|
|
942
943
|
return `${STORAGE_KEYS.SKIPPED_SENDER_KEY_PREFIX}${escapeKeyComponent(groupId)}:`;
|
|
943
944
|
}
|
|
944
|
-
getSkippedSenderKeyStorageKey(groupId, senderId, senderDeviceId, chainIndex) {
|
|
945
|
-
return `${this.getSkippedSenderKeyPrefix(groupId, senderId, senderDeviceId)}${chainIndex}`;
|
|
945
|
+
getSkippedSenderKeyStorageKey(groupId, senderId, senderDeviceId, senderKeyId, chainIndex) {
|
|
946
|
+
return `${this.getSkippedSenderKeyPrefix(groupId, senderId, senderDeviceId)}${escapeKeyComponent(senderKeyId)}:${chainIndex}`;
|
|
946
947
|
}
|
|
947
948
|
getMessageRecordStorageKey(sessionId, timestamp) {
|
|
948
949
|
return `${this.getMessageRecordSessionPrefix(sessionId)}${timestamp}`;
|
|
@@ -1036,23 +1037,24 @@ export class KeyValueSignalProtocolStore {
|
|
|
1036
1037
|
async deleteStaleRecords(maxLatency) {
|
|
1037
1038
|
const now = Date.now();
|
|
1038
1039
|
let deletedCount = 0;
|
|
1040
|
+
// The scan takes no lock. Each device is decided again under the locks of
|
|
1041
|
+
// its records, so a write that lands after the scan is kept.
|
|
1039
1042
|
for (const userId of await this.getAllUserIds()) {
|
|
1040
1043
|
const userRecord = await this.getUserRecord(userId);
|
|
1041
1044
|
if (!userRecord)
|
|
1042
1045
|
continue;
|
|
1043
|
-
const devicesToDelete = [];
|
|
1044
1046
|
for (const [deviceId, deviceRecord] of userRecord.devices) {
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1047
|
+
if (!isStaleDeviceRecord(deviceRecord, now, maxLatency))
|
|
1048
|
+
continue;
|
|
1049
|
+
const deleted = await withDeviceRecordLocks(this, userId, deviceId, async () => {
|
|
1050
|
+
const current = await this.getDeviceRecord(userId, deviceId);
|
|
1051
|
+
if (!current || !isStaleDeviceRecord(current, now, maxLatency))
|
|
1052
|
+
return false;
|
|
1053
|
+
await this.deleteDeviceRecord(userId, deviceId);
|
|
1054
|
+
return true;
|
|
1055
|
+
});
|
|
1056
|
+
if (deleted)
|
|
1057
|
+
deletedCount++;
|
|
1056
1058
|
}
|
|
1057
1059
|
}
|
|
1058
1060
|
return deletedCount;
|
|
@@ -1060,6 +1062,8 @@ export class KeyValueSignalProtocolStore {
|
|
|
1060
1062
|
async cleanupExpiredSessions(maxRecv) {
|
|
1061
1063
|
const now = Date.now();
|
|
1062
1064
|
let deletedCount = 0;
|
|
1065
|
+
// The scan takes no lock. Each session is decided again under the locks
|
|
1066
|
+
// of its device, so a session that is written after the scan is kept.
|
|
1063
1067
|
for (const userId of await this.getAllUserIds()) {
|
|
1064
1068
|
const userRecord = await this.getUserRecord(userId);
|
|
1065
1069
|
if (!userRecord)
|
|
@@ -1067,33 +1071,17 @@ export class KeyValueSignalProtocolStore {
|
|
|
1067
1071
|
for (const [deviceId, deviceRecord] of userRecord.devices) {
|
|
1068
1072
|
if (!deviceRecord.session)
|
|
1069
1073
|
continue;
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1074
|
+
deletedCount += await withDeviceRecordLocks(this, userId, deviceId, async () => {
|
|
1075
|
+
const current = await this.getDeviceRecord(userId, deviceId);
|
|
1076
|
+
if (!current)
|
|
1077
|
+
return 0;
|
|
1078
|
+
const deleted = expireDeviceSessions(current, now, maxRecv);
|
|
1079
|
+
if (deleted > 0) {
|
|
1080
|
+
current.updatedAt = Date.now();
|
|
1081
|
+
await this.setDeviceRecord(userId, deviceId, current);
|
|
1078
1082
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
const archivedKeys = Object.keys(deviceRecord.session.archivedSessions);
|
|
1082
|
-
for (const baseKey of archivedKeys) {
|
|
1083
|
-
const session = deviceRecord.session.archivedSessions[baseKey];
|
|
1084
|
-
if (session && now - session.createdAt > maxRecv) {
|
|
1085
|
-
delete deviceRecord.session.archivedSessions[baseKey];
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
const removed = originalCount - Object.keys(deviceRecord.session.archivedSessions).length;
|
|
1089
|
-
if (removed > 0) {
|
|
1090
|
-
deletedCount += removed;
|
|
1091
|
-
modified = true;
|
|
1092
|
-
}
|
|
1093
|
-
if (modified) {
|
|
1094
|
-
deviceRecord.updatedAt = Date.now();
|
|
1095
|
-
await this.setDeviceRecord(userId, deviceId, deviceRecord);
|
|
1096
|
-
}
|
|
1083
|
+
return deleted;
|
|
1084
|
+
});
|
|
1097
1085
|
}
|
|
1098
1086
|
}
|
|
1099
1087
|
return deletedCount;
|
|
@@ -1283,15 +1271,30 @@ export class KeyValueSignalProtocolStore {
|
|
|
1283
1271
|
});
|
|
1284
1272
|
}
|
|
1285
1273
|
if (receive) {
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1274
|
+
if (receive.skippedKeys) {
|
|
1275
|
+
for (const skipped of receive.skippedKeys.keys) {
|
|
1276
|
+
operations.push({
|
|
1277
|
+
type: 'pruneSkippedSenderKeys',
|
|
1278
|
+
keyPrefix: this.getSkippedSenderKeyPrefix(groupId, userId, deviceId),
|
|
1279
|
+
maxCount: Math.max(0, receive.skippedKeys.maxSkippedKeys - 1),
|
|
1280
|
+
}, {
|
|
1281
|
+
type: 'set',
|
|
1282
|
+
key: this.getSkippedSenderKeyStorageKey(groupId, userId, deviceId, skipped.senderKeyId, skipped.chainIndex),
|
|
1283
|
+
value: await this.encrypt(JSON.stringify(skipped.messageKey)),
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
if (receive.content) {
|
|
1288
|
+
operations.push({
|
|
1289
|
+
type: 'set',
|
|
1290
|
+
key: `@signal:received-content:${receive.content.id}`,
|
|
1291
|
+
value: await this.encrypt(JSON.stringify(receive.content)),
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
if (receive.consumedSkippedKey !== undefined)
|
|
1292
1295
|
operations.push({
|
|
1293
1296
|
type: 'remove',
|
|
1294
|
-
key: this.getSkippedSenderKeyStorageKey(groupId, userId, deviceId, receive.
|
|
1297
|
+
key: this.getSkippedSenderKeyStorageKey(groupId, userId, deviceId, receive.consumedSkippedKey.senderKeyId, receive.consumedSkippedKey.chainIndex),
|
|
1295
1298
|
});
|
|
1296
1299
|
}
|
|
1297
1300
|
await this.storageBackend.atomicWrite(operations);
|
|
@@ -1308,22 +1311,22 @@ export class KeyValueSignalProtocolStore {
|
|
|
1308
1311
|
// ============================================================================
|
|
1309
1312
|
// Skipped Sender Keys
|
|
1310
1313
|
// ============================================================================
|
|
1311
|
-
async storeSkippedSenderKey(groupId, senderId, senderDeviceId, chainIndex, messageKey) {
|
|
1314
|
+
async storeSkippedSenderKey(groupId, senderId, senderDeviceId, senderKeyId, chainIndex, messageKey) {
|
|
1312
1315
|
this.ensureInitialized();
|
|
1313
|
-
await this.storageBackend.setItem(this.getSkippedSenderKeyStorageKey(groupId, senderId, senderDeviceId, chainIndex), await this.encrypt(JSON.stringify(messageKey)));
|
|
1316
|
+
await this.storageBackend.setItem(this.getSkippedSenderKeyStorageKey(groupId, senderId, senderDeviceId, senderKeyId, chainIndex), await this.encrypt(JSON.stringify(messageKey)));
|
|
1314
1317
|
}
|
|
1315
|
-
async getSkippedSenderKey(groupId, senderId, senderDeviceId, chainIndex) {
|
|
1318
|
+
async getSkippedSenderKey(groupId, senderId, senderDeviceId, senderKeyId, chainIndex) {
|
|
1316
1319
|
this.ensureInitialized();
|
|
1317
|
-
const encrypted = await this.storageBackend.getItem(this.getSkippedSenderKeyStorageKey(groupId, senderId, senderDeviceId, chainIndex));
|
|
1320
|
+
const encrypted = await this.storageBackend.getItem(this.getSkippedSenderKeyStorageKey(groupId, senderId, senderDeviceId, senderKeyId, chainIndex));
|
|
1318
1321
|
if (!encrypted) {
|
|
1319
1322
|
return null;
|
|
1320
1323
|
}
|
|
1321
1324
|
const decrypted = await this.decrypt(encrypted);
|
|
1322
1325
|
return JSON.parse(decrypted);
|
|
1323
1326
|
}
|
|
1324
|
-
async deleteSkippedSenderKey(groupId, senderId, senderDeviceId, chainIndex) {
|
|
1327
|
+
async deleteSkippedSenderKey(groupId, senderId, senderDeviceId, senderKeyId, chainIndex) {
|
|
1325
1328
|
this.ensureInitialized();
|
|
1326
|
-
await this.storageBackend.removeItem(this.getSkippedSenderKeyStorageKey(groupId, senderId, senderDeviceId, chainIndex));
|
|
1329
|
+
await this.storageBackend.removeItem(this.getSkippedSenderKeyStorageKey(groupId, senderId, senderDeviceId, senderKeyId, chainIndex));
|
|
1327
1330
|
}
|
|
1328
1331
|
async countSkippedSenderKeys(groupId, senderId, senderDeviceId) {
|
|
1329
1332
|
this.ensureInitialized();
|
|
@@ -1469,4 +1472,39 @@ export class KeyValueSignalProtocolStore {
|
|
|
1469
1472
|
};
|
|
1470
1473
|
}
|
|
1471
1474
|
}
|
|
1475
|
+
/**
|
|
1476
|
+
* A device record is stale when it has no current session and no archived
|
|
1477
|
+
* session, and it has not been updated within `maxLatency`.
|
|
1478
|
+
*/
|
|
1479
|
+
function isStaleDeviceRecord(record, now, maxLatency) {
|
|
1480
|
+
const hasNoSessions = !record.session ||
|
|
1481
|
+
(!record.session.currentSession && Object.keys(record.session.archivedSessions).length === 0);
|
|
1482
|
+
return hasNoSessions && now - record.updatedAt > maxLatency;
|
|
1483
|
+
}
|
|
1484
|
+
/**
|
|
1485
|
+
* Delete the sessions of `record` that are older than `maxRecv`, and return
|
|
1486
|
+
* how many it deleted. The age of the current session comes from the session
|
|
1487
|
+
* metadata when it has a creation time.
|
|
1488
|
+
*/
|
|
1489
|
+
function expireDeviceSessions(record, now, maxRecv) {
|
|
1490
|
+
const session = record.session;
|
|
1491
|
+
if (!session)
|
|
1492
|
+
return 0;
|
|
1493
|
+
let deleted = 0;
|
|
1494
|
+
if (session.currentSession) {
|
|
1495
|
+
const createdAt = session.metadata?.createdAt ?? session.currentSession.createdAt;
|
|
1496
|
+
if (now - createdAt > maxRecv) {
|
|
1497
|
+
session.currentSession = null;
|
|
1498
|
+
deleted++;
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
for (const baseKey of Object.keys(session.archivedSessions)) {
|
|
1502
|
+
const archived = session.archivedSessions[baseKey];
|
|
1503
|
+
if (archived && now - archived.createdAt > maxRecv) {
|
|
1504
|
+
delete session.archivedSessions[baseKey];
|
|
1505
|
+
deleted++;
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
return deleted;
|
|
1509
|
+
}
|
|
1472
1510
|
//# sourceMappingURL=adapter.js.map
|