@coffre/vault 0.9.0 → 0.10.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.
@@ -1,5 +1,5 @@
1
- import { a as KekUnavailableError, c as awsKms, d as Kek, f as People, i as KekProvider, l as checkpointMessage, m as derivedSigningKey, n as AwsKmsOptions, o as SecretContext, p as VaultConfig, r as KekBadClaimError, s as WrappedDek, t as AwsCredentials, u as verifyCheckpoint } from "./index-BkHJR9Gt.js";
2
- import { AdmitInput, EndReferencesInput, ReferenceInput, RemoveInput, RewrapInput, SetAccessInput, SetSettingsInput, UnwrapInput, Vault, VerifyLogInput, WrapInput } from "@coffre/core/vault";
1
+ import { a as KekUnavailableError, c as awsKms, d as Kek, f as VaultConfig, i as KekProvider, l as checkpointMessage, n as AwsKmsOptions, o as SecretContext, p as derivedSigningKey, r as KekBadClaimError, s as WrappedDek, t as AwsCredentials, u as verifyCheckpoint } from "./index-CByXzyi-.js";
2
+ import { AdmitInput, ChangePolicyInput, EndReferencesInput, ReferenceInput, RemoveInput, RewrapInput, SetAccessInput, SetSettingsInput, UnwrapInput, Vault, VerifyLogInput, WrapInput } from "@coffre/core/vault";
3
3
  import { PostgresDatabase, PostgresDatabase as PostgresDatabase$1, postgres } from "@coffre/db/hyperdrive";
4
4
  import { WorkerEntrypoint } from "cloudflare:workers";
5
5
  export * from "@coffre/core/vault";
