@camstack/system 1.2.465 → 1.2.467
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/addon-runner.js +1 -0
- package/dist/addon-runner.mjs +1 -0
- package/dist/addon-utils.mjs +1 -1
- package/dist/{agent-https-CzA1AmyI.js → agent-https-DJ8OzQOr.js} +1 -1
- package/dist/{agent-https-CPJ7FTs0.mjs → agent-https-DR1wmhYY.mjs} +1 -1
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +4 -4
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +5 -5
- package/dist/builtins/alerts/alerts.addon.js +1 -1
- package/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/dist/builtins/autotrack/index.js +1 -1
- package/dist/builtins/autotrack/index.mjs +1 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +5 -5
- package/dist/builtins/calendars/calendars.addon.js +1 -1
- package/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/dist/builtins/camera-grid/index.js +1 -1
- package/dist/builtins/camera-grid/index.mjs +1 -1
- package/dist/builtins/composer/composer.addon.js +2 -2
- package/dist/builtins/composer/composer.addon.mjs +2 -2
- package/dist/builtins/console-logging/index.js +1 -1
- package/dist/builtins/console-logging/index.mjs +1 -1
- package/dist/builtins/core-blocks/core-blocks.addon.js +2 -2
- package/dist/builtins/core-blocks/core-blocks.addon.mjs +2 -2
- package/dist/builtins/device-history/device-history.addon.js +1 -1
- package/dist/builtins/device-history/device-history.addon.mjs +1 -1
- package/dist/builtins/device-manager/device-manager.addon.js +1 -1
- package/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
- package/dist/builtins/hub-forwarder/index.js +1 -1
- package/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/dist/builtins/keychain/index.js +3 -3
- package/dist/builtins/keychain/index.mjs +3 -3
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/dist/builtins/local-auth/auth-schema.d.ts +0 -2
- package/dist/builtins/local-auth/local-auth.addon.d.ts +0 -1
- package/dist/builtins/local-auth/local-auth.addon.js +23 -178
- package/dist/builtins/local-auth/local-auth.addon.mjs +27 -181
- package/dist/builtins/local-auth/record-kinds.d.ts +1 -6
- package/dist/builtins/local-network/local-network.addon.js +2 -2
- package/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/dist/builtins/loki-logging/index.js +1 -1
- package/dist/builtins/loki-logging/index.mjs +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +10 -10
- package/dist/builtins/platform-probe/index.js +1 -1
- package/dist/builtins/platform-probe/index.mjs +8 -8
- package/dist/builtins/record-entries/index.js +1 -1
- package/dist/builtins/record-entries/index.mjs +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/dist/builtins/snapshot/index.js +1 -1
- package/dist/builtins/snapshot/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +20 -20
- package/dist/builtins/sqlite-storage/index.js +1 -1
- package/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/records/records-engine.d.ts +11 -0
- package/dist/builtins/sqlite-storage/records/records-provider.d.ts +7 -2
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +25 -15
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +25 -15
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/dist/builtins/system-config/system-config.addon.js +3 -3
- package/dist/builtins/system-config/system-config.addon.mjs +115 -115
- package/dist/builtins/winston-logging/index.js +1 -1
- package/dist/builtins/winston-logging/index.mjs +1 -1
- package/dist/{composition-sources-BG0E76VO.js → composition-sources-5rpWQhA1.js} +1 -1
- package/dist/{composition-sources-CqRsEC0a.mjs → composition-sources-Qto-S6MA.mjs} +1 -1
- package/dist/{constants-CmGw1liQ.mjs → constants-BWli8Cju.mjs} +1 -1
- package/dist/{constants-BYJ4ni7h.js → constants-CuO3rcw4.js} +1 -1
- package/dist/{coral-accelerators-Qhn5TOYZ.mjs → coral-accelerators-D_S1Fo5h.mjs} +5 -5
- package/dist/{custom-action-registry-DZSCLBuT.mjs → custom-action-registry-BGYDjTqY.mjs} +37 -37
- package/dist/{device-ca-CQcB6yfj.mjs → device-ca-C5cLlah1.mjs} +1 -1
- package/dist/{device-ca-B-Txwl4W.js → device-ca-CGcaSheI.js} +1 -1
- package/dist/{dist-CR7idLer.mjs → dist-BpUtAgqR.mjs} +158 -72
- package/dist/{dist-Dwi4JA96.js → dist-l6zKmHEb.js} +175 -77
- package/dist/file-host-worker.js +1 -1
- package/dist/file-host-worker.mjs +1 -1
- package/dist/{hub-mdns-ciao-BlLwL65g.mjs → hub-mdns-ciao-0KWDyIMD.mjs} +2 -2
- package/dist/{hub-mdns-ciao-3qdHbtyp.js → hub-mdns-ciao-CIno_SNn.js} +2 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +8 -8
- package/dist/index.mjs +228 -227
- package/dist/{restore-archive-D1uxP8Eb.js → restore-archive-B71JI-sP.js} +1 -1
- package/dist/{restore-archive-BYL7E5af.mjs → restore-archive-DKxAZ9pI.mjs} +94 -94
- package/dist/{wal-maintenance-BQlvAduo.js → wal-maintenance-B6LSQ_OZ.js} +0 -0
- package/dist/{wal-maintenance-BDQT7TIi.mjs → wal-maintenance-BXYwFecW.mjs} +0 -0
- package/package.json +1 -1
- package/dist/auth/api-key-manager.d.ts +0 -19
|
@@ -3,11 +3,11 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
7
|
-
const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
|
|
6
|
+
const require_dist = require("../../dist-l6zKmHEb.js");
|
|
8
7
|
const require_safe_buffer$1 = require("../../safe-buffer-D3aoa-7X.js");
|
|
9
8
|
const require_ms$1 = require("../../ms-LB3giGoU.js");
|
|
10
|
-
const require_device_ca = require("../../device-ca-
|
|
9
|
+
const require_device_ca = require("../../device-ca-CGcaSheI.js");
|
|
10
|
+
const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
|
|
11
11
|
let zod = require("zod");
|
|
12
12
|
let node_crypto = require("node:crypto");
|
|
13
13
|
node_crypto = require_chunk.__toESM(node_crypto);
|
|
@@ -17,87 +17,6 @@ let node_path = require("node:path");
|
|
|
17
17
|
node_path = require_chunk.__toESM(node_path);
|
|
18
18
|
let node_fs = require("node:fs");
|
|
19
19
|
node_fs = require_chunk.__toESM(node_fs);
|
|
20
|
-
//#region src/auth/parse-record.ts
|
|
21
|
-
function parseRecord$2(kind, schema, data) {
|
|
22
|
-
try {
|
|
23
|
-
return schema.parse(data);
|
|
24
|
-
} catch (err) {
|
|
25
|
-
const topKeys = data && typeof data === "object" && !Array.isArray(data) ? Object.keys(data).join(", ") || "(empty)" : `(non-object: ${typeof data})`;
|
|
26
|
-
const detail = err instanceof Error ? err.message : String(err);
|
|
27
|
-
const hint = data && typeof data === "object" && !Array.isArray(data) && Object.keys(data).length === 1 && "data" in data ? " This shape is the legacy double-wrap from a stale settings-store query path. Restart the server with the latest @camstack/system build." : "";
|
|
28
|
-
throw new Error(`Failed to parse ${kind} from settings store. Top-level keys=[${topKeys}].${hint} Underlying: ${detail}`, { cause: err });
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/auth/api-key-manager.ts
|
|
33
|
-
/**
|
|
34
|
-
* Legacy API keys — LIST and REVOKE only.
|
|
35
|
-
*
|
|
36
|
-
* No boundary accepts one (the tRPC context has no branch for them) and
|
|
37
|
-
* nothing creates them any more: what is left is the rows a hub may still
|
|
38
|
-
* hold, so an operator can see and delete them. Tokens (`auth.mintToken`) are
|
|
39
|
-
* the credential for scripts and integrations.
|
|
40
|
-
*/
|
|
41
|
-
var import_read_all_rows = require_read_all_rows$1.require_read_all_rows();
|
|
42
|
-
var API_KEYS_COLLECTION$1 = "api_keys";
|
|
43
|
-
function parseApiKey(data) {
|
|
44
|
-
return parseRecord$2("api-key", require_dist.ApiKeyRecordSchema, data);
|
|
45
|
-
}
|
|
46
|
-
function rowToApiKey(id, body) {
|
|
47
|
-
return parseApiKey({
|
|
48
|
-
id,
|
|
49
|
-
...body
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
var ApiKeyManager = class {
|
|
53
|
-
kind;
|
|
54
|
-
legacyStore;
|
|
55
|
-
constructor(deps) {
|
|
56
|
-
if ("apiKeysKind" in deps) {
|
|
57
|
-
this.kind = deps.apiKeysKind;
|
|
58
|
-
this.legacyStore = deps.legacyStore ?? null;
|
|
59
|
-
} else {
|
|
60
|
-
this.kind = null;
|
|
61
|
-
this.legacyStore = deps.getStore();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
get store() {
|
|
65
|
-
if (this.legacyStore === null) throw new Error("ApiKeyManager: legacy store unavailable on records-only path");
|
|
66
|
-
return this.legacyStore;
|
|
67
|
-
}
|
|
68
|
-
async listAll() {
|
|
69
|
-
const kind = this.kind;
|
|
70
|
-
return (kind !== null ? (await (0, import_read_all_rows.readAllRows)(kind)).map((row) => rowToApiKey(row.id, row.data)) : (await this.store.query.query({ collection: API_KEYS_COLLECTION$1 })).map((r) => parseApiKey(r.data))).map((parsed) => {
|
|
71
|
-
const { tokenHash: _th, ...rest } = parsed;
|
|
72
|
-
return rest;
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
async revoke(id) {
|
|
76
|
-
const kind = this.kind;
|
|
77
|
-
if (kind !== null) {
|
|
78
|
-
await kind.delete(id);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
await this.store.delete.mutate({
|
|
82
|
-
collection: API_KEYS_COLLECTION$1,
|
|
83
|
-
key: id
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
async findById(id) {
|
|
87
|
-
const kind = this.kind;
|
|
88
|
-
if (kind !== null) {
|
|
89
|
-
const row = await kind.get(id);
|
|
90
|
-
return row === null ? null : rowToApiKey(row.id, row.data);
|
|
91
|
-
}
|
|
92
|
-
const results = await this.store.query.query({
|
|
93
|
-
collection: API_KEYS_COLLECTION$1,
|
|
94
|
-
filter: { where: { id } }
|
|
95
|
-
});
|
|
96
|
-
if (results.length === 0) return null;
|
|
97
|
-
return parseApiKey(results[0].data);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
//#endregion
|
|
101
20
|
//#region ../../node_modules/bcryptjs/index.js
|
|
102
21
|
/**
|
|
103
22
|
* The random implementation to use as a fallback.
|
|
@@ -6345,6 +6264,7 @@ var AuthManager = class {
|
|
|
6345
6264
|
* cannot be stored is logged loudly instead, and never blocks the action
|
|
6346
6265
|
* (a login must not fail because the audit table is busy).
|
|
6347
6266
|
*/
|
|
6267
|
+
var import_read_all_rows = require_read_all_rows$1.require_read_all_rows();
|
|
6348
6268
|
/**
|
|
6349
6269
|
* @durable class=ledger owner=local-auth
|
|
6350
6270
|
* write="one row per audited auth event: a second factor skipped from a trusted
|
|
@@ -6399,7 +6319,7 @@ var AUTH_AUDIT_ACTIONS = [
|
|
|
6399
6319
|
];
|
|
6400
6320
|
var RETENTION_MS = 90 * 864e5;
|
|
6401
6321
|
var MAX_LIST = 500;
|
|
6402
|
-
function parseRecord$
|
|
6322
|
+
function parseRecord$2(data) {
|
|
6403
6323
|
const id = data["id"];
|
|
6404
6324
|
const rawAt = data["at"];
|
|
6405
6325
|
const at = typeof rawAt === "number" ? rawAt : typeof rawAt === "string" && rawAt.trim() !== "" && Number.isFinite(Number(rawAt)) ? Number(rawAt) : null;
|
|
@@ -6492,7 +6412,7 @@ var AuthAuditLog = class {
|
|
|
6492
6412
|
order: "at",
|
|
6493
6413
|
desc: true,
|
|
6494
6414
|
limit
|
|
6495
|
-
})).records.map((row) => parseRecord$
|
|
6415
|
+
})).records.map((row) => parseRecord$2({
|
|
6496
6416
|
id: row.id,
|
|
6497
6417
|
at: row.at,
|
|
6498
6418
|
action: row.data.action,
|
|
@@ -6503,7 +6423,7 @@ var AuthAuditLog = class {
|
|
|
6503
6423
|
return (await this.store.query.query({
|
|
6504
6424
|
collection: AUTH_AUDIT_COLLECTION,
|
|
6505
6425
|
...input.userId !== void 0 ? { filter: { where: { userId: input.userId } } } : {}
|
|
6506
|
-
})).map((row) => parseRecord$
|
|
6426
|
+
})).map((row) => parseRecord$2(row.data)).filter((r) => r !== null).toSorted((a, b) => b.at - a.at).slice(0, limit);
|
|
6507
6427
|
}
|
|
6508
6428
|
/** Delete rows older than 90 days. Returns how many. */
|
|
6509
6429
|
async reap() {
|
|
@@ -6719,7 +6639,7 @@ var PLATFORMS = [
|
|
|
6719
6639
|
"web",
|
|
6720
6640
|
"other"
|
|
6721
6641
|
];
|
|
6722
|
-
function parseRecord(data) {
|
|
6642
|
+
function parseRecord$1(data) {
|
|
6723
6643
|
const id = str$1(data, "id");
|
|
6724
6644
|
const userId = str$1(data, "userId");
|
|
6725
6645
|
const deviceName = str$1(data, "deviceName");
|
|
@@ -6784,7 +6704,7 @@ var DeviceCredentialManager = class {
|
|
|
6784
6704
|
const kind = this.deps.deviceCredentialsKind ?? null;
|
|
6785
6705
|
if (kind !== null) {
|
|
6786
6706
|
for (const row of await (0, import_read_all_rows.readAllRows)(kind)) {
|
|
6787
|
-
const record = parseRecord({
|
|
6707
|
+
const record = parseRecord$1({
|
|
6788
6708
|
id: row.id,
|
|
6789
6709
|
...row.data
|
|
6790
6710
|
});
|
|
@@ -6794,7 +6714,7 @@ var DeviceCredentialManager = class {
|
|
|
6794
6714
|
}
|
|
6795
6715
|
const rows = await this.store.query.query({ collection: DEVICE_CREDENTIALS_COLLECTION });
|
|
6796
6716
|
for (const row of rows) {
|
|
6797
|
-
const record = parseRecord(row.data);
|
|
6717
|
+
const record = parseRecord$1(row.data);
|
|
6798
6718
|
if (record !== null) this.records.set(record.id, record);
|
|
6799
6719
|
}
|
|
6800
6720
|
}
|
|
@@ -7215,7 +7135,6 @@ var USERS_COLLECTION$1 = "users";
|
|
|
7215
7135
|
* expiry column and no sweep, so a key lives until someone removes it (or the
|
|
7216
7136
|
* destructive `declareCollection` rebuild takes the table)."
|
|
7217
7137
|
*/
|
|
7218
|
-
var API_KEYS_COLLECTION = "api_keys";
|
|
7219
7138
|
/**
|
|
7220
7139
|
* @durable class=config owner=local-auth
|
|
7221
7140
|
* write="none since D895 — the pre-D892 scoped-token rows are kept on disk,
|
|
@@ -7304,52 +7223,6 @@ var USERS_COLUMNS = [
|
|
|
7304
7223
|
notNull: true
|
|
7305
7224
|
}
|
|
7306
7225
|
];
|
|
7307
|
-
var API_KEYS_COLUMNS = [
|
|
7308
|
-
{
|
|
7309
|
-
name: "id",
|
|
7310
|
-
type: "TEXT",
|
|
7311
|
-
primaryKey: true,
|
|
7312
|
-
notNull: true
|
|
7313
|
-
},
|
|
7314
|
-
{
|
|
7315
|
-
name: "label",
|
|
7316
|
-
type: "TEXT",
|
|
7317
|
-
notNull: true
|
|
7318
|
-
},
|
|
7319
|
-
{
|
|
7320
|
-
name: "isAdmin",
|
|
7321
|
-
type: "BOOLEAN",
|
|
7322
|
-
notNull: true
|
|
7323
|
-
},
|
|
7324
|
-
{
|
|
7325
|
-
name: "tokenHash",
|
|
7326
|
-
type: "TEXT",
|
|
7327
|
-
notNull: true,
|
|
7328
|
-
unique: true
|
|
7329
|
-
},
|
|
7330
|
-
{
|
|
7331
|
-
name: "tokenPrefix",
|
|
7332
|
-
type: "TEXT",
|
|
7333
|
-
notNull: true
|
|
7334
|
-
},
|
|
7335
|
-
{
|
|
7336
|
-
name: "allowedProviders",
|
|
7337
|
-
type: "JSON"
|
|
7338
|
-
},
|
|
7339
|
-
{
|
|
7340
|
-
name: "allowedDevices",
|
|
7341
|
-
type: "JSON"
|
|
7342
|
-
},
|
|
7343
|
-
{
|
|
7344
|
-
name: "createdAt",
|
|
7345
|
-
type: "INTEGER",
|
|
7346
|
-
notNull: true
|
|
7347
|
-
},
|
|
7348
|
-
{
|
|
7349
|
-
name: "lastUsedAt",
|
|
7350
|
-
type: "INTEGER"
|
|
7351
|
-
}
|
|
7352
|
-
];
|
|
7353
7226
|
var USER_TOTP_COLUMNS = [
|
|
7354
7227
|
{
|
|
7355
7228
|
name: "userId",
|
|
@@ -7467,14 +7340,6 @@ async function declareAuthSchema(store, options) {
|
|
|
7467
7340
|
collection: USERS_COLLECTION$1,
|
|
7468
7341
|
columns: USERS_COLUMNS
|
|
7469
7342
|
});
|
|
7470
|
-
if (!skip.has("api_keys")) await store.declareCollection.mutate({
|
|
7471
|
-
collection: API_KEYS_COLLECTION,
|
|
7472
|
-
columns: API_KEYS_COLUMNS,
|
|
7473
|
-
indexes: [{
|
|
7474
|
-
name: "idx_api_keys_token_prefix",
|
|
7475
|
-
columns: ["tokenPrefix"]
|
|
7476
|
-
}]
|
|
7477
|
-
});
|
|
7478
7343
|
if (!skip.has("scoped_tokens")) await store.declareCollection.mutate({
|
|
7479
7344
|
collection: SCOPED_TOKENS_COLLECTION,
|
|
7480
7345
|
columns: SCOPED_TOKENS_COLUMNS,
|
|
@@ -7548,7 +7413,6 @@ async function declareAuthSchema(store, options) {
|
|
|
7548
7413
|
*/
|
|
7549
7414
|
var DAY_MS = 864e5;
|
|
7550
7415
|
var UserBodySchema = require_dist.UserRecordSchema.omit({ id: true });
|
|
7551
|
-
var ApiKeyBodySchema = require_dist.ApiKeyRecordSchema.omit({ id: true });
|
|
7552
7416
|
var ScopedTokenBodySchema = require_dist.ScopedTokenSchema.omit({ id: true });
|
|
7553
7417
|
var AdminTokenBodySchema = zod.z.object({
|
|
7554
7418
|
createdBy: zod.z.string(),
|
|
@@ -7636,18 +7500,6 @@ var _localAuthRecordKinds = require_dist.defineRecordKinds({
|
|
|
7636
7500
|
}],
|
|
7637
7501
|
retention: { none: "row goes only when an operator deletes the user; destructive declareCollection rebuild wipes all accounts" }
|
|
7638
7502
|
},
|
|
7639
|
-
"api-keys": {
|
|
7640
|
-
schema: ApiKeyBodySchema,
|
|
7641
|
-
class: "config",
|
|
7642
|
-
writeTrigger: "legacy list/revoke only — nothing creates new API keys",
|
|
7643
|
-
device: "none",
|
|
7644
|
-
at: "none",
|
|
7645
|
-
indexes: [{
|
|
7646
|
-
name: "prefix",
|
|
7647
|
-
fields: ["tokenPrefix"]
|
|
7648
|
-
}],
|
|
7649
|
-
retention: { none: "explicit revoke only" }
|
|
7650
|
-
},
|
|
7651
7503
|
"scoped-tokens": {
|
|
7652
7504
|
schema: ScopedTokenBodySchema,
|
|
7653
7505
|
class: "config",
|
|
@@ -7784,7 +7636,6 @@ var _localAuthRecordKinds = require_dist.defineRecordKinds({
|
|
|
7784
7636
|
});
|
|
7785
7637
|
var localAuthRecordKinds = _localAuthRecordKinds;
|
|
7786
7638
|
var localAuthUsersRecordKind = _localAuthRecordKinds.users;
|
|
7787
|
-
var localAuthApiKeysRecordKind = _localAuthRecordKinds["api-keys"];
|
|
7788
7639
|
_localAuthRecordKinds["scoped-tokens"];
|
|
7789
7640
|
_localAuthRecordKinds["admin-tokens"];
|
|
7790
7641
|
var localAuthLoginSessionsRecordKind = _localAuthRecordKinds["login-sessions"];
|
|
@@ -7797,7 +7648,6 @@ var localAuthAuthAuditRecordKind = _localAuthRecordKinds["auth-audit"];
|
|
|
7797
7648
|
/** Legacy collections that must not be `declareCollection` once these kinds are live. */
|
|
7798
7649
|
var LOCAL_AUTH_RECORDS_LEGACY_COLLECTIONS = [
|
|
7799
7650
|
USERS_COLLECTION$1,
|
|
7800
|
-
API_KEYS_COLLECTION,
|
|
7801
7651
|
SCOPED_TOKENS_COLLECTION,
|
|
7802
7652
|
ADMIN_TOKENS_COLLECTION,
|
|
7803
7653
|
LOGIN_SESSIONS_COLLECTION,
|
|
@@ -7810,7 +7660,6 @@ var LOCAL_AUTH_RECORDS_LEGACY_COLLECTIONS = [
|
|
|
7810
7660
|
function localAuthRecordStoresOf(records) {
|
|
7811
7661
|
return {
|
|
7812
7662
|
users: records.kind(localAuthUsersRecordKind),
|
|
7813
|
-
apiKeys: records.kind(localAuthApiKeysRecordKind),
|
|
7814
7663
|
loginSessions: records.kind(localAuthLoginSessionsRecordKind),
|
|
7815
7664
|
loginSessionCutoffs: records.kind(localAuthLoginSessionCutoffsRecordKind),
|
|
7816
7665
|
oauthSessions: records.kind(localAuthOauthSessionsRecordKind),
|
|
@@ -8731,6 +8580,18 @@ function getUserManagementInternal(provider) {
|
|
|
8731
8580
|
return internal;
|
|
8732
8581
|
}
|
|
8733
8582
|
//#endregion
|
|
8583
|
+
//#region src/auth/parse-record.ts
|
|
8584
|
+
function parseRecord(kind, schema, data) {
|
|
8585
|
+
try {
|
|
8586
|
+
return schema.parse(data);
|
|
8587
|
+
} catch (err) {
|
|
8588
|
+
const topKeys = data && typeof data === "object" && !Array.isArray(data) ? Object.keys(data).join(", ") || "(empty)" : `(non-object: ${typeof data})`;
|
|
8589
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
8590
|
+
const hint = data && typeof data === "object" && !Array.isArray(data) && Object.keys(data).length === 1 && "data" in data ? " This shape is the legacy double-wrap from a stale settings-store query path. Restart the server with the latest @camstack/system build." : "";
|
|
8591
|
+
throw new Error(`Failed to parse ${kind} from settings store. Top-level keys=[${topKeys}].${hint} Underlying: ${detail}`, { cause: err });
|
|
8592
|
+
}
|
|
8593
|
+
}
|
|
8594
|
+
//#endregion
|
|
8734
8595
|
//#region src/auth/user-manager.ts
|
|
8735
8596
|
var USERS_COLLECTION = "users";
|
|
8736
8597
|
/**
|
|
@@ -8742,7 +8603,7 @@ var USERS_COLLECTION = "users";
|
|
|
8742
8603
|
var FIRST_BOOT_ADMIN_USERNAME = "admin";
|
|
8743
8604
|
var FIRST_BOOT_ADMIN_PASSWORD = "changeme";
|
|
8744
8605
|
function parseUser(data) {
|
|
8745
|
-
return parseRecord
|
|
8606
|
+
return parseRecord("user", require_dist.UserRecordSchema, data);
|
|
8746
8607
|
}
|
|
8747
8608
|
function userToBody(user) {
|
|
8748
8609
|
const { id: _id, ...body } = user;
|
|
@@ -12132,7 +11993,6 @@ function toAuthResult(user) {
|
|
|
12132
11993
|
var LocalAuthAddon = class extends require_dist.BaseAddon {
|
|
12133
11994
|
authManager = null;
|
|
12134
11995
|
userManager = null;
|
|
12135
|
-
apiKeyManager = null;
|
|
12136
11996
|
oauthSessionManager = null;
|
|
12137
11997
|
reapTimer = null;
|
|
12138
11998
|
totpManager = null;
|
|
@@ -12168,10 +12028,6 @@ var LocalAuthAddon = class extends require_dist.BaseAddon {
|
|
|
12168
12028
|
usersKind: authStores.users,
|
|
12169
12029
|
legacyStore: store
|
|
12170
12030
|
}, this.authManager);
|
|
12171
|
-
this.apiKeyManager = new ApiKeyManager({
|
|
12172
|
-
apiKeysKind: authStores.apiKeys,
|
|
12173
|
-
legacyStore: store
|
|
12174
|
-
});
|
|
12175
12031
|
this.oauthSessionManager = new OauthSessionManager({ oauthSessionsKind: authStores.oauthSessions });
|
|
12176
12032
|
this.totpManager = new TotpManager({
|
|
12177
12033
|
userTotpKind: authStores.userTotp,
|
|
@@ -12336,15 +12192,6 @@ var LocalAuthAddon = class extends require_dist.BaseAddon {
|
|
|
12336
12192
|
totpEnabled
|
|
12337
12193
|
};
|
|
12338
12194
|
},
|
|
12339
|
-
listApiKeys: async () => {
|
|
12340
|
-
if (!this.apiKeyManager) return [];
|
|
12341
|
-
return this.apiKeyManager.listAll();
|
|
12342
|
-
},
|
|
12343
|
-
revokeApiKey: async (input) => {
|
|
12344
|
-
if (!this.apiKeyManager) throw new Error("API key management not available");
|
|
12345
|
-
await this.apiKeyManager.revoke(input.id);
|
|
12346
|
-
return { success: true };
|
|
12347
|
-
},
|
|
12348
12195
|
oauthIssueCode: async (input) => {
|
|
12349
12196
|
return lazyOauthGrants().oauthIssueCode(input);
|
|
12350
12197
|
},
|
|
@@ -12705,7 +12552,6 @@ var LocalAuthAddon = class extends require_dist.BaseAddon {
|
|
|
12705
12552
|
}
|
|
12706
12553
|
this.authManager = null;
|
|
12707
12554
|
this.userManager = null;
|
|
12708
|
-
this.apiKeyManager = null;
|
|
12709
12555
|
this.oauthSessionManager = null;
|
|
12710
12556
|
this.externalIdentities = null;
|
|
12711
12557
|
this.loginSessions = null;
|
|
@@ -12715,7 +12561,6 @@ var LocalAuthAddon = class extends require_dist.BaseAddon {
|
|
|
12715
12561
|
}
|
|
12716
12562
|
};
|
|
12717
12563
|
//#endregion
|
|
12718
|
-
exports.ApiKeyManager = ApiKeyManager;
|
|
12719
12564
|
exports.AuthAuditLog = AuthAuditLog;
|
|
12720
12565
|
exports.AuthManager = AuthManager;
|
|
12721
12566
|
exports.DeviceCaStore = DeviceCaStore;
|