|
@@ -8,6 +8,12 @@ pub use contract::{
|
8
|
8
|
view_moderator_account,
|
9
|
9
|
};
|
10
|
10
|
|
|
11
|
+use near_client::{
|
|
12
|
+ core::{hash::CryptoHash, types::Nonce},
|
|
13
|
+ prelude::*,
|
|
14
|
+};
|
|
15
|
+
|
|
16
|
+use base64::prelude::*;
|
11
|
17
|
use common_api::api::{ApiResponse, Data, ExchangeMessage};
|
12
|
18
|
use crypto::{decrypt, encrypt, secret};
|
13
|
19
|
use error::ApiError;
|
|
@@ -17,8 +23,6 @@ use gloo_timers::future::TimeoutFuture;
|
17
|
23
|
use itertools::Itertools;
|
18
|
24
|
use js_sys::Promise;
|
19
|
25
|
use log::{info, warn};
|
20
|
|
-use near_client::prelude::*;
|
21
|
|
-use near_primitives_core::{account::id::AccountId, hash::CryptoHash, types::Nonce};
|
22
|
26
|
use serde::{Deserialize, Serialize};
|
23
|
27
|
use std::{collections::HashSet, str::FromStr, sync::Arc};
|
24
|
28
|
use url::Url;
|
|
@@ -142,6 +146,7 @@ impl KeyProvisioner {
|
142
|
146
|
///
|
143
|
147
|
/// - participants_set - The [`js_sys::Set`] represents hash set of participants' keys
|
144
|
148
|
/// - timeout_ms - The [`u32`] that represents milliseconds that were given not to be exceeded
|
|
149
|
+ #[wasm_bindgen(js_name = initMeeting)]
|
145
|
150
|
pub fn init_meeting(&self, participants_set: js_sys::Set, timeout_ms: u32) -> Promise {
|
146
|
151
|
let handler = self.handler();
|
147
|
152
|
let signer = self.signer();
|
|
@@ -184,6 +189,7 @@ impl KeyProvisioner {
|
184
|
189
|
///
|
185
|
190
|
/// - meeting_id - The [`String`] that indicates ID of the meeting room
|
186
|
191
|
/// - timeout_ms - The [`u32`] that represents milliseconds that were given not to be exceeded
|
|
192
|
+ #[wasm_bindgen(js_name = sendKeys)]
|
187
|
193
|
pub fn send_keys(&self, meeting_id: String, timeout_ms: u32) -> Promise {
|
188
|
194
|
let handler = self.handler();
|
189
|
195
|
let signer = self.signer();
|
|
@@ -239,7 +245,9 @@ impl KeyProvisioner {
|
239
|
245
|
exchange(&handler, &signer, meet_id, messages).await?;
|
240
|
246
|
}
|
241
|
247
|
|
242
|
|
- Ok(JsValue::from_str(&base64::encode(handler.secret)))
|
|
248
|
+ Ok(JsValue::from_str(
|
|
249
|
+ &BASE64_STANDARD_NO_PAD.encode(handler.secret),
|
|
250
|
+ ))
|
243
|
251
|
};
|
244
|
252
|
|
245
|
253
|
wasm_bindgen_futures::future_to_promise(async move {
|
|
@@ -258,6 +266,7 @@ impl KeyProvisioner {
|
258
|
266
|
///
|
259
|
267
|
/// - meeting_id - The [`String`] that indicates ID of the meeting room
|
260
|
268
|
/// - timeout_ms - The [`u32`] that represents milliseconds that were given not to be exceeded
|
|
269
|
+ #[wasm_bindgen(js_name = getKey)]
|
261
|
270
|
pub fn get_key(&self, meeting_id: String, timeout_ms: u32) -> Promise {
|
262
|
271
|
let handler = self.handler();
|
263
|
272
|
let signer = self.signer();
|
|
@@ -269,7 +278,7 @@ impl KeyProvisioner {
|
269
|
278
|
if let ApiResponse::Success(data) = receive(&handler, &signer, meet_id).await? {
|
270
|
279
|
let secret =
|
271
|
280
|
decrypt(signer.secret_key(), data.moderator_pk, meet_id, data.data)?;
|
272
|
|
- return Ok(JsValue::from_str(&base64::encode(secret)));
|
|
281
|
+ return Ok(JsValue::from_str(&BASE64_STANDARD_NO_PAD.encode(secret)));
|
273
|
282
|
}
|
274
|
283
|
}
|
275
|
284
|
};
|