@gvnrdao/dh-mcp 0.5.5 → 0.5.7

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.js CHANGED
@@ -14194,6 +14194,9 @@ var require_pkg_src = __commonJS({
14194
14194
  });
14195
14195
  var index_exports = {};
14196
14196
  __export3(index_exports, {
14197
+ BORROWER_AUTHORIZATION_ENCODE_TYPES: () => BORROWER_AUTHORIZATION_ENCODE_TYPES,
14198
+ BORROWER_AUTHORIZATION_FIELDS: () => BORROWER_AUTHORIZATION_FIELDS,
14199
+ BORROWER_AUTHORIZATION_PRIMARY_TYPES: () => BORROWER_AUTHORIZATION_PRIMARY_TYPES,
14197
14200
  CHIPOTLE_DEPLOYMENTS: () => CHIPOTLE_DEPLOYMENTS,
14198
14201
  DEFAULT_CACHE_CONFIG: () => DEFAULT_CACHE_CONFIG,
14199
14202
  DEFAULT_DEBUG_CONFIG: () => DEFAULT_DEBUG_CONFIG,
@@ -14206,6 +14209,8 @@ var require_pkg_src = __commonJS({
14206
14209
  PerformanceTracker: () => PerformanceTracker,
14207
14210
  RetryStrategy: () => RetryStrategy,
14208
14211
  analyzeError: () => analyzeError,
14212
+ borrowerAuthorizationTypes: () => borrowerAuthorizationTypes,
14213
+ buildBorrowerAuthorizationDomain: () => buildBorrowerAuthorizationDomain,
14209
14214
  calculateDelay: () => calculateDelay,
14210
14215
  cidToHex: () => cidToHex,
14211
14216
  classifyError: () => classifyError,
@@ -14452,30 +14457,30 @@ var require_pkg_src = __commonJS({
14452
14457
  }
14453
14458
  },
14454
14459
  btcTransactionSigner: {
14455
- cid: "QmakWzTce8NH1Jkgv1xwg83Bg9WmF2UG1Mq76pDYDSwwUp",
14460
+ cid: "QmVi1BYdxvCX3QUhXwPtP6FjWMzqSPtXzrS54YsXjTgjYf",
14456
14461
  authorizedCidHex: cidToHex(
14457
- "QmakWzTce8NH1Jkgv1xwg83Bg9WmF2UG1Mq76pDYDSwwUp"
14462
+ "QmVi1BYdxvCX3QUhXwPtP6FjWMzqSPtXzrS54YsXjTgjYf"
14458
14463
  ),
14459
14464
  name: "Btc Transaction Signer",
14460
14465
  description: "Production Btc Transaction Signer",
14461
14466
  version: "1.1.1",
14462
14467
  deployed: true,
14463
- deployedAt: 1786465606156,
14464
- size: 67999,
14465
- hash: "83f3644c68819215e05ba8db3225571354a009458fc1437f606df6cb9142d3f9"
14468
+ deployedAt: 1787923905597,
14469
+ size: 70646,
14470
+ hash: "37c3bb72a660c8275d92e1b73f9482742d86b64789480b9246304c0ca1bab47a"
14466
14471
  },
14467
14472
  ucdMintValidator: {
14468
- cid: "Qmd8jgKRceLvf5aoTtwdXG2JqMoBK5cRJwrvEtQkgvbFbx",
14473
+ cid: "QmUWR5fLiyimLT9TPXpYx3HgwNwkvR6MxjZ7hdeYCFodbc",
14469
14474
  authorizedCidHex: cidToHex(
14470
- "Qmd8jgKRceLvf5aoTtwdXG2JqMoBK5cRJwrvEtQkgvbFbx"
14475
+ "QmUWR5fLiyimLT9TPXpYx3HgwNwkvR6MxjZ7hdeYCFodbc"
14471
14476
  ),
14472
14477
  name: "Ucd Mint Validator",
14473
14478
  description: "Production Ucd Mint Validator",
14474
14479
  version: "1.2.1",
14475
14480
  deployed: true,
14476
- deployedAt: 1786465627201,
14477
- size: 82739,
14478
- hash: "2bdd9aebdaad58a43a4731d5b7284f2531b7a9caaf8caf5719d891c4ed33cb2e",
14481
+ deployedAt: 1787923919527,
14482
+ size: 86197,
14483
+ hash: "c2d80939746cc37f65ef2f63c6a3215b929214a63f10c78144e1f5c98320dabf",
14479
14484
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14480
14485
  pkp: {
14481
14486
  publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
@@ -14483,17 +14488,17 @@ var require_pkg_src = __commonJS({
14483
14488
  }
14484
14489
  },
14485
14490
  processPaymentValidator: {
14486
- cid: "QmNXVdysXDhCaQ1uNE2Vgjbuzy6yUEnnVgHzmDfNKXMU6z",
14491
+ cid: "QmXmXuMRAjMLdgKGyTf9KQdGwYrDp8DxkiF44TvSXDf7wF",
14487
14492
  authorizedCidHex: cidToHex(
14488
- "QmNXVdysXDhCaQ1uNE2Vgjbuzy6yUEnnVgHzmDfNKXMU6z"
14493
+ "QmXmXuMRAjMLdgKGyTf9KQdGwYrDp8DxkiF44TvSXDf7wF"
14489
14494
  ),
14490
14495
  name: "Process Payment Validator",
14491
14496
  description: "Production Process Payment Validator",
14492
14497
  version: "1.2.1",
14493
14498
  deployed: true,
14494
- deployedAt: 1786465654796,
14495
- size: 78736,
14496
- hash: "17191ecc9c009e0fa5ab52c876330beb2a9a75d30cccb92e7c0c04f169df088b",
14499
+ deployedAt: 1787923987153,
14500
+ size: 82217,
14501
+ hash: "13defa19614215ab3b1fe88955d69e530d13a09475396af932fe0e213637da2f",
14497
14502
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14498
14503
  pkp: {
14499
14504
  publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
@@ -14501,17 +14506,17 @@ var require_pkg_src = __commonJS({
14501
14506
  }
14502
14507
  },
14503
14508
  extendPositionValidator: {
14504
- cid: "QmYwBsyrhGfHWyRKx549G4tKHxsBLAuRUHcecigeUCkFav",
14509
+ cid: "QmU8h99EEVEsQkxroXiYqLsKZw9gNjE6N5CcTpE9aUc12m",
14505
14510
  authorizedCidHex: cidToHex(
14506
- "QmYwBsyrhGfHWyRKx549G4tKHxsBLAuRUHcecigeUCkFav"
14511
+ "QmU8h99EEVEsQkxroXiYqLsKZw9gNjE6N5CcTpE9aUc12m"
14507
14512
  ),
14508
14513
  name: "Extend Position Validator",
14509
14514
  description: "Production Extend Position Validator",
14510
14515
  version: "1.2.1",
14511
14516
  deployed: true,
14512
- deployedAt: 1786465681874,
14513
- size: 76515,
14514
- hash: "1d4e085335af80f194a663a577876902c83015177e95906a0b461fa93bd5da08",
14517
+ deployedAt: 1787923999294,
14518
+ size: 79975,
14519
+ hash: "31c1aaf883ef22f37681ddb0a4a949be5c05304b6aef178989475a2da935ef9a",
14515
14520
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14516
14521
  pkp: {
14517
14522
  publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
@@ -14519,17 +14524,17 @@ var require_pkg_src = __commonJS({
14519
14524
  }
14520
14525
  },
14521
14526
  btcWithdrawal: {
14522
- cid: "QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh",
14527
+ cid: "QmZQWET9pzrVD4gwQuSzYZmqa24JrUNtnnGFDd513sxMCY",
14523
14528
  authorizedCidHex: cidToHex(
14524
- "QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh"
14529
+ "QmZQWET9pzrVD4gwQuSzYZmqa24JrUNtnnGFDd513sxMCY"
14525
14530
  ),
14526
14531
  name: "Btc Withdrawal",
14527
14532
  description: "Production Btc Withdrawal",
14528
14533
  version: "1.2.7",
14529
14534
  deployed: true,
14530
- deployedAt: 1786446046614,
14531
- size: 97456,
14532
- hash: "3cae8250861832f91ee3c573abeb50ff27b9acd34148176071cbfbabb359fc91",
14535
+ deployedAt: 1787924017769,
14536
+ size: 100069,
14537
+ hash: "4f8e27414e4da235e63d6ae1325c63f3d2fb956464515a21aa007a99935f0f13",
14533
14538
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14534
14539
  pkp: {
14535
14540
  publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
@@ -14641,30 +14646,30 @@ var require_pkg_src = __commonJS({
14641
14646
  hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
14642
14647
  },
14643
14648
  agentModuleExecutor: {
14644
- cid: "QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ",
14649
+ cid: "QmcD65vuremot5fsHVgp9JBAmei6gAaEtm5mdtLP7Yt9Kf",
14645
14650
  authorizedCidHex: cidToHex(
14646
- "QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ"
14651
+ "QmcD65vuremot5fsHVgp9JBAmei6gAaEtm5mdtLP7Yt9Kf"
14647
14652
  ),
14648
14653
  name: "Agent Module Executor",
14649
14654
  description: "Production Agent Module Executor",
14650
14655
  version: "1.1.1",
14651
14656
  deployed: true,
14652
- deployedAt: 1786446108348,
14653
- size: 11655,
14654
- hash: "d4e2149f843d6c2699fc61114d54b268ba4ed2c46ebdaee1145e0f101ec2a1ec"
14657
+ deployedAt: 1787924032013,
14658
+ size: 13878,
14659
+ hash: "a7f0204700912e26e5a354bee13a1242a2baa218643b3bb22d28481f67f9baf4"
14655
14660
  },
14656
14661
  staleSpendRecoveryValidator: {
14657
- cid: "QmXQWT8V4wjuvH8BbC7xrkYxsVu5AKfvfWcS7jnYfrexYm",
14662
+ cid: "QmNuwo4PT4AikAmhMdZgPWCb2mJDwWa9TnUqrqvofjbrT8",
14658
14663
  authorizedCidHex: cidToHex(
14659
- "QmXQWT8V4wjuvH8BbC7xrkYxsVu5AKfvfWcS7jnYfrexYm"
14664
+ "QmNuwo4PT4AikAmhMdZgPWCb2mJDwWa9TnUqrqvofjbrT8"
14660
14665
  ),
14661
14666
  name: "Stale Spend Recovery Validator",
14662
14667
  description: "Production Stale Spend Recovery Validator",
14663
14668
  version: "1.1.2",
14664
14669
  deployed: true,
14665
- deployedAt: 1785173285829,
14666
- size: 37108,
14667
- hash: "04de5fc5b6f5131dc1544e3d3d187a1f9ef9616ffd12483d119f9102b3671791",
14670
+ deployedAt: 1787924048772,
14671
+ size: 41424,
14672
+ hash: "3c5f028d2bef4344768462993616d45e30d9d44ef126e04d6eb579821d57d99c",
14668
14673
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14669
14674
  pkp: {
14670
14675
  publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
@@ -14672,17 +14677,17 @@ var require_pkg_src = __commonJS({
14672
14677
  }
14673
14678
  },
14674
14679
  btcUtxoInvalidator: {
14675
- cid: "Qmf4Ze8yhnQhHbnX5RPgJrC7Jw1aA3gbpfpd52kFg7fd1m",
14680
+ cid: "QmaNGeWut7EiGwW4zUc2sFSt7RY5NWFgxYboyG333TwrJf",
14676
14681
  authorizedCidHex: cidToHex(
14677
- "Qmf4Ze8yhnQhHbnX5RPgJrC7Jw1aA3gbpfpd52kFg7fd1m"
14682
+ "QmaNGeWut7EiGwW4zUc2sFSt7RY5NWFgxYboyG333TwrJf"
14678
14683
  ),
14679
14684
  name: "Btc Utxo Invalidator",
14680
14685
  description: "Production Btc Utxo Invalidator",
14681
14686
  version: "1.0.0",
14682
14687
  deployed: true,
14683
- deployedAt: 1786465704240,
14684
- size: 62553,
14685
- hash: "1dcea2b49e545c423195be22e072dc5e3039ed1c95a8490b23505956029f5b33"
14688
+ deployedAt: 1787924133241,
14689
+ size: 66026,
14690
+ hash: "603bc50920d7f1dee77086f2c518d9e2922ab3858a419d3fbea8221ea3a6d9e9"
14686
14691
  }
14687
14692
  };
14688
14693
  function getDeploymentsForNetwork(network) {
@@ -15441,6 +15446,101 @@ ${errorReport}`);
15441
15446
  var SECONDS_PER_DAY = 86400;
15442
15447
  var DAYS_PER_MONTH = 30;
15443
15448
  var LIT_ACTION_ETH_RPC_TIMEOUT_MS = 8e3;
15449
+ var PINNED_CONTRACT_ADDRESSES = {
15450
+ 1: {
15451
+ PositionManager: "0x12A1836e56139ccaD8722B89519d84233efc224B",
15452
+ LoanOperationsManagerModule: "0x2561974A40F1AEed1251d0A090A83cF8536FB9E9",
15453
+ BTCSpendAuthorizer: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
15454
+ BitcoinProviderRegistry: "0x4ab3Fb96e02893Ed6FAa61bad1918390c8DbbFFC",
15455
+ LITActionValidator: "0xD2c5d59c2CC5c409AC65ce0A817236aeC6869512",
15456
+ PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C"
15457
+ },
15458
+ 11155111: {
15459
+ PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
15460
+ LoanOperationsManagerModule: "0x3e05e760a87715207b7F4e8fD35EF7559BcA72C0",
15461
+ BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
15462
+ BitcoinProviderRegistry: "0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",
15463
+ LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
15464
+ PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9"
15465
+ }
15466
+ };
15467
+ function getPinnedContractAddresses(chainId) {
15468
+ return PINNED_CONTRACT_ADDRESSES[chainId] ?? null;
15469
+ }
15470
+ var PROTOCOL_EIP712_DOMAIN_NAME = "DiamondHands.Protocol";
15471
+ var PROTOCOL_EIP712_DOMAIN_VERSION = "1";
15472
+ var BORROWER_AUTHORIZATION_PRIMARY_TYPES = {
15473
+ MINT: "MintRequest",
15474
+ REPAY: "RepayRequest",
15475
+ RENEW: "RenewRequest",
15476
+ WITHDRAW: "WithdrawRequest"
15477
+ };
15478
+ var BORROWER_AUTHORIZATION_FIELDS = {
15479
+ MintRequest: [
15480
+ { name: "positionId", type: "bytes32" },
15481
+ { name: "mintAmount", type: "uint256" },
15482
+ { name: "quantumTimestamp", type: "uint256" }
15483
+ ],
15484
+ RepayRequest: [
15485
+ { name: "positionId", type: "bytes32" },
15486
+ { name: "paymentAmount", type: "uint256" },
15487
+ { name: "quantumTimestamp", type: "uint256" }
15488
+ ],
15489
+ RenewRequest: [
15490
+ { name: "positionId", type: "bytes32" },
15491
+ { name: "selectedTerm", type: "uint256" },
15492
+ { name: "quantumTimestamp", type: "uint256" }
15493
+ ],
15494
+ WithdrawRequest: [
15495
+ { name: "positionId", type: "bytes32" },
15496
+ { name: "totalDeduction", type: "uint256" },
15497
+ { name: "withdrawalAddress", type: "string" },
15498
+ { name: "quantumTimestamp", type: "uint256" }
15499
+ ]
15500
+ };
15501
+ var BORROWER_AUTHORIZATION_ENCODE_TYPES = {
15502
+ MintRequest: "MintRequest(bytes32 positionId,uint256 mintAmount,uint256 quantumTimestamp)",
15503
+ RepayRequest: "RepayRequest(bytes32 positionId,uint256 paymentAmount,uint256 quantumTimestamp)",
15504
+ RenewRequest: "RenewRequest(bytes32 positionId,uint256 selectedTerm,uint256 quantumTimestamp)",
15505
+ WithdrawRequest: "WithdrawRequest(bytes32 positionId,uint256 totalDeduction,string withdrawalAddress,uint256 quantumTimestamp)"
15506
+ };
15507
+ function borrowerAuthorizationTypes(primaryType) {
15508
+ const fields = BORROWER_AUTHORIZATION_FIELDS[primaryType];
15509
+ if (!fields) {
15510
+ throw new Error(
15511
+ `Unknown borrower authorization primary type "${primaryType}"; expected one of ${Object.keys(BORROWER_AUTHORIZATION_FIELDS).join(", ")}`
15512
+ );
15513
+ }
15514
+ return { [primaryType]: fields.map((field) => ({ ...field })) };
15515
+ }
15516
+ function buildBorrowerAuthorizationDomain(chainId, verifyingContractOverride) {
15517
+ if (!Number.isInteger(chainId) || chainId <= 0) {
15518
+ throw new Error(
15519
+ `Borrower authorization domain requires a positive integer chainId, got ${String(chainId)}`
15520
+ );
15521
+ }
15522
+ const pinned = getPinnedContractAddresses(chainId);
15523
+ const pinnedLom = pinned?.LoanOperationsManagerModule;
15524
+ if (pinnedLom && verifyingContractOverride) {
15525
+ if (pinnedLom.toLowerCase() !== verifyingContractOverride.toLowerCase()) {
15526
+ throw new Error(
15527
+ `Refusing a caller-supplied verifyingContract that contradicts the pin for chainId ${chainId}: caller ${verifyingContractOverride}, pinned ${pinnedLom}`
15528
+ );
15529
+ }
15530
+ }
15531
+ const verifyingContract = pinnedLom ?? verifyingContractOverride;
15532
+ if (!verifyingContract) {
15533
+ throw new Error(
15534
+ `No pinned LoanOperationsManagerModule for chainId ${chainId} and no verifyingContract supplied; refusing to build a borrower authorization domain without one`
15535
+ );
15536
+ }
15537
+ return {
15538
+ name: PROTOCOL_EIP712_DOMAIN_NAME,
15539
+ version: PROTOCOL_EIP712_DOMAIN_VERSION,
15540
+ chainId,
15541
+ verifyingContract
15542
+ };
15543
+ }
15444
15544
  var EVMChain = /* @__PURE__ */ ((EVMChain3) => {
15445
15545
  EVMChain3["SEPOLIA"] = "sepolia";
15446
15546
  EVMChain3["ETHEREUM"] = "ethereum";
@@ -18687,22 +18787,82 @@ var require_axios = __commonJS({
18687
18787
  var hasOwnProperty2 = (({
18688
18788
  hasOwnProperty: hasOwnProperty3
18689
18789
  }) => (obj, prop) => hasOwnProperty3.call(obj, prop))(Object.prototype);
18790
+ var isUnsafeObjectKey2 = (prop) => typeof prop === "string" && (prop === "__proto__" || prop === "constructor" || prop === "prototype");
18791
+ var isPrototypeBoundary2 = (obj, prototype3, source) => obj === Object.prototype || !source && prototype3 === null;
18792
+ var isSafeAndFullyMutable2 = (obj) => {
18793
+ if (!Object.isExtensible(obj)) {
18794
+ return false;
18795
+ }
18796
+ const props = Object.getOwnPropertyNames(obj);
18797
+ if (Object.getOwnPropertySymbols) {
18798
+ props.push(...Object.getOwnPropertySymbols(obj));
18799
+ }
18800
+ return props.every((prop) => {
18801
+ if (isUnsafeObjectKey2(prop)) {
18802
+ return false;
18803
+ }
18804
+ const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
18805
+ return !!descriptor && descriptor.configurable && descriptor.writable === true;
18806
+ });
18807
+ };
18690
18808
  var hasOwnInPrototypeChain2 = (thing, prop) => {
18691
18809
  let obj = thing;
18692
18810
  const seen = [];
18693
- while (obj != null && obj !== Object.prototype) {
18811
+ while (obj != null) {
18694
18812
  if (seen.indexOf(obj) !== -1) {
18695
18813
  return false;
18696
18814
  }
18697
18815
  seen.push(obj);
18816
+ const prototype3 = getPrototypeOf2(obj);
18817
+ if (isPrototypeBoundary2(obj, prototype3, obj === thing)) {
18818
+ return false;
18819
+ }
18698
18820
  if (hasOwnProperty2(obj, prop)) {
18699
18821
  return true;
18700
18822
  }
18701
- obj = getPrototypeOf2(obj);
18823
+ obj = prototype3;
18702
18824
  }
18703
18825
  return false;
18704
18826
  };
18705
18827
  var getSafeProp2 = (obj, prop) => obj != null && hasOwnInPrototypeChain2(obj, prop) ? obj[prop] : void 0;
18828
+ var toSafeFlatObject2 = (thing) => {
18829
+ if (thing == null || typeof thing !== "object" && typeof thing !== "function") {
18830
+ return thing;
18831
+ }
18832
+ const sourcePrototype = getPrototypeOf2(thing);
18833
+ if (sourcePrototype === null && isSafeAndFullyMutable2(thing)) {
18834
+ return thing;
18835
+ }
18836
+ const result = /* @__PURE__ */ Object.create(null);
18837
+ const merged = /* @__PURE__ */ Object.create(null);
18838
+ const seen = [];
18839
+ let current = thing;
18840
+ while (current != null) {
18841
+ if (seen.indexOf(current) !== -1) {
18842
+ break;
18843
+ }
18844
+ seen.push(current);
18845
+ const prototype3 = current === thing ? sourcePrototype : getPrototypeOf2(current);
18846
+ if (isPrototypeBoundary2(current, prototype3, current === thing)) {
18847
+ break;
18848
+ }
18849
+ const props = Object.getOwnPropertyNames(current);
18850
+ if (Object.getOwnPropertySymbols) {
18851
+ props.push(...Object.getOwnPropertySymbols(current));
18852
+ }
18853
+ for (const prop of props) {
18854
+ if (isUnsafeObjectKey2(prop)) {
18855
+ continue;
18856
+ }
18857
+ if (!hasOwnProperty2(merged, prop)) {
18858
+ result[prop] = thing[prop];
18859
+ merged[prop] = true;
18860
+ }
18861
+ }
18862
+ current = prototype3;
18863
+ }
18864
+ return result;
18865
+ };
18706
18866
  var kindOf2 = /* @__PURE__ */ ((cache) => (thing) => {
18707
18867
  const str = toString3.call(thing);
18708
18868
  return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
@@ -18739,9 +18899,9 @@ var require_axios = __commonJS({
18739
18899
  return false;
18740
18900
  }
18741
18901
  const prototype3 = getPrototypeOf2(val);
18742
- return (prototype3 === null || prototype3 === Object.prototype || getPrototypeOf2(prototype3) === null) && // Treat any genuine (non-Object.prototype-polluted) Symbol.toStringTag or
18743
- // Symbol.iterator as evidence the value is a tagged/iterable type rather
18744
- // than a plain object, while ignoring keys injected onto Object.prototype.
18902
+ return (prototype3 === null || prototype3 === Object.prototype || getPrototypeOf2(prototype3) === null) && // Treat safe own/inherited Symbol.toStringTag or Symbol.iterator members as
18903
+ // evidence the value is tagged/iterable, while ignoring members reachable
18904
+ // only through shared or terminal prototype boundaries.
18745
18905
  !hasOwnInPrototypeChain2(val, toStringTag2) && !hasOwnInPrototypeChain2(val, iterator2);
18746
18906
  };
18747
18907
  var isEmptyObject2 = (val) => {
@@ -19153,6 +19313,7 @@ var require_axios = __commonJS({
19153
19313
  // an alias to avoid ESLint no-prototype-builtins detection
19154
19314
  hasOwnInPrototypeChain: hasOwnInPrototypeChain2,
19155
19315
  getSafeProp: getSafeProp2,
19316
+ toSafeFlatObject: toSafeFlatObject2,
19156
19317
  reduceDescriptors: reduceDescriptors2,
19157
19318
  freezeMethods: freezeMethods2,
19158
19319
  toObjectSet: toObjectSet2,
@@ -19233,7 +19394,7 @@ var require_axios = __commonJS({
19233
19394
  });
19234
19395
  return byteStringHeaders;
19235
19396
  }
19236
- var $internals2 = Symbol("internals");
19397
+ var $internals$1 = Symbol("internals");
19237
19398
  function normalizeHeader2(header) {
19238
19399
  return header && String(header).trim().toLowerCase();
19239
19400
  }
@@ -19529,7 +19690,7 @@ var require_axios = __commonJS({
19529
19690
  return computed;
19530
19691
  }
19531
19692
  static accessor(header) {
19532
- const internals = this[$internals2] = this[$internals2] = {
19693
+ const internals = this[$internals$1] = this[$internals$1] = {
19533
19694
  accessors: {}
19534
19695
  };
19535
19696
  const accessors = internals.accessors;
@@ -19750,19 +19911,16 @@ var require_axios = __commonJS({
19750
19911
  throw new TypeError("target must be an object");
19751
19912
  }
19752
19913
  formData = formData || new (FormData$1 || FormData)();
19753
- options = utils$1.toFlatObject(options, {
19754
- metaTokens: true,
19755
- dots: false,
19756
- indexes: false
19757
- }, false, function defined(option, source) {
19758
- return !utils$1.isUndefined(source[option]);
19759
- });
19760
- const metaTokens = options.metaTokens;
19761
- const visitor = options.visitor || defaultVisitor;
19762
- const dots = options.dots;
19763
- const indexes = options.indexes;
19764
- const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
19765
- const maxDepth = options.maxDepth === void 0 ? DEFAULT_FORM_DATA_MAX_DEPTH2 : options.maxDepth;
19914
+ const option = (name, fallback) => {
19915
+ const value = utils$1.getSafeProp(options, name);
19916
+ return utils$1.isUndefined(value) ? fallback : value;
19917
+ };
19918
+ const metaTokens = option("metaTokens", true);
19919
+ const visitor = option("visitor") || defaultVisitor;
19920
+ const dots = option("dots", false);
19921
+ const indexes = option("indexes", false);
19922
+ const _Blob = option("Blob") || typeof Blob !== "undefined" && Blob;
19923
+ const maxDepth = option("maxDepth", DEFAULT_FORM_DATA_MAX_DEPTH2);
19766
19924
  const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
19767
19925
  const stack = [];
19768
19926
  if (!utils$1.isFunction(visitor)) {
@@ -19921,9 +20079,47 @@ var require_axios = __commonJS({
19921
20079
  }
19922
20080
  return url3;
19923
20081
  }
20082
+ var $internals3 = Symbol("internals");
20083
+ function countHandlers2(handlers) {
20084
+ return handlers ? handlers.length : 0;
20085
+ }
20086
+ function trimHandlers2(handlers) {
20087
+ if (!handlers) {
20088
+ return;
20089
+ }
20090
+ while (handlers.length && handlers[handlers.length - 1] === null) {
20091
+ handlers.pop();
20092
+ }
20093
+ }
20094
+ function syncHandlerEntries2(manager, internals) {
20095
+ const handlers = manager.handlers;
20096
+ const length = countHandlers2(handlers);
20097
+ if (handlers !== internals.handlersRef) {
20098
+ internals.handlersRef = handlers;
20099
+ internals.handlerEntries.clear();
20100
+ } else if (length !== internals.handlersLength) {
20101
+ if (!length) {
20102
+ internals.handlerEntries.clear();
20103
+ } else {
20104
+ internals.handlerEntries.forEach(function removeStaleEntry(entry, id) {
20105
+ if (handlers[entry.index] !== entry.handler) {
20106
+ internals.handlerEntries.delete(id);
20107
+ }
20108
+ });
20109
+ }
20110
+ }
20111
+ internals.handlersLength = length;
20112
+ }
19924
20113
  var InterceptorManager2 = class {
19925
20114
  constructor() {
19926
20115
  this.handlers = [];
20116
+ this[$internals3] = {
20117
+ handlersRef: this.handlers,
20118
+ handlersLength: this.handlers.length,
20119
+ handlerEntries: /* @__PURE__ */ new Map(),
20120
+ iterationDepth: 0,
20121
+ nextId: 0
20122
+ };
19927
20123
  }
19928
20124
  /**
19929
20125
  * Add a new interceptor to the stack
@@ -19935,13 +20131,25 @@ var require_axios = __commonJS({
19935
20131
  * @return {Number} An ID used to remove interceptor later
19936
20132
  */
19937
20133
  use(fulfilled, rejected, options) {
19938
- this.handlers.push({
20134
+ const handler = {
19939
20135
  fulfilled,
19940
20136
  rejected,
19941
20137
  synchronous: options ? options.synchronous : false,
19942
20138
  runWhen: options ? options.runWhen : null
20139
+ };
20140
+ const internals = this[$internals3];
20141
+ if (this.handlers == null) {
20142
+ this.handlers = [];
20143
+ }
20144
+ syncHandlerEntries2(this, internals);
20145
+ const id = internals.nextId++;
20146
+ this.handlers.push(handler);
20147
+ internals.handlerEntries.set(id, {
20148
+ handler,
20149
+ index: this.handlers.length - 1
19943
20150
  });
19944
- return this.handlers.length - 1;
20151
+ internals.handlersLength = this.handlers.length;
20152
+ return id;
19945
20153
  }
19946
20154
  /**
19947
20155
  * Remove an interceptor from the stack
@@ -19951,8 +20159,19 @@ var require_axios = __commonJS({
19951
20159
  * @returns {void}
19952
20160
  */
19953
20161
  eject(id) {
19954
- if (this.handlers[id]) {
19955
- this.handlers[id] = null;
20162
+ const internals = this[$internals3];
20163
+ syncHandlerEntries2(this, internals);
20164
+ const entry = internals.handlerEntries.get(id);
20165
+ if (entry) {
20166
+ internals.handlerEntries.delete(id);
20167
+ if (this.handlers[entry.index] !== entry.handler) {
20168
+ return;
20169
+ }
20170
+ this.handlers[entry.index] = null;
20171
+ if (!internals.iterationDepth) {
20172
+ trimHandlers2(this.handlers);
20173
+ internals.handlersLength = this.handlers.length;
20174
+ }
19956
20175
  }
19957
20176
  }
19958
20177
  /**
@@ -19963,6 +20182,7 @@ var require_axios = __commonJS({
19963
20182
  clear() {
19964
20183
  if (this.handlers) {
19965
20184
  this.handlers = [];
20185
+ syncHandlerEntries2(this, this[$internals3]);
19966
20186
  }
19967
20187
  }
19968
20188
  /**
@@ -19976,11 +20196,22 @@ var require_axios = __commonJS({
19976
20196
  * @returns {void}
19977
20197
  */
19978
20198
  forEach(fn) {
19979
- utils$1.forEach(this.handlers, function forEachHandler(h) {
19980
- if (h !== null) {
19981
- fn(h);
20199
+ const internals = this[$internals3];
20200
+ syncHandlerEntries2(this, internals);
20201
+ internals.iterationDepth++;
20202
+ try {
20203
+ utils$1.forEach(this.handlers, function forEachHandler(h) {
20204
+ if (h !== null) {
20205
+ fn(h);
20206
+ }
20207
+ });
20208
+ } finally {
20209
+ if (!--internals.iterationDepth) {
20210
+ syncHandlerEntries2(this, internals);
20211
+ trimHandlers2(this.handlers);
20212
+ internals.handlersLength = countHandlers2(this.handlers);
19982
20213
  }
19983
- });
20214
+ }
19984
20215
  }
19985
20216
  };
19986
20217
  var transitionalDefaults = {
@@ -20116,6 +20347,7 @@ var require_axios = __commonJS({
20116
20347
  }
20117
20348
  return null;
20118
20349
  }
20350
+ var methodList2 = Object.freeze(["get", "delete", "head", "options", "post", "put", "patch", "purge", "link", "unlink", "query"]);
20119
20351
  var own2 = (obj, key) => obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : void 0;
20120
20352
  function stringifySafely3(rawValue, parser, encoder) {
20121
20353
  if (utils$1.isString(rawValue)) {
@@ -20221,7 +20453,7 @@ var require_axios = __commonJS({
20221
20453
  }
20222
20454
  }
20223
20455
  };
20224
- utils$1.forEach(["delete", "get", "head", "post", "put", "patch", "query"], (method) => {
20456
+ utils$1.forEach(methodList2, (method) => {
20225
20457
  defaults2.headers[method] = {};
20226
20458
  });
20227
20459
  function transformData2(fns, response) {
@@ -20278,18 +20510,18 @@ var require_axios = __commonJS({
20278
20510
  }
20279
20511
  return baseURL.slice(0, end) + "/" + relativeURL.replace(/^\/+/, "");
20280
20512
  }
20281
- var malformedHttpProtocol2 = /^https?:(?!\/\/)/i;
20282
- var httpProtocolControlCharacters2 = /[\t\n\r]/g;
20283
- function stripLeadingC0ControlOrSpace2(url3) {
20284
- let i = 0;
20285
- while (i < url3.length && url3.charCodeAt(i) <= 32) {
20286
- i++;
20287
- }
20288
- return url3.slice(i);
20289
- }
20513
+ var urlParserControlCharacters2 = /[\t\n\r]/g;
20290
20514
  function normalizeURLForProtocolCheck2(url3) {
20291
- return stripLeadingC0ControlOrSpace2(url3).replace(httpProtocolControlCharacters2, "");
20515
+ if (typeof url3 !== "string") {
20516
+ return url3;
20517
+ }
20518
+ let start = 0;
20519
+ while (start < url3.length && url3.charCodeAt(start) <= 32) {
20520
+ start++;
20521
+ }
20522
+ return url3.slice(start).replace(urlParserControlCharacters2, "");
20292
20523
  }
20524
+ var malformedHttpProtocol2 = /^https?:(?!\/\/)/i;
20293
20525
  function redactFragment2(fragment) {
20294
20526
  if (!fragment) {
20295
20527
  return fragment;
@@ -20390,12 +20622,12 @@ var require_axios = __commonJS({
20390
20622
  function getEnv2(key) {
20391
20623
  return process.env[key.toLowerCase()] || process.env[key.toUpperCase()] || "";
20392
20624
  }
20393
- var VERSION3 = "1.19.0";
20625
+ var VERSION3 = "1.20.0";
20394
20626
  function parseProtocol2(url3) {
20395
20627
  const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url3);
20396
20628
  return match && match[1] || "";
20397
20629
  }
20398
- var DATA_URL_PATTERN2 = /^([^,;]+\/[^,;]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
20630
+ var DATA_URL_PATTERN2 = /^([^,;/]+\/[^,;/]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
20399
20631
  function fromDataURI2(uri, asBlob, options) {
20400
20632
  const _Blob = options && options.Blob || platform.classes.Blob;
20401
20633
  const protocol = parseProtocol2(uri);
@@ -20672,7 +20904,7 @@ var require_axios = __commonJS({
20672
20904
  this.sessions = /* @__PURE__ */ Object.create(null);
20673
20905
  }
20674
20906
  getSession(authority, options) {
20675
- options = Object.assign({
20907
+ options = Object.assign(/* @__PURE__ */ Object.create(null), {
20676
20908
  sessionTimeout: 1e3
20677
20909
  }, options);
20678
20910
  let authoritySessions = this.sessions[authority];
@@ -20737,6 +20969,7 @@ var require_axios = __commonJS({
20737
20969
  };
20738
20970
  }
20739
20971
  session.once("close", removeSession);
20972
+ session.once("error", removeSession);
20740
20973
  let entry = [session, options];
20741
20974
  authoritySessions ? authoritySessions.push(entry) : authoritySessions = this.sessions[authority] = [entry];
20742
20975
  return session;
@@ -20755,6 +20988,13 @@ var require_axios = __commonJS({
20755
20988
  } : fn;
20756
20989
  };
20757
20990
  var LOOPBACK_HOSTNAMES2 = /* @__PURE__ */ new Set(["localhost", "0.0.0.0"]);
20991
+ var trimTrailingDots2 = (value) => {
20992
+ let end = value.length;
20993
+ while (end && value.charCodeAt(end - 1) === 46) {
20994
+ end--;
20995
+ }
20996
+ return end === value.length ? value : value.slice(0, end);
20997
+ };
20758
20998
  var isIPv4Loopback2 = (host) => {
20759
20999
  const parts = host.split(".");
20760
21000
  if (parts.length !== 4) return false;
@@ -20787,7 +21027,7 @@ var require_axios = __commonJS({
20787
21027
  if (h.charAt(0) === "[" && h.charAt(h.length - 1) === "]") {
20788
21028
  h = h.slice(1, -1);
20789
21029
  }
20790
- h = h.replace(/\.+$/, "");
21030
+ h = trimTrailingDots2(h);
20791
21031
  if (!/^[0-9.xXa-fA-F]+$/.test(h)) return host;
20792
21032
  const parts = h.split(".");
20793
21033
  if (parts.some((p) => p === "")) return host;
@@ -20899,6 +21139,40 @@ var require_axios = __commonJS({
20899
21139
  }
20900
21140
  return host;
20901
21141
  };
21142
+ var IPV4_OCTET_RE2 = /^(?:0|[1-9]\d{0,2})$/;
21143
+ var ipv4ToBytes2 = (host) => {
21144
+ const parts = host.split(".");
21145
+ return parts.length === 4 && parts.every((part) => IPV4_OCTET_RE2.test(part) && Number(part) <= 255) ? parts.map(Number) : null;
21146
+ };
21147
+ var IPV6_GROUP_RE2 = /^[0-9a-f]{1,4}$/i;
21148
+ var ipv6ToBytes2 = (host) => {
21149
+ const halves = host.split("::");
21150
+ if (halves.length > 2) {
21151
+ return null;
21152
+ }
21153
+ const groups = halves[0] ? halves[0].split(":") : [];
21154
+ if (halves.length === 2) {
21155
+ const rear = halves[1] ? halves[1].split(":") : [];
21156
+ const missing = 8 - groups.length - rear.length;
21157
+ if (missing < 1) {
21158
+ return null;
21159
+ }
21160
+ groups.push(...new Array(missing).fill("0"), ...rear);
21161
+ }
21162
+ if (groups.length !== 8 || groups.some((group) => !IPV6_GROUP_RE2.test(group))) {
21163
+ return null;
21164
+ }
21165
+ return groups.flatMap((group) => {
21166
+ const value = Number.parseInt(group, 16);
21167
+ return [value >> 8 & 255, value & 255];
21168
+ });
21169
+ };
21170
+ var ipToBytes2 = (host) => {
21171
+ if (typeof host !== "string" || !host) {
21172
+ return null;
21173
+ }
21174
+ return host.indexOf(":") !== -1 ? ipv6ToBytes2(host) : ipv4ToBytes2(host);
21175
+ };
20902
21176
  var normalizeNoProxyHost2 = (hostname) => {
20903
21177
  if (!hostname) {
20904
21178
  return hostname;
@@ -20906,13 +21180,99 @@ var require_axios = __commonJS({
20906
21180
  if (hostname.charAt(0) === "[" && hostname.charAt(hostname.length - 1) === "]") {
20907
21181
  hostname = hostname.slice(1, -1);
20908
21182
  }
20909
- const trimmed = hostname.replace(/\.+$/, "");
21183
+ const trimmed = trimTrailingDots2(hostname);
20910
21184
  const ipv4 = normalizeIPAddress2(trimmed);
20911
21185
  if (ipv4 !== trimmed) {
20912
21186
  return ipv4;
20913
21187
  }
20914
21188
  return unmapIPv4MappedIPv62(trimmed);
20915
21189
  };
21190
+ var normalizeCidrBase2 = (input) => {
21191
+ let base = input;
21192
+ const startsBracket = base.charAt(0) === "[";
21193
+ const endsBracket = base.charAt(base.length - 1) === "]";
21194
+ const hasBracket = base.includes("[") || base.includes("]");
21195
+ if (startsBracket || endsBracket) {
21196
+ if (!startsBracket || !endsBracket) {
21197
+ return null;
21198
+ }
21199
+ base = base.slice(1, -1);
21200
+ if (base.indexOf(":") === -1 || base.includes("[") || base.includes("]")) {
21201
+ return null;
21202
+ }
21203
+ } else if (hasBracket) {
21204
+ return null;
21205
+ }
21206
+ if (!base || base.charAt(base.length - 1) === ".") {
21207
+ return null;
21208
+ }
21209
+ const wasIPv6 = base.indexOf(":") !== -1;
21210
+ if (wasIPv6) {
21211
+ try {
21212
+ base = new URL(`http://[${base}]/`).hostname.slice(1, -1);
21213
+ } catch (_err) {
21214
+ return null;
21215
+ }
21216
+ } else {
21217
+ base = normalizeIPAddress2(base);
21218
+ if (!ipv4ToBytes2(base)) {
21219
+ return null;
21220
+ }
21221
+ }
21222
+ return {
21223
+ normalized: unmapIPv4MappedIPv62(base),
21224
+ wasIPv6
21225
+ };
21226
+ };
21227
+ var CIDR_ENTRY_RE2 = /^(.+)\/(0|[1-9]\d{0,2})$/;
21228
+ var parseCidrEntry2 = (entry) => {
21229
+ if (entry.indexOf("/") === -1) {
21230
+ return void 0;
21231
+ }
21232
+ const match = CIDR_ENTRY_RE2.exec(entry);
21233
+ if (!match) {
21234
+ return null;
21235
+ }
21236
+ let prefix = Number(match[2]);
21237
+ const parsedBase = normalizeCidrBase2(match[1]);
21238
+ if (!parsedBase) {
21239
+ return null;
21240
+ }
21241
+ const {
21242
+ normalized,
21243
+ wasIPv6
21244
+ } = parsedBase;
21245
+ if (wasIPv6 && normalized.indexOf(":") === -1) {
21246
+ if (prefix < 96) {
21247
+ return null;
21248
+ }
21249
+ prefix -= 96;
21250
+ }
21251
+ const bytes = ipToBytes2(normalized);
21252
+ if (!bytes || prefix > bytes.length * 8) {
21253
+ return null;
21254
+ }
21255
+ return {
21256
+ bytes,
21257
+ prefix
21258
+ };
21259
+ };
21260
+ var isInSubnet2 = (addressBytes, networkBytes, prefix) => {
21261
+ const fullBytes = prefix >> 3;
21262
+ for (let i = 0; i < fullBytes; i++) {
21263
+ if (addressBytes[i] !== networkBytes[i]) {
21264
+ return false;
21265
+ }
21266
+ }
21267
+ const remainingBits = prefix & 7;
21268
+ if (remainingBits) {
21269
+ const mask = 255 << 8 - remainingBits & 255;
21270
+ if ((addressBytes[fullBytes] & mask) !== (networkBytes[fullBytes] & mask)) {
21271
+ return false;
21272
+ }
21273
+ }
21274
+ return true;
21275
+ };
20916
21276
  function shouldBypassProxy2(location) {
20917
21277
  let parsed;
20918
21278
  try {
@@ -20929,6 +21289,7 @@ var require_axios = __commonJS({
20929
21289
  }
20930
21290
  const port = Number.parseInt(parsed.port, 10) || DEFAULT_PORTS3[parsed.protocol.split(":", 1)[0]] || 0;
20931
21291
  const hostname = normalizeNoProxyHost2(parsed.hostname.toLowerCase());
21292
+ const hostnameBytes = ipToBytes2(hostname);
20932
21293
  return noProxy.split(/[\s,]+/).some((entry) => {
20933
21294
  if (!entry) {
20934
21295
  return false;
@@ -20936,6 +21297,10 @@ var require_axios = __commonJS({
20936
21297
  if (entry === "*") {
20937
21298
  return true;
20938
21299
  }
21300
+ const cidr = parseCidrEntry2(entry);
21301
+ if (cidr !== void 0) {
21302
+ return cidr !== null && !!hostnameBytes && hostnameBytes.length === cidr.bytes.length && isInSubnet2(hostnameBytes, cidr.bytes, cidr.prefix);
21303
+ }
20939
21304
  let [entryHost, entryPort] = parseNoProxyEntry2(entry);
20940
21305
  entryHost = normalizeNoProxyHost2(entryHost);
20941
21306
  if (!entryHost) {
@@ -21016,13 +21381,14 @@ var require_axios = __commonJS({
21016
21381
  }
21017
21382
  };
21018
21383
  const flush = () => lastArgs && invoke(lastArgs);
21019
- return [throttled, flush];
21384
+ const flushWith = (...args) => invoke(args);
21385
+ return [throttled, flush, flushWith];
21020
21386
  }
21021
21387
  var progressEventReducer2 = (listener, isDownloadStream, freq = 3) => {
21022
21388
  let bytesNotified = 0;
21023
21389
  const _speedometer = speedometer2(50, 250);
21024
21390
  return throttle2((e) => {
21025
- if (!e || typeof e.loaded !== "number") {
21391
+ if (!e || !utils$1.isNumber(e.loaded)) {
21026
21392
  return;
21027
21393
  }
21028
21394
  const rawLoaded = e.loaded;
@@ -21176,6 +21542,12 @@ var require_axios = __commonJS({
21176
21542
  var isHttps2 = /https:?/;
21177
21543
  var kAxiosSocketListener2 = Symbol("axios.http.socketListener");
21178
21544
  var kAxiosCurrentReq2 = Symbol("axios.http.currentReq");
21545
+ function handleSocketError2(err) {
21546
+ const current = this[kAxiosCurrentReq2];
21547
+ if (current && !current.destroyed) {
21548
+ current.destroy(err);
21549
+ }
21550
+ }
21179
21551
  var kAxiosInstalledTunnel2 = Symbol("axios.http.installedTunnel");
21180
21552
  var tunnelingAgentCache2 = /* @__PURE__ */ new Map();
21181
21553
  var tunnelingAgentCacheUser2 = /* @__PURE__ */ new WeakMap();
@@ -21284,10 +21656,10 @@ var require_axios = __commonJS({
21284
21656
  return false;
21285
21657
  }
21286
21658
  }
21287
- function setProxy2(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent) {
21659
+ function setProxy2(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent, allowEnvProxy = true) {
21288
21660
  let proxy = configProxy;
21289
21661
  const proxyEnvAgent = getProxyEnvAgent2(options, configHttpAgent, configHttpsAgent);
21290
- if (!proxy && proxy !== false && !isNodeEnvProxyEnabled2(proxyEnvAgent)) {
21662
+ if (!proxy && proxy !== false && allowEnvProxy && !isNodeEnvProxyEnabled2(proxyEnvAgent)) {
21291
21663
  const proxyUrl = getProxyForUrl2(location);
21292
21664
  if (proxyUrl) {
21293
21665
  if (!shouldBypassProxy2(location)) {
@@ -21378,8 +21750,9 @@ var require_axios = __commonJS({
21378
21750
  }
21379
21751
  }
21380
21752
  options.beforeRedirects.proxy = function beforeRedirect(redirectOptions) {
21381
- setProxy2(redirectOptions, configProxy, redirectOptions.href, true, configHttpsAgent, configHttpAgent);
21753
+ setProxy2(redirectOptions, configProxy, redirectOptions.href, true, configHttpsAgent, configHttpAgent, allowEnvProxy);
21382
21754
  };
21755
+ return Boolean(proxy || configProxy !== false && allowEnvProxy && isNodeEnvProxyEnabled2(proxyEnvAgent));
21383
21756
  }
21384
21757
  var isHttpAdapterSupported2 = typeof process !== "undefined" && utils$1.kindOf(process) === "process";
21385
21758
  var wrapAsync2 = (asyncExecutor) => {
@@ -21407,7 +21780,7 @@ var require_axios = __commonJS({
21407
21780
  family
21408
21781
  }) => {
21409
21782
  if (!utils$1.isString(address)) {
21410
- throw TypeError("address must be a string");
21783
+ throw new AxiosError3("address must be a string", AxiosError3.ERR_BAD_OPTION_VALUE);
21411
21784
  }
21412
21785
  return {
21413
21786
  address,
@@ -21418,6 +21791,30 @@ var require_axios = __commonJS({
21418
21791
  address,
21419
21792
  family
21420
21793
  });
21794
+ var normalizedLookupCache2 = /* @__PURE__ */ new WeakMap();
21795
+ var normalizeLookup2 = (lookup) => {
21796
+ let normalized = normalizedLookupCache2.get(lookup);
21797
+ if (normalized) {
21798
+ return normalized;
21799
+ }
21800
+ const callbackLookup = callbackify2(lookup, (value) => utils$1.isArray(value) ? value : [value]);
21801
+ normalized = (hostname, opt, cb) => {
21802
+ callbackLookup(hostname, opt, (err, arg0, arg1) => {
21803
+ if (err) {
21804
+ return cb(err);
21805
+ }
21806
+ let addresses;
21807
+ try {
21808
+ addresses = utils$1.isArray(arg0) ? arg0.map((addr) => buildAddressEntry2(addr)) : [buildAddressEntry2(arg0, arg1)];
21809
+ } catch (error) {
21810
+ return cb(error);
21811
+ }
21812
+ opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
21813
+ });
21814
+ };
21815
+ normalizedLookupCache2.set(lookup, normalized);
21816
+ return normalized;
21817
+ };
21421
21818
  var http2Transport2 = {
21422
21819
  request(options, cb) {
21423
21820
  const authority = options.protocol + "//" + options.hostname + ":" + (options.port || (options.protocol === "https:" ? 443 : 80));
@@ -21462,6 +21859,7 @@ var require_axios = __commonJS({
21462
21859
  let family = own3("family");
21463
21860
  let httpVersion = own3("httpVersion");
21464
21861
  if (httpVersion === void 0) httpVersion = 1;
21862
+ const rawHttpVersion = httpVersion;
21465
21863
  let http2Options = own3("http2Options");
21466
21864
  const httpAgent = own3("httpAgent");
21467
21865
  const httpsAgent = own3("httpsAgent");
@@ -21478,25 +21876,20 @@ var require_axios = __commonJS({
21478
21876
  let rejected = false;
21479
21877
  let req;
21480
21878
  let connectPhaseTimer;
21481
- httpVersion = +httpVersion;
21879
+ try {
21880
+ httpVersion = +httpVersion;
21881
+ } catch (err) {
21882
+ throw new AxiosError3("Invalid protocol version: value is not a number", AxiosError3.ERR_BAD_OPTION_VALUE, config);
21883
+ }
21482
21884
  if (Number.isNaN(httpVersion)) {
21483
- throw TypeError(`Invalid protocol version: '${config.httpVersion}' is not a number`);
21885
+ throw new AxiosError3(`Invalid protocol version: '${rawHttpVersion}' is not a number`, AxiosError3.ERR_BAD_OPTION_VALUE, config);
21484
21886
  }
21485
21887
  if (httpVersion !== 1 && httpVersion !== 2) {
21486
- throw TypeError(`Unsupported protocol version '${httpVersion}'`);
21888
+ throw new AxiosError3(`Unsupported protocol version '${httpVersion}'`, AxiosError3.ERR_BAD_OPTION_VALUE, config);
21487
21889
  }
21488
21890
  const isHttp2 = httpVersion === 2;
21489
21891
  if (lookup) {
21490
- const _lookup = callbackify2(lookup, (value) => utils$1.isArray(value) ? value : [value]);
21491
- lookup = (hostname, opt, cb) => {
21492
- _lookup(hostname, opt, (err, arg0, arg1) => {
21493
- if (err) {
21494
- return cb(err);
21495
- }
21496
- const addresses = utils$1.isArray(arg0) ? arg0.map((addr) => buildAddressEntry2(addr)) : [buildAddressEntry2(arg0, arg1)];
21497
- opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
21498
- });
21499
- };
21892
+ lookup = normalizeLookup2(lookup);
21500
21893
  }
21501
21894
  const abortEmitter = new events.EventEmitter();
21502
21895
  function abort(reason) {
@@ -21689,6 +22082,11 @@ var require_axios = __commonJS({
21689
22082
  }));
21690
22083
  }
21691
22084
  headers.set("Accept-Encoding", utils$1.hasOwnProp(transitional2, "advertiseZstdAcceptEncoding") && transitional2.advertiseZstdAcceptEncoding === true ? ACCEPT_ENCODING_WITH_ZSTD2 : ACCEPT_ENCODING2, false);
22085
+ if (isHttp2 && lookup) {
22086
+ http2Options = Object.assign(/* @__PURE__ */ Object.create(null), http2Options, {
22087
+ lookup
22088
+ });
22089
+ }
21692
22090
  const options = Object.assign(/* @__PURE__ */ Object.create(null), {
21693
22091
  path: path$1,
21694
22092
  method,
@@ -21702,9 +22100,11 @@ var require_axios = __commonJS({
21702
22100
  family,
21703
22101
  beforeRedirect: dispatchBeforeRedirect2,
21704
22102
  beforeRedirects: /* @__PURE__ */ Object.create(null),
21705
- http2Options
22103
+ http2Options,
22104
+ createConnection: void 0
21706
22105
  });
21707
22106
  !utils$1.isUndefined(lookup) && (options.lookup = lookup);
22107
+ let proxyApplied = false;
21708
22108
  if (socketPath) {
21709
22109
  if (typeof socketPath !== "string") {
21710
22110
  return reject(new AxiosError3("socketPath must be a string", AxiosError3.ERR_BAD_OPTION_VALUE, config));
@@ -21722,7 +22122,18 @@ var require_axios = __commonJS({
21722
22122
  } else {
21723
22123
  options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
21724
22124
  options.port = parsed.port;
21725
- setProxy2(options, configProxy, protocol + "//" + parsed.hostname + (parsed.port ? ":" + parsed.port : "") + options.path, false, httpsAgent, httpAgent);
22125
+ proxyApplied = setProxy2(
22126
+ options,
22127
+ configProxy,
22128
+ protocol + "//" + parsed.hostname + (parsed.port ? ":" + parsed.port : "") + options.path,
22129
+ false,
22130
+ httpsAgent,
22131
+ httpAgent,
22132
+ // The HTTP/2 transport connects independently of HTTP/1 agents, so it
22133
+ // cannot apply either axios-resolved or agent-local environment proxies.
22134
+ // Explicit proxy config is still processed and rejected below.
22135
+ !isHttp2
22136
+ );
21726
22137
  }
21727
22138
  let transport;
21728
22139
  let isNativeTransport = false;
@@ -21732,6 +22143,9 @@ var require_axios = __commonJS({
21732
22143
  options.agent = isHttpsRequest ? httpsAgent : httpAgent;
21733
22144
  }
21734
22145
  if (isHttp2) {
22146
+ if (proxyApplied) {
22147
+ return reject(new AxiosError3("HTTP/2 requests with a proxy are not supported", AxiosError3.ERR_NOT_SUPPORT, config));
22148
+ }
21735
22149
  transport = http2Transport2;
21736
22150
  } else {
21737
22151
  const configTransport = own3("transport");
@@ -21929,12 +22343,7 @@ var require_axios = __commonJS({
21929
22343
  socket.setKeepAlive(true, 1e3 * 60);
21930
22344
  }
21931
22345
  if (!socket[kAxiosSocketListener2]) {
21932
- socket.on("error", function handleSocketError(err) {
21933
- const current = socket[kAxiosCurrentReq2];
21934
- if (current && !current.destroyed) {
21935
- current.destroy(err);
21936
- }
21937
- });
22346
+ socket.on("error", handleSocketError2);
21938
22347
  socket[kAxiosSocketListener2] = true;
21939
22348
  }
21940
22349
  socket[kAxiosCurrentReq2] = req;
@@ -22150,7 +22559,7 @@ var require_axios = __commonJS({
22150
22559
  transformResponse: defaultToConfig2,
22151
22560
  paramsSerializer: defaultToConfig2,
22152
22561
  timeout: defaultToConfig2,
22153
- timeoutMessage: defaultToConfig2,
22562
+ timeoutErrorMessage: defaultToConfig2,
22154
22563
  withCredentials: defaultToConfig2,
22155
22564
  withXSRFToken: defaultToConfig2,
22156
22565
  adapter: defaultToConfig2,
@@ -22218,10 +22627,11 @@ var require_axios = __commonJS({
22218
22627
  }
22219
22628
  }
22220
22629
  if (utils$1.isFormData(data)) {
22630
+ const getHeaders = utils$1.getSafeProp(data, "getHeaders");
22221
22631
  if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv || utils$1.isReactNative(data)) {
22222
22632
  headers.setContentType(void 0);
22223
- } else if (utils$1.isFunction(data.getHeaders)) {
22224
- setFormDataHeaders2(headers, data.getHeaders(), own3("formDataHeaderPolicy"));
22633
+ } else if (utils$1.isFunction(getHeaders)) {
22634
+ setFormDataHeaders2(headers, getHeaders.call(data), own3("formDataHeaderPolicy"));
22225
22635
  }
22226
22636
  }
22227
22637
  if (platform.hasStandardBrowserEnv) {
@@ -22251,7 +22661,7 @@ var require_axios = __commonJS({
22251
22661
  } = _config;
22252
22662
  let onCanceled;
22253
22663
  let uploadThrottled, downloadThrottled;
22254
- let flushUpload, flushDownload;
22664
+ let flushUpload, flushDownload, flushDownloadWithEvent;
22255
22665
  function done() {
22256
22666
  flushUpload && flushUpload();
22257
22667
  flushDownload && flushDownload();
@@ -22261,7 +22671,27 @@ var require_axios = __commonJS({
22261
22671
  let request = new XMLHttpRequest();
22262
22672
  request.open(_config.method.toUpperCase(), _config.url, true);
22263
22673
  request.timeout = _config.timeout;
22264
- function onloadend() {
22674
+ function onloadend(event) {
22675
+ if (!request) {
22676
+ return;
22677
+ }
22678
+ if (request.status === 0 && (parseProtocol2(normalizeURLForProtocolCheck2(_config.url)) || parseProtocol2(platform.origin)) !== "file" && !(request.responseURL && request.responseURL.startsWith("file:"))) {
22679
+ reject(new AxiosError3("Request aborted", AxiosError3.ECONNABORTED, config, request));
22680
+ done();
22681
+ request = null;
22682
+ return;
22683
+ }
22684
+ try {
22685
+ if (event) {
22686
+ flushDownloadWithEvent && flushDownloadWithEvent(event);
22687
+ } else {
22688
+ flushDownload && flushDownload();
22689
+ }
22690
+ } catch (err) {
22691
+ setTimeout(() => {
22692
+ throw err;
22693
+ });
22694
+ }
22265
22695
  if (!request) {
22266
22696
  return;
22267
22697
  }
@@ -22336,7 +22766,7 @@ var require_axios = __commonJS({
22336
22766
  request.responseType = _config.responseType;
22337
22767
  }
22338
22768
  if (onDownloadProgress) {
22339
- [downloadThrottled, flushDownload] = progressEventReducer2(onDownloadProgress, true);
22769
+ [downloadThrottled, flushDownload, flushDownloadWithEvent] = progressEventReducer2(onDownloadProgress, true);
22340
22770
  request.addEventListener("progress", downloadThrottled);
22341
22771
  }
22342
22772
  if (onUploadProgress && request.upload) {
@@ -22498,6 +22928,17 @@ var require_axios = __commonJS({
22498
22928
  });
22499
22929
  };
22500
22930
  var DEFAULT_CHUNK_SIZE2 = 64 * 1024;
22931
+ var DEFAULT_REQUEST_OPTIONS2 = {
22932
+ cache: "default",
22933
+ redirect: "follow",
22934
+ referrer: "about:client",
22935
+ referrerPolicy: "",
22936
+ mode: "cors",
22937
+ integrity: "",
22938
+ keepalive: false,
22939
+ priority: "auto",
22940
+ window: null
22941
+ };
22501
22942
  var {
22502
22943
  isFunction: isFunction3
22503
22944
  } = utils$1;
@@ -22626,7 +23067,8 @@ var require_axios = __commonJS({
22626
23067
  withCredentials = "same-origin",
22627
23068
  fetchOptions,
22628
23069
  maxContentLength,
22629
- maxBodyLength
23070
+ maxBodyLength,
23071
+ maxRedirects
22630
23072
  } = resolveConfig2(config);
22631
23073
  const hasMaxContentLength = utils$1.isNumber(maxContentLength) && maxContentLength > -1;
22632
23074
  const hasMaxBodyLength = utils$1.isNumber(maxBodyLength) && maxBodyLength > -1;
@@ -22727,17 +23169,44 @@ var require_axios = __commonJS({
22727
23169
  }
22728
23170
  }
22729
23171
  headers.set("User-Agent", "axios/" + VERSION3, false);
22730
- const resolvedOptions = {
22731
- ...fetchOptions,
23172
+ const safeFetchOptions = fetchOptions == null ? fetchOptions : Object.assign(/* @__PURE__ */ Object.create(null), fetchOptions);
23173
+ if (safeFetchOptions) {
23174
+ delete safeFetchOptions.body;
23175
+ delete safeFetchOptions.headers;
23176
+ delete safeFetchOptions.method;
23177
+ delete safeFetchOptions.signal;
23178
+ delete safeFetchOptions.duplex;
23179
+ delete safeFetchOptions.credentials;
23180
+ }
23181
+ const resolvedOptions = Object.assign(/* @__PURE__ */ Object.create(null), safeFetchOptions, {
22732
23182
  signal: composedSignal,
22733
23183
  method: method.toUpperCase(),
22734
23184
  headers: toByteStringHeaderObject2(headers.normalize()),
22735
23185
  body: data,
22736
23186
  duplex: "half",
22737
23187
  credentials: isCredentialsSupported ? withCredentials : void 0
22738
- };
23188
+ });
23189
+ if (isRequestSupported) {
23190
+ utils$1.forEach(DEFAULT_REQUEST_OPTIONS2, (value, key) => {
23191
+ if (resolvedOptions[key] === void 0) {
23192
+ resolvedOptions[key] = value;
23193
+ }
23194
+ });
23195
+ if (resolvedOptions.signal === void 0) {
23196
+ resolvedOptions.signal = null;
23197
+ }
23198
+ if (resolvedOptions.body === void 0) {
23199
+ resolvedOptions.body = null;
23200
+ }
23201
+ }
23202
+ if (maxRedirects === 0) {
23203
+ resolvedOptions.redirect = "manual";
23204
+ if (safeFetchOptions) {
23205
+ safeFetchOptions.redirect = "manual";
23206
+ }
23207
+ }
22739
23208
  request = isRequestSupported && new Request(url3, resolvedOptions);
22740
- let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url3, resolvedOptions));
23209
+ let response = await (isRequestSupported ? _fetch(request, safeFetchOptions) : _fetch(url3, resolvedOptions));
22741
23210
  const responseHeaders = AxiosHeaders3.from(response.headers);
22742
23211
  if (hasMaxContentLength) {
22743
23212
  const declaredLength = utils$1.toFiniteNumber(responseHeaders.getContentLength());
@@ -22929,9 +23398,10 @@ var require_axios = __commonJS({
22929
23398
  throw new CanceledError3(null, config);
22930
23399
  }
22931
23400
  }
22932
- function dispatchRequest2(config) {
23401
+ function dispatchRequest2(_config) {
23402
+ const config = utils$1.toSafeFlatObject(_config);
22933
23403
  throwIfCancellationRequested2(config);
22934
- config.headers = AxiosHeaders3.from(config.headers);
23404
+ config.headers = AxiosHeaders3.from(utils$1.getSafeProp(config, "headers"));
22935
23405
  config.data = transformData2.call(config, config.transformRequest);
22936
23406
  if (["post", "put", "patch"].indexOf(config.method) !== -1) {
22937
23407
  config.headers.setContentType("application/x-www-form-urlencoded", false);
@@ -23039,16 +23509,15 @@ var require_axios = __commonJS({
23039
23509
  return await this._request(configOrUrl, config);
23040
23510
  } catch (err) {
23041
23511
  if (err instanceof Error) {
23042
- let dummy = {};
23043
- Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
23044
- const stack = (() => {
23045
- if (!dummy.stack) {
23046
- return "";
23047
- }
23048
- const firstNewlineIndex = dummy.stack.indexOf("\n");
23049
- return firstNewlineIndex === -1 ? "" : dummy.stack.slice(firstNewlineIndex + 1);
23050
- })();
23051
23512
  try {
23513
+ let dummy = {};
23514
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
23515
+ const dummyStack = dummy.stack;
23516
+ let stack = "";
23517
+ if (typeof dummyStack === "string") {
23518
+ const firstNewlineIndex = dummyStack.indexOf("\n");
23519
+ stack = firstNewlineIndex === -1 ? "" : dummyStack.slice(firstNewlineIndex + 1);
23520
+ }
23052
23521
  if (!err.stack) {
23053
23522
  err.stack = stack;
23054
23523
  } else if (stack) {
@@ -23110,9 +23579,9 @@ var require_axios = __commonJS({
23110
23579
  baseUrl: validators3.spelling("baseURL"),
23111
23580
  withXsrfToken: validators3.spelling("withXSRFToken")
23112
23581
  }, true);
23113
- config.method = (config.method || this.defaults.method || "get").toLowerCase();
23582
+ config.method = (utils$1.getSafeProp(config, "method") || utils$1.getSafeProp(this.defaults, "method") || "get").toLowerCase();
23114
23583
  let contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
23115
- headers && utils$1.forEach(["delete", "get", "head", "post", "put", "patch", "query", "common"], (method) => {
23584
+ headers && utils$1.forEach(methodList2.concat("common"), (method) => {
23116
23585
  delete headers[method];
23117
23586
  });
23118
23587
  config.headers = AxiosHeaders3.concat(contextHeaders, headers);
@@ -23359,14 +23828,22 @@ var require_axios = __commonJS({
23359
23828
  Gone: 410,
23360
23829
  LengthRequired: 411,
23361
23830
  PreconditionFailed: 412,
23831
+ /**
23832
+ * @deprecated Use `ContentTooLarge` instead.
23833
+ */
23362
23834
  PayloadTooLarge: 413,
23835
+ ContentTooLarge: 413,
23363
23836
  UriTooLong: 414,
23364
23837
  UnsupportedMediaType: 415,
23365
23838
  RangeNotSatisfiable: 416,
23366
23839
  ExpectationFailed: 417,
23367
23840
  ImATeapot: 418,
23368
23841
  MisdirectedRequest: 421,
23842
+ /**
23843
+ * @deprecated Use `UnprocessableContent` instead.
23844
+ */
23369
23845
  UnprocessableEntity: 422,
23846
+ UnprocessableContent: 422,
23370
23847
  Locked: 423,
23371
23848
  FailedDependency: 424,
23372
23849
  TooEarly: 425,
@@ -23395,7 +23872,9 @@ var require_axios = __commonJS({
23395
23872
  InvalidSslCertificate: 526
23396
23873
  };
23397
23874
  Object.entries(HttpStatusCode3).forEach(([key, value]) => {
23398
- HttpStatusCode3[value] = key;
23875
+ if (HttpStatusCode3[value] === void 0) {
23876
+ HttpStatusCode3[value] = key;
23877
+ }
23399
23878
  });
23400
23879
  function createInstance2(defaultConfig) {
23401
23880
  const context = new Axios3(defaultConfig);
@@ -23446,6 +23925,7 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
23446
23925
  exports2.fetchLitActionCodeFromIpfs = fetchLitActionCodeFromIpfs;
23447
23926
  var axios_1 = __importDefault(require_axios());
23448
23927
  var ipfsCodeCache = /* @__PURE__ */ new Map();
23928
+ var GATEWAY_TIMEOUT_MS = 2e4;
23449
23929
  var buildGatewayList = (cid, pinataJwt) => {
23450
23930
  const gateways = [];
23451
23931
  if (pinataJwt) {
@@ -23454,7 +23934,7 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
23454
23934
  headers: { Authorization: `Bearer ${pinataJwt}` }
23455
23935
  });
23456
23936
  }
23457
- gateways.push({ url: `https://${cid}.ipfs.dweb.link/` }, { url: `https://dweb.link/ipfs/${cid}` }, { url: `https://ipfs.io/ipfs/${cid}` }, { url: `https://gateway.pinata.cloud/ipfs/${cid}` }, { url: `https://cloudflare-ipfs.com/ipfs/${cid}` });
23937
+ gateways.push({ url: `https://${cid}.ipfs.dweb.link/` }, { url: `https://dweb.link/ipfs/${cid}` }, { url: `https://ipfs.io/ipfs/${cid}` }, { url: `https://gateway.pinata.cloud/ipfs/${cid}` });
23458
23938
  return gateways;
23459
23939
  };
23460
23940
  async function fetchLitActionCodeFromIpfs(cid, options = {}) {
@@ -23468,13 +23948,14 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
23468
23948
  const pinataJwt = options.pinataJwt ?? process.env.PINATA_JWT;
23469
23949
  const extraGateways = options.extraGateways?.map((t) => ({ url: t.replace("{cid}", cid) })) ?? [];
23470
23950
  const gateways = [...extraGateways, ...buildGatewayList(cid, pinataJwt)];
23951
+ const failures = [];
23471
23952
  for (const gateway of gateways) {
23472
23953
  try {
23473
23954
  if (options.debug) {
23474
23955
  console.log(`\u{1F4E1} [fetchLitActionCodeFromIpfs] Trying ${gateway.url}...`);
23475
23956
  }
23476
23957
  const response = await axios_1.default.get(gateway.url, {
23477
- timeout: 1e4,
23958
+ timeout: GATEWAY_TIMEOUT_MS,
23478
23959
  headers: {
23479
23960
  Accept: "text/plain, application/javascript, text/javascript",
23480
23961
  ...gateway.headers
@@ -23487,13 +23968,17 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
23487
23968
  ipfsCodeCache.set(cid, response.data);
23488
23969
  return response.data;
23489
23970
  }
23971
+ failures.push(`${gateway.url}: HTTP ${response.status} returned ${typeof response.data}, expected string`);
23490
23972
  } catch (error) {
23973
+ const message = error instanceof Error ? error.message : String(error);
23974
+ failures.push(`${gateway.url}: ${message}`);
23491
23975
  if (options.debug) {
23492
- console.log(`\u274C [fetchLitActionCodeFromIpfs] ${gateway.url}:`, error instanceof Error ? error.message : error);
23976
+ console.log(`\u274C [fetchLitActionCodeFromIpfs] ${gateway.url}:`, message);
23493
23977
  }
23494
23978
  }
23495
23979
  }
23496
- throw new Error(`Failed to fetch LIT Action from IPFS CID: ${cid}`);
23980
+ throw new Error(`Failed to fetch LIT Action from IPFS CID: ${cid} \u2014 all ${gateways.length} gateway(s) failed:
23981
+ ` + failures.map((f) => ` - ${f}`).join("\n"));
23497
23982
  }
23498
23983
  }
23499
23984
  });
@@ -45220,22 +45705,82 @@ var { toString } = Object.prototype;
45220
45705
  var { getPrototypeOf } = Object;
45221
45706
  var { iterator, toStringTag } = Symbol;
45222
45707
  var hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
45708
+ var isUnsafeObjectKey = (prop) => typeof prop === "string" && (prop === "__proto__" || prop === "constructor" || prop === "prototype");
45709
+ var isPrototypeBoundary = (obj, prototype2, source) => obj === Object.prototype || !source && prototype2 === null;
45710
+ var isSafeAndFullyMutable = (obj) => {
45711
+ if (!Object.isExtensible(obj)) {
45712
+ return false;
45713
+ }
45714
+ const props = Object.getOwnPropertyNames(obj);
45715
+ if (Object.getOwnPropertySymbols) {
45716
+ props.push(...Object.getOwnPropertySymbols(obj));
45717
+ }
45718
+ return props.every((prop) => {
45719
+ if (isUnsafeObjectKey(prop)) {
45720
+ return false;
45721
+ }
45722
+ const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
45723
+ return !!descriptor && descriptor.configurable && descriptor.writable === true;
45724
+ });
45725
+ };
45223
45726
  var hasOwnInPrototypeChain = (thing, prop) => {
45224
45727
  let obj = thing;
45225
45728
  const seen = [];
45226
- while (obj != null && obj !== Object.prototype) {
45729
+ while (obj != null) {
45227
45730
  if (seen.indexOf(obj) !== -1) {
45228
45731
  return false;
45229
45732
  }
45230
45733
  seen.push(obj);
45734
+ const prototype2 = getPrototypeOf(obj);
45735
+ if (isPrototypeBoundary(obj, prototype2, obj === thing)) {
45736
+ return false;
45737
+ }
45231
45738
  if (hasOwnProperty(obj, prop)) {
45232
45739
  return true;
45233
45740
  }
45234
- obj = getPrototypeOf(obj);
45741
+ obj = prototype2;
45235
45742
  }
45236
45743
  return false;
45237
45744
  };
45238
45745
  var getSafeProp = (obj, prop) => obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : void 0;
45746
+ var toSafeFlatObject = (thing) => {
45747
+ if (thing == null || typeof thing !== "object" && typeof thing !== "function") {
45748
+ return thing;
45749
+ }
45750
+ const sourcePrototype = getPrototypeOf(thing);
45751
+ if (sourcePrototype === null && isSafeAndFullyMutable(thing)) {
45752
+ return thing;
45753
+ }
45754
+ const result = /* @__PURE__ */ Object.create(null);
45755
+ const merged = /* @__PURE__ */ Object.create(null);
45756
+ const seen = [];
45757
+ let current = thing;
45758
+ while (current != null) {
45759
+ if (seen.indexOf(current) !== -1) {
45760
+ break;
45761
+ }
45762
+ seen.push(current);
45763
+ const prototype2 = current === thing ? sourcePrototype : getPrototypeOf(current);
45764
+ if (isPrototypeBoundary(current, prototype2, current === thing)) {
45765
+ break;
45766
+ }
45767
+ const props = Object.getOwnPropertyNames(current);
45768
+ if (Object.getOwnPropertySymbols) {
45769
+ props.push(...Object.getOwnPropertySymbols(current));
45770
+ }
45771
+ for (const prop of props) {
45772
+ if (isUnsafeObjectKey(prop)) {
45773
+ continue;
45774
+ }
45775
+ if (!hasOwnProperty(merged, prop)) {
45776
+ result[prop] = thing[prop];
45777
+ merged[prop] = true;
45778
+ }
45779
+ }
45780
+ current = prototype2;
45781
+ }
45782
+ return result;
45783
+ };
45239
45784
  var kindOf = /* @__PURE__ */ ((cache) => (thing) => {
45240
45785
  const str = toString.call(thing);
45241
45786
  return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
@@ -45270,9 +45815,9 @@ var isPlainObject = (val) => {
45270
45815
  return false;
45271
45816
  }
45272
45817
  const prototype2 = getPrototypeOf(val);
45273
- return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat any genuine (non-Object.prototype-polluted) Symbol.toStringTag or
45274
- // Symbol.iterator as evidence the value is a tagged/iterable type rather
45275
- // than a plain object, while ignoring keys injected onto Object.prototype.
45818
+ return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat safe own/inherited Symbol.toStringTag or Symbol.iterator members as
45819
+ // evidence the value is tagged/iterable, while ignoring members reachable
45820
+ // only through shared or terminal prototype boundaries.
45276
45821
  !hasOwnInPrototypeChain(val, toStringTag) && !hasOwnInPrototypeChain(val, iterator);
45277
45822
  };
45278
45823
  var isEmptyObject = (val) => {
@@ -45683,6 +46228,7 @@ var utils_default = {
45683
46228
  // an alias to avoid ESLint no-prototype-builtins detection
45684
46229
  hasOwnInPrototypeChain,
45685
46230
  getSafeProp,
46231
+ toSafeFlatObject,
45686
46232
  reduceDescriptors,
45687
46233
  freezeMethods,
45688
46234
  toObjectSet,
@@ -46321,24 +46867,16 @@ function toFormData(obj, formData, options) {
46321
46867
  throw new TypeError("target must be an object");
46322
46868
  }
46323
46869
  formData = formData || new (FormData_default || FormData)();
46324
- options = utils_default.toFlatObject(
46325
- options,
46326
- {
46327
- metaTokens: true,
46328
- dots: false,
46329
- indexes: false
46330
- },
46331
- false,
46332
- function defined(option, source) {
46333
- return !utils_default.isUndefined(source[option]);
46334
- }
46335
- );
46336
- const metaTokens = options.metaTokens;
46337
- const visitor = options.visitor || defaultVisitor;
46338
- const dots = options.dots;
46339
- const indexes = options.indexes;
46340
- const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
46341
- const maxDepth = options.maxDepth === void 0 ? DEFAULT_FORM_DATA_MAX_DEPTH : options.maxDepth;
46870
+ const option = (name, fallback) => {
46871
+ const value = utils_default.getSafeProp(options, name);
46872
+ return utils_default.isUndefined(value) ? fallback : value;
46873
+ };
46874
+ const metaTokens = option("metaTokens", true);
46875
+ const visitor = option("visitor") || defaultVisitor;
46876
+ const dots = option("dots", false);
46877
+ const indexes = option("indexes", false);
46878
+ const _Blob = option("Blob") || typeof Blob !== "undefined" && Blob;
46879
+ const maxDepth = option("maxDepth", DEFAULT_FORM_DATA_MAX_DEPTH);
46342
46880
  const useBlob = _Blob && utils_default.isSpecCompliantForm(formData);
46343
46881
  const stack = [];
46344
46882
  if (!utils_default.isFunction(visitor)) {
@@ -46362,7 +46900,10 @@ function toFormData(obj, formData, options) {
46362
46900
  if (Buffer_default && Buffer_default.isBufferAvailable()) {
46363
46901
  return Buffer_default.from(value);
46364
46902
  }
46365
- throw new AxiosError_default("Blob is not supported. Use a Buffer instead.", AxiosError_default.ERR_NOT_SUPPORT);
46903
+ throw new AxiosError_default(
46904
+ "Blob is not supported. Use a Buffer instead.",
46905
+ AxiosError_default.ERR_NOT_SUPPORT
46906
+ );
46366
46907
  }
46367
46908
  return value;
46368
46909
  }
@@ -46508,9 +47049,47 @@ function buildURL(url2, params, options) {
46508
47049
  }
46509
47050
 
46510
47051
  // node_modules/axios/lib/core/InterceptorManager.js
47052
+ var $internals2 = Symbol("internals");
47053
+ function countHandlers(handlers) {
47054
+ return handlers ? handlers.length : 0;
47055
+ }
47056
+ function trimHandlers(handlers) {
47057
+ if (!handlers) {
47058
+ return;
47059
+ }
47060
+ while (handlers.length && handlers[handlers.length - 1] === null) {
47061
+ handlers.pop();
47062
+ }
47063
+ }
47064
+ function syncHandlerEntries(manager, internals) {
47065
+ const handlers = manager.handlers;
47066
+ const length = countHandlers(handlers);
47067
+ if (handlers !== internals.handlersRef) {
47068
+ internals.handlersRef = handlers;
47069
+ internals.handlerEntries.clear();
47070
+ } else if (length !== internals.handlersLength) {
47071
+ if (!length) {
47072
+ internals.handlerEntries.clear();
47073
+ } else {
47074
+ internals.handlerEntries.forEach(function removeStaleEntry(entry, id) {
47075
+ if (handlers[entry.index] !== entry.handler) {
47076
+ internals.handlerEntries.delete(id);
47077
+ }
47078
+ });
47079
+ }
47080
+ }
47081
+ internals.handlersLength = length;
47082
+ }
46511
47083
  var InterceptorManager = class {
46512
47084
  constructor() {
46513
47085
  this.handlers = [];
47086
+ this[$internals2] = {
47087
+ handlersRef: this.handlers,
47088
+ handlersLength: this.handlers.length,
47089
+ handlerEntries: /* @__PURE__ */ new Map(),
47090
+ iterationDepth: 0,
47091
+ nextId: 0
47092
+ };
46514
47093
  }
46515
47094
  /**
46516
47095
  * Add a new interceptor to the stack
@@ -46522,13 +47101,25 @@ var InterceptorManager = class {
46522
47101
  * @return {Number} An ID used to remove interceptor later
46523
47102
  */
46524
47103
  use(fulfilled, rejected, options) {
46525
- this.handlers.push({
47104
+ const handler = {
46526
47105
  fulfilled,
46527
47106
  rejected,
46528
47107
  synchronous: options ? options.synchronous : false,
46529
47108
  runWhen: options ? options.runWhen : null
47109
+ };
47110
+ const internals = this[$internals2];
47111
+ if (this.handlers == null) {
47112
+ this.handlers = [];
47113
+ }
47114
+ syncHandlerEntries(this, internals);
47115
+ const id = internals.nextId++;
47116
+ this.handlers.push(handler);
47117
+ internals.handlerEntries.set(id, {
47118
+ handler,
47119
+ index: this.handlers.length - 1
46530
47120
  });
46531
- return this.handlers.length - 1;
47121
+ internals.handlersLength = this.handlers.length;
47122
+ return id;
46532
47123
  }
46533
47124
  /**
46534
47125
  * Remove an interceptor from the stack
@@ -46538,8 +47129,19 @@ var InterceptorManager = class {
46538
47129
  * @returns {void}
46539
47130
  */
46540
47131
  eject(id) {
46541
- if (this.handlers[id]) {
46542
- this.handlers[id] = null;
47132
+ const internals = this[$internals2];
47133
+ syncHandlerEntries(this, internals);
47134
+ const entry = internals.handlerEntries.get(id);
47135
+ if (entry) {
47136
+ internals.handlerEntries.delete(id);
47137
+ if (this.handlers[entry.index] !== entry.handler) {
47138
+ return;
47139
+ }
47140
+ this.handlers[entry.index] = null;
47141
+ if (!internals.iterationDepth) {
47142
+ trimHandlers(this.handlers);
47143
+ internals.handlersLength = this.handlers.length;
47144
+ }
46543
47145
  }
46544
47146
  }
46545
47147
  /**
@@ -46550,6 +47152,7 @@ var InterceptorManager = class {
46550
47152
  clear() {
46551
47153
  if (this.handlers) {
46552
47154
  this.handlers = [];
47155
+ syncHandlerEntries(this, this[$internals2]);
46553
47156
  }
46554
47157
  }
46555
47158
  /**
@@ -46563,11 +47166,22 @@ var InterceptorManager = class {
46563
47166
  * @returns {void}
46564
47167
  */
46565
47168
  forEach(fn) {
46566
- utils_default.forEach(this.handlers, function forEachHandler(h) {
46567
- if (h !== null) {
46568
- fn(h);
47169
+ const internals = this[$internals2];
47170
+ syncHandlerEntries(this, internals);
47171
+ internals.iterationDepth++;
47172
+ try {
47173
+ utils_default.forEach(this.handlers, function forEachHandler(h) {
47174
+ if (h !== null) {
47175
+ fn(h);
47176
+ }
47177
+ });
47178
+ } finally {
47179
+ if (!--internals.iterationDepth) {
47180
+ syncHandlerEntries(this, internals);
47181
+ trimHandlers(this.handlers);
47182
+ internals.handlersLength = countHandlers(this.handlers);
46569
47183
  }
46570
- });
47184
+ }
46571
47185
  }
46572
47186
  };
46573
47187
  var InterceptorManager_default = InterceptorManager;
@@ -46725,6 +47339,22 @@ function formDataToJSON(formData) {
46725
47339
  }
46726
47340
  var formDataToJSON_default = formDataToJSON;
46727
47341
 
47342
+ // node_modules/axios/lib/core/methodList.js
47343
+ var methodList = Object.freeze([
47344
+ "get",
47345
+ "delete",
47346
+ "head",
47347
+ "options",
47348
+ "post",
47349
+ "put",
47350
+ "patch",
47351
+ "purge",
47352
+ "link",
47353
+ "unlink",
47354
+ "query"
47355
+ ]);
47356
+ var methodList_default = methodList;
47357
+
46728
47358
  // node_modules/axios/lib/defaults/index.js
46729
47359
  var own = (obj, key) => obj != null && utils_default.hasOwnProp(obj, key) ? obj[key] : void 0;
46730
47360
  function stringifySafely2(rawValue, parser, encoder) {
@@ -46837,7 +47467,7 @@ var defaults = {
46837
47467
  }
46838
47468
  }
46839
47469
  };
46840
- utils_default.forEach(["delete", "get", "head", "post", "put", "patch", "query"], (method) => {
47470
+ utils_default.forEach(methodList_default, (method) => {
46841
47471
  defaults.headers[method] = {};
46842
47472
  });
46843
47473
  var defaults_default = defaults;
@@ -46915,19 +47545,21 @@ function combineURLs(baseURL, relativeURL) {
46915
47545
  return baseURL.slice(0, end) + "/" + relativeURL.replace(/^\/+/, "");
46916
47546
  }
46917
47547
 
46918
- // node_modules/axios/lib/core/buildFullPath.js
46919
- var malformedHttpProtocol = /^https?:(?!\/\/)/i;
46920
- var httpProtocolControlCharacters = /[\t\n\r]/g;
46921
- function stripLeadingC0ControlOrSpace(url2) {
46922
- let i = 0;
46923
- while (i < url2.length && url2.charCodeAt(i) <= 32) {
46924
- i++;
46925
- }
46926
- return url2.slice(i);
46927
- }
47548
+ // node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js
47549
+ var urlParserControlCharacters = /[\t\n\r]/g;
46928
47550
  function normalizeURLForProtocolCheck(url2) {
46929
- return stripLeadingC0ControlOrSpace(url2).replace(httpProtocolControlCharacters, "");
47551
+ if (typeof url2 !== "string") {
47552
+ return url2;
47553
+ }
47554
+ let start = 0;
47555
+ while (start < url2.length && url2.charCodeAt(start) <= 32) {
47556
+ start++;
47557
+ }
47558
+ return url2.slice(start).replace(urlParserControlCharacters, "");
46930
47559
  }
47560
+
47561
+ // node_modules/axios/lib/core/buildFullPath.js
47562
+ var malformedHttpProtocol = /^https?:(?!\/\/)/i;
46931
47563
  function redactFragment(fragment) {
46932
47564
  if (!fragment) {
46933
47565
  return fragment;
@@ -47049,7 +47681,7 @@ var import_follow_redirects = __toESM(require_follow_redirects(), 1);
47049
47681
  var import_zlib = __toESM(require("zlib"), 1);
47050
47682
 
47051
47683
  // node_modules/axios/lib/env/data.js
47052
- var VERSION = "1.19.0";
47684
+ var VERSION = "1.20.0";
47053
47685
 
47054
47686
  // node_modules/axios/lib/helpers/parseProtocol.js
47055
47687
  function parseProtocol(url2) {
@@ -47058,7 +47690,7 @@ function parseProtocol(url2) {
47058
47690
  }
47059
47691
 
47060
47692
  // node_modules/axios/lib/helpers/fromDataURI.js
47061
- var DATA_URL_PATTERN = /^([^,;]+\/[^,;]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
47693
+ var DATA_URL_PATTERN = /^([^,;/]+\/[^,;/]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
47062
47694
  function fromDataURI(uri, asBlob, options) {
47063
47695
  const _Blob = options && options.Blob || platform_default.classes.Blob;
47064
47696
  const protocol = parseProtocol(uri);
@@ -47371,6 +48003,7 @@ var Http2Sessions = class {
47371
48003
  }
47372
48004
  getSession(authority, options) {
47373
48005
  options = Object.assign(
48006
+ /* @__PURE__ */ Object.create(null),
47374
48007
  {
47375
48008
  sessionTimeout: 1e3
47376
48009
  },
@@ -47436,6 +48069,7 @@ var Http2Sessions = class {
47436
48069
  };
47437
48070
  }
47438
48071
  session.once("close", removeSession);
48072
+ session.once("error", removeSession);
47439
48073
  let entry = [session, options];
47440
48074
  authoritySessions ? authoritySessions.push(entry) : authoritySessions = this.sessions[authority] = [entry];
47441
48075
  return session;
@@ -47460,6 +48094,13 @@ var callbackify_default = callbackify;
47460
48094
 
47461
48095
  // node_modules/axios/lib/helpers/shouldBypassProxy.js
47462
48096
  var LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["localhost", "0.0.0.0"]);
48097
+ var trimTrailingDots = (value) => {
48098
+ let end = value.length;
48099
+ while (end && value.charCodeAt(end - 1) === 46) {
48100
+ end--;
48101
+ }
48102
+ return end === value.length ? value : value.slice(0, end);
48103
+ };
47463
48104
  var isIPv4Loopback = (host) => {
47464
48105
  const parts = host.split(".");
47465
48106
  if (parts.length !== 4) return false;
@@ -47492,7 +48133,7 @@ var normalizeIPAddress = (host) => {
47492
48133
  if (h.charAt(0) === "[" && h.charAt(h.length - 1) === "]") {
47493
48134
  h = h.slice(1, -1);
47494
48135
  }
47495
- h = h.replace(/\.+$/, "");
48136
+ h = trimTrailingDots(h);
47496
48137
  if (!/^[0-9.xXa-fA-F]+$/.test(h)) return host;
47497
48138
  const parts = h.split(".");
47498
48139
  if (parts.some((p) => p === "")) return host;
@@ -47604,6 +48245,40 @@ var unmapIPv4MappedIPv6 = (host) => {
47604
48245
  }
47605
48246
  return host;
47606
48247
  };
48248
+ var IPV4_OCTET_RE = /^(?:0|[1-9]\d{0,2})$/;
48249
+ var ipv4ToBytes = (host) => {
48250
+ const parts = host.split(".");
48251
+ return parts.length === 4 && parts.every((part) => IPV4_OCTET_RE.test(part) && Number(part) <= 255) ? parts.map(Number) : null;
48252
+ };
48253
+ var IPV6_GROUP_RE = /^[0-9a-f]{1,4}$/i;
48254
+ var ipv6ToBytes = (host) => {
48255
+ const halves = host.split("::");
48256
+ if (halves.length > 2) {
48257
+ return null;
48258
+ }
48259
+ const groups = halves[0] ? halves[0].split(":") : [];
48260
+ if (halves.length === 2) {
48261
+ const rear = halves[1] ? halves[1].split(":") : [];
48262
+ const missing = 8 - groups.length - rear.length;
48263
+ if (missing < 1) {
48264
+ return null;
48265
+ }
48266
+ groups.push(...new Array(missing).fill("0"), ...rear);
48267
+ }
48268
+ if (groups.length !== 8 || groups.some((group) => !IPV6_GROUP_RE.test(group))) {
48269
+ return null;
48270
+ }
48271
+ return groups.flatMap((group) => {
48272
+ const value = Number.parseInt(group, 16);
48273
+ return [value >> 8 & 255, value & 255];
48274
+ });
48275
+ };
48276
+ var ipToBytes = (host) => {
48277
+ if (typeof host !== "string" || !host) {
48278
+ return null;
48279
+ }
48280
+ return host.indexOf(":") !== -1 ? ipv6ToBytes(host) : ipv4ToBytes(host);
48281
+ };
47607
48282
  var normalizeNoProxyHost = (hostname) => {
47608
48283
  if (!hostname) {
47609
48284
  return hostname;
@@ -47611,13 +48286,90 @@ var normalizeNoProxyHost = (hostname) => {
47611
48286
  if (hostname.charAt(0) === "[" && hostname.charAt(hostname.length - 1) === "]") {
47612
48287
  hostname = hostname.slice(1, -1);
47613
48288
  }
47614
- const trimmed = hostname.replace(/\.+$/, "");
48289
+ const trimmed = trimTrailingDots(hostname);
47615
48290
  const ipv4 = normalizeIPAddress(trimmed);
47616
48291
  if (ipv4 !== trimmed) {
47617
48292
  return ipv4;
47618
48293
  }
47619
48294
  return unmapIPv4MappedIPv6(trimmed);
47620
48295
  };
48296
+ var normalizeCidrBase = (input) => {
48297
+ let base = input;
48298
+ const startsBracket = base.charAt(0) === "[";
48299
+ const endsBracket = base.charAt(base.length - 1) === "]";
48300
+ const hasBracket = base.includes("[") || base.includes("]");
48301
+ if (startsBracket || endsBracket) {
48302
+ if (!startsBracket || !endsBracket) {
48303
+ return null;
48304
+ }
48305
+ base = base.slice(1, -1);
48306
+ if (base.indexOf(":") === -1 || base.includes("[") || base.includes("]")) {
48307
+ return null;
48308
+ }
48309
+ } else if (hasBracket) {
48310
+ return null;
48311
+ }
48312
+ if (!base || base.charAt(base.length - 1) === ".") {
48313
+ return null;
48314
+ }
48315
+ const wasIPv6 = base.indexOf(":") !== -1;
48316
+ if (wasIPv6) {
48317
+ try {
48318
+ base = new URL(`http://[${base}]/`).hostname.slice(1, -1);
48319
+ } catch (_err) {
48320
+ return null;
48321
+ }
48322
+ } else {
48323
+ base = normalizeIPAddress(base);
48324
+ if (!ipv4ToBytes(base)) {
48325
+ return null;
48326
+ }
48327
+ }
48328
+ return { normalized: unmapIPv4MappedIPv6(base), wasIPv6 };
48329
+ };
48330
+ var CIDR_ENTRY_RE = /^(.+)\/(0|[1-9]\d{0,2})$/;
48331
+ var parseCidrEntry = (entry) => {
48332
+ if (entry.indexOf("/") === -1) {
48333
+ return void 0;
48334
+ }
48335
+ const match = CIDR_ENTRY_RE.exec(entry);
48336
+ if (!match) {
48337
+ return null;
48338
+ }
48339
+ let prefix = Number(match[2]);
48340
+ const parsedBase = normalizeCidrBase(match[1]);
48341
+ if (!parsedBase) {
48342
+ return null;
48343
+ }
48344
+ const { normalized, wasIPv6 } = parsedBase;
48345
+ if (wasIPv6 && normalized.indexOf(":") === -1) {
48346
+ if (prefix < 96) {
48347
+ return null;
48348
+ }
48349
+ prefix -= 96;
48350
+ }
48351
+ const bytes = ipToBytes(normalized);
48352
+ if (!bytes || prefix > bytes.length * 8) {
48353
+ return null;
48354
+ }
48355
+ return { bytes, prefix };
48356
+ };
48357
+ var isInSubnet = (addressBytes, networkBytes, prefix) => {
48358
+ const fullBytes = prefix >> 3;
48359
+ for (let i = 0; i < fullBytes; i++) {
48360
+ if (addressBytes[i] !== networkBytes[i]) {
48361
+ return false;
48362
+ }
48363
+ }
48364
+ const remainingBits = prefix & 7;
48365
+ if (remainingBits) {
48366
+ const mask = 255 << 8 - remainingBits & 255;
48367
+ if ((addressBytes[fullBytes] & mask) !== (networkBytes[fullBytes] & mask)) {
48368
+ return false;
48369
+ }
48370
+ }
48371
+ return true;
48372
+ };
47621
48373
  function shouldBypassProxy(location) {
47622
48374
  let parsed;
47623
48375
  try {
@@ -47634,6 +48386,7 @@ function shouldBypassProxy(location) {
47634
48386
  }
47635
48387
  const port = Number.parseInt(parsed.port, 10) || DEFAULT_PORTS2[parsed.protocol.split(":", 1)[0]] || 0;
47636
48388
  const hostname = normalizeNoProxyHost(parsed.hostname.toLowerCase());
48389
+ const hostnameBytes = ipToBytes(hostname);
47637
48390
  return noProxy.split(/[\s,]+/).some((entry) => {
47638
48391
  if (!entry) {
47639
48392
  return false;
@@ -47641,6 +48394,10 @@ function shouldBypassProxy(location) {
47641
48394
  if (entry === "*") {
47642
48395
  return true;
47643
48396
  }
48397
+ const cidr = parseCidrEntry(entry);
48398
+ if (cidr !== void 0) {
48399
+ return cidr !== null && !!hostnameBytes && hostnameBytes.length === cidr.bytes.length && isInSubnet(hostnameBytes, cidr.bytes, cidr.prefix);
48400
+ }
47644
48401
  let [entryHost, entryPort] = parseNoProxyEntry(entry);
47645
48402
  entryHost = normalizeNoProxyHost(entryHost);
47646
48403
  if (!entryHost) {
@@ -47726,7 +48483,8 @@ function throttle(fn, freq) {
47726
48483
  }
47727
48484
  };
47728
48485
  const flush = () => lastArgs && invoke(lastArgs);
47729
- return [throttled, flush];
48486
+ const flushWith = (...args) => invoke(args);
48487
+ return [throttled, flush, flushWith];
47730
48488
  }
47731
48489
  var throttle_default = throttle;
47732
48490
 
@@ -47735,7 +48493,7 @@ var progressEventReducer = (listener, isDownloadStream, freq = 3) => {
47735
48493
  let bytesNotified = 0;
47736
48494
  const _speedometer = speedometer_default(50, 250);
47737
48495
  return throttle_default((e) => {
47738
- if (!e || typeof e.loaded !== "number") {
48496
+ if (!e || !utils_default.isNumber(e.loaded)) {
47739
48497
  return;
47740
48498
  }
47741
48499
  const rawLoaded = e.loaded;
@@ -47896,6 +48654,12 @@ var { http: httpFollow, https: httpsFollow } = import_follow_redirects.default;
47896
48654
  var isHttps = /https:?/;
47897
48655
  var kAxiosSocketListener = Symbol("axios.http.socketListener");
47898
48656
  var kAxiosCurrentReq = Symbol("axios.http.currentReq");
48657
+ function handleSocketError(err) {
48658
+ const current = this[kAxiosCurrentReq];
48659
+ if (current && !current.destroyed) {
48660
+ current.destroy(err);
48661
+ }
48662
+ }
47899
48663
  var kAxiosInstalledTunnel = Symbol("axios.http.installedTunnel");
47900
48664
  var tunnelingAgentCache = /* @__PURE__ */ new Map();
47901
48665
  var tunnelingAgentCacheUser = /* @__PURE__ */ new WeakMap();
@@ -47998,10 +48762,10 @@ function isSameOriginRedirect(redirectOptions, requestDetails) {
47998
48762
  return false;
47999
48763
  }
48000
48764
  }
48001
- function setProxy(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent) {
48765
+ function setProxy(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent, allowEnvProxy = true) {
48002
48766
  let proxy = configProxy;
48003
48767
  const proxyEnvAgent = getProxyEnvAgent(options, configHttpAgent, configHttpsAgent);
48004
- if (!proxy && proxy !== false && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
48768
+ if (!proxy && proxy !== false && allowEnvProxy && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
48005
48769
  const proxyUrl = getProxyForUrl(location);
48006
48770
  if (proxyUrl) {
48007
48771
  if (!shouldBypassProxy(location)) {
@@ -48098,9 +48862,13 @@ function setProxy(options, configProxy, location, isRedirect, configHttpsAgent,
48098
48862
  redirectOptions.href,
48099
48863
  true,
48100
48864
  configHttpsAgent,
48101
- configHttpAgent
48865
+ configHttpAgent,
48866
+ allowEnvProxy
48102
48867
  );
48103
48868
  };
48869
+ return Boolean(
48870
+ proxy || configProxy !== false && allowEnvProxy && isNodeEnvProxyEnabled(proxyEnvAgent)
48871
+ );
48104
48872
  }
48105
48873
  var isHttpAdapterSupported = typeof process !== "undefined" && utils_default.kindOf(process) === "process";
48106
48874
  var wrapAsync = (asyncExecutor) => {
@@ -48125,7 +48893,7 @@ var wrapAsync = (asyncExecutor) => {
48125
48893
  };
48126
48894
  var resolveFamily = ({ address, family }) => {
48127
48895
  if (!utils_default.isString(address)) {
48128
- throw TypeError("address must be a string");
48896
+ throw new AxiosError_default("address must be a string", AxiosError_default.ERR_BAD_OPTION_VALUE);
48129
48897
  }
48130
48898
  return {
48131
48899
  address,
@@ -48133,6 +48901,30 @@ var resolveFamily = ({ address, family }) => {
48133
48901
  };
48134
48902
  };
48135
48903
  var buildAddressEntry = (address, family) => resolveFamily(utils_default.isObject(address) ? address : { address, family });
48904
+ var normalizedLookupCache = /* @__PURE__ */ new WeakMap();
48905
+ var normalizeLookup = (lookup) => {
48906
+ let normalized = normalizedLookupCache.get(lookup);
48907
+ if (normalized) {
48908
+ return normalized;
48909
+ }
48910
+ const callbackLookup = callbackify_default(lookup, (value) => utils_default.isArray(value) ? value : [value]);
48911
+ normalized = (hostname, opt, cb) => {
48912
+ callbackLookup(hostname, opt, (err, arg0, arg1) => {
48913
+ if (err) {
48914
+ return cb(err);
48915
+ }
48916
+ let addresses;
48917
+ try {
48918
+ addresses = utils_default.isArray(arg0) ? arg0.map((addr) => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
48919
+ } catch (error) {
48920
+ return cb(error);
48921
+ }
48922
+ opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
48923
+ });
48924
+ };
48925
+ normalizedLookupCache.set(lookup, normalized);
48926
+ return normalized;
48927
+ };
48136
48928
  var http2Transport = {
48137
48929
  request(options, cb) {
48138
48930
  const authority = options.protocol + "//" + options.hostname + ":" + (options.port || (options.protocol === "https:" ? 443 : 80));
@@ -48169,6 +48961,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48169
48961
  let family = own2("family");
48170
48962
  let httpVersion = own2("httpVersion");
48171
48963
  if (httpVersion === void 0) httpVersion = 1;
48964
+ const rawHttpVersion = httpVersion;
48172
48965
  let http2Options = own2("http2Options");
48173
48966
  const httpAgent = own2("httpAgent");
48174
48967
  const httpsAgent = own2("httpsAgent");
@@ -48185,25 +48978,32 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48185
48978
  let rejected = false;
48186
48979
  let req;
48187
48980
  let connectPhaseTimer;
48188
- httpVersion = +httpVersion;
48981
+ try {
48982
+ httpVersion = +httpVersion;
48983
+ } catch (err) {
48984
+ throw new AxiosError_default(
48985
+ "Invalid protocol version: value is not a number",
48986
+ AxiosError_default.ERR_BAD_OPTION_VALUE,
48987
+ config
48988
+ );
48989
+ }
48189
48990
  if (Number.isNaN(httpVersion)) {
48190
- throw TypeError(`Invalid protocol version: '${config.httpVersion}' is not a number`);
48991
+ throw new AxiosError_default(
48992
+ `Invalid protocol version: '${rawHttpVersion}' is not a number`,
48993
+ AxiosError_default.ERR_BAD_OPTION_VALUE,
48994
+ config
48995
+ );
48191
48996
  }
48192
48997
  if (httpVersion !== 1 && httpVersion !== 2) {
48193
- throw TypeError(`Unsupported protocol version '${httpVersion}'`);
48998
+ throw new AxiosError_default(
48999
+ `Unsupported protocol version '${httpVersion}'`,
49000
+ AxiosError_default.ERR_BAD_OPTION_VALUE,
49001
+ config
49002
+ );
48194
49003
  }
48195
49004
  const isHttp2 = httpVersion === 2;
48196
49005
  if (lookup) {
48197
- const _lookup = callbackify_default(lookup, (value) => utils_default.isArray(value) ? value : [value]);
48198
- lookup = (hostname, opt, cb) => {
48199
- _lookup(hostname, opt, (err, arg0, arg1) => {
48200
- if (err) {
48201
- return cb(err);
48202
- }
48203
- const addresses = utils_default.isArray(arg0) ? arg0.map((addr) => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
48204
- opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
48205
- });
48206
- };
49006
+ lookup = normalizeLookup(lookup);
48207
49007
  }
48208
49008
  const abortEmitter = new import_events.EventEmitter();
48209
49009
  function abort(reason) {
@@ -48446,6 +49246,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48446
49246
  utils_default.hasOwnProp(transitional2, "advertiseZstdAcceptEncoding") && transitional2.advertiseZstdAcceptEncoding === true ? ACCEPT_ENCODING_WITH_ZSTD : ACCEPT_ENCODING,
48447
49247
  false
48448
49248
  );
49249
+ if (isHttp2 && lookup) {
49250
+ http2Options = Object.assign(/* @__PURE__ */ Object.create(null), http2Options, { lookup });
49251
+ }
48449
49252
  const options = Object.assign(/* @__PURE__ */ Object.create(null), {
48450
49253
  path: path5,
48451
49254
  method,
@@ -48456,9 +49259,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48456
49259
  family,
48457
49260
  beforeRedirect: dispatchBeforeRedirect,
48458
49261
  beforeRedirects: /* @__PURE__ */ Object.create(null),
48459
- http2Options
49262
+ http2Options,
49263
+ createConnection: void 0
48460
49264
  });
48461
49265
  !utils_default.isUndefined(lookup) && (options.lookup = lookup);
49266
+ let proxyApplied = false;
48462
49267
  if (socketPath) {
48463
49268
  if (typeof socketPath !== "string") {
48464
49269
  return reject(
@@ -48486,13 +49291,17 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48486
49291
  } else {
48487
49292
  options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
48488
49293
  options.port = parsed.port;
48489
- setProxy(
49294
+ proxyApplied = setProxy(
48490
49295
  options,
48491
49296
  configProxy,
48492
49297
  protocol + "//" + parsed.hostname + (parsed.port ? ":" + parsed.port : "") + options.path,
48493
49298
  false,
48494
49299
  httpsAgent,
48495
- httpAgent
49300
+ httpAgent,
49301
+ // The HTTP/2 transport connects independently of HTTP/1 agents, so it
49302
+ // cannot apply either axios-resolved or agent-local environment proxies.
49303
+ // Explicit proxy config is still processed and rejected below.
49304
+ !isHttp2
48496
49305
  );
48497
49306
  }
48498
49307
  let transport;
@@ -48503,6 +49312,15 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48503
49312
  options.agent = isHttpsRequest ? httpsAgent : httpAgent;
48504
49313
  }
48505
49314
  if (isHttp2) {
49315
+ if (proxyApplied) {
49316
+ return reject(
49317
+ new AxiosError_default(
49318
+ "HTTP/2 requests with a proxy are not supported",
49319
+ AxiosError_default.ERR_NOT_SUPPORT,
49320
+ config
49321
+ )
49322
+ );
49323
+ }
48506
49324
  transport = http2Transport;
48507
49325
  } else {
48508
49326
  const configTransport = own2("transport");
@@ -48590,7 +49408,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48590
49408
  transformStream,
48591
49409
  progressEventDecorator(
48592
49410
  responseLength,
48593
- progressEventReducer(asyncDecorator(onDownloadProgress, scheduleProgress), true, 3)
49411
+ progressEventReducer(
49412
+ asyncDecorator(onDownloadProgress, scheduleProgress),
49413
+ true,
49414
+ 3
49415
+ )
48594
49416
  )
48595
49417
  )
48596
49418
  );
@@ -48739,12 +49561,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48739
49561
  socket.setKeepAlive(true, 1e3 * 60);
48740
49562
  }
48741
49563
  if (!socket[kAxiosSocketListener]) {
48742
- socket.on("error", function handleSocketError(err) {
48743
- const current = socket[kAxiosCurrentReq];
48744
- if (current && !current.destroyed) {
48745
- current.destroy(err);
48746
- }
48747
- });
49564
+ socket.on("error", handleSocketError);
48748
49565
  socket[kAxiosSocketListener] = true;
48749
49566
  }
48750
49567
  socket[kAxiosCurrentReq] = req;
@@ -48989,7 +49806,7 @@ function mergeConfig(config1, config2) {
48989
49806
  transformResponse: defaultToConfig2,
48990
49807
  paramsSerializer: defaultToConfig2,
48991
49808
  timeout: defaultToConfig2,
48992
- timeoutMessage: defaultToConfig2,
49809
+ timeoutErrorMessage: defaultToConfig2,
48993
49810
  withCredentials: defaultToConfig2,
48994
49811
  withXSRFToken: defaultToConfig2,
48995
49812
  adapter: defaultToConfig2,
@@ -49066,10 +49883,11 @@ function resolveConfig(config) {
49066
49883
  }
49067
49884
  }
49068
49885
  if (utils_default.isFormData(data)) {
49886
+ const getHeaders = utils_default.getSafeProp(data, "getHeaders");
49069
49887
  if (platform_default.hasStandardBrowserEnv || platform_default.hasStandardBrowserWebWorkerEnv || utils_default.isReactNative(data)) {
49070
49888
  headers.setContentType(void 0);
49071
- } else if (utils_default.isFunction(data.getHeaders)) {
49072
- setFormDataHeaders(headers, data.getHeaders(), own2("formDataHeaderPolicy"));
49889
+ } else if (utils_default.isFunction(getHeaders)) {
49890
+ setFormDataHeaders(headers, getHeaders.call(data), own2("formDataHeaderPolicy"));
49073
49891
  }
49074
49892
  }
49075
49893
  if (platform_default.hasStandardBrowserEnv) {
@@ -49098,7 +49916,7 @@ var xhr_default = isXHRAdapterSupported && function(config) {
49098
49916
  let { responseType, onUploadProgress, onDownloadProgress } = _config;
49099
49917
  let onCanceled;
49100
49918
  let uploadThrottled, downloadThrottled;
49101
- let flushUpload, flushDownload;
49919
+ let flushUpload, flushDownload, flushDownloadWithEvent;
49102
49920
  function done() {
49103
49921
  flushUpload && flushUpload();
49104
49922
  flushDownload && flushDownload();
@@ -49108,7 +49926,27 @@ var xhr_default = isXHRAdapterSupported && function(config) {
49108
49926
  let request = new XMLHttpRequest();
49109
49927
  request.open(_config.method.toUpperCase(), _config.url, true);
49110
49928
  request.timeout = _config.timeout;
49111
- function onloadend() {
49929
+ function onloadend(event) {
49930
+ if (!request) {
49931
+ return;
49932
+ }
49933
+ if (request.status === 0 && (parseProtocol(normalizeURLForProtocolCheck(_config.url)) || parseProtocol(platform_default.origin)) !== "file" && !(request.responseURL && request.responseURL.startsWith("file:"))) {
49934
+ reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED, config, request));
49935
+ done();
49936
+ request = null;
49937
+ return;
49938
+ }
49939
+ try {
49940
+ if (event) {
49941
+ flushDownloadWithEvent && flushDownloadWithEvent(event);
49942
+ } else {
49943
+ flushDownload && flushDownload();
49944
+ }
49945
+ } catch (err) {
49946
+ setTimeout(() => {
49947
+ throw err;
49948
+ });
49949
+ }
49112
49950
  if (!request) {
49113
49951
  return;
49114
49952
  }
@@ -49196,7 +50034,10 @@ var xhr_default = isXHRAdapterSupported && function(config) {
49196
50034
  request.responseType = _config.responseType;
49197
50035
  }
49198
50036
  if (onDownloadProgress) {
49199
- [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
50037
+ [downloadThrottled, flushDownload, flushDownloadWithEvent] = progressEventReducer(
50038
+ onDownloadProgress,
50039
+ true
50040
+ );
49200
50041
  request.addEventListener("progress", downloadThrottled);
49201
50042
  }
49202
50043
  if (onUploadProgress && request.upload) {
@@ -49366,6 +50207,17 @@ var trackStream = (stream4, chunkSize, onProgress, onFinish) => {
49366
50207
 
49367
50208
  // node_modules/axios/lib/adapters/fetch.js
49368
50209
  var DEFAULT_CHUNK_SIZE = 64 * 1024;
50210
+ var DEFAULT_REQUEST_OPTIONS = {
50211
+ cache: "default",
50212
+ redirect: "follow",
50213
+ referrer: "about:client",
50214
+ referrerPolicy: "",
50215
+ mode: "cors",
50216
+ integrity: "",
50217
+ keepalive: false,
50218
+ priority: "auto",
50219
+ window: null
50220
+ };
49369
50221
  var { isFunction: isFunction2 } = utils_default;
49370
50222
  var encodeUTF82 = (str) => encodeURIComponent(str).replace(
49371
50223
  /%([0-9A-F]{2})/gi,
@@ -49496,7 +50348,8 @@ var factory = (env) => {
49496
50348
  withCredentials = "same-origin",
49497
50349
  fetchOptions,
49498
50350
  maxContentLength,
49499
- maxBodyLength
50351
+ maxBodyLength,
50352
+ maxRedirects
49500
50353
  } = resolveConfig_default(config);
49501
50354
  const hasMaxContentLength = utils_default.isNumber(maxContentLength) && maxContentLength > -1;
49502
50355
  const hasMaxBodyLength = utils_default.isNumber(maxBodyLength) && maxBodyLength > -1;
@@ -49626,17 +50479,44 @@ var factory = (env) => {
49626
50479
  }
49627
50480
  }
49628
50481
  headers.set("User-Agent", "axios/" + VERSION, false);
49629
- const resolvedOptions = {
49630
- ...fetchOptions,
50482
+ const safeFetchOptions = fetchOptions == null ? fetchOptions : Object.assign(/* @__PURE__ */ Object.create(null), fetchOptions);
50483
+ if (safeFetchOptions) {
50484
+ delete safeFetchOptions.body;
50485
+ delete safeFetchOptions.headers;
50486
+ delete safeFetchOptions.method;
50487
+ delete safeFetchOptions.signal;
50488
+ delete safeFetchOptions.duplex;
50489
+ delete safeFetchOptions.credentials;
50490
+ }
50491
+ const resolvedOptions = Object.assign(/* @__PURE__ */ Object.create(null), safeFetchOptions, {
49631
50492
  signal: composedSignal,
49632
50493
  method: method.toUpperCase(),
49633
50494
  headers: toByteStringHeaderObject(headers.normalize()),
49634
50495
  body: data,
49635
50496
  duplex: "half",
49636
50497
  credentials: isCredentialsSupported ? withCredentials : void 0
49637
- };
50498
+ });
50499
+ if (isRequestSupported) {
50500
+ utils_default.forEach(DEFAULT_REQUEST_OPTIONS, (value, key) => {
50501
+ if (resolvedOptions[key] === void 0) {
50502
+ resolvedOptions[key] = value;
50503
+ }
50504
+ });
50505
+ if (resolvedOptions.signal === void 0) {
50506
+ resolvedOptions.signal = null;
50507
+ }
50508
+ if (resolvedOptions.body === void 0) {
50509
+ resolvedOptions.body = null;
50510
+ }
50511
+ }
50512
+ if (maxRedirects === 0) {
50513
+ resolvedOptions.redirect = "manual";
50514
+ if (safeFetchOptions) {
50515
+ safeFetchOptions.redirect = "manual";
50516
+ }
50517
+ }
49638
50518
  request = isRequestSupported && new Request(url2, resolvedOptions);
49639
- let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url2, resolvedOptions));
50519
+ let response = await (isRequestSupported ? _fetch(request, safeFetchOptions) : _fetch(url2, resolvedOptions));
49640
50520
  const responseHeaders = AxiosHeaders_default.from(response.headers);
49641
50521
  if (hasMaxContentLength) {
49642
50522
  const declaredLength = utils_default.toFiniteNumber(responseHeaders.getContentLength());
@@ -49855,9 +50735,10 @@ function throwIfCancellationRequested(config) {
49855
50735
  throw new CanceledError_default(null, config);
49856
50736
  }
49857
50737
  }
49858
- function dispatchRequest(config) {
50738
+ function dispatchRequest(_config) {
50739
+ const config = utils_default.toSafeFlatObject(_config);
49859
50740
  throwIfCancellationRequested(config);
49860
- config.headers = AxiosHeaders_default.from(config.headers);
50741
+ config.headers = AxiosHeaders_default.from(utils_default.getSafeProp(config, "headers"));
49861
50742
  config.data = transformData.call(config, config.transformRequest);
49862
50743
  if (["post", "put", "patch"].indexOf(config.method) !== -1) {
49863
50744
  config.headers.setContentType("application/x-www-form-urlencoded", false);
@@ -49987,16 +50868,15 @@ var Axios = class {
49987
50868
  return await this._request(configOrUrl, config);
49988
50869
  } catch (err) {
49989
50870
  if (err instanceof Error) {
49990
- let dummy = {};
49991
- Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
49992
- const stack = (() => {
49993
- if (!dummy.stack) {
49994
- return "";
49995
- }
49996
- const firstNewlineIndex = dummy.stack.indexOf("\n");
49997
- return firstNewlineIndex === -1 ? "" : dummy.stack.slice(firstNewlineIndex + 1);
49998
- })();
49999
50871
  try {
50872
+ let dummy = {};
50873
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
50874
+ const dummyStack = dummy.stack;
50875
+ let stack = "";
50876
+ if (typeof dummyStack === "string") {
50877
+ const firstNewlineIndex = dummyStack.indexOf("\n");
50878
+ stack = firstNewlineIndex === -1 ? "" : dummyStack.slice(firstNewlineIndex + 1);
50879
+ }
50000
50880
  if (!err.stack) {
50001
50881
  err.stack = stack;
50002
50882
  } else if (stack) {
@@ -50066,9 +50946,9 @@ var Axios = class {
50066
50946
  },
50067
50947
  true
50068
50948
  );
50069
- config.method = (config.method || this.defaults.method || "get").toLowerCase();
50949
+ config.method = (utils_default.getSafeProp(config, "method") || utils_default.getSafeProp(this.defaults, "method") || "get").toLowerCase();
50070
50950
  let contextHeaders = headers && utils_default.merge(headers.common, headers[config.method]);
50071
- headers && utils_default.forEach(["delete", "get", "head", "post", "put", "patch", "query", "common"], (method) => {
50951
+ headers && utils_default.forEach(methodList_default.concat("common"), (method) => {
50072
50952
  delete headers[method];
50073
50953
  });
50074
50954
  config.headers = AxiosHeaders_default.concat(contextHeaders, headers);
@@ -50331,14 +51211,22 @@ var HttpStatusCode = {
50331
51211
  Gone: 410,
50332
51212
  LengthRequired: 411,
50333
51213
  PreconditionFailed: 412,
51214
+ /**
51215
+ * @deprecated Use `ContentTooLarge` instead.
51216
+ */
50334
51217
  PayloadTooLarge: 413,
51218
+ ContentTooLarge: 413,
50335
51219
  UriTooLong: 414,
50336
51220
  UnsupportedMediaType: 415,
50337
51221
  RangeNotSatisfiable: 416,
50338
51222
  ExpectationFailed: 417,
50339
51223
  ImATeapot: 418,
50340
51224
  MisdirectedRequest: 421,
51225
+ /**
51226
+ * @deprecated Use `UnprocessableContent` instead.
51227
+ */
50341
51228
  UnprocessableEntity: 422,
51229
+ UnprocessableContent: 422,
50342
51230
  Locked: 423,
50343
51231
  FailedDependency: 424,
50344
51232
  TooEarly: 425,
@@ -50367,7 +51255,9 @@ var HttpStatusCode = {
50367
51255
  InvalidSslCertificate: 526
50368
51256
  };
50369
51257
  Object.entries(HttpStatusCode).forEach(([key, value]) => {
50370
- HttpStatusCode[value] = key;
51258
+ if (HttpStatusCode[value] === void 0) {
51259
+ HttpStatusCode[value] = key;
51260
+ }
50371
51261
  });
50372
51262
  var HttpStatusCode_default = HttpStatusCode;
50373
51263
 
@@ -50990,6 +51880,14 @@ var init_deployment_addresses = __esm2({
50990
51880
  reason: "2026-08 agent-stack release. The mainnet PositionManagerViews at 0x9225647a was deployed as a BARE implementation (EIP-1967 slot 0x00), so upgradeToAndCall reverts UUPSUnauthorizedCallContext \u2014 it could never be upgraded. PositionManager.setViews (added in the same Execute B batch) removed the repoint blocker, so Views was replaced behind a new proxy rather than upgraded. This makes the Pashov F3 renewal debt-ceiling check REACHABLE for the first time: ExceedsMaxLoan (0x499e7985) is present in 0xE68DC096 and absent from 0x9225647a. Views holds no protocol state (8 wiring slots + roles + pause), which is what made replacement safe. The old contract is ABANDONED, not decommissioned \u2014 it stays live and callable as the rollback target for setViews. NOTE: VERSION reads 1.1.1 on both sides; verify by address.",
50991
51881
  executeTx: "0xf1f8d5fc13f45d7a3f932bf1a2d6e29381fdd41cd31298ad785bf7688df07fe6",
50992
51882
  block: 25673200
51883
+ },
51884
+ AgentDelegationRegistry: {
51885
+ newImplementation: "0xa9fF405Edd4329fc3159a64F56B37EBD253e4928",
51886
+ upgradedAt: "2026-07-31T22:03:35.000Z",
51887
+ upgradedBy: "AdminModule/Safe audit-batch upgradeToAndCall; executed by 0xEba7BfAeB35ee18408b424Ee0BB45AdDf776589f in tx 0x8fed0ab7eee3aaaa3792a35b40b0ef74bd09cfb1a175934afd846bee546048d4 (block 25655710)",
51888
+ reason: "Reconciled from chain \u2014 mainnet audit rollout batch (cross-ref onchain-auth/.safe-batches/mainnet-audit-execute.json)",
51889
+ executeTx: "0x8fed0ab7eee3aaaa3792a35b40b0ef74bd09cfb1a175934afd846bee546048d4",
51890
+ block: 25655710
50993
51891
  }
50994
51892
  },
50995
51893
  latestEnv: {
@@ -51539,6 +52437,9 @@ var require_pkg_src2 = __commonJS2({
51539
52437
  });
51540
52438
  var index_exports = {};
51541
52439
  __export22(index_exports, {
52440
+ BORROWER_AUTHORIZATION_ENCODE_TYPES: () => BORROWER_AUTHORIZATION_ENCODE_TYPES,
52441
+ BORROWER_AUTHORIZATION_FIELDS: () => BORROWER_AUTHORIZATION_FIELDS,
52442
+ BORROWER_AUTHORIZATION_PRIMARY_TYPES: () => BORROWER_AUTHORIZATION_PRIMARY_TYPES,
51542
52443
  CHIPOTLE_DEPLOYMENTS: () => CHIPOTLE_DEPLOYMENTS,
51543
52444
  DEFAULT_CACHE_CONFIG: () => DEFAULT_CACHE_CONFIG,
51544
52445
  DEFAULT_DEBUG_CONFIG: () => DEFAULT_DEBUG_CONFIG,
@@ -51551,6 +52452,8 @@ var require_pkg_src2 = __commonJS2({
51551
52452
  PerformanceTracker: () => PerformanceTracker,
51552
52453
  RetryStrategy: () => RetryStrategy,
51553
52454
  analyzeError: () => analyzeError,
52455
+ borrowerAuthorizationTypes: () => borrowerAuthorizationTypes,
52456
+ buildBorrowerAuthorizationDomain: () => buildBorrowerAuthorizationDomain,
51554
52457
  calculateDelay: () => calculateDelay,
51555
52458
  cidToHex: () => cidToHex,
51556
52459
  classifyError: () => classifyError,
@@ -51797,30 +52700,30 @@ var require_pkg_src2 = __commonJS2({
51797
52700
  }
51798
52701
  },
51799
52702
  btcTransactionSigner: {
51800
- cid: "QmakWzTce8NH1Jkgv1xwg83Bg9WmF2UG1Mq76pDYDSwwUp",
52703
+ cid: "QmVi1BYdxvCX3QUhXwPtP6FjWMzqSPtXzrS54YsXjTgjYf",
51801
52704
  authorizedCidHex: cidToHex(
51802
- "QmakWzTce8NH1Jkgv1xwg83Bg9WmF2UG1Mq76pDYDSwwUp"
52705
+ "QmVi1BYdxvCX3QUhXwPtP6FjWMzqSPtXzrS54YsXjTgjYf"
51803
52706
  ),
51804
52707
  name: "Btc Transaction Signer",
51805
52708
  description: "Production Btc Transaction Signer",
51806
52709
  version: "1.1.1",
51807
52710
  deployed: true,
51808
- deployedAt: 1786465606156,
51809
- size: 67999,
51810
- hash: "83f3644c68819215e05ba8db3225571354a009458fc1437f606df6cb9142d3f9"
52711
+ deployedAt: 1787923905597,
52712
+ size: 70646,
52713
+ hash: "37c3bb72a660c8275d92e1b73f9482742d86b64789480b9246304c0ca1bab47a"
51811
52714
  },
51812
52715
  ucdMintValidator: {
51813
- cid: "Qmd8jgKRceLvf5aoTtwdXG2JqMoBK5cRJwrvEtQkgvbFbx",
52716
+ cid: "QmUWR5fLiyimLT9TPXpYx3HgwNwkvR6MxjZ7hdeYCFodbc",
51814
52717
  authorizedCidHex: cidToHex(
51815
- "Qmd8jgKRceLvf5aoTtwdXG2JqMoBK5cRJwrvEtQkgvbFbx"
52718
+ "QmUWR5fLiyimLT9TPXpYx3HgwNwkvR6MxjZ7hdeYCFodbc"
51816
52719
  ),
51817
52720
  name: "Ucd Mint Validator",
51818
52721
  description: "Production Ucd Mint Validator",
51819
52722
  version: "1.2.1",
51820
52723
  deployed: true,
51821
- deployedAt: 1786465627201,
51822
- size: 82739,
51823
- hash: "2bdd9aebdaad58a43a4731d5b7284f2531b7a9caaf8caf5719d891c4ed33cb2e",
52724
+ deployedAt: 1787923919527,
52725
+ size: 86197,
52726
+ hash: "c2d80939746cc37f65ef2f63c6a3215b929214a63f10c78144e1f5c98320dabf",
51824
52727
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
51825
52728
  pkp: {
51826
52729
  publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
@@ -51828,17 +52731,17 @@ var require_pkg_src2 = __commonJS2({
51828
52731
  }
51829
52732
  },
51830
52733
  processPaymentValidator: {
51831
- cid: "QmNXVdysXDhCaQ1uNE2Vgjbuzy6yUEnnVgHzmDfNKXMU6z",
52734
+ cid: "QmXmXuMRAjMLdgKGyTf9KQdGwYrDp8DxkiF44TvSXDf7wF",
51832
52735
  authorizedCidHex: cidToHex(
51833
- "QmNXVdysXDhCaQ1uNE2Vgjbuzy6yUEnnVgHzmDfNKXMU6z"
52736
+ "QmXmXuMRAjMLdgKGyTf9KQdGwYrDp8DxkiF44TvSXDf7wF"
51834
52737
  ),
51835
52738
  name: "Process Payment Validator",
51836
52739
  description: "Production Process Payment Validator",
51837
52740
  version: "1.2.1",
51838
52741
  deployed: true,
51839
- deployedAt: 1786465654796,
51840
- size: 78736,
51841
- hash: "17191ecc9c009e0fa5ab52c876330beb2a9a75d30cccb92e7c0c04f169df088b",
52742
+ deployedAt: 1787923987153,
52743
+ size: 82217,
52744
+ hash: "13defa19614215ab3b1fe88955d69e530d13a09475396af932fe0e213637da2f",
51842
52745
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
51843
52746
  pkp: {
51844
52747
  publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
@@ -51846,17 +52749,17 @@ var require_pkg_src2 = __commonJS2({
51846
52749
  }
51847
52750
  },
51848
52751
  extendPositionValidator: {
51849
- cid: "QmYwBsyrhGfHWyRKx549G4tKHxsBLAuRUHcecigeUCkFav",
52752
+ cid: "QmU8h99EEVEsQkxroXiYqLsKZw9gNjE6N5CcTpE9aUc12m",
51850
52753
  authorizedCidHex: cidToHex(
51851
- "QmYwBsyrhGfHWyRKx549G4tKHxsBLAuRUHcecigeUCkFav"
52754
+ "QmU8h99EEVEsQkxroXiYqLsKZw9gNjE6N5CcTpE9aUc12m"
51852
52755
  ),
51853
52756
  name: "Extend Position Validator",
51854
52757
  description: "Production Extend Position Validator",
51855
52758
  version: "1.2.1",
51856
52759
  deployed: true,
51857
- deployedAt: 1786465681874,
51858
- size: 76515,
51859
- hash: "1d4e085335af80f194a663a577876902c83015177e95906a0b461fa93bd5da08",
52760
+ deployedAt: 1787923999294,
52761
+ size: 79975,
52762
+ hash: "31c1aaf883ef22f37681ddb0a4a949be5c05304b6aef178989475a2da935ef9a",
51860
52763
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
51861
52764
  pkp: {
51862
52765
  publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
@@ -51864,17 +52767,17 @@ var require_pkg_src2 = __commonJS2({
51864
52767
  }
51865
52768
  },
51866
52769
  btcWithdrawal: {
51867
- cid: "QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh",
52770
+ cid: "QmZQWET9pzrVD4gwQuSzYZmqa24JrUNtnnGFDd513sxMCY",
51868
52771
  authorizedCidHex: cidToHex(
51869
- "QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh"
52772
+ "QmZQWET9pzrVD4gwQuSzYZmqa24JrUNtnnGFDd513sxMCY"
51870
52773
  ),
51871
52774
  name: "Btc Withdrawal",
51872
52775
  description: "Production Btc Withdrawal",
51873
52776
  version: "1.2.7",
51874
52777
  deployed: true,
51875
- deployedAt: 1786446046614,
51876
- size: 97456,
51877
- hash: "3cae8250861832f91ee3c573abeb50ff27b9acd34148176071cbfbabb359fc91",
52778
+ deployedAt: 1787924017769,
52779
+ size: 100069,
52780
+ hash: "4f8e27414e4da235e63d6ae1325c63f3d2fb956464515a21aa007a99935f0f13",
51878
52781
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
51879
52782
  pkp: {
51880
52783
  publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
@@ -51986,30 +52889,30 @@ var require_pkg_src2 = __commonJS2({
51986
52889
  hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
51987
52890
  },
51988
52891
  agentModuleExecutor: {
51989
- cid: "QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ",
52892
+ cid: "QmcD65vuremot5fsHVgp9JBAmei6gAaEtm5mdtLP7Yt9Kf",
51990
52893
  authorizedCidHex: cidToHex(
51991
- "QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ"
52894
+ "QmcD65vuremot5fsHVgp9JBAmei6gAaEtm5mdtLP7Yt9Kf"
51992
52895
  ),
51993
52896
  name: "Agent Module Executor",
51994
52897
  description: "Production Agent Module Executor",
51995
52898
  version: "1.1.1",
51996
52899
  deployed: true,
51997
- deployedAt: 1786446108348,
51998
- size: 11655,
51999
- hash: "d4e2149f843d6c2699fc61114d54b268ba4ed2c46ebdaee1145e0f101ec2a1ec"
52900
+ deployedAt: 1787924032013,
52901
+ size: 13878,
52902
+ hash: "a7f0204700912e26e5a354bee13a1242a2baa218643b3bb22d28481f67f9baf4"
52000
52903
  },
52001
52904
  staleSpendRecoveryValidator: {
52002
- cid: "QmXQWT8V4wjuvH8BbC7xrkYxsVu5AKfvfWcS7jnYfrexYm",
52905
+ cid: "QmNuwo4PT4AikAmhMdZgPWCb2mJDwWa9TnUqrqvofjbrT8",
52003
52906
  authorizedCidHex: cidToHex(
52004
- "QmXQWT8V4wjuvH8BbC7xrkYxsVu5AKfvfWcS7jnYfrexYm"
52907
+ "QmNuwo4PT4AikAmhMdZgPWCb2mJDwWa9TnUqrqvofjbrT8"
52005
52908
  ),
52006
52909
  name: "Stale Spend Recovery Validator",
52007
52910
  description: "Production Stale Spend Recovery Validator",
52008
52911
  version: "1.1.2",
52009
52912
  deployed: true,
52010
- deployedAt: 1785173285829,
52011
- size: 37108,
52012
- hash: "04de5fc5b6f5131dc1544e3d3d187a1f9ef9616ffd12483d119f9102b3671791",
52913
+ deployedAt: 1787924048772,
52914
+ size: 41424,
52915
+ hash: "3c5f028d2bef4344768462993616d45e30d9d44ef126e04d6eb579821d57d99c",
52013
52916
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
52014
52917
  pkp: {
52015
52918
  publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
@@ -52017,17 +52920,17 @@ var require_pkg_src2 = __commonJS2({
52017
52920
  }
52018
52921
  },
52019
52922
  btcUtxoInvalidator: {
52020
- cid: "Qmf4Ze8yhnQhHbnX5RPgJrC7Jw1aA3gbpfpd52kFg7fd1m",
52923
+ cid: "QmaNGeWut7EiGwW4zUc2sFSt7RY5NWFgxYboyG333TwrJf",
52021
52924
  authorizedCidHex: cidToHex(
52022
- "Qmf4Ze8yhnQhHbnX5RPgJrC7Jw1aA3gbpfpd52kFg7fd1m"
52925
+ "QmaNGeWut7EiGwW4zUc2sFSt7RY5NWFgxYboyG333TwrJf"
52023
52926
  ),
52024
52927
  name: "Btc Utxo Invalidator",
52025
52928
  description: "Production Btc Utxo Invalidator",
52026
52929
  version: "1.0.0",
52027
52930
  deployed: true,
52028
- deployedAt: 1786465704240,
52029
- size: 62553,
52030
- hash: "1dcea2b49e545c423195be22e072dc5e3039ed1c95a8490b23505956029f5b33"
52931
+ deployedAt: 1787924133241,
52932
+ size: 66026,
52933
+ hash: "603bc50920d7f1dee77086f2c518d9e2922ab3858a419d3fbea8221ea3a6d9e9"
52031
52934
  }
52032
52935
  };
52033
52936
  function getDeploymentsForNetwork(network) {
@@ -52788,6 +53691,101 @@ ${errorReport}`);
52788
53691
  var SECONDS_PER_DAY = 86400;
52789
53692
  var DAYS_PER_MONTH = 30;
52790
53693
  var LIT_ACTION_ETH_RPC_TIMEOUT_MS = 8e3;
53694
+ var PINNED_CONTRACT_ADDRESSES = {
53695
+ 1: {
53696
+ PositionManager: "0x12A1836e56139ccaD8722B89519d84233efc224B",
53697
+ LoanOperationsManagerModule: "0x2561974A40F1AEed1251d0A090A83cF8536FB9E9",
53698
+ BTCSpendAuthorizer: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
53699
+ BitcoinProviderRegistry: "0x4ab3Fb96e02893Ed6FAa61bad1918390c8DbbFFC",
53700
+ LITActionValidator: "0xD2c5d59c2CC5c409AC65ce0A817236aeC6869512",
53701
+ PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C"
53702
+ },
53703
+ 11155111: {
53704
+ PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
53705
+ LoanOperationsManagerModule: "0x3e05e760a87715207b7F4e8fD35EF7559BcA72C0",
53706
+ BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
53707
+ BitcoinProviderRegistry: "0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",
53708
+ LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
53709
+ PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9"
53710
+ }
53711
+ };
53712
+ function getPinnedContractAddresses(chainId) {
53713
+ return PINNED_CONTRACT_ADDRESSES[chainId] ?? null;
53714
+ }
53715
+ var PROTOCOL_EIP712_DOMAIN_NAME = "DiamondHands.Protocol";
53716
+ var PROTOCOL_EIP712_DOMAIN_VERSION = "1";
53717
+ var BORROWER_AUTHORIZATION_PRIMARY_TYPES = {
53718
+ MINT: "MintRequest",
53719
+ REPAY: "RepayRequest",
53720
+ RENEW: "RenewRequest",
53721
+ WITHDRAW: "WithdrawRequest"
53722
+ };
53723
+ var BORROWER_AUTHORIZATION_FIELDS = {
53724
+ MintRequest: [
53725
+ { name: "positionId", type: "bytes32" },
53726
+ { name: "mintAmount", type: "uint256" },
53727
+ { name: "quantumTimestamp", type: "uint256" }
53728
+ ],
53729
+ RepayRequest: [
53730
+ { name: "positionId", type: "bytes32" },
53731
+ { name: "paymentAmount", type: "uint256" },
53732
+ { name: "quantumTimestamp", type: "uint256" }
53733
+ ],
53734
+ RenewRequest: [
53735
+ { name: "positionId", type: "bytes32" },
53736
+ { name: "selectedTerm", type: "uint256" },
53737
+ { name: "quantumTimestamp", type: "uint256" }
53738
+ ],
53739
+ WithdrawRequest: [
53740
+ { name: "positionId", type: "bytes32" },
53741
+ { name: "totalDeduction", type: "uint256" },
53742
+ { name: "withdrawalAddress", type: "string" },
53743
+ { name: "quantumTimestamp", type: "uint256" }
53744
+ ]
53745
+ };
53746
+ var BORROWER_AUTHORIZATION_ENCODE_TYPES = {
53747
+ MintRequest: "MintRequest(bytes32 positionId,uint256 mintAmount,uint256 quantumTimestamp)",
53748
+ RepayRequest: "RepayRequest(bytes32 positionId,uint256 paymentAmount,uint256 quantumTimestamp)",
53749
+ RenewRequest: "RenewRequest(bytes32 positionId,uint256 selectedTerm,uint256 quantumTimestamp)",
53750
+ WithdrawRequest: "WithdrawRequest(bytes32 positionId,uint256 totalDeduction,string withdrawalAddress,uint256 quantumTimestamp)"
53751
+ };
53752
+ function borrowerAuthorizationTypes(primaryType) {
53753
+ const fields = BORROWER_AUTHORIZATION_FIELDS[primaryType];
53754
+ if (!fields) {
53755
+ throw new Error(
53756
+ `Unknown borrower authorization primary type "${primaryType}"; expected one of ${Object.keys(BORROWER_AUTHORIZATION_FIELDS).join(", ")}`
53757
+ );
53758
+ }
53759
+ return { [primaryType]: fields.map((field) => ({ ...field })) };
53760
+ }
53761
+ function buildBorrowerAuthorizationDomain(chainId, verifyingContractOverride) {
53762
+ if (!Number.isInteger(chainId) || chainId <= 0) {
53763
+ throw new Error(
53764
+ `Borrower authorization domain requires a positive integer chainId, got ${String(chainId)}`
53765
+ );
53766
+ }
53767
+ const pinned = getPinnedContractAddresses(chainId);
53768
+ const pinnedLom = pinned?.LoanOperationsManagerModule;
53769
+ if (pinnedLom && verifyingContractOverride) {
53770
+ if (pinnedLom.toLowerCase() !== verifyingContractOverride.toLowerCase()) {
53771
+ throw new Error(
53772
+ `Refusing a caller-supplied verifyingContract that contradicts the pin for chainId ${chainId}: caller ${verifyingContractOverride}, pinned ${pinnedLom}`
53773
+ );
53774
+ }
53775
+ }
53776
+ const verifyingContract = pinnedLom ?? verifyingContractOverride;
53777
+ if (!verifyingContract) {
53778
+ throw new Error(
53779
+ `No pinned LoanOperationsManagerModule for chainId ${chainId} and no verifyingContract supplied; refusing to build a borrower authorization domain without one`
53780
+ );
53781
+ }
53782
+ return {
53783
+ name: PROTOCOL_EIP712_DOMAIN_NAME,
53784
+ version: PROTOCOL_EIP712_DOMAIN_VERSION,
53785
+ chainId,
53786
+ verifyingContract
53787
+ };
53788
+ }
52791
53789
  var EVMChain = /* @__PURE__ */ ((EVMChain3) => {
52792
53790
  EVMChain3["SEPOLIA"] = "sepolia";
52793
53791
  EVMChain3["ETHEREUM"] = "ethereum";
@@ -56583,6 +57581,77 @@ async function awaitSafeSubmissionWindowOnChain(signatureQuantum, chainNow, slee
56583
57581
  );
56584
57582
  return { waited: waitedSeconds > 0, waitedSeconds };
56585
57583
  }
57584
+ init_deployment_addresses();
57585
+ var BORROWER_AUTHORIZATION_712_DOMAIN_NAME = "DiamondHands.Protocol";
57586
+ var BORROWER_AUTHORIZATION_712_DOMAIN_VERSION = "1";
57587
+ var BORROWER_AUTHORIZATION_712_FIELDS = {
57588
+ MintRequest: [
57589
+ { name: "positionId", type: "bytes32" },
57590
+ { name: "mintAmount", type: "uint256" },
57591
+ { name: "quantumTimestamp", type: "uint256" }
57592
+ ],
57593
+ RepayRequest: [
57594
+ { name: "positionId", type: "bytes32" },
57595
+ { name: "paymentAmount", type: "uint256" },
57596
+ { name: "quantumTimestamp", type: "uint256" }
57597
+ ],
57598
+ RenewRequest: [
57599
+ { name: "positionId", type: "bytes32" },
57600
+ { name: "selectedTerm", type: "uint256" },
57601
+ { name: "quantumTimestamp", type: "uint256" }
57602
+ ],
57603
+ WithdrawRequest: [
57604
+ { name: "positionId", type: "bytes32" },
57605
+ { name: "totalDeduction", type: "uint256" },
57606
+ { name: "withdrawalAddress", type: "string" },
57607
+ { name: "quantumTimestamp", type: "uint256" }
57608
+ ]
57609
+ };
57610
+ function borrowerAuthorization712Types(primaryType) {
57611
+ const fields = BORROWER_AUTHORIZATION_712_FIELDS[primaryType];
57612
+ if (!fields) {
57613
+ throw new Error(
57614
+ `Unknown borrower authorization primary type "${primaryType}"; expected one of ` + Object.keys(BORROWER_AUTHORIZATION_712_FIELDS).join(", ")
57615
+ );
57616
+ }
57617
+ return { [primaryType]: fields.map((field) => ({ ...field })) };
57618
+ }
57619
+ function buildBorrowerAuthorization712Domain(chainId) {
57620
+ if (!Number.isInteger(chainId) || chainId <= 0) {
57621
+ throw new Error(
57622
+ `Borrower authorization domain requires a positive integer chainId, got ${String(chainId)}`
57623
+ );
57624
+ }
57625
+ const deployment = Object.values(ALL_DEPLOYMENTS).find(
57626
+ (d) => d.chainId === chainId
57627
+ );
57628
+ const verifyingContract = deployment?.contracts?.LoanOperationsManagerModule;
57629
+ if (!verifyingContract) {
57630
+ throw new Error(
57631
+ `No LoanOperationsManagerModule deployment known for chainId ${chainId}; refusing to build a borrower authorization domain without one`
57632
+ );
57633
+ }
57634
+ return {
57635
+ name: BORROWER_AUTHORIZATION_712_DOMAIN_NAME,
57636
+ version: BORROWER_AUTHORIZATION_712_DOMAIN_VERSION,
57637
+ chainId,
57638
+ verifyingContract
57639
+ };
57640
+ }
57641
+ async function signBorrowerAuthorization712(signer, primaryType, chainId, message) {
57642
+ const signTypedData = signer.signTypedData;
57643
+ if (typeof signTypedData !== "function") {
57644
+ throw new Error(
57645
+ `Signer has no signTypedData \u2014 cannot produce an EIP-712 ${primaryType}. Wallets without typed-data support must supply the signature via an authorizationProvider instead of a connected signer.`
57646
+ );
57647
+ }
57648
+ return signTypedData.call(
57649
+ signer,
57650
+ buildBorrowerAuthorization712Domain(chainId),
57651
+ borrowerAuthorization712Types(primaryType),
57652
+ message
57653
+ );
57654
+ }
56586
57655
  var PKP_NFT_ABI = [
56587
57656
  "function getPubkey(uint256 tokenId) external view returns (bytes memory)"
56588
57657
  ];
@@ -56595,29 +57664,11 @@ async function generateMintAuthorization(positionId, amount, chainId, signerOrPr
56595
57664
  const signer = signerOrPrecomputed;
56596
57665
  const timestamp = calculateNextQuantumTimestamp();
56597
57666
  const action = "mint-ucd";
56598
- const actionHash = (0, import_ethers15.keccak256)((0, import_ethers15.toUtf8Bytes)(action));
56599
- const types = [
56600
- "bytes32",
56601
- // positionId
56602
- "uint256",
56603
- // timestamp
56604
- "uint256",
56605
- // chainId
56606
- "uint256",
56607
- // amount
56608
- "bytes32"
56609
- // actionHash
56610
- ];
56611
- const values = [
57667
+ const signature = await signBorrowerAuthorization712(signer, "MintRequest", chainId, {
56612
57668
  positionId,
56613
- timestamp,
56614
- chainId,
56615
- amount.toString(),
56616
- actionHash
56617
- ];
56618
- const messageHash = (0, import_ethers15.solidityPackedKeccak256)(types, values);
56619
- const messageHashBytes = (0, import_ethers15.getBytes)(messageHash);
56620
- const signature = await signer.signMessage(messageHashBytes);
57669
+ mintAmount: amount.toString(),
57670
+ quantumTimestamp: timestamp
57671
+ });
56621
57672
  return {
56622
57673
  positionId,
56623
57674
  timestamp,
@@ -56654,44 +57705,17 @@ async function generatePaymentAuthorization(positionId, amount, chainId, signerO
56654
57705
  throw new Error(`timestamp must be a number, got ${typeof timestamp}`);
56655
57706
  }
56656
57707
  const action = "make-payment";
56657
- const actionHash = (0, import_ethers15.keccak256)((0, import_ethers15.toUtf8Bytes)(action));
56658
- if (typeof actionHash !== "string") {
56659
- throw new Error(`actionHash must be a string, got ${typeof actionHash}`);
56660
- }
56661
- const types = [
56662
- "bytes32",
56663
- // positionId
56664
- "uint256",
56665
- // timestamp
56666
- "uint256",
56667
- // chainId
56668
- "uint256",
56669
- // amount
56670
- "bytes32"
56671
- // actionHash
56672
- ];
56673
57708
  const amountStr = amount.toString();
56674
- if (typeof amountStr !== "string") {
56675
- throw new Error(
56676
- `amount.toString() must return a string, got ${typeof amountStr}`
56677
- );
56678
- }
56679
- const values = [positionId, timestamp, chainId, amountStr, actionHash];
56680
- for (let i = 0; i < values.length; i++) {
56681
- if (typeof values[i] === "object" && values[i] !== null) {
56682
- throw new Error(
56683
- `Value at index ${i} is an object: ${JSON.stringify(values[i])}`
56684
- );
56685
- }
56686
- }
56687
- const messageHash = (0, import_ethers15.solidityPackedKeccak256)(types, values);
56688
- const messageHashBytes = (0, import_ethers15.getBytes)(messageHash);
56689
- const signature = await signer.signMessage(messageHashBytes);
57709
+ const signature = await signBorrowerAuthorization712(signer, "RepayRequest", chainId, {
57710
+ positionId,
57711
+ paymentAmount: amountStr,
57712
+ quantumTimestamp: timestamp
57713
+ });
56690
57714
  return {
56691
57715
  positionId,
56692
57716
  timestamp,
56693
57717
  chainId,
56694
- amount: amount.toString(),
57718
+ amount: amountStr,
56695
57719
  action,
56696
57720
  signature
56697
57721
  };
@@ -56778,32 +57802,12 @@ async function generateWithdrawAuthorization(positionId, amount, chainId, signer
56778
57802
  const signer = signerOrPrecomputed;
56779
57803
  const timestamp = calculateNextQuantumTimestamp();
56780
57804
  const action = "withdraw-btc";
56781
- const actionHash = (0, import_ethers15.keccak256)((0, import_ethers15.toUtf8Bytes)(action));
56782
- const types = [
56783
- "bytes32",
56784
- // positionId
56785
- "uint256",
56786
- // timestamp
56787
- "uint256",
56788
- // chainId
56789
- "uint256",
56790
- // amount (in satoshis)
56791
- "string",
56792
- // destinationAddress (Bitcoin address)
56793
- "bytes32"
56794
- // actionHash
56795
- ];
56796
- const values = [
57805
+ const signature = await signBorrowerAuthorization712(signer, "WithdrawRequest", chainId, {
56797
57806
  positionId,
56798
- timestamp,
56799
- chainId,
56800
- amount.toString(),
56801
- destinationAddress,
56802
- actionHash
56803
- ];
56804
- const messageHash = (0, import_ethers15.solidityPackedKeccak256)(types, values);
56805
- const messageHashBytes = (0, import_ethers15.getBytes)(messageHash);
56806
- const signature = await signer.signMessage(messageHashBytes);
57807
+ totalDeduction: amount.toString(),
57808
+ withdrawalAddress: destinationAddress,
57809
+ quantumTimestamp: timestamp
57810
+ });
56807
57811
  return {
56808
57812
  positionId,
56809
57813
  timestamp,
@@ -56852,29 +57856,11 @@ async function generateExtendAuthorization(positionId, newTerm, chainId, signerO
56852
57856
  const signer = signerOrPrecomputed;
56853
57857
  const timestamp = calculateNextQuantumTimestamp();
56854
57858
  const action = "extend-position";
56855
- const actionHash = (0, import_ethers16.keccak256)((0, import_ethers16.toUtf8Bytes)(action));
56856
- const types = [
56857
- "bytes32",
56858
- // positionId
56859
- "uint256",
56860
- // timestamp
56861
- "uint256",
56862
- // chainId
56863
- "uint256",
56864
- // newTerm (extension term in months)
56865
- "bytes32"
56866
- // actionHash
56867
- ];
56868
- const values = [
57859
+ const signature = await signBorrowerAuthorization712(signer, "RenewRequest", chainId, {
56869
57860
  positionId,
56870
- timestamp,
56871
- chainId,
56872
- newTerm,
56873
- actionHash
56874
- ];
56875
- const messageHash = (0, import_ethers16.solidityPackedKeccak256)(types, values);
56876
- const messageHashBytes = (0, import_ethers16.getBytes)(messageHash);
56877
- const signature = await signer.signMessage(messageHashBytes);
57861
+ selectedTerm: newTerm,
57862
+ quantumTimestamp: timestamp
57863
+ });
56878
57864
  return {
56879
57865
  positionId,
56880
57866
  timestamp,
@@ -57109,6 +58095,7 @@ var ServerSession = class {
57109
58095
  store;
57110
58096
  onSignaturePrompt;
57111
58097
  onSignatureResolved;
58098
+ onSessionRestored;
57112
58099
  now;
57113
58100
  fetchImpl;
57114
58101
  cached = null;
@@ -57149,6 +58136,7 @@ var ServerSession = class {
57149
58136
  this.store = opts.persistSession === false ? null : opts.sessionStore ?? createDefaultSessionStore();
57150
58137
  this.onSignaturePrompt = opts.onSignaturePrompt;
57151
58138
  this.onSignatureResolved = opts.onSignatureResolved;
58139
+ this.onSessionRestored = opts.onSessionRestored;
57152
58140
  this.now = opts.now ?? (() => Math.floor(Date.now() / 1e3));
57153
58141
  this.fetchImpl = opts.fetchImpl ?? ((...a) => fetch(...a));
57154
58142
  }
@@ -57229,7 +58217,7 @@ var ServerSession = class {
57229
58217
  */
57230
58218
  async logout() {
57231
58219
  const cached = this.cached;
57232
- const token = cached && cached.expiresAt > this.now() ? cached.token : await this.getValidToken({ silent: true }).catch(() => null);
58220
+ const token = cached && cached.expiresAt > this.now() ? cached.token : await this.tryResolveSilently(this.generation, false).then((session) => session?.token ?? null).catch(() => null);
57233
58221
  await this.clearPersisted();
57234
58222
  if (!token)
57235
58223
  return;
@@ -57301,8 +58289,9 @@ var ServerSession = class {
57301
58289
  *
57302
58290
  * `gen` is the caller's clear-generation snapshot: writes to `this.cached`
57303
58291
  * and the store are skipped if a `clearPersisted()` landed meanwhile.
58292
+ * `announce` gates `onSessionRestored` for the two persisted-store outcomes.
57304
58293
  */
57305
- async tryResolveSilently(gen) {
58294
+ async tryResolveSilently(gen, announce = true) {
57306
58295
  const nowSec = this.now();
57307
58296
  if (this.cached && this.cached.expiresAt - REFRESH_LEEWAY_SECONDS > nowSec) {
57308
58297
  return this.cached;
@@ -57317,6 +58306,8 @@ var ServerSession = class {
57317
58306
  };
57318
58307
  if (gen === this.generation)
57319
58308
  this.cached = adopted;
58309
+ if (announce)
58310
+ this.onSessionRestored?.();
57320
58311
  return adopted;
57321
58312
  }
57322
58313
  try {
@@ -57325,6 +58316,8 @@ var ServerSession = class {
57325
58316
  this.persist(persisted.payload, session);
57326
58317
  this.cached = session;
57327
58318
  }
58319
+ if (announce)
58320
+ this.onSessionRestored?.();
57328
58321
  return session;
57329
58322
  } catch (error) {
57330
58323
  if (!isLoginRejection(error))
@@ -60410,6 +61403,10 @@ function normalizePkpId(pkpId) {
60410
61403
  }
60411
61404
  return pkpId;
60412
61405
  }
61406
+ function isNormalizedChipotlePkpId(pkpId) {
61407
+ const rawId = pkpId.startsWith("0x") ? pkpId.slice(2) : pkpId;
61408
+ return rawId.length === 40;
61409
+ }
60413
61410
  function padPkpIdForSubgraph(pkpId) {
60414
61411
  const raw = pkpId.startsWith("0x") ? pkpId.slice(2) : pkpId;
60415
61412
  if (raw.length === 40) {
@@ -60694,7 +61691,7 @@ var LoanQuery = class {
60694
61691
  batch.map(async (loan) => {
60695
61692
  try {
60696
61693
  const rawId = loan.pkpId?.startsWith("0x") ? loan.pkpId.slice(2) : loan.pkpId;
60697
- const isChipotlePkpId2 = typeof rawId === "string" && rawId.length === 40 && !rawId.toLowerCase().startsWith("04");
61694
+ const isChipotlePkpId2 = typeof rawId === "string" && isNormalizedChipotlePkpId(rawId);
60698
61695
  if (isChipotlePkpId2) {
60699
61696
  if (this.config.positionManagerCoreAddress && this.config.provider) {
60700
61697
  const pmContract = new import_ethers25.Contract(
@@ -61021,6 +62018,7 @@ function createLoanQuery(config) {
61021
62018
  );
61022
62019
  }
61023
62020
  }
62021
+ var STATIC_CALL_DIAGNOSTIC_TIMEOUT_MS = 5e3;
61024
62022
  var WithdrawalAddressModule = class {
61025
62023
  config;
61026
62024
  graphClient;
@@ -61066,13 +62064,17 @@ var WithdrawalAddressModule = class {
61066
62064
  const reg = this.getRegistry();
61067
62065
  if (!reg.success)
61068
62066
  return reg;
62067
+ const normalized = normalizeBitcoinAddress(btcAddress2);
61069
62068
  try {
61070
- const tx2 = await reg.value.addAddress(
61071
- normalizeBitcoinAddress(btcAddress2)
61072
- );
62069
+ const tx2 = await reg.value.addAddress(normalized);
61073
62070
  return success(tx2);
61074
62071
  } catch (error) {
61075
- return this.txFailure("addAddress", error, btcAddress2);
62072
+ return this.txFailure(
62073
+ "addAddress",
62074
+ error,
62075
+ btcAddress2,
62076
+ await this.staticCallDiagnostic(reg.value, "addAddress", normalized)
62077
+ );
61076
62078
  }
61077
62079
  }
61078
62080
  /** Remove a Bitcoin address from the caller's allowlist (effective immediately). */
@@ -61080,13 +62082,17 @@ var WithdrawalAddressModule = class {
61080
62082
  const reg = this.getRegistry();
61081
62083
  if (!reg.success)
61082
62084
  return reg;
62085
+ const normalized = normalizeBitcoinAddress(btcAddress2);
61083
62086
  try {
61084
- const tx2 = await reg.value.removeAddress(
61085
- normalizeBitcoinAddress(btcAddress2)
61086
- );
62087
+ const tx2 = await reg.value.removeAddress(normalized);
61087
62088
  return success(tx2);
61088
62089
  } catch (error) {
61089
- return this.txFailure("removeAddress", error, btcAddress2);
62090
+ return this.txFailure(
62091
+ "removeAddress",
62092
+ error,
62093
+ btcAddress2,
62094
+ await this.staticCallDiagnostic(reg.value, "removeAddress", normalized)
62095
+ );
61090
62096
  }
61091
62097
  }
61092
62098
  /**
@@ -61182,16 +62188,59 @@ var WithdrawalAddressModule = class {
61182
62188
  }
61183
62189
  return success(void 0);
61184
62190
  }
61185
- txFailure(op, error, context) {
62191
+ /**
62192
+ * Ask the node for the reason a failed write did not carry.
62193
+ *
62194
+ * A failing `eth_estimateGas` frequently answers with NOTHING to decode — ethers renders that
62195
+ * as `missing revert data ... data=null, reason=null, revert=null`, which names no cause and
62196
+ * cannot distinguish "the contract rejected this" from "the RPC hiccuped". An `eth_call` of the
62197
+ * same calldata usually does carry the revert reason or custom-error selector, so this runs one
62198
+ * and folds the answer into the reported error.
62199
+ *
62200
+ * Three deliberate properties:
62201
+ *
62202
+ * 1. It runs ONLY after the write has already failed. Gating the write on a static call would
62203
+ * let a flaky endpoint — precisely the condition this exists to diagnose — block an add that
62204
+ * would otherwise have succeeded.
62205
+ * 2. It costs NO extra signature. `staticCall` is `eth_call`: a node read, never a wallet prompt.
62206
+ * 3. It can never throw. A diagnostic that escapes would replace the real cause with itself.
62207
+ * (The `try/catch` here is the authorized exception to CLAUDE.md's forbidden-patterns rule;
62208
+ * it swallows nothing — every branch returns text that is reported alongside the original.)
62209
+ *
62210
+ * A static call that SUCCEEDS is itself a finding: the contract accepts this call, so the
62211
+ * failure lay outside contract logic (RPC, gas, or nonce).
62212
+ */
62213
+ async staticCallDiagnostic(registry, op, normalizedAddress) {
62214
+ try {
62215
+ await Promise.race([
62216
+ registry[op].staticCall(normalizedAddress),
62217
+ // The failure being diagnosed is often an unresponsive endpoint, so the diagnostic must
62218
+ // not inherit that hang — the user is waiting on this error message.
62219
+ new Promise(
62220
+ (_, reject) => setTimeout(
62221
+ () => reject(new Error("static call timed out after 5s")),
62222
+ STATIC_CALL_DIAGNOSTIC_TIMEOUT_MS
62223
+ )
62224
+ )
62225
+ ]);
62226
+ return "static call SUCCEEDED \u2014 the contract accepts this call, so the failure was not contract logic (RPC, gas, or nonce)";
62227
+ } catch (diagnostic) {
62228
+ const code = typeof diagnostic === "object" && diagnostic !== null ? diagnostic.code : void 0;
62229
+ const msg = diagnostic instanceof Error ? diagnostic.message : String(diagnostic);
62230
+ return typeof code === "string" ? `static call reverted [${code}]: ${msg}` : `static call failed: ${msg}`;
62231
+ }
62232
+ }
62233
+ txFailure(op, error, context, diagnostic) {
61186
62234
  const msg = error instanceof Error ? error.message : String(error);
62235
+ const detail = diagnostic ? `${msg} \u2014 ${diagnostic}` : msg;
61187
62236
  return failure(
61188
62237
  new SDKError({
61189
62238
  code: `SDK_WITHDRAWAL_REGISTRY_${op.toUpperCase()}_FAILED`,
61190
- message: `WithdrawalAddressRegistry.${op} failed: ${msg}`,
62239
+ message: `WithdrawalAddressRegistry.${op} failed: ${detail}`,
61191
62240
  category: "CONTRACT",
61192
62241
  severity: "MEDIUM",
61193
62242
  originalError: error instanceof Error ? error : new Error(String(error)),
61194
- context: { op, context }
62243
+ context: { op, context, diagnostic }
61195
62244
  })
61196
62245
  );
61197
62246
  }
@@ -62269,6 +63318,210 @@ function normalizePkpId2(pkpId) {
62269
63318
  }
62270
63319
  return pkpId;
62271
63320
  }
63321
+ function applyLoanEventsFilter(events, opts) {
63322
+ const { wantsEvent, fromTimestamp, toTimestamp, fromBlock, toBlock, limit } = opts;
63323
+ const inBounds = (e) => {
63324
+ const ts = e?.timestamp;
63325
+ const bn = e?.blockNumber;
63326
+ try {
63327
+ if (fromTimestamp !== void 0 && ts !== void 0 && BigInt(ts) < BigInt(fromTimestamp))
63328
+ return false;
63329
+ if (toTimestamp !== void 0 && ts !== void 0 && BigInt(ts) > BigInt(toTimestamp))
63330
+ return false;
63331
+ if (fromBlock !== void 0 && bn !== void 0 && BigInt(bn) < BigInt(fromBlock))
63332
+ return false;
63333
+ if (toBlock !== void 0 && bn !== void 0 && BigInt(bn) > BigInt(toBlock))
63334
+ return false;
63335
+ } catch {
63336
+ return true;
63337
+ }
63338
+ return true;
63339
+ };
63340
+ const narrow = (list, kind) => wantsEvent(kind) ? (list ?? []).filter(inBounds).slice(0, limit) : [];
63341
+ const single = (value, kind) => value && wantsEvent(kind) && inBounds(value) ? value : void 0;
63342
+ const filtered = {
63343
+ ...events,
63344
+ positionCreated: single(events.positionCreated, "positionCreated"),
63345
+ payments: narrow(events.payments, "payment"),
63346
+ statusUpdates: narrow(events.statusUpdates, "status"),
63347
+ liquidation: single(events.liquidation, "liquidation"),
63348
+ mints: narrow(events.mints, "mint"),
63349
+ withdrawals: narrow(events.withdrawals, "withdrawal"),
63350
+ renewals: narrow(events.renewals, "renewal"),
63351
+ operationFailures: narrow(events.operationFailures, "operationFailure"),
63352
+ mintRequests: narrow(events.mintRequests, "mintRequest"),
63353
+ burnRequests: narrow(events.burnRequests, "burnRequest"),
63354
+ collateralEvents: narrow(events.collateralEvents, "collateralEvent"),
63355
+ mintingFees: narrow(events.mintingFees, "mintingFee"),
63356
+ renewalFees: narrow(events.renewalFees, "renewalFee"),
63357
+ totalEvents: 0
63358
+ };
63359
+ filtered.totalEvents = (filtered.positionCreated ? 1 : 0) + (filtered.liquidation ? 1 : 0) + filtered.payments.length + filtered.statusUpdates.length + filtered.mints.length + filtered.withdrawals.length + filtered.renewals.length + filtered.operationFailures.length + filtered.mintRequests.length + filtered.burnRequests.length + filtered.collateralEvents.length + filtered.mintingFees.length + filtered.renewalFees.length;
63360
+ return filtered;
63361
+ }
63362
+ function hasLoanEventsFilter(filter2) {
63363
+ if (!filter2)
63364
+ return false;
63365
+ return filter2.eventTypes !== void 0 || filter2.fromTimestamp !== void 0 || filter2.toTimestamp !== void 0 || filter2.fromBlock !== void 0 || filter2.toBlock !== void 0 || filter2.limit !== void 0 || filter2.orderDirection !== void 0;
63366
+ }
63367
+ var WALLET_LOAN_EVENTS_QUERY = `
63368
+ query GetWalletLoanEvents($borrower: Bytes!, $first: Int!, $limit: Int!, $orderDirection: OrderDirection!) {
63369
+ positions(where: { borrower: $borrower }, first: $first, orderBy: id) {
63370
+ id
63371
+ payments(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63372
+ id
63373
+ payer { id }
63374
+ amount
63375
+ type
63376
+ transactionHash
63377
+ timestamp
63378
+ blockNumber
63379
+ logIndex
63380
+ newDebt
63381
+ newCollateralRatio
63382
+ }
63383
+ statusUpdates(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63384
+ id
63385
+ oldStatus
63386
+ newStatus
63387
+ reason
63388
+ timestamp
63389
+ blockNumber
63390
+ transactionHash
63391
+ }
63392
+ liquidation {
63393
+ id
63394
+ liquidator
63395
+ liquidatedAmount
63396
+ collateralSeized
63397
+ transactionHash
63398
+ timestamp
63399
+ blockNumber
63400
+ commitHash
63401
+ commitTimestamp
63402
+ revealDelay
63403
+ }
63404
+ withdrawals(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63405
+ id
63406
+ withdrawalAmount
63407
+ withdrawalAddress
63408
+ networkFee
63409
+ timestamp
63410
+ blockNumber
63411
+ transactionHash
63412
+ logIndex
63413
+ }
63414
+ renewals(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63415
+ id
63416
+ extensionTerm
63417
+ extensionFee
63418
+ newExpiryDate
63419
+ timestamp
63420
+ blockNumber
63421
+ transactionHash
63422
+ logIndex
63423
+ }
63424
+ operationFailures(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63425
+ id
63426
+ operationType
63427
+ reason
63428
+ errorCode
63429
+ amount
63430
+ timestamp
63431
+ blockNumber
63432
+ transactionHash
63433
+ logIndex
63434
+ }
63435
+ mintRequests(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63436
+ id
63437
+ pkpId
63438
+ borrower { id }
63439
+ mintAmount
63440
+ originationFee
63441
+ newDebt
63442
+ newCollateralRatio
63443
+ btcPrice
63444
+ quantumTimestamp
63445
+ opId
63446
+ timestamp
63447
+ blockNumber
63448
+ transactionHash
63449
+ logIndex
63450
+ }
63451
+ burnRequests(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63452
+ id
63453
+ pkpId
63454
+ borrower { id }
63455
+ burnAmount
63456
+ remainingDebt
63457
+ newCollateralRatio
63458
+ opId
63459
+ timestamp
63460
+ blockNumber
63461
+ transactionHash
63462
+ logIndex
63463
+ }
63464
+ mintingFees(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63465
+ id
63466
+ borrower { id }
63467
+ feeAmount
63468
+ mintAmount
63469
+ newDebt
63470
+ btcPrice
63471
+ quantumTimestamp
63472
+ timestamp
63473
+ blockNumber
63474
+ transactionHash
63475
+ logIndex
63476
+ }
63477
+ renewalFees(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63478
+ id
63479
+ borrower { id }
63480
+ feeAmount
63481
+ extensionTerm
63482
+ newExpiryDate
63483
+ timestamp
63484
+ blockNumber
63485
+ transactionHash
63486
+ logIndex
63487
+ }
63488
+ positionCreatedEvents(first: 1, orderBy: timestamp, orderDirection: asc) {
63489
+ id
63490
+ pkpId
63491
+ borrower { id }
63492
+ requestedCollateralRatio
63493
+ selectedTerm
63494
+ expiryAt
63495
+ timestamp
63496
+ blockNumber
63497
+ transactionHash
63498
+ }
63499
+ }
63500
+ ucdmintEvents(where: { position_: { borrower: $borrower } }, first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63501
+ id
63502
+ position { id }
63503
+ amount
63504
+ proof
63505
+ minter { id }
63506
+ isCommunityMint
63507
+ timestamp
63508
+ blockNumber
63509
+ transactionHash
63510
+ }
63511
+ collateralEvents(where: { position_: { borrower: $borrower } }, first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63512
+ id
63513
+ position { id }
63514
+ eventType
63515
+ networkFee
63516
+ remainingCollateral
63517
+ collateralRatio
63518
+ timestamp
63519
+ blockNumber
63520
+ transactionHash
63521
+ logIndex
63522
+ }
63523
+ }
63524
+ `;
62272
63525
  var DiamondHandsGraph = class {
62273
63526
  client;
62274
63527
  defaultPageSize;
@@ -62374,7 +63627,7 @@ var DiamondHandsGraph = class {
62374
63627
  /**
62375
63628
  * Get user positions from subgraph
62376
63629
  */
62377
- async getUserPositions(userAddress, first, skip, orderBy, orderDirection) {
63630
+ async getUserPositionsOnly(userAddress, first, skip, orderBy, orderDirection) {
62378
63631
  const query = `
62379
63632
  query GetUserPositions($borrower: Bytes!, $first: Int, $skip: Int, $orderBy: Position_orderBy, $orderDirection: OrderDirection) {
62380
63633
  user(id: $borrower) {
@@ -62415,17 +63668,28 @@ var DiamondHandsGraph = class {
62415
63668
  query,
62416
63669
  variables
62417
63670
  );
62418
- const total = await this.getTotalCountPaginated("{ borrower: $borrower }", {
62419
- borrower: userAddress.toLowerCase()
62420
- });
62421
63671
  let positions = [];
62422
63672
  if (result && result.user && Array.isArray(result.user.positions)) {
62423
63673
  positions = result.user.positions.filter((p) => p != null).map((p) => this.transformGraphPositionToLoanData(p));
62424
63674
  }
62425
- return {
62426
- positions,
62427
- total
62428
- };
63675
+ return positions;
63676
+ }
63677
+ /**
63678
+ * Get user positions, plus an accurate total count.
63679
+ *
63680
+ * The count is a SECOND round trip (`getTotalCountPaginated`, which pages to handle
63681
+ * >1000 items). Callers that only need the rows should use `getUserPositionsOnly` and
63682
+ * skip it — the event paths did not, and paid for a count they immediately discarded on
63683
+ * every activity refresh.
63684
+ */
63685
+ async getUserPositions(userAddress, first, skip, orderBy, orderDirection) {
63686
+ const [positions, total] = await Promise.all([
63687
+ this.getUserPositionsOnly(userAddress, first, skip, orderBy, orderDirection),
63688
+ this.getTotalCountPaginated("{ borrower: $borrower }", {
63689
+ borrower: userAddress.toLowerCase()
63690
+ })
63691
+ ]);
63692
+ return { positions, total };
62429
63693
  }
62430
63694
  /**
62431
63695
  * Get user positions with enriched Bitcoin balance data
@@ -63251,32 +64515,24 @@ var DiamondHandsGraph = class {
63251
64515
  limit = 1e3,
63252
64516
  orderDirection = "desc"
63253
64517
  } = filter2 || {};
64518
+ const wantsEvent = (kind) => !eventTypes || eventTypes.includes(kind);
64519
+ const hasBounds = fromTimestamp !== void 0 || toTimestamp !== void 0 || fromBlock !== void 0 || toBlock !== void 0;
64520
+ const pageSize = hasBounds ? THE_GRAPH_MAX_BATCH_SIZE : limit;
64521
+ const buildPositionWhereClause = () => `where: { position: "${positionId.toLowerCase()}" }`;
63254
64522
  const shouldQuery = {
63255
- positionCreated: !eventTypes || eventTypes.includes("positionCreated"),
63256
- payment: !eventTypes || eventTypes.includes("payment"),
63257
- status: !eventTypes || eventTypes.includes("status"),
63258
- liquidation: !eventTypes || eventTypes.includes("liquidation"),
63259
- mint: !eventTypes || eventTypes.includes("mint"),
63260
- withdrawal: !eventTypes || eventTypes.includes("withdrawal"),
63261
- renewal: !eventTypes || eventTypes.includes("renewal"),
63262
- operationFailure: !eventTypes || eventTypes.includes("operationFailure"),
63263
- mintRequest: !eventTypes || eventTypes.includes("mintRequest"),
63264
- burnRequest: !eventTypes || eventTypes.includes("burnRequest"),
63265
- collateralEvent: !eventTypes || eventTypes.includes("collateralEvent"),
63266
- mintingFee: !eventTypes || eventTypes.includes("mintingFee"),
63267
- renewalFee: !eventTypes || eventTypes.includes("renewalFee")
63268
- };
63269
- const buildPositionWhereClause = () => {
63270
- const conditions = [`position: "${positionId.toLowerCase()}"`];
63271
- if (fromTimestamp)
63272
- conditions.push(`timestamp_gte: "${fromTimestamp}"`);
63273
- if (toTimestamp)
63274
- conditions.push(`timestamp_lte: "${toTimestamp}"`);
63275
- if (fromBlock)
63276
- conditions.push(`blockNumber_gte: "${fromBlock}"`);
63277
- if (toBlock)
63278
- conditions.push(`blockNumber_lte: "${toBlock}"`);
63279
- return `where: { ${conditions.join(", ")} }`;
64523
+ positionCreated: true,
64524
+ payment: true,
64525
+ status: true,
64526
+ liquidation: true,
64527
+ mint: true,
64528
+ withdrawal: true,
64529
+ renewal: true,
64530
+ operationFailure: true,
64531
+ mintRequest: true,
64532
+ burnRequest: true,
64533
+ collateralEvent: true,
64534
+ mintingFee: true,
64535
+ renewalFee: true
63280
64536
  };
63281
64537
  const query = `
63282
64538
  query GetLoanEvents($positionId: Bytes!, $limit: Int!, $orderDirection: OrderDirection!) {
@@ -63512,10 +64768,50 @@ var DiamondHandsGraph = class {
63512
64768
  `;
63513
64769
  const variables = {
63514
64770
  positionId: positionId.toLowerCase(),
63515
- limit,
64771
+ limit: pageSize,
63516
64772
  orderDirection
63517
64773
  };
63518
64774
  const result = await this.client.execute(query, variables);
64775
+ if (hasBounds) {
64776
+ const collections = [
64777
+ ["payments", result.position?.payments],
64778
+ ["statusUpdates", result.position?.statusUpdates],
64779
+ ["withdrawals", result.position?.withdrawals],
64780
+ ["renewals", result.position?.renewals],
64781
+ ["operationFailures", result.position?.operationFailures],
64782
+ ["mintRequests", result.position?.mintRequests],
64783
+ ["burnRequests", result.position?.burnRequests],
64784
+ ["mintingFees", result.position?.mintingFees],
64785
+ ["renewalFees", result.position?.renewalFees],
64786
+ ["mints", result.ucdmintEvents],
64787
+ ["collateralEvents", result.collateralEvents]
64788
+ ];
64789
+ const saturated = collections.filter(([, list]) => (list?.length ?? 0) >= pageSize).map(([name]) => name);
64790
+ if (saturated.length > 0) {
64791
+ log.warn(
64792
+ "[DiamondHandsGraph] bounded getLoanEvents page saturated \u2014 the filtered history may be incomplete",
64793
+ { positionId, pageSize, saturated }
64794
+ );
64795
+ }
64796
+ }
64797
+ const assembled = this.assembleLoanEvents(positionId, result);
64798
+ return applyLoanEventsFilter(assembled, {
64799
+ wantsEvent,
64800
+ fromTimestamp,
64801
+ toTimestamp,
64802
+ fromBlock,
64803
+ toBlock,
64804
+ limit
64805
+ });
64806
+ }
64807
+ /**
64808
+ * Map one position's raw event payload into `LoanEvents`.
64809
+ *
64810
+ * Extracted verbatim from getLoanEvents so the wallet-collapsed path produces
64811
+ * byte-identical objects by construction rather than by a second implementation
64812
+ * that has to be kept in step by hand.
64813
+ */
64814
+ assembleLoanEvents(positionId, result) {
63519
64815
  const rawCreated = result.positionCreatedEvents?.[0];
63520
64816
  const positionCreated = rawCreated ? {
63521
64817
  id: rawCreated.id,
@@ -63720,7 +65016,22 @@ var DiamondHandsGraph = class {
63720
65016
  * @returns One LoanEvents object per position; empty array if the wallet has none.
63721
65017
  */
63722
65018
  async getWalletLoanEvents(userAddress, filter2) {
63723
- const { positions } = await this.getUserPositions(userAddress);
65019
+ if (!hasLoanEventsFilter(filter2)) {
65020
+ return this.getWalletLoanEventsCollapsed(userAddress);
65021
+ }
65022
+ return this.getWalletLoanEventsFanout(userAddress, filter2);
65023
+ }
65024
+ /**
65025
+ * The per-position path: enumerate the wallet's positions, then one `GetLoanEvents` each.
65026
+ *
65027
+ * Used for filtered calls, and as the completeness fallback when the collapsed document
65028
+ * hits a page limit. Costs `1 + N` requests, which is exactly why it is not the default.
65029
+ */
65030
+ async getWalletLoanEventsFanout(userAddress, filter2) {
65031
+ const positions = await this.getUserPositionsOnly(
65032
+ userAddress,
65033
+ THE_GRAPH_MAX_BATCH_SIZE
65034
+ );
63724
65035
  const positionIds = positions.map((p) => p?.id != null ? String(p.id) : "").filter((id) => id.length > 0);
63725
65036
  if (positionIds.length === 0)
63726
65037
  return [];
@@ -63735,6 +65046,81 @@ var DiamondHandsGraph = class {
63735
65046
  }
63736
65047
  return results;
63737
65048
  }
65049
+ /**
65050
+ * The whole wallet's event history in ONE request.
65051
+ *
65052
+ * Replaces `1 + N` round trips (one position enumeration plus one per position) with a
65053
+ * single document. Measured on Sepolia: a wallet holding 44 positions cost 46 requests
65054
+ * per activity refresh against a per-wallet budget of 30/min — this makes it 1.
65055
+ *
65056
+ * Three subgraph facts make it possible, all verified against the deployed schema rather
65057
+ * than assumed:
65058
+ * - ten event collections are `@derivedFrom` on Position, so they nest under a
65059
+ * borrower-filtered `positions(...)`;
65060
+ * - `positionCreatedEvents` is ALSO derived on Position — `getLoanEvents` queries it
65061
+ * top-level, which it never needed to;
65062
+ * - `ucdmintEvents` / `collateralEvents` are not derived and carry no `borrower`
65063
+ * field, but graph-node's nested `position_: { borrower }` filter reaches them.
65064
+ * Without that last one this would be two requests, not one.
65065
+ */
65066
+ async getWalletLoanEventsCollapsed(userAddress) {
65067
+ const borrower = userAddress.toLowerCase();
65068
+ const pageSize = THE_GRAPH_MAX_BATCH_SIZE;
65069
+ const result = await this.client.execute(
65070
+ WALLET_LOAN_EVENTS_QUERY,
65071
+ {
65072
+ borrower,
65073
+ first: pageSize,
65074
+ limit: pageSize,
65075
+ orderDirection: "desc"
65076
+ }
65077
+ );
65078
+ const positions = result.positions || [];
65079
+ const ucdmintEvents = result.ucdmintEvents || [];
65080
+ const collateralEvents = result.collateralEvents || [];
65081
+ const truncated = positions.length >= pageSize || ucdmintEvents.length >= pageSize || collateralEvents.length >= pageSize;
65082
+ if (truncated) {
65083
+ log.warn(
65084
+ "[DiamondHandsGraph] wallet event page limit reached \u2014 falling back to the per-position path to avoid returning a partial history",
65085
+ {
65086
+ borrower,
65087
+ pageSize,
65088
+ positions: positions.length,
65089
+ ucdmintEvents: ucdmintEvents.length,
65090
+ collateralEvents: collateralEvents.length
65091
+ }
65092
+ );
65093
+ return this.getWalletLoanEventsFanout(userAddress);
65094
+ }
65095
+ if (positions.length === 0)
65096
+ return [];
65097
+ const mintsByPosition = /* @__PURE__ */ new Map();
65098
+ for (const m of result.ucdmintEvents || []) {
65099
+ const key = m.position?.id;
65100
+ if (!key)
65101
+ continue;
65102
+ const bucket = mintsByPosition.get(key) || [];
65103
+ bucket.push(m);
65104
+ mintsByPosition.set(key, bucket);
65105
+ }
65106
+ const collateralByPosition = /* @__PURE__ */ new Map();
65107
+ for (const c of result.collateralEvents || []) {
65108
+ const key = c.position?.id;
65109
+ if (!key)
65110
+ continue;
65111
+ const bucket = collateralByPosition.get(key) || [];
65112
+ bucket.push(c);
65113
+ collateralByPosition.set(key, bucket);
65114
+ }
65115
+ return positions.map(
65116
+ (p) => this.assembleLoanEvents(p.id, {
65117
+ position: p,
65118
+ positionCreatedEvents: p.positionCreatedEvents || [],
65119
+ ucdmintEvents: mintsByPosition.get(p.id) || [],
65120
+ collateralEvents: collateralByPosition.get(p.id) || []
65121
+ })
65122
+ );
65123
+ }
63738
65124
  // ============================================================================
63739
65125
  // Protocol-wide Events
63740
65126
  // ============================================================================
@@ -68594,16 +69980,6 @@ function createMockTokenManager(config) {
68594
69980
  }
68595
69981
  }
68596
69982
  var import_dh_lit_actions2 = __toESM2(require_pkg_src2());
68597
- var TelegramBot = null;
68598
- try {
68599
- if (typeof window === "undefined" && typeof global !== "undefined") {
68600
- TelegramBot = null /* stubbed post-build: dh-mcp never uses telegram (F-PUB-2) */;
68601
- }
68602
- } catch (error) {
68603
- log.warn("Telegram bot API not available", {
68604
- error: error instanceof Error ? error.message : String(error)
68605
- });
68606
- }
68607
69983
  function formatMintMessage(mintAmount, loanId, txHash) {
68608
69984
  return `\u2705 DH SDK: ${mintAmount} UCD was minted for loan id: ${loanId} Tx: https://sepolia.etherscan.io/tx/${txHash}`;
68609
69985
  }
@@ -69229,7 +70605,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
69229
70605
  persistSession: config.sessionPersistence?.enabled,
69230
70606
  sessionStore: config.sessionPersistence?.store,
69231
70607
  onSignaturePrompt: config.onSessionSignaturePrompt,
69232
- onSignatureResolved: config.onSessionSignatureResolved
70608
+ onSignatureResolved: config.onSessionSignatureResolved,
70609
+ onSessionRestored: config.onSessionRestored
69233
70610
  });
69234
70611
  }
69235
70612
  const contractManagerResult = createContractManager({
@@ -82559,7 +83936,7 @@ mime-types/index.js:
82559
83936
  *)
82560
83937
 
82561
83938
  axios/dist/node/axios.cjs:
82562
- (*! Axios v1.19.0 Copyright (c) 2026 Matt Zabriskie and contributors *)
83939
+ (*! Axios v1.20.0 Copyright (c) 2026 Matt Zabriskie and contributors *)
82563
83940
 
82564
83941
  safe-buffer/index.js:
82565
83942
  (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)