@knapsack/app 4.81.0--canary.6078.6bf07c6.0 → 4.81.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +270 -0
  2. package/dist/cli/commands.d.ts +12 -5
  3. package/dist/cli/commands.d.ts.map +1 -1
  4. package/dist/cli/commands.js +53 -63
  5. package/dist/cli/commands.js.map +1 -1
  6. package/dist/cli/knapsack-cli.js +190 -153
  7. package/dist/cli/knapsack-cli.js.map +1 -1
  8. package/dist/cli/log.d.ts +2 -1
  9. package/dist/cli/log.d.ts.map +1 -1
  10. package/dist/cli/log.js +48 -1
  11. package/dist/cli/log.js.map +1 -1
  12. package/dist/db.d.ts.map +1 -1
  13. package/dist/db.js +11 -1
  14. package/dist/db.js.map +1 -1
  15. package/dist/domains/patterns/patterns.d.ts.map +1 -1
  16. package/dist/domains/patterns/patterns.js +2 -84
  17. package/dist/domains/patterns/patterns.js.map +1 -1
  18. package/dist/domains/patterns/renderers/renderer-base.d.ts +1 -5
  19. package/dist/domains/patterns/renderers/renderer-base.d.ts.map +1 -1
  20. package/dist/domains/patterns/renderers/renderer-base.js.map +1 -1
  21. package/dist/lib/bootstrap.d.ts +3 -2
  22. package/dist/lib/bootstrap.d.ts.map +1 -1
  23. package/dist/lib/bootstrap.js +23 -15
  24. package/dist/lib/bootstrap.js.map +1 -1
  25. package/dist/lib/config.d.ts +2 -1
  26. package/dist/lib/config.d.ts.map +1 -1
  27. package/dist/lib/config.js +36 -13
  28. package/dist/lib/config.js.map +1 -1
  29. package/dist/lib/constants.d.ts +4 -0
  30. package/dist/lib/constants.d.ts.map +1 -1
  31. package/dist/lib/constants.js +7 -1
  32. package/dist/lib/constants.js.map +1 -1
  33. package/dist/lib/https-cert/constants.d.ts +13 -0
  34. package/dist/lib/https-cert/constants.d.ts.map +1 -0
  35. package/dist/lib/https-cert/constants.js +44 -0
  36. package/dist/lib/https-cert/constants.js.map +1 -0
  37. package/dist/lib/https-cert/index.d.ts +9 -0
  38. package/dist/lib/https-cert/index.d.ts.map +1 -0
  39. package/dist/lib/https-cert/index.js +12 -0
  40. package/dist/lib/https-cert/index.js.map +1 -0
  41. package/dist/lib/https-cert/lib/auto-encrypt-localhost.d.ts +3 -0
  42. package/dist/lib/https-cert/lib/auto-encrypt-localhost.d.ts.map +1 -0
  43. package/dist/lib/https-cert/lib/auto-encrypt-localhost.js +87 -0
  44. package/dist/lib/https-cert/lib/auto-encrypt-localhost.js.map +1 -0
  45. package/dist/lib/https-cert/lib/get-ssl-cert.d.ts +7 -0
  46. package/dist/lib/https-cert/lib/get-ssl-cert.d.ts.map +1 -0
  47. package/dist/lib/https-cert/lib/get-ssl-cert.js +32 -0
  48. package/dist/lib/https-cert/lib/get-ssl-cert.js.map +1 -0
  49. package/dist/lib/https-cert/lib/install-cert-util.d.ts +2 -0
  50. package/dist/lib/https-cert/lib/install-cert-util.d.ts.map +1 -0
  51. package/dist/lib/https-cert/lib/install-cert-util.js +133 -0
  52. package/dist/lib/https-cert/lib/install-cert-util.js.map +1 -0
  53. package/dist/lib/https-cert/lib/pre-install-mkcert.d.ts +2 -0
  54. package/dist/lib/https-cert/lib/pre-install-mkcert.d.ts.map +1 -0
  55. package/dist/lib/https-cert/lib/pre-install-mkcert.js +66 -0
  56. package/dist/lib/https-cert/lib/pre-install-mkcert.js.map +1 -0
  57. package/dist/lib/https-cert/lib/setup-local-cert-auth.d.ts +6 -0
  58. package/dist/lib/https-cert/lib/setup-local-cert-auth.d.ts.map +1 -0
  59. package/dist/lib/https-cert/lib/setup-local-cert-auth.js +35 -0
  60. package/dist/lib/https-cert/lib/setup-local-cert-auth.js.map +1 -0
  61. package/dist/lib/https-cert/log.d.ts +2 -0
  62. package/dist/lib/https-cert/log.d.ts.map +1 -0
  63. package/dist/lib/https-cert/log.js +6 -0
  64. package/dist/lib/https-cert/log.js.map +1 -0
  65. package/dist/lib/https-cert/types.d.ts +5 -0
  66. package/dist/lib/https-cert/types.d.ts.map +1 -0
  67. package/dist/lib/https-cert/types.js +3 -0
  68. package/dist/lib/https-cert/types.js.map +1 -0
  69. package/dist/lib/util/cache-dir.d.ts +46 -1
  70. package/dist/lib/util/cache-dir.d.ts.map +1 -1
  71. package/dist/lib/util/cache-dir.js +17 -2
  72. package/dist/lib/util/cache-dir.js.map +1 -1
  73. package/dist/server/rest-api.d.ts.map +1 -1
  74. package/dist/server/rest-api.js +76 -42
  75. package/dist/server/rest-api.js.map +1 -1
  76. package/dist/server/server.d.ts +5 -1
  77. package/dist/server/server.d.ts.map +1 -1
  78. package/dist/server/server.js +37 -26
  79. package/dist/server/server.js.map +1 -1
  80. package/dist/types/endpoints.d.ts +7 -1
  81. package/dist/types/endpoints.d.ts.map +1 -1
  82. package/dist/types/knapsack-config.d.ts +11 -3
  83. package/dist/types/knapsack-config.d.ts.map +1 -1
  84. package/package.json +19 -22
