import { combine } from '@typed/effects' ; import { arrayBufferToString , CryptoEffects , ExportedKeyPair , JsonWebKeyPair } from '../common' ; import { importKey } from '../effects/subtle' ; export function * importExportedKeyPair ( params , keyPair ) { const jsonWebKeyPair = { publicKey : JSON . parse ( arrayBufferToString ( keyPair . publicKey ) ) , privateKey : JSON . parse ( arrayBufferToString ( keyPair . privateKey ) ) , } ; const [ publicKey , privateKey ] = yield * combine ( importKey ( 'jwk' , jsonWebKeyPair . publicKey , params , false , jsonWebKeyPair . publicKey . key_ops || [ ] ) , importKey ( 'jwk' , jsonWebKeyPair . privateKey , params , false , jsonWebKeyPair . privateKey . key_ops || [ ] ) ) ; return { publicKey , privateKey , } ; }