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

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 (137) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +13 -0
  3. package/dist/download-lock.d.ts +3 -1
  4. package/dist/download-lock.js +4 -4
  5. package/dist/download-maintenance.js +6 -6
  6. package/dist/download-state.js +17 -14
  7. package/dist/download-store.d.ts +34 -10
  8. package/dist/download-store.js +24 -20
  9. package/dist/download-target.d.ts +6 -2
  10. package/dist/download-target.js +7 -7
  11. package/dist/download-transfer.js +18 -12
  12. package/dist/download.js +4 -4
  13. package/dist/fetch-with-timeout.d.ts +0 -53
  14. package/dist/fetch-with-timeout.js +56 -6
  15. package/dist/fs/directory-running-lock.d.ts +4 -0
  16. package/dist/fs/directory-running-lock.js +8 -1
  17. package/dist/fs/directory-workspace.d.ts +2 -1
  18. package/dist/fs/directory-workspace.js +2 -2
  19. package/dist/fs/durable-json.d.ts +3 -16
  20. package/dist/fs/durable-json.js +4 -2
  21. package/dist/fs/guarded-reader.d.ts +10 -0
  22. package/dist/fs/guarded-reader.js +34 -1
  23. package/dist/fs/index.d.ts +4 -0
  24. package/dist/fs/index.js +4 -0
  25. package/dist/fs/leased-directory-move.d.ts +49 -0
  26. package/dist/fs/leased-directory-move.js +31 -0
  27. package/dist/fs/owned-temp-root.d.ts +74 -0
  28. package/dist/fs/owned-temp-root.js +203 -0
  29. package/dist/fs/recent-directories.d.ts +2 -1
  30. package/dist/fs/resolve-directory-target.d.ts +33 -0
  31. package/dist/fs/resolve-directory-target.js +58 -0
  32. package/dist/fs/staged-file.d.ts +40 -0
  33. package/dist/fs/staged-file.js +75 -0
  34. package/dist/fs/strict-containment.d.ts +14 -0
  35. package/dist/fs/strict-containment.js +14 -0
  36. package/dist/image/png-encode.d.ts +41 -0
  37. package/dist/image/png-encode.js +96 -0
  38. package/dist/index.d.ts +3 -1
  39. package/dist/mail/email-template-agent-tools.d.ts +150 -0
  40. package/dist/mail/email-template-agent-tools.js +86 -0
  41. package/dist/mail/email-template-tool-registrations.d.ts +73 -0
  42. package/dist/mail/email-template-tool-registrations.js +66 -0
  43. package/dist/mail/feedback-route.d.ts +50 -0
  44. package/dist/mail/feedback-route.js +46 -0
  45. package/dist/mail/feedback-setup.d.ts +44 -0
  46. package/dist/mail/feedback-setup.js +53 -0
  47. package/dist/mail/feedback-sources.d.ts +67 -0
  48. package/dist/mail/feedback-sources.js +42 -0
  49. package/dist/mail/index.d.ts +10 -1
  50. package/dist/mail/index.js +4 -0
  51. package/dist/mail/mail-status.d.ts +32 -0
  52. package/dist/mail/mail-status.js +2 -0
  53. package/dist/mail/positional-purpose-gate.d.ts +14 -0
  54. package/dist/mail/positional-purpose-gate.js +18 -0
  55. package/dist/mail/purpose-gate-probe.d.ts +18 -0
  56. package/dist/mail/purpose-gate-probe.js +22 -0
  57. package/dist/mail/resolve-mailer.d.ts +13 -1
  58. package/dist/mail/resolve-mailer.js +11 -5
  59. package/dist/mail/sql/activity.repo.d.ts +20 -0
  60. package/dist/mail/sql/activity.repo.js +133 -0
  61. package/dist/mail/sql/attempts.repo.d.ts +17 -0
  62. package/dist/mail/sql/attempts.repo.js +32 -0
  63. package/dist/mail/sql/capture.repo.d.ts +69 -0
  64. package/dist/mail/sql/capture.repo.js +119 -0
  65. package/dist/mail/sql/feedback-inbox.repo.d.ts +12 -0
  66. package/dist/mail/sql/feedback-inbox.repo.js +32 -0
  67. package/dist/mail/sql/index.d.ts +12 -0
  68. package/dist/mail/sql/index.js +12 -0
  69. package/dist/mail/sql/ledger.repo.d.ts +29 -0
  70. package/dist/mail/sql/ledger.repo.js +57 -0
  71. package/dist/mail/sql/retention.d.ts +23 -0
  72. package/dist/mail/sql/retention.js +53 -0
  73. package/dist/mail/sql/site-feedback-route.d.ts +18 -0
  74. package/dist/mail/sql/site-feedback-route.js +22 -0
  75. package/dist/mail/sql/suppression-admin.repo.d.ts +11 -0
  76. package/dist/mail/sql/suppression-admin.repo.js +76 -0
  77. package/dist/mail/sql/suppression.repo.d.ts +10 -0
  78. package/dist/mail/sql/suppression.repo.js +33 -0
  79. package/dist/mail/test-send.d.ts +147 -0
  80. package/dist/mail/test-send.js +201 -0
  81. package/dist/mail/use-readiness.d.ts +104 -0
  82. package/dist/mail/use-readiness.js +140 -0
  83. package/dist/object-store/local-fs.js +34 -1
  84. package/dist/object-store/site/artifact-provider.d.ts +65 -0
  85. package/dist/object-store/site/artifact-provider.js +37 -0
  86. package/dist/object-store/site/registry.d.ts +110 -0
  87. package/dist/object-store/site/registry.js +93 -0
  88. package/dist/object-store/site/setting.d.ts +34 -0
  89. package/dist/object-store/site/setting.js +32 -0
  90. package/dist/process-probes.d.ts +11 -4
  91. package/dist/process-probes.js +3 -3
  92. package/dist/process-top-footprint.d.ts +1 -1
  93. package/dist/process.d.ts +3 -17
  94. package/dist/process.js +3 -2
  95. package/dist/retention/index.d.ts +6 -0
  96. package/dist/retention/index.js +6 -0
  97. package/dist/retention/measure-tree.d.ts +68 -0
  98. package/dist/retention/measure-tree.js +205 -0
  99. package/dist/retention/preview-store.d.ts +10 -0
  100. package/dist/retention/preview-store.js +26 -0
  101. package/dist/retention/routes.d.ts +23 -0
  102. package/dist/retention/routes.js +24 -0
  103. package/dist/retention/runner.d.ts +103 -0
  104. package/dist/retention/runner.js +164 -0
  105. package/dist/secrets/credential-sets/index.d.ts +1 -0
  106. package/dist/secrets/credential-sets/index.js +1 -0
  107. package/dist/secrets/credential-sets/store-vault-guards.d.ts +26 -0
  108. package/dist/secrets/credential-sets/store-vault-guards.js +30 -0
  109. package/dist/secrets/credential-sets/vault.service.d.ts +1 -1
  110. package/dist/secrets/index.d.ts +1 -1
  111. package/dist/secrets/index.js +1 -1
  112. package/dist/secrets/keyring.env.d.ts +1 -1
  113. package/dist/secrets/keyring.env.js +3 -5
  114. package/dist/secrets/keyring.memory.d.ts +4 -1
  115. package/dist/secrets/keyring.memory.js +4 -1
  116. package/dist/secrets/legacy-codecs.d.ts +381 -0
  117. package/dist/secrets/legacy-codecs.js +468 -0
  118. package/dist/secrets/legacy-owner.d.ts +3 -11
  119. package/dist/secrets/root-key/ensure.d.ts +154 -0
  120. package/dist/secrets/root-key/ensure.js +328 -0
  121. package/dist/secrets/root-key/files.d.ts +104 -0
  122. package/dist/secrets/root-key/files.js +166 -0
  123. package/dist/secrets/root-key/material.d.ts +132 -0
  124. package/dist/secrets/root-key/material.js +116 -0
  125. package/dist/secrets/root-key/ordered-keyring.d.ts +157 -0
  126. package/dist/secrets/root-key/ordered-keyring.js +104 -0
  127. package/dist/secrets/root-key/reconcile.d.ts +50 -0
  128. package/dist/secrets/root-key/reconcile.js +147 -0
  129. package/dist/secrets/root-key/site-keyring-errors.d.ts +78 -0
  130. package/dist/secrets/root-key/site-keyring-errors.js +37 -0
  131. package/dist/secrets/root-key/sources.d.ts +79 -0
  132. package/dist/secrets/root-key/sources.js +119 -0
  133. package/dist/secrets/secret-sealer.aesgcm.d.ts +50 -2
  134. package/dist/secrets/secret-sealer.aesgcm.js +107 -19
  135. package/dist/web/tool-registrations.d.ts +67 -0
  136. package/dist/web/tool-registrations.js +44 -0
  137. package/package.json +139 -7
