@jsenv/https-local 1.0.2 → 1.0.7
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 -8
- package/package.json +27 -33
- package/src/certificate_authority.js +68 -29
- package/src/certificate_for_localhost.js +25 -9
- package/src/hosts_file_verif.js +13 -6
- package/src/internal/authority_file_infos.js +9 -3
- package/src/internal/certificate_authority_file_urls.js +21 -5
- package/src/internal/certificate_data_converter.js +6 -2
- package/src/internal/certificate_generator.js +21 -7
- package/src/internal/command.js +2 -1
- package/src/internal/exec.js +4 -1
- package/src/internal/hosts/parse_hosts.js +15 -5
- package/src/internal/hosts/write_hosts.js +23 -11
- package/src/internal/hosts/write_line_hosts.js +28 -12
- package/src/internal/linux/chrome_linux.js +8 -2
- package/src/internal/linux/firefox_linux.js +8 -2
- package/src/internal/linux/linux_trust_store.js +41 -16
- package/src/internal/linux/nss_linux.js +10 -4
- package/src/internal/mac/firefox_mac.js +8 -2
- package/src/internal/mac/mac_keychain.js +29 -12
- package/src/internal/mac/nss_mac.js +14 -6
- package/src/internal/nssdb_browser.js +17 -10
- package/src/internal/search_certificate_in_command_output.js +4 -1
- package/src/internal/unsupported_platform/unsupported_platform.js +3 -1
- package/src/internal/validity_formatting.js +3 -1
- package/src/internal/windows/chrome_windows.js +12 -10
- package/src/internal/windows/firefox_windows.js +12 -10
- package/src/internal/windows/windows_certutil.js +38 -16
- package/src/validity_duration.js +7 -3
|
@@ -6,17 +6,31 @@
|
|
|
6
6
|
import { createDetailedMessage } from "@jsenv/logger"
|
|
7
7
|
import { urlToFileSystemPath } from "@jsenv/filesystem"
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
commandSign,
|
|
11
|
+
okSign,
|
|
12
|
+
infoSign,
|
|
13
|
+
failureSign,
|
|
14
|
+
} from "@jsenv/https-local/src/internal/logs.js"
|
|
10
15
|
import { exec } from "@jsenv/https-local/src/internal/exec.js"
|
|
11
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
VERB_CHECK_TRUST,
|
|
18
|
+
VERB_ADD_TRUST,
|
|
19
|
+
VERB_REMOVE_TRUST,
|
|
20
|
+
} from "../trust_query.js"
|
|
12
21
|
|
|
13
|
-
const REASON_NEW_AND_TRY_TO_TRUST_DISABLED =
|
|
22
|
+
const REASON_NEW_AND_TRY_TO_TRUST_DISABLED =
|
|
23
|
+
"certificate is new and tryToTrust is disabled"
|
|
14
24
|
const REASON_NOT_FOUND_IN_WINDOWS = "not found in windows store"
|
|
15
25
|
const REASON_FOUND_IN_WINDOWS = "found in windows store"
|
|
16
|
-
const REASON_ADD_COMMAND_FAILED =
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
26
|
+
const REASON_ADD_COMMAND_FAILED =
|
|
27
|
+
"command to add certificate to windows store failed"
|
|
28
|
+
const REASON_ADD_COMMAND_COMPLETED =
|
|
29
|
+
"command to add certificate to windows store completed"
|
|
30
|
+
const REASON_DELETE_COMMAND_FAILED =
|
|
31
|
+
"command to remove certificate from windows store failed"
|
|
32
|
+
const REASON_DELETE_COMMAND_COMPLETED =
|
|
33
|
+
"command to remove certificate from windows store completed"
|
|
20
34
|
|
|
21
35
|
export const executeTrustQueryOnWindows = async ({
|
|
22
36
|
logger,
|
|
@@ -44,7 +58,9 @@ export const executeTrustQueryOnWindows = async ({
|
|
|
44
58
|
|
|
45
59
|
// it's not super accurate and do not take into account if the cert is different
|
|
46
60
|
// but it's the best I could do with certutil command on windows
|
|
47
|
-
const certificateInStore = certutilListCommandOutput.includes(
|
|
61
|
+
const certificateInStore = certutilListCommandOutput.includes(
|
|
62
|
+
certificateCommonName,
|
|
63
|
+
)
|
|
48
64
|
if (!certificateInStore) {
|
|
49
65
|
logger.info(`${infoSign} certificate not found in windows`)
|
|
50
66
|
if (verb === VERB_CHECK_TRUST || verb === VERB_REMOVE_TRUST) {
|
|
@@ -67,10 +83,13 @@ export const executeTrustQueryOnWindows = async ({
|
|
|
67
83
|
}
|
|
68
84
|
} catch (e) {
|
|
69
85
|
logger.error(
|
|
70
|
-
createDetailedMessage(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
86
|
+
createDetailedMessage(
|
|
87
|
+
`${failureSign} Failed to add certificate to windows`,
|
|
88
|
+
{
|
|
89
|
+
"error stack": e.stack,
|
|
90
|
+
"certificate file": certificateFilePath,
|
|
91
|
+
},
|
|
92
|
+
),
|
|
74
93
|
)
|
|
75
94
|
return {
|
|
76
95
|
status: "not_trusted",
|
|
@@ -100,10 +119,13 @@ export const executeTrustQueryOnWindows = async ({
|
|
|
100
119
|
}
|
|
101
120
|
} catch (e) {
|
|
102
121
|
logger.error(
|
|
103
|
-
createDetailedMessage(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
122
|
+
createDetailedMessage(
|
|
123
|
+
`${failureSign} failed to remove certificate from windows`,
|
|
124
|
+
{
|
|
125
|
+
"error stack": e.stack,
|
|
126
|
+
"certificate file": certificateFilePath,
|
|
127
|
+
},
|
|
128
|
+
),
|
|
107
129
|
)
|
|
108
130
|
return {
|
|
109
131
|
status: "unknown", // maybe it was not trusted?
|
package/src/validity_duration.js
CHANGED
|
@@ -17,7 +17,9 @@ export const verifyRootCertificateValidityDuration = (validityDurationInMs) => {
|
|
|
17
17
|
return { ok: true }
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export const verifyServerCertificateValidityDuration = (
|
|
20
|
+
export const verifyServerCertificateValidityDuration = (
|
|
21
|
+
serverCertificateValidityDurationInMs,
|
|
22
|
+
) => {
|
|
21
23
|
const serverCertificateValidityDurationInDays =
|
|
22
24
|
serverCertificateValidityDurationInMs / MILLISECONDS_PER_DAY
|
|
23
25
|
|
|
@@ -34,6 +36,8 @@ export const verifyServerCertificateValidityDuration = (serverCertificateValidit
|
|
|
34
36
|
return { ok: true }
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
export const createValidityDurationOfXYears = (years) =>
|
|
39
|
+
export const createValidityDurationOfXYears = (years) =>
|
|
40
|
+
MILLISECONDS_PER_YEAR * years + 5000
|
|
38
41
|
|
|
39
|
-
export const createValidityDurationOfXDays = (days) =>
|
|
42
|
+
export const createValidityDurationOfXDays = (days) =>
|
|
43
|
+
MILLISECONDS_PER_DAY * days + 5000
|