Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 22 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 22 additions & 1 deletion crates/crypto-layer-node/src/keypairhandle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::error::unwrap_or_throw;
use crate::fromjs::vec_from_uint_8_array;
use crate::tojs::config::wrap_key_pair_spec;
use crate::tojs::uint_8_array_from_vec_u8;
use crate::JsKeyPairHandle;
use crate::{box_if_ok, JsKeyPairHandle};

/// Wraps `sign_data` function.
///
Expand Down Expand Up @@ -236,3 +236,24 @@ pub fn export_spec(mut cx: FunctionContext) -> JsResult<JsPromise> {
deferred.settle_with(&channel, move |mut cx| wrap_key_pair_spec(&mut cx, spec));
})
}

/// Wraps `start_dh_exchange` function.
///
/// # Arguments
///
/// # Returns
/// * `object` - bare dh exchange
///
/// # Throws
/// * When failing to start the dh exchange.
pub fn export_start_dh_exchange(mut cx: FunctionContext) -> JsResult<JsPromise> {
let handle_arc = (**cx.this::<JsKeyPairHandle>()?).clone();

spawn_promise(&mut cx, move |channel, deferred| {
let handle = arc_or_poisoned_error_deferred!(&channel, deferred, handle_arc.read());

let dh_exchange = handle.start_dh_exchange();

deferred.settle_with(&channel, |mut cx| box_if_ok(&mut cx, dh_exchange));
})
}
4 changes: 4 additions & 0 deletions crates/crypto-layer-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ fn main(mut cx: ModuleContext) -> NeonResult<()> {
crate::keypairhandle::export_decrypt_data,
)?;
cx.export_function("specForKeyPairHandle", crate::keypairhandle::export_spec)?;
cx.export_function(
"startDhExchangeForKeyPairHandle",
crate::keypairhandle::export_start_dh_exchange,
)?;

// key handle
cx.export_function("idForKeyHandle", crate::keyhandle::export_id)?;
Expand Down
Loading
Loading