@jini-ai/platform 0.7.1 → 0.7.3-next.1

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 (165) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/README.md +16 -4
  3. package/dist/asset-cache.d.ts +13 -3
  4. package/dist/asset-cache.js +163 -154
  5. package/dist/blob-storage.d.ts +3 -32
  6. package/dist/blob-storage.js +1 -9
  7. package/dist/child-environment.d.ts +0 -16
  8. package/dist/child-environment.js +0 -25
  9. package/dist/command.d.ts +6 -11
  10. package/dist/command.js +8 -54
  11. package/dist/download-lock.d.ts +4 -0
  12. package/dist/download-lock.js +82 -0
  13. package/dist/download-maintenance.d.ts +5 -0
  14. package/dist/download-maintenance.js +82 -0
  15. package/dist/download-state.d.ts +8 -0
  16. package/dist/download-state.js +126 -0
  17. package/dist/download-store.d.ts +22 -0
  18. package/dist/download-store.js +174 -0
  19. package/dist/download-target.d.ts +10 -0
  20. package/dist/download-target.js +102 -0
  21. package/dist/download-transfer.d.ts +12 -0
  22. package/dist/download-transfer.js +174 -0
  23. package/dist/download-types.d.ts +162 -0
  24. package/dist/download-types.js +31 -0
  25. package/dist/download.d.ts +1 -89
  26. package/dist/download.js +8 -738
  27. package/dist/fetch-with-timeout.d.ts +7 -32
  28. package/dist/fetch-with-timeout.js +1 -77
  29. package/dist/fs/app-data-root.d.ts +28 -0
  30. package/dist/fs/app-data-root.js +35 -0
  31. package/dist/fs/atomic-write.js +1 -1
  32. package/dist/fs/boot-identity.d.ts +1 -4
  33. package/dist/fs/directory-delete-guard.d.ts +93 -0
  34. package/dist/fs/directory-delete-guard.js +148 -0
  35. package/dist/fs/directory-registry.js +45 -35
  36. package/dist/fs/directory-relocation.d.ts +82 -0
  37. package/dist/fs/directory-relocation.js +99 -0
  38. package/dist/fs/directory-running-lock.d.ts +1 -1
  39. package/dist/fs/directory-running-lock.js +24 -21
  40. package/dist/fs/directory-sync.js +1 -1
  41. package/dist/fs/directory-user-config.js +30 -3
  42. package/dist/fs/directory-workspace.d.ts +34 -30
  43. package/dist/fs/directory-workspace.js +70 -29
  44. package/dist/fs/durable-json.d.ts +6 -15
  45. package/dist/fs/durable-json.js +38 -35
  46. package/dist/fs/errno.d.ts +12 -3
  47. package/dist/fs/errno.js +5 -3
  48. package/dist/fs/file-lock.d.ts +3 -87
  49. package/dist/fs/file-lock.js +16 -30
  50. package/dist/fs/guarded-reader.js +335 -315
  51. package/dist/fs/index.d.ts +5 -0
  52. package/dist/fs/index.js +5 -0
  53. package/dist/fs/recent-directories.d.ts +46 -0
  54. package/dist/fs/recent-directories.js +68 -0
  55. package/dist/fs/remove-directory-tree.d.ts +20 -0
  56. package/dist/fs/remove-directory-tree.js +28 -0
  57. package/dist/fs/user-data-directories.js +2 -2
  58. package/dist/fs/workspace-directory.js +2 -1
  59. package/dist/fs.d.ts +16 -4
  60. package/dist/fs.js +4 -4
  61. package/dist/home-expansion.d.ts +7 -2
  62. package/dist/home-expansion.js +3 -3
  63. package/dist/http/guarded/client.d.ts +1 -2
  64. package/dist/http/guarded/client.js +2 -1
  65. package/dist/http/guarded/index.d.ts +0 -3
  66. package/dist/http/guarded/node-ports.d.ts +1 -1
  67. package/dist/http/guarded/transport.fetch.d.ts +2 -3
  68. package/dist/http/guarded/transport.fetch.js +64 -58
  69. package/dist/http.d.ts +3 -1
  70. package/dist/http.js +2 -2
  71. package/dist/index.d.ts +10 -11
  72. package/dist/index.js +7 -6
  73. package/dist/mail/activity/activity.d.ts +136 -0
  74. package/dist/mail/activity/activity.js +172 -0
  75. package/dist/mail/activity/ports.d.ts +113 -0
  76. package/dist/mail/activity/suppressions.d.ts +82 -0
  77. package/dist/mail/activity/suppressions.js +119 -0
  78. package/dist/mail/activity/vocabulary.d.ts +10 -0
  79. package/dist/mail/activity/vocabulary.js +8 -0
  80. package/dist/mail/builtin-providers.d.ts +12 -6
  81. package/dist/mail/builtin-providers.js +14 -11
  82. package/dist/mail/delivery-wrapper.js +2 -1
  83. package/dist/mail/email-sender-registry.d.ts +1 -1
  84. package/dist/mail/email-sender-registry.js +1 -1
  85. package/dist/mail/email-template-operations.d.ts +186 -0
  86. package/dist/mail/email-template-operations.js +226 -0
  87. package/dist/mail/email-template.d.ts +120 -0
  88. package/dist/mail/email-template.js +243 -0
  89. package/dist/mail/index.d.ts +4 -0
  90. package/dist/mail/index.js +3 -0
  91. package/dist/mail/prepare-sender-email.d.ts +1 -10
  92. package/dist/mail/prepare-sender-email.js +1 -11
  93. package/dist/mail/resolve-mailer.d.ts +2 -1
  94. package/dist/mail/resolve-mailer.js +5 -2
  95. package/dist/mail/senders.d.ts +0 -1
  96. package/dist/mail/senders.js +0 -1
  97. package/dist/mail/smtp.d.ts +1 -31
  98. package/dist/net/address.d.ts +1 -8
  99. package/dist/net/address.js +1 -18
  100. package/dist/net/index.d.ts +1 -1
  101. package/dist/net/index.js +1 -1
  102. package/dist/net/local-http-probe.js +1 -1
  103. package/dist/net/local-http-request.js +1 -1
  104. package/dist/process-probes.d.ts +36 -0
  105. package/dist/process-probes.js +151 -0
  106. package/dist/process-top-footprint.d.ts +7 -0
  107. package/dist/process-top-footprint.js +30 -0
  108. package/dist/process.d.ts +29 -31
  109. package/dist/process.js +18 -196
  110. package/dist/proxy-env.d.ts +12 -3
  111. package/dist/proxy-env.js +9 -8
  112. package/dist/resource-paths.d.ts +15 -3
  113. package/dist/resource-paths.js +7 -5
  114. package/dist/sandbox-env.d.ts +26 -5
  115. package/dist/sandbox-env.js +7 -7
  116. package/dist/secrets/credential-sets/contracts.d.ts +0 -1
  117. package/dist/secrets/credential-sets/contracts.js +0 -1
  118. package/dist/secrets/credential-sets/index.d.ts +2 -3
  119. package/dist/secrets/credential-sets/index.js +1 -1
  120. package/dist/secrets/credential-sets/provider-matches.d.ts +1 -1
  121. package/dist/secrets/credential-sets/provider-matches.js +1 -1
  122. package/dist/secrets/credential-sets/vault-archive.d.ts +1 -1
  123. package/dist/secrets/credential-sets/vault-archive.js +14 -8
  124. package/dist/secrets/credential-sets/vault.aad.d.ts +1 -1
  125. package/dist/secrets/credential-sets/vault.meta.d.ts +1 -1
  126. package/dist/secrets/credential-sets/vault.meta.js +1 -1
  127. package/dist/secrets/credential-sets/vault.repo.memory.d.ts +1 -1
  128. package/dist/secrets/credential-sets/vault.repo.memory.js +1 -1
  129. package/dist/secrets/credential-sets/vault.reseal-refused.d.ts +23 -0
  130. package/dist/secrets/credential-sets/vault.reseal-refused.js +36 -0
  131. package/dist/secrets/credential-sets/vault.service.d.ts +25 -5
  132. package/dist/secrets/credential-sets/vault.service.js +42 -8
  133. package/dist/secrets/index.d.ts +0 -3
  134. package/dist/secrets/index.js +5 -0
  135. package/dist/secrets/keyring.env.d.ts +1 -1
  136. package/dist/secrets/legacy-owner.d.ts +61 -0
  137. package/dist/secrets/legacy-owner.js +196 -0
  138. package/dist/secrets/root-key/decide.d.ts +89 -0
  139. package/dist/secrets/root-key/decide.js +60 -0
  140. package/dist/secrets/sealer-contract.d.ts +19 -0
  141. package/dist/secrets/sealer-contract.js +37 -0
  142. package/dist/secrets/secret-sealer.aesgcm.d.ts +1 -1
  143. package/dist/secrets/testing.d.ts +1 -0
  144. package/dist/secrets/testing.js +1 -0
  145. package/dist/shell.d.ts +4 -1
  146. package/dist/shell.js +1 -1
  147. package/dist/system.d.ts +6 -0
  148. package/dist/system.js +9 -0
  149. package/dist/terminal.d.ts +11 -96
  150. package/dist/terminal.js +80 -56
  151. package/dist/web/agent-tools.d.ts +107 -0
  152. package/dist/web/agent-tools.js +49 -0
  153. package/dist/web/index.d.ts +1 -0
  154. package/dist/web/index.js +1 -0
  155. package/package.json +38 -12
  156. package/dist/http/guarded/ports.d.ts +0 -56
  157. package/dist/http/guarded/types.d.ts +0 -8
  158. package/dist/http/guarded/types.js +0 -2
  159. package/dist/mail/email-sender.d.ts +0 -109
  160. package/dist/mail/email-sender.js +0 -10
  161. package/dist/net/endpoint-policy.d.ts +0 -39
  162. package/dist/net/endpoint-policy.js +0 -218
  163. package/dist/secrets/credential-sets/vault.types.d.ts +0 -27
  164. package/dist/secrets/credential-sets/vault.types.js +0 -49
  165. /package/dist/{http/guarded → mail/activity}/ports.js +0 -0
