@jsenv/https-local 2.1.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/package.json +12 -13
- package/src/{certificate_for_localhost.js → certificate_request.js} +2 -6
- package/src/main.js +1 -1
package/README.md
CHANGED
|
@@ -61,13 +61,13 @@ node ./install_certificate_authority.mjs
|
|
|
61
61
|
*
|
|
62
62
|
* > node ./install_certificate_authority.mjs
|
|
63
63
|
*
|
|
64
|
-
* Read more in https://github.com/jsenv/https-local#
|
|
64
|
+
* Read more in https://github.com/jsenv/https-local#requestCertificate
|
|
65
65
|
*/
|
|
66
66
|
|
|
67
67
|
import { createServer } from "node:https"
|
|
68
|
-
import {
|
|
68
|
+
import { requestCertificate } from "@jsenv/https-local"
|
|
69
69
|
|
|
70
|
-
const { certificate, privateKey } =
|
|
70
|
+
const { certificate, privateKey } = requestCertificate()
|
|
71
71
|
|
|
72
72
|
const server = createServer(
|
|
73
73
|
{
|
|
@@ -99,10 +99,10 @@ The rest of the documentation goes into details.
|
|
|
99
99
|
|
|
100
100
|
# Certificate expiration
|
|
101
101
|
|
|
102
|
-
| Certificate | Expires after | How to renew?
|
|
103
|
-
| ----------- | ------------- |
|
|
104
|
-
| server | 1 year | Re-run
|
|
105
|
-
| authority | 20 year | Re-run _installCertificateAuthority_
|
|
102
|
+
| Certificate | Expires after | How to renew? |
|
|
103
|
+
| ----------- | ------------- | ------------------------------------ |
|
|
104
|
+
| server | 1 year | Re-run _requestCertificate_ |
|
|
105
|
+
| authority | 20 year | Re-run _installCertificateAuthority_ |
|
|
106
106
|
|
|
107
107
|
The **server** certificate expires after one year which is the maximum duration allowed by web browsers. In the unlikely scenario where your local server is running for more than a year without interruption, restart it and you're good for one more year.
|
|
108
108
|
|
|
@@ -352,15 +352,15 @@ Check if certificate is trusted by firefox...
|
|
|
352
352
|
|
|
353
353
|
</details>
|
|
354
354
|
|
|
355
|
-
#
|
|
355
|
+
# requestCertificate
|
|
356
356
|
|
|
357
|
-
|
|
357
|
+
_requestCertificate_ function returns a certificate and private key that can be used to start a server in HTTPS.
|
|
358
358
|
|
|
359
359
|
```js
|
|
360
360
|
import { createServer } from "node:https"
|
|
361
|
-
import {
|
|
361
|
+
import { requestCertificate } from "@jsenv/https-local"
|
|
362
362
|
|
|
363
|
-
const { certificate, privateKey } =
|
|
363
|
+
const { certificate, privateKey } = requestCertificate({
|
|
364
364
|
altNames: ["localhost", "local.example"],
|
|
365
365
|
})
|
|
366
366
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/https-local",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "A programmatic way to generate locally trusted certificates",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
"url": "https://github.com/jsenv/https-local"
|
|
14
14
|
},
|
|
15
15
|
"publishConfig": {
|
|
16
|
-
"access": "public"
|
|
17
|
-
"registry": "https://registry.npmjs.org"
|
|
16
|
+
"access": "public"
|
|
18
17
|
},
|
|
19
18
|
"engines": {
|
|
20
19
|
"node": ">=16.13.0"
|
|
@@ -48,9 +47,9 @@
|
|
|
48
47
|
"playwright-install": "npx playwright install-deps && npx playwright install"
|
|
49
48
|
},
|
|
50
49
|
"dependencies": {
|
|
51
|
-
"@jsenv/filesystem": "4.1.
|
|
52
|
-
"@jsenv/log": "
|
|
53
|
-
"@jsenv/urls": "1.2.
|
|
50
|
+
"@jsenv/filesystem": "4.1.2",
|
|
51
|
+
"@jsenv/log": "3.1.0",
|
|
52
|
+
"@jsenv/urls": "1.2.7",
|
|
54
53
|
"command-exists": "1.2.9",
|
|
55
54
|
"node-forge": "1.3.1",
|
|
56
55
|
"sudo-prompt": "9.2.1",
|
|
@@ -58,15 +57,15 @@
|
|
|
58
57
|
},
|
|
59
58
|
"devDependencies": {
|
|
60
59
|
"@jsenv/assert": "2.6.0",
|
|
61
|
-
"@jsenv/core": "
|
|
62
|
-
"@jsenv/eslint-config": "16.
|
|
60
|
+
"@jsenv/core": "28.0.2",
|
|
61
|
+
"@jsenv/eslint-config": "16.2.1",
|
|
63
62
|
"@jsenv/eslint-import-resolver": "0.3.0",
|
|
64
|
-
"@jsenv/github-release-package": "1.
|
|
65
|
-
"@jsenv/package-publish": "1.
|
|
63
|
+
"@jsenv/github-release-package": "1.5.0",
|
|
64
|
+
"@jsenv/package-publish": "1.10.0",
|
|
66
65
|
"@jsenv/performance-impact": "2.3.0",
|
|
67
|
-
"eslint": "8.
|
|
66
|
+
"eslint": "8.21.0",
|
|
68
67
|
"eslint-plugin-import": "2.26.0",
|
|
69
|
-
"playwright": "1.
|
|
68
|
+
"playwright": "1.24.2",
|
|
70
69
|
"prettier": "2.7.1"
|
|
71
70
|
}
|
|
72
|
-
}
|
|
71
|
+
}
|
|
@@ -11,7 +11,7 @@ import { getAuthorityFileInfos } from "./internal/authority_file_infos.js"
|
|
|
11
11
|
import { requestCertificateFromAuthority } from "./internal/certificate_generator.js"
|
|
12
12
|
import { formatDuration } from "./internal/validity_formatting.js"
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const requestCertificate = ({
|
|
15
15
|
logLevel,
|
|
16
16
|
logger = createLogger({ logLevel }), // to be able to catch logs during unit tests
|
|
17
17
|
|
|
@@ -47,7 +47,7 @@ export const requestCertificateForLocalhost = ({
|
|
|
47
47
|
} = getAuthorityFileInfos()
|
|
48
48
|
if (!rootCertificateFileInfo.exists) {
|
|
49
49
|
throw new Error(
|
|
50
|
-
`Certificate authority not found, "installCertificateAuthority" must be called before "
|
|
50
|
+
`Certificate authority not found, "installCertificateAuthority" must be called before "requestServerCertificate"`,
|
|
51
51
|
)
|
|
52
52
|
}
|
|
53
53
|
if (!rootCertificatePrivateKeyFileInfo.exists) {
|
|
@@ -81,10 +81,6 @@ export const requestCertificateForLocalhost = ({
|
|
|
81
81
|
JSON.stringify({ serialNumber: serverCertificateSerialNumber }, null, " "),
|
|
82
82
|
)
|
|
83
83
|
|
|
84
|
-
if (!altNames.includes("localhost")) {
|
|
85
|
-
altNames.push("localhost")
|
|
86
|
-
}
|
|
87
|
-
|
|
88
84
|
logger.debug(`Generating server certificate...`)
|
|
89
85
|
const { certificateForgeObject, certificatePrivateKeyForgeObject } =
|
|
90
86
|
requestCertificateFromAuthority({
|
package/src/main.js
CHANGED