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
9a7f56db
Commit
9a7f56db
authored
Aug 18, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix format of stanza that queries for devices.
parent
4ed43854
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
76 deletions
+84
-76
spec/omemo.js
spec/omemo.js
+80
-70
src/converse-omemo.js
src/converse-omemo.js
+4
-6
No files found.
spec/omemo.js
View file @
9a7f56db
...
@@ -48,20 +48,21 @@
...
@@ -48,20 +48,21 @@
return
_
.
filter
(
return
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
_converse
.
connection
.
IQ_stanzas
,
(
iq
)
=>
{
(
iq
)
=>
{
const
node
=
iq
.
nodeTree
.
querySelector
(
'
iq[to="
'
+
_converse
.
bare_jid
+
'
"]
query
[node="eu.siacs.conversations.axolotl.devicelist"]
'
);
const
node
=
iq
.
nodeTree
.
querySelector
(
'
iq[to="
'
+
_converse
.
bare_jid
+
'
"]
items
[node="eu.siacs.conversations.axolotl.devicelist"]
'
);
if
(
node
)
{
iq_stanza
=
iq
.
nodeTree
;}
if
(
node
)
{
iq_stanza
=
iq
.
nodeTree
;}
return
node
;
return
node
;
}).
length
;
}).
length
;
}).
then
(()
=>
{
}).
then
(()
=>
{
const
stanza
=
$iq
({
const
stanza
=
$iq
({
'
from
'
:
contact
_jid
,
'
from
'
:
_converse
.
bare
_jid
,
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
'
type
'
:
'
result
'
,
}).
c
(
'
query
'
,
{
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
'
xmlns
'
:
'
http://jabber.org/protocol/disco#items
'
,
.
c
(
'
items
'
,
{
'
node
'
:
"
eu.siacs.conversations.axolotl.devicelist
"
})
'
node
'
:
'
eu.siacs.conversations.axolotl.devicelist
'
.
c
(
'
item
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
// TODO: must have an id attribute
}).
c
(
'
device
'
,
{
'
id
'
:
'
482886413b977930064a5888b92134fe
'
}).
up
()
.
c
(
'
list
'
,
{
'
xmlns
'
:
"
eu.siacs.conversations.axolotl
"
})
.
c
(
'
device
'
,
{
'
id
'
:
'
482886413b977930064a5888b92134fe
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
emit
(
'
OMEMOInitialized
'
);
_converse
.
emit
(
'
OMEMOInitialized
'
);
...
@@ -72,7 +73,7 @@
...
@@ -72,7 +73,7 @@
return
_
.
filter
(
return
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
_converse
.
connection
.
IQ_stanzas
,
(
iq
)
=>
{
(
iq
)
=>
{
const
node
=
iq
.
nodeTree
.
querySelector
(
'
iq[to="
'
+
contact_jid
+
'
"]
query
[node="eu.siacs.conversations.axolotl.devicelist"]
'
);
const
node
=
iq
.
nodeTree
.
querySelector
(
'
iq[to="
'
+
contact_jid
+
'
"]
items
[node="eu.siacs.conversations.axolotl.devicelist"]
'
);
if
(
node
)
{
iq_stanza
=
iq
.
nodeTree
;
}
if
(
node
)
{
iq_stanza
=
iq
.
nodeTree
;
}
return
node
;
return
node
;
}).
length
;
}).
length
;
...
@@ -81,12 +82,13 @@
...
@@ -81,12 +82,13 @@
const
stanza
=
$iq
({
const
stanza
=
$iq
({
'
from
'
:
contact_jid
,
'
from
'
:
contact_jid
,
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_
jid
,
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
result
'
,
'
type
'
:
'
result
'
,
}).
c
(
'
query
'
,
{
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
'
xmlns
'
:
'
http://jabber.org/protocol/disco#items
'
,
.
c
(
'
items
'
,
{
'
node
'
:
"
eu.siacs.conversations.axolotl.devicelist
"
})
'
node
'
:
'
eu.siacs.conversations.axolotl.devicelist
'
.
c
(
'
item
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
// TODO: must have an id attribute
}).
c
(
'
device
'
,
{
'
id
'
:
'
555
'
}).
up
()
.
c
(
'
list
'
,
{
'
xmlns
'
:
"
eu.siacs.conversations.axolotl
"
})
.
c
(
'
device
'
,
{
'
id
'
:
'
555
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
const
devicelist
=
_converse
.
devicelists
.
create
({
'
jid
'
:
contact_jid
});
const
devicelist
=
_converse
.
devicelists
.
create
({
'
jid
'
:
contact_jid
});
...
@@ -211,7 +213,7 @@
...
@@ -211,7 +213,7 @@
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg__body
'
)[
1
].
textContent
.
trim
())
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg__body
'
)[
1
].
textContent
.
trim
())
.
toBe
(
'
This is an encrypted message from the contact
'
);
.
toBe
(
'
This is an encrypted message from the contact
'
);
done
();
done
();
})
;
})
.
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
))
}));
}));
it
(
"
will add processing hints to sent out encrypted <message> stanzas
"
,
it
(
"
will add processing hints to sent out encrypted <message> stanzas
"
,
...
@@ -235,26 +237,27 @@
...
@@ -235,26 +237,27 @@
return
_
.
filter
(
return
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
_converse
.
connection
.
IQ_stanzas
,
(
iq
)
=>
{
(
iq
)
=>
{
const
node
=
iq
.
nodeTree
.
querySelector
(
'
iq[to="
'
+
_converse
.
bare_jid
+
'
"]
query
[node="eu.siacs.conversations.axolotl.devicelist"]
'
);
const
node
=
iq
.
nodeTree
.
querySelector
(
'
iq[to="
'
+
_converse
.
bare_jid
+
'
"]
items
[node="eu.siacs.conversations.axolotl.devicelist"]
'
);
if
(
node
)
{
iq_stanza
=
iq
.
nodeTree
;}
if
(
node
)
{
iq_stanza
=
iq
.
nodeTree
;}
return
node
;
return
node
;
}).
length
;
}).
length
;
}).
then
(
function
()
{
}).
then
(
function
()
{
expect
(
iq_stanza
.
outerHTML
).
toBe
(
expect
(
iq_stanza
.
outerHTML
).
toBe
(
'
<iq type="get" from="dummy@localhost" to="dummy@localhost" xmlns="jabber:client" id="
'
+
iq_stanza
.
getAttribute
(
"
id
"
)
+
'
">
'
+
'
<iq type="get" from="dummy@localhost" to="dummy@localhost" xmlns="jabber:client" id="
'
+
iq_stanza
.
getAttribute
(
"
id
"
)
+
'
">
'
+
'
<query xmlns="http://jabber.org/protocol/disco#items"
'
+
'
<pubsub xmlns="http://jabber.org/protocol/pubsub">
'
+
'
node="eu.siacs.conversations.axolotl.devicelist"/>
'
+
'
<items node="eu.siacs.conversations.axolotl.devicelist"/>
'
+
'
</pubsub>
'
+
'
</iq>
'
);
'
</iq>
'
);
const
stanza
=
$iq
({
const
stanza
=
$iq
({
'
from
'
:
contact
_jid
,
'
from
'
:
_converse
.
bare
_jid
,
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
'
type
'
:
'
result
'
,
}).
c
(
'
query
'
,
{
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
'
xmlns
'
:
'
http://jabber.org/protocol/disco#items
'
,
.
c
(
'
items
'
,
{
'
node
'
:
"
eu.siacs.conversations.axolotl.devicelist
"
})
'
node
'
:
'
eu.siacs.conversations.axolotl.devicelist
'
.
c
(
'
item
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
// TODO: must have an id attribute
}).
c
(
'
device
'
,
{
'
id
'
:
'
555
'
}).
up
()
.
c
(
'
list
'
,
{
'
xmlns
'
:
"
eu.siacs.conversations.axolotl
"
})
.
c
(
'
device
'
,
{
'
id
'
:
'
555
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
expect
(
_converse
.
devicelists
.
length
).
toBe
(
1
);
expect
(
_converse
.
devicelists
.
length
).
toBe
(
1
);
...
@@ -379,7 +382,7 @@
...
@@ -379,7 +382,7 @@
expect
(
devices
.
get
(
'
555
'
).
get
(
'
active
'
)).
toBe
(
false
);
expect
(
devices
.
get
(
'
555
'
).
get
(
'
active
'
)).
toBe
(
false
);
expect
(
devices
.
get
(
'
777
'
).
get
(
'
active
'
)).
toBe
(
false
);
expect
(
devices
.
get
(
'
777
'
).
get
(
'
active
'
)).
toBe
(
false
);
done
();
done
();
})
;
})
.
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
))
}));
}));
it
(
"
updates device bundles based on PEP messages
"
,
it
(
"
updates device bundles based on PEP messages
"
,
...
@@ -395,15 +398,16 @@
...
@@ -395,15 +398,16 @@
return
_
.
filter
(
return
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
_converse
.
connection
.
IQ_stanzas
,
(
iq
)
=>
{
(
iq
)
=>
{
const
node
=
iq
.
nodeTree
.
querySelector
(
'
iq[to="
'
+
_converse
.
bare_jid
+
'
"]
query
[node="eu.siacs.conversations.axolotl.devicelist"]
'
);
const
node
=
iq
.
nodeTree
.
querySelector
(
'
iq[to="
'
+
_converse
.
bare_jid
+
'
"]
items
[node="eu.siacs.conversations.axolotl.devicelist"]
'
);
if
(
node
)
{
iq_stanza
=
iq
.
nodeTree
;}
if
(
node
)
{
iq_stanza
=
iq
.
nodeTree
;}
return
node
;
return
node
;
}).
length
;
}).
length
;
}).
then
(
function
()
{
}).
then
(
function
()
{
expect
(
iq_stanza
.
outerHTML
).
toBe
(
expect
(
iq_stanza
.
outerHTML
).
toBe
(
'
<iq type="get" from="dummy@localhost" to="dummy@localhost" xmlns="jabber:client" id="
'
+
iq_stanza
.
getAttribute
(
"
id
"
)
+
'
">
'
+
'
<iq type="get" from="dummy@localhost" to="dummy@localhost" xmlns="jabber:client" id="
'
+
iq_stanza
.
getAttribute
(
"
id
"
)
+
'
">
'
+
'
<query xmlns="http://jabber.org/protocol/disco#items"
'
+
'
<pubsub xmlns="http://jabber.org/protocol/pubsub">
'
+
'
node="eu.siacs.conversations.axolotl.devicelist"/>
'
+
'
<items node="eu.siacs.conversations.axolotl.devicelist"/>
'
+
'
</pubsub>
'
+
'
</iq>
'
);
'
</iq>
'
);
const
stanza
=
$iq
({
const
stanza
=
$iq
({
...
@@ -411,10 +415,11 @@
...
@@ -411,10 +415,11 @@
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
'
type
'
:
'
result
'
,
}).
c
(
'
query
'
,
{
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
'
xmlns
'
:
'
http://jabber.org/protocol/disco#items
'
,
.
c
(
'
items
'
,
{
'
node
'
:
"
eu.siacs.conversations.axolotl.devicelist
"
})
'
node
'
:
'
eu.siacs.conversations.axolotl.devicelist
'
.
c
(
'
item
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
// TODO: must have an id attribute
}).
c
(
'
device
'
,
{
'
id
'
:
'
555
'
}).
up
()
.
c
(
'
list
'
,
{
'
xmlns
'
:
"
eu.siacs.conversations.axolotl
"
})
.
c
(
'
device
'
,
{
'
id
'
:
'
555
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
expect
(
_converse
.
devicelists
.
length
).
toBe
(
1
);
expect
(
_converse
.
devicelists
.
length
).
toBe
(
1
);
...
@@ -523,7 +528,7 @@
...
@@ -523,7 +528,7 @@
expect
(
device
.
get
(
'
bundle
'
).
prekeys
[
1
].
id
).
toBe
(
3002
);
expect
(
device
.
get
(
'
bundle
'
).
prekeys
[
1
].
id
).
toBe
(
3002
);
expect
(
device
.
get
(
'
bundle
'
).
prekeys
[
2
].
id
).
toBe
(
3003
);
expect
(
device
.
get
(
'
bundle
'
).
prekeys
[
2
].
id
).
toBe
(
3003
);
done
();
done
();
})
;
})
.
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
))
}));
}));
it
(
"
publishes a bundle with which an encrypted session can be created
"
,
it
(
"
publishes a bundle with which an encrypted session can be created
"
,
...
@@ -542,7 +547,7 @@
...
@@ -542,7 +547,7 @@
return
_
.
filter
(
return
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
_converse
.
connection
.
IQ_stanzas
,
(
iq
)
=>
{
(
iq
)
=>
{
const
node
=
iq
.
nodeTree
.
querySelector
(
'
iq[to="
'
+
_converse
.
bare_jid
+
'
"]
query
[node="eu.siacs.conversations.axolotl.devicelist"]
'
);
const
node
=
iq
.
nodeTree
.
querySelector
(
'
iq[to="
'
+
_converse
.
bare_jid
+
'
"]
items
[node="eu.siacs.conversations.axolotl.devicelist"]
'
);
if
(
node
)
{
iq_stanza
=
iq
.
nodeTree
;}
if
(
node
)
{
iq_stanza
=
iq
.
nodeTree
;}
return
node
;
return
node
;
}).
length
;
}).
length
;
...
@@ -552,12 +557,12 @@
...
@@ -552,12 +557,12 @@
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
'
type
'
:
'
result
'
,
}).
c
(
'
query
'
,
{
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
'
xmlns
'
:
'
http://jabber.org/protocol/disco#items
'
,
.
c
(
'
items
'
,
{
'
node
'
:
"
eu.siacs.conversations.axolotl.devicelist
"
})
'
node
'
:
'
eu.siacs.conversations.axolotl.devicelist
'
.
c
(
'
item
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
// TODO: must have an id attribute
}).
c
(
'
device
'
,
{
'
id
'
:
'
482886413b977930064a5888b92134fe
'
}).
up
()
.
c
(
'
list
'
,
{
'
xmlns
'
:
"
eu.siacs.conversations.axolotl
"
})
.
c
(
'
device
'
,
{
'
id
'
:
'
482886413b977930064a5888b92134fe
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
expect
(
_converse
.
devicelists
.
length
).
toBe
(
1
);
expect
(
_converse
.
devicelists
.
length
).
toBe
(
1
);
return
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
return
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
...
@@ -624,19 +629,20 @@
...
@@ -624,19 +629,20 @@
_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
'
;
test_utils
.
waitUntil
(
function
()
{
test_utils
.
waitUntil
(
()
=>
{
return
_
.
filter
(
return
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
_converse
.
connection
.
IQ_stanzas
,
(
iq
)
=>
{
(
iq
)
=>
{
const
node
=
iq
.
nodeTree
.
querySelector
(
'
iq[to="
'
+
_converse
.
bare_jid
+
'
"]
query
[node="eu.siacs.conversations.axolotl.devicelist"]
'
);
const
node
=
iq
.
nodeTree
.
querySelector
(
'
iq[to="
'
+
_converse
.
bare_jid
+
'
"]
items
[node="eu.siacs.conversations.axolotl.devicelist"]
'
);
if
(
node
)
{
iq_stanza
=
iq
.
nodeTree
;}
if
(
node
)
{
iq_stanza
=
iq
.
nodeTree
;}
return
node
;
return
node
;
}).
length
;
}).
length
;
}).
then
(
function
()
{
}).
then
(
()
=>
{
expect
(
iq_stanza
.
outerHTML
).
toBe
(
expect
(
iq_stanza
.
outerHTML
).
toBe
(
'
<iq type="get" from="dummy@localhost" to="dummy@localhost" xmlns="jabber:client" id="
'
+
iq_stanza
.
getAttribute
(
"
id
"
)
+
'
">
'
+
'
<iq type="get" from="dummy@localhost" to="dummy@localhost" xmlns="jabber:client" id="
'
+
iq_stanza
.
getAttribute
(
"
id
"
)
+
'
">
'
+
'
<query xmlns="http://jabber.org/protocol/disco#items"
'
+
'
<pubsub xmlns="http://jabber.org/protocol/pubsub">
'
+
'
node="eu.siacs.conversations.axolotl.devicelist"/>
'
+
'
<items node="eu.siacs.conversations.axolotl.devicelist"/>
'
+
'
</pubsub>
'
+
'
</iq>
'
);
'
</iq>
'
);
const
stanza
=
$iq
({
const
stanza
=
$iq
({
...
@@ -644,10 +650,11 @@
...
@@ -644,10 +650,11 @@
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
'
type
'
:
'
result
'
,
}).
c
(
'
query
'
,
{
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
'
xmlns
'
:
'
http://jabber.org/protocol/disco#items
'
,
.
c
(
'
items
'
,
{
'
node
'
:
"
eu.siacs.conversations.axolotl.devicelist
"
})
'
node
'
:
'
eu.siacs.conversations.axolotl.devicelist
'
.
c
(
'
item
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
// TODO: must have an id attribute
}).
c
(
'
device
'
,
{
'
id
'
:
'
482886413b977930064a5888b92134fe
'
}).
up
()
.
c
(
'
list
'
,
{
'
xmlns
'
:
"
eu.siacs.conversations.axolotl
"
})
.
c
(
'
device
'
,
{
'
id
'
:
'
482886413b977930064a5888b92134fe
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
expect
(
_converse
.
devicelists
.
length
).
toBe
(
1
);
expect
(
_converse
.
devicelists
.
length
).
toBe
(
1
);
...
@@ -664,7 +671,7 @@
...
@@ -664,7 +671,7 @@
return
node
;
return
node
;
}).
length
;
}).
length
;
});
});
}).
then
(
function
()
{
}).
then
(
()
=>
{
expect
(
iq_stanza
.
outerHTML
).
toBe
(
expect
(
iq_stanza
.
outerHTML
).
toBe
(
'
<iq from="dummy@localhost" type="set" xmlns="jabber:client" id="
'
+
iq_stanza
.
getAttribute
(
'
id
'
)
+
'
">
'
+
'
<iq from="dummy@localhost" type="set" xmlns="jabber:client" id="
'
+
iq_stanza
.
getAttribute
(
'
id
'
)
+
'
">
'
+
'
<pubsub xmlns="http://jabber.org/protocol/pubsub">
'
+
'
<pubsub xmlns="http://jabber.org/protocol/pubsub">
'
+
...
@@ -693,7 +700,7 @@
...
@@ -693,7 +700,7 @@
return
node
;
return
node
;
}).
length
;
}).
length
;
});
});
}).
then
(
function
()
{
}).
then
(
()
=>
{
expect
(
iq_stanza
.
getAttributeNames
().
sort
().
join
()).
toBe
([
"
from
"
,
"
type
"
,
"
xmlns
"
,
"
id
"
].
sort
().
join
());
expect
(
iq_stanza
.
getAttributeNames
().
sort
().
join
()).
toBe
([
"
from
"
,
"
type
"
,
"
xmlns
"
,
"
id
"
].
sort
().
join
());
expect
(
iq_stanza
.
querySelector
(
'
prekeys
'
).
childNodes
.
length
).
toBe
(
100
);
expect
(
iq_stanza
.
querySelector
(
'
prekeys
'
).
childNodes
.
length
).
toBe
(
100
);
...
@@ -715,25 +722,28 @@
...
@@ -715,25 +722,28 @@
return
_
.
filter
(
return
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
_converse
.
connection
.
IQ_stanzas
,
(
iq
)
=>
{
(
iq
)
=>
{
const
node
=
iq
.
nodeTree
.
querySelector
(
'
iq[to="
'
+
contact_jid
+
'
"]
query
[node="eu.siacs.conversations.axolotl.devicelist"]
'
);
const
node
=
iq
.
nodeTree
.
querySelector
(
'
iq[to="
'
+
contact_jid
+
'
"]
items
[node="eu.siacs.conversations.axolotl.devicelist"]
'
);
if
(
node
)
{
iq_stanza
=
iq
.
nodeTree
;
}
if
(
node
)
{
iq_stanza
=
iq
.
nodeTree
;
}
return
node
;
return
node
;
}).
length
;});
}).
length
;});
}).
then
(
function
()
{
}).
then
(
()
=>
{
expect
(
iq_stanza
.
outerHTML
).
toBe
(
expect
(
iq_stanza
.
outerHTML
).
toBe
(
'
<iq type="get" from="dummy@localhost" to="
'
+
contact_jid
+
'
" xmlns="jabber:client" id="
'
+
iq_stanza
.
getAttribute
(
"
id
"
)
+
'
">
'
+
'
<iq type="get" from="dummy@localhost" to="
'
+
contact_jid
+
'
" xmlns="jabber:client" id="
'
+
iq_stanza
.
getAttribute
(
"
id
"
)
+
'
">
'
+
'
<query xmlns="http://jabber.org/protocol/disco#items"
'
+
'
<pubsub xmlns="http://jabber.org/protocol/pubsub">
'
+
'
node="eu.siacs.conversations.axolotl.devicelist"/>
'
+
'
<items node="eu.siacs.conversations.axolotl.devicelist"/>
'
+
'
</pubsub>
'
+
'
</iq>
'
);
'
</iq>
'
);
const
stanza
=
$iq
({
const
stanza
=
$iq
({
'
from
'
:
contact_jid
,
'
from
'
:
contact_jid
,
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
'
type
'
:
'
result
'
,
}).
c
(
'
query
'
,
{
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
'
xmlns
'
:
'
http://jabber.org/protocol/disco#items
'
,
.
c
(
'
items
'
,
{
'
node
'
:
"
eu.siacs.conversations.axolotl.devicelist
"
})
'
node
'
:
'
eu.siacs.conversations.axolotl.devicelist
'
.
c
(
'
item
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
// TODO: must have an id attribute
}).
c
(
'
device
'
,
{
'
id
'
:
'
368866411b877c30064a5f62b917cffe
'
}).
up
()
.
c
(
'
list
'
,
{
'
xmlns
'
:
"
eu.siacs.conversations.axolotl
"
})
.
c
(
'
device
'
,
{
'
id
'
:
'
368866411b877c30064a5f62b917cffe
'
}).
up
()
.
c
(
'
device
'
,
{
'
id
'
:
'
3300659945416e274474e469a1f0154c
'
}).
up
()
.
c
(
'
device
'
,
{
'
id
'
:
'
3300659945416e274474e469a1f0154c
'
}).
up
()
.
c
(
'
device
'
,
{
'
id
'
:
'
4e30f35051b7b8b42abe083742187228
'
}).
up
()
.
c
(
'
device
'
,
{
'
id
'
:
'
4e30f35051b7b8b42abe083742187228
'
}).
up
()
.
c
(
'
device
'
,
{
'
id
'
:
'
ae890ac52d0df67ed7cfdf51b644e901
'
});
.
c
(
'
device
'
,
{
'
id
'
:
'
ae890ac52d0df67ed7cfdf51b644e901
'
});
...
@@ -747,7 +757,7 @@
...
@@ -747,7 +757,7 @@
expect
(
devicelist
.
devices
.
at
(
2
).
get
(
'
id
'
)).
toBe
(
'
4e30f35051b7b8b42abe083742187228
'
);
expect
(
devicelist
.
devices
.
at
(
2
).
get
(
'
id
'
)).
toBe
(
'
4e30f35051b7b8b42abe083742187228
'
);
expect
(
devicelist
.
devices
.
at
(
3
).
get
(
'
id
'
)).
toBe
(
'
ae890ac52d0df67ed7cfdf51b644e901
'
);
expect
(
devicelist
.
devices
.
at
(
3
).
get
(
'
id
'
)).
toBe
(
'
ae890ac52d0df67ed7cfdf51b644e901
'
);
return
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxviews
.
get
(
contact_jid
).
el
.
querySelector
(
'
.chat-toolbar
'
));
return
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxviews
.
get
(
contact_jid
).
el
.
querySelector
(
'
.chat-toolbar
'
));
}).
then
(
function
()
{
}).
then
(
()
=>
{
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
toolbar
=
view
.
el
.
querySelector
(
'
.chat-toolbar
'
);
const
toolbar
=
view
.
el
.
querySelector
(
'
.chat-toolbar
'
);
expect
(
view
.
model
.
get
(
'
omemo_active
'
)).
toBe
(
undefined
);
expect
(
view
.
model
.
get
(
'
omemo_active
'
)).
toBe
(
undefined
);
...
@@ -763,7 +773,7 @@
...
@@ -763,7 +773,7 @@
expect
(
view
.
model
.
get
(
'
omemo_active
'
)).
toBe
(
true
);
expect
(
view
.
model
.
get
(
'
omemo_active
'
)).
toBe
(
true
);
return
test_utils
.
waitUntil
(()
=>
u
.
hasClass
(
'
fa-lock
'
,
toolbar
.
querySelector
(
'
.toggle-omemo
'
)));
return
test_utils
.
waitUntil
(()
=>
u
.
hasClass
(
'
fa-lock
'
,
toolbar
.
querySelector
(
'
.toggle-omemo
'
)));
}).
then
(
function
()
{
}).
then
(
()
=>
{
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
toolbar
=
view
.
el
.
querySelector
(
'
.chat-toolbar
'
);
const
toolbar
=
view
.
el
.
querySelector
(
'
.chat-toolbar
'
);
const
toggle
=
toolbar
.
querySelector
(
'
.toggle-omemo
'
);
const
toggle
=
toolbar
.
querySelector
(
'
.toggle-omemo
'
);
...
@@ -777,7 +787,6 @@
...
@@ -777,7 +787,6 @@
preventDefault
:
_
.
noop
,
preventDefault
:
_
.
noop
,
keyCode
:
13
keyCode
:
13
});
});
done
();
done
();
}).
catch
(
_
.
partial
(
console
.
error
,
_
));
}).
catch
(
_
.
partial
(
console
.
error
,
_
));
}));
}));
...
@@ -806,7 +815,7 @@
...
@@ -806,7 +815,7 @@
return
_
.
filter
(
return
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
_converse
.
connection
.
IQ_stanzas
,
(
iq
)
=>
{
(
iq
)
=>
{
const
node
=
iq
.
nodeTree
.
querySelector
(
'
iq[to="
'
+
contact_jid
+
'
"]
query
[node="eu.siacs.conversations.axolotl.devicelist"]
'
);
const
node
=
iq
.
nodeTree
.
querySelector
(
'
iq[to="
'
+
contact_jid
+
'
"]
items
[node="eu.siacs.conversations.axolotl.devicelist"]
'
);
if
(
node
)
{
iq_stanza
=
iq
.
nodeTree
;
}
if
(
node
)
{
iq_stanza
=
iq
.
nodeTree
;
}
return
node
;
return
node
;
}).
length
;});
}).
length
;});
...
@@ -815,7 +824,7 @@
...
@@ -815,7 +824,7 @@
iq_stanza
;
iq_stanza
;
expect
(
iq_stanza
.
outerHTML
).
toBe
(
expect
(
iq_stanza
.
outerHTML
).
toBe
(
`<iq type="get" from="dummy@localhost" to="max.frankfurter@localhost" xmlns="jabber:client" id="
${
iq_stanza
.
getAttribute
(
'
id
'
)}
">`
+
`<iq type="get" from="dummy@localhost" to="max.frankfurter@localhost" xmlns="jabber:client" id="
${
iq_stanza
.
getAttribute
(
'
id
'
)}
">`
+
`<
query xmlns="http://jabber.org/protocol/disco#items" node="eu.siacs.conversations.axolotl.devicelist"/
>`
+
`<
pubsub xmlns="http://jabber.org/protocol/pubsub"><items node="eu.siacs.conversations.axolotl.devicelist"/></pubsub
>`
+
`</iq>`
);
`</iq>`
);
const
stanza
=
$iq
({
const
stanza
=
$iq
({
...
@@ -823,10 +832,11 @@
...
@@ -823,10 +832,11 @@
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
'
type
'
:
'
result
'
,
}).
c
(
'
query
'
,
{
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
'
xmlns
'
:
'
http://jabber.org/protocol/disco#items
'
,
.
c
(
'
items
'
,
{
'
node
'
:
"
eu.siacs.conversations.axolotl.devicelist
"
})
'
node
'
:
'
eu.siacs.conversations.axolotl.devicelist
'
.
c
(
'
item
'
,
{
'
xmlns
'
:
"
http://jabber.org/protocol/pubsub
"
})
// TODO: must have an id attribute
}).
c
(
'
device
'
,
{
'
id
'
:
'
555
'
}).
up
()
.
c
(
'
list
'
,
{
'
xmlns
'
:
"
eu.siacs.conversations.axolotl
"
})
.
c
(
'
device
'
,
{
'
id
'
:
'
555
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
return
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
1000
).
then
(
function
()
{
return
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
1000
).
then
(
function
()
{
...
@@ -892,7 +902,7 @@
...
@@ -892,7 +902,7 @@
untrusted_radio
=
document
.
querySelector
(
'
input[type="radio"][name="555"][value="-1"]
'
);
untrusted_radio
=
document
.
querySelector
(
'
input[type="radio"][name="555"][value="-1"]
'
);
expect
(
untrusted_radio
.
hasAttribute
(
'
checked
'
)).
toBe
(
true
);
expect
(
untrusted_radio
.
hasAttribute
(
'
checked
'
)).
toBe
(
true
);
done
();
done
();
})
;
})
.
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
))
}));
}));
});
});
...
...
src/converse-omemo.js
View file @
9a7f56db
...
@@ -703,15 +703,13 @@
...
@@ -703,15 +703,13 @@
'
type
'
:
'
get
'
,
'
type
'
:
'
get
'
,
'
from
'
:
_converse
.
bare_jid
,
'
from
'
:
_converse
.
bare_jid
,
'
to
'
:
this
.
get
(
'
jid
'
)
'
to
'
:
this
.
get
(
'
jid
'
)
}).
c
(
'
query
'
,
{
}).
c
(
'
pubsub
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
PUBSUB
})
'
xmlns
'
:
Strophe
.
NS
.
DISCO_ITEMS
,
.
c
(
'
items
'
,
{
'
node
'
:
Strophe
.
NS
.
OMEMO_DEVICELIST
});
'
node
'
:
Strophe
.
NS
.
OMEMO_DEVICELIST
});
_converse
.
connection
.
sendIQ
(
_converse
.
connection
.
sendIQ
(
stanza
,
stanza
,
(
iq
)
=>
{
(
iq
)
=>
{
_
.
forEach
(
_
.
forEach
(
iq
.
querySelectorAll
(
'
device
'
),
sizzle
(
`list[xmlns="
${
Strophe
.
NS
.
OMEMO
}
"] device`
,
iq
),
(
dev
)
=>
this
.
devices
.
create
({
'
id
'
:
dev
.
getAttribute
(
'
id
'
),
'
jid
'
:
this
.
get
(
'
jid
'
)})
(
dev
)
=>
this
.
devices
.
create
({
'
id
'
:
dev
.
getAttribute
(
'
id
'
),
'
jid
'
:
this
.
get
(
'
jid
'
)})
);
);
resolve
();
resolve
();
...
@@ -891,7 +889,7 @@
...
@@ -891,7 +889,7 @@
.
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
ERROR
));
.
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
ERROR
));
}
}
_converse
.
api
.
listen
.
on
(
'
afterTearDown
'
,
()
=>
_converse
.
devices
.
reset
());
_converse
.
api
.
listen
.
on
(
'
afterTearDown
'
,
()
=>
_converse
.
device
list
s
.
reset
());
_converse
.
api
.
listen
.
on
(
'
connected
'
,
registerPEPPushHandler
);
_converse
.
api
.
listen
.
on
(
'
connected
'
,
registerPEPPushHandler
);
_converse
.
api
.
listen
.
on
(
'
renderToolbar
'
,
(
view
)
=>
view
.
renderOMEMOToolbarButton
());
_converse
.
api
.
listen
.
on
(
'
renderToolbar
'
,
(
view
)
=>
view
.
renderOMEMOToolbarButton
());
_converse
.
api
.
listen
.
on
(
'
statusInitialized
'
,
initOMEMO
);
_converse
.
api
.
listen
.
on
(
'
statusInitialized
'
,
initOMEMO
);
...
...
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