camstack 1.2.194 → 1.2.195
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/dist/cli.js +23 -69
- package/dist/{launcher-UJ7M7YRF.js → launcher-VKN5MWTJ.js} +967 -1918
- package/package.json +1 -1
|
@@ -24024,9 +24024,9 @@ var require_zod = __commonJS({
|
|
|
24024
24024
|
}
|
|
24025
24025
|
});
|
|
24026
24026
|
|
|
24027
|
-
// ../system/dist/dist-
|
|
24028
|
-
var
|
|
24029
|
-
"../system/dist/dist-
|
|
24027
|
+
// ../system/dist/dist-Bn-RNanh.js
|
|
24028
|
+
var require_dist_Bn_RNanh = __commonJS({
|
|
24029
|
+
"../system/dist/dist-Bn-RNanh.js"(exports) {
|
|
24030
24030
|
"use strict";
|
|
24031
24031
|
var zod = require_zod();
|
|
24032
24032
|
__require("crypto");
|
|
@@ -26671,7 +26671,13 @@ var require_dist_BZQjLPiz = __commonJS({
|
|
|
26671
26671
|
secretPaths: zod.z.array(zod.z.string().min(1)).default([]),
|
|
26672
26672
|
/** The id key of each array that carries a secret (`{ headers: 'name' }`). */
|
|
26673
26673
|
secretArrayKeys: zod.z.record(zod.z.string(), zod.z.string()).default({}),
|
|
26674
|
-
/**
|
|
26674
|
+
/**
|
|
26675
|
+
* RETIRED (D900): the legacy table a kind adopted from during the records
|
|
26676
|
+
* migration. Nothing declares it any more and nothing reads it; the schema
|
|
26677
|
+
* still ACCEPTS it because the catalog rows the migration wrote carry it
|
|
26678
|
+
* (an orphaned kind is never redeclared) and an addon built before the
|
|
26679
|
+
* removal still sends it. Never set it.
|
|
26680
|
+
*/
|
|
26675
26681
|
adoptsFrom: zod.z.string().min(1).optional(),
|
|
26676
26682
|
/** Kinds that must agree through `transact` sit in one file under one family name. */
|
|
26677
26683
|
transactFamily: zod.z.string().min(1).optional(),
|
|
@@ -26738,7 +26744,6 @@ var require_dist_BZQjLPiz = __commonJS({
|
|
|
26738
26744
|
maxDataBytes: spec.maxDataBytes,
|
|
26739
26745
|
secretPaths: [...secretPaths],
|
|
26740
26746
|
secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
|
|
26741
|
-
adoptsFrom: spec.adoptsFrom,
|
|
26742
26747
|
transactFamily: spec.transactFamily,
|
|
26743
26748
|
entry: spec.entry === void 0 ? void 0 : {
|
|
26744
26749
|
title: spec.entry.title,
|
|
@@ -26755,27 +26760,6 @@ var require_dist_BZQjLPiz = __commonJS({
|
|
|
26755
26760
|
}
|
|
26756
26761
|
return out;
|
|
26757
26762
|
}
|
|
26758
|
-
function declarationsOf(kinds) {
|
|
26759
|
-
return Object.fromEntries(Object.entries(kinds).map(([name, kind]) => [name, kind.declaration]));
|
|
26760
|
-
}
|
|
26761
|
-
function parseSettingsBrokersAdoptsFrom(from) {
|
|
26762
|
-
if (!from.startsWith("@settings-brokers/")) return null;
|
|
26763
|
-
const addonId = from.slice(18);
|
|
26764
|
-
return addonId.length > 0 ? addonId : null;
|
|
26765
|
-
}
|
|
26766
|
-
function parseSettingsArrayAdoptsFrom(from) {
|
|
26767
|
-
if (!from.startsWith("@settings-array/")) return null;
|
|
26768
|
-
const rest = from.slice(16);
|
|
26769
|
-
const slash = rest.indexOf("/");
|
|
26770
|
-
if (slash <= 0 || slash >= rest.length - 1) return null;
|
|
26771
|
-
const addonId = rest.slice(0, slash);
|
|
26772
|
-
const settingsKey = rest.slice(slash + 1);
|
|
26773
|
-
if (addonId.length === 0 || settingsKey.length === 0) return null;
|
|
26774
|
-
return {
|
|
26775
|
-
addonId,
|
|
26776
|
-
settingsKey
|
|
26777
|
-
};
|
|
26778
|
-
}
|
|
26779
26763
|
var CamProfileSchema = zod.z.enum([
|
|
26780
26764
|
"high",
|
|
26781
26765
|
"mid",
|
|
@@ -36873,11 +36857,12 @@ var require_dist_BZQjLPiz = __commonJS({
|
|
|
36873
36857
|
kindId: zod.z.number().int(),
|
|
36874
36858
|
state: RecordKindStateSchema,
|
|
36875
36859
|
createdIndexes: zod.z.array(zod.z.string()),
|
|
36876
|
-
/**
|
|
36877
|
-
|
|
36878
|
-
|
|
36879
|
-
|
|
36880
|
-
|
|
36860
|
+
/**
|
|
36861
|
+
* RETIRED (D900): always `null`. It carried the records-migration boot guard;
|
|
36862
|
+
* it stays on the wire, null, because an addon built before the removal reads
|
|
36863
|
+
* an ABSENT field as "adoption pending" and refuses to start.
|
|
36864
|
+
*/
|
|
36865
|
+
adoptionPending: zod.z.null()
|
|
36881
36866
|
});
|
|
36882
36867
|
var SecretRefsList = zod.z.array(zod.z.string());
|
|
36883
36868
|
var RecordSecretRefsSchema = zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.string()));
|
|
@@ -37067,19 +37052,7 @@ var require_dist_BZQjLPiz = __commonJS({
|
|
|
37067
37052
|
"stream-broker:rtsp-tokens",
|
|
37068
37053
|
"notification-center:device-mutes",
|
|
37069
37054
|
"recorder:recording-configs",
|
|
37070
|
-
"pipeline-orchestrator:device-features"
|
|
37071
|
-
"pipeline-analytics:stats-5m",
|
|
37072
|
-
"pipeline-orchestrator:stats-5m",
|
|
37073
|
-
"vec_object_clip",
|
|
37074
|
-
"addon-devices",
|
|
37075
|
-
"sections",
|
|
37076
|
-
"provider-settings",
|
|
37077
|
-
"device-settings",
|
|
37078
|
-
"ai:budgets",
|
|
37079
|
-
"pipeline-analytics:retrain-dataset-versions",
|
|
37080
|
-
"training:dataset-versions",
|
|
37081
|
-
"benchmark:replay-runs",
|
|
37082
|
-
"viewer-settings-snapshots"
|
|
37055
|
+
"pipeline-orchestrator:device-features"
|
|
37083
37056
|
];
|
|
37084
37057
|
var STORAGE_ADMIN_SCOPED_BASES = [
|
|
37085
37058
|
"addon-settings",
|
|
@@ -37130,42 +37103,7 @@ var require_dist_BZQjLPiz = __commonJS({
|
|
|
37130
37103
|
readRecords: method(RecordQueryInputSchema.extend({
|
|
37131
37104
|
owner: zod.z.string().min(1),
|
|
37132
37105
|
kind: RecordKindNameSchema
|
|
37133
|
-
}), RecordQueryResultSchema, { auth: "admin" })
|
|
37134
|
-
/**
|
|
37135
|
-
* The migration copy path (D881): write rows into a kind AS ITS DECLARED
|
|
37136
|
-
* OWNER. Refused when that owner's manifest does not declare the kind.
|
|
37137
|
-
* Idempotent (a put by id, so a re-run resumes). A secret field carries a
|
|
37138
|
-
* keychain marker bound to the row's own ref - the operator script imports
|
|
37139
|
-
* the value first - and a plain string there is refused.
|
|
37140
|
-
*/
|
|
37141
|
-
adoptRecords: method(zod.z.object({
|
|
37142
|
-
owner: zod.z.string().min(1),
|
|
37143
|
-
kind: RecordKindNameSchema,
|
|
37144
|
-
records: zod.z.array(RecordInputSchema).max(RECORD_BATCH_MAX),
|
|
37145
|
-
/** The LAST batch: the copy is complete, the boot guard stops asking. */
|
|
37146
|
-
complete: zod.z.boolean().optional()
|
|
37147
|
-
}).refine((input) => input.records.length > 0 || input.complete === true, { message: "records must be non-empty unless complete is true" }), zod.z.object({ adopted: zod.z.number().int() }), {
|
|
37148
|
-
kind: "mutation",
|
|
37149
|
-
auth: "admin"
|
|
37150
|
-
}),
|
|
37151
|
-
/**
|
|
37152
|
-
* Read rows from a legacy KV table by physical name, without a running
|
|
37153
|
-
* `declareCollection`. Used by `records-adopt.ts` when the owner already
|
|
37154
|
-
* moved to records and the collection door refuses the name.
|
|
37155
|
-
*/
|
|
37156
|
-
readLegacyCollection: method(zod.z.object({
|
|
37157
|
-
collection: zod.z.string().min(1),
|
|
37158
|
-
cursor: zod.z.string().optional(),
|
|
37159
|
-
limit: zod.z.number().int().min(1).max(1e3).optional()
|
|
37160
|
-
}), zod.z.object({
|
|
37161
|
-
rows: zod.z.array(zod.z.object({
|
|
37162
|
-
id: zod.z.string(),
|
|
37163
|
-
data: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
37164
|
-
})),
|
|
37165
|
-
nextCursor: zod.z.string().nullable()
|
|
37166
|
-
}), { auth: "admin" }),
|
|
37167
|
-
/** True when a declared kind lists `collection` as `adoptsFrom` and adoption finished. */
|
|
37168
|
-
isAdoptedLegacyTable: method(zod.z.object({ collection: zod.z.string().min(1) }), zod.z.object({ adopted: zod.z.boolean() }), { auth: "admin" })
|
|
37106
|
+
}), RecordQueryResultSchema, { auth: "admin" })
|
|
37169
37107
|
}
|
|
37170
37108
|
};
|
|
37171
37109
|
var EntryKindInfoSchema = zod.z.object({
|
|
@@ -89394,6 +89332,12 @@ var require_dist_BZQjLPiz = __commonJS({
|
|
|
89394
89332
|
addonId: null,
|
|
89395
89333
|
access: "view"
|
|
89396
89334
|
},
|
|
89335
|
+
"deviceHistory.queryMany": {
|
|
89336
|
+
capName: "device-history",
|
|
89337
|
+
capScope: "system",
|
|
89338
|
+
addonId: null,
|
|
89339
|
+
access: "view"
|
|
89340
|
+
},
|
|
89397
89341
|
"deviceHistory.queryNode": {
|
|
89398
89342
|
capName: "device-history",
|
|
89399
89343
|
capScope: "system",
|
|
@@ -94614,24 +94558,12 @@ var require_dist_BZQjLPiz = __commonJS({
|
|
|
94614
94558
|
addonId: null,
|
|
94615
94559
|
access: "create"
|
|
94616
94560
|
},
|
|
94617
|
-
"storageAdmin.adoptRecords": {
|
|
94618
|
-
capName: "storage-admin",
|
|
94619
|
-
capScope: "system",
|
|
94620
|
-
addonId: null,
|
|
94621
|
-
access: "create"
|
|
94622
|
-
},
|
|
94623
94561
|
"storageAdmin.dropCollection": {
|
|
94624
94562
|
capName: "storage-admin",
|
|
94625
94563
|
capScope: "system",
|
|
94626
94564
|
addonId: null,
|
|
94627
94565
|
access: "delete"
|
|
94628
94566
|
},
|
|
94629
|
-
"storageAdmin.isAdoptedLegacyTable": {
|
|
94630
|
-
capName: "storage-admin",
|
|
94631
|
-
capScope: "system",
|
|
94632
|
-
addonId: null,
|
|
94633
|
-
access: "view"
|
|
94634
|
-
},
|
|
94635
94567
|
"storageAdmin.listKinds": {
|
|
94636
94568
|
capName: "storage-admin",
|
|
94637
94569
|
capScope: "system",
|
|
@@ -94644,12 +94576,6 @@ var require_dist_BZQjLPiz = __commonJS({
|
|
|
94644
94576
|
addonId: null,
|
|
94645
94577
|
access: "view"
|
|
94646
94578
|
},
|
|
94647
|
-
"storageAdmin.readLegacyCollection": {
|
|
94648
|
-
capName: "storage-admin",
|
|
94649
|
-
capScope: "system",
|
|
94650
|
-
addonId: null,
|
|
94651
|
-
access: "view"
|
|
94652
|
-
},
|
|
94653
94579
|
"storageAdmin.readRecords": {
|
|
94654
94580
|
capName: "storage-admin",
|
|
94655
94581
|
capScope: "system",
|
|
@@ -98721,12 +98647,6 @@ var require_dist_BZQjLPiz = __commonJS({
|
|
|
98721
98647
|
form: "single",
|
|
98722
98648
|
optional: false
|
|
98723
98649
|
}],
|
|
98724
|
-
"storageAdmin.adoptRecords": [{
|
|
98725
|
-
name: "records",
|
|
98726
|
-
form: "object-array",
|
|
98727
|
-
optional: false,
|
|
98728
|
-
itemField: "deviceId"
|
|
98729
|
-
}],
|
|
98730
98650
|
"storageAdmin.readRecords": [{
|
|
98731
98651
|
name: "deviceId",
|
|
98732
98652
|
form: "single",
|
|
@@ -101822,12 +101742,6 @@ var require_dist_BZQjLPiz = __commonJS({
|
|
|
101822
101742
|
return declarationOwnerNodeId;
|
|
101823
101743
|
}
|
|
101824
101744
|
});
|
|
101825
|
-
Object.defineProperty(exports, "declarationsOf", {
|
|
101826
|
-
enumerable: true,
|
|
101827
|
-
get: function() {
|
|
101828
|
-
return declarationsOf;
|
|
101829
|
-
}
|
|
101830
|
-
});
|
|
101831
101745
|
Object.defineProperty(exports, "decodeVectorBase64", {
|
|
101832
101746
|
enumerable: true,
|
|
101833
101747
|
get: function() {
|
|
@@ -102308,18 +102222,6 @@ var require_dist_BZQjLPiz = __commonJS({
|
|
|
102308
102222
|
return parseSecretRef;
|
|
102309
102223
|
}
|
|
102310
102224
|
});
|
|
102311
|
-
Object.defineProperty(exports, "parseSettingsArrayAdoptsFrom", {
|
|
102312
|
-
enumerable: true,
|
|
102313
|
-
get: function() {
|
|
102314
|
-
return parseSettingsArrayAdoptsFrom;
|
|
102315
|
-
}
|
|
102316
|
-
});
|
|
102317
|
-
Object.defineProperty(exports, "parseSettingsBrokersAdoptsFrom", {
|
|
102318
|
-
enumerable: true,
|
|
102319
|
-
get: function() {
|
|
102320
|
-
return parseSettingsBrokersAdoptsFrom;
|
|
102321
|
-
}
|
|
102322
|
-
});
|
|
102323
102225
|
Object.defineProperty(exports, "parseStreamParamsFormPatch", {
|
|
102324
102226
|
enumerable: true,
|
|
102325
102227
|
get: function() {
|
|
@@ -114164,11 +114066,11 @@ ${values.join("\n")}` : `${blockName} :`;
|
|
|
114164
114066
|
}
|
|
114165
114067
|
});
|
|
114166
114068
|
|
|
114167
|
-
// ../system/dist/device-ca-
|
|
114168
|
-
var
|
|
114169
|
-
"../system/dist/device-ca-
|
|
114069
|
+
// ../system/dist/device-ca-CPTDs--d.js
|
|
114070
|
+
var require_device_ca_CPTDs_d = __commonJS({
|
|
114071
|
+
"../system/dist/device-ca-CPTDs--d.js"(exports) {
|
|
114170
114072
|
"use strict";
|
|
114171
|
-
var require_dist10 =
|
|
114073
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
114172
114074
|
var require_x509_es = require_x509_es_C4cOo48M();
|
|
114173
114075
|
var node_crypto = __require("crypto");
|
|
114174
114076
|
var SYSTEM_SECRET_OWNER = "system";
|
|
@@ -114583,95 +114485,6 @@ var require_device_ca_BrVK_5s3 = __commonJS({
|
|
|
114583
114485
|
}
|
|
114584
114486
|
});
|
|
114585
114487
|
|
|
114586
|
-
// ../system/dist/phase6-declare-gate-Dag1_WR2.js
|
|
114587
|
-
var require_phase6_declare_gate_Dag1_WR2 = __commonJS({
|
|
114588
|
-
"../system/dist/phase6-declare-gate-Dag1_WR2.js"(exports) {
|
|
114589
|
-
"use strict";
|
|
114590
|
-
var require_dist10 = require_dist_BZQjLPiz();
|
|
114591
|
-
function legacyTableRowCountFromList(tables, collection) {
|
|
114592
|
-
return tables.find((t) => t.name === collection)?.rows ?? 0;
|
|
114593
|
-
}
|
|
114594
|
-
var CAMSTACK_RECORDS_DECLARE_PHASE6 = "CAMSTACK_RECORDS_DECLARE_PHASE6";
|
|
114595
|
-
function isPhase6RecordsDeclareForced() {
|
|
114596
|
-
const raw = process.env[CAMSTACK_RECORDS_DECLARE_PHASE6]?.trim().toLowerCase();
|
|
114597
|
-
return raw === "1" || raw === "true" || raw === "yes";
|
|
114598
|
-
}
|
|
114599
|
-
async function legacyTablesHoldRows(collections, legacyRowCount) {
|
|
114600
|
-
for (const collection of collections) if (await legacyRowCount(collection) > 0) return true;
|
|
114601
|
-
return false;
|
|
114602
|
-
}
|
|
114603
|
-
async function catalogKindsFullyAdopted(owner, kindNames, declarations, listKindsForOwner, isAdoptedLegacyTable) {
|
|
114604
|
-
const listed = await listKindsForOwner(owner);
|
|
114605
|
-
const byKind = new Map(listed.map((k) => [k.kind, k]));
|
|
114606
|
-
for (const name of kindNames) {
|
|
114607
|
-
if (byKind.get(name) === void 0) return false;
|
|
114608
|
-
const legacy = declarations[name]?.adoptsFrom;
|
|
114609
|
-
if (typeof legacy !== "string") continue;
|
|
114610
|
-
if (!await isAdoptedLegacyTable(legacy)) return false;
|
|
114611
|
-
}
|
|
114612
|
-
return true;
|
|
114613
|
-
}
|
|
114614
|
-
async function resolvePhase6UseRecordsPath(deps) {
|
|
114615
|
-
const declarations = require_dist10.declarationsOf(deps.kinds);
|
|
114616
|
-
const kindNames = Object.keys(deps.kinds);
|
|
114617
|
-
if (await catalogKindsFullyAdopted(deps.owner, kindNames, declarations, deps.listKindsForOwner, deps.isAdoptedLegacyTable)) {
|
|
114618
|
-
await deps.records.declare(deps.kinds);
|
|
114619
|
-
return true;
|
|
114620
|
-
}
|
|
114621
|
-
if (!await legacyTablesHoldRows(deps.legacyCollections, deps.legacyRowCount)) {
|
|
114622
|
-
await deps.records.declare(deps.kinds);
|
|
114623
|
-
return true;
|
|
114624
|
-
}
|
|
114625
|
-
if (isPhase6RecordsDeclareForced()) {
|
|
114626
|
-
try {
|
|
114627
|
-
await deps.records.declare(deps.kinds);
|
|
114628
|
-
} catch (err) {
|
|
114629
|
-
if (!(err instanceof Error ? err.message : String(err)).startsWith("records/adoption-pending:")) throw err;
|
|
114630
|
-
deps.log.info("phase 6: records kinds declared; legacy tables until adopt completes", { owner: deps.owner });
|
|
114631
|
-
}
|
|
114632
|
-
return false;
|
|
114633
|
-
}
|
|
114634
|
-
deps.log.info("phase 6: skipping records.declare \u2014 serving legacy collections until adopt completes", { owner: deps.owner });
|
|
114635
|
-
return false;
|
|
114636
|
-
}
|
|
114637
|
-
async function resolvePhase6UseRecordsPathForHub(ctx, owner, kinds, legacyCollections) {
|
|
114638
|
-
const records = ctx.records;
|
|
114639
|
-
const store = ctx.api?.settingsStore;
|
|
114640
|
-
if (records === void 0 || store === void 0) return false;
|
|
114641
|
-
const admin = ctx.api?.storageAdmin;
|
|
114642
|
-
return resolvePhase6UseRecordsPath({
|
|
114643
|
-
owner,
|
|
114644
|
-
records,
|
|
114645
|
-
kinds,
|
|
114646
|
-
legacyCollections,
|
|
114647
|
-
legacyRowCount: async (collection) => {
|
|
114648
|
-
if (admin !== void 0) {
|
|
114649
|
-
const fromEngine = legacyTableRowCountFromList((await admin.listTables.query({})).tables, collection);
|
|
114650
|
-
if (fromEngine > 0) return fromEngine;
|
|
114651
|
-
}
|
|
114652
|
-
try {
|
|
114653
|
-
return await store.count.query({ collection });
|
|
114654
|
-
} catch {
|
|
114655
|
-
return admin === void 0 ? 0 : legacyTableRowCountFromList((await admin.listTables.query({})).tables, collection);
|
|
114656
|
-
}
|
|
114657
|
-
},
|
|
114658
|
-
listKindsForOwner: async (o) => admin === void 0 ? [] : (await admin.listKinds.query({
|
|
114659
|
-
owner: o,
|
|
114660
|
-
counts: false
|
|
114661
|
-
})).kinds,
|
|
114662
|
-
isAdoptedLegacyTable: async (collection) => admin === void 0 ? false : (await admin.isAdoptedLegacyTable.query({ collection })).adopted,
|
|
114663
|
-
log: { info: (message, meta) => ctx.logger.info(message, meta ? { meta } : void 0) }
|
|
114664
|
-
});
|
|
114665
|
-
}
|
|
114666
|
-
Object.defineProperty(exports, "resolvePhase6UseRecordsPathForHub", {
|
|
114667
|
-
enumerable: true,
|
|
114668
|
-
get: function() {
|
|
114669
|
-
return resolvePhase6UseRecordsPathForHub;
|
|
114670
|
-
}
|
|
114671
|
-
});
|
|
114672
|
-
}
|
|
114673
|
-
});
|
|
114674
|
-
|
|
114675
114488
|
// ../system/dist/builtins/alerts/alerts.addon.js
|
|
114676
114489
|
var require_alerts_addon = __commonJS({
|
|
114677
114490
|
"../system/dist/builtins/alerts/alerts.addon.js"(exports) {
|
|
@@ -114681,9 +114494,8 @@ var require_alerts_addon = __commonJS({
|
|
|
114681
114494
|
[Symbol.toStringTag]: { value: "Module" }
|
|
114682
114495
|
});
|
|
114683
114496
|
require_chunk_Cek0wNdY();
|
|
114684
|
-
var require_dist10 =
|
|
114497
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
114685
114498
|
var require_read_all_rows$1 = require_read_all_rows_CVoO1ONM();
|
|
114686
|
-
var require_phase6_declare_gate = require_phase6_declare_gate_Dag1_WR2();
|
|
114687
114499
|
function nextEpisodeId(input) {
|
|
114688
114500
|
const { previous } = input;
|
|
114689
114501
|
if (previous !== null && require_dist10.isAlertEpisodeOpen(previous.status)) {
|
|
@@ -114873,8 +114685,7 @@ var require_alerts_addon = __commonJS({
|
|
|
114873
114685
|
retention: {
|
|
114874
114686
|
owner: "alert-center",
|
|
114875
114687
|
reason: "maxAlerts cap and retentionDays enforced on write (enforceMaxAlerts / enforceRetention); read alerts preferred when trimming overflow"
|
|
114876
|
-
}
|
|
114877
|
-
adoptsFrom: ALERTS_COLLECTION
|
|
114688
|
+
}
|
|
114878
114689
|
} });
|
|
114879
114690
|
var alertCenterRecordKinds = _alertCenterRecordKinds;
|
|
114880
114691
|
var alertsRecordKind = _alertCenterRecordKinds.alerts;
|
|
@@ -115229,8 +115040,8 @@ var require_alerts_addon = __commonJS({
|
|
|
115229
115040
|
async onInitialize() {
|
|
115230
115041
|
const records = this.ctx.records;
|
|
115231
115042
|
const store = this.ctx.api?.settingsStore;
|
|
115232
|
-
|
|
115233
|
-
this.alertStore =
|
|
115043
|
+
if (records !== void 0) await records.declare(alertCenterRecordKinds);
|
|
115044
|
+
this.alertStore = records !== void 0 ? AlertStore.of(records) : store === void 0 ? null : AlertStore.legacy(store);
|
|
115234
115045
|
if (this.alertStore === null) throw new Error("alert-center needs ctx.records or settings-store on the hub");
|
|
115235
115046
|
const alertsProvider = {
|
|
115236
115047
|
emit: (alert) => this.emitAlert(alert),
|
|
@@ -116088,7 +115899,7 @@ var require_calendars_addon = __commonJS({
|
|
|
116088
115899
|
[Symbol.toStringTag]: { value: "Module" }
|
|
116089
115900
|
});
|
|
116090
115901
|
require_chunk_Cek0wNdY();
|
|
116091
|
-
var require_dist10 =
|
|
115902
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
116092
115903
|
var require_settle_sources = require_settle_sources_Bhsy57y();
|
|
116093
115904
|
var zod = require_zod();
|
|
116094
115905
|
var CALENDAR_COLOR_PALETTE = [
|
|
@@ -116113,7 +115924,6 @@ var require_calendars_addon = __commonJS({
|
|
|
116113
115924
|
}
|
|
116114
115925
|
return CALENDAR_COLOR_PALETTE[Math.abs(hash) % CALENDAR_COLOR_PALETTE.length];
|
|
116115
115926
|
}
|
|
116116
|
-
var CALENDARS_USER_PREFS_COLLECTION = "calendars:user-prefs";
|
|
116117
115927
|
var CalendarUserPrefsBodySchema = zod.z.object({
|
|
116118
115928
|
calendars: require_dist10.CalendarPreferencesSchema.shape.calendars,
|
|
116119
115929
|
updatedAt: zod.z.number()
|
|
@@ -116128,8 +115938,7 @@ var require_calendars_addon = __commonJS({
|
|
|
116128
115938
|
name: "updated_at",
|
|
116129
115939
|
fields: ["updatedAt"]
|
|
116130
115940
|
}],
|
|
116131
|
-
retention: { none: "a missing row reads as empty prefs (all visible, system colours)" }
|
|
116132
|
-
adoptsFrom: CALENDARS_USER_PREFS_COLLECTION
|
|
115941
|
+
retention: { none: "a missing row reads as empty prefs (all visible, system colours)" }
|
|
116133
115942
|
} });
|
|
116134
115943
|
var calendarsRecordKinds = _calendarsRecordKinds;
|
|
116135
115944
|
_calendarsRecordKinds["user-prefs"];
|
|
@@ -116306,11 +116115,11 @@ var require_calendars = __commonJS({
|
|
|
116306
116115
|
}
|
|
116307
116116
|
});
|
|
116308
116117
|
|
|
116309
|
-
// ../system/dist/composition-sources-
|
|
116310
|
-
var
|
|
116311
|
-
"../system/dist/composition-sources-
|
|
116118
|
+
// ../system/dist/composition-sources-b0e_2I-D.js
|
|
116119
|
+
var require_composition_sources_b0e_2I_D = __commonJS({
|
|
116120
|
+
"../system/dist/composition-sources-b0e_2I-D.js"(exports) {
|
|
116312
116121
|
"use strict";
|
|
116313
|
-
var require_dist10 =
|
|
116122
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
116314
116123
|
function normalizedNativeOwner(owner) {
|
|
116315
116124
|
const trimmed = owner?.trim();
|
|
116316
116125
|
return trimmed ? trimmed : null;
|
|
@@ -116425,8 +116234,8 @@ var require_composer_addon = __commonJS({
|
|
|
116425
116234
|
[Symbol.toStringTag]: { value: "Module" }
|
|
116426
116235
|
});
|
|
116427
116236
|
require_chunk_Cek0wNdY();
|
|
116428
|
-
var require_dist10 =
|
|
116429
|
-
var require_composition_sources =
|
|
116237
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
116238
|
+
var require_composition_sources = require_composition_sources_b0e_2I_D();
|
|
116430
116239
|
var zod = require_zod();
|
|
116431
116240
|
function isRecord$2(value) {
|
|
116432
116241
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -120236,7 +120045,7 @@ var require_console_logging = __commonJS({
|
|
|
120236
120045
|
[Symbol.toStringTag]: { value: "Module" }
|
|
120237
120046
|
});
|
|
120238
120047
|
require_chunk_Cek0wNdY();
|
|
120239
|
-
var require_dist10 =
|
|
120048
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
120240
120049
|
var require_formatter = require_formatter_DqAKDlvN();
|
|
120241
120050
|
var LEVEL_RANK = {
|
|
120242
120051
|
debug: 0,
|
|
@@ -124626,9 +124435,9 @@ var require_core_blocks_addon = __commonJS({
|
|
|
124626
124435
|
"use strict";
|
|
124627
124436
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
124628
124437
|
var require_chunk = require_chunk_Cek0wNdY();
|
|
124629
|
-
var require_dist10 =
|
|
124438
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
124630
124439
|
var require_read_all_rows$1 = require_read_all_rows_CVoO1ONM();
|
|
124631
|
-
var require_composition_sources =
|
|
124440
|
+
var require_composition_sources = require_composition_sources_b0e_2I_D();
|
|
124632
124441
|
var require_prefix_range = require_prefix_range_D_KueXbQ();
|
|
124633
124442
|
var require_prefix_walk = require_prefix_walk_Dv6MLZlM();
|
|
124634
124443
|
var zod = require_zod();
|
|
@@ -125065,8 +124874,7 @@ export default class CoreBlockAddon extends BaseAddon {
|
|
|
125065
124874
|
fields: ["enabled"]
|
|
125066
124875
|
}],
|
|
125067
124876
|
retention: { none: "operator delete only" },
|
|
125068
|
-
maxDataBytes: 256 * 1024
|
|
125069
|
-
adoptsFrom: CORE_BLOCKS_COLLECTION
|
|
124877
|
+
maxDataBytes: 256 * 1024
|
|
125070
124878
|
},
|
|
125071
124879
|
settings: {
|
|
125072
124880
|
schema: CoreBlockSettingsBodySchema,
|
|
@@ -125074,8 +124882,7 @@ export default class CoreBlockAddon extends BaseAddon {
|
|
|
125074
124882
|
writeTrigger: "legacy only \u2014 migrateRawSecrets reads then deletes rows (D880)",
|
|
125075
124883
|
device: "none",
|
|
125076
124884
|
at: "none",
|
|
125077
|
-
retention: { none: "rows deleted by migrateRawSecrets" }
|
|
125078
|
-
adoptsFrom: CORE_BLOCK_SETTINGS_COLLECTION
|
|
124885
|
+
retention: { none: "rows deleted by migrateRawSecrets" }
|
|
125079
124886
|
}
|
|
125080
124887
|
});
|
|
125081
124888
|
var coreBlocksRecordKinds = _coreBlocksRecordKinds;
|
|
@@ -127033,9 +126840,9 @@ var require_event_category_eSqkye_K = __commonJS({
|
|
|
127033
126840
|
}
|
|
127034
126841
|
});
|
|
127035
126842
|
|
|
127036
|
-
// ../types/dist/sleep-
|
|
127037
|
-
var
|
|
127038
|
-
"../types/dist/sleep-
|
|
126843
|
+
// ../types/dist/sleep-gRQc2IoX.js
|
|
126844
|
+
var require_sleep_gRQc2IoX = __commonJS({
|
|
126845
|
+
"../types/dist/sleep-gRQc2IoX.js"(exports) {
|
|
127039
126846
|
"use strict";
|
|
127040
126847
|
var require_event_category = require_event_category_eSqkye_K();
|
|
127041
126848
|
var zod = require_zod();
|
|
@@ -129714,7 +129521,6 @@ var require_sleep_DKtoyk6X = __commonJS({
|
|
|
129714
129521
|
"secret-unavailable",
|
|
129715
129522
|
"invalid-record",
|
|
129716
129523
|
"declaration-refused",
|
|
129717
|
-
"adoption-pending",
|
|
129718
129524
|
"no-caller",
|
|
129719
129525
|
"batch-too-large"
|
|
129720
129526
|
];
|
|
@@ -129801,12 +129607,6 @@ var require_sleep_DKtoyk6X = __commonJS({
|
|
|
129801
129607
|
this.name = "DeclarationRefusedError";
|
|
129802
129608
|
}
|
|
129803
129609
|
};
|
|
129804
|
-
var AdoptionPendingError = class extends RecordsError {
|
|
129805
|
-
constructor(detail) {
|
|
129806
|
-
super("adoption-pending", detail);
|
|
129807
|
-
this.name = "AdoptionPendingError";
|
|
129808
|
-
}
|
|
129809
|
-
};
|
|
129810
129610
|
var NoCallerError = class extends RecordsError {
|
|
129811
129611
|
constructor(detail) {
|
|
129812
129612
|
super("no-caller", detail);
|
|
@@ -129832,7 +129632,6 @@ var require_sleep_DKtoyk6X = __commonJS({
|
|
|
129832
129632
|
"secret-unavailable": (d) => new RecordSecretUnavailableError(d),
|
|
129833
129633
|
"invalid-record": (d) => new InvalidRecordError(d),
|
|
129834
129634
|
"declaration-refused": (d) => new DeclarationRefusedError(d),
|
|
129835
|
-
"adoption-pending": (d) => new AdoptionPendingError(d),
|
|
129836
129635
|
"no-caller": (d) => new NoCallerError(d),
|
|
129837
129636
|
"batch-too-large": (d) => new BatchTooLargeError(d)
|
|
129838
129637
|
};
|
|
@@ -130055,7 +129854,13 @@ var require_sleep_DKtoyk6X = __commonJS({
|
|
|
130055
129854
|
secretPaths: zod.z.array(zod.z.string().min(1)).default([]),
|
|
130056
129855
|
/** The id key of each array that carries a secret (`{ headers: 'name' }`). */
|
|
130057
129856
|
secretArrayKeys: zod.z.record(zod.z.string(), zod.z.string()).default({}),
|
|
130058
|
-
/**
|
|
129857
|
+
/**
|
|
129858
|
+
* RETIRED (D900): the legacy table a kind adopted from during the records
|
|
129859
|
+
* migration. Nothing declares it any more and nothing reads it; the schema
|
|
129860
|
+
* still ACCEPTS it because the catalog rows the migration wrote carry it
|
|
129861
|
+
* (an orphaned kind is never redeclared) and an addon built before the
|
|
129862
|
+
* removal still sends it. Never set it.
|
|
129863
|
+
*/
|
|
130059
129864
|
adoptsFrom: zod.z.string().min(1).optional(),
|
|
130060
129865
|
/** Kinds that must agree through `transact` sit in one file under one family name. */
|
|
130061
129866
|
transactFamily: zod.z.string().min(1).optional(),
|
|
@@ -130122,7 +129927,6 @@ var require_sleep_DKtoyk6X = __commonJS({
|
|
|
130122
129927
|
maxDataBytes: spec.maxDataBytes,
|
|
130123
129928
|
secretPaths: [...secretPaths],
|
|
130124
129929
|
secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
|
|
130125
|
-
adoptsFrom: spec.adoptsFrom,
|
|
130126
129930
|
transactFamily: spec.transactFamily,
|
|
130127
129931
|
entry: spec.entry === void 0 ? void 0 : {
|
|
130128
129932
|
title: spec.entry.title,
|
|
@@ -130459,10 +130263,7 @@ var require_sleep_DKtoyk6X = __commonJS({
|
|
|
130459
130263
|
return delegate;
|
|
130460
130264
|
},
|
|
130461
130265
|
async declare(kinds) {
|
|
130462
|
-
|
|
130463
|
-
const pending = Object.entries(result.kinds).filter((entry) => entry[1].adoptionPending !== null);
|
|
130464
|
-
if (pending.length > 0) throw new AdoptionPendingError(`${pending.map(([name, r]) => r.adoptionPending === null ? name : `${name} (legacy table "${r.adoptionPending.legacyTable}" holds ${r.adoptionPending.legacyRows} rows)`).join(", ")}. Stop the addon and run scripts/hub/records-adopt.ts --copy --apply before starting this build`);
|
|
130465
|
-
return result.kinds;
|
|
130266
|
+
return (await call(() => options.transport.declareKinds({ kinds: { ...declarationsOf(kinds) } }))).kinds;
|
|
130466
130267
|
},
|
|
130467
130268
|
kind(definition) {
|
|
130468
130269
|
const existing = handles.get(definition);
|
|
@@ -130503,7 +130304,6 @@ var require_sleep_DKtoyk6X = __commonJS({
|
|
|
130503
130304
|
...spec.database === void 0 ? {} : { database: spec.database },
|
|
130504
130305
|
...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
|
|
130505
130306
|
...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
|
|
130506
|
-
...spec.adoptsFrom === void 0 ? {} : { adoptsFrom: spec.adoptsFrom },
|
|
130507
130307
|
entry: {
|
|
130508
130308
|
title: spec.title,
|
|
130509
130309
|
...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
|
|
@@ -130512,32 +130312,6 @@ var require_sleep_DKtoyk6X = __commonJS({
|
|
|
130512
130312
|
if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
|
|
130513
130313
|
return defined;
|
|
130514
130314
|
}
|
|
130515
|
-
var SETTINGS_BROKERS_ADOPTS_PREFIX = "@settings-brokers/";
|
|
130516
|
-
function settingsBrokersAdoptsFrom(addonId) {
|
|
130517
|
-
return `${SETTINGS_BROKERS_ADOPTS_PREFIX}${addonId}`;
|
|
130518
|
-
}
|
|
130519
|
-
function parseSettingsBrokersAdoptsFrom(from) {
|
|
130520
|
-
if (!from.startsWith("@settings-brokers/")) return null;
|
|
130521
|
-
const addonId = from.slice(18);
|
|
130522
|
-
return addonId.length > 0 ? addonId : null;
|
|
130523
|
-
}
|
|
130524
|
-
var SETTINGS_ARRAY_ADOPTS_PREFIX = "@settings-array/";
|
|
130525
|
-
function settingsArrayAdoptsFrom(addonId, settingsKey) {
|
|
130526
|
-
return `${SETTINGS_ARRAY_ADOPTS_PREFIX}${addonId}/${settingsKey}`;
|
|
130527
|
-
}
|
|
130528
|
-
function parseSettingsArrayAdoptsFrom(from) {
|
|
130529
|
-
if (!from.startsWith("@settings-array/")) return null;
|
|
130530
|
-
const rest = from.slice(16);
|
|
130531
|
-
const slash = rest.indexOf("/");
|
|
130532
|
-
if (slash <= 0 || slash >= rest.length - 1) return null;
|
|
130533
|
-
const addonId = rest.slice(0, slash);
|
|
130534
|
-
const settingsKey = rest.slice(slash + 1);
|
|
130535
|
-
if (addonId.length === 0 || settingsKey.length === 0) return null;
|
|
130536
|
-
return {
|
|
130537
|
-
addonId,
|
|
130538
|
-
settingsKey
|
|
130539
|
-
};
|
|
130540
|
-
}
|
|
130541
130315
|
function isRecord(value) {
|
|
130542
130316
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
130543
130317
|
}
|
|
@@ -133306,12 +133080,6 @@ var require_sleep_DKtoyk6X = __commonJS({
|
|
|
133306
133080
|
return AUDIO_CHUNK_FORMATS;
|
|
133307
133081
|
}
|
|
133308
133082
|
});
|
|
133309
|
-
Object.defineProperty(exports, "AdoptionPendingError", {
|
|
133310
|
-
enumerable: true,
|
|
133311
|
-
get: function() {
|
|
133312
|
-
return AdoptionPendingError;
|
|
133313
|
-
}
|
|
133314
|
-
});
|
|
133315
133083
|
Object.defineProperty(exports, "AudioChunkFormatSchema", {
|
|
133316
133084
|
enumerable: true,
|
|
133317
133085
|
get: function() {
|
|
@@ -133828,18 +133596,6 @@ var require_sleep_DKtoyk6X = __commonJS({
|
|
|
133828
133596
|
return SECRET_REF_SCHEME;
|
|
133829
133597
|
}
|
|
133830
133598
|
});
|
|
133831
|
-
Object.defineProperty(exports, "SETTINGS_ARRAY_ADOPTS_PREFIX", {
|
|
133832
|
-
enumerable: true,
|
|
133833
|
-
get: function() {
|
|
133834
|
-
return SETTINGS_ARRAY_ADOPTS_PREFIX;
|
|
133835
|
-
}
|
|
133836
|
-
});
|
|
133837
|
-
Object.defineProperty(exports, "SETTINGS_BROKERS_ADOPTS_PREFIX", {
|
|
133838
|
-
enumerable: true,
|
|
133839
|
-
get: function() {
|
|
133840
|
-
return SETTINGS_BROKERS_ADOPTS_PREFIX;
|
|
133841
|
-
}
|
|
133842
|
-
});
|
|
133843
133599
|
Object.defineProperty(exports, "SHARE_VIEW_KINDS", {
|
|
133844
133600
|
enumerable: true,
|
|
133845
133601
|
get: function() {
|
|
@@ -134422,18 +134178,6 @@ var require_sleep_DKtoyk6X = __commonJS({
|
|
|
134422
134178
|
return parseSecretStatePath;
|
|
134423
134179
|
}
|
|
134424
134180
|
});
|
|
134425
|
-
Object.defineProperty(exports, "parseSettingsArrayAdoptsFrom", {
|
|
134426
|
-
enumerable: true,
|
|
134427
|
-
get: function() {
|
|
134428
|
-
return parseSettingsArrayAdoptsFrom;
|
|
134429
|
-
}
|
|
134430
|
-
});
|
|
134431
|
-
Object.defineProperty(exports, "parseSettingsBrokersAdoptsFrom", {
|
|
134432
|
-
enumerable: true,
|
|
134433
|
-
get: function() {
|
|
134434
|
-
return parseSettingsBrokersAdoptsFrom;
|
|
134435
|
-
}
|
|
134436
|
-
});
|
|
134437
134181
|
Object.defineProperty(exports, "readErrorI18n", {
|
|
134438
134182
|
enumerable: true,
|
|
134439
134183
|
get: function() {
|
|
@@ -134548,18 +134292,6 @@ var require_sleep_DKtoyk6X = __commonJS({
|
|
|
134548
134292
|
return selectAssignedProfileSlots;
|
|
134549
134293
|
}
|
|
134550
134294
|
});
|
|
134551
|
-
Object.defineProperty(exports, "settingsArrayAdoptsFrom", {
|
|
134552
|
-
enumerable: true,
|
|
134553
|
-
get: function() {
|
|
134554
|
-
return settingsArrayAdoptsFrom;
|
|
134555
|
-
}
|
|
134556
|
-
});
|
|
134557
|
-
Object.defineProperty(exports, "settingsBrokersAdoptsFrom", {
|
|
134558
|
-
enumerable: true,
|
|
134559
|
-
get: function() {
|
|
134560
|
-
return settingsBrokersAdoptsFrom;
|
|
134561
|
-
}
|
|
134562
|
-
});
|
|
134563
134295
|
Object.defineProperty(exports, "shortSecretRefHash", {
|
|
134564
134296
|
enumerable: true,
|
|
134565
134297
|
get: function() {
|
|
@@ -134628,7 +134360,7 @@ var require_addon = __commonJS({
|
|
|
134628
134360
|
"../types/dist/addon.js"(exports) {
|
|
134629
134361
|
"use strict";
|
|
134630
134362
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
134631
|
-
var require_sleep =
|
|
134363
|
+
var require_sleep = require_sleep_gRQc2IoX();
|
|
134632
134364
|
var require_event_category = require_event_category_eSqkye_K();
|
|
134633
134365
|
var require_err_msg = require_err_msg_BhVbr0NX();
|
|
134634
134366
|
var CAP_INPUT_DEFAULTS = Object.freeze({
|
|
@@ -136844,7 +136576,6 @@ var require_addon = __commonJS({
|
|
|
136844
136576
|
}
|
|
136845
136577
|
]
|
|
136846
136578
|
});
|
|
136847
|
-
exports.AdoptionPendingError = require_sleep.AdoptionPendingError;
|
|
136848
136579
|
exports.BOOT_RECOVERY_BACKOFF_MS = require_sleep.BOOT_RECOVERY_BACKOFF_MS;
|
|
136849
136580
|
exports.BaseAddon = require_sleep.BaseAddon;
|
|
136850
136581
|
exports.BatchTooLargeError = require_sleep.BatchTooLargeError;
|
|
@@ -136907,8 +136638,6 @@ var require_addon = __commonJS({
|
|
|
136907
136638
|
exports.RevConflictError = require_sleep.RevConflictError;
|
|
136908
136639
|
exports.SECRET_CLEAR = require_sleep.SECRET_CLEAR;
|
|
136909
136640
|
exports.SECRET_REF_SCHEME = require_sleep.SECRET_REF_SCHEME;
|
|
136910
|
-
exports.SETTINGS_ARRAY_ADOPTS_PREFIX = require_sleep.SETTINGS_ARRAY_ADOPTS_PREFIX;
|
|
136911
|
-
exports.SETTINGS_BROKERS_ADOPTS_PREFIX = require_sleep.SETTINGS_BROKERS_ADOPTS_PREFIX;
|
|
136912
136641
|
exports.UnindexedFilterError = require_sleep.UnindexedFilterError;
|
|
136913
136642
|
exports.UnknownRecordKindError = require_sleep.UnknownRecordKindError;
|
|
136914
136643
|
exports.addonSliceHandleApi = require_sleep.addonSliceHandleApi;
|
|
@@ -136961,8 +136690,6 @@ var require_addon = __commonJS({
|
|
|
136961
136690
|
exports.parseJsonUnknown = require_sleep.parseJsonUnknown;
|
|
136962
136691
|
exports.parseSecretPath = require_sleep.parseSecretPath;
|
|
136963
136692
|
exports.parseSecretRef = require_sleep.parseSecretRef;
|
|
136964
|
-
exports.parseSettingsArrayAdoptsFrom = require_sleep.parseSettingsArrayAdoptsFrom;
|
|
136965
|
-
exports.parseSettingsBrokersAdoptsFrom = require_sleep.parseSettingsBrokersAdoptsFrom;
|
|
136966
136693
|
exports.readErrorI18n = require_sleep.readErrorI18n;
|
|
136967
136694
|
exports.readNodePin = require_sleep.readNodePin;
|
|
136968
136695
|
exports.recordArrayItemPath = require_sleep.recordArrayItemPath;
|
|
@@ -136974,8 +136701,6 @@ var require_addon = __commonJS({
|
|
|
136974
136701
|
exports.scopeKey = require_sleep.scopeKey;
|
|
136975
136702
|
exports.scrubKnownSecrets = require_sleep.scrubKnownSecrets;
|
|
136976
136703
|
exports.secretArrayPrefixes = require_sleep.secretArrayPrefixes;
|
|
136977
|
-
exports.settingsArrayAdoptsFrom = require_sleep.settingsArrayAdoptsFrom;
|
|
136978
|
-
exports.settingsBrokersAdoptsFrom = require_sleep.settingsBrokersAdoptsFrom;
|
|
136979
136704
|
exports.shortSecretRefHash = require_sleep.shortSecretRefHash;
|
|
136980
136705
|
exports.sleep = require_sleep.sleep;
|
|
136981
136706
|
exports.toSecretFieldView = require_sleep.toSecretFieldView;
|
|
@@ -137284,7 +137009,7 @@ var require_device_manager_addon = __commonJS({
|
|
|
137284
137009
|
[Symbol.toStringTag]: { value: "Module" }
|
|
137285
137010
|
});
|
|
137286
137011
|
require_chunk_Cek0wNdY();
|
|
137287
|
-
var require_dist10 =
|
|
137012
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
137288
137013
|
var require_read_all_rows$1 = require_read_all_rows_CVoO1ONM();
|
|
137289
137014
|
var require_prefix_range = require_prefix_range_D_KueXbQ();
|
|
137290
137015
|
var require_prefix_walk = require_prefix_walk_Dv6MLZlM();
|
|
@@ -143342,12 +143067,10 @@ var require_device_manager_addon = __commonJS({
|
|
|
143342
143067
|
retention: {
|
|
143343
143068
|
owner: "device-manager",
|
|
143344
143069
|
reason: "90 days (`DEVICE_TOMBSTONE_RETENTION_MS`), pruned whenever a tombstone is written or the list is read"
|
|
143345
|
-
}
|
|
143346
|
-
adoptsFrom: DEVICE_TOMBSTONES_COLLECTION
|
|
143070
|
+
}
|
|
143347
143071
|
} });
|
|
143348
143072
|
var deviceManagerRecordKinds = _deviceManagerRecordKinds;
|
|
143349
143073
|
_deviceManagerRecordKinds.tombstones;
|
|
143350
|
-
var DEVICE_TOMBSTONES_COLLECTION = "device-manager:tombstones";
|
|
143351
143074
|
var TOMBSTONE_READ_LIMIT = 2e4;
|
|
143352
143075
|
function rowToTombstone(id, body) {
|
|
143353
143076
|
const deviceId = Number(id);
|
|
@@ -146358,7 +146081,7 @@ var require_hub_forwarder = __commonJS({
|
|
|
146358
146081
|
[Symbol.toStringTag]: { value: "Module" }
|
|
146359
146082
|
});
|
|
146360
146083
|
require_chunk_Cek0wNdY();
|
|
146361
|
-
var require_dist10 =
|
|
146084
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
146362
146085
|
var require_formatter = require_formatter_DqAKDlvN();
|
|
146363
146086
|
var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
|
|
146364
146087
|
var HubForwarderDestination = class {
|
|
@@ -146492,7 +146215,7 @@ var require_liveness_monitor_addon = __commonJS({
|
|
|
146492
146215
|
"use strict";
|
|
146493
146216
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
146494
146217
|
require_chunk_Cek0wNdY();
|
|
146495
|
-
var require_dist10 =
|
|
146218
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
146496
146219
|
var NO_DEVICES = "liveness:no-devices";
|
|
146497
146220
|
var ALL_OFFLINE = "liveness:all-devices-offline";
|
|
146498
146221
|
var NO_FOOTAGE_PREFIX = "liveness:no-footage:";
|
|
@@ -146855,12 +146578,11 @@ var require_local_auth_addon = __commonJS({
|
|
|
146855
146578
|
[Symbol.toStringTag]: { value: "Module" }
|
|
146856
146579
|
});
|
|
146857
146580
|
var require_chunk = require_chunk_Cek0wNdY();
|
|
146858
|
-
var require_dist10 =
|
|
146581
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
146859
146582
|
var require_read_all_rows$1 = require_read_all_rows_CVoO1ONM();
|
|
146860
146583
|
var require_safe_buffer$1 = require_safe_buffer_D3aoa_7X();
|
|
146861
146584
|
var require_ms$1 = require_ms_LB3giGoU();
|
|
146862
|
-
var require_device_ca =
|
|
146863
|
-
var require_phase6_declare_gate = require_phase6_declare_gate_Dag1_WR2();
|
|
146585
|
+
var require_device_ca = require_device_ca_CPTDs_d();
|
|
146864
146586
|
var zod = require_zod();
|
|
146865
146587
|
var node_crypto = __require("crypto");
|
|
146866
146588
|
node_crypto = require_chunk.__toESM(node_crypto);
|
|
@@ -152855,8 +152577,7 @@ var require_local_auth_addon = __commonJS({
|
|
|
152855
152577
|
fields: ["username"],
|
|
152856
152578
|
unique: true
|
|
152857
152579
|
}],
|
|
152858
|
-
retention: { none: "row goes only when an operator deletes the user; destructive declareCollection rebuild wipes all accounts" }
|
|
152859
|
-
adoptsFrom: USERS_COLLECTION$1
|
|
152580
|
+
retention: { none: "row goes only when an operator deletes the user; destructive declareCollection rebuild wipes all accounts" }
|
|
152860
152581
|
},
|
|
152861
152582
|
"api-keys": {
|
|
152862
152583
|
schema: ApiKeyBodySchema,
|
|
@@ -152868,8 +152589,7 @@ var require_local_auth_addon = __commonJS({
|
|
|
152868
152589
|
name: "prefix",
|
|
152869
152590
|
fields: ["tokenPrefix"]
|
|
152870
152591
|
}],
|
|
152871
|
-
retention: { none: "explicit revoke only" }
|
|
152872
|
-
adoptsFrom: API_KEYS_COLLECTION
|
|
152592
|
+
retention: { none: "explicit revoke only" }
|
|
152873
152593
|
},
|
|
152874
152594
|
"scoped-tokens": {
|
|
152875
152595
|
schema: ScopedTokenBodySchema,
|
|
@@ -152885,8 +152605,7 @@ var require_local_auth_addon = __commonJS({
|
|
|
152885
152605
|
name: "user",
|
|
152886
152606
|
fields: ["userId"]
|
|
152887
152607
|
}],
|
|
152888
|
-
retention: { none: "the operator drops the legacy rows by hand (D895)" }
|
|
152889
|
-
adoptsFrom: SCOPED_TOKENS_COLLECTION
|
|
152608
|
+
retention: { none: "the operator drops the legacy rows by hand (D895)" }
|
|
152890
152609
|
},
|
|
152891
152610
|
"admin-tokens": {
|
|
152892
152611
|
schema: AdminTokenBodySchema,
|
|
@@ -152902,8 +152621,7 @@ var require_local_auth_addon = __commonJS({
|
|
|
152902
152621
|
name: "created_by",
|
|
152903
152622
|
fields: ["createdBy"]
|
|
152904
152623
|
}],
|
|
152905
|
-
retention: { none: "the operator drops the legacy rows by hand (D895)" }
|
|
152906
|
-
adoptsFrom: ADMIN_TOKENS_COLLECTION
|
|
152624
|
+
retention: { none: "the operator drops the legacy rows by hand (D895)" }
|
|
152907
152625
|
},
|
|
152908
152626
|
"login-sessions": {
|
|
152909
152627
|
schema: LoginSessionBodySchema,
|
|
@@ -152921,8 +152639,7 @@ var require_local_auth_addon = __commonJS({
|
|
|
152921
152639
|
retention: {
|
|
152922
152640
|
owner: "local-auth",
|
|
152923
152641
|
reason: "daily reap: expired >7d and revoked >30d"
|
|
152924
|
-
}
|
|
152925
|
-
adoptsFrom: LOGIN_SESSIONS_COLLECTION
|
|
152642
|
+
}
|
|
152926
152643
|
},
|
|
152927
152644
|
"login-session-cutoffs": {
|
|
152928
152645
|
schema: LoginSessionCutoffBodySchema,
|
|
@@ -152930,8 +152647,7 @@ var require_local_auth_addon = __commonJS({
|
|
|
152930
152647
|
writeTrigger: "revoke-all-sessions for a user (password change, delete, logout everywhere)",
|
|
152931
152648
|
device: "none",
|
|
152932
152649
|
at: "none",
|
|
152933
|
-
retention: { none: "one row per user who ever had all sessions revoked" }
|
|
152934
|
-
adoptsFrom: LOGIN_SESSION_CUTOFFS_COLLECTION
|
|
152650
|
+
retention: { none: "one row per user who ever had all sessions revoked" }
|
|
152935
152651
|
},
|
|
152936
152652
|
"oauth-sessions": {
|
|
152937
152653
|
schema: OauthSessionBodySchema,
|
|
@@ -152946,8 +152662,7 @@ var require_local_auth_addon = __commonJS({
|
|
|
152946
152662
|
retention: {
|
|
152947
152663
|
owner: "local-auth",
|
|
152948
152664
|
reason: "daily reap deletes revoked sessions older than 30 days; active rows never expire"
|
|
152949
|
-
}
|
|
152950
|
-
adoptsFrom: OAUTH_SESSIONS_COLLECTION
|
|
152665
|
+
}
|
|
152951
152666
|
},
|
|
152952
152667
|
"user-totp": {
|
|
152953
152668
|
schema: UserTotpBodySchema,
|
|
@@ -152955,8 +152670,7 @@ var require_local_auth_addon = __commonJS({
|
|
|
152955
152670
|
writeTrigger: "setup inserts seed (keychain); confirm sets confirmedAt; disable deletes row",
|
|
152956
152671
|
device: "none",
|
|
152957
152672
|
at: "none",
|
|
152958
|
-
retention: { none: "disable or replace on re-setup; user delete does not cascade" }
|
|
152959
|
-
adoptsFrom: USER_TOTP_COLLECTION
|
|
152673
|
+
retention: { none: "disable or replace on re-setup; user delete does not cascade" }
|
|
152960
152674
|
},
|
|
152961
152675
|
"user-external-identities": {
|
|
152962
152676
|
schema: ExternalIdentityBodySchema,
|
|
@@ -152972,8 +152686,7 @@ var require_local_auth_addon = __commonJS({
|
|
|
152972
152686
|
fields: ["provider", "subject"],
|
|
152973
152687
|
unique: true
|
|
152974
152688
|
}],
|
|
152975
|
-
retention: { none: "unlink or deleteUser removes rows" }
|
|
152976
|
-
adoptsFrom: USER_EXTERNAL_IDENTITIES_COLLECTION
|
|
152689
|
+
retention: { none: "unlink or deleteUser removes rows" }
|
|
152977
152690
|
},
|
|
152978
152691
|
"device-credentials": {
|
|
152979
152692
|
schema: DeviceCredentialBodySchema,
|
|
@@ -152991,8 +152704,7 @@ var require_local_auth_addon = __commonJS({
|
|
|
152991
152704
|
retention: {
|
|
152992
152705
|
owner: "local-auth",
|
|
152993
152706
|
reason: "daily reap removes revoked/expired rows older than 90 days"
|
|
152994
|
-
}
|
|
152995
|
-
adoptsFrom: DEVICE_CREDENTIALS_COLLECTION
|
|
152707
|
+
}
|
|
152996
152708
|
},
|
|
152997
152709
|
"auth-audit": {
|
|
152998
152710
|
schema: AuthAuditBodySchema,
|
|
@@ -153007,8 +152719,7 @@ var require_local_auth_addon = __commonJS({
|
|
|
153007
152719
|
retention: {
|
|
153008
152720
|
ttlMs: 90 * DAY_MS,
|
|
153009
152721
|
from: "at"
|
|
153010
|
-
}
|
|
153011
|
-
adoptsFrom: AUTH_AUDIT_COLLECTION
|
|
152722
|
+
}
|
|
153012
152723
|
}
|
|
153013
152724
|
});
|
|
153014
152725
|
var localAuthRecordKinds = _localAuthRecordKinds;
|
|
@@ -156802,45 +156513,41 @@ var require_local_auth_addon = __commonJS({
|
|
|
156802
156513
|
const store = this.ctx.api?.settingsStore;
|
|
156803
156514
|
const records = this.ctx.records;
|
|
156804
156515
|
if (store && records) {
|
|
156805
|
-
|
|
156806
|
-
const authStores =
|
|
156516
|
+
await records.declare(localAuthRecordKinds);
|
|
156517
|
+
const authStores = localAuthRecordStoresOf(records);
|
|
156807
156518
|
await records.declare(localAuthPreferencesRecordKinds);
|
|
156808
156519
|
this.preferences = new UserPreferencesStore(records.kind(localAuthPreferencesRecordKinds["user-preferences"]));
|
|
156809
|
-
|
|
156810
|
-
|
|
156811
|
-
this.userManager = authStores === null ? new UserManager(legacyStoreAccess, this.authManager) : new UserManager({
|
|
156520
|
+
await declareAuthSchema(store, { skipCollections: LOCAL_AUTH_RECORDS_LEGACY_COLLECTIONS });
|
|
156521
|
+
this.userManager = new UserManager({
|
|
156812
156522
|
usersKind: authStores.users,
|
|
156813
156523
|
legacyStore: store
|
|
156814
156524
|
}, this.authManager);
|
|
156815
|
-
this.apiKeyManager =
|
|
156525
|
+
this.apiKeyManager = new ApiKeyManager({
|
|
156816
156526
|
apiKeysKind: authStores.apiKeys,
|
|
156817
156527
|
legacyStore: store
|
|
156818
156528
|
});
|
|
156819
|
-
this.oauthSessionManager =
|
|
156529
|
+
this.oauthSessionManager = new OauthSessionManager({
|
|
156820
156530
|
oauthSessionsKind: authStores.oauthSessions,
|
|
156821
156531
|
legacyStore: store
|
|
156822
156532
|
});
|
|
156823
|
-
this.totpManager =
|
|
156824
|
-
secrets: forOwner === null ? null : forOwner("system"),
|
|
156825
|
-
logger: this.ctx.logger
|
|
156826
|
-
}) : new TotpManager({
|
|
156533
|
+
this.totpManager = new TotpManager({
|
|
156827
156534
|
userTotpKind: authStores.userTotp,
|
|
156828
156535
|
legacyStore: store
|
|
156829
156536
|
}, {
|
|
156830
156537
|
secrets: forOwner === null ? null : forOwner("system"),
|
|
156831
156538
|
logger: this.ctx.logger
|
|
156832
156539
|
});
|
|
156833
|
-
this.externalIdentities =
|
|
156540
|
+
this.externalIdentities = new ExternalIdentityManager({
|
|
156834
156541
|
identitiesKind: authStores.userExternalIdentities,
|
|
156835
156542
|
legacyStore: store
|
|
156836
156543
|
});
|
|
156837
|
-
this.loginSessions =
|
|
156544
|
+
this.loginSessions = new LoginSessionManager({
|
|
156838
156545
|
sessionsKind: authStores.loginSessions,
|
|
156839
156546
|
cutoffsKind: authStores.loginSessionCutoffs,
|
|
156840
156547
|
legacyStore: store
|
|
156841
156548
|
}, { logger: this.ctx.logger });
|
|
156842
156549
|
await this.loginSessions.load();
|
|
156843
|
-
this.auditLog =
|
|
156550
|
+
this.auditLog = new AuthAuditLog({
|
|
156844
156551
|
authAuditKind: authStores.authAudit,
|
|
156845
156552
|
legacyStore: store
|
|
156846
156553
|
}, this.ctx.logger);
|
|
@@ -156860,7 +156567,7 @@ var require_local_auth_addon = __commonJS({
|
|
|
156860
156567
|
return user === null ? null : { username: user.username };
|
|
156861
156568
|
},
|
|
156862
156569
|
selfEnrollmentAllowed: async () => (await this.readDeviceCertificateSettings()).selfEnrollment === "allowed",
|
|
156863
|
-
deviceCredentialsKind: authStores
|
|
156570
|
+
deviceCredentialsKind: authStores.deviceCredentials,
|
|
156864
156571
|
logger: this.ctx.logger
|
|
156865
156572
|
});
|
|
156866
156573
|
await this.deviceCredentials.load();
|
|
@@ -157542,7 +157249,7 @@ var require_loki_logging = __commonJS({
|
|
|
157542
157249
|
[Symbol.toStringTag]: { value: "Module" }
|
|
157543
157250
|
});
|
|
157544
157251
|
require_chunk_Cek0wNdY();
|
|
157545
|
-
var require_dist10 =
|
|
157252
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
157546
157253
|
var require_log_read_filter = require_log_read_filter_Bi066jwU();
|
|
157547
157254
|
var zod = require_zod();
|
|
157548
157255
|
function sanitizeLabelName(raw) {
|
|
@@ -158503,7 +158210,7 @@ var require_native_metrics_addon = __commonJS({
|
|
|
158503
158210
|
[Symbol.toStringTag]: { value: "Module" }
|
|
158504
158211
|
});
|
|
158505
158212
|
var require_chunk = require_chunk_Cek0wNdY();
|
|
158506
|
-
var require_dist10 =
|
|
158213
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
158507
158214
|
var node_fs_promises = __require("fs/promises");
|
|
158508
158215
|
var node_util = __require("util");
|
|
158509
158216
|
var node_os = __require("os");
|
|
@@ -161048,7 +160755,7 @@ var require_device_history_addon = __commonJS({
|
|
|
161048
160755
|
[Symbol.toStringTag]: { value: "Module" }
|
|
161049
160756
|
});
|
|
161050
160757
|
require_chunk_Cek0wNdY();
|
|
161051
|
-
var require_dist10 =
|
|
160758
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
161052
160759
|
var FIVE_MINUTES_MS = 5 * 6e4;
|
|
161053
160760
|
var HOUR_MS = 60 * 6e4;
|
|
161054
160761
|
var DAY_MS = 24 * HOUR_MS;
|
|
@@ -164094,7 +163801,7 @@ var require_filesystem_storage_addon = __commonJS({
|
|
|
164094
163801
|
[Symbol.toStringTag]: { value: "Module" }
|
|
164095
163802
|
});
|
|
164096
163803
|
var require_chunk = require_chunk_Cek0wNdY();
|
|
164097
|
-
var require_dist10 =
|
|
163804
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
164098
163805
|
var node_crypto = __require("crypto");
|
|
164099
163806
|
var node_fs_promises = __require("fs/promises");
|
|
164100
163807
|
var node_path = __require("path");
|
|
@@ -165204,12 +164911,12 @@ var require_lib = __commonJS({
|
|
|
165204
164911
|
}
|
|
165205
164912
|
});
|
|
165206
164913
|
|
|
165207
|
-
// ../system/dist/wal-maintenance-
|
|
165208
|
-
var
|
|
165209
|
-
"../system/dist/wal-maintenance-
|
|
164914
|
+
// ../system/dist/wal-maintenance-DUHEp_09.js
|
|
164915
|
+
var require_wal_maintenance_DUHEp_09 = __commonJS({
|
|
164916
|
+
"../system/dist/wal-maintenance-DUHEp_09.js"(exports) {
|
|
165210
164917
|
"use strict";
|
|
165211
164918
|
var require_chunk = require_chunk_Cek0wNdY();
|
|
165212
|
-
var require_dist10 =
|
|
164919
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
165213
164920
|
var require_prefix_range = require_prefix_range_D_KueXbQ();
|
|
165214
164921
|
var node_crypto = __require("crypto");
|
|
165215
164922
|
var node_module = __require("module");
|
|
@@ -165495,8 +165202,7 @@ var require_wal_maintenance_DfSIOj24 = __commonJS({
|
|
|
165495
165202
|
hasTable: ({ name }) => backend.hasTable(name),
|
|
165496
165203
|
dropRetiredTable: ({ name }) => backend.dropRetiredTable(name),
|
|
165497
165204
|
threadId: () => threadId,
|
|
165498
|
-
listPhysicalTables: ({ ownerPrefix }) => backend.listTables(ownerPrefix)
|
|
165499
|
-
readLegacyCollection: (input) => backend.readLegacyCollection(input)
|
|
165205
|
+
listPhysicalTables: ({ ownerPrefix }) => backend.listTables(ownerPrefix)
|
|
165500
165206
|
};
|
|
165501
165207
|
}
|
|
165502
165208
|
function callControl(target, op, input) {
|
|
@@ -165614,6 +165320,8 @@ CREATE TABLE IF NOT EXISTS _record_kinds (
|
|
|
165614
165320
|
declaration TEXT NOT NULL,
|
|
165615
165321
|
state TEXT NOT NULL,
|
|
165616
165322
|
orphaned_at INTEGER,
|
|
165323
|
+
-- RETIRED (D900): the records-migration boot guard's flag. Nothing reads it;
|
|
165324
|
+
-- the column stays so an older build can still open a file this one created.
|
|
165617
165325
|
adopted_at INTEGER,
|
|
165618
165326
|
UNIQUE (owner, kind)
|
|
165619
165327
|
);
|
|
@@ -165677,15 +165385,14 @@ CREATE TABLE IF NOT EXISTS _record_sequences (
|
|
|
165677
165385
|
database: asDatabase(row.database),
|
|
165678
165386
|
hash: row.manifest_hash,
|
|
165679
165387
|
state: asState(row.state),
|
|
165680
|
-
declaration: require_dist10.RecordKindDeclarationSchema.parse(JSON.parse(row.declaration))
|
|
165681
|
-
adoptedAt: row.adopted_at
|
|
165388
|
+
declaration: require_dist10.RecordKindDeclarationSchema.parse(JSON.parse(row.declaration))
|
|
165682
165389
|
};
|
|
165683
165390
|
}
|
|
165684
165391
|
function ensureRecordsSchema(db) {
|
|
165685
165392
|
db.exec(RECORDS_SCHEMA_SQL);
|
|
165686
165393
|
}
|
|
165687
165394
|
function loadKinds(db) {
|
|
165688
|
-
return db.prepare("SELECT kind_id, owner, kind, database, manifest_hash, declaration, state
|
|
165395
|
+
return db.prepare("SELECT kind_id, owner, kind, database, manifest_hash, declaration, state FROM _record_kinds ORDER BY kind_id").all().map(toKindRow);
|
|
165689
165396
|
}
|
|
165690
165397
|
function physicalIndexSql(db, kindId, name) {
|
|
165691
165398
|
return db.prepare("SELECT name, sql FROM sqlite_master WHERE type = 'index' AND name = ?").get(indexName(kindId, name))?.sql ?? null;
|
|
@@ -165741,8 +165448,7 @@ CREATE TABLE IF NOT EXISTS _record_sequences (
|
|
|
165741
165448
|
database: declaration.database,
|
|
165742
165449
|
hash,
|
|
165743
165450
|
state: "declared",
|
|
165744
|
-
declaration
|
|
165745
|
-
adoptedAt: prior?.adoptedAt ?? null
|
|
165451
|
+
declaration
|
|
165746
165452
|
},
|
|
165747
165453
|
result: {
|
|
165748
165454
|
kindId,
|
|
@@ -166152,8 +165858,8 @@ CREATE TABLE IF NOT EXISTS _record_sequences (
|
|
|
166152
165858
|
}
|
|
166153
165859
|
/**
|
|
166154
165860
|
* Boot correction: every kind that ever allocated an id has its counter raised
|
|
166155
|
-
* above the highest numeric id it holds.
|
|
166156
|
-
* chosen numeric id) kept ids far above a counter that started at 1, and the
|
|
165861
|
+
* above the highest numeric id it holds. Rows the records migration copied
|
|
165862
|
+
* (or any caller chosen numeric id) kept ids far above a counter that started at 1, and the
|
|
166157
165863
|
* upsert would have overwritten another device's row on the first collision.
|
|
166158
165864
|
* Runs on the engine's own connection, over the (kind_id, id) unique index.
|
|
166159
165865
|
*/
|
|
@@ -166171,16 +165877,12 @@ CREATE TABLE IF NOT EXISTS _record_sequences (
|
|
|
166171
165877
|
/** Ids handed out by allocateId and not yet written: their first write is insert-only. */
|
|
166172
165878
|
pendingAllocated = /* @__PURE__ */ new Set();
|
|
166173
165879
|
static PENDING_ALLOCATED_MAX = 4096;
|
|
166174
|
-
/** Raise a kind's counter above the numeric ids of a caller-supplied batch
|
|
165880
|
+
/** Raise a kind's counter above the numeric ids of a caller-supplied batch. */
|
|
166175
165881
|
raiseSequenceFor(k, records) {
|
|
166176
165882
|
let top = -1;
|
|
166177
165883
|
for (const r of records) if (/^\d{1,15}$/.test(r.id)) top = Math.max(top, Number(r.id));
|
|
166178
165884
|
if (top < 0) return;
|
|
166179
|
-
|
|
166180
|
-
this.db.prepare("INSERT INTO _record_sequences(kind_id, next) VALUES (?, ?) ON CONFLICT(kind_id) DO UPDATE SET next = MAX(next, excluded.next)").run(k.kindId, top + 1);
|
|
166181
|
-
return;
|
|
166182
|
-
}
|
|
166183
|
-
this.db.prepare("UPDATE _record_sequences SET next = ? WHERE kind_id = ? AND next < ?").run(top + 1, k.kindId, top + 1);
|
|
165885
|
+
this.db.prepare("INSERT INTO _record_sequences(kind_id, next) VALUES (?, ?) ON CONFLICT(kind_id) DO UPDATE SET next = MAX(next, excluded.next)").run(k.kindId, top + 1);
|
|
166184
165886
|
}
|
|
166185
165887
|
schemaReady;
|
|
166186
165888
|
kindOf(owner, kind) {
|
|
@@ -166576,32 +166278,6 @@ CREATE TABLE IF NOT EXISTS _record_sequences (
|
|
|
166576
166278
|
declarations() {
|
|
166577
166279
|
return [...this.kinds.values()];
|
|
166578
166280
|
}
|
|
166579
|
-
async legacyRowCount(input) {
|
|
166580
|
-
if (this.db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(input.table) === void 0) return null;
|
|
166581
|
-
return this.db.prepare(`SELECT COUNT(*) AS n FROM "${input.table.replaceAll('"', '""')}"`).get()?.n ?? 0;
|
|
166582
|
-
}
|
|
166583
|
-
async adoptionState(input) {
|
|
166584
|
-
return { adoptedAt: this.kindOf(input.owner, input.kind).adoptedAt };
|
|
166585
|
-
}
|
|
166586
|
-
async markAdopted(input) {
|
|
166587
|
-
const k = this.kindOf(input.owner, input.kind);
|
|
166588
|
-
if (k.adoptedAt !== null) return;
|
|
166589
|
-
const at = this.now();
|
|
166590
|
-
this.db.prepare("UPDATE _record_kinds SET adopted_at = ? WHERE kind_id = ?").run(at, k.kindId);
|
|
166591
|
-
this.kinds.set(keyOf(k.owner, k.kind), {
|
|
166592
|
-
...k,
|
|
166593
|
-
adoptedAt: at
|
|
166594
|
-
});
|
|
166595
|
-
}
|
|
166596
|
-
async revokeAdopted(input) {
|
|
166597
|
-
const k = this.kindOf(input.owner, input.kind);
|
|
166598
|
-
if (k.adoptedAt === null) return;
|
|
166599
|
-
this.db.prepare("UPDATE _record_kinds SET adopted_at = NULL WHERE kind_id = ?").run(k.kindId);
|
|
166600
|
-
this.kinds.set(keyOf(k.owner, k.kind), {
|
|
166601
|
-
...k,
|
|
166602
|
-
adoptedAt: null
|
|
166603
|
-
});
|
|
166604
|
-
}
|
|
166605
166281
|
};
|
|
166606
166282
|
var RECORDS_OPS = [
|
|
166607
166283
|
"declareKinds",
|
|
@@ -166621,11 +166297,7 @@ CREATE TABLE IF NOT EXISTS _record_sequences (
|
|
|
166621
166297
|
"deleteDevice",
|
|
166622
166298
|
"allocateId",
|
|
166623
166299
|
"listKinds",
|
|
166624
|
-
"sweepExpired"
|
|
166625
|
-
"legacyRowCount",
|
|
166626
|
-
"adoptionState",
|
|
166627
|
-
"markAdopted",
|
|
166628
|
-
"revokeAdopted"
|
|
166300
|
+
"sweepExpired"
|
|
166629
166301
|
];
|
|
166630
166302
|
function isRecordsOp(op) {
|
|
166631
166303
|
return RECORDS_OPS.some((known) => known === op);
|
|
@@ -166665,8 +166337,7 @@ CREATE TABLE IF NOT EXISTS _record_sequences (
|
|
|
166665
166337
|
"hasTable",
|
|
166666
166338
|
"dropRetiredTable",
|
|
166667
166339
|
"threadId",
|
|
166668
|
-
"listPhysicalTables"
|
|
166669
|
-
"readLegacyCollection"
|
|
166340
|
+
"listPhysicalTables"
|
|
166670
166341
|
];
|
|
166671
166342
|
function isDataStoreOp(op) {
|
|
166672
166343
|
return DATA_STORE_OPS.some((known) => known === op);
|
|
@@ -166720,7 +166391,7 @@ CREATE TABLE IF NOT EXISTS _record_sequences (
|
|
|
166720
166391
|
livesIn;
|
|
166721
166392
|
declaredFor;
|
|
166722
166393
|
constructor(table, livesIn, declaredFor) {
|
|
166723
|
-
super(`table "${table}" is in "${livesIn}", declared for "${declaredFor}";
|
|
166394
|
+
super(`table "${table}" is in "${livesIn}", declared for "${declaredFor}"; the engine never moves data (D853) \u2014 the table must be moved offline, with the hub stopped`);
|
|
166724
166395
|
this.table = table;
|
|
166725
166396
|
this.livesIn = livesIn;
|
|
166726
166397
|
this.declaredFor = declaredFor;
|
|
@@ -167877,46 +167548,6 @@ CREATE TABLE IF NOT EXISTS _record_sequences (
|
|
|
167877
167548
|
}
|
|
167878
167549
|
return out;
|
|
167879
167550
|
}
|
|
167880
|
-
/** Storage-admin only: adopted legacy may still be in `declaredThisBoot` from vestigial declares. */
|
|
167881
|
-
forgetDeclaredThisBoot(name) {
|
|
167882
|
-
this.declaredThisBoot.delete(name);
|
|
167883
|
-
}
|
|
167884
|
-
/**
|
|
167885
|
-
* Paginated `(id, data)` read of a physical table. Does not consult
|
|
167886
|
-
* `declareCollection` — for migration scripts only.
|
|
167887
|
-
*/
|
|
167888
|
-
readLegacyCollection(input) {
|
|
167889
|
-
const name = input.collection;
|
|
167890
|
-
if (RECORDS_ENGINE_TABLES.includes(name)) throw new Error(`read refused: "${name}" is a table of the records engine`);
|
|
167891
|
-
if (!this.hasTable(name)) return {
|
|
167892
|
-
rows: [],
|
|
167893
|
-
nextCursor: null
|
|
167894
|
-
};
|
|
167895
|
-
const limit = input.limit ?? 1e3;
|
|
167896
|
-
const cursor = input.cursor ?? "";
|
|
167897
|
-
const escaped = name.replaceAll('"', '""');
|
|
167898
|
-
const raw = this.getDb().prepare(`SELECT id, data FROM "${escaped}" WHERE id > ? ORDER BY id ASC LIMIT ?`).all(cursor, limit);
|
|
167899
|
-
const rows = [];
|
|
167900
|
-
for (const row of raw) {
|
|
167901
|
-
let data;
|
|
167902
|
-
try {
|
|
167903
|
-
const parsed = JSON.parse(row.data);
|
|
167904
|
-
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error("not an object");
|
|
167905
|
-
data = parsed;
|
|
167906
|
-
} catch {
|
|
167907
|
-
data = {};
|
|
167908
|
-
}
|
|
167909
|
-
rows.push({
|
|
167910
|
-
id: row.id,
|
|
167911
|
-
data
|
|
167912
|
-
});
|
|
167913
|
-
}
|
|
167914
|
-
const last = rows[rows.length - 1];
|
|
167915
|
-
return {
|
|
167916
|
-
rows,
|
|
167917
|
-
nextCursor: rows.length < limit || last === void 0 ? null : last.id
|
|
167918
|
-
};
|
|
167919
|
-
}
|
|
167920
167551
|
/**
|
|
167921
167552
|
* Drop one table nobody owns (D870 migration, one-shot). Refuses a canonical
|
|
167922
167553
|
* or engine table, one a running addon declared since boot, a table that is
|
|
@@ -169459,9 +169090,9 @@ var require_sqlite_settings_addon = __commonJS({
|
|
|
169459
169090
|
[Symbol.toStringTag]: { value: "Module" }
|
|
169460
169091
|
});
|
|
169461
169092
|
var require_chunk = require_chunk_Cek0wNdY();
|
|
169462
|
-
var require_dist10 =
|
|
169093
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
169463
169094
|
var require_retired_settings_keys = require_retired_settings_keys_D_VwZiDt();
|
|
169464
|
-
var require_wal_maintenance =
|
|
169095
|
+
var require_wal_maintenance = require_wal_maintenance_DUHEp_09();
|
|
169465
169096
|
var require_sqlite_snapshot_protocol = require_sqlite_snapshot_protocol_B9OndqZv();
|
|
169466
169097
|
var require_wal_checkpoint_policy = require_wal_checkpoint_policy_d2z2qPqx();
|
|
169467
169098
|
var node_fs_promises = __require("fs/promises");
|
|
@@ -170347,9 +169978,6 @@ var require_sqlite_settings_addon = __commonJS({
|
|
|
170347
169978
|
listPhysicalTables(ownerPrefix) {
|
|
170348
169979
|
return Promise.resolve(require_wal_maintenance.callControl(require_wal_maintenance.controlTargetOf(this.backend, 0), "listPhysicalTables", { ownerPrefix }));
|
|
170349
169980
|
}
|
|
170350
|
-
readLegacyCollection(input) {
|
|
170351
|
-
return Promise.resolve(require_wal_maintenance.callControl(require_wal_maintenance.controlTargetOf(this.backend, 0), "readLegacyCollection", input));
|
|
170352
|
-
}
|
|
170353
169981
|
async dropRetiredTable(name) {
|
|
170354
169982
|
return require_wal_maintenance.callControl(require_wal_maintenance.controlTargetOf(this.backend, 0), "dropRetiredTable", { name });
|
|
170355
169983
|
}
|
|
@@ -170406,9 +170034,6 @@ var require_sqlite_settings_addon = __commonJS({
|
|
|
170406
170034
|
listPhysicalTables(ownerPrefix) {
|
|
170407
170035
|
return this.client.control("listPhysicalTables", { ownerPrefix });
|
|
170408
170036
|
}
|
|
170409
|
-
readLegacyCollection(input) {
|
|
170410
|
-
return this.client.control("readLegacyCollection", input);
|
|
170411
|
-
}
|
|
170412
170037
|
dropRetiredTable(name) {
|
|
170413
170038
|
return this.client.control("dropRetiredTable", { name });
|
|
170414
170039
|
}
|
|
@@ -170638,50 +170263,6 @@ var require_sqlite_settings_addon = __commonJS({
|
|
|
170638
170263
|
return this.route(input.namespace, input.collection, "isEmpty", input);
|
|
170639
170264
|
}
|
|
170640
170265
|
};
|
|
170641
|
-
function isRecord$1(value) {
|
|
170642
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
170643
|
-
}
|
|
170644
|
-
function unwrapValue$1(raw) {
|
|
170645
|
-
if (isRecord$1(raw) && "value" in raw) return raw["value"];
|
|
170646
|
-
return raw;
|
|
170647
|
-
}
|
|
170648
|
-
function legacyRowId(item) {
|
|
170649
|
-
const id = item["id"];
|
|
170650
|
-
if (typeof id === "string" && id.length > 0) return id;
|
|
170651
|
-
const username = item["username"];
|
|
170652
|
-
if (typeof username === "string" && username.length > 0) return username;
|
|
170653
|
-
return null;
|
|
170654
|
-
}
|
|
170655
|
-
async function countSettingsArrayLegacy(router, addonId, settingsKey) {
|
|
170656
|
-
const list = unwrapValue$1(await router.get({
|
|
170657
|
-
collection: "addon-settings",
|
|
170658
|
-
key: `${addonId}.${settingsKey}`
|
|
170659
|
-
}));
|
|
170660
|
-
if (!Array.isArray(list)) return 0;
|
|
170661
|
-
let n = 0;
|
|
170662
|
-
for (const item of list) {
|
|
170663
|
-
if (!isRecord$1(item)) continue;
|
|
170664
|
-
if (legacyRowId(item) !== null) n += 1;
|
|
170665
|
-
}
|
|
170666
|
-
return n;
|
|
170667
|
-
}
|
|
170668
|
-
function isRecord(value) {
|
|
170669
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
170670
|
-
}
|
|
170671
|
-
function unwrapValue(raw) {
|
|
170672
|
-
if (isRecord(raw) && "value" in raw) return raw["value"];
|
|
170673
|
-
return raw;
|
|
170674
|
-
}
|
|
170675
|
-
async function countSettingsBrokersLegacy(router, addonId) {
|
|
170676
|
-
const list = unwrapValue(await router.get({
|
|
170677
|
-
collection: "addon-settings",
|
|
170678
|
-
key: `${addonId}.brokers`
|
|
170679
|
-
}));
|
|
170680
|
-
if (!Array.isArray(list)) return 0;
|
|
170681
|
-
let n = 0;
|
|
170682
|
-
for (const item of list) if (isRecord(item) && typeof item["id"] === "string") n += 1;
|
|
170683
|
-
return n;
|
|
170684
|
-
}
|
|
170685
170266
|
function recordsCallerOf(input) {
|
|
170686
170267
|
const raw = input !== null && typeof input === "object" ? Reflect.get(input, "callerAddonId") : void 0;
|
|
170687
170268
|
if (typeof raw !== "string" || raw.length === 0) throw new require_dist10.NoCallerError("the call carries no caller identity; records are reached through ctx.records");
|
|
@@ -170690,6 +170271,12 @@ var require_sqlite_settings_addon = __commonJS({
|
|
|
170690
170271
|
function keyOf(owner, kind) {
|
|
170691
170272
|
return `${owner}\0${kind}`;
|
|
170692
170273
|
}
|
|
170274
|
+
function withoutRetiredKeys(declaration) {
|
|
170275
|
+
return {
|
|
170276
|
+
...declaration,
|
|
170277
|
+
adoptsFrom: void 0
|
|
170278
|
+
};
|
|
170279
|
+
}
|
|
170693
170280
|
var RecordsProvider = class {
|
|
170694
170281
|
router;
|
|
170695
170282
|
logger;
|
|
@@ -170723,7 +170310,7 @@ var require_sqlite_settings_addon = __commonJS({
|
|
|
170723
170310
|
const owner = recordsCallerOf(input);
|
|
170724
170311
|
const byDatabase = /* @__PURE__ */ new Map();
|
|
170725
170312
|
const parsed = /* @__PURE__ */ new Map();
|
|
170726
|
-
for (const [kind, raw] of Object.entries(input.kinds)) parsed.set(kind, require_dist10.RecordKindDeclarationSchema.parse(raw));
|
|
170313
|
+
for (const [kind, raw] of Object.entries(input.kinds)) parsed.set(kind, withoutRetiredKeys(require_dist10.RecordKindDeclarationSchema.parse(raw)));
|
|
170727
170314
|
await this.assertFamiliesInOneFile(owner, parsed);
|
|
170728
170315
|
for (const [kind, declaration] of parsed) {
|
|
170729
170316
|
const known = this.placement.get(keyOf(owner, kind));
|
|
@@ -170745,22 +170332,7 @@ var require_sqlite_settings_addon = __commonJS({
|
|
|
170745
170332
|
merged[kind] = result;
|
|
170746
170333
|
}
|
|
170747
170334
|
}
|
|
170748
|
-
return { kinds:
|
|
170749
|
-
}
|
|
170750
|
-
/**
|
|
170751
|
-
* Rows of a legacy table in EVERY open records-capable file. A legacy table lives
|
|
170752
|
-
* in one file, but which one is the layout's business: the phase-3 NC ledgers moved
|
|
170753
|
-
* to `events.db` with the P5 split, and a guard that asked `camstack.db` alone
|
|
170754
|
-
* answered "no legacy rows" for 522 outbox rows (2026-10-20 audit).
|
|
170755
|
-
*/
|
|
170756
|
-
async legacyRowsAnywhere(table) {
|
|
170757
|
-
let total = 0;
|
|
170758
|
-
for (const file of this.router.openFiles()) {
|
|
170759
|
-
if (file.databaseId === "history") continue;
|
|
170760
|
-
const rows = await file.records("legacyRowCount", { table });
|
|
170761
|
-
if (rows !== null) total += rows;
|
|
170762
|
-
}
|
|
170763
|
-
return total;
|
|
170335
|
+
return { kinds: merged };
|
|
170764
170336
|
}
|
|
170765
170337
|
/**
|
|
170766
170338
|
* `transactFamily` (plan risk 8): kinds that must agree through one `transact` sit
|
|
@@ -170791,52 +170363,6 @@ var require_sqlite_settings_addon = __commonJS({
|
|
|
170791
170363
|
throw new require_dist10.DeclarationRefusedError(`transactFamily "${family}" of "${owner}" is split across files (${[...members.entries()].map(([k, db]) => `${k}@${db}`).join(", ")}); a family lives in ONE file`);
|
|
170792
170364
|
}
|
|
170793
170365
|
}
|
|
170794
|
-
/** The boot guard: empty kind + a legacy table that still has rows = adoption pending. */
|
|
170795
|
-
async withAdoption(owner, declared, results) {
|
|
170796
|
-
const out = { ...results };
|
|
170797
|
-
for (const [kind, raw] of Object.entries(declared)) {
|
|
170798
|
-
const legacy = raw.adoptsFrom;
|
|
170799
|
-
const result = results[kind];
|
|
170800
|
-
if (legacy === void 0 || result === void 0) continue;
|
|
170801
|
-
if ((await (await this.fileOf(owner, kind)).records("adoptionState", {
|
|
170802
|
-
owner,
|
|
170803
|
-
kind
|
|
170804
|
-
})).adoptedAt !== null) continue;
|
|
170805
|
-
const settingsBrokersAddon = require_dist10.parseSettingsBrokersAdoptsFrom(legacy);
|
|
170806
|
-
if (settingsBrokersAddon !== null) {
|
|
170807
|
-
const legacyRows2 = await countSettingsBrokersLegacy(this.router, settingsBrokersAddon);
|
|
170808
|
-
if (legacyRows2 > 0) out[kind] = {
|
|
170809
|
-
...result,
|
|
170810
|
-
adoptionPending: {
|
|
170811
|
-
legacyTable: legacy,
|
|
170812
|
-
legacyRows: legacyRows2
|
|
170813
|
-
}
|
|
170814
|
-
};
|
|
170815
|
-
continue;
|
|
170816
|
-
}
|
|
170817
|
-
const settingsArray = require_dist10.parseSettingsArrayAdoptsFrom(legacy);
|
|
170818
|
-
if (settingsArray !== null) {
|
|
170819
|
-
const legacyRows2 = await countSettingsArrayLegacy(this.router, settingsArray.addonId, settingsArray.settingsKey);
|
|
170820
|
-
if (legacyRows2 > 0) out[kind] = {
|
|
170821
|
-
...result,
|
|
170822
|
-
adoptionPending: {
|
|
170823
|
-
legacyTable: legacy,
|
|
170824
|
-
legacyRows: legacyRows2
|
|
170825
|
-
}
|
|
170826
|
-
};
|
|
170827
|
-
continue;
|
|
170828
|
-
}
|
|
170829
|
-
const legacyRows = await this.legacyRowsAnywhere(legacy);
|
|
170830
|
-
if (legacyRows > 0) out[kind] = {
|
|
170831
|
-
...result,
|
|
170832
|
-
adoptionPending: {
|
|
170833
|
-
legacyTable: legacy,
|
|
170834
|
-
legacyRows
|
|
170835
|
-
}
|
|
170836
|
-
};
|
|
170837
|
-
}
|
|
170838
|
-
return out;
|
|
170839
|
-
}
|
|
170840
170366
|
async get(input) {
|
|
170841
170367
|
const owner = recordsCallerOf(input);
|
|
170842
170368
|
return (await this.fileOf(owner, input.kind)).records("get", {
|
|
@@ -170970,50 +170496,6 @@ var require_sqlite_settings_addon = __commonJS({
|
|
|
170970
170496
|
} });
|
|
170971
170497
|
return (await this.fileOf(input.owner, input.kind)).records("query", input);
|
|
170972
170498
|
}
|
|
170973
|
-
/** True when a declared kind lists `collection` as `adoptsFrom` and adoption finished. */
|
|
170974
|
-
async isAdoptedLegacyTable(collection) {
|
|
170975
|
-
const { kinds } = await this.listKinds({ counts: false });
|
|
170976
|
-
for (const k of kinds) {
|
|
170977
|
-
if (k.state === "dropped") continue;
|
|
170978
|
-
if (k.declaration.adoptsFrom !== collection) continue;
|
|
170979
|
-
const { adoptedAt } = await (await this.fileOf(k.owner, k.kind)).records("adoptionState", {
|
|
170980
|
-
owner: k.owner,
|
|
170981
|
-
kind: k.kind
|
|
170982
|
-
});
|
|
170983
|
-
if (adoptedAt !== null) return true;
|
|
170984
|
-
}
|
|
170985
|
-
return false;
|
|
170986
|
-
}
|
|
170987
|
-
async adoptRecords(input) {
|
|
170988
|
-
const file = await this.fileOf(input.owner, input.kind);
|
|
170989
|
-
if (input.records.length > 0) {
|
|
170990
|
-
const { adoptedAt } = await file.records("adoptionState", {
|
|
170991
|
-
owner: input.owner,
|
|
170992
|
-
kind: input.kind
|
|
170993
|
-
});
|
|
170994
|
-
if (adoptedAt !== null) {
|
|
170995
|
-
if ((await file.records("count", {
|
|
170996
|
-
owner: input.owner,
|
|
170997
|
-
kind: input.kind
|
|
170998
|
-
})).count === 0) await file.records("revokeAdopted", {
|
|
170999
|
-
owner: input.owner,
|
|
171000
|
-
kind: input.kind
|
|
171001
|
-
});
|
|
171002
|
-
}
|
|
171003
|
-
}
|
|
171004
|
-
const result = await file.records("putMany", input);
|
|
171005
|
-
if (input.complete === true) await file.records("markAdopted", {
|
|
171006
|
-
owner: input.owner,
|
|
171007
|
-
kind: input.kind
|
|
171008
|
-
});
|
|
171009
|
-
this.logger.warn("records: ADOPTED rows as their declared owner", { meta: {
|
|
171010
|
-
owner: input.owner,
|
|
171011
|
-
kind: input.kind,
|
|
171012
|
-
count: result.count,
|
|
171013
|
-
complete: input.complete === true
|
|
171014
|
-
} });
|
|
171015
|
-
return { adopted: result.count };
|
|
171016
|
-
}
|
|
171017
170499
|
/** Housekeeping: delete rows past `expires_at` in every file that hosts kinds. */
|
|
171018
170500
|
async sweepExpired() {
|
|
171019
170501
|
let deleted = 0;
|
|
@@ -171043,32 +170525,6 @@ var require_sqlite_settings_addon = __commonJS({
|
|
|
171043
170525
|
readRecords(input) {
|
|
171044
170526
|
return this.records.readRecords(input);
|
|
171045
170527
|
}
|
|
171046
|
-
adoptRecords(input) {
|
|
171047
|
-
return this.records.adoptRecords(input);
|
|
171048
|
-
}
|
|
171049
|
-
isAdoptedLegacyTable(input) {
|
|
171050
|
-
return this.records.isAdoptedLegacyTable(input.collection).then((adopted) => ({ adopted }));
|
|
171051
|
-
}
|
|
171052
|
-
async readLegacyCollection(input) {
|
|
171053
|
-
if (this.backend.hasTable(input.collection)) {
|
|
171054
|
-
const page = this.backend.readLegacyCollection(input);
|
|
171055
|
-
return {
|
|
171056
|
-
rows: [...page.rows],
|
|
171057
|
-
nextCursor: page.nextCursor
|
|
171058
|
-
};
|
|
171059
|
-
}
|
|
171060
|
-
for (const file of await this.peerFiles()) if (await file.hasTable(input.collection)) {
|
|
171061
|
-
const page = await file.readLegacyCollection(input);
|
|
171062
|
-
return {
|
|
171063
|
-
rows: [...page.rows],
|
|
171064
|
-
nextCursor: page.nextCursor
|
|
171065
|
-
};
|
|
171066
|
-
}
|
|
171067
|
-
return {
|
|
171068
|
-
rows: [],
|
|
171069
|
-
nextCursor: null
|
|
171070
|
-
};
|
|
171071
|
-
}
|
|
171072
170528
|
/** May this table be dropped AT ALL? Throws with the reason when not. */
|
|
171073
170529
|
async assertDroppable(collection) {
|
|
171074
170530
|
const colon = collection.indexOf(":");
|
|
@@ -171080,7 +170536,7 @@ var require_sqlite_settings_addon = __commonJS({
|
|
|
171080
170536
|
throw new Error(`drop refused: the installed addons could not be read (${err instanceof Error ? err.message : String(err)})`);
|
|
171081
170537
|
});
|
|
171082
170538
|
const owner = collection.slice(0, colon);
|
|
171083
|
-
if (installed.has(owner)
|
|
170539
|
+
if (installed.has(owner)) throw new Error(`drop refused: "${collection}" belongs to the installed addon "${owner}"`);
|
|
171084
170540
|
}
|
|
171085
170541
|
async listTables(input) {
|
|
171086
170542
|
const tables = [...this.backend.listTables(input.ownerPrefix)];
|
|
@@ -171095,7 +170551,6 @@ var require_sqlite_settings_addon = __commonJS({
|
|
|
171095
170551
|
async dropCollection(input) {
|
|
171096
170552
|
try {
|
|
171097
170553
|
await this.assertDroppable(input.collection);
|
|
171098
|
-
if (await this.records.isAdoptedLegacyTable(input.collection)) this.backend.forgetDeclaredThisBoot(input.collection);
|
|
171099
170554
|
const rows = this.backend.dropTable(input.collection, input.expectRows);
|
|
171100
170555
|
this.logger.warn("storage-admin: DROPPED a table", { meta: {
|
|
171101
170556
|
collection: input.collection,
|
|
@@ -171364,7 +170819,7 @@ var require_sqlite_storage = __commonJS({
|
|
|
171364
170819
|
});
|
|
171365
170820
|
require_chunk_Cek0wNdY();
|
|
171366
170821
|
var require_builtins_sqlite_storage_filesystem_storage_addon = require_filesystem_storage_addon();
|
|
171367
|
-
var require_wal_maintenance =
|
|
170822
|
+
var require_wal_maintenance = require_wal_maintenance_DUHEp_09();
|
|
171368
170823
|
var require_builtins_sqlite_storage_sqlite_settings_addon = require_sqlite_settings_addon();
|
|
171369
170824
|
var ConfigStore = class {
|
|
171370
170825
|
db;
|
|
@@ -171448,7 +170903,7 @@ var require_storage_orchestrator_addon = __commonJS({
|
|
|
171448
170903
|
[Symbol.toStringTag]: { value: "Module" }
|
|
171449
170904
|
});
|
|
171450
170905
|
var require_chunk = require_chunk_Cek0wNdY();
|
|
171451
|
-
var require_dist10 =
|
|
170906
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
171452
170907
|
var require_read_all_rows$1 = require_read_all_rows_CVoO1ONM();
|
|
171453
170908
|
var zod = require_zod();
|
|
171454
170909
|
var node_crypto = __require("crypto");
|
|
@@ -171494,8 +170949,7 @@ var require_storage_orchestrator_addon = __commonJS({
|
|
|
171494
170949
|
name: "type",
|
|
171495
170950
|
fields: ["type"]
|
|
171496
170951
|
}],
|
|
171497
|
-
retention: { none: "operator delete or declaration prune only" }
|
|
171498
|
-
adoptsFrom: STORAGE_LOCATIONS
|
|
170952
|
+
retention: { none: "operator delete or declaration prune only" }
|
|
171499
170953
|
},
|
|
171500
170954
|
"seed-markers": {
|
|
171501
170955
|
schema: StorageSeedMarkerBodySchema,
|
|
@@ -171515,8 +170969,7 @@ var require_storage_orchestrator_addon = __commonJS({
|
|
|
171515
170969
|
name: "location_id",
|
|
171516
170970
|
fields: ["locationId"]
|
|
171517
170971
|
}],
|
|
171518
|
-
retention: { none: "row deleted when location leaves drain" }
|
|
171519
|
-
adoptsFrom: STORAGE_DRAIN_STATE_LEGACY
|
|
170972
|
+
retention: { none: "row deleted when location leaves drain" }
|
|
171520
170973
|
}
|
|
171521
170974
|
});
|
|
171522
170975
|
var storageOrchestratorRecordKinds = _storageOrchestratorRecordKinds;
|
|
@@ -175389,8 +174842,8 @@ var require_storage_orchestrator_addon = __commonJS({
|
|
|
175389
174842
|
* restart — the service never hydrates from / persists to SQLite.
|
|
175390
174843
|
*/
|
|
175391
174844
|
storeWireInFlight = null;
|
|
175392
|
-
/** True while the locations kind
|
|
175393
|
-
async
|
|
174845
|
+
/** True while the locations kind cannot be declared: its empty answer is not authoritative. */
|
|
174846
|
+
async locationsKindNotReady() {
|
|
175394
174847
|
const records = this.ctx.records;
|
|
175395
174848
|
if (records === void 0 || this.locationsKind === null) return false;
|
|
175396
174849
|
try {
|
|
@@ -175398,7 +174851,7 @@ var require_storage_orchestrator_addon = __commonJS({
|
|
|
175398
174851
|
return false;
|
|
175399
174852
|
} catch (err) {
|
|
175400
174853
|
const message = err instanceof Error ? err.message : String(err);
|
|
175401
|
-
this.ctx.logger.warn("storage-orchestrator: persistence NOT wired \u2014 the storage-locations kind is not authoritative yet (
|
|
174854
|
+
this.ctx.logger.warn("storage-orchestrator: persistence NOT wired \u2014 the storage-locations kind is not authoritative yet (its declaration failed); seeding is deferred", { meta: { error: message } });
|
|
175402
174855
|
return true;
|
|
175403
174856
|
}
|
|
175404
174857
|
}
|
|
@@ -175408,7 +174861,7 @@ var require_storage_orchestrator_addon = __commonJS({
|
|
|
175408
174861
|
if (this.storeWireInFlight) return this.storeWireInFlight;
|
|
175409
174862
|
const store = this.resolveLocationStore(true);
|
|
175410
174863
|
if (!store) return;
|
|
175411
|
-
if (await this.
|
|
174864
|
+
if (await this.locationsKindNotReady()) return;
|
|
175412
174865
|
this.ctx.logger.info("storage-orchestrator: data-store engine now available \u2014 wiring persistence");
|
|
175413
174866
|
this.storeWireInFlight = service.attachStore(store).then(() => this.seedFromDeclarations()).catch((err) => {
|
|
175414
174867
|
this.ctx.logger.error("storage-orchestrator: attachStore failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
@@ -176037,81 +175490,13 @@ var require_storage_orchestrator = __commonJS({
|
|
|
176037
175490
|
}
|
|
176038
175491
|
});
|
|
176039
175492
|
|
|
176040
|
-
// ../system/dist/
|
|
176041
|
-
var
|
|
176042
|
-
"../system/dist/
|
|
176043
|
-
"use strict";
|
|
176044
|
-
var MESH_CA_KEY_REF = require_dist_BZQjLPiz().buildSecretRef({
|
|
176045
|
-
owner: "system",
|
|
176046
|
-
scope: { kind: "global" },
|
|
176047
|
-
fieldPath: "meshCaKey"
|
|
176048
|
-
});
|
|
176049
|
-
var MESH_CA_SETTINGS_KEY = "cluster.meshCa";
|
|
176050
|
-
var MESH_CA_FIELD = "meshCa";
|
|
176051
|
-
var MESH_CA_VALIDITY_DAYS = 3650;
|
|
176052
|
-
var DEFAULT_HUB_TLS_TCP_PORT = 6443;
|
|
176053
|
-
var MESH_CA_COMMON_NAME = "CamStack Mesh CA";
|
|
176054
|
-
var SERVER_AUTH_OID = "1.3.6.1.5.5.7.3.1";
|
|
176055
|
-
var CLIENT_AUTH_OID = "1.3.6.1.5.5.7.3.2";
|
|
176056
|
-
Object.defineProperty(exports, "CLIENT_AUTH_OID", {
|
|
176057
|
-
enumerable: true,
|
|
176058
|
-
get: function() {
|
|
176059
|
-
return CLIENT_AUTH_OID;
|
|
176060
|
-
}
|
|
176061
|
-
});
|
|
176062
|
-
Object.defineProperty(exports, "DEFAULT_HUB_TLS_TCP_PORT", {
|
|
176063
|
-
enumerable: true,
|
|
176064
|
-
get: function() {
|
|
176065
|
-
return DEFAULT_HUB_TLS_TCP_PORT;
|
|
176066
|
-
}
|
|
176067
|
-
});
|
|
176068
|
-
Object.defineProperty(exports, "MESH_CA_COMMON_NAME", {
|
|
176069
|
-
enumerable: true,
|
|
176070
|
-
get: function() {
|
|
176071
|
-
return MESH_CA_COMMON_NAME;
|
|
176072
|
-
}
|
|
176073
|
-
});
|
|
176074
|
-
Object.defineProperty(exports, "MESH_CA_FIELD", {
|
|
176075
|
-
enumerable: true,
|
|
176076
|
-
get: function() {
|
|
176077
|
-
return MESH_CA_FIELD;
|
|
176078
|
-
}
|
|
176079
|
-
});
|
|
176080
|
-
Object.defineProperty(exports, "MESH_CA_KEY_REF", {
|
|
176081
|
-
enumerable: true,
|
|
176082
|
-
get: function() {
|
|
176083
|
-
return MESH_CA_KEY_REF;
|
|
176084
|
-
}
|
|
176085
|
-
});
|
|
176086
|
-
Object.defineProperty(exports, "MESH_CA_SETTINGS_KEY", {
|
|
176087
|
-
enumerable: true,
|
|
176088
|
-
get: function() {
|
|
176089
|
-
return MESH_CA_SETTINGS_KEY;
|
|
176090
|
-
}
|
|
176091
|
-
});
|
|
176092
|
-
Object.defineProperty(exports, "MESH_CA_VALIDITY_DAYS", {
|
|
176093
|
-
enumerable: true,
|
|
176094
|
-
get: function() {
|
|
176095
|
-
return MESH_CA_VALIDITY_DAYS;
|
|
176096
|
-
}
|
|
176097
|
-
});
|
|
176098
|
-
Object.defineProperty(exports, "SERVER_AUTH_OID", {
|
|
176099
|
-
enumerable: true,
|
|
176100
|
-
get: function() {
|
|
176101
|
-
return SERVER_AUTH_OID;
|
|
176102
|
-
}
|
|
176103
|
-
});
|
|
176104
|
-
}
|
|
176105
|
-
});
|
|
176106
|
-
|
|
176107
|
-
// ../system/dist/agent-https-DOELEug8.js
|
|
176108
|
-
var require_agent_https_DOELEug8 = __commonJS({
|
|
176109
|
-
"../system/dist/agent-https-DOELEug8.js"(exports) {
|
|
175493
|
+
// ../system/dist/agent-https-Dnr_nIVx.js
|
|
175494
|
+
var require_agent_https_Dnr_nIVx = __commonJS({
|
|
175495
|
+
"../system/dist/agent-https-Dnr_nIVx.js"(exports) {
|
|
176110
175496
|
"use strict";
|
|
176111
175497
|
var require_chunk = require_chunk_Cek0wNdY();
|
|
176112
|
-
var require_dist10 =
|
|
175498
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
176113
175499
|
var require_x509_es = require_x509_es_C4cOo48M();
|
|
176114
|
-
var require_constants15 = require_constants_Njka8Cv6();
|
|
176115
175500
|
var zod = require_zod();
|
|
176116
175501
|
var node_crypto = __require("crypto");
|
|
176117
175502
|
var _camstack_types_node = require_node();
|
|
@@ -176120,566 +175505,6 @@ var require_agent_https_DOELEug8 = __commonJS({
|
|
|
176120
175505
|
var node_os = __require("os");
|
|
176121
175506
|
node_os = require_chunk.__toESM(node_os);
|
|
176122
175507
|
var node_fs = __require("fs");
|
|
176123
|
-
require_x509_es.cryptoProvider.set(node_crypto.webcrypto);
|
|
176124
|
-
var MS_PER_DAY$2 = 864e5;
|
|
176125
|
-
var MESH_KEY_ALGORITHM = {
|
|
176126
|
-
name: "ECDSA",
|
|
176127
|
-
namedCurve: "P-256"
|
|
176128
|
-
};
|
|
176129
|
-
var MESH_SIGNING_ALGORITHM = {
|
|
176130
|
-
name: "ECDSA",
|
|
176131
|
-
hash: "SHA-256"
|
|
176132
|
-
};
|
|
176133
|
-
var NODE_ID_PATTERN = /^[a-z0-9][a-z0-9._-]{0,62}$/i;
|
|
176134
|
-
var RESERVED_NODE_IDS = /* @__PURE__ */ new Set(["hub"]);
|
|
176135
|
-
function isValidAgentNodeId(nodeId) {
|
|
176136
|
-
return NODE_ID_PATTERN.test(nodeId) && !RESERVED_NODE_IDS.has(nodeId.toLowerCase());
|
|
176137
|
-
}
|
|
176138
|
-
function freshSerial$1() {
|
|
176139
|
-
return `00${(0, node_crypto.randomBytes)(16).toString("hex")}`;
|
|
176140
|
-
}
|
|
176141
|
-
function toPkcs8Pem$1(pkcs8) {
|
|
176142
|
-
return `${require_x509_es.PemConverter.encode(pkcs8, "PRIVATE KEY")}
|
|
176143
|
-
`;
|
|
176144
|
-
}
|
|
176145
|
-
function toCertPem$1(cert) {
|
|
176146
|
-
return `${cert.toString("pem")}
|
|
176147
|
-
`;
|
|
176148
|
-
}
|
|
176149
|
-
async function exportKeyPem$1(key) {
|
|
176150
|
-
return toPkcs8Pem$1(await node_crypto.webcrypto.subtle.exportKey("pkcs8", key));
|
|
176151
|
-
}
|
|
176152
|
-
function caFingerprint(certPem) {
|
|
176153
|
-
return new node_crypto.X509Certificate(certPem).fingerprint256;
|
|
176154
|
-
}
|
|
176155
|
-
function caFingerprintCompact(certPem) {
|
|
176156
|
-
return (0, node_crypto.createHash)("sha256").update(new node_crypto.X509Certificate(certPem).raw).digest("hex");
|
|
176157
|
-
}
|
|
176158
|
-
async function generateMeshCa(now = /* @__PURE__ */ new Date()) {
|
|
176159
|
-
const keys = await node_crypto.webcrypto.subtle.generateKey(MESH_KEY_ALGORITHM, true, ["sign", "verify"]);
|
|
176160
|
-
const extensions = [
|
|
176161
|
-
new require_x509_es.BasicConstraintsExtension(true, 0, true),
|
|
176162
|
-
new require_x509_es.KeyUsagesExtension(require_x509_es.KeyUsageFlags.keyCertSign | require_x509_es.KeyUsageFlags.cRLSign, true),
|
|
176163
|
-
await require_x509_es.SubjectKeyIdentifierExtension.create(keys.publicKey)
|
|
176164
|
-
];
|
|
176165
|
-
const cert = await require_x509_es.X509CertificateGenerator.createSelfSigned({
|
|
176166
|
-
serialNumber: freshSerial$1(),
|
|
176167
|
-
name: `CN=${require_constants15.MESH_CA_COMMON_NAME}`,
|
|
176168
|
-
notBefore: require_x509_es.backdatedNotBefore(now),
|
|
176169
|
-
notAfter: new Date(now.getTime() + require_constants15.MESH_CA_VALIDITY_DAYS * MS_PER_DAY$2),
|
|
176170
|
-
keys,
|
|
176171
|
-
signingAlgorithm: MESH_SIGNING_ALGORITHM,
|
|
176172
|
-
extensions
|
|
176173
|
-
});
|
|
176174
|
-
return {
|
|
176175
|
-
certPem: toCertPem$1(cert),
|
|
176176
|
-
keyPem: await exportKeyPem$1(keys.privateKey),
|
|
176177
|
-
cert,
|
|
176178
|
-
privateKey: keys.privateKey,
|
|
176179
|
-
publicKey: keys.publicKey
|
|
176180
|
-
};
|
|
176181
|
-
}
|
|
176182
|
-
async function loadMeshCa(certPem, keyPem) {
|
|
176183
|
-
const cert = new require_x509_es.X509Certificate(certPem);
|
|
176184
|
-
return {
|
|
176185
|
-
certPem,
|
|
176186
|
-
keyPem,
|
|
176187
|
-
cert,
|
|
176188
|
-
privateKey: await node_crypto.webcrypto.subtle.importKey("pkcs8", require_x509_es.PemConverter.decodeFirst(keyPem), MESH_KEY_ALGORITHM, true, ["sign"]),
|
|
176189
|
-
publicKey: await cert.publicKey.export(node_crypto.webcrypto)
|
|
176190
|
-
};
|
|
176191
|
-
}
|
|
176192
|
-
async function issueMeshLeafFromCsr(ca, csrPem, opts = {}) {
|
|
176193
|
-
const csr = new require_x509_es.Pkcs10CertificateRequest(csrPem);
|
|
176194
|
-
if (!await csr.verify(node_crypto.webcrypto)) throw new Error("CSR signature is invalid");
|
|
176195
|
-
const cn = subjectCn(csr.subject);
|
|
176196
|
-
if (cn === null || cn.length === 0) throw new Error("CSR subject has no CN");
|
|
176197
|
-
if (opts.allowReserved !== true && !isValidAgentNodeId(cn)) throw new Error(`CSR CN '${cn}' is not an id an agent may carry`);
|
|
176198
|
-
if (opts.expectedNodeId !== void 0 && opts.expectedNodeId !== cn) throw new Error(`CSR CN '${cn}' does not match the token nodeId '${opts.expectedNodeId}'`);
|
|
176199
|
-
const now = opts.now ?? /* @__PURE__ */ new Date();
|
|
176200
|
-
const validDays = opts.validDays ?? 30;
|
|
176201
|
-
const serialNumber = freshSerial$1();
|
|
176202
|
-
const notAfter = new Date(now.getTime() + validDays * MS_PER_DAY$2);
|
|
176203
|
-
const extensions = [
|
|
176204
|
-
new require_x509_es.BasicConstraintsExtension(false, void 0, true),
|
|
176205
|
-
new require_x509_es.KeyUsagesExtension(require_x509_es.KeyUsageFlags.digitalSignature, true),
|
|
176206
|
-
new require_x509_es.ExtendedKeyUsageExtension([require_constants15.SERVER_AUTH_OID, require_constants15.CLIENT_AUTH_OID]),
|
|
176207
|
-
await require_x509_es.SubjectKeyIdentifierExtension.create(csr.publicKey),
|
|
176208
|
-
await require_x509_es.AuthorityKeyIdentifierExtension.create(ca.cert)
|
|
176209
|
-
];
|
|
176210
|
-
return {
|
|
176211
|
-
certPem: toCertPem$1(await require_x509_es.X509CertificateGenerator.create({
|
|
176212
|
-
serialNumber,
|
|
176213
|
-
subject: `CN=${cn}`,
|
|
176214
|
-
issuer: ca.cert.subject,
|
|
176215
|
-
notBefore: require_x509_es.backdatedNotBefore(now),
|
|
176216
|
-
notAfter,
|
|
176217
|
-
publicKey: csr.publicKey,
|
|
176218
|
-
signingKey: ca.privateKey,
|
|
176219
|
-
signingAlgorithm: MESH_SIGNING_ALGORITHM,
|
|
176220
|
-
extensions
|
|
176221
|
-
})),
|
|
176222
|
-
serialNumber,
|
|
176223
|
-
notAfter,
|
|
176224
|
-
commonName: cn
|
|
176225
|
-
};
|
|
176226
|
-
}
|
|
176227
|
-
async function issueMeshLeafForNode(ca, nodeId, opts = {}) {
|
|
176228
|
-
const keys = await node_crypto.webcrypto.subtle.generateKey(MESH_KEY_ALGORITHM, true, ["sign", "verify"]);
|
|
176229
|
-
return {
|
|
176230
|
-
...await issueMeshLeafFromCsr(ca, await createMeshCsrPem(keys, nodeId), {
|
|
176231
|
-
expectedNodeId: nodeId,
|
|
176232
|
-
now: opts.now,
|
|
176233
|
-
validDays: opts.validDays,
|
|
176234
|
-
allowReserved: true
|
|
176235
|
-
}),
|
|
176236
|
-
keyPem: await exportKeyPem$1(keys.privateKey)
|
|
176237
|
-
};
|
|
176238
|
-
}
|
|
176239
|
-
function subjectCn(subject) {
|
|
176240
|
-
return /(?:^|,)\s*CN\s*=\s*([^,]+)/i.exec(subject)?.[1]?.trim() ?? null;
|
|
176241
|
-
}
|
|
176242
|
-
async function createMeshCsrPem(keys, commonName) {
|
|
176243
|
-
return `${(await require_x509_es.Pkcs10CertificateRequestGenerator.create({
|
|
176244
|
-
name: `CN=${commonName}`,
|
|
176245
|
-
keys,
|
|
176246
|
-
signingAlgorithm: MESH_SIGNING_ALGORITHM
|
|
176247
|
-
})).toString("pem")}
|
|
176248
|
-
`;
|
|
176249
|
-
}
|
|
176250
|
-
async function generateMeshKeyPair() {
|
|
176251
|
-
return node_crypto.webcrypto.subtle.generateKey(MESH_KEY_ALGORITHM, true, ["sign", "verify"]);
|
|
176252
|
-
}
|
|
176253
|
-
async function exportMeshPrivateKeyPem(key) {
|
|
176254
|
-
return exportKeyPem$1(key);
|
|
176255
|
-
}
|
|
176256
|
-
var MESH_NODE_CERTIFICATES_COLLECTION = "mesh_node_certificates";
|
|
176257
|
-
var MESH_NODE_CERTIFICATES_COLUMNS = [
|
|
176258
|
-
{
|
|
176259
|
-
name: "id",
|
|
176260
|
-
type: "TEXT",
|
|
176261
|
-
primaryKey: true,
|
|
176262
|
-
notNull: true
|
|
176263
|
-
},
|
|
176264
|
-
{
|
|
176265
|
-
name: "nodeId",
|
|
176266
|
-
type: "TEXT",
|
|
176267
|
-
notNull: true
|
|
176268
|
-
},
|
|
176269
|
-
{
|
|
176270
|
-
name: "serial",
|
|
176271
|
-
type: "TEXT",
|
|
176272
|
-
notNull: true
|
|
176273
|
-
},
|
|
176274
|
-
{
|
|
176275
|
-
name: "fingerprint",
|
|
176276
|
-
type: "TEXT",
|
|
176277
|
-
notNull: true
|
|
176278
|
-
},
|
|
176279
|
-
{
|
|
176280
|
-
name: "notBefore",
|
|
176281
|
-
type: "INTEGER",
|
|
176282
|
-
notNull: true
|
|
176283
|
-
},
|
|
176284
|
-
{
|
|
176285
|
-
name: "notAfter",
|
|
176286
|
-
type: "INTEGER",
|
|
176287
|
-
notNull: true
|
|
176288
|
-
},
|
|
176289
|
-
{
|
|
176290
|
-
name: "issuedAt",
|
|
176291
|
-
type: "INTEGER",
|
|
176292
|
-
notNull: true
|
|
176293
|
-
},
|
|
176294
|
-
{
|
|
176295
|
-
name: "issuedVia",
|
|
176296
|
-
type: "TEXT",
|
|
176297
|
-
notNull: true
|
|
176298
|
-
},
|
|
176299
|
-
{
|
|
176300
|
-
name: "revokedAt",
|
|
176301
|
-
type: "INTEGER"
|
|
176302
|
-
},
|
|
176303
|
-
{
|
|
176304
|
-
name: "revokedReason",
|
|
176305
|
-
type: "TEXT"
|
|
176306
|
-
}
|
|
176307
|
-
];
|
|
176308
|
-
var RETENTION_MS = 90 * 864e5;
|
|
176309
|
-
var RENEWAL_ABANDONED = "renewal-abandoned";
|
|
176310
|
-
var VIAS = [
|
|
176311
|
-
"enroll",
|
|
176312
|
-
"pairing",
|
|
176313
|
-
"renewal",
|
|
176314
|
-
"boot",
|
|
176315
|
-
"observed"
|
|
176316
|
-
];
|
|
176317
|
-
function describeMeshLeaf(cert) {
|
|
176318
|
-
const x509 = new node_crypto.X509Certificate(cert);
|
|
176319
|
-
return {
|
|
176320
|
-
cn: subjectCn(x509.subject) ?? "",
|
|
176321
|
-
serial: x509.serialNumber,
|
|
176322
|
-
fingerprint: x509.fingerprint256,
|
|
176323
|
-
notBefore: Date.parse(x509.validFrom),
|
|
176324
|
-
notAfter: Date.parse(x509.validTo)
|
|
176325
|
-
};
|
|
176326
|
-
}
|
|
176327
|
-
function normalizeSerial(serial) {
|
|
176328
|
-
return serial.replace(/^0x/i, "").replace(/:/g, "").toLowerCase();
|
|
176329
|
-
}
|
|
176330
|
-
function parse$1(data) {
|
|
176331
|
-
const str = (k) => {
|
|
176332
|
-
const v = data[k];
|
|
176333
|
-
return typeof v === "string" && v.length > 0 ? v : null;
|
|
176334
|
-
};
|
|
176335
|
-
const num = (k) => {
|
|
176336
|
-
const v = data[k];
|
|
176337
|
-
return typeof v === "number" && Number.isFinite(v) ? v : null;
|
|
176338
|
-
};
|
|
176339
|
-
const nodeId = str("nodeId");
|
|
176340
|
-
const serial = str("serial");
|
|
176341
|
-
const fingerprint = str("fingerprint");
|
|
176342
|
-
const notBefore = num("notBefore");
|
|
176343
|
-
const notAfter = num("notAfter");
|
|
176344
|
-
const issuedAt = num("issuedAt");
|
|
176345
|
-
if (nodeId === null || serial === null || fingerprint === null || notBefore === null || notAfter === null || issuedAt === null) return null;
|
|
176346
|
-
return {
|
|
176347
|
-
nodeId,
|
|
176348
|
-
serial,
|
|
176349
|
-
fingerprint,
|
|
176350
|
-
notBefore,
|
|
176351
|
-
notAfter,
|
|
176352
|
-
issuedAt,
|
|
176353
|
-
issuedVia: VIAS.find((v) => v === data["issuedVia"]) ?? "observed",
|
|
176354
|
-
revokedAt: num("revokedAt"),
|
|
176355
|
-
revokedReason: str("revokedReason")
|
|
176356
|
-
};
|
|
176357
|
-
}
|
|
176358
|
-
var MeshCertificateRegistry = class {
|
|
176359
|
-
store;
|
|
176360
|
-
deps;
|
|
176361
|
-
rows = /* @__PURE__ */ new Map();
|
|
176362
|
-
constructor(store, deps = {}) {
|
|
176363
|
-
this.store = store;
|
|
176364
|
-
this.deps = deps;
|
|
176365
|
-
}
|
|
176366
|
-
recordToBody(record) {
|
|
176367
|
-
return {
|
|
176368
|
-
nodeId: record.nodeId,
|
|
176369
|
-
serial: record.serial,
|
|
176370
|
-
fingerprint: record.fingerprint,
|
|
176371
|
-
notBefore: record.notBefore,
|
|
176372
|
-
notAfter: record.notAfter,
|
|
176373
|
-
issuedAt: record.issuedAt,
|
|
176374
|
-
issuedVia: record.issuedVia,
|
|
176375
|
-
revokedAt: record.revokedAt,
|
|
176376
|
-
revokedReason: record.revokedReason
|
|
176377
|
-
};
|
|
176378
|
-
}
|
|
176379
|
-
now() {
|
|
176380
|
-
return (this.deps.now ?? Date.now)();
|
|
176381
|
-
}
|
|
176382
|
-
async load() {
|
|
176383
|
-
const kind = this.deps.meshKind ?? null;
|
|
176384
|
-
if (kind !== null) {
|
|
176385
|
-
const page = await kind.query({ limit: 1e4 });
|
|
176386
|
-
for (const row of page.records) {
|
|
176387
|
-
const { fingerprint: _fp, ...body } = row.data;
|
|
176388
|
-
const record = parse$1({
|
|
176389
|
-
...body,
|
|
176390
|
-
fingerprint: row.id
|
|
176391
|
-
});
|
|
176392
|
-
if (record !== null) this.rows.set(record.fingerprint, record);
|
|
176393
|
-
}
|
|
176394
|
-
return;
|
|
176395
|
-
}
|
|
176396
|
-
const rows = await this.store.query.query({ collection: MESH_NODE_CERTIFICATES_COLLECTION });
|
|
176397
|
-
for (const row of rows) {
|
|
176398
|
-
const record = parse$1(row.data);
|
|
176399
|
-
if (record !== null) this.rows.set(record.fingerprint, record);
|
|
176400
|
-
}
|
|
176401
|
-
}
|
|
176402
|
-
/** Write down a leaf the hub just issued. Idempotent per fingerprint. */
|
|
176403
|
-
async recordIssued(nodeId, certPem, via) {
|
|
176404
|
-
const leaf = describeMeshLeaf(certPem);
|
|
176405
|
-
const existing = this.rows.get(leaf.fingerprint);
|
|
176406
|
-
if (existing !== void 0) return existing;
|
|
176407
|
-
const record = {
|
|
176408
|
-
nodeId,
|
|
176409
|
-
serial: leaf.serial,
|
|
176410
|
-
fingerprint: leaf.fingerprint,
|
|
176411
|
-
notBefore: leaf.notBefore,
|
|
176412
|
-
notAfter: leaf.notAfter,
|
|
176413
|
-
issuedAt: this.now(),
|
|
176414
|
-
issuedVia: via,
|
|
176415
|
-
revokedAt: null,
|
|
176416
|
-
revokedReason: null
|
|
176417
|
-
};
|
|
176418
|
-
await this.insert(record);
|
|
176419
|
-
this.deps.logger?.info("Mesh certificate recorded", {
|
|
176420
|
-
tags: { nodeId },
|
|
176421
|
-
meta: {
|
|
176422
|
-
via,
|
|
176423
|
-
serial: leaf.serial,
|
|
176424
|
-
notAfter: new Date(leaf.notAfter).toISOString()
|
|
176425
|
-
}
|
|
176426
|
-
});
|
|
176427
|
-
return record;
|
|
176428
|
-
}
|
|
176429
|
-
/**
|
|
176430
|
-
* A node was seen presenting `leaf` on its live connection. A leaf the hub already
|
|
176431
|
-
* knows is left alone; an unknown one is recorded `observed` (a node enrolled
|
|
176432
|
-
* before this record existed).
|
|
176433
|
-
*/
|
|
176434
|
-
async recordObserved(nodeId, leaf) {
|
|
176435
|
-
const known = this.rows.get(leaf.fingerprint);
|
|
176436
|
-
if (known !== void 0) {
|
|
176437
|
-
if (known.revokedReason !== "renewal-abandoned") return known.revokedAt === null ? this.abandonRenewalsNewerThan(known) : false;
|
|
176438
|
-
const reinstated = {
|
|
176439
|
-
...known,
|
|
176440
|
-
revokedAt: null,
|
|
176441
|
-
revokedReason: null
|
|
176442
|
-
};
|
|
176443
|
-
this.rows.set(known.fingerprint, reinstated);
|
|
176444
|
-
await this.persist(reinstated);
|
|
176445
|
-
this.deps.logger?.warn("An abandoned renewal leaf is in use - reinstated", {
|
|
176446
|
-
tags: { nodeId },
|
|
176447
|
-
meta: { serial: known.serial }
|
|
176448
|
-
});
|
|
176449
|
-
return true;
|
|
176450
|
-
}
|
|
176451
|
-
const record = {
|
|
176452
|
-
nodeId,
|
|
176453
|
-
serial: leaf.serial,
|
|
176454
|
-
fingerprint: leaf.fingerprint,
|
|
176455
|
-
notBefore: leaf.notBefore,
|
|
176456
|
-
notAfter: leaf.notAfter,
|
|
176457
|
-
issuedAt: this.now(),
|
|
176458
|
-
issuedVia: "observed",
|
|
176459
|
-
revokedAt: null,
|
|
176460
|
-
revokedReason: null
|
|
176461
|
-
};
|
|
176462
|
-
await this.insert(record);
|
|
176463
|
-
this.deps.logger?.info("Mesh certificate observed on a live connection and recorded", {
|
|
176464
|
-
tags: { nodeId },
|
|
176465
|
-
meta: {
|
|
176466
|
-
serial: leaf.serial,
|
|
176467
|
-
fingerprint: leaf.fingerprint
|
|
176468
|
-
}
|
|
176469
|
-
});
|
|
176470
|
-
return true;
|
|
176471
|
-
}
|
|
176472
|
-
list(nodeId) {
|
|
176473
|
-
return [...this.rows.values()].filter((r) => nodeId === void 0 || r.nodeId === nodeId).toSorted((a, b) => b.issuedAt - a.issuedAt);
|
|
176474
|
-
}
|
|
176475
|
-
/** The newest non-revoked leaf of a node, or `undefined`. */
|
|
176476
|
-
currentFor(nodeId) {
|
|
176477
|
-
return this.list(nodeId).find((r) => r.revokedAt === null);
|
|
176478
|
-
}
|
|
176479
|
-
/** Every non-revoked leaf of a node (a renewal in flight has two). */
|
|
176480
|
-
liveFor(nodeId) {
|
|
176481
|
-
return this.list(nodeId).filter((r) => r.revokedAt === null);
|
|
176482
|
-
}
|
|
176483
|
-
/** Stamp a leaf revoked (and mirror it into `crl`). `false` when unknown or already revoked. */
|
|
176484
|
-
async revoke(fingerprint, reason, crl) {
|
|
176485
|
-
const record = this.rows.get(fingerprint);
|
|
176486
|
-
if (record === void 0 || record.revokedAt !== null) return false;
|
|
176487
|
-
const revoked = {
|
|
176488
|
-
...record,
|
|
176489
|
-
revokedAt: this.now(),
|
|
176490
|
-
revokedReason: reason
|
|
176491
|
-
};
|
|
176492
|
-
this.rows.set(fingerprint, revoked);
|
|
176493
|
-
crl?.revoke(record.serial);
|
|
176494
|
-
await this.persist(revoked);
|
|
176495
|
-
this.deps.logger?.warn("Mesh certificate revoked", {
|
|
176496
|
-
tags: { nodeId: record.nodeId },
|
|
176497
|
-
meta: {
|
|
176498
|
-
serial: record.serial,
|
|
176499
|
-
reason
|
|
176500
|
-
}
|
|
176501
|
-
});
|
|
176502
|
-
return true;
|
|
176503
|
-
}
|
|
176504
|
-
/**
|
|
176505
|
-
* Operator revocation of a whole node: EVERY leaf of the node that is not already on the
|
|
176506
|
-
* CRL goes on it - the current one, an observed one, a renewal one, and a leaf that was set
|
|
176507
|
-
* aside (`renewal-abandoned`: a copy of it may sit on a stolen box, and it must not stay
|
|
176508
|
-
* valid just because the hub once set it aside). Returns the serials put on the CRL.
|
|
176509
|
-
* A leaf revoked this way is never reinstated by `recordObserved`.
|
|
176510
|
-
*/
|
|
176511
|
-
async revokeAllForNode(nodeId, reason, crl, keepFingerprint) {
|
|
176512
|
-
const serials = [];
|
|
176513
|
-
for (const record of this.list(nodeId)) {
|
|
176514
|
-
if (keepFingerprint !== void 0 && record.fingerprint === keepFingerprint) continue;
|
|
176515
|
-
if (record.revokedAt !== null && record.revokedReason !== "renewal-abandoned") continue;
|
|
176516
|
-
const revoked = {
|
|
176517
|
-
...record,
|
|
176518
|
-
revokedAt: record.revokedAt ?? this.now(),
|
|
176519
|
-
revokedReason: reason
|
|
176520
|
-
};
|
|
176521
|
-
this.rows.set(record.fingerprint, revoked);
|
|
176522
|
-
crl.revoke(record.serial);
|
|
176523
|
-
await this.persist(revoked);
|
|
176524
|
-
serials.push(record.serial);
|
|
176525
|
-
}
|
|
176526
|
-
if (serials.length > 0) this.deps.logger?.warn("Every mesh certificate of the node revoked", {
|
|
176527
|
-
tags: { nodeId },
|
|
176528
|
-
meta: {
|
|
176529
|
-
serials,
|
|
176530
|
-
reason
|
|
176531
|
-
}
|
|
176532
|
-
});
|
|
176533
|
-
return serials;
|
|
176534
|
-
}
|
|
176535
|
-
/**
|
|
176536
|
-
* At boot: a node with TWO live leaves had a renewal in flight when the hub stopped. The
|
|
176537
|
-
* newer (renewal) one is set aside - it is not the node's current leaf until the node is
|
|
176538
|
-
* seen presenting it, which reinstates it. It is NOT put on the CRL.
|
|
176539
|
-
*/
|
|
176540
|
-
async settleInterruptedRenewals() {
|
|
176541
|
-
let settled = 0;
|
|
176542
|
-
const byNode = /* @__PURE__ */ new Map();
|
|
176543
|
-
for (const record of this.rows.values()) {
|
|
176544
|
-
if (record.revokedAt !== null) continue;
|
|
176545
|
-
byNode.set(record.nodeId, [...byNode.get(record.nodeId) ?? [], record]);
|
|
176546
|
-
}
|
|
176547
|
-
for (const records of byNode.values()) {
|
|
176548
|
-
if (records.length < 2) continue;
|
|
176549
|
-
for (const record of records) if (record.issuedVia === "renewal" && await this.abandon(record.fingerprint)) settled += 1;
|
|
176550
|
-
}
|
|
176551
|
-
return settled;
|
|
176552
|
-
}
|
|
176553
|
-
/** Set a never-completed renewal leaf aside (not current, NOT on the CRL). */
|
|
176554
|
-
/** Fingerprints of renewal leaves whose handover is running right now (this process only). */
|
|
176555
|
-
renewalsInFlight = /* @__PURE__ */ new Set();
|
|
176556
|
-
/**
|
|
176557
|
-
* A renewal's leaf is "in flight" from signing until the handover ends. While it is, a node seen
|
|
176558
|
-
* presenting its OLD leaf is simply not swapped yet: the new leaf is not set aside (that would
|
|
176559
|
-
* flap set-aside / reinstate on the node's first connection with it).
|
|
176560
|
-
*/
|
|
176561
|
-
beginRenewal(fingerprint) {
|
|
176562
|
-
this.renewalsInFlight.add(fingerprint);
|
|
176563
|
-
}
|
|
176564
|
-
endRenewal(fingerprint) {
|
|
176565
|
-
this.renewalsInFlight.delete(fingerprint);
|
|
176566
|
-
}
|
|
176567
|
-
async abandonRenewalsNewerThan(presented) {
|
|
176568
|
-
let changed = false;
|
|
176569
|
-
for (const record of this.liveFor(presented.nodeId)) {
|
|
176570
|
-
if (record.fingerprint === presented.fingerprint) continue;
|
|
176571
|
-
if (record.issuedVia !== "renewal" || record.issuedAt <= presented.issuedAt) continue;
|
|
176572
|
-
if (this.renewalsInFlight.has(record.fingerprint)) continue;
|
|
176573
|
-
if (await this.abandon(record.fingerprint)) changed = true;
|
|
176574
|
-
}
|
|
176575
|
-
return changed;
|
|
176576
|
-
}
|
|
176577
|
-
async abandon(fingerprint) {
|
|
176578
|
-
const record = this.rows.get(fingerprint);
|
|
176579
|
-
if (record === void 0 || record.revokedAt !== null) return false;
|
|
176580
|
-
const abandoned = {
|
|
176581
|
-
...record,
|
|
176582
|
-
revokedAt: this.now(),
|
|
176583
|
-
revokedReason: RENEWAL_ABANDONED
|
|
176584
|
-
};
|
|
176585
|
-
this.rows.set(fingerprint, abandoned);
|
|
176586
|
-
await this.persist(abandoned);
|
|
176587
|
-
this.deps.logger?.warn("Renewal leaf set aside (not current, not on the CRL)", {
|
|
176588
|
-
tags: { nodeId: record.nodeId },
|
|
176589
|
-
meta: { serial: record.serial }
|
|
176590
|
-
});
|
|
176591
|
-
return true;
|
|
176592
|
-
}
|
|
176593
|
-
/** Replay every persisted revocation into `crl` (hub boot). Set-aside leaves are not revocations. */
|
|
176594
|
-
restoreCrl(crl) {
|
|
176595
|
-
let restored = 0;
|
|
176596
|
-
for (const record of this.rows.values()) {
|
|
176597
|
-
if (record.revokedAt === null || record.revokedReason === "renewal-abandoned") continue;
|
|
176598
|
-
crl.revoke(record.serial);
|
|
176599
|
-
restored += 1;
|
|
176600
|
-
}
|
|
176601
|
-
return restored;
|
|
176602
|
-
}
|
|
176603
|
-
/** Is `serial` listed as revoked here? */
|
|
176604
|
-
isRevoked(serial) {
|
|
176605
|
-
const wanted = normalizeSerial(serial);
|
|
176606
|
-
for (const record of this.rows.values()) if (record.revokedAt !== null && record.revokedReason !== "renewal-abandoned" && normalizeSerial(record.serial) === wanted) return true;
|
|
176607
|
-
return false;
|
|
176608
|
-
}
|
|
176609
|
-
async reap() {
|
|
176610
|
-
const cutoff = this.now() - RETENTION_MS;
|
|
176611
|
-
const dead = [...this.rows.values()].filter((r) => (r.revokedAt ?? r.notAfter) < cutoff);
|
|
176612
|
-
for (const r of dead) {
|
|
176613
|
-
this.rows.delete(r.fingerprint);
|
|
176614
|
-
await this.deleteRow(r.fingerprint);
|
|
176615
|
-
}
|
|
176616
|
-
return dead.length;
|
|
176617
|
-
}
|
|
176618
|
-
async insert(record) {
|
|
176619
|
-
this.rows.set(record.fingerprint, record);
|
|
176620
|
-
const kind = this.deps.meshKind ?? null;
|
|
176621
|
-
if (kind !== null) {
|
|
176622
|
-
const parsed = systemConfigRecordKinds["mesh-node-certificates"].schema.safeParse(this.recordToBody(record));
|
|
176623
|
-
if (!parsed.success) throw new Error(parsed.error.message);
|
|
176624
|
-
await kind.put({
|
|
176625
|
-
id: record.fingerprint,
|
|
176626
|
-
data: parsed.data
|
|
176627
|
-
});
|
|
176628
|
-
return;
|
|
176629
|
-
}
|
|
176630
|
-
await this.store.insert.mutate({
|
|
176631
|
-
collection: MESH_NODE_CERTIFICATES_COLLECTION,
|
|
176632
|
-
record: {
|
|
176633
|
-
id: record.fingerprint,
|
|
176634
|
-
data: { ...record }
|
|
176635
|
-
}
|
|
176636
|
-
});
|
|
176637
|
-
}
|
|
176638
|
-
async deleteRow(fingerprint) {
|
|
176639
|
-
const kind = this.deps.meshKind ?? null;
|
|
176640
|
-
if (kind !== null) {
|
|
176641
|
-
await kind.delete(fingerprint);
|
|
176642
|
-
return;
|
|
176643
|
-
}
|
|
176644
|
-
await this.store.delete.mutate({
|
|
176645
|
-
collection: MESH_NODE_CERTIFICATES_COLLECTION,
|
|
176646
|
-
key: fingerprint
|
|
176647
|
-
});
|
|
176648
|
-
}
|
|
176649
|
-
async persist(record) {
|
|
176650
|
-
try {
|
|
176651
|
-
const kind = this.deps.meshKind ?? null;
|
|
176652
|
-
if (kind !== null) {
|
|
176653
|
-
const parsed = systemConfigRecordKinds["mesh-node-certificates"].schema.safeParse(this.recordToBody(record));
|
|
176654
|
-
if (!parsed.success) throw new Error(parsed.error.message);
|
|
176655
|
-
await kind.put({
|
|
176656
|
-
id: record.fingerprint,
|
|
176657
|
-
data: parsed.data
|
|
176658
|
-
});
|
|
176659
|
-
return;
|
|
176660
|
-
}
|
|
176661
|
-
await this.store.update.mutate({
|
|
176662
|
-
collection: MESH_NODE_CERTIFICATES_COLLECTION,
|
|
176663
|
-
id: record.fingerprint,
|
|
176664
|
-
data: { ...record }
|
|
176665
|
-
});
|
|
176666
|
-
} catch (error) {
|
|
176667
|
-
this.deps.logger?.error("Mesh certificate write failed - the change holds until restart", {
|
|
176668
|
-
tags: { nodeId: record.nodeId },
|
|
176669
|
-
meta: { error: error instanceof Error ? error.message : String(error) }
|
|
176670
|
-
});
|
|
176671
|
-
}
|
|
176672
|
-
}
|
|
176673
|
-
};
|
|
176674
|
-
var SLOT$1 = /* @__PURE__ */ Symbol.for("camstack.mesh.certificate-registry");
|
|
176675
|
-
function setProcessMeshCertificateRegistry(registry) {
|
|
176676
|
-
if (registry === null) Reflect.deleteProperty(globalThis, SLOT$1);
|
|
176677
|
-
else Reflect.set(globalThis, SLOT$1, registry);
|
|
176678
|
-
}
|
|
176679
|
-
function getProcessMeshCertificateRegistry() {
|
|
176680
|
-
const value = Reflect.get(globalThis, SLOT$1);
|
|
176681
|
-
return value !== null && typeof value === "object" && typeof Reflect.get(value, "recordIssued") === "function" ? value : null;
|
|
176682
|
-
}
|
|
176683
175508
|
var MeshNodeCertificateBodySchema = zod.z.object({
|
|
176684
175509
|
nodeId: zod.z.string(),
|
|
176685
175510
|
serial: zod.z.string(),
|
|
@@ -176712,8 +175537,7 @@ var require_agent_https_DOELEug8 = __commonJS({
|
|
|
176712
175537
|
retention: {
|
|
176713
175538
|
owner: "system-config",
|
|
176714
175539
|
reason: "daily reap removes revoked/expired rows older than 90 days"
|
|
176715
|
-
}
|
|
176716
|
-
adoptsFrom: MESH_NODE_CERTIFICATES_COLLECTION
|
|
175540
|
+
}
|
|
176717
175541
|
},
|
|
176718
175542
|
"agent-https-names": {
|
|
176719
175543
|
schema: AgentHttpsNameBodySchema,
|
|
@@ -176721,8 +175545,7 @@ var require_agent_https_DOELEug8 = __commonJS({
|
|
|
176721
175545
|
writeTrigger: "agent HTTPS certificate issuance records the CN/SAN set",
|
|
176722
175546
|
device: "none",
|
|
176723
175547
|
at: "none",
|
|
176724
|
-
retention: { none: "one row per node id" }
|
|
176725
|
-
adoptsFrom: AGENT_HTTPS_NAMES_COLLECTION
|
|
175548
|
+
retention: { none: "one row per node id" }
|
|
176726
175549
|
}
|
|
176727
175550
|
});
|
|
176728
175551
|
var systemConfigRecordKinds = _systemConfigRecordKinds;
|
|
@@ -177529,24 +176352,6 @@ var require_agent_https_DOELEug8 = __commonJS({
|
|
|
177529
176352
|
return MAX_LEAF_VALIDITY_DAYS;
|
|
177530
176353
|
}
|
|
177531
176354
|
});
|
|
177532
|
-
Object.defineProperty(exports, "MESH_NODE_CERTIFICATES_COLLECTION", {
|
|
177533
|
-
enumerable: true,
|
|
177534
|
-
get: function() {
|
|
177535
|
-
return MESH_NODE_CERTIFICATES_COLLECTION;
|
|
177536
|
-
}
|
|
177537
|
-
});
|
|
177538
|
-
Object.defineProperty(exports, "MESH_NODE_CERTIFICATES_COLUMNS", {
|
|
177539
|
-
enumerable: true,
|
|
177540
|
-
get: function() {
|
|
177541
|
-
return MESH_NODE_CERTIFICATES_COLUMNS;
|
|
177542
|
-
}
|
|
177543
|
-
});
|
|
177544
|
-
Object.defineProperty(exports, "MeshCertificateRegistry", {
|
|
177545
|
-
enumerable: true,
|
|
177546
|
-
get: function() {
|
|
177547
|
-
return MeshCertificateRegistry;
|
|
177548
|
-
}
|
|
177549
|
-
});
|
|
177550
176355
|
Object.defineProperty(exports, "PERMITTED_DNS_SUFFIXES", {
|
|
177551
176356
|
enumerable: true,
|
|
177552
176357
|
get: function() {
|
|
@@ -177559,12 +176364,6 @@ var require_agent_https_DOELEug8 = __commonJS({
|
|
|
177559
176364
|
return PERMITTED_IP_RANGES;
|
|
177560
176365
|
}
|
|
177561
176366
|
});
|
|
177562
|
-
Object.defineProperty(exports, "RENEWAL_ABANDONED", {
|
|
177563
|
-
enumerable: true,
|
|
177564
|
-
get: function() {
|
|
177565
|
-
return RENEWAL_ABANDONED;
|
|
177566
|
-
}
|
|
177567
|
-
});
|
|
177568
176367
|
Object.defineProperty(exports, "SERVER_AUTH_OID", {
|
|
177569
176368
|
enumerable: true,
|
|
177570
176369
|
get: function() {
|
|
@@ -177589,18 +176388,6 @@ var require_agent_https_DOELEug8 = __commonJS({
|
|
|
177589
176388
|
return buildNameConstraintSet;
|
|
177590
176389
|
}
|
|
177591
176390
|
});
|
|
177592
|
-
Object.defineProperty(exports, "caFingerprint", {
|
|
177593
|
-
enumerable: true,
|
|
177594
|
-
get: function() {
|
|
177595
|
-
return caFingerprint;
|
|
177596
|
-
}
|
|
177597
|
-
});
|
|
177598
|
-
Object.defineProperty(exports, "caFingerprintCompact", {
|
|
177599
|
-
enumerable: true,
|
|
177600
|
-
get: function() {
|
|
177601
|
-
return caFingerprintCompact;
|
|
177602
|
-
}
|
|
177603
|
-
});
|
|
177604
176391
|
Object.defineProperty(exports, "certificateNames", {
|
|
177605
176392
|
enumerable: true,
|
|
177606
176393
|
get: function() {
|
|
@@ -177625,66 +176412,30 @@ var require_agent_https_DOELEug8 = __commonJS({
|
|
|
177625
176412
|
return createAgentHttpsRequest;
|
|
177626
176413
|
}
|
|
177627
176414
|
});
|
|
177628
|
-
Object.defineProperty(exports, "createMeshCsrPem", {
|
|
177629
|
-
enumerable: true,
|
|
177630
|
-
get: function() {
|
|
177631
|
-
return createMeshCsrPem;
|
|
177632
|
-
}
|
|
177633
|
-
});
|
|
177634
176415
|
Object.defineProperty(exports, "describeHttpsLeaf", {
|
|
177635
176416
|
enumerable: true,
|
|
177636
176417
|
get: function() {
|
|
177637
176418
|
return describeHttpsLeaf;
|
|
177638
176419
|
}
|
|
177639
176420
|
});
|
|
177640
|
-
Object.defineProperty(exports, "describeMeshLeaf", {
|
|
177641
|
-
enumerable: true,
|
|
177642
|
-
get: function() {
|
|
177643
|
-
return describeMeshLeaf;
|
|
177644
|
-
}
|
|
177645
|
-
});
|
|
177646
176421
|
Object.defineProperty(exports, "evaluateExistingCert", {
|
|
177647
176422
|
enumerable: true,
|
|
177648
176423
|
get: function() {
|
|
177649
176424
|
return evaluateExistingCert;
|
|
177650
176425
|
}
|
|
177651
176426
|
});
|
|
177652
|
-
Object.defineProperty(exports, "exportMeshPrivateKeyPem", {
|
|
177653
|
-
enumerable: true,
|
|
177654
|
-
get: function() {
|
|
177655
|
-
return exportMeshPrivateKeyPem;
|
|
177656
|
-
}
|
|
177657
|
-
});
|
|
177658
176427
|
Object.defineProperty(exports, "generateCa", {
|
|
177659
176428
|
enumerable: true,
|
|
177660
176429
|
get: function() {
|
|
177661
176430
|
return generateCa;
|
|
177662
176431
|
}
|
|
177663
176432
|
});
|
|
177664
|
-
Object.defineProperty(exports, "generateMeshCa", {
|
|
177665
|
-
enumerable: true,
|
|
177666
|
-
get: function() {
|
|
177667
|
-
return generateMeshCa;
|
|
177668
|
-
}
|
|
177669
|
-
});
|
|
177670
|
-
Object.defineProperty(exports, "generateMeshKeyPair", {
|
|
177671
|
-
enumerable: true,
|
|
177672
|
-
get: function() {
|
|
177673
|
-
return generateMeshKeyPair;
|
|
177674
|
-
}
|
|
177675
|
-
});
|
|
177676
176433
|
Object.defineProperty(exports, "getProcessAgentHttpsNames", {
|
|
177677
176434
|
enumerable: true,
|
|
177678
176435
|
get: function() {
|
|
177679
176436
|
return getProcessAgentHttpsNames;
|
|
177680
176437
|
}
|
|
177681
176438
|
});
|
|
177682
|
-
Object.defineProperty(exports, "getProcessMeshCertificateRegistry", {
|
|
177683
|
-
enumerable: true,
|
|
177684
|
-
get: function() {
|
|
177685
|
-
return getProcessMeshCertificateRegistry;
|
|
177686
|
-
}
|
|
177687
|
-
});
|
|
177688
176439
|
Object.defineProperty(exports, "installAgentHttps", {
|
|
177689
176440
|
enumerable: true,
|
|
177690
176441
|
get: function() {
|
|
@@ -177715,12 +176466,6 @@ var require_agent_https_DOELEug8 = __commonJS({
|
|
|
177715
176466
|
return isPrivateAddress;
|
|
177716
176467
|
}
|
|
177717
176468
|
});
|
|
177718
|
-
Object.defineProperty(exports, "isValidAgentNodeId", {
|
|
177719
|
-
enumerable: true,
|
|
177720
|
-
get: function() {
|
|
177721
|
-
return isValidAgentNodeId;
|
|
177722
|
-
}
|
|
177723
|
-
});
|
|
177724
176469
|
Object.defineProperty(exports, "issueAgentHttpsLeaf", {
|
|
177725
176470
|
enumerable: true,
|
|
177726
176471
|
get: function() {
|
|
@@ -177733,18 +176478,6 @@ var require_agent_https_DOELEug8 = __commonJS({
|
|
|
177733
176478
|
return issueLeaf;
|
|
177734
176479
|
}
|
|
177735
176480
|
});
|
|
177736
|
-
Object.defineProperty(exports, "issueMeshLeafForNode", {
|
|
177737
|
-
enumerable: true,
|
|
177738
|
-
get: function() {
|
|
177739
|
-
return issueMeshLeafForNode;
|
|
177740
|
-
}
|
|
177741
|
-
});
|
|
177742
|
-
Object.defineProperty(exports, "issueMeshLeafFromCsr", {
|
|
177743
|
-
enumerable: true,
|
|
177744
|
-
get: function() {
|
|
177745
|
-
return issueMeshLeafFromCsr;
|
|
177746
|
-
}
|
|
177747
|
-
});
|
|
177748
176481
|
Object.defineProperty(exports, "loadAgentHttps", {
|
|
177749
176482
|
enumerable: true,
|
|
177750
176483
|
get: function() {
|
|
@@ -177757,12 +176490,6 @@ var require_agent_https_DOELEug8 = __commonJS({
|
|
|
177757
176490
|
return loadCa;
|
|
177758
176491
|
}
|
|
177759
176492
|
});
|
|
177760
|
-
Object.defineProperty(exports, "loadMeshCa", {
|
|
177761
|
-
enumerable: true,
|
|
177762
|
-
get: function() {
|
|
177763
|
-
return loadMeshCa;
|
|
177764
|
-
}
|
|
177765
|
-
});
|
|
177766
176493
|
Object.defineProperty(exports, "localCaCommonName", {
|
|
177767
176494
|
enumerable: true,
|
|
177768
176495
|
get: function() {
|
|
@@ -177811,28 +176538,83 @@ var require_agent_https_DOELEug8 = __commonJS({
|
|
|
177811
176538
|
return setProcessAgentHttpsNames;
|
|
177812
176539
|
}
|
|
177813
176540
|
});
|
|
177814
|
-
Object.defineProperty(exports, "
|
|
176541
|
+
Object.defineProperty(exports, "systemConfigRecordKinds", {
|
|
177815
176542
|
enumerable: true,
|
|
177816
176543
|
get: function() {
|
|
177817
|
-
return
|
|
176544
|
+
return systemConfigRecordKinds;
|
|
177818
176545
|
}
|
|
177819
176546
|
});
|
|
177820
|
-
Object.defineProperty(exports, "
|
|
176547
|
+
Object.defineProperty(exports, "systemHostFacts", {
|
|
177821
176548
|
enumerable: true,
|
|
177822
176549
|
get: function() {
|
|
177823
|
-
return
|
|
176550
|
+
return systemHostFacts;
|
|
177824
176551
|
}
|
|
177825
176552
|
});
|
|
177826
|
-
|
|
176553
|
+
}
|
|
176554
|
+
});
|
|
176555
|
+
|
|
176556
|
+
// ../system/dist/constants-6OeJiZgi.js
|
|
176557
|
+
var require_constants_6OeJiZgi = __commonJS({
|
|
176558
|
+
"../system/dist/constants-6OeJiZgi.js"(exports) {
|
|
176559
|
+
"use strict";
|
|
176560
|
+
var MESH_CA_KEY_REF = require_dist_Bn_RNanh().buildSecretRef({
|
|
176561
|
+
owner: "system",
|
|
176562
|
+
scope: { kind: "global" },
|
|
176563
|
+
fieldPath: "meshCaKey"
|
|
176564
|
+
});
|
|
176565
|
+
var MESH_CA_SETTINGS_KEY = "cluster.meshCa";
|
|
176566
|
+
var MESH_CA_FIELD = "meshCa";
|
|
176567
|
+
var MESH_CA_VALIDITY_DAYS = 3650;
|
|
176568
|
+
var DEFAULT_HUB_TLS_TCP_PORT = 6443;
|
|
176569
|
+
var MESH_CA_COMMON_NAME = "CamStack Mesh CA";
|
|
176570
|
+
var SERVER_AUTH_OID = "1.3.6.1.5.5.7.3.1";
|
|
176571
|
+
var CLIENT_AUTH_OID = "1.3.6.1.5.5.7.3.2";
|
|
176572
|
+
Object.defineProperty(exports, "CLIENT_AUTH_OID", {
|
|
177827
176573
|
enumerable: true,
|
|
177828
176574
|
get: function() {
|
|
177829
|
-
return
|
|
176575
|
+
return CLIENT_AUTH_OID;
|
|
177830
176576
|
}
|
|
177831
176577
|
});
|
|
177832
|
-
Object.defineProperty(exports, "
|
|
176578
|
+
Object.defineProperty(exports, "DEFAULT_HUB_TLS_TCP_PORT", {
|
|
177833
176579
|
enumerable: true,
|
|
177834
176580
|
get: function() {
|
|
177835
|
-
return
|
|
176581
|
+
return DEFAULT_HUB_TLS_TCP_PORT;
|
|
176582
|
+
}
|
|
176583
|
+
});
|
|
176584
|
+
Object.defineProperty(exports, "MESH_CA_COMMON_NAME", {
|
|
176585
|
+
enumerable: true,
|
|
176586
|
+
get: function() {
|
|
176587
|
+
return MESH_CA_COMMON_NAME;
|
|
176588
|
+
}
|
|
176589
|
+
});
|
|
176590
|
+
Object.defineProperty(exports, "MESH_CA_FIELD", {
|
|
176591
|
+
enumerable: true,
|
|
176592
|
+
get: function() {
|
|
176593
|
+
return MESH_CA_FIELD;
|
|
176594
|
+
}
|
|
176595
|
+
});
|
|
176596
|
+
Object.defineProperty(exports, "MESH_CA_KEY_REF", {
|
|
176597
|
+
enumerable: true,
|
|
176598
|
+
get: function() {
|
|
176599
|
+
return MESH_CA_KEY_REF;
|
|
176600
|
+
}
|
|
176601
|
+
});
|
|
176602
|
+
Object.defineProperty(exports, "MESH_CA_SETTINGS_KEY", {
|
|
176603
|
+
enumerable: true,
|
|
176604
|
+
get: function() {
|
|
176605
|
+
return MESH_CA_SETTINGS_KEY;
|
|
176606
|
+
}
|
|
176607
|
+
});
|
|
176608
|
+
Object.defineProperty(exports, "MESH_CA_VALIDITY_DAYS", {
|
|
176609
|
+
enumerable: true,
|
|
176610
|
+
get: function() {
|
|
176611
|
+
return MESH_CA_VALIDITY_DAYS;
|
|
176612
|
+
}
|
|
176613
|
+
});
|
|
176614
|
+
Object.defineProperty(exports, "SERVER_AUTH_OID", {
|
|
176615
|
+
enumerable: true,
|
|
176616
|
+
get: function() {
|
|
176617
|
+
return SERVER_AUTH_OID;
|
|
177836
176618
|
}
|
|
177837
176619
|
});
|
|
177838
176620
|
}
|
|
@@ -194872,11 +193654,11 @@ var require_system_config_addon = __commonJS({
|
|
|
194872
193654
|
[Symbol.toStringTag]: { value: "Module" }
|
|
194873
193655
|
});
|
|
194874
193656
|
var require_chunk = require_chunk_Cek0wNdY();
|
|
194875
|
-
var require_dist10 =
|
|
193657
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
194876
193658
|
var require_safe_buffer$1 = require_safe_buffer_D3aoa_7X();
|
|
194877
193659
|
var require_x509_es = require_x509_es_C4cOo48M();
|
|
194878
|
-
var
|
|
194879
|
-
var
|
|
193660
|
+
var require_agent_https = require_agent_https_Dnr_nIVx();
|
|
193661
|
+
var require_constants$8 = require_constants_6OeJiZgi();
|
|
194880
193662
|
var require_src$1 = require_src_CnAqG6EF();
|
|
194881
193663
|
var zod = require_zod();
|
|
194882
193664
|
var node_crypto = __require("crypto");
|
|
@@ -195109,7 +193891,140 @@ var require_system_config_addon = __commonJS({
|
|
|
195109
193891
|
jti
|
|
195110
193892
|
};
|
|
195111
193893
|
}
|
|
195112
|
-
|
|
193894
|
+
require_x509_es.cryptoProvider.set(node_crypto.webcrypto);
|
|
193895
|
+
var MS_PER_DAY = 864e5;
|
|
193896
|
+
var MESH_KEY_ALGORITHM = {
|
|
193897
|
+
name: "ECDSA",
|
|
193898
|
+
namedCurve: "P-256"
|
|
193899
|
+
};
|
|
193900
|
+
var MESH_SIGNING_ALGORITHM = {
|
|
193901
|
+
name: "ECDSA",
|
|
193902
|
+
hash: "SHA-256"
|
|
193903
|
+
};
|
|
193904
|
+
var NODE_ID_PATTERN = /^[a-z0-9][a-z0-9._-]{0,62}$/i;
|
|
193905
|
+
var RESERVED_NODE_IDS = /* @__PURE__ */ new Set(["hub"]);
|
|
193906
|
+
function isValidAgentNodeId(nodeId) {
|
|
193907
|
+
return NODE_ID_PATTERN.test(nodeId) && !RESERVED_NODE_IDS.has(nodeId.toLowerCase());
|
|
193908
|
+
}
|
|
193909
|
+
function freshSerial() {
|
|
193910
|
+
return `00${(0, node_crypto.randomBytes)(16).toString("hex")}`;
|
|
193911
|
+
}
|
|
193912
|
+
function toPkcs8Pem(pkcs8) {
|
|
193913
|
+
return `${require_x509_es.PemConverter.encode(pkcs8, "PRIVATE KEY")}
|
|
193914
|
+
`;
|
|
193915
|
+
}
|
|
193916
|
+
function toCertPem(cert) {
|
|
193917
|
+
return `${cert.toString("pem")}
|
|
193918
|
+
`;
|
|
193919
|
+
}
|
|
193920
|
+
async function exportKeyPem(key) {
|
|
193921
|
+
return toPkcs8Pem(await node_crypto.webcrypto.subtle.exportKey("pkcs8", key));
|
|
193922
|
+
}
|
|
193923
|
+
function caFingerprint(certPem) {
|
|
193924
|
+
return new node_crypto.X509Certificate(certPem).fingerprint256;
|
|
193925
|
+
}
|
|
193926
|
+
function caFingerprintCompact(certPem) {
|
|
193927
|
+
return (0, node_crypto.createHash)("sha256").update(new node_crypto.X509Certificate(certPem).raw).digest("hex");
|
|
193928
|
+
}
|
|
193929
|
+
async function generateMeshCa(now = /* @__PURE__ */ new Date()) {
|
|
193930
|
+
const keys = await node_crypto.webcrypto.subtle.generateKey(MESH_KEY_ALGORITHM, true, ["sign", "verify"]);
|
|
193931
|
+
const extensions = [
|
|
193932
|
+
new require_x509_es.BasicConstraintsExtension(true, 0, true),
|
|
193933
|
+
new require_x509_es.KeyUsagesExtension(require_x509_es.KeyUsageFlags.keyCertSign | require_x509_es.KeyUsageFlags.cRLSign, true),
|
|
193934
|
+
await require_x509_es.SubjectKeyIdentifierExtension.create(keys.publicKey)
|
|
193935
|
+
];
|
|
193936
|
+
const cert = await require_x509_es.X509CertificateGenerator.createSelfSigned({
|
|
193937
|
+
serialNumber: freshSerial(),
|
|
193938
|
+
name: `CN=${require_constants$8.MESH_CA_COMMON_NAME}`,
|
|
193939
|
+
notBefore: require_x509_es.backdatedNotBefore(now),
|
|
193940
|
+
notAfter: new Date(now.getTime() + require_constants$8.MESH_CA_VALIDITY_DAYS * MS_PER_DAY),
|
|
193941
|
+
keys,
|
|
193942
|
+
signingAlgorithm: MESH_SIGNING_ALGORITHM,
|
|
193943
|
+
extensions
|
|
193944
|
+
});
|
|
193945
|
+
return {
|
|
193946
|
+
certPem: toCertPem(cert),
|
|
193947
|
+
keyPem: await exportKeyPem(keys.privateKey),
|
|
193948
|
+
cert,
|
|
193949
|
+
privateKey: keys.privateKey,
|
|
193950
|
+
publicKey: keys.publicKey
|
|
193951
|
+
};
|
|
193952
|
+
}
|
|
193953
|
+
async function loadMeshCa(certPem, keyPem) {
|
|
193954
|
+
const cert = new require_x509_es.X509Certificate(certPem);
|
|
193955
|
+
return {
|
|
193956
|
+
certPem,
|
|
193957
|
+
keyPem,
|
|
193958
|
+
cert,
|
|
193959
|
+
privateKey: await node_crypto.webcrypto.subtle.importKey("pkcs8", require_x509_es.PemConverter.decodeFirst(keyPem), MESH_KEY_ALGORITHM, true, ["sign"]),
|
|
193960
|
+
publicKey: await cert.publicKey.export(node_crypto.webcrypto)
|
|
193961
|
+
};
|
|
193962
|
+
}
|
|
193963
|
+
async function issueMeshLeafFromCsr(ca, csrPem, opts = {}) {
|
|
193964
|
+
const csr = new require_x509_es.Pkcs10CertificateRequest(csrPem);
|
|
193965
|
+
if (!await csr.verify(node_crypto.webcrypto)) throw new Error("CSR signature is invalid");
|
|
193966
|
+
const cn = subjectCn(csr.subject);
|
|
193967
|
+
if (cn === null || cn.length === 0) throw new Error("CSR subject has no CN");
|
|
193968
|
+
if (opts.allowReserved !== true && !isValidAgentNodeId(cn)) throw new Error(`CSR CN '${cn}' is not an id an agent may carry`);
|
|
193969
|
+
if (opts.expectedNodeId !== void 0 && opts.expectedNodeId !== cn) throw new Error(`CSR CN '${cn}' does not match the token nodeId '${opts.expectedNodeId}'`);
|
|
193970
|
+
const now = opts.now ?? /* @__PURE__ */ new Date();
|
|
193971
|
+
const validDays = opts.validDays ?? 30;
|
|
193972
|
+
const serialNumber = freshSerial();
|
|
193973
|
+
const notAfter = new Date(now.getTime() + validDays * MS_PER_DAY);
|
|
193974
|
+
const extensions = [
|
|
193975
|
+
new require_x509_es.BasicConstraintsExtension(false, void 0, true),
|
|
193976
|
+
new require_x509_es.KeyUsagesExtension(require_x509_es.KeyUsageFlags.digitalSignature, true),
|
|
193977
|
+
new require_x509_es.ExtendedKeyUsageExtension([require_constants$8.SERVER_AUTH_OID, require_constants$8.CLIENT_AUTH_OID]),
|
|
193978
|
+
await require_x509_es.SubjectKeyIdentifierExtension.create(csr.publicKey),
|
|
193979
|
+
await require_x509_es.AuthorityKeyIdentifierExtension.create(ca.cert)
|
|
193980
|
+
];
|
|
193981
|
+
return {
|
|
193982
|
+
certPem: toCertPem(await require_x509_es.X509CertificateGenerator.create({
|
|
193983
|
+
serialNumber,
|
|
193984
|
+
subject: `CN=${cn}`,
|
|
193985
|
+
issuer: ca.cert.subject,
|
|
193986
|
+
notBefore: require_x509_es.backdatedNotBefore(now),
|
|
193987
|
+
notAfter,
|
|
193988
|
+
publicKey: csr.publicKey,
|
|
193989
|
+
signingKey: ca.privateKey,
|
|
193990
|
+
signingAlgorithm: MESH_SIGNING_ALGORITHM,
|
|
193991
|
+
extensions
|
|
193992
|
+
})),
|
|
193993
|
+
serialNumber,
|
|
193994
|
+
notAfter,
|
|
193995
|
+
commonName: cn
|
|
193996
|
+
};
|
|
193997
|
+
}
|
|
193998
|
+
async function issueMeshLeafForNode(ca, nodeId, opts = {}) {
|
|
193999
|
+
const keys = await node_crypto.webcrypto.subtle.generateKey(MESH_KEY_ALGORITHM, true, ["sign", "verify"]);
|
|
194000
|
+
return {
|
|
194001
|
+
...await issueMeshLeafFromCsr(ca, await createMeshCsrPem(keys, nodeId), {
|
|
194002
|
+
expectedNodeId: nodeId,
|
|
194003
|
+
now: opts.now,
|
|
194004
|
+
validDays: opts.validDays,
|
|
194005
|
+
allowReserved: true
|
|
194006
|
+
}),
|
|
194007
|
+
keyPem: await exportKeyPem(keys.privateKey)
|
|
194008
|
+
};
|
|
194009
|
+
}
|
|
194010
|
+
function subjectCn(subject) {
|
|
194011
|
+
return /(?:^|,)\s*CN\s*=\s*([^,]+)/i.exec(subject)?.[1]?.trim() ?? null;
|
|
194012
|
+
}
|
|
194013
|
+
async function createMeshCsrPem(keys, commonName) {
|
|
194014
|
+
return `${(await require_x509_es.Pkcs10CertificateRequestGenerator.create({
|
|
194015
|
+
name: `CN=${commonName}`,
|
|
194016
|
+
keys,
|
|
194017
|
+
signingAlgorithm: MESH_SIGNING_ALGORITHM
|
|
194018
|
+
})).toString("pem")}
|
|
194019
|
+
`;
|
|
194020
|
+
}
|
|
194021
|
+
async function generateMeshKeyPair() {
|
|
194022
|
+
return node_crypto.webcrypto.subtle.generateKey(MESH_KEY_ALGORITHM, true, ["sign", "verify"]);
|
|
194023
|
+
}
|
|
194024
|
+
async function exportMeshPrivateKeyPem(key) {
|
|
194025
|
+
return exportKeyPem(key);
|
|
194026
|
+
}
|
|
194027
|
+
var SLOT$3 = /* @__PURE__ */ Symbol.for("camstack.mesh.ca");
|
|
195113
194028
|
var NOT_LOADED = {
|
|
195114
194029
|
state: "unavailable",
|
|
195115
194030
|
reason: "not-loaded"
|
|
@@ -195121,10 +194036,10 @@ var require_system_config_addon = __commonJS({
|
|
|
195121
194036
|
return state === "unavailable" && typeof Reflect.get(value, "reason") === "string";
|
|
195122
194037
|
}
|
|
195123
194038
|
function setProcessMeshCa(state) {
|
|
195124
|
-
Reflect.set(globalThis, SLOT$
|
|
194039
|
+
Reflect.set(globalThis, SLOT$3, state);
|
|
195125
194040
|
}
|
|
195126
194041
|
function getProcessMeshCaState() {
|
|
195127
|
-
const value = Reflect.get(globalThis, SLOT$
|
|
194042
|
+
const value = Reflect.get(globalThis, SLOT$3);
|
|
195128
194043
|
return isState(value) ? value : NOT_LOADED;
|
|
195129
194044
|
}
|
|
195130
194045
|
function requireProcessMeshCa() {
|
|
@@ -195232,7 +194147,7 @@ var require_system_config_addon = __commonJS({
|
|
|
195232
194147
|
try {
|
|
195233
194148
|
return {
|
|
195234
194149
|
state: "ready",
|
|
195235
|
-
ca: await
|
|
194150
|
+
ca: await loadMeshCa(certPem, entry.value)
|
|
195236
194151
|
};
|
|
195237
194152
|
} catch (err) {
|
|
195238
194153
|
return {
|
|
@@ -195243,12 +194158,12 @@ var require_system_config_addon = __commonJS({
|
|
|
195243
194158
|
}
|
|
195244
194159
|
case "missing":
|
|
195245
194160
|
try {
|
|
195246
|
-
const generated = await
|
|
194161
|
+
const generated = await generateMeshCa();
|
|
195247
194162
|
await deps.secrets.put(require_constants$8.MESH_CA_KEY_REF, generated.keyPem);
|
|
195248
194163
|
await deps.writeMeshCaCert(generated.certPem);
|
|
195249
194164
|
return {
|
|
195250
194165
|
state: "ready",
|
|
195251
|
-
ca: await
|
|
194166
|
+
ca: await loadMeshCa(generated.certPem, generated.keyPem)
|
|
195252
194167
|
};
|
|
195253
194168
|
} catch (err) {
|
|
195254
194169
|
return {
|
|
@@ -195261,10 +194176,10 @@ var require_system_config_addon = __commonJS({
|
|
|
195261
194176
|
var MeshCrl = class {
|
|
195262
194177
|
serials = /* @__PURE__ */ new Set();
|
|
195263
194178
|
revoke(serialNumber) {
|
|
195264
|
-
this.serials.add(normalizeSerial(serialNumber));
|
|
194179
|
+
this.serials.add(normalizeSerial$1(serialNumber));
|
|
195265
194180
|
}
|
|
195266
194181
|
isRevoked(serialNumber) {
|
|
195267
|
-
return this.serials.has(normalizeSerial(serialNumber));
|
|
194182
|
+
return this.serials.has(normalizeSerial$1(serialNumber));
|
|
195268
194183
|
}
|
|
195269
194184
|
list() {
|
|
195270
194185
|
return [...this.serials];
|
|
@@ -195272,20 +194187,447 @@ var require_system_config_addon = __commonJS({
|
|
|
195272
194187
|
/** Restore from persisted serials (system-settings). */
|
|
195273
194188
|
replaceAll(serials) {
|
|
195274
194189
|
this.serials.clear();
|
|
195275
|
-
for (const s of serials) this.serials.add(normalizeSerial(s));
|
|
194190
|
+
for (const s of serials) this.serials.add(normalizeSerial$1(s));
|
|
195276
194191
|
}
|
|
195277
194192
|
};
|
|
195278
|
-
function normalizeSerial(serial) {
|
|
194193
|
+
function normalizeSerial$1(serial) {
|
|
195279
194194
|
return serial.replace(/^0x/i, "").replace(/:/g, "").toLowerCase();
|
|
195280
194195
|
}
|
|
195281
|
-
var SLOT$
|
|
194196
|
+
var SLOT$2 = /* @__PURE__ */ Symbol.for("camstack.mesh.crl");
|
|
195282
194197
|
function processMeshCrl() {
|
|
195283
|
-
const existing = Reflect.get(globalThis, SLOT$
|
|
194198
|
+
const existing = Reflect.get(globalThis, SLOT$2);
|
|
195284
194199
|
if (existing instanceof MeshCrl) return existing;
|
|
195285
194200
|
const crl = new MeshCrl();
|
|
195286
|
-
Reflect.set(globalThis, SLOT$
|
|
194201
|
+
Reflect.set(globalThis, SLOT$2, crl);
|
|
195287
194202
|
return crl;
|
|
195288
194203
|
}
|
|
194204
|
+
var MESH_NODE_CERTIFICATES_COLLECTION = "mesh_node_certificates";
|
|
194205
|
+
var MESH_NODE_CERTIFICATES_COLUMNS = [
|
|
194206
|
+
{
|
|
194207
|
+
name: "id",
|
|
194208
|
+
type: "TEXT",
|
|
194209
|
+
primaryKey: true,
|
|
194210
|
+
notNull: true
|
|
194211
|
+
},
|
|
194212
|
+
{
|
|
194213
|
+
name: "nodeId",
|
|
194214
|
+
type: "TEXT",
|
|
194215
|
+
notNull: true
|
|
194216
|
+
},
|
|
194217
|
+
{
|
|
194218
|
+
name: "serial",
|
|
194219
|
+
type: "TEXT",
|
|
194220
|
+
notNull: true
|
|
194221
|
+
},
|
|
194222
|
+
{
|
|
194223
|
+
name: "fingerprint",
|
|
194224
|
+
type: "TEXT",
|
|
194225
|
+
notNull: true
|
|
194226
|
+
},
|
|
194227
|
+
{
|
|
194228
|
+
name: "notBefore",
|
|
194229
|
+
type: "INTEGER",
|
|
194230
|
+
notNull: true
|
|
194231
|
+
},
|
|
194232
|
+
{
|
|
194233
|
+
name: "notAfter",
|
|
194234
|
+
type: "INTEGER",
|
|
194235
|
+
notNull: true
|
|
194236
|
+
},
|
|
194237
|
+
{
|
|
194238
|
+
name: "issuedAt",
|
|
194239
|
+
type: "INTEGER",
|
|
194240
|
+
notNull: true
|
|
194241
|
+
},
|
|
194242
|
+
{
|
|
194243
|
+
name: "issuedVia",
|
|
194244
|
+
type: "TEXT",
|
|
194245
|
+
notNull: true
|
|
194246
|
+
},
|
|
194247
|
+
{
|
|
194248
|
+
name: "revokedAt",
|
|
194249
|
+
type: "INTEGER"
|
|
194250
|
+
},
|
|
194251
|
+
{
|
|
194252
|
+
name: "revokedReason",
|
|
194253
|
+
type: "TEXT"
|
|
194254
|
+
}
|
|
194255
|
+
];
|
|
194256
|
+
var RETENTION_MS = 90 * 864e5;
|
|
194257
|
+
var RENEWAL_ABANDONED = "renewal-abandoned";
|
|
194258
|
+
var VIAS = [
|
|
194259
|
+
"enroll",
|
|
194260
|
+
"pairing",
|
|
194261
|
+
"renewal",
|
|
194262
|
+
"boot",
|
|
194263
|
+
"observed"
|
|
194264
|
+
];
|
|
194265
|
+
function describeMeshLeaf(cert) {
|
|
194266
|
+
const x509 = new node_crypto.X509Certificate(cert);
|
|
194267
|
+
return {
|
|
194268
|
+
cn: subjectCn(x509.subject) ?? "",
|
|
194269
|
+
serial: x509.serialNumber,
|
|
194270
|
+
fingerprint: x509.fingerprint256,
|
|
194271
|
+
notBefore: Date.parse(x509.validFrom),
|
|
194272
|
+
notAfter: Date.parse(x509.validTo)
|
|
194273
|
+
};
|
|
194274
|
+
}
|
|
194275
|
+
function normalizeSerial(serial) {
|
|
194276
|
+
return serial.replace(/^0x/i, "").replace(/:/g, "").toLowerCase();
|
|
194277
|
+
}
|
|
194278
|
+
function parse$1(data) {
|
|
194279
|
+
const str = (k2) => {
|
|
194280
|
+
const v2 = data[k2];
|
|
194281
|
+
return typeof v2 === "string" && v2.length > 0 ? v2 : null;
|
|
194282
|
+
};
|
|
194283
|
+
const num = (k2) => {
|
|
194284
|
+
const v2 = data[k2];
|
|
194285
|
+
return typeof v2 === "number" && Number.isFinite(v2) ? v2 : null;
|
|
194286
|
+
};
|
|
194287
|
+
const nodeId = str("nodeId");
|
|
194288
|
+
const serial = str("serial");
|
|
194289
|
+
const fingerprint = str("fingerprint");
|
|
194290
|
+
const notBefore = num("notBefore");
|
|
194291
|
+
const notAfter = num("notAfter");
|
|
194292
|
+
const issuedAt = num("issuedAt");
|
|
194293
|
+
if (nodeId === null || serial === null || fingerprint === null || notBefore === null || notAfter === null || issuedAt === null) return null;
|
|
194294
|
+
return {
|
|
194295
|
+
nodeId,
|
|
194296
|
+
serial,
|
|
194297
|
+
fingerprint,
|
|
194298
|
+
notBefore,
|
|
194299
|
+
notAfter,
|
|
194300
|
+
issuedAt,
|
|
194301
|
+
issuedVia: VIAS.find((v2) => v2 === data["issuedVia"]) ?? "observed",
|
|
194302
|
+
revokedAt: num("revokedAt"),
|
|
194303
|
+
revokedReason: str("revokedReason")
|
|
194304
|
+
};
|
|
194305
|
+
}
|
|
194306
|
+
var MeshCertificateRegistry = class {
|
|
194307
|
+
store;
|
|
194308
|
+
deps;
|
|
194309
|
+
rows = /* @__PURE__ */ new Map();
|
|
194310
|
+
constructor(store, deps = {}) {
|
|
194311
|
+
this.store = store;
|
|
194312
|
+
this.deps = deps;
|
|
194313
|
+
}
|
|
194314
|
+
recordToBody(record) {
|
|
194315
|
+
return {
|
|
194316
|
+
nodeId: record.nodeId,
|
|
194317
|
+
serial: record.serial,
|
|
194318
|
+
fingerprint: record.fingerprint,
|
|
194319
|
+
notBefore: record.notBefore,
|
|
194320
|
+
notAfter: record.notAfter,
|
|
194321
|
+
issuedAt: record.issuedAt,
|
|
194322
|
+
issuedVia: record.issuedVia,
|
|
194323
|
+
revokedAt: record.revokedAt,
|
|
194324
|
+
revokedReason: record.revokedReason
|
|
194325
|
+
};
|
|
194326
|
+
}
|
|
194327
|
+
now() {
|
|
194328
|
+
return (this.deps.now ?? Date.now)();
|
|
194329
|
+
}
|
|
194330
|
+
async load() {
|
|
194331
|
+
const kind = this.deps.meshKind ?? null;
|
|
194332
|
+
if (kind !== null) {
|
|
194333
|
+
const page = await kind.query({ limit: 1e4 });
|
|
194334
|
+
for (const row of page.records) {
|
|
194335
|
+
const { fingerprint: _fp, ...body } = row.data;
|
|
194336
|
+
const record = parse$1({
|
|
194337
|
+
...body,
|
|
194338
|
+
fingerprint: row.id
|
|
194339
|
+
});
|
|
194340
|
+
if (record !== null) this.rows.set(record.fingerprint, record);
|
|
194341
|
+
}
|
|
194342
|
+
return;
|
|
194343
|
+
}
|
|
194344
|
+
const rows = await this.store.query.query({ collection: MESH_NODE_CERTIFICATES_COLLECTION });
|
|
194345
|
+
for (const row of rows) {
|
|
194346
|
+
const record = parse$1(row.data);
|
|
194347
|
+
if (record !== null) this.rows.set(record.fingerprint, record);
|
|
194348
|
+
}
|
|
194349
|
+
}
|
|
194350
|
+
/** Write down a leaf the hub just issued. Idempotent per fingerprint. */
|
|
194351
|
+
async recordIssued(nodeId, certPem, via) {
|
|
194352
|
+
const leaf = describeMeshLeaf(certPem);
|
|
194353
|
+
const existing = this.rows.get(leaf.fingerprint);
|
|
194354
|
+
if (existing !== void 0) return existing;
|
|
194355
|
+
const record = {
|
|
194356
|
+
nodeId,
|
|
194357
|
+
serial: leaf.serial,
|
|
194358
|
+
fingerprint: leaf.fingerprint,
|
|
194359
|
+
notBefore: leaf.notBefore,
|
|
194360
|
+
notAfter: leaf.notAfter,
|
|
194361
|
+
issuedAt: this.now(),
|
|
194362
|
+
issuedVia: via,
|
|
194363
|
+
revokedAt: null,
|
|
194364
|
+
revokedReason: null
|
|
194365
|
+
};
|
|
194366
|
+
await this.insert(record);
|
|
194367
|
+
this.deps.logger?.info("Mesh certificate recorded", {
|
|
194368
|
+
tags: { nodeId },
|
|
194369
|
+
meta: {
|
|
194370
|
+
via,
|
|
194371
|
+
serial: leaf.serial,
|
|
194372
|
+
notAfter: new Date(leaf.notAfter).toISOString()
|
|
194373
|
+
}
|
|
194374
|
+
});
|
|
194375
|
+
return record;
|
|
194376
|
+
}
|
|
194377
|
+
/**
|
|
194378
|
+
* A node was seen presenting `leaf` on its live connection. A leaf the hub already
|
|
194379
|
+
* knows is left alone; an unknown one is recorded `observed` (a node enrolled
|
|
194380
|
+
* before this record existed).
|
|
194381
|
+
*/
|
|
194382
|
+
async recordObserved(nodeId, leaf) {
|
|
194383
|
+
const known = this.rows.get(leaf.fingerprint);
|
|
194384
|
+
if (known !== void 0) {
|
|
194385
|
+
if (known.revokedReason !== "renewal-abandoned") return known.revokedAt === null ? this.abandonRenewalsNewerThan(known) : false;
|
|
194386
|
+
const reinstated = {
|
|
194387
|
+
...known,
|
|
194388
|
+
revokedAt: null,
|
|
194389
|
+
revokedReason: null
|
|
194390
|
+
};
|
|
194391
|
+
this.rows.set(known.fingerprint, reinstated);
|
|
194392
|
+
await this.persist(reinstated);
|
|
194393
|
+
this.deps.logger?.warn("An abandoned renewal leaf is in use - reinstated", {
|
|
194394
|
+
tags: { nodeId },
|
|
194395
|
+
meta: { serial: known.serial }
|
|
194396
|
+
});
|
|
194397
|
+
return true;
|
|
194398
|
+
}
|
|
194399
|
+
const record = {
|
|
194400
|
+
nodeId,
|
|
194401
|
+
serial: leaf.serial,
|
|
194402
|
+
fingerprint: leaf.fingerprint,
|
|
194403
|
+
notBefore: leaf.notBefore,
|
|
194404
|
+
notAfter: leaf.notAfter,
|
|
194405
|
+
issuedAt: this.now(),
|
|
194406
|
+
issuedVia: "observed",
|
|
194407
|
+
revokedAt: null,
|
|
194408
|
+
revokedReason: null
|
|
194409
|
+
};
|
|
194410
|
+
await this.insert(record);
|
|
194411
|
+
this.deps.logger?.info("Mesh certificate observed on a live connection and recorded", {
|
|
194412
|
+
tags: { nodeId },
|
|
194413
|
+
meta: {
|
|
194414
|
+
serial: leaf.serial,
|
|
194415
|
+
fingerprint: leaf.fingerprint
|
|
194416
|
+
}
|
|
194417
|
+
});
|
|
194418
|
+
return true;
|
|
194419
|
+
}
|
|
194420
|
+
list(nodeId) {
|
|
194421
|
+
return [...this.rows.values()].filter((r) => nodeId === void 0 || r.nodeId === nodeId).toSorted((a, b) => b.issuedAt - a.issuedAt);
|
|
194422
|
+
}
|
|
194423
|
+
/** The newest non-revoked leaf of a node, or `undefined`. */
|
|
194424
|
+
currentFor(nodeId) {
|
|
194425
|
+
return this.list(nodeId).find((r) => r.revokedAt === null);
|
|
194426
|
+
}
|
|
194427
|
+
/** Every non-revoked leaf of a node (a renewal in flight has two). */
|
|
194428
|
+
liveFor(nodeId) {
|
|
194429
|
+
return this.list(nodeId).filter((r) => r.revokedAt === null);
|
|
194430
|
+
}
|
|
194431
|
+
/** Stamp a leaf revoked (and mirror it into `crl`). `false` when unknown or already revoked. */
|
|
194432
|
+
async revoke(fingerprint, reason, crl) {
|
|
194433
|
+
const record = this.rows.get(fingerprint);
|
|
194434
|
+
if (record === void 0 || record.revokedAt !== null) return false;
|
|
194435
|
+
const revoked = {
|
|
194436
|
+
...record,
|
|
194437
|
+
revokedAt: this.now(),
|
|
194438
|
+
revokedReason: reason
|
|
194439
|
+
};
|
|
194440
|
+
this.rows.set(fingerprint, revoked);
|
|
194441
|
+
crl?.revoke(record.serial);
|
|
194442
|
+
await this.persist(revoked);
|
|
194443
|
+
this.deps.logger?.warn("Mesh certificate revoked", {
|
|
194444
|
+
tags: { nodeId: record.nodeId },
|
|
194445
|
+
meta: {
|
|
194446
|
+
serial: record.serial,
|
|
194447
|
+
reason
|
|
194448
|
+
}
|
|
194449
|
+
});
|
|
194450
|
+
return true;
|
|
194451
|
+
}
|
|
194452
|
+
/**
|
|
194453
|
+
* Operator revocation of a whole node: EVERY leaf of the node that is not already on the
|
|
194454
|
+
* CRL goes on it - the current one, an observed one, a renewal one, and a leaf that was set
|
|
194455
|
+
* aside (`renewal-abandoned`: a copy of it may sit on a stolen box, and it must not stay
|
|
194456
|
+
* valid just because the hub once set it aside). Returns the serials put on the CRL.
|
|
194457
|
+
* A leaf revoked this way is never reinstated by `recordObserved`.
|
|
194458
|
+
*/
|
|
194459
|
+
async revokeAllForNode(nodeId, reason, crl, keepFingerprint) {
|
|
194460
|
+
const serials = [];
|
|
194461
|
+
for (const record of this.list(nodeId)) {
|
|
194462
|
+
if (keepFingerprint !== void 0 && record.fingerprint === keepFingerprint) continue;
|
|
194463
|
+
if (record.revokedAt !== null && record.revokedReason !== "renewal-abandoned") continue;
|
|
194464
|
+
const revoked = {
|
|
194465
|
+
...record,
|
|
194466
|
+
revokedAt: record.revokedAt ?? this.now(),
|
|
194467
|
+
revokedReason: reason
|
|
194468
|
+
};
|
|
194469
|
+
this.rows.set(record.fingerprint, revoked);
|
|
194470
|
+
crl.revoke(record.serial);
|
|
194471
|
+
await this.persist(revoked);
|
|
194472
|
+
serials.push(record.serial);
|
|
194473
|
+
}
|
|
194474
|
+
if (serials.length > 0) this.deps.logger?.warn("Every mesh certificate of the node revoked", {
|
|
194475
|
+
tags: { nodeId },
|
|
194476
|
+
meta: {
|
|
194477
|
+
serials,
|
|
194478
|
+
reason
|
|
194479
|
+
}
|
|
194480
|
+
});
|
|
194481
|
+
return serials;
|
|
194482
|
+
}
|
|
194483
|
+
/**
|
|
194484
|
+
* At boot: a node with TWO live leaves had a renewal in flight when the hub stopped. The
|
|
194485
|
+
* newer (renewal) one is set aside - it is not the node's current leaf until the node is
|
|
194486
|
+
* seen presenting it, which reinstates it. It is NOT put on the CRL.
|
|
194487
|
+
*/
|
|
194488
|
+
async settleInterruptedRenewals() {
|
|
194489
|
+
let settled = 0;
|
|
194490
|
+
const byNode = /* @__PURE__ */ new Map();
|
|
194491
|
+
for (const record of this.rows.values()) {
|
|
194492
|
+
if (record.revokedAt !== null) continue;
|
|
194493
|
+
byNode.set(record.nodeId, [...byNode.get(record.nodeId) ?? [], record]);
|
|
194494
|
+
}
|
|
194495
|
+
for (const records of byNode.values()) {
|
|
194496
|
+
if (records.length < 2) continue;
|
|
194497
|
+
for (const record of records) if (record.issuedVia === "renewal" && await this.abandon(record.fingerprint)) settled += 1;
|
|
194498
|
+
}
|
|
194499
|
+
return settled;
|
|
194500
|
+
}
|
|
194501
|
+
/** Set a never-completed renewal leaf aside (not current, NOT on the CRL). */
|
|
194502
|
+
/** Fingerprints of renewal leaves whose handover is running right now (this process only). */
|
|
194503
|
+
renewalsInFlight = /* @__PURE__ */ new Set();
|
|
194504
|
+
/**
|
|
194505
|
+
* A renewal's leaf is "in flight" from signing until the handover ends. While it is, a node seen
|
|
194506
|
+
* presenting its OLD leaf is simply not swapped yet: the new leaf is not set aside (that would
|
|
194507
|
+
* flap set-aside / reinstate on the node's first connection with it).
|
|
194508
|
+
*/
|
|
194509
|
+
beginRenewal(fingerprint) {
|
|
194510
|
+
this.renewalsInFlight.add(fingerprint);
|
|
194511
|
+
}
|
|
194512
|
+
endRenewal(fingerprint) {
|
|
194513
|
+
this.renewalsInFlight.delete(fingerprint);
|
|
194514
|
+
}
|
|
194515
|
+
async abandonRenewalsNewerThan(presented) {
|
|
194516
|
+
let changed = false;
|
|
194517
|
+
for (const record of this.liveFor(presented.nodeId)) {
|
|
194518
|
+
if (record.fingerprint === presented.fingerprint) continue;
|
|
194519
|
+
if (record.issuedVia !== "renewal" || record.issuedAt <= presented.issuedAt) continue;
|
|
194520
|
+
if (this.renewalsInFlight.has(record.fingerprint)) continue;
|
|
194521
|
+
if (await this.abandon(record.fingerprint)) changed = true;
|
|
194522
|
+
}
|
|
194523
|
+
return changed;
|
|
194524
|
+
}
|
|
194525
|
+
async abandon(fingerprint) {
|
|
194526
|
+
const record = this.rows.get(fingerprint);
|
|
194527
|
+
if (record === void 0 || record.revokedAt !== null) return false;
|
|
194528
|
+
const abandoned = {
|
|
194529
|
+
...record,
|
|
194530
|
+
revokedAt: this.now(),
|
|
194531
|
+
revokedReason: RENEWAL_ABANDONED
|
|
194532
|
+
};
|
|
194533
|
+
this.rows.set(fingerprint, abandoned);
|
|
194534
|
+
await this.persist(abandoned);
|
|
194535
|
+
this.deps.logger?.warn("Renewal leaf set aside (not current, not on the CRL)", {
|
|
194536
|
+
tags: { nodeId: record.nodeId },
|
|
194537
|
+
meta: { serial: record.serial }
|
|
194538
|
+
});
|
|
194539
|
+
return true;
|
|
194540
|
+
}
|
|
194541
|
+
/** Replay every persisted revocation into `crl` (hub boot). Set-aside leaves are not revocations. */
|
|
194542
|
+
restoreCrl(crl) {
|
|
194543
|
+
let restored = 0;
|
|
194544
|
+
for (const record of this.rows.values()) {
|
|
194545
|
+
if (record.revokedAt === null || record.revokedReason === "renewal-abandoned") continue;
|
|
194546
|
+
crl.revoke(record.serial);
|
|
194547
|
+
restored += 1;
|
|
194548
|
+
}
|
|
194549
|
+
return restored;
|
|
194550
|
+
}
|
|
194551
|
+
/** Is `serial` listed as revoked here? */
|
|
194552
|
+
isRevoked(serial) {
|
|
194553
|
+
const wanted = normalizeSerial(serial);
|
|
194554
|
+
for (const record of this.rows.values()) if (record.revokedAt !== null && record.revokedReason !== "renewal-abandoned" && normalizeSerial(record.serial) === wanted) return true;
|
|
194555
|
+
return false;
|
|
194556
|
+
}
|
|
194557
|
+
async reap() {
|
|
194558
|
+
const cutoff = this.now() - RETENTION_MS;
|
|
194559
|
+
const dead = [...this.rows.values()].filter((r) => (r.revokedAt ?? r.notAfter) < cutoff);
|
|
194560
|
+
for (const r of dead) {
|
|
194561
|
+
this.rows.delete(r.fingerprint);
|
|
194562
|
+
await this.deleteRow(r.fingerprint);
|
|
194563
|
+
}
|
|
194564
|
+
return dead.length;
|
|
194565
|
+
}
|
|
194566
|
+
async insert(record) {
|
|
194567
|
+
this.rows.set(record.fingerprint, record);
|
|
194568
|
+
const kind = this.deps.meshKind ?? null;
|
|
194569
|
+
if (kind !== null) {
|
|
194570
|
+
const parsed = require_agent_https.systemConfigRecordKinds["mesh-node-certificates"].schema.safeParse(this.recordToBody(record));
|
|
194571
|
+
if (!parsed.success) throw new Error(parsed.error.message);
|
|
194572
|
+
await kind.put({
|
|
194573
|
+
id: record.fingerprint,
|
|
194574
|
+
data: parsed.data
|
|
194575
|
+
});
|
|
194576
|
+
return;
|
|
194577
|
+
}
|
|
194578
|
+
await this.store.insert.mutate({
|
|
194579
|
+
collection: MESH_NODE_CERTIFICATES_COLLECTION,
|
|
194580
|
+
record: {
|
|
194581
|
+
id: record.fingerprint,
|
|
194582
|
+
data: { ...record }
|
|
194583
|
+
}
|
|
194584
|
+
});
|
|
194585
|
+
}
|
|
194586
|
+
async deleteRow(fingerprint) {
|
|
194587
|
+
const kind = this.deps.meshKind ?? null;
|
|
194588
|
+
if (kind !== null) {
|
|
194589
|
+
await kind.delete(fingerprint);
|
|
194590
|
+
return;
|
|
194591
|
+
}
|
|
194592
|
+
await this.store.delete.mutate({
|
|
194593
|
+
collection: MESH_NODE_CERTIFICATES_COLLECTION,
|
|
194594
|
+
key: fingerprint
|
|
194595
|
+
});
|
|
194596
|
+
}
|
|
194597
|
+
async persist(record) {
|
|
194598
|
+
try {
|
|
194599
|
+
const kind = this.deps.meshKind ?? null;
|
|
194600
|
+
if (kind !== null) {
|
|
194601
|
+
const parsed = require_agent_https.systemConfigRecordKinds["mesh-node-certificates"].schema.safeParse(this.recordToBody(record));
|
|
194602
|
+
if (!parsed.success) throw new Error(parsed.error.message);
|
|
194603
|
+
await kind.put({
|
|
194604
|
+
id: record.fingerprint,
|
|
194605
|
+
data: parsed.data
|
|
194606
|
+
});
|
|
194607
|
+
return;
|
|
194608
|
+
}
|
|
194609
|
+
await this.store.update.mutate({
|
|
194610
|
+
collection: MESH_NODE_CERTIFICATES_COLLECTION,
|
|
194611
|
+
id: record.fingerprint,
|
|
194612
|
+
data: { ...record }
|
|
194613
|
+
});
|
|
194614
|
+
} catch (error) {
|
|
194615
|
+
this.deps.logger?.error("Mesh certificate write failed - the change holds until restart", {
|
|
194616
|
+
tags: { nodeId: record.nodeId },
|
|
194617
|
+
meta: { error: error instanceof Error ? error.message : String(error) }
|
|
194618
|
+
});
|
|
194619
|
+
}
|
|
194620
|
+
}
|
|
194621
|
+
};
|
|
194622
|
+
var SLOT$1 = /* @__PURE__ */ Symbol.for("camstack.mesh.certificate-registry");
|
|
194623
|
+
function setProcessMeshCertificateRegistry(registry) {
|
|
194624
|
+
if (registry === null) Reflect.deleteProperty(globalThis, SLOT$1);
|
|
194625
|
+
else Reflect.set(globalThis, SLOT$1, registry);
|
|
194626
|
+
}
|
|
194627
|
+
function getProcessMeshCertificateRegistry() {
|
|
194628
|
+
const value = Reflect.get(globalThis, SLOT$1);
|
|
194629
|
+
return value !== null && typeof value === "object" && typeof Reflect.get(value, "recordIssued") === "function" ? value : null;
|
|
194630
|
+
}
|
|
195289
194631
|
var STATE_SLOT = /* @__PURE__ */ Symbol.for("camstack.mesh.tls-listener-state");
|
|
195290
194632
|
function setProcessMeshTlsListenerState(state) {
|
|
195291
194633
|
if (state === null) Reflect.deleteProperty(globalThis, STATE_SLOT);
|
|
@@ -195420,7 +194762,7 @@ var require_system_config_addon = __commonJS({
|
|
|
195420
194762
|
}
|
|
195421
194763
|
let issued;
|
|
195422
194764
|
try {
|
|
195423
|
-
issued = await
|
|
194765
|
+
issued = await issueMeshLeafFromCsr(deps.ca, csrPem, { expectedNodeId: nodeId });
|
|
195424
194766
|
await deps.registry.recordIssued(nodeId, issued.certPem, "renewal");
|
|
195425
194767
|
log.info("Mesh renewal: new leaf signed and recorded", {
|
|
195426
194768
|
tags,
|
|
@@ -195432,7 +194774,7 @@ var require_system_config_addon = __commonJS({
|
|
|
195432
194774
|
} catch (error) {
|
|
195433
194775
|
return fail2("issue", message(error), true);
|
|
195434
194776
|
}
|
|
195435
|
-
const newLeaf =
|
|
194777
|
+
const newLeaf = describeMeshLeaf(issued.certPem);
|
|
195436
194778
|
deps.registry.beginRenewal(newLeaf.fingerprint);
|
|
195437
194779
|
inFlight.fingerprint = newLeaf.fingerprint;
|
|
195438
194780
|
let resolveRegistered = () => void 0;
|
|
@@ -267394,7 +266736,7 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
267394
266736
|
if (cert == null || typeof cert !== "object" || !("raw" in cert) || !cert.raw) return null;
|
|
267395
266737
|
try {
|
|
267396
266738
|
const x509 = new node_crypto.X509Certificate(cert.raw);
|
|
267397
|
-
const cn =
|
|
266739
|
+
const cn = subjectCn(x509.subject) ?? subjectCn(`CN=${cert.subject?.CN ?? ""}`);
|
|
267398
266740
|
if (cn === null || cn.length === 0) return null;
|
|
267399
266741
|
return {
|
|
267400
266742
|
cn,
|
|
@@ -267885,7 +267227,7 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
267885
267227
|
return (0, node_crypto.randomBytes)(16).toString("base64url");
|
|
267886
267228
|
}
|
|
267887
267229
|
function computePairingCommitment(caCertPem, hubNonce) {
|
|
267888
|
-
return (0, node_crypto.createHash)("sha256").update(`${PAIRING_DOMAIN}|commit|${
|
|
267230
|
+
return (0, node_crypto.createHash)("sha256").update(`${PAIRING_DOMAIN}|commit|${caFingerprintCompact(caCertPem)}|${hubNonce}`, "utf8").digest("hex");
|
|
267889
267231
|
}
|
|
267890
267232
|
function commitmentsEqual(expected, presented) {
|
|
267891
267233
|
return constantTimeEqual(expected, presented);
|
|
@@ -267894,7 +267236,7 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
267894
267236
|
const value = (0, node_crypto.createHash)("sha256").update([
|
|
267895
267237
|
PAIRING_DOMAIN,
|
|
267896
267238
|
"sas",
|
|
267897
|
-
|
|
267239
|
+
caFingerprintCompact(input.caCertPem),
|
|
267898
267240
|
input.agentPublicKeySpki,
|
|
267899
267241
|
input.hubNonce,
|
|
267900
267242
|
input.agentNonce
|
|
@@ -267910,7 +267252,7 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
267910
267252
|
async function describeCsr(csrPem) {
|
|
267911
267253
|
const csr = new require_x509_es.Pkcs10CertificateRequest(csrPem);
|
|
267912
267254
|
if (!await csr.verify(node_crypto.webcrypto)) throw new Error("the agent CSR signature is invalid");
|
|
267913
|
-
const cn =
|
|
267255
|
+
const cn = subjectCn(csr.subject);
|
|
267914
267256
|
if (cn === null || cn.length === 0) throw new Error("the agent CSR has no CN");
|
|
267915
267257
|
return {
|
|
267916
267258
|
commonName: cn,
|
|
@@ -267970,14 +267312,14 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
267970
267312
|
const hubNonce = str("hubNonce");
|
|
267971
267313
|
const agentNonce = str("agentNonce");
|
|
267972
267314
|
const leafFingerprint = str("leafFingerprint");
|
|
267973
|
-
const
|
|
267315
|
+
const caFingerprint2 = str("caFingerprint");
|
|
267974
267316
|
const hubMeshAddress = str("hubMeshAddress");
|
|
267975
267317
|
const hubUrl = str("hubUrl");
|
|
267976
267318
|
const exp = Reflect.get(value, "exp");
|
|
267977
267319
|
const iat = Reflect.get(value, "iat");
|
|
267978
267320
|
if (Reflect.get(value, "v") !== 1) return null;
|
|
267979
267321
|
if (Reflect.get(value, "use") !== "pairing-complete") return null;
|
|
267980
|
-
if (pairingId === null || nodeId === null || hubNonce === null || agentNonce === null || leafFingerprint === null ||
|
|
267322
|
+
if (pairingId === null || nodeId === null || hubNonce === null || agentNonce === null || leafFingerprint === null || caFingerprint2 === null || hubMeshAddress === null || hubUrl === null || typeof exp !== "number" || !Number.isFinite(exp) || typeof iat !== "number" || !Number.isFinite(iat)) return null;
|
|
267981
267323
|
return {
|
|
267982
267324
|
v: 1,
|
|
267983
267325
|
use: PAIRING_PROOF_USE,
|
|
@@ -267986,7 +267328,7 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
267986
267328
|
hubNonce,
|
|
267987
267329
|
agentNonce,
|
|
267988
267330
|
leafFingerprint,
|
|
267989
|
-
caFingerprint,
|
|
267331
|
+
caFingerprint: caFingerprint2,
|
|
267990
267332
|
hubMeshAddress,
|
|
267991
267333
|
hubUrl,
|
|
267992
267334
|
iat,
|
|
@@ -268038,18 +267380,18 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
268038
267380
|
const iat = Reflect.get(payload, "iat");
|
|
268039
267381
|
const agentNodeId = str("agentNodeId");
|
|
268040
267382
|
const hubNodeId = str("hubNodeId");
|
|
268041
|
-
const
|
|
267383
|
+
const caFingerprint2 = str("caFingerprint");
|
|
268042
267384
|
const commitment = str("commitment");
|
|
268043
267385
|
const hubUrl = str("hubUrl");
|
|
268044
267386
|
const hubMeshAddress = str("hubMeshAddress");
|
|
268045
267387
|
if (Reflect.get(payload, "use") !== "pairing-offer") return null;
|
|
268046
267388
|
if (typeof iat !== "number" || !Number.isFinite(iat)) return null;
|
|
268047
|
-
if (agentNodeId === null || hubNodeId === null ||
|
|
267389
|
+
if (agentNodeId === null || hubNodeId === null || caFingerprint2 === null || commitment === null || hubUrl === null || hubMeshAddress === null) return null;
|
|
268048
267390
|
return {
|
|
268049
267391
|
use: PAIRING_OFFER_USE,
|
|
268050
267392
|
agentNodeId,
|
|
268051
267393
|
hubNodeId,
|
|
268052
|
-
caFingerprint,
|
|
267394
|
+
caFingerprint: caFingerprint2,
|
|
268053
267395
|
commitment,
|
|
268054
267396
|
hubUrl,
|
|
268055
267397
|
hubMeshAddress,
|
|
@@ -268181,23 +267523,23 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
268181
267523
|
async offer(body) {
|
|
268182
267524
|
this.expireIfDue();
|
|
268183
267525
|
if (this.deps.isPaired()) return fail(409, "already-paired", "this agent is paired \u2014 unpair it first (from the hub or here)");
|
|
268184
|
-
if (!
|
|
267526
|
+
if (!isValidAgentNodeId(this.deps.nodeId)) return fail(409, "invalid-node-id", `this agent's node id "${this.deps.nodeId}" cannot be paired - rename the agent`);
|
|
268185
267527
|
const request = parseOffer(body);
|
|
268186
267528
|
if (request === null) return fail(400, "bad-offer", "the offer is malformed");
|
|
268187
267529
|
if (request.protocol !== 1) return fail(400, "unsupported-protocol", `pairing protocol ${String(request.protocol)} is not supported`);
|
|
268188
267530
|
if (readCaCertificate(request.hubCaCertPem, this.now()) === null) return fail(400, "bad-ca", "the offered CA is not a valid self-signed CA certificate");
|
|
268189
267531
|
if (!/^[0-9a-f]{64}$/.test(request.commitment)) return fail(400, "bad-offer", "the commitment is malformed");
|
|
268190
267532
|
if (!isHttpUrl(request.hubUrl)) return fail(400, "bad-offer", "hubUrl is not an http(s) URL");
|
|
268191
|
-
const
|
|
268192
|
-
const refused = this.checkOfferSignature(request,
|
|
267533
|
+
const caFingerprint2 = caFingerprintCompact(request.hubCaCertPem);
|
|
267534
|
+
const refused = this.checkOfferSignature(request, caFingerprint2);
|
|
268193
267535
|
if (refused !== null) return refused;
|
|
268194
|
-
const rationed = this.rationOffer(
|
|
267536
|
+
const rationed = this.rationOffer(caFingerprint2);
|
|
268195
267537
|
if (rationed !== null) return rationed;
|
|
268196
|
-
for (const existing of [...this.sessions.values()]) if (existing.hub.caFingerprint ===
|
|
267538
|
+
for (const existing of [...this.sessions.values()]) if (existing.hub.caFingerprint === caFingerprint2) this.end(existing, "failed");
|
|
268197
267539
|
if (this.sessions.size >= 4 && !this.makeRoom()) return fail(409, "too-many-pending", "too many pairings are pending on this agent");
|
|
268198
|
-
const keys = await
|
|
268199
|
-
const csrPem = await
|
|
268200
|
-
const keyPem = await
|
|
267540
|
+
const keys = await generateMeshKeyPair();
|
|
267541
|
+
const csrPem = await createMeshCsrPem(keys, this.deps.nodeId);
|
|
267542
|
+
const keyPem = await exportMeshPrivateKeyPem(keys.privateKey);
|
|
268201
267543
|
const publicKeySpki = Buffer.from(await node_crypto.webcrypto.subtle.exportKey("spki", keys.publicKey)).toString("base64");
|
|
268202
267544
|
if (this.sessions.size >= 4 && !this.makeRoom()) return fail(409, "too-many-pending", "too many pairings are pending on this agent");
|
|
268203
267545
|
const session = {
|
|
@@ -268205,7 +267547,7 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
268205
267547
|
hub: {
|
|
268206
267548
|
nodeId: request.hubNodeId,
|
|
268207
267549
|
caCertPem: request.hubCaCertPem,
|
|
268208
|
-
caFingerprint,
|
|
267550
|
+
caFingerprint: caFingerprint2,
|
|
268209
267551
|
commitment: request.commitment,
|
|
268210
267552
|
url: request.hubUrl,
|
|
268211
267553
|
meshAddress: request.hubMeshAddress
|
|
@@ -268427,10 +267769,10 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
268427
267769
|
return { ok: true };
|
|
268428
267770
|
}
|
|
268429
267771
|
/** Verify the CA-key signature of an offer and spend its commitment. */
|
|
268430
|
-
checkOfferSignature(request,
|
|
267772
|
+
checkOfferSignature(request, caFingerprint2) {
|
|
268431
267773
|
const claims = verifyPairingOffer(request.hubCaCertPem, request.signature);
|
|
268432
267774
|
const at2 = this.now();
|
|
268433
|
-
if (claims === null || claims.use !== "pairing-offer" || claims.agentNodeId !== this.deps.nodeId || claims.hubNodeId !== request.hubNodeId || claims.caFingerprint !==
|
|
267775
|
+
if (claims === null || claims.use !== "pairing-offer" || claims.agentNodeId !== this.deps.nodeId || claims.hubNodeId !== request.hubNodeId || claims.caFingerprint !== caFingerprint2 || claims.commitment !== request.commitment || claims.hubUrl !== request.hubUrl || claims.hubMeshAddress !== request.hubMeshAddress || claims.iat > at2 + 6e4 || at2 - claims.iat > 12e4) {
|
|
268434
267776
|
this.deps.log?.("an offer without a valid CA signature was refused", {});
|
|
268435
267777
|
return fail(403, "bad-offer-signature", "the offer is not signed by the CA it presents");
|
|
268436
267778
|
}
|
|
@@ -268451,16 +267793,16 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
268451
267793
|
return true;
|
|
268452
267794
|
}
|
|
268453
267795
|
/** Offers that never reached local confirmation are rationed - globally and per hub CA. */
|
|
268454
|
-
rationOffer(
|
|
267796
|
+
rationOffer(caFingerprint2) {
|
|
268455
267797
|
const at2 = this.now();
|
|
268456
267798
|
if (at2 < this.lockedUntil) {
|
|
268457
267799
|
this.deps.log?.("offer refused: the budget of abandoned pairings is spent", { retryAfterMs: this.lockedUntil - at2 });
|
|
268458
267800
|
return fail(429, "offer-budget", "too many pairings were abandoned recently - try again later", this.lockedUntil - at2);
|
|
268459
267801
|
}
|
|
268460
|
-
const ca = this.perCa.get(
|
|
267802
|
+
const ca = this.perCa.get(caFingerprint2);
|
|
268461
267803
|
if (ca !== void 0 && at2 < ca.until) {
|
|
268462
267804
|
this.deps.log?.("offer refused: this hub abandoned a pairing a moment ago", {
|
|
268463
|
-
caFingerprint,
|
|
267805
|
+
caFingerprint: caFingerprint2,
|
|
268464
267806
|
retryAfterMs: ca.until - at2
|
|
268465
267807
|
});
|
|
268466
267808
|
return fail(429, "offer-backoff", "this hub abandoned a pairing a moment ago - wait before offering again", ca.until - at2);
|
|
@@ -268537,7 +267879,7 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
268537
267879
|
const leaf = new node_crypto.X509Certificate(leafPem);
|
|
268538
267880
|
const ca = new node_crypto.X509Certificate(session.hub.caCertPem);
|
|
268539
267881
|
if (!leaf.verify(ca.publicKey)) return fail(400, "bad-leaf", "the certificate is not signed by the offered CA");
|
|
268540
|
-
if (
|
|
267882
|
+
if (subjectCn(leaf.subject.replaceAll("\n", ",")) !== this.deps.nodeId) return fail(400, "bad-leaf", `the certificate is not issued for "${this.deps.nodeId}"`);
|
|
268541
267883
|
if (!leaf.checkPrivateKey((0, node_crypto.createPrivateKey)(session.keyPem))) return fail(400, "bad-leaf", "the certificate does not match this agent's private key");
|
|
268542
267884
|
if (Date.parse(leaf.validTo) <= this.now()) return fail(400, "bad-leaf", "the certificate is already expired");
|
|
268543
267885
|
} catch {
|
|
@@ -268595,7 +267937,7 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
268595
267937
|
}
|
|
268596
267938
|
function caFingerprintOf(pem) {
|
|
268597
267939
|
try {
|
|
268598
|
-
return
|
|
267940
|
+
return caFingerprintCompact(pem);
|
|
268599
267941
|
} catch {
|
|
268600
267942
|
return null;
|
|
268601
267943
|
}
|
|
@@ -268672,7 +268014,7 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
268672
268014
|
use: PAIRING_OFFER_USE,
|
|
268673
268015
|
agentNodeId: hello.nodeId,
|
|
268674
268016
|
hubNodeId: this.deps.hubNodeId,
|
|
268675
|
-
caFingerprint:
|
|
268017
|
+
caFingerprint: caFingerprintCompact(ca.certPem),
|
|
268676
268018
|
commitment,
|
|
268677
268019
|
hubUrl,
|
|
268678
268020
|
hubMeshAddress,
|
|
@@ -268789,14 +268131,14 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
268789
268131
|
}
|
|
268790
268132
|
async complete(session) {
|
|
268791
268133
|
const ca = this.deps.ca();
|
|
268792
|
-
if (ca === null ||
|
|
268134
|
+
if (ca === null || caFingerprintCompact(ca.certPem) !== caFingerprintCompact(session.caCertPem)) {
|
|
268793
268135
|
await this.cancel(session, "failed", "the mesh CA changed during the pairing");
|
|
268794
268136
|
return;
|
|
268795
268137
|
}
|
|
268796
268138
|
session.state = "completing";
|
|
268797
268139
|
let issuedPem = null;
|
|
268798
268140
|
try {
|
|
268799
|
-
const leaf = await
|
|
268141
|
+
const leaf = await issueMeshLeafFromCsr(ca, session.csrPem, { expectedNodeId: session.nodeId });
|
|
268800
268142
|
issuedPem = leaf.certPem;
|
|
268801
268143
|
await this.deps.recordIssued(session.nodeId, leaf.certPem);
|
|
268802
268144
|
session.issued = true;
|
|
@@ -268808,7 +268150,7 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
268808
268150
|
hubNonce: session.hubNonce,
|
|
268809
268151
|
agentNonce: session.agentNonce,
|
|
268810
268152
|
leafFingerprint: leafFingerprintCompact(leaf.certPem),
|
|
268811
|
-
caFingerprint:
|
|
268153
|
+
caFingerprint: caFingerprintCompact(ca.certPem),
|
|
268812
268154
|
hubMeshAddress: session.hubMeshAddress,
|
|
268813
268155
|
hubUrl: session.hubUrl,
|
|
268814
268156
|
iat: this.now(),
|
|
@@ -268862,7 +268204,7 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
268862
268204
|
}
|
|
268863
268205
|
}
|
|
268864
268206
|
assertNodeIdUsable(nodeId) {
|
|
268865
|
-
if (!
|
|
268207
|
+
if (!isValidAgentNodeId(nodeId)) throw new Error(`"${nodeId}" cannot be an agent node id (letters, digits, . _ - ; not "hub"; at most 63 characters)`);
|
|
268866
268208
|
if (this.deps.isNodeConnected(nodeId)) throw new Error(`a node called "${nodeId}" is already connected to this hub \u2014 unpair it first`);
|
|
268867
268209
|
const lower = nodeId.toLowerCase();
|
|
268868
268210
|
const clash = (this.deps.knownNodeIds?.() ?? []).find((known) => known !== nodeId && known.toLowerCase() === lower);
|
|
@@ -268983,7 +268325,7 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
268983
268325
|
};
|
|
268984
268326
|
}
|
|
268985
268327
|
async onShutdown() {
|
|
268986
|
-
|
|
268328
|
+
setProcessMeshCertificateRegistry(null);
|
|
268987
268329
|
setProcessMeshTlsListenerState(null);
|
|
268988
268330
|
require_agent_https.setProcessAgentHttpsNames(null);
|
|
268989
268331
|
this.stoppedMesh = true;
|
|
@@ -269014,14 +268356,14 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
269014
268356
|
this.loadAgentHttpsNames(store, records);
|
|
269015
268357
|
try {
|
|
269016
268358
|
if (records === void 0) await store.declareCollection.mutate({
|
|
269017
|
-
collection:
|
|
269018
|
-
columns:
|
|
268359
|
+
collection: MESH_NODE_CERTIFICATES_COLLECTION,
|
|
268360
|
+
columns: MESH_NODE_CERTIFICATES_COLUMNS,
|
|
269019
268361
|
indexes: [{
|
|
269020
268362
|
name: "idx_mesh_node_certificates_node",
|
|
269021
268363
|
columns: ["nodeId"]
|
|
269022
268364
|
}]
|
|
269023
268365
|
});
|
|
269024
|
-
const registry = new
|
|
268366
|
+
const registry = new MeshCertificateRegistry(store, {
|
|
269025
268367
|
logger: this.ctx.logger,
|
|
269026
268368
|
meshKind
|
|
269027
268369
|
});
|
|
@@ -269029,7 +268371,7 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
269029
268371
|
const restored = registry.restoreCrl(processMeshCrl());
|
|
269030
268372
|
const settled = await registry.settleInterruptedRenewals();
|
|
269031
268373
|
if (settled > 0) this.ctx.logger.warn("A mesh renewal was interrupted by a hub restart - its new leaf was set aside", { meta: { settled } });
|
|
269032
|
-
|
|
268374
|
+
setProcessMeshCertificateRegistry(registry);
|
|
269033
268375
|
if (restored > 0) this.ctx.logger.info("Mesh revocations restored into the CRL", { meta: { restored } });
|
|
269034
268376
|
return registry;
|
|
269035
268377
|
} catch (err) {
|
|
@@ -269063,7 +268405,7 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
269063
268405
|
await openMeshTlsWhenRevocationsLoaded({
|
|
269064
268406
|
loadRegistry: () => this.initMeshCertificateRegistry(),
|
|
269065
268407
|
open: async (registry) => {
|
|
269066
|
-
const hubLeaf = await
|
|
268408
|
+
const hubLeaf = await issueMeshLeafForNode(ca, "hub");
|
|
269067
268409
|
await registry.recordIssued("hub", hubLeaf.certPem, "boot").catch((err) => {
|
|
269068
268410
|
this.ctx.logger.warn("Hub mesh leaf could not be recorded", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
269069
268411
|
});
|
|
@@ -269368,8 +268710,11 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
269368
268710
|
exports.AgentPairing = AgentPairing;
|
|
269369
268711
|
exports.Errors = Errors;
|
|
269370
268712
|
exports.HubPairing = HubPairing;
|
|
268713
|
+
exports.MESH_NODE_CERTIFICATES_COLLECTION = MESH_NODE_CERTIFICATES_COLLECTION;
|
|
268714
|
+
exports.MESH_NODE_CERTIFICATES_COLUMNS = MESH_NODE_CERTIFICATES_COLUMNS;
|
|
269371
268715
|
exports.MESH_TLS_PORT_HELLO_FIELD = MESH_TLS_PORT_HELLO_FIELD;
|
|
269372
268716
|
exports.MeshCaKeeper = MeshCaKeeper;
|
|
268717
|
+
exports.MeshCertificateRegistry = MeshCertificateRegistry;
|
|
269373
268718
|
exports.MeshCrl = MeshCrl;
|
|
269374
268719
|
exports.PAIRING_CODE_DIGITS = PAIRING_CODE_DIGITS;
|
|
269375
268720
|
exports.PAIRING_MAX_CODE_ATTEMPTS = PAIRING_MAX_CODE_ATTEMPTS;
|
|
@@ -269379,26 +268724,39 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
269379
268724
|
exports.PAIRING_PROTOCOL = PAIRING_PROTOCOL;
|
|
269380
268725
|
exports.PAIRING_TTL_MS = PAIRING_TTL_MS;
|
|
269381
268726
|
exports.PairingHttpError = PairingHttpError;
|
|
268727
|
+
exports.RENEWAL_ABANDONED = RENEWAL_ABANDONED;
|
|
269382
268728
|
exports.SYSTEM_CONFIG_CLUSTER_SECTION_ID = SYSTEM_CONFIG_CLUSTER_SECTION_ID;
|
|
269383
268729
|
exports.ServiceBroker = ServiceBroker;
|
|
269384
268730
|
exports.SystemConfigAddon = SystemConfigAddon;
|
|
269385
268731
|
exports.default = SystemConfigAddon;
|
|
269386
268732
|
exports.TlsTcpTransporter = TlsTcpTransporter;
|
|
269387
268733
|
exports.UnlockTicketJtiStore = UnlockTicketJtiStore;
|
|
268734
|
+
exports.caFingerprint = caFingerprint;
|
|
268735
|
+
exports.caFingerprintCompact = caFingerprintCompact;
|
|
269388
268736
|
exports.computePairingCommitment = computePairingCommitment;
|
|
269389
268737
|
exports.computePairingSas = computePairingSas;
|
|
269390
268738
|
exports.createCidrMatcher = createCidrMatcher;
|
|
268739
|
+
exports.createMeshCsrPem = createMeshCsrPem;
|
|
269391
268740
|
exports.describeCsr = describeCsr;
|
|
268741
|
+
exports.describeMeshLeaf = describeMeshLeaf;
|
|
269392
268742
|
exports.dropProcessPeer = dropProcessPeer;
|
|
269393
268743
|
exports.emitProcessNodeRegistered = emitProcessNodeRegistered;
|
|
268744
|
+
exports.exportMeshPrivateKeyPem = exportMeshPrivateKeyPem;
|
|
268745
|
+
exports.generateMeshCa = generateMeshCa;
|
|
268746
|
+
exports.generateMeshKeyPair = generateMeshKeyPair;
|
|
269394
268747
|
exports.getProcessMeshCaState = getProcessMeshCaState;
|
|
268748
|
+
exports.getProcessMeshCertificateRegistry = getProcessMeshCertificateRegistry;
|
|
269395
268749
|
exports.getProcessMeshTlsListenerState = getProcessMeshTlsListenerState;
|
|
269396
268750
|
exports.getProcessNodeMeshTransport = getProcessNodeMeshTransport;
|
|
269397
268751
|
exports.getProcessPeerLeaf = getProcessPeerLeaf;
|
|
269398
268752
|
exports.hubHostFromMeshAddress = hubHostFromMeshAddress;
|
|
269399
268753
|
exports.isAllowedAgentDashboardReturnTo = isAllowedAgentDashboardReturnTo;
|
|
269400
268754
|
exports.isProcessVerifiedMeshPeer = isProcessVerifiedMeshPeer;
|
|
268755
|
+
exports.isValidAgentNodeId = isValidAgentNodeId;
|
|
268756
|
+
exports.issueMeshLeafForNode = issueMeshLeafForNode;
|
|
268757
|
+
exports.issueMeshLeafFromCsr = issueMeshLeafFromCsr;
|
|
269401
268758
|
exports.keyFingerprintShort = keyFingerprintShort;
|
|
268759
|
+
exports.loadMeshCa = loadMeshCa;
|
|
269402
268760
|
exports.mintAgentUiUnlockTicket = mintAgentUiUnlockTicket;
|
|
269403
268761
|
exports.normalizeIp = normalizeIp;
|
|
269404
268762
|
exports.onProcessNodeRegistered = onProcessNodeRegistered;
|
|
@@ -269410,6 +268768,7 @@ globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) retur
|
|
|
269410
268768
|
exports.renewMeshCertificate = renewMeshCertificate;
|
|
269411
268769
|
exports.requireProcessMeshCa = requireProcessMeshCa;
|
|
269412
268770
|
exports.revokeMeshCertificate = revokeMeshCertificate;
|
|
268771
|
+
exports.setProcessMeshCertificateRegistry = setProcessMeshCertificateRegistry;
|
|
269413
268772
|
exports.setProcessMeshPeerTransportLookup = setProcessMeshPeerTransportLookup;
|
|
269414
268773
|
exports.setProcessMeshTlsEnabler = setProcessMeshTlsEnabler;
|
|
269415
268774
|
exports.setProcessMeshTlsListenerState = setProcessMeshTlsListenerState;
|
|
@@ -275351,7 +274710,7 @@ var require_winston_logging = __commonJS({
|
|
|
275351
274710
|
[Symbol.toStringTag]: { value: "Module" }
|
|
275352
274711
|
});
|
|
275353
274712
|
var require_chunk = require_chunk_Cek0wNdY();
|
|
275354
|
-
var require_dist10 =
|
|
274713
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
275355
274714
|
var require_formatter = require_formatter_DqAKDlvN();
|
|
275356
274715
|
var require_log_file_read_protocol = require_log_file_read_protocol_D0WcLbIV();
|
|
275357
274716
|
var node_path = __require("path");
|
|
@@ -283152,14 +282511,14 @@ var require_lib_8oZrELLm = __commonJS({
|
|
|
283152
282511
|
}
|
|
283153
282512
|
});
|
|
283154
282513
|
|
|
283155
|
-
// ../system/dist/hub-mdns-ciao-
|
|
283156
|
-
var
|
|
283157
|
-
"../system/dist/hub-mdns-ciao-
|
|
282514
|
+
// ../system/dist/hub-mdns-ciao-CTBTlia4.js
|
|
282515
|
+
var require_hub_mdns_ciao_CTBTlia4 = __commonJS({
|
|
282516
|
+
"../system/dist/hub-mdns-ciao-CTBTlia4.js"(exports) {
|
|
283158
282517
|
"use strict";
|
|
283159
282518
|
var require_chunk = require_chunk_Cek0wNdY();
|
|
283160
|
-
var require_dist10 =
|
|
282519
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
283161
282520
|
var require_x509_es = require_x509_es_C4cOo48M();
|
|
283162
|
-
var require_agent_https =
|
|
282521
|
+
var require_agent_https = require_agent_https_Dnr_nIVx();
|
|
283163
282522
|
var node_crypto = __require("crypto");
|
|
283164
282523
|
var _camstack_types_node = require_node();
|
|
283165
282524
|
var node_fs_promises = __require("fs/promises");
|
|
@@ -284171,13 +283530,12 @@ var require_platform_key_source_Di7HrlGR = __commonJS({
|
|
|
284171
283530
|
}
|
|
284172
283531
|
});
|
|
284173
283532
|
|
|
284174
|
-
// ../system/dist/restore-archive-
|
|
284175
|
-
var
|
|
284176
|
-
"../system/dist/restore-archive-
|
|
283533
|
+
// ../system/dist/restore-archive-DM1OBYq4.js
|
|
283534
|
+
var require_restore_archive_DM1OBYq4 = __commonJS({
|
|
283535
|
+
"../system/dist/restore-archive-DM1OBYq4.js"(exports) {
|
|
284177
283536
|
"use strict";
|
|
284178
283537
|
var require_chunk = require_chunk_Cek0wNdY();
|
|
284179
|
-
var require_dist10 =
|
|
284180
|
-
var require_read_all_rows$1 = require_read_all_rows_CVoO1ONM();
|
|
283538
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
284181
283539
|
var zod = require_zod();
|
|
284182
283540
|
var node_crypto = __require("crypto");
|
|
284183
283541
|
var buffer = __require("buffer");
|
|
@@ -284209,6 +283567,87 @@ var require_restore_archive_FyfZ8YMC = __commonJS({
|
|
|
284209
283567
|
var node_stream_promises = __require("stream/promises");
|
|
284210
283568
|
var node_assert = __require("assert");
|
|
284211
283569
|
node_assert = require_chunk.__toESM(node_assert, 1);
|
|
283570
|
+
var BackupScheduleBodySchema = zod.z.object({
|
|
283571
|
+
label: zod.z.string(),
|
|
283572
|
+
cron: zod.z.string(),
|
|
283573
|
+
enabled: zod.z.boolean(),
|
|
283574
|
+
locationIds: zod.z.array(zod.z.string()).readonly(),
|
|
283575
|
+
retentionCount: zod.z.number(),
|
|
283576
|
+
dataSources: zod.z.array(zod.z.string()).readonly().optional(),
|
|
283577
|
+
databases: zod.z.array(require_dist10.DataStoreDatabaseSchema).readonly().optional(),
|
|
283578
|
+
lastAttemptAt: zod.z.number().optional(),
|
|
283579
|
+
lastSuccessAt: zod.z.number().optional(),
|
|
283580
|
+
lastError: zod.z.string().optional()
|
|
283581
|
+
});
|
|
283582
|
+
var BackupDestinationPolicyBodySchema = zod.z.object({
|
|
283583
|
+
enabled: zod.z.boolean(),
|
|
283584
|
+
retentionCount: zod.z.number(),
|
|
283585
|
+
label: zod.z.string().optional(),
|
|
283586
|
+
lastAttemptAt: zod.z.number().optional(),
|
|
283587
|
+
lastError: zod.z.string().optional()
|
|
283588
|
+
});
|
|
283589
|
+
var BackupEncryptionKeyBodySchema = zod.z.object({
|
|
283590
|
+
keyId: zod.z.string(),
|
|
283591
|
+
publicKey: zod.z.string(),
|
|
283592
|
+
createdAt: zod.z.number(),
|
|
283593
|
+
retiredAt: zod.z.number().nullable()
|
|
283594
|
+
});
|
|
283595
|
+
var BackupSeedMarkerBodySchema = zod.z.object({ seededAt: zod.z.number() });
|
|
283596
|
+
var _backupOrchestratorRecordKinds = require_dist10.defineRecordKinds({
|
|
283597
|
+
schedules: {
|
|
283598
|
+
schema: BackupScheduleBodySchema,
|
|
283599
|
+
class: "config",
|
|
283600
|
+
writeTrigger: "operator upsert/delete; orchestrator stamps lastAttempt/success/error",
|
|
283601
|
+
device: "none",
|
|
283602
|
+
at: "none",
|
|
283603
|
+
indexes: [{
|
|
283604
|
+
name: "enabled",
|
|
283605
|
+
fields: ["enabled"]
|
|
283606
|
+
}],
|
|
283607
|
+
retention: { none: "operator delete only" },
|
|
283608
|
+
entry: {
|
|
283609
|
+
title: "Backup schedules",
|
|
283610
|
+
nameField: "label"
|
|
283611
|
+
}
|
|
283612
|
+
},
|
|
283613
|
+
"destination-policies": {
|
|
283614
|
+
schema: BackupDestinationPolicyBodySchema,
|
|
283615
|
+
class: "config",
|
|
283616
|
+
writeTrigger: "ensureDefault, operator upsert, recordAttempt after each archive write",
|
|
283617
|
+
device: "none",
|
|
283618
|
+
at: "none",
|
|
283619
|
+
retention: { none: "row outlives location; ensureDefault recreates" }
|
|
283620
|
+
},
|
|
283621
|
+
"encryption-keys": {
|
|
283622
|
+
schema: BackupEncryptionKeyBodySchema,
|
|
283623
|
+
class: "config",
|
|
283624
|
+
writeTrigger: "setupEncryption activate; disableEncryption retires active row",
|
|
283625
|
+
device: "none",
|
|
283626
|
+
at: "none",
|
|
283627
|
+
retention: { none: "retired keys kept for archive decryption hints" }
|
|
283628
|
+
},
|
|
283629
|
+
"seed-markers": {
|
|
283630
|
+
schema: BackupSeedMarkerBodySchema,
|
|
283631
|
+
class: "config",
|
|
283632
|
+
writeTrigger: "mark() once per seed id after seed landed",
|
|
283633
|
+
device: "none",
|
|
283634
|
+
at: "none",
|
|
283635
|
+
retention: { none: "one row per seed id ever" }
|
|
283636
|
+
}
|
|
283637
|
+
});
|
|
283638
|
+
var backupOrchestratorRecordKinds = _backupOrchestratorRecordKinds;
|
|
283639
|
+
var backupSchedulesRecordKind = _backupOrchestratorRecordKinds.schedules;
|
|
283640
|
+
var backupDestinationPoliciesRecordKind = _backupOrchestratorRecordKinds["destination-policies"];
|
|
283641
|
+
var backupEncryptionKeysRecordKind = _backupOrchestratorRecordKinds["encryption-keys"];
|
|
283642
|
+
var backupSeedMarkersRecordKind = _backupOrchestratorRecordKinds["seed-markers"];
|
|
283643
|
+
function backupRecordStoresOf(records) {
|
|
283644
|
+
return {
|
|
283645
|
+
schedules: records.kind(backupSchedulesRecordKind),
|
|
283646
|
+
destinationPolicies: records.kind(backupDestinationPoliciesRecordKind),
|
|
283647
|
+
encryptionKeys: records.kind(backupEncryptionKeysRecordKind),
|
|
283648
|
+
seedMarkers: records.kind(backupSeedMarkersRecordKind)
|
|
283649
|
+
};
|
|
283650
|
+
}
|
|
284212
283651
|
var BACKUP_ENCRYPTION_SCHEME = "x25519-hkdf-aes256gcm-stream-v1";
|
|
284213
283652
|
var ENCRYPTED_BACKUP_SUFFIX = ".csbk";
|
|
284214
283653
|
var MAGIC = Buffer.from("CSBKENC1", "ascii");
|
|
@@ -284523,314 +283962,6 @@ var require_restore_archive_FyfZ8YMC = __commonJS({
|
|
|
284523
283962
|
throw err;
|
|
284524
283963
|
}
|
|
284525
283964
|
}
|
|
284526
|
-
var import_read_all_rows = require_read_all_rows$1.require_read_all_rows();
|
|
284527
|
-
var BACKUP_ENCRYPTION_KEYS_COLLECTION = "backup_encryption_keys";
|
|
284528
|
-
var COLUMNS$1 = [
|
|
284529
|
-
{
|
|
284530
|
-
name: "key_id",
|
|
284531
|
-
type: "TEXT",
|
|
284532
|
-
primaryKey: true
|
|
284533
|
-
},
|
|
284534
|
-
{
|
|
284535
|
-
name: "public_key",
|
|
284536
|
-
type: "TEXT",
|
|
284537
|
-
notNull: true
|
|
284538
|
-
},
|
|
284539
|
-
{
|
|
284540
|
-
name: "created_at",
|
|
284541
|
-
type: "INTEGER",
|
|
284542
|
-
notNull: true
|
|
284543
|
-
},
|
|
284544
|
-
{
|
|
284545
|
-
name: "retired_at",
|
|
284546
|
-
type: "INTEGER"
|
|
284547
|
-
}
|
|
284548
|
-
];
|
|
284549
|
-
var BackupEncryptionKeyStore = class {
|
|
284550
|
-
store;
|
|
284551
|
-
now;
|
|
284552
|
-
declared = false;
|
|
284553
|
-
keysKind;
|
|
284554
|
-
constructor(store, now = Date.now, keysKind = null) {
|
|
284555
|
-
this.store = store;
|
|
284556
|
-
this.now = now;
|
|
284557
|
-
this.keysKind = keysKind;
|
|
284558
|
-
}
|
|
284559
|
-
async ensureDeclared() {
|
|
284560
|
-
if (this.keysKind !== null) return;
|
|
284561
|
-
if (this.declared) return;
|
|
284562
|
-
await this.store.declareCollection({
|
|
284563
|
-
collection: BACKUP_ENCRYPTION_KEYS_COLLECTION,
|
|
284564
|
-
columns: COLUMNS$1
|
|
284565
|
-
});
|
|
284566
|
-
this.declared = true;
|
|
284567
|
-
}
|
|
284568
|
-
/** Every key, newest first. */
|
|
284569
|
-
async list() {
|
|
284570
|
-
await this.ensureDeclared();
|
|
284571
|
-
const kind = this.keysKind;
|
|
284572
|
-
if (kind !== null) {
|
|
284573
|
-
const rows2 = await (0, import_read_all_rows.readAllRows)(kind);
|
|
284574
|
-
rows2.sort((a, b2) => b2.data.createdAt - a.data.createdAt);
|
|
284575
|
-
const out2 = [];
|
|
284576
|
-
for (const row of rows2) {
|
|
284577
|
-
const record = bodyToRecord(row.id, row.data);
|
|
284578
|
-
if (record !== null) out2.push(record);
|
|
284579
|
-
}
|
|
284580
|
-
return out2;
|
|
284581
|
-
}
|
|
284582
|
-
const rows = await this.store.query({
|
|
284583
|
-
collection: BACKUP_ENCRYPTION_KEYS_COLLECTION,
|
|
284584
|
-
filter: { orderBy: {
|
|
284585
|
-
field: "created_at",
|
|
284586
|
-
direction: "desc"
|
|
284587
|
-
} }
|
|
284588
|
-
});
|
|
284589
|
-
const out = [];
|
|
284590
|
-
for (const row of rows) {
|
|
284591
|
-
const record = toRecord(row.data);
|
|
284592
|
-
if (record !== null) out.push(record);
|
|
284593
|
-
}
|
|
284594
|
-
return out;
|
|
284595
|
-
}
|
|
284596
|
-
/** The key new archives are encrypted to; `null` = encryption off. */
|
|
284597
|
-
async active() {
|
|
284598
|
-
return (await this.list()).find((k) => k.retiredAt === null) ?? null;
|
|
284599
|
-
}
|
|
284600
|
-
/** Make `publicKey` the active key; the previous one is retired, kept listed. */
|
|
284601
|
-
async activate(input) {
|
|
284602
|
-
const parsed = parseBackupPublicKey(input.publicKey);
|
|
284603
|
-
const t = this.now();
|
|
284604
|
-
await this.retireActive(t);
|
|
284605
|
-
const record = {
|
|
284606
|
-
keyId: parsed.keyId,
|
|
284607
|
-
publicKey: input.publicKey.trim(),
|
|
284608
|
-
createdAt: t,
|
|
284609
|
-
retiredAt: null
|
|
284610
|
-
};
|
|
284611
|
-
await this.write(record);
|
|
284612
|
-
return record;
|
|
284613
|
-
}
|
|
284614
|
-
/** Encryption off: the active key is retired. Archives already made keep needing it. */
|
|
284615
|
-
async disable() {
|
|
284616
|
-
await this.retireActive(this.now());
|
|
284617
|
-
}
|
|
284618
|
-
async retireActive(at2) {
|
|
284619
|
-
for (const key of await this.list()) if (key.retiredAt === null) await this.write({
|
|
284620
|
-
...key,
|
|
284621
|
-
retiredAt: at2
|
|
284622
|
-
});
|
|
284623
|
-
}
|
|
284624
|
-
async write(record) {
|
|
284625
|
-
await this.ensureDeclared();
|
|
284626
|
-
const kind = this.keysKind;
|
|
284627
|
-
if (kind !== null) {
|
|
284628
|
-
const body = {
|
|
284629
|
-
keyId: record.keyId,
|
|
284630
|
-
publicKey: record.publicKey,
|
|
284631
|
-
createdAt: record.createdAt,
|
|
284632
|
-
retiredAt: record.retiredAt
|
|
284633
|
-
};
|
|
284634
|
-
const data = backupOrchestratorRecordKinds["encryption-keys"].schema.parse(body);
|
|
284635
|
-
await kind.put({
|
|
284636
|
-
id: record.keyId,
|
|
284637
|
-
data
|
|
284638
|
-
});
|
|
284639
|
-
return;
|
|
284640
|
-
}
|
|
284641
|
-
await this.store.deleteWhere({
|
|
284642
|
-
collection: BACKUP_ENCRYPTION_KEYS_COLLECTION,
|
|
284643
|
-
filter: { where: { key_id: record.keyId } }
|
|
284644
|
-
});
|
|
284645
|
-
await this.store.insert({
|
|
284646
|
-
collection: BACKUP_ENCRYPTION_KEYS_COLLECTION,
|
|
284647
|
-
record: {
|
|
284648
|
-
id: record.keyId,
|
|
284649
|
-
data: {
|
|
284650
|
-
key_id: record.keyId,
|
|
284651
|
-
public_key: record.publicKey,
|
|
284652
|
-
created_at: record.createdAt,
|
|
284653
|
-
retired_at: record.retiredAt
|
|
284654
|
-
}
|
|
284655
|
-
}
|
|
284656
|
-
});
|
|
284657
|
-
}
|
|
284658
|
-
};
|
|
284659
|
-
function bodyToRecord(keyId, body) {
|
|
284660
|
-
if (!keyId) return null;
|
|
284661
|
-
return {
|
|
284662
|
-
keyId: body.keyId,
|
|
284663
|
-
publicKey: body.publicKey,
|
|
284664
|
-
createdAt: body.createdAt,
|
|
284665
|
-
retiredAt: body.retiredAt
|
|
284666
|
-
};
|
|
284667
|
-
}
|
|
284668
|
-
function toRecord(row) {
|
|
284669
|
-
const keyId = row["key_id"];
|
|
284670
|
-
const publicKey = row["public_key"];
|
|
284671
|
-
const createdAt = row["created_at"];
|
|
284672
|
-
if (typeof keyId !== "string" || typeof publicKey !== "string") return null;
|
|
284673
|
-
const retired = row["retired_at"];
|
|
284674
|
-
return {
|
|
284675
|
-
keyId,
|
|
284676
|
-
publicKey,
|
|
284677
|
-
createdAt: typeof createdAt === "number" ? createdAt : Number(createdAt ?? 0),
|
|
284678
|
-
retiredAt: typeof retired === "number" ? retired : null
|
|
284679
|
-
};
|
|
284680
|
-
}
|
|
284681
|
-
var BACKUP_SEED_MARKERS_COLLECTION = "backup_seed_markers";
|
|
284682
|
-
var COLUMNS = [{
|
|
284683
|
-
name: "seed_id",
|
|
284684
|
-
type: "TEXT",
|
|
284685
|
-
primaryKey: true
|
|
284686
|
-
}, {
|
|
284687
|
-
name: "seeded_at",
|
|
284688
|
-
type: "INTEGER",
|
|
284689
|
-
notNull: true
|
|
284690
|
-
}];
|
|
284691
|
-
var BackupSeedMarkerStore = class {
|
|
284692
|
-
store;
|
|
284693
|
-
now;
|
|
284694
|
-
declared = false;
|
|
284695
|
-
markersKind;
|
|
284696
|
-
constructor(store, now = Date.now, markersKind = null) {
|
|
284697
|
-
this.store = store;
|
|
284698
|
-
this.now = now;
|
|
284699
|
-
this.markersKind = markersKind;
|
|
284700
|
-
}
|
|
284701
|
-
async ensureDeclared() {
|
|
284702
|
-
if (this.markersKind !== null) return;
|
|
284703
|
-
if (this.declared) return;
|
|
284704
|
-
await this.store.declareCollection({
|
|
284705
|
-
collection: BACKUP_SEED_MARKERS_COLLECTION,
|
|
284706
|
-
columns: COLUMNS
|
|
284707
|
-
});
|
|
284708
|
-
this.declared = true;
|
|
284709
|
-
}
|
|
284710
|
-
async has(seedId) {
|
|
284711
|
-
await this.ensureDeclared();
|
|
284712
|
-
const kind = this.markersKind;
|
|
284713
|
-
if (kind !== null) return await kind.get(seedId) !== null;
|
|
284714
|
-
return (await this.store.query({
|
|
284715
|
-
collection: BACKUP_SEED_MARKERS_COLLECTION,
|
|
284716
|
-
filter: {
|
|
284717
|
-
where: { seed_id: seedId },
|
|
284718
|
-
limit: 1
|
|
284719
|
-
}
|
|
284720
|
-
})).length > 0;
|
|
284721
|
-
}
|
|
284722
|
-
async mark(seedId) {
|
|
284723
|
-
await this.ensureDeclared();
|
|
284724
|
-
if (await this.has(seedId)) return;
|
|
284725
|
-
const kind = this.markersKind;
|
|
284726
|
-
if (kind !== null) {
|
|
284727
|
-
const body = { seededAt: this.now() };
|
|
284728
|
-
const data = backupOrchestratorRecordKinds["seed-markers"].schema.parse(body);
|
|
284729
|
-
await kind.put({
|
|
284730
|
-
id: seedId,
|
|
284731
|
-
data
|
|
284732
|
-
});
|
|
284733
|
-
return;
|
|
284734
|
-
}
|
|
284735
|
-
await this.store.insert({
|
|
284736
|
-
collection: BACKUP_SEED_MARKERS_COLLECTION,
|
|
284737
|
-
record: {
|
|
284738
|
-
id: seedId,
|
|
284739
|
-
data: {
|
|
284740
|
-
seed_id: seedId,
|
|
284741
|
-
seeded_at: this.now()
|
|
284742
|
-
}
|
|
284743
|
-
}
|
|
284744
|
-
});
|
|
284745
|
-
}
|
|
284746
|
-
};
|
|
284747
|
-
var BACKUP_SCHEDULES_LEGACY = "backup_schedules";
|
|
284748
|
-
var BACKUP_DESTINATION_POLICIES_LEGACY = "backup_destination_policies";
|
|
284749
|
-
var BackupScheduleBodySchema = zod.z.object({
|
|
284750
|
-
label: zod.z.string(),
|
|
284751
|
-
cron: zod.z.string(),
|
|
284752
|
-
enabled: zod.z.boolean(),
|
|
284753
|
-
locationIds: zod.z.array(zod.z.string()).readonly(),
|
|
284754
|
-
retentionCount: zod.z.number(),
|
|
284755
|
-
dataSources: zod.z.array(zod.z.string()).readonly().optional(),
|
|
284756
|
-
databases: zod.z.array(require_dist10.DataStoreDatabaseSchema).readonly().optional(),
|
|
284757
|
-
lastAttemptAt: zod.z.number().optional(),
|
|
284758
|
-
lastSuccessAt: zod.z.number().optional(),
|
|
284759
|
-
lastError: zod.z.string().optional()
|
|
284760
|
-
});
|
|
284761
|
-
var BackupDestinationPolicyBodySchema = zod.z.object({
|
|
284762
|
-
enabled: zod.z.boolean(),
|
|
284763
|
-
retentionCount: zod.z.number(),
|
|
284764
|
-
label: zod.z.string().optional(),
|
|
284765
|
-
lastAttemptAt: zod.z.number().optional(),
|
|
284766
|
-
lastError: zod.z.string().optional()
|
|
284767
|
-
});
|
|
284768
|
-
var BackupEncryptionKeyBodySchema = zod.z.object({
|
|
284769
|
-
keyId: zod.z.string(),
|
|
284770
|
-
publicKey: zod.z.string(),
|
|
284771
|
-
createdAt: zod.z.number(),
|
|
284772
|
-
retiredAt: zod.z.number().nullable()
|
|
284773
|
-
});
|
|
284774
|
-
var BackupSeedMarkerBodySchema = zod.z.object({ seededAt: zod.z.number() });
|
|
284775
|
-
var _backupOrchestratorRecordKinds = require_dist10.defineRecordKinds({
|
|
284776
|
-
schedules: {
|
|
284777
|
-
schema: BackupScheduleBodySchema,
|
|
284778
|
-
class: "config",
|
|
284779
|
-
writeTrigger: "operator upsert/delete; orchestrator stamps lastAttempt/success/error",
|
|
284780
|
-
device: "none",
|
|
284781
|
-
at: "none",
|
|
284782
|
-
indexes: [{
|
|
284783
|
-
name: "enabled",
|
|
284784
|
-
fields: ["enabled"]
|
|
284785
|
-
}],
|
|
284786
|
-
retention: { none: "operator delete only" },
|
|
284787
|
-
adoptsFrom: BACKUP_SCHEDULES_LEGACY,
|
|
284788
|
-
entry: {
|
|
284789
|
-
title: "Backup schedules",
|
|
284790
|
-
nameField: "label"
|
|
284791
|
-
}
|
|
284792
|
-
},
|
|
284793
|
-
"destination-policies": {
|
|
284794
|
-
schema: BackupDestinationPolicyBodySchema,
|
|
284795
|
-
class: "config",
|
|
284796
|
-
writeTrigger: "ensureDefault, operator upsert, recordAttempt after each archive write",
|
|
284797
|
-
device: "none",
|
|
284798
|
-
at: "none",
|
|
284799
|
-
retention: { none: "row outlives location; ensureDefault recreates" },
|
|
284800
|
-
adoptsFrom: BACKUP_DESTINATION_POLICIES_LEGACY
|
|
284801
|
-
},
|
|
284802
|
-
"encryption-keys": {
|
|
284803
|
-
schema: BackupEncryptionKeyBodySchema,
|
|
284804
|
-
class: "config",
|
|
284805
|
-
writeTrigger: "setupEncryption activate; disableEncryption retires active row",
|
|
284806
|
-
device: "none",
|
|
284807
|
-
at: "none",
|
|
284808
|
-
retention: { none: "retired keys kept for archive decryption hints" },
|
|
284809
|
-
adoptsFrom: BACKUP_ENCRYPTION_KEYS_COLLECTION
|
|
284810
|
-
},
|
|
284811
|
-
"seed-markers": {
|
|
284812
|
-
schema: BackupSeedMarkerBodySchema,
|
|
284813
|
-
class: "config",
|
|
284814
|
-
writeTrigger: "mark() once per seed id after seed landed",
|
|
284815
|
-
device: "none",
|
|
284816
|
-
at: "none",
|
|
284817
|
-
retention: { none: "one row per seed id ever" },
|
|
284818
|
-
adoptsFrom: BACKUP_SEED_MARKERS_COLLECTION
|
|
284819
|
-
}
|
|
284820
|
-
});
|
|
284821
|
-
var backupOrchestratorRecordKinds = _backupOrchestratorRecordKinds;
|
|
284822
|
-
var backupSchedulesRecordKind = _backupOrchestratorRecordKinds.schedules;
|
|
284823
|
-
var backupDestinationPoliciesRecordKind = _backupOrchestratorRecordKinds["destination-policies"];
|
|
284824
|
-
var backupEncryptionKeysRecordKind = _backupOrchestratorRecordKinds["encryption-keys"];
|
|
284825
|
-
var backupSeedMarkersRecordKind = _backupOrchestratorRecordKinds["seed-markers"];
|
|
284826
|
-
function backupRecordStoresOf(records) {
|
|
284827
|
-
return {
|
|
284828
|
-
schedules: records.kind(backupSchedulesRecordKind),
|
|
284829
|
-
destinationPolicies: records.kind(backupDestinationPoliciesRecordKind),
|
|
284830
|
-
encryptionKeys: records.kind(backupEncryptionKeysRecordKind),
|
|
284831
|
-
seedMarkers: records.kind(backupSeedMarkersRecordKind)
|
|
284832
|
-
};
|
|
284833
|
-
}
|
|
284834
283965
|
var Mr = Object.defineProperty;
|
|
284835
283966
|
var Br = (s, t) => {
|
|
284836
283967
|
for (var e in t) Mr(s, e, {
|
|
@@ -288806,12 +287937,6 @@ var require_restore_archive_FyfZ8YMC = __commonJS({
|
|
|
288806
287937
|
return BackupDecryptError;
|
|
288807
287938
|
}
|
|
288808
287939
|
});
|
|
288809
|
-
Object.defineProperty(exports, "BackupEncryptionKeyStore", {
|
|
288810
|
-
enumerable: true,
|
|
288811
|
-
get: function() {
|
|
288812
|
-
return BackupEncryptionKeyStore;
|
|
288813
|
-
}
|
|
288814
|
-
});
|
|
288815
287940
|
Object.defineProperty(exports, "BackupKeyFormatError", {
|
|
288816
287941
|
enumerable: true,
|
|
288817
287942
|
get: function() {
|
|
@@ -288830,12 +287955,6 @@ var require_restore_archive_FyfZ8YMC = __commonJS({
|
|
|
288830
287955
|
return BackupKeyRequiredError;
|
|
288831
287956
|
}
|
|
288832
287957
|
});
|
|
288833
|
-
Object.defineProperty(exports, "BackupSeedMarkerStore", {
|
|
288834
|
-
enumerable: true,
|
|
288835
|
-
get: function() {
|
|
288836
|
-
return BackupSeedMarkerStore;
|
|
288837
|
-
}
|
|
288838
|
-
});
|
|
288839
287958
|
Object.defineProperty(exports, "BackupSnapshotRefusedError", {
|
|
288840
287959
|
enumerable: true,
|
|
288841
287960
|
get: function() {
|
|
@@ -288878,6 +287997,12 @@ var require_restore_archive_FyfZ8YMC = __commonJS({
|
|
|
288878
287997
|
return generateBackupKeyPair;
|
|
288879
287998
|
}
|
|
288880
287999
|
});
|
|
288000
|
+
Object.defineProperty(exports, "parseBackupPublicKey", {
|
|
288001
|
+
enumerable: true,
|
|
288002
|
+
get: function() {
|
|
288003
|
+
return parseBackupPublicKey;
|
|
288004
|
+
}
|
|
288005
|
+
});
|
|
288881
288006
|
Object.defineProperty(exports, "parseBackupSecretKey", {
|
|
288882
288007
|
enumerable: true,
|
|
288883
288008
|
get: function() {
|
|
@@ -295642,9 +294767,9 @@ var require_dist3 = __commonJS({
|
|
|
295642
294767
|
"use strict";
|
|
295643
294768
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
295644
294769
|
var require_chunk = require_chunk_Cek0wNdY();
|
|
295645
|
-
var require_dist10 =
|
|
294770
|
+
var require_dist10 = require_dist_Bn_RNanh();
|
|
295646
294771
|
var require_read_all_rows$1 = require_read_all_rows_CVoO1ONM();
|
|
295647
|
-
var require_device_ca =
|
|
294772
|
+
var require_device_ca = require_device_ca_CPTDs_d();
|
|
295648
294773
|
var require_builtins_alerts_alerts_addon = require_alerts_addon();
|
|
295649
294774
|
require_alerts();
|
|
295650
294775
|
var require_builtins_calendars_calendars_addon = require_calendars_addon();
|
|
@@ -295670,21 +294795,21 @@ var require_dist3 = __commonJS({
|
|
|
295670
294795
|
var require_builtins_native_metrics_native_metrics_addon = require_native_metrics_addon();
|
|
295671
294796
|
var require_builtins_device_history_device_history_addon = require_device_history_addon();
|
|
295672
294797
|
var require_builtins_sqlite_storage_filesystem_storage_addon = require_filesystem_storage_addon();
|
|
295673
|
-
var require_wal_maintenance =
|
|
294798
|
+
var require_wal_maintenance = require_wal_maintenance_DUHEp_09();
|
|
295674
294799
|
var require_builtins_sqlite_storage_sqlite_settings_addon = require_sqlite_settings_addon();
|
|
295675
294800
|
var require_builtins_sqlite_storage_index = require_sqlite_storage();
|
|
295676
294801
|
var require_builtins_storage_orchestrator_storage_orchestrator_addon = require_storage_orchestrator_addon();
|
|
295677
294802
|
require_storage_orchestrator();
|
|
295678
|
-
var
|
|
295679
|
-
var
|
|
294803
|
+
var require_agent_https = require_agent_https_Dnr_nIVx();
|
|
294804
|
+
var require_constants15 = require_constants_6OeJiZgi();
|
|
295680
294805
|
var require_builtins_system_config_system_config_addon = require_system_config_addon();
|
|
295681
294806
|
require_system_config();
|
|
295682
294807
|
var require_builtins_winston_logging_index = require_winston_logging();
|
|
295683
294808
|
var require_custom_action_registry = require_custom_action_registry_COyb49zm();
|
|
295684
|
-
var require_hub_mdns_ciao =
|
|
294809
|
+
var require_hub_mdns_ciao = require_hub_mdns_ciao_CTBTlia4();
|
|
295685
294810
|
var require_platform_key_source = require_platform_key_source_Di7HrlGR();
|
|
295686
294811
|
var require_resource_monitor = require_resource_monitor_mio9dSCT();
|
|
295687
|
-
var require_restore_archive =
|
|
294812
|
+
var require_restore_archive = require_restore_archive_DM1OBYq4();
|
|
295688
294813
|
var require_coral_accelerators = require_coral_accelerators_Bi_c3Rft();
|
|
295689
294814
|
var zod = require_zod();
|
|
295690
294815
|
var node_crypto = __require("crypto");
|
|
@@ -299676,8 +298801,7 @@ var require_dist3 = __commonJS({
|
|
|
299676
298801
|
name: "addon_id",
|
|
299677
298802
|
fields: ["addonId"]
|
|
299678
298803
|
}],
|
|
299679
|
-
retention: { none: "deleteIntegration only" }
|
|
299680
|
-
adoptsFrom: INTEGRATIONS_LEGACY
|
|
298804
|
+
retention: { none: "deleteIntegration only" }
|
|
299681
298805
|
},
|
|
299682
298806
|
"integration-settings": {
|
|
299683
298807
|
schema: IntegrationSettingBodySchema,
|
|
@@ -299689,8 +298813,7 @@ var require_dist3 = __commonJS({
|
|
|
299689
298813
|
name: "integration_id",
|
|
299690
298814
|
fields: ["integrationId"]
|
|
299691
298815
|
}],
|
|
299692
|
-
retention: { none: "cascade on deleteIntegration" }
|
|
299693
|
-
adoptsFrom: INTEGRATION_SETTINGS_LEGACY
|
|
298816
|
+
retention: { none: "cascade on deleteIntegration" }
|
|
299694
298817
|
}
|
|
299695
298818
|
});
|
|
299696
298819
|
var integrationRegistryRecordKinds = _integrationRegistryRecordKinds;
|
|
@@ -300128,8 +299251,7 @@ var require_dist3 = __commonJS({
|
|
|
300128
299251
|
name: "last_active",
|
|
300129
299252
|
fields: ["at"]
|
|
300130
299253
|
}],
|
|
300131
|
-
retention: { none: "rows removed only by operator forget(nodeId)" }
|
|
300132
|
-
adoptsFrom: CLUSTER_NODE_HISTORY_COLLECTION
|
|
299254
|
+
retention: { none: "rows removed only by operator forget(nodeId)" }
|
|
300133
299255
|
} });
|
|
300134
299256
|
var clusterAgentRecordKinds = _clusterAgentRecordKinds;
|
|
300135
299257
|
var clusterNodeHistoryRecordKind = _clusterAgentRecordKinds["node-history"];
|
|
@@ -318502,14 +317624,14 @@ var require_dist3 = __commonJS({
|
|
|
318502
317624
|
exports.MESH_CA_FIELD = require_constants15.MESH_CA_FIELD;
|
|
318503
317625
|
exports.MESH_CA_KEY_REF = require_constants15.MESH_CA_KEY_REF;
|
|
318504
317626
|
exports.MESH_CA_SETTINGS_KEY = require_constants15.MESH_CA_SETTINGS_KEY;
|
|
318505
|
-
exports.MESH_NODE_CERTIFICATES_COLLECTION =
|
|
318506
|
-
exports.MESH_NODE_CERTIFICATES_COLUMNS =
|
|
317627
|
+
exports.MESH_NODE_CERTIFICATES_COLLECTION = require_builtins_system_config_system_config_addon.MESH_NODE_CERTIFICATES_COLLECTION;
|
|
317628
|
+
exports.MESH_NODE_CERTIFICATES_COLUMNS = require_builtins_system_config_system_config_addon.MESH_NODE_CERTIFICATES_COLUMNS;
|
|
318507
317629
|
exports.MESH_NODE_UNAUTHENTICATED_TYPE = MESH_NODE_UNAUTHENTICATED_TYPE;
|
|
318508
317630
|
exports.MESH_QUEUE_TOP_N = MESH_QUEUE_TOP_N;
|
|
318509
317631
|
exports.MESH_TLS_PORT_HELLO_FIELD = require_builtins_system_config_system_config_addon.MESH_TLS_PORT_HELLO_FIELD;
|
|
318510
317632
|
exports.METHOD_ACCESS_MAP = require_dist10.METHOD_ACCESS_MAP;
|
|
318511
317633
|
exports.MeshCaKeeper = require_builtins_system_config_system_config_addon.MeshCaKeeper;
|
|
318512
|
-
exports.MeshCertificateRegistry =
|
|
317634
|
+
exports.MeshCertificateRegistry = require_builtins_system_config_system_config_addon.MeshCertificateRegistry;
|
|
318513
317635
|
exports.MeshCrl = require_builtins_system_config_system_config_addon.MeshCrl;
|
|
318514
317636
|
exports.MeshIdentityGate = MeshIdentityGate;
|
|
318515
317637
|
exports.ModelDownloadService = require_custom_action_registry.ModelDownloadService;
|
|
@@ -318546,7 +317668,7 @@ var require_dist3 = __commonJS({
|
|
|
318546
317668
|
exports.PythonEnvManager = PythonEnvManager;
|
|
318547
317669
|
exports.QUARANTINE_DIRNAME = QUARANTINE_DIRNAME;
|
|
318548
317670
|
exports.REFRESH_TOKEN_PREFIX = require_builtins_local_auth_local_auth_addon.REFRESH_TOKEN_PREFIX;
|
|
318549
|
-
exports.RENEWAL_ABANDONED =
|
|
317671
|
+
exports.RENEWAL_ABANDONED = require_builtins_system_config_system_config_addon.RENEWAL_ABANDONED;
|
|
318550
317672
|
exports.RESTART_MARKER_FILE = RESTART_MARKER_FILE;
|
|
318551
317673
|
exports.RSS_BUDGET_REANNOUNCE_MIN_MS = RSS_BUDGET_REANNOUNCE_MIN_MS;
|
|
318552
317674
|
exports.RSS_BUDGET_RELEASE_RATIO = RSS_BUDGET_RELEASE_RATIO;
|
|
@@ -318636,8 +317758,8 @@ var require_dist3 = __commonJS({
|
|
|
318636
317758
|
exports.buildStorageLocationRegistry = require_builtins_storage_orchestrator_storage_orchestrator_addon.buildStorageLocationRegistry;
|
|
318637
317759
|
exports.buildTransporter = buildTransporter;
|
|
318638
317760
|
exports.builderMountedCapNames = builderMountedCapNames;
|
|
318639
|
-
exports.caFingerprint =
|
|
318640
|
-
exports.caFingerprintCompact =
|
|
317761
|
+
exports.caFingerprint = require_builtins_system_config_system_config_addon.caFingerprint;
|
|
317762
|
+
exports.caFingerprintCompact = require_builtins_system_config_system_config_addon.caFingerprintCompact;
|
|
318641
317763
|
exports.caReplacementMarkerFile = require_hub_mdns_ciao.caReplacementMarkerFile;
|
|
318642
317764
|
exports.callRegisterNodeWithRetry = callRegisterNodeWithRetry;
|
|
318643
317765
|
exports.callWithServiceDiscovery = callWithServiceDiscovery;
|
|
@@ -318699,7 +317821,7 @@ var require_dist3 = __commonJS({
|
|
|
318699
317821
|
exports.createLocalTransport = createLocalTransport;
|
|
318700
317822
|
exports.createLoopDelayMeter = createLoopDelayMeter;
|
|
318701
317823
|
exports.createMeshAccessMiddleware = createMeshAccessMiddleware;
|
|
318702
|
-
exports.createMeshCsrPem =
|
|
317824
|
+
exports.createMeshCsrPem = require_builtins_system_config_system_config_addon.createMeshCsrPem;
|
|
318703
317825
|
exports.createMeshQueueReader = createMeshQueueReader;
|
|
318704
317826
|
exports.createOutboundQueueGate = createOutboundQueueGate;
|
|
318705
317827
|
exports.createParentUnownedCallHandler = createParentUnownedCallHandler;
|
|
@@ -318722,7 +317844,7 @@ var require_dist3 = __commonJS({
|
|
|
318722
317844
|
exports.deriveAgentListenPort = deriveAgentListenPort;
|
|
318723
317845
|
exports.describeCsr = require_builtins_system_config_system_config_addon.describeCsr;
|
|
318724
317846
|
exports.describeHttpsLeaf = require_agent_https.describeHttpsLeaf;
|
|
318725
|
-
exports.describeMeshLeaf =
|
|
317847
|
+
exports.describeMeshLeaf = require_builtins_system_config_system_config_addon.describeMeshLeaf;
|
|
318726
317848
|
exports.describeProviderKindDrift = describeProviderKindDrift;
|
|
318727
317849
|
exports.describeRss = describeRss;
|
|
318728
317850
|
exports.detectWorkspacePackagesDir = detectWorkspacePackagesDir;
|
|
@@ -318771,7 +317893,7 @@ var require_dist3 = __commonJS({
|
|
|
318771
317893
|
exports.ensureTlsCert = require_hub_mdns_ciao.ensureTlsCert;
|
|
318772
317894
|
exports.evaluateExistingCert = require_agent_https.evaluateExistingCert;
|
|
318773
317895
|
exports.expandCapMethods = require_dist10.expandCapMethods;
|
|
318774
|
-
exports.exportMeshPrivateKeyPem =
|
|
317896
|
+
exports.exportMeshPrivateKeyPem = require_builtins_system_config_system_config_addon.exportMeshPrivateKeyPem;
|
|
318775
317897
|
exports.fetchJson = require_custom_action_registry.fetchJson;
|
|
318776
317898
|
exports.filterIsEmpty = require_log_read_filter.filterIsEmpty;
|
|
318777
317899
|
exports.findAddonRefusal = findAddonRefusal;
|
|
@@ -318790,8 +317912,8 @@ var require_dist3 = __commonJS({
|
|
|
318790
317912
|
exports.formatSocketPlane = formatSocketPlane;
|
|
318791
317913
|
exports.generateBackupKeyPair = require_restore_archive.generateBackupKeyPair;
|
|
318792
317914
|
exports.generateDeviceCa = require_device_ca.generateDeviceCa;
|
|
318793
|
-
exports.generateMeshCa =
|
|
318794
|
-
exports.generateMeshKeyPair =
|
|
317915
|
+
exports.generateMeshCa = require_builtins_system_config_system_config_addon.generateMeshCa;
|
|
317916
|
+
exports.generateMeshKeyPair = require_builtins_system_config_system_config_addon.generateMeshKeyPair;
|
|
318795
317917
|
exports.getBrokerEventBus = getBrokerEventBus;
|
|
318796
317918
|
exports.getBrokerTlsTransporter = getBrokerTlsTransporter;
|
|
318797
317919
|
exports.getCapUsageRegistry = getCapUsageRegistry;
|
|
@@ -318818,7 +317940,7 @@ var require_dist3 = __commonJS({
|
|
|
318818
317940
|
exports.getProcessAgentHttpsNames = require_agent_https.getProcessAgentHttpsNames;
|
|
318819
317941
|
exports.getProcessJwtSigningKeyState = require_device_ca.getProcessJwtSigningKeyState;
|
|
318820
317942
|
exports.getProcessMeshCaState = require_builtins_system_config_system_config_addon.getProcessMeshCaState;
|
|
318821
|
-
exports.getProcessMeshCertificateRegistry =
|
|
317943
|
+
exports.getProcessMeshCertificateRegistry = require_builtins_system_config_system_config_addon.getProcessMeshCertificateRegistry;
|
|
318822
317944
|
exports.getProcessMeshTlsListenerState = require_builtins_system_config_system_config_addon.getProcessMeshTlsListenerState;
|
|
318823
317945
|
exports.getProcessNodeMeshTransport = require_builtins_system_config_system_config_addon.getProcessNodeMeshTransport;
|
|
318824
317946
|
exports.getProcessPeerLeaf = require_builtins_system_config_system_config_addon.getProcessPeerLeaf;
|
|
@@ -318876,12 +317998,12 @@ var require_dist3 = __commonJS({
|
|
|
318876
317998
|
exports.isRemoteForbiddenOnAgent = isRemoteForbiddenOnAgent;
|
|
318877
317999
|
exports.isSettingsReadUnavailable = require_builtins_local_auth_local_auth_addon.isSettingsReadUnavailable;
|
|
318878
318000
|
exports.isSourceNewer = isSourceNewer;
|
|
318879
|
-
exports.isValidAgentNodeId =
|
|
318001
|
+
exports.isValidAgentNodeId = require_builtins_system_config_system_config_addon.isValidAgentNodeId;
|
|
318880
318002
|
exports.isolatedBuiltinPhase = isolatedBuiltinPhase;
|
|
318881
318003
|
exports.issueAgentHttpsLeaf = require_agent_https.issueAgentHttpsLeaf;
|
|
318882
318004
|
exports.issueDeviceLeaf = require_device_ca.issueDeviceLeaf;
|
|
318883
|
-
exports.issueMeshLeafForNode =
|
|
318884
|
-
exports.issueMeshLeafFromCsr =
|
|
318005
|
+
exports.issueMeshLeafForNode = require_builtins_system_config_system_config_addon.issueMeshLeafForNode;
|
|
318006
|
+
exports.issueMeshLeafFromCsr = require_builtins_system_config_system_config_addon.issueMeshLeafFromCsr;
|
|
318885
318007
|
exports.keyFingerprintShort = require_builtins_system_config_system_config_addon.keyFingerprintShort;
|
|
318886
318008
|
exports.leafFingerprintOf = require_hub_mdns_ciao.leafFingerprintOf;
|
|
318887
318009
|
exports.levelRank = require_log_read_filter.levelRank;
|
|
@@ -318889,7 +318011,7 @@ var require_dist3 = __commonJS({
|
|
|
318889
318011
|
exports.lineMatches = require_log_read_filter.lineMatches;
|
|
318890
318012
|
exports.loadAgentHttps = require_agent_https.loadAgentHttps;
|
|
318891
318013
|
exports.loadDeviceCa = require_device_ca.loadDeviceCa;
|
|
318892
|
-
exports.loadMeshCa =
|
|
318014
|
+
exports.loadMeshCa = require_builtins_system_config_system_config_addon.loadMeshCa;
|
|
318893
318015
|
exports.loadTlsCert = require_hub_mdns_ciao.loadTlsCert;
|
|
318894
318016
|
exports.localCaCommonName = require_agent_https.localCaCommonName;
|
|
318895
318017
|
exports.localEndpointPath = localEndpointPath;
|
|
@@ -318981,7 +318103,7 @@ var require_dist3 = __commonJS({
|
|
|
318981
318103
|
exports.setNodeEventInterest = setNodeEventInterest;
|
|
318982
318104
|
exports.setPlatformKeychainKey = require_platform_key_source.setPlatformKeychainKey;
|
|
318983
318105
|
exports.setProcessAgentHttpsNames = require_agent_https.setProcessAgentHttpsNames;
|
|
318984
|
-
exports.setProcessMeshCertificateRegistry =
|
|
318106
|
+
exports.setProcessMeshCertificateRegistry = require_builtins_system_config_system_config_addon.setProcessMeshCertificateRegistry;
|
|
318985
318107
|
exports.setProcessMeshPeerTransportLookup = require_builtins_system_config_system_config_addon.setProcessMeshPeerTransportLookup;
|
|
318986
318108
|
exports.setProcessMeshTlsEnabler = require_builtins_system_config_system_config_addon.setProcessMeshTlsEnabler;
|
|
318987
318109
|
exports.setProcessMeshTlsListenerState = require_builtins_system_config_system_config_addon.setProcessMeshTlsListenerState;
|
|
@@ -319241,7 +318363,7 @@ var require_dist4 = __commonJS({
|
|
|
319241
318363
|
"../types/dist/index.js"(exports) {
|
|
319242
318364
|
"use strict";
|
|
319243
318365
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
319244
|
-
var require_sleep =
|
|
318366
|
+
var require_sleep = require_sleep_gRQc2IoX();
|
|
319245
318367
|
var require_event_category = require_event_category_eSqkye_K();
|
|
319246
318368
|
var require_composition = require_composition_eoYYVfOp();
|
|
319247
318369
|
var require_node_color2 = require_node_color();
|
|
@@ -329582,11 +328704,12 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
|
|
|
329582
328704
|
kindId: zod.z.number().int(),
|
|
329583
328705
|
state: RecordKindStateSchema,
|
|
329584
328706
|
createdIndexes: zod.z.array(zod.z.string()),
|
|
329585
|
-
/**
|
|
329586
|
-
|
|
329587
|
-
|
|
329588
|
-
|
|
329589
|
-
|
|
328707
|
+
/**
|
|
328708
|
+
* RETIRED (D900): always `null`. It carried the records-migration boot guard;
|
|
328709
|
+
* it stays on the wire, null, because an addon built before the removal reads
|
|
328710
|
+
* an ABSENT field as "adoption pending" and refuses to start.
|
|
328711
|
+
*/
|
|
328712
|
+
adoptionPending: zod.z.null()
|
|
329590
328713
|
});
|
|
329591
328714
|
var SecretRefsList = zod.z.array(zod.z.string());
|
|
329592
328715
|
var RecordSecretRefsSchema = zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.string()));
|
|
@@ -329776,19 +328899,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
|
|
|
329776
328899
|
"stream-broker:rtsp-tokens",
|
|
329777
328900
|
"notification-center:device-mutes",
|
|
329778
328901
|
"recorder:recording-configs",
|
|
329779
|
-
"pipeline-orchestrator:device-features"
|
|
329780
|
-
"pipeline-analytics:stats-5m",
|
|
329781
|
-
"pipeline-orchestrator:stats-5m",
|
|
329782
|
-
"vec_object_clip",
|
|
329783
|
-
"addon-devices",
|
|
329784
|
-
"sections",
|
|
329785
|
-
"provider-settings",
|
|
329786
|
-
"device-settings",
|
|
329787
|
-
"ai:budgets",
|
|
329788
|
-
"pipeline-analytics:retrain-dataset-versions",
|
|
329789
|
-
"training:dataset-versions",
|
|
329790
|
-
"benchmark:replay-runs",
|
|
329791
|
-
"viewer-settings-snapshots"
|
|
328902
|
+
"pipeline-orchestrator:device-features"
|
|
329792
328903
|
];
|
|
329793
328904
|
var STORAGE_ADMIN_SCOPED_BASES = [
|
|
329794
328905
|
"addon-settings",
|
|
@@ -329839,42 +328950,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
|
|
|
329839
328950
|
readRecords: require_sleep.method(RecordQueryInputSchema.extend({
|
|
329840
328951
|
owner: zod.z.string().min(1),
|
|
329841
328952
|
kind: require_sleep.RecordKindNameSchema
|
|
329842
|
-
}), RecordQueryResultSchema, { auth: "admin" })
|
|
329843
|
-
/**
|
|
329844
|
-
* The migration copy path (D881): write rows into a kind AS ITS DECLARED
|
|
329845
|
-
* OWNER. Refused when that owner's manifest does not declare the kind.
|
|
329846
|
-
* Idempotent (a put by id, so a re-run resumes). A secret field carries a
|
|
329847
|
-
* keychain marker bound to the row's own ref - the operator script imports
|
|
329848
|
-
* the value first - and a plain string there is refused.
|
|
329849
|
-
*/
|
|
329850
|
-
adoptRecords: require_sleep.method(zod.z.object({
|
|
329851
|
-
owner: zod.z.string().min(1),
|
|
329852
|
-
kind: require_sleep.RecordKindNameSchema,
|
|
329853
|
-
records: zod.z.array(RecordInputSchema).max(require_sleep.RECORD_BATCH_MAX),
|
|
329854
|
-
/** The LAST batch: the copy is complete, the boot guard stops asking. */
|
|
329855
|
-
complete: zod.z.boolean().optional()
|
|
329856
|
-
}).refine((input) => input.records.length > 0 || input.complete === true, { message: "records must be non-empty unless complete is true" }), zod.z.object({ adopted: zod.z.number().int() }), {
|
|
329857
|
-
kind: "mutation",
|
|
329858
|
-
auth: "admin"
|
|
329859
|
-
}),
|
|
329860
|
-
/**
|
|
329861
|
-
* Read rows from a legacy KV table by physical name, without a running
|
|
329862
|
-
* `declareCollection`. Used by `records-adopt.ts` when the owner already
|
|
329863
|
-
* moved to records and the collection door refuses the name.
|
|
329864
|
-
*/
|
|
329865
|
-
readLegacyCollection: require_sleep.method(zod.z.object({
|
|
329866
|
-
collection: zod.z.string().min(1),
|
|
329867
|
-
cursor: zod.z.string().optional(),
|
|
329868
|
-
limit: zod.z.number().int().min(1).max(1e3).optional()
|
|
329869
|
-
}), zod.z.object({
|
|
329870
|
-
rows: zod.z.array(zod.z.object({
|
|
329871
|
-
id: zod.z.string(),
|
|
329872
|
-
data: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
329873
|
-
})),
|
|
329874
|
-
nextCursor: zod.z.string().nullable()
|
|
329875
|
-
}), { auth: "admin" }),
|
|
329876
|
-
/** True when a declared kind lists `collection` as `adoptsFrom` and adoption finished. */
|
|
329877
|
-
isAdoptedLegacyTable: require_sleep.method(zod.z.object({ collection: zod.z.string().min(1) }), zod.z.object({ adopted: zod.z.boolean() }), { auth: "admin" })
|
|
328953
|
+
}), RecordQueryResultSchema, { auth: "admin" })
|
|
329878
328954
|
}
|
|
329879
328955
|
};
|
|
329880
328956
|
var EntryKindInfoSchema = zod.z.object({
|
|
@@ -385590,6 +384666,12 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
|
|
|
385590
384666
|
addonId: null,
|
|
385591
384667
|
access: "view"
|
|
385592
384668
|
},
|
|
384669
|
+
"deviceHistory.queryMany": {
|
|
384670
|
+
capName: "device-history",
|
|
384671
|
+
capScope: "system",
|
|
384672
|
+
addonId: null,
|
|
384673
|
+
access: "view"
|
|
384674
|
+
},
|
|
385593
384675
|
"deviceHistory.queryNode": {
|
|
385594
384676
|
capName: "device-history",
|
|
385595
384677
|
capScope: "system",
|
|
@@ -390810,24 +389892,12 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
|
|
|
390810
389892
|
addonId: null,
|
|
390811
389893
|
access: "create"
|
|
390812
389894
|
},
|
|
390813
|
-
"storageAdmin.adoptRecords": {
|
|
390814
|
-
capName: "storage-admin",
|
|
390815
|
-
capScope: "system",
|
|
390816
|
-
addonId: null,
|
|
390817
|
-
access: "create"
|
|
390818
|
-
},
|
|
390819
389895
|
"storageAdmin.dropCollection": {
|
|
390820
389896
|
capName: "storage-admin",
|
|
390821
389897
|
capScope: "system",
|
|
390822
389898
|
addonId: null,
|
|
390823
389899
|
access: "delete"
|
|
390824
389900
|
},
|
|
390825
|
-
"storageAdmin.isAdoptedLegacyTable": {
|
|
390826
|
-
capName: "storage-admin",
|
|
390827
|
-
capScope: "system",
|
|
390828
|
-
addonId: null,
|
|
390829
|
-
access: "view"
|
|
390830
|
-
},
|
|
390831
389901
|
"storageAdmin.listKinds": {
|
|
390832
389902
|
capName: "storage-admin",
|
|
390833
389903
|
capScope: "system",
|
|
@@ -390840,12 +389910,6 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
|
|
|
390840
389910
|
addonId: null,
|
|
390841
389911
|
access: "view"
|
|
390842
389912
|
},
|
|
390843
|
-
"storageAdmin.readLegacyCollection": {
|
|
390844
|
-
capName: "storage-admin",
|
|
390845
|
-
capScope: "system",
|
|
390846
|
-
addonId: null,
|
|
390847
|
-
access: "view"
|
|
390848
|
-
},
|
|
390849
389913
|
"storageAdmin.readRecords": {
|
|
390850
389914
|
capName: "storage-admin",
|
|
390851
389915
|
capScope: "system",
|
|
@@ -397815,12 +396879,6 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
|
|
|
397815
396879
|
form: "single",
|
|
397816
396880
|
optional: false
|
|
397817
396881
|
}],
|
|
397818
|
-
"storageAdmin.adoptRecords": [{
|
|
397819
|
-
name: "records",
|
|
397820
|
-
form: "object-array",
|
|
397821
|
-
optional: false,
|
|
397822
|
-
itemField: "deviceId"
|
|
397823
|
-
}],
|
|
397824
396882
|
"storageAdmin.readRecords": [{
|
|
397825
396883
|
name: "deviceId",
|
|
397826
396884
|
form: "single",
|
|
@@ -398359,7 +397417,6 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
|
|
|
398359
397417
|
"records.histogram",
|
|
398360
397418
|
"records.putMany",
|
|
398361
397419
|
"records.query",
|
|
398362
|
-
"storageAdmin.adoptRecords",
|
|
398363
397420
|
"storageAdmin.readRecords",
|
|
398364
397421
|
"streamBroker.acquireEgressTranscode",
|
|
398365
397422
|
"streamBroker.applyDeviceSettingsPatch",
|
|
@@ -407092,7 +406149,6 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
|
|
|
407092
406149
|
exports.AdoptionListCandidatesInputSchema = ListCandidatesInputSchema;
|
|
407093
406150
|
exports.AdoptionListCandidatesOutputSchema = ListCandidatesOutputSchema;
|
|
407094
406151
|
exports.AdoptionOutcomeSchema = AdoptionOutcomeSchema;
|
|
407095
|
-
exports.AdoptionPendingError = require_sleep.AdoptionPendingError;
|
|
407096
406152
|
exports.AdoptionReleaseInputSchema = ReleaseInputSchema;
|
|
407097
406153
|
exports.AdoptionStatusSchema = AdoptionStatusSchema;
|
|
407098
406154
|
exports.AgentLoadSummarySchema = AgentLoadSummarySchema;
|
|
@@ -408633,8 +407689,6 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
|
|
|
408633
407689
|
exports.SERVER_NAME_MAX_LENGTH = SERVER_NAME_MAX_LENGTH;
|
|
408634
407690
|
exports.SERVER_NAME_SETTING_KEY = SERVER_NAME_SETTING_KEY;
|
|
408635
407691
|
exports.SESSION_PLACEMENT_SETTING_KEY = SESSION_PLACEMENT_SETTING_KEY;
|
|
408636
|
-
exports.SETTINGS_ARRAY_ADOPTS_PREFIX = require_sleep.SETTINGS_ARRAY_ADOPTS_PREFIX;
|
|
408637
|
-
exports.SETTINGS_BROKERS_ADOPTS_PREFIX = require_sleep.SETTINGS_BROKERS_ADOPTS_PREFIX;
|
|
408638
407692
|
exports.SHARE_SOURCE_SETTING_KEY = SHARE_SOURCE_SETTING_KEY;
|
|
408639
407693
|
exports.SHARE_VIEW_KINDS = require_sleep.SHARE_VIEW_KINDS;
|
|
408640
407694
|
exports.SHARE_VIEW_MAX_DEVICES = SHARE_VIEW_MAX_DEVICES;
|
|
@@ -409544,8 +408598,6 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
|
|
|
409544
408598
|
exports.parseSecretRef = require_sleep.parseSecretRef;
|
|
409545
408599
|
exports.parseSecretStatePath = require_sleep.parseSecretStatePath;
|
|
409546
408600
|
exports.parseSessionPlacementPolicy = parseSessionPlacementPolicy;
|
|
409547
|
-
exports.parseSettingsArrayAdoptsFrom = require_sleep.parseSettingsArrayAdoptsFrom;
|
|
409548
|
-
exports.parseSettingsBrokersAdoptsFrom = require_sleep.parseSettingsBrokersAdoptsFrom;
|
|
409549
408601
|
exports.parseShareSource = parseShareSource;
|
|
409550
408602
|
exports.parseStreamParamsFormPatch = parseStreamParamsFormPatch;
|
|
409551
408603
|
exports.parseTrainingEventLine = parseTrainingEventLine;
|
|
@@ -409724,9 +408776,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
|
|
|
409724
408776
|
exports.serverManagementCapability = serverManagementCapability;
|
|
409725
408777
|
exports.setByPath = setByPath;
|
|
409726
408778
|
exports.settingValuesEqual = settingValuesEqual;
|
|
409727
|
-
exports.settingsArrayAdoptsFrom = require_sleep.settingsArrayAdoptsFrom;
|
|
409728
408779
|
exports.settingsBelow = settingsBelow;
|
|
409729
|
-
exports.settingsBrokersAdoptsFrom = require_sleep.settingsBrokersAdoptsFrom;
|
|
409730
408780
|
exports.settingsStoreCapability = settingsStoreCapability;
|
|
409731
408781
|
exports.shareViewGrantOf = shareViewGrantOf;
|
|
409732
408782
|
exports.shortHostname = shortHostname;
|
|
@@ -575335,7 +574385,7 @@ var require_cap_providers = __commonJS({
|
|
|
575335
574385
|
integrationId: input.id,
|
|
575336
574386
|
forOwner,
|
|
575337
574387
|
...secretKeys !== void 0 ? { secretKeys } : {},
|
|
575338
|
-
onSuspectSecret: (suspect) => logger.error(suspect.kind === "coerced-marker" ? 'integration secret is "[object Object]" \u2014 a keychain marker was coerced to text; the addon is sending it as the credential
|
|
574388
|
+
onSuspectSecret: (suspect) => logger.error(suspect.kind === "coerced-marker" ? 'integration secret is "[object Object]" \u2014 a keychain marker was coerced to text; the addon is sending it as the credential; re-type it' : "integration secret stored as PLAINTEXT under a keychain-declared key \u2014 withheld from the form; re-type it to move it into the keychain", {
|
|
575339
574389
|
tags: { integrationId: input.id, addonId: integration.addonId },
|
|
575340
574390
|
meta: { phase: "getSettings", key: suspect.key, kind: suspect.kind, forOwner }
|
|
575341
574391
|
})
|
|
@@ -588671,8 +587721,7 @@ var require_record_kinds = __commonJS({
|
|
|
588671
587721
|
{ name: "hash", fields: ["tokenHash"], unique: true },
|
|
588672
587722
|
{ name: "user", fields: ["userId"] }
|
|
588673
587723
|
],
|
|
588674
|
-
retention: { none: "operator drops the legacy rows by hand (D895)" }
|
|
588675
|
-
adoptsFrom: exports.SHARE_VIEW_TOKENS_LEGACY
|
|
587724
|
+
retention: { none: "operator drops the legacy rows by hand (D895)" }
|
|
588676
587725
|
},
|
|
588677
587726
|
"credential-tokens": {
|
|
588678
587727
|
schema: CredentialTokenBodySchema,
|