@@ -0,0 +1,164 @@
1
+ /**
2
+ * @file A host-neutral storage retention runner: it schedules passes over host-supplied policies and
3
+ * never touches the filesystem itself. Every collaborator (clock, scheduler, error sink, policies) is
4
+ * injected; the host decides which policies exist, where their files live and whether scheduled
5
+ * passes may clean or only measure.
6
+ *
7
+ * Pass rules:
8
+ * - Passes are serialized. A request that matches the running pass's mode joins it; a request of the
9
+ * other mode waits for it and then runs its own pass (at most one waiting pass, joined the same way).
10
+ * So a dry run always gets a measurement-only result, even when it arrives during a cleanup, and a
11
+ * confirmed cleanup always gets the result of an actual sweep, even when it arrives during a dry run.
12
+ * - A dry run calls `measure()` only and never enters `sweep()`.
13
+ * - A failing policy is reported in plain words and the next policy still runs.
14
+ * - `stop()` clears the timer, cancels a waiting pass and resolves once the running pass has finished,
15
+ * so the host can close storage right after it.
16
+ */
17
+ /** Daily, matching the plan's default pass cadence; hosts can pass their own `intervalMs`. */
18
+ export const RETENTION_DEFAULT_INTERVAL_MS = 24 * 60 * 60 * 1000;
19
+ const RETENTION_POLICY_KINDS = new Set(['cache', 'derived', 'old-copy']);
20
+ /**
21
+ * Creates a runner over the given policies. Nothing runs until `start()` or `runOnce()`.
22
+ * @throws TypeError for a duplicate policy id or a kind outside cache/derived/old-copy (a JS caller
23
+ * can bypass the type, so the kind rule is enforced at runtime as well).
24
+ * @throws RangeError for an interval that is not a positive finite number.
25
+ * @complexity O(p) per pass in policies, run one at a time.
26
+ * @example createRetentionRunner({ policies, clock: Date, scheduler: globalThis, reportError }, { onReport });
27
+ */
28
+ export function createRetentionRunner(required, { intervalMs = RETENTION_DEFAULT_INTERVAL_MS, scheduledDryRun = true, onReport } = {}) {
29
+ const policies = validatePolicies({ policies: required.policies });
30
+ if (!Number.isFinite(intervalMs) || intervalMs <= 0) {
31
+ throw new RangeError(`The storage cleanup interval must be a positive number of milliseconds (got ${intervalMs}).`);
32
+ }
33
+ const queue = createPassQueue({ execute: dryRun => executePass({ ...required, policies, dryRun, onReport }) });
34
+ let timer;
35
+ const scheduledPass = () => {
36
+ queue.request({ dryRun: scheduledDryRun }).catch((error) => {
37
+ report({ reportError: required.reportError, error: new Error('A scheduled storage cleanup pass could not run.', { cause: error }) });
38
+ });
39
+ };
40
+ return {
41
+ runOnce: ({ dryRun }) => queue.request({ dryRun }),
42
+ start() {
43
+ if (queue.isStopped())
44
+ throw new Error('This storage cleanup runner was stopped; create a new one to start again.');
45
+ if (timer)
46
+ return;
47
+ timer = { handle: required.scheduler.setInterval(scheduledPass, intervalMs) };
48
+ scheduledPass();
49
+ },
50
+ async stop() {
51
+ if (timer)
52
+ required.scheduler.clearInterval(timer.handle);
53
+ await queue.stop();
54
+ },
55
+ };
56
+ }
57
+ function validatePolicies({ policies }, _optional = {}) {
58
+ const seen = new Set();
59
+ for (const policy of policies) {
60
+ if (!RETENTION_POLICY_KINDS.has(policy.kind)) {
61
+ throw new TypeError(`Storage policy "${policy.id}" has kind "${String(policy.kind)}". Only cache, derived and old-copy data may be cleaned automatically.`);
62
+ }
63
+ if (seen.has(policy.id))
64
+ throw new TypeError(`Storage policy "${policy.id}" is listed twice.`);
65
+ seen.add(policy.id);
66
+ }
67
+ // A private copy: a host mutating its array later cannot change what a running pass iterates.
68
+ return [...policies];
69
+ }
70
+ function pendingPass({ dryRun }, _optional = {}) {
71
+ let resolve;
72
+ let reject;
73
+ const promise = new Promise((settle, fail) => { resolve = settle; reject = fail; });
74
+ return { dryRun, promise, resolve, reject };
75
+ }
76
+ /** The serialization core: one running pass, at most one waiting pass of the other mode.
77
+ * The running slot is published before `execute` is called, so a collaborator that synchronously
78
+ * requests another pass joins or queues behind this one instead of starting an overlapping pass. The
79
+ * queue advances whether the pass fulfils or rejects, so a failed pass never strands a waiter. */
80
+ function createPassQueue({ execute }, _optional = {}) {
81
+ let running;
82
+ let waiting;
83
+ let stopped = false;
84
+ const begin = (pass) => {
85
+ running = pass;
86
+ const advance = (settle) => {
87
+ running = undefined;
88
+ const next = waiting;
89
+ waiting = undefined;
90
+ if (next)
91
+ begin(next);
92
+ settle();
93
+ };
94
+ // The executor runs synchronously, so a synchronous throw becomes this pass's rejection.
95
+ new Promise(resolve => resolve(execute(pass.dryRun)))
96
+ .then(result => advance(() => pass.resolve(result)), (error) => advance(() => pass.reject(error)));
97
+ };
98
+ return {
99
+ isStopped: () => stopped,
100
+ request({ dryRun }) {
101
+ if (stopped)
102
+ return Promise.resolve({ status: 'stopped', dryRun });
103
+ if (!running) {
104
+ const pass = pendingPass({ dryRun });
105
+ begin(pass);
106
+ return pass.promise;
107
+ }
108
+ if (running.dryRun === dryRun)
109
+ return running.promise;
110
+ // The waiting pass is always the other mode from the running one, so a same-mode request joins it.
111
+ waiting ??= pendingPass({ dryRun });
112
+ return waiting.promise;
113
+ },
114
+ async stop() {
115
+ stopped = true;
116
+ const cancelled = waiting;
117
+ waiting = undefined;
118
+ cancelled?.resolve({ status: 'stopped', dryRun: cancelled.dryRun });
119
+ // The pass's own requester observes a failure; stop only waits for the pass to end.
120
+ if (running)
121
+ await running.promise.catch(() => undefined);
122
+ },
123
+ };
124
+ }
125
+ /** Runs one pass to completion. It never rejects: every failure becomes an outcome plus a report. */
126
+ async function executePass({ policies, clock, reportError, dryRun, onReport }, _optional = {}) {
127
+ const startedAt = clock.now();
128
+ const outcomes = [];
129
+ for (const policy of policies)
130
+ outcomes.push(await runPolicy({ policy, dryRun, now: startedAt, reportError }));
131
+ const result = { status: 'completed', dryRun, startedAt, finishedAt: clock.now(), policies: outcomes };
132
+ try {
133
+ onReport?.(result);
134
+ }
135
+ catch (error) {
136
+ report({ reportError, error: new Error('Storage cleanup report could not be delivered.', { cause: error }) });
137
+ }
138
+ return result;
139
+ }
140
+ async function runPolicy({ policy, dryRun, now, reportError }, _optional = {}) {
141
+ const { id, kind } = policy;
142
+ try {
143
+ if (dryRun)
144
+ return { id, kind, status: 'measured', measurement: await policy.measure() };
145
+ return { id, kind, status: 'swept', result: await policy.sweep({ now }) };
146
+ }
147
+ catch (error) {
148
+ // Fixed outcome text: a raw message can quote a path or a secret, so nothing from the error reaches
149
+ // the outcome; the host's error sink still receives the full error as `cause`.
150
+ const message = `Storage cleanup "${id}" failed while ${dryRun ? 'measuring' : 'cleaning up'}.`;
151
+ report({ reportError, error: new Error(message, { cause: error }), policyId: id });
152
+ return { id, kind, status: 'failed', message };
153
+ }
154
+ }
155
+ function report({ reportError, error, policyId }, _optional = {}) {
156
+ try {
157
+ reportError(error, policyId === undefined ? {} : { policyId });
158
+ }
159
+ catch {
160
+ // A broken error sink must not turn into a failed pass or an unhandled rejection on a timer. The
161
+ // injected reporter is the only outlet this runner has, so its own failure is dropped here.
162
+ }
163
+ }
164
+ //# sourceMappingURL=runner.js.map
@@ -5,4 +5,5 @@ export { VaultResealRefusedError, type VaultResealRefusalStep } from "./vault.re
5
5
  export { InMemoryVaultRepo } from "./vault.repo.memory.js";
