@coffre/db 0.6.2 → 0.8.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 (72) hide show
  1. package/dist/connect.d.ts +1 -1
  2. package/dist/{database-C63WjCrC.d.ts → database-BEnexh-3.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 +22 -1
  8. package/dist/log.js +37 -2
  9. package/dist/migrations/postgres/0004_environment_parents.sql +5 -0
  10. package/dist/migrations/postgres/0005_personal_tokens.sql +5 -0
  11. package/dist/migrations/postgres/0006_uploaded_keys.sql +2 -0
  12. package/dist/migrations/postgres/0007_personal_configs.sql +4 -0
  13. package/dist/migrations/postgres/0008_recipes.sql +19 -0
  14. package/dist/migrations/postgres/0009_handles.sql +3 -0
  15. package/dist/migrations/postgres/meta/0004_snapshot.json +2913 -0
  16. package/dist/migrations/postgres/meta/0005_snapshot.json +2929 -0
  17. package/dist/migrations/postgres/meta/0006_snapshot.json +2935 -0
  18. package/dist/migrations/postgres/meta/0007_snapshot.json +2967 -0
  19. package/dist/migrations/postgres/meta/0008_snapshot.json +2985 -0
  20. package/dist/migrations/postgres/meta/0009_snapshot.json +2985 -0
  21. package/dist/migrations/postgres/meta/_journal.json +42 -0
  22. package/dist/migrations/sqlite/0004_environment_parents.sql +3 -0
  23. package/dist/migrations/sqlite/0005_personal_tokens.sql +37 -0
  24. package/dist/migrations/sqlite/0006_uploaded_keys.sql +1 -0
  25. package/dist/migrations/sqlite/0007_personal_configs.sql +3 -0
  26. package/dist/migrations/sqlite/0008_recipes.sql +15 -0
  27. package/dist/migrations/sqlite/0009_handles.sql +36 -0
  28. package/dist/migrations/sqlite/meta/0004_snapshot.json +2641 -0
  29. package/dist/migrations/sqlite/meta/0005_snapshot.json +2656 -0
  30. package/dist/migrations/sqlite/meta/0006_snapshot.json +2663 -0
  31. package/dist/migrations/sqlite/meta/0007_snapshot.json +2683 -0
  32. package/dist/migrations/sqlite/meta/0008_snapshot.json +2704 -0
  33. package/dist/migrations/sqlite/meta/0009_snapshot.json +2704 -0
  34. package/dist/migrations/sqlite/meta/_journal.json +42 -0
  35. package/dist/portable.d.ts +2 -2
  36. package/dist/{schema-a7PkFgea.d.ts → schema-BZRkBJQZ.d.ts} +102 -0
  37. package/dist/schema-sqlite.d.ts +114 -0
  38. package/dist/schema-sqlite.js +20 -4
  39. package/dist/schema-version.d.ts +1 -1
  40. package/dist/schema-version.js +84 -0
  41. package/dist/schema.d.ts +1 -1
  42. package/dist/schema.js +20 -4
  43. package/package.json +2 -2
  44. package/src/log.ts +40 -1
  45. package/src/migrations/postgres/0004_environment_parents.sql +5 -0
  46. package/src/migrations/postgres/0005_personal_tokens.sql +5 -0
  47. package/src/migrations/postgres/0006_uploaded_keys.sql +2 -0
  48. package/src/migrations/postgres/0007_personal_configs.sql +4 -0
  49. package/src/migrations/postgres/0008_recipes.sql +19 -0
  50. package/src/migrations/postgres/0009_handles.sql +3 -0
  51. package/src/migrations/postgres/meta/0004_snapshot.json +2913 -0
  52. package/src/migrations/postgres/meta/0005_snapshot.json +2929 -0
  53. package/src/migrations/postgres/meta/0006_snapshot.json +2935 -0
  54. package/src/migrations/postgres/meta/0007_snapshot.json +2967 -0
  55. package/src/migrations/postgres/meta/0008_snapshot.json +2985 -0
  56. package/src/migrations/postgres/meta/0009_snapshot.json +2985 -0
  57. package/src/migrations/postgres/meta/_journal.json +42 -0
  58. package/src/migrations/sqlite/0004_environment_parents.sql +3 -0
  59. package/src/migrations/sqlite/0005_personal_tokens.sql +37 -0
  60. package/src/migrations/sqlite/0006_uploaded_keys.sql +1 -0
  61. package/src/migrations/sqlite/0007_personal_configs.sql +3 -0
  62. package/src/migrations/sqlite/0008_recipes.sql +15 -0
  63. package/src/migrations/sqlite/0009_handles.sql +36 -0
  64. package/src/migrations/sqlite/meta/0004_snapshot.json +2641 -0
  65. package/src/migrations/sqlite/meta/0005_snapshot.json +2656 -0
  66. package/src/migrations/sqlite/meta/0006_snapshot.json +2663 -0
  67. package/src/migrations/sqlite/meta/0007_snapshot.json +2683 -0
  68. package/src/migrations/sqlite/meta/0008_snapshot.json +2704 -0
  69. package/src/migrations/sqlite/meta/0009_snapshot.json +2704 -0
  70. package/src/migrations/sqlite/meta/_journal.json +42 -0
  71. package/src/schema.sqlite.ts +31 -3
  72. package/src/schema.ts +37 -3
@@ -0,0 +1,19 @@
1
+ ALTER TABLE "secret_versions" ADD COLUMN "recipe" text;--> statement-breakpoint
2
+ ALTER TABLE "secret_versions" ADD COLUMN "pair_id" uuid;--> statement-breakpoint
3
+ ALTER TABLE "secret_versions" ADD COLUMN "pair_half" text;--> statement-breakpoint
4
+ -- A version is still only ever erased: its recipe and its pair with it.
5
+ CREATE OR REPLACE FUNCTION secret_versions_erase_only() RETURNS trigger LANGUAGE plpgsql AS $$
6
+ BEGIN
7
+ IF octet_length(NEW.ciphertext) <> 0 OR octet_length(NEW.wrapped_dek) <> 0
8
+ OR (NEW.id, NEW.secret_id, NEW.version, NEW.envelope_version, NEW.iv, NEW.auth_tag,
9
+ NEW.kek_provider, NEW.kek_id, NEW.kek_version, NEW.created_at, NEW.created_by,
10
+ NEW.recipe, NEW.pair_id, NEW.pair_half)
11
+ IS DISTINCT FROM
12
+ (OLD.id, OLD.secret_id, OLD.version, OLD.envelope_version, OLD.iv, OLD.auth_tag,
13
+ OLD.kek_provider, OLD.kek_id, OLD.kek_version, OLD.created_at, OLD.created_by,
14
+ OLD.recipe, OLD.pair_id, OLD.pair_half) THEN
15
+ RAISE EXCEPTION 'a secret version is only ever erased' USING ERRCODE = 'insufficient_privilege';
16
+ END IF;
17
+ RETURN NEW;
18
+ END
19
+ $$;
@@ -0,0 +1,3 @@
1
+ -- Handles (0.8): the stand-ins a person's app holds, which reach only the credential proxy. The check widens to their kind: the release before makes none, and refuses one, whose prefix, coffre_use_, it does not take for a token.
2
+ ALTER TABLE "credentials" DROP CONSTRAINT "credentials_kind_check";--> statement-breakpoint
3
+ ALTER TABLE "credentials" ADD CONSTRAINT "credentials_kind_check" CHECK ("credentials"."kind" IN ('browser', 'cli', 'service', 'personal', 'handle'));