You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-23 17:02:25 +03:00
Add crypto methods for export and import of secrets bundle (#4227)
* Add crypto methods for OIDC QR code login Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Improve test Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Revert test due to hang inside Rust. Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update test name Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update test name Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
committed by
GitHub
parent
c88487da07
commit
a3cea8ce7d
@@ -38,6 +38,7 @@ import {
|
||||
CrossSigningKey,
|
||||
CrossSigningKeyInfo,
|
||||
CrossSigningStatus,
|
||||
CryptoApi,
|
||||
CryptoCallbacks,
|
||||
Curve25519AuthData,
|
||||
DecryptionFailureCode,
|
||||
@@ -1165,6 +1166,26 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, RustCryptoEv
|
||||
this.checkKeyBackupAndEnable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of {@link CryptoApi#importSecretsBundle}.
|
||||
*/
|
||||
public async importSecretsBundle(
|
||||
secrets: Parameters<NonNullable<CryptoApi["importSecretsBundle"]>>[0],
|
||||
): Promise<void> {
|
||||
const secretsBundle = RustSdkCryptoJs.SecretsBundle.from_json(secrets);
|
||||
await this.getOlmMachineOrThrow().importSecretsBundle(secretsBundle); // this method frees the SecretsBundle
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of {@link CryptoApi#exportSecretsBundle}.
|
||||
*/
|
||||
public async exportsSecretsBundle(): ReturnType<NonNullable<CryptoApi["exportSecretsBundle"]>> {
|
||||
const secretsBundle = await this.getOlmMachineOrThrow().exportSecretsBundle();
|
||||
const secrets = secretsBundle.to_json();
|
||||
secretsBundle.free();
|
||||
return secrets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signs the given object with the current device and current identity (if available).
|
||||
* As defined in {@link https://spec.matrix.org/v1.8/appendices/#signing-json | Signing JSON}.
|
||||
|
||||
Reference in New Issue
Block a user