@@ -19,14 +19,8 @@ export declare class VaultEntrypoint extends WorkerEntrypoint implements Vault {
19
19
  unwrap(input: UnwrapInput): Promise<import("@coffre/core/vault").Outcome<{
20
20
  keys: string[];
21
21
  }>>;
22
- wrap(input: WrapInput): Promise<import("@coffre/core/vault").Outcome<{
23
- wrapped: import("@coffre/core/vault").WrappedKey[];
24
- seqs: number[];
25
- }>>;
26
- rewrap(input: RewrapInput): Promise<import("@coffre/core/vault").Outcome<{
27
- wrapped: import("@coffre/core/vault").WrappedKey[];
28
- seqs: number[];
29
- }>>;
22
+ wrap(input: WrapInput): Promise<import("@coffre/core/vault").Outcome<import("@coffre/core/vault").Wrapped>>;
23
+ rewrap(input: RewrapInput): Promise<import("@coffre/core/vault").Outcome<import("@coffre/core/vault").Wrapped>>;
30
24
  reference(input: ReferenceInput): Promise<import("@coffre/core/vault").Outcome<{
31
25
  seqs: number[];
32
26
  }>>;
@@ -47,6 +41,11 @@ export declare class VaultEntrypoint extends WorkerEntrypoint implements Vault {
47
41
  setSettings(input: SetSettingsInput): Promise<import("@coffre/core/vault").Outcome<{
48
42
  settings: import("@coffre/core/vault").Settings;
49
43
  }>>;
44
+ policy(): Promise<import("@coffre/core/access").Policy>;
45
+ changePolicy(input: ChangePolicyInput): Promise<import("@coffre/core/vault").Outcome<{
46
+ policy: import("@coffre/core/access").Policy;
47
+ seq: number | null;
48
+ }>>;
50
49
  checkpoint(): Promise<import("@coffre/core/vault").Outcome<{
51
50
  checkpoint: import("@coffre/core/vault").Checkpoint;
52
51
  }>>;
@@ -63,4 +62,4 @@ export declare class VaultEntrypoint extends WorkerEntrypoint implements Vault {
63
62
  /** The vault Worker's default export, `VaultEntrypoint`, configured from its `env`. */
64
63
  export declare function vault<Env>(configure_: (env: Env) => WorkersVaultConfig): typeof VaultEntrypoint;
65
64
  //#endregion
66
- export { type AwsCredentials, type AwsKmsOptions, type Kek, KekBadClaimError, type KekProvider, KekUnavailableError, type People, type PostgresDatabase, type SecretContext, type Vault, type VaultConfig, type WrappedDek, awsKms, checkpointMessage, derivedSigningKey, postgres, verifyCheckpoint };
65
+ export { type AwsCredentials, type AwsKmsOptions, type Kek, KekBadClaimError, type KekProvider, KekUnavailableError, type PostgresDatabase, type SecretContext, type Vault, type VaultConfig, type WrappedDek, awsKms, checkpointMessage, derivedSigningKey, postgres, verifyCheckpoint };
@@ -1,5 +1,5 @@
1
- import { a as verifyCheckpoint, i as checkpointMessage, n as KekUnavailableError, o as derivedSigningKey, r as awsKms, s as resolveVaultConfig, t as KekBadClaimError } from "./src-BcttALFQ.js";
2
- import { n as prepareVault, t as openVault } from "./vault-lBbyZ3kQ.js";
1
+ import { a as verifyCheckpoint, i as checkpointMessage, n as KekUnavailableError, o as derivedSigningKey, r as awsKms, s as resolveVaultConfig, t as KekBadClaimError } from "./src-D82jyprb.js";
2
+ import { n as prepareVault, t as openVault } from "./vault-COqZ12ny.js";
3
3
  import { createDatabase } from "@coffre/db";
4
4
  import { HyperdrivePool, postgres } from "@coffre/db/hyperdrive";
5
5
  import { WorkerEntrypoint } from "cloudflare:workers";
@@ -76,6 +76,12 @@ var VaultEntrypoint = class extends WorkerEntrypoint {
76
76
  async setSettings(input) {
77
77
  return this.#call((vault) => vault.setSettings(input));
78
78
  }
79
+ async policy() {
80
+ return this.#call((vault) => vault.policy());
81
+ }
82
+ async changePolicy(input) {
83
+ return this.#call((vault) => vault.changePolicy(input));
84
+ }
79
85
  async checkpoint() {
80
86
  return this.#call((vault) => vault.checkpoint());
81
87
  }
@@ -2,15 +2,6 @@ import { checkpointMessage as checkpointMessage$1, verifyCheckpoint } from "@cof
2
2
  import { AwsCredentials, AwsKmsOptions, KekBadClaimError as KekBadClaimError$1, KekProvider, KekProvider as KekProvider$1, KekRegistry, KekUnavailableError as KekUnavailableError$1, WrappedDek, awsKms } from "@coffre/core/kek";
3
3
  import { SecretContext } from "@coffre/core/envelope";
4
4
  //#region src/config.d.ts
5
- /**
6
- * What a person's reads open (docs/design/credential-proxy.md): `values`,
7
- * as any member's; or `stand-ins`, where a person, on any credential of
8
- * theirs (a session, a personal token, an MCP connection), opens values
9
- * only for coffre to use for them, never to be handed back: the credential
10
- * proxy injects them, and the deployment's `expose` list names the few it
11
- * may pass on. Service accounts read values either way.
12
- */
13
- type People = 'values' | 'stand-ins';
14
5
  /**
15
6
  * A key-encryption key: 32 random bytes, base64, and the id envelopes record
16
7
  * it under; or one a key service holds, such as `awsKms({ keyArn, … })`.
@@ -50,8 +41,12 @@ type VaultConfig = {
50
41
  count: number;
51
42
  windowMinutes: number;
52
43
  };
53
- /** What a person's reads open (`People`): `values` unless set. */
54
- people?: People;
44
+ /**
45
+ * @deprecated Gone in 0.10, and refused: each key says who sees it now. Mark
46
+ * those no person may read sensitive (`coffre mark <env> sensitive`), and
47
+ * give people read through their roles where they should see values.
48
+ */
49
+ people?: 'gone in 0.10: mark keys sensitive (coffre mark <env> sensitive), and let roles say who reads the rest';
55
50
  } & Owners;
56
51
  /**
57
52
  * At least one email, each an Owner of the whole instance: made one when
@@ -80,4 +75,4 @@ type Owners = {
80
75
  /** The signing key a local KEK stands for, when the vault is given none: HKDF-SHA-256 of the KEK. */
81
76
  declare function derivedSigningKey(kek: Uint8Array): Buffer;
82
77
  //#endregion
83
- export { KekUnavailableError$1 as a, awsKms as c, Kek as d, People as f, KekProvider$1 as i, checkpointMessage$1 as l, derivedSigningKey as m, AwsKmsOptions as n, SecretContext as o, VaultConfig as p, KekBadClaimError$1 as r, WrappedDek as s, AwsCredentials as t, verifyCheckpoint as u };
78
+ export { KekUnavailableError$1 as a, awsKms as c, Kek as d, VaultConfig as f, KekProvider$1 as i, checkpointMessage$1 as l, AwsKmsOptions as n, SecretContext as o, derivedSigningKey as p, KekBadClaimError$1 as r, WrappedDek as s, AwsCredentials as t, verifyCheckpoint as u };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { a as KekUnavailableError, c as awsKms, d as Kek, f as People, i as KekProvider, l as checkpointMessage, m as derivedSigningKey, n as AwsKmsOptions, o as SecretContext, p as VaultConfig, r as KekBadClaimError, s as WrappedDek, t as AwsCredentials, u as verifyCheckpoint } from "./index-BkHJR9Gt.js";
1
+ import { a as KekUnavailableError, c as awsKms, d as Kek, f as VaultConfig, i as KekProvider, l as checkpointMessage, n as AwsKmsOptions, o as SecretContext, p as derivedSigningKey, r as KekBadClaimError, s as WrappedDek, t as AwsCredentials, u as verifyCheckpoint } from "./index-CByXzyi-.js";
2
2
  export type * from "@coffre/core/vault";
3
- export { type AwsCredentials, type AwsKmsOptions, type Kek, KekBadClaimError, type KekProvider, KekUnavailableError, type People, type SecretContext, type VaultConfig, type WrappedDek, awsKms, checkpointMessage, derivedSigningKey, verifyCheckpoint };
3
+ export { type AwsCredentials, type AwsKmsOptions, type Kek, KekBadClaimError, type KekProvider, KekUnavailableError, type SecretContext, type VaultConfig, type WrappedDek, awsKms, checkpointMessage, derivedSigningKey, verifyCheckpoint };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as verifyCheckpoint, i as checkpointMessage, n as KekUnavailableError, o as derivedSigningKey, r as awsKms, t as KekBadClaimError } from "./src-BcttALFQ.js";
1
+ import { a as verifyCheckpoint, i as checkpointMessage, n as KekUnavailableError, o as derivedSigningKey, r as awsKms, t as KekBadClaimError } from "./src-D82jyprb.js";
2
2
  export { KekBadClaimError, KekUnavailableError, awsKms, checkpointMessage, derivedSigningKey, verifyCheckpoint };
package/dist/node.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as KekUnavailableError, c as awsKms, d as Kek, f as People, i as KekProvider, l as checkpointMessage, m as derivedSigningKey, n as AwsKmsOptions, o as SecretContext, p as VaultConfig, r as KekBadClaimError, s as WrappedDek, t as AwsCredentials, u as verifyCheckpoint } from "./index-BkHJR9Gt.js";
1
+ import { a as KekUnavailableError, c as awsKms, d as Kek, f as VaultConfig, i as KekProvider, l as checkpointMessage, n as AwsKmsOptions, o as SecretContext, p as derivedSigningKey, r as KekBadClaimError, s as WrappedDek, t as AwsCredentials, u as verifyCheckpoint } from "./index-CByXzyi-.js";
2
2
  import { Vault, Vault as Vault$1 } from "@coffre/core/vault";
3
3
  import { Database } from "@coffre/db";
4
4
  import "@coffre/core/audit";
@@ -45,4 +45,4 @@ export declare function serveVault(config: NodeVaultConfig & {
45
45
  /** The vault that `serveVault` runs, from the server's side of its socket. */
46
46
  export declare function connectVault(socket: string): Vault;
47
47
  //#endregion
48
- export { type AwsCredentials, type AwsKmsOptions, type Kek, KekBadClaimError, type KekProvider, KekUnavailableError, type LocalVault, type People, type SecretContext, type Vault, type VaultConfig, type VaultOptions, type WrappedDek, awsKms, checkpointMessage, derivedSigningKey, verifyCheckpoint };
48
+ export { type AwsCredentials, type AwsKmsOptions, type Kek, KekBadClaimError, type KekProvider, KekUnavailableError, type LocalVault, type SecretContext, type Vault, type VaultConfig, type VaultOptions, type WrappedDek, awsKms, checkpointMessage, derivedSigningKey, verifyCheckpoint };
package/dist/node.js CHANGED
@@ -1,5 +1,5 @@
1
- import { a as verifyCheckpoint, i as checkpointMessage, n as KekUnavailableError, o as derivedSigningKey, r as awsKms, s as resolveVaultConfig, t as KekBadClaimError } from "./src-BcttALFQ.js";
2
- import { n as prepareVault, t as openVault } from "./vault-lBbyZ3kQ.js";
1
+ import { a as verifyCheckpoint, i as checkpointMessage, n as KekUnavailableError, o as derivedSigningKey, r as awsKms, s as resolveVaultConfig, t as KekBadClaimError } from "./src-D82jyprb.js";
2
+ import { n as prepareVault, t as openVault } from "./vault-COqZ12ny.js";
3
3
  import { chmodSync, existsSync, lstatSync, rmSync } from "node:fs";
4
4
  import { Agent, createServer, request } from "node:http";
5
5
  import { openDatabase } from "@coffre/db/connect";
@@ -17,6 +17,8 @@ const METHODS = [
17
17
  "remove",
18
18
  "settings",
19
19
  "setSettings",
20
+ "policy",
21
+ "changePolicy",
20
22
  "checkpoint",
21
23
  "about",
22
24
  "keyChecks",
@@ -48,6 +48,7 @@ function kek(entry) {
48
48
  }
49
49
  /** Check a deployment's vault configuration, failing on the first problem. */
50
50
  function resolveVaultConfig(config) {
51
+ if ("people" in config && config.people !== void 0) throw new Error(`people is gone in 0.10 (it was ${JSON.stringify(config.people)}): each key says who sees it now. Remove people, mark the keys no person may read sensitive (coffre mark <env> sensitive, or coffre set <env>/<KEY> --sensitive), and let roles say who reads the rest (docs/design/credential-proxy.md)`);
51
52
  const keks = [config.kek, ...config.previousKeks ?? []].map(kek);
52
53
  const [current, ...previous] = keks.map((entry) => entry.provider);
53
54
  const refs = [current, ...previous].map(({ provider, keyId }) => `${provider}:${keyId}`);
@@ -57,8 +58,7 @@ function resolveVaultConfig(config) {
57
58
  keks: new KekRegistry(current, previous),
58
59
  owners: checkOwners(config.owners ?? config.bootstrapOwners ?? config.rootAdmins ?? []),
59
60
  signingKeys: signingKeys(config.signingKey, keks),
60
- bulkLimit: config.bulkLimit === void 0 ? DEFAULT_BULK_LIMIT : checkBulkLimit(config.bulkLimit),
61
- people: checkPeople(config.people ?? "values")
61
+ bulkLimit: config.bulkLimit === void 0 ? DEFAULT_BULK_LIMIT : checkBulkLimit(config.bulkLimit)
62
62
  };
63
63
  }
64
64
  /**
@@ -81,10 +81,6 @@ function signingKeys(given, keks) {
81
81
  }
82
82
  return [signing, ...derived].filter((key, i, all) => all.findIndex((other) => other.equals(key)) === i);
83
83
  }
84
- function checkPeople(people) {
85
- if (people !== "values" && people !== "stand-ins") throw new Error(`people is 'values' or 'stand-ins'; got ${JSON.stringify(people)}`);
86
- return people;
87
- }
88
84
  function checkBulkLimit({ count, windowMinutes }) {
89
85
  if (!Number.isInteger(count) || count < 1 || !(windowMinutes > 0)) throw new Error("bulkLimit needs a whole count of at least 1 and a window above 0 minutes");
90
86
  return {