Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
79598558
Commit
79598558
authored
Aug 24, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move `publishBundle` to OMEMOStore
updates #497
parent
71e418fa
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
51 deletions
+48
-51
dist/converse.js
dist/converse.js
+25
-27
src/converse-omemo.js
src/converse-omemo.js
+23
-24
No files found.
dist/converse.js
View file @
79598558
...
...
@@ -74301,7 +74301,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}));
}).then(plaintext => {
// TODO remove newly used key before republishing
_converse.omemo.publishBundle();
_converse.omemo
_store
.publishBundle();
return _.extend(attrs, {
'plaintext': plaintext
...
...
@@ -74726,6 +74726,28 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
return Promise.resolve();
},
publishBundle() {
const signed_prekey = this.get('signed_prekey');
const stanza = $iq({
'from': _converse.bare_jid,
'type': 'set'
}).c('pubsub', {
'xmlns': Strophe.NS.PUBSUB
}).c('publish', {
'node': `${Strophe.NS.OMEMO_BUNDLES}:${this.get('device_id')}`
}).c('item').c('bundle', {
'xmlns': Strophe.NS.OMEMO
}).c('signedPreKeyPublic', {
'signedPreKeyId': signed_prekey.keyId
}).t(signed_prekey.keyPair.pubKey).up().c('signedPreKeySignature').t(signed_prekey.signature).up().c('identityKey').t(this.get('identity_keypair').pubKey).up().c('prekeys');
_.forEach(this.get('prekeys').slice(0, _converse.NUM_PREKEYS), prekey => stanza.c('preKeyPublic', {
'preKeyId': prekey.keyId
}).t(prekey.keyPair.pubKey).up());
return _converse.api.sendIQ(stanza);
},
generateBundle() {
/* The first thing that needs to happen if a client wants to
* start using OMEMO is they need to generate an IdentityKey
...
...
@@ -74950,31 +74972,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
_converse.DeviceLists = Backbone.Collection.extend({
model: _converse.DeviceList
});
_converse.omemo = {
publishBundle() {
const store = _converse.omemo_store,
signed_prekey = store.get('signed_prekey');
const stanza = $iq({
'from': _converse.bare_jid,
'type': 'set'
}).c('pubsub', {
'xmlns': Strophe.NS.PUBSUB
}).c('publish', {
'node': `${Strophe.NS.OMEMO_BUNDLES}:${store.get('device_id')}`
}).c('item').c('bundle', {
'xmlns': Strophe.NS.OMEMO
}).c('signedPreKeyPublic', {
'signedPreKeyId': signed_prekey.keyId
}).t(signed_prekey.keyPair.pubKey).up().c('signedPreKeySignature').t(signed_prekey.signature).up().c('identityKey').t(store.get('identity_keypair').pubKey).up().c('prekeys');
_.forEach(store.get('prekeys').slice(0, _converse.NUM_PREKEYS), prekey => stanza.c('preKeyPublic', {
'preKeyId': prekey.keyId
}).t(prekey.keyPair.pubKey).up());
return _converse.api.sendIQ(stanza);
}
};
_converse.omemo = {};
function fetchDeviceLists() {
return new Promise((resolve, reject) => _converse.devicelists.fetch({
...
...
@@ -75097,7 +75095,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
id = `converse.devicelists-${_converse.bare_jid}`;
_converse.devicelists.browserStorage = new Backbone.BrowserStorage[storage](id);
fetchOwnDevices().then(() => restoreOMEMOSession()).then(() => _converse.omemo.publishBundle()).then(() => _converse.emit('OMEMOInitialized')).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR));
fetchOwnDevices().then(() => restoreOMEMOSession()).then(() => _converse.omemo
_store
.publishBundle()).then(() => _converse.emit('OMEMOInitialized')).catch(_.partial(_converse.log, _, Strophe.LogLevel.ERROR));
}
_converse.api.listen.on('afterTearDown', () => {
src/converse-omemo.js
View file @
79598558
...
...
@@ -261,7 +261,7 @@
return
this
.
decryptMessage
(
_
.
extend
(
attrs
.
encrypted
,
{
'
key
'
:
aes_data
.
key
,
'
tag
'
:
aes_data
.
tag
}));
}).
then
(
plaintext
=>
{
// TODO remove newly used key before republishing
_converse
.
omemo
.
publishBundle
()
_converse
.
omemo
_store
.
publishBundle
()
return
_
.
extend
(
attrs
,
{
'
plaintext
'
:
plaintext
});
}).
catch
((
e
)
=>
{
this
.
reportDecryptionError
(
e
);
...
...
@@ -656,6 +656,27 @@
return
Promise
.
resolve
();
},
publishBundle
()
{
const
signed_prekey
=
this
.
get
(
'
signed_prekey
'
);
const
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
'
type
'
:
'
set
'
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
PUBSUB
})
.
c
(
'
publish
'
,
{
'
node
'
:
`
${
Strophe
.
NS
.
OMEMO_BUNDLES
}
:
${
this
.
get
(
'
device_id
'
)}
`
})
.
c
(
'
item
'
)
.
c
(
'
bundle
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
OMEMO
})
.
c
(
'
signedPreKeyPublic
'
,
{
'
signedPreKeyId
'
:
signed_prekey
.
keyId
})
.
t
(
signed_prekey
.
keyPair
.
pubKey
).
up
()
.
c
(
'
signedPreKeySignature
'
).
t
(
signed_prekey
.
signature
).
up
()
.
c
(
'
identityKey
'
).
t
(
this
.
get
(
'
identity_keypair
'
).
pubKey
).
up
()
.
c
(
'
prekeys
'
);
_
.
forEach
(
this
.
get
(
'
prekeys
'
).
slice
(
0
,
_converse
.
NUM_PREKEYS
),
(
prekey
)
=>
stanza
.
c
(
'
preKeyPublic
'
,
{
'
preKeyId
'
:
prekey
.
keyId
}).
t
(
prekey
.
keyPair
.
pubKey
).
up
()
);
return
_converse
.
api
.
sendIQ
(
stanza
);
},
generateBundle
()
{
/* The first thing that needs to happen if a client wants to
* start using OMEMO is they need to generate an IdentityKey
...
...
@@ -863,28 +884,6 @@
_converse
.
omemo
=
{
publishBundle
()
{
const
store
=
_converse
.
omemo_store
,
signed_prekey
=
store
.
get
(
'
signed_prekey
'
);
const
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
'
type
'
:
'
set
'
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
PUBSUB
})
.
c
(
'
publish
'
,
{
'
node
'
:
`
${
Strophe
.
NS
.
OMEMO_BUNDLES
}
:
${
store
.
get
(
'
device_id
'
)}
`
})
.
c
(
'
item
'
)
.
c
(
'
bundle
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
OMEMO
})
.
c
(
'
signedPreKeyPublic
'
,
{
'
signedPreKeyId
'
:
signed_prekey
.
keyId
})
.
t
(
signed_prekey
.
keyPair
.
pubKey
).
up
()
.
c
(
'
signedPreKeySignature
'
).
t
(
signed_prekey
.
signature
).
up
()
.
c
(
'
identityKey
'
).
t
(
store
.
get
(
'
identity_keypair
'
).
pubKey
).
up
()
.
c
(
'
prekeys
'
);
_
.
forEach
(
store
.
get
(
'
prekeys
'
).
slice
(
0
,
_converse
.
NUM_PREKEYS
),
(
prekey
)
=>
stanza
.
c
(
'
preKeyPublic
'
,
{
'
preKeyId
'
:
prekey
.
keyId
}).
t
(
prekey
.
keyPair
.
pubKey
).
up
()
);
return
_converse
.
api
.
sendIQ
(
stanza
);
}
}
function
fetchDeviceLists
()
{
...
...
@@ -983,7 +982,7 @@
fetchOwnDevices
()
.
then
(()
=>
restoreOMEMOSession
())
.
then
(()
=>
_converse
.
omemo
.
publishBundle
())
.
then
(()
=>
_converse
.
omemo
_store
.
publishBundle
())
.
then
(()
=>
_converse
.
emit
(
'
OMEMOInitialized
'
))
.
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
ERROR
));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment