@open-e2ee/signal-protocol-sdk 7.2.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ADAPTERS.md +54 -7
- package/ARCHITECTURE.md +1 -0
- package/CHANGELOG.md +503 -0
- package/README.md +9 -5
- package/SECURITY.md +2 -2
- package/THIRD_PARTY_NOTICES.md +429 -0
- package/client/README.md +1 -2
- package/device/README.md +50 -19
- package/dist/client/client.d.ts +31 -5
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +149 -90
- package/dist/client/client.js.map +1 -1
- package/dist/client/event-hooks.d.ts.map +1 -1
- package/dist/client/event-hooks.js +2 -0
- package/dist/client/event-hooks.js.map +1 -1
- package/dist/client/files.d.ts.map +1 -1
- package/dist/client/files.js +19 -2
- package/dist/client/files.js.map +1 -1
- package/dist/client/headless.d.ts +1 -1
- package/dist/client/headless.js +1 -1
- package/dist/client/hosted-anonymous-delivery.d.ts.map +1 -1
- package/dist/client/hosted-anonymous-delivery.js +2 -1
- package/dist/client/hosted-anonymous-delivery.js.map +1 -1
- package/dist/client/hosted-connection.d.ts +1 -1
- package/dist/client/hosted-connection.d.ts.map +1 -1
- package/dist/client/hosted-connection.js +8 -12
- package/dist/client/hosted-connection.js.map +1 -1
- package/dist/client/hosted-group-authority.d.ts.map +1 -1
- package/dist/client/hosted-group-authority.js +2 -1
- package/dist/client/hosted-group-authority.js.map +1 -1
- package/dist/client/hosted-groups.d.ts.map +1 -1
- package/dist/client/hosted-groups.js +2 -1
- package/dist/client/hosted-groups.js.map +1 -1
- package/dist/client/hosted-push.d.ts.map +1 -1
- package/dist/client/hosted-push.js +2 -1
- package/dist/client/hosted-push.js.map +1 -1
- package/dist/client/hosted-transport.d.ts.map +1 -1
- package/dist/client/hosted-transport.js +10 -11
- package/dist/client/hosted-transport.js.map +1 -1
- package/dist/client/hosted-trust.d.ts +11 -11
- package/dist/client/hosted-trust.d.ts.map +1 -1
- package/dist/client/hosted-trust.js +12 -12
- package/dist/client/hosted-trust.js.map +1 -1
- package/dist/client/messages.d.ts.map +1 -1
- package/dist/client/messages.js +6 -1
- package/dist/client/messages.js.map +1 -1
- package/dist/client/multi-device.d.ts.map +1 -1
- package/dist/client/multi-device.js +2 -1
- package/dist/client/multi-device.js.map +1 -1
- package/dist/client/relay-work.d.ts +30 -0
- package/dist/client/relay-work.d.ts.map +1 -0
- package/dist/client/relay-work.js +189 -0
- package/dist/client/relay-work.js.map +1 -0
- package/dist/client/retry.d.ts.map +1 -1
- package/dist/client/retry.js +2 -0
- package/dist/client/retry.js.map +1 -1
- package/dist/client/sessions.d.ts.map +1 -1
- package/dist/client/sessions.js +3 -0
- package/dist/client/sessions.js.map +1 -1
- package/dist/client/signal-service-cipher.d.ts +19 -11
- package/dist/client/signal-service-cipher.d.ts.map +1 -1
- package/dist/client/signal-service-cipher.js +48 -46
- package/dist/client/signal-service-cipher.js.map +1 -1
- package/dist/client/state.d.ts +8 -0
- package/dist/client/state.d.ts.map +1 -1
- package/dist/client/state.js +11 -0
- package/dist/client/state.js.map +1 -1
- package/dist/device/connection.d.ts +1 -1
- package/dist/device/connection.d.ts.map +1 -1
- package/dist/device/connection.js +4 -11
- package/dist/device/connection.js.map +1 -1
- package/dist/device/device-id.d.ts +10 -4
- package/dist/device/device-id.d.ts.map +1 -1
- package/dist/device/device-id.js +15 -9
- package/dist/device/device-id.js.map +1 -1
- package/dist/device/device-name-crypto.d.ts.map +1 -1
- package/dist/device/device-name-crypto.js +2 -2
- package/dist/device/device-name-crypto.js.map +1 -1
- package/dist/device/expo/index.d.ts +25 -8
- package/dist/device/expo/index.d.ts.map +1 -1
- package/dist/device/expo/index.js +58 -8
- package/dist/device/expo/index.js.map +1 -1
- package/dist/device/index.d.ts +2 -2
- package/dist/device/index.d.ts.map +1 -1
- package/dist/device/index.js +3 -2
- package/dist/device/index.js.map +1 -1
- package/dist/device/lifecycle/index.d.ts +4 -2
- package/dist/device/lifecycle/index.d.ts.map +1 -1
- package/dist/device/lifecycle/index.js.map +1 -1
- package/dist/device/lifecycle/manager.d.ts +12 -14
- package/dist/device/lifecycle/manager.d.ts.map +1 -1
- package/dist/device/lifecycle/manager.js +52 -97
- package/dist/device/lifecycle/manager.js.map +1 -1
- package/dist/device/lifecycle/types.d.ts +26 -16
- package/dist/device/lifecycle/types.d.ts.map +1 -1
- package/dist/device/lifecycle/utils.d.ts +8 -4
- package/dist/device/lifecycle/utils.d.ts.map +1 -1
- package/dist/device/lifecycle/utils.js +12 -16
- package/dist/device/lifecycle/utils.js.map +1 -1
- package/dist/device/provisioning.d.ts.map +1 -1
- package/dist/device/provisioning.js +6 -8
- package/dist/device/provisioning.js.map +1 -1
- package/dist/device/react-native/index.d.ts +40 -0
- package/dist/device/react-native/index.d.ts.map +1 -0
- package/dist/device/react-native/index.js +74 -0
- package/dist/device/react-native/index.js.map +1 -0
- package/dist/device/transfer.d.ts +15 -7
- package/dist/device/transfer.d.ts.map +1 -1
- package/dist/device/transfer.js +30 -22
- package/dist/device/transfer.js.map +1 -1
- package/dist/device/types.d.ts +15 -7
- package/dist/device/types.d.ts.map +1 -1
- package/dist/device/types.js.map +1 -1
- package/dist/device/vault-text.d.ts +13 -0
- package/dist/device/vault-text.d.ts.map +1 -0
- package/dist/device/vault-text.js +17 -0
- package/dist/device/vault-text.js.map +1 -0
- package/dist/index.d.ts +9 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/internal/crypto/index.d.ts +3 -3
- package/dist/internal/crypto/index.d.ts.map +1 -1
- package/dist/internal/crypto/index.js +3 -3
- package/dist/internal/crypto/index.js.map +1 -1
- package/dist/internal/crypto/random-host.d.ts +1 -1
- package/dist/internal/crypto/random-host.d.ts.map +1 -1
- package/dist/internal/crypto/random-host.js +3 -2
- package/dist/internal/crypto/random-host.js.map +1 -1
- package/dist/internal/crypto/random-host.native.d.ts +6 -1
- package/dist/internal/crypto/random-host.native.d.ts.map +1 -1
- package/dist/internal/crypto/random-host.native.js +14 -10
- package/dist/internal/crypto/random-host.native.js.map +1 -1
- package/dist/internal/crypto/random-host.node.d.ts +1 -1
- package/dist/internal/crypto/random-host.node.d.ts.map +1 -1
- package/dist/internal/crypto/random-host.node.js +1 -1
- package/dist/internal/crypto/random-host.node.js.map +1 -1
- package/dist/internal/crypto/random.d.ts +12 -3
- package/dist/internal/crypto/random.d.ts.map +1 -1
- package/dist/internal/crypto/random.js +14 -3
- package/dist/internal/crypto/random.js.map +1 -1
- package/dist/internal/crypto/utils.d.ts.map +1 -1
- package/dist/internal/crypto/utils.js +10 -6
- package/dist/internal/crypto/utils.js.map +1 -1
- package/dist/internal/encoding/proto/primitives.d.ts +2 -0
- package/dist/internal/encoding/proto/primitives.d.ts.map +1 -1
- package/dist/internal/encoding/proto/primitives.js +2 -1
- package/dist/internal/encoding/proto/primitives.js.map +1 -1
- package/dist/internal/encoding/proto/signal-message.d.ts +1 -0
- package/dist/internal/encoding/proto/signal-message.d.ts.map +1 -1
- package/dist/internal/encoding/proto/signal-message.js +2 -1
- package/dist/internal/encoding/proto/signal-message.js.map +1 -1
- package/dist/internal/groups/authority-certificate.d.ts.map +1 -1
- package/dist/internal/groups/authority-certificate.js +2 -1
- package/dist/internal/groups/authority-certificate.js.map +1 -1
- package/dist/internal/groups/encrypted-state.d.ts.map +1 -1
- package/dist/internal/groups/encrypted-state.js +9 -7
- package/dist/internal/groups/encrypted-state.js.map +1 -1
- package/dist/internal/groups/invite-link.d.ts.map +1 -1
- package/dist/internal/groups/invite-link.js +2 -1
- package/dist/internal/groups/invite-link.js.map +1 -1
- package/dist/internal/groups/manager.d.ts.map +1 -1
- package/dist/internal/groups/manager.js +5 -5
- package/dist/internal/groups/manager.js.map +1 -1
- package/dist/internal/groups/sdk-store.d.ts.map +1 -1
- package/dist/internal/groups/sdk-store.js +4 -3
- package/dist/internal/groups/sdk-store.js.map +1 -1
- package/dist/internal/groups/server-engine.d.ts +6 -1
- package/dist/internal/groups/server-engine.d.ts.map +1 -1
- package/dist/internal/groups/server-engine.js +11 -15
- package/dist/internal/groups/server-engine.js.map +1 -1
- package/dist/internal/groups/wire.d.ts.map +1 -1
- package/dist/internal/groups/wire.js +2 -1
- package/dist/internal/groups/wire.js.map +1 -1
- package/dist/internal/platform/blob.d.ts +10 -0
- package/dist/internal/platform/blob.d.ts.map +1 -0
- package/dist/internal/platform/blob.js +30 -0
- package/dist/internal/platform/blob.js.map +1 -0
- package/dist/internal/platform/env.d.ts +13 -0
- package/dist/internal/platform/env.d.ts.map +1 -0
- package/dist/internal/platform/env.js +17 -0
- package/dist/internal/platform/env.js.map +1 -0
- package/dist/internal/platform/index.d.ts +5 -0
- package/dist/internal/platform/index.d.ts.map +1 -0
- package/dist/internal/platform/index.js +5 -0
- package/dist/internal/platform/index.js.map +1 -0
- package/dist/internal/platform/url.d.ts +72 -0
- package/dist/internal/platform/url.d.ts.map +1 -0
- package/dist/internal/platform/url.js +275 -0
- package/dist/internal/platform/url.js.map +1 -0
- package/dist/internal/platform/utf8.d.ts +28 -0
- package/dist/internal/platform/utf8.d.ts.map +1 -0
- package/dist/internal/platform/utf8.js +167 -0
- package/dist/internal/platform/utf8.js.map +1 -0
- package/dist/internal/protocol/sealed-sender/delivery-token.d.ts +1 -1
- package/dist/internal/protocol/sealed-sender/delivery-token.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/delivery-token.js +5 -10
- package/dist/internal/protocol/sealed-sender/delivery-token.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/proto/index.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/proto/index.js +2 -4
- package/dist/internal/protocol/sealed-sender/proto/index.js.map +1 -1
- package/dist/internal/protocol/sender-keys/manager.d.ts.map +1 -1
- package/dist/internal/protocol/sender-keys/manager.js +4 -3
- package/dist/internal/protocol/sender-keys/manager.js.map +1 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.d.ts +4 -4
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.js +8 -10
- package/dist/internal/protocol/spqr/ml-kem-braid/noble-pq/index.js.map +1 -1
- package/dist/internal/protocol/username/hash.d.ts.map +1 -1
- package/dist/internal/protocol/username/hash.js +18 -3
- package/dist/internal/protocol/username/hash.js.map +1 -1
- package/dist/internal/protocol/username/link.d.ts.map +1 -1
- package/dist/internal/protocol/username/link.js +2 -1
- package/dist/internal/protocol/username/link.js.map +1 -1
- package/dist/internal/protocol/username/proof.d.ts.map +1 -1
- package/dist/internal/protocol/username/proof.js +2 -1
- package/dist/internal/protocol/username/proof.js.map +1 -1
- package/dist/internal/sesame/device-registry.d.ts +16 -3
- package/dist/internal/sesame/device-registry.d.ts.map +1 -1
- package/dist/internal/sesame/device-registry.js +10 -7
- package/dist/internal/sesame/device-registry.js.map +1 -1
- package/dist/internal/sesame/index.d.ts +1 -1
- package/dist/internal/sesame/index.d.ts.map +1 -1
- package/dist/internal/sesame/manager.d.ts.map +1 -1
- package/dist/internal/sesame/manager.js +3 -2
- package/dist/internal/sesame/manager.js.map +1 -1
- package/dist/internal/session/index.d.ts +1 -2
- package/dist/internal/session/index.d.ts.map +1 -1
- package/dist/internal/session/index.js +1 -1
- package/dist/internal/session/index.js.map +1 -1
- package/dist/internal/session/validation.d.ts +0 -80
- package/dist/internal/session/validation.d.ts.map +1 -1
- package/dist/internal/session/validation.js +0 -134
- package/dist/internal/session/validation.js.map +1 -1
- package/dist/local/store/device-record.d.ts +18 -0
- package/dist/local/store/device-record.d.ts.map +1 -0
- package/dist/local/store/device-record.js +34 -0
- package/dist/local/store/device-record.js.map +1 -0
- package/dist/local/store/expo/adapter.d.ts +59 -238
- package/dist/local/store/expo/adapter.d.ts.map +1 -1
- package/dist/local/store/expo/adapter.js +83 -640
- package/dist/local/store/expo/adapter.js.map +1 -1
- package/dist/local/store/expo/driver.d.ts +16 -0
- package/dist/local/store/expo/driver.d.ts.map +1 -0
- package/dist/local/store/expo/driver.js +141 -0
- package/dist/local/store/expo/driver.js.map +1 -0
- package/dist/local/store/expo/index.d.ts +3 -12
- package/dist/local/store/expo/index.d.ts.map +1 -1
- package/dist/local/store/expo/index.js +1 -8
- package/dist/local/store/expo/index.js.map +1 -1
- package/dist/local/store/expo/maintenance.d.ts +3 -2
- package/dist/local/store/expo/maintenance.d.ts.map +1 -1
- package/dist/local/store/expo/maintenance.js +5 -34
- package/dist/local/store/expo/maintenance.js.map +1 -1
- package/dist/local/store/index.d.ts +10 -5
- package/dist/local/store/index.d.ts.map +1 -1
- package/dist/local/store/index.js +10 -5
- package/dist/local/store/index.js.map +1 -1
- package/dist/local/store/key-value/adapter.d.ts +326 -0
- package/dist/local/store/key-value/adapter.d.ts.map +1 -0
- package/dist/local/store/key-value/adapter.js +1472 -0
- package/dist/local/store/key-value/adapter.js.map +1 -0
- package/dist/local/store/{react-native → key-value}/backend-conformance.d.ts +6 -6
- package/dist/local/store/key-value/backend-conformance.d.ts.map +1 -0
- package/dist/local/store/{react-native → key-value}/backend-conformance.js +3 -3
- package/dist/local/store/key-value/backend-conformance.js.map +1 -0
- package/dist/local/store/key-value/batch.d.ts +41 -0
- package/dist/local/store/key-value/batch.d.ts.map +1 -0
- package/dist/local/store/key-value/batch.js +77 -0
- package/dist/local/store/key-value/batch.js.map +1 -0
- package/dist/local/store/key-value/device-record.d.ts +23 -0
- package/dist/local/store/key-value/device-record.d.ts.map +1 -0
- package/dist/local/store/key-value/device-record.js +33 -0
- package/dist/local/store/key-value/device-record.js.map +1 -0
- package/dist/local/store/key-value/index.d.ts +24 -0
- package/dist/local/store/key-value/index.d.ts.map +1 -0
- package/dist/local/store/key-value/index.js +8 -0
- package/dist/local/store/key-value/index.js.map +1 -0
- package/dist/local/store/key-value/realm/index.d.ts +83 -0
- package/dist/local/store/key-value/realm/index.d.ts.map +1 -0
- package/dist/local/store/key-value/realm/index.js +102 -0
- package/dist/local/store/key-value/realm/index.js.map +1 -0
- package/dist/local/store/{react-native → key-value}/storage.d.ts +6 -6
- package/dist/local/store/key-value/storage.d.ts.map +1 -0
- package/dist/local/store/key-value/storage.js.map +1 -0
- package/dist/local/store/key-value/transactional-backend.d.ts +50 -0
- package/dist/local/store/key-value/transactional-backend.d.ts.map +1 -0
- package/dist/local/store/key-value/transactional-backend.js +90 -0
- package/dist/local/store/key-value/transactional-backend.js.map +1 -0
- package/dist/local/store/key-value/value-key.d.ts +34 -0
- package/dist/local/store/key-value/value-key.d.ts.map +1 -0
- package/dist/local/store/key-value/value-key.js +83 -0
- package/dist/local/store/key-value/value-key.js.map +1 -0
- package/dist/local/store/memory/adapter.d.ts +8 -0
- package/dist/local/store/memory/adapter.d.ts.map +1 -1
- package/dist/local/store/memory/adapter.js +60 -75
- package/dist/local/store/memory/adapter.js.map +1 -1
- package/dist/local/store/node/adapter.d.ts +74 -130
- package/dist/local/store/node/adapter.d.ts.map +1 -1
- package/dist/local/store/node/adapter.js +83 -727
- package/dist/local/store/node/adapter.js.map +1 -1
- package/dist/local/store/node/index.d.ts +8 -6
- package/dist/local/store/node/index.d.ts.map +1 -1
- package/dist/local/store/node/index.js +3 -7
- package/dist/local/store/node/index.js.map +1 -1
- package/dist/local/store/node/maintenance.d.ts +5 -0
- package/dist/local/store/node/maintenance.d.ts.map +1 -0
- package/dist/local/store/node/maintenance.js +7 -0
- package/dist/local/store/node/maintenance.js.map +1 -0
- package/dist/local/store/node/owner-lock.d.ts +26 -0
- package/dist/local/store/node/owner-lock.d.ts.map +1 -0
- package/dist/local/store/node/owner-lock.js +88 -0
- package/dist/local/store/node/owner-lock.js.map +1 -0
- package/dist/local/store/react-native/adapter.d.ts +63 -274
- package/dist/local/store/react-native/adapter.d.ts.map +1 -1
- package/dist/local/store/react-native/adapter.js +80 -1406
- package/dist/local/store/react-native/adapter.js.map +1 -1
- package/dist/local/store/react-native/index.d.ts +7 -19
- package/dist/local/store/react-native/index.d.ts.map +1 -1
- package/dist/local/store/react-native/index.js +2 -7
- package/dist/local/store/react-native/index.js.map +1 -1
- package/dist/local/store/react-native/maintenance.d.ts +5 -0
- package/dist/local/store/react-native/maintenance.d.ts.map +1 -0
- package/dist/local/store/react-native/maintenance.js +7 -0
- package/dist/local/store/react-native/maintenance.js.map +1 -0
- package/dist/local/store/sqlite/better-sqlite3-multiple-ciphers-driver.d.ts +38 -0
- package/dist/local/store/sqlite/better-sqlite3-multiple-ciphers-driver.d.ts.map +1 -0
- package/dist/local/store/sqlite/better-sqlite3-multiple-ciphers-driver.js +196 -0
- package/dist/local/store/sqlite/better-sqlite3-multiple-ciphers-driver.js.map +1 -0
- package/dist/local/store/sqlite/database.d.ts +20 -0
- package/dist/local/store/sqlite/database.d.ts.map +1 -0
- package/dist/local/store/sqlite/database.js +41 -0
- package/dist/local/store/sqlite/database.js.map +1 -0
- package/dist/local/store/sqlite/driver.d.ts +138 -0
- package/dist/local/store/sqlite/driver.d.ts.map +1 -0
- package/dist/local/store/sqlite/driver.js +10 -0
- package/dist/local/store/sqlite/driver.js.map +1 -0
- package/dist/local/store/sqlite/encryption.d.ts +61 -0
- package/dist/local/store/sqlite/encryption.d.ts.map +1 -0
- package/dist/local/store/sqlite/encryption.js +98 -0
- package/dist/local/store/sqlite/encryption.js.map +1 -0
- package/dist/local/store/sqlite/errors.d.ts +70 -0
- package/dist/local/store/sqlite/errors.d.ts.map +1 -0
- package/dist/local/store/sqlite/errors.js +101 -0
- package/dist/local/store/sqlite/errors.js.map +1 -0
- package/dist/local/store/sqlite/executor.d.ts +22 -0
- package/dist/local/store/sqlite/executor.d.ts.map +1 -0
- package/dist/local/store/sqlite/executor.js +129 -0
- package/dist/local/store/sqlite/executor.js.map +1 -0
- package/dist/local/store/sqlite/index.d.ts +20 -0
- package/dist/local/store/sqlite/index.d.ts.map +1 -0
- package/dist/local/store/sqlite/index.js +18 -0
- package/dist/local/store/sqlite/index.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/account.d.ts +45 -0
- package/dist/local/store/sqlite/key-storage/account.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/account.js +125 -0
- package/dist/local/store/sqlite/key-storage/account.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/contact-identities.d.ts +19 -0
- package/dist/local/store/sqlite/key-storage/contact-identities.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/contact-identities.js +85 -0
- package/dist/local/store/sqlite/key-storage/contact-identities.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/context.d.ts +19 -0
- package/dist/local/store/sqlite/key-storage/context.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/context.js +18 -0
- package/dist/local/store/sqlite/key-storage/context.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/identity-keys.d.ts +18 -0
- package/dist/local/store/sqlite/key-storage/identity-keys.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/identity-keys.js +88 -0
- package/dist/local/store/sqlite/key-storage/identity-keys.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/index.d.ts +108 -0
- package/dist/local/store/sqlite/key-storage/index.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/index.js +241 -0
- package/dist/local/store/sqlite/key-storage/index.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/message-records.d.ts +41 -0
- package/dist/local/store/sqlite/key-storage/message-records.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/message-records.js +133 -0
- package/dist/local/store/sqlite/key-storage/message-records.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/metadata.d.ts +16 -0
- package/dist/local/store/sqlite/key-storage/metadata.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/metadata.js +53 -0
- package/dist/local/store/sqlite/key-storage/metadata.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/one-time-prekeys.d.ts +36 -0
- package/dist/local/store/sqlite/key-storage/one-time-prekeys.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/one-time-prekeys.js +129 -0
- package/dist/local/store/sqlite/key-storage/one-time-prekeys.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/session-trust.d.ts +10 -0
- package/dist/local/store/sqlite/key-storage/session-trust.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/session-trust.js +88 -0
- package/dist/local/store/sqlite/key-storage/session-trust.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/sessions.d.ts +50 -0
- package/dist/local/store/sqlite/key-storage/sessions.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/sessions.js +209 -0
- package/dist/local/store/sqlite/key-storage/sessions.js.map +1 -0
- package/dist/local/store/sqlite/key-storage/signed-prekeys.d.ts +69 -0
- package/dist/local/store/sqlite/key-storage/signed-prekeys.d.ts.map +1 -0
- package/dist/local/store/sqlite/key-storage/signed-prekeys.js +219 -0
- package/dist/local/store/sqlite/key-storage/signed-prekeys.js.map +1 -0
- package/dist/local/store/sqlite/maintenance.d.ts +7 -0
- package/dist/local/store/sqlite/maintenance.d.ts.map +1 -0
- package/dist/local/store/sqlite/maintenance.js +32 -0
- package/dist/local/store/sqlite/maintenance.js.map +1 -0
- package/dist/local/store/sqlite/migrations.d.ts +31 -0
- package/dist/local/store/sqlite/migrations.d.ts.map +1 -0
- package/dist/local/store/sqlite/migrations.js +232 -0
- package/dist/local/store/sqlite/migrations.js.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/ec-one-time-prekey.d.ts +17 -22
- package/dist/local/store/sqlite/models/ec-one-time-prekey.d.ts.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/ec-one-time-prekey.js +61 -99
- package/dist/local/store/sqlite/models/ec-one-time-prekey.js.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/ec-signed-prekey.d.ts +22 -25
- package/dist/local/store/sqlite/models/ec-signed-prekey.d.ts.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/ec-signed-prekey.js +82 -128
- package/dist/local/store/sqlite/models/ec-signed-prekey.js.map +1 -0
- package/dist/local/store/sqlite/models/identity-key-id.d.ts.map +1 -0
- package/dist/local/store/sqlite/models/identity-key-id.js.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/index.d.ts +5 -5
- package/dist/local/store/sqlite/models/index.d.ts.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/index.js +12 -5
- package/dist/local/store/sqlite/models/index.js.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/kyber-one-time-prekey.d.ts +17 -20
- package/dist/local/store/sqlite/models/kyber-one-time-prekey.d.ts.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/kyber-one-time-prekey.js +65 -105
- package/dist/local/store/sqlite/models/kyber-one-time-prekey.js.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/kyber-prekey-used.d.ts +3 -3
- package/dist/local/store/sqlite/models/kyber-prekey-used.d.ts.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/kyber-prekey-used.js +13 -25
- package/dist/local/store/sqlite/models/kyber-prekey-used.js.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/kyber-prekey.d.ts +16 -19
- package/dist/local/store/sqlite/models/kyber-prekey.d.ts.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/kyber-prekey.js +67 -111
- package/dist/local/store/sqlite/models/kyber-prekey.js.map +1 -0
- package/dist/local/store/sqlite/models/local-identity.d.ts +51 -0
- package/dist/local/store/sqlite/models/local-identity.d.ts.map +1 -0
- package/dist/local/store/sqlite/models/local-identity.js +150 -0
- package/dist/local/store/sqlite/models/local-identity.js.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/message-record.d.ts +15 -44
- package/dist/local/store/sqlite/models/message-record.d.ts.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/message-record.js +43 -109
- package/dist/local/store/sqlite/models/message-record.js.map +1 -0
- package/dist/local/store/sqlite/models/recipient-identity.d.ts +21 -0
- package/dist/local/store/sqlite/models/recipient-identity.d.ts.map +1 -0
- package/dist/local/store/sqlite/models/recipient-identity.js +59 -0
- package/dist/local/store/sqlite/models/recipient-identity.js.map +1 -0
- package/dist/local/store/sqlite/models/replaced-prekeys.d.ts +23 -0
- package/dist/local/store/sqlite/models/replaced-prekeys.d.ts.map +1 -0
- package/dist/local/store/sqlite/models/replaced-prekeys.js +42 -0
- package/dist/local/store/sqlite/models/replaced-prekeys.js.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/sender-key.d.ts +22 -23
- package/dist/local/store/sqlite/models/sender-key.d.ts.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/sender-key.js +66 -94
- package/dist/local/store/sqlite/models/sender-key.js.map +1 -0
- package/dist/local/store/sqlite/models/sesame-user-record.d.ts +32 -0
- package/dist/local/store/sqlite/models/sesame-user-record.d.ts.map +1 -0
- package/dist/local/store/sqlite/models/sesame-user-record.js +78 -0
- package/dist/local/store/sqlite/models/sesame-user-record.js.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/session.d.ts +24 -20
- package/dist/local/store/sqlite/models/session.d.ts.map +1 -0
- package/dist/local/store/{expo → sqlite}/models/session.js +54 -72
- package/dist/local/store/sqlite/models/session.js.map +1 -0
- package/dist/local/store/sqlite/models/skipped-sender-key.d.ts +24 -0
- package/dist/local/store/sqlite/models/skipped-sender-key.d.ts.map +1 -0
- package/dist/local/store/sqlite/models/skipped-sender-key.js +62 -0
- package/dist/local/store/sqlite/models/skipped-sender-key.js.map +1 -0
- package/dist/local/store/sqlite/op-sqlite-driver.d.ts +14 -0
- package/dist/local/store/sqlite/op-sqlite-driver.d.ts.map +1 -0
- package/dist/local/store/sqlite/op-sqlite-driver.js +180 -0
- package/dist/local/store/sqlite/op-sqlite-driver.js.map +1 -0
- package/dist/local/store/sqlite/open-store.d.ts +83 -0
- package/dist/local/store/sqlite/open-store.d.ts.map +1 -0
- package/dist/local/store/sqlite/open-store.js +177 -0
- package/dist/local/store/sqlite/open-store.js.map +1 -0
- package/dist/local/store/sqlite/schema.d.ts +102 -0
- package/dist/local/store/sqlite/schema.d.ts.map +1 -0
- package/dist/local/store/sqlite/schema.js +61 -0
- package/dist/local/store/sqlite/schema.js.map +1 -0
- package/dist/local/store/sqlite/store.d.ts +199 -0
- package/dist/local/store/sqlite/store.d.ts.map +1 -0
- package/dist/local/store/sqlite/store.js +494 -0
- package/dist/local/store/sqlite/store.js.map +1 -0
- package/dist/local/store/sqlite/web/driver.d.ts +50 -0
- package/dist/local/store/sqlite/web/driver.d.ts.map +1 -0
- package/dist/local/store/sqlite/web/driver.js +169 -0
- package/dist/local/store/sqlite/web/driver.js.map +1 -0
- package/dist/local/store/sqlite/web/protocol.d.ts +80 -0
- package/dist/local/store/sqlite/web/protocol.d.ts.map +1 -0
- package/dist/local/store/sqlite/web/protocol.js +13 -0
- package/dist/local/store/sqlite/web/protocol.js.map +1 -0
- package/dist/local/store/sqlite/web/sqlite3mc/sqlite3.mjs +14526 -0
- package/dist/local/store/sqlite/web/sqlite3mc/sqlite3.wasm +0 -0
- package/dist/local/store/sqlite/web/worker.d.ts +36 -0
- package/dist/local/store/sqlite/web/worker.d.ts.map +1 -0
- package/dist/local/store/sqlite/web/worker.js +616 -0
- package/dist/local/store/sqlite/web/worker.js.map +1 -0
- package/dist/local/store/web/adapter.d.ts +5 -14
- package/dist/local/store/web/adapter.d.ts.map +1 -1
- package/dist/local/store/web/adapter.js +119 -106
- package/dist/local/store/web/adapter.js.map +1 -1
- package/dist/local/store/web/device-record.d.ts +23 -0
- package/dist/local/store/web/device-record.d.ts.map +1 -0
- package/dist/local/store/web/device-record.js +31 -0
- package/dist/local/store/web/device-record.js.map +1 -0
- package/dist/local/store/web-sqlite/adapter.d.ts +98 -0
- package/dist/local/store/web-sqlite/adapter.d.ts.map +1 -0
- package/dist/local/store/web-sqlite/adapter.js +151 -0
- package/dist/local/store/web-sqlite/adapter.js.map +1 -0
- package/dist/local/store/web-sqlite/index.d.ts +14 -0
- package/dist/local/store/web-sqlite/index.d.ts.map +1 -0
- package/dist/local/store/web-sqlite/index.js +3 -0
- package/dist/local/store/web-sqlite/index.js.map +1 -0
- package/dist/local/store/web-sqlite/maintenance.d.ts +5 -0
- package/dist/local/store/web-sqlite/maintenance.d.ts.map +1 -0
- package/dist/local/store/web-sqlite/maintenance.js +7 -0
- package/dist/local/store/web-sqlite/maintenance.js.map +1 -0
- package/dist/local/store/web-sqlite/store-locks.d.ts +33 -0
- package/dist/local/store/web-sqlite/store-locks.d.ts.map +1 -0
- package/dist/local/store/web-sqlite/store-locks.js +60 -0
- package/dist/local/store/web-sqlite/store-locks.js.map +1 -0
- package/dist/local/vault/electron-safe-storage.d.ts +45 -0
- package/dist/local/vault/electron-safe-storage.d.ts.map +1 -0
- package/dist/local/vault/electron-safe-storage.js +212 -0
- package/dist/local/vault/electron-safe-storage.js.map +1 -0
- package/dist/local/vault/index.d.ts +4 -2
- package/dist/local/vault/index.d.ts.map +1 -1
- package/dist/local/vault/indexed-db.d.ts +37 -0
- package/dist/local/vault/indexed-db.d.ts.map +1 -0
- package/dist/local/vault/indexed-db.js +102 -0
- package/dist/local/vault/indexed-db.js.map +1 -0
- package/dist/local/vault/react-native-keychain.d.ts +12 -0
- package/dist/local/vault/react-native-keychain.d.ts.map +1 -0
- package/dist/local/vault/react-native-keychain.js +71 -0
- package/dist/local/vault/react-native-keychain.js.map +1 -0
- package/dist/local/vault/require.d.ts +10 -0
- package/dist/local/vault/require.d.ts.map +1 -0
- package/dist/local/vault/require.js +16 -0
- package/dist/local/vault/require.js.map +1 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +2 -1
- package/dist/logger.js.map +1 -1
- package/dist/media/index.d.ts.map +1 -1
- package/dist/media/index.js +2 -1
- package/dist/media/index.js.map +1 -1
- package/dist/profile/contact-state.d.ts.map +1 -1
- package/dist/profile/contact-state.js +2 -4
- package/dist/profile/contact-state.js.map +1 -1
- package/dist/profile/index.d.ts +0 -1
- package/dist/profile/index.d.ts.map +1 -1
- package/dist/profile/index.js +0 -2
- package/dist/profile/index.js.map +1 -1
- package/dist/profile/profile-key.d.ts +16 -11
- package/dist/profile/profile-key.d.ts.map +1 -1
- package/dist/profile/profile-key.js +29 -29
- package/dist/profile/profile-key.js.map +1 -1
- package/dist/profile/update-service.d.ts +6 -0
- package/dist/profile/update-service.d.ts.map +1 -1
- package/dist/profile/update-service.js +3 -1
- package/dist/profile/update-service.js.map +1 -1
- package/dist/remote/object-store/validation.d.ts.map +1 -1
- package/dist/remote/object-store/validation.js +2 -1
- package/dist/remote/object-store/validation.js.map +1 -1
- package/dist/remote/relay/memory/adapter.d.ts +2 -3
- package/dist/remote/relay/memory/adapter.d.ts.map +1 -1
- package/dist/remote/relay/memory/adapter.js +22 -30
- package/dist/remote/relay/memory/adapter.js.map +1 -1
- package/dist/remote/relay/memory/failures.d.ts.map +1 -1
- package/dist/remote/relay/memory/failures.js +2 -1
- package/dist/remote/relay/memory/failures.js.map +1 -1
- package/dist/remote/relay/memory/group-server.d.ts +5 -1
- package/dist/remote/relay/memory/group-server.d.ts.map +1 -1
- package/dist/remote/relay/memory/group-server.js +11 -1
- package/dist/remote/relay/memory/group-server.js.map +1 -1
- package/dist/safety/url.d.ts.map +1 -1
- package/dist/safety/url.js +21 -26
- package/dist/safety/url.js.map +1 -1
- package/dist/types/api.d.ts +15 -2
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/errors.d.ts +97 -1
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +105 -1
- package/dist/types/errors.js.map +1 -1
- package/dist/types/session.d.ts.map +1 -1
- package/dist/types/session.js +2 -1
- package/dist/types/session.js.map +1 -1
- package/dist/utils/retry.d.ts +2 -0
- package/dist/utils/retry.d.ts.map +1 -1
- package/dist/utils/retry.js +4 -2
- package/dist/utils/retry.js.map +1 -1
- package/docs/ASSURANCE.md +80 -8
- package/docs/CLIENT_COMPOSITION.md +1 -2
- package/docs/DEVIATIONS.md +1 -1
- package/docs/ERROR_HANDLING.md +6 -0
- package/docs/GETTING_STARTED.md +1 -2
- package/docs/PACKAGE_SURFACE.md +29 -11
- package/docs/RECIPES.md +1 -2
- package/examples/browser/index.html +1 -1
- package/local/store/README.md +117 -37
- package/local/store/expo/README.md +67 -47
- package/local/store/key-value/README.md +278 -0
- package/local/store/node/README.md +206 -46
- package/local/store/react-native/README.md +120 -61
- package/local/store/web/README.md +9 -0
- package/local/store/web-sqlite/README.md +202 -0
- package/local/vault/README.md +115 -2
- package/package.json +42 -23
- package/profile/README.md +9 -11
- package/remote/README.md +1 -2
- package/dist/local/store/expo/database-key.d.ts +0 -142
- package/dist/local/store/expo/database-key.d.ts.map +0 -1
- package/dist/local/store/expo/database-key.js +0 -312
- package/dist/local/store/expo/database-key.js.map +0 -1
- package/dist/local/store/expo/db.d.ts +0 -95
- package/dist/local/store/expo/db.d.ts.map +0 -1
- package/dist/local/store/expo/db.js +0 -147
- package/dist/local/store/expo/db.js.map +0 -1
- package/dist/local/store/expo/key-storage.d.ts +0 -429
- package/dist/local/store/expo/key-storage.d.ts.map +0 -1
- package/dist/local/store/expo/key-storage.js +0 -1361
- package/dist/local/store/expo/key-storage.js.map +0 -1
- package/dist/local/store/expo/models/ec-one-time-prekey.d.ts.map +0 -1
- package/dist/local/store/expo/models/ec-one-time-prekey.js.map +0 -1
- package/dist/local/store/expo/models/ec-signed-prekey.d.ts.map +0 -1
- package/dist/local/store/expo/models/ec-signed-prekey.js.map +0 -1
- package/dist/local/store/expo/models/identity-key-id.d.ts.map +0 -1
- package/dist/local/store/expo/models/identity-key-id.js.map +0 -1
- package/dist/local/store/expo/models/index.d.ts.map +0 -1
- package/dist/local/store/expo/models/index.js.map +0 -1
- package/dist/local/store/expo/models/kyber-one-time-prekey.d.ts.map +0 -1
- package/dist/local/store/expo/models/kyber-one-time-prekey.js.map +0 -1
- package/dist/local/store/expo/models/kyber-prekey-used.d.ts.map +0 -1
- package/dist/local/store/expo/models/kyber-prekey-used.js.map +0 -1
- package/dist/local/store/expo/models/kyber-prekey.d.ts.map +0 -1
- package/dist/local/store/expo/models/kyber-prekey.js.map +0 -1
- package/dist/local/store/expo/models/local-identity.d.ts +0 -52
- package/dist/local/store/expo/models/local-identity.d.ts.map +0 -1
- package/dist/local/store/expo/models/local-identity.js +0 -166
- package/dist/local/store/expo/models/local-identity.js.map +0 -1
- package/dist/local/store/expo/models/message-record.d.ts.map +0 -1
- package/dist/local/store/expo/models/message-record.js.map +0 -1
- package/dist/local/store/expo/models/recipient-identity.d.ts +0 -21
- package/dist/local/store/expo/models/recipient-identity.d.ts.map +0 -1
- package/dist/local/store/expo/models/recipient-identity.js +0 -66
- package/dist/local/store/expo/models/recipient-identity.js.map +0 -1
- package/dist/local/store/expo/models/replaced-prekey-utils.d.ts +0 -33
- package/dist/local/store/expo/models/replaced-prekey-utils.d.ts.map +0 -1
- package/dist/local/store/expo/models/replaced-prekey-utils.js +0 -54
- package/dist/local/store/expo/models/replaced-prekey-utils.js.map +0 -1
- package/dist/local/store/expo/models/sender-key.d.ts.map +0 -1
- package/dist/local/store/expo/models/sender-key.js.map +0 -1
- package/dist/local/store/expo/models/session.d.ts.map +0 -1
- package/dist/local/store/expo/models/session.js.map +0 -1
- package/dist/local/store/expo/schema.d.ts +0 -1917
- package/dist/local/store/expo/schema.d.ts.map +0 -1
- package/dist/local/store/expo/schema.js +0 -197
- package/dist/local/store/expo/schema.js.map +0 -1
- package/dist/local/store/node/database-encryption.d.ts +0 -109
- package/dist/local/store/node/database-encryption.d.ts.map +0 -1
- package/dist/local/store/node/database-encryption.js +0 -202
- package/dist/local/store/node/database-encryption.js.map +0 -1
- package/dist/local/store/node/database-file-commit.d.ts +0 -8
- package/dist/local/store/node/database-file-commit.d.ts.map +0 -1
- package/dist/local/store/node/database-file-commit.js +0 -62
- package/dist/local/store/node/database-file-commit.js.map +0 -1
- package/dist/local/store/node/database-key.d.ts +0 -129
- package/dist/local/store/node/database-key.d.ts.map +0 -1
- package/dist/local/store/node/database-key.js +0 -293
- package/dist/local/store/node/database-key.js.map +0 -1
- package/dist/local/store/node/database-lock.d.ts +0 -8
- package/dist/local/store/node/database-lock.d.ts.map +0 -1
- package/dist/local/store/node/database-lock.js +0 -44
- package/dist/local/store/node/database-lock.js.map +0 -1
- package/dist/local/store/node/database.d.ts +0 -226
- package/dist/local/store/node/database.d.ts.map +0 -1
- package/dist/local/store/node/database.js +0 -813
- package/dist/local/store/node/database.js.map +0 -1
- package/dist/local/store/react-native/backend-conformance.d.ts.map +0 -1
- package/dist/local/store/react-native/backend-conformance.js.map +0 -1
- package/dist/local/store/react-native/reference-backend.d.ts +0 -43
- package/dist/local/store/react-native/reference-backend.d.ts.map +0 -1
- package/dist/local/store/react-native/reference-backend.js +0 -178
- package/dist/local/store/react-native/reference-backend.js.map +0 -1
- package/dist/local/store/react-native/storage.d.ts.map +0 -1
- package/dist/local/store/react-native/storage.js.map +0 -1
- package/dist/profile/storage.d.ts +0 -61
- package/dist/profile/storage.d.ts.map +0 -1
- package/dist/profile/storage.js +0 -145
- package/dist/profile/storage.js.map +0 -1
- /package/dist/local/store/{react-native → key-value}/storage.js +0 -0
- /package/dist/local/store/{expo → sqlite}/models/identity-key-id.d.ts +0 -0
- /package/dist/local/store/{expo → sqlite}/models/identity-key-id.js +0 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PreKeyMaintenanceStore } from '../../../types/protocol-config.js';
|
|
2
|
+
import { type WebSqliteSignalProtocolStore } from './adapter.js';
|
|
3
|
+
/** Replaced-prekey maintenance on the database of an open store. */
|
|
4
|
+
export declare function createPreKeyMaintenanceStore(store: WebSqliteSignalProtocolStore): PreKeyMaintenanceStore;
|
|
5
|
+
//# sourceMappingURL=maintenance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maintenance.d.ts","sourceRoot":"","sources":["../../../../local/store/web-sqlite/maintenance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAE7E,OAAO,EAA0B,KAAK,4BAA4B,EAAE,MAAM,WAAW,CAAC;AAEtF,oEAAoE;AACpE,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,4BAA4B,GAClC,sBAAsB,CAExB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createSqlitePreKeyMaintenanceStore } from '../sqlite/maintenance.js';
|
|
2
|
+
import { webSqliteStoreDatabase } from './adapter.js';
|
|
3
|
+
/** Replaced-prekey maintenance on the database of an open store. */
|
|
4
|
+
export function createPreKeyMaintenanceStore(store) {
|
|
5
|
+
return createSqlitePreKeyMaintenanceStore(webSqliteStoreDatabase(store));
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=maintenance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maintenance.js","sourceRoot":"","sources":["../../../../local/store/web-sqlite/maintenance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kCAAkC,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAqC,MAAM,WAAW,CAAC;AAEtF,oEAAoE;AACpE,MAAM,UAAU,4BAA4B,CAC1C,KAAmC;IAEnC,OAAO,kCAAkC,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Web Locks that order the stores of one name across the tabs and
|
|
3
|
+
* workers of an origin.
|
|
4
|
+
*
|
|
5
|
+
* The open lock. A first open reads the vault, finds no key, checks that the
|
|
6
|
+
* file does not exist, writes a new key, and creates the file. Two tabs that
|
|
7
|
+
* run this sequence at the same time both find no key, and each writes its
|
|
8
|
+
* own key. The key that the vault keeps can then differ from the key that
|
|
9
|
+
* created the file, and the store cannot open that file again. So the entry
|
|
10
|
+
* holds one lock for each store name over the whole open or reset, and the
|
|
11
|
+
* next tab finds the key that the first tab wrote.
|
|
12
|
+
*
|
|
13
|
+
* The store lock. Each open store holds it in shared mode until it closes. A
|
|
14
|
+
* reset takes it in exclusive mode, and fails at once when a store of the
|
|
15
|
+
* name is open in any context. So a reset never deletes a file that another
|
|
16
|
+
* tab still uses. The reset runs inside the open lock, so no open can take
|
|
17
|
+
* the store lock between the reset and the new store.
|
|
18
|
+
*
|
|
19
|
+
* Both names differ from the name of the driver's file lock, which the
|
|
20
|
+
* driver's worker takes inside each call. The tabs share the file of an open
|
|
21
|
+
* store through the driver.
|
|
22
|
+
*/
|
|
23
|
+
/** Run `run` while this context holds the open lock of the store `name`. */
|
|
24
|
+
export declare function withSqliteOpenLock<T>(name: string, operation: string, run: () => Promise<T>): Promise<T>;
|
|
25
|
+
/**
|
|
26
|
+
* Take the store lock of `name`, and return the function that releases it.
|
|
27
|
+
* Call it only inside the open lock of the same name.
|
|
28
|
+
*
|
|
29
|
+
* @throws EncryptionError with `INVALID_STATE` when `mode` is `exclusive` and
|
|
30
|
+
* a store of the name is open in any context of the origin.
|
|
31
|
+
*/
|
|
32
|
+
export declare function acquireSqliteStoreLock(name: string, mode: LockMode, operation: string): Promise<() => void>;
|
|
33
|
+
//# sourceMappingURL=store-locks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-locks.d.ts","sourceRoot":"","sources":["../../../../local/store/web-sqlite/store-locks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAcH,4EAA4E;AAC5E,wBAAsB,kBAAkB,CAAC,CAAC,EACxC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACpB,OAAO,CAAC,CAAC,CAAC,CAGZ;AAED;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,QAAQ,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,IAAI,CAAC,CA0BrB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Web Locks that order the stores of one name across the tabs and
|
|
3
|
+
* workers of an origin.
|
|
4
|
+
*
|
|
5
|
+
* The open lock. A first open reads the vault, finds no key, checks that the
|
|
6
|
+
* file does not exist, writes a new key, and creates the file. Two tabs that
|
|
7
|
+
* run this sequence at the same time both find no key, and each writes its
|
|
8
|
+
* own key. The key that the vault keeps can then differ from the key that
|
|
9
|
+
* created the file, and the store cannot open that file again. So the entry
|
|
10
|
+
* holds one lock for each store name over the whole open or reset, and the
|
|
11
|
+
* next tab finds the key that the first tab wrote.
|
|
12
|
+
*
|
|
13
|
+
* The store lock. Each open store holds it in shared mode until it closes. A
|
|
14
|
+
* reset takes it in exclusive mode, and fails at once when a store of the
|
|
15
|
+
* name is open in any context. So a reset never deletes a file that another
|
|
16
|
+
* tab still uses. The reset runs inside the open lock, so no open can take
|
|
17
|
+
* the store lock between the reset and the new store.
|
|
18
|
+
*
|
|
19
|
+
* Both names differ from the name of the driver's file lock, which the
|
|
20
|
+
* driver's worker takes inside each call. The tabs share the file of an open
|
|
21
|
+
* store through the driver.
|
|
22
|
+
*/
|
|
23
|
+
import { EncryptionError, EncryptionErrorCode } from '../../../types/errors.js';
|
|
24
|
+
function assertWebLocks(operation) {
|
|
25
|
+
if (typeof navigator.locks?.request !== 'function') {
|
|
26
|
+
throw new EncryptionError('This browser context cannot keep a SQLite database in the origin private file system: missing Web Locks', EncryptionErrorCode.OPFS_UNAVAILABLE, { operation });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** Run `run` while this context holds the open lock of the store `name`. */
|
|
30
|
+
export async function withSqliteOpenLock(name, operation, run) {
|
|
31
|
+
assertWebLocks(operation);
|
|
32
|
+
return navigator.locks.request(`open-e2ee:sqlite-open:${name}`, run);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Take the store lock of `name`, and return the function that releases it.
|
|
36
|
+
* Call it only inside the open lock of the same name.
|
|
37
|
+
*
|
|
38
|
+
* @throws EncryptionError with `INVALID_STATE` when `mode` is `exclusive` and
|
|
39
|
+
* a store of the name is open in any context of the origin.
|
|
40
|
+
*/
|
|
41
|
+
export async function acquireSqliteStoreLock(name, mode, operation) {
|
|
42
|
+
assertWebLocks(operation);
|
|
43
|
+
let release;
|
|
44
|
+
const held = new Promise((resolve) => {
|
|
45
|
+
release = resolve;
|
|
46
|
+
});
|
|
47
|
+
const granted = await new Promise((resolve, reject) => {
|
|
48
|
+
navigator.locks
|
|
49
|
+
.request(`open-e2ee:sqlite-store:${name}`, { mode, ifAvailable: mode === 'exclusive' }, (lock) => {
|
|
50
|
+
resolve(lock !== null);
|
|
51
|
+
return lock === null ? undefined : held;
|
|
52
|
+
})
|
|
53
|
+
.catch(reject);
|
|
54
|
+
});
|
|
55
|
+
if (!granted) {
|
|
56
|
+
throw new EncryptionError(`The SQLite store ${name} is open in this or another tab or worker. Close it everywhere first.`, EncryptionErrorCode.INVALID_STATE, { operation });
|
|
57
|
+
}
|
|
58
|
+
return release;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=store-locks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-locks.js","sourceRoot":"","sources":["../../../../local/store/web-sqlite/store-locks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE7E,SAAS,cAAc,CAAC,SAAiB;IACvC,IAAI,OAAO,SAAS,CAAC,KAAK,EAAE,OAAO,KAAK,UAAU,EAAE,CAAC;QACnD,MAAM,IAAI,eAAe,CACvB,yGAAyG,EACzG,mBAAmB,CAAC,gBAAgB,EACpC,EAAE,SAAS,EAAE,CACd,CAAC;IACJ,CAAC;AACH,CAAC;AAED,4EAA4E;AAC5E,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,IAAY,EACZ,SAAiB,EACjB,GAAqB;IAErB,cAAc,CAAC,SAAS,CAAC,CAAC;IAC1B,OAAO,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,yBAAyB,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;AACvE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,IAAY,EACZ,IAAc,EACd,SAAiB;IAEjB,cAAc,CAAC,SAAS,CAAC,CAAC;IAC1B,IAAI,OAAoB,CAAC;IACzB,MAAM,IAAI,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QACzC,OAAO,GAAG,OAAO,CAAC;IACpB,CAAC,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,MAAM,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC7D,SAAS,CAAC,KAAK;aACZ,OAAO,CACN,0BAA0B,IAAI,EAAE,EAChC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,KAAK,WAAW,EAAE,EAC3C,CAAC,IAAI,EAAE,EAAE;YACP,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;YACvB,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;QAC1C,CAAC,CACF;aACA,KAAK,CAAC,MAAM,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,eAAe,CACvB,oBAAoB,IAAI,uEAAuE,EAC/F,mBAAmB,CAAC,aAAa,EACjC,EAAE,SAAS,EAAE,CACd,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { SignalProtocolLocalSecretVault } from '../../types/api.js';
|
|
2
|
+
/**
|
|
3
|
+
* The part of Electron's `safeStorage` that the vault uses. The app passes
|
|
4
|
+
* `safeStorage` from `electron`, so the SDK never imports `electron`.
|
|
5
|
+
*/
|
|
6
|
+
export interface ElectronSafeStorage {
|
|
7
|
+
isAsyncEncryptionAvailable(): Promise<boolean>;
|
|
8
|
+
encryptStringAsync(plainText: string): Promise<Uint8Array>;
|
|
9
|
+
decryptStringAsync(encrypted: Uint8Array): Promise<{
|
|
10
|
+
shouldReEncrypt: boolean;
|
|
11
|
+
result: string;
|
|
12
|
+
}>;
|
|
13
|
+
/** Present on Linux only. */
|
|
14
|
+
getSelectedStorageBackend?(): string;
|
|
15
|
+
}
|
|
16
|
+
export interface ElectronSafeStorageSecretVaultOptions {
|
|
17
|
+
/** `safeStorage` from `electron`, in the main process. */
|
|
18
|
+
safeStorage: ElectronSafeStorage;
|
|
19
|
+
/**
|
|
20
|
+
* The file that holds the ciphertexts, for example under
|
|
21
|
+
* `app.getPath('userData')`. Its directory must exist. One vault owns it.
|
|
22
|
+
*/
|
|
23
|
+
file: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Electron `safeStorage`-backed local secret vault for the Electron main
|
|
27
|
+
* process. `safeStorage` encrypts each secret, as lowercase hex, under a key
|
|
28
|
+
* that the OS holds: the macOS Keychain, Windows DPAPI, or the Linux secret
|
|
29
|
+
* store. The vault keeps only the ciphertexts, as base64 in a JSON file that
|
|
30
|
+
* the app names, so no secret is on disk in plaintext.
|
|
31
|
+
*
|
|
32
|
+
* Use the vault after the app is ready. It fails closed when async encryption
|
|
33
|
+
* is not available, and on Linux when the backend is `basic_text` or
|
|
34
|
+
* `unknown`, or when a ciphertext does not start with `v11`. On macOS, sign
|
|
35
|
+
* every build with the same identity: a build with a different signature can
|
|
36
|
+
* make the Keychain ask the user again.
|
|
37
|
+
*/
|
|
38
|
+
export declare class ElectronSafeStorageSignalProtocolSecretVault implements SignalProtocolLocalSecretVault {
|
|
39
|
+
#private;
|
|
40
|
+
constructor({ safeStorage, file }: ElectronSafeStorageSecretVaultOptions);
|
|
41
|
+
getSecret(name: string): Promise<Uint8Array | null>;
|
|
42
|
+
setSecret(name: string, value: Uint8Array): Promise<void>;
|
|
43
|
+
deleteSecret(name: string): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=electron-safe-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"electron-safe-storage.d.ts","sourceRoot":"","sources":["../../../local/vault/electron-safe-storage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,iBAAiB,CAAC;AAWtE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,0BAA0B,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/C,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC3D,kBAAkB,CAChB,SAAS,EAAE,UAAU,GACpB,OAAO,CAAC;QAAE,eAAe,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACzD,6BAA6B;IAC7B,yBAAyB,CAAC,IAAI,MAAM,CAAC;CACtC;AAED,MAAM,WAAW,qCAAqC;IACpD,0DAA0D;IAC1D,WAAW,EAAE,mBAAmB,CAAC;IACjC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAmCD;;;;;;;;;;;;GAYG;AACH,qBAAa,4CACX,YAAW,8BAA8B;;IAMzC,YAAY,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,qCAAqC,EAGvE;IAEK,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CA2BxD;IAEK,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAY9D;IAEK,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAM9C;CAiHF"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { open, readFile, rename, rm } from 'node:fs/promises';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import { EncryptionError, EncryptionErrorCode } from '../../types/errors.js';
|
|
4
|
+
import { asBase64 } from '../../types/utils.js';
|
|
5
|
+
import { base64ToBytes, bytesToBase64 } from '../../encoding/index.js';
|
|
6
|
+
import { bytesToHex, hexToBytes } from '../../encoding/hex.js';
|
|
7
|
+
const STORED_HEX = /^(?:[0-9a-f]{2})+$/;
|
|
8
|
+
const STORED_BASE64 = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
|
9
|
+
/** The ASCII prefix of a Linux ciphertext under a key from the secret service. */
|
|
10
|
+
const SECRET_SERVICE_PREFIX = [0x76, 0x31, 0x31];
|
|
11
|
+
function keyStorageError(message, operation, cause) {
|
|
12
|
+
return new EncryptionError(message, EncryptionErrorCode.KEY_STORAGE_ERROR, {
|
|
13
|
+
operation,
|
|
14
|
+
...(cause instanceof Error ? { originalError: cause } : {}),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function assertName(name, operation) {
|
|
18
|
+
if (name.length === 0) {
|
|
19
|
+
throw keyStorageError('Electron safeStorage secret name must not be empty', operation);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function parseSecrets(text) {
|
|
23
|
+
let parsed;
|
|
24
|
+
try {
|
|
25
|
+
parsed = JSON.parse(text);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
parsed = undefined;
|
|
29
|
+
}
|
|
30
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
31
|
+
throw keyStorageError('Electron safeStorage vault file is not a JSON object', 'read');
|
|
32
|
+
}
|
|
33
|
+
const secrets = new Map();
|
|
34
|
+
for (const [name, value] of Object.entries(parsed)) {
|
|
35
|
+
if (typeof value !== 'string' || value.length === 0 || !STORED_BASE64.test(value)) {
|
|
36
|
+
throw keyStorageError('Electron safeStorage vault file holds a value that is not base64', 'read');
|
|
37
|
+
}
|
|
38
|
+
secrets.set(name, value);
|
|
39
|
+
}
|
|
40
|
+
return secrets;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Electron `safeStorage`-backed local secret vault for the Electron main
|
|
44
|
+
* process. `safeStorage` encrypts each secret, as lowercase hex, under a key
|
|
45
|
+
* that the OS holds: the macOS Keychain, Windows DPAPI, or the Linux secret
|
|
46
|
+
* store. The vault keeps only the ciphertexts, as base64 in a JSON file that
|
|
47
|
+
* the app names, so no secret is on disk in plaintext.
|
|
48
|
+
*
|
|
49
|
+
* Use the vault after the app is ready. It fails closed when async encryption
|
|
50
|
+
* is not available, and on Linux when the backend is `basic_text` or
|
|
51
|
+
* `unknown`, or when a ciphertext does not start with `v11`. On macOS, sign
|
|
52
|
+
* every build with the same identity: a build with a different signature can
|
|
53
|
+
* make the Keychain ask the user again.
|
|
54
|
+
*/
|
|
55
|
+
export class ElectronSafeStorageSignalProtocolSecretVault {
|
|
56
|
+
#safeStorage;
|
|
57
|
+
#file;
|
|
58
|
+
#queue = Promise.resolve();
|
|
59
|
+
constructor({ safeStorage, file }) {
|
|
60
|
+
this.#safeStorage = safeStorage;
|
|
61
|
+
this.#file = file;
|
|
62
|
+
}
|
|
63
|
+
async getSecret(name) {
|
|
64
|
+
assertName(name, 'getSecret');
|
|
65
|
+
return this.#serialize(async () => {
|
|
66
|
+
const secrets = await this.#read();
|
|
67
|
+
const stored = secrets.get(name);
|
|
68
|
+
if (stored === undefined)
|
|
69
|
+
return null;
|
|
70
|
+
await this.#assertProtected('getSecret');
|
|
71
|
+
const ciphertext = base64ToBytes(asBase64(stored));
|
|
72
|
+
this.#assertSecretServiceKey(ciphertext, 'getSecret');
|
|
73
|
+
let decrypted;
|
|
74
|
+
try {
|
|
75
|
+
decrypted = await this.#safeStorage.decryptStringAsync(ciphertext);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
throw keyStorageError('Electron safeStorage could not decrypt the secret', 'getSecret', error);
|
|
79
|
+
}
|
|
80
|
+
if (!STORED_HEX.test(decrypted.result)) {
|
|
81
|
+
throw keyStorageError('Electron safeStorage secret is not a lowercase hex byte string', 'getSecret');
|
|
82
|
+
}
|
|
83
|
+
if (decrypted.shouldReEncrypt) {
|
|
84
|
+
secrets.set(name, await this.#encrypt(decrypted.result, 'getSecret'));
|
|
85
|
+
await this.#write(secrets);
|
|
86
|
+
}
|
|
87
|
+
return hexToBytes(decrypted.result);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
async setSecret(name, value) {
|
|
91
|
+
assertName(name, 'setSecret');
|
|
92
|
+
if (value.length === 0) {
|
|
93
|
+
throw keyStorageError('Electron safeStorage secret value must not be empty', 'setSecret');
|
|
94
|
+
}
|
|
95
|
+
const hex = bytesToHex(value);
|
|
96
|
+
await this.#serialize(async () => {
|
|
97
|
+
await this.#assertProtected('setSecret');
|
|
98
|
+
const secrets = await this.#read();
|
|
99
|
+
secrets.set(name, await this.#encrypt(hex, 'setSecret'));
|
|
100
|
+
await this.#write(secrets);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
async deleteSecret(name) {
|
|
104
|
+
assertName(name, 'deleteSecret');
|
|
105
|
+
await this.#serialize(async () => {
|
|
106
|
+
const secrets = await this.#read();
|
|
107
|
+
if (secrets.delete(name))
|
|
108
|
+
await this.#write(secrets);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Each operation reads, changes, and writes the whole file, so the vault
|
|
113
|
+
* runs one at a time. A failed operation does not stop the next one.
|
|
114
|
+
*/
|
|
115
|
+
#serialize(operation) {
|
|
116
|
+
const result = this.#queue.then(operation);
|
|
117
|
+
this.#queue = result.catch(() => undefined);
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Before the app is ready, encryption is not available and the Linux backend
|
|
122
|
+
* is `unknown`. `basic_text` encrypts with a fixed password, so it does not
|
|
123
|
+
* protect the secret. A `gnome_libsecret` or `kwallet` backend can also use a
|
|
124
|
+
* fixed key, so `#assertSecretServiceKey` checks each Linux ciphertext.
|
|
125
|
+
*/
|
|
126
|
+
async #assertProtected(operation) {
|
|
127
|
+
if (!(await this.#safeStorage.isAsyncEncryptionAvailable())) {
|
|
128
|
+
throw keyStorageError('Electron safeStorage encryption is not available. Use the vault in the main process after the app is ready.', operation);
|
|
129
|
+
}
|
|
130
|
+
const backend = this.#safeStorage.getSelectedStorageBackend?.();
|
|
131
|
+
if (backend === undefined) {
|
|
132
|
+
if (process.platform !== 'linux')
|
|
133
|
+
return;
|
|
134
|
+
throw keyStorageError('Electron safeStorage does not report its Linux storage backend. Pass safeStorage from electron.', operation);
|
|
135
|
+
}
|
|
136
|
+
if (backend === 'basic_text') {
|
|
137
|
+
throw keyStorageError('Electron safeStorage uses the basic_text backend, which encrypts with a fixed password. Run the app with a secret store such as gnome-libsecret or kwallet.', operation);
|
|
138
|
+
}
|
|
139
|
+
if (backend === 'unknown') {
|
|
140
|
+
throw keyStorageError('Electron safeStorage has no storage backend. Use the vault in the main process after the app is ready.', operation);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* On Linux, safeStorage uses its fixed fallback key when no secret service
|
|
145
|
+
* answers, and the backend does not show it. The ciphertext prefix names the
|
|
146
|
+
* key: `v11` is a key from the secret service, and `v10` is the fallback key.
|
|
147
|
+
* Any other prefix is a key that the vault does not know, so it fails closed.
|
|
148
|
+
*/
|
|
149
|
+
#assertSecretServiceKey(ciphertext, operation) {
|
|
150
|
+
if (process.platform !== 'linux')
|
|
151
|
+
return;
|
|
152
|
+
if (SECRET_SERVICE_PREFIX.every((byte, index) => ciphertext[index] === byte))
|
|
153
|
+
return;
|
|
154
|
+
throw keyStorageError('Electron safeStorage did not encrypt with a key from a secret service. When no secret service answers, safeStorage uses its fixed fallback key. Run the app with a secret service such as gnome-keyring or kwallet.', operation);
|
|
155
|
+
}
|
|
156
|
+
async #encrypt(hex, operation) {
|
|
157
|
+
let encrypted;
|
|
158
|
+
try {
|
|
159
|
+
encrypted = await this.#safeStorage.encryptStringAsync(hex);
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
throw keyStorageError('Electron safeStorage could not encrypt the secret', operation, error);
|
|
163
|
+
}
|
|
164
|
+
if (encrypted.length === 0) {
|
|
165
|
+
throw keyStorageError('Electron safeStorage returned an empty ciphertext', operation);
|
|
166
|
+
}
|
|
167
|
+
this.#assertSecretServiceKey(encrypted, operation);
|
|
168
|
+
return bytesToBase64(encrypted);
|
|
169
|
+
}
|
|
170
|
+
async #read() {
|
|
171
|
+
let text;
|
|
172
|
+
try {
|
|
173
|
+
text = await readFile(this.#file, 'utf8');
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
if (error.code === 'ENOENT')
|
|
177
|
+
return new Map();
|
|
178
|
+
throw error;
|
|
179
|
+
}
|
|
180
|
+
return parseSecrets(text);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Replace the file atomically: write and sync a temporary file, rename it
|
|
184
|
+
* over the old one, then sync the directory so that the rename survives a
|
|
185
|
+
* power loss. Windows cannot open a directory to sync it.
|
|
186
|
+
*/
|
|
187
|
+
async #write(secrets) {
|
|
188
|
+
const temporary = `${this.#file}.tmp`;
|
|
189
|
+
const handle = await open(temporary, 'w', 0o600);
|
|
190
|
+
try {
|
|
191
|
+
await handle.writeFile(JSON.stringify(Object.fromEntries(secrets)), 'utf8');
|
|
192
|
+
await handle.sync();
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
await handle.close();
|
|
196
|
+
await rm(temporary, { force: true });
|
|
197
|
+
throw error;
|
|
198
|
+
}
|
|
199
|
+
await handle.close();
|
|
200
|
+
await rename(temporary, this.#file);
|
|
201
|
+
if (process.platform === 'win32')
|
|
202
|
+
return;
|
|
203
|
+
const directory = await open(dirname(this.#file), 'r');
|
|
204
|
+
try {
|
|
205
|
+
await directory.sync();
|
|
206
|
+
}
|
|
207
|
+
finally {
|
|
208
|
+
await directory.close();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=electron-safe-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"electron-safe-storage.js","sourceRoot":"","sources":["../../../local/vault/electron-safe-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,UAAU,GAAG,oBAAoB,CAAC;AACxC,MAAM,aAAa,GAAG,kEAAkE,CAAC;AACzF,kFAAkF;AAClF,MAAM,qBAAqB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AA0BjD,SAAS,eAAe,CAAC,OAAe,EAAE,SAAiB,EAAE,KAAe;IAC1E,OAAO,IAAI,eAAe,CAAC,OAAO,EAAE,mBAAmB,CAAC,iBAAiB,EAAE;QACzE,SAAS;QACT,GAAG,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5D,CAAC,CAAC;AACL,CAAC;AAED,SAAS,UAAU,CAAC,IAAY,EAAE,SAAiB;IACjD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,eAAe,CAAC,oDAAoD,EAAE,SAAS,CAAC,CAAC;IACzF,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IAChC,IAAI,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YAAE,OAAO;QACzC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;QACvD,IAAI,CAAC;YACH,MAAM,SAAS,CAAC,IAAI,EAAE,CAAC;QACzB,CAAC;gBAAS,CAAC;YACT,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC;QAC1B,CAAC;IACH,CAAC;CACF"}
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The contract only. Each implementation is bound to the platform whose secret
|
|
5
5
|
* storage it wraps, and is imported from its own subpath
|
|
6
|
-
* (`./local/vault/expo-secure-store` for Expo
|
|
7
|
-
*
|
|
6
|
+
* (`./local/vault/expo-secure-store` for Expo,
|
|
7
|
+
* `./local/vault/react-native-keychain` for bare React Native,
|
|
8
|
+
* `./local/vault/electron-safe-storage` for the Electron main process).
|
|
9
|
+
* Naming the interface therefore does not drag a platform in behind it.
|
|
8
10
|
*/
|
|
9
11
|
export {};
|
|
10
12
|
export type { SignalProtocolLocalSecretVault } from '../../types/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../local/vault/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../local/vault/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,CAAC;AACV,YAAY,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { SignalProtocolLocalSecretVault } from '../../types/api.js';
|
|
2
|
+
export interface IndexedDbSignalProtocolSecretVaultOptions {
|
|
3
|
+
/** The IndexedDB database that holds the secrets. */
|
|
4
|
+
readonly databaseName?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* IndexedDB-backed local secret vault for the web.
|
|
8
|
+
*
|
|
9
|
+
* The vault stores each secret as raw bytes in one IndexedDB object store,
|
|
10
|
+
* under the secret name.
|
|
11
|
+
*
|
|
12
|
+
* This vault is not a secret manager. The secret is raw bytes in IndexedDB in
|
|
13
|
+
* the same origin as the encrypted database: the documented exception to
|
|
14
|
+
* "the key never sits beside the data".
|
|
15
|
+
*
|
|
16
|
+
* - What the key protects: a copy of the database file that does not also
|
|
17
|
+
* include this IndexedDB record.
|
|
18
|
+
* - What it does not protect: script that runs in the origin (XSS), a
|
|
19
|
+
* browser extension with access to the site, malware that reads the
|
|
20
|
+
* browser profile, or a copy of the full profile. It is not an XSS
|
|
21
|
+
* defense.
|
|
22
|
+
*
|
|
23
|
+
* An app with a different custody supplies its own vault.
|
|
24
|
+
*/
|
|
25
|
+
export declare class IndexedDbSignalProtocolSecretVault implements SignalProtocolLocalSecretVault {
|
|
26
|
+
private readonly databaseName;
|
|
27
|
+
private database;
|
|
28
|
+
constructor(options?: IndexedDbSignalProtocolSecretVaultOptions);
|
|
29
|
+
getSecret(name: string): Promise<Uint8Array | null>;
|
|
30
|
+
setSecret(name: string, value: Uint8Array): Promise<void>;
|
|
31
|
+
deleteSecret(name: string): Promise<void>;
|
|
32
|
+
/** Runs one request, and reports its failure as `KEY_STORAGE_ERROR`. */
|
|
33
|
+
private request;
|
|
34
|
+
/** Opens the database once. A failed open is not kept: the next call tries again. */
|
|
35
|
+
private open;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=indexed-db.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexed-db.d.ts","sourceRoot":"","sources":["../../../local/vault/indexed-db.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,iBAAiB,CAAC;AAatE,MAAM,WAAW,yCAAyC;IACxD,qDAAqD;IACrD,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AA2BD;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,kCAAmC,YAAW,8BAA8B;IACvF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAyD;IAEzE,YAAY,OAAO,GAAE,yCAA8C,EAElE;IAEK,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAQxD;IAEK,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAM9D;IAEK,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9C;IAED,wEAAwE;YAC1D,OAAO;IAYrB,qFAAqF;IACrF,OAAO,CAAC,IAAI;CAoBb"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { openDB } from 'idb';
|
|
2
|
+
import { EncryptionError, EncryptionErrorCode } from '../../types/errors.js';
|
|
3
|
+
const DEFAULT_DATABASE_NAME = 'open-e2ee-secret-vault';
|
|
4
|
+
const STORE_NAME = 'secrets';
|
|
5
|
+
function keyStorageError(message, operation, cause) {
|
|
6
|
+
return new EncryptionError(message, EncryptionErrorCode.KEY_STORAGE_ERROR, {
|
|
7
|
+
operation,
|
|
8
|
+
...(cause instanceof Error ? { originalError: cause } : {}),
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
function detail(error) {
|
|
12
|
+
return error instanceof Error ? error.message : String(error);
|
|
13
|
+
}
|
|
14
|
+
function assertName(name, operation) {
|
|
15
|
+
if (name.length === 0) {
|
|
16
|
+
throw keyStorageError('IndexedDB secret name must not be empty', operation);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Checks the tag, because a value can come from another realm. */
|
|
20
|
+
function isNonEmptyBytes(value) {
|
|
21
|
+
return (Object.prototype.toString.call(value) === '[object Uint8Array]' &&
|
|
22
|
+
value.length > 0);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* IndexedDB-backed local secret vault for the web.
|
|
26
|
+
*
|
|
27
|
+
* The vault stores each secret as raw bytes in one IndexedDB object store,
|
|
28
|
+
* under the secret name.
|
|
29
|
+
*
|
|
30
|
+
* This vault is not a secret manager. The secret is raw bytes in IndexedDB in
|
|
31
|
+
* the same origin as the encrypted database: the documented exception to
|
|
32
|
+
* "the key never sits beside the data".
|
|
33
|
+
*
|
|
34
|
+
* - What the key protects: a copy of the database file that does not also
|
|
35
|
+
* include this IndexedDB record.
|
|
36
|
+
* - What it does not protect: script that runs in the origin (XSS), a
|
|
37
|
+
* browser extension with access to the site, malware that reads the
|
|
38
|
+
* browser profile, or a copy of the full profile. It is not an XSS
|
|
39
|
+
* defense.
|
|
40
|
+
*
|
|
41
|
+
* An app with a different custody supplies its own vault.
|
|
42
|
+
*/
|
|
43
|
+
export class IndexedDbSignalProtocolSecretVault {
|
|
44
|
+
databaseName;
|
|
45
|
+
database = null;
|
|
46
|
+
constructor(options = {}) {
|
|
47
|
+
this.databaseName = options.databaseName ?? DEFAULT_DATABASE_NAME;
|
|
48
|
+
}
|
|
49
|
+
async getSecret(name) {
|
|
50
|
+
assertName(name, 'getSecret');
|
|
51
|
+
const stored = await this.request('getSecret', (database) => database.get(STORE_NAME, name));
|
|
52
|
+
if (stored === undefined)
|
|
53
|
+
return null;
|
|
54
|
+
if (!isNonEmptyBytes(stored)) {
|
|
55
|
+
throw keyStorageError('IndexedDB secret is not a non-empty byte array', 'getSecret');
|
|
56
|
+
}
|
|
57
|
+
return stored;
|
|
58
|
+
}
|
|
59
|
+
async setSecret(name, value) {
|
|
60
|
+
assertName(name, 'setSecret');
|
|
61
|
+
if (!isNonEmptyBytes(value)) {
|
|
62
|
+
throw keyStorageError('IndexedDB secret value must be a non-empty byte array', 'setSecret');
|
|
63
|
+
}
|
|
64
|
+
await this.request('setSecret', (database) => database.put(STORE_NAME, value, name));
|
|
65
|
+
}
|
|
66
|
+
async deleteSecret(name) {
|
|
67
|
+
assertName(name, 'deleteSecret');
|
|
68
|
+
await this.request('deleteSecret', (database) => database.delete(STORE_NAME, name));
|
|
69
|
+
}
|
|
70
|
+
/** Runs one request, and reports its failure as `KEY_STORAGE_ERROR`. */
|
|
71
|
+
async request(operation, run) {
|
|
72
|
+
const database = await this.open();
|
|
73
|
+
try {
|
|
74
|
+
return await run(database);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
throw keyStorageError(`IndexedDB secret vault ${operation} failed: ${detail(error)}`, operation, error);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** Opens the database once. A failed open is not kept: the next call tries again. */
|
|
81
|
+
open() {
|
|
82
|
+
this.database ??= openDB(this.databaseName, 1, {
|
|
83
|
+
upgrade(database) {
|
|
84
|
+
database.createObjectStore(STORE_NAME);
|
|
85
|
+
},
|
|
86
|
+
// Another context deletes or upgrades the database: let it proceed.
|
|
87
|
+
blocking: () => {
|
|
88
|
+
const current = this.database;
|
|
89
|
+
this.database = null;
|
|
90
|
+
void current?.then((database) => database.close());
|
|
91
|
+
},
|
|
92
|
+
terminated: () => {
|
|
93
|
+
this.database = null;
|
|
94
|
+
},
|
|
95
|
+
}).catch((error) => {
|
|
96
|
+
this.database = null;
|
|
97
|
+
throw keyStorageError(`IndexedDB secret vault did not open: ${detail(error)}`, 'open', error);
|
|
98
|
+
});
|
|
99
|
+
return this.database;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=indexed-db.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexed-db.js","sourceRoot":"","sources":["../../../local/vault/indexed-db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAoC,MAAM,KAAK,CAAC;AAG/D,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE1E,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AACvD,MAAM,UAAU,GAAG,SAAS,CAAC;AAc7B,SAAS,eAAe,CAAC,OAAe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,qFAAqF;IAC7E,IAAI;QACV,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAoB,IAAI,CAAC,YAAY,EAAE,CAAC,EAAE;YAChE,OAAO,CAAC,QAAQ;gBACd,QAAQ,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;YACzC,CAAC;YACD,oEAAoE;YACpE,QAAQ,EAAE,GAAG,EAAE;gBACb,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;gBAC9B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;gBACrB,KAAK,OAAO,EAAE,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;YACrD,CAAC;YACD,UAAU,EAAE,GAAG,EAAE;gBACf,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACvB,CAAC;SACF,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,MAAM,eAAe,CAAC,wCAAwC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QAChG,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SignalProtocolLocalSecretVault } from '../../types/api.js';
|
|
2
|
+
/**
|
|
3
|
+
* react-native-keychain-backed local secret vault for tiny bootstrap secrets
|
|
4
|
+
* in a bare React Native app. The secret name is the keychain service, and the
|
|
5
|
+
* value is stored as lowercase hex.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ReactNativeKeychainSignalProtocolSecretVault implements SignalProtocolLocalSecretVault {
|
|
8
|
+
getSecret(name: string): Promise<Uint8Array | null>;
|
|
9
|
+
setSecret(name: string, value: Uint8Array): Promise<void>;
|
|
10
|
+
deleteSecret(name: string): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=react-native-keychain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-native-keychain.d.ts","sourceRoot":"","sources":["../../../local/vault/react-native-keychain.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,iBAAiB,CAAC;AAgDtE;;;;GAIG;AACH,qBAAa,4CACX,YAAW,8BAA8B;IAEnC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAYxD;IAEK,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAiB9D;IAEK,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9C;CACF"}
|