@@ -1,7 +1,8 @@
1
1
  import { credentialTokenHint } from "../credential-token.js";
2
2
  import { buildVaultAad } from "./vault.aad.js";
3
3
  import { isCopyableKind } from "./vault.meta.js";
4
- import { VAULT_KINDS, VaultError, isInVaultQueryScope } from "./vault.types.js";
4
+ import { VaultResealRefusedError } from "./vault.reseal-refused.js";
5
+ import { VAULT_KINDS, VaultError, isInVaultQueryScope, } from "@jini-ai/core/contracts/vault";
5
6
  /** Kinds whose payloads are addresses, environment maps or OAuth sessions, never single tokens. */
6
7
  const HINTLESS_KINDS = ["database-destination", "mcp-env", "mcp-auth"];
7
8
  function isNonEmptyString({ value }) {
@@ -106,10 +107,27 @@ export class SecretsVaultService {
106
107
  const plaintext = JSON.stringify(input.payload);
107
108
  return this.deps.sealer.seal({ plaintext, key: await this.deps.keyring.activeKey({}), aad: buildVaultAad(input.context) });
108
109
  }
109
- async open(record) {
110
+ /** Opens a fresh envelope with this service's own sealer, under the stored row's own binding, and
111
+ * requires the exact sealed plaintext back. A seal that cannot be read back would replace the only
112
+ * copy of a secret with something nobody can open.
113
+ * @throws VaultResealRefusedError naming the failing step, the key and the sealer error's name/code only. */
114
+ async assertOpensTo({ record, sealed, payload }) {
115
+ if (sealed === null)
116
+ return;
117
+ let reopened;
118
+ try {
119
+ reopened = await this.deps.sealer.open({ sealed }, { aad: buildVaultAad(record) });
120
+ }
121
+ catch (error) {
122
+ throw new VaultResealRefusedError({ step: "open-new-envelope", keyId: sealed.keyId }, { cause: error });
123
+ }
124
+ if (reopened !== JSON.stringify(payload))
125
+ throw new VaultResealRefusedError({ step: "plaintext-mismatch", keyId: sealed.keyId });
126
+ }
127
+ async open(record, { opener = this.deps.sealer } = {}) {
110
128
  if (!record.sealed)
111
129
  return null;
112
- const plaintext = await this.deps.sealer.open({ sealed: record.sealed }, { aad: buildVaultAad(record) });
130
+ const plaintext = await opener.open({ sealed: record.sealed }, { aad: buildVaultAad(record) });
113
131
  let payload;
114
132
  try {
115
133
  payload = JSON.parse(plaintext);
@@ -285,7 +303,9 @@ export class SecretsVaultService {
285
303
  return { status: "copied", ...(last4 ? { last4 } : {}) };
286
304
  }
287
305
  /** Overwrite keeps the target's default, revision chain and creation time. A new copy leaves
288
- * placement unspecified, so the repo's first-row rule applies (never the source's default flag). */
306
+ * placement unspecified, so the repo's first-row rule applies (never the source's default flag).
307
+ * An overwrite opens its fresh seal again before writing (see `assertOpensTo`), so a seal that cannot
308
+ * be read back leaves the existing target row as it was; a first copy does not. */
289
309
  async writeCopy({ source, record, targetIdentity, existing }) {
290
310
  if (existing && !isCompatibleOverwrite({ existing, record }))
291
311
  throw new VaultError({ code: "context" });
@@ -294,7 +314,12 @@ export class SecretsVaultService {
294
314
  ? { isDefault: existing.isDefault, revision: existing.revision + 1, createdAt: existing.createdAt }
295
315
  : { isDefault: undefined, revision: 1, createdAt: now };
296
316
  const candidate = this.parse({ ...record, ...targetIdentity, ...placement, updatedAt: now });
297
- candidate.sealed = await this.seal({ context: targetIdentity, payload: await source.open(record) });
317
+ const payload = await source.open(record);
318
+ candidate.sealed = await this.seal({ context: targetIdentity, payload });
319
+ // Overwrite replaces a secret that opens today, so a seal that cannot be read back must not reach
320
+ // the repo. A first copy has nothing to lose and, like put and prepare, adds no open.
321
+ if (existing)
322
+ await this.assertOpensTo({ record: existing, sealed: candidate.sealed, payload });
298
323
  // Reuse the source's hint policy without guessing a token field from a structured payload.
299
324
  const hintless = record.kind === "database-destination";
300
325
  candidate.last4 = hintless ? null : summary(record).last4;
@@ -329,14 +354,23 @@ export class SecretsVaultService {
329
354
  return summary(this.parse(await this.deps.repo.patchMeta({ workspaceId: input.workspaceId, id: input.id,
330
355
  expectedRevision: input.expectedRevision, patch, updatedAt: this.deps.now({}) })));
331
356
  }
332
- /** Re-seal using the active key; concurrent replacement wins through CAS. Metadata-only rows persist. */
333
- async rotate(input, _options = {}) {
357
+ /** Re-seal using the active key; concurrent replacement wins through CAS. Metadata-only rows persist.
358
+ * A re-seal that cannot be opened again under the row's own binding is refused before anything is
359
+ * written: rotation replaces the only copy of the secret, so a bad seal would destroy it.
360
+ * After a key switch the stored row no longer opens with this service's sealer: pass the previous
361
+ * key's opener as `sourceOpener` rather than binding `sealer.open` to it.
362
+ * @throws VaultResealRefusedError (`invalid-record`) when the new envelope does not open to the stored payload.
363
+ * @example await vault.rotate({ ...identity, expectedRevision }, { sourceOpener: previousKeySealer });
364
+ */
365
+ async rotate(input, { sourceOpener } = {}) {
334
366
  assertContext(input);
335
367
  await this.authorize({ action: "rotate", context: input });
336
368
  const existing = await this.find(input);
337
369
  if (existing?.revision !== input.expectedRevision)
338
370
  throw new VaultError({ code: "conflict" });
339
- const sealed = await this.seal({ context: input, payload: await this.open(existing) });
371
+ const payload = await this.open(existing, sourceOpener ? { opener: sourceOpener } : {});
372
+ const sealed = await this.seal({ context: input, payload });
373
+ await this.assertOpensTo({ record: existing, sealed, payload });
340
374
  return summary(this.parse(await this.deps.repo.put({ expectedRevision: input.expectedRevision,
341
375
  record: { ...existing, sealed, revision: existing.revision + 1, updatedAt: this.deps.now({}) } })));
342
376
  }
@@ -1,11 +1,9 @@
1
1
  export type { SealedSecret } from "./types.js";
2
- export type { KeyringPort, SecretSealerPort } from "./ports.js";
3
2
  export { AesGcmSecretSealer } from "./secret-sealer.aesgcm.js";
4
3
  export { sealWithPassphrase, openWithPassphrase } from "./passphrase-envelope.js";
5
4
  export type { PassphraseEnvelopeOptions } from "./passphrase-envelope.js";
6
5
  export { EnvOrFileKeyring } from "./keyring.env.js";
7
6
  export type { EnvOrFileKeyringRequired, EnvOrFileKeyringOptions } from "./keyring.env.js";
8
- export type { RootKeyHandle as SiteKeyHandle } from "./ports.js";
9
7
  export { FixedRootKeyKeyring as FixedSiteKeyKeyring } from "./keyring.env.js";
10
8
  export { UnusableRootKeyError as UnusableSiteKeyError } from "./keyring.env.js";
11
9
  export { RootKeyFileAlreadyExistsError as SiteKeyFileAlreadyExistsError } from "./keyring.env.js";
@@ -24,7 +22,6 @@ export type { RootKeyReveal as SiteKeyReveal } from "./keyring.env.js";
24
22
  export type { InspectRootKeyMaterialOptions as InspectSiteKeyMaterialOptions } from "./keyring.env.js";
25
23
  export type { GeneratedFileRootKey as GeneratedFileSiteKey } from "./keyring.env.js";
26
24
  /** @deprecated use SiteKeyHandle */
27
- export type { RootKeyHandle } from "./ports.js";
28
25
  /** @deprecated use FixedSiteKeyKeyring */
29
26
  export { FixedRootKeyKeyring } from "./keyring.env.js";
30
27
  /** @deprecated use UnusableSiteKeyError */
@@ -1,6 +1,8 @@
1
1
  export { AesGcmSecretSealer } from "./secret-sealer.aesgcm.js";
2
2
  export { sealWithPassphrase, openWithPassphrase } from "./passphrase-envelope.js";
3
3
  export { EnvOrFileKeyring } from "./keyring.env.js";
4
+ // Canonical public names; the implementation bindings retain compatibility for direct consumers.
5
+ // site-key-legacy: implementation binding; remove on/after 2026-11-01
4
6
  export { FixedRootKeyKeyring as FixedSiteKeyKeyring } from "./keyring.env.js"; // site-key-legacy: implementation binding; remove on/after 2026-11-01
5
7
  export { UnusableRootKeyError as UnusableSiteKeyError } from "./keyring.env.js"; // site-key-legacy: implementation binding; remove on/after 2026-11-01
6
8
  export { RootKeyFileAlreadyExistsError as SiteKeyFileAlreadyExistsError } from "./keyring.env.js"; // site-key-legacy: implementation binding; remove on/after 2026-11-01
@@ -11,6 +13,9 @@ export { revealRootKeyMaterial as revealSiteKeyMaterial } from "./keyring.env.js
11
13
  export { generateFileRootKey as generateFileSiteKey } from "./keyring.env.js"; // site-key-legacy: implementation binding; remove on/after 2026-11-01
12
14
  export { deriveFromRootKey as deriveFromSiteKey } from "./keyring.env.js"; // site-key-legacy: implementation binding; remove on/after 2026-11-01
13
15
  export { deriveSigningSecretFromRootKey as deriveSigningSecretFromSiteKey } from "./keyring.env.js"; // site-key-legacy: implementation binding; remove on/after 2026-11-01
16
+ // Temporary aliases preserve imports and constructor/function identity across the rename.
17
+ /** @deprecated use SiteKeyHandle */
18
+ // site-key-legacy: deprecated alias; remove on/after 2026-11-01
14
19
  /** @deprecated use FixedSiteKeyKeyring */
15
20
  export { FixedRootKeyKeyring } from "./keyring.env.js"; // site-key-legacy: deprecated alias; remove on/after 2026-11-01
16
21
  /** @deprecated use UnusableSiteKeyError */
@@ -1,5 +1,5 @@
1
1
  import { type PlatformMessages } from "../messages.js";
2
- import type { KeyringPort } from "./ports.js";
2
+ import type { KeyringPort } from "@jini-ai/core/contracts/vault";
3
3
  /** Environment access belongs to the host; the library never reads ambient process state. */
4
4
  export interface RootKeyEnvironmentPort {
5
5
  read(required: {
@@ -0,0 +1,61 @@
1
+ import { type VaultContext, type VaultKind, type VaultOptions, type VaultRepoPort } from "@jini-ai/core/contracts/vault";
2
+ import { SecretsVaultService, type VaultServiceDeps } from "./credential-sets/vault.service.js";
3
+ import type { VaultArchiveEntry } from "./credential-sets/vault-archive.js";
4
+ /** @file Decoder for a legacy owner store's passphrase backup and the vault policy that reads its
5
+ * `owner.db` rows (keyring, authorization, recovery error). Shared keys are now project references,
6
+ * so nothing here writes, migrates or generates a key. The SQL reads live in
7
+ * `@jini-ai/db/owner-store`; the file wiring lives in `@jini-ai/server/owner-store`.
8
+ */
9
+ export declare const OWNER_WORKSPACE_ID = "owner";
10
+ /** A site the legacy store copied an entry to (consumerId = the site's canonical folder). */
11
+ export interface LegacyOwnerDestination {
12
+ entryId: string;
13
+ consumerId: string;
14
+ }
15
+ /** grants: active copies. revocations: revoked copies whose site cleanup never finished. */
16
+ export interface LegacyOwnerSnapshot {
17
+ entries: VaultArchiveEntry[];
18
+ grants: LegacyOwnerDestination[];
19
+ revocations: LegacyOwnerDestination[];
20
+ }
21
+ /** Safe recovery guidance never includes underlying key material or vault payloads. */
22
+ export declare class OwnerStoreRecoveryError extends Error {
23
+ constructor();
24
+ }
25
+ /** Fixed owner scope still preserves feature ownership, which the vault's AAD authenticates. */
26
+ export declare function ownerContext(input: Pick<VaultContext, "kind" | "ownerKey" | "binding">, _options?: {}): VaultContext;
27
+ /** The legacy keyring exactly as the store wrote it; file fallback on, auto-generation off. */
28
+ export declare function openLegacyOwnerVault({ repo, keyFilePath }: {
29
+ repo: VaultRepoPort;
30
+ keyFilePath: string;
31
+ }, options?: Partial<Pick<VaultServiceDeps, "metaParsers">>): SecretsVaultService;
32
+ /** One authenticated decrypt; any key or envelope failure is the fixed recovery error. */
33
+ export declare function readLegacyOwnerEntry({ vault, row }: {
34
+ vault: SecretsVaultService;
35
+ row: {
36
+ id: string;
37
+ kind: VaultKind;
38
+ ownerKey: string;
39
+ binding: string | null;
40
+ };
41
+ }): Promise<VaultArchiveEntry>;
42
+ /** Fixed errors keep recovery diagnostics free of parsed secret values. */
43
+ export declare class OwnerStoreBackupError extends Error {
44
+ readonly code: "invalid-backup";
45
+ constructor({ code }: {
46
+ code: OwnerStoreBackupError["code"];
47
+ }, _options?: VaultOptions);
48
+ }
49
+ /** Authenticate, then structurally validate a legacy owner backup (v1 or v2) without writing anything.
50
+ * The importer, not this decoder, decides what reaches a project. Validation is unchanged from the
51
+ * old restore: unknown versions, duplicate IDs, malformed grants/cleanups and hint-policy breaks all
52
+ * fail as `invalid-backup` before any caller sees an entry.
53
+ * @throws OwnerStoreBackupError for malformed snapshots; passphrase/envelope errors propagate.
54
+ * @complexity O(n + payload bytes) with bounded platform KDF work.
55
+ * @example const { entries, grants } = await readLegacyOwnerBackup({ envelope, passphrase });
56
+ */
57
+ export declare function readLegacyOwnerBackup({ envelope, passphrase }: {
58
+ envelope: string;
59
+ passphrase: string;
60
+ }, _options?: VaultOptions): Promise<LegacyOwnerSnapshot>;
61
+ //# sourceMappingURL=legacy-owner.d.ts.map
@@ -0,0 +1,196 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { VAULT_KINDS, VaultError, } from "@jini-ai/core/contracts/vault";
3
+ import { EnvOrFileKeyring } from "./keyring.env.js";
4
+ import { openWithPassphrase } from "./passphrase-envelope.js";
5
+ import { AesGcmSecretSealer } from "./secret-sealer.aesgcm.js";
6
+ import { createVaultMetaParsers, isCopyableKind } from "./credential-sets/vault.meta.js";
7
+ import { SecretsVaultService } from "./credential-sets/vault.service.js";
8
+ /** @file Decoder for a legacy owner store's passphrase backup and the vault policy that reads its
9
+ * `owner.db` rows (keyring, authorization, recovery error). Shared keys are now project references,
10
+ * so nothing here writes, migrates or generates a key. The SQL reads live in
11
+ * `@jini-ai/db/owner-store`; the file wiring lives in `@jini-ai/server/owner-store`.
12
+ */
13
+ export const OWNER_WORKSPACE_ID = "owner";
14
+ /** Safe recovery guidance never includes underlying key material or vault payloads. */
15
+ export class OwnerStoreRecoveryError extends Error {
16
+ constructor() {
17
+ super("Owner store key is missing, invalid, or cannot open existing data. Restore the original owner key.");
18
+ this.name = "OwnerStoreRecoveryError";
19
+ }
20
+ }
21
+ /** Fixed owner scope still preserves feature ownership, which the vault's AAD authenticates. */
22
+ export function ownerContext(input, _options = {}) {
23
+ return { kind: input.kind, ownerKey: input.ownerKey, binding: input.binding, workspaceId: OWNER_WORKSPACE_ID, principalId: null };
24
+ }
25
+ /** The legacy keyring exactly as the store wrote it; file fallback on, auto-generation off. */
26
+ export function openLegacyOwnerVault({ repo, keyFilePath }, options = {}) {
27
+ const keyring = new EnvOrFileKeyring({ env: { read: () => undefined }, envVarName: "OWNER_STORE_KEY",
28
+ keyFilePath, hkdfSalt: "jini-owner-store-v1", allowFileFallback: true, allowFileAutoGenerate: false });
29
+ return new SecretsVaultService({ repo, keyring, sealer: new AesGcmSecretSealer({ keyring }),
30
+ metaParsers: options.metaParsers ?? createVaultMetaParsers({}), now: () => new Date().toISOString(), newId: () => randomUUID(),
31
+ authorize: async ({ context }) => {
32
+ if (context.workspaceId !== OWNER_WORKSPACE_ID || context.principalId !== null || !isCopyableKind[context.kind])
33
+ throw new VaultError({ code: "context" });
34
+ } });
35
+ }
36
+ /** One authenticated decrypt; any key or envelope failure is the fixed recovery error. */
37
+ export async function readLegacyOwnerEntry({ vault, row }) {
38
+ let entry;
39
+ try {
40
+ entry = await vault.get({ ...ownerContext({ kind: row.kind, ownerKey: row.ownerKey, binding: row.binding }), id: row.id });
41
+ }
42
+ catch {
43
+ throw new OwnerStoreRecoveryError();
44
+ }
45
+ if (!entry)
46
+ throw new OwnerStoreRecoveryError();
47
+ const { summary } = entry;
48
+ return { id: summary.id, kind: summary.kind, ownerKey: summary.ownerKey, binding: summary.binding, provider: summary.provider,
49
+ label: summary.label, isDefault: summary.isDefault, meta: summary.meta, payload: entry.payload };
50
+ }
51
+ const INVALID_BACKUP = "invalid-backup";
52
+ /** Version 1 had no cleanup records, so it cannot show whether a revoked copy is still on a site. */
53
+ const BACKUP_VERSION = 2;
54
+ /** Written by published @jini-ai/db 0.6.12: entries only, with no grants, destinations or cleanup records. */
55
+ const LEGACY_BACKUP_VERSION = 1;
56
+ const ENTRY_FIELDS = ["id", "kind", "ownerKey", "binding", "provider", "label", "isDefault", "meta", "payload"];
57
+ const HINT_FIELDS = ["last4", "tokenLength"];
58
+ const REVOCATION_FIELDS = ["entryId", "consumerId", "workspaceId", "attempts", "updatedAt"];
59
+ const GRANT_FIELDS = ["entryId", "consumerId", "workspaceId", "createdAt"];
60
+ /** Fixed errors keep recovery diagnostics free of parsed secret values. */
61
+ export class OwnerStoreBackupError extends Error {
62
+ code;
63
+ constructor({ code }, _options = {}) {
64
+ super(`Owner store backup: ${code}`);
65
+ this.name = "OwnerStoreBackupError";
66
+ this.code = code;
67
+ }
68
+ }
69
+ /** Authenticate, then structurally validate a legacy owner backup (v1 or v2) without writing anything.
70
+ * The importer, not this decoder, decides what reaches a project. Validation is unchanged from the
71
+ * old restore: unknown versions, duplicate IDs, malformed grants/cleanups and hint-policy breaks all
72
+ * fail as `invalid-backup` before any caller sees an entry.
73
+ * @throws OwnerStoreBackupError for malformed snapshots; passphrase/envelope errors propagate.
74
+ * @complexity O(n + payload bytes) with bounded platform KDF work.
75
+ * @example const { entries, grants } = await readLegacyOwnerBackup({ envelope, passphrase });
76
+ */
77
+ export async function readLegacyOwnerBackup({ envelope, passphrase }, _options = {}) {
78
+ const snapshot = parseSnapshot({ payload: await openWithPassphrase({ envelope, passphrase }) });
79
+ const destination = (row) => ({ entryId: row.entryId, consumerId: row.consumerId });
80
+ return { entries: snapshot.entries.map(({ last4: _last4, tokenLength: _length, ...entry }) => entry),
81
+ grants: snapshot.grants.map(destination), revocations: snapshot.revocations.map(destination) };
82
+ }
83
+ /** Reject unknown versions/duplicate IDs before any caller sees an entry.
84
+ * Version 1 (published @jini-ai/db 0.6.12 wrote it) has no grant or cleanup records, so every entry
85
+ * it holds comes back unreconciled: copies may sit on sites no record names.
86
+ */
87
+ function parseSnapshot({ payload }) {
88
+ let document;
89
+ try {
90
+ document = JSON.parse(payload);
91
+ }
92
+ catch {
93
+ throw new OwnerStoreBackupError({ code: INVALID_BACKUP });
94
+ }
95
+ if (!isObject(document) || document.format !== "jini-owner-store")
96
+ throw new OwnerStoreBackupError({ code: INVALID_BACKUP });
97
+ const entries = arrayOf(document.entries).map(parseEntry);
98
+ const ids = new Set(entries.map(entry => entry.id));
99
+ if (ids.size !== entries.length)
100
+ throw new OwnerStoreBackupError({ code: INVALID_BACKUP });
101
+ if (document.version === LEGACY_BACKUP_VERSION)
102
+ return { entries, grants: [], revocations: [], unreconciled: [...ids] };
103
+ if (document.version !== BACKUP_VERSION)
104
+ throw new OwnerStoreBackupError({ code: INVALID_BACKUP });
105
+ const grants = assertUniquePairs(arrayOf(document.grants).map(value => parseGrant({ value, ids })));
106
+ const revocations = assertUniquePairs(arrayOf(document.revocations).map(value => parseRevocation({ value, ids })));
107
+ const unreconciled = arrayOf(document.unreconciled);
108
+ if (unreconciled.some(id => !ids.has(id)) || new Set(unreconciled).size !== unreconciled.length) {
109
+ throw new OwnerStoreBackupError({ code: INVALID_BACKUP });
110
+ }
111
+ return { entries, grants, revocations, unreconciled: unreconciled };
112
+ }
113
+ /** A portable list, or the fixed error. */
114
+ function arrayOf(value) {
115
+ if (!Array.isArray(value))
116
+ throw new OwnerStoreBackupError({ code: INVALID_BACKUP });
117
+ return value;
118
+ }
119
+ /** One row per (entry, consumer), matching each table's primary key; JSON pairs avoid separator collisions. */
120
+ function assertUniquePairs(rows) {
121
+ if (new Set(rows.map(row => JSON.stringify([row.entryId, row.consumerId]))).size !== rows.length) {
122
+ throw new OwnerStoreBackupError({ code: INVALID_BACKUP });
123
+ }
124
+ return rows;
125
+ }
126
+ /** Exact fields, a restored entry, a named consumer and a named (or not yet bound) destination. */
127
+ function parseGrant({ value, ids }) {
128
+ if (!isObject(value) || Object.keys(value).length !== GRANT_FIELDS.length || GRANT_FIELDS.some(key => !Object.hasOwn(value, key))) {
129
+ throw new OwnerStoreBackupError({ code: INVALID_BACKUP });
130
+ }
131
+ const destination = value.workspaceId === null ? [] : [value.workspaceId];
132
+ const named = [value.consumerId, value.createdAt, ...destination].every(item => typeof item === "string" && item.length > 0);
133
+ if (!named || !ids.has(value.entryId))
134
+ throw new OwnerStoreBackupError({ code: INVALID_BACKUP });
135
+ return value;
136
+ }
137
+ /** Exact fields, a restored entry, a named site workspace and at least the one failure that created it. */
138
+ function parseRevocation({ value, ids }) {
139
+ if (!isObject(value) || Object.keys(value).length !== REVOCATION_FIELDS.length || REVOCATION_FIELDS.some(key => !Object.hasOwn(value, key))) {
140
+ throw new OwnerStoreBackupError({ code: INVALID_BACKUP });
141
+ }
142
+ const named = [value.consumerId, value.workspaceId, value.updatedAt].every(item => typeof item === "string" && item.length > 0);
143
+ if (!named || !ids.has(value.entryId) || !Number.isSafeInteger(value.attempts) || value.attempts < 1) {
144
+ throw new OwnerStoreBackupError({ code: INVALID_BACKUP });
145
+ }
146
+ return value;
147
+ }
148
+ /** Validate portable field types; the existing vault owns metadata and payload semantics. */
149
+ function parseEntry(value) {
150
+ if (!isObject(value))
151
+ throw new OwnerStoreBackupError({ code: INVALID_BACKUP });
152
+ const keys = Object.keys(value);
153
+ if (ENTRY_FIELDS.some(key => !Object.hasOwn(value, key)) || keys.some(key => !ENTRY_FIELDS.includes(key) && !HINT_FIELDS.includes(key))) {
154
+ throw new OwnerStoreBackupError({ code: INVALID_BACKUP });
155
+ }
156
+ assertEntryIdentity(value);
157
+ if (!isObject(value.meta) || !(value.payload === null || isObject(value.payload)) || typeof value.isDefault !== "boolean") {
158
+ throw new OwnerStoreBackupError({ code: INVALID_BACKUP });
159
+ }
160
+ const hint = parseHint({ value });
161
+ assertHintPolicy({ value, hint });
162
+ return { ...value, ...hint };
163
+ }
164
+ /** Older version-1 snapshots omitted both fields; validate supplied hints before any writes. */
165
+ function parseHint({ value }) {
166
+ const hint = { last4: value.last4 ?? null, tokenLength: value.tokenLength ?? null };
167
+ const validLast4 = hint.last4 === null || (typeof hint.last4 === "string" && hint.last4.length === 4);
168
+ const validLength = hint.tokenLength === null || (Number.isSafeInteger(hint.tokenLength) && hint.tokenLength >= 0);
169
+ if (!validLast4 || !validLength)
170
+ throw new OwnerStoreBackupError({ code: INVALID_BACKUP });
171
+ return hint;
172
+ }
173
+ /** Portable hints must retain the vault's short-token and non-token payload privacy rules. */
174
+ function assertHintPolicy({ value, hint }) {
175
+ const hintless = value.kind === "database-destination" || value.payload === null;
176
+ if (hintless && (hint.last4 !== null || hint.tokenLength !== null))
177
+ throw new OwnerStoreBackupError({ code: INVALID_BACKUP });
178
+ if (hint.last4 !== null && (hint.tokenLength === null || hint.tokenLength < 12))
179
+ throw new OwnerStoreBackupError({ code: INVALID_BACKUP });
180
+ }
181
+ /** Ownership is constrained to the kinds supported by cross-site copying. */
182
+ function assertEntryIdentity(value) {
183
+ if (![value.id, value.ownerKey, value.label].every(item => typeof item === "string" && item.length > 0)) {
184
+ throw new OwnerStoreBackupError({ code: INVALID_BACKUP });
185
+ }
186
+ if (![value.binding, value.provider].every(item => item === null || typeof item === "string"))
187
+ throw new OwnerStoreBackupError({ code: INVALID_BACKUP });
188
+ if (!VAULT_KINDS.includes(value.kind) || !isCopyableKind[value.kind]) {
189
+ throw new OwnerStoreBackupError({ code: INVALID_BACKUP });
190
+ }
191
+ }
192
+ /** JSON objects only; arrays cannot masquerade as metadata or portable rows. */
193
+ function isObject(value) {
194
+ return value !== null && typeof value === "object" && !Array.isArray(value);
195
+ }
196
+ //# sourceMappingURL=legacy-owner.js.map
@@ -0,0 +1,89 @@
1
+ /** Pure root-key provisioning decisions over already resolved material; no source reads or writes. */
2
+ import { type ParsedRootKeyHex, type RootKeyRejection } from "../keyring.env.js";
3
+ /** The pure table's outcomes only. `"mismatch"` is a post-hoc reconciliation outcome: the table
4
+ * never sees the host's stamped fingerprint. Keeping it out of the plan lets an effect executor
5
+ * switch exhaustively over real planned outcomes without a dead `"mismatch"` case. Production
6
+ * returns before local execution, so that executor needs no `"production-noop"` case either. */
7
+ export type SiteKeyEnsurePlanAction = "noop" | "adopt" | "mint" | "refuse" | "invalid" | "production-noop";
8
+ export interface SiteKeyEnsurePlan {
9
+ readonly action: SiteKeyEnsurePlanAction;
10
+ }
11
+ /** Full provisioning result range, including a fingerprint mismatch discovered after planning. */
12
+ export type SiteKeyEnsureAction = SiteKeyEnsurePlanAction | "mismatch";
13
+ /** Only what the table needs; material and rejection payloads stay with the caller. */
14
+ export type SiteKeyMaterialCheck = {
15
+ readonly kind: "absent";
16
+ } | {
17
+ readonly kind: "valid";
18
+ } | {
19
+ readonly kind: "invalid";
20
+ };
21
+ export interface PlanSiteKeyEnsureInput {
22
+ readonly mode: "production" | "local";
23
+ /** The current key's material check. Location and source selection belong to the host. */
24
+ readonly perSite: SiteKeyMaterialCheck;
25
+ /** Other candidate: the source holding the stamped key when any does, otherwise the first
26
+ * present source. The host excludes the current key's source before resolving this check. */
27
+ readonly other: SiteKeyMaterialCheck;
28
+ /** Irrelevant unless both checks are absent; callers may pass false otherwise. */
29
+ readonly siteDbsWithKeyData: boolean;
30
+ }
31
+ /**
32
+ * Pure provisioning table, in priority order:
33
+ *
34
+ * 1. Production never touches a per-site file: preserve the host's existing source mechanism.
35
+ * 2. Valid per-site material is a no-op: fill gaps, never repair an already usable key.
36
+ * 3. Invalid per-site material is reported, never treated as absent or overwritten.
37
+ * 4. Per-site absent, other valid material: adopt those exact bytes so data stays decryptable.
38
+ * 5. Per-site absent, other invalid material: report it; adoption would only move the breakage.
39
+ * 6. Both absent with key-dependent data: refuse a fresh key that would orphan that data.
40
+ * 7. Only after every other check passes may a new key be minted.
41
+ *
42
+ * @complexity O(1) time and space over already computed inputs.
43
+ */
44
+ export declare function planSiteKeyEnsure(input: PlanSiteKeyEnsureInput, _optional?: {}): SiteKeyEnsurePlan;
45
+ /** A check carrying valid material (V) or a rejection (I). Effect dispatch receives the payload
46
+ * the decision was made on, without extra guards inferring material from an action alone. */
47
+ export type SiteKeyVerdict<V, I> = {
48
+ readonly kind: "absent";
49
+ } | {
50
+ readonly kind: "valid";
51
+ readonly value: V;
52
+ } | {
53
+ readonly kind: "invalid";
54
+ readonly value: I;
55
+ };
56
+ /** Local rows only; production is decided before this table is reached. */
57
+ export type LocalSiteKeyDecision<V, I> = {
58
+ readonly action: "noop" | "adopt";
59
+ readonly value: V;
60
+ } | {
61
+ readonly action: "invalid";
62
+ readonly value: I;
63
+ } | {
64
+ readonly action: "refuse" | "mint";
65
+ };
66
+ /** Rows 2–7 of {@link planSiteKeyEnsure}, preserving the selected material or rejection.
67
+ * @complexity O(1) time and space.
68
+ */
69
+ export declare function decideLocalSiteKeyEnsure<V, I>(input: {
70
+ perSite: SiteKeyVerdict<V, I>;
71
+ other: SiteKeyVerdict<V, I>;
72
+ siteDbsWithKeyData: boolean;
73
+ }, _optional?: {}): LocalSiteKeyDecision<V, I>;
74
+ /** Convert payload-free checks for the same local table used by material-bearing callers. */
75
+ export declare function verdictOfCheck({ check }: {
76
+ check: SiteKeyMaterialCheck;
77
+ }, _optional?: {}): SiteKeyVerdict<undefined, undefined>;
78
+ /** Convert an existing parse result, or absence, without revalidating or normalizing material. */
79
+ export declare function verdictOf({ parsed }: {
80
+ parsed: ParsedRootKeyHex | undefined;
81
+ }, _optional?: {}): SiteKeyVerdict<string, RootKeyRejection>;
82
+ /** Whether validated material matches the host's stamp, using the keyring's byte fingerprint.
83
+ * @complexity O(k) time and space for k hex characters; no source access.
84
+ */
85
+ export declare function matchesFingerprint({ parsed, fingerprint }: {
86
+ parsed: ParsedRootKeyHex | undefined;
87
+ fingerprint: string | undefined;
88
+ }, _optional?: {}): boolean;
89
+ //# sourceMappingURL=decide.d.ts.map
@@ -0,0 +1,60 @@
1
+ /** Pure root-key provisioning decisions over already resolved material; no source reads or writes. */
2
+ import { fingerprintRootKeyHex } from "../keyring.env.js";
3
+ /**
4
+ * Pure provisioning table, in priority order:
5
+ *
6
+ * 1. Production never touches a per-site file: preserve the host's existing source mechanism.
7
+ * 2. Valid per-site material is a no-op: fill gaps, never repair an already usable key.
8
+ * 3. Invalid per-site material is reported, never treated as absent or overwritten.
9
+ * 4. Per-site absent, other valid material: adopt those exact bytes so data stays decryptable.
10
+ * 5. Per-site absent, other invalid material: report it; adoption would only move the breakage.
11
+ * 6. Both absent with key-dependent data: refuse a fresh key that would orphan that data.
12
+ * 7. Only after every other check passes may a new key be minted.
13
+ *
14
+ * @complexity O(1) time and space over already computed inputs.
15
+ */
16
+ export function planSiteKeyEnsure(input, _optional = {}) {
17
+ if (input.mode === "production")
18
+ return { action: "production-noop" };
19
+ const decision = decideLocalSiteKeyEnsure({
20
+ perSite: verdictOfCheck({ check: input.perSite }),
21
+ other: verdictOfCheck({ check: input.other }),
22
+ siteDbsWithKeyData: input.siteDbsWithKeyData,
23
+ });
24
+ return { action: decision.action };
25
+ }
26
+ /** Rows 2–7 of {@link planSiteKeyEnsure}, preserving the selected material or rejection.
27
+ * @complexity O(1) time and space.
28
+ */
29
+ export function decideLocalSiteKeyEnsure(input, _optional = {}) {
30
+ if (input.perSite.kind === "valid")
31
+ return { action: "noop", value: input.perSite.value };
32
+ if (input.perSite.kind === "invalid")
33
+ return { action: "invalid", value: input.perSite.value };
34
+ // perSite.kind === "absent" from here on.
35
+ if (input.other.kind === "valid")
36
+ return { action: "adopt", value: input.other.value };
37
+ if (input.other.kind === "invalid")
38
+ return { action: "invalid", value: input.other.value };
39
+ // other.kind === "absent" too — nothing anywhere.
40
+ if (input.siteDbsWithKeyData)
41
+ return { action: "refuse" };
42
+ return { action: "mint" };
43
+ }
44
+ /** Convert payload-free checks for the same local table used by material-bearing callers. */
45
+ export function verdictOfCheck({ check }, _optional = {}) {
46
+ return check.kind === "absent" ? check : { kind: check.kind, value: undefined };
47
+ }
48
+ /** Convert an existing parse result, or absence, without revalidating or normalizing material. */
49
+ export function verdictOf({ parsed }, _optional = {}) {
50
+ if (parsed === undefined)
51
+ return { kind: "absent" };
52
+ return parsed.ok ? { kind: "valid", value: parsed.hex } : { kind: "invalid", value: parsed.reason };
53
+ }
54
+ /** Whether validated material matches the host's stamp, using the keyring's byte fingerprint.
55
+ * @complexity O(k) time and space for k hex characters; no source access.
56
+ */
57
+ export function matchesFingerprint({ parsed, fingerprint }, _optional = {}) {
58
+ return parsed?.ok === true && fingerprint !== undefined && fingerprintRootKeyHex({ hex: parsed.hex }) === fingerprint;
59
+ }
60
+ //# sourceMappingURL=decide.js.map
@@ -0,0 +1,19 @@
1
+ import type { KeyringPort, SecretSealerPort } from "@jini-ai/core/contracts/vault";
2
+ /** The two rules every sealer binding handed to `SecretsVaultService` must hold. */
3
+ export type SecretSealerContractRule = "opens-what-it-seals" | "refuses-another-binding";
4
+ export interface SecretSealerContractSubject {
5
+ readonly sealer: SecretSealerPort;
6
+ readonly keyring: Pick<KeyringPort, "activeKey">;
7
+ }
8
+ /** Runs one binding through the sealer contract: `open(seal(x))` returns exactly `x` under the same
9
+ * binding string, and the same envelope is refused under any other binding string. Runner-agnostic so a
10
+ * host can run it in its own test framework against each `{ sealer, keyring }` pair it builds. A binding
11
+ * that seals with one key and opens with another (a key-switch recovery binding) breaks the first rule:
12
+ * give `rotate` a `sourceOpener` instead.
13
+ * @returns The violated rules in a fixed order; empty when the binding holds the contract.
14
+ * @throws Whatever `keyring.activeKey` or `sealer.seal` throws: a binding that cannot seal has no contract to check.
15
+ * @complexity O(total sample bytes): four seals and eight opens.
16
+ * @example assert.deepEqual(await secretSealerContractViolations({ sealer, keyring }), []);
17
+ */
18
+ export declare function secretSealerContractViolations({ sealer, keyring }: SecretSealerContractSubject, _options?: Record<string, never>): Promise<SecretSealerContractRule[]>;
19
+ //# sourceMappingURL=sealer-contract.d.ts.map
@@ -0,0 +1,37 @@
1
+ const BINDING = 'sealer-contract:v1:["row"]';
2
+ const ANOTHER_BINDING = 'sealer-contract:v1:["another row"]';
3
+ /** Empty, padded (the value must come back byte for byte), non-ASCII and multi-block payloads. */
4
+ const SAMPLES = ["{}", ' {"padded":true}\n', JSON.stringify({ token: "contract-sample", note: "naïve ✓ 日本" }), JSON.stringify({ blob: "x".repeat(4096) })];
5
+ /** What the binding returns for this envelope, or `undefined` when it refuses. A refusal is the measured
6
+ * outcome here, so the sealer's error is the answer rather than something to report. */
7
+ async function opened({ sealer, sealed, aad }, _options = {}) {
8
+ try {
9
+ return await sealer.open({ sealed }, { aad });
10
+ }
11
+ catch {
12
+ return undefined;
13
+ }
14
+ }
15
+ /** Runs one binding through the sealer contract: `open(seal(x))` returns exactly `x` under the same
16
+ * binding string, and the same envelope is refused under any other binding string. Runner-agnostic so a
17
+ * host can run it in its own test framework against each `{ sealer, keyring }` pair it builds. A binding
18
+ * that seals with one key and opens with another (a key-switch recovery binding) breaks the first rule:
19
+ * give `rotate` a `sourceOpener` instead.
20
+ * @returns The violated rules in a fixed order; empty when the binding holds the contract.
21
+ * @throws Whatever `keyring.activeKey` or `sealer.seal` throws: a binding that cannot seal has no contract to check.
22
+ * @complexity O(total sample bytes): four seals and eight opens.
23
+ * @example assert.deepEqual(await secretSealerContractViolations({ sealer, keyring }), []);
24
+ */
25
+ export async function secretSealerContractViolations({ sealer, keyring }, _options = {}) {
26
+ const key = await keyring.activeKey({});
27
+ const violated = new Set();
28
+ for (const plaintext of SAMPLES) {
29
+ const sealed = await sealer.seal({ plaintext, key, aad: BINDING });
30
+ if (await opened({ sealer, sealed, aad: BINDING }) !== plaintext)
31
+ violated.add("opens-what-it-seals");
32
+ if (await opened({ sealer, sealed, aad: ANOTHER_BINDING }) !== undefined)
33
+ violated.add("refuses-another-binding");
34
+ }
35
+ return ["opens-what-it-seals", "refuses-another-binding"].filter(rule => violated.has(rule));
36
+ }
37
+ //# sourceMappingURL=sealer-contract.js.map
@@ -1,4 +1,4 @@
1
- import type { KeyringPort, RootKeyHandle, SecretSealerPort } from "./ports.js";
1
+ import type { KeyringPort, RootKeyHandle, SecretSealerPort } from "@jini-ai/core/contracts/vault";
2
2
  import type { SealedSecret } from "./types.js";
3
3
  export declare class AesGcmSecretSealer implements SecretSealerPort {
4
4
  private readonly keyring;
@@ -1,3 +1,4 @@
1
1
  export { InMemoryKeyring } from "./keyring.memory.js";
2
2
  export { FixedRootKeyKeyring } from "./keyring.env.js";
3
+ export { secretSealerContractViolations, type SecretSealerContractRule, type SecretSealerContractSubject } from "./sealer-contract.js";
3
4
  //# sourceMappingURL=testing.d.ts.map
@@ -1,3 +1,4 @@
1
1
  export { InMemoryKeyring } from "./keyring.memory.js";
2
2
  export { FixedRootKeyKeyring } from "./keyring.env.js";
3
+ export { secretSealerContractViolations } from "./sealer-contract.js";
3
4
  //# sourceMappingURL=testing.js.map
package/dist/shell.d.ts CHANGED
@@ -46,5 +46,8 @@ export declare function execFileBuffered(command: string, args: readonly string[
46
46
  * `process.env` so the re-exported `PATH` above has a base to restore from.
47
47
  * @returns The buffered result.
48
48
  */
49
- export declare function execCommandViaLoginShell(command: string, args: readonly string[], opts?: ExecFileOptions): Promise<BufferedCommandResult>;
49
+ export declare function execCommandViaLoginShell({ command, args }: {
50
+ command: string;
51
+ args: readonly string[];
52
+ }, opts?: ExecFileOptions): Promise<BufferedCommandResult>;
50
53
  //# sourceMappingURL=shell.d.ts.map