Exporting it the way we were was causing problems for webpack way down
the line, so we export it differently here to get around that. We also
have to fix all the import references so we import the right thing.
The bulk of this is just export/import changes, though there's a couple pieces to highlight:
* We no longer use default exports. This is because it's discouraged by the JS community, though not in any official capacity.
* We now use `polyfillSuper` for some prototype inheritance because the tests, and sometimes webpack, break on "cannot call EncryptionAlgorithm without 'new'". It's very much a workaround, and definitely not needed when we use real classes.
There is some import shuffling to help keep the imports clean - this was done by my IDE.
This changes `addKey` for secret storage to consume info about a pre-generated
key, rather than creating the key in middle of the method. This eases UI work
that want to have the public and private keys earlier on in the flow.
This adjusts the metadata from `createRecoveryKeyFromPassphrase` to include KDF
info formatted in the way secret storage expects. Since
`prepareKeyBackupVersion` did something similar, we adjust it to use the new
function and reshape the objects.
Riot doesn't fully implement to_device verifications, e.g.
it doesn't send a `request` but immediately sends a `start` event.
Because of this, `crypto.verification.request` doesn't get fired,
as that code path doesn't get triggered. This is why MatrixChat
in the react-sdk was listening for `crypto.verification.start`.
Verification over DM *does* send a `request` event first, so
to have the same API for both methods, we fake the request and
wrap the verifier in it.
We had a bunch of logic in place to suppress calls if the answer
or hangup had already arrived, but we only used it on startup.
This extends this logic to happen all the time, which means we'll
also do the same suppression if a call happenned while we were
offline.
We have a heap of logic to do the right thing when a call event
arrives, eg. wait until the client is ready so we can see if there's
already been a hangup event before saying there's an incoming call.
Unfortunately it only waited until the client was prepared, not
until it was syncing, so any events that arrived from the server
in the catchup sync bypassed this logic altogether.
This was probably broken back when we introduced the sync accumulator,
since before then, "PREPARED" meant, "done initialsync" rather than
"loaded fake initialsync from storage".
Fixes https://github.com/vector-im/riot-web/issues/3572
This adds a first chunk of bootstrapping Secure Secret Storage by creating
cross-signing keys and supporting interactive auth to upload them.
Part of https://github.com/vector-im/riot-web/issues/11212