Skip to content

Commit 57f1692

Browse files
authoredMar 19, 2019
fix: key.toJWK() fixed on windows
* ci: try different os builds * fix: key.toJWK() fixed on windows resolves #17
1 parent 925d47c commit 57f1692

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed
 

‎.travis.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@ script: npm run coverage
66
after_script: npx codecov
77
jobs:
88
include:
9+
- stage: macOS
10+
os: osx
11+
script: npm run coverage
12+
node_js: stable
13+
- stage: windows
14+
os: windows
15+
script: npm run coverage
16+
node_js: node
917
- stage: Lint
1018
script: npm run lint
11-
node_js: stable
19+
node_js: node
1220
after_script: skip

‎lib/help/key_utils.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { EOL } = require('os')
12
const keyto = require('@trust/keyto')
23

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

11-
const pem = keyObject.export({ type, format })
12+
let pem = keyObject.export({ type, format })
13+
14+
// keyObject export always uses \n but @trust/keyto splits based on the os.EOL
15+
if (EOL !== '\n') {
16+
pem = pem.replace(/\n/g, EOL)
17+
}
1218

1319
return keyto.from(pem, 'pem').toJwk(keyObject.type)
1420
}

0 commit comments

Comments
 (0)