import 'node-forge/lib/rsa.js' ; import forge from 'node-forge/lib/forge.js' ; import { base64urlToBigInteger } from '../util' ; function convert ( key , types ) { return types . map ( t => base64urlToBigInteger ( key [ t ] ) ) ; } export function jwk2priv ( key ) { return forge . pki . setRsaPrivateKey ( ... convert ( key , [ 'n' , 'e' , 'd' , 'p' , 'q' , 'dp' , 'dq' , 'qi' ] ) ) ; } export function jwk2pub ( key ) { return forge . pki . setRsaPublicKey ( ... convert ( key , [ 'n' , 'e' ] ) ) ; }