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
09eb1731
Commit
09eb1731
authored
May 12, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add code to generate and publish our bundle and update the test
updates #497
parent
6042c233
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
168 additions
and
79 deletions
+168
-79
spec/omemo.js
spec/omemo.js
+64
-24
src/converse-chatview.js
src/converse-chatview.js
+1
-0
src/converse-omemo.js
src/converse-omemo.js
+93
-48
src/utils/core.js
src/utils/core.js
+9
-7
tests/runner.js
tests/runner.js
+1
-0
No files found.
spec/omemo.js
View file @
09eb1731
...
...
@@ -15,7 +15,25 @@
});
},
'
generateRegistrationId
'
:
function
()
{
return
1234
;
return
'
31415
'
;
},
'
generatePreKey
'
:
function
(
keyid
)
{
return
Promise
.
resolve
({
'
keyId
'
:
keyid
,
'
keyPair
'
:
{
'
pubKey
'
:
1234
,
'
privKey
'
:
4321
}
});
},
'
generateSignedPreKey
'
:
function
(
identity_keypair
,
keyid
)
{
return
Promise
.
resolve
({
'
keyId
'
:
keyid
,
'
keyPair
'
:
{
'
pubKey
'
:
1234
,
'
privKey
'
:
4321
}
});
}
}
};
...
...
@@ -35,15 +53,14 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
let
devicelist_iq
,
disco_info_iq
;
let
iq_stanza
;
test_utils
.
createContacts
(
_converse
,
'
current
'
);
const
contact_jid
=
mock
.
cur_names
[
2
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
waitUntil
(
function
()
{
return
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
function
(
iq
)
{
const
node
=
iq
.
nodeTree
.
querySelector
(
'
iq[to="dummy@localhost"] query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
if
(
node
)
{
disco_info_iq
=
iq
;
}
if
(
node
)
{
iq_stanza
=
iq
.
nodeTree
;
}
return
node
;
}).
length
>
0
;
},
1000
).
then
(
function
()
{
...
...
@@ -52,32 +69,57 @@
'
type
'
:
'
result
'
,
'
from
'
:
'
dummy@localhost
'
,
'
to
'
:
'
dummy@localhost/resource
'
,
'
id
'
:
disco_info_iq
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
.
c
(
'
identity
'
,
{
'
category
'
:
'
pubsub
'
,
'
type
'
:
'
pep
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
return
test_utils
.
waitUntil
(()
=>
{
return
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
function
(
iq
)
{
const
node
=
iq
.
nodeTree
.
querySelector
(
'
publish[node="eu.siacs.conversations.axolotl.bundles:31415"]
'
);
if
(
node
)
{
iq_stanza
=
iq
.
nodeTree
;
}
return
node
;
}).
length
;
});
}).
then
(
function
()
{
expect
(
iq_stanza
.
getAttributeNames
().
sort
().
join
()).
toBe
([
"
from
"
,
"
type
"
,
"
xmlns
"
,
"
id
"
].
sort
().
join
());
expect
(
iq_stanza
.
querySelector
(
'
prekeys
'
).
childNodes
.
length
).
toBe
(
100
);
const
signed_prekeys
=
iq_stanza
.
querySelectorAll
(
'
signedPreKeyPublic
'
);
expect
(
signed_prekeys
.
length
).
toBe
(
1
);
const
signed_prekey
=
signed_prekeys
[
0
];
expect
(
signed_prekey
.
getAttribute
(
'
signedPreKeyId
'
)).
toBe
(
'
0
'
)
expect
(
iq_stanza
.
querySelectorAll
(
'
signedPreKeySignature
'
).
length
).
toBe
(
1
);
expect
(
iq_stanza
.
querySelectorAll
(
'
identityKey
'
).
length
).
toBe
(
1
);
const
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
return
test_utils
.
waitUntil
(()
=>
{
return
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
(
iq
)
=>
{
const
node
=
iq
.
nodeTree
.
querySelector
(
'
iq[to="
'
+
_converse
.
bare_jid
+
'
"] query[node="eu.siacs.conversations.axolotl.devicelist"]
'
);
if
(
node
)
{
devicelist_iq
=
iq
;
}
if
(
node
)
{
iq_stanza
=
iq
.
nodeTree
;}
return
node
;
}).
length
;
});
}).
then
(
function
()
{
expect
(
devicelist_iq
.
toLocaleString
()).
toBe
(
"
<iq type='get' from='dummy@localhost' to='dummy@localhost' xmlns='jabber:client' id='
"
+
devicelist_iq
.
nodeTree
.
getAttribute
(
'
id
'
)
+
"
'>
"
+
"
<query xmlns='http://jabber.org/protocol/disco#items'
"
+
"
node='eu.siacs.conversations.axolotl.devicelist'/>
"
+
"
</iq>
"
);
expect
(
iq_stanza
.
outerHTML
).
toBe
(
'
<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"
'
+
'
node="eu.siacs.conversations.axolotl.devicelist"/>
'
+
'
</iq>
'
);
const
stanza
=
$iq
({
'
from
'
:
contact_jid
,
'
id
'
:
devicelist_iq
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
query
'
,
{
...
...
@@ -97,20 +139,18 @@
_converse
.
connection
.
IQ_stanzas
,
(
iq
)
=>
{
const
node
=
iq
.
nodeTree
.
querySelector
(
'
iq[to="
'
+
contact_jid
+
'
"] query[node="eu.siacs.conversations.axolotl.devicelist"]
'
);
if
(
node
)
{
devicelist_iq
=
iq
;
}
if
(
node
)
{
iq_stanza
=
iq
.
nodeTree
;
}
return
node
;
}).
length
;});
}).
then
(
function
()
{
expect
(
devicelist_iq
.
toLocaleString
()
).
toBe
(
"
<iq type='get' from='dummy@localhost' to='
"
+
contact_jid
+
"
' xmlns='jabber:client' id='
"
+
devicelist_iq
.
nodeTree
.
getAttribute
(
'
id
'
)
+
"
'>
"
+
"
<query xmlns='http://jabber.org/protocol/disco#items'
"
+
"
node='eu.siacs.conversations.axolotl.devicelist'/>
"
+
"
</iq>
"
);
expect
(
iq_stanza
.
outerHTML
).
toBe
(
'
<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"
'
+
'
node="eu.siacs.conversations.axolotl.devicelist"/>
'
+
'
</iq>
'
);
const
stanza
=
$iq
({
'
from
'
:
contact_jid
,
'
id
'
:
devicelist_iq
.
nodeTree
.
getAttribute
(
'
id
'
),
'
id
'
:
iq_stanza
.
getAttribute
(
'
id
'
),
'
to
'
:
_converse
.
bare_jid
,
'
type
'
:
'
result
'
,
}).
c
(
'
query
'
,
{
...
...
@@ -139,7 +179,7 @@
toolbar
.
querySelector
(
'
.toggle-omemo
'
).
click
();
expect
(
view
.
toggleOMEMO
).
toHaveBeenCalled
();
done
();
});
})
.
catch
(
_
.
partial
(
console
.
error
,
_
))
;
}));
});
...
...
src/converse-chatview.js
View file @
09eb1731
...
...
@@ -387,6 +387,7 @@
this
.
addSpoilerButton
(
options
);
this
.
addFileUploadButton
();
this
.
insertEmojiPicker
();
_converse
.
emit
(
'
renderToolbar
'
,
this
);
return
this
;
},
...
...
src/converse-omemo.js
View file @
09eb1731
This diff is collapsed.
Click to expand it.
src/utils/core.js
View file @
09eb1731
...
...
@@ -823,14 +823,11 @@
return
text
.
replace
(
_converse
.
geouri_regex
,
replacement
);
};
u
.
getSelectValues
=
function
(
select
)
{
var
result
=
[];
var
options
=
select
&&
select
.
options
;
var
opt
;
u
.
getSelectValues
=
function
(
select
)
{
const
result
=
[];
const
options
=
select
&&
select
.
options
;
for
(
var
i
=
0
,
iLen
=
options
.
length
;
i
<
iLen
;
i
++
)
{
opt
=
options
[
i
];
const
opt
=
options
[
i
];
if
(
opt
.
selected
)
{
result
.
push
(
opt
.
value
||
opt
.
text
);
}
...
...
@@ -838,5 +835,10 @@
return
result
;
};
u
.
arrayBuffer2Base64
=
function
(
ab
)
{
return
new
window
.
Uint8Array
(
ab
)
.
reduce
((
data
,
byte
)
=>
data
+
String
.
fromCharCode
(
byte
),
''
)
};
return
u
;
}));
tests/runner.js
View file @
09eb1731
...
...
@@ -47,6 +47,7 @@ var specs = [
"
spec/ping
"
,
"
spec/xmppstatus
"
,
"
spec/mam
"
,
"
spec/omemo
"
,
"
spec/controlbox
"
,
"
spec/roster
"
,
"
spec/chatbox
"
,
...
...
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