@coffre/db 0.8.1 → 0.9.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.
Files changed (38) hide show
  1. package/dist/connect.d.ts +1 -1
  2. package/dist/{database-BEnexh-3.d.ts → database-hd1hAll-.d.ts} +1 -1
  3. package/dist/dialect.d.ts +1 -1
  4. package/dist/grants.d.ts +1 -1
  5. package/dist/hyperdrive.d.ts +1 -1
  6. package/dist/index.d.ts +2 -2
  7. package/dist/log.d.ts +1 -1
  8. package/dist/migrations/postgres/0010_handle_places.sql +2 -0
  9. package/dist/migrations/postgres/0011_plain_values.sql +19 -0
  10. package/dist/migrations/postgres/meta/0010_snapshot.json +2991 -0
  11. package/dist/migrations/postgres/meta/0011_snapshot.json +2997 -0
  12. package/dist/migrations/postgres/meta/_journal.json +14 -0
  13. package/dist/migrations/sqlite/0010_handle_places.sql +2 -0
  14. package/dist/migrations/sqlite/0011_plain_values.sql +14 -0
  15. package/dist/migrations/sqlite/meta/0010_snapshot.json +2711 -0
  16. package/dist/migrations/sqlite/meta/0011_snapshot.json +2718 -0
  17. package/dist/migrations/sqlite/meta/_journal.json +14 -0
  18. package/dist/portable.d.ts +2 -2
  19. package/dist/{schema-BZRkBJQZ.d.ts → schema-CCYKTG-E.d.ts} +34 -0
  20. package/dist/schema-sqlite.d.ts +38 -0
  21. package/dist/schema-sqlite.js +3 -1
  22. package/dist/schema-version.d.ts +1 -1
  23. package/dist/schema-version.js +28 -0
  24. package/dist/schema.d.ts +1 -1
  25. package/dist/schema.js +3 -1
  26. package/package.json +2 -2
  27. package/src/migrations/postgres/0010_handle_places.sql +2 -0
  28. package/src/migrations/postgres/0011_plain_values.sql +19 -0
  29. package/src/migrations/postgres/meta/0010_snapshot.json +2991 -0
  30. package/src/migrations/postgres/meta/0011_snapshot.json +2997 -0
  31. package/src/migrations/postgres/meta/_journal.json +14 -0
  32. package/src/migrations/sqlite/0010_handle_places.sql +2 -0
  33. package/src/migrations/sqlite/0011_plain_values.sql +14 -0
  34. package/src/migrations/sqlite/meta/0010_snapshot.json +2711 -0
  35. package/src/migrations/sqlite/meta/0011_snapshot.json +2718 -0
  36. package/src/migrations/sqlite/meta/_journal.json +14 -0
  37. package/src/schema.sqlite.ts +7 -0
  38. package/src/schema.ts +7 -0
@@ -71,6 +71,20 @@
71
71
  "when": 1792281880190,
72
72
  "tag": "0009_handles",
73
73
  "breakpoints": true
74
+ },
75
+ {
76
+ "idx": 10,
77
+ "version": "6",
78
+ "when": 1792315000277,
79
+ "tag": "0010_handle_places",
80
+ "breakpoints": true
81
+ },
82
+ {
83
+ "idx": 11,
84
+ "version": "6",
85
+ "when": 1792317461299,
86
+ "tag": "0011_plain_values",
87
+ "breakpoints": true
74
88
  }
75
89
  ]
76
90
  }
@@ -1,5 +1,5 @@
1
- import { m as schema_d_exports } from "./schema-BZRkBJQZ.js";
2
- import { t as Database } from "./database-BEnexh-3.js";
1
+ import { m as schema_d_exports } from "./schema-CCYKTG-E.js";
2
+ import { t as Database } from "./database-hd1hAll-.js";
3
3
  import { t as schema_sqlite_d_exports } from "./schema-sqlite.js";
