@open-e2ee/signal-protocol-sdk 7.2.0 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ADAPTERS.md +55 -8
- package/ARCHITECTURE.md +1 -0
- package/CHANGELOG.md +538 -0
- package/README.md +10 -6
- 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 +151 -91
- 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 +9 -0
- package/dist/client/hosted-transport.d.ts.map +1 -1
- package/dist/client/hosted-transport.js +59 -24
- 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/protocol/zk/credentials/attributes.d.ts.map +1 -1
- package/dist/internal/protocol/zk/credentials/attributes.js +2 -1
- package/dist/internal/protocol/zk/credentials/attributes.js.map +1 -1
- package/dist/internal/protocol/zk/credentials/credentials.d.ts.map +1 -1
- package/dist/internal/protocol/zk/credentials/credentials.js +8 -6
- package/dist/internal/protocol/zk/credentials/credentials.js.map +1 -1
- package/dist/internal/protocol/zk/credentials/presentation.d.ts.map +1 -1
- package/dist/internal/protocol/zk/credentials/presentation.js +19 -13
- package/dist/internal/protocol/zk/credentials/presentation.js.map +1 -1
- package/dist/internal/protocol/zk/groups/lizard.d.ts +8 -0
- package/dist/internal/protocol/zk/groups/lizard.d.ts.map +1 -1
- package/dist/internal/protocol/zk/groups/lizard.js +18 -5
- package/dist/internal/protocol/zk/groups/lizard.js.map +1 -1
- package/dist/internal/protocol/zk/groups/profile-key-commitment.d.ts.map +1 -1
- package/dist/internal/protocol/zk/groups/profile-key-commitment.js +7 -6
- package/dist/internal/protocol/zk/groups/profile-key-commitment.js.map +1 -1
- package/dist/internal/protocol/zk/groups/profile-key-encryption.d.ts.map +1 -1
- package/dist/internal/protocol/zk/groups/profile-key-encryption.js +3 -2
- package/dist/internal/protocol/zk/groups/profile-key-encryption.js.map +1 -1
- package/dist/internal/protocol/zk/groups/uid-encryption.d.ts.map +1 -1
- package/dist/internal/protocol/zk/groups/uid-encryption.js +3 -2
- package/dist/internal/protocol/zk/groups/uid-encryption.js.map +1 -1
- package/dist/internal/protocol/zk/proofs/point-multiplication.d.ts +53 -0
- package/dist/internal/protocol/zk/proofs/point-multiplication.d.ts.map +1 -0
- package/dist/internal/protocol/zk/proofs/point-multiplication.js +164 -0
- package/dist/internal/protocol/zk/proofs/point-multiplication.js.map +1 -0
- package/dist/internal/protocol/zk/proofs/sho.d.ts +1 -0
- package/dist/internal/protocol/zk/proofs/sho.d.ts.map +1 -1
- package/dist/internal/protocol/zk/proofs/sho.js.map +1 -1
- package/dist/internal/protocol/zk/proofs/statement.d.ts.map +1 -1
- package/dist/internal/protocol/zk/proofs/statement.js +11 -11
- package/dist/internal/protocol/zk/proofs/statement.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 +11 -6
- package/dist/local/store/index.d.ts.map +1 -1
- package/dist/local/store/index.js +11 -6
- 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 +171 -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 +39 -0
- package/dist/local/store/sqlite/web/worker.d.ts.map +1 -0
- package/dist/local/store/sqlite/web/worker.js +646 -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 +101 -0
- package/dist/local/store/web-sqlite/adapter.d.ts.map +1 -0
- package/dist/local/store/web-sqlite/adapter.js +154 -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 +84 -11
- package/docs/CLIENT_COMPOSITION.md +1 -2
- package/docs/DEVIATIONS.md +1 -1
- package/docs/ERROR_HANDLING.md +7 -1
- package/docs/GETTING_STARTED.md +1 -2
- package/docs/PACKAGE_SURFACE.md +32 -12
- package/docs/RECIPES.md +1 -2
- package/examples/browser/index.html +1 -1
- package/local/store/README.md +142 -42
- 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 +14 -0
- package/local/store/web-sqlite/README.md +210 -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,129 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Node.js Database Key Manager
|
|
3
|
-
*
|
|
4
|
-
* Manages the database encryption key for Node.js applications.
|
|
5
|
-
*
|
|
6
|
-
* Layer 1 (Secure Storage): Single 32-byte database encryption key
|
|
7
|
-
* Layer 2 (Encrypted Files): All Signal Protocol keys, encrypted with the database key
|
|
8
|
-
*
|
|
9
|
-
* Security Properties:
|
|
10
|
-
* - Database key stored with 0600 permissions (owner read/write only)
|
|
11
|
-
* - Key generated once on first initialization
|
|
12
|
-
* - All large keys (Kyber, etc.) stored in encrypted files
|
|
13
|
-
*
|
|
14
|
-
* Storage Strategy:
|
|
15
|
-
* - Primary: Filesystem with strict owner-only permissions
|
|
16
|
-
* - Optional: OS keychain via keytar (if available)
|
|
17
|
-
*/
|
|
18
|
-
/**
|
|
19
|
-
* Database encryption key size (AES-256)
|
|
20
|
-
*/
|
|
21
|
-
export {};
|
|
22
|
-
/** A durable marker prevents access during an incomplete explicit reset. */
|
|
23
|
-
export declare const NODE_DATABASE_RESET_FILE = ".database.reset";
|
|
24
|
-
/**
|
|
25
|
-
* Node.js Database Key Manager
|
|
26
|
-
*
|
|
27
|
-
* Handles generation, storage, and retrieval of the database encryption key.
|
|
28
|
-
* This key encrypts and decrypts all Signal Protocol keys in storage.
|
|
29
|
-
*/
|
|
30
|
-
export declare class NodeDatabaseKeyManager {
|
|
31
|
-
private readonly dataDir;
|
|
32
|
-
private cachedKey;
|
|
33
|
-
private readonly keyFilePath;
|
|
34
|
-
constructor(dataDir?: string);
|
|
35
|
-
/**
|
|
36
|
-
* Initialize the database encryption key
|
|
37
|
-
*
|
|
38
|
-
* Generates and stores a new 32-byte key if one does not exist.
|
|
39
|
-
* Callers should run this once on app start.
|
|
40
|
-
*
|
|
41
|
-
* @returns true if the method generated a key, false if one already exists
|
|
42
|
-
*/
|
|
43
|
-
initialize(): Promise<boolean>;
|
|
44
|
-
private initializeLocked;
|
|
45
|
-
/**
|
|
46
|
-
* Get the database encryption key
|
|
47
|
-
*
|
|
48
|
-
* Rechecks the filesystem and reuses the cached key only when its bytes match.
|
|
49
|
-
* Returns null if key does not exist (needs initialization).
|
|
50
|
-
*
|
|
51
|
-
* @returns Database encryption key or null
|
|
52
|
-
*/
|
|
53
|
-
getKey(): Promise<Uint8Array | null>;
|
|
54
|
-
private readKeyLocked;
|
|
55
|
-
/**
|
|
56
|
-
* Get the database encryption key (throws if not initialized)
|
|
57
|
-
*
|
|
58
|
-
* Convenience method that throws when the key is missing.
|
|
59
|
-
* Use this when you expect the key to be initialized.
|
|
60
|
-
*
|
|
61
|
-
* @throws EncryptionError if key does not exist
|
|
62
|
-
* @returns Database encryption key
|
|
63
|
-
*/
|
|
64
|
-
getKeyOrThrow(): Promise<Uint8Array>;
|
|
65
|
-
/**
|
|
66
|
-
* Check if database encryption key exists
|
|
67
|
-
*
|
|
68
|
-
* @returns true if key exists, false otherwise
|
|
69
|
-
*/
|
|
70
|
-
hasKey(): Promise<boolean>;
|
|
71
|
-
/**
|
|
72
|
-
* Delete the database encryption key
|
|
73
|
-
*
|
|
74
|
-
* ⚠️ DANGEROUS: This will make all encrypted data
|
|
75
|
-
* permanently unrecoverable. Only use for:
|
|
76
|
-
* - Account deletion
|
|
77
|
-
* - Factory reset
|
|
78
|
-
* - Controlled local reset
|
|
79
|
-
*
|
|
80
|
-
* @returns true if the method deleted a key, false if none existed
|
|
81
|
-
*/
|
|
82
|
-
deleteKey(): Promise<boolean>;
|
|
83
|
-
/**
|
|
84
|
-
* Rotate the database encryption key
|
|
85
|
-
*
|
|
86
|
-
* Generates a new key and returns both old and new keys.
|
|
87
|
-
* Caller is responsible for:
|
|
88
|
-
* 1. Re-encrypting all storage with new key
|
|
89
|
-
* 2. Storing new key
|
|
90
|
-
* 3. Deleting old key
|
|
91
|
-
*
|
|
92
|
-
* @returns Object with oldKey and newKey
|
|
93
|
-
*/
|
|
94
|
-
rotateKey(): Promise<{
|
|
95
|
-
oldKey: Uint8Array;
|
|
96
|
-
newKey: Uint8Array;
|
|
97
|
-
}>;
|
|
98
|
-
/**
|
|
99
|
-
* Complete key rotation after re-encryption
|
|
100
|
-
*
|
|
101
|
-
* Stores the new key and clears cache.
|
|
102
|
-
* Call this AFTER successfully re-encrypting all data.
|
|
103
|
-
*
|
|
104
|
-
* @param newKey The new database encryption key
|
|
105
|
-
*/
|
|
106
|
-
completeKeyRotation(newKey: Uint8Array): Promise<void>;
|
|
107
|
-
/**
|
|
108
|
-
* Clear cached key (security: minimize key in memory)
|
|
109
|
-
*
|
|
110
|
-
* Forces next getKey() to read from filesystem.
|
|
111
|
-
* Call this when application exits.
|
|
112
|
-
*/
|
|
113
|
-
clearCache(): void;
|
|
114
|
-
/**
|
|
115
|
-
* Get the key file path for diagnostics.
|
|
116
|
-
*/
|
|
117
|
-
getKeyFilePath(): string;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Get singleton NodeDatabaseKeyManager instance
|
|
121
|
-
*
|
|
122
|
-
* @param dataDir Optional custom data directory
|
|
123
|
-
*/
|
|
124
|
-
export declare function getNodeDatabaseKeyManager(dataDir?: string): NodeDatabaseKeyManager;
|
|
125
|
-
/**
|
|
126
|
-
* Reset the singleton for controlled local teardown.
|
|
127
|
-
*/
|
|
128
|
-
export declare function resetNodeDatabaseKeyManager(): void;
|
|
129
|
-
//# sourceMappingURL=database-key.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"database-key.d.ts","sourceRoot":"","sources":["../../../../local/store/node/database-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAcH;;GAEG;AACH,OAAO,EAAE,CAAC;AAaV,4EAA4E;AAC5E,eAAO,MAAM,wBAAwB,oBAAoB,CAAC;AAE1D;;;;;GAKG;AACH,qBAAa,sBAAsB;IAIrB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAHpC,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IAErC,YAA6B,OAAO,GAAE,MAAyB,EAE9D;IAED;;;;;;;OAOG;IACG,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,CAEnC;YAEa,gBAAgB;IAqC9B;;;;;;;OAOG;IACG,MAAM,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAEzC;YAea,aAAa;IAyC3B;;;;;;;;OAQG;IACG,aAAa,IAAI,OAAO,CAAC,UAAU,CAAC,CASzC;IAED;;;;OAIG;IACG,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,CAO/B;IAED;;;;;;;;;;OAUG;IACG,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAuBlC;IAED;;;;;;;;;;OAUG;IACG,SAAS,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,UAAU,CAAC;QAAC,MAAM,EAAE,UAAU,CAAA;KAAE,CAAC,CAgBrE;IAED;;;;;;;OAOG;IACG,mBAAmB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAsB3D;IAED;;;;;OAKG;IACH,UAAU,IAAI,IAAI,CAEjB;IAED;;OAEG;IACH,cAAc,IAAI,MAAM,CAEvB;CACF;AAOD;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,sBAAsB,CAQlF;AAED;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,IAAI,CAKlD"}
|
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Node.js Database Key Manager
|
|
3
|
-
*
|
|
4
|
-
* Manages the database encryption key for Node.js applications.
|
|
5
|
-
*
|
|
6
|
-
* Layer 1 (Secure Storage): Single 32-byte database encryption key
|
|
7
|
-
* Layer 2 (Encrypted Files): All Signal Protocol keys, encrypted with the database key
|
|
8
|
-
*
|
|
9
|
-
* Security Properties:
|
|
10
|
-
* - Database key stored with 0600 permissions (owner read/write only)
|
|
11
|
-
* - Key generated once on first initialization
|
|
12
|
-
* - All large keys (Kyber, etc.) stored in encrypted files
|
|
13
|
-
*
|
|
14
|
-
* Storage Strategy:
|
|
15
|
-
* - Primary: Filesystem with strict owner-only permissions
|
|
16
|
-
* - Optional: OS keychain via keytar (if available)
|
|
17
|
-
*/
|
|
18
|
-
import { randomBytes } from 'node:crypto';
|
|
19
|
-
import { access, readFile, unlink } from 'node:fs/promises';
|
|
20
|
-
import { join } from 'node:path';
|
|
21
|
-
import { homedir } from 'node:os';
|
|
22
|
-
import { EncryptionError, EncryptionErrorCode } from '../../../types/index.js';
|
|
23
|
-
import { withNodeDatabaseLock } from './database-lock.js';
|
|
24
|
-
import { clearPendingNodeDatabaseFiles, commitNodeDatabaseFile, syncNodeDatabaseDirectory, } from './database-file-commit.js';
|
|
25
|
-
const DB_KEY_SIZE = 32; // 256 bits
|
|
26
|
-
/**
|
|
27
|
-
* Default directory for Signal Protocol storage
|
|
28
|
-
*/
|
|
29
|
-
const DEFAULT_DATA_DIR = join(homedir(), '.config', 'open-e2ee', 'signal-protocol');
|
|
30
|
-
/**
|
|
31
|
-
* Filename for the database encryption key
|
|
32
|
-
*/
|
|
33
|
-
const DB_KEY_FILENAME = 'db.key';
|
|
34
|
-
/** A durable marker prevents access during an incomplete explicit reset. */
|
|
35
|
-
export const NODE_DATABASE_RESET_FILE = '.database.reset';
|
|
36
|
-
/**
|
|
37
|
-
* Node.js Database Key Manager
|
|
38
|
-
*
|
|
39
|
-
* Handles generation, storage, and retrieval of the database encryption key.
|
|
40
|
-
* This key encrypts and decrypts all Signal Protocol keys in storage.
|
|
41
|
-
*/
|
|
42
|
-
export class NodeDatabaseKeyManager {
|
|
43
|
-
dataDir;
|
|
44
|
-
cachedKey = null;
|
|
45
|
-
keyFilePath;
|
|
46
|
-
constructor(dataDir = DEFAULT_DATA_DIR) {
|
|
47
|
-
this.dataDir = dataDir;
|
|
48
|
-
this.keyFilePath = join(dataDir, DB_KEY_FILENAME);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Initialize the database encryption key
|
|
52
|
-
*
|
|
53
|
-
* Generates and stores a new 32-byte key if one does not exist.
|
|
54
|
-
* Callers should run this once on app start.
|
|
55
|
-
*
|
|
56
|
-
* @returns true if the method generated a key, false if one already exists
|
|
57
|
-
*/
|
|
58
|
-
async initialize() {
|
|
59
|
-
return withNodeDatabaseLock(this.dataDir, () => this.initializeLocked());
|
|
60
|
-
}
|
|
61
|
-
async initializeLocked() {
|
|
62
|
-
try {
|
|
63
|
-
await clearPendingNodeDatabaseFiles(this.dataDir);
|
|
64
|
-
// Check if key already exists
|
|
65
|
-
const existingKey = await this.readKeyLocked();
|
|
66
|
-
if (existingKey) {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
try {
|
|
70
|
-
await access(join(this.dataDir, 'protocol_security_state_v1.json'));
|
|
71
|
-
throw new Error('Node database key is missing. Restore the key or explicitly reset the store.');
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
if (error.code !== 'ENOENT')
|
|
75
|
-
throw error;
|
|
76
|
-
}
|
|
77
|
-
// Generate cryptographically secure random 32-byte key
|
|
78
|
-
const keyBytes = randomBytes(DB_KEY_SIZE);
|
|
79
|
-
// Store in filesystem with secure permissions
|
|
80
|
-
await commitNodeDatabaseFile(this.keyFilePath, keyBytes);
|
|
81
|
-
// Cache the key
|
|
82
|
-
this.cachedKey = new Uint8Array(keyBytes);
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
throw new EncryptionError('Failed to initialize database encryption key', EncryptionErrorCode.KEY_STORAGE_ERROR, { originalError: error });
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Get the database encryption key
|
|
91
|
-
*
|
|
92
|
-
* Rechecks the filesystem and reuses the cached key only when its bytes match.
|
|
93
|
-
* Returns null if key does not exist (needs initialization).
|
|
94
|
-
*
|
|
95
|
-
* @returns Database encryption key or null
|
|
96
|
-
*/
|
|
97
|
-
async getKey() {
|
|
98
|
-
return withNodeDatabaseLock(this.dataDir, () => this.readKeyLocked());
|
|
99
|
-
}
|
|
100
|
-
/** @internal Holds authority through the caller's complete state transaction. */
|
|
101
|
-
async withKey(operation, initialize = false) {
|
|
102
|
-
return withNodeDatabaseLock(this.dataDir, async () => {
|
|
103
|
-
if (initialize)
|
|
104
|
-
await this.initializeLocked();
|
|
105
|
-
const key = await this.readKeyLocked();
|
|
106
|
-
if (!key)
|
|
107
|
-
throw new Error('Node database key is missing. Restore the key or explicitly reset the store.');
|
|
108
|
-
return operation(key);
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
async readKeyLocked() {
|
|
112
|
-
try {
|
|
113
|
-
await access(join(this.dataDir, NODE_DATABASE_RESET_FILE));
|
|
114
|
-
throw new Error('Node database reset is incomplete. Repeat the explicit reset before opening the store.');
|
|
115
|
-
}
|
|
116
|
-
catch (error) {
|
|
117
|
-
if (error.code !== 'ENOENT')
|
|
118
|
-
throw error;
|
|
119
|
-
}
|
|
120
|
-
try {
|
|
121
|
-
// Read key from file. A missing file surfaces as ENOENT below. A
|
|
122
|
-
// separate access() pre-check would race against concurrent
|
|
123
|
-
// creation or deletion of the key file.
|
|
124
|
-
const keyBuffer = await readFile(this.keyFilePath);
|
|
125
|
-
const keyBytes = new Uint8Array(keyBuffer);
|
|
126
|
-
// Validate key size
|
|
127
|
-
if (keyBytes.length !== DB_KEY_SIZE) {
|
|
128
|
-
throw new Error(`Invalid database key size: expected ${DB_KEY_SIZE} bytes, got ${keyBytes.length}`);
|
|
129
|
-
}
|
|
130
|
-
// Recheck disk on each transaction so reset cannot leave a stale writer.
|
|
131
|
-
if (this.cachedKey && Buffer.from(this.cachedKey).equals(keyBuffer))
|
|
132
|
-
return this.cachedKey;
|
|
133
|
-
this.cachedKey = keyBytes;
|
|
134
|
-
return keyBytes;
|
|
135
|
-
}
|
|
136
|
-
catch (error) {
|
|
137
|
-
if (error.code === 'ENOENT') {
|
|
138
|
-
this.cachedKey = null;
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
throw new EncryptionError('Failed to retrieve database encryption key', EncryptionErrorCode.KEY_STORAGE_ERROR, { originalError: error });
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Get the database encryption key (throws if not initialized)
|
|
146
|
-
*
|
|
147
|
-
* Convenience method that throws when the key is missing.
|
|
148
|
-
* Use this when you expect the key to be initialized.
|
|
149
|
-
*
|
|
150
|
-
* @throws EncryptionError if key does not exist
|
|
151
|
-
* @returns Database encryption key
|
|
152
|
-
*/
|
|
153
|
-
async getKeyOrThrow() {
|
|
154
|
-
const key = await this.getKey();
|
|
155
|
-
if (!key) {
|
|
156
|
-
throw new EncryptionError('Database encryption key not initialized. Call initialize() first.', EncryptionErrorCode.INITIALIZATION_FAILED);
|
|
157
|
-
}
|
|
158
|
-
return key;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Check if database encryption key exists
|
|
162
|
-
*
|
|
163
|
-
* @returns true if key exists, false otherwise
|
|
164
|
-
*/
|
|
165
|
-
async hasKey() {
|
|
166
|
-
try {
|
|
167
|
-
const key = await this.getKey();
|
|
168
|
-
return key !== null;
|
|
169
|
-
}
|
|
170
|
-
catch {
|
|
171
|
-
return false;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Delete the database encryption key
|
|
176
|
-
*
|
|
177
|
-
* ⚠️ DANGEROUS: This will make all encrypted data
|
|
178
|
-
* permanently unrecoverable. Only use for:
|
|
179
|
-
* - Account deletion
|
|
180
|
-
* - Factory reset
|
|
181
|
-
* - Controlled local reset
|
|
182
|
-
*
|
|
183
|
-
* @returns true if the method deleted a key, false if none existed
|
|
184
|
-
*/
|
|
185
|
-
async deleteKey() {
|
|
186
|
-
return withNodeDatabaseLock(this.dataDir, async () => {
|
|
187
|
-
try {
|
|
188
|
-
const exists = await this.readKeyLocked();
|
|
189
|
-
if (!exists) {
|
|
190
|
-
return false;
|
|
191
|
-
}
|
|
192
|
-
await unlink(this.keyFilePath);
|
|
193
|
-
await syncNodeDatabaseDirectory(this.dataDir);
|
|
194
|
-
// Clear cache
|
|
195
|
-
this.cachedKey = null;
|
|
196
|
-
return true;
|
|
197
|
-
}
|
|
198
|
-
catch (error) {
|
|
199
|
-
throw new EncryptionError('Failed to delete database encryption key', EncryptionErrorCode.KEY_STORAGE_ERROR, { originalError: error });
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Rotate the database encryption key
|
|
205
|
-
*
|
|
206
|
-
* Generates a new key and returns both old and new keys.
|
|
207
|
-
* Caller is responsible for:
|
|
208
|
-
* 1. Re-encrypting all storage with new key
|
|
209
|
-
* 2. Storing new key
|
|
210
|
-
* 3. Deleting old key
|
|
211
|
-
*
|
|
212
|
-
* @returns Object with oldKey and newKey
|
|
213
|
-
*/
|
|
214
|
-
async rotateKey() {
|
|
215
|
-
try {
|
|
216
|
-
// Get existing key
|
|
217
|
-
const oldKey = await this.getKeyOrThrow();
|
|
218
|
-
// Generate new key
|
|
219
|
-
const newKeyBytes = new Uint8Array(randomBytes(DB_KEY_SIZE));
|
|
220
|
-
return { oldKey, newKey: newKeyBytes };
|
|
221
|
-
}
|
|
222
|
-
catch (error) {
|
|
223
|
-
throw new EncryptionError('Failed to rotate database encryption key', EncryptionErrorCode.KEY_STORAGE_ERROR, { originalError: error });
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Complete key rotation after re-encryption
|
|
228
|
-
*
|
|
229
|
-
* Stores the new key and clears cache.
|
|
230
|
-
* Call this AFTER successfully re-encrypting all data.
|
|
231
|
-
*
|
|
232
|
-
* @param newKey The new database encryption key
|
|
233
|
-
*/
|
|
234
|
-
async completeKeyRotation(newKey) {
|
|
235
|
-
return withNodeDatabaseLock(this.dataDir, async () => {
|
|
236
|
-
try {
|
|
237
|
-
// Validate key size
|
|
238
|
-
if (newKey.length !== DB_KEY_SIZE) {
|
|
239
|
-
throw new Error(`Invalid key size: expected ${DB_KEY_SIZE} bytes`);
|
|
240
|
-
}
|
|
241
|
-
// Store new key
|
|
242
|
-
await this.readKeyLocked();
|
|
243
|
-
await commitNodeDatabaseFile(this.keyFilePath, newKey);
|
|
244
|
-
// Update cache
|
|
245
|
-
this.cachedKey = newKey;
|
|
246
|
-
}
|
|
247
|
-
catch (error) {
|
|
248
|
-
throw new EncryptionError('Failed to complete database key rotation', EncryptionErrorCode.KEY_STORAGE_ERROR, { originalError: error });
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Clear cached key (security: minimize key in memory)
|
|
254
|
-
*
|
|
255
|
-
* Forces next getKey() to read from filesystem.
|
|
256
|
-
* Call this when application exits.
|
|
257
|
-
*/
|
|
258
|
-
clearCache() {
|
|
259
|
-
this.cachedKey = null;
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Get the key file path for diagnostics.
|
|
263
|
-
*/
|
|
264
|
-
getKeyFilePath() {
|
|
265
|
-
return this.keyFilePath;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Singleton instance
|
|
270
|
-
*/
|
|
271
|
-
let dbKeyManagerInstance = null;
|
|
272
|
-
/**
|
|
273
|
-
* Get singleton NodeDatabaseKeyManager instance
|
|
274
|
-
*
|
|
275
|
-
* @param dataDir Optional custom data directory
|
|
276
|
-
*/
|
|
277
|
-
export function getNodeDatabaseKeyManager(dataDir) {
|
|
278
|
-
if (!dbKeyManagerInstance ||
|
|
279
|
-
(dataDir && dbKeyManagerInstance.getKeyFilePath() !== join(dataDir, DB_KEY_FILENAME))) {
|
|
280
|
-
dbKeyManagerInstance = new NodeDatabaseKeyManager(dataDir);
|
|
281
|
-
}
|
|
282
|
-
return dbKeyManagerInstance;
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Reset the singleton for controlled local teardown.
|
|
286
|
-
*/
|
|
287
|
-
export function resetNodeDatabaseKeyManager() {
|
|
288
|
-
if (dbKeyManagerInstance) {
|
|
289
|
-
dbKeyManagerInstance.clearCache();
|
|
290
|
-
}
|
|
291
|
-
dbKeyManagerInstance = null;
|
|
292
|
-
}
|
|
293
|
-
//# sourceMappingURL=database-key.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"database-key.js","sourceRoot":"","sources":["../../../../local/store/node/database-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC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,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF;AAED;;GAEG;AACH,IAAI,oBAAoB,GAAkC,IAAI,CAAC;AAE/D;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,OAAgB;IACxD,IACE,CAAC,oBAAoB;QACrB,CAAC,OAAO,IAAI,oBAAoB,CAAC,cAAc,EAAE,KAAK,IAAI,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,EACrF,CAAC;QACD,oBAAoB,GAAG,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B;IACzC,IAAI,oBAAoB,EAAE,CAAC;QACzB,oBAAoB,CAAC,UAAU,EAAE,CAAC;IACpC,CAAC;IACD,oBAAoB,GAAG,IAAI,CAAC;AAC9B,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const NODE_DATABASE_LOCK_FILE = ".database.lock";
|
|
2
|
-
/**
|
|
3
|
-
* The persistent inode coordinates every handle, including directory aliases.
|
|
4
|
-
* Never unlink this file during reset. An unlinked lock can admit another writer.
|
|
5
|
-
* Process exit releases the kernel lock. No timestamp authorizes a takeover.
|
|
6
|
-
*/
|
|
7
|
-
export declare function withNodeDatabaseLock<T>(dataDir: string, operation: () => Promise<T>, timeoutMs?: number): Promise<T>;
|
|
8
|
-
//# sourceMappingURL=database-lock.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"database-lock.d.ts","sourceRoot":"","sources":["../../../../local/store/node/database-lock.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,uBAAuB,mBAAmB,CAAC;AAOxD;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,CAAC,EAC1C,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,SAAS,SAAS,GACjB,OAAO,CAAC,CAAC,CAAC,CAgCZ"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { mkdir, open } from "node:fs/promises";
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { performance } from "node:perf_hooks";
|
|
5
|
-
import { setTimeout } from "node:timers/promises";
|
|
6
|
-
const require = createRequire(import.meta.url);
|
|
7
|
-
export const NODE_DATABASE_LOCK_FILE = ".database.lock";
|
|
8
|
-
/**
|
|
9
|
-
* The persistent inode coordinates every handle, including directory aliases.
|
|
10
|
-
* Never unlink this file during reset. An unlinked lock can admit another writer.
|
|
11
|
-
* Process exit releases the kernel lock. No timestamp authorizes a takeover.
|
|
12
|
-
*/
|
|
13
|
-
export async function withNodeDatabaseLock(dataDir, operation, timeoutMs = 30_000) {
|
|
14
|
-
let native;
|
|
15
|
-
try {
|
|
16
|
-
native = require("fs-native-extensions");
|
|
17
|
-
}
|
|
18
|
-
catch {
|
|
19
|
-
throw new Error("Node storage requires fs-native-extensions. Install it before opening the store.");
|
|
20
|
-
}
|
|
21
|
-
await mkdir(dataDir, { recursive: true, mode: 0o700 });
|
|
22
|
-
const handle = await open(join(dataDir, NODE_DATABASE_LOCK_FILE), "a+", 0o600);
|
|
23
|
-
let locked = false;
|
|
24
|
-
const deadline = performance.now() + timeoutMs;
|
|
25
|
-
try {
|
|
26
|
-
while (!(locked = native.tryLock(handle.fd))) {
|
|
27
|
-
if (performance.now() >= deadline)
|
|
28
|
-
throw new Error("Node database is busy. Retry the operation.");
|
|
29
|
-
// Blocking native waits can exhaust the thread pool needed by the lock owner.
|
|
30
|
-
await setTimeout(10);
|
|
31
|
-
}
|
|
32
|
-
return await operation();
|
|
33
|
-
}
|
|
34
|
-
finally {
|
|
35
|
-
try {
|
|
36
|
-
if (locked)
|
|
37
|
-
native.unlock(handle.fd);
|
|
38
|
-
}
|
|
39
|
-
finally {
|
|
40
|
-
await handle.close();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=database-lock.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"database-lock.js","sourceRoot":"","sources":["../../../../local/store/node/database-lock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,CAAC,MAAM,uBAAuB,GAAG,gBAAgB,CAAC;AAOxD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAAe,EACf,SAA2B,EAC3B,SAAS,GAAG,MAAM;IAElB,IAAI,MAAsB,CAAC;IAC3B,IAAI,CAAC;QACH,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAmB,CAAC;IAC7D,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,kFAAkF,CACnF,CAAC;IACJ,CAAC;IACD,MAAM,KAAK,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACvD,MAAM,MAAM,GAAG,MAAM,IAAI,CACvB,IAAI,CAAC,OAAO,EAAE,uBAAuB,CAAC,EACtC,IAAI,EACJ,KAAK,CACN,CAAC;IACF,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;IA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