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
85dab736
Commit
85dab736
authored
Dec 19, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `pubsub#access_model` to publish keys and devices publically
parent
0b258003
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
114 additions
and
46 deletions
+114
-46
dist/converse.js
dist/converse.js
+15
-21
spec/omemo.js
spec/omemo.js
+83
-1
src/converse-omemo.js
src/converse-omemo.js
+16
-24
No files found.
dist/converse.js
View file @
85dab736
...
...
@@ -55970,6 +55970,7 @@ const _converse$env = _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_
Strophe = _converse$env.Strophe,
moment = _converse$env.moment,
sizzle = _converse$env.sizzle,
$build = _converse$env.$build,
$iq = _converse$env.$iq,
$msg = _converse$env.$msg,
_ = _converse$env._,
...
...
@@ -56758,24 +56759,21 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
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', {
const node = `${Strophe.NS.OMEMO_BUNDLES}:${this.get('device_id')}`;
const item = $build('item').c('bundle', {
'xmlns': Strophe.NS.OMEMO
}).c('signedPreKeyPublic', {
'signedPreKeyId': signed_prekey.id
}).t(signed_prekey.pubKey).up().c('signedPreKeySignature').t(signed_prekey.signature).up().c('identityKey').t(this.get('identity_keypair').pubKey).up().c('prekeys');
_.forEach(this.get('prekeys'), (prekey, id) =>
stanza
.c('preKeyPublic', {
_.forEach(this.get('prekeys'), (prekey, id) =>
item
.c('preKeyPublic', {
'preKeyId': id
}).t(prekey.pubKey).up());
return _converse.api.sendIQ(stanza);
const options = {
'pubsub#access_model': 'open'
};
return _converse.api.pubsub.publish(null, node, item, options);
},
generateMissingPreKeys() {
...
...
@@ -57013,20 +57011,16 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
},
publishDevices() {
const stanza = $iq({
'from': _converse.bare_jid,
'type': 'set'
}).c('pubsub', {
'xmlns': Strophe.NS.PUBSUB
}).c('publish', {
'node': Strophe.NS.OMEMO_DEVICELIST
}).c('item').c('list', {
const item = $build('item').c('list', {
'xmlns': Strophe.NS.OMEMO
});
this.devices.each(d
evice => stanza
.c('device', {
'id': d
evice
.get('id')
this.devices.each(d
=> item
.c('device', {
'id': d.get('id')
}).up());
return _converse.api.sendIQ(stanza);
const options = {
'pubsub#access_model': 'open'
};
return _converse.api.pubsub.publish(null, Strophe.NS.OMEMO_DEVICELIST, item, options, false);
},
removeOwnDevices(device_ids) {
spec/omemo.js
View file @
85dab736
...
...
@@ -34,6 +34,11 @@
}
async
function
initializedOMEMO
(
_converse
)
{
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
bare_jid
,
[{
'
category
'
:
'
pubsub
'
,
'
type
'
:
'
pep
'
}],
[
'
http://jabber.org/protocol/pubsub#publish-options
'
]
);
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
_converse
.
bare_jid
));
let
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
...
...
@@ -427,6 +432,7 @@
_converse
.
connection
.
IQ_stanzas
=
[];
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
test_utils
.
waitUntil
(()
=>
_converse
.
omemo_store
);
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
bundleHasBeenPublished
(
_converse
));
expect
(
iq_stanza
.
toLocaleString
()).
toBe
(
`<iq from="dummy@localhost" id="
${
iq_stanza
.
nodeTree
.
getAttribute
(
"
id
"
)}
" type="set" xmlns="jabber:client">`
+
...
...
@@ -447,6 +453,16 @@
`</bundle>`
+
`</item>`
+
`</publish>`
+
`<publish-options>`
+
`<x type="submit" xmlns="jabber:x:data">`
+
`<field type="hidden" var="FORM_TYPE">`
+
`<value>http://jabber.org/protocol/pubsub#publish-options</value>`
+
`</field>`
+
`<field var="pubsub#access_model">`
+
`<value>open</value>`
+
`</field>`
+
`</x>`
+
`</publish-options>`
+
`</pubsub>`
+
`</iq>`
)
const
own_device
=
_converse
.
devicelists
.
get
(
_converse
.
bare_jid
).
devices
.
get
(
_converse
.
omemo_store
.
get
(
'
device_id
'
));
...
...
@@ -461,6 +477,12 @@
null
,
[
'
rosterGroupsFetched
'
],
{
'
allow_non_roster_messaging
'
:
true
},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
bare_jid
,
[{
'
category
'
:
'
pubsub
'
,
'
type
'
:
'
pep
'
}],
[
'
http://jabber.org/protocol/pubsub#publish-options
'
]
);
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
...
...
@@ -592,6 +614,16 @@
`</list>`
+
`</item>`
+
`</publish>`
+
`<publish-options>`
+
`<x type="submit" xmlns="jabber:x:data">`
+
`<field type="hidden" var="FORM_TYPE">`
+
`<value>http://jabber.org/protocol/pubsub#publish-options</value>`
+
`</field>`
+
`<field var="pubsub#access_model">`
+
`<value>open</value>`
+
`</field>`
+
`</x>`
+
`</publish-options>`
+
`</pubsub>`
+
`</iq>`
);
expect
(
_converse
.
devicelists
.
length
).
toBe
(
2
);
...
...
@@ -609,6 +641,12 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
bare_jid
,
[{
'
category
'
:
'
pubsub
'
,
'
type
'
:
'
pep
'
}],
[
'
http://jabber.org/protocol/pubsub#publish-options
'
]
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
const
contact_jid
=
mock
.
cur_names
[
3
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
let
iq_stanza
=
await
test_utils
.
waitUntil
(()
=>
deviceListFetched
(
_converse
,
_converse
.
bare_jid
));
...
...
@@ -753,6 +791,12 @@
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
bare_jid
,
[{
'
category
'
:
'
pubsub
'
,
'
type
'
:
'
pep
'
}],
[
'
http://jabber.org/protocol/pubsub#publish-options
'
]
);
_converse
.
NUM_PREKEYS
=
2
;
// Restrict to 2, otherwise the resulting stanza is too large to easily test
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
...
...
@@ -797,6 +841,16 @@
`</bundle>`
+
`</item>`
+
`</publish>`
+
`<publish-options>`
+
`<x type="submit" xmlns="jabber:x:data">`
+
`<field type="hidden" var="FORM_TYPE">`
+
`<value>http://jabber.org/protocol/pubsub#publish-options</value>`
+
`</field>`
+
`<field var="pubsub#access_model">`
+
`<value>open</value>`
+
`</field>`
+
`</x>`
+
`</publish-options>`
+
`</pubsub>`
+
`</iq>`
)
...
...
@@ -816,6 +870,12 @@
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
bare_jid
,
[{
'
category
'
:
'
pubsub
'
,
'
type
'
:
'
pep
'
}],
[
'
http://jabber.org/protocol/pubsub#publish-options
'
]
);
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
...
...
@@ -858,6 +918,16 @@
`</list>`
+
`</item>`
+
`</publish>`
+
`<publish-options>`
+
`<x type="submit" xmlns="jabber:x:data">`
+
`<field type="hidden" var="FORM_TYPE">`
+
`<value>http://jabber.org/protocol/pubsub#publish-options</value>`
+
`</field>`
+
`<field var="pubsub#access_model">`
+
`<value>open</value>`
+
`</field>`
+
`</x>`
+
`</publish-options>`
+
`</pubsub>`
+
`</iq>`
);
...
...
@@ -965,6 +1035,12 @@
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{
'
view_mode
'
:
'
fullscreen
'
},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
bare_jid
,
[{
'
category
'
:
'
pubsub
'
,
'
type
'
:
'
pep
'
}],
[
'
http://jabber.org/protocol/pubsub#publish-options
'
]
);
// MEMO encryption works only in members-only conferences that are non-anonymous.
const
features
=
[
'
http://jabber.org/protocol/muc
'
,
...
...
@@ -1147,6 +1223,12 @@
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
_converse
.
bare_jid
,
[{
'
category
'
:
'
pubsub
'
,
'
type
'
:
'
pep
'
}],
[
'
http://jabber.org/protocol/pubsub#publish-options
'
]
);
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
...
...
src/converse-omemo.js
View file @
85dab736
...
...
@@ -9,7 +9,7 @@
import
converse
from
"
@converse/headless/converse-core
"
;
import
tpl_toolbar_omemo
from
"
templates/toolbar_omemo.html
"
;
const
{
Backbone
,
Promise
,
Strophe
,
moment
,
sizzle
,
$iq
,
$msg
,
_
,
f
,
b64_sha1
}
=
converse
.
env
;
const
{
Backbone
,
Promise
,
Strophe
,
moment
,
sizzle
,
$
build
,
$
iq
,
$msg
,
_
,
f
,
b64_sha1
}
=
converse
.
env
;
const
u
=
converse
.
env
.
utils
;
Strophe
.
addNamespace
(
'
OMEMO_DEVICELIST
'
,
Strophe
.
NS
.
OMEMO
+
"
.devicelist
"
);
...
...
@@ -750,12 +750,8 @@ converse.plugins.add('converse-omemo', {
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
'
)
const
node
=
`
${
Strophe
.
NS
.
OMEMO_BUNDLES
}
:
${
this
.
get
(
'
device_id
'
)}
`
;
const
item
=
$build
(
'
item
'
)
.
c
(
'
bundle
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
OMEMO
})
.
c
(
'
signedPreKeyPublic
'
,
{
'
signedPreKeyId
'
:
signed_prekey
.
id
})
.
t
(
signed_prekey
.
pubKey
).
up
()
...
...
@@ -764,9 +760,10 @@ converse.plugins.add('converse-omemo', {
.
c
(
'
prekeys
'
);
_
.
forEach
(
this
.
get
(
'
prekeys
'
),
(
prekey
,
id
)
=>
stanza
.
c
(
'
preKeyPublic
'
,
{
'
preKeyId
'
:
id
}).
t
(
prekey
.
pubKey
).
up
()
(
prekey
,
id
)
=>
item
.
c
(
'
preKeyPublic
'
,
{
'
preKeyId
'
:
id
}).
t
(
prekey
.
pubKey
).
up
()
);
return
_converse
.
api
.
sendIQ
(
stanza
);
const
options
=
{
'
pubsub#access_model
'
:
'
open
'
};
return
_converse
.
api
.
pubsub
.
publish
(
null
,
node
,
item
,
options
);
},
generateMissingPreKeys
()
{
...
...
@@ -967,15 +964,10 @@ converse.plugins.add('converse-omemo', {
},
publishDevices
()
{
const
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
'
type
'
:
'
set
'
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
PUBSUB
})
.
c
(
'
publish
'
,
{
'
node
'
:
Strophe
.
NS
.
OMEMO_DEVICELIST
})
.
c
(
'
item
'
)
.
c
(
'
list
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
OMEMO
})
this
.
devices
.
each
(
device
=>
stanza
.
c
(
'
device
'
,
{
'
id
'
:
device
.
get
(
'
id
'
)}).
up
());
return
_converse
.
api
.
sendIQ
(
stanza
);
const
item
=
$build
(
'
item
'
).
c
(
'
list
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
OMEMO
})
this
.
devices
.
each
(
d
=>
item
.
c
(
'
device
'
,
{
'
id
'
:
d
.
get
(
'
id
'
)}).
up
());
const
options
=
{
'
pubsub#access_model
'
:
'
open
'
};
return
_converse
.
api
.
pubsub
.
publish
(
null
,
Strophe
.
NS
.
OMEMO_DEVICELIST
,
item
,
options
,
false
);
},
removeOwnDevices
(
device_ids
)
{
...
...
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