@jsenv/https-local 3.1.1 → 3.2.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/https-local",
3
- "version": "3.1.1",
3
+ "version": "3.2.1",
4
4
  "description": "A programmatic way to generate locally trusted certificates",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -326,13 +326,13 @@ export const uninstallCertificateAuthority = async ({
326
326
  const rootCertificateCommonName = attributeDescriptionFromAttributeArray(
327
327
  rootCertificateForgeObject.subject.attributes,
328
328
  ).commonName;
329
- const { removeCertificateFromTrustStores } =
330
- await importPlatformMethods();
331
- await removeCertificateFromTrustStores({
329
+ const platformMethods = await importPlatformMethods();
330
+ await platformMethods.executeTrustQuery({
332
331
  logger,
333
- certificate: rootCertificate,
334
- certificateFileUrl: rootCertificateFileInfo.url,
335
332
  certificateCommonName: rootCertificateCommonName,
333
+ certificateFileUrl: rootCertificateFileInfo.url,
334
+ certificate: rootCertificate,
335
+ verb: "REMOVE_TRUST",
336
336
  });
337
337
  }
338
338
  filesToRemove.push(rootCertificateFileInfo.url);
@@ -25,6 +25,9 @@ if (values.help || positionals.length === 0) {
25
25
 
26
26
  Usage:
27
27
 
28
+ npx @jsenv/https-local setup
29
+ Install root certificate, try to trust it and ensure localhost is mapped to 127.0.0.1
30
+
28
31
  npx @jsenv/https-local install --trust
29
32
  Install root certificate on the filesystem
30
33
  - trust: Try to add root certificate to os and browser trusted stores.
@@ -43,10 +46,22 @@ https://github.com/jsenv/core/tree/main/packages/independent/https-local
43
46
  }
44
47
 
45
48
  const commandHandlers = {
46
- install: async ({ tryToTrust }) => {
49
+ setup: async () => {
50
+ await installCertificateAuthority({
51
+ tryToTrust: true,
52
+ NSSDynamicInstall: true,
53
+ });
54
+ await verifyHostsFile({
55
+ ipMappings: {
56
+ "127.0.0.1": ["localhost"],
57
+ },
58
+ tryToUpdatesHostsFile: true,
59
+ });
60
+ },
61
+ install: async ({ trust }) => {
47
62
  await installCertificateAuthority({
48
- tryToTrust,
49
- NSSDynamicInstall: tryToTrust,
63
+ tryToTrust: trust,
64
+ NSSDynamicInstall: trust,
50
65
  });
51
66
  },
52
67
  uninstall: async () => {