6
6
  export { captureVaultArchive, prepareVaultArchiveRestore, type VaultArchiveEntry } from "./vault-archive.js";
7
7
  export { matchingCredentialProviderIds, selectCredentialForProvider, suggestCredentialWorksFor, normalizeCredentialWorksFor, type CredentialProviderDescriptor, type MatchableCredential } from "./provider-matches.js";
8
+ export { createStoreKeyring, protectStorage, type StorageFailureSource } from "./store-vault-guards.js";
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -5,4 +5,5 @@ export { VaultResealRefusedError } from "./vault.reseal-refused.js";
5
5
  export { InMemoryVaultRepo } from "./vault.repo.memory.js";
6
6
  export { captureVaultArchive, prepareVaultArchiveRestore } from "./vault-archive.js";
7
7
  export { matchingCredentialProviderIds, selectCredentialForProvider, suggestCredentialWorksFor, normalizeCredentialWorksFor } from "./provider-matches.js";
8
+ export { createStoreKeyring, protectStorage } from "./store-vault-guards.js";
8
9
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,26 @@
1
+ import type { KeyringPort } from "@jini-ai/core/contracts/vault";
2
+ /** The parts of a store vault's `required` input that crypto guards read. Both are read at call time,
3
+ * never captured, so a guard always sees the store's current keyring and translator. */
4
+ export interface StorageFailureSource {
5
+ keyring?: KeyringPort;
6
+ storageError: (required: {}, options?: {
7
+ error?: unknown;
8
+ }) => Error;
9
+ }
10
+ /** Only crypto errors become the feature's safe storage error; the original error is its argument.
11
+ * @throws whatever `source.storageError` returns, for any sync or async failure of `operation`.
12
+ * @complexity O(1) around one awaited operation.
13
+ */
14
+ export declare function protectStorage<T>({ operation, source }: {
15
+ operation: () => Promise<T>;
16
+ source: Pick<StorageFailureSource, "storageError">;
17
+ }, _optional?: {}): Promise<T>;
18
+ /** Keyring port for a store vault. A missing keyring raises the storage error inside the guard, which
19
+ * then translates it once more, passing the first storage error back to the translator. Jini's vault
20
+ * service calls only `activeKey`; `derive` and `deriveSigningSecret` complete the port contract.
21
+ * @complexity O(1) per call; delegates all key work to the injected keyring.
22
+ */
23
+ export declare function createStoreKeyring({ source }: {
24
+ source: StorageFailureSource;
25
+ }, _optional?: {}): KeyringPort;
26
+ //# sourceMappingURL=store-vault-guards.d.ts.map
@@ -0,0 +1,30 @@
1
+ /** Only crypto errors become the feature's safe storage error; the original error is its argument.
2
+ * @throws whatever `source.storageError` returns, for any sync or async failure of `operation`.
3
+ * @complexity O(1) around one awaited operation.
4
+ */
5
+ export async function protectStorage({ operation, source }, _optional = {}) {
6
+ try {
7
+ return await operation();
8
+ }
9
+ catch (error) {
10
+ throw source.storageError({}, { error });
11
+ }
12
+ }
13
+ /** Keyring port for a store vault. A missing keyring raises the storage error inside the guard, which
14
+ * then translates it once more, passing the first storage error back to the translator. Jini's vault
15
+ * service calls only `activeKey`; `derive` and `deriveSigningSecret` complete the port contract.
16
+ * @complexity O(1) per call; delegates all key work to the injected keyring.
17
+ */
18
+ export function createStoreKeyring({ source }, _optional = {}) {
19
+ const withKeyring = ({ use }) => protectStorage({ source, operation: () => {
20
+ if (!source.keyring)
21
+ throw source.storageError({});
22
+ return use({ keyring: source.keyring });
23
+ } });
24
+ return {
25
+ derive: input => withKeyring({ use: ({ keyring }) => keyring.derive(input) }),
26
+ deriveSigningSecret: input => withKeyring({ use: ({ keyring }) => keyring.deriveSigningSecret(input) }),
27
+ activeKey: () => withKeyring({ use: ({ keyring }) => keyring.activeKey({}) }),
28
+ };
29
+ }
30
+ //# sourceMappingURL=store-vault-guards.js.map
@@ -2,7 +2,7 @@ import type { KeyringPort, SecretSealerPort } from "@jini-ai/core/contracts/vaul
2
2
  import { type VaultContext, type VaultIdentity, type VaultMeta, type VaultMetaParsers, type VaultCopyResult, type VaultDefaultQuery, type VaultOptions, type VaultQuery, type VaultPutRecord, type VaultRepoPort, type VaultSummary } from "@jini-ai/core/contracts/vault";
