@cosmicdrift/kumiko-bundled-features 0.254.0 → 0.255.0

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.254.0",
3
+ "version": "0.255.0",
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>",
@@ -130,12 +130,12 @@
130
130
  "./workflow-runner": "./src/workflow-runner/index.ts"
131
131
  },
132
132
  "dependencies": {
133
- "@cosmicdrift/kumiko-dispatcher-live": "0.254.0",
134
- "@cosmicdrift/kumiko-framework": "0.254.0",
135
- "@cosmicdrift/kumiko-headless": "0.254.0",
136
- "@cosmicdrift/kumiko-renderer": "0.254.0",
137
- "@cosmicdrift/kumiko-renderer-web": "0.254.0",
138
- "@cosmicdrift/kumiko-types": "0.254.0",
133
+ "@cosmicdrift/kumiko-dispatcher-live": "0.255.0",
134
+ "@cosmicdrift/kumiko-framework": "0.255.0",
135
+ "@cosmicdrift/kumiko-headless": "0.255.0",
136
+ "@cosmicdrift/kumiko-renderer": "0.255.0",
137
+ "@cosmicdrift/kumiko-renderer-web": "0.255.0",
138
+ "@cosmicdrift/kumiko-types": "0.255.0",
139
139
  "@mollie/api-client": "^4.5.0",
140
140
  "@node-rs/argon2": "^2.0.2",
141
141
  "@types/mailparser": "^3.4.6",
@@ -164,7 +164,7 @@
164
164
  "devDependencies": {
165
165
  "@testing-library/user-event": "^14.6.1",
166
166
  "@types/qrcode": "^1.5.5",
167
- "@cosmicdrift/kumiko-locale-de": "0.254.0",
168
- "@cosmicdrift/kumiko-locale-es": "0.254.0"
167
+ "@cosmicdrift/kumiko-locale-de": "0.255.0",
168
+ "@cosmicdrift/kumiko-locale-es": "0.255.0"
169
169
  }
170
170
  }
@@ -0,0 +1,42 @@
1
+ // Mint/shred parity (fw#2801 security review): a record subject key is
2
+ // minted via subjectKeyForRecord (framework crypto) but shredded via a
3
+ // forget-subject request validated against subjectIdSchema (this feature).
4
+ // If the two ever disagreed on which entity names are valid, a field could
5
+ // encrypt cleanly and then never be reachable by forgetSubject — the
6
+ // "encrypted but not shreddable" state fw#2809 was built to prevent. This
7
+ // pins the invariant down without needing a DB.
8
+
9
+ import { describe, expect, test } from "bun:test";
10
+ import { subjectKeyForRecord } from "@cosmicdrift/kumiko-framework/crypto";
11
+ import { subjectIdSchema } from "../handlers/forget-subject.write";
12
+
13
+ const UUID_A = "6b2f4a0e-1c9d-4f3a-9d2e-00000000000a";
14
+
15
+ const VALID_ENTITY_NAMES = [
16
+ "mail-account",
17
+ "note-entry",
18
+ "documentExtract",
19
+ "a",
20
+ "A1",
21
+ "tenant_membership",
22
+ ];
23
+
24
+ const INVALID_ENTITY_NAMES = ["v2.digest", "_internal", "3rd", "bad:name", ""];
25
+
26
+ describe("record subject mint/shred parity", () => {
27
+ test("every entity name subjectKeyForRecord accepts, subjectIdSchema also accepts", () => {
28
+ for (const entity of VALID_ENTITY_NAMES) {
29
+ expect(() => subjectKeyForRecord(entity, UUID_A)).not.toThrow();
30
+ const result = subjectIdSchema.safeParse({ kind: "record", entity, id: UUID_A });
31
+ expect(result.success).toBe(true);
32
+ }
33
+ });
34
+
35
+ test("every entity name subjectKeyForRecord rejects, subjectIdSchema also rejects", () => {
36
+ for (const entity of INVALID_ENTITY_NAMES) {
37
+ expect(() => subjectKeyForRecord(entity, UUID_A)).toThrow();
38
+ const result = subjectIdSchema.safeParse({ kind: "record", entity, id: UUID_A });
39
+ expect(result.success).toBe(false);
40
+ }
41
+ });
42
+ });
@@ -3,6 +3,7 @@ import { requestContext } from "@cosmicdrift/kumiko-framework/api";
3
3
  import { ROLES } from "@cosmicdrift/kumiko-framework/auth";
4
4
  import {
5
5
  configuredPiiSubjectKms,
6
+ RECORD_ENTITY_PATTERN,
6
7
  type SubjectId,
7
8
  subjectIdToKey,
8
9
  } from "@cosmicdrift/kumiko-framework/crypto";
@@ -48,9 +49,6 @@ import {
48
49
  TARGET_TENANT_NOT_ADMIN_TENANT,
49
50
  } from "../constants";
50
51
 
51
- // Registry entity names are identifier-shaped; ":" would break the subject-key round-trip.
52
- const RECORD_ENTITY_PATTERN = /^[A-Za-z][A-Za-z0-9_-]*$/;
53
-
54
52
  export const subjectIdSchema = z.discriminatedUnion("kind", [
55
53
  z.object({ kind: z.literal("user"), userId: z.uuid() }),
56
54
  z.object({ kind: z.literal("tenant"), tenantId: z.uuid() }),
@@ -64,7 +64,7 @@ export function createDeliveryFeature(options?: DeliveryFeatureOptions): Feature
64
64
  // recipientAddress is the real PII (email address); recipientId stays
65
65
  // plaintext — pseudonymous fk, same line as config.userId (#821).
66
66
  r.defineEvent("attempt", deliveryAttemptSchema, {
67
- piiFields: { recipientAddress: { subjectField: "recipientId" } },
67
+ piiFields: { recipientAddress: { personal: { of: "recipientId" } } },
68
68
  });
69
69
 
70
70
  // Inline projection that materialises every delivery attempt into