@cosmicdrift/kumiko-bundled-features 0.199.0 → 0.199.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-bundled-features",
|
|
3
|
-
"version": "0.199.
|
|
3
|
+
"version": "0.199.2",
|
|
4
4
|
"description": "Built-in features — tenant, user, auth, delivery. The stuff you'd rewrite anyway, already typed.",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
@@ -125,12 +125,12 @@
|
|
|
125
125
|
"./step-dispatcher": "./src/step-dispatcher/index.ts"
|
|
126
126
|
},
|
|
127
127
|
"dependencies": {
|
|
128
|
-
"@cosmicdrift/kumiko-dispatcher-live": "0.199.
|
|
129
|
-
"@cosmicdrift/kumiko-framework": "0.199.
|
|
130
|
-
"@cosmicdrift/kumiko-headless": "0.199.
|
|
131
|
-
"@cosmicdrift/kumiko-renderer": "0.199.
|
|
132
|
-
"@cosmicdrift/kumiko-renderer-web": "0.199.
|
|
133
|
-
"@cosmicdrift/kumiko-types": "0.199.
|
|
128
|
+
"@cosmicdrift/kumiko-dispatcher-live": "0.199.2",
|
|
129
|
+
"@cosmicdrift/kumiko-framework": "0.199.2",
|
|
130
|
+
"@cosmicdrift/kumiko-headless": "0.199.2",
|
|
131
|
+
"@cosmicdrift/kumiko-renderer": "0.199.2",
|
|
132
|
+
"@cosmicdrift/kumiko-renderer-web": "0.199.2",
|
|
133
|
+
"@cosmicdrift/kumiko-types": "0.199.2",
|
|
134
134
|
"@mollie/api-client": "^4.5.0",
|
|
135
135
|
"@node-rs/argon2": "^2.0.2",
|
|
136
136
|
"@types/mailparser": "^3.4.6",
|
|
@@ -451,6 +451,27 @@ describe("Settings-Hub system-scope write by a human SystemAdmin", () => {
|
|
|
451
451
|
);
|
|
452
452
|
expectErrorIncludes(error, "access_denied");
|
|
453
453
|
});
|
|
454
|
+
|
|
455
|
+
// Regression for assertTenantMatch wiring in reset.write.ts: a scope=
|
|
456
|
+
// "system" reset writes/deletes a row whose tenantId is SYSTEM_TENANT_ID,
|
|
457
|
+
// not the caller's own tenantId. If the handler ever passed that row
|
|
458
|
+
// tenantId (instead of event.user.tenantId) into assertTenantMatch, this
|
|
459
|
+
// would throw "tenant self-check failed" for every SystemAdmin reset.
|
|
460
|
+
test("resets a system-scope key back to its declared default", async () => {
|
|
461
|
+
await stack.http.writeOk(
|
|
462
|
+
ConfigHandlers.set,
|
|
463
|
+
{ key: "integration:config:billing-live", value: true, scope: "system" },
|
|
464
|
+
systemAdmin,
|
|
465
|
+
);
|
|
466
|
+
expect(await sysAccessor()("integration:config:billing-live")).toBe(true);
|
|
467
|
+
|
|
468
|
+
await stack.http.writeOk(
|
|
469
|
+
ConfigHandlers.reset,
|
|
470
|
+
{ key: "integration:config:billing-live", scope: "system" },
|
|
471
|
+
systemAdmin,
|
|
472
|
+
);
|
|
473
|
+
expect(await sysAccessor()("integration:config:billing-live")).toBe(false);
|
|
474
|
+
});
|
|
454
475
|
});
|
|
455
476
|
|
|
456
477
|
// --- Scenario 2: Mail Server — system default + tenant override ---
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
} from "@cosmicdrift/kumiko-framework/engine";
|
|
7
7
|
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
8
8
|
import { z } from "zod";
|
|
9
|
+
import { requireSystemDb } from "../feature";
|
|
9
10
|
import { configValueEntity, configValuesTable } from "../table";
|
|
10
11
|
import { findConfigRow, prepareConfigWrite } from "../write-helpers";
|
|
11
12
|
|
|
@@ -24,7 +25,7 @@ export const resetWrite = defineWriteHandler({
|
|
|
24
25
|
// Per-key access enforcement lives inside the handler via checkWriteAccess.
|
|
25
26
|
access: { openToAll: true },
|
|
26
27
|
handler: async (event, ctx) => {
|
|
27
|
-
const db = ctx.
|
|
28
|
+
const db = requireSystemDb(ctx, "config:write:reset", event.user.tenantId);
|
|
28
29
|
|
|
29
30
|
const prep = prepareConfigWrite({
|
|
30
31
|
registry: ctx.registry,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
writeFailure,
|
|
17
17
|
} from "@cosmicdrift/kumiko-framework/errors";
|
|
18
18
|
import { z } from "zod";
|
|
19
|
-
import { requireConfigEncryption } from "../feature";
|
|
19
|
+
import { requireConfigEncryption, requireSystemDb } from "../feature";
|
|
20
20
|
import { configValueEntity, configValuesTable } from "../table";
|
|
21
21
|
import {
|
|
22
22
|
findConfigRow,
|
|
@@ -44,7 +44,7 @@ export const setWrite = defineWriteHandler({
|
|
|
44
44
|
// Per-key access enforcement lives inside the handler via checkWriteAccess.
|
|
45
45
|
access: { openToAll: true },
|
|
46
46
|
handler: async (event, ctx) => {
|
|
47
|
-
const db = ctx.
|
|
47
|
+
const db = requireSystemDb(ctx, "config:write:set", event.user.tenantId);
|
|
48
48
|
|
|
49
49
|
const prep = prepareConfigWrite({
|
|
50
50
|
registry: ctx.registry,
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
|
|
2
2
|
import { randomBytes } from "node:crypto";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
createTenantDb,
|
|
5
|
+
createUncheckedSystemDb,
|
|
6
|
+
type DbConnection,
|
|
7
|
+
} from "@cosmicdrift/kumiko-framework/db";
|
|
4
8
|
import {
|
|
5
9
|
access,
|
|
6
10
|
createRegistry,
|
|
@@ -78,6 +82,7 @@ const billingFeature = defineFeature("billing", (r) => {
|
|
|
78
82
|
{
|
|
79
83
|
db: tenantDb,
|
|
80
84
|
dbOutsideTransaction: tenantDb,
|
|
85
|
+
systemDb: createUncheckedSystemDb(tenantDb),
|
|
81
86
|
registry: reg,
|
|
82
87
|
configResolver: ctx["configResolver"] as ConfigResolver,
|
|
83
88
|
...bridgeStub(),
|
|
@@ -161,11 +166,13 @@ describe("SYSTEM_USER in jobs", () => {
|
|
|
161
166
|
});
|
|
162
167
|
|
|
163
168
|
const adminUser = TestUsers.admin;
|
|
169
|
+
const adminTenantDb = createTenantDb(db, adminUser.tenantId, "system");
|
|
164
170
|
const result = await handler.handler(
|
|
165
171
|
{ type: ConfigHandlers.set, payload: parsed, user: adminUser },
|
|
166
172
|
{
|
|
167
|
-
db:
|
|
168
|
-
dbOutsideTransaction:
|
|
173
|
+
db: adminTenantDb,
|
|
174
|
+
dbOutsideTransaction: adminTenantDb,
|
|
175
|
+
systemDb: createUncheckedSystemDb(adminTenantDb),
|
|
169
176
|
registry,
|
|
170
177
|
configResolver: resolver,
|
|
171
178
|
...bridgeStub(),
|