File tree Expand file tree Collapse file tree 1 file changed +20
-17
lines changed Expand file tree Collapse file tree 1 file changed +20
-17
lines changed Original file line number Diff line number Diff line change @@ -259,23 +259,26 @@ export default class Phase {
259259 await _sodium . ready ;
260260 const sodium = _sodium ;
261261
262- try {
263- const oneTimeKeyPair = await randomKeyPair ( ) ;
264-
265- const symmetricKeys = await clientSessionKeys (
266- oneTimeKeyPair ,
267- sodium . from_hex ( this . appPubKey )
268- ) ;
269-
270- const ciphertext = await encryptString ( plaintext , symmetricKeys . sharedTx ) ;
271-
272- return `ph:${ PH_VERSION } :${ sodium . to_hex (
273- oneTimeKeyPair . publicKey
274- ) } :${ ciphertext } :${ tag } `;
275- } catch ( error ) {
276- console . log ( `Something went wrong: ${ error } ` ) ;
277- return undefined ;
278- }
262+ return new Promise < PhaseCiphertext > ( async ( resolve , reject ) => {
263+ try {
264+ const oneTimeKeyPair = await randomKeyPair ( ) ;
265+
266+ const symmetricKeys = await clientSessionKeys (
267+ oneTimeKeyPair ,
268+ sodium . from_hex ( this . appPubKey )
269+ ) ;
270+
271+ const ciphertext = await encryptString ( plaintext , symmetricKeys . sharedTx ) ;
272+
273+ resolve ( `ph:${ PH_VERSION } :${ sodium . to_hex (
274+ oneTimeKeyPair . publicKey
275+ ) } :${ ciphertext } :${ tag } `) ;
276+ } catch ( error ) {
277+ reject ( `Something went wrong: ${ error } ` )
278+ }
279+ } )
280+
281+
279282 } ;
280283
281284 decrypt = async ( phaseCiphertext : PhaseCiphertext ) : Promise < string > => {
You can’t perform that action at this time.
0 commit comments