@haven_ai/signer 0.1.21-alpha.0 → 0.1.22-alpha.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.
package/dist/cli.cjs CHANGED
@@ -238,9 +238,16 @@ var SUPPORTED_SWEEP_BINDING_VERSIONS = [1];
238
238
  function assertSupportedBindingVersion(received, supported, context) {
239
239
  if (supported.includes(received)) return;
240
240
  const highest = Math.max(...supported);
241
- const ceiling = received > highest ? `This signer is out of date: it supports ${context} versions up to ${highest}, and Haven sent version ${received}. Update @haven_ai/signer \u2014 rerun the Haven connector (\`npx @haven_ai/connect@alpha\`), which reinstalls the pinned MCP runtime.` : `Unsupported ${context} version ${received}: this signer supports ${supported.join(", ")}.`;
242
- throw new sdk.HavenSigningError(
243
- `${ceiling} Nothing was signed. Do not rewrite the version field to a supported value: it is part of the Haven-signed binding message, so changing it invalidates the signature and would misrepresent what Haven authorised.`
241
+ const outOfDate = received > highest;
242
+ const code = context === "x402 expected context" ? sdk.SignerRefusalCode.UnsupportedExpectedContextVersion : sdk.SignerRefusalCode.UnsupportedSweepBindingVersion;
243
+ const ceiling = outOfDate ? `This signer is out of date: it supports ${context} versions up to ${highest}, and Haven sent version ${received}. Update @haven_ai/signer \u2014 rerun the Haven connector (\`npx @haven_ai/connect@alpha\`), which reinstalls the pinned MCP runtime.` : `Unsupported ${context} version ${received}: this signer supports ${supported.join(", ")}.`;
244
+ const fallback = outOfDate ? sdk.SIGNER_UPDATE_FALLBACK : `This ${context} version (${received}) is older than what this signer enforces (${supported.join(", ")}) \u2014 updating @haven_ai/signer will not restore it. Nothing was signed or spent; stop and tell the user rather than retrying.`;
245
+ throw new sdk.HavenUnsupportedSignerVersionError(
246
+ `${ceiling} Nothing was signed. Do not rewrite the version field to a supported value: it is part of the Haven-signed binding message, so changing it invalidates the signature and would misrepresent what Haven authorised.`,
247
+ code,
248
+ supported,
249
+ received,
250
+ fallback
244
251
  );
245
252
  }
246
253
  function assertExpectedBinding(payloadHash, expected, trustedSigner, mode = "hash") {
@@ -339,7 +346,11 @@ function signerInstructions() {
339
346
  "above, this signer is out of date: STOP before signing, and tell the user to update",
340
347
  "@haven_ai/signer by rerunning `npx @haven_ai/connect@alpha`, which reinstalls the pinned",
341
348
  "MCP runtime. Do not edit the version field to a supported value \u2014 it is part of the",
342
- "Haven-signed binding message, so changing it invalidates the signature."
349
+ "Haven-signed binding message, so changing it invalidates the signature.",
350
+ "",
351
+ "A version-mismatch refusal from haven_sign / haven_sign_x402 / haven_sign_sweep_delegate is",
352
+ "machine-readable, not just prose: it carries code, supported_versions, received_version, and",
353
+ "fallback fields alongside the message, so you can branch on it directly."
343
354
  ].join("\n");
344
355
  }
345
356
  async function loadHavenIdentity(credentialsPath) {
@@ -763,6 +774,17 @@ function normalizeError(err) {
763
774
  statusCode: 400
764
775
  };
765
776
  }
777
+ if (err instanceof sdk.HavenUnsupportedSignerVersionError) {
778
+ return {
779
+ success: false,
780
+ code: err.code,
781
+ message: err.message,
782
+ supported_versions: [...err.supportedVersions],
783
+ received_version: err.receivedVersion,
784
+ fallback: err.fallback,
785
+ next_action: sdk.AgentPaymentNextAction.StopAndTellUser
786
+ };
787
+ }
766
788
  if (err instanceof sdk.HavenSigningError) {
767
789
  return { success: false, code: err.code, message: err.message };
768
790
  }
@@ -998,7 +1020,7 @@ async function warnIfCredentialFilePermissive(path, log = (message) => process.s
998
1020
 
999
1021
  // src/server.ts
1000
1022
  var SIGNER_NAME = "@haven_ai/signer";
1001
- var SIGNER_VERSION = "0.1.21-alpha.0";
1023
+ var SIGNER_VERSION = "0.1.22-alpha.0";
1002
1024
  async function resolveSignerRuntime(options = {}) {
1003
1025
  assertSupportedNodeVersion(options.nodeVersion);
1004
1026
  if (options.delegateKey) {