Commit graph

273 commits

Author SHA1 Message Date
Danila Fedorin 3cd0d1f423 Migrate DeviceIdentityStore to TypeScript 2021-08-27 09:30:10 -07:00
Danila Fedorin 8d44df83c4 Migrate UserIdentityStore to TypeScript 2021-08-27 09:30:10 -07:00
Danila Fedorin b46ae152d6 Migrate PendingEventStore.js to TypeScript 2021-08-27 09:30:10 -07:00
Danila Fedorin fad6d63c14 Migrate TimelineFragmentStore.js to TypeScript 2021-08-27 09:30:10 -07:00
Danila Fedorin 742ab28099 Migrate AccountDataStore.js to TypeScript. 2021-08-27 09:30:10 -07:00
Danila Fedorin 77f75fd968 Migrate OperationStore to TypeScript 2021-08-27 09:30:10 -07:00
Danila Fedorin 8c966627bc Migrate GroupSessionDecryptionStore to TypeScript 2021-08-27 09:30:10 -07:00
Danila Fedorin 33d94b9497 Migrate OutboundGroupSessionStore to TypeScript 2021-08-27 09:30:10 -07:00
Danila Fedorin 5d4454734a Migrate RoomStateStore.js to TypeScript 2021-08-27 09:30:10 -07:00
Danila Fedorin af70269169 Merge branch 'snowpack-ts-storage-1' into snowpack-ts-storage-2 2021-08-27 09:29:53 -07:00
Danila Fedorin 4c4687a05f Avoid unsafe (and error-prone) cast 2021-08-27 09:29:02 -07:00
Danila Fedorin a95704528f Merge branch 'snowpack-ts-storage-1' into snowpack-ts-storage-2 2021-08-26 17:01:23 -07:00
Danila Fedorin b7d232d56d Remove unnecessary cast and restrict constructor parameter type 2021-08-26 16:56:03 -07:00
Danila Fedorin 6d6821319e Merge branch 'snowpack-ts-storage-1' into snowpack-ts-storage-2 2021-08-24 11:19:36 -07:00
Danila Fedorin 1707df71df Try to reduce repitition in CursorIterator 2021-08-24 11:11:30 -07:00
Danila Fedorin e610087a79 Merge branch 'snowpack-ts-storage-1' into snowpack-ts-storage-2 2021-08-20 12:51:23 -07:00
Danila Fedorin a2ff02e6c0 Try using an enum for store names. 2021-08-20 12:33:06 -07:00
Danila Fedorin 69953e5277 Migrate TimelineRelationStore.js to TypeScript 2021-08-20 11:23:27 -07:00
Danila Fedorin e3b1d034f0 Migrate TimelineEventStore.js to TypeScript 2021-08-20 11:23:21 -07:00
Danila Fedorin 7de704ef86 Migrate InviteStore.js to TypeScript. 2021-08-20 11:23:14 -07:00
Danila Fedorin 7c56ac7746 Migrate RoomMemberStore.js to TypeScript 2021-08-20 11:23:08 -07:00
Danila Fedorin 38a38e8287 Migrate common.ts 2021-08-20 11:23:01 -07:00
Danila Fedorin e284224cc8 Migrate RoomSummaryStore.js to TypeScript. 2021-08-20 11:22:53 -07:00
Danila Fedorin 144e391c82 Migrate SessionStore.js to TypeScript. 2021-08-20 11:22:45 -07:00
Danila Fedorin 0b8acb51a4 Switch errors to using nulls 2021-08-20 10:41:15 -07:00
Danila Fedorin 50b7a8a3fd Add a comment explaining CursorIterator 2021-08-20 10:34:06 -07:00
Danila Fedorin 94ff76711c Use 'in' to be more idiomatic 2021-08-20 10:04:22 -07:00
Danila Fedorin 19bababa68 Use method syntax in QueryTarget. 2021-08-19 17:40:10 -07:00
Danila Fedorin 704a8d99c7 Add missing return types to QueryTarget 2021-08-19 17:39:53 -07:00
Danila Fedorin db66570d7a Migrate Store.js to TypeScript 2021-08-17 16:33:07 -07:00
Danila Fedorin c4e8ed8851 Migrate QueryTarget.js to TypeScript 2021-08-17 16:30:05 -07:00
Danila Fedorin 28ee87cd2f Migrate error.js to TypeScript 2021-08-17 16:30:05 -07:00
Danila Fedorin aa9839ee40 Seemingly fix a bug in utils.ts 2021-08-17 16:30:05 -07:00
Danila Fedorin cd9fe360a4 Start migrating utils.js to TypeScript 2021-08-17 16:30:05 -07:00
Danila Fedorin 5579c018d1 Migrate common.js to TypeScript
Add initial stab at annotating common

