@econ-v1/domain 6.11.0 → 6.12.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.
@@ -38,5 +38,6 @@ export type CertificateTrustServiceOptions = {
38
38
  platform: CertificateTrustPlatform;
39
39
  probe: CertificateTrustProbePort;
40
40
  onChange?: (snapshot: CertificateTrustSnapshot) => void;
41
+ liveness?: () => boolean;
41
42
  };
42
43
  //# sourceMappingURL=certificate-trust-service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"certificate-trust-service.d.ts","sourceRoot":"","sources":["../../src/services/certificate-trust-service.js"],"names":[],"mappings":"AACA,4FAA4F;AAC5F,8FAA8F;AAC9F;IAWE;;OAEG;IACH,qBAFW,8BAA8B,EAYxC;IACD;;OAEG;IACH,UAFa,wBAAwB,CAIpC;IACD;;OAEG;IACH,kBAFa,wBAAwB,CAIpC;IACD;;OAEG;IACH,QAFa,wBAAwB,CAIpC;IACD;;OAEG;IACH,UAFa,OAAO,CAAC,wBAAwB,CAAC,CAoC7C;;CAkBF;uCApGa,OAAO,gBAAgB,EAAE,wBAAwB;wCACjD,OAAO,gBAAgB,EAAE,yBAAyB;qCAoGlD,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,aAAa;;YAG5E,sBAAsB;YACtB,MAAM;cACN,wBAAwB;kBACxB,MAAM;gBACN,MAAM;;;YAIN,MAAM;cACN,wBAAwB;WACxB,yBAAyB;eACzB,CAAC,QAAQ,EAAE,wBAAwB,KAAK,IAAI"}
1
+ {"version":3,"file":"certificate-trust-service.d.ts","sourceRoot":"","sources":["../../src/services/certificate-trust-service.js"],"names":[],"mappings":"AACA,4FAA4F;AAC5F,8FAA8F;AAC9F;IAaE;;OAEG;IACH,qBAFW,8BAA8B,EAaxC;IACD;;OAEG;IACH,UAFa,wBAAwB,CAIpC;IACD;;OAEG;IACH,kBAFa,wBAAwB,CAIpC;IACD;;OAEG;IACH,QAFa,wBAAwB,CAIpC;IACD;;OAEG;IACH,UAFa,OAAO,CAAC,wBAAwB,CAAC,CAmD7C;;CAkBF;uCAtHa,OAAO,gBAAgB,EAAE,wBAAwB;wCACjD,OAAO,gBAAgB,EAAE,yBAAyB;qCAsHlD,SAAS,GAAG,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,aAAa;;YAG5E,sBAAsB;YACtB,MAAM;cACN,wBAAwB;kBACxB,MAAM;gBACN,MAAM;;;YAIN,MAAM;cACN,wBAAwB;WACxB,yBAAyB;eACzB,CAAC,QAAQ,EAAE,wBAAwB,KAAK,IAAI;eAC5C,MAAM,OAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@econ-v1/domain",
3
- "version": "6.11.0",
3
+ "version": "6.12.1",
4
4
  "description": "Platform-neutral domain contracts and errors for Node clients",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "author": "Node contributors",
@@ -57,6 +57,6 @@
57
57
  "access": "public"
58
58
  },
59
59
  "dependencies": {
60
- "@econ-v1/ports": "6.11.0"
60
+ "@econ-v1/ports": "6.12.1"
61
61
  }
62
62
  }
@@ -10,6 +10,8 @@ export class CertificateTrustService {
10
10
  #probe;
11
11
  /** @readonly @type {(snapshot: CertificateTrustSnapshot) => void} */
12
12
  #onChange;
13
+ /** @readonly @type {(() => boolean) | undefined} */
14
+ #liveness;
13
15
  /** @type {CertificateTrustSnapshot} */
14
16
  #snapshot;
15
17
  /**
@@ -20,6 +22,7 @@ export class CertificateTrustService {
20
22
  this.#platform = options.platform;
21
23
  this.#probe = options.probe;
22
24
  this.#onChange = options.onChange ?? (() => undefined);
25
+ this.#liveness = options.liveness;
23
26
  this.#snapshot = {
24
27
  status: "unknown",
25
28
  origin: options.origin,
@@ -65,7 +68,22 @@ export class CertificateTrustService {
65
68
  // trust the CA yet" here would tell someone to go re-install a certificate
66
69
  // when the real problem is that nothing is listening — the same unmet
67
70
  // prerequisite reported as the wrong one.
71
+ //
72
+ // `fetch` cannot tell a rejected TLS handshake from a dead socket — the
73
+ // Fetch spec deliberately hides the reason — so both arrive here as
74
+ // `unreachable`. When some OTHER channel is currently talking to this
75
+ // node, the socket plainly is not dead, and the only remaining
76
+ // explanation is that this browser refuses the chain. Reporting that as
77
+ // "could not be reached" sends someone to check their network when what
78
+ // they actually need is to install the CA.
68
79
  if (result.status === "unreachable") {
80
+ if (this.#liveness?.() === true) {
81
+ return this.#set({
82
+ status: "failed",
83
+ lastError:
84
+ "This device does not trust the node's certificate authority yet.",
85
+ });
86
+ }
69
87
  return this.#set({
70
88
  status: "unavailable",
71
89
  lastError: "The node could not be reached over HTTPS.",
@@ -115,5 +133,6 @@ export class CertificateTrustService {
115
133
  * @property {CertificateTrustPlatform} platform
116
134
  * @property {CertificateTrustProbePort} probe
117
135
  * @property {(snapshot: CertificateTrustSnapshot) => void} [onChange]
136
+ * @property {() => boolean} [liveness]
118
137
  */
119
138
  // @ts-check