@coffre/db 0.14.2 → 0.14.4
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/connect.d.ts +1 -1
- package/dist/{database-Ds1Y79h6.d.ts → database-CFhTnnzM.d.ts} +1 -1
- package/dist/dialect.d.ts +4 -3
- package/dist/dialect.js +1 -0
- package/dist/grants.d.ts +1 -1
- package/dist/hyperdrive.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/log.d.ts +1 -1
- package/dist/migrate.d.ts +21 -5
- package/dist/migrate.js +49 -9
- package/dist/migrations/postgres/0019_backup_role.sql +63 -0
- package/dist/migrations/postgres/0020_vault_releases.sql +36 -0
- package/dist/migrations/postgres/meta/0019_snapshot.json +3295 -0
- package/dist/migrations/postgres/meta/0020_snapshot.json +3334 -0
- package/dist/migrations/postgres/meta/_journal.json +14 -0
- package/dist/migrations/sqlite/0017_vault_releases.sql +26 -0
- package/dist/migrations/sqlite/meta/0017_snapshot.json +3037 -0
- package/dist/migrations/sqlite/meta/_journal.json +7 -0
- package/dist/portable.d.ts +2 -2
- package/dist/schema-sqlite.d.ts +75 -1
- package/dist/schema-sqlite.js +21 -1
- package/dist/schema-version.d.ts +1 -1
- package/dist/schema-version.js +21 -0
- package/dist/{schema-DcVkJhCf.d.ts → schema-z8GcN_Xu.d.ts} +72 -2
- package/dist/schema.d.ts +2 -2
- package/dist/schema.js +23 -2
- package/package.json +2 -2
- package/src/dialect.ts +3 -2
- package/src/migrate-main.ts +6 -3
- package/src/migrate.ts +49 -10
- package/src/migrations/postgres/0019_backup_role.sql +63 -0
- package/src/migrations/postgres/0020_vault_releases.sql +36 -0
- package/src/migrations/postgres/meta/0019_snapshot.json +3295 -0
- package/src/migrations/postgres/meta/0020_snapshot.json +3334 -0
- package/src/migrations/postgres/meta/_journal.json +14 -0
- package/src/migrations/sqlite/0017_vault_releases.sql +26 -0
- package/src/migrations/sqlite/meta/0017_snapshot.json +3037 -0
- package/src/migrations/sqlite/meta/_journal.json +7 -0
- package/src/schema.sqlite.ts +22 -0
- package/src/schema.ts +24 -0
package/src/schema.sqlite.ts
CHANGED
|
@@ -303,6 +303,28 @@ export const vaultGrants = sqliteTable(
|
|
|
303
303
|
],
|
|
304
304
|
);
|
|
305
305
|
|
|
306
|
+
/**
|
|
307
|
+
* Each key the vault released to a principal, and when last: what its bulk
|
|
308
|
+
* limit counts (R28), the distinct keys released within a window, without
|
|
309
|
+
* reading the log. The database keeps it from the log itself, in the
|
|
310
|
+
* transaction of each vault `secret.read` allowed: a trigger on
|
|
311
|
+
* `audit_log` upserts a row for each key the entry names, as the count
|
|
312
|
+
* read them from the entries before (an entry that names none, which only
|
|
313
|
+
* a forged one is, counts as a key of its own, `entry:<seq>`). No login
|
|
314
|
+
* writes it: the vault and the backup read it. A row a window old counts
|
|
315
|
+
* for nothing, so nothing prunes them: there are at most as many as
|
|
316
|
+
* principals times keys, and a count reads one principal's.
|
|
317
|
+
*/
|
|
318
|
+
export const vaultReleases = sqliteTable(
|
|
319
|
+
'vault_releases',
|
|
320
|
+
{
|
|
321
|
+
principal: text().notNull(),
|
|
322
|
+
key: text().notNull(),
|
|
323
|
+
releasedAt: integer('released_at', { mode: 'number' }).notNull(),
|
|
324
|
+
},
|
|
325
|
+
(table) => [primaryKey({ name: 'vault_releases_pkey', columns: [table.principal, table.key] })],
|
|
326
|
+
);
|
|
327
|
+
|
|
306
328
|
export const auditLog = sqliteTable(
|
|
307
329
|
'audit_log',
|
|
308
330
|
{
|
package/src/schema.ts
CHANGED
|
@@ -321,6 +321,30 @@ export const vaultGrants = pgTable(
|
|
|
321
321
|
],
|
|
322
322
|
);
|
|
323
323
|
|
|
324
|
+
/**
|
|
325
|
+
* Each key the vault released to a principal, and when last: what its bulk
|
|
326
|
+
* limit counts (R28), the distinct keys released within a window, without
|
|
327
|
+
* reading the log. The database keeps it from the log itself, in the
|
|
328
|
+
* transaction of each vault `secret.read` allowed: a trigger on
|
|
329
|
+
* `audit_log` upserts a row for each key the entry names, as the count
|
|
330
|
+
* read them from the entries before (an entry that names none, which only
|
|
331
|
+
* a forged one is, counts as a key of its own, `entry:<seq>`). No login
|
|
332
|
+
* writes it: the vault and the backup read it. A row a window old counts
|
|
333
|
+
* for nothing, so nothing prunes them: there are at most as many as
|
|
334
|
+
* principals times keys, and a count reads one principal's.
|
|
335
|
+
*/
|
|
336
|
+
export const vaultReleases = pgTable(
|
|
337
|
+
'vault_releases',
|
|
338
|
+
{
|
|
339
|
+
principal: text().notNull(),
|
|
340
|
+
key: text().notNull(),
|
|
341
|
+
releasedAt: bigint('released_at', { mode: 'number' }).notNull(),
|
|
342
|
+
},
|
|
343
|
+
// The key alone is indexed: a read moves its keys' times on in place (a HOT update), leaving no index entry behind,
|
|
344
|
+
// and the count reads the principal's keys from the key, a row each, however often they are read.
|
|
345
|
+
(table) => [primaryKey({ name: 'vault_releases_pkey', columns: [table.principal, table.key] })],
|
|
346
|
+
);
|
|
347
|
+
|
|
324
348
|
export const auditLog = pgTable(
|
|
325
349
|
'audit_log',
|
|
326
350
|
{
|