@bgord/bun 0.30.0 → 0.30.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": "@bgord/bun",
3
- "version": "0.30.0",
3
+ "version": "0.30.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "author": "Bartosz Gordon",
@@ -6,6 +6,8 @@ import type { ClockPort } from "./clock.port";
6
6
  type Dependencies = { Clock: ClockPort };
7
7
 
8
8
  export class CertificateInspectorTLSAdapter implements CertificateInspectorPort {
9
+ private static readonly ROUNDING = new tools.RoundToNearest();
10
+
9
11
  constructor(private readonly deps: Dependencies) {}
10
12
 
11
13
  async inspect(hostname: string): Promise<CertificateInspection> {
@@ -28,7 +30,10 @@ export class CertificateInspectorTLSAdapter implements CertificateInspectorPort
28
30
  const validToMs = new Date(certificate.valid_to).getTime();
29
31
  const daysRemaining = tools.Duration.Ms(validToMs - this.deps.Clock.nowMs()).days;
30
32
 
31
- settle({ success: true, daysRemaining });
33
+ settle({
34
+ success: true,
35
+ daysRemaining: CertificateInspectorTLSAdapter.ROUNDING.round(daysRemaining),
36
+ });
32
37
  },
33
38
  );
34
39
 
@@ -7,13 +7,13 @@ export class PrerequisiteSSLCertificateExpiry implements prereqs.Prerequisite {
7
7
  readonly enabled?: boolean = true;
8
8
 
9
9
  private readonly host: string;
10
- private readonly validDaysMinimum: number;
10
+ private readonly days: number;
11
11
  private readonly inspector: CertificateInspectorPort;
12
12
 
13
13
  constructor(
14
14
  config: prereqs.PrerequisiteConfigType & {
15
15
  host: string;
16
- validDaysMinimum: number;
16
+ days: number;
17
17
  inspector: CertificateInspectorPort;
18
18
  },
19
19
  ) {
@@ -21,7 +21,7 @@ export class PrerequisiteSSLCertificateExpiry implements prereqs.Prerequisite {
21
21
  this.enabled = config.enabled === undefined ? true : config.enabled;
22
22
 
23
23
  this.host = config.host;
24
- this.validDaysMinimum = config.validDaysMinimum;
24
+ this.days = config.days;
25
25
  this.inspector = config.inspector;
26
26
  }
27
27
 
@@ -31,7 +31,7 @@ export class PrerequisiteSSLCertificateExpiry implements prereqs.Prerequisite {
31
31
  const result = await this.inspector.inspect(this.host);
32
32
 
33
33
  if (!result.success) return prereqs.Verification.failure({ message: "Unavailable" });
34
- if (result.daysRemaining <= this.validDaysMinimum) {
34
+ if (result.daysRemaining <= this.days) {
35
35
  return prereqs.Verification.failure({ message: `${result.daysRemaining} days remaining` });
36
36
  }
37
37
  return prereqs.Verification.success();
@@ -37,7 +37,7 @@ type Dependencies = {
37
37
  export class Setup {
38
38
  static essentials(deps: Dependencies, overrides?: SetupOverridesType) {
39
39
  const corsOptions = overrides?.cors ?? { origin: "*" };
40
- const secureHeadersOptions = overrides?.secureHeaders ?? undefined;
40
+ const secureHeadersOptions = { crossOriginResourcePolicy: "cross-origin", ...overrides?.secureHeaders };
41
41
 
42
42
  return [
43
43
  secureHeaders(secureHeadersOptions),