@@ -5,7 +5,6 @@ const sanitize = require('sanitize-filename')
55const mergeOptions = require ( 'merge-options' )
66const crypto = require ( 'libp2p-crypto' )
77const DS = require ( 'interface-datastore' )
8- const promisify = require ( 'promisify-es6' )
98const CMS = require ( './cms' )
109const errcode = require ( 'err-code' )
1110
@@ -206,16 +205,9 @@ class Keychain {
206205
207206 let keyInfo
208207 try {
209- const keypair = await promisify ( crypto . keys . generateKeyPair , {
210- context : crypto . keys
211- } ) ( type , size )
212-
213- const kid = await promisify ( keypair . id , {
214- context : keypair
215- } ) ( )
216- const pem = await promisify ( keypair . export , {
217- context : keypair
218- } ) ( this . _ ( ) )
208+ const keypair = await crypto . keys . generateKeyPair ( type , size )
209+ const kid = await keypair . id ( )
210+ const pem = await keypair . export ( this . _ ( ) )
219211 keyInfo = {
220212 name : name ,
221213 id : kid
@@ -367,12 +359,8 @@ class Keychain {
367359 try {
368360 const res = await this . store . get ( dsname )
369361 const pem = res . toString ( )
370- const privateKey = await promisify ( crypto . keys . import , {
371- context : crypto . keys
372- } ) ( pem , this . _ ( ) )
373- return promisify ( privateKey . export , {
374- context : privateKey
375- } ) ( password )
362+ const privateKey = await crypto . keys . import ( pem , this . _ ( ) )
363+ return privateKey . export ( password )
376364 } catch ( err ) {
377365 return throwDelayed ( err )
378366 }
@@ -400,21 +388,15 @@ class Keychain {
400388
401389 let privateKey
402390 try {
403- privateKey = await promisify ( crypto . keys . import , {
404- context : crypto . keys
405- } ) ( pem , password )
391+ privateKey = await crypto . keys . import ( pem , password )
406392 } catch ( err ) {
407393 return throwDelayed ( errcode ( new Error ( 'Cannot read the key, most likely the password is wrong' ) , 'ERR_CANNOT_READ_KEY' ) )
408394 }
409395
410396 let kid
411397 try {
412- kid = await promisify ( privateKey . id , {
413- context : privateKey
414- } ) ( )
415- pem = await promisify ( privateKey . export , {
416- context : privateKey
417- } ) ( this . _ ( ) )
398+ kid = await privateKey . id ( )
399+ pem = await privateKey . export ( this . _ ( ) )
418400 } catch ( err ) {
419401 return throwDelayed ( err )
420402 }
@@ -446,12 +428,8 @@ class Keychain {
446428 if ( exists ) return throwDelayed ( errcode ( new Error ( `Key '${ name } ' already exists` ) , 'ERR_KEY_ALREADY_EXISTS' ) )
447429
448430 try {
449- const kid = await promisify ( privateKey . id , {
450- context : privateKey
451- } ) ( )
452- const pem = await promisify ( privateKey . export , {
453- context : privateKey
454- } ) ( this . _ ( ) )
431+ const kid = await privateKey . id ( )
432+ const pem = await privateKey . export ( this . _ ( ) )
455433 const keyInfo = {
456434 name : name ,
457435 id : kid
0 commit comments