@keyban/cli 0.4.1 → 0.4.2

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/index.mjs CHANGED
@@ -77684,6 +77684,8 @@ var require_sas = __commonJS({
77684
77684
  "node_modules/.pnpm/@keyban+agent-wallet-protocol@file+..+..+sdk+libs+keyban-agent-wallet-protocol_viem@2.57.4_typescript@5.9.3_zod@3.25.76_/node_modules/@keyban/agent-wallet-protocol/dist/sas.js"(exports) {
77685
77685
  "use strict";
77686
77686
  Object.defineProperty(exports, "__esModule", { value: true });
77687
+ exports.sasContext = sasContext;
77688
+ exports.managementSasScope = managementSasScope;
77687
77689
  exports.commitEnrollment = commitEnrollment;
77688
77690
  exports.verifyEnrollmentCommitment = verifyEnrollmentCommitment;
77689
77691
  exports.deriveSas = deriveSas;
@@ -77691,23 +77693,40 @@ var require_sas = __commonJS({
77691
77693
  var viem_1 = require_cjs2();
77692
77694
  var SAS_DIGITS = 4;
77693
77695
  var SAS_MODULUS = 10n ** BigInt(SAS_DIGITS);
77694
- var COMMIT_KEY = utf8("keyban/treasury/sas/commit/v1");
77695
- var DERIVE_KEY = utf8("keyban/treasury/sas/derive/v1");
77696
- function commitEnrollment(signerBytes, nonceC) {
77697
- return (0, viem_1.bytesToHex)(hmacSha256(COMMIT_KEY, cat((0, viem_1.hexToBytes)(nonceC), (0, viem_1.hexToBytes)(signerBytes))));
77696
+ var COMMIT_KEY = utf8("keyban/treasury/sas/commit/v2");
77697
+ var DERIVE_KEY = utf8("keyban/treasury/sas/derive/v2");
77698
+ var CONTEXT_PATTERN = /^0x[0-9a-fA-F]{256}$/;
77699
+ function sasContext(input) {
77700
+ return (0, viem_1.encodeAbiParameters)([
77701
+ { type: "bytes32" },
77702
+ { type: "uint256" },
77703
+ { type: "address" },
77704
+ { type: "bytes32" }
77705
+ ], [
77706
+ (0, viem_1.keccak256)(utf8(`keyban/treasury/sas/${input.purpose}`)),
77707
+ BigInt(input.chainId),
77708
+ input.account.toLowerCase(),
77709
+ (0, viem_1.keccak256)(utf8(input.scope.toLowerCase()))
77710
+ ]);
77711
+ }
77712
+ function managementSasScope(of, sessionId) {
77713
+ return of.kind === "add" ? `add:${sessionId}` : `recover/${of.form}:${sessionId}`;
77698
77714
  }
77699
- function verifyEnrollmentCommitment(commitment, signerBytes, nonceC) {
77700
- return timingSafeEqualHex(commitEnrollment(signerBytes, nonceC), commitment);
77715
+ function commitEnrollment(signerBytes, nonceC, context2) {
77716
+ return (0, viem_1.bytesToHex)(hmacSha256(COMMIT_KEY, cat(contextBytes(context2), (0, viem_1.hexToBytes)(nonceC), (0, viem_1.hexToBytes)(signerBytes))));
77701
77717
  }
77702
- function deriveSas(signerBytes, nonceC, nonceV) {
77703
- const okm = hmacSha256(DERIVE_KEY, cat((0, viem_1.hexToBytes)(signerBytes), (0, viem_1.hexToBytes)(nonceC), (0, viem_1.hexToBytes)(nonceV)));
77718
+ function verifyEnrollmentCommitment(commitment, signerBytes, nonceC, context2) {
77719
+ return timingSafeEqualHex(commitEnrollment(signerBytes, nonceC, context2), commitment);
77720
+ }
77721
+ function deriveSas(signerBytes, nonceC, nonceV, context2) {
77722
+ const okm = hmacSha256(DERIVE_KEY, cat(contextBytes(context2), (0, viem_1.hexToBytes)(signerBytes), (0, viem_1.hexToBytes)(nonceC), (0, viem_1.hexToBytes)(nonceV)));
77704
77723
  let n = 0n;
77705
77724
  for (let i = 0; i < 8; i++)
77706
77725
  n = n << 8n | BigInt(okm[i]);
77707
77726
  return (n % SAS_MODULUS).toString().padStart(SAS_DIGITS, "0");
77708
77727
  }
77709
- function sasMatches(signerBytes, nonceC, nonceV, typed) {
77710
- const expected = deriveSas(signerBytes, nonceC, nonceV);
77728
+ function sasMatches(signerBytes, nonceC, nonceV, typed, context2) {
77729
+ const expected = deriveSas(signerBytes, nonceC, nonceV, context2);
77711
77730
  const got = typed.trim();
77712
77731
  if (got.length !== expected.length)
77713
77732
  return false;
@@ -77717,6 +77736,12 @@ var require_sas = __commonJS({
77717
77736
  return diff === 0;
77718
77737
  }
77719
77738
  var SHA256_BLOCK = 64;
77739
+ function contextBytes(context2) {
77740
+ if (!CONTEXT_PATTERN.test(context2)) {
77741
+ throw new Error("A SAS context is the 128 bytes of a sasContext");
77742
+ }
77743
+ return (0, viem_1.hexToBytes)(context2);
77744
+ }
77720
77745
  function hmacSha256(key, message) {
77721
77746
  const block = new Uint8Array(SHA256_BLOCK);
77722
77747
  block.set(key.length > SHA256_BLOCK ? (0, viem_1.sha256)(key, "bytes") : key);
@@ -130205,12 +130230,394 @@ var require_wire_schemas = __commonJS({
130205
130230
  }
130206
130231
  });
130207
130232
 
130233
+ // node_modules/.pnpm/@keyban+agent-wallet-protocol@file+..+..+sdk+libs+keyban-agent-wallet-protocol_viem@2.57.4_typescript@5.9.3_zod@3.25.76_/node_modules/@keyban/agent-wallet-protocol/dist/address-words.js
130234
+ var require_address_words = __commonJS({
130235
+ "node_modules/.pnpm/@keyban+agent-wallet-protocol@file+..+..+sdk+libs+keyban-agent-wallet-protocol_viem@2.57.4_typescript@5.9.3_zod@3.25.76_/node_modules/@keyban/agent-wallet-protocol/dist/address-words.js"(exports) {
130236
+ "use strict";
130237
+ Object.defineProperty(exports, "__esModule", { value: true });
130238
+ exports.addressWords = addressWords;
130239
+ var accounts_1 = require_accounts();
130240
+ var viem_1 = require_cjs2();
130241
+ function addressWords(address) {
130242
+ const hash3 = (0, viem_1.hexToBytes)((0, viem_1.keccak256)((0, viem_1.stringToBytes)(address.toLowerCase())));
130243
+ const bits = [];
130244
+ for (const byte of hash3) {
130245
+ for (let i = 7; i >= 0; i--)
130246
+ bits.push(byte >> i & 1);
130247
+ }
130248
+ const words = [];
130249
+ for (let w = 0; w < 6; w++) {
130250
+ let index2 = 0;
130251
+ for (let b = 0; b < 11; b++)
130252
+ index2 = index2 << 1 | bits[w * 11 + b];
130253
+ words.push(accounts_1.english[index2]);
130254
+ }
130255
+ return words;
130256
+ }
130257
+ }
130258
+ });
130259
+
130260
+ // node_modules/.pnpm/@keyban+agent-wallet-protocol@file+..+..+sdk+libs+keyban-agent-wallet-protocol_viem@2.57.4_typescript@5.9.3_zod@3.25.76_/node_modules/@keyban/agent-wallet-protocol/dist/treasury-attestation.js
130261
+ var require_treasury_attestation = __commonJS({
130262
+ "node_modules/.pnpm/@keyban+agent-wallet-protocol@file+..+..+sdk+libs+keyban-agent-wallet-protocol_viem@2.57.4_typescript@5.9.3_zod@3.25.76_/node_modules/@keyban/agent-wallet-protocol/dist/treasury-attestation.js"(exports) {
130263
+ "use strict";
130264
+ Object.defineProperty(exports, "__esModule", { value: true });
130265
+ exports.TREASURY_ATTESTATION_TYPEHASH = void 0;
130266
+ exports.computeInitHash = computeInitHash;
130267
+ exports.hashSignerSet = hashSignerSet;
130268
+ exports.hashRing = hashRing;
130269
+ exports.computeTreasuryAttestationDigest = computeTreasuryAttestationDigest;
130270
+ exports.verifyTreasuryAttestation = verifyTreasuryAttestation;
130271
+ var viem_1 = require_cjs2();
130272
+ var webauthn_1 = require_webauthn();
130273
+ exports.TREASURY_ATTESTATION_TYPEHASH = (0, viem_1.keccak256)((0, viem_1.stringToBytes)("KeybanTreasuryVerified(uint256 chainId,address account,bytes32 setHash,uint64 threshold,bool allowNoMargin,bytes32 ringHash)"));
130274
+ function computeInitHash(input) {
130275
+ return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "bytes[]" }, { type: "uint64" }, { type: "bool" }], [input.signers, BigInt(input.threshold), input.allowNoMargin]));
130276
+ }
130277
+ function hashSignerSet(signers) {
130278
+ const sorted = [...signers].sort((a, b) => {
130279
+ const ha = (0, viem_1.keccak256)(a);
130280
+ const hb = (0, viem_1.keccak256)(b);
130281
+ return ha < hb ? -1 : ha > hb ? 1 : 0;
130282
+ });
130283
+ return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "bytes[]" }], [sorted]));
130284
+ }
130285
+ function uuidToBytes32(uuid2) {
130286
+ return `0x${"0".repeat(32)}${uuid2.replace(/-/g, "")}`;
130287
+ }
130288
+ function hashRing(input) {
130289
+ return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "bytes32[]" }, { type: "uint64" }], [input.userIds.map(uuidToBytes32), BigInt(input.threshold)]));
130290
+ }
130291
+ function computeTreasuryAttestationDigest(input) {
130292
+ return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([
130293
+ { type: "bytes32" },
130294
+ { type: "uint256" },
130295
+ { type: "address" },
130296
+ { type: "bytes32" },
130297
+ { type: "uint64" },
130298
+ { type: "bool" },
130299
+ { type: "bytes32" }
130300
+ ], [
130301
+ exports.TREASURY_ATTESTATION_TYPEHASH,
130302
+ BigInt(input.chainId),
130303
+ input.account,
130304
+ input.setHash,
130305
+ BigInt(input.threshold),
130306
+ input.allowNoMargin,
130307
+ input.ringHash
130308
+ ]));
130309
+ }
130310
+ async function verifyTreasuryAttestation(input) {
130311
+ try {
130312
+ if ((0, viem_1.size)(input.signerBytes) === 20) {
130313
+ const recovered = await (0, viem_1.recoverAddress)({
130314
+ hash: input.digest,
130315
+ signature: input.signature
130316
+ });
130317
+ return recovered.toLowerCase() === input.signerBytes.toLowerCase();
130318
+ }
130319
+ return (0, webauthn_1.verifyWebAuthnAssertion)({
130320
+ signerBytes: input.signerBytes,
130321
+ hash: input.digest,
130322
+ signature: input.signature
130323
+ });
130324
+ } catch {
130325
+ return false;
130326
+ }
130327
+ }
130328
+ }
130329
+ });
130330
+
130331
+ // node_modules/.pnpm/@keyban+agent-wallet-protocol@file+..+..+sdk+libs+keyban-agent-wallet-protocol_viem@2.57.4_typescript@5.9.3_zod@3.25.76_/node_modules/@keyban/agent-wallet-protocol/dist/management.js
130332
+ var require_management = __commonJS({
130333
+ "node_modules/.pnpm/@keyban+agent-wallet-protocol@file+..+..+sdk+libs+keyban-agent-wallet-protocol_viem@2.57.4_typescript@5.9.3_zod@3.25.76_/node_modules/@keyban/agent-wallet-protocol/dist/management.js"(exports) {
130334
+ "use strict";
130335
+ Object.defineProperty(exports, "__esModule", { value: true });
130336
+ exports.SIGNER_BYTES = exports.MANAGE_SIGNERS_TYPEHASH = exports.ManagementReplayError = void 0;
130337
+ exports.hashSignerChanges = hashSignerChanges;
130338
+ exports.computeManageSignersDigest = computeManageSignersDigest;
130339
+ exports.assertReachable = assertReachable;
130340
+ exports.assertMargin = assertMargin;
130341
+ exports.applySignerChanges = applySignerChanges;
130342
+ exports.buildManagementChanges = buildManagementChanges;
130343
+ var viem_1 = require_cjs2();
130344
+ var ManagementReplayError = class extends Error {
130345
+ reason;
130346
+ constructor(reason, detail) {
130347
+ super(detail ? `management/${reason}: ${detail}` : `management/${reason}`);
130348
+ this.reason = reason;
130349
+ this.name = "ManagementReplayError";
130350
+ }
130351
+ };
130352
+ exports.ManagementReplayError = ManagementReplayError;
130353
+ exports.MANAGE_SIGNERS_TYPEHASH = (0, viem_1.keccak256)((0, viem_1.stringToBytes)("KeybanManageSigners(uint256 chainId,address account,uint256 nonce,bytes32 changesHash)"));
130354
+ var SIGNER_CHANGES_PARAMS = [
130355
+ {
130356
+ type: "tuple",
130357
+ components: [
130358
+ { name: "add", type: "bytes[]" },
130359
+ { name: "remove", type: "bytes[]" },
130360
+ { name: "newThreshold", type: "uint64" },
130361
+ { name: "setNoMargin", type: "bool" }
130362
+ ]
130363
+ }
130364
+ ];
130365
+ exports.SIGNER_BYTES = /^0x(?:[0-9a-f]{2}){20,}$/;
130366
+ var MIN_SIGNERS = 2;
130367
+ var lower = (hex) => hex.toLowerCase();
130368
+ function assertThreshold(newThreshold) {
130369
+ if (!Number.isSafeInteger(newThreshold) || newThreshold < 0) {
130370
+ throw new ManagementReplayError("invalid-request", `threshold ${newThreshold} is not a uint64`);
130371
+ }
130372
+ }
130373
+ function hashSignerChanges(changes) {
130374
+ assertThreshold(changes.newThreshold);
130375
+ return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)(SIGNER_CHANGES_PARAMS, [
130376
+ {
130377
+ add: changes.add.map(lower),
130378
+ remove: changes.remove.map(lower),
130379
+ newThreshold: BigInt(changes.newThreshold),
130380
+ setNoMargin: changes.setNoMargin
130381
+ }
130382
+ ]));
130383
+ }
130384
+ function computeManageSignersDigest(input) {
130385
+ return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([
130386
+ { type: "bytes32" },
130387
+ { type: "uint256" },
130388
+ { type: "address" },
130389
+ { type: "uint256" },
130390
+ { type: "bytes32" }
130391
+ ], [
130392
+ exports.MANAGE_SIGNERS_TYPEHASH,
130393
+ BigInt(input.chainId),
130394
+ lower(input.account),
130395
+ input.nonce,
130396
+ hashSignerChanges(input.changes)
130397
+ ]));
130398
+ }
130399
+ function assertReachable(signers, threshold) {
130400
+ if (signers < threshold) {
130401
+ throw new ManagementReplayError("unreachable-threshold", `${signers} signers cannot reach a threshold of ${threshold}`);
130402
+ }
130403
+ }
130404
+ function assertMargin(signers, threshold, allowNoMargin) {
130405
+ if (signers < MIN_SIGNERS) {
130406
+ throw new ManagementReplayError("too-few-signers", `${signers} signer(s) left, at least ${MIN_SIGNERS} needed`);
130407
+ }
130408
+ if (signers < threshold + 1 && !allowNoMargin) {
130409
+ throw new ManagementReplayError("no-margin", `${signers} signers at a threshold of ${threshold} leave no spare seat`);
130410
+ }
130411
+ }
130412
+ function applySignerChanges(state, changes, signedBy) {
130413
+ assertThreshold(changes.newThreshold);
130414
+ const signers = new Set(state.signers.map(lower));
130415
+ const current = state.threshold;
130416
+ let { threshold, allowNoMargin } = state;
130417
+ for (const added of changes.add) {
130418
+ const signer = lower(added);
130419
+ if (!exports.SIGNER_BYTES.test(signer)) {
130420
+ throw new ManagementReplayError("invalid-signer", added);
130421
+ }
130422
+ if (signers.has(signer)) {
130423
+ throw new ManagementReplayError("already-exists", signer);
130424
+ }
130425
+ signers.add(signer);
130426
+ }
130427
+ if (changes.newThreshold !== 0 && changes.newThreshold < current) {
130428
+ threshold = changes.newThreshold;
130429
+ assertReachable(signers.size, threshold);
130430
+ }
130431
+ for (const removed of changes.remove) {
130432
+ if (!signers.delete(lower(removed))) {
130433
+ throw new ManagementReplayError("nonexistent-signer", removed);
130434
+ }
130435
+ }
130436
+ assertReachable(signers.size, threshold);
130437
+ if (changes.newThreshold > current) {
130438
+ threshold = changes.newThreshold;
130439
+ assertReachable(signers.size, threshold);
130440
+ }
130441
+ if (changes.setNoMargin && !allowNoMargin) {
130442
+ if (signedBy) {
130443
+ const signed = new Set(signedBy.map(lower));
130444
+ const silent = [...signers].filter((signer) => !signed.has(signer));
130445
+ if (silent.length > 0) {
130446
+ throw new ManagementReplayError("no-margin-signers", `${silent.length} signer(s) of the resulting set did not sign`);
130447
+ }
130448
+ }
130449
+ allowNoMargin = true;
130450
+ }
130451
+ assertMargin(signers.size, threshold, allowNoMargin);
130452
+ return { signers: [...signers].sort(), threshold, allowNoMargin };
130453
+ }
130454
+ function changesFor(input) {
130455
+ const { kind, head, vouch, target, newThreshold } = input;
130456
+ const count2 = new Set(head.signers.map(lower)).size;
130457
+ switch (kind) {
130458
+ case "add":
130459
+ if (!vouch?.signerBytes) {
130460
+ throw new ManagementReplayError("invalid-request", "an add needs the vouched signer bytes");
130461
+ }
130462
+ return {
130463
+ add: [lower(vouch.signerBytes)],
130464
+ remove: [],
130465
+ newThreshold: 0,
130466
+ setNoMargin: false
130467
+ };
130468
+ case "remove":
130469
+ if (!target) {
130470
+ throw new ManagementReplayError("invalid-request", "a removal needs the target signer");
130471
+ }
130472
+ return {
130473
+ add: [],
130474
+ remove: [lower(target)],
130475
+ newThreshold: 0,
130476
+ setNoMargin: count2 - 1 === head.threshold && !head.allowNoMargin
130477
+ };
130478
+ case "threshold":
130479
+ if (newThreshold === void 0 || !Number.isSafeInteger(newThreshold) || newThreshold < 1 || newThreshold === head.threshold) {
130480
+ throw new ManagementReplayError("invalid-request", `${newThreshold} is not a new threshold`);
130481
+ }
130482
+ return {
130483
+ add: [],
130484
+ remove: [],
130485
+ newThreshold,
130486
+ setNoMargin: count2 === newThreshold && !head.allowNoMargin
130487
+ };
130488
+ default:
130489
+ throw new ManagementReplayError("invalid-request", `unknown management kind ${String(kind)}`);
130490
+ }
130491
+ }
130492
+ function buildManagementChanges(input) {
130493
+ const changes = changesFor(input);
130494
+ applySignerChanges(input.head, changes);
130495
+ return changes;
130496
+ }
130497
+ }
130498
+ });
130499
+
130500
+ // node_modules/.pnpm/@keyban+agent-wallet-protocol@file+..+..+sdk+libs+keyban-agent-wallet-protocol_viem@2.57.4_typescript@5.9.3_zod@3.25.76_/node_modules/@keyban/agent-wallet-protocol/dist/rotation.js
130501
+ var require_rotation = __commonJS({
130502
+ "node_modules/.pnpm/@keyban+agent-wallet-protocol@file+..+..+sdk+libs+keyban-agent-wallet-protocol_viem@2.57.4_typescript@5.9.3_zod@3.25.76_/node_modules/@keyban/agent-wallet-protocol/dist/rotation.js"(exports) {
130503
+ "use strict";
130504
+ Object.defineProperty(exports, "__esModule", { value: true });
130505
+ exports.NO_MARGIN_RECOVERY_INTERVAL_SECONDS = exports.RENEWAL_COOLDOWN_SECONDS = exports.SCHNORR_MULTISIG_STORAGE_BASE = exports.SIGNER_ROTATED_TOPIC = exports.ROTATION_TYPEHASHES = void 0;
130506
+ exports.computeRotationDigest = computeRotationDigest;
130507
+ exports.isSameKind = isSameKind;
130508
+ exports.applySignerRotation = applySignerRotation;
130509
+ exports.renewalCooldownSlot = renewalCooldownSlot;
130510
+ exports.lastRenewalAtOf = lastRenewalAtOf;
130511
+ exports.renewableAt = renewableAt;
130512
+ exports.recoveryFormOf = recoveryFormOf;
130513
+ exports.noMarginPeersNeeded = noMarginPeersNeeded;
130514
+ exports.noMarginReopensAt = noMarginReopensAt;
130515
+ var viem_1 = require_cjs2();
130516
+ var management_1 = require_management();
130517
+ var ROTATION_FIELDS = "(uint256 chainId,address account,uint256 nonce,bytes32 oldSigner,bytes32 newSigner)";
130518
+ var typehashOf = (name) => (0, viem_1.keccak256)((0, viem_1.stringToBytes)(`${name}${ROTATION_FIELDS}`));
130519
+ exports.ROTATION_TYPEHASHES = {
130520
+ renew: typehashOf("KeybanRenewSigner"),
130521
+ pop: typehashOf("KeybanProofOfPossession"),
130522
+ peers: typehashOf("KeybanRotateSignerByPeers"),
130523
+ noMargin: typehashOf("KeybanRotateSignerNoMargin"),
130524
+ attest: typehashOf("KeybanRecoveryAttestation")
130525
+ };
130526
+ exports.SIGNER_ROTATED_TOPIC = (0, viem_1.keccak256)((0, viem_1.stringToBytes)("SignerRotated(bytes32,bytes32,uint256,bytes32)"));
130527
+ var lower = (hex) => hex.toLowerCase();
130528
+ function computeRotationDigest(input) {
130529
+ return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([
130530
+ { type: "bytes32" },
130531
+ { type: "uint256" },
130532
+ { type: "address" },
130533
+ { type: "uint256" },
130534
+ { type: "bytes32" },
130535
+ { type: "bytes32" }
130536
+ ], [
130537
+ input.typehash,
130538
+ BigInt(input.chainId),
130539
+ lower(input.account),
130540
+ input.nonce,
130541
+ (0, viem_1.keccak256)(lower(input.oldSigner)),
130542
+ (0, viem_1.keccak256)(lower(input.newSigner))
130543
+ ]));
130544
+ }
130545
+ function isSameKind(a, b) {
130546
+ const left = lower(a);
130547
+ const right = lower(b);
130548
+ if (!management_1.SIGNER_BYTES.test(left) || !management_1.SIGNER_BYTES.test(right))
130549
+ return false;
130550
+ if (left.length !== right.length)
130551
+ return false;
130552
+ return left.length === 42 || left.slice(0, 42) === right.slice(0, 42);
130553
+ }
130554
+ function applySignerRotation(state, oldSigner, newSigner) {
130555
+ const from16 = lower(oldSigner);
130556
+ const to = lower(newSigner);
130557
+ for (const signer of [oldSigner, newSigner]) {
130558
+ if (!management_1.SIGNER_BYTES.test(lower(signer))) {
130559
+ throw new management_1.ManagementReplayError("invalid-signer", signer);
130560
+ }
130561
+ }
130562
+ const signers = new Set(state.signers.map(lower));
130563
+ if (!signers.has(from16)) {
130564
+ throw new management_1.ManagementReplayError("nonexistent-signer", from16);
130565
+ }
130566
+ if (signers.has(to)) {
130567
+ throw new management_1.ManagementReplayError("already-exists", to);
130568
+ }
130569
+ if (!isSameKind(from16, to)) {
130570
+ throw new management_1.ManagementReplayError("not-same-kind", `${to} is not of the kind of ${from16}`);
130571
+ }
130572
+ signers.add(to);
130573
+ signers.delete(from16);
130574
+ (0, management_1.assertReachable)(signers.size, state.threshold);
130575
+ (0, management_1.assertMargin)(signers.size, state.threshold, state.allowNoMargin);
130576
+ return {
130577
+ signers: [...signers].sort(),
130578
+ threshold: state.threshold,
130579
+ allowNoMargin: state.allowNoMargin
130580
+ };
130581
+ }
130582
+ exports.SCHNORR_MULTISIG_STORAGE_BASE = "0xea52a9ad8384622388119609dca1722a3aa89a3d8118d73009c61a4f0cc19100";
130583
+ exports.RENEWAL_COOLDOWN_SECONDS = 86400;
130584
+ var LAST_RENEWAL_AT_FIELD = 3n;
130585
+ function renewalCooldownSlot(signerBytes) {
130586
+ return (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: "bytes32" }, { type: "uint256" }], [
130587
+ (0, viem_1.keccak256)(lower(signerBytes)),
130588
+ (0, viem_1.hexToBigInt)(exports.SCHNORR_MULTISIG_STORAGE_BASE) + LAST_RENEWAL_AT_FIELD
130589
+ ]));
130590
+ }
130591
+ function lastRenewalAtOf(word) {
130592
+ return Number((0, viem_1.hexToBigInt)((0, viem_1.slice)(word, 24, 32)));
130593
+ }
130594
+ function renewableAt(word) {
130595
+ const lastRenewalAt = lastRenewalAtOf(word);
130596
+ return lastRenewalAt === 0 ? null : lastRenewalAt + exports.RENEWAL_COOLDOWN_SECONDS;
130597
+ }
130598
+ exports.NO_MARGIN_RECOVERY_INTERVAL_SECONDS = 2592e3;
130599
+ function recoveryFormOf(state) {
130600
+ const count2 = state.signers.length;
130601
+ if (count2 - 1 >= state.threshold)
130602
+ return "peers";
130603
+ return state.allowNoMargin && count2 === state.threshold && count2 >= 2 ? "noMargin" : null;
130604
+ }
130605
+ function noMarginPeersNeeded(signerCount) {
130606
+ return Math.min(2, signerCount - 1);
130607
+ }
130608
+ function noMarginReopensAt(landedAt) {
130609
+ return new Date(landedAt.getTime() + exports.NO_MARGIN_RECOVERY_INTERVAL_SECONDS * 1e3);
130610
+ }
130611
+ }
130612
+ });
130613
+
130208
130614
  // node_modules/.pnpm/@keyban+agent-wallet-protocol@file+..+..+sdk+libs+keyban-agent-wallet-protocol_viem@2.57.4_typescript@5.9.3_zod@3.25.76_/node_modules/@keyban/agent-wallet-protocol/dist/index.js