Add missing return types and semicolons
2021-08-17 16:30:05 -07:00
Bruno Windels eee1be1ceb safari doesn't like empty string key paths 🙄 2021-06-24 16:16:15 +02:00
Bruno Windels ce5409dc26 aggregate relations when seeing event target during back-pagination 2021-06-16 17:40:29 +02:00
Bruno Windels 41fb30c68b add relations store 2021-06-03 16:50:37 +02:00
Bruno Windels 46bfab3eb7 fix some lint and comment 2021-06-03 16:50:11 +02:00
Bruno Windels edbac25613 prepare storage to work with alternative idb impl 2021-06-02 12:31:13 +02:00
Bruno Windels 2bd7c23076 fix lint 2021-05-31 15:08:49 +02:00
Bruno Windels 23459aad52 check if you are allowed to redact a message 2021-05-31 13:52:03 +02:00
Bruno Windels 5d139dff43 Support deleting data in several stores for room id 2021-05-12 15:38:11 +02:00
Bruno Windels e233caf7ac change order of type and scope in operation index key to scan per scope 2021-05-12 15:36:48 +02:00
Bruno Windels 2087059c0b fix archived room summary key path now the summary is nested 2021-05-11 13:01:19 +02:00
Bruno Windels 6bb8e2fa43 allow loading an archived room 2021-05-07 13:10:10 +02:00
Bruno Windels 243d105aad support getting the room status for a room: invited, joined or archived 2021-05-07 13:08:39 +02:00
Bruno Windels 7e450071b1 clear all room state when rejoining room 2021-05-06 15:27:10 +02:00
Bruno Windels f16c08f13e remove room from all user identities when leaving
and delete identity as well as all device identities if no rooms left
2021-05-06 15:24:52 +02:00
Bruno Windels 00d8f81bdd clear all room state before rejoining room 2021-05-06 14:15:47 +02:00
Bruno Windels 12da71f731 unneeded ? 2021-05-06 14:15:47 +02:00
Bruno Windels bcfc4d1fd7 have better transaction errors 2021-05-06 14:15:47 +02:00
Bruno Windels 184480ad36 no need to capture req here 2021-05-06 14:15:47 +02:00
Bruno Windels d4d7adc7fc add archivedRoomSummary store 2021-05-06 14:15:47 +02:00
Bruno Windels ac312cbdc7 fix c/p error in invite store 2021-04-21 17:49:59 +02:00
Bruno Windels 39c772300a fix indenting 2021-04-20 16:21:35 +02:00
Bruno Windels 7c4a6fbe4b invite store 2021-04-20 13:13:56 +02:00
Bruno Windels d08c41c13a probably best to close this 2021-03-04 22:09:11 +01:00
Bruno Windels 932d26ed8c detect the webkit bug, and await a bogus request when opening a txn 2021-03-04 19:49:13 +01:00
Bruno Windels e0d14207ac make opening a txn async again
as we'll need to await a bogus request first thing after opening the txn

funny enough, we originally made it sync to accommodate the same bug
in safari, but that didn't prevent any microtask being awaited
before scheduling a request in the calling code closing the txn.

