@open-e2ee/signal-protocol-sdk 0.1.0-alpha.9 → 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/ADAPTERS.md +12 -12
- package/ARCHITECTURE.md +12 -4
- package/CHANGELOG.md +457 -0
- package/README.md +25 -15
- package/SECURITY.md +1 -1
- package/client/README.md +2 -2
- package/device/README.md +3 -1
- package/dist/client/client.d.ts +6 -6
- package/dist/client/client.js +6 -6
- package/dist/client/compose.d.ts +2 -2
- package/dist/client/config.d.ts +17 -1
- package/dist/client/config.d.ts.map +1 -1
- package/dist/client/config.js.map +1 -1
- package/dist/client/index.d.ts +2 -2
- package/dist/device/expo-metadata.d.ts +26 -0
- package/dist/device/expo-metadata.d.ts.map +1 -0
- package/dist/device/expo-metadata.js +33 -0
- package/dist/device/expo-metadata.js.map +1 -0
- package/dist/device/index.d.ts +1 -1
- package/dist/device/index.d.ts.map +1 -1
- package/dist/device/index.js +5 -1
- package/dist/device/index.js.map +1 -1
- package/dist/device/provisioning.d.ts +4 -12
- package/dist/device/provisioning.d.ts.map +1 -1
- package/dist/device/provisioning.js +4 -21
- package/dist/device/provisioning.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/dist/internal/crypto/symmetric/aes.d.ts.map +1 -1
- package/dist/internal/crypto/symmetric/aes.js +27 -30
- package/dist/internal/crypto/symmetric/aes.js.map +1 -1
- package/dist/internal/crypto/utils.d.ts.map +1 -1
- package/dist/internal/crypto/utils.js +26 -1
- package/dist/internal/crypto/utils.js.map +1 -1
- package/dist/internal/encoding/proto/pq-ratchet-serialize.d.ts.map +1 -1
- package/dist/internal/encoding/proto/pq-ratchet-serialize.js +12 -4
- package/dist/internal/encoding/proto/pq-ratchet-serialize.js.map +1 -1
- package/dist/internal/encoding/proto/primitives.d.ts +261 -6
- package/dist/internal/encoding/proto/primitives.d.ts.map +1 -1
- package/dist/internal/encoding/proto/primitives.js +468 -6
- package/dist/internal/encoding/proto/primitives.js.map +1 -1
- package/dist/internal/encoding/proto/sender-key-message.d.ts +4 -3
- package/dist/internal/encoding/proto/sender-key-message.d.ts.map +1 -1
- package/dist/internal/encoding/proto/sender-key-message.js +97 -76
- package/dist/internal/encoding/proto/sender-key-message.js.map +1 -1
- package/dist/internal/encoding/proto/signal-message.d.ts +7 -2
- package/dist/internal/encoding/proto/signal-message.d.ts.map +1 -1
- package/dist/internal/encoding/proto/signal-message.js +194 -110
- package/dist/internal/encoding/proto/signal-message.js.map +1 -1
- package/dist/internal/manager/manager.d.ts +2 -2
- package/dist/internal/manager/manager.js +1 -1
- package/dist/internal/manager/manager.js.map +1 -1
- package/dist/internal/protocol/sealed-sender/proto/index.d.ts +50 -4
- package/dist/internal/protocol/sealed-sender/proto/index.d.ts.map +1 -1
- package/dist/internal/protocol/sealed-sender/proto/index.js +273 -151
- package/dist/internal/protocol/sealed-sender/proto/index.js.map +1 -1
- package/dist/internal/protocol/spqr/braid.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/braid.js.map +1 -1
- package/dist/internal/protocol/spqr/index.d.ts +1 -1
- package/dist/internal/protocol/spqr/index.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/index.js +0 -2
- package/dist/internal/protocol/spqr/index.js.map +1 -1
- package/dist/internal/protocol/spqr/message.d.ts +0 -18
- package/dist/internal/protocol/spqr/message.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/message.js +1 -37
- package/dist/internal/protocol/spqr/message.js.map +1 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/progress.d.ts +30 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/progress.d.ts.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/progress.js +45 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/progress.js.map +1 -0
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/codec.d.ts +11 -8
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/codec.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/codec.js +11 -8
- package/dist/internal/protocol/spqr/ml-kem-braid/rs/codec.js.map +1 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/serialize.d.ts +7 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/serialize.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/serialize.js +342 -152
- package/dist/internal/protocol/spqr/ml-kem-braid/serialize.js.map +1 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/types.d.ts +9 -6
- package/dist/internal/protocol/spqr/ml-kem-braid/types.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/ml-kem-braid/types.js.map +1 -1
- package/dist/internal/protocol/spqr/spqr.d.ts +5 -3
- package/dist/internal/protocol/spqr/spqr.d.ts.map +1 -1
- package/dist/internal/protocol/spqr/spqr.js +62 -7
- package/dist/internal/protocol/spqr/spqr.js.map +1 -1
- package/dist/internal/session/cipher.d.ts +4 -0
- package/dist/internal/session/cipher.d.ts.map +1 -1
- package/dist/internal/session/cipher.js +8 -3
- package/dist/internal/session/cipher.js.map +1 -1
- package/dist/internal/session/types.d.ts +8 -0
- package/dist/internal/session/types.d.ts.map +1 -1
- package/dist/layers.d.ts +2 -2
- package/dist/layers.d.ts.map +1 -1
- package/dist/layers.js +2 -2
- package/dist/layers.js.map +1 -1
- package/dist/local/store/index.d.ts +3 -3
- package/dist/local/store/index.d.ts.map +1 -1
- package/dist/local/store/index.js +4 -4
- package/dist/local/store/index.js.map +1 -1
- package/dist/local/store/{mock → memory}/adapter.d.ts +10 -10
- package/dist/local/store/memory/adapter.d.ts.map +1 -0
- package/dist/local/store/{mock → memory}/adapter.js +5 -5
- package/dist/local/store/memory/adapter.js.map +1 -0
- package/dist/local/store/{mock → memory}/failures.d.ts +6 -6
- package/dist/local/store/memory/failures.d.ts.map +1 -0
- package/dist/local/store/{mock → memory}/failures.js +6 -6
- package/dist/local/store/memory/failures.js.map +1 -0
- package/dist/local/store/memory/index.d.ts +11 -0
- package/dist/local/store/memory/index.d.ts.map +1 -0
- package/dist/local/store/memory/index.js +7 -0
- package/dist/local/store/memory/index.js.map +1 -0
- package/dist/local/store/node/database.d.ts +1 -1
- package/dist/local/store/node/database.js +1 -1
- package/dist/local/store/react-native/adapter.d.ts.map +1 -1
- package/dist/local/store/react-native/adapter.js +69 -1
- package/dist/local/store/react-native/adapter.js.map +1 -1
- package/dist/local/store/react-native/backend-conformance.d.ts +66 -0
- package/dist/local/store/react-native/backend-conformance.d.ts.map +1 -0
- package/dist/local/store/react-native/backend-conformance.js +326 -0
- package/dist/local/store/react-native/backend-conformance.js.map +1 -0
- package/dist/local/store/react-native/index.d.ts +9 -4
- package/dist/local/store/react-native/index.d.ts.map +1 -1
- package/dist/local/store/react-native/index.js +2 -0
- package/dist/local/store/react-native/index.js.map +1 -1
- package/dist/local/store/react-native/reference-backend.d.ts +42 -0
- package/dist/local/store/react-native/reference-backend.d.ts.map +1 -0
- package/dist/local/store/react-native/reference-backend.js +177 -0
- package/dist/local/store/react-native/reference-backend.js.map +1 -0
- package/dist/local/store/react-native/storage.d.ts +9 -0
- package/dist/local/store/react-native/storage.d.ts.map +1 -1
- package/dist/local/store/web/adapter.d.ts +11 -1
- package/dist/local/store/web/adapter.d.ts.map +1 -1
- package/dist/local/store/web/adapter.js +226 -50
- package/dist/local/store/web/adapter.js.map +1 -1
- package/dist/local/store/web/index.d.ts +3 -2
- package/dist/local/store/web/index.d.ts.map +1 -1
- package/dist/local/store/web/index.js.map +1 -1
- package/dist/local/vault/index.d.ts +5 -1
- package/dist/local/vault/index.d.ts.map +1 -1
- package/dist/local/vault/index.js +1 -1
- package/dist/local/vault/index.js.map +1 -1
- package/dist/remote/relay/convex/component/certificates.d.ts.map +1 -1
- package/dist/remote/relay/convex/component/certificates.js +26 -31
- package/dist/remote/relay/convex/component/certificates.js.map +1 -1
- package/dist/remote/relay/index.d.ts +1 -1
- package/dist/remote/relay/index.d.ts.map +1 -1
- package/dist/remote/relay/index.js +2 -2
- package/dist/remote/relay/index.js.map +1 -1
- package/dist/remote/relay/{mock → memory}/adapter.d.ts +17 -17
- package/dist/remote/relay/memory/adapter.d.ts.map +1 -0
- package/dist/remote/relay/{mock → memory}/adapter.js +17 -17
- package/dist/remote/relay/memory/adapter.js.map +1 -0
- package/dist/remote/relay/{mock → memory}/failures.d.ts +5 -5
- package/dist/remote/relay/memory/failures.d.ts.map +1 -0
- package/dist/remote/relay/{mock → memory}/failures.js +1 -1
- package/dist/remote/relay/memory/failures.js.map +1 -0
- package/dist/remote/relay/{mock → memory}/group-server.d.ts +1 -1
- package/dist/remote/relay/memory/group-server.d.ts.map +1 -0
- package/dist/remote/relay/{mock → memory}/group-server.js +1 -1
- package/dist/remote/relay/memory/group-server.js.map +1 -0
- package/dist/remote/relay/memory/index.d.ts +11 -0
- package/dist/remote/relay/memory/index.d.ts.map +1 -0
- package/dist/remote/relay/memory/index.js +7 -0
- package/dist/remote/relay/memory/index.js.map +1 -0
- package/dist/types/errors.d.ts +33 -0
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +36 -0
- package/dist/types/errors.js.map +1 -1
- package/dist/types/protocol-config.d.ts +44 -1
- package/dist/types/protocol-config.d.ts.map +1 -1
- package/dist/types/protocol-config.js +1 -0
- package/dist/types/protocol-config.js.map +1 -1
- package/dist/types/session.d.ts +1 -1
- package/dist/types/session.js +1 -1
- package/docs/ASSURANCE.md +49 -14
- package/docs/CLIENT_COMPOSITION.md +3 -3
- package/docs/DEVIATIONS.md +72 -31
- package/docs/GETTING_STARTED.md +11 -11
- package/docs/PACKAGE_SURFACE.md +10 -8
- package/docs/PROTOCOL_POLICY.md +6 -0
- package/docs/RECIPES.md +12 -12
- package/local/store/README.md +95 -8
- package/local/store/{mock → memory}/README.md +8 -8
- package/local/store/react-native/README.md +34 -2
- package/local/store/web/README.md +30 -3
- package/package.json +14 -11
- package/remote/README.md +7 -7
- package/remote/relay/README.md +5 -5
- package/remote/relay/{mock → memory}/README.md +8 -8
- package/dist/local/store/mock/adapter.d.ts.map +0 -1
- package/dist/local/store/mock/adapter.js.map +0 -1
- package/dist/local/store/mock/failures.d.ts.map +0 -1
- package/dist/local/store/mock/failures.js.map +0 -1
- package/dist/local/store/mock/index.d.ts +0 -11
- package/dist/local/store/mock/index.d.ts.map +0 -1
- package/dist/local/store/mock/index.js +0 -7
- package/dist/local/store/mock/index.js.map +0 -1
- package/dist/remote/relay/mock/adapter.d.ts.map +0 -1
- package/dist/remote/relay/mock/adapter.js.map +0 -1
- package/dist/remote/relay/mock/failures.d.ts.map +0 -1
- package/dist/remote/relay/mock/failures.js.map +0 -1
- package/dist/remote/relay/mock/group-server.d.ts.map +0 -1
- package/dist/remote/relay/mock/group-server.js.map +0 -1
- package/dist/remote/relay/mock/index.d.ts +0 -11
- package/dist/remote/relay/mock/index.d.ts.map +0 -1
- package/dist/remote/relay/mock/index.js +0 -7
- package/dist/remote/relay/mock/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../../local/store/react-native/storage.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../../local/store/react-native/storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,0BAA0B;IACzC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC7C,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAChC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,mFAAmF;IACnF,WAAW,CAAC,UAAU,EAAE,SAAS,4BAA4B,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjF;AAED,MAAM,MAAM,4BAA4B,GACpC;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACtE;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE;AACnD,sEAAsE;GACpE;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE;AACzF;;;GAGG;GACD;IACE,QAAQ,CAAC,IAAI,EAAE,uBAAuB,CAAC;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC"}
|
|
@@ -45,6 +45,7 @@ export declare class IndexedDbSignalProtocolStore implements ISignalProtocolLoca
|
|
|
45
45
|
private readonly dbName;
|
|
46
46
|
private readonly dbVersion;
|
|
47
47
|
private readonly _metadata;
|
|
48
|
+
constructor();
|
|
48
49
|
/**
|
|
49
50
|
* Initialize the storage adapter
|
|
50
51
|
*
|
|
@@ -55,6 +56,16 @@ export declare class IndexedDbSignalProtocolStore implements ISignalProtocolLoca
|
|
|
55
56
|
* @throws Error if IndexedDB is not available
|
|
56
57
|
*/
|
|
57
58
|
initialize(): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Close the underlying IndexedDB connection and drop the in-memory copy of
|
|
61
|
+
* the database key.
|
|
62
|
+
*
|
|
63
|
+
* An open connection blocks both deletion and version upgrades of the
|
|
64
|
+
* database from any other connection, so an application that signs out,
|
|
65
|
+
* clears local state, or migrates must be able to close the store. After
|
|
66
|
+
* close(), call initialize() again before any other operation.
|
|
67
|
+
*/
|
|
68
|
+
close(): void;
|
|
58
69
|
/**
|
|
59
70
|
* Get the database encryption key
|
|
60
71
|
*
|
|
@@ -111,7 +122,6 @@ export declare class IndexedDbSignalProtocolStore implements ISignalProtocolLoca
|
|
|
111
122
|
private serializeAddress;
|
|
112
123
|
private serializeContactIdentityKey;
|
|
113
124
|
private decodeContactRecord;
|
|
114
|
-
private putContactRecord;
|
|
115
125
|
/**
|
|
116
126
|
* Encrypt data using AES-256-GCM with Web Crypto API
|
|
117
127
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../local/store/web/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EACV,yBAAyB,EACzB,aAAa,EACb,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,eAAe,EACf,WAAW,EACX,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAQpG,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../local/store/web/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EACV,yBAAyB,EACzB,aAAa,EACb,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,eAAe,EACf,WAAW,EACX,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,E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AAC;QACxB,gBAAgB,EAAE,MAAM,CAAC;QACzB,YAAY,EAAE,MAAM,CAAC;QACrB,iBAAiB,EAAE,MAAM,CAAC;KAC3B,CAAC,CAqCD;IAEK,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAItC;IAEK,gBAAgB,IAAI,OAAO,CAAC;QAChC,QAAQ,EAAE,MAAM,CAAC;QACjB,eAAe,EAAE,MAAM,CAAC;QACxB,gBAAgB,EAAE,MAAM,CAAC;QACzB,YAAY,EAAE,MAAM,CAAC;QACrB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,KAAK,EAAE,MAAM,CAAC;KACf,CAAC,CAgCD;IAED,OAAO,CAAC,4BAA4B;IAIpC,OAAO,CAAC,yBAAyB;IAQjC,OAAO,CAAC,6BAA6B;IASrC,OAAO,CAAC,0BAA0B;CAGnC"}
|
|
@@ -22,9 +22,102 @@ import { openDB } from 'idb';
|
|
|
22
22
|
import { MAX_UNACKNOWLEDGED_SESSION_AGE_MS } from '../../../types/protocol-config.js';
|
|
23
23
|
import { getErrorMessage } from '../../../utils/errors.js';
|
|
24
24
|
import { acceptContactIdentityRotation as acceptRotation, createUnverifiedContactIdentityRecord, evaluateContactIdentityCandidate, validateContactIdentityRecord, verifyContactIdentityRecord, } from '../../../keys/identity.js';
|
|
25
|
-
import { IdentityKeyChange } from '../../../types/index.js';
|
|
25
|
+
import { IdentityKeyChange, StorageQuotaExceededError, } from '../../../types/index.js';
|
|
26
26
|
import { assertCurrentSessionRecord, } from '../../../types/session.js';
|
|
27
27
|
import { deserializeSessionRecord, serializeSessionRecord } from '../session-codec.js';
|
|
28
|
+
/**
|
|
29
|
+
* Compares stored ciphertext, not secret material - corrupt-row cleanup only
|
|
30
|
+
* deletes a row whose bytes are still the ones that failed to deserialize.
|
|
31
|
+
*/
|
|
32
|
+
function encryptedBytesEqual(a, b) {
|
|
33
|
+
if (a.length !== b.length) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
for (let i = 0; i < a.length; i += 1) {
|
|
37
|
+
if (a[i] !== b[i]) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* An IndexedDB add() that lost a create race fails with ConstraintError.
|
|
45
|
+
* Checked by name rather than instanceof: the error crosses the idb
|
|
46
|
+
* wrapper, and test doubles construct it without the DOMException class.
|
|
47
|
+
*/
|
|
48
|
+
function isConstraintError(error) {
|
|
49
|
+
return (typeof error === 'object' &&
|
|
50
|
+
error !== null &&
|
|
51
|
+
error.name === 'ConstraintError');
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A write that exhausts the origin's storage quota fails with
|
|
55
|
+
* QuotaExceededError. Checked by name rather than instanceof, like
|
|
56
|
+
* isConstraintError: engines differ on the constructor - a DOMException
|
|
57
|
+
* today, an Error subclass in the newer storage spec - and the name is
|
|
58
|
+
* the stable part.
|
|
59
|
+
*/
|
|
60
|
+
function isQuotaExceededError(error) {
|
|
61
|
+
return (typeof error === 'object' &&
|
|
62
|
+
error !== null &&
|
|
63
|
+
error.name === 'QuotaExceededError');
|
|
64
|
+
}
|
|
65
|
+
function mapQuotaFailure(operation, error) {
|
|
66
|
+
if (!isQuotaExceededError(error))
|
|
67
|
+
return error;
|
|
68
|
+
// The failure is Error-shaped by the name check above, but not always
|
|
69
|
+
// instanceof Error: Node's DOMException does not extend Error.
|
|
70
|
+
return new StorageQuotaExceededError(operation, error);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Rebinds every method of the store so a QuotaExceededError from
|
|
74
|
+
* IndexedDB crosses the adapter boundary as the typed
|
|
75
|
+
* StorageQuotaExceededError. Quota exhaustion can surface from any put,
|
|
76
|
+
* add, or transaction commit, so the mapping lives at this one seam
|
|
77
|
+
* instead of inside each of the adapter's write paths, and a method
|
|
78
|
+
* added later is covered without a wrapper of its own. The failed
|
|
79
|
+
* transaction rolls back whole, so the typed error always means the
|
|
80
|
+
* write did not persist.
|
|
81
|
+
*
|
|
82
|
+
* The walk starts at the instance's own prototype rather than this
|
|
83
|
+
* class's, so a subclass override is the method that gets wrapped
|
|
84
|
+
* instead of being shadowed by a wrapper around the base method.
|
|
85
|
+
*/
|
|
86
|
+
function mapQuotaFailuresAtBoundary(store) {
|
|
87
|
+
const methods = new Map();
|
|
88
|
+
for (let prototype = Object.getPrototypeOf(store); prototype !== null && prototype !== Object.prototype; prototype = Object.getPrototypeOf(prototype)) {
|
|
89
|
+
for (const name of Object.getOwnPropertyNames(prototype)) {
|
|
90
|
+
// First found wins: the walk goes most-derived first.
|
|
91
|
+
if (name === 'constructor' || methods.has(name))
|
|
92
|
+
continue;
|
|
93
|
+
const descriptor = Object.getOwnPropertyDescriptor(prototype, name);
|
|
94
|
+
if (typeof descriptor?.value !== 'function')
|
|
95
|
+
continue;
|
|
96
|
+
methods.set(name, descriptor.value);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
for (const [name, method] of methods) {
|
|
100
|
+
store[name] = function mapped(...args) {
|
|
101
|
+
let result;
|
|
102
|
+
try {
|
|
103
|
+
result = method.apply(this, args);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
throw mapQuotaFailure(name, error);
|
|
107
|
+
}
|
|
108
|
+
// Duck-typed rather than instanceof Promise so a cross-realm
|
|
109
|
+
// promise or plain thenable from an override maps too.
|
|
110
|
+
if (result !== null &&
|
|
111
|
+
typeof result === 'object' &&
|
|
112
|
+
typeof result.then === 'function') {
|
|
113
|
+
return Promise.resolve(result).catch((error) => {
|
|
114
|
+
throw mapQuotaFailure(name, error);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
28
121
|
/**
|
|
29
122
|
* Web storage adapter using IndexedDB and Web Crypto API
|
|
30
123
|
*
|
|
@@ -40,6 +133,9 @@ export class IndexedDbSignalProtocolStore {
|
|
|
40
133
|
dbName = 'signal-protocol-storage';
|
|
41
134
|
dbVersion = 6; // v6 indexes sender key records by senderKeyId
|
|
42
135
|
_metadata = new Map();
|
|
136
|
+
constructor() {
|
|
137
|
+
mapQuotaFailuresAtBoundary(this);
|
|
138
|
+
}
|
|
43
139
|
/**
|
|
44
140
|
* Initialize the storage adapter
|
|
45
141
|
*
|
|
@@ -126,14 +222,39 @@ export class IndexedDbSignalProtocolStore {
|
|
|
126
222
|
this.databaseKey = storedKey;
|
|
127
223
|
}
|
|
128
224
|
else {
|
|
129
|
-
// Generate new 32-byte key using Web Crypto
|
|
130
|
-
|
|
131
|
-
|
|
225
|
+
// Generate new 32-byte key using Web Crypto. add() refuses to
|
|
226
|
+
// overwrite, so when two connections bootstrap a fresh database
|
|
227
|
+
// concurrently exactly one key is ever stored - the loser adopts the
|
|
228
|
+
// winner's key instead of encrypting records nobody else can read.
|
|
229
|
+
const candidate = crypto.getRandomValues(new Uint8Array(32));
|
|
230
|
+
try {
|
|
231
|
+
await this.db.add('metadata', candidate, 'databaseKey');
|
|
232
|
+
this.databaseKey = candidate;
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
if (!isConstraintError(error))
|
|
236
|
+
throw error;
|
|
237
|
+
this.databaseKey = (await this.db.get('metadata', 'databaseKey'));
|
|
238
|
+
}
|
|
132
239
|
// ⚠️ WARNING: Browser storage is vulnerable to XSS attacks
|
|
133
240
|
console.warn('[IndexedDbSignalProtocolStore] Database encryption key stored in IndexedDB. ' +
|
|
134
241
|
'Ensure Content Security Policy (CSP) is configured to mitigate XSS risks.');
|
|
135
242
|
}
|
|
136
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Close the underlying IndexedDB connection and drop the in-memory copy of
|
|
246
|
+
* the database key.
|
|
247
|
+
*
|
|
248
|
+
* An open connection blocks both deletion and version upgrades of the
|
|
249
|
+
* database from any other connection, so an application that signs out,
|
|
250
|
+
* clears local state, or migrates must be able to close the store. After
|
|
251
|
+
* close(), call initialize() again before any other operation.
|
|
252
|
+
*/
|
|
253
|
+
close() {
|
|
254
|
+
this.db?.close();
|
|
255
|
+
this.db = null;
|
|
256
|
+
this.databaseKey = null;
|
|
257
|
+
}
|
|
137
258
|
/**
|
|
138
259
|
* Get the database encryption key
|
|
139
260
|
*
|
|
@@ -190,21 +311,40 @@ export class IndexedDbSignalProtocolStore {
|
|
|
190
311
|
async saveContactIdentity(address, identity, identityType, suppliedCommitment) {
|
|
191
312
|
this.ensureInitialized();
|
|
192
313
|
const contactKey = this.serializeContactIdentityKey(address, identityType);
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
314
|
+
for (;;) {
|
|
315
|
+
const existing = await this.db.get('contacts', contactKey);
|
|
316
|
+
const record = existing ? await this.decodeContactRecord(existing.data) : null;
|
|
317
|
+
if (existing && record && existing.revision !== record.revision) {
|
|
318
|
+
throw new Error('Contact identity revision metadata does not match encrypted record');
|
|
319
|
+
}
|
|
320
|
+
const status = evaluateContactIdentityCandidate(record, identity, suppliedCommitment);
|
|
321
|
+
if (status === 'NEW') {
|
|
322
|
+
const created = createUnverifiedContactIdentityRecord(identity, Date.now());
|
|
323
|
+
validateContactIdentityRecord(created);
|
|
324
|
+
try {
|
|
325
|
+
// add() refuses to overwrite: if a concurrent connection pinned
|
|
326
|
+
// this contact first, re-evaluate the candidate against the record
|
|
327
|
+
// that won instead of silently replacing a TOFU pin.
|
|
328
|
+
await this.db.add('contacts', {
|
|
329
|
+
key: contactKey,
|
|
330
|
+
userId: address.userId,
|
|
331
|
+
data: await this.encrypt(JSON.stringify(created)),
|
|
332
|
+
revision: created.revision,
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
catch (error) {
|
|
336
|
+
if (isConstraintError(error))
|
|
337
|
+
continue;
|
|
338
|
+
throw error;
|
|
339
|
+
}
|
|
340
|
+
return IdentityKeyChange.NEW_IDENTITY;
|
|
341
|
+
}
|
|
342
|
+
if (status === 'MATCH')
|
|
343
|
+
return IdentityKeyChange.UNCHANGED;
|
|
344
|
+
if (status === 'ROLLBACK')
|
|
345
|
+
return IdentityKeyChange.ROLLBACK;
|
|
346
|
+
return IdentityKeyChange.CHANGED;
|
|
202
347
|
}
|
|
203
|
-
if (status === 'MATCH')
|
|
204
|
-
return IdentityKeyChange.UNCHANGED;
|
|
205
|
-
if (status === 'ROLLBACK')
|
|
206
|
-
return IdentityKeyChange.ROLLBACK;
|
|
207
|
-
return IdentityKeyChange.CHANGED;
|
|
208
348
|
}
|
|
209
349
|
async getContactIdentity(address, identityType) {
|
|
210
350
|
this.ensureInitialized();
|
|
@@ -237,16 +377,24 @@ export class IndexedDbSignalProtocolStore {
|
|
|
237
377
|
await tx.done;
|
|
238
378
|
throw new Error('Contact identity changed concurrently during rotation');
|
|
239
379
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
const sessions = tx.objectStore('sessions')
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
380
|
+
// Read the doomed session keys before mutating, then enter every
|
|
381
|
+
// mutation in one synchronous batch. A dying page closes its connection
|
|
382
|
+
// gracefully, and a transaction that is idle at an await boundary then
|
|
383
|
+
// commits the writes it already holds — a cursor walk that deletes as
|
|
384
|
+
// it goes leaves windows where the new pin commits with sessions still
|
|
385
|
+
// trusted under the old identity.
|
|
386
|
+
const sessions = tx.objectStore('sessions');
|
|
387
|
+
const doomedKeys = await sessions.index('by-user').getAllKeys(address.userId);
|
|
388
|
+
await Promise.all([
|
|
389
|
+
contacts.put({
|
|
390
|
+
key,
|
|
391
|
+
userId: address.userId,
|
|
392
|
+
data: encrypted,
|
|
393
|
+
revision: replacement.revision,
|
|
394
|
+
}),
|
|
395
|
+
...doomedKeys.map((sessionKey) => sessions.delete(sessionKey)),
|
|
396
|
+
tx.done,
|
|
397
|
+
]);
|
|
250
398
|
return replacement;
|
|
251
399
|
}
|
|
252
400
|
async verifyContactIdentity(address, identity, identityType, suppliedCommitment) {
|
|
@@ -535,26 +683,31 @@ export class IndexedDbSignalProtocolStore {
|
|
|
535
683
|
await tx.done;
|
|
536
684
|
throw new Error('Atomic session/trust commit cannot consume a missing KEM one-time prekey');
|
|
537
685
|
}
|
|
686
|
+
// Every mutation must enter the transaction in one synchronous batch.
|
|
687
|
+
// A dying page closes its connection gracefully, and a transaction that
|
|
688
|
+
// is idle at an await boundary then commits the writes it already holds
|
|
689
|
+
// — an await between mutations is a window for a partial commit.
|
|
690
|
+
const writes = [];
|
|
538
691
|
if (newContact && encryptedContact) {
|
|
539
|
-
|
|
692
|
+
writes.push(contacts.put({
|
|
540
693
|
key: contactKey,
|
|
541
694
|
userId: commit.address.userId,
|
|
542
695
|
data: encryptedContact,
|
|
543
696
|
revision: newContact.revision,
|
|
544
|
-
});
|
|
697
|
+
}));
|
|
545
698
|
}
|
|
546
|
-
|
|
699
|
+
writes.push(tx.objectStore('sessions').put({
|
|
547
700
|
key: addressKey,
|
|
548
701
|
userId: commit.address.userId,
|
|
549
702
|
deviceId: commit.address.deviceId,
|
|
550
703
|
data: encrypted,
|
|
551
704
|
updatedAt: Date.now(),
|
|
552
|
-
});
|
|
705
|
+
}));
|
|
553
706
|
if (ecPreKeyStorageKey)
|
|
554
|
-
|
|
707
|
+
writes.push(prekeys.delete(ecPreKeyStorageKey));
|
|
555
708
|
if (kemPreKeyStorageKey)
|
|
556
|
-
|
|
557
|
-
await tx.done;
|
|
709
|
+
writes.push(prekeys.delete(kemPreKeyStorageKey));
|
|
710
|
+
await Promise.all([...writes, tx.done]);
|
|
558
711
|
}
|
|
559
712
|
async deleteSessionRecord(address) {
|
|
560
713
|
this.ensureInitialized();
|
|
@@ -583,18 +736,42 @@ export class IndexedDbSignalProtocolStore {
|
|
|
583
736
|
}
|
|
584
737
|
async getSessionsForUser(userId) {
|
|
585
738
|
this.ensureInitialized();
|
|
586
|
-
|
|
587
|
-
|
|
739
|
+
// Collect encrypted rows first - decrypting inside the iteration would
|
|
740
|
+
// deactivate the transaction and the next cursor advance throws
|
|
741
|
+
// TransactionInactiveError on spec-conformant engines (Firefox, WebKit)
|
|
742
|
+
const rows = [];
|
|
743
|
+
const tx = this.db.transaction('sessions', 'readonly');
|
|
588
744
|
const index = tx.objectStore('sessions').index('by-user');
|
|
589
745
|
for await (const cursor of index.iterate(userId)) {
|
|
590
|
-
|
|
746
|
+
rows.push({ key: cursor.primaryKey, data: cursor.value.data });
|
|
747
|
+
}
|
|
748
|
+
await tx.done;
|
|
749
|
+
const records = [];
|
|
750
|
+
const corruptRows = [];
|
|
751
|
+
for (const row of rows) {
|
|
752
|
+
const decrypted = await this.decrypt(row.data);
|
|
591
753
|
try {
|
|
592
754
|
records.push(deserializeSessionRecord(decrypted));
|
|
593
755
|
}
|
|
594
756
|
catch {
|
|
595
|
-
|
|
757
|
+
corruptRows.push(row);
|
|
596
758
|
}
|
|
597
759
|
}
|
|
760
|
+
if (corruptRows.length > 0) {
|
|
761
|
+
// Re-read and compare inside one readwrite transaction: a concurrent
|
|
762
|
+
// writer may have replaced the corrupt bytes with a valid record since
|
|
763
|
+
// the snapshot above, and an unconditional delete would destroy it.
|
|
764
|
+
// Every await here is an IDB request, so the transaction stays active.
|
|
765
|
+
const cleanupTx = this.db.transaction('sessions', 'readwrite');
|
|
766
|
+
const store = cleanupTx.objectStore('sessions');
|
|
767
|
+
for (const row of corruptRows) {
|
|
768
|
+
const current = await store.get(row.key);
|
|
769
|
+
if (current && encryptedBytesEqual(current.data, row.data)) {
|
|
770
|
+
await store.delete(row.key);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
await cleanupTx.done;
|
|
774
|
+
}
|
|
598
775
|
return records;
|
|
599
776
|
}
|
|
600
777
|
async hasSession(address) {
|
|
@@ -672,15 +849,6 @@ export class IndexedDbSignalProtocolStore {
|
|
|
672
849
|
validateContactIdentityRecord(record);
|
|
673
850
|
return record;
|
|
674
851
|
}
|
|
675
|
-
async putContactRecord(key, userId, record) {
|
|
676
|
-
validateContactIdentityRecord(record);
|
|
677
|
-
await this.db.put('contacts', {
|
|
678
|
-
key,
|
|
679
|
-
userId,
|
|
680
|
-
data: await this.encrypt(JSON.stringify(record)),
|
|
681
|
-
revision: record.revision,
|
|
682
|
-
});
|
|
683
|
-
}
|
|
684
852
|
/**
|
|
685
853
|
* Encrypt data using AES-256-GCM with Web Crypto API
|
|
686
854
|
*
|
|
@@ -968,11 +1136,19 @@ export class IndexedDbSignalProtocolStore {
|
|
|
968
1136
|
}
|
|
969
1137
|
async getAllSenderKeysForGroup(groupId) {
|
|
970
1138
|
this.ensureInitialized();
|
|
971
|
-
|
|
1139
|
+
// Collect encrypted rows first - decrypting inside the iteration would
|
|
1140
|
+
// deactivate the transaction and the next cursor advance throws
|
|
1141
|
+
// TransactionInactiveError on spec-conformant engines (Firefox, WebKit)
|
|
1142
|
+
const encryptedRows = [];
|
|
972
1143
|
const tx = this.db.transaction('senderKeyRecords', 'readonly');
|
|
973
1144
|
const index = tx.objectStore('senderKeyRecords').index('by-group');
|
|
974
1145
|
for await (const cursor of index.iterate(groupId)) {
|
|
975
|
-
|
|
1146
|
+
encryptedRows.push(cursor.value.data);
|
|
1147
|
+
}
|
|
1148
|
+
await tx.done;
|
|
1149
|
+
const states = [];
|
|
1150
|
+
for (const data of encryptedRows) {
|
|
1151
|
+
const decrypted = await this.decrypt(data);
|
|
976
1152
|
const record = JSON.parse(decrypted);
|
|
977
1153
|
if (record[0]) {
|
|
978
1154
|
states.push(record[0]);
|