130209
130615
  var require_dist3 = __commonJS({
130210
130616
  "node_modules/.pnpm/@keyban+agent-wallet-protocol@file+..+..+sdk+libs+keyban-agent-wallet-protocol_viem@2.57.4_typescript@5.9.3_zod@3.25.76_/node_modules/@keyban/agent-wallet-protocol/dist/index.js"(exports) {
130211
130617
  "use strict";
130212
130618
  Object.defineProperty(exports, "__esModule", { value: true });
130213
- exports.networkToChainId = exports.evmChainIdForNetwork = exports.x402RequestSchema = exports.x402AuthorizationSchema = exports.relayPreimageSchema = exports.policyInputSchema = exports.policyDecisionSchema = exports.normalizeFrostSig = exports.encodeMultiSignerSignature = exports.decompressPoint = exports.selectExactUsdcAccept = exports.extractPayTos = exports.decodeX402 = exports.x402ToCanonical = exports.relayToCanonical = exports.extractRelayPayment = exports.computeRelayHash = exports.computeLotRelayHash = exports.computeBatchRelayHash = exports.recomputeErc7739Hash = exports.buildEip3009TypedData = exports.EIP3009_PRIMARY_TYPES = exports.EIP3009_FIELDS = exports.webAuthnSignerFromPrivateKey = exports.webAuthnChallenge = exports.verifyWebAuthnAssertion = exports.toLowS = exports.signWebAuthnAssertion = exports.encodeWebAuthnSigner = exports.encodeWebAuthnSignature = exports.encodeAuthenticatorAssertion = exports.decodeWebAuthnSignature = exports.decodeP256PublicKey = exports.base64UrlToBytes = exports.P256_N = exports.encodeMultiSignerEnvelope = exports.verifyEnrollmentCommitment = exports.sasMatches = exports.deriveSas = exports.commitEnrollment = exports.isCanonicalUsdc = exports.getUsdcChainEntry = void 0;
130619
+ exports.hashSignerSet = exports.hashRing = exports.computeTreasuryAttestationDigest = exports.computeInitHash = exports.TREASURY_ATTESTATION_TYPEHASH = exports.addressWords = exports.networkToChainId = exports.evmChainIdForNetwork = exports.x402RequestSchema = exports.x402AuthorizationSchema = exports.relayPreimageSchema = exports.policyInputSchema = exports.policyDecisionSchema = exports.normalizeFrostSig = exports.encodeMultiSignerSignature = exports.decompressPoint = exports.selectExactUsdcAccept = exports.extractPayTos = exports.decodeX402 = exports.x402ToCanonical = exports.relayToCanonical = exports.extractRelayPayment = exports.computeRelayHash = exports.computeLotRelayHash = exports.computeBatchRelayHash = exports.recomputeErc7739Hash = exports.buildEip3009TypedData = exports.EIP3009_PRIMARY_TYPES = exports.EIP3009_FIELDS = exports.webAuthnSignerFromPrivateKey = exports.webAuthnChallenge = exports.verifyWebAuthnAssertion = exports.toLowS = exports.signWebAuthnAssertion = exports.encodeWebAuthnSigner = exports.encodeWebAuthnSignature = exports.encodeAuthenticatorAssertion = exports.decodeWebAuthnSignature = exports.decodeP256PublicKey = exports.base64UrlToBytes = exports.P256_N = exports.encodeMultiSignerEnvelope = exports.verifyEnrollmentCommitment = exports.sasMatches = exports.sasContext = exports.managementSasScope = exports.deriveSas = exports.commitEnrollment = exports.isCanonicalUsdc = exports.getUsdcChainEntry = void 0;
130620
+ exports.renewalCooldownSlot = exports.renewableAt = exports.recoveryFormOf = exports.noMarginReopensAt = exports.noMarginPeersNeeded = exports.lastRenewalAtOf = exports.isSameKind = exports.computeRotationDigest = exports.applySignerRotation = exports.SIGNER_ROTATED_TOPIC = exports.SCHNORR_MULTISIG_STORAGE_BASE = exports.ROTATION_TYPEHASHES = exports.RENEWAL_COOLDOWN_SECONDS = exports.NO_MARGIN_RECOVERY_INTERVAL_SECONDS = exports.hashSignerChanges = exports.computeManageSignersDigest = exports.buildManagementChanges = exports.applySignerChanges = exports.ManagementReplayError = exports.MANAGE_SIGNERS_TYPEHASH = exports.verifyTreasuryAttestation = void 0;
130214
130621
  var usdc_registry_1 = require_usdc_registry();
130215
130622
  Object.defineProperty(exports, "getUsdcChainEntry", { enumerable: true, get: function() {
130216
130623
  return usdc_registry_1.getUsdcChainEntry;
@@ -130225,6 +130632,12 @@ var require_dist3 = __commonJS({
130225
130632
  Object.defineProperty(exports, "deriveSas", { enumerable: true, get: function() {
130226
130633
  return sas_1.deriveSas;
130227
130634
  } });
130635
+ Object.defineProperty(exports, "managementSasScope", { enumerable: true, get: function() {
130636
+ return sas_1.managementSasScope;
130637
+ } });
130638
+ Object.defineProperty(exports, "sasContext", { enumerable: true, get: function() {
130639
+ return sas_1.sasContext;
130640
+ } });
130228
130641
  Object.defineProperty(exports, "sasMatches", { enumerable: true, get: function() {
130229
130642
  return sas_1.sasMatches;
130230
130643
  } });
@@ -130349,6 +130762,91 @@ var require_dist3 = __commonJS({
130349
130762
  Object.defineProperty(exports, "networkToChainId", { enumerable: true, get: function() {
130350
130763
  return network_1.networkToChainId;
130351
130764
  } });
130765
+ var address_words_1 = require_address_words();
130766
+ Object.defineProperty(exports, "addressWords", { enumerable: true, get: function() {
130767
+ return address_words_1.addressWords;
130768
+ } });
130769
+ var treasury_attestation_1 = require_treasury_attestation();
130770
+ Object.defineProperty(exports, "TREASURY_ATTESTATION_TYPEHASH", { enumerable: true, get: function() {
130771
+ return treasury_attestation_1.TREASURY_ATTESTATION_TYPEHASH;
130772
+ } });
130773
+ Object.defineProperty(exports, "computeInitHash", { enumerable: true, get: function() {
130774
+ return treasury_attestation_1.computeInitHash;
130775
+ } });
130776
+ Object.defineProperty(exports, "computeTreasuryAttestationDigest", { enumerable: true, get: function() {
130777
+ return treasury_attestation_1.computeTreasuryAttestationDigest;
130778
+ } });
130779
+ Object.defineProperty(exports, "hashRing", { enumerable: true, get: function() {
130780
+ return treasury_attestation_1.hashRing;
130781
+ } });
130782
+ Object.defineProperty(exports, "hashSignerSet", { enumerable: true, get: function() {
130783
+ return treasury_attestation_1.hashSignerSet;
130784
+ } });
130785
+ Object.defineProperty(exports, "verifyTreasuryAttestation", { enumerable: true, get: function() {
130786
+ return treasury_attestation_1.verifyTreasuryAttestation;
130787
+ } });
130788
+ var management_1 = require_management();
130789
+ Object.defineProperty(exports, "MANAGE_SIGNERS_TYPEHASH", { enumerable: true, get: function() {
130790
+ return management_1.MANAGE_SIGNERS_TYPEHASH;
130791
+ } });
130792
+ Object.defineProperty(exports, "ManagementReplayError", { enumerable: true, get: function() {
130793
+ return management_1.ManagementReplayError;
130794
+ } });
130795
+ Object.defineProperty(exports, "applySignerChanges", { enumerable: true, get: function() {
130796
+ return management_1.applySignerChanges;
130797
+ } });
130798
+ Object.defineProperty(exports, "buildManagementChanges", { enumerable: true, get: function() {
130799
+ return management_1.buildManagementChanges;
130800
+ } });
130801
+ Object.defineProperty(exports, "computeManageSignersDigest", { enumerable: true, get: function() {
130802
+ return management_1.computeManageSignersDigest;
130803
+ } });
130804
+ Object.defineProperty(exports, "hashSignerChanges", { enumerable: true, get: function() {
130805
+ return management_1.hashSignerChanges;
130806
+ } });
130807
+ var rotation_1 = require_rotation();
130808
+ Object.defineProperty(exports, "NO_MARGIN_RECOVERY_INTERVAL_SECONDS", { enumerable: true, get: function() {
130809
+ return rotation_1.NO_MARGIN_RECOVERY_INTERVAL_SECONDS;
130810
+ } });
130811
+ Object.defineProperty(exports, "RENEWAL_COOLDOWN_SECONDS", { enumerable: true, get: function() {
130812
+ return rotation_1.RENEWAL_COOLDOWN_SECONDS;
130813
+ } });
130814
+ Object.defineProperty(exports, "ROTATION_TYPEHASHES", { enumerable: true, get: function() {
130815
+ return rotation_1.ROTATION_TYPEHASHES;
130816
+ } });
130817
+ Object.defineProperty(exports, "SCHNORR_MULTISIG_STORAGE_BASE", { enumerable: true, get: function() {
130818
+ return rotation_1.SCHNORR_MULTISIG_STORAGE_BASE;
130819
+ } });
130820
+ Object.defineProperty(exports, "SIGNER_ROTATED_TOPIC", { enumerable: true, get: function() {
130821
+ return rotation_1.SIGNER_ROTATED_TOPIC;
130822
+ } });
130823
+ Object.defineProperty(exports, "applySignerRotation", { enumerable: true, get: function() {
130824
+ return rotation_1.applySignerRotation;
130825
+ } });
130826
+ Object.defineProperty(exports, "computeRotationDigest", { enumerable: true, get: function() {
130827
+ return rotation_1.computeRotationDigest;
130828
+ } });
130829
+ Object.defineProperty(exports, "isSameKind", { enumerable: true, get: function() {
130830
+ return rotation_1.isSameKind;
130831
+ } });
130832
+ Object.defineProperty(exports, "lastRenewalAtOf", { enumerable: true, get: function() {
130833
+ return rotation_1.lastRenewalAtOf;
130834
+ } });
130835
+ Object.defineProperty(exports, "noMarginPeersNeeded", { enumerable: true, get: function() {
130836
+ return rotation_1.noMarginPeersNeeded;
130837
+ } });
130838
+ Object.defineProperty(exports, "noMarginReopensAt", { enumerable: true, get: function() {
130839
+ return rotation_1.noMarginReopensAt;
130840
+ } });
130841
+ Object.defineProperty(exports, "recoveryFormOf", { enumerable: true, get: function() {
130842
+ return rotation_1.recoveryFormOf;
130843
+ } });
130844
+ Object.defineProperty(exports, "renewableAt", { enumerable: true, get: function() {
130845
+ return rotation_1.renewableAt;
130846
+ } });
130847
+ Object.defineProperty(exports, "renewalCooldownSlot", { enumerable: true, get: function() {
130848
+ return rotation_1.renewalCooldownSlot;
130849
+ } });
130352
130850
  }
130353
130851
  });
130354
130852
 
@@ -156004,9 +156502,15 @@ function setupCommand() {
156004
156502
  ).requiredOption("--wallet-id <id>", "the wallet to install, as the dashboard names it").requiredOption("--client <client>", "the agent, as install-mcp names it: codex, claude-code, cursor\u2026").option("--api <env|url>", "the Keyban API the wallet lives on", defaultApi()).option("--force", "overwrite the wallet file there, losing its client share").action(async (options) => {
156005
156503
  try {
156006
156504
  const api = resolveURL(options.api);
156505
+ process.stderr.write(`Checking the Keyban session on ${new URL(api).origin}\u2026
156506
+ `);
156007
156507
  process.stdout.write(`${await loggedIn(api)}
156508
+ `);
156509
+ process.stderr.write(`Keeping wallet ${options.walletId} (waits for its signer, up to a minute)\u2026
156008
156510
  `);
156009
156511
  process.stdout.write(`Using ${await importWalletSigner(api, options.walletId, process.env, options.force)}
156512
+ `);
156513
+ process.stderr.write(`Registering agent-wallet for ${options.client} with npx install-mcp\u2026
156010
156514
  `);
156011
156515
  register(options.client);
156012
156516
  process.stdout.write(`Registered agent-wallet for ${options.client}: open a new conversation to use it.
@@ -156021,7 +156525,7 @@ function setupCommand() {
156021
156525
  }
156022
156526
 
156023
156527
  // src/index.ts
156024
- var VERSION5 = true ? "0.4.1" : "0.0.0";
156528
+ var VERSION5 = true ? "0.4.2" : "0.0.0";
156025
156529
  if (process.argv[2] !== "mcp" && !process.env.MCP_LOG_LEVEL) logger.setMinLevel("error");
156026
156530
  function typedArgv(argv) {
156027
156531
  if (argv[2] !== "__complete") return argv;