@@ -534,7 +534,8 @@ impl OlmMachine {
534
534
} )
535
535
}
536
536
537
- /// Export all the secrets we have in the store into a [`SecretsBundle`].
537
+ /// Export all the secrets we have in the store into a {@link
538
+ /// SecretsBundle}.
538
539
///
539
540
/// This method will export all the private cross-signing keys and, if
540
541
/// available, the private part of a backup key and its accompanying
@@ -546,35 +547,29 @@ impl OlmMachine {
546
547
/// **Warning**: Only export this and share it with a trusted recipient,
547
548
/// i.e. if an existing device is sharing this with a new device.
548
549
#[ wasm_bindgen( js_name = "exportSecretsBundle" ) ]
549
- pub fn export_secrets_bundle ( & self ) -> Promise {
550
- let me = self . inner . clone ( ) ;
551
-
552
- future_to_promise ( async move {
553
- Ok ( me. store ( ) . export_secrets_bundle ( ) . await . map ( store:: SecretsBundle :: from) ?)
554
- } )
550
+ pub async fn export_secrets_bundle ( & self ) -> Result < store:: SecretsBundle , JsError > {
551
+ Ok ( self . inner . store ( ) . export_secrets_bundle ( ) . await ?. into ( ) )
555
552
}
556
553
557
- /// Import and persists secrets from a [` SecretsBundle`] .
554
+ /// Import and persists secrets from a {@link SecretsBundle} .
558
555
///
559
556
/// This method will import all the private cross-signing keys and, if
560
557
/// available, the private part of a backup key and its accompanying
561
558
/// version into the store.
562
559
///
563
560
/// **Warning**: Only import this from a trusted source, i.e. if an existing
564
561
/// device is sharing this with a new device. The imported cross-signing
565
- /// keys will create a [` OwnUserIdentity`] and mark it as verified.
562
+ /// keys will create a {@link OwnUserIdentity} and mark it as verified.
566
563
///
567
564
/// The backup key will be persisted in the store and can be enabled using
568
- /// the [`BackupMachine`].
565
+ /// the {@link BackupMachine}.
566
+ ///
567
+ /// The provided `SecretsBundle` is freed by this method; be careful not to
568
+ /// use it once this method has been called.
569
569
#[ wasm_bindgen( js_name = "importSecretsBundle" ) ]
570
- pub fn import_secrets_bundle ( & self , bundle : store:: SecretsBundle ) -> Promise {
571
- let me = self . inner . clone ( ) ;
572
-
573
- future_to_promise ( async move {
574
- me. store ( ) . import_secrets_bundle ( & bundle. inner ) . await ?;
575
-
576
- Ok ( JsValue :: null ( ) )
577
- } )
570
+ pub async fn import_secrets_bundle ( & self , bundle : store:: SecretsBundle ) -> Result < ( ) , JsError > {
571
+ self . inner . store ( ) . import_secrets_bundle ( & bundle. inner ) . await ?;
572
+ Ok ( ( ) )
578
573
}
579
574
580
575
/// Export all the private cross signing keys we have.
0 commit comments