3
3
  export interface VaultServiceDeps {
4
4
  repo: VaultRepoPort;
5
- keyring: KeyringPort;
5
+ keyring: Pick<KeyringPort, "activeKey">;
6
6
  sealer: SecretSealerPort;
7
7
  metaParsers: VaultMetaParsers;
8
8
  /** Host policy must throw on denial. No permissive default is provided. */
@@ -1,5 +1,5 @@
1
1
  export type { SealedSecret } from "./types.js";
2
- export { AesGcmSecretSealer } from "./secret-sealer.aesgcm.js";
2
+ export { AesGcmSecretSealer, LegacyUnboundAesGcmSecretSealer, SecretOpenError, SECRET_OPEN_FAILED } from "./secret-sealer.aesgcm.js";
3
3
  export { sealWithPassphrase, openWithPassphrase } from "./passphrase-envelope.js";
4
4
  export type { PassphraseEnvelopeOptions } from "./passphrase-envelope.js";
5
5
  export { EnvOrFileKeyring } from "./keyring.env.js";
@@ -1,4 +1,4 @@
1
- export { AesGcmSecretSealer } from "./secret-sealer.aesgcm.js";
1
+ export { AesGcmSecretSealer, LegacyUnboundAesGcmSecretSealer, SecretOpenError, SECRET_OPEN_FAILED } from "./secret-sealer.aesgcm.js";
2
2
  export { sealWithPassphrase, openWithPassphrase } from "./passphrase-envelope.js";
3
3
  export { EnvOrFileKeyring } from "./keyring.env.js";
4
4
  // Canonical public names; the implementation bindings retain compatibility for direct consumers.
@@ -91,7 +91,7 @@ export declare class FixedRootKeyKeyring implements KeyringPort {
91
91
  }, optional?: {
92
92
  keyId?: string;
93
93
  });