@@ -0,0 +1,13 @@
1
+ /** the mkcert binary version */
2
+ export declare const version = "1.4.4";
3
+ /** the mkcert binary name. Falls back to using linux + x64 if we somehow run across an unknown / unsupported system. */
4
+ export declare const binaryName: string;
5
+ /** the path to the folder containing any SSL certs + binary downloaded */
6
+ export declare const settingsPath: string;
7
+ type MkCertOpts = {
8
+ name: string;
9
+ env: NodeJS.Process['env'];
10
+ };
11
+ export declare const mkcertProcessOptions: MkCertOpts;
12
+ export {};
13
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/https-cert/constants.ts"],"names":[],"mappings":"AAKA,gCAAgC;AAEhC,eAAO,MAAM,OAAO,UAAU,CAAC;AAiC/B,wHAAwH;AACxH,eAAO,MAAM,UAAU,QAIrB,CAAC;AAEH,0EAA0E;AAC1E,eAAO,MAAM,YAAY,QAIxB,CAAC;AAGF,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,UAGlC,CAAC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.mkcertProcessOptions = exports.settingsPath = exports.binaryName = exports.version = void 0;
7
+ const os_1 = __importDefault(require("os"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const utils_1 = require("@knapsack/utils");
10
+ const log_1 = require("./log");
11
+ /** the mkcert binary version */
12
+ // @todo: is it worth having some logic here to help keep this version # up to date?
13
+ exports.version = '1.4.4';
14
+ const platformMap = {
15
+ linux: 'linux',
16
+ darwin: 'darwin',
17
+ win32: 'windows',
18
+ };
19
+ const architectureMap = {
20
+ arm: 'arm',
21
+ arm64: 'arm64',
22
+ x64: 'amd64',
23
+ };
24
+ const plat = os_1.default.platform();
25
+ const platform = (0, utils_1.isObjKey)(plat, platformMap) ? platformMap[plat] : undefined;
26
+ const arch = os_1.default.arch();
27
+ const architecture = (0, utils_1.isObjKey)(arch, architectureMap)
28
+ ? architectureMap[arch]
29
+ : undefined;
30
+ if (platform === undefined) {
31
+ log_1.log.warn(`Automatic HTTPS support for the ${plat} platform is unsupported...`);
32
+ }
33
+ if (architecture === undefined) {
34
+ log_1.log.warn(`Automatic HTTPS support for the ${arch} architecture is unsupported...`);
35
+ }
36
+ /** the mkcert binary name. Falls back to using linux + x64 if we somehow run across an unknown / unsupported system. */
37
+ exports.binaryName = `mkcert-v${exports.version}-${platform || platformMap.linux}-${architecture || architectureMap.x64}${platform === 'windows' ? '.exe' : ''}`;
38
+ /** the path to the folder containing any SSL certs + binary downloaded */
39
+ exports.settingsPath = path_1.default.join(os_1.default.homedir(), '.knapsack.cloud', 'auto-encrypt-localhost');
40
+ exports.mkcertProcessOptions = {
41
+ name: 'Knapsack dev server is configuring local HTTPS',
42
+ env: { ...process.env, CAROOT: exports.settingsPath },
43
+ };
44
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/https-cert/constants.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,2CAA2C;AAC3C,+BAA4B;AAE5B,gCAAgC;AAChC,oFAAoF;AACvE,QAAA,OAAO,GAAG,OAAO,CAAC;AAE/B,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,SAAS;CACjB,CAAC;AAEF,MAAM,eAAe,GAAG;IACtB,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,OAAO;CACb,CAAC;AAEF,MAAM,IAAI,GAAG,YAAE,CAAC,QAAQ,EAAE,CAAC;AAC3B,MAAM,QAAQ,GAAG,IAAA,gBAAQ,EAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7E,MAAM,IAAI,GAAG,YAAE,CAAC,IAAI,EAAE,CAAC;AACvB,MAAM,YAAY,GAAG,IAAA,gBAAQ,EAAC,IAAI,EAAE,eAAe,CAAC;IAClD,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC;IACvB,CAAC,CAAC,SAAS,CAAC;AAEd,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;IAC3B,SAAG,CAAC,IAAI,CACN,mCAAmC,IAAI,6BAA6B,CACrE,CAAC;AACJ,CAAC;AAED,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;IAC/B,SAAG,CAAC,IAAI,CACN,mCAAmC,IAAI,iCAAiC,CACzE,CAAC;AACJ,CAAC;AAED,wHAAwH;AAC3G,QAAA,UAAU,GAAG,WAAW,eAAO,IAC1C,QAAQ,IAAI,WAAW,CAAC,KAC1B,IAAI,YAAY,IAAI,eAAe,CAAC,GAAG,GACrC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EACpC,EAAE,CAAC;AAEH,0EAA0E;AAC7D,QAAA,YAAY,GAAG,cAAI,CAAC,IAAI,CACnC,YAAE,CAAC,OAAO,EAAE,EACZ,iBAAiB,EACjB,wBAAwB,CACzB,CAAC;AAQW,QAAA,oBAAoB,GAAe;IAC9C,IAAI,EAAE,gDAAgD;IACtD,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,oBAAY,EAAE;CAC9C,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Automatically provisions and installs locally-trusted TLS certificates for Node.js® https servers
3
+ * (including Express.js, etc.) using mkcert.
4
+ *
5
+ * Based originally on @small-tech/auto-encrypt-localhost with major modifications
6
+ */
7
+ export { getAutoGeneratedSSLCert } from './lib/get-ssl-cert';
8
+ export type { SslCert } from './types';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/https-cert/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ /**
3
+ * Automatically provisions and installs locally-trusted TLS certificates for Node.js® https servers
4
+ * (including Express.js, etc.) using mkcert.
5
+ *
6
+ * Based originally on @small-tech/auto-encrypt-localhost with major modifications
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.getAutoGeneratedSSLCert = void 0;
10
+ var get_ssl_cert_1 = require("./lib/get-ssl-cert");
11
+ Object.defineProperty(exports, "getAutoGeneratedSSLCert", { enumerable: true, get: function () { return get_ssl_cert_1.getAutoGeneratedSSLCert; } });
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/https-cert/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,mDAA6D;AAApD,uHAAA,uBAAuB,OAAA"}
@@ -0,0 +1,3 @@
1
+ import type { SslCert } from '../types';
2
+ export declare function setupAndGetCert(): Promise<null | SslCert>;
3
+ //# sourceMappingURL=auto-encrypt-localhost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-encrypt-localhost.d.ts","sourceRoot":"","sources":["../../../../src/lib/https-cert/lib/auto-encrypt-localhost.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGxC,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,CAmG/D"}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.setupAndGetCert = setupAndGetCert;
7
+ const os_1 = __importDefault(require("os"));
8
+ const fs_extra_1 = __importDefault(require("fs-extra"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const child_process_1 = __importDefault(require("child_process"));
11
+ const log_1 = require("../log");
12
+ const install_cert_util_1 = require("./install-cert-util");
13
+ const constants_1 = require("../constants");
14
+ const setup_local_cert_auth_1 = require("./setup-local-cert-auth");
15
+ const pre_install_mkcert_1 = require("./pre-install-mkcert");
16
+ async function setupAndGetCert() {
17
+ const mkcertBinary = path_1.default.join(constants_1.settingsPath, constants_1.binaryName);
18
+ const keyFilePath = path_1.default.join(constants_1.settingsPath, 'localhost-key.pem');
19
+ const certFilePath = path_1.default.join(constants_1.settingsPath, 'localhost.pem');
20
+ const rootCAKeyFilePath = path_1.default.join(constants_1.settingsPath, 'rootCA-key.pem');
21
+ const rootCACertFilePath = path_1.default.join(constants_1.settingsPath, 'rootCA.pem');
22
+ // if we failed to get the mkcert file downloaded by this point, exit early
23
+ // @todo: add even more CLI logging for each of these use cases
24
+ await (0, pre_install_mkcert_1.preInstallMkCert)();
25
+ if (!fs_extra_1.default.existsSync(mkcertBinary)) {
26
+ throw new Error(`Failed to download mkcert binary to ${mkcertBinary}`);
27
+ }
28
+ const mkcertBinarySize = fs_extra_1.default.statSync(mkcertBinary);
29
+ // exit early if the mkcert file size is 0 bytes (a bad download)
30
+ if (mkcertBinarySize.size === 0)
31
+ return null;
32
+ function allOK() {
33
+ return (fs_extra_1.default.existsSync(rootCACertFilePath) &&
34
+ fs_extra_1.default.existsSync(rootCAKeyFilePath) &&
35
+ fs_extra_1.default.existsSync(certFilePath) &&
36
+ fs_extra_1.default.existsSync(keyFilePath));
37
+ }
38
+ // Create certificates.
39
+ if (!allOK()) {
40
+ log_1.log.info('❨auto-encrypt-localhost❩ Setting up…');
41
+ // On Linux and on macOS, mkcert uses the Mozilla nss library.
42
+ // Try to install this automatically and warn the person if we can’t so
43
+ // that they can do it manually themselves.
44
+ (0, install_cert_util_1.installCertutil)();
45
+ // Create the local certificate.
46
+ log_1.log.info('❨auto-encrypt-localhost❩ Creating local TLS certificates using mkcert…');
47
+ // Support all local interfaces so that the machine can be reached over the local network via IPv4.
48
+ // This is very useful for testing with multiple devices over the local area network without needing to expose
49
+ // the machine over the wide area network/Internet using a service like ngrok.
50
+ const localIPv4Addresses = Object.entries(os_1.default.networkInterfaces())
51
+ .map((iface) => {
52
+ var _a;
53
+ return (_a = iface[1]) === null || _a === void 0 ? void 0 : _a.filter((addresses) => addresses.family === 'IPv4').map((addresses) => addresses.address);
54
+ })
55
+ .flat();
56
+ const certificateDetails = [
57
+ `-key-file=${keyFilePath}`,
58
+ `-cert-file=${certFilePath}`,
59
+ 'localhost',
60
+ ].concat(localIPv4Addresses.filter((address) => address !== undefined));
61
+ child_process_1.default.execFileSync(mkcertBinary, certificateDetails, constants_1.mkcertProcessOptions);
62
+ log_1.log.info(' 📜 ❨auto-encrypt-localhost❩ Local TLS certificates created.');
63
+ await (0, setup_local_cert_auth_1.setupLocalCertAuthority)({
64
+ certFilePath,
65
+ keyFilePath,
66
+ mkcertBinary,
67
+ });
68
+ if (rootCACertFilePath) {
69
+ const syswidecas = await import('syswide-cas');
70
+ await syswidecas.addCAs(rootCACertFilePath);
71
+ }
72
+ if (!allOK()) {
73
+ throw new Error('Ran into an unexpected issue setting up HTTPS. Exiting early');
74
+ }
75
+ // Add root store to Node to ensure Node recognises the certificates (e.g., when using https.get(), etc.)
76
+ return {
77
+ key: fs_extra_1.default.readFileSync(keyFilePath, 'utf-8'),
78
+ cert: fs_extra_1.default.readFileSync(certFilePath, 'utf-8'),
79
+ };
80
+ }
81
+ log_1.log.info('❨auto-encrypt-localhost❩ Local development TLS certificate exists.');
82
+ return {
83
+ key: fs_extra_1.default.readFileSync(keyFilePath, 'utf-8'),
84
+ cert: fs_extra_1.default.readFileSync(certFilePath, 'utf-8'),
85
+ };
86
+ }
87
+ //# sourceMappingURL=auto-encrypt-localhost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-encrypt-localhost.js","sourceRoot":"","sources":["../../../../src/lib/https-cert/lib/auto-encrypt-localhost.ts"],"names":[],"mappings":";;;;;AAWA,0CAmGC;AA9GD,4CAAoB;AACpB,wDAA0B;AAC1B,gDAAwB;AACxB,kEAAyC;AACzC,gCAA6B;AAC7B,2DAAsD;AACtD,4CAA8E;AAC9E,mEAAkE;AAElE,6DAAwD;AAEjD,KAAK,UAAU,eAAe;IACnC,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,wBAAY,EAAE,sBAAU,CAAC,CAAC;IACzD,MAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,wBAAY,EAAE,mBAAmB,CAAC,CAAC;IACjE,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,wBAAY,EAAE,eAAe,CAAC,CA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,YAAY,EAAE,OAAO,CAAC;KAC7C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { SslCert } from '../types';
2
+ /**
3
+ * Auto-generates SSL certs using mkcert
4
+ * Will reuse certs this function has generated before if they already exist
5
+ */
6
+ export declare function getAutoGeneratedSSLCert(): Promise<SslCert>;
7
+ //# sourceMappingURL=get-ssl-cert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-ssl-cert.d.ts","sourceRoot":"","sources":["../../../../src/lib/https-cert/lib/get-ssl-cert.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAMxC;;;GAGG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,OAAO,CAAC,CAgBhE"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAutoGeneratedSSLCert = getAutoGeneratedSSLCert;
4
+ const file_utils_1 = require("@knapsack/file-utils");
5
+ const path_1 = require("path");
6
+ const auto_encrypt_localhost_1 = require("./auto-encrypt-localhost");
7
+ const constants_1 = require("../constants");
8
+ const keyFilePath = (0, path_1.join)(constants_1.settingsPath, 'localhost-key.pem');
9
+ const certFilePath = (0, path_1.join)(constants_1.settingsPath, 'localhost.pem');
10
+ /**
11
+ * Auto-generates SSL certs using mkcert
12
+ * Will reuse certs this function has generated before if they already exist
13
+ */
14
+ async function getAutoGeneratedSSLCert() {
15
+ // try to reuse existing SSL certs if they already exist
16
+ try {
17
+ const [key, cert] = await Promise.all([
18
+ (0, file_utils_1.readFile)(keyFilePath),
19
+ (0, file_utils_1.readFile)(certFilePath),
20
+ ]);
21
+ return {
22
+ key,
23
+ cert,
24
+ };
25
+ }
26
+ catch (_error) {
27
+ // if the file doesn't exist, we'll catch the error and continue
28
+ // no pre-existing certs, so use mkcert to try and auto-generate SSL certs.
29
+ return (0, auto_encrypt_localhost_1.setupAndGetCert)();
30
+ }
31
+ }
32
+ //# sourceMappingURL=get-ssl-cert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-ssl-cert.js","sourceRoot":"","sources":["../../../../src/lib/https-cert/lib/get-ssl-cert.ts"],"names":[],"mappings":";;AAaA,0DAgBC;AA7BD,qDAAgD;AAChD,+BAA4B;AAC5B,qEAA2D;AAE3D,4CAAgE;AAEhE,MAAM,WAAW,GAAG,IAAA,WAAI,EAAC,wBAAgB,EAAE,mBAAmB,CAAC,CAAC;AAChE,MAAM,YAAY,GAAG,IAAA,WAAI,EAAC,wBAAgB,EAAE,eAAe,CAAC,CAAC;AAE7D;;;GAGG;AACI,KAAK,UAAU,uBAAuB;IAC3C,wDAAwD;IACxD,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACpC,IAAA,qBAAQ,EAAC,WAAW,CAAC;YACrB,IAAA,qBAAQ,EAAC,YAAY,CAAC;SACvB,CAAC,CAAC;QACH,OAAO;YACL,GAAG;YACH,IAAI;SACL,CAAC;IACJ,CAAC;IAAC,OAAO,MAAM,EAAE,CAAC;QAChB,gEAAgE;QAChE,2EAA2E;QAC3E,OAAO,IAAA,wCAAe,GAAE,CAAC;IAC3B,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function installCertutil(): void;
2
+ //# sourceMappingURL=install-cert-util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-cert-util.d.ts","sourceRoot":"","sources":["../../../../src/lib/https-cert/lib/install-cert-util.ts"],"names":[],"mappings":"AA8HA,wBAAgB,eAAe,IAAI,IAAI,CAetC"}
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.installCertutil = installCertutil;
7
+ const os_1 = __importDefault(require("os"));
8
+ const child_process_1 = __importDefault(require("child_process"));
9
+ const log_1 = require("../log");
10
+ // Does the passed command exist? Returns: bool.
11
+ function commandExists(command) {
12
+ try {
13
+ child_process_1.default.execFileSync('which', [command], { env: process.env });
14
+ return true;
15
+ }
16
+ catch (error) {
17
+ return false;
18
+ }
19
+ }
20
+ //
21
+ // Private.
22
+ //
23
+ // On Linux, we must install nss for mkcert to work with both Chrome and Firefox.
24
+ // Depending on the platform we try to do so using apt, yum, or pacman. If none of
25
+ // those exist, we fail.
26
+ function installCertutilOnLinux() {
27
+ if (commandExists('certutil')) {
28
+ // Already installed
29
+ log_1.log.verbose('done.\n');
30
+ return;
31
+ }
32
+ log_1.log.info('❨auto-encrypt-localhost❩ Installing certutil dependency (Linux) ');
33
+ const options = { env: process.env };
34
+ try {
35
+ if (commandExists('apt')) {
36
+ log_1.log.verbose('using apt… \n');
37
+ options.env.DEBIAN_FRONTEND = 'noninteractive';
38
+ child_process_1.default.execSync('sudo apt-get install -y -q libnss3-tools', options);
39
+ }
40
+ else if (commandExists('yum')) {
41
+ // Untested: if you test this, please let me know https://github.com/indie-mirror/https-server/issues
42
+ log_1.log.verbose('❨auto-encrypt-localhost❩ Attempting to install required dependency using yum. This is currently untested. If it works (or blows up) for you, I’d appreciate it if you could open an issue at https://github.com/indie-mirror/https-server/issues and let me know. Thanks! – Aral\n');
43
+ child_process_1.default.execSync('sudo yum install nss-tools', options);
44
+ log_1.log.verbose('❨auto-encrypt-localhost❩ Certutil installed using yum.');
45
+ }
46
+ else if (commandExists('pacman')) {
47
+ child_process_1.default.execSync('sudo pacman -S nss', options);
48
+ log_1.log.verbose('❨auto-encrypt-localhost❩ Certutil installed using pacman.');
49
+ }
50
+ else {
51
+ // Neither Homebrew nor MacPorts is installed. Warn the person.
52
+ log_1.log.verbose('❨auto-encrypt-localhost❩ Linux: No supported package manager found for installing certutil on Linux (tried apt, yum, and pacman. Please install certutil manually and run Auto Encrypt Localhost again. For more instructions on installing mkcert dependencies, please see https://github.com/FiloSottile/mkcert/\n');
53
+ }
54
+ }
55
+ catch (error) {
56
+ // There was an error and we couldn’t install the dependency. Warn the person.
57
+ log_1.log.verbose('❨auto-encrypt-localhost❩ Linux: Failed to install nss. Please install it manually and run Auto Encrypt Localhost again if you want your certificate to work in Chrome and Firefox', error);
58
+ }
59
+ }
60
+ // On macOS, we install nss for mkcert to work with Firefox. To
61
+ // install nss, we can use either Homebrew or Macports.
62
+ // If neither Homebrew or MacPorts is installed, we warn the person that
63
+ // they need to install it manually if they want their certificates to work
64
+ // in Firefox.
65
+ function installCertutilOnDarwin() {
66
+ const options = { env: process.env };
67
+ if (commandExists('brew')) {
68
+ // Check if nss installed using brew (we can’t just check using commandExists as
69
+ // nss is installed as keg-only and not symlinked to /usr/local due to issues
70
+ // with Firefox crashing).
71
+ try {
72
+ // Homebrew can take a long time start, show current status.
73
+ child_process_1.default.execSync('brew list nss >/dev/null 2>&1', options);
74
+ log_1.log.verbose('done.');
75
+ }
76
+ catch (error) {
77
+ // NSS is not installed. Install it.
78
+ try {
79
+ log_1.log.info('❨auto-encrypt-localhost❩Installing certutil dependency (Darwin) using Homebrew… ');
80
+ child_process_1.default.execSync('brew install nss >/dev/null 2>&1', options);
81
+ log_1.log.verbose('done.');
82
+ }
83
+ catch (err) {
84
+ log_1.log.warn('❨auto-encrypt-localhost❩ macOS: Failed to install nss via Homebrew. Please install it manually and run Auto Encrypt Localhost again if you want your certificate to work in Firefox', err);
85
+ }
86
+ }
87
+ }
88
+ else if (commandExists('port')) {
89
+ // Untested. This is based on the documentation at https://guide.macports.org/#using.port.installed. I don’t have MacPorts installed
90
+ // and it doesn’t play well with Homebrew so I won’t be testing this anytime soon. If you do, please let me know how it works
91
+ // by opening an issue on https://github.com/indie-mirror/https-server/issues
92
+ log_1.log.warn('❨auto-encrypt-localhost❩ Attempting to install required dependency using MacPorts. This is currently untested. If it works (or blows up) for you, I’d appreciate it if you could open an issue at https://github.com/indie-mirror/https-server/issues and let me know. Thanks! – Aral\n');
93
+ try {
94
+ child_process_1.default.execSync('port installed nss', options);
95
+ }
96
+ catch (error) {
97
+ // nss is not installed, attempt to install it using MacPorts.
98
+ try {
99
+ child_process_1.default.execSync('sudo port install nss', options);
100
+ }
101
+ catch (err) {
102
+ log_1.log.error('❨auto-encrypt-localhost❩ macOS: Failed to install nss via MacPorts. Please install it manually and run Auto Encrypt Localhost again if you want your certificate to work in Firefox', err);
103
+ }
104
+ }
105
+ }
106
+ else {
107
+ // Neither Homebrew nor MacPorts is installed. Warn the person.
108
+ log_1.log.error('macOS: Cannot install certutil (nss) as you don’t have Homebrew or MacPorts installed.\n\n If you want your certificate to work in Firefox, please install one of those package managers and then install nss manually:\n ╰─ * Homebrew (https://brew.sh): brew install nss ╰─ * MacPorts(https://macports.org): sudo port install nss\n');
109
+ }
110
+ }
111
+ // Mozilla’s nss is used on Linux to install the certificate in Chrome and Firefox
112
+ // and on macOS for Firefox. Ensure it exists.
113
+ // Source: https://github.com/FiloSottile/mkcert/blob/master/README.md#installation
114
+ function installCertutil() {
115
+ log_1.log.info(`Installing certutil if necessary… `);
116
+ const platform = os_1.default.platform();
117
+ if (platform === 'linux') {
118
+ installCertutilOnLinux();
119
+ }
120
+ else if (platform === 'darwin') {
121
+ installCertutilOnDarwin();
122
+ }
123
+ else if (platform === 'win32') {
124
+ // Do nothing. According to the mkcert documentation, certutil is not
125
+ // required on Windows.
126
+ log_1.log.verbose('done.');
127
+ }
128
+ else {
129
+ // Unknown platform. This should have been caught earlier. Panic.
130
+ throw new Error(`Panic: Unknown platform detected. ${platform}`);
131
+ }
132
+ }
133
+ //# sourceMappingURL=install-cert-util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-cert-util.js","sourceRoot":"","sources":["../../../../src/lib/https-cert/lib/install-cert-util.ts"],"names":[],"mappings":";;;;;AA8HA,0CAeC;AA7ID,4CAAoB;AACpB,kEAAyC;AACzC,gCAA6B;AAE7B,gDAAgD;AAChD,SAAS,aAAa,CAAC,OAAe;I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C,oBAAoB,EAAE,OAAO,CAAC,CAAC;QACvD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,8DAA8D;YAC9D,IAAI,CAAC;gBACH,uBAAY,CAAC,QAAQ,CAAC,uBAAuB,EAAE,OAAO,CAAC,CAAC;YAC1D,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,SAAG,CAAC,KAAK,CACP,qLAAqL,EACrL,GAAG,CACJ,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;SAAM,CAAC;QACN,+DAA+D;QAC/D,SAAG,CAAC,KAAK,CACP,8UAA8U,CAC/U,CAAC;IACJ,CAAC;AACH,CAAC;AAED,kFAAkF;AAClF,8CAA8C;AAC9C,mFAAmF;AACnF,SAAgB,eAAe;IAC7B,SAAG,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;IAC/C,MAAM,QAAQ,GAAG,YAAE,CAAC,QAAQ,EAAE,CAAC;IAC/B,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QACzB,sBAAsB,EAAE,CAAC;IAC3B,CAAC;SAAM,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,uBAAuB,EAAE,CAAC;IAC5B,CAAC;SAAM,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QAChC,qEAAqE;QACrE,uBAAuB;QACvB,SAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,iEAAiE;QACjE,MAAM,IAAI,KAAK,CAAC,qCAAqC,QAAQ,EAAE,CAAC,CAAC;IACnE,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function preInstallMkCert(): Promise<void>;
2
+ //# sourceMappingURL=pre-install-mkcert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pre-install-mkcert.d.ts","sourceRoot":"","sources":["../../../../src/lib/https-cert/lib/pre-install-mkcert.ts"],"names":[],"mappings":"AA0CA,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CA6BtD"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.preInstallMkCert = preInstallMkCert;
7
+ const path_1 = __importDefault(require("path"));
8
+ const fs_extra_1 = __importDefault(require("fs-extra"));
9
+ const https_1 = __importDefault(require("https"));
10
+ const log_1 = require("../log");
11
+ const constants_1 = require("../constants");
12
+ async function download(url, filePath) {
13
+ return new Promise((resolve, reject) => {
14
+ https_1.default
15
+ .get(url, (response) => {
16
+ const { statusCode } = response;
17
+ const redirectUrl = response.headers.location;
18
+ if (typeof redirectUrl !== 'string') {
19
+ return reject(new Error('redirectUrl is not a string'));
20
+ }
21
+ // Reject if it’s not one of the status codes we're expecting.
22
+ if (statusCode !== 302 && statusCode !== 200) {
23
+ return reject(new Error(`bad https download status code: ${statusCode}`));
24
+ }
25
+ const fileStream = fs_extra_1.default.createWriteStream(filePath);
26
+ https_1.default.get(redirectUrl, (resp2) => {
27
+ resp2.pipe(fileStream);
28
+ fileStream.on('finish', () => {
29
+ fileStream.close();
30
+ return resolve();
31
+ });
32
+ fileStream.on('error', (error) => {
33
+ fs_extra_1.default.unlinkSync(filePath);
34
+ reject(error);
35
+ });
36
+ });
37
+ })
38
+ .on('error', (error) => reject(error));
39
+ });
40
+ }
41
+ async function preInstallMkCert() {
42
+ /**
43
+ * Try to install the mkcert binary...
44
+ *
45
+ * 1. If you're running `knapsack start` (ie. locally)
46
+ * 2. Also, only if the binary doesn't already exist on your filesystem
47
+ */
48
+ fs_extra_1.default.mkdirpSync(constants_1.settingsPath);
49
+ const mkcertBinaryUrl = `https://github.com/FiloSottile/mkcert/releases/download/v${constants_1.version}/${constants_1.binaryName}`;
50
+ if (!fs_extra_1.default.existsSync(path_1.default.join(constants_1.settingsPath, constants_1.binaryName))) {
51
+ log_1.log.info(`🔒️ Downloading mkcert v${constants_1.version} to automatically set up HTTPS`);
52
+ const dlPath = path_1.default.join(constants_1.settingsPath, constants_1.binaryName);
53
+ await download(mkcertBinaryUrl, dlPath);
54
+ if (fs_extra_1.default.existsSync(dlPath)) {
55
+ fs_extra_1.default.chmodSync(path_1.default.join(constants_1.settingsPath, constants_1.binaryName), 0o755);
56
+ log_1.log.info(`✅ Successfully downloaded the mkcert v${constants_1.version} binary!`);
57
+ }
58
+ else {
59
+ throw new Error(`Failed to download mkcert binary to ${dlPath}`);
60
+ }
61
+ }
62
+ else {
63
+ log_1.log.info('✅ mkcert already installed so we can auto-configure local HTTPS!');
64
+ }
65
+ }
66
+ //# sourceMappingURL=pre-install-mkcert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pre-install-mkcert.js","sourceRoot":"","sources":["../../../../src/lib/https-cert/lib/pre-install-mkcert.ts"],"names":[],"mappings":";;;;;AA0CA,4CA6BC;AAvED,gDAAwB;AACxB,wDAA0B;AAC1B,kDAA0B;AAC1B,gCAA6B;AAC7B,4CAAiE;AAEjE,KAAK,UAAU,QAAQ,CAAC,GAAW,EAAE,QAAgB;IACnD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,eAAK;aACF,GAAG,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,EAAE;YACrB,MAAM,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC;YAChC,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC;YAC9C,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;gBACpC,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC,CAAC;YAC1D,CAAC;YAED,8DAA8D;YAC9D,IAAI,UAAU,KAAK,GAAG,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC;gBAC7C,OAAO,MAAM,CACX,IAAI,KAAK,CAAC,mCAAmC,UA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UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1B,kBAAE,CAAC,SAAS,CAAC,cAAI,CAAC,IAAI,CAAC,wBAAY,EAAE,sBAAU,CAAC,EAAE,KAAK,CAAC,CAAC;YACzD,SAAG,CAAC,IAAI,CAAC,yCAAyC,mBAAO,UAAU,CAAC,CAAC;QACvE,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,uCAAuC,MAAM,EAAE,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;SAAM,CAAC;QACN,SAAG,CAAC,IAAI,CACN,kEAAkE,CACnE,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare function setupLocalCertAuthority({ mkcertBinary, certFilePath, keyFilePath, }: {
2
+ mkcertBinary: string;
3
+ certFilePath: string;
4
+ keyFilePath: string;
5
+ }): Promise<void>;
6
+ //# sourceMappingURL=setup-local-cert-auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-local-cert-auth.d.ts","sourceRoot":"","sources":["../../../../src/lib/https-cert/lib/setup-local-cert-auth.ts"],"names":[],"mappings":"AAOA,wBAAsB,uBAAuB,CAAC,EAC5C,YAAY,EACZ,YAAY,EACZ,WAAW,GACZ,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,IAAI,CAAC,CA6BhB"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.setupLocalCertAuthority = setupLocalCertAuthority;
7
+ const fs_extra_1 = __importDefault(require("fs-extra"));
8
+ const child_process_1 = __importDefault(require("child_process"));
9
+ const log_1 = require("../log");
10
+ const constants_1 = require("../constants");
11
+ const { exec } = child_process_1.default;
12
+ async function setupLocalCertAuthority({ mkcertBinary, certFilePath, keyFilePath, }) {
13
+ return new Promise((resolve, reject) => {
14
+ // mkcert uses the CAROOT environment variable to know where to create/find the certificate authority.
15
+ // We also pass the rest of the system environment to the spawned processes.
16
+ // Create the local certificate authority.
17
+ log_1.log.info('Creating local certificate authority (local CA) using mkcert…');
18
+ exec(`${mkcertBinary} -install`, constants_1.mkcertProcessOptions, (error) => {
19
+ if (error) {
20
+ const err = new Error(`Failed to create local certificate authority. ${error.message}`, { cause: error });
21
+ // auto-cleanup so re-running knapsack start will try to re-configure
22
+ if (fs_extra_1.default.existsSync(certFilePath)) {
23
+ fs_extra_1.default.removeSync(certFilePath);
24
+ }
25
+ if (fs_extra_1.default.existsSync(keyFilePath)) {
26
+ fs_extra_1.default.removeSync(keyFilePath);
27
+ }
28
+ return reject(err);
29
+ }
30
+ log_1.log.info('❨auto-encrypt-localhost❩ Local certificate authority created.');
31
+ return resolve();
32
+ });
33
+ });
34
+ }
35
+ //# sourceMappingURL=setup-local-cert-auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-local-cert-auth.js","sourceRoot":"","sources":["../../../../src/lib/https-cert/lib/setup-local-cert-auth.ts"],"names":[],"mappings":";;;;;AAOA,0DAqCC;AA5CD,wDAA0B;AAC1B,kEAA4C;AAC5C,gCAA6B;AAC7B,4CAAoD;AAEpD,MAAM,EAAE,IAAI,EAAE,GAAG,uBAAe,CAAC;AAE1B,KAAK,UAAU,uBAAuB,CAAC,EAC5C,YAAY,EACZ,YAAY,EACZ,WAAW,GAKZ;IACC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,sGAAsG;QACtG,4EAA4E;QAE5E,0CAA0C;QAC1C,SAAG,CAAC,IAAI,CAAC,+DAA+D,CAAC,CAAC;QAC1E,IAAI,CAAC,GAAG,YAAY,WAAW,EAAE,gCAAoB,EAAE,CAAC,KAAK,EAAE,EAAE;YAC/D,IAAI,KAAK,EAAE,CAAC;gBACV,MAAM,GAAG,GAAG,IAAI,KAAK,CACnB,iDAAiD,KAAK,CAAC,OAAO,EAAE,EAChE,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;gBAEF,qEAAqE;gBACrE,IAAI,kBAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;oBAChC,kBAAE,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;gBAC9B,CAAC;gBAED,IAAI,kBAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;oBAC/B,kBAAE,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;gBAC7B,CAAC;gBACD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;YACrB,CAAC;YAED,SAAG,CAAC,IAAI,CAAC,+DAA+D,CAAC,CAAC;YAC1E,OAAO,OAAO,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { log } from '../../cli/log';
2
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../src/lib/https-cert/log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.log = void 0;
4
+ var log_1 = require("../../cli/log");
5
+ Object.defineProperty(exports, "log", { enumerable: true, get: function () { return log_1.log; } });
6
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../../../src/lib/https-cert/log.ts"],"names":[],"mappings":";;;AAAA,qCAAoC;AAA3B,0FAAA,GAAG,OAAA"}
@@ -0,0 +1,5 @@
1
+ export type SslCert = {
2
+ key: string;
3
+ cert: string;
4
+ };
5
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/https-cert/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/https-cert/types.ts"],"names":[],"mappings":""}