diff --git a/keyserver/addons/rust-node-addon/rust-binding-types.js b/keyserver/addons/rust-node-addon/rust-binding-types.js --- a/keyserver/addons/rust-node-addon/rust-binding-types.js +++ b/keyserver/addons/rust-node-addon/rust-binding-types.js @@ -54,6 +54,13 @@ notifPrekey: string, notifPrekeySignature: string, ) => Promise, + +uploadOneTimeKeys: ( + userId: string, + deviceId: string, + accessToken: string, + contentOneTimePreKeys: $ReadOnlyArray, + notifOneTimePreKeys: $ReadOnlyArray, + ) => Promise, +getInboundKeysForUserDevice: ( identifierType: string, identifierValue: string, diff --git a/keyserver/addons/rust-node-addon/src/identity_client/mod.rs b/keyserver/addons/rust-node-addon/src/identity_client/mod.rs --- a/keyserver/addons/rust-node-addon/src/identity_client/mod.rs +++ b/keyserver/addons/rust-node-addon/src/identity_client/mod.rs @@ -3,6 +3,7 @@ pub mod prekey; pub mod register_user; pub mod remove_reserved_usernames; +pub mod upload_one_time_keys; use grpc_clients::identity::authenticated::AuthLayer; use grpc_clients::identity::protos::unauthenticated as client_proto; @@ -11,7 +12,7 @@ use client_proto::{ AddReservedUsernamesRequest, DeviceKeyUpload, IdentityKeyInfo, PreKey, RegistrationFinishRequest, RegistrationStartRequest, DeviceType, - RemoveReservedUsernameRequest, InboundKeyInfo + RemoveReservedUsernameRequest, InboundKeyInfo, UploadOneTimeKeysRequest }; use lazy_static::lazy_static; use napi::bindgen_prelude::*; diff --git a/keyserver/addons/rust-node-addon/src/identity_client/upload_one_time_keys.rs b/keyserver/addons/rust-node-addon/src/identity_client/upload_one_time_keys.rs new file mode 100644 --- /dev/null +++ b/keyserver/addons/rust-node-addon/src/identity_client/upload_one_time_keys.rs @@ -0,0 +1,29 @@ +use super::*; + +use tracing::debug; + +#[napi] +#[instrument(skip_all)] +pub async fn upload_one_time_keys( + user_id: String, + device_id: String, + access_token: String, + content_one_time_pre_keys: Vec, + notif_one_time_pre_keys: Vec, +) -> Result { + // Set up the gRPC client that will be used to talk to the Identity service + let mut identity_client = get_identity_client_service_channel().await?; + + let upload_request = UploadOneTimeKeysRequest { + user_id, + device_id, + access_token, + content_one_time_pre_keys, + notif_one_time_pre_keys, + }; + + debug!("Sending one time keys to Identity service"); + let result = identity_client.upload_one_time_keys(upload_request).await; + + Ok(true) +}