Skip to content

Commit

Permalink
fix: key.toJWK() fixed on windows
Browse files Browse the repository at this point in the history
resolves #17
  • Loading branch information
panva committed Mar 19, 2019
1 parent be101a1 commit d27915d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/help/key_utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { EOL } = require('os')
const keyto = require('@trust/keyto')

const errors = require('../errors')
Expand All @@ -8,7 +9,12 @@ module.exports.keyObjectToJWK = (keyObject) => {
const type = keyObject.type === 'private' ? 'pkcs8' : 'spki'
const format = 'pem'

const pem = keyObject.export({ type, format })
let pem = keyObject.export({ type, format })

// keyObject export always uses \n but @trust/keyto splits based on the os.EOL
if (EOL !== '\n') {
pem = pem.replace(/\n/g, EOL)
}

return keyto.from(pem, 'pem').toJwk(keyObject.type)
}
Expand Down

0 comments on commit d27915d

Please sign in to comment.