94
- activeKey(_required: Record<string, never>): Promise<{
94
+ activeKey(_required?: Record<string, never>): Promise<{
95
95
  readonly keyId: string;
96
96
  }>;
97
97
  deriveSigningSecret(input: {
@@ -65,10 +65,8 @@ export class EnvOrFileKeyring {
65
65
  if (!this.allowFileAutoGenerate) {
66
66
  throw new Error(`no root key: ${this.envVarName} is not set, no key file exists at ${this.keyFilePath}, and this instance does not auto-generate one — set the env var, or call generateFileRootKey() explicitly`);
67
67
  }
68
- const generated = randomBytes(ROOT_KEY_LENGTH_BYTES);
69
- mkdirSync(dirname(this.keyFilePath), { recursive: true });
70
- writeFileSync(this.keyFilePath, generated.toString("hex"), { mode: 0o600 });
71
- this.cachedRootKey = generated;
68
+ const generated = generateFileRootKey({ keyFilePath: this.keyFilePath });
69
+ this.cachedRootKey = Buffer.from(generated.hex, "hex");
72
70
  return this.cachedRootKey;
73
71
  }
74
72
  parseEnvRootKey(raw) {
@@ -133,7 +131,7 @@ export class FixedRootKeyKeyring {
133
131
  throw new Error(`FixedRootKeyKeyring: not a valid root key (${parsed.reason})`);
134
132
  this.rootKey = Buffer.from(parsed.hex, "hex");
135
133
  }
136
- async activeKey(_required) {
134
+ async activeKey(_required = {}) {
137
135
  return { keyId: this.keyId };
138
136
  }
139
137
  async deriveSigningSecret(input) {
@@ -1,5 +1,8 @@
1
1
  import { FixedRootKeyKeyring } from "./keyring.env.js";
2
- /** Real HKDF over an ephemeral 32-byte key, with no environment or filesystem resolution. */
2
+ /** An in-memory `KeyringPort` test/dev double: real HKDF over an ephemeral 32-byte key, with no
3
+ * environment or filesystem resolution. One random root key is generated per instance and held only in
4
+ * memory, so a hermetic composition (every route test) exercises the real signer/HKDF derivation path
5
+ * without reading an env var or touching the filesystem the way the env/file keyring does. */
3
6
  export declare class InMemoryKeyring extends FixedRootKeyKeyring {
4
7
  constructor(required: {
5
8
  hkdfSalt: string | Uint8Array;
@@ -1,6 +1,9 @@
1
1
  import { randomBytes } from "node:crypto";
2
2
  import { FixedRootKeyKeyring } from "./keyring.env.js";
3
- /** Real HKDF over an ephemeral 32-byte key, with no environment or filesystem resolution. */
3
+ /** An in-memory `KeyringPort` test/dev double: real HKDF over an ephemeral 32-byte key, with no
4
+ * environment or filesystem resolution. One random root key is generated per instance and held only in
5
+ * memory, so a hermetic composition (every route test) exercises the real signer/HKDF derivation path
6
+ * without reading an env var or touching the filesystem the way the env/file keyring does. */
4
7
  export class InMemoryKeyring extends FixedRootKeyKeyring {
5
8
  constructor(required, optional = {}) {
6
9
  super({ hex: randomBytes(32).toString("hex"), hkdfSalt: required.hkdfSalt }, optional);