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
21a04d9d
Commit
21a04d9d
authored
Aug 22, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid unnecessary promise-wrapping
parent
de077ba9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
37 deletions
+30
-37
src/converse-omemo.js
src/converse-omemo.js
+30
-37
No files found.
src/converse-omemo.js
View file @
21a04d9d
...
@@ -458,23 +458,18 @@
...
@@ -458,23 +458,18 @@
_converse
.
NUM_PREKEYS
=
100
;
// Set here so that tests can override
_converse
.
NUM_PREKEYS
=
100
;
// Set here so that tests can override
function
generateFingerprint
(
device
)
{
function
generateFingerprint
(
device
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
bundle
;
device
.
getBundle
().
then
((
bundle
)
=>
{
return
device
.
getBundle
().
then
(
b
=>
{
if
(
_
.
isNil
(
bundle
))
{
resolve
();
}
bundle
=
b
;
return
crypto
.
subtle
.
digest
(
'
SHA-1
'
,
u
.
base64ToArrayBuffer
(
bundle
[
'
identity_key
'
]));
// TODO: only generate fingerprints when necessary
}).
then
(
fp
=>
{
crypto
.
subtle
.
digest
(
'
SHA-1
'
,
u
.
base64ToArrayBuffer
(
bundle
[
'
identity_key
'
]))
.
then
((
fp
)
=>
{
bundle
[
'
fingerprint
'
]
=
u
.
arrayBufferToHex
(
fp
);
bundle
[
'
fingerprint
'
]
=
u
.
arrayBufferToHex
(
fp
);
device
.
save
(
'
bundle
'
,
bundle
);
device
.
save
(
'
bundle
'
,
bundle
);
device
.
trigger
(
'
change:bundle
'
);
// Doesn't get triggered automatically due to pass-by-reference
device
.
trigger
(
'
change:bundle
'
);
// Doesn't get triggered automatically due to pass-by-reference
resolve
();
}).
catch
(
reject
);
});
});
});
}
}
_converse
.
generateFingerprints
=
function
(
jid
)
{
_converse
.
generateFingerprints
=
function
(
jid
)
{
return
_converse
.
getDevicesForContact
(
jid
)
return
_converse
.
getDevicesForContact
(
jid
)
.
then
(
devices
=>
Promise
.
all
(
devices
.
map
(
d
=>
generateFingerprint
(
d
))))
.
then
(
devices
=>
Promise
.
all
(
devices
.
map
(
d
=>
generateFingerprint
(
d
))))
}
}
...
@@ -822,7 +817,6 @@
...
@@ -822,7 +817,6 @@
const
store
=
_converse
.
omemo_store
,
const
store
=
_converse
.
omemo_store
,
signed_prekey
=
store
.
get
(
'
signed_prekey
'
);
signed_prekey
=
store
.
get
(
'
signed_prekey
'
);
return
new
Promise
((
resolve
,
reject
)
=>
{
const
stanza
=
$iq
({
const
stanza
=
$iq
({
'
from
'
:
_converse
.
bare_jid
,
'
from
'
:
_converse
.
bare_jid
,
'
type
'
:
'
set
'
'
type
'
:
'
set
'
...
@@ -843,8 +837,7 @@
...
@@ -843,8 +837,7 @@
stanza
.
c
(
'
preKeyPublic
'
,
{
'
preKeyId
'
:
prekey
.
keyId
})
stanza
.
c
(
'
preKeyPublic
'
,
{
'
preKeyId
'
:
prekey
.
keyId
})
.
t
(
u
.
arrayBufferToBase64
(
prekey
.
keyPair
.
pubKey
)).
up
();
.
t
(
u
.
arrayBufferToBase64
(
prekey
.
keyPair
.
pubKey
)).
up
();
});
});
_converse
.
connection
.
sendIQ
(
stanza
,
resolve
,
reject
,
_converse
.
IQ_TIMEOUT
);
return
_converse
.
api
.
sendIQ
(
stanza
);
});
}
}
}
}
...
...
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