@camstack/server 1.2.872 → 1.2.874
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/CHANGELOG.md +17 -0
- package/dist/api/trpc/generated-cap-routers.js +7 -0
- package/dist/core/agent/expired-leaf-renewer.js +67 -0
- package/dist/core/agent/mesh-handshake-wiring.js +48 -0
- package/dist/manual-boot.js +6 -0
- package/package.json +13 -11
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/alerts/alerts.addon.js +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +1 -1
- package/system/dist/builtins/camera-grid/index.mjs +1 -1
- package/system/dist/builtins/composer/composer.addon.js +4 -4
- package/system/dist/builtins/composer/composer.addon.mjs +4 -4
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
- package/system/dist/builtins/device-history/device-history.addon.js +2 -2
- package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +87 -29
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +87 -29
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +4 -4
- package/system/dist/builtins/keychain/index.mjs +4 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
- package/system/dist/builtins/local-network/local-network.addon.js +3 -3
- package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
- package/system/dist/builtins/loki-logging/index.js +1 -1
- package/system/dist/builtins/loki-logging/index.mjs +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +1 -1
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/system-config/system-config.addon.js +190 -22
- package/system/dist/builtins/system-config/system-config.addon.mjs +189 -23
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{capture-engine-BNeKmvyo.js → capture-engine-Cm-Bq2GH.js} +1 -1
- package/system/dist/{capture-engine-BYuDoU5P.mjs → capture-engine-v5nSEyMa.mjs} +1 -1
- package/system/dist/{composition-sources-DQwbBMG1.mjs → composition-sources-BVxOFdMp.mjs} +1 -1
- package/system/dist/{composition-sources-52ZtkEBw.js → composition-sources-DgAdHcEq.js} +1 -1
- package/system/dist/{constants-jwecWQuN.js → constants-CPAYm7Bq.js} +14 -1
- package/system/dist/constants-Di6cOA3l.mjs +27 -0
- package/system/dist/{device-ca-Bkujp9Cx.js → device-ca-CtsnO3ul.js} +1 -1
- package/system/dist/{device-ca-DFi1axk5.mjs → device-ca-DukusHra.mjs} +1 -1
- package/system/dist/{dist-8pvVkKh4.js → dist-AbO-Bmtw.js} +182 -2
- package/system/dist/{dist-B15a2506.mjs → dist-CIUo0MpB.mjs} +177 -3
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-identity-3uLEvGsn.mjs → hub-identity-CMzGT-O8.mjs} +1 -1
- package/system/dist/{hub-identity-C3ijBf-E.js → hub-identity-DyXxu-ZQ.js} +1 -1
- package/system/dist/{hub-mdns-ciao-Ch6HwlRl.mjs → hub-mdns-ciao-BTpy99VT.mjs} +2 -2
- package/system/dist/{hub-mdns-ciao-BUL3yLqz.js → hub-mdns-ciao-C6Gkg80T.js} +2 -2
- package/system/dist/index.js +10 -8
- package/system/dist/index.mjs +10 -10
- package/system/dist/kernel/index.d.ts +1 -1
- package/system/dist/kernel/moleculer/mesh-mtls/constants.d.ts +7 -2
- package/system/dist/kernel/moleculer/mesh-mtls/index.d.ts +2 -2
- package/system/dist/kernel/moleculer/mesh-mtls/mesh-ca.d.ts +1 -1
- package/system/dist/kernel/moleculer/mesh-mtls/mesh-peer-transport.d.ts +16 -0
- package/system/dist/kernel/moleculer/mesh-mtls/mesh-peer-verification.d.ts +30 -0
- package/system/dist/kernel/moleculer/mesh-mtls/tls-tcp-transporter.d.ts +31 -0
- package/system/dist/{legacy-integration-rows-door-BtRtvXfK.js → legacy-integration-rows-door-BQztEAgV.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-ChF97F5x.mjs → legacy-integration-rows-door-ChwuaraH.mjs} +1 -1
- package/system/dist/{rename-composition-block-DfsNTQ2H.mjs → rename-composition-block-CEkkKNmw.mjs} +1 -1
- package/system/dist/{rename-composition-block-CHIIBly8.js → rename-composition-block-CnQKQDSg.js} +1 -1
- package/system/dist/{restore-archive-BfaE7Y65.mjs → restore-archive-DROkE3b4.mjs} +1 -1
- package/system/dist/{restore-archive-8o1pcPFB.js → restore-archive-DRYoZ_dn.js} +1 -1
- package/system/dist/{wal-maintenance-Cv6MfFm9.js → wal-maintenance-C81WD-_A.js} +0 -0
- package/system/dist/{wal-maintenance-DxtgYuYM.mjs → wal-maintenance-DYmw2kX7.mjs} +0 -0
- package/system/package.json +1 -1
- package/system/dist/constants-RWobCEGs.mjs +0 -20
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { a as __toCommonJS, i as __require, n as __esmMin, o as __toESM, r as __exportAll, t as __commonJSMin } from "../../chunk-CNf5ZN-e.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { Fc as customAction, Jc as hydrateSchema, Lc as defineCustomActions, Ll as errMsg, Ls as BaseAddon, _o as shortHostname, cn as ServerNameSchema } from "../../dist-CIUo0MpB.mjs";
|
|
3
3
|
import { t as require_safe_buffer } from "../../safe-buffer-B1OjL1I9.mjs";
|
|
4
4
|
import { C as backdatedNotBefore, S as withUtcTimeEncoding, a as KeyUsageFlags, c as Pkcs10CertificateRequest, d as SubjectKeyIdentifierExtension, f as X509Certificate$1, l as Pkcs10CertificateRequestGenerator, m as cryptoProvider, n as BasicConstraintsExtension, o as KeyUsagesExtension, p as X509CertificateGenerator, r as ExtendedKeyUsageExtension, s as PemConverter, t as AuthorityKeyIdentifierExtension } from "../../x509.es-BRiJgOvu.mjs";
|
|
5
|
-
import { B as AGENT_HTTPS_NAMES_COLLECTION, G as systemConfigRecordKinds, H as AgentHttpsNames, I as isLocalOnlyHostname, U as getProcessAgentHttpsNames, V as AGENT_HTTPS_NAMES_COLUMNS, W as setProcessAgentHttpsNames, m as isPrivateAddress, r as isAnnouncedHubId } from "../../hub-identity-
|
|
6
|
-
import { a as MESH_CA_KEY_REF, c as
|
|
5
|
+
import { B as AGENT_HTTPS_NAMES_COLLECTION, G as systemConfigRecordKinds, H as AgentHttpsNames, I as isLocalOnlyHostname, U as getProcessAgentHttpsNames, V as AGENT_HTTPS_NAMES_COLUMNS, W as setProcessAgentHttpsNames, m as isPrivateAddress, r as isAnnouncedHubId } from "../../hub-identity-CMzGT-O8.mjs";
|
|
6
|
+
import { a as MESH_CA_KEY_REF, c as MESH_LEAF_NOT_AFTER, i as MESH_CA_FIELD, l as SERVER_AUTH_OID, n as DEFAULT_HUB_TLS_TCP_PORT, o as MESH_CA_SETTINGS_KEY, r as MESH_CA_COMMON_NAME, s as MESH_CA_VALIDITY_DAYS, t as CLIENT_AUTH_OID } from "../../constants-Di6cOA3l.mjs";
|
|
7
7
|
import { t as require_src } from "../../src-hG4grMU4.mjs";
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
import { X509Certificate, createHash, createPrivateKey, randomBytes, randomInt, sign, timingSafeEqual, verify, webcrypto } from "node:crypto";
|
|
@@ -449,7 +449,7 @@ async function loadMeshCa(certPem, keyPem) {
|
|
|
449
449
|
}
|
|
450
450
|
/**
|
|
451
451
|
* Issue a leaf from a CSR. CN must be present; when `expectedNodeId` is set
|
|
452
|
-
* it must match. Validity:
|
|
452
|
+
* it must match. Validity: none (`MESH_LEAF_NOT_AFTER`); `validDays` is a spec seam that forges a short one.
|
|
453
453
|
*/
|
|
454
454
|
async function issueMeshLeafFromCsr(ca, csrPem, opts = {}) {
|
|
455
455
|
const csr = new Pkcs10CertificateRequest(csrPem);
|
|
@@ -459,9 +459,8 @@ async function issueMeshLeafFromCsr(ca, csrPem, opts = {}) {
|
|
|
459
459
|
if (opts.allowReserved !== true && !isValidAgentNodeId(cn)) throw new Error(`CSR CN '${cn}' is not an id an agent may carry`);
|
|
460
460
|
if (opts.expectedNodeId !== void 0 && opts.expectedNodeId !== cn) throw new Error(`CSR CN '${cn}' does not match the token nodeId '${opts.expectedNodeId}'`);
|
|
461
461
|
const now = opts.now ?? /* @__PURE__ */ new Date();
|
|
462
|
-
const validDays = opts.validDays ?? 30;
|
|
463
462
|
const serialNumber = freshSerial();
|
|
464
|
-
const notAfter = new Date(now.getTime() + validDays * MS_PER_DAY);
|
|
463
|
+
const notAfter = opts.validDays === void 0 ? new Date(MESH_LEAF_NOT_AFTER) : new Date(now.getTime() + opts.validDays * MS_PER_DAY);
|
|
465
464
|
const extensions = [
|
|
466
465
|
new BasicConstraintsExtension(false, void 0, true),
|
|
467
466
|
new KeyUsagesExtension(KeyUsageFlags.digitalSignature, true),
|
|
@@ -1499,6 +1498,18 @@ function emitProcessNodeRegistered(nodeId, addonIds) {
|
|
|
1499
1498
|
listener(nodeId, addonIds);
|
|
1500
1499
|
} catch {}
|
|
1501
1500
|
}
|
|
1501
|
+
var REPORTER_SLOT = Symbol.for("camstack.cluster.mesh-handshake-reporter");
|
|
1502
|
+
function setProcessMeshHandshakeReporter(reporter) {
|
|
1503
|
+
if (reporter === null) Reflect.deleteProperty(globalThis, REPORTER_SLOT);
|
|
1504
|
+
else Reflect.set(globalThis, REPORTER_SLOT, reporter);
|
|
1505
|
+
}
|
|
1506
|
+
function isHandshakeReporter(value) {
|
|
1507
|
+
return value !== null && typeof value === "object" && typeof Reflect.get(value, "warn") === "function";
|
|
1508
|
+
}
|
|
1509
|
+
function getProcessMeshHandshakeReporter() {
|
|
1510
|
+
const value = Reflect.get(globalThis, REPORTER_SLOT);
|
|
1511
|
+
return isHandshakeReporter(value) ? value : null;
|
|
1512
|
+
}
|
|
1502
1513
|
//#endregion
|
|
1503
1514
|
//#region src/kernel/moleculer/mesh-mtls/mesh-tls-enabler.ts
|
|
1504
1515
|
var SLOT = Symbol.for("camstack.mesh.tls-enabler");
|
|
@@ -86733,6 +86744,63 @@ import_moleculer.default.Utils;
|
|
|
86733
86744
|
import_moleculer.default.Validator;
|
|
86734
86745
|
import_moleculer.default.Validators;
|
|
86735
86746
|
//#endregion
|
|
86747
|
+
//#region src/kernel/moleculer/mesh-mtls/mesh-peer-verification.ts
|
|
86748
|
+
/**
|
|
86749
|
+
* The hub's judgement of a mesh peer's leaf (#558, amends D857).
|
|
86750
|
+
*
|
|
86751
|
+
* Node verifies the chain and the clock in one step and reports a single error, so an expired leaf
|
|
86752
|
+
* and a forged one both fail the handshake. The listener therefore keeps verification ON but lets
|
|
86753
|
+
* the handshake finish (`rejectUnauthorized: false` reports `authorized` / `authorizationError`),
|
|
86754
|
+
* and decides here, explicitly: a peer is admitted when it is authorized, or - on the hub only -
|
|
86755
|
+
* when its sole failure is `CERT_HAS_EXPIRED` AND an independent check proves the leaf is signed by
|
|
86756
|
+
* the mesh CA, is a client-auth end entity, has started, and is not on the CRL. Revocation stays the
|
|
86757
|
+
* kill switch.
|
|
86758
|
+
*/
|
|
86759
|
+
function chainsToCa(leaf, ca, now) {
|
|
86760
|
+
if (now < Date.parse(ca.validFrom) || now > Date.parse(ca.validTo)) return false;
|
|
86761
|
+
if (!leaf.checkIssued(ca)) return false;
|
|
86762
|
+
if (!leaf.verify(ca.publicKey)) return false;
|
|
86763
|
+
if (leaf.ca) return false;
|
|
86764
|
+
return (leaf.keyUsage ?? []).includes(CLIENT_AUTH_OID);
|
|
86765
|
+
}
|
|
86766
|
+
function refused(reason, nodeId, detail) {
|
|
86767
|
+
return {
|
|
86768
|
+
admit: false,
|
|
86769
|
+
reason,
|
|
86770
|
+
nodeId,
|
|
86771
|
+
detail
|
|
86772
|
+
};
|
|
86773
|
+
}
|
|
86774
|
+
function judgeMeshPeerLeaf(input) {
|
|
86775
|
+
if (input.leafDer === void 0) return refused("no-certificate", null, "no client certificate");
|
|
86776
|
+
let leaf;
|
|
86777
|
+
let ca;
|
|
86778
|
+
try {
|
|
86779
|
+
leaf = new X509Certificate(input.leafDer);
|
|
86780
|
+
ca = new X509Certificate(input.caCertPem);
|
|
86781
|
+
} catch {
|
|
86782
|
+
return refused("not-chained", null, "unparseable certificate");
|
|
86783
|
+
}
|
|
86784
|
+
const nodeId = subjectCn(leaf.subject);
|
|
86785
|
+
if (nodeId === null || nodeId.length === 0) return refused("cn-mismatch", null, "leaf has no CN");
|
|
86786
|
+
const timeOnly = !input.authorized && input.authorizationError === "CERT_HAS_EXPIRED";
|
|
86787
|
+
if (!input.authorized && !timeOnly) return refused(input.authorizationError === "CERT_NOT_YET_VALID" ? "not-yet-valid" : "not-chained", nodeId, input.authorizationError ?? "unverified");
|
|
86788
|
+
if (timeOnly) {
|
|
86789
|
+
if (!chainsToCa(leaf, ca, input.now)) return refused("not-chained", nodeId, "expired and not signed by the mesh CA");
|
|
86790
|
+
if (input.now < Date.parse(leaf.validFrom)) return refused("not-yet-valid", nodeId, "leaf not valid yet");
|
|
86791
|
+
}
|
|
86792
|
+
const serial = leaf.serialNumber;
|
|
86793
|
+
if (input.crl.isRevoked(serial)) return refused("revoked", nodeId, `serial ${serial} is revoked`);
|
|
86794
|
+
if (timeOnly && !input.admitExpired) return refused("expired", nodeId, "leaf expired");
|
|
86795
|
+
return {
|
|
86796
|
+
admit: true,
|
|
86797
|
+
nodeId,
|
|
86798
|
+
serial,
|
|
86799
|
+
expired: timeOnly,
|
|
86800
|
+
notAfter: Date.parse(leaf.validTo)
|
|
86801
|
+
};
|
|
86802
|
+
}
|
|
86803
|
+
//#endregion
|
|
86736
86804
|
//#region src/kernel/moleculer/mesh-mtls/tls-tcp-transporter.ts
|
|
86737
86805
|
/**
|
|
86738
86806
|
* Moleculer TCP transporter with a mutual-TLS listener (D826, D848).
|
|
@@ -86850,6 +86918,8 @@ var TlsTcpTransporter = class extends TcpTransporterBase {
|
|
|
86850
86918
|
tlsServer = null;
|
|
86851
86919
|
meshTls;
|
|
86852
86920
|
crl;
|
|
86921
|
+
handshakeReporter;
|
|
86922
|
+
refusalLoggedAt = /* @__PURE__ */ new Map();
|
|
86853
86923
|
revokedPeerLoggedAt = /* @__PURE__ */ new Map();
|
|
86854
86924
|
tlsSockets = /* @__PURE__ */ new Set();
|
|
86855
86925
|
/** Node id (certificate CN) → serial of every peer that completed a mutual-TLS handshake. */
|
|
@@ -86872,6 +86942,7 @@ var TlsTcpTransporter = class extends TcpTransporterBase {
|
|
|
86872
86942
|
super({ ...opts });
|
|
86873
86943
|
this.meshTls = opts.meshTls ?? null;
|
|
86874
86944
|
this.crl = opts.crl ?? processMeshCrl();
|
|
86945
|
+
this.handshakeReporter = opts.handshakeReporter;
|
|
86875
86946
|
this.hubTlsOnly = opts.hubTlsOnly === true;
|
|
86876
86947
|
this.hubOnlyPeers = opts.hubOnlyPeers === true;
|
|
86877
86948
|
this.hubNodeId = opts.hubNodeId ?? DEFAULT_HUB_NODE_ID;
|
|
@@ -86948,10 +87019,11 @@ var TlsTcpTransporter = class extends TcpTransporterBase {
|
|
|
86948
87019
|
key: material.keyPem,
|
|
86949
87020
|
cert: material.certPem,
|
|
86950
87021
|
ca: [material.caCertPem],
|
|
86951
|
-
rejectUnauthorized:
|
|
87022
|
+
rejectUnauthorized: !self.hubTlsOnly,
|
|
86952
87023
|
minVersion: "TLSv1.3",
|
|
86953
87024
|
servername: nodeID,
|
|
86954
87025
|
checkServerIdentity: (hostname, cert) => {
|
|
87026
|
+
if (self.hubTlsOnly) return void 0;
|
|
86955
87027
|
const cn = typeof cert.subject === "object" && cert.subject !== null && "CN" in cert.subject ? String(cert.subject.CN ?? "") : "";
|
|
86956
87028
|
if (cn !== nodeID) return /* @__PURE__ */ new Error(`Mesh TLS peer CN '${cn}' does not match expected node '${nodeID}' (SNI=${hostname})`);
|
|
86957
87029
|
try {
|
|
@@ -86961,6 +87033,11 @@ var TlsTcpTransporter = class extends TcpTransporterBase {
|
|
|
86961
87033
|
}
|
|
86962
87034
|
}, () => {
|
|
86963
87035
|
const tlsSock = socket;
|
|
87036
|
+
if (self.hubTlsOnly && !self.judgeDialedServer(tlsSock, nodeID, material.caCertPem)) {
|
|
87037
|
+
tlsSock.destroy();
|
|
87038
|
+
reject(/* @__PURE__ */ new Error(`Mesh TLS server of '${nodeID}' refused by the hub`));
|
|
87039
|
+
return;
|
|
87040
|
+
}
|
|
86964
87041
|
tlsSock.nodeID = nodeID;
|
|
86965
87042
|
tlsSock.lastUsed = Date.now();
|
|
86966
87043
|
tlsSock.setNoDelay(true);
|
|
@@ -87110,9 +87187,42 @@ var TlsTcpTransporter = class extends TcpTransporterBase {
|
|
|
87110
87187
|
if (last !== void 0 && at - last < REVOKED_PEER_LOG_INTERVAL_MS) return;
|
|
87111
87188
|
if (this.revokedPeerLoggedAt.size >= 256) this.revokedPeerLoggedAt.clear();
|
|
87112
87189
|
this.revokedPeerLoggedAt.set(nodeId, at);
|
|
87113
|
-
this.
|
|
87114
|
-
|
|
87115
|
-
|
|
87190
|
+
this.reportWarn(`Mesh TLS peer presented a revoked certificate - ${action}`, nodeId, "revoked");
|
|
87191
|
+
}
|
|
87192
|
+
reporter() {
|
|
87193
|
+
return this.handshakeReporter ?? getProcessMeshHandshakeReporter();
|
|
87194
|
+
}
|
|
87195
|
+
/** A WARN that survives the transport log pin: the reporter when there is one, else the logger. */
|
|
87196
|
+
reportWarn(message, nodeId, reason, meta = {}) {
|
|
87197
|
+
const extras = {
|
|
87198
|
+
...nodeId !== null ? { tags: { nodeId } } : {},
|
|
87199
|
+
meta: {
|
|
87200
|
+
reason,
|
|
87201
|
+
...meta
|
|
87202
|
+
}
|
|
87203
|
+
};
|
|
87204
|
+
const reporter = this.reporter();
|
|
87205
|
+
if (reporter !== null) reporter.warn(message, extras);
|
|
87206
|
+
else this.logger.warn(message, extras);
|
|
87207
|
+
}
|
|
87208
|
+
/**
|
|
87209
|
+
* A refusal, once per window. Only `expired` carries a node id that was proven (the chain to the
|
|
87210
|
+
* mesh CA was checked); every other refusal is of a peer nobody vouched for, whose CN is whatever
|
|
87211
|
+
* it wrote. Those are keyed by remote address, and the claimed CN goes in `meta`, never in
|
|
87212
|
+
* `tags.nodeId` - a peer must not mint a log tag or a rate-limit key per CN.
|
|
87213
|
+
*/
|
|
87214
|
+
noteRefusedPeer(claimedCn, reason, detail, remoteAddress) {
|
|
87215
|
+
const proven = reason === "expired" && claimedCn !== null;
|
|
87216
|
+
const origin = remoteAddress?.replace(/^::ffff:/, "") ?? "unknown";
|
|
87217
|
+
const key = proven ? `node:${claimedCn}:${reason}` : `addr:${origin}:${reason}`;
|
|
87218
|
+
const at = Date.now();
|
|
87219
|
+
const last = this.refusalLoggedAt.get(key);
|
|
87220
|
+
if (last !== void 0 && at - last < REVOKED_PEER_LOG_INTERVAL_MS) return;
|
|
87221
|
+
if (this.refusalLoggedAt.size >= 256) this.refusalLoggedAt.clear();
|
|
87222
|
+
this.refusalLoggedAt.set(key, at);
|
|
87223
|
+
this.reportWarn(`Mesh TLS handshake refused (${reason}): ${detail}`, proven ? claimedCn : null, reason, proven ? { remoteAddress: origin } : {
|
|
87224
|
+
remoteAddress: origin,
|
|
87225
|
+
...claimedCn !== null ? { claimedNodeId: claimedCn } : {}
|
|
87116
87226
|
});
|
|
87117
87227
|
}
|
|
87118
87228
|
/** Close sockets whose peer serial was just revoked. */
|
|
@@ -87228,11 +87338,11 @@ var TlsTcpTransporter = class extends TcpTransporterBase {
|
|
|
87228
87338
|
cert: material.certPem,
|
|
87229
87339
|
ca: [material.caCertPem],
|
|
87230
87340
|
requestCert: true,
|
|
87231
|
-
rejectUnauthorized:
|
|
87341
|
+
rejectUnauthorized: false,
|
|
87232
87342
|
minVersion: "TLSv1.3"
|
|
87233
87343
|
}, (socket) => this.onTlsClientConnected(socket));
|
|
87234
|
-
server.on("tlsClientError", (err) => {
|
|
87235
|
-
this.
|
|
87344
|
+
server.on("tlsClientError", (err, failed) => {
|
|
87345
|
+
this.noteRefusedPeer(null, "handshake-failed", `TLS handshake failed: ${err.message}`, failed.remoteAddress);
|
|
87236
87346
|
});
|
|
87237
87347
|
server.on("error", (err) => {
|
|
87238
87348
|
this.logger.error("Mesh TLS server error.", err);
|
|
@@ -87252,20 +87362,69 @@ var TlsTcpTransporter = class extends TcpTransporterBase {
|
|
|
87252
87362
|
});
|
|
87253
87363
|
});
|
|
87254
87364
|
}
|
|
87255
|
-
|
|
87256
|
-
|
|
87257
|
-
|
|
87258
|
-
|
|
87259
|
-
|
|
87260
|
-
|
|
87365
|
+
/**
|
|
87366
|
+
* The hub let a peer in on a leaf that only expired: say so, and hand the node to the renewal,
|
|
87367
|
+
* which swaps it for the no-expiry leaf. The WARN is not rate limited - it is a recovery event.
|
|
87368
|
+
*/
|
|
87369
|
+
admitExpiredLeaf(nodeId, serial, notAfter) {
|
|
87370
|
+
this.reportWarn(`Mesh leaf of node '${nodeId}' expired ${new Date(notAfter).toISOString()} - admitted for recovery, renewing it`, nodeId, "expired");
|
|
87371
|
+
this.reporter()?.expiredLeafAdmitted?.({
|
|
87372
|
+
nodeId,
|
|
87373
|
+
serial,
|
|
87374
|
+
notAfter
|
|
87375
|
+
});
|
|
87376
|
+
}
|
|
87377
|
+
/**
|
|
87378
|
+
* The hub dialed a peer's TLS server: apply the verdict the inbound side applies (chain, CRL,
|
|
87379
|
+
* a leaf that only expired is admitted) plus the CN must be the node dialed. The expired
|
|
87380
|
+
* admission is not announced here: the peer's own inbound connection already hands the node to
|
|
87381
|
+
* the renewal, and a second trigger would only double the log line.
|
|
87382
|
+
*/
|
|
87383
|
+
judgeDialedServer(socket, nodeID, caCertPem) {
|
|
87384
|
+
const presented = socket.getPeerCertificate(true);
|
|
87385
|
+
const verdict = judgeMeshPeerLeaf({
|
|
87386
|
+
leafDer: presented != null && typeof presented === "object" && Buffer.isBuffer(presented.raw) ? presented.raw : void 0,
|
|
87387
|
+
authorized: socket.authorized,
|
|
87388
|
+
authorizationError: authorizationCodeOf(socket.authorizationError),
|
|
87389
|
+
caCertPem,
|
|
87390
|
+
crl: this.crl,
|
|
87391
|
+
admitExpired: true,
|
|
87392
|
+
now: Date.now()
|
|
87393
|
+
});
|
|
87394
|
+
if (!verdict.admit) {
|
|
87395
|
+
if (verdict.reason === "revoked") this.noteRevokedPeer(verdict.nodeId ?? nodeID, "refusing to dial it");
|
|
87396
|
+
else this.noteRefusedPeer(verdict.nodeId, verdict.reason, verdict.detail, socket.remoteAddress);
|
|
87397
|
+
return false;
|
|
87398
|
+
}
|
|
87399
|
+
if (verdict.nodeId !== nodeID) {
|
|
87400
|
+
this.noteRefusedPeer(verdict.nodeId, "cn-mismatch", `dialed '${nodeID}' but it presented '${verdict.nodeId}'`, socket.remoteAddress);
|
|
87401
|
+
return false;
|
|
87261
87402
|
}
|
|
87262
|
-
|
|
87263
|
-
|
|
87403
|
+
return true;
|
|
87404
|
+
}
|
|
87405
|
+
onTlsClientConnected(socket) {
|
|
87406
|
+
const presented = socket.getPeerCertificate(true);
|
|
87407
|
+
const verdict = judgeMeshPeerLeaf({
|
|
87408
|
+
leafDer: presented != null && typeof presented === "object" && Buffer.isBuffer(presented.raw) ? presented.raw : void 0,
|
|
87409
|
+
authorized: socket.authorized,
|
|
87410
|
+
authorizationError: authorizationCodeOf(socket.authorizationError),
|
|
87411
|
+
caCertPem: (this.meshTls ?? { caCertPem: "" }).caCertPem,
|
|
87412
|
+
crl: this.crl,
|
|
87413
|
+
admitExpired: this.hubTlsOnly,
|
|
87414
|
+
now: Date.now()
|
|
87415
|
+
});
|
|
87416
|
+
if (!verdict.admit) {
|
|
87417
|
+
if (verdict.reason === "revoked") this.noteRevokedPeer(verdict.nodeId ?? "unknown", "rejecting its connection");
|
|
87418
|
+
else this.noteRefusedPeer(verdict.nodeId, verdict.reason, verdict.detail, socket.remoteAddress);
|
|
87264
87419
|
socket.destroy();
|
|
87265
87420
|
return;
|
|
87266
87421
|
}
|
|
87422
|
+
const identity = {
|
|
87423
|
+
cn: verdict.nodeId,
|
|
87424
|
+
serial: verdict.serial
|
|
87425
|
+
};
|
|
87267
87426
|
if (this.hubOnlyPeers && identity.cn !== this.hubNodeId) {
|
|
87268
|
-
this.
|
|
87427
|
+
this.noteRefusedPeer(identity.cn, "cn-mismatch", `an enrolled agent accepts only '${this.hubNodeId}' (D848)`, socket.remoteAddress);
|
|
87269
87428
|
socket.destroy();
|
|
87270
87429
|
return;
|
|
87271
87430
|
}
|
|
@@ -87274,6 +87433,7 @@ var TlsTcpTransporter = class extends TcpTransporterBase {
|
|
|
87274
87433
|
this.tlsSockets.add(socket);
|
|
87275
87434
|
this.tlsPeers.set(identity.cn, identity.serial);
|
|
87276
87435
|
this.rememberPeerLeaf(identity.cn, socket);
|
|
87436
|
+
if (verdict.expired) this.admitExpiredLeaf(identity.cn, identity.serial, verdict.notAfter);
|
|
87277
87437
|
const reader = this.reader;
|
|
87278
87438
|
socket.on("close", () => {
|
|
87279
87439
|
this.tlsSockets.delete(socket);
|
|
@@ -87299,6 +87459,12 @@ var TlsTcpTransporter = class extends TcpTransporterBase {
|
|
|
87299
87459
|
});
|
|
87300
87460
|
}
|
|
87301
87461
|
};
|
|
87462
|
+
/** Node types the server-side `authorizationError` as an Error but sets the OpenSSL code name. */
|
|
87463
|
+
function authorizationCodeOf(error) {
|
|
87464
|
+
if (typeof error === "string") return error;
|
|
87465
|
+
if (error instanceof Error) return error.message;
|
|
87466
|
+
return null;
|
|
87467
|
+
}
|
|
87302
87468
|
function isTlsSocket(socket) {
|
|
87303
87469
|
return typeof socket.getPeerCertificate === "function" && typeof socket.encrypted === "boolean" && socket.encrypted === true;
|
|
87304
87470
|
}
|
|
@@ -89309,4 +89475,4 @@ function parseMintUnlockInput(input) {
|
|
|
89309
89475
|
};
|
|
89310
89476
|
}
|
|
89311
89477
|
//#endregion
|
|
89312
|
-
export {
|
|
89478
|
+
export { getProcessMeshCaState as $, emitProcessNodeRegistered as A, readCidrSetting as At, getProcessMeshTlsListenerState as B, verifyMembershipAnswer as C, isInsecureOrigin as Ct, ServiceBroker as D, createCidrMatcher as Dt, Errors as E, readOriginSetting as Et, onProcessNodeRegistered as F, MeshCertificateRegistry as G, setProcessMeshTlsListenerState as H, setProcessMeshHandshakeReporter as I, getProcessMeshCertificateRegistry as J, RENEWAL_ABANDONED as K, setProcessMeshPeerTransportLookup as L, getProcessNodeMeshTransport as M, getProcessPeerLeaf as N, setProcessMeshTlsEnabler as O, normalizeIp as Ot, isProcessVerifiedMeshPeer as P, MeshCaKeeper as Q, renewMeshCertificate as R, signMembershipProof as S, SYSTEM_CONFIG_CLUSTER_SECTION_ID, OPAQUE_ORIGIN as St, SystemConfigAddon, SystemConfigAddon as default, TlsTcpTransporter as T, parseOriginList as Tt, MESH_NODE_CERTIFICATES_COLLECTION as U, openMeshTlsWhenRevocationsLoaded as V, MESH_NODE_CERTIFICATES_COLUMNS as W, MeshCrl as X, setProcessMeshCertificateRegistry as Y, processMeshCrl as Z, keyFingerprintShort as _, isAllowedAgentDashboardReturnTo as _t, dialableHubHost as a, generateMeshCa as at, MEMBERSHIP_PATHS as b, verifyAgentUiUnlockTicket as bt, PAIRING_MAX_CODE_ATTEMPTS as c, issueMeshLeafForNode as ct, PAIRING_PIN_DIGITS as d, AGENT_DASHBOARD_ORIGINS_FIELD as dt, requireProcessMeshCa as et, PAIRING_PROTOCOL as f, AGENT_UI_UNLOCK_TTL_MS as ft, describeCsr as g, UnlockTicketJtiStore as gt, computePairingSas as h, AGENT_UI_UNLOCK_VERSION as ht, AgentPairing as i, exportMeshPrivateKeyPem as it, getProcessMeshHandshakeReporter as j, dropProcessPeer as k, parseCidrList as kt, PAIRING_MAX_SESSIONS as l, issueMeshLeafFromCsr as lt, computePairingCommitment as m, AGENT_UI_UNLOCK_USE as mt, HubPairing as n, caFingerprintCompact as nt, hubHostFromMeshAddress as o, generateMeshKeyPair as ot, PAIRING_TTL_MS as p, AGENT_UI_UNLOCK_TYP as pt, describeMeshLeaf as q, PairingHttpError as r, createMeshCsrPem as rt, PAIRING_CODE_DIGITS as s, isValidAgentNodeId as st, systemConfigMeshActions as t, caFingerprint as tt, PAIRING_PATHS as u, loadMeshCa as ut, signPairingProof as v, mintAgentUiUnlockTicket as vt, MESH_TLS_PORT_HELLO_FIELD as w, normalizeOrigin as wt, MembershipResponder as x, InvalidCorsOriginError as xt, verifyPairingProof as y, parseAgentDashboardOrigins as yt, revokeMeshCertificate as z };
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-AbO-Bmtw.js");
|
|
7
7
|
const require_formatter = require("../../formatter-xbxeV4GD.js");
|
|
8
8
|
const require_log_file_read_protocol = require("../../log-file-read-protocol-DSV_vQRb.js");
|
|
9
9
|
let node_path = require("node:path");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ic as defineAddonMigrations, Ls as BaseAddon, Vi as logDestinationCapability, xa as preconditionOf } from "../../dist-CIUo0MpB.mjs";
|
|
2
2
|
import { t as formatLogLine } from "../../formatter-DkYZ4LXp.mjs";
|
|
3
3
|
import { a as LogFileIndexStore, i as serveRead, n as isFromReader, t as CancelBook } from "../../log-file-read-protocol-hTaAsYlX.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_dist = require("./dist-
|
|
1
|
+
const require_dist = require("./dist-AbO-Bmtw.js");
|
|
2
2
|
//#region src/builtins/device-history/store/series-registry.ts
|
|
3
3
|
function subjectIdOf(subject) {
|
|
4
4
|
return subject.kind === "device" ? `d:${subject.deviceId}` : `n:${subject.nodeId}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Il as DeviceType, Kc as historyItemFieldPath, qs as HISTORY_DEFAULT_MIN_INTERVAL_MS } from "./dist-CIUo0MpB.mjs";
|
|
2
2
|
//#region src/builtins/device-history/store/series-registry.ts
|
|
3
3
|
function subjectIdOf(subject) {
|
|
4
4
|
return subject.kind === "device" ? `d:${subject.deviceId}` : `n:${subject.nodeId}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ll as errMsg, vs as compositionSourceKey } from "./dist-CIUo0MpB.mjs";
|
|
2
2
|
//#region src/builtins/shared/device-state-changed.ts
|
|
3
3
|
/** Structural narrowing helper for untrusted bus payloads. */
|
|
4
4
|
function isRecord(value) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** `secret://system/global/meshCaKey` — EC P-256 PKCS#8 PEM of the hub mesh CA. */
|
|
2
|
-
var MESH_CA_KEY_REF = require("./dist-
|
|
2
|
+
var MESH_CA_KEY_REF = require("./dist-AbO-Bmtw.js").buildSecretRef({
|
|
3
3
|
owner: "system",
|
|
4
4
|
scope: { kind: "global" },
|
|
5
5
|
fieldPath: "meshCaKey"
|
|
@@ -8,6 +8,13 @@ var MESH_CA_KEY_REF = require("./dist-8pvVkKh4.js").buildSecretRef({
|
|
|
8
8
|
var MESH_CA_SETTINGS_KEY = "cluster.meshCa";
|
|
9
9
|
/** Field inside the `cluster` section. */
|
|
10
10
|
var MESH_CA_FIELD = "meshCa";
|
|
11
|
+
/**
|
|
12
|
+
* A mesh leaf does not expire (#558, amends D857): RFC 5280 section 4.1.2.5 "no well-defined
|
|
13
|
+
* expiration date" is 9999-12-31T23:59:59Z. Identity ends by revocation (the CRL) or by an explicit
|
|
14
|
+
* rotation (`certificates.renewMeshOnNode`), never by the clock.
|
|
15
|
+
*/
|
|
16
|
+
var MESH_LEAF_NOT_AFTER = /* @__PURE__ */ new Date("9999-12-31T23:59:59Z");
|
|
17
|
+
/** The mesh CA lifetime. Leaves outlive it on purpose: chain building does not nest validity. */
|
|
11
18
|
var MESH_CA_VALIDITY_DAYS = 3650;
|
|
12
19
|
var DEFAULT_HUB_TLS_TCP_PORT = 6443;
|
|
13
20
|
/** Subject of the mesh root. Distinct from the HTTPS local CA. */
|
|
@@ -58,6 +65,12 @@ Object.defineProperty(exports, "MESH_CA_VALIDITY_DAYS", {
|
|
|
58
65
|
return MESH_CA_VALIDITY_DAYS;
|
|
59
66
|
}
|
|
60
67
|
});
|
|
68
|
+
Object.defineProperty(exports, "MESH_LEAF_NOT_AFTER", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function() {
|
|
71
|
+
return MESH_LEAF_NOT_AFTER;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
61
74
|
Object.defineProperty(exports, "SERVER_AUTH_OID", {
|
|
62
75
|
enumerable: true,
|
|
63
76
|
get: function() {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Dc as buildSecretRef } from "./dist-CIUo0MpB.mjs";
|
|
2
|
+
/** `secret://system/global/meshCaKey` — EC P-256 PKCS#8 PEM of the hub mesh CA. */
|
|
3
|
+
var MESH_CA_KEY_REF = buildSecretRef({
|
|
4
|
+
owner: "system",
|
|
5
|
+
scope: { kind: "global" },
|
|
6
|
+
fieldPath: "meshCaKey"
|
|
7
|
+
});
|
|
8
|
+
/** `system-settings` key holding the public CA certificate PEM. */
|
|
9
|
+
var MESH_CA_SETTINGS_KEY = "cluster.meshCa";
|
|
10
|
+
/** Field inside the `cluster` section. */
|
|
11
|
+
var MESH_CA_FIELD = "meshCa";
|
|
12
|
+
/**
|
|
13
|
+
* A mesh leaf does not expire (#558, amends D857): RFC 5280 section 4.1.2.5 "no well-defined
|
|
14
|
+
* expiration date" is 9999-12-31T23:59:59Z. Identity ends by revocation (the CRL) or by an explicit
|
|
15
|
+
* rotation (`certificates.renewMeshOnNode`), never by the clock.
|
|
16
|
+
*/
|
|
17
|
+
var MESH_LEAF_NOT_AFTER = /* @__PURE__ */ new Date("9999-12-31T23:59:59Z");
|
|
18
|
+
/** The mesh CA lifetime. Leaves outlive it on purpose: chain building does not nest validity. */
|
|
19
|
+
var MESH_CA_VALIDITY_DAYS = 3650;
|
|
20
|
+
var DEFAULT_HUB_TLS_TCP_PORT = 6443;
|
|
21
|
+
/** Subject of the mesh root. Distinct from the HTTPS local CA. */
|
|
22
|
+
var MESH_CA_COMMON_NAME = "CamStack Mesh CA";
|
|
23
|
+
/** Client + server auth EKU OIDs (mutual TLS). */
|
|
24
|
+
var SERVER_AUTH_OID = "1.3.6.1.5.5.7.3.1";
|
|
25
|
+
var CLIENT_AUTH_OID = "1.3.6.1.5.5.7.3.2";
|
|
26
|
+
//#endregion
|
|
27
|
+
export { MESH_CA_KEY_REF as a, MESH_LEAF_NOT_AFTER as c, MESH_CA_FIELD as i, SERVER_AUTH_OID as l, DEFAULT_HUB_TLS_TCP_PORT as n, MESH_CA_SETTINGS_KEY as o, MESH_CA_COMMON_NAME as r, MESH_CA_VALIDITY_DAYS as s, CLIENT_AUTH_OID as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Dc as buildSecretRef, K as DEVICE_SAN_CREDENTIAL_PREFIX, q as DEVICE_SAN_USER_PREFIX } from "./dist-CIUo0MpB.mjs";
|
|
2
2
|
import { C as backdatedNotBefore, S as withUtcTimeEncoding, a as KeyUsageFlags, d as SubjectKeyIdentifierExtension, f as X509Certificate$1, m as cryptoProvider, n as BasicConstraintsExtension, o as KeyUsagesExtension, p as X509CertificateGenerator, r as ExtendedKeyUsageExtension, s as PemConverter, t as AuthorityKeyIdentifierExtension, u as SubjectAlternativeNameExtension } from "./x509.es-BRiJgOvu.mjs";
|
|
3
3
|
import { X509Certificate, createPublicKey, randomBytes, verify, webcrypto } from "node:crypto";
|
|
4
4
|
//#region src/auth/jwt-signing-key.ts
|