Commit Graph

14 Commits

Author SHA1 Message Date
Richard van der Hoff
0a01320fca
Element-R: pass pickleKey in as raw key for indexeddb encryption (#12543)
* Element-R: pass pickleKey in as raw key for indexeddb encryption

Currently, we pass the `pickleKey` to the rust library for use as a passphrase
for encrypting its crypto store. The Rust libary then passes that passphrase
through 200000 rounds of PBKDF2 to generate an encryption key, which is
(deliberately) slow.

However, the pickleKey is actually 32 bytes of random data (base64-encoded). By
passing the raw key into the rust library, we can therefore save the PBKDF
operation.

Backwards-compatibility with existing sessions is maintained, because if the
rust library discovers that the store was previously encrypted with a key based
on a PBKDF, it will re-base64 and PBKDF the key we provide, thus reconstructing
the right key.

* Update src/Lifecycle.ts

Co-authored-by: Florian Duros <florianduros@element.io>

* Lifecycle-test: clean up test setup

Rely less on the unit under test for setting up the test preconditions -- not
least because we don't really want to fire up matrix clients and the like
during test setup.

* Factor out "encryptPickleKey" method

For a start it makes it easier to grok what's going on, but also I went to use
this in a test

* Improve tests for `Lifecycle.restoreFromLocalStorage`

---------

Co-authored-by: Florian Duros <florianduros@element.io>
2024-06-05 08:52:28 +00:00
Thor Arne Johansen
6392759bec
Replace SecurityCustomisations with CryptoSetupExtension (#12342)
* Changed call sites from customisations/security to ModuleRunner.extensions

* Updated depenndecy and added tests

* Fixed style and formatting with prettier

* Fix according to Element PR comments

* Fixing issues raised in PR review

* Removed commented code. Improved encapsulation. Removed noisy logging

* Improved language of comment about calling the factory

* Refactor to get better encapsulation

* Find a better name. Provide explicit reset function. Provide more TSDoc

* Simplify mock for cryptoSetup, and add assertion for exception message.

* Remove unused className property. Adjust TSDoc comments

* Fix linting  and code style issues

* Added test to ensure we canregister anduse experimental extensions

* Fix linting and code-style issues

* Added test to ensure only on registration of experimental extensions

* Added test toensure call to getDehydratedDeviceCallback()

* Test what happens when there is no implementation

* Iterating cryptoSetup tests

* Lint/prettier fix

* Assert both branches when checking for dehydrationkey callback

* Update src/modules/ModuleRunner.ts

Language and formatting

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* Update src/modules/ModuleRunner.ts

Reset by setting a fresh ExtensionsManager

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* Update src/modules/ModuleRunner.ts

Use regular comment instead of TSDoc style comment

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* Update test/MatrixClientPeg-test.ts

No need to extend the base class

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* Update src/modules/ModuleRunner.ts

Fix spelling

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* Update src/modules/ModuleRunner.ts

Fix spelling

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* Update src/modules/ModuleRunner.ts

Fix TSDoc formatting

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* Simplify mock setup

* Simplified mock and cleaned up a bit

* Keeping track of extensions is an implementation detail internal to ExtensionsManager.  Language and punctuation

* Addressed issues and comments from PR review

* Update src/modules/ModuleRunner.ts

Keep the flags to track implementations as direct properties

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* Fix flattening of implementation map

* Update src/modules/ModuleRunner.ts

Fix whitespace

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

---------

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
2024-04-12 15:15:17 +00:00
Valere
cb7fd5118e
SettingsStore: Change feature_rust_crypto to default true (#12203)
* Set default crypto stack to rust

* Update test for default to rust crypto

* Fix labs settings tests

* Fix test not working with rust crypto
2024-02-02 12:20:13 +00:00
Valere
a5f9df5855
Support staged rollout of migration to Rust Crypto (#12184)
* Rust migration staged rollout

* Phased rollout unit tests
2024-01-31 15:52:23 +00:00
Richard van der Hoff
b6364a4cea
Enable the rust-crypto labs button (#12114)
* `LabsUserSettingsTab-test.tsx`: use a real `SdkConfig`

... instead of mocking it out. Doing so allows us more flexibility, and gives a
more realistic test.

* Enable the rust-crypto labs button

* fix up a test
2024-01-18 11:18:55 +00:00
Pankaj Singh
773b03e15e
Added meaning full error message based on platform (#12074)
* fix: fixed 'Database unexpectedly closed' is a bad error message (#25948)

* Added deviceType condition check for web and desktop

* Added Error description for web and desktop

* Changed 'error_database_closed_title' Title to '%(brand)s stopped working'

Signed-off-by: Pankaj Singh <pankajsingh132000@gmail.com>

* refactor(platform): replace UA parsing with Platform for platform detection

Signed-off-by: Pankaj Singh <pankajsingh132000@gmail.com>

* refactor(platform-test): added getHumanReadableName function in testcase

Signed-off-by: Pankaj Singh <pankajsingh132000@gmail.com>

* refactor(platform): added %brand argument for description

Signed-off-by: Pankaj Singh <pankajsingh132000@gmail.com>

* refactor by linter

Signed-off-by: Pankaj Singh <pankajsingh132000@gmail.com>

* refactor(linter): used prettier for linter

* Enable `A thread with a redacted unread is still read after restart` (#12083)

* [create-pull-request] automated change (#12085)

Co-authored-by: github-merge-queue <github-merge-queue@users.noreply.github.com>

* Allow element-web hash to be specified when calling playwright tests workflow (#12087)

* add link to issue for disabled test

* [create-pull-request] automated change (#12093)

Co-authored-by: github-merge-queue <github-merge-queue@users.noreply.github.com>

* Add tests about room list order (#12088)

---------

Signed-off-by: Pankaj Singh <pankajsingh132000@gmail.com>
Co-authored-by: Florian Duros <florianduros@element.io>
Co-authored-by: ElementRobot <releases@riot.im>
Co-authored-by: github-merge-queue <github-merge-queue@users.noreply.github.com>
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
Co-authored-by: Richard van der Hoff <richard@matrix.org>
2024-01-02 11:48:12 +00:00
Michael Telatynski
6b46d6e4f8
Add MatrixClientPeg::safeGet and use it in tests (#10985) 2023-06-05 18:12:23 +01:00
Michael Telatynski
404c412bcb
Handle IDB closed event by showing modal with prompt to reload app (#10395
* Handle IDB `closed` event by showing modal with prompt to reload app

* Iterate

* Skip the modal for guests, e.g. during registration

* Iterate

* Add tests
2023-03-31 10:08:45 +01:00
Richard van der Hoff
d821323e5c
Prevent rust-crypto setting from leaking to other tests (#10464)
Follow-up to #9759.

Because the MatrixClientPeg pushes the use_rust_crypto setting back into the SettingsStore, the setting was leaking out to other tests despite getValue's mock being restored.

The solution is to mock out setValue as well.
2023-03-27 18:03:17 +00:00
Michael Telatynski
ad8d27d2b2
Fix some features not being configurable via features (#10276) 2023-03-03 13:31:51 +00:00
Richard van der Hoff
6ec6d44c96
Add a config flag to enable the rust crypto-sdk (#9759)
This PR adds an option to `config.json` which will make the js-sdk use the rust crypto sdk, instead of the libolm implementation.

To use it, you need to add something like this to `config.json`:

```
    "features": {
        "feature_rust_crypto": true
    },
```

We don't (yet) have any way to migrate a device between implementations, so the setting that was in use when you log in is persisted to the device; it is *visible* via the labs section but cannot currently be changed.

This is part of https://github.com/vector-im/element-web/issues/21972, and enables the functionality added to the js-sdk in https://github.com/matrix-org/matrix-js-sdk/pull/2969.
2022-12-16 17:10:26 +00:00
Michael Weimann
3be20cf434
Use doMaybeLocalRoomAction (#9038)
* Use doMaybeLocalRoomAction

* Revert unnecessary changes
2022-07-13 07:56:36 +02:00
Kerry
68c5a55eed
use fake timers and restore mocks in MatrixClientPeg test (#8356)
Signed-off-by: Kerry Archibald <kerrya@element.io>
2022-04-19 14:44:15 +02:00
Hugh Nimmo-Smith
26b771bbf9
Don't show the prompt to enable desktop notifications immediately after registration (#8274)
* Fix MatrixClientPeg.userRegisteredWithinLastHours so that it works

* Try fixing end-to-end test + add case for New search beta

* Remove end-to-end test case for Search beta toast as it only shows up after 5 minutes

* Revert to localStorage based solution + non-inverted logic + test including time advancement
2022-04-13 19:05:08 +01:00