Skip to content

Commit

Permalink
fix: key.toJWK() fixed on windows
Browse files Browse the repository at this point in the history
* ci: try different os builds
* fix: key.toJWK() fixed on windows

resolves #17
  • Loading branch information
panva authored Mar 19, 2019
1 parent 925d47c commit 57f1692
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ script: npm run coverage
after_script: npx codecov
jobs:
include:
- stage: macOS
os: osx
script: npm run coverage
node_js: stable
- stage: windows
os: windows
script: npm run coverage
node_js: node
- stage: Lint
script: npm run lint
node_js: stable
node_js: node
after_script: skip
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 57f1692

Please sign in to comment.