zapo-js 0.1.2 → 0.2.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/README.md +12 -4
- package/dist/appstate/WaAppStateCrypto.js +1 -1
- package/dist/appstate/WaAppStateSyncClient.js +138 -93
- package/dist/appstate/{store/sqlite.js → encoding.js} +13 -8
- package/dist/appstate/index.js +8 -6
- package/dist/appstate/utils.js +0 -5
- package/dist/auth/WaAuthClient.js +36 -47
- package/dist/auth/flow/WaAuthCredentialsFlow.js +7 -7
- package/dist/auth/index.js +1 -6
- package/dist/auth/pairing/WaPairingCodeCrypto.js +6 -4
- package/dist/auth/pairing/WaPairingFlow.js +13 -3
- package/dist/client/WaClient.js +225 -101
- package/dist/client/WaClientFactory.js +294 -44
- package/dist/client/connection/WaConnectionManager.js +19 -10
- package/dist/client/coordinators/WaBusinessCoordinator.js +241 -0
- package/dist/client/coordinators/WaGroupCoordinator.js +11 -7
- package/dist/client/coordinators/WaIncomingNodeCoordinator.js +1 -0
- package/dist/client/coordinators/WaMessageDispatchCoordinator.js +292 -99
- package/dist/client/coordinators/WaPassiveTasksCoordinator.js +74 -31
- package/dist/client/coordinators/WaPrivacyCoordinator.js +134 -0
- package/dist/client/coordinators/WaProfileCoordinator.js +212 -0
- package/dist/client/coordinators/WaRetryCoordinator.js +179 -27
- package/dist/client/coordinators/WaStreamControlCoordinator.js +18 -11
- package/dist/client/coordinators/WaTrustedContactTokenCoordinator.js +166 -0
- package/dist/client/dirty.js +40 -20
- package/dist/client/events/devices.js +72 -0
- package/dist/client/events/group.js +3 -11
- package/dist/client/events/identity.js +22 -0
- package/dist/client/events/privacy-token.js +39 -0
- package/dist/client/history-sync.js +50 -9
- package/dist/client/incoming.js +37 -7
- package/dist/client/mailbox.js +24 -23
- package/dist/client/messages.js +107 -31
- package/dist/client/messaging/fanout.js +21 -11
- package/dist/client/messaging/participants.js +6 -4
- package/dist/client/persistence/WriteBehindPersistence.js +129 -0
- package/dist/client/tokens/cs-token.js +50 -0
- package/dist/client/tokens/tc-token.js +25 -0
- package/dist/crypto/core/index.js +2 -2
- package/dist/crypto/core/keys.js +4 -4
- package/dist/crypto/core/nonce.js +2 -0
- package/dist/crypto/core/primitives.js +0 -8
- package/dist/crypto/core/random.js +22 -0
- package/dist/crypto/curves/X25519.js +25 -6
- package/dist/crypto/index.js +3 -0
- package/dist/crypto/math/constants.js +13 -36
- package/dist/crypto/math/edwards.js +171 -44
- package/dist/crypto/math/fe.js +706 -0
- package/dist/crypto/math/mod.js +10 -3
- package/dist/esm/appstate/WaAppStateCrypto.js +1 -1
- package/dist/esm/appstate/WaAppStateSyncClient.js +138 -93
- package/dist/esm/appstate/{store/sqlite.js → encoding.js} +13 -8
- package/dist/esm/appstate/index.js +2 -2
- package/dist/esm/appstate/utils.js +2 -5
- package/dist/esm/auth/WaAuthClient.js +36 -47
- package/dist/esm/auth/flow/WaAuthCredentialsFlow.js +7 -7
- package/dist/esm/auth/index.js +0 -2
- package/dist/esm/auth/pairing/WaPairingCodeCrypto.js +6 -4
- package/dist/esm/auth/pairing/WaPairingFlow.js +14 -4
- package/dist/esm/client/WaClient.js +225 -101
- package/dist/esm/client/WaClientFactory.js +295 -45
- package/dist/esm/client/connection/WaConnectionManager.js +19 -10
- package/dist/esm/client/coordinators/WaBusinessCoordinator.js +238 -0
- package/dist/esm/client/coordinators/WaGroupCoordinator.js +11 -7
- package/dist/esm/client/coordinators/WaIncomingNodeCoordinator.js +1 -0
- package/dist/esm/client/coordinators/WaMessageDispatchCoordinator.js +295 -102
- package/dist/esm/client/coordinators/WaPassiveTasksCoordinator.js +74 -31
- package/dist/esm/client/coordinators/WaPrivacyCoordinator.js +131 -0
- package/dist/esm/client/coordinators/WaProfileCoordinator.js +209 -0
- package/dist/esm/client/coordinators/WaRetryCoordinator.js +181 -29
- package/dist/esm/client/coordinators/WaStreamControlCoordinator.js +19 -12
- package/dist/esm/client/coordinators/WaTrustedContactTokenCoordinator.js +162 -0
- package/dist/esm/client/dirty.js +40 -20
- package/dist/esm/client/events/devices.js +68 -0
- package/dist/esm/client/events/group.js +3 -11
- package/dist/esm/client/events/identity.js +19 -0
- package/dist/esm/client/events/privacy-token.js +36 -0
- package/dist/esm/client/history-sync.js +50 -9
- package/dist/esm/client/incoming.js +38 -8
- package/dist/esm/client/mailbox.js +24 -23
- package/dist/esm/client/messages.js +108 -32
- package/dist/esm/client/messaging/fanout.js +22 -12
- package/dist/esm/client/messaging/participants.js +6 -4
- package/dist/esm/client/persistence/WriteBehindPersistence.js +125 -0
- package/dist/esm/client/tokens/cs-token.js +46 -0
- package/dist/esm/client/tokens/tc-token.js +18 -0
- package/dist/esm/crypto/core/index.js +2 -2
- package/dist/esm/crypto/core/keys.js +1 -1
- package/dist/esm/crypto/core/nonce.js +2 -0
- package/dist/esm/crypto/core/primitives.js +0 -7
- package/dist/esm/crypto/core/random.js +22 -1
- package/dist/esm/crypto/curves/X25519.js +25 -6
- package/dist/esm/crypto/index.js +1 -0
- package/dist/esm/crypto/math/constants.js +12 -35
- package/dist/esm/crypto/math/edwards.js +174 -47
- package/dist/esm/crypto/math/fe.js +691 -0
- package/dist/esm/crypto/math/mod.js +10 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/infra/perf/BackgroundQueue.js +478 -0
- package/dist/esm/infra/perf/BoundedTaskQueue.js +3 -1
- package/dist/esm/infra/perf/PromiseDedup.js +20 -0
- package/dist/esm/infra/perf/SharedExclusiveGate.js +109 -0
- package/dist/esm/infra/perf/StoreLock.js +77 -0
- package/dist/esm/media/WaMediaCrypto.js +95 -13
- package/dist/esm/media/WaMediaTransferClient.js +39 -47
- package/dist/esm/media/constants.js +2 -1
- package/dist/esm/message/WaMessageClient.js +26 -19
- package/dist/esm/message/content.js +195 -9
- package/dist/esm/message/icdc.js +76 -0
- package/dist/esm/message/incoming.js +24 -12
- package/dist/esm/message/phash.js +3 -1
- package/dist/esm/message/reporting-token.js +14 -27
- package/dist/esm/protocol/appstate.js +9 -40
- package/dist/esm/protocol/browser.js +10 -18
- package/dist/esm/protocol/constants.js +5 -3
- package/dist/esm/protocol/defaults.js +6 -0
- package/dist/esm/protocol/index.js +1 -2
- package/dist/esm/protocol/jid.js +105 -36
- package/dist/esm/protocol/message.js +61 -1
- package/dist/esm/protocol/nodes.js +2 -0
- package/dist/esm/protocol/notification.js +3 -1
- package/dist/esm/protocol/privacy-token.js +17 -0
- package/dist/esm/protocol/privacy.js +55 -0
- package/dist/esm/protocol/stream.js +26 -1
- package/dist/esm/retry/codec.js +216 -0
- package/dist/esm/retry/constants.js +1 -1
- package/dist/esm/retry/index.js +2 -2
- package/dist/esm/retry/parse.js +50 -30
- package/dist/esm/retry/replay.js +11 -7
- package/dist/esm/retry/tracker.js +50 -12
- package/dist/esm/signal/api/SignalDeviceSyncApi.js +49 -32
- package/dist/esm/signal/api/SignalDigestSyncApi.js +13 -9
- package/dist/esm/signal/api/SignalIdentitySyncApi.js +26 -11
- package/dist/esm/signal/api/SignalMissingPreKeysSyncApi.js +18 -7
- package/dist/esm/signal/api/SignalRotateKeyApi.js +4 -2
- package/dist/esm/signal/api/SignalSessionSyncApi.js +16 -7
- package/dist/esm/signal/api/result-map.js +10 -0
- package/dist/esm/signal/constants.js +0 -4
- package/dist/esm/signal/crypto/WaAdvSignature.js +12 -6
- package/dist/esm/signal/{store/sqlite.js → encoding.js} +78 -24
- package/dist/esm/signal/group/SenderKeyCodec.js +3 -2
- package/dist/esm/signal/group/SenderKeyManager.js +125 -106
- package/dist/esm/signal/index.js +1 -0
- package/dist/esm/signal/registration/keygen.js +6 -2
- package/dist/esm/signal/registration/utils.js +1 -0
- package/dist/esm/signal/session/SignalProtocol.js +150 -74
- package/dist/esm/signal/session/resolver.js +137 -102
- package/dist/esm/store/contracts/privacy-token.store.js +1 -0
- package/dist/esm/store/createStore.js +101 -187
- package/dist/esm/store/index.js +1 -10
- package/dist/esm/store/locks/appstate.lock.js +26 -0
- package/dist/esm/store/locks/auth.lock.js +15 -0
- package/dist/esm/store/locks/contact.lock.js +20 -0
- package/dist/esm/store/locks/device-list.lock.js +20 -0
- package/dist/esm/store/locks/message.lock.js +21 -0
- package/dist/esm/store/locks/participants.lock.js +20 -0
- package/dist/esm/store/locks/privacy-token.lock.js +18 -0
- package/dist/esm/store/locks/retry.lock.js +29 -0
- package/dist/esm/store/locks/sender-key.lock.js +52 -0
- package/dist/esm/store/locks/signal.lock.js +63 -0
- package/dist/esm/store/locks/thread.lock.js +21 -0
- package/dist/esm/store/noop.store.js +1 -1
- package/dist/esm/store/providers/memory/appstate.store.js +22 -24
- package/dist/esm/store/providers/memory/device-list.store.js +10 -5
- package/dist/esm/store/providers/memory/privacy-token.store.js +43 -0
- package/dist/esm/store/providers/memory/retry.store.js +77 -2
- package/dist/esm/store/providers/memory/sender-key.store.js +6 -1
- package/dist/esm/store/providers/memory/signal.store.js +36 -19
- package/dist/esm/transport/WaComms.js +3 -1
- package/dist/esm/transport/WaWebSocket.js +0 -6
- package/dist/esm/transport/binary/constants.js +0 -30
- package/dist/esm/transport/binary/decoder.js +4 -4
- package/dist/esm/transport/binary/encoder.js +8 -15
- package/dist/esm/transport/binary/index.js +0 -1
- package/dist/esm/transport/node/WaNodeOrchestrator.js +25 -19
- package/dist/esm/transport/node/builders/business.js +129 -0
- package/dist/esm/transport/node/builders/global.js +370 -0
- package/dist/esm/transport/node/builders/index.js +5 -2
- package/dist/esm/transport/node/builders/message.js +63 -239
- package/dist/esm/transport/node/builders/pairing.js +0 -24
- package/dist/esm/transport/node/builders/privacy-token.js +41 -0
- package/dist/esm/transport/node/builders/privacy.js +48 -0
- package/dist/esm/transport/node/builders/profile.js +70 -0
- package/dist/esm/transport/node/builders/retry.js +10 -22
- package/dist/esm/transport/node/builders/usync.js +6 -2
- package/dist/esm/transport/node/helpers.js +19 -1
- package/dist/esm/transport/node/usync.js +3 -33
- package/dist/esm/transport/node/xml.js +35 -14
- package/dist/esm/transport/noise/WaClientPayload.js +10 -10
- package/dist/esm/transport/noise/WaNoiseCert.js +3 -3
- package/dist/esm/transport/noise/WaNoiseSession.js +64 -23
- package/dist/esm/transport/noise/WaNoiseSocket.js +8 -4
- package/dist/esm/transport/stream/parse.js +8 -4
- package/dist/esm/util/bytes.js +22 -18
- package/dist/esm/util/index.js +5 -0
- package/dist/esm/util/primitives.js +3 -2
- package/dist/index.js +7 -1
- package/dist/infra/perf/BackgroundQueue.js +482 -0
- package/dist/infra/perf/BoundedTaskQueue.js +3 -1
- package/dist/infra/perf/PromiseDedup.js +24 -0
- package/dist/infra/perf/SharedExclusiveGate.js +113 -0
- package/dist/infra/perf/StoreLock.js +81 -0
- package/dist/media/WaMediaCrypto.js +94 -12
- package/dist/media/WaMediaTransferClient.js +39 -47
- package/dist/media/constants.js +2 -1
- package/dist/message/WaMessageClient.js +26 -19
- package/dist/message/content.js +198 -9
- package/dist/message/icdc.js +81 -0
- package/dist/message/incoming.js +24 -12
- package/dist/message/phash.js +3 -1
- package/dist/message/reporting-token.js +14 -28
- package/dist/protocol/appstate.js +10 -41
- package/dist/protocol/browser.js +10 -18
- package/dist/protocol/constants.js +21 -2
- package/dist/protocol/defaults.js +6 -0
- package/dist/protocol/index.js +8 -5
- package/dist/protocol/jid.js +111 -36
- package/dist/protocol/message.js +62 -2
- package/dist/protocol/nodes.js +2 -0
- package/dist/protocol/notification.js +3 -1
- package/dist/protocol/privacy-token.js +20 -0
- package/dist/protocol/privacy.js +58 -0
- package/dist/protocol/stream.js +27 -2
- package/dist/retry/codec.js +220 -0
- package/dist/retry/constants.js +1 -1
- package/dist/retry/index.js +5 -5
- package/dist/retry/parse.js +51 -30
- package/dist/retry/replay.js +10 -6
- package/dist/retry/tracker.js +50 -12
- package/dist/signal/api/SignalDeviceSyncApi.js +48 -31
- package/dist/signal/api/SignalDigestSyncApi.js +13 -9
- package/dist/signal/api/SignalIdentitySyncApi.js +25 -10
- package/dist/signal/api/SignalMissingPreKeysSyncApi.js +17 -6
- package/dist/signal/api/SignalRotateKeyApi.js +4 -2
- package/dist/signal/api/SignalSessionSyncApi.js +16 -7
- package/dist/signal/api/result-map.js +13 -0
- package/dist/signal/constants.js +1 -5
- package/dist/signal/crypto/WaAdvSignature.js +11 -5
- package/dist/signal/{store/sqlite.js → encoding.js} +79 -25
- package/dist/signal/group/SenderKeyCodec.js +4 -3
- package/dist/signal/group/SenderKeyManager.js +125 -106
- package/dist/signal/index.js +13 -1
- package/dist/signal/registration/keygen.js +6 -2
- package/dist/signal/registration/utils.js +1 -0
- package/dist/signal/session/SignalProtocol.js +150 -74
- package/dist/signal/session/resolver.js +135 -100
- package/dist/store/contracts/privacy-token.store.js +2 -0
- package/dist/store/createStore.js +101 -187
- package/dist/store/index.js +15 -33
- package/dist/store/locks/appstate.lock.js +29 -0
- package/dist/store/locks/auth.lock.js +18 -0
- package/dist/store/locks/contact.lock.js +23 -0
- package/dist/store/locks/device-list.lock.js +23 -0
- package/dist/store/locks/message.lock.js +24 -0
- package/dist/store/locks/participants.lock.js +23 -0
- package/dist/store/locks/privacy-token.lock.js +21 -0
- package/dist/store/locks/retry.lock.js +32 -0
- package/dist/store/locks/sender-key.lock.js +55 -0
- package/dist/store/locks/signal.lock.js +66 -0
- package/dist/store/locks/thread.lock.js +24 -0
- package/dist/store/noop.store.js +1 -1
- package/dist/store/providers/memory/appstate.store.js +22 -24
- package/dist/store/providers/memory/device-list.store.js +10 -5
- package/dist/store/providers/memory/privacy-token.store.js +47 -0
- package/dist/store/providers/memory/retry.store.js +77 -2
- package/dist/store/providers/memory/sender-key.store.js +6 -1
- package/dist/store/providers/memory/signal.store.js +36 -19
- package/dist/transport/WaComms.js +3 -1
- package/dist/transport/WaWebSocket.js +0 -6
- package/dist/transport/binary/constants.js +1 -31
- package/dist/transport/binary/decoder.js +4 -4
- package/dist/transport/binary/encoder.js +8 -15
- package/dist/transport/binary/index.js +0 -4
- package/dist/transport/node/WaNodeOrchestrator.js +24 -18
- package/dist/transport/node/builders/business.js +137 -0
- package/dist/transport/node/builders/global.js +375 -0
- package/dist/transport/node/builders/index.js +18 -9
- package/dist/transport/node/builders/message.js +64 -245
- package/dist/transport/node/builders/pairing.js +0 -26
- package/dist/transport/node/builders/privacy-token.js +46 -0
- package/dist/transport/node/builders/privacy.js +55 -0
- package/dist/transport/node/builders/profile.js +78 -0
- package/dist/transport/node/builders/retry.js +9 -21
- package/dist/transport/node/builders/usync.js +6 -2
- package/dist/transport/node/helpers.js +20 -1
- package/dist/transport/node/usync.js +2 -32
- package/dist/transport/node/xml.js +35 -14
- package/dist/transport/noise/WaClientPayload.js +13 -13
- package/dist/transport/noise/WaNoiseCert.js +2 -2
- package/dist/transport/noise/WaNoiseSession.js +64 -23
- package/dist/transport/noise/WaNoiseSocket.js +8 -4
- package/dist/transport/stream/parse.js +7 -3
- package/dist/types/appstate/encoding.d.ts +7 -0
- package/dist/types/appstate/index.d.ts +3 -3
- package/dist/types/appstate/utils.d.ts +0 -2
- package/dist/types/auth/flow/WaAuthCredentialsFlow.d.ts +1 -1
- package/dist/types/auth/index.d.ts +0 -2
- package/dist/types/auth/types.d.ts +1 -0
- package/dist/types/client/WaClient.d.ts +27 -12
- package/dist/types/client/WaClientFactory.d.ts +12 -4
- package/dist/types/client/connection/WaConnectionManager.d.ts +2 -0
- package/dist/types/client/coordinators/WaBusinessCoordinator.d.ts +57 -0
- package/dist/types/client/coordinators/WaIncomingNodeCoordinator.d.ts +3 -1
- package/dist/types/client/coordinators/WaMessageDispatchCoordinator.d.ts +14 -0
- package/dist/types/client/coordinators/WaPassiveTasksCoordinator.d.ts +4 -0
- package/dist/types/client/coordinators/WaPrivacyCoordinator.d.ts +26 -0
- package/dist/types/client/coordinators/WaProfileCoordinator.d.ts +36 -0
- package/dist/types/client/coordinators/WaRetryCoordinator.d.ts +6 -0
- package/dist/types/client/coordinators/WaStreamControlCoordinator.d.ts +3 -2
- package/dist/types/client/coordinators/WaTrustedContactTokenCoordinator.d.ts +45 -0
- package/dist/types/client/events/devices.d.ts +20 -0
- package/dist/types/client/events/identity.d.ts +9 -0
- package/dist/types/client/events/privacy-token.d.ts +7 -0
- package/dist/types/client/history-sync.d.ts +9 -6
- package/dist/types/client/incoming.d.ts +3 -1
- package/dist/types/client/index.d.ts +1 -1
- package/dist/types/client/mailbox.d.ts +3 -5
- package/dist/types/client/messages.d.ts +1 -2
- package/dist/types/client/persistence/WriteBehindPersistence.d.ts +34 -0
- package/dist/types/client/tokens/cs-token.d.ts +10 -0
- package/dist/types/client/tokens/tc-token.d.ts +5 -0
- package/dist/types/client/types.d.ts +51 -3
- package/dist/types/crypto/core/index.d.ts +2 -2
- package/dist/types/crypto/core/nonce.d.ts +2 -0
- package/dist/types/crypto/core/primitives.d.ts +0 -1
- package/dist/types/crypto/core/random.d.ts +1 -0
- package/dist/types/crypto/index.d.ts +1 -0
- package/dist/types/crypto/math/constants.d.ts +4 -2
- package/dist/types/crypto/math/fe.d.ts +30 -0
- package/dist/types/crypto/math/mod.d.ts +0 -2
- package/dist/types/crypto/math/types.d.ts +11 -4
- package/dist/types/index.d.ts +5 -3
- package/dist/types/infra/perf/BackgroundQueue.d.ts +58 -0
- package/dist/types/infra/perf/PromiseDedup.d.ts +4 -0
- package/dist/types/infra/perf/SharedExclusiveGate.d.ts +17 -0
- package/dist/types/infra/perf/StoreLock.d.ts +10 -0
- package/dist/types/media/WaMediaCrypto.d.ts +3 -2
- package/dist/types/media/WaMediaTransferClient.d.ts +3 -12
- package/dist/types/media/constants.d.ts +1 -1
- package/dist/types/media/index.d.ts +1 -1
- package/dist/types/media/types.d.ts +10 -2
- package/dist/types/message/content.d.ts +8 -0
- package/dist/types/message/icdc.d.ts +13 -0
- package/dist/types/message/reporting-token.d.ts +0 -1
- package/dist/types/message/types.d.ts +45 -6
- package/dist/types/protocol/appstate.d.ts +0 -11
- package/dist/types/protocol/constants.d.ts +7 -3
- package/dist/types/protocol/defaults.d.ts +6 -0
- package/dist/types/protocol/index.d.ts +1 -2
- package/dist/types/protocol/jid.d.ts +19 -2
- package/dist/types/protocol/message.d.ts +60 -0
- package/dist/types/protocol/nodes.d.ts +2 -0
- package/dist/types/protocol/notification.d.ts +2 -0
- package/dist/types/protocol/privacy-token.d.ts +17 -0
- package/dist/types/protocol/privacy.d.ts +75 -0
- package/dist/types/protocol/stream.d.ts +30 -0
- package/dist/types/retry/codec.d.ts +3 -0
- package/dist/types/retry/index.d.ts +3 -3
- package/dist/types/retry/parse.d.ts +5 -2
- package/dist/types/retry/tracker.d.ts +1 -0
- package/dist/types/retry/types.d.ts +6 -1
- package/dist/types/signal/api/SignalDeviceSyncApi.d.ts +2 -1
- package/dist/types/signal/api/SignalDigestSyncApi.d.ts +6 -0
- package/dist/types/signal/api/SignalIdentitySyncApi.d.ts +2 -0
- package/dist/types/signal/api/SignalRotateKeyApi.d.ts +4 -5
- package/dist/types/signal/api/SignalSessionSyncApi.d.ts +8 -6
- package/dist/types/signal/api/result-map.d.ts +1 -0
- package/dist/types/signal/constants.d.ts +0 -3
- package/dist/types/signal/{store/sqlite.d.ts → encoding.d.ts} +3 -3
- package/dist/types/signal/group/SenderKeyManager.d.ts +10 -5
- package/dist/types/signal/index.d.ts +2 -0
- package/dist/types/signal/session/SignalProtocol.d.ts +10 -4
- package/dist/types/signal/session/resolver.d.ts +7 -2
- package/dist/types/store/contracts/appstate.store.d.ts +1 -1
- package/dist/types/store/contracts/privacy-token.store.d.ts +16 -0
- package/dist/types/store/contracts/retry.store.d.ts +7 -0
- package/dist/types/store/contracts/signal.store.d.ts +7 -0
- package/dist/types/store/createStore.d.ts +1 -1
- package/dist/types/store/index.d.ts +5 -13
- package/dist/types/store/locks/appstate.lock.d.ts +3 -0
- package/dist/types/store/locks/auth.lock.d.ts +3 -0
- package/dist/types/store/locks/contact.lock.d.ts +3 -0
- package/dist/types/store/locks/device-list.lock.d.ts +2 -0
- package/dist/types/store/locks/message.lock.d.ts +3 -0
- package/dist/types/store/locks/participants.lock.d.ts +2 -0
- package/dist/types/store/locks/privacy-token.lock.d.ts +2 -0
- package/dist/types/store/locks/retry.lock.d.ts +2 -0
- package/dist/types/store/locks/sender-key.lock.d.ts +3 -0
- package/dist/types/store/locks/signal.lock.d.ts +3 -0
- package/dist/types/store/locks/thread.lock.d.ts +3 -0
- package/dist/types/store/providers/memory/appstate.store.d.ts +1 -1
- package/dist/types/store/providers/memory/privacy-token.store.d.ts +13 -0
- package/dist/types/store/providers/memory/retry.store.d.ts +8 -0
- package/dist/types/store/providers/memory/signal.store.d.ts +2 -1
- package/dist/types/store/types.d.ts +49 -61
- package/dist/types/transport/WaWebSocket.d.ts +0 -1
- package/dist/types/transport/binary/constants.d.ts +0 -30
- package/dist/types/transport/binary/index.d.ts +0 -1
- package/dist/types/transport/node/WaNodeOrchestrator.d.ts +3 -4
- package/dist/types/transport/node/builders/business.d.ts +29 -0
- package/dist/types/transport/node/builders/global.d.ts +102 -0
- package/dist/types/transport/node/builders/index.d.ts +5 -2
- package/dist/types/transport/node/builders/message.d.ts +8 -7
- package/dist/types/transport/node/builders/pairing.d.ts +0 -2
- package/dist/types/transport/node/builders/privacy-token.d.ts +9 -0
- package/dist/types/transport/node/builders/privacy.d.ts +7 -0
- package/dist/types/transport/node/builders/profile.d.ts +8 -0
- package/dist/types/transport/node/builders/retry.d.ts +0 -1
- package/dist/types/transport/node/helpers.d.ts +5 -0
- package/dist/types/transport/noise/WaNoiseSession.d.ts +3 -2
- package/dist/types/transport/noise/WaNoiseSocket.d.ts +4 -2
- package/dist/types/util/bytes.d.ts +1 -1
- package/dist/types/util/index.d.ts +5 -0
- package/dist/types/util/primitives.d.ts +0 -1
- package/dist/util/bytes.js +22 -18
- package/dist/util/index.js +23 -0
- package/dist/util/primitives.js +2 -2
- package/package.json +29 -7
- package/proto/index.js +1 -1
- package/dist/crypto/core/constants.js +0 -4
- package/dist/esm/crypto/core/constants.js +0 -1
- package/dist/esm/retry/outbound.js +0 -82
- package/dist/esm/store/providers/sqlite/BaseSqliteStore.js +0 -37
- package/dist/esm/store/providers/sqlite/appstate.store.js +0 -250
- package/dist/esm/store/providers/sqlite/auth.store.js +0 -176
- package/dist/esm/store/providers/sqlite/connection.js +0 -245
- package/dist/esm/store/providers/sqlite/contact.store.js +0 -74
- package/dist/esm/store/providers/sqlite/device-list.store.js +0 -127
- package/dist/esm/store/providers/sqlite/message.store.js +0 -132
- package/dist/esm/store/providers/sqlite/migrations.js +0 -347
- package/dist/esm/store/providers/sqlite/participants.store.js +0 -77
- package/dist/esm/store/providers/sqlite/retry.store.js +0 -141
- package/dist/esm/store/providers/sqlite/sender-key.store.js +0 -198
- package/dist/esm/store/providers/sqlite/signal.store.js +0 -435
- package/dist/esm/store/providers/sqlite/table-names.js +0 -107
- package/dist/esm/store/providers/sqlite/thread.store.js +0 -85
- package/dist/retry/outbound.js +0 -87
- package/dist/store/providers/sqlite/BaseSqliteStore.js +0 -41
- package/dist/store/providers/sqlite/appstate.store.js +0 -254
- package/dist/store/providers/sqlite/auth.store.js +0 -180
- package/dist/store/providers/sqlite/connection.js +0 -281
- package/dist/store/providers/sqlite/contact.store.js +0 -78
- package/dist/store/providers/sqlite/device-list.store.js +0 -131
- package/dist/store/providers/sqlite/message.store.js +0 -136
- package/dist/store/providers/sqlite/migrations.js +0 -350
- package/dist/store/providers/sqlite/participants.store.js +0 -81
- package/dist/store/providers/sqlite/retry.store.js +0 -145
- package/dist/store/providers/sqlite/sender-key.store.js +0 -202
- package/dist/store/providers/sqlite/signal.store.js +0 -439
- package/dist/store/providers/sqlite/table-names.js +0 -113
- package/dist/store/providers/sqlite/thread.store.js +0 -89
- package/dist/types/appstate/store/sqlite.d.ts +0 -7
- package/dist/types/crypto/core/constants.d.ts +0 -1
- package/dist/types/retry/outbound.d.ts +0 -4
- package/dist/types/store/providers/sqlite/BaseSqliteStore.d.ts +0 -12
- package/dist/types/store/providers/sqlite/appstate.store.d.ts +0 -17
- package/dist/types/store/providers/sqlite/auth.store.d.ts +0 -10
- package/dist/types/store/providers/sqlite/connection.d.ts +0 -10
- package/dist/types/store/providers/sqlite/contact.store.d.ts +0 -12
- package/dist/types/store/providers/sqlite/device-list.store.d.ts +0 -15
- package/dist/types/store/providers/sqlite/message.store.d.ts +0 -13
- package/dist/types/store/providers/sqlite/migrations.d.ts +0 -3
- package/dist/types/store/providers/sqlite/participants.store.d.ts +0 -12
- package/dist/types/store/providers/sqlite/retry.store.d.ts +0 -15
- package/dist/types/store/providers/sqlite/sender-key.store.d.ts +0 -24
- package/dist/types/store/providers/sqlite/signal.store.d.ts +0 -53
- package/dist/types/store/providers/sqlite/table-names.d.ts +0 -5
- package/dist/types/store/providers/sqlite/thread.store.d.ts +0 -13
|
@@ -1,439 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WaSignalSqliteStore = void 0;
|
|
4
|
-
const jid_1 = require("../../../protocol/jid");
|
|
5
|
-
const sqlite_1 = require("../../../signal/store/sqlite");
|
|
6
|
-
const BaseSqliteStore_1 = require("../../providers/sqlite/BaseSqliteStore");
|
|
7
|
-
const coercion_1 = require("../../../util/coercion");
|
|
8
|
-
const DEFAULTS = Object.freeze({
|
|
9
|
-
preKeyBatchSize: 500,
|
|
10
|
-
hasSessionBatchSize: 250
|
|
11
|
-
});
|
|
12
|
-
function repeatSqlToken(token, count, separator) {
|
|
13
|
-
if (count <= 1) {
|
|
14
|
-
return token;
|
|
15
|
-
}
|
|
16
|
-
let out = token;
|
|
17
|
-
for (let index = 1; index < count; index += 1) {
|
|
18
|
-
out += separator + token;
|
|
19
|
-
}
|
|
20
|
-
return out;
|
|
21
|
-
}
|
|
22
|
-
class WaSignalSqliteStore extends BaseSqliteStore_1.BaseSqliteStore {
|
|
23
|
-
constructor(options, storeOptions = {}) {
|
|
24
|
-
super(options, ['signal']);
|
|
25
|
-
this.preKeyBatchSize = (0, coercion_1.resolvePositive)(storeOptions.preKeyBatchSize, DEFAULTS.preKeyBatchSize, 'signal.sqlite.preKeyBatchSize');
|
|
26
|
-
this.hasSessionBatchSize = (0, coercion_1.resolvePositive)(storeOptions.hasSessionBatchSize, DEFAULTS.hasSessionBatchSize, 'signal.sqlite.hasSessionBatchSize');
|
|
27
|
-
}
|
|
28
|
-
async getRegistrationInfo() {
|
|
29
|
-
const db = await this.getConnection();
|
|
30
|
-
const row = db.get(`SELECT registration_id, identity_pub_key, identity_priv_key
|
|
31
|
-
FROM signal_registration
|
|
32
|
-
WHERE session_id = ?`, [this.options.sessionId]);
|
|
33
|
-
return row ? (0, sqlite_1.decodeSignalRegistrationRow)(row) : null;
|
|
34
|
-
}
|
|
35
|
-
async setRegistrationInfo(info) {
|
|
36
|
-
const db = await this.getConnection();
|
|
37
|
-
db.run(`INSERT INTO signal_registration (
|
|
38
|
-
session_id,
|
|
39
|
-
registration_id,
|
|
40
|
-
identity_pub_key,
|
|
41
|
-
identity_priv_key
|
|
42
|
-
) VALUES (?, ?, ?, ?)
|
|
43
|
-
ON CONFLICT(session_id) DO UPDATE SET
|
|
44
|
-
registration_id=excluded.registration_id,
|
|
45
|
-
identity_pub_key=excluded.identity_pub_key,
|
|
46
|
-
identity_priv_key=excluded.identity_priv_key`, [
|
|
47
|
-
this.options.sessionId,
|
|
48
|
-
info.registrationId,
|
|
49
|
-
info.identityKeyPair.pubKey,
|
|
50
|
-
info.identityKeyPair.privKey
|
|
51
|
-
]);
|
|
52
|
-
}
|
|
53
|
-
async getSignedPreKey() {
|
|
54
|
-
const db = await this.getConnection();
|
|
55
|
-
const row = db.get(`SELECT key_id, pub_key, priv_key, signature, uploaded
|
|
56
|
-
FROM signal_signed_prekey
|
|
57
|
-
WHERE session_id = ?`, [this.options.sessionId]);
|
|
58
|
-
return row ? (0, sqlite_1.decodeSignalSignedPreKeyRow)(row) : null;
|
|
59
|
-
}
|
|
60
|
-
async setSignedPreKey(record) {
|
|
61
|
-
const db = await this.getConnection();
|
|
62
|
-
db.run(`INSERT INTO signal_signed_prekey (
|
|
63
|
-
session_id,
|
|
64
|
-
key_id,
|
|
65
|
-
pub_key,
|
|
66
|
-
priv_key,
|
|
67
|
-
signature,
|
|
68
|
-
uploaded
|
|
69
|
-
) VALUES (?, ?, ?, ?, ?, ?)
|
|
70
|
-
ON CONFLICT(session_id) DO UPDATE SET
|
|
71
|
-
key_id=excluded.key_id,
|
|
72
|
-
pub_key=excluded.pub_key,
|
|
73
|
-
priv_key=excluded.priv_key,
|
|
74
|
-
signature=excluded.signature,
|
|
75
|
-
uploaded=excluded.uploaded`, [
|
|
76
|
-
this.options.sessionId,
|
|
77
|
-
record.keyId,
|
|
78
|
-
record.keyPair.pubKey,
|
|
79
|
-
record.keyPair.privKey,
|
|
80
|
-
record.signature,
|
|
81
|
-
record.uploaded === true ? 1 : 0
|
|
82
|
-
]);
|
|
83
|
-
}
|
|
84
|
-
async getSignedPreKeyById(keyId) {
|
|
85
|
-
const db = await this.getConnection();
|
|
86
|
-
const row = db.get(`SELECT key_id, pub_key, priv_key, signature, uploaded
|
|
87
|
-
FROM signal_signed_prekey
|
|
88
|
-
WHERE session_id = ? AND key_id = ?`, [this.options.sessionId, keyId]);
|
|
89
|
-
return row ? (0, sqlite_1.decodeSignalSignedPreKeyRow)(row) : null;
|
|
90
|
-
}
|
|
91
|
-
async setSignedPreKeyRotationTs(value) {
|
|
92
|
-
const db = await this.getConnection();
|
|
93
|
-
this.ensureMetaRow(db);
|
|
94
|
-
db.run(`UPDATE signal_meta
|
|
95
|
-
SET signed_prekey_rotation_ts = ?
|
|
96
|
-
WHERE session_id = ?`, [value, this.options.sessionId]);
|
|
97
|
-
}
|
|
98
|
-
async getSignedPreKeyRotationTs() {
|
|
99
|
-
const db = await this.getConnection();
|
|
100
|
-
const meta = this.getMeta(db);
|
|
101
|
-
return meta.signedPreKeyRotationTs;
|
|
102
|
-
}
|
|
103
|
-
async putPreKey(record) {
|
|
104
|
-
const db = await this.getConnection();
|
|
105
|
-
this.ensureMetaRow(db);
|
|
106
|
-
this.upsertPreKey(db, record);
|
|
107
|
-
db.run(`UPDATE signal_meta
|
|
108
|
-
SET next_prekey_id = MAX(next_prekey_id, ?)
|
|
109
|
-
WHERE session_id = ?`, [record.keyId + 1, this.options.sessionId]);
|
|
110
|
-
}
|
|
111
|
-
async getOrGenPreKeys(count, generator) {
|
|
112
|
-
if (!Number.isSafeInteger(count) || count <= 0) {
|
|
113
|
-
throw new Error(`invalid prekey count: ${count}`);
|
|
114
|
-
}
|
|
115
|
-
return this.withTransaction(async (db) => {
|
|
116
|
-
this.ensureMetaRow(db);
|
|
117
|
-
const available = db
|
|
118
|
-
.all(`SELECT key_id, pub_key, priv_key, uploaded
|
|
119
|
-
FROM signal_prekey
|
|
120
|
-
WHERE session_id = ? AND uploaded = 0
|
|
121
|
-
ORDER BY key_id ASC
|
|
122
|
-
LIMIT ?`, [this.options.sessionId, count])
|
|
123
|
-
.map((row) => (0, sqlite_1.decodeSignalPreKeyRow)(row));
|
|
124
|
-
if (available.length < count) {
|
|
125
|
-
let nextPreKeyId = this.getMeta(db).nextPreKeyId;
|
|
126
|
-
while (available.length < count) {
|
|
127
|
-
const requestedKeyId = nextPreKeyId;
|
|
128
|
-
const generated = await generator(requestedKeyId);
|
|
129
|
-
this.upsertPreKey(db, generated);
|
|
130
|
-
available.push(generated);
|
|
131
|
-
nextPreKeyId = Math.max(requestedKeyId + 1, generated.keyId + 1);
|
|
132
|
-
}
|
|
133
|
-
db.run(`UPDATE signal_meta
|
|
134
|
-
SET next_prekey_id = ?
|
|
135
|
-
WHERE session_id = ?`, [nextPreKeyId, this.options.sessionId]);
|
|
136
|
-
}
|
|
137
|
-
return available;
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
async getPreKeyById(keyId) {
|
|
141
|
-
const db = await this.getConnection();
|
|
142
|
-
const row = db.get(`SELECT key_id, pub_key, priv_key, uploaded
|
|
143
|
-
FROM signal_prekey
|
|
144
|
-
WHERE session_id = ? AND key_id = ?`, [this.options.sessionId, keyId]);
|
|
145
|
-
return row ? (0, sqlite_1.decodeSignalPreKeyRow)(row) : null;
|
|
146
|
-
}
|
|
147
|
-
async getPreKeysById(keyIds) {
|
|
148
|
-
if (keyIds.length === 0) {
|
|
149
|
-
return [];
|
|
150
|
-
}
|
|
151
|
-
const db = await this.getConnection();
|
|
152
|
-
const uniqueKeyIds = [...new Set(keyIds)];
|
|
153
|
-
const byId = new Map();
|
|
154
|
-
for (let start = 0; start < uniqueKeyIds.length; start += this.preKeyBatchSize) {
|
|
155
|
-
const end = Math.min(start + this.preKeyBatchSize, uniqueKeyIds.length);
|
|
156
|
-
const batchLength = end - start;
|
|
157
|
-
const placeholders = repeatSqlToken('?', batchLength, ', ');
|
|
158
|
-
const params = [this.options.sessionId];
|
|
159
|
-
for (let index = start; index < end; index += 1) {
|
|
160
|
-
params.push(uniqueKeyIds[index]);
|
|
161
|
-
}
|
|
162
|
-
const rows = db.all(`SELECT key_id, pub_key, priv_key, uploaded
|
|
163
|
-
FROM signal_prekey
|
|
164
|
-
WHERE session_id = ? AND key_id IN (${placeholders})`, params);
|
|
165
|
-
for (const row of rows) {
|
|
166
|
-
const record = (0, sqlite_1.decodeSignalPreKeyRow)(row);
|
|
167
|
-
byId.set(record.keyId, record);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return keyIds.map((keyId) => byId.get(keyId) ?? null);
|
|
171
|
-
}
|
|
172
|
-
async consumePreKeyById(keyId) {
|
|
173
|
-
return this.withTransaction((db) => {
|
|
174
|
-
const row = db.get(`SELECT key_id, pub_key, priv_key, uploaded
|
|
175
|
-
FROM signal_prekey
|
|
176
|
-
WHERE session_id = ? AND key_id = ?`, [this.options.sessionId, keyId]);
|
|
177
|
-
if (!row) {
|
|
178
|
-
return null;
|
|
179
|
-
}
|
|
180
|
-
db.run(`DELETE FROM signal_prekey
|
|
181
|
-
WHERE session_id = ? AND key_id = ?`, [this.options.sessionId, keyId]);
|
|
182
|
-
return (0, sqlite_1.decodeSignalPreKeyRow)(row);
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
async getOrGenSinglePreKey(generator) {
|
|
186
|
-
const records = await this.getOrGenPreKeys(1, generator);
|
|
187
|
-
return records[0];
|
|
188
|
-
}
|
|
189
|
-
async markKeyAsUploaded(keyId) {
|
|
190
|
-
const db = await this.getConnection();
|
|
191
|
-
const meta = this.getMeta(db);
|
|
192
|
-
if (keyId < 0 || keyId >= meta.nextPreKeyId) {
|
|
193
|
-
throw new Error(`prekey ${keyId} is out of boundary`);
|
|
194
|
-
}
|
|
195
|
-
db.run(`UPDATE signal_prekey
|
|
196
|
-
SET uploaded = 1
|
|
197
|
-
WHERE session_id = ? AND key_id <= ?`, [this.options.sessionId, keyId]);
|
|
198
|
-
}
|
|
199
|
-
async setServerHasPreKeys(value) {
|
|
200
|
-
const db = await this.getConnection();
|
|
201
|
-
this.ensureMetaRow(db);
|
|
202
|
-
db.run(`UPDATE signal_meta
|
|
203
|
-
SET server_has_prekeys = ?
|
|
204
|
-
WHERE session_id = ?`, [value ? 1 : 0, this.options.sessionId]);
|
|
205
|
-
}
|
|
206
|
-
async getServerHasPreKeys() {
|
|
207
|
-
const db = await this.getConnection();
|
|
208
|
-
const meta = this.getMeta(db);
|
|
209
|
-
return meta.serverHasPreKeys;
|
|
210
|
-
}
|
|
211
|
-
async hasSession(address) {
|
|
212
|
-
const db = await this.getConnection();
|
|
213
|
-
const target = (0, sqlite_1.toSignalAddressParts)(address);
|
|
214
|
-
return (db.get(`SELECT 1 AS has_session
|
|
215
|
-
FROM signal_session
|
|
216
|
-
WHERE session_id = ? AND user = ? AND server = ? AND device = ?
|
|
217
|
-
LIMIT 1`, [this.options.sessionId, target.user, target.server, target.device]) !== null);
|
|
218
|
-
}
|
|
219
|
-
async hasSessions(addresses) {
|
|
220
|
-
if (addresses.length === 0) {
|
|
221
|
-
return [];
|
|
222
|
-
}
|
|
223
|
-
const db = await this.getConnection();
|
|
224
|
-
const targets = addresses.map((address) => (0, sqlite_1.toSignalAddressParts)(address));
|
|
225
|
-
const existingKeys = new Set();
|
|
226
|
-
for (let start = 0; start < targets.length; start += this.hasSessionBatchSize) {
|
|
227
|
-
const end = Math.min(start + this.hasSessionBatchSize, targets.length);
|
|
228
|
-
const batchLength = end - start;
|
|
229
|
-
const filters = repeatSqlToken('(user = ? AND server = ? AND device = ?)', batchLength, ' OR ');
|
|
230
|
-
const params = [this.options.sessionId];
|
|
231
|
-
for (let index = start; index < end; index += 1) {
|
|
232
|
-
const target = targets[index];
|
|
233
|
-
params.push(target.user, target.server, target.device);
|
|
234
|
-
}
|
|
235
|
-
const rows = db.all(`SELECT user, server, device
|
|
236
|
-
FROM signal_session
|
|
237
|
-
WHERE session_id = ? AND (${filters})`, params);
|
|
238
|
-
for (const row of rows) {
|
|
239
|
-
existingKeys.add((0, jid_1.signalAddressKey)({
|
|
240
|
-
user: (0, coercion_1.asString)(row.user, 'signal_session.user'),
|
|
241
|
-
server: (0, coercion_1.asString)(row.server, 'signal_session.server'),
|
|
242
|
-
device: (0, coercion_1.asNumber)(row.device, 'signal_session.device')
|
|
243
|
-
}));
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
return targets.map((target) => existingKeys.has((0, jid_1.signalAddressKey)(target)));
|
|
247
|
-
}
|
|
248
|
-
async getSession(address) {
|
|
249
|
-
const db = await this.getConnection();
|
|
250
|
-
const target = (0, sqlite_1.toSignalAddressParts)(address);
|
|
251
|
-
const row = db.get(`SELECT user, server, device, record
|
|
252
|
-
FROM signal_session
|
|
253
|
-
WHERE session_id = ? AND user = ? AND server = ? AND device = ?`, [this.options.sessionId, target.user, target.server, target.device]);
|
|
254
|
-
return row ? (0, sqlite_1.decodeSignalSessionRecord)(row.record) : null;
|
|
255
|
-
}
|
|
256
|
-
async getSessionsBatch(addresses) {
|
|
257
|
-
if (addresses.length === 0) {
|
|
258
|
-
return [];
|
|
259
|
-
}
|
|
260
|
-
const db = await this.getConnection();
|
|
261
|
-
const targets = addresses.map((address) => (0, sqlite_1.toSignalAddressParts)(address));
|
|
262
|
-
const byAddressKey = new Map();
|
|
263
|
-
for (let start = 0; start < targets.length; start += this.hasSessionBatchSize) {
|
|
264
|
-
const end = Math.min(start + this.hasSessionBatchSize, targets.length);
|
|
265
|
-
const batchLength = end - start;
|
|
266
|
-
const filters = repeatSqlToken('(user = ? AND server = ? AND device = ?)', batchLength, ' OR ');
|
|
267
|
-
const params = [this.options.sessionId];
|
|
268
|
-
for (let index = start; index < end; index += 1) {
|
|
269
|
-
const target = targets[index];
|
|
270
|
-
params.push(target.user, target.server, target.device);
|
|
271
|
-
}
|
|
272
|
-
const rows = db.all(`SELECT user, server, device, record
|
|
273
|
-
FROM signal_session
|
|
274
|
-
WHERE session_id = ? AND (${filters})`, params);
|
|
275
|
-
for (const row of rows) {
|
|
276
|
-
byAddressKey.set((0, jid_1.signalAddressKey)({
|
|
277
|
-
user: (0, coercion_1.asString)(row.user, 'signal_session.user'),
|
|
278
|
-
server: (0, coercion_1.asString)(row.server, 'signal_session.server'),
|
|
279
|
-
device: (0, coercion_1.asNumber)(row.device, 'signal_session.device')
|
|
280
|
-
}), (0, sqlite_1.decodeSignalSessionRecord)(row.record));
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
return targets.map((target) => byAddressKey.get((0, jid_1.signalAddressKey)(target)) ?? null);
|
|
284
|
-
}
|
|
285
|
-
async setSession(address, session) {
|
|
286
|
-
const db = await this.getConnection();
|
|
287
|
-
const target = (0, sqlite_1.toSignalAddressParts)(address);
|
|
288
|
-
this.upsertSession(db, target, session);
|
|
289
|
-
}
|
|
290
|
-
async setSessionsBatch(entries) {
|
|
291
|
-
if (entries.length === 0) {
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
await this.withTransaction((db) => {
|
|
295
|
-
for (let index = 0; index < entries.length; index += 1) {
|
|
296
|
-
const entry = entries[index];
|
|
297
|
-
this.upsertSession(db, (0, sqlite_1.toSignalAddressParts)(entry.address), entry.session);
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
async deleteSession(address) {
|
|
302
|
-
const db = await this.getConnection();
|
|
303
|
-
const target = (0, sqlite_1.toSignalAddressParts)(address);
|
|
304
|
-
db.run(`DELETE FROM signal_session
|
|
305
|
-
WHERE session_id = ? AND user = ? AND server = ? AND device = ?`, [this.options.sessionId, target.user, target.server, target.device]);
|
|
306
|
-
}
|
|
307
|
-
async getRemoteIdentity(address) {
|
|
308
|
-
const db = await this.getConnection();
|
|
309
|
-
const target = (0, sqlite_1.toSignalAddressParts)(address);
|
|
310
|
-
const row = db.get(`SELECT identity_key
|
|
311
|
-
FROM signal_identity
|
|
312
|
-
WHERE session_id = ? AND user = ? AND server = ? AND device = ?`, [this.options.sessionId, target.user, target.server, target.device]);
|
|
313
|
-
return row ? (0, sqlite_1.decodeSignalRemoteIdentity)(row.identity_key) : null;
|
|
314
|
-
}
|
|
315
|
-
async getRemoteIdentities(addresses) {
|
|
316
|
-
if (addresses.length === 0) {
|
|
317
|
-
return [];
|
|
318
|
-
}
|
|
319
|
-
const db = await this.getConnection();
|
|
320
|
-
const targets = addresses.map((address) => (0, sqlite_1.toSignalAddressParts)(address));
|
|
321
|
-
const byAddressKey = new Map();
|
|
322
|
-
for (let start = 0; start < targets.length; start += this.hasSessionBatchSize) {
|
|
323
|
-
const end = Math.min(start + this.hasSessionBatchSize, targets.length);
|
|
324
|
-
const batchLength = end - start;
|
|
325
|
-
const filters = repeatSqlToken('(user = ? AND server = ? AND device = ?)', batchLength, ' OR ');
|
|
326
|
-
const params = [this.options.sessionId];
|
|
327
|
-
for (let index = start; index < end; index += 1) {
|
|
328
|
-
const target = targets[index];
|
|
329
|
-
params.push(target.user, target.server, target.device);
|
|
330
|
-
}
|
|
331
|
-
const rows = db.all(`SELECT user, server, device, identity_key
|
|
332
|
-
FROM signal_identity
|
|
333
|
-
WHERE session_id = ? AND (${filters})`, params);
|
|
334
|
-
for (const row of rows) {
|
|
335
|
-
byAddressKey.set((0, jid_1.signalAddressKey)({
|
|
336
|
-
user: (0, coercion_1.asString)(row.user, 'signal_identity.user'),
|
|
337
|
-
server: (0, coercion_1.asString)(row.server, 'signal_identity.server'),
|
|
338
|
-
device: (0, coercion_1.asNumber)(row.device, 'signal_identity.device')
|
|
339
|
-
}), (0, sqlite_1.decodeSignalRemoteIdentity)(row.identity_key));
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
return targets.map((target) => byAddressKey.get((0, jid_1.signalAddressKey)(target)) ?? null);
|
|
343
|
-
}
|
|
344
|
-
async setRemoteIdentity(address, identityKey) {
|
|
345
|
-
const db = await this.getConnection();
|
|
346
|
-
const target = (0, sqlite_1.toSignalAddressParts)(address);
|
|
347
|
-
this.upsertRemoteIdentity(db, target, identityKey);
|
|
348
|
-
}
|
|
349
|
-
async setRemoteIdentities(entries) {
|
|
350
|
-
if (entries.length === 0) {
|
|
351
|
-
return;
|
|
352
|
-
}
|
|
353
|
-
await this.withTransaction((db) => {
|
|
354
|
-
for (const entry of entries) {
|
|
355
|
-
const target = (0, sqlite_1.toSignalAddressParts)(entry.address);
|
|
356
|
-
this.upsertRemoteIdentity(db, target, entry.identityKey);
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
async clear() {
|
|
361
|
-
await this.withTransaction((db) => {
|
|
362
|
-
db.run('DELETE FROM signal_registration WHERE session_id = ?', [this.options.sessionId]);
|
|
363
|
-
db.run('DELETE FROM signal_signed_prekey WHERE session_id = ?', [
|
|
364
|
-
this.options.sessionId
|
|
365
|
-
]);
|
|
366
|
-
db.run('DELETE FROM signal_prekey WHERE session_id = ?', [this.options.sessionId]);
|
|
367
|
-
db.run('DELETE FROM signal_session WHERE session_id = ?', [this.options.sessionId]);
|
|
368
|
-
db.run('DELETE FROM signal_identity WHERE session_id = ?', [this.options.sessionId]);
|
|
369
|
-
db.run('DELETE FROM signal_meta WHERE session_id = ?', [this.options.sessionId]);
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
upsertPreKey(db, record) {
|
|
373
|
-
db.run(`INSERT INTO signal_prekey (
|
|
374
|
-
session_id,
|
|
375
|
-
key_id,
|
|
376
|
-
pub_key,
|
|
377
|
-
priv_key,
|
|
378
|
-
uploaded
|
|
379
|
-
) VALUES (?, ?, ?, ?, ?)
|
|
380
|
-
ON CONFLICT(session_id, key_id) DO UPDATE SET
|
|
381
|
-
pub_key=excluded.pub_key,
|
|
382
|
-
priv_key=excluded.priv_key,
|
|
383
|
-
uploaded=excluded.uploaded`, [
|
|
384
|
-
this.options.sessionId,
|
|
385
|
-
record.keyId,
|
|
386
|
-
record.keyPair.pubKey,
|
|
387
|
-
record.keyPair.privKey,
|
|
388
|
-
record.uploaded === true ? 1 : 0
|
|
389
|
-
]);
|
|
390
|
-
}
|
|
391
|
-
upsertSession(db, target, session) {
|
|
392
|
-
db.run(`INSERT INTO signal_session (
|
|
393
|
-
session_id,
|
|
394
|
-
user,
|
|
395
|
-
server,
|
|
396
|
-
device,
|
|
397
|
-
record
|
|
398
|
-
) VALUES (?, ?, ?, ?, ?)
|
|
399
|
-
ON CONFLICT(session_id, user, server, device) DO UPDATE SET
|
|
400
|
-
record=excluded.record`, [
|
|
401
|
-
this.options.sessionId,
|
|
402
|
-
target.user,
|
|
403
|
-
target.server,
|
|
404
|
-
target.device,
|
|
405
|
-
(0, sqlite_1.encodeSignalSessionRecord)(session)
|
|
406
|
-
]);
|
|
407
|
-
}
|
|
408
|
-
ensureMetaRow(db) {
|
|
409
|
-
db.run(`INSERT INTO signal_meta (
|
|
410
|
-
session_id,
|
|
411
|
-
server_has_prekeys,
|
|
412
|
-
next_prekey_id
|
|
413
|
-
) VALUES (?, 0, 1)
|
|
414
|
-
ON CONFLICT(session_id) DO NOTHING`, [this.options.sessionId]);
|
|
415
|
-
}
|
|
416
|
-
getMeta(db) {
|
|
417
|
-
this.ensureMetaRow(db);
|
|
418
|
-
const row = db.get(`SELECT server_has_prekeys, next_prekey_id, signed_prekey_rotation_ts
|
|
419
|
-
FROM signal_meta
|
|
420
|
-
WHERE session_id = ?`, [this.options.sessionId]);
|
|
421
|
-
return {
|
|
422
|
-
serverHasPreKeys: (0, coercion_1.toBoolOrUndef)(row.server_has_prekeys) === true,
|
|
423
|
-
nextPreKeyId: (0, coercion_1.asNumber)(row.next_prekey_id, 'signal_meta.next_prekey_id'),
|
|
424
|
-
signedPreKeyRotationTs: (0, coercion_1.asOptionalNumber)(row.signed_prekey_rotation_ts, 'signal_meta.signed_prekey_rotation_ts') ?? null
|
|
425
|
-
};
|
|
426
|
-
}
|
|
427
|
-
upsertRemoteIdentity(db, target, identityKey) {
|
|
428
|
-
db.run(`INSERT INTO signal_identity (
|
|
429
|
-
session_id,
|
|
430
|
-
user,
|
|
431
|
-
server,
|
|
432
|
-
device,
|
|
433
|
-
identity_key
|
|
434
|
-
) VALUES (?, ?, ?, ?, ?)
|
|
435
|
-
ON CONFLICT(session_id, user, server, device) DO UPDATE SET
|
|
436
|
-
identity_key=excluded.identity_key`, [this.options.sessionId, target.user, target.server, target.device, identityKey]);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
exports.WaSignalSqliteStore = WaSignalSqliteStore;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WA_SQLITE_DEFAULT_TABLE_NAMES = void 0;
|
|
4
|
-
exports.resolveSqliteTableNames = resolveSqliteTableNames;
|
|
5
|
-
exports.serializeSqliteTableNames = serializeSqliteTableNames;
|
|
6
|
-
exports.createSqliteTableNameSqlResolver = createSqliteTableNameSqlResolver;
|
|
7
|
-
const SQLITE_TABLE_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
8
|
-
const WA_SQLITE_TABLE_NAME_ORDER = Object.freeze([
|
|
9
|
-
'wa_migrations',
|
|
10
|
-
'auth_credentials',
|
|
11
|
-
'signal_meta',
|
|
12
|
-
'signal_registration',
|
|
13
|
-
'signal_signed_prekey',
|
|
14
|
-
'signal_prekey',
|
|
15
|
-
'signal_session',
|
|
16
|
-
'signal_identity',
|
|
17
|
-
'sender_keys',
|
|
18
|
-
'sender_key_distribution',
|
|
19
|
-
'appstate_sync_keys',
|
|
20
|
-
'appstate_collection_versions',
|
|
21
|
-
'appstate_collection_index_values',
|
|
22
|
-
'retry_outbound_messages',
|
|
23
|
-
'retry_inbound_counters',
|
|
24
|
-
'mailbox_messages',
|
|
25
|
-
'mailbox_threads',
|
|
26
|
-
'mailbox_contacts',
|
|
27
|
-
'group_participants_cache',
|
|
28
|
-
'device_list_cache'
|
|
29
|
-
]);
|
|
30
|
-
const WA_SQLITE_ALLOWED_TABLE_NAME_SET = new Set(WA_SQLITE_TABLE_NAME_ORDER);
|
|
31
|
-
const WA_SQLITE_ALLOWED_TABLE_NAME_LIST = WA_SQLITE_TABLE_NAME_ORDER.join(', ');
|
|
32
|
-
exports.WA_SQLITE_DEFAULT_TABLE_NAMES = Object.freeze({
|
|
33
|
-
wa_migrations: 'wa_migrations',
|
|
34
|
-
auth_credentials: 'auth_credentials',
|
|
35
|
-
signal_meta: 'signal_meta',
|
|
36
|
-
signal_registration: 'signal_registration',
|
|
37
|
-
signal_signed_prekey: 'signal_signed_prekey',
|
|
38
|
-
signal_prekey: 'signal_prekey',
|
|
39
|
-
signal_session: 'signal_session',
|
|
40
|
-
signal_identity: 'signal_identity',
|
|
41
|
-
sender_keys: 'sender_keys',
|
|
42
|
-
sender_key_distribution: 'sender_key_distribution',
|
|
43
|
-
appstate_sync_keys: 'appstate_sync_keys',
|
|
44
|
-
appstate_collection_versions: 'appstate_collection_versions',
|
|
45
|
-
appstate_collection_index_values: 'appstate_collection_index_values',
|
|
46
|
-
retry_outbound_messages: 'retry_outbound_messages',
|
|
47
|
-
retry_inbound_counters: 'retry_inbound_counters',
|
|
48
|
-
mailbox_messages: 'mailbox_messages',
|
|
49
|
-
mailbox_threads: 'mailbox_threads',
|
|
50
|
-
mailbox_contacts: 'mailbox_contacts',
|
|
51
|
-
group_participants_cache: 'group_participants_cache',
|
|
52
|
-
device_list_cache: 'device_list_cache'
|
|
53
|
-
});
|
|
54
|
-
const DEFAULT_SQLITE_TABLE_NAME_SERIALIZATION = serializeSqliteTableNames(exports.WA_SQLITE_DEFAULT_TABLE_NAMES);
|
|
55
|
-
function normalizeTableName(table, rawValue) {
|
|
56
|
-
const value = rawValue.trim();
|
|
57
|
-
if (value.length === 0) {
|
|
58
|
-
throw new Error(`sqlite tableNames.${table} must be a non-empty string`);
|
|
59
|
-
}
|
|
60
|
-
if (!SQLITE_TABLE_NAME_PATTERN.test(value)) {
|
|
61
|
-
throw new Error(`sqlite tableNames.${table} must match ${SQLITE_TABLE_NAME_PATTERN.toString()}`);
|
|
62
|
-
}
|
|
63
|
-
return value;
|
|
64
|
-
}
|
|
65
|
-
function assertNoDuplicateTableNames(tableNames) {
|
|
66
|
-
const seen = new Set();
|
|
67
|
-
for (const table of WA_SQLITE_TABLE_NAME_ORDER) {
|
|
68
|
-
const mapped = tableNames[table];
|
|
69
|
-
const normalizedMapped = mapped.toLowerCase();
|
|
70
|
-
if (seen.has(normalizedMapped)) {
|
|
71
|
-
throw new Error(`sqlite tableNames contains duplicate target "${mapped}"`);
|
|
72
|
-
}
|
|
73
|
-
seen.add(normalizedMapped);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
function resolveSqliteTableNames(overrides) {
|
|
77
|
-
if (!overrides) {
|
|
78
|
-
return exports.WA_SQLITE_DEFAULT_TABLE_NAMES;
|
|
79
|
-
}
|
|
80
|
-
const entries = Object.entries(overrides);
|
|
81
|
-
if (entries.length === 0) {
|
|
82
|
-
return exports.WA_SQLITE_DEFAULT_TABLE_NAMES;
|
|
83
|
-
}
|
|
84
|
-
const resolved = {
|
|
85
|
-
...exports.WA_SQLITE_DEFAULT_TABLE_NAMES
|
|
86
|
-
};
|
|
87
|
-
for (const [table, rawName] of entries) {
|
|
88
|
-
if (!WA_SQLITE_ALLOWED_TABLE_NAME_SET.has(table)) {
|
|
89
|
-
throw new Error(`unsupported sqlite tableNames key "${table}". Allowed table names: ${WA_SQLITE_ALLOWED_TABLE_NAME_LIST}`);
|
|
90
|
-
}
|
|
91
|
-
if (typeof rawName !== 'string') {
|
|
92
|
-
throw new Error(`sqlite tableNames.${table} must be a string`);
|
|
93
|
-
}
|
|
94
|
-
const tableName = table;
|
|
95
|
-
resolved[tableName] = normalizeTableName(tableName, rawName);
|
|
96
|
-
}
|
|
97
|
-
assertNoDuplicateTableNames(resolved);
|
|
98
|
-
return Object.freeze(resolved);
|
|
99
|
-
}
|
|
100
|
-
function serializeSqliteTableNames(tableNames) {
|
|
101
|
-
return WA_SQLITE_TABLE_NAME_ORDER.map((table) => `${table}=${tableNames[table]}`).join(';');
|
|
102
|
-
}
|
|
103
|
-
function escapeRegexToken(value) {
|
|
104
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
105
|
-
}
|
|
106
|
-
function createSqliteTableNameSqlResolver(tableNames) {
|
|
107
|
-
const serialized = serializeSqliteTableNames(tableNames);
|
|
108
|
-
if (serialized === DEFAULT_SQLITE_TABLE_NAME_SERIALIZATION) {
|
|
109
|
-
return (sql) => sql;
|
|
110
|
-
}
|
|
111
|
-
const pattern = new RegExp(`\\b(?:${WA_SQLITE_TABLE_NAME_ORDER.map(escapeRegexToken).join('|')})\\b`, 'g');
|
|
112
|
-
return (sql) => sql.replace(pattern, (token) => tableNames[token] ?? token);
|
|
113
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WaThreadSqliteStore = void 0;
|
|
4
|
-
const BaseSqliteStore_1 = require("../../providers/sqlite/BaseSqliteStore");
|
|
5
|
-
const coercion_1 = require("../../../util/coercion");
|
|
6
|
-
const collections_1 = require("../../../util/collections");
|
|
7
|
-
const THREAD_COLUMNS = 'jid, name, unread_count, archived, pinned, mute_end_ms, marked_as_unread, ephemeral_expiration';
|
|
8
|
-
function decodeThreadRow(row) {
|
|
9
|
-
return {
|
|
10
|
-
jid: (0, coercion_1.asString)(row.jid, 'mailbox_threads.jid'),
|
|
11
|
-
name: (0, coercion_1.asOptionalString)(row.name, 'mailbox_threads.name'),
|
|
12
|
-
unreadCount: (0, coercion_1.asOptionalNumber)(row.unread_count, 'mailbox_threads.unread_count'),
|
|
13
|
-
archived: (0, coercion_1.toBoolOrUndef)(row.archived),
|
|
14
|
-
pinned: (0, coercion_1.asOptionalNumber)(row.pinned, 'mailbox_threads.pinned'),
|
|
15
|
-
muteEndMs: (0, coercion_1.asOptionalNumber)(row.mute_end_ms, 'mailbox_threads.mute_end_ms'),
|
|
16
|
-
markedAsUnread: (0, coercion_1.toBoolOrUndef)(row.marked_as_unread),
|
|
17
|
-
ephemeralExpiration: (0, coercion_1.asOptionalNumber)(row.ephemeral_expiration, 'mailbox_threads.ephemeral_expiration')
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
class WaThreadSqliteStore extends BaseSqliteStore_1.BaseSqliteStore {
|
|
21
|
-
constructor(options) {
|
|
22
|
-
super(options, ['mailbox']);
|
|
23
|
-
}
|
|
24
|
-
async upsert(record) {
|
|
25
|
-
const db = await this.getConnection();
|
|
26
|
-
this.upsertThreadRow(db, record);
|
|
27
|
-
}
|
|
28
|
-
async upsertBatch(records) {
|
|
29
|
-
if (records.length === 0) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
await this.withTransaction((db) => {
|
|
33
|
-
for (const record of records) {
|
|
34
|
-
this.upsertThreadRow(db, record);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
async getByJid(jid) {
|
|
39
|
-
const db = await this.getConnection();
|
|
40
|
-
const row = db.get(`SELECT ${THREAD_COLUMNS}
|
|
41
|
-
FROM mailbox_threads
|
|
42
|
-
WHERE session_id = ? AND jid = ?`, [this.options.sessionId, jid]);
|
|
43
|
-
return row ? decodeThreadRow(row) : null;
|
|
44
|
-
}
|
|
45
|
-
async list(limit) {
|
|
46
|
-
const db = await this.getConnection();
|
|
47
|
-
const rows = db.all(`SELECT ${THREAD_COLUMNS}
|
|
48
|
-
FROM mailbox_threads
|
|
49
|
-
WHERE session_id = ?
|
|
50
|
-
LIMIT ?`, [this.options.sessionId, (0, collections_1.normalizeQueryLimit)(limit, 100)]);
|
|
51
|
-
return rows.map(decodeThreadRow);
|
|
52
|
-
}
|
|
53
|
-
async deleteByJid(jid) {
|
|
54
|
-
const db = await this.getConnection();
|
|
55
|
-
db.run(`DELETE FROM mailbox_threads
|
|
56
|
-
WHERE session_id = ? AND jid = ?`, [this.options.sessionId, jid]);
|
|
57
|
-
const row = db.get('SELECT changes() AS total', []);
|
|
58
|
-
return row ? Number(row.total) : 0;
|
|
59
|
-
}
|
|
60
|
-
async clear() {
|
|
61
|
-
const db = await this.getConnection();
|
|
62
|
-
db.run('DELETE FROM mailbox_threads WHERE session_id = ?', [this.options.sessionId]);
|
|
63
|
-
}
|
|
64
|
-
upsertThreadRow(db, record) {
|
|
65
|
-
db.run(`INSERT INTO mailbox_threads (
|
|
66
|
-
session_id, jid, name, unread_count, archived, pinned,
|
|
67
|
-
mute_end_ms, marked_as_unread, ephemeral_expiration
|
|
68
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
69
|
-
ON CONFLICT(session_id, jid) DO UPDATE SET
|
|
70
|
-
name=COALESCE(excluded.name, mailbox_threads.name),
|
|
71
|
-
unread_count=COALESCE(excluded.unread_count, mailbox_threads.unread_count),
|
|
72
|
-
archived=COALESCE(excluded.archived, mailbox_threads.archived),
|
|
73
|
-
pinned=COALESCE(excluded.pinned, mailbox_threads.pinned),
|
|
74
|
-
mute_end_ms=COALESCE(excluded.mute_end_ms, mailbox_threads.mute_end_ms),
|
|
75
|
-
marked_as_unread=COALESCE(excluded.marked_as_unread, mailbox_threads.marked_as_unread),
|
|
76
|
-
ephemeral_expiration=COALESCE(excluded.ephemeral_expiration, mailbox_threads.ephemeral_expiration)`, [
|
|
77
|
-
this.options.sessionId,
|
|
78
|
-
record.jid,
|
|
79
|
-
record.name ?? null,
|
|
80
|
-
record.unreadCount ?? null,
|
|
81
|
-
record.archived === undefined ? null : record.archived ? 1 : 0,
|
|
82
|
-
record.pinned ?? null,
|
|
83
|
-
record.muteEndMs ?? null,
|
|
84
|
-
record.markedAsUnread === undefined ? null : record.markedAsUnread ? 1 : 0,
|
|
85
|
-
record.ephemeralExpiration ?? null
|
|
86
|
-
]);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
exports.WaThreadSqliteStore = WaThreadSqliteStore;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { WaAppStateStoreData, WaAppStateSyncKey } from '../types';
|
|
2
|
-
type SqliteRow = Readonly<Record<string, unknown>>;
|
|
3
|
-
export declare function encodeAppStateFingerprint(fingerprint: WaAppStateSyncKey['fingerprint']): Uint8Array | null;
|
|
4
|
-
export declare function decodeAppStateFingerprint(raw: unknown): WaAppStateSyncKey['fingerprint'] | undefined;
|
|
5
|
-
export declare function decodeAppStateSyncKeys(rows: readonly SqliteRow[]): readonly WaAppStateSyncKey[];
|
|
6
|
-
export declare function decodeAppStateCollections(versionRows: readonly SqliteRow[], valueRows: readonly SqliteRow[]): WaAppStateStoreData['collections'];
|
|
7
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const SERIALIZED_PUB_KEY_PREFIX = 5;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { WaRetryOutboundState, WaRetryReplayPayload } from './types';
|
|
2
|
-
export declare function encodeRetryReplayPayload(payload: WaRetryReplayPayload): Uint8Array;
|
|
3
|
-
export declare function decodeRetryReplayPayload(raw: Uint8Array): WaRetryReplayPayload;
|
|
4
|
-
export declare function pickRetryStateMax(left: WaRetryOutboundState, right: WaRetryOutboundState): WaRetryOutboundState;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type WaSqliteConnection } from '../../providers/sqlite/connection';
|
|
2
|
-
import { type WaSqliteMigrationDomain } from '../../providers/sqlite/migrations';
|
|
3
|
-
import type { WaSqliteStorageOptions } from '../../types';
|
|
4
|
-
export declare abstract class BaseSqliteStore {
|
|
5
|
-
protected readonly options: WaSqliteStorageOptions;
|
|
6
|
-
private readonly migrationDomains;
|
|
7
|
-
private connectionPromise;
|
|
8
|
-
protected constructor(options: WaSqliteStorageOptions, migrationDomains: readonly WaSqliteMigrationDomain[]);
|
|
9
|
-
protected getConnection(): Promise<WaSqliteConnection>;
|
|
10
|
-
protected withTransaction<T>(run: (connection: WaSqliteConnection) => Promise<T> | T): Promise<T>;
|
|
11
|
-
destroy(): Promise<void>;
|
|
12
|
-
}
|