4
4
  import { LibSQLDatabase } from "drizzle-orm/libsql";
5
5
  //#region src/portable.d.ts
@@ -714,6 +714,23 @@ declare const secretVersions: import("drizzle-orm/pg-core").PgTableWithColumns<{
714
714
  identity: undefined;
715
715
  generated: undefined;
716
716
  }, {}, {}>;
717
+ plaintext: import("drizzle-orm/pg-core").PgColumn<{
718
+ name: "plaintext";
719
+ tableName: "secret_versions";
720
+ dataType: "string";
721
+ columnType: "PgText";
722
+ data: string;
723
+ driverParam: string;
724
+ notNull: false;
725
+ hasDefault: false;
726
+ isPrimaryKey: false;
727
+ isAutoincrement: false;
728
+ hasRuntimeDefault: false;
729
+ enumValues: [string, ...string[]];
730
+ baseColumn: never;
731
+ identity: undefined;
732
+ generated: undefined;
733
+ }, {}, {}>;
717
734
  };
718
735
  dialect: "pg";
719
736
  }>;
@@ -3298,6 +3315,23 @@ declare const credentials: import("drizzle-orm/pg-core").PgTableWithColumns<{
3298
3315
  identity: undefined;
3299
3316
  generated: undefined;
3300
3317
  }, {}, {}>;
3318
+ places: import("drizzle-orm/pg-core").PgColumn<{
3319
+ name: "places";
3320
+ tableName: "credentials";
3321
+ dataType: "string";
3322
+ columnType: "PgText";
3323
+ data: string;
3324
+ driverParam: string;
3325
+ notNull: false;
3326
+ hasDefault: false;
3327
+ isPrimaryKey: false;
3328
+ isAutoincrement: false;
3329
+ hasRuntimeDefault: false;
3330
+ enumValues: [string, ...string[]];
3331
+ baseColumn: never;
3332
+ identity: undefined;
3333
+ generated: undefined;
3334
+ }, {}, {}>;
3301
3335
  label: import("drizzle-orm/pg-core").PgColumn<{
3302
3336
  name: "label";
3303
3337
  tableName: "credentials";
@@ -756,6 +756,25 @@ export declare const secretVersions: import("drizzle-orm/sqlite-core").SQLiteTab
756
756
  }, {}, {
757
757
  length: number | undefined;
758
758
  }>;
759
+ plaintext: import("drizzle-orm/sqlite-core").SQLiteColumn<{
760
+ name: "plaintext";
761
+ tableName: "secret_versions";
762
+ dataType: "string";
763
+ columnType: "SQLiteText";
764
+ data: string;
765
+ driverParam: string;
766
+ notNull: false;
767
+ hasDefault: false;
768
+ isPrimaryKey: false;
769
+ isAutoincrement: false;
770
+ hasRuntimeDefault: false;
771
+ enumValues: [string, ...string[]];
772
+ baseColumn: never;
773
+ identity: undefined;
774
+ generated: undefined;
775
+ }, {}, {
776
+ length: undefined;
777
+ }>;
759
778
  };
760
779
  dialect: "sqlite";
761
780
  }>;
@@ -3427,6 +3446,25 @@ export declare const credentials: import("drizzle-orm/sqlite-core").SQLiteTableW
3427
3446
  }, {}, {
3428
3447
  length: undefined;
3429
3448
  }>;
