@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/boundary.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
  });
@@ -45018,22 +45503,82 @@ var { toString } = Object.prototype;
45018
45503
  var { getPrototypeOf } = Object;
45019
45504
  var { iterator, toStringTag } = Symbol;
45020
45505
  var hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
45506
+ var isUnsafeObjectKey = (prop) => typeof prop === "string" && (prop === "__proto__" || prop === "constructor" || prop === "prototype");
45507
+ var isPrototypeBoundary = (obj, prototype2, source) => obj === Object.prototype || !source && prototype2 === null;
45508
+ var isSafeAndFullyMutable = (obj) => {
45509
+ if (!Object.isExtensible(obj)) {
45510
+ return false;
45511
+ }
45512
+ const props = Object.getOwnPropertyNames(obj);
45513
+ if (Object.getOwnPropertySymbols) {
45514
+ props.push(...Object.getOwnPropertySymbols(obj));
45515
+ }
45516
+ return props.every((prop) => {
45517
+ if (isUnsafeObjectKey(prop)) {
45518
+ return false;
45519
+ }
45520
+ const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
45521
+ return !!descriptor && descriptor.configurable && descriptor.writable === true;
45522
+ });
45523
+ };
45021
45524
  var hasOwnInPrototypeChain = (thing, prop) => {
45022
45525
  let obj = thing;
45023
45526
  const seen = [];
45024
- while (obj != null && obj !== Object.prototype) {
45527
+ while (obj != null) {
45025
45528
  if (seen.indexOf(obj) !== -1) {
45026
45529
  return false;
45027
45530
  }
45028
45531
  seen.push(obj);
45532
+ const prototype2 = getPrototypeOf(obj);
45533
+ if (isPrototypeBoundary(obj, prototype2, obj === thing)) {
45534
+ return false;
45535
+ }
45029
45536
  if (hasOwnProperty(obj, prop)) {
45030
45537
  return true;
45031
45538
  }
45032
- obj = getPrototypeOf(obj);
45539
+ obj = prototype2;
45033
45540
  }
45034
45541
  return false;
45035
45542
  };
45036
45543
  var getSafeProp = (obj, prop) => obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : void 0;
45544
+ var toSafeFlatObject = (thing) => {
45545
+ if (thing == null || typeof thing !== "object" && typeof thing !== "function") {
45546
+ return thing;
45547
+ }
45548
+ const sourcePrototype = getPrototypeOf(thing);
45549
+ if (sourcePrototype === null && isSafeAndFullyMutable(thing)) {
45550
+ return thing;
45551
+ }
45552
+ const result = /* @__PURE__ */ Object.create(null);
45553
+ const merged = /* @__PURE__ */ Object.create(null);
45554
+ const seen = [];
45555
+ let current = thing;
45556
+ while (current != null) {
45557
+ if (seen.indexOf(current) !== -1) {
45558
+ break;
45559
+ }
45560
+ seen.push(current);
45561
+ const prototype2 = current === thing ? sourcePrototype : getPrototypeOf(current);
45562
+ if (isPrototypeBoundary(current, prototype2, current === thing)) {
45563
+ break;
45564
+ }
45565
+ const props = Object.getOwnPropertyNames(current);
45566
+ if (Object.getOwnPropertySymbols) {
45567
+ props.push(...Object.getOwnPropertySymbols(current));
45568
+ }
45569
+ for (const prop of props) {
45570
+ if (isUnsafeObjectKey(prop)) {
45571
+ continue;
45572
+ }
45573
+ if (!hasOwnProperty(merged, prop)) {
45574
+ result[prop] = thing[prop];
45575
+ merged[prop] = true;
45576
+ }
45577
+ }
45578
+ current = prototype2;
45579
+ }
45580
+ return result;
45581
+ };
45037
45582
  var kindOf = /* @__PURE__ */ ((cache) => (thing) => {
45038
45583
  const str = toString.call(thing);
45039
45584
  return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
@@ -45068,9 +45613,9 @@ var isPlainObject = (val) => {
45068
45613
  return false;
45069
45614
  }
45070
45615
  const prototype2 = getPrototypeOf(val);
45071
- return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat any genuine (non-Object.prototype-polluted) Symbol.toStringTag or
45072
- // Symbol.iterator as evidence the value is a tagged/iterable type rather
45073
- // than a plain object, while ignoring keys injected onto Object.prototype.
45616
+ return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat safe own/inherited Symbol.toStringTag or Symbol.iterator members as
45617
+ // evidence the value is tagged/iterable, while ignoring members reachable
45618
+ // only through shared or terminal prototype boundaries.
45074
45619
  !hasOwnInPrototypeChain(val, toStringTag) && !hasOwnInPrototypeChain(val, iterator);
45075
45620
  };
45076
45621
  var isEmptyObject = (val) => {
@@ -45481,6 +46026,7 @@ var utils_default = {
45481
46026
  // an alias to avoid ESLint no-prototype-builtins detection
45482
46027
  hasOwnInPrototypeChain,
45483
46028
  getSafeProp,
46029
+ toSafeFlatObject,
45484
46030
  reduceDescriptors,
45485
46031
  freezeMethods,
45486
46032
  toObjectSet,
@@ -46119,24 +46665,16 @@ function toFormData(obj, formData, options) {
46119
46665
  throw new TypeError("target must be an object");
46120
46666
  }
46121
46667
  formData = formData || new (FormData_default || FormData)();
46122
- options = utils_default.toFlatObject(
46123
- options,
46124
- {
46125
- metaTokens: true,
46126
- dots: false,
46127
- indexes: false
46128
- },
46129
- false,
46130
- function defined(option, source) {
46131
- return !utils_default.isUndefined(source[option]);
46132
- }
46133
- );
46134
- const metaTokens = options.metaTokens;
46135
- const visitor = options.visitor || defaultVisitor;
46136
- const dots = options.dots;
46137
- const indexes = options.indexes;
46138
- const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
46139
- const maxDepth = options.maxDepth === void 0 ? DEFAULT_FORM_DATA_MAX_DEPTH : options.maxDepth;
46668
+ const option = (name, fallback) => {
46669
+ const value = utils_default.getSafeProp(options, name);
46670
+ return utils_default.isUndefined(value) ? fallback : value;
46671
+ };
46672
+ const metaTokens = option("metaTokens", true);
46673
+ const visitor = option("visitor") || defaultVisitor;
46674
+ const dots = option("dots", false);
46675
+ const indexes = option("indexes", false);
46676
+ const _Blob = option("Blob") || typeof Blob !== "undefined" && Blob;
46677
+ const maxDepth = option("maxDepth", DEFAULT_FORM_DATA_MAX_DEPTH);
46140
46678
  const useBlob = _Blob && utils_default.isSpecCompliantForm(formData);
46141
46679
  const stack = [];
46142
46680
  if (!utils_default.isFunction(visitor)) {
@@ -46160,7 +46698,10 @@ function toFormData(obj, formData, options) {
46160
46698
  if (Buffer_default && Buffer_default.isBufferAvailable()) {
46161
46699
  return Buffer_default.from(value);
46162
46700
  }
46163
- throw new AxiosError_default("Blob is not supported. Use a Buffer instead.", AxiosError_default.ERR_NOT_SUPPORT);
46701
+ throw new AxiosError_default(
46702
+ "Blob is not supported. Use a Buffer instead.",
46703
+ AxiosError_default.ERR_NOT_SUPPORT
46704
+ );
46164
46705
  }
46165
46706
  return value;
46166
46707
  }
@@ -46306,9 +46847,47 @@ function buildURL(url2, params, options) {
46306
46847
  }
46307
46848
 
46308
46849
  // node_modules/axios/lib/core/InterceptorManager.js
46850
+ var $internals2 = Symbol("internals");
46851
+ function countHandlers(handlers) {
46852
+ return handlers ? handlers.length : 0;
46853
+ }
46854
+ function trimHandlers(handlers) {
46855
+ if (!handlers) {
46856
+ return;
46857
+ }
46858
+ while (handlers.length && handlers[handlers.length - 1] === null) {
46859
+ handlers.pop();
46860
+ }
46861
+ }
46862
+ function syncHandlerEntries(manager, internals) {
46863
+ const handlers = manager.handlers;
46864
+ const length = countHandlers(handlers);
46865
+ if (handlers !== internals.handlersRef) {
46866
+ internals.handlersRef = handlers;
46867
+ internals.handlerEntries.clear();
46868
+ } else if (length !== internals.handlersLength) {
46869
+ if (!length) {
46870
+ internals.handlerEntries.clear();
46871
+ } else {
46872
+ internals.handlerEntries.forEach(function removeStaleEntry(entry, id) {
46873
+ if (handlers[entry.index] !== entry.handler) {
46874
+ internals.handlerEntries.delete(id);
46875
+ }
46876
+ });
46877
+ }
46878
+ }
46879
+ internals.handlersLength = length;
46880
+ }
46309
46881
  var InterceptorManager = class {
46310
46882
  constructor() {
46311
46883
  this.handlers = [];
46884
+ this[$internals2] = {
46885
+ handlersRef: this.handlers,
46886
+ handlersLength: this.handlers.length,
46887
+ handlerEntries: /* @__PURE__ */ new Map(),
46888
+ iterationDepth: 0,
46889
+ nextId: 0
46890
+ };
46312
46891
  }
46313
46892
  /**
46314
46893
  * Add a new interceptor to the stack
@@ -46320,13 +46899,25 @@ var InterceptorManager = class {
46320
46899
  * @return {Number} An ID used to remove interceptor later
46321
46900
  */
46322
46901
  use(fulfilled, rejected, options) {
46323
- this.handlers.push({
46902
+ const handler = {
46324
46903
  fulfilled,
46325
46904
  rejected,
46326
46905
  synchronous: options ? options.synchronous : false,
46327
46906
  runWhen: options ? options.runWhen : null
46907
+ };
46908
+ const internals = this[$internals2];
46909
+ if (this.handlers == null) {
46910
+ this.handlers = [];
46911
+ }
46912
+ syncHandlerEntries(this, internals);
46913
+ const id = internals.nextId++;
46914
+ this.handlers.push(handler);
46915
+ internals.handlerEntries.set(id, {
46916
+ handler,
46917
+ index: this.handlers.length - 1
46328
46918
  });
46329
- return this.handlers.length - 1;
46919
+ internals.handlersLength = this.handlers.length;
46920
+ return id;
46330
46921
  }
46331
46922
  /**
46332
46923
  * Remove an interceptor from the stack
@@ -46336,8 +46927,19 @@ var InterceptorManager = class {
46336
46927
  * @returns {void}
46337
46928
  */
46338
46929
  eject(id) {
46339
- if (this.handlers[id]) {
46340
- this.handlers[id] = null;
46930
+ const internals = this[$internals2];
46931
+ syncHandlerEntries(this, internals);
46932
+ const entry = internals.handlerEntries.get(id);
46933
+ if (entry) {
46934
+ internals.handlerEntries.delete(id);
46935
+ if (this.handlers[entry.index] !== entry.handler) {
46936
+ return;
46937
+ }
46938
+ this.handlers[entry.index] = null;
46939
+ if (!internals.iterationDepth) {
46940
+ trimHandlers(this.handlers);
46941
+ internals.handlersLength = this.handlers.length;
46942
+ }
46341
46943
  }
46342
46944
  }
46343
46945
  /**
@@ -46348,6 +46950,7 @@ var InterceptorManager = class {
46348
46950
  clear() {
46349
46951
  if (this.handlers) {
46350
46952
  this.handlers = [];
46953
+ syncHandlerEntries(this, this[$internals2]);
46351
46954
  }
46352
46955
  }
46353
46956
  /**
@@ -46361,11 +46964,22 @@ var InterceptorManager = class {
46361
46964
  * @returns {void}
46362
46965
  */
46363
46966
  forEach(fn) {
46364
- utils_default.forEach(this.handlers, function forEachHandler(h) {
46365
- if (h !== null) {
46366
- fn(h);
46967
+ const internals = this[$internals2];
46968
+ syncHandlerEntries(this, internals);
46969
+ internals.iterationDepth++;
46970
+ try {
46971
+ utils_default.forEach(this.handlers, function forEachHandler(h) {
46972
+ if (h !== null) {
46973
+ fn(h);
46974
+ }
46975
+ });
46976
+ } finally {
46977
+ if (!--internals.iterationDepth) {
46978
+ syncHandlerEntries(this, internals);
46979
+ trimHandlers(this.handlers);
46980
+ internals.handlersLength = countHandlers(this.handlers);
46367
46981
  }
46368
- });
46982
+ }
46369
46983
  }
46370
46984
  };
46371
46985
  var InterceptorManager_default = InterceptorManager;
@@ -46523,6 +47137,22 @@ function formDataToJSON(formData) {
46523
47137
  }
46524
47138
  var formDataToJSON_default = formDataToJSON;
46525
47139
 
47140
+ // node_modules/axios/lib/core/methodList.js
47141
+ var methodList = Object.freeze([
47142
+ "get",
47143
+ "delete",
47144
+ "head",
47145
+ "options",
47146
+ "post",
47147
+ "put",
47148
+ "patch",
47149
+ "purge",
47150
+ "link",
47151
+ "unlink",
47152
+ "query"
47153
+ ]);
47154
+ var methodList_default = methodList;
47155
+
46526
47156
  // node_modules/axios/lib/defaults/index.js
46527
47157
  var own = (obj, key) => obj != null && utils_default.hasOwnProp(obj, key) ? obj[key] : void 0;
46528
47158
  function stringifySafely2(rawValue, parser, encoder) {
@@ -46635,7 +47265,7 @@ var defaults = {
46635
47265
  }
46636
47266
  }
46637
47267
  };
46638
- utils_default.forEach(["delete", "get", "head", "post", "put", "patch", "query"], (method) => {
47268
+ utils_default.forEach(methodList_default, (method) => {
46639
47269
  defaults.headers[method] = {};
46640
47270
  });
46641
47271
  var defaults_default = defaults;
@@ -46713,19 +47343,21 @@ function combineURLs(baseURL, relativeURL) {
46713
47343
  return baseURL.slice(0, end) + "/" + relativeURL.replace(/^\/+/, "");
46714
47344
  }
46715
47345
 
46716
- // node_modules/axios/lib/core/buildFullPath.js
46717
- var malformedHttpProtocol = /^https?:(?!\/\/)/i;
46718
- var httpProtocolControlCharacters = /[\t\n\r]/g;
46719
- function stripLeadingC0ControlOrSpace(url2) {
46720
- let i = 0;
46721
- while (i < url2.length && url2.charCodeAt(i) <= 32) {
46722
- i++;
46723
- }
46724
- return url2.slice(i);
46725
- }
47346
+ // node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js
47347
+ var urlParserControlCharacters = /[\t\n\r]/g;
46726
47348
  function normalizeURLForProtocolCheck(url2) {
46727
- return stripLeadingC0ControlOrSpace(url2).replace(httpProtocolControlCharacters, "");
47349
+ if (typeof url2 !== "string") {
47350
+ return url2;
47351
+ }
47352
+ let start = 0;
47353
+ while (start < url2.length && url2.charCodeAt(start) <= 32) {
47354
+ start++;
47355
+ }
47356
+ return url2.slice(start).replace(urlParserControlCharacters, "");
46728
47357
  }
47358
+
47359
+ // node_modules/axios/lib/core/buildFullPath.js
47360
+ var malformedHttpProtocol = /^https?:(?!\/\/)/i;
46729
47361
  function redactFragment(fragment) {
46730
47362
  if (!fragment) {
46731
47363
  return fragment;
@@ -46847,7 +47479,7 @@ var import_follow_redirects = __toESM(require_follow_redirects(), 1);
46847
47479
  var import_zlib = __toESM(require("zlib"), 1);
46848
47480
 
46849
47481
  // node_modules/axios/lib/env/data.js
46850
- var VERSION = "1.19.0";
47482
+ var VERSION = "1.20.0";
46851
47483
 
46852
47484
  // node_modules/axios/lib/helpers/parseProtocol.js
46853
47485
  function parseProtocol(url2) {
@@ -46856,7 +47488,7 @@ function parseProtocol(url2) {
46856
47488
  }
46857
47489
 
46858
47490
  // node_modules/axios/lib/helpers/fromDataURI.js
46859
- var DATA_URL_PATTERN = /^([^,;]+\/[^,;]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
47491
+ var DATA_URL_PATTERN = /^([^,;/]+\/[^,;/]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
46860
47492
  function fromDataURI(uri, asBlob, options) {
46861
47493
  const _Blob = options && options.Blob || platform_default.classes.Blob;
46862
47494
  const protocol = parseProtocol(uri);
@@ -47169,6 +47801,7 @@ var Http2Sessions = class {
47169
47801
  }
47170
47802
  getSession(authority, options) {
47171
47803
  options = Object.assign(
47804
+ /* @__PURE__ */ Object.create(null),
47172
47805
  {
47173
47806
  sessionTimeout: 1e3
47174
47807
  },
@@ -47234,6 +47867,7 @@ var Http2Sessions = class {
47234
47867
  };
47235
47868
  }
47236
47869
  session.once("close", removeSession);
47870
+ session.once("error", removeSession);
47237
47871
  let entry = [session, options];
47238
47872
  authoritySessions ? authoritySessions.push(entry) : authoritySessions = this.sessions[authority] = [entry];
47239
47873
  return session;
@@ -47258,6 +47892,13 @@ var callbackify_default = callbackify;
47258
47892
 
47259
47893
  // node_modules/axios/lib/helpers/shouldBypassProxy.js
47260
47894
  var LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["localhost", "0.0.0.0"]);
47895
+ var trimTrailingDots = (value) => {
47896
+ let end = value.length;
47897
+ while (end && value.charCodeAt(end - 1) === 46) {
47898
+ end--;
47899
+ }
47900
+ return end === value.length ? value : value.slice(0, end);
47901
+ };
47261
47902
  var isIPv4Loopback = (host) => {
47262
47903
  const parts = host.split(".");
47263
47904
  if (parts.length !== 4) return false;
@@ -47290,7 +47931,7 @@ var normalizeIPAddress = (host) => {
47290
47931
  if (h.charAt(0) === "[" && h.charAt(h.length - 1) === "]") {
47291
47932
  h = h.slice(1, -1);
47292
47933
  }
47293
- h = h.replace(/\.+$/, "");
47934
+ h = trimTrailingDots(h);
47294
47935
  if (!/^[0-9.xXa-fA-F]+$/.test(h)) return host;
47295
47936
  const parts = h.split(".");
47296
47937
  if (parts.some((p) => p === "")) return host;
@@ -47402,6 +48043,40 @@ var unmapIPv4MappedIPv6 = (host) => {
47402
48043
  }
47403
48044
  return host;
47404
48045
  };
48046
+ var IPV4_OCTET_RE = /^(?:0|[1-9]\d{0,2})$/;
48047
+ var ipv4ToBytes = (host) => {
48048
+ const parts = host.split(".");
48049
+ return parts.length === 4 && parts.every((part) => IPV4_OCTET_RE.test(part) && Number(part) <= 255) ? parts.map(Number) : null;
48050
+ };
48051
+ var IPV6_GROUP_RE = /^[0-9a-f]{1,4}$/i;
48052
+ var ipv6ToBytes = (host) => {
48053
+ const halves = host.split("::");
48054
+ if (halves.length > 2) {
48055
+ return null;
48056
+ }
48057
+ const groups = halves[0] ? halves[0].split(":") : [];
48058
+ if (halves.length === 2) {
48059
+ const rear = halves[1] ? halves[1].split(":") : [];
48060
+ const missing = 8 - groups.length - rear.length;
48061
+ if (missing < 1) {
48062
+ return null;
48063
+ }
48064
+ groups.push(...new Array(missing).fill("0"), ...rear);
48065
+ }
48066
+ if (groups.length !== 8 || groups.some((group) => !IPV6_GROUP_RE.test(group))) {
48067
+ return null;
48068
+ }
48069
+ return groups.flatMap((group) => {
48070
+ const value = Number.parseInt(group, 16);
48071
+ return [value >> 8 & 255, value & 255];
48072
+ });
48073
+ };
48074
+ var ipToBytes = (host) => {
48075
+ if (typeof host !== "string" || !host) {
48076
+ return null;
48077
+ }
48078
+ return host.indexOf(":") !== -1 ? ipv6ToBytes(host) : ipv4ToBytes(host);
48079
+ };
47405
48080
  var normalizeNoProxyHost = (hostname) => {
47406
48081
  if (!hostname) {
47407
48082
  return hostname;
@@ -47409,13 +48084,90 @@ var normalizeNoProxyHost = (hostname) => {
47409
48084
  if (hostname.charAt(0) === "[" && hostname.charAt(hostname.length - 1) === "]") {
47410
48085
  hostname = hostname.slice(1, -1);
47411
48086
  }
47412
- const trimmed = hostname.replace(/\.+$/, "");
48087
+ const trimmed = trimTrailingDots(hostname);
47413
48088
  const ipv4 = normalizeIPAddress(trimmed);
47414
48089
  if (ipv4 !== trimmed) {
47415
48090
  return ipv4;
47416
48091
  }
47417
48092
  return unmapIPv4MappedIPv6(trimmed);
47418
48093
  };
48094
+ var normalizeCidrBase = (input) => {
48095
+ let base = input;
48096
+ const startsBracket = base.charAt(0) === "[";
48097
+ const endsBracket = base.charAt(base.length - 1) === "]";
48098
+ const hasBracket = base.includes("[") || base.includes("]");
48099
+ if (startsBracket || endsBracket) {
48100
+ if (!startsBracket || !endsBracket) {
48101
+ return null;
48102
+ }
48103
+ base = base.slice(1, -1);
48104
+ if (base.indexOf(":") === -1 || base.includes("[") || base.includes("]")) {
48105
+ return null;
48106
+ }
48107
+ } else if (hasBracket) {
48108
+ return null;
48109
+ }
48110
+ if (!base || base.charAt(base.length - 1) === ".") {
48111
+ return null;
48112
+ }
48113
+ const wasIPv6 = base.indexOf(":") !== -1;
48114
+ if (wasIPv6) {
48115
+ try {
48116
+ base = new URL(`http://[${base}]/`).hostname.slice(1, -1);
48117
+ } catch (_err) {
48118
+ return null;
48119
+ }
48120
+ } else {
48121
+ base = normalizeIPAddress(base);
48122
+ if (!ipv4ToBytes(base)) {
48123
+ return null;
48124
+ }
48125
+ }
48126
+ return { normalized: unmapIPv4MappedIPv6(base), wasIPv6 };
48127
+ };
48128
+ var CIDR_ENTRY_RE = /^(.+)\/(0|[1-9]\d{0,2})$/;
48129
+ var parseCidrEntry = (entry) => {
48130
+ if (entry.indexOf("/") === -1) {
48131
+ return void 0;
48132
+ }
48133
+ const match = CIDR_ENTRY_RE.exec(entry);
48134
+ if (!match) {
48135
+ return null;
48136
+ }
48137
+ let prefix = Number(match[2]);
48138
+ const parsedBase = normalizeCidrBase(match[1]);
48139
+ if (!parsedBase) {
48140
+ return null;
48141
+ }
48142
+ const { normalized, wasIPv6 } = parsedBase;
48143
+ if (wasIPv6 && normalized.indexOf(":") === -1) {
48144
+ if (prefix < 96) {
48145
+ return null;
48146
+ }
48147
+ prefix -= 96;
48148
+ }
48149
+ const bytes = ipToBytes(normalized);
48150
+ if (!bytes || prefix > bytes.length * 8) {
48151
+ return null;
48152
+ }
48153
+ return { bytes, prefix };
48154
+ };
48155
+ var isInSubnet = (addressBytes, networkBytes, prefix) => {
48156
+ const fullBytes = prefix >> 3;
48157
+ for (let i = 0; i < fullBytes; i++) {
48158
+ if (addressBytes[i] !== networkBytes[i]) {
48159
+ return false;
48160
+ }
48161
+ }
48162
+ const remainingBits = prefix & 7;
48163
+ if (remainingBits) {
48164
+ const mask = 255 << 8 - remainingBits & 255;
48165
+ if ((addressBytes[fullBytes] & mask) !== (networkBytes[fullBytes] & mask)) {
48166
+ return false;
48167
+ }
48168
+ }
48169
+ return true;
48170
+ };
47419
48171
  function shouldBypassProxy(location) {
47420
48172
  let parsed;
47421
48173
  try {
@@ -47432,6 +48184,7 @@ function shouldBypassProxy(location) {
47432
48184
  }
47433
48185
  const port = Number.parseInt(parsed.port, 10) || DEFAULT_PORTS2[parsed.protocol.split(":", 1)[0]] || 0;
47434
48186
  const hostname = normalizeNoProxyHost(parsed.hostname.toLowerCase());
48187
+ const hostnameBytes = ipToBytes(hostname);
47435
48188
  return noProxy.split(/[\s,]+/).some((entry) => {
47436
48189
  if (!entry) {
47437
48190
  return false;
@@ -47439,6 +48192,10 @@ function shouldBypassProxy(location) {
47439
48192
  if (entry === "*") {
47440
48193
  return true;
47441
48194
  }
48195
+ const cidr = parseCidrEntry(entry);
48196
+ if (cidr !== void 0) {
48197
+ return cidr !== null && !!hostnameBytes && hostnameBytes.length === cidr.bytes.length && isInSubnet(hostnameBytes, cidr.bytes, cidr.prefix);
48198
+ }
47442
48199
  let [entryHost, entryPort] = parseNoProxyEntry(entry);
47443
48200
  entryHost = normalizeNoProxyHost(entryHost);
47444
48201
  if (!entryHost) {
@@ -47524,7 +48281,8 @@ function throttle(fn, freq) {
47524
48281
  }
47525
48282
  };
47526
48283
  const flush = () => lastArgs && invoke(lastArgs);
47527
- return [throttled, flush];
48284
+ const flushWith = (...args) => invoke(args);
48285
+ return [throttled, flush, flushWith];
47528
48286
  }
47529
48287
  var throttle_default = throttle;
47530
48288
 
@@ -47533,7 +48291,7 @@ var progressEventReducer = (listener, isDownloadStream, freq = 3) => {
47533
48291
  let bytesNotified = 0;
47534
48292
  const _speedometer = speedometer_default(50, 250);
47535
48293
  return throttle_default((e) => {
47536
- if (!e || typeof e.loaded !== "number") {
48294
+ if (!e || !utils_default.isNumber(e.loaded)) {
47537
48295
  return;
47538
48296
  }
47539
48297
  const rawLoaded = e.loaded;
@@ -47694,6 +48452,12 @@ var { http: httpFollow, https: httpsFollow } = import_follow_redirects.default;
47694
48452
  var isHttps = /https:?/;
47695
48453
  var kAxiosSocketListener = Symbol("axios.http.socketListener");
47696
48454
  var kAxiosCurrentReq = Symbol("axios.http.currentReq");
48455
+ function handleSocketError(err) {
48456
+ const current = this[kAxiosCurrentReq];
48457
+ if (current && !current.destroyed) {
48458
+ current.destroy(err);
48459
+ }
48460
+ }
47697
48461
  var kAxiosInstalledTunnel = Symbol("axios.http.installedTunnel");
47698
48462
  var tunnelingAgentCache = /* @__PURE__ */ new Map();
47699
48463
  var tunnelingAgentCacheUser = /* @__PURE__ */ new WeakMap();
@@ -47796,10 +48560,10 @@ function isSameOriginRedirect(redirectOptions, requestDetails) {
47796
48560
  return false;
47797
48561
  }
47798
48562
  }
47799
- function setProxy(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent) {
48563
+ function setProxy(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent, allowEnvProxy = true) {
47800
48564
  let proxy = configProxy;
47801
48565
  const proxyEnvAgent = getProxyEnvAgent(options, configHttpAgent, configHttpsAgent);
47802
- if (!proxy && proxy !== false && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
48566
+ if (!proxy && proxy !== false && allowEnvProxy && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
47803
48567
  const proxyUrl = getProxyForUrl(location);
47804
48568
  if (proxyUrl) {
47805
48569
  if (!shouldBypassProxy(location)) {
@@ -47896,9 +48660,13 @@ function setProxy(options, configProxy, location, isRedirect, configHttpsAgent,
47896
48660
  redirectOptions.href,
47897
48661
  true,
47898
48662
  configHttpsAgent,
47899
- configHttpAgent
48663
+ configHttpAgent,
48664
+ allowEnvProxy
47900
48665
  );
47901
48666
  };
48667
+ return Boolean(
48668
+ proxy || configProxy !== false && allowEnvProxy && isNodeEnvProxyEnabled(proxyEnvAgent)
48669
+ );
47902
48670
  }
47903
48671
  var isHttpAdapterSupported = typeof process !== "undefined" && utils_default.kindOf(process) === "process";
47904
48672
  var wrapAsync = (asyncExecutor) => {
@@ -47923,7 +48691,7 @@ var wrapAsync = (asyncExecutor) => {
47923
48691
  };
47924
48692
  var resolveFamily = ({ address, family }) => {
47925
48693
  if (!utils_default.isString(address)) {
47926
- throw TypeError("address must be a string");
48694
+ throw new AxiosError_default("address must be a string", AxiosError_default.ERR_BAD_OPTION_VALUE);
47927
48695
  }
47928
48696
  return {
47929
48697
  address,
@@ -47931,6 +48699,30 @@ var resolveFamily = ({ address, family }) => {
47931
48699
  };
47932
48700
  };
47933
48701
  var buildAddressEntry = (address, family) => resolveFamily(utils_default.isObject(address) ? address : { address, family });
48702
+ var normalizedLookupCache = /* @__PURE__ */ new WeakMap();
48703
+ var normalizeLookup = (lookup) => {
48704
+ let normalized = normalizedLookupCache.get(lookup);
48705
+ if (normalized) {
48706
+ return normalized;
48707
+ }
48708
+ const callbackLookup = callbackify_default(lookup, (value) => utils_default.isArray(value) ? value : [value]);
48709
+ normalized = (hostname, opt, cb) => {
48710
+ callbackLookup(hostname, opt, (err, arg0, arg1) => {
48711
+ if (err) {
48712
+ return cb(err);
48713
+ }
48714
+ let addresses;
48715
+ try {
48716
+ addresses = utils_default.isArray(arg0) ? arg0.map((addr) => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
48717
+ } catch (error) {
48718
+ return cb(error);
48719
+ }
48720
+ opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
48721
+ });
48722
+ };
48723
+ normalizedLookupCache.set(lookup, normalized);
48724
+ return normalized;
48725
+ };
47934
48726
  var http2Transport = {
47935
48727
  request(options, cb) {
47936
48728
  const authority = options.protocol + "//" + options.hostname + ":" + (options.port || (options.protocol === "https:" ? 443 : 80));
@@ -47967,6 +48759,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
47967
48759
  let family = own2("family");
47968
48760
  let httpVersion = own2("httpVersion");
47969
48761
  if (httpVersion === void 0) httpVersion = 1;
48762
+ const rawHttpVersion = httpVersion;
47970
48763
  let http2Options = own2("http2Options");
47971
48764
  const httpAgent = own2("httpAgent");
47972
48765
  const httpsAgent = own2("httpsAgent");
@@ -47983,25 +48776,32 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
47983
48776
  let rejected = false;
47984
48777
  let req;
47985
48778
  let connectPhaseTimer;
47986
- httpVersion = +httpVersion;
48779
+ try {
48780
+ httpVersion = +httpVersion;
48781
+ } catch (err) {
48782
+ throw new AxiosError_default(
48783
+ "Invalid protocol version: value is not a number",
48784
+ AxiosError_default.ERR_BAD_OPTION_VALUE,
48785
+ config
48786
+ );
48787
+ }
47987
48788
  if (Number.isNaN(httpVersion)) {
47988
- throw TypeError(`Invalid protocol version: '${config.httpVersion}' is not a number`);
48789
+ throw new AxiosError_default(
48790
+ `Invalid protocol version: '${rawHttpVersion}' is not a number`,
48791
+ AxiosError_default.ERR_BAD_OPTION_VALUE,
48792
+ config
48793
+ );
47989
48794
  }
47990
48795
  if (httpVersion !== 1 && httpVersion !== 2) {
47991
- throw TypeError(`Unsupported protocol version '${httpVersion}'`);
48796
+ throw new AxiosError_default(
48797
+ `Unsupported protocol version '${httpVersion}'`,
48798
+ AxiosError_default.ERR_BAD_OPTION_VALUE,
48799
+ config
48800
+ );
47992
48801
  }
47993
48802
  const isHttp2 = httpVersion === 2;
47994
48803
  if (lookup) {
47995
- const _lookup = callbackify_default(lookup, (value) => utils_default.isArray(value) ? value : [value]);
47996
- lookup = (hostname, opt, cb) => {
47997
- _lookup(hostname, opt, (err, arg0, arg1) => {
47998
- if (err) {
47999
- return cb(err);
48000
- }
48001
- const addresses = utils_default.isArray(arg0) ? arg0.map((addr) => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
48002
- opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
48003
- });
48004
- };
48804
+ lookup = normalizeLookup(lookup);
48005
48805
  }
48006
48806
  const abortEmitter = new import_events.EventEmitter();
48007
48807
  function abort(reason) {
@@ -48244,6 +49044,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48244
49044
  utils_default.hasOwnProp(transitional2, "advertiseZstdAcceptEncoding") && transitional2.advertiseZstdAcceptEncoding === true ? ACCEPT_ENCODING_WITH_ZSTD : ACCEPT_ENCODING,
48245
49045
  false
48246
49046
  );
49047
+ if (isHttp2 && lookup) {
49048
+ http2Options = Object.assign(/* @__PURE__ */ Object.create(null), http2Options, { lookup });
49049
+ }
48247
49050
  const options = Object.assign(/* @__PURE__ */ Object.create(null), {
48248
49051
  path: path5,
48249
49052
  method,
@@ -48254,9 +49057,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48254
49057
  family,
48255
49058
  beforeRedirect: dispatchBeforeRedirect,
48256
49059
  beforeRedirects: /* @__PURE__ */ Object.create(null),
48257
- http2Options
49060
+ http2Options,
49061
+ createConnection: void 0
48258
49062
  });
48259
49063
  !utils_default.isUndefined(lookup) && (options.lookup = lookup);
49064
+ let proxyApplied = false;
48260
49065
  if (socketPath) {
48261
49066
  if (typeof socketPath !== "string") {
48262
49067
  return reject(
@@ -48284,13 +49089,17 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48284
49089
  } else {
48285
49090
  options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
48286
49091
  options.port = parsed.port;
48287
- setProxy(
49092
+ proxyApplied = setProxy(
48288
49093
  options,
48289
49094
  configProxy,
48290
49095
  protocol + "//" + parsed.hostname + (parsed.port ? ":" + parsed.port : "") + options.path,
48291
49096
  false,
48292
49097
  httpsAgent,
48293
- httpAgent
49098
+ httpAgent,
49099
+ // The HTTP/2 transport connects independently of HTTP/1 agents, so it
49100
+ // cannot apply either axios-resolved or agent-local environment proxies.
49101
+ // Explicit proxy config is still processed and rejected below.
49102
+ !isHttp2
48294
49103
  );
48295
49104
  }
48296
49105
  let transport;
@@ -48301,6 +49110,15 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48301
49110
  options.agent = isHttpsRequest ? httpsAgent : httpAgent;
48302
49111
  }
48303
49112
  if (isHttp2) {
49113
+ if (proxyApplied) {
49114
+ return reject(
49115
+ new AxiosError_default(
49116
+ "HTTP/2 requests with a proxy are not supported",
49117
+ AxiosError_default.ERR_NOT_SUPPORT,
49118
+ config
49119
+ )
49120
+ );
49121
+ }
48304
49122
  transport = http2Transport;
48305
49123
  } else {
48306
49124
  const configTransport = own2("transport");
@@ -48388,7 +49206,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48388
49206
  transformStream,
48389
49207
  progressEventDecorator(
48390
49208
  responseLength,
48391
- progressEventReducer(asyncDecorator(onDownloadProgress, scheduleProgress), true, 3)
49209
+ progressEventReducer(
49210
+ asyncDecorator(onDownloadProgress, scheduleProgress),
49211
+ true,
49212
+ 3
49213
+ )
48392
49214
  )
48393
49215
  )
48394
49216
  );
@@ -48537,12 +49359,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48537
49359
  socket.setKeepAlive(true, 1e3 * 60);
48538
49360
  }
48539
49361
  if (!socket[kAxiosSocketListener]) {
48540
- socket.on("error", function handleSocketError(err) {
48541
- const current = socket[kAxiosCurrentReq];
48542
- if (current && !current.destroyed) {
48543
- current.destroy(err);
48544
- }
48545
- });
49362
+ socket.on("error", handleSocketError);
48546
49363
  socket[kAxiosSocketListener] = true;
48547
49364
  }
48548
49365
  socket[kAxiosCurrentReq] = req;
@@ -48787,7 +49604,7 @@ function mergeConfig(config1, config2) {
48787
49604
  transformResponse: defaultToConfig2,
48788
49605
  paramsSerializer: defaultToConfig2,
48789
49606
  timeout: defaultToConfig2,
48790
- timeoutMessage: defaultToConfig2,
49607
+ timeoutErrorMessage: defaultToConfig2,
48791
49608
  withCredentials: defaultToConfig2,
48792
49609
  withXSRFToken: defaultToConfig2,
48793
49610
  adapter: defaultToConfig2,
@@ -48864,10 +49681,11 @@ function resolveConfig(config) {
48864
49681
  }
48865
49682
  }
48866
49683
  if (utils_default.isFormData(data)) {
49684
+ const getHeaders = utils_default.getSafeProp(data, "getHeaders");
48867
49685
  if (platform_default.hasStandardBrowserEnv || platform_default.hasStandardBrowserWebWorkerEnv || utils_default.isReactNative(data)) {
48868
49686
  headers.setContentType(void 0);
48869
- } else if (utils_default.isFunction(data.getHeaders)) {
48870
- setFormDataHeaders(headers, data.getHeaders(), own2("formDataHeaderPolicy"));
49687
+ } else if (utils_default.isFunction(getHeaders)) {
49688
+ setFormDataHeaders(headers, getHeaders.call(data), own2("formDataHeaderPolicy"));
48871
49689
  }
48872
49690
  }
48873
49691
  if (platform_default.hasStandardBrowserEnv) {
@@ -48896,7 +49714,7 @@ var xhr_default = isXHRAdapterSupported && function(config) {
48896
49714
  let { responseType, onUploadProgress, onDownloadProgress } = _config;
48897
49715
  let onCanceled;
48898
49716
  let uploadThrottled, downloadThrottled;
48899
- let flushUpload, flushDownload;
49717
+ let flushUpload, flushDownload, flushDownloadWithEvent;
48900
49718
  function done() {
48901
49719
  flushUpload && flushUpload();
48902
49720
  flushDownload && flushDownload();
@@ -48906,7 +49724,27 @@ var xhr_default = isXHRAdapterSupported && function(config) {
48906
49724
  let request = new XMLHttpRequest();
48907
49725
  request.open(_config.method.toUpperCase(), _config.url, true);
48908
49726
  request.timeout = _config.timeout;
48909
- function onloadend() {
49727
+ function onloadend(event) {
49728
+ if (!request) {
49729
+ return;
49730
+ }
49731
+ if (request.status === 0 && (parseProtocol(normalizeURLForProtocolCheck(_config.url)) || parseProtocol(platform_default.origin)) !== "file" && !(request.responseURL && request.responseURL.startsWith("file:"))) {
49732
+ reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED, config, request));
49733
+ done();
49734
+ request = null;
49735
+ return;
49736
+ }
49737
+ try {
49738
+ if (event) {
49739
+ flushDownloadWithEvent && flushDownloadWithEvent(event);
49740
+ } else {
49741
+ flushDownload && flushDownload();
49742
+ }
49743
+ } catch (err) {
49744
+ setTimeout(() => {
49745
+ throw err;
49746
+ });
49747
+ }
48910
49748
  if (!request) {
48911
49749
  return;
48912
49750
  }
@@ -48994,7 +49832,10 @@ var xhr_default = isXHRAdapterSupported && function(config) {
48994
49832
  request.responseType = _config.responseType;
48995
49833
  }
48996
49834
  if (onDownloadProgress) {
48997
- [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
49835
+ [downloadThrottled, flushDownload, flushDownloadWithEvent] = progressEventReducer(
49836
+ onDownloadProgress,
49837
+ true
49838
+ );
48998
49839
  request.addEventListener("progress", downloadThrottled);
48999
49840
  }
49000
49841
  if (onUploadProgress && request.upload) {
@@ -49164,6 +50005,17 @@ var trackStream = (stream4, chunkSize, onProgress, onFinish) => {
49164
50005
 
49165
50006
  // node_modules/axios/lib/adapters/fetch.js
49166
50007
  var DEFAULT_CHUNK_SIZE = 64 * 1024;
50008
+ var DEFAULT_REQUEST_OPTIONS = {
50009
+ cache: "default",
50010
+ redirect: "follow",
50011
+ referrer: "about:client",
50012
+ referrerPolicy: "",
50013
+ mode: "cors",
50014
+ integrity: "",
50015
+ keepalive: false,
50016
+ priority: "auto",
50017
+ window: null
50018
+ };
49167
50019
  var { isFunction: isFunction2 } = utils_default;
49168
50020
  var encodeUTF82 = (str) => encodeURIComponent(str).replace(
49169
50021
  /%([0-9A-F]{2})/gi,
@@ -49294,7 +50146,8 @@ var factory = (env) => {
49294
50146
  withCredentials = "same-origin",
49295
50147
  fetchOptions,
49296
50148
  maxContentLength,
49297
- maxBodyLength
50149
+ maxBodyLength,
50150
+ maxRedirects
49298
50151
  } = resolveConfig_default(config);
49299
50152
  const hasMaxContentLength = utils_default.isNumber(maxContentLength) && maxContentLength > -1;
49300
50153
  const hasMaxBodyLength = utils_default.isNumber(maxBodyLength) && maxBodyLength > -1;
@@ -49424,17 +50277,44 @@ var factory = (env) => {
49424
50277
  }
49425
50278
  }
49426
50279
  headers.set("User-Agent", "axios/" + VERSION, false);
49427
- const resolvedOptions = {
49428
- ...fetchOptions,
50280
+ const safeFetchOptions = fetchOptions == null ? fetchOptions : Object.assign(/* @__PURE__ */ Object.create(null), fetchOptions);
50281
+ if (safeFetchOptions) {
50282
+ delete safeFetchOptions.body;
50283
+ delete safeFetchOptions.headers;
50284
+ delete safeFetchOptions.method;
50285
+ delete safeFetchOptions.signal;
50286
+ delete safeFetchOptions.duplex;
50287
+ delete safeFetchOptions.credentials;
50288
+ }
50289
+ const resolvedOptions = Object.assign(/* @__PURE__ */ Object.create(null), safeFetchOptions, {
49429
50290
  signal: composedSignal,
49430
50291
  method: method.toUpperCase(),
49431
50292
  headers: toByteStringHeaderObject(headers.normalize()),
49432
50293
  body: data,
49433
50294
  duplex: "half",
49434
50295
  credentials: isCredentialsSupported ? withCredentials : void 0
49435
- };
50296
+ });
50297
+ if (isRequestSupported) {
50298
+ utils_default.forEach(DEFAULT_REQUEST_OPTIONS, (value, key) => {
50299
+ if (resolvedOptions[key] === void 0) {
50300
+ resolvedOptions[key] = value;
50301
+ }
50302
+ });
50303
+ if (resolvedOptions.signal === void 0) {
50304
+ resolvedOptions.signal = null;
50305
+ }
50306
+ if (resolvedOptions.body === void 0) {
50307
+ resolvedOptions.body = null;
50308
+ }
50309
+ }
50310
+ if (maxRedirects === 0) {
50311
+ resolvedOptions.redirect = "manual";
50312
+ if (safeFetchOptions) {
50313
+ safeFetchOptions.redirect = "manual";
50314
+ }
50315
+ }
49436
50316
  request = isRequestSupported && new Request(url2, resolvedOptions);
49437
- let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url2, resolvedOptions));
50317
+ let response = await (isRequestSupported ? _fetch(request, safeFetchOptions) : _fetch(url2, resolvedOptions));
49438
50318
  const responseHeaders = AxiosHeaders_default.from(response.headers);
49439
50319
  if (hasMaxContentLength) {
49440
50320
  const declaredLength = utils_default.toFiniteNumber(responseHeaders.getContentLength());
@@ -49653,9 +50533,10 @@ function throwIfCancellationRequested(config) {
49653
50533
  throw new CanceledError_default(null, config);
49654
50534
  }
49655
50535
  }
49656
- function dispatchRequest(config) {
50536
+ function dispatchRequest(_config) {
50537
+ const config = utils_default.toSafeFlatObject(_config);
49657
50538
  throwIfCancellationRequested(config);
49658
- config.headers = AxiosHeaders_default.from(config.headers);
50539
+ config.headers = AxiosHeaders_default.from(utils_default.getSafeProp(config, "headers"));
49659
50540
  config.data = transformData.call(config, config.transformRequest);
49660
50541
  if (["post", "put", "patch"].indexOf(config.method) !== -1) {
49661
50542
  config.headers.setContentType("application/x-www-form-urlencoded", false);
@@ -49785,16 +50666,15 @@ var Axios = class {
49785
50666
  return await this._request(configOrUrl, config);
49786
50667
  } catch (err) {
49787
50668
  if (err instanceof Error) {
49788
- let dummy = {};
49789
- Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
49790
- const stack = (() => {
49791
- if (!dummy.stack) {
49792
- return "";
49793
- }
49794
- const firstNewlineIndex = dummy.stack.indexOf("\n");
49795
- return firstNewlineIndex === -1 ? "" : dummy.stack.slice(firstNewlineIndex + 1);
49796
- })();
49797
50669
  try {
50670
+ let dummy = {};
50671
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
50672
+ const dummyStack = dummy.stack;
50673
+ let stack = "";
50674
+ if (typeof dummyStack === "string") {
50675
+ const firstNewlineIndex = dummyStack.indexOf("\n");
50676
+ stack = firstNewlineIndex === -1 ? "" : dummyStack.slice(firstNewlineIndex + 1);
50677
+ }
49798
50678
  if (!err.stack) {
49799
50679
  err.stack = stack;
49800
50680
  } else if (stack) {
@@ -49864,9 +50744,9 @@ var Axios = class {
49864
50744
  },
49865
50745
  true
49866
50746
  );
49867
- config.method = (config.method || this.defaults.method || "get").toLowerCase();
50747
+ config.method = (utils_default.getSafeProp(config, "method") || utils_default.getSafeProp(this.defaults, "method") || "get").toLowerCase();
49868
50748
  let contextHeaders = headers && utils_default.merge(headers.common, headers[config.method]);
49869
- headers && utils_default.forEach(["delete", "get", "head", "post", "put", "patch", "query", "common"], (method) => {
50749
+ headers && utils_default.forEach(methodList_default.concat("common"), (method) => {
49870
50750
  delete headers[method];
49871
50751
  });
49872
50752
  config.headers = AxiosHeaders_default.concat(contextHeaders, headers);
@@ -50129,14 +51009,22 @@ var HttpStatusCode = {
50129
51009
  Gone: 410,
50130
51010
  LengthRequired: 411,
50131
51011
  PreconditionFailed: 412,
51012
+ /**
51013
+ * @deprecated Use `ContentTooLarge` instead.
51014
+ */
50132
51015
  PayloadTooLarge: 413,
51016
+ ContentTooLarge: 413,
50133
51017
  UriTooLong: 414,
50134
51018
  UnsupportedMediaType: 415,
50135
51019
  RangeNotSatisfiable: 416,
50136
51020
  ExpectationFailed: 417,
50137
51021
  ImATeapot: 418,
50138
51022
  MisdirectedRequest: 421,
51023
+ /**
51024
+ * @deprecated Use `UnprocessableContent` instead.
51025
+ */
50139
51026
  UnprocessableEntity: 422,
51027
+ UnprocessableContent: 422,
50140
51028
  Locked: 423,
50141
51029
  FailedDependency: 424,
50142
51030
  TooEarly: 425,
@@ -50165,7 +51053,9 @@ var HttpStatusCode = {
50165
51053
  InvalidSslCertificate: 526
50166
51054
  };
50167
51055
  Object.entries(HttpStatusCode).forEach(([key, value]) => {
50168
- HttpStatusCode[value] = key;
51056
+ if (HttpStatusCode[value] === void 0) {
51057
+ HttpStatusCode[value] = key;
51058
+ }
50169
51059
  });
50170
51060
  var HttpStatusCode_default = HttpStatusCode;
50171
51061
 
@@ -50788,6 +51678,14 @@ var init_deployment_addresses = __esm2({
50788
51678
  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.",
50789
51679
  executeTx: "0xf1f8d5fc13f45d7a3f932bf1a2d6e29381fdd41cd31298ad785bf7688df07fe6",
50790
51680
  block: 25673200
51681
+ },
51682
+ AgentDelegationRegistry: {
51683
+ newImplementation: "0xa9fF405Edd4329fc3159a64F56B37EBD253e4928",
51684
+ upgradedAt: "2026-07-31T22:03:35.000Z",
51685
+ upgradedBy: "AdminModule/Safe audit-batch upgradeToAndCall; executed by 0xEba7BfAeB35ee18408b424Ee0BB45AdDf776589f in tx 0x8fed0ab7eee3aaaa3792a35b40b0ef74bd09cfb1a175934afd846bee546048d4 (block 25655710)",
51686
+ reason: "Reconciled from chain \u2014 mainnet audit rollout batch (cross-ref onchain-auth/.safe-batches/mainnet-audit-execute.json)",
51687
+ executeTx: "0x8fed0ab7eee3aaaa3792a35b40b0ef74bd09cfb1a175934afd846bee546048d4",
51688
+ block: 25655710
50791
51689
  }
50792
51690
  },
50793
51691
  latestEnv: {
@@ -51337,6 +52235,9 @@ var require_pkg_src2 = __commonJS2({
51337
52235
  });
51338
52236
  var index_exports = {};
51339
52237
  __export22(index_exports, {
52238
+ BORROWER_AUTHORIZATION_ENCODE_TYPES: () => BORROWER_AUTHORIZATION_ENCODE_TYPES,
52239
+ BORROWER_AUTHORIZATION_FIELDS: () => BORROWER_AUTHORIZATION_FIELDS,
52240
+ BORROWER_AUTHORIZATION_PRIMARY_TYPES: () => BORROWER_AUTHORIZATION_PRIMARY_TYPES,
51340
52241
  CHIPOTLE_DEPLOYMENTS: () => CHIPOTLE_DEPLOYMENTS,
51341
52242
  DEFAULT_CACHE_CONFIG: () => DEFAULT_CACHE_CONFIG,
51342
52243
  DEFAULT_DEBUG_CONFIG: () => DEFAULT_DEBUG_CONFIG,
@@ -51349,6 +52250,8 @@ var require_pkg_src2 = __commonJS2({
51349
52250
  PerformanceTracker: () => PerformanceTracker,
51350
52251
  RetryStrategy: () => RetryStrategy,
51351
52252
  analyzeError: () => analyzeError,
52253
+ borrowerAuthorizationTypes: () => borrowerAuthorizationTypes,
52254
+ buildBorrowerAuthorizationDomain: () => buildBorrowerAuthorizationDomain,
51352
52255
  calculateDelay: () => calculateDelay,
51353
52256
  cidToHex: () => cidToHex,
51354
52257
  classifyError: () => classifyError,
@@ -51595,30 +52498,30 @@ var require_pkg_src2 = __commonJS2({
51595
52498
  }
51596
52499
  },
51597
52500
  btcTransactionSigner: {
51598
- cid: "QmakWzTce8NH1Jkgv1xwg83Bg9WmF2UG1Mq76pDYDSwwUp",
52501
+ cid: "QmVi1BYdxvCX3QUhXwPtP6FjWMzqSPtXzrS54YsXjTgjYf",
51599
52502
  authorizedCidHex: cidToHex(
51600
- "QmakWzTce8NH1Jkgv1xwg83Bg9WmF2UG1Mq76pDYDSwwUp"
52503
+ "QmVi1BYdxvCX3QUhXwPtP6FjWMzqSPtXzrS54YsXjTgjYf"
51601
52504
  ),
51602
52505
  name: "Btc Transaction Signer",
51603
52506
  description: "Production Btc Transaction Signer",
51604
52507
  version: "1.1.1",
51605
52508
  deployed: true,
51606
- deployedAt: 1786465606156,
51607
- size: 67999,
51608
- hash: "83f3644c68819215e05ba8db3225571354a009458fc1437f606df6cb9142d3f9"
52509
+ deployedAt: 1787923905597,
52510
+ size: 70646,
52511
+ hash: "37c3bb72a660c8275d92e1b73f9482742d86b64789480b9246304c0ca1bab47a"
51609
52512
  },
51610
52513
  ucdMintValidator: {
51611
- cid: "Qmd8jgKRceLvf5aoTtwdXG2JqMoBK5cRJwrvEtQkgvbFbx",
52514
+ cid: "QmUWR5fLiyimLT9TPXpYx3HgwNwkvR6MxjZ7hdeYCFodbc",
51612
52515
  authorizedCidHex: cidToHex(
51613
- "Qmd8jgKRceLvf5aoTtwdXG2JqMoBK5cRJwrvEtQkgvbFbx"
52516
+ "QmUWR5fLiyimLT9TPXpYx3HgwNwkvR6MxjZ7hdeYCFodbc"
51614
52517
  ),
51615
52518
  name: "Ucd Mint Validator",
51616
52519
  description: "Production Ucd Mint Validator",
51617
52520
  version: "1.2.1",
51618
52521
  deployed: true,
51619
- deployedAt: 1786465627201,
51620
- size: 82739,
51621
- hash: "2bdd9aebdaad58a43a4731d5b7284f2531b7a9caaf8caf5719d891c4ed33cb2e",
52522
+ deployedAt: 1787923919527,
52523
+ size: 86197,
52524
+ hash: "c2d80939746cc37f65ef2f63c6a3215b929214a63f10c78144e1f5c98320dabf",
51622
52525
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
51623
52526
  pkp: {
51624
52527
  publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
@@ -51626,17 +52529,17 @@ var require_pkg_src2 = __commonJS2({
51626
52529
  }
51627
52530
  },
51628
52531
  processPaymentValidator: {
51629
- cid: "QmNXVdysXDhCaQ1uNE2Vgjbuzy6yUEnnVgHzmDfNKXMU6z",
52532
+ cid: "QmXmXuMRAjMLdgKGyTf9KQdGwYrDp8DxkiF44TvSXDf7wF",
51630
52533
  authorizedCidHex: cidToHex(
51631
- "QmNXVdysXDhCaQ1uNE2Vgjbuzy6yUEnnVgHzmDfNKXMU6z"
52534
+ "QmXmXuMRAjMLdgKGyTf9KQdGwYrDp8DxkiF44TvSXDf7wF"
51632
52535
  ),
51633
52536
  name: "Process Payment Validator",
51634
52537
  description: "Production Process Payment Validator",
51635
52538
  version: "1.2.1",
51636
52539
  deployed: true,
51637
- deployedAt: 1786465654796,
51638
- size: 78736,
51639
- hash: "17191ecc9c009e0fa5ab52c876330beb2a9a75d30cccb92e7c0c04f169df088b",
52540
+ deployedAt: 1787923987153,
52541
+ size: 82217,
52542
+ hash: "13defa19614215ab3b1fe88955d69e530d13a09475396af932fe0e213637da2f",
51640
52543
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
51641
52544
  pkp: {
51642
52545
  publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
@@ -51644,17 +52547,17 @@ var require_pkg_src2 = __commonJS2({
51644
52547
  }
51645
52548
  },
51646
52549
  extendPositionValidator: {
51647
- cid: "QmYwBsyrhGfHWyRKx549G4tKHxsBLAuRUHcecigeUCkFav",
52550
+ cid: "QmU8h99EEVEsQkxroXiYqLsKZw9gNjE6N5CcTpE9aUc12m",
51648
52551
  authorizedCidHex: cidToHex(
51649
- "QmYwBsyrhGfHWyRKx549G4tKHxsBLAuRUHcecigeUCkFav"
52552
+ "QmU8h99EEVEsQkxroXiYqLsKZw9gNjE6N5CcTpE9aUc12m"
51650
52553
  ),
51651
52554
  name: "Extend Position Validator",
51652
52555
  description: "Production Extend Position Validator",
51653
52556
  version: "1.2.1",
51654
52557
  deployed: true,
51655
- deployedAt: 1786465681874,
51656
- size: 76515,
51657
- hash: "1d4e085335af80f194a663a577876902c83015177e95906a0b461fa93bd5da08",
52558
+ deployedAt: 1787923999294,
52559
+ size: 79975,
52560
+ hash: "31c1aaf883ef22f37681ddb0a4a949be5c05304b6aef178989475a2da935ef9a",
51658
52561
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
51659
52562
  pkp: {
51660
52563
  publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
@@ -51662,17 +52565,17 @@ var require_pkg_src2 = __commonJS2({
51662
52565
  }
51663
52566
  },
51664
52567
  btcWithdrawal: {
51665
- cid: "QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh",
52568
+ cid: "QmZQWET9pzrVD4gwQuSzYZmqa24JrUNtnnGFDd513sxMCY",
51666
52569
  authorizedCidHex: cidToHex(
51667
- "QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh"
52570
+ "QmZQWET9pzrVD4gwQuSzYZmqa24JrUNtnnGFDd513sxMCY"
51668
52571
  ),
51669
52572
  name: "Btc Withdrawal",
51670
52573
  description: "Production Btc Withdrawal",
51671
52574
  version: "1.2.7",
51672
52575
  deployed: true,
51673
- deployedAt: 1786446046614,
51674
- size: 97456,
51675
- hash: "3cae8250861832f91ee3c573abeb50ff27b9acd34148176071cbfbabb359fc91",
52576
+ deployedAt: 1787924017769,
52577
+ size: 100069,
52578
+ hash: "4f8e27414e4da235e63d6ae1325c63f3d2fb956464515a21aa007a99935f0f13",
51676
52579
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
51677
52580
  pkp: {
51678
52581
  publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
@@ -51784,30 +52687,30 @@ var require_pkg_src2 = __commonJS2({
51784
52687
  hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
51785
52688
  },
51786
52689
  agentModuleExecutor: {
51787
- cid: "QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ",
52690
+ cid: "QmcD65vuremot5fsHVgp9JBAmei6gAaEtm5mdtLP7Yt9Kf",
51788
52691
  authorizedCidHex: cidToHex(
51789
- "QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ"
52692
+ "QmcD65vuremot5fsHVgp9JBAmei6gAaEtm5mdtLP7Yt9Kf"
51790
52693
  ),
51791
52694
  name: "Agent Module Executor",
51792
52695
  description: "Production Agent Module Executor",
51793
52696
  version: "1.1.1",
51794
52697
  deployed: true,
51795
- deployedAt: 1786446108348,
51796
- size: 11655,
51797
- hash: "d4e2149f843d6c2699fc61114d54b268ba4ed2c46ebdaee1145e0f101ec2a1ec"
52698
+ deployedAt: 1787924032013,
52699
+ size: 13878,
52700
+ hash: "a7f0204700912e26e5a354bee13a1242a2baa218643b3bb22d28481f67f9baf4"
51798
52701
  },
51799
52702
  staleSpendRecoveryValidator: {
51800
- cid: "QmXQWT8V4wjuvH8BbC7xrkYxsVu5AKfvfWcS7jnYfrexYm",
52703
+ cid: "QmNuwo4PT4AikAmhMdZgPWCb2mJDwWa9TnUqrqvofjbrT8",
51801
52704
  authorizedCidHex: cidToHex(
51802
- "QmXQWT8V4wjuvH8BbC7xrkYxsVu5AKfvfWcS7jnYfrexYm"
52705
+ "QmNuwo4PT4AikAmhMdZgPWCb2mJDwWa9TnUqrqvofjbrT8"
51803
52706
  ),
51804
52707
  name: "Stale Spend Recovery Validator",
51805
52708
  description: "Production Stale Spend Recovery Validator",
51806
52709
  version: "1.1.2",
51807
52710
  deployed: true,
51808
- deployedAt: 1785173285829,
51809
- size: 37108,
51810
- hash: "04de5fc5b6f5131dc1544e3d3d187a1f9ef9616ffd12483d119f9102b3671791",
52711
+ deployedAt: 1787924048772,
52712
+ size: 41424,
52713
+ hash: "3c5f028d2bef4344768462993616d45e30d9d44ef126e04d6eb579821d57d99c",
51811
52714
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
51812
52715
  pkp: {
51813
52716
  publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
@@ -51815,17 +52718,17 @@ var require_pkg_src2 = __commonJS2({
51815
52718
  }
51816
52719
  },
51817
52720
  btcUtxoInvalidator: {
51818
- cid: "Qmf4Ze8yhnQhHbnX5RPgJrC7Jw1aA3gbpfpd52kFg7fd1m",
52721
+ cid: "QmaNGeWut7EiGwW4zUc2sFSt7RY5NWFgxYboyG333TwrJf",
51819
52722
  authorizedCidHex: cidToHex(
51820
- "Qmf4Ze8yhnQhHbnX5RPgJrC7Jw1aA3gbpfpd52kFg7fd1m"
52723
+ "QmaNGeWut7EiGwW4zUc2sFSt7RY5NWFgxYboyG333TwrJf"
51821
52724
  ),
51822
52725
  name: "Btc Utxo Invalidator",
51823
52726
  description: "Production Btc Utxo Invalidator",
51824
52727
  version: "1.0.0",
51825
52728
  deployed: true,
51826
- deployedAt: 1786465704240,
51827
- size: 62553,
51828
- hash: "1dcea2b49e545c423195be22e072dc5e3039ed1c95a8490b23505956029f5b33"
52729
+ deployedAt: 1787924133241,
52730
+ size: 66026,
52731
+ hash: "603bc50920d7f1dee77086f2c518d9e2922ab3858a419d3fbea8221ea3a6d9e9"
51829
52732
  }
51830
52733
  };
51831
52734
  function getDeploymentsForNetwork(network) {
@@ -52586,6 +53489,101 @@ ${errorReport}`);
52586
53489
  var SECONDS_PER_DAY = 86400;
52587
53490
  var DAYS_PER_MONTH = 30;
52588
53491
  var LIT_ACTION_ETH_RPC_TIMEOUT_MS = 8e3;
53492
+ var PINNED_CONTRACT_ADDRESSES = {
53493
+ 1: {
53494
+ PositionManager: "0x12A1836e56139ccaD8722B89519d84233efc224B",
53495
+ LoanOperationsManagerModule: "0x2561974A40F1AEed1251d0A090A83cF8536FB9E9",
53496
+ BTCSpendAuthorizer: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
53497
+ BitcoinProviderRegistry: "0x4ab3Fb96e02893Ed6FAa61bad1918390c8DbbFFC",
53498
+ LITActionValidator: "0xD2c5d59c2CC5c409AC65ce0A817236aeC6869512",
53499
+ PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C"
53500
+ },
53501
+ 11155111: {
53502
+ PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
53503
+ LoanOperationsManagerModule: "0x3e05e760a87715207b7F4e8fD35EF7559BcA72C0",
53504
+ BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
53505
+ BitcoinProviderRegistry: "0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",
53506
+ LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
53507
+ PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9"
53508
+ }
53509
+ };
53510
+ function getPinnedContractAddresses(chainId) {
53511
+ return PINNED_CONTRACT_ADDRESSES[chainId] ?? null;
53512
+ }
53513
+ var PROTOCOL_EIP712_DOMAIN_NAME = "DiamondHands.Protocol";
53514
+ var PROTOCOL_EIP712_DOMAIN_VERSION = "1";
53515
+ var BORROWER_AUTHORIZATION_PRIMARY_TYPES = {
53516
+ MINT: "MintRequest",
53517
+ REPAY: "RepayRequest",
53518
+ RENEW: "RenewRequest",
53519
+ WITHDRAW: "WithdrawRequest"
53520
+ };
53521
+ var BORROWER_AUTHORIZATION_FIELDS = {
53522
+ MintRequest: [
53523
+ { name: "positionId", type: "bytes32" },
53524
+ { name: "mintAmount", type: "uint256" },
53525
+ { name: "quantumTimestamp", type: "uint256" }
53526
+ ],
53527
+ RepayRequest: [
53528
+ { name: "positionId", type: "bytes32" },
53529
+ { name: "paymentAmount", type: "uint256" },
53530
+ { name: "quantumTimestamp", type: "uint256" }
53531
+ ],
53532
+ RenewRequest: [
53533
+ { name: "positionId", type: "bytes32" },
53534
+ { name: "selectedTerm", type: "uint256" },
53535
+ { name: "quantumTimestamp", type: "uint256" }
53536
+ ],
53537
+ WithdrawRequest: [
53538
+ { name: "positionId", type: "bytes32" },
53539
+ { name: "totalDeduction", type: "uint256" },
53540
+ { name: "withdrawalAddress", type: "string" },
53541
+ { name: "quantumTimestamp", type: "uint256" }
53542
+ ]
53543
+ };
53544
+ var BORROWER_AUTHORIZATION_ENCODE_TYPES = {
53545
+ MintRequest: "MintRequest(bytes32 positionId,uint256 mintAmount,uint256 quantumTimestamp)",
53546
+ RepayRequest: "RepayRequest(bytes32 positionId,uint256 paymentAmount,uint256 quantumTimestamp)",
53547
+ RenewRequest: "RenewRequest(bytes32 positionId,uint256 selectedTerm,uint256 quantumTimestamp)",
53548
+ WithdrawRequest: "WithdrawRequest(bytes32 positionId,uint256 totalDeduction,string withdrawalAddress,uint256 quantumTimestamp)"
53549
+ };
53550
+ function borrowerAuthorizationTypes(primaryType) {
53551
+ const fields = BORROWER_AUTHORIZATION_FIELDS[primaryType];
53552
+ if (!fields) {
53553
+ throw new Error(
53554
+ `Unknown borrower authorization primary type "${primaryType}"; expected one of ${Object.keys(BORROWER_AUTHORIZATION_FIELDS).join(", ")}`
53555
+ );
53556
+ }
53557
+ return { [primaryType]: fields.map((field) => ({ ...field })) };
53558
+ }
53559
+ function buildBorrowerAuthorizationDomain(chainId, verifyingContractOverride) {
53560
+ if (!Number.isInteger(chainId) || chainId <= 0) {
53561
+ throw new Error(
53562
+ `Borrower authorization domain requires a positive integer chainId, got ${String(chainId)}`
53563
+ );
53564
+ }
53565
+ const pinned = getPinnedContractAddresses(chainId);
53566
+ const pinnedLom = pinned?.LoanOperationsManagerModule;
53567
+ if (pinnedLom && verifyingContractOverride) {
53568
+ if (pinnedLom.toLowerCase() !== verifyingContractOverride.toLowerCase()) {
53569
+ throw new Error(
53570
+ `Refusing a caller-supplied verifyingContract that contradicts the pin for chainId ${chainId}: caller ${verifyingContractOverride}, pinned ${pinnedLom}`
53571
+ );
53572
+ }
53573
+ }
53574
+ const verifyingContract = pinnedLom ?? verifyingContractOverride;
53575
+ if (!verifyingContract) {
53576
+ throw new Error(
53577
+ `No pinned LoanOperationsManagerModule for chainId ${chainId} and no verifyingContract supplied; refusing to build a borrower authorization domain without one`
53578
+ );
53579
+ }
53580
+ return {
53581
+ name: PROTOCOL_EIP712_DOMAIN_NAME,
53582
+ version: PROTOCOL_EIP712_DOMAIN_VERSION,
53583
+ chainId,
53584
+ verifyingContract
53585
+ };
53586
+ }
52589
53587
  var EVMChain = /* @__PURE__ */ ((EVMChain3) => {
52590
53588
  EVMChain3["SEPOLIA"] = "sepolia";
52591
53589
  EVMChain3["ETHEREUM"] = "ethereum";
@@ -56381,6 +57379,77 @@ async function awaitSafeSubmissionWindowOnChain(signatureQuantum, chainNow, slee
56381
57379
  );
56382
57380
  return { waited: waitedSeconds > 0, waitedSeconds };
56383
57381
  }
57382
+ init_deployment_addresses();
57383
+ var BORROWER_AUTHORIZATION_712_DOMAIN_NAME = "DiamondHands.Protocol";
57384
+ var BORROWER_AUTHORIZATION_712_DOMAIN_VERSION = "1";
57385
+ var BORROWER_AUTHORIZATION_712_FIELDS = {
57386
+ MintRequest: [
57387
+ { name: "positionId", type: "bytes32" },
57388
+ { name: "mintAmount", type: "uint256" },
57389
+ { name: "quantumTimestamp", type: "uint256" }
57390
+ ],
57391
+ RepayRequest: [
57392
+ { name: "positionId", type: "bytes32" },
57393
+ { name: "paymentAmount", type: "uint256" },
57394
+ { name: "quantumTimestamp", type: "uint256" }
57395
+ ],
57396
+ RenewRequest: [
57397
+ { name: "positionId", type: "bytes32" },
57398
+ { name: "selectedTerm", type: "uint256" },
57399
+ { name: "quantumTimestamp", type: "uint256" }
57400
+ ],
57401
+ WithdrawRequest: [
57402
+ { name: "positionId", type: "bytes32" },
57403
+ { name: "totalDeduction", type: "uint256" },
57404
+ { name: "withdrawalAddress", type: "string" },
57405
+ { name: "quantumTimestamp", type: "uint256" }
57406
+ ]
57407
+ };
57408
+ function borrowerAuthorization712Types(primaryType) {
57409
+ const fields = BORROWER_AUTHORIZATION_712_FIELDS[primaryType];
57410
+ if (!fields) {
57411
+ throw new Error(
57412
+ `Unknown borrower authorization primary type "${primaryType}"; expected one of ` + Object.keys(BORROWER_AUTHORIZATION_712_FIELDS).join(", ")
57413
+ );
57414
+ }
57415
+ return { [primaryType]: fields.map((field) => ({ ...field })) };
57416
+ }
57417
+ function buildBorrowerAuthorization712Domain(chainId) {
57418
+ if (!Number.isInteger(chainId) || chainId <= 0) {
57419
+ throw new Error(
57420
+ `Borrower authorization domain requires a positive integer chainId, got ${String(chainId)}`
57421
+ );
57422
+ }
57423
+ const deployment = Object.values(ALL_DEPLOYMENTS).find(
57424
+ (d) => d.chainId === chainId
57425
+ );
57426
+ const verifyingContract = deployment?.contracts?.LoanOperationsManagerModule;
57427
+ if (!verifyingContract) {
57428
+ throw new Error(
57429
+ `No LoanOperationsManagerModule deployment known for chainId ${chainId}; refusing to build a borrower authorization domain without one`
57430
+ );
57431
+ }
57432
+ return {
57433
+ name: BORROWER_AUTHORIZATION_712_DOMAIN_NAME,
57434
+ version: BORROWER_AUTHORIZATION_712_DOMAIN_VERSION,
57435
+ chainId,
57436
+ verifyingContract
57437
+ };
57438
+ }
57439
+ async function signBorrowerAuthorization712(signer, primaryType, chainId, message) {
57440
+ const signTypedData = signer.signTypedData;
57441
+ if (typeof signTypedData !== "function") {
57442
+ throw new Error(
57443
+ `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.`
57444
+ );
57445
+ }
57446
+ return signTypedData.call(
57447
+ signer,
57448
+ buildBorrowerAuthorization712Domain(chainId),
57449
+ borrowerAuthorization712Types(primaryType),
57450
+ message
57451
+ );
57452
+ }
56384
57453
  var PKP_NFT_ABI = [
56385
57454
  "function getPubkey(uint256 tokenId) external view returns (bytes memory)"
56386
57455
  ];
@@ -56393,29 +57462,11 @@ async function generateMintAuthorization(positionId, amount, chainId, signerOrPr
56393
57462
  const signer = signerOrPrecomputed;
56394
57463
  const timestamp = calculateNextQuantumTimestamp();
56395
57464
  const action = "mint-ucd";
56396
- const actionHash = (0, import_ethers15.keccak256)((0, import_ethers15.toUtf8Bytes)(action));
56397
- const types = [
56398
- "bytes32",
56399
- // positionId
56400
- "uint256",
56401
- // timestamp
56402
- "uint256",
56403
- // chainId
56404
- "uint256",
56405
- // amount
56406
- "bytes32"
56407
- // actionHash
56408
- ];
56409
- const values = [
57465
+ const signature = await signBorrowerAuthorization712(signer, "MintRequest", chainId, {
56410
57466
  positionId,
56411
- timestamp,
56412
- chainId,
56413
- amount.toString(),
56414
- actionHash
56415
- ];
56416
- const messageHash = (0, import_ethers15.solidityPackedKeccak256)(types, values);
56417
- const messageHashBytes = (0, import_ethers15.getBytes)(messageHash);
56418
- const signature = await signer.signMessage(messageHashBytes);
57467
+ mintAmount: amount.toString(),
57468
+ quantumTimestamp: timestamp
57469
+ });
56419
57470
  return {
56420
57471
  positionId,
56421
57472
  timestamp,
@@ -56452,44 +57503,17 @@ async function generatePaymentAuthorization(positionId, amount, chainId, signerO
56452
57503
  throw new Error(`timestamp must be a number, got ${typeof timestamp}`);
56453
57504
  }
56454
57505
  const action = "make-payment";
56455
- const actionHash = (0, import_ethers15.keccak256)((0, import_ethers15.toUtf8Bytes)(action));
56456
- if (typeof actionHash !== "string") {
56457
- throw new Error(`actionHash must be a string, got ${typeof actionHash}`);
56458
- }
56459
- const types = [
56460
- "bytes32",
56461
- // positionId
56462
- "uint256",
56463
- // timestamp
56464
- "uint256",
56465
- // chainId
56466
- "uint256",
56467
- // amount
56468
- "bytes32"
56469
- // actionHash
56470
- ];
56471
57506
  const amountStr = amount.toString();
56472
- if (typeof amountStr !== "string") {
56473
- throw new Error(
56474
- `amount.toString() must return a string, got ${typeof amountStr}`
56475
- );
56476
- }
56477
- const values = [positionId, timestamp, chainId, amountStr, actionHash];
56478
- for (let i = 0; i < values.length; i++) {
56479
- if (typeof values[i] === "object" && values[i] !== null) {
56480
- throw new Error(
56481
- `Value at index ${i} is an object: ${JSON.stringify(values[i])}`
56482
- );
56483
- }
56484
- }
56485
- const messageHash = (0, import_ethers15.solidityPackedKeccak256)(types, values);
56486
- const messageHashBytes = (0, import_ethers15.getBytes)(messageHash);
56487
- const signature = await signer.signMessage(messageHashBytes);
57507
+ const signature = await signBorrowerAuthorization712(signer, "RepayRequest", chainId, {
57508
+ positionId,
57509
+ paymentAmount: amountStr,
57510
+ quantumTimestamp: timestamp
57511
+ });
56488
57512
  return {
56489
57513
  positionId,
56490
57514
  timestamp,
56491
57515
  chainId,
56492
- amount: amount.toString(),
57516
+ amount: amountStr,
56493
57517
  action,
56494
57518
  signature
56495
57519
  };
@@ -56576,32 +57600,12 @@ async function generateWithdrawAuthorization(positionId, amount, chainId, signer
56576
57600
  const signer = signerOrPrecomputed;
56577
57601
  const timestamp = calculateNextQuantumTimestamp();
56578
57602
  const action = "withdraw-btc";
56579
- const actionHash = (0, import_ethers15.keccak256)((0, import_ethers15.toUtf8Bytes)(action));
56580
- const types = [
56581
- "bytes32",
56582
- // positionId
56583
- "uint256",
56584
- // timestamp
56585
- "uint256",
56586
- // chainId
56587
- "uint256",
56588
- // amount (in satoshis)
56589
- "string",
56590
- // destinationAddress (Bitcoin address)
56591
- "bytes32"
56592
- // actionHash
56593
- ];
56594
- const values = [
57603
+ const signature = await signBorrowerAuthorization712(signer, "WithdrawRequest", chainId, {
56595
57604
  positionId,
56596
- timestamp,
56597
- chainId,
56598
- amount.toString(),
56599
- destinationAddress,
56600
- actionHash
56601
- ];
56602
- const messageHash = (0, import_ethers15.solidityPackedKeccak256)(types, values);
56603
- const messageHashBytes = (0, import_ethers15.getBytes)(messageHash);
56604
- const signature = await signer.signMessage(messageHashBytes);
57605
+ totalDeduction: amount.toString(),
57606
+ withdrawalAddress: destinationAddress,
57607
+ quantumTimestamp: timestamp
57608
+ });
56605
57609
  return {
56606
57610
  positionId,
56607
57611
  timestamp,
@@ -56650,29 +57654,11 @@ async function generateExtendAuthorization(positionId, newTerm, chainId, signerO
56650
57654
  const signer = signerOrPrecomputed;
56651
57655
  const timestamp = calculateNextQuantumTimestamp();
56652
57656
  const action = "extend-position";
56653
- const actionHash = (0, import_ethers16.keccak256)((0, import_ethers16.toUtf8Bytes)(action));
56654
- const types = [
56655
- "bytes32",
56656
- // positionId
56657
- "uint256",
56658
- // timestamp
56659
- "uint256",
56660
- // chainId
56661
- "uint256",
56662
- // newTerm (extension term in months)
56663
- "bytes32"
56664
- // actionHash
56665
- ];
56666
- const values = [
57657
+ const signature = await signBorrowerAuthorization712(signer, "RenewRequest", chainId, {
56667
57658
  positionId,
56668
- timestamp,
56669
- chainId,
56670
- newTerm,
56671
- actionHash
56672
- ];
56673
- const messageHash = (0, import_ethers16.solidityPackedKeccak256)(types, values);
56674
- const messageHashBytes = (0, import_ethers16.getBytes)(messageHash);
56675
- const signature = await signer.signMessage(messageHashBytes);
57659
+ selectedTerm: newTerm,
57660
+ quantumTimestamp: timestamp
57661
+ });
56676
57662
  return {
56677
57663
  positionId,
56678
57664
  timestamp,
@@ -56907,6 +57893,7 @@ var ServerSession = class {
56907
57893
  store;
56908
57894
  onSignaturePrompt;
56909
57895
  onSignatureResolved;
57896
+ onSessionRestored;
56910
57897
  now;
56911
57898
  fetchImpl;
56912
57899
  cached = null;
@@ -56947,6 +57934,7 @@ var ServerSession = class {
56947
57934
  this.store = opts.persistSession === false ? null : opts.sessionStore ?? createDefaultSessionStore();
56948
57935
  this.onSignaturePrompt = opts.onSignaturePrompt;
56949
57936
  this.onSignatureResolved = opts.onSignatureResolved;
57937
+ this.onSessionRestored = opts.onSessionRestored;
56950
57938
  this.now = opts.now ?? (() => Math.floor(Date.now() / 1e3));
56951
57939
  this.fetchImpl = opts.fetchImpl ?? ((...a) => fetch(...a));
56952
57940
  }
@@ -57027,7 +58015,7 @@ var ServerSession = class {
57027
58015
  */
57028
58016
  async logout() {
57029
58017
  const cached = this.cached;
57030
- const token = cached && cached.expiresAt > this.now() ? cached.token : await this.getValidToken({ silent: true }).catch(() => null);
58018
+ const token = cached && cached.expiresAt > this.now() ? cached.token : await this.tryResolveSilently(this.generation, false).then((session) => session?.token ?? null).catch(() => null);
57031
58019
  await this.clearPersisted();
57032
58020
  if (!token)
57033
58021
  return;
@@ -57099,8 +58087,9 @@ var ServerSession = class {
57099
58087
  *
57100
58088
  * `gen` is the caller's clear-generation snapshot: writes to `this.cached`
57101
58089
  * and the store are skipped if a `clearPersisted()` landed meanwhile.
58090
+ * `announce` gates `onSessionRestored` for the two persisted-store outcomes.
57102
58091
  */
57103
- async tryResolveSilently(gen) {
58092
+ async tryResolveSilently(gen, announce = true) {
57104
58093
  const nowSec = this.now();
57105
58094
  if (this.cached && this.cached.expiresAt - REFRESH_LEEWAY_SECONDS > nowSec) {
57106
58095
  return this.cached;
@@ -57115,6 +58104,8 @@ var ServerSession = class {
57115
58104
  };
57116
58105
  if (gen === this.generation)
57117
58106
  this.cached = adopted;
58107
+ if (announce)
58108
+ this.onSessionRestored?.();
57118
58109
  return adopted;
57119
58110
  }
57120
58111
  try {
@@ -57123,6 +58114,8 @@ var ServerSession = class {
57123
58114
  this.persist(persisted.payload, session);
57124
58115
  this.cached = session;
57125
58116
  }
58117
+ if (announce)
58118
+ this.onSessionRestored?.();
57126
58119
  return session;
57127
58120
  } catch (error) {
57128
58121
  if (!isLoginRejection(error))
@@ -60208,6 +61201,10 @@ function normalizePkpId(pkpId) {
60208
61201
  }
60209
61202
  return pkpId;
60210
61203
  }
61204
+ function isNormalizedChipotlePkpId(pkpId) {
61205
+ const rawId = pkpId.startsWith("0x") ? pkpId.slice(2) : pkpId;
61206
+ return rawId.length === 40;
61207
+ }
60211
61208
  function padPkpIdForSubgraph(pkpId) {
60212
61209
  const raw = pkpId.startsWith("0x") ? pkpId.slice(2) : pkpId;
60213
61210
  if (raw.length === 40) {
@@ -60492,7 +61489,7 @@ var LoanQuery = class {
60492
61489
  batch.map(async (loan) => {
60493
61490
  try {
60494
61491
  const rawId = loan.pkpId?.startsWith("0x") ? loan.pkpId.slice(2) : loan.pkpId;
60495
- const isChipotlePkpId2 = typeof rawId === "string" && rawId.length === 40 && !rawId.toLowerCase().startsWith("04");
61492
+ const isChipotlePkpId2 = typeof rawId === "string" && isNormalizedChipotlePkpId(rawId);
60496
61493
  if (isChipotlePkpId2) {
60497
61494
  if (this.config.positionManagerCoreAddress && this.config.provider) {
60498
61495
  const pmContract = new import_ethers25.Contract(
@@ -60819,6 +61816,7 @@ function createLoanQuery(config) {
60819
61816
  );
60820
61817
  }
60821
61818
  }
61819
+ var STATIC_CALL_DIAGNOSTIC_TIMEOUT_MS = 5e3;
60822
61820
  var WithdrawalAddressModule = class {
60823
61821
  config;
60824
61822
  graphClient;
@@ -60864,13 +61862,17 @@ var WithdrawalAddressModule = class {
60864
61862
  const reg = this.getRegistry();
60865
61863
  if (!reg.success)
60866
61864
  return reg;
61865
+ const normalized = normalizeBitcoinAddress(btcAddress2);
60867
61866
  try {
60868
- const tx2 = await reg.value.addAddress(
60869
- normalizeBitcoinAddress(btcAddress2)
60870
- );
61867
+ const tx2 = await reg.value.addAddress(normalized);
60871
61868
  return success(tx2);
60872
61869
  } catch (error) {
60873
- return this.txFailure("addAddress", error, btcAddress2);
61870
+ return this.txFailure(
61871
+ "addAddress",
61872
+ error,
61873
+ btcAddress2,
61874
+ await this.staticCallDiagnostic(reg.value, "addAddress", normalized)
61875
+ );
60874
61876
  }
60875
61877
  }
60876
61878
  /** Remove a Bitcoin address from the caller's allowlist (effective immediately). */
@@ -60878,13 +61880,17 @@ var WithdrawalAddressModule = class {
60878
61880
  const reg = this.getRegistry();
60879
61881
  if (!reg.success)
60880
61882
  return reg;
61883
+ const normalized = normalizeBitcoinAddress(btcAddress2);
60881
61884
  try {
60882
- const tx2 = await reg.value.removeAddress(
60883
- normalizeBitcoinAddress(btcAddress2)
60884
- );
61885
+ const tx2 = await reg.value.removeAddress(normalized);
60885
61886
  return success(tx2);
60886
61887
  } catch (error) {
60887
- return this.txFailure("removeAddress", error, btcAddress2);
61888
+ return this.txFailure(
61889
+ "removeAddress",
61890
+ error,
61891
+ btcAddress2,
61892
+ await this.staticCallDiagnostic(reg.value, "removeAddress", normalized)
61893
+ );
60888
61894
  }
60889
61895
  }
60890
61896
  /**
@@ -60980,16 +61986,59 @@ var WithdrawalAddressModule = class {
60980
61986
  }
60981
61987
  return success(void 0);
60982
61988
  }
60983
- txFailure(op, error, context) {
61989
+ /**
61990
+ * Ask the node for the reason a failed write did not carry.
61991
+ *
61992
+ * A failing `eth_estimateGas` frequently answers with NOTHING to decode — ethers renders that
61993
+ * as `missing revert data ... data=null, reason=null, revert=null`, which names no cause and
61994
+ * cannot distinguish "the contract rejected this" from "the RPC hiccuped". An `eth_call` of the
61995
+ * same calldata usually does carry the revert reason or custom-error selector, so this runs one
61996
+ * and folds the answer into the reported error.
61997
+ *
61998
+ * Three deliberate properties:
61999
+ *
62000
+ * 1. It runs ONLY after the write has already failed. Gating the write on a static call would
62001
+ * let a flaky endpoint — precisely the condition this exists to diagnose — block an add that
62002
+ * would otherwise have succeeded.
62003
+ * 2. It costs NO extra signature. `staticCall` is `eth_call`: a node read, never a wallet prompt.
62004
+ * 3. It can never throw. A diagnostic that escapes would replace the real cause with itself.
62005
+ * (The `try/catch` here is the authorized exception to CLAUDE.md's forbidden-patterns rule;
62006
+ * it swallows nothing — every branch returns text that is reported alongside the original.)
62007
+ *
62008
+ * A static call that SUCCEEDS is itself a finding: the contract accepts this call, so the
62009
+ * failure lay outside contract logic (RPC, gas, or nonce).
62010
+ */
62011
+ async staticCallDiagnostic(registry, op, normalizedAddress) {
62012
+ try {
62013
+ await Promise.race([
62014
+ registry[op].staticCall(normalizedAddress),
62015
+ // The failure being diagnosed is often an unresponsive endpoint, so the diagnostic must
62016
+ // not inherit that hang — the user is waiting on this error message.
62017
+ new Promise(
62018
+ (_, reject) => setTimeout(
62019
+ () => reject(new Error("static call timed out after 5s")),
62020
+ STATIC_CALL_DIAGNOSTIC_TIMEOUT_MS
62021
+ )
62022
+ )
62023
+ ]);
62024
+ return "static call SUCCEEDED \u2014 the contract accepts this call, so the failure was not contract logic (RPC, gas, or nonce)";
62025
+ } catch (diagnostic) {
62026
+ const code = typeof diagnostic === "object" && diagnostic !== null ? diagnostic.code : void 0;
62027
+ const msg = diagnostic instanceof Error ? diagnostic.message : String(diagnostic);
62028
+ return typeof code === "string" ? `static call reverted [${code}]: ${msg}` : `static call failed: ${msg}`;
62029
+ }
62030
+ }
62031
+ txFailure(op, error, context, diagnostic) {
60984
62032
  const msg = error instanceof Error ? error.message : String(error);
62033
+ const detail = diagnostic ? `${msg} \u2014 ${diagnostic}` : msg;
60985
62034
  return failure(
60986
62035
  new SDKError({
60987
62036
  code: `SDK_WITHDRAWAL_REGISTRY_${op.toUpperCase()}_FAILED`,
60988
- message: `WithdrawalAddressRegistry.${op} failed: ${msg}`,
62037
+ message: `WithdrawalAddressRegistry.${op} failed: ${detail}`,
60989
62038
  category: "CONTRACT",
60990
62039
  severity: "MEDIUM",
60991
62040
  originalError: error instanceof Error ? error : new Error(String(error)),
60992
- context: { op, context }
62041
+ context: { op, context, diagnostic }
60993
62042
  })
60994
62043
  );
60995
62044
  }
@@ -62067,6 +63116,210 @@ function normalizePkpId2(pkpId) {
62067
63116
  }
62068
63117
  return pkpId;
62069
63118
  }
63119
+ function applyLoanEventsFilter(events, opts) {
63120
+ const { wantsEvent, fromTimestamp, toTimestamp, fromBlock, toBlock, limit } = opts;
63121
+ const inBounds = (e) => {
63122
+ const ts = e?.timestamp;
63123
+ const bn = e?.blockNumber;
63124
+ try {
63125
+ if (fromTimestamp !== void 0 && ts !== void 0 && BigInt(ts) < BigInt(fromTimestamp))
63126
+ return false;
63127
+ if (toTimestamp !== void 0 && ts !== void 0 && BigInt(ts) > BigInt(toTimestamp))
63128
+ return false;
63129
+ if (fromBlock !== void 0 && bn !== void 0 && BigInt(bn) < BigInt(fromBlock))
63130
+ return false;
63131
+ if (toBlock !== void 0 && bn !== void 0 && BigInt(bn) > BigInt(toBlock))
63132
+ return false;
63133
+ } catch {
63134
+ return true;
63135
+ }
63136
+ return true;
63137
+ };
63138
+ const narrow = (list, kind) => wantsEvent(kind) ? (list ?? []).filter(inBounds).slice(0, limit) : [];
63139
+ const single = (value, kind) => value && wantsEvent(kind) && inBounds(value) ? value : void 0;
63140
+ const filtered = {
63141
+ ...events,
63142
+ positionCreated: single(events.positionCreated, "positionCreated"),
63143
+ payments: narrow(events.payments, "payment"),
63144
+ statusUpdates: narrow(events.statusUpdates, "status"),
63145
+ liquidation: single(events.liquidation, "liquidation"),
63146
+ mints: narrow(events.mints, "mint"),
63147
+ withdrawals: narrow(events.withdrawals, "withdrawal"),
63148
+ renewals: narrow(events.renewals, "renewal"),
63149
+ operationFailures: narrow(events.operationFailures, "operationFailure"),
63150
+ mintRequests: narrow(events.mintRequests, "mintRequest"),
63151
+ burnRequests: narrow(events.burnRequests, "burnRequest"),
63152
+ collateralEvents: narrow(events.collateralEvents, "collateralEvent"),
63153
+ mintingFees: narrow(events.mintingFees, "mintingFee"),
63154
+ renewalFees: narrow(events.renewalFees, "renewalFee"),
63155
+ totalEvents: 0
63156
+ };
63157
+ 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;
63158
+ return filtered;
63159
+ }
63160
+ function hasLoanEventsFilter(filter2) {
63161
+ if (!filter2)
63162
+ return false;
63163
+ 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;
63164
+ }
63165
+ var WALLET_LOAN_EVENTS_QUERY = `
63166
+ query GetWalletLoanEvents($borrower: Bytes!, $first: Int!, $limit: Int!, $orderDirection: OrderDirection!) {
63167
+ positions(where: { borrower: $borrower }, first: $first, orderBy: id) {
63168
+ id
63169
+ payments(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63170
+ id
63171
+ payer { id }
63172
+ amount
63173
+ type
63174
+ transactionHash
63175
+ timestamp
63176
+ blockNumber
63177
+ logIndex
63178
+ newDebt
63179
+ newCollateralRatio
63180
+ }
63181
+ statusUpdates(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63182
+ id
63183
+ oldStatus
63184
+ newStatus
63185
+ reason
63186
+ timestamp
63187
+ blockNumber
63188
+ transactionHash
63189
+ }
63190
+ liquidation {
63191
+ id
63192
+ liquidator
63193
+ liquidatedAmount
63194
+ collateralSeized
63195
+ transactionHash
63196
+ timestamp
63197
+ blockNumber
63198
+ commitHash
63199
+ commitTimestamp
63200
+ revealDelay
63201
+ }
63202
+ withdrawals(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63203
+ id
63204
+ withdrawalAmount
63205
+ withdrawalAddress
63206
+ networkFee
63207
+ timestamp
63208
+ blockNumber
63209
+ transactionHash
63210
+ logIndex
63211
+ }
63212
+ renewals(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63213
+ id
63214
+ extensionTerm
63215
+ extensionFee
63216
+ newExpiryDate
63217
+ timestamp
63218
+ blockNumber
63219
+ transactionHash
63220
+ logIndex
63221
+ }
63222
+ operationFailures(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63223
+ id
63224
+ operationType
63225
+ reason
63226
+ errorCode
63227
+ amount
63228
+ timestamp
63229
+ blockNumber
63230
+ transactionHash
63231
+ logIndex
63232
+ }
63233
+ mintRequests(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63234
+ id
63235
+ pkpId
63236
+ borrower { id }
63237
+ mintAmount
63238
+ originationFee
63239
+ newDebt
63240
+ newCollateralRatio
63241
+ btcPrice
63242
+ quantumTimestamp
63243
+ opId
63244
+ timestamp
63245
+ blockNumber
63246
+ transactionHash
63247
+ logIndex
63248
+ }
63249
+ burnRequests(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63250
+ id
63251
+ pkpId
63252
+ borrower { id }
63253
+ burnAmount
63254
+ remainingDebt
63255
+ newCollateralRatio
63256
+ opId
63257
+ timestamp
63258
+ blockNumber
63259
+ transactionHash
63260
+ logIndex
63261
+ }
63262
+ mintingFees(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63263
+ id
63264
+ borrower { id }
63265
+ feeAmount
63266
+ mintAmount
63267
+ newDebt
63268
+ btcPrice
63269
+ quantumTimestamp
63270
+ timestamp
63271
+ blockNumber
63272
+ transactionHash
63273
+ logIndex
63274
+ }
63275
+ renewalFees(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63276
+ id
63277
+ borrower { id }
63278
+ feeAmount
63279
+ extensionTerm
63280
+ newExpiryDate
63281
+ timestamp
63282
+ blockNumber
63283
+ transactionHash
63284
+ logIndex
63285
+ }
63286
+ positionCreatedEvents(first: 1, orderBy: timestamp, orderDirection: asc) {
63287
+ id
63288
+ pkpId
63289
+ borrower { id }
63290
+ requestedCollateralRatio
63291
+ selectedTerm
63292
+ expiryAt
63293
+ timestamp
63294
+ blockNumber
63295
+ transactionHash
63296
+ }
63297
+ }
63298
+ ucdmintEvents(where: { position_: { borrower: $borrower } }, first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63299
+ id
63300
+ position { id }
63301
+ amount
63302
+ proof
63303
+ minter { id }
63304
+ isCommunityMint
63305
+ timestamp
63306
+ blockNumber
63307
+ transactionHash
63308
+ }
63309
+ collateralEvents(where: { position_: { borrower: $borrower } }, first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63310
+ id
63311
+ position { id }
63312
+ eventType
63313
+ networkFee
63314
+ remainingCollateral
63315
+ collateralRatio
63316
+ timestamp
63317
+ blockNumber
63318
+ transactionHash
63319
+ logIndex
63320
+ }
63321
+ }
63322
+ `;
62070
63323
  var DiamondHandsGraph = class {
62071
63324
  client;
62072
63325
  defaultPageSize;
@@ -62172,7 +63425,7 @@ var DiamondHandsGraph = class {
62172
63425
  /**
62173
63426
  * Get user positions from subgraph
62174
63427
  */
62175
- async getUserPositions(userAddress, first, skip, orderBy, orderDirection) {
63428
+ async getUserPositionsOnly(userAddress, first, skip, orderBy, orderDirection) {
62176
63429
  const query = `
62177
63430
  query GetUserPositions($borrower: Bytes!, $first: Int, $skip: Int, $orderBy: Position_orderBy, $orderDirection: OrderDirection) {
62178
63431
  user(id: $borrower) {
@@ -62213,17 +63466,28 @@ var DiamondHandsGraph = class {
62213
63466
  query,
62214
63467
  variables
62215
63468
  );
62216
- const total = await this.getTotalCountPaginated("{ borrower: $borrower }", {
62217
- borrower: userAddress.toLowerCase()
62218
- });
62219
63469
  let positions = [];
62220
63470
  if (result && result.user && Array.isArray(result.user.positions)) {
62221
63471
  positions = result.user.positions.filter((p) => p != null).map((p) => this.transformGraphPositionToLoanData(p));
62222
63472
  }
62223
- return {
62224
- positions,
62225
- total
62226
- };
63473
+ return positions;
63474
+ }
63475
+ /**
63476
+ * Get user positions, plus an accurate total count.
63477
+ *
63478
+ * The count is a SECOND round trip (`getTotalCountPaginated`, which pages to handle
63479
+ * >1000 items). Callers that only need the rows should use `getUserPositionsOnly` and
63480
+ * skip it — the event paths did not, and paid for a count they immediately discarded on
63481
+ * every activity refresh.
63482
+ */
63483
+ async getUserPositions(userAddress, first, skip, orderBy, orderDirection) {
63484
+ const [positions, total] = await Promise.all([
63485
+ this.getUserPositionsOnly(userAddress, first, skip, orderBy, orderDirection),
63486
+ this.getTotalCountPaginated("{ borrower: $borrower }", {
63487
+ borrower: userAddress.toLowerCase()
63488
+ })
63489
+ ]);
63490
+ return { positions, total };
62227
63491
  }
62228
63492
  /**
62229
63493
  * Get user positions with enriched Bitcoin balance data
@@ -63049,32 +64313,24 @@ var DiamondHandsGraph = class {
63049
64313
  limit = 1e3,
63050
64314
  orderDirection = "desc"
63051
64315
  } = filter2 || {};
64316
+ const wantsEvent = (kind) => !eventTypes || eventTypes.includes(kind);
64317
+ const hasBounds = fromTimestamp !== void 0 || toTimestamp !== void 0 || fromBlock !== void 0 || toBlock !== void 0;
64318
+ const pageSize = hasBounds ? THE_GRAPH_MAX_BATCH_SIZE : limit;
64319
+ const buildPositionWhereClause = () => `where: { position: "${positionId.toLowerCase()}" }`;
63052
64320
  const shouldQuery = {
63053
- positionCreated: !eventTypes || eventTypes.includes("positionCreated"),
63054
- payment: !eventTypes || eventTypes.includes("payment"),
63055
- status: !eventTypes || eventTypes.includes("status"),
63056
- liquidation: !eventTypes || eventTypes.includes("liquidation"),
63057
- mint: !eventTypes || eventTypes.includes("mint"),
63058
- withdrawal: !eventTypes || eventTypes.includes("withdrawal"),
63059
- renewal: !eventTypes || eventTypes.includes("renewal"),
63060
- operationFailure: !eventTypes || eventTypes.includes("operationFailure"),
63061
- mintRequest: !eventTypes || eventTypes.includes("mintRequest"),
63062
- burnRequest: !eventTypes || eventTypes.includes("burnRequest"),
63063
- collateralEvent: !eventTypes || eventTypes.includes("collateralEvent"),
63064
- mintingFee: !eventTypes || eventTypes.includes("mintingFee"),
63065
- renewalFee: !eventTypes || eventTypes.includes("renewalFee")
63066
- };
63067
- const buildPositionWhereClause = () => {
63068
- const conditions = [`position: "${positionId.toLowerCase()}"`];
63069
- if (fromTimestamp)
63070
- conditions.push(`timestamp_gte: "${fromTimestamp}"`);
63071
- if (toTimestamp)
63072
- conditions.push(`timestamp_lte: "${toTimestamp}"`);
63073
- if (fromBlock)
63074
- conditions.push(`blockNumber_gte: "${fromBlock}"`);
63075
- if (toBlock)
63076
- conditions.push(`blockNumber_lte: "${toBlock}"`);
63077
- return `where: { ${conditions.join(", ")} }`;
64321
+ positionCreated: true,
64322
+ payment: true,
64323
+ status: true,
64324
+ liquidation: true,
64325
+ mint: true,
64326
+ withdrawal: true,
64327
+ renewal: true,
64328
+ operationFailure: true,
64329
+ mintRequest: true,
64330
+ burnRequest: true,
64331
+ collateralEvent: true,
64332
+ mintingFee: true,
64333
+ renewalFee: true
63078
64334
  };
63079
64335
  const query = `
63080
64336
  query GetLoanEvents($positionId: Bytes!, $limit: Int!, $orderDirection: OrderDirection!) {
@@ -63310,10 +64566,50 @@ var DiamondHandsGraph = class {
63310
64566
  `;
63311
64567
  const variables = {
63312
64568
  positionId: positionId.toLowerCase(),
63313
- limit,
64569
+ limit: pageSize,
63314
64570
  orderDirection
63315
64571
  };
63316
64572
  const result = await this.client.execute(query, variables);
64573
+ if (hasBounds) {
64574
+ const collections = [
64575
+ ["payments", result.position?.payments],
64576
+ ["statusUpdates", result.position?.statusUpdates],
64577
+ ["withdrawals", result.position?.withdrawals],
64578
+ ["renewals", result.position?.renewals],
64579
+ ["operationFailures", result.position?.operationFailures],
64580
+ ["mintRequests", result.position?.mintRequests],
64581
+ ["burnRequests", result.position?.burnRequests],
64582
+ ["mintingFees", result.position?.mintingFees],
64583
+ ["renewalFees", result.position?.renewalFees],
64584
+ ["mints", result.ucdmintEvents],
64585
+ ["collateralEvents", result.collateralEvents]
64586
+ ];
64587
+ const saturated = collections.filter(([, list]) => (list?.length ?? 0) >= pageSize).map(([name]) => name);
64588
+ if (saturated.length > 0) {
64589
+ log.warn(
64590
+ "[DiamondHandsGraph] bounded getLoanEvents page saturated \u2014 the filtered history may be incomplete",
64591
+ { positionId, pageSize, saturated }
64592
+ );
64593
+ }
64594
+ }
64595
+ const assembled = this.assembleLoanEvents(positionId, result);
64596
+ return applyLoanEventsFilter(assembled, {
64597
+ wantsEvent,
64598
+ fromTimestamp,
64599
+ toTimestamp,
64600
+ fromBlock,
64601
+ toBlock,
64602
+ limit
64603
+ });
64604
+ }
64605
+ /**
64606
+ * Map one position's raw event payload into `LoanEvents`.
64607
+ *
64608
+ * Extracted verbatim from getLoanEvents so the wallet-collapsed path produces
64609
+ * byte-identical objects by construction rather than by a second implementation
64610
+ * that has to be kept in step by hand.
64611
+ */
64612
+ assembleLoanEvents(positionId, result) {
63317
64613
  const rawCreated = result.positionCreatedEvents?.[0];
63318
64614
  const positionCreated = rawCreated ? {
63319
64615
  id: rawCreated.id,
@@ -63518,7 +64814,22 @@ var DiamondHandsGraph = class {
63518
64814
  * @returns One LoanEvents object per position; empty array if the wallet has none.
63519
64815
  */
63520
64816
  async getWalletLoanEvents(userAddress, filter2) {
63521
- const { positions } = await this.getUserPositions(userAddress);
64817
+ if (!hasLoanEventsFilter(filter2)) {
64818
+ return this.getWalletLoanEventsCollapsed(userAddress);
64819
+ }
64820
+ return this.getWalletLoanEventsFanout(userAddress, filter2);
64821
+ }
64822
+ /**
64823
+ * The per-position path: enumerate the wallet's positions, then one `GetLoanEvents` each.
64824
+ *
64825
+ * Used for filtered calls, and as the completeness fallback when the collapsed document
64826
+ * hits a page limit. Costs `1 + N` requests, which is exactly why it is not the default.
64827
+ */
64828
+ async getWalletLoanEventsFanout(userAddress, filter2) {
64829
+ const positions = await this.getUserPositionsOnly(
64830
+ userAddress,
64831
+ THE_GRAPH_MAX_BATCH_SIZE
64832
+ );
63522
64833
  const positionIds = positions.map((p) => p?.id != null ? String(p.id) : "").filter((id) => id.length > 0);
63523
64834
  if (positionIds.length === 0)
63524
64835
  return [];
@@ -63533,6 +64844,81 @@ var DiamondHandsGraph = class {
63533
64844
  }
63534
64845
  return results;
63535
64846
  }
64847
+ /**
64848
+ * The whole wallet's event history in ONE request.
64849
+ *
64850
+ * Replaces `1 + N` round trips (one position enumeration plus one per position) with a
64851
+ * single document. Measured on Sepolia: a wallet holding 44 positions cost 46 requests
64852
+ * per activity refresh against a per-wallet budget of 30/min — this makes it 1.
64853
+ *
64854
+ * Three subgraph facts make it possible, all verified against the deployed schema rather
64855
+ * than assumed:
64856
+ * - ten event collections are `@derivedFrom` on Position, so they nest under a
64857
+ * borrower-filtered `positions(...)`;
64858
+ * - `positionCreatedEvents` is ALSO derived on Position — `getLoanEvents` queries it
64859
+ * top-level, which it never needed to;
64860
+ * - `ucdmintEvents` / `collateralEvents` are not derived and carry no `borrower`
64861
+ * field, but graph-node's nested `position_: { borrower }` filter reaches them.
64862
+ * Without that last one this would be two requests, not one.
64863
+ */
64864
+ async getWalletLoanEventsCollapsed(userAddress) {
64865
+ const borrower = userAddress.toLowerCase();
64866
+ const pageSize = THE_GRAPH_MAX_BATCH_SIZE;
64867
+ const result = await this.client.execute(
64868
+ WALLET_LOAN_EVENTS_QUERY,
64869
+ {
64870
+ borrower,
64871
+ first: pageSize,
64872
+ limit: pageSize,
64873
+ orderDirection: "desc"
64874
+ }
64875
+ );
64876
+ const positions = result.positions || [];
64877
+ const ucdmintEvents = result.ucdmintEvents || [];
64878
+ const collateralEvents = result.collateralEvents || [];
64879
+ const truncated = positions.length >= pageSize || ucdmintEvents.length >= pageSize || collateralEvents.length >= pageSize;
64880
+ if (truncated) {
64881
+ log.warn(
64882
+ "[DiamondHandsGraph] wallet event page limit reached \u2014 falling back to the per-position path to avoid returning a partial history",
64883
+ {
64884
+ borrower,
64885
+ pageSize,
64886
+ positions: positions.length,
64887
+ ucdmintEvents: ucdmintEvents.length,
64888
+ collateralEvents: collateralEvents.length
64889
+ }
64890
+ );
64891
+ return this.getWalletLoanEventsFanout(userAddress);
64892
+ }
64893
+ if (positions.length === 0)
64894
+ return [];
64895
+ const mintsByPosition = /* @__PURE__ */ new Map();
64896
+ for (const m of result.ucdmintEvents || []) {
64897
+ const key = m.position?.id;
64898
+ if (!key)
64899
+ continue;
64900
+ const bucket = mintsByPosition.get(key) || [];
64901
+ bucket.push(m);
64902
+ mintsByPosition.set(key, bucket);
64903
+ }
64904
+ const collateralByPosition = /* @__PURE__ */ new Map();
64905
+ for (const c of result.collateralEvents || []) {
64906
+ const key = c.position?.id;
64907
+ if (!key)
64908
+ continue;
64909
+ const bucket = collateralByPosition.get(key) || [];
64910
+ bucket.push(c);
64911
+ collateralByPosition.set(key, bucket);
64912
+ }
64913
+ return positions.map(
64914
+ (p) => this.assembleLoanEvents(p.id, {
64915
+ position: p,
64916
+ positionCreatedEvents: p.positionCreatedEvents || [],
64917
+ ucdmintEvents: mintsByPosition.get(p.id) || [],
64918
+ collateralEvents: collateralByPosition.get(p.id) || []
64919
+ })
64920
+ );
64921
+ }
63536
64922
  // ============================================================================
63537
64923
  // Protocol-wide Events
63538
64924
  // ============================================================================
@@ -68392,16 +69778,6 @@ function createMockTokenManager(config) {
68392
69778
  }
68393
69779
  }
68394
69780
  var import_dh_lit_actions2 = __toESM2(require_pkg_src2());
68395
- var TelegramBot = null;
68396
- try {
68397
- if (typeof window === "undefined" && typeof global !== "undefined") {
68398
- TelegramBot = null /* stubbed post-build: dh-mcp never uses telegram (F-PUB-2) */;
68399
- }
68400
- } catch (error) {
68401
- log.warn("Telegram bot API not available", {
68402
- error: error instanceof Error ? error.message : String(error)
68403
- });
68404
- }
68405
69781
  function formatMintMessage(mintAmount, loanId, txHash) {
68406
69782
  return `\u2705 DH SDK: ${mintAmount} UCD was minted for loan id: ${loanId} Tx: https://sepolia.etherscan.io/tx/${txHash}`;
68407
69783
  }
@@ -69027,7 +70403,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
69027
70403
  persistSession: config.sessionPersistence?.enabled,
69028
70404
  sessionStore: config.sessionPersistence?.store,
69029
70405
  onSignaturePrompt: config.onSessionSignaturePrompt,
69030
- onSignatureResolved: config.onSessionSignatureResolved
70406
+ onSignatureResolved: config.onSessionSignatureResolved,
70407
+ onSessionRestored: config.onSessionRestored
69031
70408
  });
69032
70409
  }
69033
70410
  const contractManagerResult = createContractManager({
@@ -80462,7 +81839,7 @@ mime-types/index.js:
80462
81839
  *)
80463
81840
 
80464
81841
  axios/dist/node/axios.cjs:
80465
- (*! Axios v1.19.0 Copyright (c) 2026 Matt Zabriskie and contributors *)
81842
+ (*! Axios v1.20.0 Copyright (c) 2026 Matt Zabriskie and contributors *)
80466
81843
 
80467
81844
  safe-buffer/index.js:
80468
81845
  (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)