We had two identical sets of base64 functions in the js-sdk, both
using Buffer which isn't really available in the browser unless you're
using an old webpack (ie. what element-web uses). This PR:
* Takes the crypto base64 file and moves it out of crypto (because
we use base64 for much more than just crypto)
* Makes them work in a browser without the Buffer global
* Removes the other base64 functions
* Changes everything to use the new common ones
* Adds a comment explaining why the function is kinda ugly and how
soul destroyingly awful the JS ecosystem is.
* Runs the tests with both impls
* Changes the test to not just test the decoder against the encoder
* Adds explicit support & tests for (decoding) base64Url (I'll add an
encode method later, no need for that to go in this PR too).
* Don't remove thread info from a thread root when it is redacted
* Move the redaction event to main at the same time we move redacted
Since the redacted event is moving to the main timeline, the redaction
belongs there too, since its relationship to the redacted event is the
only thing making it part of the thread.
* 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>
* Move redaction event tests into their own describe block
* Factor out utils in redaction tests
* Factor out the code for moving an event to the main timeline
* Move all related messages into main timeline on redaction
* Deprecate `MatrixEvent.toJSON`
Per https://github.com/vector-im/element-web/issues/26380, this method is too
easy to use accidentally, and per the comments, it doesn't even return a
meaningful JSON-serialisation of the object.
* Update src/models/event.ts
https://github.com/matrix-org/matrix-js-sdk/pull/3756 changed
the membership update function to await on the next call, but this
meant it never returned and therefore never cleared
`updateCallMembershipRunning`. We therefore didn't send the updated
call member event when leaving, instead sending it whenever the next
poll interval arrived.
This changes it to only await if we are retrying, not if we're just
scheduling the next poll.
Fixes https://github.com/vector-im/element-call/issues/1763
* Extract threadIdForReceipt function from sendReceipt
* Tests for threadIdForReceipt
* Correct test of threadIdForReceipt to expect main for redaction of threaded
* Expand and comment implementation of threadIdForReceipt
* 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>
* Don't use event.sender in CallMembership
I fell into another js-sdk trap: this is "only guaranteed to be set
for events that appear in a timeline" and not state events. It does
not say why. We only ever used it to get the sender user ID anyway,
so just use getSender().
* Fix test
* 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.
* Support MatrixClient-specific loggers.
Signed-off-by: Patrick Cloke <clokep@patrick.cloke.us>
* Use client-specific logger in client.ts.
Signed-off-by: Patrick Cloke <clokep@patrick.cloke.us>
* Log `fetch` requests to the per-client logger
* Use client-specific logger in rust-crypto
* add tokenRefresher class
* export generateScope
* export oidc from matrix
* mark experimental
* 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
* document TokenRefreshFunction
---------
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* rename loglevel import to loglevel
* Define new `Logger` interface to replace `PrefixedLogger`
* PrefixedLogger -> Logger in crypto store
* PrefixedLogger -> Logger in `src/crypto`
* PrefixedLogger -> Logger in rust-crypto
* make leaveRoomSession async.
This does not resolve the promise until the event is actually send.
No network connection would make awaiting on this blocking.
Signed-off-by: Timo K <toger5@hotmail.de>
* add timeout to leave
Signed-off-by: Timo K <toger5@hotmail.de>
* formatting
Signed-off-by: Timo K <toger5@hotmail.de>
---------
Signed-off-by: Timo K <toger5@hotmail.de>
* Avoid `VerificationRequest.generateQRCode` to crash when QRCode is unavailable
* Add tests `can try to generate a QR code when QR code is not supported`
* `RustBackupManager.getActiveBackupVersion`: check that backup is enabled
The previous check on `isBackupEnabled` was a no-op
* Fix log spam on shieldless events
* Reduce log spam about tracking users
* Reduce log spam about decrypting events
Logging the entire event is excessive