We'll await a bogus request within the transaction class now so it
doesn't depend on the calling code
2021-03-04 19:47:02 +01:00
Bruno Windels 4445b1ee01 store key share operations before tracking the room 2021-03-03 18:56:16 +01:00
Bruno Windels d39c3812b2
Merge pull request #231 from vector-im/bwindels/logs
Structured logging
2021-02-17 10:19:46 +00:00
Bruno Windels 91bd5f638c finish logging api 2021-02-12 13:04:05 +01:00
Bruno Windels e515548037 add some comments while debugging a problem 2021-02-11 21:08:06 +01:00
Bruno Windels 89599e9f87 WIP 2021-02-11 21:07:18 +01:00
Bruno Windels 46fd769dda (re)move old (compile-time) platform code 2020-10-26 10:34:35 +01:00
Bruno Windels a7a922680d request persisted storage when logging in/restoring a session 2020-10-20 17:02:34 +02:00
Bruno Windels 0d622164df close session db in other tabs when opening 2020-10-16 12:50:37 +02:00
Bruno Windels 9a4d47820d change this back as well 2020-10-01 14:46:30 +02:00
Bruno Windels cb7da2ba4a dont need this anymore 2020-10-01 14:45:09 +02:00
Bruno Windels d5a6a4d350 todo comment 2020-10-01 14:35:46 +02:00
Bruno Windels 3c7125bb88 add (optional) logging for idb requests 2020-10-01 14:35:33 +02:00
Bruno Windels ddb14f48bf we actually don't need to track write requests
as errors will bubble up to the txn
2020-10-01 14:31:08 +02:00
Bruno Windels d5a52c32d6 these don't return a promise anymore 2020-09-29 11:51:14 +02:00
Bruno Windels 37690cffe3 track storage write requests internally, as we never await their promise 2020-09-29 11:50:37 +02:00
Bruno Windels 482b5f4d22 allow passing message to IDBRequestError 2020-09-29 11:50:10 +02:00
Bruno Windels 43d430fc98 remove unused storage modification functions 2020-09-29 11:47:49 +02:00
Bruno Windels 7627a2bda2 add comment 2020-09-29 10:53:02 +02:00
Bruno Windels 919357b474 more broken imports after refactor 2020-09-29 09:57:48 +02:00
Bruno Windels c529df179b also import this 2020-09-29 09:56:46 +02:00
Bruno Windels c1ecaffbae fix refactor typo 2020-09-29 09:54:51 +02:00
Bruno Windels 07fcf7e75b also do this in try catch 2020-09-29 09:43:25 +02:00
Bruno Windels b1f9cfd972 cleanup storage errors a bit 2020-09-29 09:17:03 +02:00
Bruno Windels 76381fbca1 open storage transactions synchronously
this (almost) makes it work in some browsers that otherwise
have throw a TransactionInactiveError on the first operation
you try to do on a store.
2020-09-28 16:06:41 +02:00
Bruno Windels dd30f51ffe add copyright 2020-09-28 15:28:51 +02:00
Bruno Windels 8366b44d8c dont assume global is window 2020-09-28 14:52:12 +02:00
Bruno Windels 98a6d82820 detect when sync promise hack is needed 2020-09-28 14:51:41 +02:00
Bruno Windels 706ec97296 change method name 2020-09-28 13:25:44 +02:00
Bruno Windels 64290d5ae6 flush promises manually in idb event handler 2020-09-25 16:53:19 +02:00
Bruno Windels 1a105d391b cleanup: rename session name to hydrogen as well
as we'll need people to resync because of account data as well
2020-09-17 12:34:10 +02:00
Bruno Windels 7412b3aae8 forgot to commit account data store 2020-09-17 11:38:44 +02:00
Bruno Windels abfde76e24 store account data in storage
needs a resync, need to think how to handle this
2020-09-17 10:39:51 +02:00
Bruno Windels 3325f12092 remove devices not present in /keys/query response 2020-09-14 15:47:00 +02:00
Bruno Windels 504371eaf3 this is outdated (and not really needed) 2020-09-14 15:47:00 +02:00
Bruno Windels 2855166239 migrate encryption flag so old sessions dont send unencrypted events 2020-09-11 16:48:04 +02:00
Bruno Windels b00865510f add operation store 2020-09-11 14:40:05 +02:00
Bruno Windels 9f6822f362 remove needsRoomKey flag on member 2020-09-11 14:38:36 +02:00
Bruno Windels bba53b3477 dont store duplicated key values for replay detection 2020-09-11 12:08:06 +02:00
Bruno Windels 0b26e6f53a compress new e2ee stores into one new idb version 2020-09-11 08:40:43 +02:00
Bruno Windels a4c8e56ab0 fix getKey not working on IE11 2020-09-09 11:42:26 +01:00
Bruno Windels da4b710e49 don't return promise here, not used 2020-09-08 18:30:45 +02:00
Bruno Windels 31d4b6f75d send room keys to newly joined members in afterSyncCompleted stage 2020-09-08 14:38:27 +02:00
Bruno Windels d184be2d22 rotate outbound megolm session when somebody leaves the room 2020-09-08 11:09:09 +02:00
Bruno Windels c32ac2c764 use decryption result to show message verification status in timeline 2020-09-08 10:50:39 +02:00
Bruno Windels 7bfcfc9eed correct store name 2020-09-04 16:40:51 +02:00
Bruno Windels f31efe3e87 encode key with proper names 2020-09-04 16:40:39 +02:00
Bruno Windels 32a399afec implement storage changes for megolm decryption 2020-09-04 15:31:00 +02:00
Bruno Windels be4d887178 add outbound group session storage 2020-09-03 17:49:20 +02:00
Bruno Windels dde8c66196 implement store changes for olm encryption 2020-09-03 15:33:03 +02:00
Bruno Windels 6d3aa219fa implement storing room keys 2020-09-02 14:24:38 +02:00
Bruno Windels f5c7b1b3ec remove obsolete comment 2020-09-02 13:35:25 +02:00
Bruno Windels 6aad751611 fix wrong idb method used in session store 2020-09-02 13:35:08 +02:00
Bruno Windels 44e9f91d4c to_device handler for encrypted messages
changes the api of the olm decryption to decrypt in batch
so we can isolate side-effects until we have a write-txn open
and we can parallelize the decryption of different sender keys.
2020-09-02 13:33:27 +02:00
Bruno Windels 6788a612fc implement olm session storage 2020-09-01 17:59:59 +02:00
Bruno Windels 4077f57afb fix typos in stores 2020-08-31 16:09:13 +02:00
Bruno Windels 8b7fdb2c61 create user & device identity stores 2020-08-31 14:38:03 +02:00
Bruno Windels 8b358379e8 first draft of device tracker
mainly missing race protection with /sync and actually running the code
2020-08-31 14:12:12 +02:00
Bruno Windels f98b3dd5fa create/load olm account before first sync 2020-08-27 19:13:09 +02:00
Bruno Windels 09a018ade1 store sync token and filter id under the same key in session
as they are updated together
2020-08-27 14:36:50 +02:00
Bruno Windels 14b27f81fe store session values as individual values in store
so we don't have to write the whole object every time something changes
we'll use this to store the olm account
2020-08-27 14:28:40 +02:00
Bruno Windels fe7cc08287 add _selectWhile with proper "while" semantics
the existing _selectWhile method was more like _selectUntil,
which is what we want for _selectLimit but not for selectWhile(Reverse)

