* initial commit
* new interation test
* more comments
* fix test, quick refactor on request version
* cleaning and logs
* fix type
* cleaning
* remove delegate stuff
* remove events and use timer mocks
* fix import
* ts ignore in tests
* Quick cleaning
* code review
* Use Errors instead of Results
* cleaning
* review
* remove forceCheck as not useful
* bad naming
* inline pauseLoop
* mark as paused in finally
* code review
* post merge fix
* rename KeyDownloadRateLimit
* use same config in loop and pass along
* Rust-crypto: fix `bootstrapCrossSigning` on second call
Currently, `bootstrapCrossSigning` raises an exception if it is called a second
time before secret storage is set up. It is easily fixed by checking that 4S is
set up before trying to export to 4S.
Also a few logging fixes while we're in the area.
* Factor out an `AccountDataAccumulator`
* Another test for bootstrapCrossSigning
MatrixClient API was exposing two methods that only worked for legacy crypto:
- getDeviceEd25519Key
- getDeviceCurve25519Key
=> These are used in the react-sdk for some functionality (rageshake, sentry, rendez-vous).
I have deprecated those calls from MatrixClient and created a new API in CryptoApi (where it belongs):
getOwnDeviceKeys(): Promise<OwnDeviceKeys>
* fix members loaded on intitial sync
* Update test to use KeyResponder
* Use E2EKeyResponder
* code review
* better comment
* fix test
* post merge fix
* fix imports
* refactoring, better names
* code review
* clean tests
* Cleanups per review comments
* fix test
* Apply suggestions from code review
---------
Co-authored-by: Richard van der Hoff <richard@matrix.org>
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Element-R: reduce log spam when checking server key backup
Fixes a lot of spam in the logs about "uncaught in promise: No room_keys
found".
* Improve integ tests for backup query after UTD
* Yield in the backup decryption loop
* Fix another broken test
* Wire up history visibility in `RoomEncryptor.ts`
* Add more tests to history visibility conversion
* Factorize `expectSendMessage` and `expectSendMegolmMessage`
* Use correct import
* Fix overwriteRoutes
* Update comments
* Element-R: silence log errors when viewing a pending event
Fixes the second half of vector-im/element-web#26272
* Update spec/integ/crypto/crypto.spec.ts
* Handle backup secret gossip
* use getSecretsFromInbox
* add gossip test
* use delete secret API
* fix logger
* better comment and cleaning
* free the pkSigning
* fix typo
* add missing mocks
* improve coverage
* better var name
* quick refactoring
* add more tests
* Review, format and comments
* refactor move more logic to backup.ts
* poll secret inbox
* missing mock
* Update src/rust-crypto/rust-crypto.ts
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Update src/rust-crypto/rust-crypto.ts
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Update src/rust-crypto/rust-crypto.ts
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Update src/rust-crypto/backup.ts
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Update src/rust-crypto/rust-crypto.ts
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* code review
* fix comment
* remove comment
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* quick factorise
---------
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* very messy poc
* iterate
* more types and use tokenRefreshFunction
* working refresh without persistence
* tidy
* add claims to completeauhtorizationcodegrant response
* export tokenrefresher from matrix
* add idtokenclaims
* add claims to completeauhtorizationcodegrant response
* only one token refresh attempt at a time
* tests
* comments
* add tokenRefresher class
* export generateScope
* export oidc from matrix
* test refreshtoken
* mark experimental
* add getRefreshToken to client
* Apply suggestions from code review
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* remove some vars in test
* make TokenRefresher un-abstract, comments and improvements
* remove invalid jsdoc
* Update src/oidc/tokenRefresher.ts
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Code review improvements
* fix verification integ tests
* remove unused type from props
* fix incomplete mock fn in fetch.spec
* document TokenRefreshFunction
* comments
* tidying
* update for injected logger
---------
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Element-R: Don't mark QR code verification as done too soon
The rust crypto sdk doesn't actually finish QR code verification until the
`m.key.verification.done` is received, so make sure we don't tell the
application it is done before that happens.
Fixes https://github.com/vector-im/element-web/issues/26293
* ignore fallback line
* Revert unnecessary changes
Can't get the coverage high enough on this and it's not needed.
* Avoid `VerificationRequest.generateQRCode` to crash when QRCode is unavailable
* Add tests `can try to generate a QR code when QR code is not supported`
* Element-R: use the pickleKey to encrypt the crypto store
`pickleKey` is a passphrase set by the application for this express purpose.
* update tests
* fix tests, again
* Refactor key backup recovery to prepare for rust
* rust backup restore support
* map decryption errors correctly from rust
* query backup on fail to decrypt
* Refactor key backup recovery to prepare for rust
* rust backup restore support
* map decryption errors correctly from rust
* Move export out of old crypto to api with re-export
* extract base64 utility
* add tests for base64 util
* more efficient regex
* fix typo
* use different vector for bob
* missing import
* Group tests for decryption errors
* Do not map unneeded rust error for now
* Refactor key backup recovery to prepare for rust
* rust backup restore support
* Move export out of old crypto to api with re-export
* extract base64 utility
* add tests for base64 util
* more efficient regex
* fix typo
* WIP `CryptoApi.getStoredCrossSigningForUser`
* Fix QRCode
* Add docs and rename
* Add tests for `RustCrossSigningInfo.ts`
* Do `/keys/query` instead of using `UserIdentity`
* Review changes
* Get rid of `CrossSigningInfo`
* Merge `hasCrossSigningKeysForUser` into `userHasCrossSigningKeys`
* Apply suggestions from code review
* More review comments
---------
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
Co-authored-by: Richard van der Hoff <richard@matrix.org>
* Add `CryptoApi.requestVerificationDM`
* Fix RoomMessageRequest url
* Review changes
* Merge fixes
* Add BOB test data
* `requestVerificationDM` test works against old crypto (encrypted verification request)
* Update test data
* Implement `CryptoApi.checkKeyBackup`
* Deprecate `MatrixClient.enableKeyBackup`.
* fix integ test
* more tests
* Implement keybackup loop
* cleaning
* update matrix-sdk-crypto-wasm to 1.2.1
* fix lint
* avoid real timer stuff
* Simplify test
* post merge lint fix
* revert change on yarn.lock
* code review
* Generate test data for exported keys
* code review cleaning
* cleanup legacy backup loop
* Update spec/test-utils/test-data/generate-test-data.py
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Update spec/test-utils/test-data/generate-test-data.py
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* update yarn.lock for new wasm bindings
---------
Co-authored-by: Richard van der Hoff <richard@matrix.org>
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* stub backupmanager
* Implement `CryptoApi.getActiveSessionBackupVersion`
* Revert unnecessary change
we can do this later, once we have better test coverage
* more test coverage
---------
Co-authored-by: Richard van der Hoff <richard@matrix.org>
* Add `CryptoApi.setDeviceVerified`
I need a way to mark devices as trusted for the backup tests.
* More tests
* Simplify E2EKeyResponder.addDeviceKeys
The user and device IDs are in the test data, so no need to pass them in
* Clean up key backup integration test
Make it use the CryptoApi rather than legacy `MatrixClient.crypto`, and use a
pre-signed backup instead of requiring a "blindlySignAnything" method.
* run megolm-backup tests on both crypto stacks
* avoid internal backupManager
* replace deprecated TestClient with fetchMock
* add stop() api to BackupManager for clean shutdown
* fix merge
* code review cleaning
* lint
* Address review comments
* Remove unused `TestClient.expectKeyBackupQuery`
* clean up imports
---------
Co-authored-by: Richard van der Hoff <richard@matrix.org>
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>