Use pubsub#access_model
to publish keys and devices publically
This commit is contained in:
parent
0b25800392
commit
85dab7367b
36
dist/converse.js
vendored
36
dist/converse.js
vendored
@ -55970,6 +55970,7 @@ const _converse$env = _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_
|
|||||||
Strophe = _converse$env.Strophe,
|
Strophe = _converse$env.Strophe,
|
||||||
moment = _converse$env.moment,
|
moment = _converse$env.moment,
|
||||||
sizzle = _converse$env.sizzle,
|
sizzle = _converse$env.sizzle,
|
||||||
|
$build = _converse$env.$build,
|
||||||
$iq = _converse$env.$iq,
|
$iq = _converse$env.$iq,
|
||||||
$msg = _converse$env.$msg,
|
$msg = _converse$env.$msg,
|
||||||
_ = _converse$env._,
|
_ = _converse$env._,
|
||||||
@ -56758,24 +56759,21 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
|
|||||||
|
|
||||||
publishBundle() {
|
publishBundle() {
|
||||||
const signed_prekey = this.get('signed_prekey');
|
const signed_prekey = this.get('signed_prekey');
|
||||||
const stanza = $iq({
|
const node = `${Strophe.NS.OMEMO_BUNDLES}:${this.get('device_id')}`;
|
||||||
'from': _converse.bare_jid,
|
const item = $build('item').c('bundle', {
|
||||||
'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
|
'xmlns': Strophe.NS.OMEMO
|
||||||
}).c('signedPreKeyPublic', {
|
}).c('signedPreKeyPublic', {
|
||||||
'signedPreKeyId': signed_prekey.id
|
'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');
|
}).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
|
'preKeyId': id
|
||||||
}).t(prekey.pubKey).up());
|
}).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() {
|
generateMissingPreKeys() {
|
||||||
@ -57013,20 +57011,16 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
|
|||||||
},
|
},
|
||||||
|
|
||||||
publishDevices() {
|
publishDevices() {
|
||||||
const stanza = $iq({
|
const item = $build('item').c('list', {
|
||||||
'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
|
'xmlns': Strophe.NS.OMEMO
|
||||||
});
|
});
|
||||||
this.devices.each(device => stanza.c('device', {
|
this.devices.each(d => item.c('device', {
|
||||||
'id': device.get('id')
|
'id': d.get('id')
|
||||||
}).up());
|
}).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) {
|
removeOwnDevices(device_ids) {
|
||||||
|
@ -34,6 +34,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function initializedOMEMO (_converse) {
|
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 iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, _converse.bare_jid));
|
||||||
let stanza = $iq({
|
let stanza = $iq({
|
||||||
'from': _converse.bare_jid,
|
'from': _converse.bare_jid,
|
||||||
@ -427,6 +432,7 @@
|
|||||||
_converse.connection.IQ_stanzas = [];
|
_converse.connection.IQ_stanzas = [];
|
||||||
_converse.connection._dataRecv(test_utils.createRequest(stanza));
|
_converse.connection._dataRecv(test_utils.createRequest(stanza));
|
||||||
await test_utils.waitUntil(() => _converse.omemo_store);
|
await test_utils.waitUntil(() => _converse.omemo_store);
|
||||||
|
|
||||||
iq_stanza = await test_utils.waitUntil(() => bundleHasBeenPublished(_converse));
|
iq_stanza = await test_utils.waitUntil(() => bundleHasBeenPublished(_converse));
|
||||||
expect(iq_stanza.toLocaleString()).toBe(
|
expect(iq_stanza.toLocaleString()).toBe(
|
||||||
`<iq from="dummy@localhost" id="${iq_stanza.nodeTree.getAttribute("id")}" type="set" xmlns="jabber:client">`+
|
`<iq from="dummy@localhost" id="${iq_stanza.nodeTree.getAttribute("id")}" type="set" xmlns="jabber:client">`+
|
||||||
@ -447,6 +453,16 @@
|
|||||||
`</bundle>`+
|
`</bundle>`+
|
||||||
`</item>`+
|
`</item>`+
|
||||||
`</publish>`+
|
`</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>`+
|
`</pubsub>`+
|
||||||
`</iq>`)
|
`</iq>`)
|
||||||
const own_device = _converse.devicelists.get(_converse.bare_jid).devices.get(_converse.omemo_store.get('device_id'));
|
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},
|
null, ['rosterGroupsFetched'], {'allow_non_roster_messaging': true},
|
||||||
async function (done, _converse) {
|
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);
|
test_utils.createContacts(_converse, 'current', 1);
|
||||||
const contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
const contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
|
|
||||||
@ -592,6 +614,16 @@
|
|||||||
`</list>`+
|
`</list>`+
|
||||||
`</item>`+
|
`</item>`+
|
||||||
`</publish>`+
|
`</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>`+
|
`</pubsub>`+
|
||||||
`</iq>`);
|
`</iq>`);
|
||||||
expect(_converse.devicelists.length).toBe(2);
|
expect(_converse.devicelists.length).toBe(2);
|
||||||
@ -609,6 +641,12 @@
|
|||||||
null, ['rosterGroupsFetched'], {},
|
null, ['rosterGroupsFetched'], {},
|
||||||
async function (done, _converse) {
|
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');
|
test_utils.createContacts(_converse, 'current');
|
||||||
const contact_jid = mock.cur_names[3].replace(/ /g,'.').toLowerCase() + '@localhost';
|
const contact_jid = mock.cur_names[3].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, _converse.bare_jid));
|
let iq_stanza = await test_utils.waitUntil(() => deviceListFetched(_converse, _converse.bare_jid));
|
||||||
@ -753,6 +791,12 @@
|
|||||||
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
|
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
|
||||||
async function (done, _converse) {
|
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
|
_converse.NUM_PREKEYS = 2; // Restrict to 2, otherwise the resulting stanza is too large to easily test
|
||||||
|
|
||||||
test_utils.createContacts(_converse, 'current', 1);
|
test_utils.createContacts(_converse, 'current', 1);
|
||||||
@ -797,6 +841,16 @@
|
|||||||
`</bundle>`+
|
`</bundle>`+
|
||||||
`</item>`+
|
`</item>`+
|
||||||
`</publish>`+
|
`</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>`+
|
`</pubsub>`+
|
||||||
`</iq>`)
|
`</iq>`)
|
||||||
|
|
||||||
@ -816,6 +870,12 @@
|
|||||||
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
|
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
|
||||||
async function (done, _converse) {
|
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);
|
test_utils.createContacts(_converse, 'current', 1);
|
||||||
_converse.emit('rosterContactsFetched');
|
_converse.emit('rosterContactsFetched');
|
||||||
const contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
const contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
@ -858,7 +918,17 @@
|
|||||||
`</list>`+
|
`</list>`+
|
||||||
`</item>`+
|
`</item>`+
|
||||||
`</publish>`+
|
`</publish>`+
|
||||||
`</pubsub>`+
|
`<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>`);
|
`</iq>`);
|
||||||
|
|
||||||
stanza = $iq({
|
stanza = $iq({
|
||||||
@ -965,6 +1035,12 @@
|
|||||||
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {'view_mode': 'fullscreen'},
|
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {'view_mode': 'fullscreen'},
|
||||||
async function (done, _converse) {
|
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.
|
// MEMO encryption works only in members-only conferences that are non-anonymous.
|
||||||
const features = [
|
const features = [
|
||||||
'http://jabber.org/protocol/muc',
|
'http://jabber.org/protocol/muc',
|
||||||
@ -1147,6 +1223,12 @@
|
|||||||
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
|
null, ['rosterGroupsFetched', 'chatBoxesFetched'], {},
|
||||||
async function (done, _converse) {
|
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);
|
test_utils.createContacts(_converse, 'current', 1);
|
||||||
_converse.emit('rosterContactsFetched');
|
_converse.emit('rosterContactsFetched');
|
||||||
const contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
const contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
import converse from "@converse/headless/converse-core";
|
import converse from "@converse/headless/converse-core";
|
||||||
import tpl_toolbar_omemo from "templates/toolbar_omemo.html";
|
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;
|
const u = converse.env.utils;
|
||||||
|
|
||||||
Strophe.addNamespace('OMEMO_DEVICELIST', Strophe.NS.OMEMO+".devicelist");
|
Strophe.addNamespace('OMEMO_DEVICELIST', Strophe.NS.OMEMO+".devicelist");
|
||||||
@ -750,23 +750,20 @@ converse.plugins.add('converse-omemo', {
|
|||||||
|
|
||||||
publishBundle () {
|
publishBundle () {
|
||||||
const signed_prekey = this.get('signed_prekey');
|
const signed_prekey = this.get('signed_prekey');
|
||||||
const stanza = $iq({
|
const node = `${Strophe.NS.OMEMO_BUNDLES}:${this.get('device_id')}`;
|
||||||
'from': _converse.bare_jid,
|
const item = $build('item')
|
||||||
'type': 'set'
|
.c('bundle', {'xmlns': Strophe.NS.OMEMO})
|
||||||
}).c('pubsub', {'xmlns': Strophe.NS.PUBSUB})
|
.c('signedPreKeyPublic', {'signedPreKeyId': signed_prekey.id})
|
||||||
.c('publish', {'node': `${Strophe.NS.OMEMO_BUNDLES}:${this.get('device_id')}`})
|
.t(signed_prekey.pubKey).up()
|
||||||
.c('item')
|
.c('signedPreKeySignature').t(signed_prekey.signature).up()
|
||||||
.c('bundle', {'xmlns': Strophe.NS.OMEMO})
|
.c('identityKey').t(this.get('identity_keypair').pubKey).up()
|
||||||
.c('signedPreKeyPublic', {'signedPreKeyId': signed_prekey.id})
|
.c('prekeys');
|
||||||
.t(signed_prekey.pubKey).up()
|
|
||||||
.c('signedPreKeySignature').t(signed_prekey.signature).up()
|
|
||||||
.c('identityKey').t(this.get('identity_keypair').pubKey).up()
|
|
||||||
.c('prekeys');
|
|
||||||
_.forEach(
|
_.forEach(
|
||||||
this.get('prekeys'),
|
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 () {
|
generateMissingPreKeys () {
|
||||||
@ -967,15 +964,10 @@ converse.plugins.add('converse-omemo', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
publishDevices () {
|
publishDevices () {
|
||||||
const stanza = $iq({
|
const item = $build('item').c('list', {'xmlns': Strophe.NS.OMEMO})
|
||||||
'from': _converse.bare_jid,
|
this.devices.each(d => item.c('device', {'id': d.get('id')}).up());
|
||||||
'type': 'set'
|
const options = {'pubsub#access_model': 'open'};
|
||||||
}).c('pubsub', {'xmlns': Strophe.NS.PUBSUB})
|
return _converse.api.pubsub.publish(null, Strophe.NS.OMEMO_DEVICELIST, item, options, false);
|
||||||
.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);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
removeOwnDevices (device_ids) {
|
removeOwnDevices (device_ids) {
|
||||||
|
Loading…
Reference in New Issue
Block a user