The changes we had made before also broke _selectLimit as it would
look at the results length before the value got added so you
always got 1 value more than requested, breaking sync.
2020-08-19 18:25:49 +02:00
Bruno Windels 79363ed1d7 use optional chaining 2020-08-19 18:25:38 +02:00
Bruno Windels d08297d1e0 move RoomMembers to own dir 2020-08-19 16:28:09 +02:00
Bruno Windels 9edd1bb0bb implement loading all members 2020-08-19 16:13:30 +02:00
Bruno Windels 5ad7b74b2b keep string key since we have to support IE11 2020-08-19 16:08:42 +02:00
Bruno Windels 9ff4f3839c Merge branch 'master' into bwindels/memberlist 2020-08-19 12:13:38 +02:00
Bruno Windels 2526198251 replace usage of readPath with ?. 2020-08-19 11:36:43 +02:00
Bruno Windels cc4c9d7893 Improve IDB error reporting
Hope this can help with
https://github.com/vector-im/hydrogen-web/issues/50
2020-08-18 17:27:40 +02:00
Bruno Windels 00a85697ab add license header in all source files 2020-08-05 18:38:55 +02:00
Bruno Windels f5d3092031 WIP 2020-06-26 23:26:24 +02:00
Bruno Windels bb7fca0592 support deleting the session from the container 2020-04-20 22:29:25 +02:00
Bruno Windels a097929dbd rename lowercase filenames of classes to camelcase like class 2020-04-20 21:41:10 +02:00
Bruno Windels 001dbefbcf stop using default exports
because it becomes hard to remember where you used them and where not
2020-04-20 21:26:39 +02:00
Bruno Windels 35c090dcb4 add proper import/export functionality 2019-12-14 18:29:35 +01:00
Bruno Windels 5ecf0a6717 fix error path on transaction abort error 2019-11-21 18:23:48 +01:00
Bruno Windels b16f21867c preserve value for storage errors on add and put 2019-10-12 22:19:16 +02:00
Bruno Windels 2fa5fa7890 add delete button in session picker 2019-10-12 21:16:48 +02:00
Bruno Windels 6f527fd2e0 use openCursor where openKeyCursor is not supported 2019-09-15 12:24:46 +02:00
Bruno Windels bbf6943455 use .get fallback where .getKey is not supported (Edge 15) 2019-09-15 12:24:27 +02:00
Bruno Windels 8e590fe53b rename and use StorageError to deal with idb DOMerror 2019-09-15 12:23:54 +02:00
Bruno Windels 3ed72df620 put everything together to make it roughly work
no local echo yet, and send errors are being swallowed
2019-07-27 10:51:51 +02:00
Bruno Windels 707988f806 better handle remote echos and hookup in session and room 2019-07-26 22:33:33 +02:00
Bruno Windels ccb722d766 more WIP 2019-07-26 22:03:57 +02:00
Bruno Windels f3d1128f28 WIP 2019-07-01 10:00:29 +02:00
Bruno Windels cd9f25ea80 convert tabs to spaces where needed 2019-06-26 22:31:36 +02:00
Bruno Windels b882e0ef8a respect argument count of idb calls
lumia doesn't like undefined arguments if they
are being left out, so call the idb calls with
the exact amount of arguments
2019-06-26 22:02:00 +02:00
Bruno Windels bbb5e35bcb wrap everything that can throw a idb DOMException in StorageError
as lumia gives very cryptic errors without a stacktrace.
2019-06-26 22:00:50 +02:00
Bruno Windels 0fd52be710 encode idb array keys as sortable strings
that's why numeric parts of the keys have to be encoded
as a fixed length, "big-endian" ordered strings, so
string sorting will also sort the numeric keys correctly.

this also assumes room ids don't contain the "|" character,
we should probably escape the separator at some point.
2019-06-26 21:55:33 +02:00
Bruno Windels 106146660c define storage keys to be 32bit for idb / web platform
as a preparation to serialize the eventIndex and fragmentId
as a 8 character string, part of a concatenated string PK,
as lumia doesn't support array keys.
2019-06-26 21:52:41 +02:00
Bruno Windels 3dbf5e727d process in incoming order (reverse-chronological order if backward)
makes code simpler, don't need fix to undo reverse ordering of
nonOverlappingEvents. reverse looking is very likely premature
optimization as well.
2019-06-03 00:18:52 +02:00