@clef-sh/agent 0.1.11-beta.62 → 0.1.11-beta.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/agent.cjs CHANGED
@@ -183802,7 +183802,7 @@ var ArtifactDecryptor = class {
183802
183802
  } finally {
183803
183803
  plaintext = "";
183804
183804
  }
183805
- return { values, keys: artifact.keys, revision: artifact.revision };
183805
+ return { values, keys: Object.keys(values), revision: artifact.revision };
183806
183806
  }
183807
183807
  /** KMS envelope: unwrap DEK via KMS, then AES-256-GCM decrypt. */
183808
183808
  async decryptKmsEnvelope(artifact) {
@@ -183859,14 +183859,13 @@ var ArtifactDecryptor = class {
183859
183859
  var crypto15 = __toESM(require("crypto"));
183860
183860
  function buildSigningPayload(artifact) {
183861
183861
  const fields = [
183862
- "clef-sig-v2",
183862
+ "clef-sig-v3",
183863
183863
  String(artifact.version),
183864
183864
  artifact.identity,
183865
183865
  artifact.environment,
183866
183866
  artifact.revision,
183867
183867
  artifact.packedAt,
183868
183868
  artifact.ciphertextHash,
183869
- [...artifact.keys].sort().join(","),
183870
183869
  artifact.expiresAt ?? "",
183871
183870
  artifact.envelope?.provider ?? "",
183872
183871
  artifact.envelope?.keyId ?? "",
@@ -183950,7 +183949,6 @@ var ArtifactPoller = class {
183950
183949
  this.options.onRefresh?.(artifact.revision);
183951
183950
  this.telemetry?.artifactRefreshed({
183952
183951
  revision: artifact.revision,
183953
- keyCount: artifact.keys.length,
183954
183952
  kmsEnvelope: !!artifact.envelope
183955
183953
  });
183956
183954
  }
@@ -184113,14 +184111,15 @@ var ArtifactPoller = class {
184113
184111
  const artifact = this.validateArtifact(parsed);
184114
184112
  if (artifact.revision === this.lastRevision) return;
184115
184113
  const { values } = await this.decryptor.decrypt(artifact);
184116
- this.options.cache.swap(values, artifact.keys, artifact.revision);
184114
+ const keys = Object.keys(values);
184115
+ this.options.cache.swap(values, keys, artifact.revision);
184117
184116
  this.lastRevision = artifact.revision;
184118
184117
  this.lastContentHash = contentHash ?? null;
184119
184118
  this.lastExpiresAt = artifact.expiresAt ?? null;
184120
184119
  this.options.onRefresh?.(artifact.revision);
184121
184120
  this.telemetry?.artifactRefreshed({
184122
184121
  revision: artifact.revision,
184123
- keyCount: artifact.keys.length,
184122
+ keyCount: keys.length,
184124
184123
  kmsEnvelope: !!artifact.envelope
184125
184124
  });
184126
184125
  }
@@ -184228,10 +184227,6 @@ var EncryptedArtifactStore = class {
184228
184227
  getStoredAt() {
184229
184228
  return this._storedAt;
184230
184229
  }
184231
- /** Get key names from the stored artifact metadata (no decryption needed). */
184232
- getKeys() {
184233
- return this.artifact ? [...this.artifact.keys] : [];
184234
- }
184235
184230
  /** Get the revision from the stored artifact. */
184236
184231
  getRevision() {
184237
184232
  return this.artifact?.revision ?? null;
@@ -184702,9 +184697,20 @@ function startAgentServer(options) {
184702
184697
  res.json(all);
184703
184698
  }
184704
184699
  });
184705
- app.get("/v1/keys", (_req, res) => {
184700
+ app.get("/v1/keys", async (_req, res) => {
184706
184701
  if (jitMode) {
184707
- res.json(encryptedStore.getKeys());
184702
+ const artifact = encryptedStore.get();
184703
+ if (!artifact) {
184704
+ res.status(503).json({ error: "Secrets not yet loaded" });
184705
+ return;
184706
+ }
184707
+ try {
184708
+ const { values } = await decryptor.decrypt(artifact);
184709
+ res.json(Object.keys(values));
184710
+ } catch (err) {
184711
+ const message = err instanceof Error ? err.message : String(err);
184712
+ res.status(503).json({ error: "Decryption failed", detail: message });
184713
+ }
184708
184714
  } else {
184709
184715
  res.json(cache.getKeys());
184710
184716
  }
@@ -184907,7 +184913,7 @@ async function initialFetch(poller, jitMode, encryptedStore, cache, sourceDesc)
184907
184913
  await poller.fetchAndValidate();
184908
184914
  const artifact = encryptedStore.get();
184909
184915
  const { values } = await poller.getDecryptor().decrypt(artifact);
184910
- cache.swap(values, artifact.keys, artifact.revision);
184916
+ cache.swap(values, Object.keys(values), artifact.revision);
184911
184917
  } else {
184912
184918
  await poller.fetchAndDecrypt();
184913
184919
  }
@@ -184930,7 +184936,7 @@ async function initialFetch(poller, jitMode, encryptedStore, cache, sourceDesc)
184930
184936
  }
184931
184937
 
184932
184938
  // package.json
184933
- var version5 = "0.1.11-beta.62";
184939
+ var version5 = "0.1.11-beta.66";
184934
184940
 
184935
184941
  // src/main.ts
184936
184942
  var isLambda = !!process.env.AWS_LAMBDA_RUNTIME_API;