feat(crypto) Implement OlmMachine.user_id, .device_id and .display_name.

This commit is contained in:
Ivan Enderlin
2022-05-12 16:19:03 +02:00
parent fdb9fe21c6
commit fd4dff79d4
2 changed files with 26 additions and 1 deletions

View File

@@ -33,6 +33,28 @@ impl OlmMachine {
})
}
/// The unique user ID that owns this `OlmMachine` instance.
pub fn user_id(&self) -> identifiers::UserId {
identifiers::UserId { inner: self.inner.user_id().to_owned() }
}
/// The unique device ID that identifies this `OlmMachine`.
pub fn device_id(&self) -> identifiers::DeviceId {
identifiers::DeviceId { inner: self.inner.device_id().to_owned() }
}
///// Get the public parts of our Olm identity keys.
//pub fn identity_keys(&self) ->
/// Get the display name of our own device.
pub fn display_name(&self) -> Promise {
let me = self.inner.clone();
future_to_promise(async move {
Ok(JsValue::from(me.display_name().await.map_err(any_error_to_jsvalue)?))
})
}
pub fn receive_sync_changes(
&self,
to_device_events: &str,

View File

@@ -6,6 +6,9 @@ async function run_example() {
const olm_machine = await new OlmMachine(user_id, device_id);
console.log(olm_machine);
console.log('olm_machine.user_id().localpart() =', olm_machine.user_id().localpart());
console.log('olm_machine.device_id =', olm_machine.device_id());
console.log('olm_machine.display_name =', await olm_machine.display_name());
const to_device_events = '{}';
const changed_devices = new DeviceLists();
@@ -26,7 +29,7 @@ async function run_example() {
const outgoing_requests = await olm_machine.outgoing_requests();
console.log(outgoing_requests);
console.log(JSON.parse(outgoing_requests[0].body));
//console.log(JSON.parse(outgoing_requests[0].body));
}
run_example();