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
7bb7f8f4
Commit
7bb7f8f4
authored
Aug 23, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Can now successfully send an encrypted stanza
updates #497
parent
c1123fd6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
16 deletions
+9
-16
src/converse-omemo.js
src/converse-omemo.js
+9
-16
No files found.
src/converse-omemo.js
View file @
7bb7f8f4
...
@@ -291,7 +291,7 @@
...
@@ -291,7 +291,7 @@
},
},
buildSessions
(
devices
)
{
buildSessions
(
devices
)
{
return
Promise
.
all
(
devices
.
map
(
device
=>
this
.
buildSession
(
device
)));
return
Promise
.
all
(
devices
.
map
(
device
=>
this
.
buildSession
(
device
)))
.
then
(()
=>
devices
)
;
},
},
encryptMessage
(
plaintext
)
{
encryptMessage
(
plaintext
)
{
...
@@ -330,14 +330,10 @@
...
@@ -330,14 +330,10 @@
encryptKey
(
plaintext
,
device
)
{
encryptKey
(
plaintext
,
device
)
{
const
{
_converse
}
=
this
.
__super__
,
const
{
_converse
}
=
this
.
__super__
,
address
=
new
libsignal
.
SignalProtocolAddress
(
this
.
get
(
'
jid
'
),
device
.
get
(
'
id
'
)),
address
=
new
libsignal
.
SignalProtocolAddress
(
device
.
get
(
'
jid
'
),
device
.
get
(
'
id
'
)),
session_cipher
=
new
window
.
libsignal
.
SessionCipher
(
_converse
.
omemo_store
,
address
);
session_cipher
=
new
window
.
libsignal
.
SessionCipher
(
_converse
.
omemo_store
,
address
);
return
new
Promise
((
resolve
,
reject
)
=>
{
return
session_cipher
.
encrypt
(
plaintext
).
then
(
payload
=>
({
'
payload
'
:
payload
,
'
device
'
:
device
}));
session_cipher
.
encrypt
(
plaintext
)
.
then
(
payload
=>
resolve
({
'
payload
'
:
payload
,
'
device
'
:
device
}))
.
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
ERROR
));
});
},
},
addKeysToMessageStanza
(
stanza
,
dicts
,
iv
)
{
addKeysToMessageStanza
(
stanza
,
dicts
,
iv
)
{
...
@@ -380,7 +376,7 @@
...
@@ -380,7 +376,7 @@
.
c
(
'
encrypted
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
OMEMO
})
.
c
(
'
encrypted
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
OMEMO
})
.
c
(
'
header
'
,
{
'
sid
'
:
_converse
.
omemo_store
.
get
(
'
device_id
'
)});
.
c
(
'
header
'
,
{
'
sid
'
:
_converse
.
omemo_store
.
get
(
'
device_id
'
)});
return
this
.
encryptMessage
(
message
).
then
(
(
obj
)
=>
{
return
this
.
encryptMessage
(
message
).
then
(
obj
=>
{
// The 16 bytes key and the GCM authentication tag (The tag
// The 16 bytes key and the GCM authentication tag (The tag
// SHOULD have at least 128 bit) are concatenated and for each
// SHOULD have at least 128 bit) are concatenated and for each
// intended recipient device, i.e. both own devices as well as
// intended recipient device, i.e. both own devices as well as
...
@@ -394,7 +390,6 @@
...
@@ -394,7 +390,6 @@
return
Promise
.
all
(
promises
)
return
Promise
.
all
(
promises
)
.
then
((
dicts
)
=>
this
.
addKeysToMessageStanza
(
stanza
,
dicts
,
obj
.
iv
))
.
then
((
dicts
)
=>
this
.
addKeysToMessageStanza
(
stanza
,
dicts
,
obj
.
iv
))
.
then
((
stanza
)
=>
stanza
.
c
(
'
payload
'
).
t
(
obj
.
payload
))
.
then
((
stanza
)
=>
stanza
.
c
(
'
payload
'
).
t
(
obj
.
payload
))
.
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
ERROR
));
});
});
},
},
...
@@ -406,12 +401,12 @@
...
@@ -406,12 +401,12 @@
this
.
getBundlesAndBuildSessions
()
this
.
getBundlesAndBuildSessions
()
.
then
(
devices
=>
this
.
createOMEMOMessageStanza
(
message
,
devices
))
.
then
(
devices
=>
this
.
createOMEMOMessageStanza
(
message
,
devices
))
.
then
(
stanza
=>
this
.
sendMessageStanza
(
stanza
))
.
then
(
stanza
=>
this
.
sendMessageStanza
(
stanza
))
.
catch
(
(
e
)
=>
{
.
catch
(
e
=>
{
this
.
messages
.
create
({
this
.
messages
.
create
({
'
message
'
:
__
(
"
Sorry, could not send the message due to an error.
"
)
+
`
${
e
.
message
}
`
,
'
message
'
:
__
(
"
Sorry, could not send the message due to an error.
"
)
+
`
${
e
.
message
}
`
,
'
type
'
:
'
error
'
,
'
type
'
:
'
error
'
,
});
});
converse
.
log
(
e
,
Strophe
.
LogLevel
.
ERROR
);
_
converse
.
log
(
e
,
Strophe
.
LogLevel
.
ERROR
);
});
});
}
else
{
}
else
{
...
@@ -527,7 +522,7 @@
...
@@ -527,7 +522,7 @@
},
},
getLocalRegistrationId
()
{
getLocalRegistrationId
()
{
return
Promise
.
resolve
(
this
.
get
(
'
device_id
'
));
return
Promise
.
resolve
(
parseInt
(
this
.
get
(
'
device_id
'
),
10
));
},
},
isTrustedIdentity
(
identifier
,
identity_key
,
direction
)
{
isTrustedIdentity
(
identifier
,
identity_key
,
direction
)
{
...
@@ -863,10 +858,8 @@
...
@@ -863,10 +858,8 @@
.
c
(
'
prekeys
'
);
.
c
(
'
prekeys
'
);
_
.
forEach
(
_
.
forEach
(
store
.
get
(
'
prekeys
'
).
slice
(
0
,
_converse
.
NUM_PREKEYS
),
store
.
get
(
'
prekeys
'
).
slice
(
0
,
_converse
.
NUM_PREKEYS
),
(
prekey
)
=>
{
(
prekey
)
=>
stanza
.
c
(
'
preKeyPublic
'
,
{
'
preKeyId
'
:
prekey
.
keyId
}).
t
(
prekey
.
keyPair
.
pubKey
).
up
()
stanza
.
c
(
'
preKeyPublic
'
,
{
'
preKeyId
'
:
prekey
.
keyId
})
);
.
t
(
prekey
.
keyPair
.
pubKey
).
up
();
});
return
_converse
.
api
.
sendIQ
(
stanza
);
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