Commit fa4c555c authored by JC Brand's avatar JC Brand

Use async/await instead of explicit Promise

parent 77a73976
...@@ -159,28 +159,26 @@ converse.plugins.add('converse-omemo', { ...@@ -159,28 +159,26 @@ converse.plugins.add('converse-omemo', {
}).then(() => this.buildSessions(devices)) }).then(() => this.buildSessions(devices))
}, },
buildSession (device) { async buildSession (device) {
const { _converse } = this.__super__, const { _converse } = this.__super__,
address = new libsignal.SignalProtocolAddress(device.get('jid'), device.get('id')), address = new libsignal.SignalProtocolAddress(device.get('jid'), device.get('id')),
sessionBuilder = new libsignal.SessionBuilder(_converse.omemo_store, address), sessionBuilder = new libsignal.SessionBuilder(_converse.omemo_store, address),
prekey = device.getRandomPreKey(); prekey = device.getRandomPreKey(),
bundle = await device.getBundle();
return device.getBundle()
.then(bundle => { return sessionBuilder.processPreKey({
return sessionBuilder.processPreKey({ 'registrationId': parseInt(device.get('id'), 10),
'registrationId': parseInt(device.get('id'), 10), 'identityKey': u.base64ToArrayBuffer(bundle.identity_key),
'identityKey': u.base64ToArrayBuffer(bundle.identity_key), 'signedPreKey': {
'signedPreKey': { 'keyId': bundle.signed_prekey.id, // <Number>
'keyId': bundle.signed_prekey.id, // <Number> 'publicKey': u.base64ToArrayBuffer(bundle.signed_prekey.public_key),
'publicKey': u.base64ToArrayBuffer(bundle.signed_prekey.public_key), 'signature': u.base64ToArrayBuffer(bundle.signed_prekey.signature)
'signature': u.base64ToArrayBuffer(bundle.signed_prekey.signature) },
}, 'preKey': {
'preKey': { 'keyId': prekey.id, // <Number>
'keyId': prekey.id, // <Number> 'publicKey': u.base64ToArrayBuffer(prekey.key),
'publicKey': u.base64ToArrayBuffer(prekey.key), }
} });
});
});
}, },
getSession (device) { getSession (device) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment