@idearium/certs
Advanced tools
Comparing version 2.0.0-beta.3 to 2.0.0-beta.4
@@ -5,2 +5,8 @@ # @idearium/certs | ||
## v2.0.0-beta.4 - 2023-03-10 | ||
### Fixed | ||
- Fixed an issue when loading real files. | ||
## v2.0.0-beta.3 - 2023-03-10 | ||
@@ -7,0 +13,0 @@ |
20
index.js
@@ -25,11 +25,17 @@ 'use strict'; | ||
const results = {}; | ||
await Promise.all( | ||
certPaths.map((file) => | ||
fs.readFile(file, 'utf8', (readErr, cert) => { | ||
if (readErr) { | ||
throw readErr; | ||
} | ||
certPaths.map( | ||
(file) => | ||
new Promise((resolve, reject) => { | ||
fs.readFile(file, 'utf8', (readErr, cert) => { | ||
if (readErr) { | ||
reject(readErr); | ||
} | ||
results[file] = cert; | ||
}) | ||
results[file] = cert; | ||
resolve(); | ||
}); | ||
}) | ||
) | ||
@@ -36,0 +42,0 @@ ); |
{ | ||
"name": "@idearium/certs", | ||
"version": "2.0.0-beta.3", | ||
"version": "2.0.0-beta.4", | ||
"description": "A package to load custom and OS certificates into Node.js.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -85,2 +85,44 @@ 'use strict'; | ||
it('supports files with periods in the name', async () => { | ||
require('fs').__setMockFiles({ | ||
'/ssl/ca/first.ca.crt': 'ssl-ca-first-content', | ||
'/ssl/ca/second.ca.crt': 'ssl-ca-second-content', | ||
'/ssl/mq.common.crt': 'ssl-mq-common-crt-data', | ||
'/ssl/mq.common.key': 'ssl-mq-common-key-data', | ||
}); | ||
const certs = await loadCerts(); | ||
expect(certs).toHaveProperty('ca', [ | ||
'ssl-ca-first-content', | ||
'ssl-ca-second-content', | ||
]); | ||
expect(certs).toHaveProperty('certs', { | ||
'mq.common': { | ||
crt: 'ssl-mq-common-crt-data', | ||
key: 'ssl-mq-common-key-data', | ||
}, | ||
}); | ||
}); | ||
it('supports nested directories', async () => { | ||
require('fs').__setMockFiles({ | ||
'/ssl/local/ca/first.ca.crt': 'ssl-local-ca-first-content', | ||
'/ssl/local/ca/second.ca.crt': 'ssl-local-ca-second-content', | ||
'/ssl/local/mq.common.crt': 'ssl-local-mq-common-crt-data', | ||
'/ssl/local/mq.common.key': 'ssl-local-mq-common-key-data', | ||
}); | ||
const certs = await loadCerts('/ssl/local'); | ||
expect(certs).toHaveProperty('ca', [ | ||
'ssl-local-ca-first-content', | ||
'ssl-local-ca-second-content', | ||
]); | ||
expect(certs).toHaveProperty('certs', { | ||
'mq.common': { | ||
crt: 'ssl-local-mq-common-crt-data', | ||
key: 'ssl-local-mq-common-key-data', | ||
}, | ||
}); | ||
}); | ||
it('will load OS provided certs', async () => { | ||
@@ -87,0 +129,0 @@ require('fs').__setMockFiles({ |
11100
278
8