3449
+ places: import("drizzle-orm/sqlite-core").SQLiteColumn<{
3450
+ name: "places";
3451
+ tableName: "credentials";
3452
+ dataType: "string";
3453
+ columnType: "SQLiteText";
3454
+ data: string;
3455
+ driverParam: string;
3456
+ notNull: false;
3457
+ hasDefault: false;
3458
+ isPrimaryKey: false;
3459
+ isAutoincrement: false;
3460
+ hasRuntimeDefault: false;
3461
+ enumValues: [string, ...string[]];
3462
+ baseColumn: never;
3463
+ identity: undefined;
3464
+ generated: undefined;
3465
+ }, {}, {
3466
+ length: undefined;
3467
+ }>;
3430
3468
  label: import("drizzle-orm/sqlite-core").SQLiteColumn<{
3431
3469
  name: "label";
3432
3470
  tableName: "credentials";
@@ -124,7 +124,8 @@ const secretVersions = sqliteTable("secret_versions", {
124
124
  createdBy: text("created_by").notNull(),
125
125
  recipe: text(),
126
126
  pairId: text("pair_id"),
127
- pairHalf: text("pair_half")
127
+ pairHalf: text("pair_half"),
128
+ plaintext: text()
128
129
  }, (table) => [
129
130
  unique("secret_versions_secret_id_version_key").on(table.secretId, table.version),
130
131
  check("secret_versions_version_check", sql`${table.version} > 0`),
@@ -487,6 +488,7 @@ const credentials = sqliteTable("credentials", {
487
488
  principal: text().notNull(),
488
489
  identityId: text("identity_id"),
489
490
  scope: text(),
491
+ places: text(),
490
492
  label: text(),
491
493
  createdAt: createdAt(),
492
494
  createdBy: text("created_by").notNull(),
@@ -1,4 +1,4 @@
1
- import { i as Queryable } from "./database-BEnexh-3.js";
1
+ import { i as Queryable } from "./database-hd1hAll-.js";
2
2
  import { Engine } from "./dialect.js";
3
3
  //#region src/schema-version.d.ts
4
4
  /**
@@ -78,6 +78,20 @@ const KNOWN_MIGRATIONS = {
78
78
  "when": 1792281879553,
79
79
  "tag": "0009_handles",
80
80
  "breakpoints": true
81
+ },
82
+ {
83
+ "idx": 10,
84
+ "version": "7",
85
+ "when": 1792314999425,
86
+ "tag": "0010_handle_places",
87
+ "breakpoints": true
88
+ },
89
+ {
90
+ "idx": 11,
91
+ "version": "7",
92
+ "when": 1792317460399,
93
+ "tag": "0011_plain_values",
94
+ "breakpoints": true
81
95
  }
82
96
  ].map((entry) => entry.tag),
83
97
  sqlite: [
@@ -150,6 +164,20 @@ const KNOWN_MIGRATIONS = {
150
164
  "when": 1792281880190,
151
165
  "tag": "0009_handles",
152
166
  "breakpoints": true
167
+ },
168
+ {
169
+ "idx": 10,
170
+ "version": "6",
171
+ "when": 1792315000277,
172
+ "tag": "0010_handle_places",
173
+ "breakpoints": true
174
+ },
175
+ {
176
+ "idx": 11,
177
+ "version": "6",
178
+ "when": 1792317461299,
179
+ "tag": "0011_plain_values",
180
+ "breakpoints": true
153
181
  }
154
182
  ].map((entry) => entry.tag)
155
183
  };
package/dist/schema.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as secrets, a as deviceAuthorizations, b as vaultGrants, c as environmentsRelations, d as mcpConnections, f as oauthClients, g as secretVersions, h as secretReferences, i as credentials, l as identities, n as auditLog, o as dismissedKeys, p as projects, r as consumedTokens, s as environments, t as auditChainHead, u as mcpApprovals, v as secretsRelations, x as vaultMembers, y as serviceBindings } from "./schema-BZRkBJQZ.js";
1
+ import { _ as secrets, a as deviceAuthorizations, b as vaultGrants, c as environmentsRelations, d as mcpConnections, f as oauthClients, g as secretVersions, h as secretReferences, i as credentials, l as identities, n as auditLog, o as dismissedKeys, p as projects, r as consumedTokens, s as environments, t as auditChainHead, u as mcpApprovals, v as secretsRelations, x as vaultMembers, y as serviceBindings } from "./schema-CCYKTG-E.js";
2
2
  export { auditChainHead, auditLog, consumedTokens, credentials, deviceAuthorizations, dismissedKeys, environments, environmentsRelations, identities, mcpApprovals, mcpConnections, oauthClients, projects, secretReferences, secretVersions, secrets, secretsRelations, serviceBindings, vaultGrants, vaultMembers };
package/dist/schema.js CHANGED
@@ -129,7 +129,8 @@ const secretVersions = pgTable("secret_versions", {
129
129
  createdBy: text("created_by").notNull(),
130
130
  recipe: text(),
131
131
  pairId: uuid("pair_id"),
132
- pairHalf: text("pair_half")
132
+ pairHalf: text("pair_half"),
133
+ plaintext: text()
133
134
  }, (table) => [
134
135
  unique("secret_versions_secret_id_version_key").on(table.secretId, table.version),
135
136
  check("secret_versions_version_check", sql`${table.version} > 0`),
@@ -553,6 +554,7 @@ const credentials = pgTable("credentials", {
553
554
  principal: text().notNull(),
554
555
  identityId: uuid("identity_id"),
555
556
  scope: text(),
557
+ places: text(),
556
558
  label: text(),
557
559
  createdAt: createdAt(),
558
560
  createdBy: text("created_by").notNull(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffre/db",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "coffre's database: the schema, its migrations and the connections, on Postgres or SQLite.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -79,7 +79,7 @@
79
79
  "drizzle-orm": "0.45.2",
80
80
  "pg": "8.16.3",
81
81
  "pg-connection-string": "2.14.0",
82
- "@coffre/core": "0.8.1"
82
+ "@coffre/core": "0.9.0"
83
83
  },
84
84
  "devDependencies": {
85
85
  "@types/node": "26.1.1",
@@ -0,0 +1,2 @@
1
+ -- A handle's places (0.9): the environments it was made for, by id and whether as @me, which the proxy's stable URL resolves to. A nullable column the release before neither reads nor writes; the app sets it when it makes a handle, and never after (no UPDATE grant).
2
+ ALTER TABLE "credentials" ADD COLUMN "places" text;
@@ -0,0 +1,19 @@
1
+ -- Plain values (0.9): a version of a key marked not secret holds its value in the clear too. Nullable, so the release before writes on as it did.
2
+ ALTER TABLE "secret_versions" ADD COLUMN "plaintext" text;--> statement-breakpoint
3
+ -- A version is still only ever erased, and an erased one holds no value, in the clear or not.
4
+ CREATE OR REPLACE FUNCTION secret_versions_erase_only() RETURNS trigger LANGUAGE plpgsql AS $$
5
+ BEGIN
6
+ IF octet_length(NEW.ciphertext) <> 0 OR octet_length(NEW.wrapped_dek) <> 0 OR NEW.plaintext IS NOT NULL
7
+ OR (NEW.id, NEW.secret_id, NEW.version, NEW.envelope_version, NEW.iv, NEW.auth_tag,
8
+ NEW.kek_provider, NEW.kek_id, NEW.kek_version, NEW.created_at, NEW.created_by,
9
+ NEW.recipe, NEW.pair_id, NEW.pair_half)
10
+ IS DISTINCT FROM
11
+ (OLD.id, OLD.secret_id, OLD.version, OLD.envelope_version, OLD.iv, OLD.auth_tag,
12
+ OLD.kek_provider, OLD.kek_id, OLD.kek_version, OLD.created_at, OLD.created_by,
13
+ OLD.recipe, OLD.pair_id, OLD.pair_half) THEN
14
+ RAISE EXCEPTION 'a secret version is only ever erased' USING ERRCODE = 'insufficient_privilege';
15
+ END IF;
16
+ RETURN NEW;
17
+ END
18
+ $$;--> statement-breakpoint
19
+ GRANT UPDATE (plaintext) ON secret_versions TO coffre_app;