sliftutils 1.1.0 → 1.1.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/.gitignore CHANGED
@@ -28,6 +28,7 @@ data
28
28
  *.gif
29
29
  *.bmp
30
30
  *.tiff
31
+ *.cert
31
32
  temp
32
33
  yarn-error.log
33
34
  pretrained_models
@@ -5,11 +5,22 @@ import * as forge from "node-forge";
5
5
  import acme from "acme-client";
6
6
  import { magenta, red } from "socket-function/src/formatting/logColors";
7
7
  import { formatDateTime, formatTime } from "socket-function/src/formatting/format";
8
- import { timeInMinute } from "socket-function/src/misc";
8
+ import { timeInHour, timeInMinute } from "socket-function/src/misc";
9
9
  import { delay } from "socket-function/src/batching";
10
10
  import fs from "fs";
11
11
  import { getKeyStore } from "./persistentLocalStorage";
12
12
 
13
+ // For example:
14
+ /*
15
+ let domain = "querysubtest.com";
16
+ await loadIdentityCA(domain);
17
+
18
+ let listenPublic = false;
19
+ let port = 9823;
20
+ let localDomain = "127-0-0-1." + domain;
21
+ await addRecord("A", localDomain, "127.0.0.1");
22
+ let keyCert = await getHTTPSCert(domain);
23
+ */
13
24
 
14
25
  // Expire EXPIRATION_THRESHOLD% of the way through the certificate's lifetime
15
26
  const EXPIRATION_THRESHOLD = 0.4;
@@ -19,6 +30,12 @@ export const getHTTPSCert = cache(async (domain: string): Promise<{ key: string;
19
30
  if (!domain.endsWith(".")) {
20
31
  domain = domain + ".";
21
32
  }
33
+
34
+ // No matter what, reset this from the in-memory cache in an hour. This is fine. We'll just see the cache on disk and see that it hasn't expired. Or we might see that it has expired, and then we will get the new value.
35
+ setTimeout(() => {
36
+ getHTTPSCert.clear(domain);
37
+ }, timeInHour);
38
+
22
39
  let keyCert: { key: string; cert: string } | undefined;
23
40
  let path = domain + ".cert";
24
41
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sliftutils",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "files": [