@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/connector.js CHANGED
@@ -14313,6 +14313,9 @@ var require_pkg_src = __commonJS({
14313
14313
  });
14314
14314
  var index_exports = {};
14315
14315
  __export3(index_exports, {
14316
+ BORROWER_AUTHORIZATION_ENCODE_TYPES: () => BORROWER_AUTHORIZATION_ENCODE_TYPES,
14317
+ BORROWER_AUTHORIZATION_FIELDS: () => BORROWER_AUTHORIZATION_FIELDS,
14318
+ BORROWER_AUTHORIZATION_PRIMARY_TYPES: () => BORROWER_AUTHORIZATION_PRIMARY_TYPES,
14316
14319
  CHIPOTLE_DEPLOYMENTS: () => CHIPOTLE_DEPLOYMENTS,
14317
14320
  DEFAULT_CACHE_CONFIG: () => DEFAULT_CACHE_CONFIG,
14318
14321
  DEFAULT_DEBUG_CONFIG: () => DEFAULT_DEBUG_CONFIG,
@@ -14325,6 +14328,8 @@ var require_pkg_src = __commonJS({
14325
14328
  PerformanceTracker: () => PerformanceTracker,
14326
14329
  RetryStrategy: () => RetryStrategy,
14327
14330
  analyzeError: () => analyzeError,
14331
+ borrowerAuthorizationTypes: () => borrowerAuthorizationTypes,
14332
+ buildBorrowerAuthorizationDomain: () => buildBorrowerAuthorizationDomain,
14328
14333
  calculateDelay: () => calculateDelay,
14329
14334
  cidToHex: () => cidToHex,
14330
14335
  classifyError: () => classifyError,
@@ -14571,30 +14576,30 @@ var require_pkg_src = __commonJS({
14571
14576
  }
14572
14577
  },
14573
14578
  btcTransactionSigner: {
14574
- cid: "QmakWzTce8NH1Jkgv1xwg83Bg9WmF2UG1Mq76pDYDSwwUp",
14579
+ cid: "QmVi1BYdxvCX3QUhXwPtP6FjWMzqSPtXzrS54YsXjTgjYf",
14575
14580
  authorizedCidHex: cidToHex(
14576
- "QmakWzTce8NH1Jkgv1xwg83Bg9WmF2UG1Mq76pDYDSwwUp"
14581
+ "QmVi1BYdxvCX3QUhXwPtP6FjWMzqSPtXzrS54YsXjTgjYf"
14577
14582
  ),
14578
14583
  name: "Btc Transaction Signer",
14579
14584
  description: "Production Btc Transaction Signer",
14580
14585
  version: "1.1.1",
14581
14586
  deployed: true,
14582
- deployedAt: 1786465606156,
14583
- size: 67999,
14584
- hash: "83f3644c68819215e05ba8db3225571354a009458fc1437f606df6cb9142d3f9"
14587
+ deployedAt: 1787923905597,
14588
+ size: 70646,
14589
+ hash: "37c3bb72a660c8275d92e1b73f9482742d86b64789480b9246304c0ca1bab47a"
14585
14590
  },
14586
14591
  ucdMintValidator: {
14587
- cid: "Qmd8jgKRceLvf5aoTtwdXG2JqMoBK5cRJwrvEtQkgvbFbx",
14592
+ cid: "QmUWR5fLiyimLT9TPXpYx3HgwNwkvR6MxjZ7hdeYCFodbc",
14588
14593
  authorizedCidHex: cidToHex(
14589
- "Qmd8jgKRceLvf5aoTtwdXG2JqMoBK5cRJwrvEtQkgvbFbx"
14594
+ "QmUWR5fLiyimLT9TPXpYx3HgwNwkvR6MxjZ7hdeYCFodbc"
14590
14595
  ),
14591
14596
  name: "Ucd Mint Validator",
14592
14597
  description: "Production Ucd Mint Validator",
14593
14598
  version: "1.2.1",
14594
14599
  deployed: true,
14595
- deployedAt: 1786465627201,
14596
- size: 82739,
14597
- hash: "2bdd9aebdaad58a43a4731d5b7284f2531b7a9caaf8caf5719d891c4ed33cb2e",
14600
+ deployedAt: 1787923919527,
14601
+ size: 86197,
14602
+ hash: "c2d80939746cc37f65ef2f63c6a3215b929214a63f10c78144e1f5c98320dabf",
14598
14603
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14599
14604
  pkp: {
14600
14605
  publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
@@ -14602,17 +14607,17 @@ var require_pkg_src = __commonJS({
14602
14607
  }
14603
14608
  },
14604
14609
  processPaymentValidator: {
14605
- cid: "QmNXVdysXDhCaQ1uNE2Vgjbuzy6yUEnnVgHzmDfNKXMU6z",
14610
+ cid: "QmXmXuMRAjMLdgKGyTf9KQdGwYrDp8DxkiF44TvSXDf7wF",
14606
14611
  authorizedCidHex: cidToHex(
14607
- "QmNXVdysXDhCaQ1uNE2Vgjbuzy6yUEnnVgHzmDfNKXMU6z"
14612
+ "QmXmXuMRAjMLdgKGyTf9KQdGwYrDp8DxkiF44TvSXDf7wF"
14608
14613
  ),
14609
14614
  name: "Process Payment Validator",
14610
14615
  description: "Production Process Payment Validator",
14611
14616
  version: "1.2.1",
14612
14617
  deployed: true,
14613
- deployedAt: 1786465654796,
14614
- size: 78736,
14615
- hash: "17191ecc9c009e0fa5ab52c876330beb2a9a75d30cccb92e7c0c04f169df088b",
14618
+ deployedAt: 1787923987153,
14619
+ size: 82217,
14620
+ hash: "13defa19614215ab3b1fe88955d69e530d13a09475396af932fe0e213637da2f",
14616
14621
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14617
14622
  pkp: {
14618
14623
  publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
@@ -14620,17 +14625,17 @@ var require_pkg_src = __commonJS({
14620
14625
  }
14621
14626
  },
14622
14627
  extendPositionValidator: {
14623
- cid: "QmYwBsyrhGfHWyRKx549G4tKHxsBLAuRUHcecigeUCkFav",
14628
+ cid: "QmU8h99EEVEsQkxroXiYqLsKZw9gNjE6N5CcTpE9aUc12m",
14624
14629
  authorizedCidHex: cidToHex(
14625
- "QmYwBsyrhGfHWyRKx549G4tKHxsBLAuRUHcecigeUCkFav"
14630
+ "QmU8h99EEVEsQkxroXiYqLsKZw9gNjE6N5CcTpE9aUc12m"
14626
14631
  ),
14627
14632
  name: "Extend Position Validator",
14628
14633
  description: "Production Extend Position Validator",
14629
14634
  version: "1.2.1",
14630
14635
  deployed: true,
14631
- deployedAt: 1786465681874,
14632
- size: 76515,
14633
- hash: "1d4e085335af80f194a663a577876902c83015177e95906a0b461fa93bd5da08",
14636
+ deployedAt: 1787923999294,
14637
+ size: 79975,
14638
+ hash: "31c1aaf883ef22f37681ddb0a4a949be5c05304b6aef178989475a2da935ef9a",
14634
14639
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14635
14640
  pkp: {
14636
14641
  publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
@@ -14638,17 +14643,17 @@ var require_pkg_src = __commonJS({
14638
14643
  }
14639
14644
  },
14640
14645
  btcWithdrawal: {
14641
- cid: "QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh",
14646
+ cid: "QmZQWET9pzrVD4gwQuSzYZmqa24JrUNtnnGFDd513sxMCY",
14642
14647
  authorizedCidHex: cidToHex(
14643
- "QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh"
14648
+ "QmZQWET9pzrVD4gwQuSzYZmqa24JrUNtnnGFDd513sxMCY"
14644
14649
  ),
14645
14650
  name: "Btc Withdrawal",
14646
14651
  description: "Production Btc Withdrawal",
14647
14652
  version: "1.2.7",
14648
14653
  deployed: true,
14649
- deployedAt: 1786446046614,
14650
- size: 97456,
14651
- hash: "3cae8250861832f91ee3c573abeb50ff27b9acd34148176071cbfbabb359fc91",
14654
+ deployedAt: 1787924017769,
14655
+ size: 100069,
14656
+ hash: "4f8e27414e4da235e63d6ae1325c63f3d2fb956464515a21aa007a99935f0f13",
14652
14657
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14653
14658
  pkp: {
14654
14659
  publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
@@ -14760,30 +14765,30 @@ var require_pkg_src = __commonJS({
14760
14765
  hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
14761
14766
  },
14762
14767
  agentModuleExecutor: {
14763
- cid: "QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ",
14768
+ cid: "QmcD65vuremot5fsHVgp9JBAmei6gAaEtm5mdtLP7Yt9Kf",
14764
14769
  authorizedCidHex: cidToHex(
14765
- "QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ"
14770
+ "QmcD65vuremot5fsHVgp9JBAmei6gAaEtm5mdtLP7Yt9Kf"
14766
14771
  ),
14767
14772
  name: "Agent Module Executor",
14768
14773
  description: "Production Agent Module Executor",
14769
14774
  version: "1.1.1",
14770
14775
  deployed: true,
14771
- deployedAt: 1786446108348,
14772
- size: 11655,
14773
- hash: "d4e2149f843d6c2699fc61114d54b268ba4ed2c46ebdaee1145e0f101ec2a1ec"
14776
+ deployedAt: 1787924032013,
14777
+ size: 13878,
14778
+ hash: "a7f0204700912e26e5a354bee13a1242a2baa218643b3bb22d28481f67f9baf4"
14774
14779
  },
14775
14780
  staleSpendRecoveryValidator: {
14776
- cid: "QmXQWT8V4wjuvH8BbC7xrkYxsVu5AKfvfWcS7jnYfrexYm",
14781
+ cid: "QmNuwo4PT4AikAmhMdZgPWCb2mJDwWa9TnUqrqvofjbrT8",
14777
14782
  authorizedCidHex: cidToHex(
14778
- "QmXQWT8V4wjuvH8BbC7xrkYxsVu5AKfvfWcS7jnYfrexYm"
14783
+ "QmNuwo4PT4AikAmhMdZgPWCb2mJDwWa9TnUqrqvofjbrT8"
14779
14784
  ),
14780
14785
  name: "Stale Spend Recovery Validator",
14781
14786
  description: "Production Stale Spend Recovery Validator",
14782
14787
  version: "1.1.2",
14783
14788
  deployed: true,
14784
- deployedAt: 1785173285829,
14785
- size: 37108,
14786
- hash: "04de5fc5b6f5131dc1544e3d3d187a1f9ef9616ffd12483d119f9102b3671791",
14789
+ deployedAt: 1787924048772,
14790
+ size: 41424,
14791
+ hash: "3c5f028d2bef4344768462993616d45e30d9d44ef126e04d6eb579821d57d99c",
14787
14792
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
14788
14793
  pkp: {
14789
14794
  publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
@@ -14791,17 +14796,17 @@ var require_pkg_src = __commonJS({
14791
14796
  }
14792
14797
  },
14793
14798
  btcUtxoInvalidator: {
14794
- cid: "Qmf4Ze8yhnQhHbnX5RPgJrC7Jw1aA3gbpfpd52kFg7fd1m",
14799
+ cid: "QmaNGeWut7EiGwW4zUc2sFSt7RY5NWFgxYboyG333TwrJf",
14795
14800
  authorizedCidHex: cidToHex(
14796
- "Qmf4Ze8yhnQhHbnX5RPgJrC7Jw1aA3gbpfpd52kFg7fd1m"
14801
+ "QmaNGeWut7EiGwW4zUc2sFSt7RY5NWFgxYboyG333TwrJf"
14797
14802
  ),
14798
14803
  name: "Btc Utxo Invalidator",
14799
14804
  description: "Production Btc Utxo Invalidator",
14800
14805
  version: "1.0.0",
14801
14806
  deployed: true,
14802
- deployedAt: 1786465704240,
14803
- size: 62553,
14804
- hash: "1dcea2b49e545c423195be22e072dc5e3039ed1c95a8490b23505956029f5b33"
14807
+ deployedAt: 1787924133241,
14808
+ size: 66026,
14809
+ hash: "603bc50920d7f1dee77086f2c518d9e2922ab3858a419d3fbea8221ea3a6d9e9"
14805
14810
  }
14806
14811
  };
14807
14812
  function getDeploymentsForNetwork(network) {
@@ -15560,6 +15565,101 @@ ${errorReport}`);
15560
15565
  var SECONDS_PER_DAY = 86400;
15561
15566
  var DAYS_PER_MONTH = 30;
15562
15567
  var LIT_ACTION_ETH_RPC_TIMEOUT_MS = 8e3;
15568
+ var PINNED_CONTRACT_ADDRESSES = {
15569
+ 1: {
15570
+ PositionManager: "0x12A1836e56139ccaD8722B89519d84233efc224B",
15571
+ LoanOperationsManagerModule: "0x2561974A40F1AEed1251d0A090A83cF8536FB9E9",
15572
+ BTCSpendAuthorizer: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
15573
+ BitcoinProviderRegistry: "0x4ab3Fb96e02893Ed6FAa61bad1918390c8DbbFFC",
15574
+ LITActionValidator: "0xD2c5d59c2CC5c409AC65ce0A817236aeC6869512",
15575
+ PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C"
15576
+ },
15577
+ 11155111: {
15578
+ PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
15579
+ LoanOperationsManagerModule: "0x3e05e760a87715207b7F4e8fD35EF7559BcA72C0",
15580
+ BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
15581
+ BitcoinProviderRegistry: "0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",
15582
+ LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
15583
+ PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9"
15584
+ }
15585
+ };
15586
+ function getPinnedContractAddresses(chainId) {
15587
+ return PINNED_CONTRACT_ADDRESSES[chainId] ?? null;
15588
+ }
15589
+ var PROTOCOL_EIP712_DOMAIN_NAME = "DiamondHands.Protocol";
15590
+ var PROTOCOL_EIP712_DOMAIN_VERSION = "1";
15591
+ var BORROWER_AUTHORIZATION_PRIMARY_TYPES = {
15592
+ MINT: "MintRequest",
15593
+ REPAY: "RepayRequest",
15594
+ RENEW: "RenewRequest",
15595
+ WITHDRAW: "WithdrawRequest"
15596
+ };
15597
+ var BORROWER_AUTHORIZATION_FIELDS = {
15598
+ MintRequest: [
15599
+ { name: "positionId", type: "bytes32" },
15600
+ { name: "mintAmount", type: "uint256" },
15601
+ { name: "quantumTimestamp", type: "uint256" }
15602
+ ],
15603
+ RepayRequest: [
15604
+ { name: "positionId", type: "bytes32" },
15605
+ { name: "paymentAmount", type: "uint256" },
15606
+ { name: "quantumTimestamp", type: "uint256" }
15607
+ ],
15608
+ RenewRequest: [
15609
+ { name: "positionId", type: "bytes32" },
15610
+ { name: "selectedTerm", type: "uint256" },
15611
+ { name: "quantumTimestamp", type: "uint256" }
15612
+ ],
15613
+ WithdrawRequest: [
15614
+ { name: "positionId", type: "bytes32" },
15615
+ { name: "totalDeduction", type: "uint256" },
15616
+ { name: "withdrawalAddress", type: "string" },
15617
+ { name: "quantumTimestamp", type: "uint256" }
15618
+ ]
15619
+ };
15620
+ var BORROWER_AUTHORIZATION_ENCODE_TYPES = {
15621
+ MintRequest: "MintRequest(bytes32 positionId,uint256 mintAmount,uint256 quantumTimestamp)",
15622
+ RepayRequest: "RepayRequest(bytes32 positionId,uint256 paymentAmount,uint256 quantumTimestamp)",
15623
+ RenewRequest: "RenewRequest(bytes32 positionId,uint256 selectedTerm,uint256 quantumTimestamp)",
15624
+ WithdrawRequest: "WithdrawRequest(bytes32 positionId,uint256 totalDeduction,string withdrawalAddress,uint256 quantumTimestamp)"
15625
+ };
15626
+ function borrowerAuthorizationTypes(primaryType) {
15627
+ const fields = BORROWER_AUTHORIZATION_FIELDS[primaryType];
15628
+ if (!fields) {
15629
+ throw new Error(
15630
+ `Unknown borrower authorization primary type "${primaryType}"; expected one of ${Object.keys(BORROWER_AUTHORIZATION_FIELDS).join(", ")}`
15631
+ );
15632
+ }
15633
+ return { [primaryType]: fields.map((field) => ({ ...field })) };
15634
+ }
15635
+ function buildBorrowerAuthorizationDomain(chainId, verifyingContractOverride) {
15636
+ if (!Number.isInteger(chainId) || chainId <= 0) {
15637
+ throw new Error(
15638
+ `Borrower authorization domain requires a positive integer chainId, got ${String(chainId)}`
15639
+ );
15640
+ }
15641
+ const pinned = getPinnedContractAddresses(chainId);
15642
+ const pinnedLom = pinned?.LoanOperationsManagerModule;
15643
+ if (pinnedLom && verifyingContractOverride) {
15644
+ if (pinnedLom.toLowerCase() !== verifyingContractOverride.toLowerCase()) {
15645
+ throw new Error(
15646
+ `Refusing a caller-supplied verifyingContract that contradicts the pin for chainId ${chainId}: caller ${verifyingContractOverride}, pinned ${pinnedLom}`
15647
+ );
15648
+ }
15649
+ }
15650
+ const verifyingContract = pinnedLom ?? verifyingContractOverride;
15651
+ if (!verifyingContract) {
15652
+ throw new Error(
15653
+ `No pinned LoanOperationsManagerModule for chainId ${chainId} and no verifyingContract supplied; refusing to build a borrower authorization domain without one`
15654
+ );
15655
+ }
15656
+ return {
15657
+ name: PROTOCOL_EIP712_DOMAIN_NAME,
15658
+ version: PROTOCOL_EIP712_DOMAIN_VERSION,
15659
+ chainId,
15660
+ verifyingContract
15661
+ };
15662
+ }
15563
15663
  var EVMChain = /* @__PURE__ */ ((EVMChain3) => {
15564
15664
  EVMChain3["SEPOLIA"] = "sepolia";
15565
15665
  EVMChain3["ETHEREUM"] = "ethereum";
@@ -18806,22 +18906,82 @@ var require_axios = __commonJS({
18806
18906
  var hasOwnProperty2 = (({
18807
18907
  hasOwnProperty: hasOwnProperty3
18808
18908
  }) => (obj, prop) => hasOwnProperty3.call(obj, prop))(Object.prototype);
18909
+ var isUnsafeObjectKey2 = (prop) => typeof prop === "string" && (prop === "__proto__" || prop === "constructor" || prop === "prototype");
18910
+ var isPrototypeBoundary2 = (obj, prototype3, source) => obj === Object.prototype || !source && prototype3 === null;
18911
+ var isSafeAndFullyMutable2 = (obj) => {
18912
+ if (!Object.isExtensible(obj)) {
18913
+ return false;
18914
+ }
18915
+ const props = Object.getOwnPropertyNames(obj);
18916
+ if (Object.getOwnPropertySymbols) {
18917
+ props.push(...Object.getOwnPropertySymbols(obj));
18918
+ }
18919
+ return props.every((prop) => {
18920
+ if (isUnsafeObjectKey2(prop)) {
18921
+ return false;
18922
+ }
18923
+ const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
18924
+ return !!descriptor && descriptor.configurable && descriptor.writable === true;
18925
+ });
18926
+ };
18809
18927
  var hasOwnInPrototypeChain2 = (thing, prop) => {
18810
18928
  let obj = thing;
18811
18929
  const seen = [];
18812
- while (obj != null && obj !== Object.prototype) {
18930
+ while (obj != null) {
18813
18931
  if (seen.indexOf(obj) !== -1) {
18814
18932
  return false;
18815
18933
  }
18816
18934
  seen.push(obj);
18935
+ const prototype3 = getPrototypeOf2(obj);
18936
+ if (isPrototypeBoundary2(obj, prototype3, obj === thing)) {
18937
+ return false;
18938
+ }
18817
18939
  if (hasOwnProperty2(obj, prop)) {
18818
18940
  return true;
18819
18941
  }
18820
- obj = getPrototypeOf2(obj);
18942
+ obj = prototype3;
18821
18943
  }
18822
18944
  return false;
18823
18945
  };
18824
18946
  var getSafeProp2 = (obj, prop) => obj != null && hasOwnInPrototypeChain2(obj, prop) ? obj[prop] : void 0;
18947
+ var toSafeFlatObject2 = (thing) => {
18948
+ if (thing == null || typeof thing !== "object" && typeof thing !== "function") {
18949
+ return thing;
18950
+ }
18951
+ const sourcePrototype = getPrototypeOf2(thing);
18952
+ if (sourcePrototype === null && isSafeAndFullyMutable2(thing)) {
18953
+ return thing;
18954
+ }
18955
+ const result = /* @__PURE__ */ Object.create(null);
18956
+ const merged = /* @__PURE__ */ Object.create(null);
18957
+ const seen = [];
18958
+ let current = thing;
18959
+ while (current != null) {
18960
+ if (seen.indexOf(current) !== -1) {
18961
+ break;
18962
+ }
18963
+ seen.push(current);
18964
+ const prototype3 = current === thing ? sourcePrototype : getPrototypeOf2(current);
18965
+ if (isPrototypeBoundary2(current, prototype3, current === thing)) {
18966
+ break;
18967
+ }
18968
+ const props = Object.getOwnPropertyNames(current);
18969
+ if (Object.getOwnPropertySymbols) {
18970
+ props.push(...Object.getOwnPropertySymbols(current));
18971
+ }
18972
+ for (const prop of props) {
18973
+ if (isUnsafeObjectKey2(prop)) {
18974
+ continue;
18975
+ }
18976
+ if (!hasOwnProperty2(merged, prop)) {
18977
+ result[prop] = thing[prop];
18978
+ merged[prop] = true;
18979
+ }
18980
+ }
18981
+ current = prototype3;
18982
+ }
18983
+ return result;
18984
+ };
18825
18985
  var kindOf2 = /* @__PURE__ */ ((cache) => (thing) => {
18826
18986
  const str = toString3.call(thing);
18827
18987
  return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
@@ -18858,9 +19018,9 @@ var require_axios = __commonJS({
18858
19018
  return false;
18859
19019
  }
18860
19020
  const prototype3 = getPrototypeOf2(val);
18861
- return (prototype3 === null || prototype3 === Object.prototype || getPrototypeOf2(prototype3) === null) && // Treat any genuine (non-Object.prototype-polluted) Symbol.toStringTag or
18862
- // Symbol.iterator as evidence the value is a tagged/iterable type rather
18863
- // than a plain object, while ignoring keys injected onto Object.prototype.
19021
+ return (prototype3 === null || prototype3 === Object.prototype || getPrototypeOf2(prototype3) === null) && // Treat safe own/inherited Symbol.toStringTag or Symbol.iterator members as
19022
+ // evidence the value is tagged/iterable, while ignoring members reachable
19023
+ // only through shared or terminal prototype boundaries.
18864
19024
  !hasOwnInPrototypeChain2(val, toStringTag2) && !hasOwnInPrototypeChain2(val, iterator2);
18865
19025
  };
18866
19026
  var isEmptyObject2 = (val) => {
@@ -19272,6 +19432,7 @@ var require_axios = __commonJS({
19272
19432
  // an alias to avoid ESLint no-prototype-builtins detection
19273
19433
  hasOwnInPrototypeChain: hasOwnInPrototypeChain2,
19274
19434
  getSafeProp: getSafeProp2,
19435
+ toSafeFlatObject: toSafeFlatObject2,
19275
19436
  reduceDescriptors: reduceDescriptors2,
19276
19437
  freezeMethods: freezeMethods2,
19277
19438
  toObjectSet: toObjectSet2,
@@ -19352,7 +19513,7 @@ var require_axios = __commonJS({
19352
19513
  });
19353
19514
  return byteStringHeaders;
19354
19515
  }
19355
- var $internals2 = Symbol("internals");
19516
+ var $internals$1 = Symbol("internals");
19356
19517
  function normalizeHeader2(header) {
19357
19518
  return header && String(header).trim().toLowerCase();
19358
19519
  }
@@ -19648,7 +19809,7 @@ var require_axios = __commonJS({
19648
19809
  return computed;
19649
19810
  }
19650
19811
  static accessor(header) {
19651
- const internals = this[$internals2] = this[$internals2] = {
19812
+ const internals = this[$internals$1] = this[$internals$1] = {
19652
19813
  accessors: {}
19653
19814
  };
19654
19815
  const accessors = internals.accessors;
@@ -19869,19 +20030,16 @@ var require_axios = __commonJS({
19869
20030
  throw new TypeError("target must be an object");
19870
20031
  }
19871
20032
  formData = formData || new (FormData$1 || FormData)();
19872
- options = utils$1.toFlatObject(options, {
19873
- metaTokens: true,
19874
- dots: false,
19875
- indexes: false
19876
- }, false, function defined(option, source) {
19877
- return !utils$1.isUndefined(source[option]);
19878
- });
19879
- const metaTokens = options.metaTokens;
19880
- const visitor = options.visitor || defaultVisitor;
19881
- const dots = options.dots;
19882
- const indexes = options.indexes;
19883
- const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
19884
- const maxDepth = options.maxDepth === void 0 ? DEFAULT_FORM_DATA_MAX_DEPTH2 : options.maxDepth;
20033
+ const option = (name, fallback) => {
20034
+ const value = utils$1.getSafeProp(options, name);
20035
+ return utils$1.isUndefined(value) ? fallback : value;
20036
+ };
20037
+ const metaTokens = option("metaTokens", true);
20038
+ const visitor = option("visitor") || defaultVisitor;
20039
+ const dots = option("dots", false);
20040
+ const indexes = option("indexes", false);
20041
+ const _Blob = option("Blob") || typeof Blob !== "undefined" && Blob;
20042
+ const maxDepth = option("maxDepth", DEFAULT_FORM_DATA_MAX_DEPTH2);
19885
20043
  const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
19886
20044
  const stack = [];
19887
20045
  if (!utils$1.isFunction(visitor)) {
@@ -20040,9 +20198,47 @@ var require_axios = __commonJS({
20040
20198
  }
20041
20199
  return url3;
20042
20200
  }
20201
+ var $internals3 = Symbol("internals");
20202
+ function countHandlers2(handlers) {
20203
+ return handlers ? handlers.length : 0;
20204
+ }
20205
+ function trimHandlers2(handlers) {
20206
+ if (!handlers) {
20207
+ return;
20208
+ }
20209
+ while (handlers.length && handlers[handlers.length - 1] === null) {
20210
+ handlers.pop();
20211
+ }
20212
+ }
20213
+ function syncHandlerEntries2(manager, internals) {
20214
+ const handlers = manager.handlers;
20215
+ const length = countHandlers2(handlers);
20216
+ if (handlers !== internals.handlersRef) {
20217
+ internals.handlersRef = handlers;
20218
+ internals.handlerEntries.clear();
20219
+ } else if (length !== internals.handlersLength) {
20220
+ if (!length) {
20221
+ internals.handlerEntries.clear();
20222
+ } else {
20223
+ internals.handlerEntries.forEach(function removeStaleEntry(entry, id) {
20224
+ if (handlers[entry.index] !== entry.handler) {
20225
+ internals.handlerEntries.delete(id);
20226
+ }
20227
+ });
20228
+ }
20229
+ }
20230
+ internals.handlersLength = length;
20231
+ }
20043
20232
  var InterceptorManager2 = class {
20044
20233
  constructor() {
20045
20234
  this.handlers = [];
20235
+ this[$internals3] = {
20236
+ handlersRef: this.handlers,
20237
+ handlersLength: this.handlers.length,
20238
+ handlerEntries: /* @__PURE__ */ new Map(),
20239
+ iterationDepth: 0,
20240
+ nextId: 0
20241
+ };
20046
20242
  }
20047
20243
  /**
20048
20244
  * Add a new interceptor to the stack
@@ -20054,13 +20250,25 @@ var require_axios = __commonJS({
20054
20250
  * @return {Number} An ID used to remove interceptor later
20055
20251
  */
20056
20252
  use(fulfilled, rejected, options) {
20057
- this.handlers.push({
20253
+ const handler = {
20058
20254
  fulfilled,
20059
20255
  rejected,
20060
20256
  synchronous: options ? options.synchronous : false,
20061
20257
  runWhen: options ? options.runWhen : null
20258
+ };
20259
+ const internals = this[$internals3];
20260
+ if (this.handlers == null) {
20261
+ this.handlers = [];
20262
+ }
20263
+ syncHandlerEntries2(this, internals);
20264
+ const id = internals.nextId++;
20265
+ this.handlers.push(handler);
20266
+ internals.handlerEntries.set(id, {
20267
+ handler,
20268
+ index: this.handlers.length - 1
20062
20269
  });
20063
- return this.handlers.length - 1;
20270
+ internals.handlersLength = this.handlers.length;
20271
+ return id;
20064
20272
  }
20065
20273
  /**
20066
20274
  * Remove an interceptor from the stack
@@ -20070,8 +20278,19 @@ var require_axios = __commonJS({
20070
20278
  * @returns {void}
20071
20279
  */
20072
20280
  eject(id) {
20073
- if (this.handlers[id]) {
20074
- this.handlers[id] = null;
20281
+ const internals = this[$internals3];
20282
+ syncHandlerEntries2(this, internals);
20283
+ const entry = internals.handlerEntries.get(id);
20284
+ if (entry) {
20285
+ internals.handlerEntries.delete(id);
20286
+ if (this.handlers[entry.index] !== entry.handler) {
20287
+ return;
20288
+ }
20289
+ this.handlers[entry.index] = null;
20290
+ if (!internals.iterationDepth) {
20291
+ trimHandlers2(this.handlers);
20292
+ internals.handlersLength = this.handlers.length;
20293
+ }
20075
20294
  }
20076
20295
  }
20077
20296
  /**
@@ -20082,6 +20301,7 @@ var require_axios = __commonJS({
20082
20301
  clear() {
20083
20302
  if (this.handlers) {
20084
20303
  this.handlers = [];
20304
+ syncHandlerEntries2(this, this[$internals3]);
20085
20305
  }
20086
20306
  }
20087
20307
  /**
@@ -20095,11 +20315,22 @@ var require_axios = __commonJS({
20095
20315
  * @returns {void}
20096
20316
  */
20097
20317
  forEach(fn) {
20098
- utils$1.forEach(this.handlers, function forEachHandler(h) {
20099
- if (h !== null) {
20100
- fn(h);
20318
+ const internals = this[$internals3];
20319
+ syncHandlerEntries2(this, internals);
20320
+ internals.iterationDepth++;
20321
+ try {
20322
+ utils$1.forEach(this.handlers, function forEachHandler(h) {
20323
+ if (h !== null) {
20324
+ fn(h);
20325
+ }
20326
+ });
20327
+ } finally {
20328
+ if (!--internals.iterationDepth) {
20329
+ syncHandlerEntries2(this, internals);
20330
+ trimHandlers2(this.handlers);
20331
+ internals.handlersLength = countHandlers2(this.handlers);
20101
20332
  }
20102
- });
20333
+ }
20103
20334
  }
20104
20335
  };
20105
20336
  var transitionalDefaults = {
@@ -20235,6 +20466,7 @@ var require_axios = __commonJS({
20235
20466
  }
20236
20467
  return null;
20237
20468
  }
20469
+ var methodList2 = Object.freeze(["get", "delete", "head", "options", "post", "put", "patch", "purge", "link", "unlink", "query"]);
20238
20470
  var own2 = (obj, key) => obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : void 0;
20239
20471
  function stringifySafely3(rawValue, parser, encoder) {
20240
20472
  if (utils$1.isString(rawValue)) {
@@ -20340,7 +20572,7 @@ var require_axios = __commonJS({
20340
20572
  }
20341
20573
  }
20342
20574
  };
20343
- utils$1.forEach(["delete", "get", "head", "post", "put", "patch", "query"], (method) => {
20575
+ utils$1.forEach(methodList2, (method) => {
20344
20576
  defaults2.headers[method] = {};
20345
20577
  });
20346
20578
  function transformData2(fns, response) {
@@ -20397,18 +20629,18 @@ var require_axios = __commonJS({
20397
20629
  }
20398
20630
  return baseURL.slice(0, end) + "/" + relativeURL.replace(/^\/+/, "");
20399
20631
  }
20400
- var malformedHttpProtocol2 = /^https?:(?!\/\/)/i;
20401
- var httpProtocolControlCharacters2 = /[\t\n\r]/g;
20402
- function stripLeadingC0ControlOrSpace2(url3) {
20403
- let i = 0;
20404
- while (i < url3.length && url3.charCodeAt(i) <= 32) {
20405
- i++;
20406
- }
20407
- return url3.slice(i);
20408
- }
20632
+ var urlParserControlCharacters2 = /[\t\n\r]/g;
20409
20633
  function normalizeURLForProtocolCheck2(url3) {
20410
- return stripLeadingC0ControlOrSpace2(url3).replace(httpProtocolControlCharacters2, "");
20634
+ if (typeof url3 !== "string") {
20635
+ return url3;
20636
+ }
20637
+ let start = 0;
20638
+ while (start < url3.length && url3.charCodeAt(start) <= 32) {
20639
+ start++;
20640
+ }
20641
+ return url3.slice(start).replace(urlParserControlCharacters2, "");
20411
20642
  }
20643
+ var malformedHttpProtocol2 = /^https?:(?!\/\/)/i;
20412
20644
  function redactFragment2(fragment) {
20413
20645
  if (!fragment) {
20414
20646
  return fragment;
@@ -20509,12 +20741,12 @@ var require_axios = __commonJS({
20509
20741
  function getEnv2(key) {
20510
20742
  return process.env[key.toLowerCase()] || process.env[key.toUpperCase()] || "";
20511
20743
  }
20512
- var VERSION3 = "1.19.0";
20744
+ var VERSION3 = "1.20.0";
20513
20745
  function parseProtocol2(url3) {
20514
20746
  const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url3);
20515
20747
  return match && match[1] || "";
20516
20748
  }
20517
- var DATA_URL_PATTERN2 = /^([^,;]+\/[^,;]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
20749
+ var DATA_URL_PATTERN2 = /^([^,;/]+\/[^,;/]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
20518
20750
  function fromDataURI2(uri, asBlob, options) {
20519
20751
  const _Blob = options && options.Blob || platform.classes.Blob;
20520
20752
  const protocol = parseProtocol2(uri);
@@ -20791,7 +21023,7 @@ var require_axios = __commonJS({
20791
21023
  this.sessions = /* @__PURE__ */ Object.create(null);
20792
21024
  }
20793
21025
  getSession(authority, options) {
20794
- options = Object.assign({
21026
+ options = Object.assign(/* @__PURE__ */ Object.create(null), {
20795
21027
  sessionTimeout: 1e3
20796
21028
  }, options);
20797
21029
  let authoritySessions = this.sessions[authority];
@@ -20856,6 +21088,7 @@ var require_axios = __commonJS({
20856
21088
  };
20857
21089
  }
20858
21090
  session.once("close", removeSession);
21091
+ session.once("error", removeSession);
20859
21092
  let entry = [session, options];
20860
21093
  authoritySessions ? authoritySessions.push(entry) : authoritySessions = this.sessions[authority] = [entry];
20861
21094
  return session;
@@ -20874,6 +21107,13 @@ var require_axios = __commonJS({
20874
21107
  } : fn;
20875
21108
  };
20876
21109
  var LOOPBACK_HOSTNAMES2 = /* @__PURE__ */ new Set(["localhost", "0.0.0.0"]);
21110
+ var trimTrailingDots2 = (value) => {
21111
+ let end = value.length;
21112
+ while (end && value.charCodeAt(end - 1) === 46) {
21113
+ end--;
21114
+ }
21115
+ return end === value.length ? value : value.slice(0, end);
21116
+ };
20877
21117
  var isIPv4Loopback2 = (host) => {
20878
21118
  const parts = host.split(".");
20879
21119
  if (parts.length !== 4) return false;
@@ -20906,7 +21146,7 @@ var require_axios = __commonJS({
20906
21146
  if (h.charAt(0) === "[" && h.charAt(h.length - 1) === "]") {
20907
21147
  h = h.slice(1, -1);
20908
21148
  }
20909
- h = h.replace(/\.+$/, "");
21149
+ h = trimTrailingDots2(h);
20910
21150
  if (!/^[0-9.xXa-fA-F]+$/.test(h)) return host;
20911
21151
  const parts = h.split(".");
20912
21152
  if (parts.some((p) => p === "")) return host;
@@ -21018,6 +21258,40 @@ var require_axios = __commonJS({
21018
21258
  }
21019
21259
  return host;
21020
21260
  };
21261
+ var IPV4_OCTET_RE2 = /^(?:0|[1-9]\d{0,2})$/;
21262
+ var ipv4ToBytes2 = (host) => {
21263
+ const parts = host.split(".");
21264
+ return parts.length === 4 && parts.every((part) => IPV4_OCTET_RE2.test(part) && Number(part) <= 255) ? parts.map(Number) : null;
21265
+ };
21266
+ var IPV6_GROUP_RE2 = /^[0-9a-f]{1,4}$/i;
21267
+ var ipv6ToBytes2 = (host) => {
21268
+ const halves = host.split("::");
21269
+ if (halves.length > 2) {
21270
+ return null;
21271
+ }
21272
+ const groups = halves[0] ? halves[0].split(":") : [];
21273
+ if (halves.length === 2) {
21274
+ const rear = halves[1] ? halves[1].split(":") : [];
21275
+ const missing = 8 - groups.length - rear.length;
21276
+ if (missing < 1) {
21277
+ return null;
21278
+ }
21279
+ groups.push(...new Array(missing).fill("0"), ...rear);
21280
+ }
21281
+ if (groups.length !== 8 || groups.some((group) => !IPV6_GROUP_RE2.test(group))) {
21282
+ return null;
21283
+ }
21284
+ return groups.flatMap((group) => {
21285
+ const value = Number.parseInt(group, 16);
21286
+ return [value >> 8 & 255, value & 255];
21287
+ });
21288
+ };
21289
+ var ipToBytes2 = (host) => {
21290
+ if (typeof host !== "string" || !host) {
21291
+ return null;
21292
+ }
21293
+ return host.indexOf(":") !== -1 ? ipv6ToBytes2(host) : ipv4ToBytes2(host);
21294
+ };
21021
21295
  var normalizeNoProxyHost2 = (hostname) => {
21022
21296
  if (!hostname) {
21023
21297
  return hostname;
@@ -21025,13 +21299,99 @@ var require_axios = __commonJS({
21025
21299
  if (hostname.charAt(0) === "[" && hostname.charAt(hostname.length - 1) === "]") {
21026
21300
  hostname = hostname.slice(1, -1);
21027
21301
  }
21028
- const trimmed = hostname.replace(/\.+$/, "");
21302
+ const trimmed = trimTrailingDots2(hostname);
21029
21303
  const ipv4 = normalizeIPAddress2(trimmed);
21030
21304
  if (ipv4 !== trimmed) {
21031
21305
  return ipv4;
21032
21306
  }
21033
21307
  return unmapIPv4MappedIPv62(trimmed);
21034
21308
  };
21309
+ var normalizeCidrBase2 = (input) => {
21310
+ let base = input;
21311
+ const startsBracket = base.charAt(0) === "[";
21312
+ const endsBracket = base.charAt(base.length - 1) === "]";
21313
+ const hasBracket = base.includes("[") || base.includes("]");
21314
+ if (startsBracket || endsBracket) {
21315
+ if (!startsBracket || !endsBracket) {
21316
+ return null;
21317
+ }
21318
+ base = base.slice(1, -1);
21319
+ if (base.indexOf(":") === -1 || base.includes("[") || base.includes("]")) {
21320
+ return null;
21321
+ }
21322
+ } else if (hasBracket) {
21323
+ return null;
21324
+ }
21325
+ if (!base || base.charAt(base.length - 1) === ".") {
21326
+ return null;
21327
+ }
21328
+ const wasIPv6 = base.indexOf(":") !== -1;
21329
+ if (wasIPv6) {
21330
+ try {
21331
+ base = new URL(`http://[${base}]/`).hostname.slice(1, -1);
21332
+ } catch (_err) {
21333
+ return null;
21334
+ }
21335
+ } else {
21336
+ base = normalizeIPAddress2(base);
21337
+ if (!ipv4ToBytes2(base)) {
21338
+ return null;
21339
+ }
21340
+ }
21341
+ return {
21342
+ normalized: unmapIPv4MappedIPv62(base),
21343
+ wasIPv6
21344
+ };
21345
+ };
21346
+ var CIDR_ENTRY_RE2 = /^(.+)\/(0|[1-9]\d{0,2})$/;
21347
+ var parseCidrEntry2 = (entry) => {
21348
+ if (entry.indexOf("/") === -1) {
21349
+ return void 0;
21350
+ }
21351
+ const match = CIDR_ENTRY_RE2.exec(entry);
21352
+ if (!match) {
21353
+ return null;
21354
+ }
21355
+ let prefix = Number(match[2]);
21356
+ const parsedBase = normalizeCidrBase2(match[1]);
21357
+ if (!parsedBase) {
21358
+ return null;
21359
+ }
21360
+ const {
21361
+ normalized,
21362
+ wasIPv6
21363
+ } = parsedBase;
21364
+ if (wasIPv6 && normalized.indexOf(":") === -1) {
21365
+ if (prefix < 96) {
21366
+ return null;
21367
+ }
21368
+ prefix -= 96;
21369
+ }
21370
+ const bytes = ipToBytes2(normalized);
21371
+ if (!bytes || prefix > bytes.length * 8) {
21372
+ return null;
21373
+ }
21374
+ return {
21375
+ bytes,
21376
+ prefix
21377
+ };
21378
+ };
21379
+ var isInSubnet2 = (addressBytes, networkBytes, prefix) => {
21380
+ const fullBytes = prefix >> 3;
21381
+ for (let i = 0; i < fullBytes; i++) {
21382
+ if (addressBytes[i] !== networkBytes[i]) {
21383
+ return false;
21384
+ }
21385
+ }
21386
+ const remainingBits = prefix & 7;
21387
+ if (remainingBits) {
21388
+ const mask = 255 << 8 - remainingBits & 255;
21389
+ if ((addressBytes[fullBytes] & mask) !== (networkBytes[fullBytes] & mask)) {
21390
+ return false;
21391
+ }
21392
+ }
21393
+ return true;
21394
+ };
21035
21395
  function shouldBypassProxy2(location) {
21036
21396
  let parsed;
21037
21397
  try {
@@ -21048,6 +21408,7 @@ var require_axios = __commonJS({
21048
21408
  }
21049
21409
  const port = Number.parseInt(parsed.port, 10) || DEFAULT_PORTS3[parsed.protocol.split(":", 1)[0]] || 0;
21050
21410
  const hostname = normalizeNoProxyHost2(parsed.hostname.toLowerCase());
21411
+ const hostnameBytes = ipToBytes2(hostname);
21051
21412
  return noProxy.split(/[\s,]+/).some((entry) => {
21052
21413
  if (!entry) {
21053
21414
  return false;
@@ -21055,6 +21416,10 @@ var require_axios = __commonJS({
21055
21416
  if (entry === "*") {
21056
21417
  return true;
21057
21418
  }
21419
+ const cidr = parseCidrEntry2(entry);
21420
+ if (cidr !== void 0) {
21421
+ return cidr !== null && !!hostnameBytes && hostnameBytes.length === cidr.bytes.length && isInSubnet2(hostnameBytes, cidr.bytes, cidr.prefix);
21422
+ }
21058
21423
  let [entryHost, entryPort] = parseNoProxyEntry2(entry);
21059
21424
  entryHost = normalizeNoProxyHost2(entryHost);
21060
21425
  if (!entryHost) {
@@ -21135,13 +21500,14 @@ var require_axios = __commonJS({
21135
21500
  }
21136
21501
  };
21137
21502
  const flush = () => lastArgs && invoke(lastArgs);
21138
- return [throttled, flush];
21503
+ const flushWith = (...args) => invoke(args);
21504
+ return [throttled, flush, flushWith];
21139
21505
  }
21140
21506
  var progressEventReducer2 = (listener, isDownloadStream, freq = 3) => {
21141
21507
  let bytesNotified = 0;
21142
21508
  const _speedometer = speedometer2(50, 250);
21143
21509
  return throttle2((e) => {
21144
- if (!e || typeof e.loaded !== "number") {
21510
+ if (!e || !utils$1.isNumber(e.loaded)) {
21145
21511
  return;
21146
21512
  }
21147
21513
  const rawLoaded = e.loaded;
@@ -21295,6 +21661,12 @@ var require_axios = __commonJS({
21295
21661
  var isHttps2 = /https:?/;
21296
21662
  var kAxiosSocketListener2 = Symbol("axios.http.socketListener");
21297
21663
  var kAxiosCurrentReq2 = Symbol("axios.http.currentReq");
21664
+ function handleSocketError2(err) {
21665
+ const current = this[kAxiosCurrentReq2];
21666
+ if (current && !current.destroyed) {
21667
+ current.destroy(err);
21668
+ }
21669
+ }
21298
21670
  var kAxiosInstalledTunnel2 = Symbol("axios.http.installedTunnel");
21299
21671
  var tunnelingAgentCache2 = /* @__PURE__ */ new Map();
21300
21672
  var tunnelingAgentCacheUser2 = /* @__PURE__ */ new WeakMap();
@@ -21403,10 +21775,10 @@ var require_axios = __commonJS({
21403
21775
  return false;
21404
21776
  }
21405
21777
  }
21406
- function setProxy2(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent) {
21778
+ function setProxy2(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent, allowEnvProxy = true) {
21407
21779
  let proxy = configProxy;
21408
21780
  const proxyEnvAgent = getProxyEnvAgent2(options, configHttpAgent, configHttpsAgent);
21409
- if (!proxy && proxy !== false && !isNodeEnvProxyEnabled2(proxyEnvAgent)) {
21781
+ if (!proxy && proxy !== false && allowEnvProxy && !isNodeEnvProxyEnabled2(proxyEnvAgent)) {
21410
21782
  const proxyUrl = getProxyForUrl2(location);
21411
21783
  if (proxyUrl) {
21412
21784
  if (!shouldBypassProxy2(location)) {
@@ -21497,8 +21869,9 @@ var require_axios = __commonJS({
21497
21869
  }
21498
21870
  }
21499
21871
  options.beforeRedirects.proxy = function beforeRedirect(redirectOptions) {
21500
- setProxy2(redirectOptions, configProxy, redirectOptions.href, true, configHttpsAgent, configHttpAgent);
21872
+ setProxy2(redirectOptions, configProxy, redirectOptions.href, true, configHttpsAgent, configHttpAgent, allowEnvProxy);
21501
21873
  };
21874
+ return Boolean(proxy || configProxy !== false && allowEnvProxy && isNodeEnvProxyEnabled2(proxyEnvAgent));
21502
21875
  }
21503
21876
  var isHttpAdapterSupported2 = typeof process !== "undefined" && utils$1.kindOf(process) === "process";
21504
21877
  var wrapAsync2 = (asyncExecutor) => {
@@ -21526,7 +21899,7 @@ var require_axios = __commonJS({
21526
21899
  family
21527
21900
  }) => {
21528
21901
  if (!utils$1.isString(address)) {
21529
- throw TypeError("address must be a string");
21902
+ throw new AxiosError3("address must be a string", AxiosError3.ERR_BAD_OPTION_VALUE);
21530
21903
  }
21531
21904
  return {
21532
21905
  address,
@@ -21537,6 +21910,30 @@ var require_axios = __commonJS({
21537
21910
  address,
21538
21911
  family
21539
21912
  });
21913
+ var normalizedLookupCache2 = /* @__PURE__ */ new WeakMap();
21914
+ var normalizeLookup2 = (lookup) => {
21915
+ let normalized = normalizedLookupCache2.get(lookup);
21916
+ if (normalized) {
21917
+ return normalized;
21918
+ }
21919
+ const callbackLookup = callbackify2(lookup, (value) => utils$1.isArray(value) ? value : [value]);
21920
+ normalized = (hostname, opt, cb) => {
21921
+ callbackLookup(hostname, opt, (err, arg0, arg1) => {
21922
+ if (err) {
21923
+ return cb(err);
21924
+ }
21925
+ let addresses;
21926
+ try {
21927
+ addresses = utils$1.isArray(arg0) ? arg0.map((addr) => buildAddressEntry2(addr)) : [buildAddressEntry2(arg0, arg1)];
21928
+ } catch (error) {
21929
+ return cb(error);
21930
+ }
21931
+ opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
21932
+ });
21933
+ };
21934
+ normalizedLookupCache2.set(lookup, normalized);
21935
+ return normalized;
21936
+ };
21540
21937
  var http2Transport2 = {
21541
21938
  request(options, cb) {
21542
21939
  const authority = options.protocol + "//" + options.hostname + ":" + (options.port || (options.protocol === "https:" ? 443 : 80));
@@ -21581,6 +21978,7 @@ var require_axios = __commonJS({
21581
21978
  let family = own3("family");
21582
21979
  let httpVersion = own3("httpVersion");
21583
21980
  if (httpVersion === void 0) httpVersion = 1;
21981
+ const rawHttpVersion = httpVersion;
21584
21982
  let http2Options = own3("http2Options");
21585
21983
  const httpAgent = own3("httpAgent");
21586
21984
  const httpsAgent = own3("httpsAgent");
@@ -21597,25 +21995,20 @@ var require_axios = __commonJS({
21597
21995
  let rejected = false;
21598
21996
  let req;
21599
21997
  let connectPhaseTimer;
21600
- httpVersion = +httpVersion;
21998
+ try {
21999
+ httpVersion = +httpVersion;
22000
+ } catch (err) {
22001
+ throw new AxiosError3("Invalid protocol version: value is not a number", AxiosError3.ERR_BAD_OPTION_VALUE, config);
22002
+ }
21601
22003
  if (Number.isNaN(httpVersion)) {
21602
- throw TypeError(`Invalid protocol version: '${config.httpVersion}' is not a number`);
22004
+ throw new AxiosError3(`Invalid protocol version: '${rawHttpVersion}' is not a number`, AxiosError3.ERR_BAD_OPTION_VALUE, config);
21603
22005
  }
21604
22006
  if (httpVersion !== 1 && httpVersion !== 2) {
21605
- throw TypeError(`Unsupported protocol version '${httpVersion}'`);
22007
+ throw new AxiosError3(`Unsupported protocol version '${httpVersion}'`, AxiosError3.ERR_BAD_OPTION_VALUE, config);
21606
22008
  }
21607
22009
  const isHttp2 = httpVersion === 2;
21608
22010
  if (lookup) {
21609
- const _lookup = callbackify2(lookup, (value) => utils$1.isArray(value) ? value : [value]);
21610
- lookup = (hostname, opt, cb) => {
21611
- _lookup(hostname, opt, (err, arg0, arg1) => {
21612
- if (err) {
21613
- return cb(err);
21614
- }
21615
- const addresses = utils$1.isArray(arg0) ? arg0.map((addr) => buildAddressEntry2(addr)) : [buildAddressEntry2(arg0, arg1)];
21616
- opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
21617
- });
21618
- };
22011
+ lookup = normalizeLookup2(lookup);
21619
22012
  }
21620
22013
  const abortEmitter = new events.EventEmitter();
21621
22014
  function abort(reason) {
@@ -21808,6 +22201,11 @@ var require_axios = __commonJS({
21808
22201
  }));
21809
22202
  }
21810
22203
  headers.set("Accept-Encoding", utils$1.hasOwnProp(transitional2, "advertiseZstdAcceptEncoding") && transitional2.advertiseZstdAcceptEncoding === true ? ACCEPT_ENCODING_WITH_ZSTD2 : ACCEPT_ENCODING2, false);
22204
+ if (isHttp2 && lookup) {
22205
+ http2Options = Object.assign(/* @__PURE__ */ Object.create(null), http2Options, {
22206
+ lookup
22207
+ });
22208
+ }
21811
22209
  const options = Object.assign(/* @__PURE__ */ Object.create(null), {
21812
22210
  path: path$1,
21813
22211
  method,
@@ -21821,9 +22219,11 @@ var require_axios = __commonJS({
21821
22219
  family,
21822
22220
  beforeRedirect: dispatchBeforeRedirect2,
21823
22221
  beforeRedirects: /* @__PURE__ */ Object.create(null),
21824
- http2Options
22222
+ http2Options,
22223
+ createConnection: void 0
21825
22224
  });
21826
22225
  !utils$1.isUndefined(lookup) && (options.lookup = lookup);
22226
+ let proxyApplied = false;
21827
22227
  if (socketPath) {
21828
22228
  if (typeof socketPath !== "string") {
21829
22229
  return reject(new AxiosError3("socketPath must be a string", AxiosError3.ERR_BAD_OPTION_VALUE, config));
@@ -21841,7 +22241,18 @@ var require_axios = __commonJS({
21841
22241
  } else {
21842
22242
  options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
21843
22243
  options.port = parsed.port;
21844
- setProxy2(options, configProxy, protocol + "//" + parsed.hostname + (parsed.port ? ":" + parsed.port : "") + options.path, false, httpsAgent, httpAgent);
22244
+ proxyApplied = setProxy2(
22245
+ options,
22246
+ configProxy,
22247
+ protocol + "//" + parsed.hostname + (parsed.port ? ":" + parsed.port : "") + options.path,
22248
+ false,
22249
+ httpsAgent,
22250
+ httpAgent,
22251
+ // The HTTP/2 transport connects independently of HTTP/1 agents, so it
22252
+ // cannot apply either axios-resolved or agent-local environment proxies.
22253
+ // Explicit proxy config is still processed and rejected below.
22254
+ !isHttp2
22255
+ );
21845
22256
  }
21846
22257
  let transport;
21847
22258
  let isNativeTransport = false;
@@ -21851,6 +22262,9 @@ var require_axios = __commonJS({
21851
22262
  options.agent = isHttpsRequest ? httpsAgent : httpAgent;
21852
22263
  }
21853
22264
  if (isHttp2) {
22265
+ if (proxyApplied) {
22266
+ return reject(new AxiosError3("HTTP/2 requests with a proxy are not supported", AxiosError3.ERR_NOT_SUPPORT, config));
22267
+ }
21854
22268
  transport = http2Transport2;
21855
22269
  } else {
21856
22270
  const configTransport = own3("transport");
@@ -22048,12 +22462,7 @@ var require_axios = __commonJS({
22048
22462
  socket.setKeepAlive(true, 1e3 * 60);
22049
22463
  }
22050
22464
  if (!socket[kAxiosSocketListener2]) {
22051
- socket.on("error", function handleSocketError(err) {
22052
- const current = socket[kAxiosCurrentReq2];
22053
- if (current && !current.destroyed) {
22054
- current.destroy(err);
22055
- }
22056
- });
22465
+ socket.on("error", handleSocketError2);
22057
22466
  socket[kAxiosSocketListener2] = true;
22058
22467
  }
22059
22468
  socket[kAxiosCurrentReq2] = req;
@@ -22269,7 +22678,7 @@ var require_axios = __commonJS({
22269
22678
  transformResponse: defaultToConfig2,
22270
22679
  paramsSerializer: defaultToConfig2,
22271
22680
  timeout: defaultToConfig2,
22272
- timeoutMessage: defaultToConfig2,
22681
+ timeoutErrorMessage: defaultToConfig2,
22273
22682
  withCredentials: defaultToConfig2,
22274
22683
  withXSRFToken: defaultToConfig2,
22275
22684
  adapter: defaultToConfig2,
@@ -22337,10 +22746,11 @@ var require_axios = __commonJS({
22337
22746
  }
22338
22747
  }
22339
22748
  if (utils$1.isFormData(data)) {
22749
+ const getHeaders = utils$1.getSafeProp(data, "getHeaders");
22340
22750
  if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv || utils$1.isReactNative(data)) {
22341
22751
  headers.setContentType(void 0);
22342
- } else if (utils$1.isFunction(data.getHeaders)) {
22343
- setFormDataHeaders2(headers, data.getHeaders(), own3("formDataHeaderPolicy"));
22752
+ } else if (utils$1.isFunction(getHeaders)) {
22753
+ setFormDataHeaders2(headers, getHeaders.call(data), own3("formDataHeaderPolicy"));
22344
22754
  }
22345
22755
  }
22346
22756
  if (platform.hasStandardBrowserEnv) {
@@ -22370,7 +22780,7 @@ var require_axios = __commonJS({
22370
22780
  } = _config;
22371
22781
  let onCanceled;
22372
22782
  let uploadThrottled, downloadThrottled;
22373
- let flushUpload, flushDownload;
22783
+ let flushUpload, flushDownload, flushDownloadWithEvent;
22374
22784
  function done() {
22375
22785
  flushUpload && flushUpload();
22376
22786
  flushDownload && flushDownload();
@@ -22380,7 +22790,27 @@ var require_axios = __commonJS({
22380
22790
  let request = new XMLHttpRequest();
22381
22791
  request.open(_config.method.toUpperCase(), _config.url, true);
22382
22792
  request.timeout = _config.timeout;
22383
- function onloadend() {
22793
+ function onloadend(event) {
22794
+ if (!request) {
22795
+ return;
22796
+ }
22797
+ if (request.status === 0 && (parseProtocol2(normalizeURLForProtocolCheck2(_config.url)) || parseProtocol2(platform.origin)) !== "file" && !(request.responseURL && request.responseURL.startsWith("file:"))) {
22798
+ reject(new AxiosError3("Request aborted", AxiosError3.ECONNABORTED, config, request));
22799
+ done();
22800
+ request = null;
22801
+ return;
22802
+ }
22803
+ try {
22804
+ if (event) {
22805
+ flushDownloadWithEvent && flushDownloadWithEvent(event);
22806
+ } else {
22807
+ flushDownload && flushDownload();
22808
+ }
22809
+ } catch (err) {
22810
+ setTimeout(() => {
22811
+ throw err;
22812
+ });
22813
+ }
22384
22814
  if (!request) {
22385
22815
  return;
22386
22816
  }
@@ -22455,7 +22885,7 @@ var require_axios = __commonJS({
22455
22885
  request.responseType = _config.responseType;
22456
22886
  }
22457
22887
  if (onDownloadProgress) {
22458
- [downloadThrottled, flushDownload] = progressEventReducer2(onDownloadProgress, true);
22888
+ [downloadThrottled, flushDownload, flushDownloadWithEvent] = progressEventReducer2(onDownloadProgress, true);
22459
22889
  request.addEventListener("progress", downloadThrottled);
22460
22890
  }
22461
22891
  if (onUploadProgress && request.upload) {
@@ -22617,6 +23047,17 @@ var require_axios = __commonJS({
22617
23047
  });
22618
23048
  };
22619
23049
  var DEFAULT_CHUNK_SIZE2 = 64 * 1024;
23050
+ var DEFAULT_REQUEST_OPTIONS2 = {
23051
+ cache: "default",
23052
+ redirect: "follow",
23053
+ referrer: "about:client",
23054
+ referrerPolicy: "",
23055
+ mode: "cors",
23056
+ integrity: "",
23057
+ keepalive: false,
23058
+ priority: "auto",
23059
+ window: null
23060
+ };
22620
23061
  var {
22621
23062
  isFunction: isFunction3
22622
23063
  } = utils$1;
@@ -22745,7 +23186,8 @@ var require_axios = __commonJS({
22745
23186
  withCredentials = "same-origin",
22746
23187
  fetchOptions,
22747
23188
  maxContentLength,
22748
- maxBodyLength
23189
+ maxBodyLength,
23190
+ maxRedirects
22749
23191
  } = resolveConfig2(config);
22750
23192
  const hasMaxContentLength = utils$1.isNumber(maxContentLength) && maxContentLength > -1;
22751
23193
  const hasMaxBodyLength = utils$1.isNumber(maxBodyLength) && maxBodyLength > -1;
@@ -22846,17 +23288,44 @@ var require_axios = __commonJS({
22846
23288
  }
22847
23289
  }
22848
23290
  headers.set("User-Agent", "axios/" + VERSION3, false);
22849
- const resolvedOptions = {
22850
- ...fetchOptions,
23291
+ const safeFetchOptions = fetchOptions == null ? fetchOptions : Object.assign(/* @__PURE__ */ Object.create(null), fetchOptions);
23292
+ if (safeFetchOptions) {
23293
+ delete safeFetchOptions.body;
23294
+ delete safeFetchOptions.headers;
23295
+ delete safeFetchOptions.method;
23296
+ delete safeFetchOptions.signal;
23297
+ delete safeFetchOptions.duplex;
23298
+ delete safeFetchOptions.credentials;
23299
+ }
23300
+ const resolvedOptions = Object.assign(/* @__PURE__ */ Object.create(null), safeFetchOptions, {
22851
23301
  signal: composedSignal,
22852
23302
  method: method.toUpperCase(),
22853
23303
  headers: toByteStringHeaderObject2(headers.normalize()),
22854
23304
  body: data,
22855
23305
  duplex: "half",
22856
23306
  credentials: isCredentialsSupported ? withCredentials : void 0
22857
- };
23307
+ });
23308
+ if (isRequestSupported) {
23309
+ utils$1.forEach(DEFAULT_REQUEST_OPTIONS2, (value, key) => {
23310
+ if (resolvedOptions[key] === void 0) {
23311
+ resolvedOptions[key] = value;
23312
+ }
23313
+ });
23314
+ if (resolvedOptions.signal === void 0) {
23315
+ resolvedOptions.signal = null;
23316
+ }
23317
+ if (resolvedOptions.body === void 0) {
23318
+ resolvedOptions.body = null;
23319
+ }
23320
+ }
23321
+ if (maxRedirects === 0) {
23322
+ resolvedOptions.redirect = "manual";
23323
+ if (safeFetchOptions) {
23324
+ safeFetchOptions.redirect = "manual";
23325
+ }
23326
+ }
22858
23327
  request = isRequestSupported && new Request(url3, resolvedOptions);
22859
- let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url3, resolvedOptions));
23328
+ let response = await (isRequestSupported ? _fetch(request, safeFetchOptions) : _fetch(url3, resolvedOptions));
22860
23329
  const responseHeaders = AxiosHeaders3.from(response.headers);
22861
23330
  if (hasMaxContentLength) {
22862
23331
  const declaredLength = utils$1.toFiniteNumber(responseHeaders.getContentLength());
@@ -23048,9 +23517,10 @@ var require_axios = __commonJS({
23048
23517
  throw new CanceledError3(null, config);
23049
23518
  }
23050
23519
  }
23051
- function dispatchRequest2(config) {
23520
+ function dispatchRequest2(_config) {
23521
+ const config = utils$1.toSafeFlatObject(_config);
23052
23522
  throwIfCancellationRequested2(config);
23053
- config.headers = AxiosHeaders3.from(config.headers);
23523
+ config.headers = AxiosHeaders3.from(utils$1.getSafeProp(config, "headers"));
23054
23524
  config.data = transformData2.call(config, config.transformRequest);
23055
23525
  if (["post", "put", "patch"].indexOf(config.method) !== -1) {
23056
23526
  config.headers.setContentType("application/x-www-form-urlencoded", false);
@@ -23158,16 +23628,15 @@ var require_axios = __commonJS({
23158
23628
  return await this._request(configOrUrl, config);
23159
23629
  } catch (err) {
23160
23630
  if (err instanceof Error) {
23161
- let dummy = {};
23162
- Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
23163
- const stack = (() => {
23164
- if (!dummy.stack) {
23165
- return "";
23166
- }
23167
- const firstNewlineIndex = dummy.stack.indexOf("\n");
23168
- return firstNewlineIndex === -1 ? "" : dummy.stack.slice(firstNewlineIndex + 1);
23169
- })();
23170
23631
  try {
23632
+ let dummy = {};
23633
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
23634
+ const dummyStack = dummy.stack;
23635
+ let stack = "";
23636
+ if (typeof dummyStack === "string") {
23637
+ const firstNewlineIndex = dummyStack.indexOf("\n");
23638
+ stack = firstNewlineIndex === -1 ? "" : dummyStack.slice(firstNewlineIndex + 1);
23639
+ }
23171
23640
  if (!err.stack) {
23172
23641
  err.stack = stack;
23173
23642
  } else if (stack) {
@@ -23229,9 +23698,9 @@ var require_axios = __commonJS({
23229
23698
  baseUrl: validators3.spelling("baseURL"),
23230
23699
  withXsrfToken: validators3.spelling("withXSRFToken")
23231
23700
  }, true);
23232
- config.method = (config.method || this.defaults.method || "get").toLowerCase();
23701
+ config.method = (utils$1.getSafeProp(config, "method") || utils$1.getSafeProp(this.defaults, "method") || "get").toLowerCase();
23233
23702
  let contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
23234
- headers && utils$1.forEach(["delete", "get", "head", "post", "put", "patch", "query", "common"], (method) => {
23703
+ headers && utils$1.forEach(methodList2.concat("common"), (method) => {
23235
23704
  delete headers[method];
23236
23705
  });
23237
23706
  config.headers = AxiosHeaders3.concat(contextHeaders, headers);
@@ -23478,14 +23947,22 @@ var require_axios = __commonJS({
23478
23947
  Gone: 410,
23479
23948
  LengthRequired: 411,
23480
23949
  PreconditionFailed: 412,
23950
+ /**
23951
+ * @deprecated Use `ContentTooLarge` instead.
23952
+ */
23481
23953
  PayloadTooLarge: 413,
23954
+ ContentTooLarge: 413,
23482
23955
  UriTooLong: 414,
23483
23956
  UnsupportedMediaType: 415,
23484
23957
  RangeNotSatisfiable: 416,
23485
23958
  ExpectationFailed: 417,
23486
23959
  ImATeapot: 418,
23487
23960
  MisdirectedRequest: 421,
23961
+ /**
23962
+ * @deprecated Use `UnprocessableContent` instead.
23963
+ */
23488
23964
  UnprocessableEntity: 422,
23965
+ UnprocessableContent: 422,
23489
23966
  Locked: 423,
23490
23967
  FailedDependency: 424,
23491
23968
  TooEarly: 425,
@@ -23514,7 +23991,9 @@ var require_axios = __commonJS({
23514
23991
  InvalidSslCertificate: 526
23515
23992
  };
23516
23993
  Object.entries(HttpStatusCode3).forEach(([key, value]) => {
23517
- HttpStatusCode3[value] = key;
23994
+ if (HttpStatusCode3[value] === void 0) {
23995
+ HttpStatusCode3[value] = key;
23996
+ }
23518
23997
  });
23519
23998
  function createInstance2(defaultConfig) {
23520
23999
  const context = new Axios3(defaultConfig);
@@ -23565,6 +24044,7 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
23565
24044
  exports2.fetchLitActionCodeFromIpfs = fetchLitActionCodeFromIpfs;
23566
24045
  var axios_1 = __importDefault(require_axios());
23567
24046
  var ipfsCodeCache = /* @__PURE__ */ new Map();
24047
+ var GATEWAY_TIMEOUT_MS = 2e4;
23568
24048
  var buildGatewayList = (cid, pinataJwt) => {
23569
24049
  const gateways = [];
23570
24050
  if (pinataJwt) {
@@ -23573,7 +24053,7 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
23573
24053
  headers: { Authorization: `Bearer ${pinataJwt}` }
23574
24054
  });
23575
24055
  }
23576
- 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}` });
24056
+ 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}` });
23577
24057
  return gateways;
23578
24058
  };
23579
24059
  async function fetchLitActionCodeFromIpfs(cid, options = {}) {
@@ -23587,13 +24067,14 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
23587
24067
  const pinataJwt = options.pinataJwt ?? process.env.PINATA_JWT;
23588
24068
  const extraGateways = options.extraGateways?.map((t) => ({ url: t.replace("{cid}", cid) })) ?? [];
23589
24069
  const gateways = [...extraGateways, ...buildGatewayList(cid, pinataJwt)];
24070
+ const failures = [];
23590
24071
  for (const gateway of gateways) {
23591
24072
  try {
23592
24073
  if (options.debug) {
23593
24074
  console.log(`\u{1F4E1} [fetchLitActionCodeFromIpfs] Trying ${gateway.url}...`);
23594
24075
  }
23595
24076
  const response = await axios_1.default.get(gateway.url, {
23596
- timeout: 1e4,
24077
+ timeout: GATEWAY_TIMEOUT_MS,
23597
24078
  headers: {
23598
24079
  Accept: "text/plain, application/javascript, text/javascript",
23599
24080
  ...gateway.headers
@@ -23606,13 +24087,17 @@ var require_fetch_lit_action_from_ipfs = __commonJS({
23606
24087
  ipfsCodeCache.set(cid, response.data);
23607
24088
  return response.data;
23608
24089
  }
24090
+ failures.push(`${gateway.url}: HTTP ${response.status} returned ${typeof response.data}, expected string`);
23609
24091
  } catch (error) {
24092
+ const message = error instanceof Error ? error.message : String(error);
24093
+ failures.push(`${gateway.url}: ${message}`);
23610
24094
  if (options.debug) {
23611
- console.log(`\u274C [fetchLitActionCodeFromIpfs] ${gateway.url}:`, error instanceof Error ? error.message : error);
24095
+ console.log(`\u274C [fetchLitActionCodeFromIpfs] ${gateway.url}:`, message);
23612
24096
  }
23613
24097
  }
23614
24098
  }
23615
- throw new Error(`Failed to fetch LIT Action from IPFS CID: ${cid}`);
24099
+ throw new Error(`Failed to fetch LIT Action from IPFS CID: ${cid} \u2014 all ${gateways.length} gateway(s) failed:
24100
+ ` + failures.map((f) => ` - ${f}`).join("\n"));
23616
24101
  }
23617
24102
  }
23618
24103
  });
@@ -45661,22 +46146,82 @@ var { toString } = Object.prototype;
45661
46146
  var { getPrototypeOf } = Object;
45662
46147
  var { iterator, toStringTag } = Symbol;
45663
46148
  var hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
46149
+ var isUnsafeObjectKey = (prop) => typeof prop === "string" && (prop === "__proto__" || prop === "constructor" || prop === "prototype");
46150
+ var isPrototypeBoundary = (obj, prototype2, source) => obj === Object.prototype || !source && prototype2 === null;
46151
+ var isSafeAndFullyMutable = (obj) => {
46152
+ if (!Object.isExtensible(obj)) {
46153
+ return false;
46154
+ }
46155
+ const props = Object.getOwnPropertyNames(obj);
46156
+ if (Object.getOwnPropertySymbols) {
46157
+ props.push(...Object.getOwnPropertySymbols(obj));
46158
+ }
46159
+ return props.every((prop) => {
46160
+ if (isUnsafeObjectKey(prop)) {
46161
+ return false;
46162
+ }
46163
+ const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
46164
+ return !!descriptor && descriptor.configurable && descriptor.writable === true;
46165
+ });
46166
+ };
45664
46167
  var hasOwnInPrototypeChain = (thing, prop) => {
45665
46168
  let obj = thing;
45666
46169
  const seen = [];
45667
- while (obj != null && obj !== Object.prototype) {
46170
+ while (obj != null) {
45668
46171
  if (seen.indexOf(obj) !== -1) {
45669
46172
  return false;
45670
46173
  }
45671
46174
  seen.push(obj);
46175
+ const prototype2 = getPrototypeOf(obj);
46176
+ if (isPrototypeBoundary(obj, prototype2, obj === thing)) {
46177
+ return false;
46178
+ }
45672
46179
  if (hasOwnProperty(obj, prop)) {
45673
46180
  return true;
45674
46181
  }
45675
- obj = getPrototypeOf(obj);
46182
+ obj = prototype2;
45676
46183
  }
45677
46184
  return false;
45678
46185
  };
45679
46186
  var getSafeProp = (obj, prop) => obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : void 0;
46187
+ var toSafeFlatObject = (thing) => {
46188
+ if (thing == null || typeof thing !== "object" && typeof thing !== "function") {
46189
+ return thing;
46190
+ }
46191
+ const sourcePrototype = getPrototypeOf(thing);
46192
+ if (sourcePrototype === null && isSafeAndFullyMutable(thing)) {
46193
+ return thing;
46194
+ }
46195
+ const result = /* @__PURE__ */ Object.create(null);
46196
+ const merged = /* @__PURE__ */ Object.create(null);
46197
+ const seen = [];
46198
+ let current = thing;
46199
+ while (current != null) {
46200
+ if (seen.indexOf(current) !== -1) {
46201
+ break;
46202
+ }
46203
+ seen.push(current);
46204
+ const prototype2 = current === thing ? sourcePrototype : getPrototypeOf(current);
46205
+ if (isPrototypeBoundary(current, prototype2, current === thing)) {
46206
+ break;
46207
+ }
46208
+ const props = Object.getOwnPropertyNames(current);
46209
+ if (Object.getOwnPropertySymbols) {
46210
+ props.push(...Object.getOwnPropertySymbols(current));
46211
+ }
46212
+ for (const prop of props) {
46213
+ if (isUnsafeObjectKey(prop)) {
46214
+ continue;
46215
+ }
46216
+ if (!hasOwnProperty(merged, prop)) {
46217
+ result[prop] = thing[prop];
46218
+ merged[prop] = true;
46219
+ }
46220
+ }
46221
+ current = prototype2;
46222
+ }
46223
+ return result;
46224
+ };
45680
46225
  var kindOf = /* @__PURE__ */ ((cache) => (thing) => {
45681
46226
  const str = toString.call(thing);
45682
46227
  return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
@@ -45711,9 +46256,9 @@ var isPlainObject = (val) => {
45711
46256
  return false;
45712
46257
  }
45713
46258
  const prototype2 = getPrototypeOf(val);
45714
- return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat any genuine (non-Object.prototype-polluted) Symbol.toStringTag or
45715
- // Symbol.iterator as evidence the value is a tagged/iterable type rather
45716
- // than a plain object, while ignoring keys injected onto Object.prototype.
46259
+ return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat safe own/inherited Symbol.toStringTag or Symbol.iterator members as
46260
+ // evidence the value is tagged/iterable, while ignoring members reachable
46261
+ // only through shared or terminal prototype boundaries.
45717
46262
  !hasOwnInPrototypeChain(val, toStringTag) && !hasOwnInPrototypeChain(val, iterator);
45718
46263
  };
45719
46264
  var isEmptyObject = (val) => {
@@ -46124,6 +46669,7 @@ var utils_default = {
46124
46669
  // an alias to avoid ESLint no-prototype-builtins detection
46125
46670
  hasOwnInPrototypeChain,
46126
46671
  getSafeProp,
46672
+ toSafeFlatObject,
46127
46673
  reduceDescriptors,
46128
46674
  freezeMethods,
46129
46675
  toObjectSet,
@@ -46762,24 +47308,16 @@ function toFormData(obj, formData, options) {
46762
47308
  throw new TypeError("target must be an object");
46763
47309
  }
46764
47310
  formData = formData || new (FormData_default || FormData)();
46765
- options = utils_default.toFlatObject(
46766
- options,
46767
- {
46768
- metaTokens: true,
46769
- dots: false,
46770
- indexes: false
46771
- },
46772
- false,
46773
- function defined(option, source) {
46774
- return !utils_default.isUndefined(source[option]);
46775
- }
46776
- );
46777
- const metaTokens = options.metaTokens;
46778
- const visitor = options.visitor || defaultVisitor;
46779
- const dots = options.dots;
46780
- const indexes = options.indexes;
46781
- const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
46782
- const maxDepth = options.maxDepth === void 0 ? DEFAULT_FORM_DATA_MAX_DEPTH : options.maxDepth;
47311
+ const option = (name, fallback) => {
47312
+ const value = utils_default.getSafeProp(options, name);
47313
+ return utils_default.isUndefined(value) ? fallback : value;
47314
+ };
47315
+ const metaTokens = option("metaTokens", true);
47316
+ const visitor = option("visitor") || defaultVisitor;
47317
+ const dots = option("dots", false);
47318
+ const indexes = option("indexes", false);
47319
+ const _Blob = option("Blob") || typeof Blob !== "undefined" && Blob;
47320
+ const maxDepth = option("maxDepth", DEFAULT_FORM_DATA_MAX_DEPTH);
46783
47321
  const useBlob = _Blob && utils_default.isSpecCompliantForm(formData);
46784
47322
  const stack = [];
46785
47323
  if (!utils_default.isFunction(visitor)) {
@@ -46803,7 +47341,10 @@ function toFormData(obj, formData, options) {
46803
47341
  if (Buffer_default && Buffer_default.isBufferAvailable()) {
46804
47342
  return Buffer_default.from(value);
46805
47343
  }
46806
- throw new AxiosError_default("Blob is not supported. Use a Buffer instead.", AxiosError_default.ERR_NOT_SUPPORT);
47344
+ throw new AxiosError_default(
47345
+ "Blob is not supported. Use a Buffer instead.",
47346
+ AxiosError_default.ERR_NOT_SUPPORT
47347
+ );
46807
47348
  }
46808
47349
  return value;
46809
47350
  }
@@ -46949,9 +47490,47 @@ function buildURL(url2, params, options) {
46949
47490
  }
46950
47491
 
46951
47492
  // node_modules/axios/lib/core/InterceptorManager.js
47493
+ var $internals2 = Symbol("internals");
47494
+ function countHandlers(handlers) {
47495
+ return handlers ? handlers.length : 0;
47496
+ }
47497
+ function trimHandlers(handlers) {
47498
+ if (!handlers) {
47499
+ return;
47500
+ }
47501
+ while (handlers.length && handlers[handlers.length - 1] === null) {
47502
+ handlers.pop();
47503
+ }
47504
+ }
47505
+ function syncHandlerEntries(manager, internals) {
47506
+ const handlers = manager.handlers;
47507
+ const length = countHandlers(handlers);
47508
+ if (handlers !== internals.handlersRef) {
47509
+ internals.handlersRef = handlers;
47510
+ internals.handlerEntries.clear();
47511
+ } else if (length !== internals.handlersLength) {
47512
+ if (!length) {
47513
+ internals.handlerEntries.clear();
47514
+ } else {
47515
+ internals.handlerEntries.forEach(function removeStaleEntry(entry, id) {
47516
+ if (handlers[entry.index] !== entry.handler) {
47517
+ internals.handlerEntries.delete(id);
47518
+ }
47519
+ });
47520
+ }
47521
+ }
47522
+ internals.handlersLength = length;
47523
+ }
46952
47524
  var InterceptorManager = class {
46953
47525
  constructor() {
46954
47526
  this.handlers = [];
47527
+ this[$internals2] = {
47528
+ handlersRef: this.handlers,
47529
+ handlersLength: this.handlers.length,
47530
+ handlerEntries: /* @__PURE__ */ new Map(),
47531
+ iterationDepth: 0,
47532
+ nextId: 0
47533
+ };
46955
47534
  }
46956
47535
  /**
46957
47536
  * Add a new interceptor to the stack
@@ -46963,13 +47542,25 @@ var InterceptorManager = class {
46963
47542
  * @return {Number} An ID used to remove interceptor later
46964
47543
  */
46965
47544
  use(fulfilled, rejected, options) {
46966
- this.handlers.push({
47545
+ const handler = {
46967
47546
  fulfilled,
46968
47547
  rejected,
46969
47548
  synchronous: options ? options.synchronous : false,
46970
47549
  runWhen: options ? options.runWhen : null
47550
+ };
47551
+ const internals = this[$internals2];
47552
+ if (this.handlers == null) {
47553
+ this.handlers = [];
47554
+ }
47555
+ syncHandlerEntries(this, internals);
47556
+ const id = internals.nextId++;
47557
+ this.handlers.push(handler);
47558
+ internals.handlerEntries.set(id, {
47559
+ handler,
47560
+ index: this.handlers.length - 1
46971
47561
  });
46972
- return this.handlers.length - 1;
47562
+ internals.handlersLength = this.handlers.length;
47563
+ return id;
46973
47564
  }
46974
47565
  /**
46975
47566
  * Remove an interceptor from the stack
@@ -46979,8 +47570,19 @@ var InterceptorManager = class {
46979
47570
  * @returns {void}
46980
47571
  */
46981
47572
  eject(id) {
46982
- if (this.handlers[id]) {
46983
- this.handlers[id] = null;
47573
+ const internals = this[$internals2];
47574
+ syncHandlerEntries(this, internals);
47575
+ const entry = internals.handlerEntries.get(id);
47576
+ if (entry) {
47577
+ internals.handlerEntries.delete(id);
47578
+ if (this.handlers[entry.index] !== entry.handler) {
47579
+ return;
47580
+ }
47581
+ this.handlers[entry.index] = null;
47582
+ if (!internals.iterationDepth) {
47583
+ trimHandlers(this.handlers);
47584
+ internals.handlersLength = this.handlers.length;
47585
+ }
46984
47586
  }
46985
47587
  }
46986
47588
  /**
@@ -46991,6 +47593,7 @@ var InterceptorManager = class {
46991
47593
  clear() {
46992
47594
  if (this.handlers) {
46993
47595
  this.handlers = [];
47596
+ syncHandlerEntries(this, this[$internals2]);
46994
47597
  }
46995
47598
  }
46996
47599
  /**
@@ -47004,11 +47607,22 @@ var InterceptorManager = class {
47004
47607
  * @returns {void}
47005
47608
  */
47006
47609
  forEach(fn) {
47007
- utils_default.forEach(this.handlers, function forEachHandler(h) {
47008
- if (h !== null) {
47009
- fn(h);
47610
+ const internals = this[$internals2];
47611
+ syncHandlerEntries(this, internals);
47612
+ internals.iterationDepth++;
47613
+ try {
47614
+ utils_default.forEach(this.handlers, function forEachHandler(h) {
47615
+ if (h !== null) {
47616
+ fn(h);
47617
+ }
47618
+ });
47619
+ } finally {
47620
+ if (!--internals.iterationDepth) {
47621
+ syncHandlerEntries(this, internals);
47622
+ trimHandlers(this.handlers);
47623
+ internals.handlersLength = countHandlers(this.handlers);
47010
47624
  }
47011
- });
47625
+ }
47012
47626
  }
47013
47627
  };
47014
47628
  var InterceptorManager_default = InterceptorManager;
@@ -47166,6 +47780,22 @@ function formDataToJSON(formData) {
47166
47780
  }
47167
47781
  var formDataToJSON_default = formDataToJSON;
47168
47782
 
47783
+ // node_modules/axios/lib/core/methodList.js
47784
+ var methodList = Object.freeze([
47785
+ "get",
47786
+ "delete",
47787
+ "head",
47788
+ "options",
47789
+ "post",
47790
+ "put",
47791
+ "patch",
47792
+ "purge",
47793
+ "link",
47794
+ "unlink",
47795
+ "query"
47796
+ ]);
47797
+ var methodList_default = methodList;
47798
+
47169
47799
  // node_modules/axios/lib/defaults/index.js
47170
47800
  var own = (obj, key) => obj != null && utils_default.hasOwnProp(obj, key) ? obj[key] : void 0;
47171
47801
  function stringifySafely2(rawValue, parser, encoder) {
@@ -47278,7 +47908,7 @@ var defaults = {
47278
47908
  }
47279
47909
  }
47280
47910
  };
47281
- utils_default.forEach(["delete", "get", "head", "post", "put", "patch", "query"], (method) => {
47911
+ utils_default.forEach(methodList_default, (method) => {
47282
47912
  defaults.headers[method] = {};
47283
47913
  });
47284
47914
  var defaults_default = defaults;
@@ -47356,19 +47986,21 @@ function combineURLs(baseURL, relativeURL) {
47356
47986
  return baseURL.slice(0, end) + "/" + relativeURL.replace(/^\/+/, "");
47357
47987
  }
47358
47988
 
47359
- // node_modules/axios/lib/core/buildFullPath.js
47360
- var malformedHttpProtocol = /^https?:(?!\/\/)/i;
47361
- var httpProtocolControlCharacters = /[\t\n\r]/g;
47362
- function stripLeadingC0ControlOrSpace(url2) {
47363
- let i = 0;
47364
- while (i < url2.length && url2.charCodeAt(i) <= 32) {
47365
- i++;
47366
- }
47367
- return url2.slice(i);
47368
- }
47989
+ // node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js
47990
+ var urlParserControlCharacters = /[\t\n\r]/g;
47369
47991
  function normalizeURLForProtocolCheck(url2) {
47370
- return stripLeadingC0ControlOrSpace(url2).replace(httpProtocolControlCharacters, "");
47992
+ if (typeof url2 !== "string") {
47993
+ return url2;
47994
+ }
47995
+ let start = 0;
47996
+ while (start < url2.length && url2.charCodeAt(start) <= 32) {
47997
+ start++;
47998
+ }
47999
+ return url2.slice(start).replace(urlParserControlCharacters, "");
47371
48000
  }
48001
+
48002
+ // node_modules/axios/lib/core/buildFullPath.js
48003
+ var malformedHttpProtocol = /^https?:(?!\/\/)/i;
47372
48004
  function redactFragment(fragment) {
47373
48005
  if (!fragment) {
47374
48006
  return fragment;
@@ -47490,7 +48122,7 @@ var import_follow_redirects = __toESM(require_follow_redirects(), 1);
47490
48122
  var import_zlib = __toESM(require("zlib"), 1);
47491
48123
 
47492
48124
  // node_modules/axios/lib/env/data.js
47493
- var VERSION = "1.19.0";
48125
+ var VERSION = "1.20.0";
47494
48126
 
47495
48127
  // node_modules/axios/lib/helpers/parseProtocol.js
47496
48128
  function parseProtocol(url2) {
@@ -47499,7 +48131,7 @@ function parseProtocol(url2) {
47499
48131
  }
47500
48132
 
47501
48133
  // node_modules/axios/lib/helpers/fromDataURI.js
47502
- var DATA_URL_PATTERN = /^([^,;]+\/[^,;]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
48134
+ var DATA_URL_PATTERN = /^([^,;/]+\/[^,;/]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
47503
48135
  function fromDataURI(uri, asBlob, options) {
47504
48136
  const _Blob = options && options.Blob || platform_default.classes.Blob;
47505
48137
  const protocol = parseProtocol(uri);
@@ -47812,6 +48444,7 @@ var Http2Sessions = class {
47812
48444
  }
47813
48445
  getSession(authority, options) {
47814
48446
  options = Object.assign(
48447
+ /* @__PURE__ */ Object.create(null),
47815
48448
  {
47816
48449
  sessionTimeout: 1e3
47817
48450
  },
@@ -47877,6 +48510,7 @@ var Http2Sessions = class {
47877
48510
  };
47878
48511
  }
47879
48512
  session.once("close", removeSession);
48513
+ session.once("error", removeSession);
47880
48514
  let entry = [session, options];
47881
48515
  authoritySessions ? authoritySessions.push(entry) : authoritySessions = this.sessions[authority] = [entry];
47882
48516
  return session;
@@ -47901,6 +48535,13 @@ var callbackify_default = callbackify;
47901
48535
 
47902
48536
  // node_modules/axios/lib/helpers/shouldBypassProxy.js
47903
48537
  var LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["localhost", "0.0.0.0"]);
48538
+ var trimTrailingDots = (value) => {
48539
+ let end = value.length;
48540
+ while (end && value.charCodeAt(end - 1) === 46) {
48541
+ end--;
48542
+ }
48543
+ return end === value.length ? value : value.slice(0, end);
48544
+ };
47904
48545
  var isIPv4Loopback = (host) => {
47905
48546
  const parts = host.split(".");
47906
48547
  if (parts.length !== 4) return false;
@@ -47933,7 +48574,7 @@ var normalizeIPAddress = (host) => {
47933
48574
  if (h.charAt(0) === "[" && h.charAt(h.length - 1) === "]") {
47934
48575
  h = h.slice(1, -1);
47935
48576
  }
47936
- h = h.replace(/\.+$/, "");
48577
+ h = trimTrailingDots(h);
47937
48578
  if (!/^[0-9.xXa-fA-F]+$/.test(h)) return host;
47938
48579
  const parts = h.split(".");
47939
48580
  if (parts.some((p) => p === "")) return host;
@@ -48045,6 +48686,40 @@ var unmapIPv4MappedIPv6 = (host) => {
48045
48686
  }
48046
48687
  return host;
48047
48688
  };
48689
+ var IPV4_OCTET_RE = /^(?:0|[1-9]\d{0,2})$/;
48690
+ var ipv4ToBytes = (host) => {
48691
+ const parts = host.split(".");
48692
+ return parts.length === 4 && parts.every((part) => IPV4_OCTET_RE.test(part) && Number(part) <= 255) ? parts.map(Number) : null;
48693
+ };
48694
+ var IPV6_GROUP_RE = /^[0-9a-f]{1,4}$/i;
48695
+ var ipv6ToBytes = (host) => {
48696
+ const halves = host.split("::");
48697
+ if (halves.length > 2) {
48698
+ return null;
48699
+ }
48700
+ const groups = halves[0] ? halves[0].split(":") : [];
48701
+ if (halves.length === 2) {
48702
+ const rear = halves[1] ? halves[1].split(":") : [];
48703
+ const missing = 8 - groups.length - rear.length;
48704
+ if (missing < 1) {
48705
+ return null;
48706
+ }
48707
+ groups.push(...new Array(missing).fill("0"), ...rear);
48708
+ }
48709
+ if (groups.length !== 8 || groups.some((group) => !IPV6_GROUP_RE.test(group))) {
48710
+ return null;
48711
+ }
48712
+ return groups.flatMap((group) => {
48713
+ const value = Number.parseInt(group, 16);
48714
+ return [value >> 8 & 255, value & 255];
48715
+ });
48716
+ };
48717
+ var ipToBytes = (host) => {
48718
+ if (typeof host !== "string" || !host) {
48719
+ return null;
48720
+ }
48721
+ return host.indexOf(":") !== -1 ? ipv6ToBytes(host) : ipv4ToBytes(host);
48722
+ };
48048
48723
  var normalizeNoProxyHost = (hostname) => {
48049
48724
  if (!hostname) {
48050
48725
  return hostname;
@@ -48052,13 +48727,90 @@ var normalizeNoProxyHost = (hostname) => {
48052
48727
  if (hostname.charAt(0) === "[" && hostname.charAt(hostname.length - 1) === "]") {
48053
48728
  hostname = hostname.slice(1, -1);
48054
48729
  }
48055
- const trimmed = hostname.replace(/\.+$/, "");
48730
+ const trimmed = trimTrailingDots(hostname);
48056
48731
  const ipv4 = normalizeIPAddress(trimmed);
48057
48732
  if (ipv4 !== trimmed) {
48058
48733
  return ipv4;
48059
48734
  }
48060
48735
  return unmapIPv4MappedIPv6(trimmed);
48061
48736
  };
48737
+ var normalizeCidrBase = (input) => {
48738
+ let base = input;
48739
+ const startsBracket = base.charAt(0) === "[";
48740
+ const endsBracket = base.charAt(base.length - 1) === "]";
48741
+ const hasBracket = base.includes("[") || base.includes("]");
48742
+ if (startsBracket || endsBracket) {
48743
+ if (!startsBracket || !endsBracket) {
48744
+ return null;
48745
+ }
48746
+ base = base.slice(1, -1);
48747
+ if (base.indexOf(":") === -1 || base.includes("[") || base.includes("]")) {
48748
+ return null;
48749
+ }
48750
+ } else if (hasBracket) {
48751
+ return null;
48752
+ }
48753
+ if (!base || base.charAt(base.length - 1) === ".") {
48754
+ return null;
48755
+ }
48756
+ const wasIPv6 = base.indexOf(":") !== -1;
48757
+ if (wasIPv6) {
48758
+ try {
48759
+ base = new URL(`http://[${base}]/`).hostname.slice(1, -1);
48760
+ } catch (_err) {
48761
+ return null;
48762
+ }
48763
+ } else {
48764
+ base = normalizeIPAddress(base);
48765
+ if (!ipv4ToBytes(base)) {
48766
+ return null;
48767
+ }
48768
+ }
48769
+ return { normalized: unmapIPv4MappedIPv6(base), wasIPv6 };
48770
+ };
48771
+ var CIDR_ENTRY_RE = /^(.+)\/(0|[1-9]\d{0,2})$/;
48772
+ var parseCidrEntry = (entry) => {
48773
+ if (entry.indexOf("/") === -1) {
48774
+ return void 0;
48775
+ }
48776
+ const match = CIDR_ENTRY_RE.exec(entry);
48777
+ if (!match) {
48778
+ return null;
48779
+ }
48780
+ let prefix = Number(match[2]);
48781
+ const parsedBase = normalizeCidrBase(match[1]);
48782
+ if (!parsedBase) {
48783
+ return null;
48784
+ }
48785
+ const { normalized, wasIPv6 } = parsedBase;
48786
+ if (wasIPv6 && normalized.indexOf(":") === -1) {
48787
+ if (prefix < 96) {
48788
+ return null;
48789
+ }
48790
+ prefix -= 96;
48791
+ }
48792
+ const bytes = ipToBytes(normalized);
48793
+ if (!bytes || prefix > bytes.length * 8) {
48794
+ return null;
48795
+ }
48796
+ return { bytes, prefix };
48797
+ };
48798
+ var isInSubnet = (addressBytes, networkBytes, prefix) => {
48799
+ const fullBytes = prefix >> 3;
48800
+ for (let i = 0; i < fullBytes; i++) {
48801
+ if (addressBytes[i] !== networkBytes[i]) {
48802
+ return false;
48803
+ }
48804
+ }
48805
+ const remainingBits = prefix & 7;
48806
+ if (remainingBits) {
48807
+ const mask = 255 << 8 - remainingBits & 255;
48808
+ if ((addressBytes[fullBytes] & mask) !== (networkBytes[fullBytes] & mask)) {
48809
+ return false;
48810
+ }
48811
+ }
48812
+ return true;
48813
+ };
48062
48814
  function shouldBypassProxy(location) {
48063
48815
  let parsed;
48064
48816
  try {
@@ -48075,6 +48827,7 @@ function shouldBypassProxy(location) {
48075
48827
  }
48076
48828
  const port = Number.parseInt(parsed.port, 10) || DEFAULT_PORTS2[parsed.protocol.split(":", 1)[0]] || 0;
48077
48829
  const hostname = normalizeNoProxyHost(parsed.hostname.toLowerCase());
48830
+ const hostnameBytes = ipToBytes(hostname);
48078
48831
  return noProxy.split(/[\s,]+/).some((entry) => {
48079
48832
  if (!entry) {
48080
48833
  return false;
@@ -48082,6 +48835,10 @@ function shouldBypassProxy(location) {
48082
48835
  if (entry === "*") {
48083
48836
  return true;
48084
48837
  }
48838
+ const cidr = parseCidrEntry(entry);
48839
+ if (cidr !== void 0) {
48840
+ return cidr !== null && !!hostnameBytes && hostnameBytes.length === cidr.bytes.length && isInSubnet(hostnameBytes, cidr.bytes, cidr.prefix);
48841
+ }
48085
48842
  let [entryHost, entryPort] = parseNoProxyEntry(entry);
48086
48843
  entryHost = normalizeNoProxyHost(entryHost);
48087
48844
  if (!entryHost) {
@@ -48167,7 +48924,8 @@ function throttle(fn, freq) {
48167
48924
  }
48168
48925
  };
48169
48926
  const flush = () => lastArgs && invoke(lastArgs);
48170
- return [throttled, flush];
48927
+ const flushWith = (...args) => invoke(args);
48928
+ return [throttled, flush, flushWith];
48171
48929
  }
48172
48930
  var throttle_default = throttle;
48173
48931
 
@@ -48176,7 +48934,7 @@ var progressEventReducer = (listener, isDownloadStream, freq = 3) => {
48176
48934
  let bytesNotified = 0;
48177
48935
  const _speedometer = speedometer_default(50, 250);
48178
48936
  return throttle_default((e) => {
48179
- if (!e || typeof e.loaded !== "number") {
48937
+ if (!e || !utils_default.isNumber(e.loaded)) {
48180
48938
  return;
48181
48939
  }
48182
48940
  const rawLoaded = e.loaded;
@@ -48337,6 +49095,12 @@ var { http: httpFollow, https: httpsFollow } = import_follow_redirects.default;
48337
49095
  var isHttps = /https:?/;
48338
49096
  var kAxiosSocketListener = Symbol("axios.http.socketListener");
48339
49097
  var kAxiosCurrentReq = Symbol("axios.http.currentReq");
49098
+ function handleSocketError(err) {
49099
+ const current = this[kAxiosCurrentReq];
49100
+ if (current && !current.destroyed) {
49101
+ current.destroy(err);
49102
+ }
49103
+ }
48340
49104
  var kAxiosInstalledTunnel = Symbol("axios.http.installedTunnel");
48341
49105
  var tunnelingAgentCache = /* @__PURE__ */ new Map();
48342
49106
  var tunnelingAgentCacheUser = /* @__PURE__ */ new WeakMap();
@@ -48439,10 +49203,10 @@ function isSameOriginRedirect(redirectOptions, requestDetails) {
48439
49203
  return false;
48440
49204
  }
48441
49205
  }
48442
- function setProxy(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent) {
49206
+ function setProxy(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent, allowEnvProxy = true) {
48443
49207
  let proxy = configProxy;
48444
49208
  const proxyEnvAgent = getProxyEnvAgent(options, configHttpAgent, configHttpsAgent);
48445
- if (!proxy && proxy !== false && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
49209
+ if (!proxy && proxy !== false && allowEnvProxy && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
48446
49210
  const proxyUrl = getProxyForUrl(location);
48447
49211
  if (proxyUrl) {
48448
49212
  if (!shouldBypassProxy(location)) {
@@ -48539,9 +49303,13 @@ function setProxy(options, configProxy, location, isRedirect, configHttpsAgent,
48539
49303
  redirectOptions.href,
48540
49304
  true,
48541
49305
  configHttpsAgent,
48542
- configHttpAgent
49306
+ configHttpAgent,
49307
+ allowEnvProxy
48543
49308
  );
48544
49309
  };
49310
+ return Boolean(
49311
+ proxy || configProxy !== false && allowEnvProxy && isNodeEnvProxyEnabled(proxyEnvAgent)
49312
+ );
48545
49313
  }
48546
49314
  var isHttpAdapterSupported = typeof process !== "undefined" && utils_default.kindOf(process) === "process";
48547
49315
  var wrapAsync = (asyncExecutor) => {
@@ -48566,7 +49334,7 @@ var wrapAsync = (asyncExecutor) => {
48566
49334
  };
48567
49335
  var resolveFamily = ({ address, family }) => {
48568
49336
  if (!utils_default.isString(address)) {
48569
- throw TypeError("address must be a string");
49337
+ throw new AxiosError_default("address must be a string", AxiosError_default.ERR_BAD_OPTION_VALUE);
48570
49338
  }
48571
49339
  return {
48572
49340
  address,
@@ -48574,6 +49342,30 @@ var resolveFamily = ({ address, family }) => {
48574
49342
  };
48575
49343
  };
48576
49344
  var buildAddressEntry = (address, family) => resolveFamily(utils_default.isObject(address) ? address : { address, family });
49345
+ var normalizedLookupCache = /* @__PURE__ */ new WeakMap();
49346
+ var normalizeLookup = (lookup) => {
49347
+ let normalized = normalizedLookupCache.get(lookup);
49348
+ if (normalized) {
49349
+ return normalized;
49350
+ }
49351
+ const callbackLookup = callbackify_default(lookup, (value) => utils_default.isArray(value) ? value : [value]);
49352
+ normalized = (hostname, opt, cb) => {
49353
+ callbackLookup(hostname, opt, (err, arg0, arg1) => {
49354
+ if (err) {
49355
+ return cb(err);
49356
+ }
49357
+ let addresses;
49358
+ try {
49359
+ addresses = utils_default.isArray(arg0) ? arg0.map((addr) => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
49360
+ } catch (error) {
49361
+ return cb(error);
49362
+ }
49363
+ opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
49364
+ });
49365
+ };
49366
+ normalizedLookupCache.set(lookup, normalized);
49367
+ return normalized;
49368
+ };
48577
49369
  var http2Transport = {
48578
49370
  request(options, cb) {
48579
49371
  const authority = options.protocol + "//" + options.hostname + ":" + (options.port || (options.protocol === "https:" ? 443 : 80));
@@ -48610,6 +49402,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48610
49402
  let family = own2("family");
48611
49403
  let httpVersion = own2("httpVersion");
48612
49404
  if (httpVersion === void 0) httpVersion = 1;
49405
+ const rawHttpVersion = httpVersion;
48613
49406
  let http2Options = own2("http2Options");
48614
49407
  const httpAgent = own2("httpAgent");
48615
49408
  const httpsAgent = own2("httpsAgent");
@@ -48626,25 +49419,32 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48626
49419
  let rejected = false;
48627
49420
  let req;
48628
49421
  let connectPhaseTimer;
48629
- httpVersion = +httpVersion;
49422
+ try {
49423
+ httpVersion = +httpVersion;
49424
+ } catch (err) {
49425
+ throw new AxiosError_default(
49426
+ "Invalid protocol version: value is not a number",
49427
+ AxiosError_default.ERR_BAD_OPTION_VALUE,
49428
+ config
49429
+ );
49430
+ }
48630
49431
  if (Number.isNaN(httpVersion)) {
48631
- throw TypeError(`Invalid protocol version: '${config.httpVersion}' is not a number`);
49432
+ throw new AxiosError_default(
49433
+ `Invalid protocol version: '${rawHttpVersion}' is not a number`,
49434
+ AxiosError_default.ERR_BAD_OPTION_VALUE,
49435
+ config
49436
+ );
48632
49437
  }
48633
49438
  if (httpVersion !== 1 && httpVersion !== 2) {
48634
- throw TypeError(`Unsupported protocol version '${httpVersion}'`);
49439
+ throw new AxiosError_default(
49440
+ `Unsupported protocol version '${httpVersion}'`,
49441
+ AxiosError_default.ERR_BAD_OPTION_VALUE,
49442
+ config
49443
+ );
48635
49444
  }
48636
49445
  const isHttp2 = httpVersion === 2;
48637
49446
  if (lookup) {
48638
- const _lookup = callbackify_default(lookup, (value) => utils_default.isArray(value) ? value : [value]);
48639
- lookup = (hostname, opt, cb) => {
48640
- _lookup(hostname, opt, (err, arg0, arg1) => {
48641
- if (err) {
48642
- return cb(err);
48643
- }
48644
- const addresses = utils_default.isArray(arg0) ? arg0.map((addr) => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
48645
- opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
48646
- });
48647
- };
49447
+ lookup = normalizeLookup(lookup);
48648
49448
  }
48649
49449
  const abortEmitter = new import_events.EventEmitter();
48650
49450
  function abort(reason) {
@@ -48887,6 +49687,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48887
49687
  utils_default.hasOwnProp(transitional2, "advertiseZstdAcceptEncoding") && transitional2.advertiseZstdAcceptEncoding === true ? ACCEPT_ENCODING_WITH_ZSTD : ACCEPT_ENCODING,
48888
49688
  false
48889
49689
  );
49690
+ if (isHttp2 && lookup) {
49691
+ http2Options = Object.assign(/* @__PURE__ */ Object.create(null), http2Options, { lookup });
49692
+ }
48890
49693
  const options = Object.assign(/* @__PURE__ */ Object.create(null), {
48891
49694
  path: path5,
48892
49695
  method,
@@ -48897,9 +49700,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48897
49700
  family,
48898
49701
  beforeRedirect: dispatchBeforeRedirect,
48899
49702
  beforeRedirects: /* @__PURE__ */ Object.create(null),
48900
- http2Options
49703
+ http2Options,
49704
+ createConnection: void 0
48901
49705
  });
48902
49706
  !utils_default.isUndefined(lookup) && (options.lookup = lookup);
49707
+ let proxyApplied = false;
48903
49708
  if (socketPath) {
48904
49709
  if (typeof socketPath !== "string") {
48905
49710
  return reject(
@@ -48927,13 +49732,17 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48927
49732
  } else {
48928
49733
  options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
48929
49734
  options.port = parsed.port;
48930
- setProxy(
49735
+ proxyApplied = setProxy(
48931
49736
  options,
48932
49737
  configProxy,
48933
49738
  protocol + "//" + parsed.hostname + (parsed.port ? ":" + parsed.port : "") + options.path,
48934
49739
  false,
48935
49740
  httpsAgent,
48936
- httpAgent
49741
+ httpAgent,
49742
+ // The HTTP/2 transport connects independently of HTTP/1 agents, so it
49743
+ // cannot apply either axios-resolved or agent-local environment proxies.
49744
+ // Explicit proxy config is still processed and rejected below.
49745
+ !isHttp2
48937
49746
  );
48938
49747
  }
48939
49748
  let transport;
@@ -48944,6 +49753,15 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48944
49753
  options.agent = isHttpsRequest ? httpsAgent : httpAgent;
48945
49754
  }
48946
49755
  if (isHttp2) {
49756
+ if (proxyApplied) {
49757
+ return reject(
49758
+ new AxiosError_default(
49759
+ "HTTP/2 requests with a proxy are not supported",
49760
+ AxiosError_default.ERR_NOT_SUPPORT,
49761
+ config
49762
+ )
49763
+ );
49764
+ }
48947
49765
  transport = http2Transport;
48948
49766
  } else {
48949
49767
  const configTransport = own2("transport");
@@ -49031,7 +49849,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
49031
49849
  transformStream,
49032
49850
  progressEventDecorator(
49033
49851
  responseLength,
49034
- progressEventReducer(asyncDecorator(onDownloadProgress, scheduleProgress), true, 3)
49852
+ progressEventReducer(
49853
+ asyncDecorator(onDownloadProgress, scheduleProgress),
49854
+ true,
49855
+ 3
49856
+ )
49035
49857
  )
49036
49858
  )
49037
49859
  );
@@ -49180,12 +50002,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
49180
50002
  socket.setKeepAlive(true, 1e3 * 60);
49181
50003
  }
49182
50004
  if (!socket[kAxiosSocketListener]) {
49183
- socket.on("error", function handleSocketError(err) {
49184
- const current = socket[kAxiosCurrentReq];
49185
- if (current && !current.destroyed) {
49186
- current.destroy(err);
49187
- }
49188
- });
50005
+ socket.on("error", handleSocketError);
49189
50006
  socket[kAxiosSocketListener] = true;
49190
50007
  }
49191
50008
  socket[kAxiosCurrentReq] = req;
@@ -49430,7 +50247,7 @@ function mergeConfig(config1, config2) {
49430
50247
  transformResponse: defaultToConfig2,
49431
50248
  paramsSerializer: defaultToConfig2,
49432
50249
  timeout: defaultToConfig2,
49433
- timeoutMessage: defaultToConfig2,
50250
+ timeoutErrorMessage: defaultToConfig2,
49434
50251
  withCredentials: defaultToConfig2,
49435
50252
  withXSRFToken: defaultToConfig2,
49436
50253
  adapter: defaultToConfig2,
@@ -49507,10 +50324,11 @@ function resolveConfig(config) {
49507
50324
  }
49508
50325
  }
49509
50326
  if (utils_default.isFormData(data)) {
50327
+ const getHeaders = utils_default.getSafeProp(data, "getHeaders");
49510
50328
  if (platform_default.hasStandardBrowserEnv || platform_default.hasStandardBrowserWebWorkerEnv || utils_default.isReactNative(data)) {
49511
50329
  headers.setContentType(void 0);
49512
- } else if (utils_default.isFunction(data.getHeaders)) {
49513
- setFormDataHeaders(headers, data.getHeaders(), own2("formDataHeaderPolicy"));
50330
+ } else if (utils_default.isFunction(getHeaders)) {
50331
+ setFormDataHeaders(headers, getHeaders.call(data), own2("formDataHeaderPolicy"));
49514
50332
  }
49515
50333
  }
49516
50334
  if (platform_default.hasStandardBrowserEnv) {
@@ -49539,7 +50357,7 @@ var xhr_default = isXHRAdapterSupported && function(config) {
49539
50357
  let { responseType, onUploadProgress, onDownloadProgress } = _config;
49540
50358
  let onCanceled;
49541
50359
  let uploadThrottled, downloadThrottled;
49542
- let flushUpload, flushDownload;
50360
+ let flushUpload, flushDownload, flushDownloadWithEvent;
49543
50361
  function done() {
49544
50362
  flushUpload && flushUpload();
49545
50363
  flushDownload && flushDownload();
@@ -49549,7 +50367,27 @@ var xhr_default = isXHRAdapterSupported && function(config) {
49549
50367
  let request = new XMLHttpRequest();
49550
50368
  request.open(_config.method.toUpperCase(), _config.url, true);
49551
50369
  request.timeout = _config.timeout;
49552
- function onloadend() {
50370
+ function onloadend(event) {
50371
+ if (!request) {
50372
+ return;
50373
+ }
50374
+ if (request.status === 0 && (parseProtocol(normalizeURLForProtocolCheck(_config.url)) || parseProtocol(platform_default.origin)) !== "file" && !(request.responseURL && request.responseURL.startsWith("file:"))) {
50375
+ reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED, config, request));
50376
+ done();
50377
+ request = null;
50378
+ return;
50379
+ }
50380
+ try {
50381
+ if (event) {
50382
+ flushDownloadWithEvent && flushDownloadWithEvent(event);
50383
+ } else {
50384
+ flushDownload && flushDownload();
50385
+ }
50386
+ } catch (err) {
50387
+ setTimeout(() => {
50388
+ throw err;
50389
+ });
50390
+ }
49553
50391
  if (!request) {
49554
50392
  return;
49555
50393
  }
@@ -49637,7 +50475,10 @@ var xhr_default = isXHRAdapterSupported && function(config) {
49637
50475
  request.responseType = _config.responseType;
49638
50476
  }
49639
50477
  if (onDownloadProgress) {
49640
- [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
50478
+ [downloadThrottled, flushDownload, flushDownloadWithEvent] = progressEventReducer(
50479
+ onDownloadProgress,
50480
+ true
50481
+ );
49641
50482
  request.addEventListener("progress", downloadThrottled);
49642
50483
  }
49643
50484
  if (onUploadProgress && request.upload) {
@@ -49807,6 +50648,17 @@ var trackStream = (stream4, chunkSize, onProgress, onFinish) => {
49807
50648
 
49808
50649
  // node_modules/axios/lib/adapters/fetch.js
49809
50650
  var DEFAULT_CHUNK_SIZE = 64 * 1024;
50651
+ var DEFAULT_REQUEST_OPTIONS = {
50652
+ cache: "default",
50653
+ redirect: "follow",
50654
+ referrer: "about:client",
50655
+ referrerPolicy: "",
50656
+ mode: "cors",
50657
+ integrity: "",
50658
+ keepalive: false,
50659
+ priority: "auto",
50660
+ window: null
50661
+ };
49810
50662
  var { isFunction: isFunction2 } = utils_default;
49811
50663
  var encodeUTF82 = (str) => encodeURIComponent(str).replace(
49812
50664
  /%([0-9A-F]{2})/gi,
@@ -49937,7 +50789,8 @@ var factory = (env) => {
49937
50789
  withCredentials = "same-origin",
49938
50790
  fetchOptions,
49939
50791
  maxContentLength,
49940
- maxBodyLength
50792
+ maxBodyLength,
50793
+ maxRedirects
49941
50794
  } = resolveConfig_default(config);
49942
50795
  const hasMaxContentLength = utils_default.isNumber(maxContentLength) && maxContentLength > -1;
49943
50796
  const hasMaxBodyLength = utils_default.isNumber(maxBodyLength) && maxBodyLength > -1;
@@ -50067,17 +50920,44 @@ var factory = (env) => {
50067
50920
  }
50068
50921
  }
50069
50922
  headers.set("User-Agent", "axios/" + VERSION, false);
50070
- const resolvedOptions = {
50071
- ...fetchOptions,
50923
+ const safeFetchOptions = fetchOptions == null ? fetchOptions : Object.assign(/* @__PURE__ */ Object.create(null), fetchOptions);
50924
+ if (safeFetchOptions) {
50925
+ delete safeFetchOptions.body;
50926
+ delete safeFetchOptions.headers;
50927
+ delete safeFetchOptions.method;
50928
+ delete safeFetchOptions.signal;
50929
+ delete safeFetchOptions.duplex;
50930
+ delete safeFetchOptions.credentials;
50931
+ }
50932
+ const resolvedOptions = Object.assign(/* @__PURE__ */ Object.create(null), safeFetchOptions, {
50072
50933
  signal: composedSignal,
50073
50934
  method: method.toUpperCase(),
50074
50935
  headers: toByteStringHeaderObject(headers.normalize()),
50075
50936
  body: data,
50076
50937
  duplex: "half",
50077
50938
  credentials: isCredentialsSupported ? withCredentials : void 0
50078
- };
50939
+ });
50940
+ if (isRequestSupported) {
50941
+ utils_default.forEach(DEFAULT_REQUEST_OPTIONS, (value, key) => {
50942
+ if (resolvedOptions[key] === void 0) {
50943
+ resolvedOptions[key] = value;
50944
+ }
50945
+ });
50946
+ if (resolvedOptions.signal === void 0) {
50947
+ resolvedOptions.signal = null;
50948
+ }
50949
+ if (resolvedOptions.body === void 0) {
50950
+ resolvedOptions.body = null;
50951
+ }
50952
+ }
50953
+ if (maxRedirects === 0) {
50954
+ resolvedOptions.redirect = "manual";
50955
+ if (safeFetchOptions) {
50956
+ safeFetchOptions.redirect = "manual";
50957
+ }
50958
+ }
50079
50959
  request = isRequestSupported && new Request(url2, resolvedOptions);
50080
- let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url2, resolvedOptions));
50960
+ let response = await (isRequestSupported ? _fetch(request, safeFetchOptions) : _fetch(url2, resolvedOptions));
50081
50961
  const responseHeaders = AxiosHeaders_default.from(response.headers);
50082
50962
  if (hasMaxContentLength) {
50083
50963
  const declaredLength = utils_default.toFiniteNumber(responseHeaders.getContentLength());
@@ -50296,9 +51176,10 @@ function throwIfCancellationRequested(config) {
50296
51176
  throw new CanceledError_default(null, config);
50297
51177
  }
50298
51178
  }
50299
- function dispatchRequest(config) {
51179
+ function dispatchRequest(_config) {
51180
+ const config = utils_default.toSafeFlatObject(_config);
50300
51181
  throwIfCancellationRequested(config);
50301
- config.headers = AxiosHeaders_default.from(config.headers);
51182
+ config.headers = AxiosHeaders_default.from(utils_default.getSafeProp(config, "headers"));
50302
51183
  config.data = transformData.call(config, config.transformRequest);
50303
51184
  if (["post", "put", "patch"].indexOf(config.method) !== -1) {
50304
51185
  config.headers.setContentType("application/x-www-form-urlencoded", false);
@@ -50428,16 +51309,15 @@ var Axios = class {
50428
51309
  return await this._request(configOrUrl, config);
50429
51310
  } catch (err) {
50430
51311
  if (err instanceof Error) {
50431
- let dummy = {};
50432
- Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
50433
- const stack = (() => {
50434
- if (!dummy.stack) {
50435
- return "";
50436
- }
50437
- const firstNewlineIndex = dummy.stack.indexOf("\n");
50438
- return firstNewlineIndex === -1 ? "" : dummy.stack.slice(firstNewlineIndex + 1);
50439
- })();
50440
51312
  try {
51313
+ let dummy = {};
51314
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
51315
+ const dummyStack = dummy.stack;
51316
+ let stack = "";
51317
+ if (typeof dummyStack === "string") {
51318
+ const firstNewlineIndex = dummyStack.indexOf("\n");
51319
+ stack = firstNewlineIndex === -1 ? "" : dummyStack.slice(firstNewlineIndex + 1);
51320
+ }
50441
51321
  if (!err.stack) {
50442
51322
  err.stack = stack;
50443
51323
  } else if (stack) {
@@ -50507,9 +51387,9 @@ var Axios = class {
50507
51387
  },
50508
51388
  true
50509
51389
  );
50510
- config.method = (config.method || this.defaults.method || "get").toLowerCase();
51390
+ config.method = (utils_default.getSafeProp(config, "method") || utils_default.getSafeProp(this.defaults, "method") || "get").toLowerCase();
50511
51391
  let contextHeaders = headers && utils_default.merge(headers.common, headers[config.method]);
50512
- headers && utils_default.forEach(["delete", "get", "head", "post", "put", "patch", "query", "common"], (method) => {
51392
+ headers && utils_default.forEach(methodList_default.concat("common"), (method) => {
50513
51393
  delete headers[method];
50514
51394
  });
50515
51395
  config.headers = AxiosHeaders_default.concat(contextHeaders, headers);
@@ -50772,14 +51652,22 @@ var HttpStatusCode = {
50772
51652
  Gone: 410,
50773
51653
  LengthRequired: 411,
50774
51654
  PreconditionFailed: 412,
51655
+ /**
51656
+ * @deprecated Use `ContentTooLarge` instead.
51657
+ */
50775
51658
  PayloadTooLarge: 413,
51659
+ ContentTooLarge: 413,
50776
51660
  UriTooLong: 414,
50777
51661
  UnsupportedMediaType: 415,
50778
51662
  RangeNotSatisfiable: 416,
50779
51663
  ExpectationFailed: 417,
50780
51664
  ImATeapot: 418,
50781
51665
  MisdirectedRequest: 421,
51666
+ /**
51667
+ * @deprecated Use `UnprocessableContent` instead.
51668
+ */
50782
51669
  UnprocessableEntity: 422,
51670
+ UnprocessableContent: 422,
50783
51671
  Locked: 423,
50784
51672
  FailedDependency: 424,
50785
51673
  TooEarly: 425,
@@ -50808,7 +51696,9 @@ var HttpStatusCode = {
50808
51696
  InvalidSslCertificate: 526
50809
51697
  };
50810
51698
  Object.entries(HttpStatusCode).forEach(([key, value]) => {
50811
- HttpStatusCode[value] = key;
51699
+ if (HttpStatusCode[value] === void 0) {
51700
+ HttpStatusCode[value] = key;
51701
+ }
50812
51702
  });
50813
51703
  var HttpStatusCode_default = HttpStatusCode;
50814
51704
 
@@ -51431,6 +52321,14 @@ var init_deployment_addresses = __esm2({
51431
52321
  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.",
51432
52322
  executeTx: "0xf1f8d5fc13f45d7a3f932bf1a2d6e29381fdd41cd31298ad785bf7688df07fe6",
51433
52323
  block: 25673200
52324
+ },
52325
+ AgentDelegationRegistry: {
52326
+ newImplementation: "0xa9fF405Edd4329fc3159a64F56B37EBD253e4928",
52327
+ upgradedAt: "2026-07-31T22:03:35.000Z",
52328
+ upgradedBy: "AdminModule/Safe audit-batch upgradeToAndCall; executed by 0xEba7BfAeB35ee18408b424Ee0BB45AdDf776589f in tx 0x8fed0ab7eee3aaaa3792a35b40b0ef74bd09cfb1a175934afd846bee546048d4 (block 25655710)",
52329
+ reason: "Reconciled from chain \u2014 mainnet audit rollout batch (cross-ref onchain-auth/.safe-batches/mainnet-audit-execute.json)",
52330
+ executeTx: "0x8fed0ab7eee3aaaa3792a35b40b0ef74bd09cfb1a175934afd846bee546048d4",
52331
+ block: 25655710
51434
52332
  }
51435
52333
  },
51436
52334
  latestEnv: {
@@ -51980,6 +52878,9 @@ var require_pkg_src2 = __commonJS2({
51980
52878
  });
51981
52879
  var index_exports = {};
51982
52880
  __export22(index_exports, {
52881
+ BORROWER_AUTHORIZATION_ENCODE_TYPES: () => BORROWER_AUTHORIZATION_ENCODE_TYPES,
52882
+ BORROWER_AUTHORIZATION_FIELDS: () => BORROWER_AUTHORIZATION_FIELDS,
52883
+ BORROWER_AUTHORIZATION_PRIMARY_TYPES: () => BORROWER_AUTHORIZATION_PRIMARY_TYPES,
51983
52884
  CHIPOTLE_DEPLOYMENTS: () => CHIPOTLE_DEPLOYMENTS,
51984
52885
  DEFAULT_CACHE_CONFIG: () => DEFAULT_CACHE_CONFIG,
51985
52886
  DEFAULT_DEBUG_CONFIG: () => DEFAULT_DEBUG_CONFIG,
@@ -51992,6 +52893,8 @@ var require_pkg_src2 = __commonJS2({
51992
52893
  PerformanceTracker: () => PerformanceTracker,
51993
52894
  RetryStrategy: () => RetryStrategy,
51994
52895
  analyzeError: () => analyzeError,
52896
+ borrowerAuthorizationTypes: () => borrowerAuthorizationTypes,
52897
+ buildBorrowerAuthorizationDomain: () => buildBorrowerAuthorizationDomain,
51995
52898
  calculateDelay: () => calculateDelay,
51996
52899
  cidToHex: () => cidToHex,
51997
52900
  classifyError: () => classifyError,
@@ -52238,30 +53141,30 @@ var require_pkg_src2 = __commonJS2({
52238
53141
  }
52239
53142
  },
52240
53143
  btcTransactionSigner: {
52241
- cid: "QmakWzTce8NH1Jkgv1xwg83Bg9WmF2UG1Mq76pDYDSwwUp",
53144
+ cid: "QmVi1BYdxvCX3QUhXwPtP6FjWMzqSPtXzrS54YsXjTgjYf",
52242
53145
  authorizedCidHex: cidToHex(
52243
- "QmakWzTce8NH1Jkgv1xwg83Bg9WmF2UG1Mq76pDYDSwwUp"
53146
+ "QmVi1BYdxvCX3QUhXwPtP6FjWMzqSPtXzrS54YsXjTgjYf"
52244
53147
  ),
52245
53148
  name: "Btc Transaction Signer",
52246
53149
  description: "Production Btc Transaction Signer",
52247
53150
  version: "1.1.1",
52248
53151
  deployed: true,
52249
- deployedAt: 1786465606156,
52250
- size: 67999,
52251
- hash: "83f3644c68819215e05ba8db3225571354a009458fc1437f606df6cb9142d3f9"
53152
+ deployedAt: 1787923905597,
53153
+ size: 70646,
53154
+ hash: "37c3bb72a660c8275d92e1b73f9482742d86b64789480b9246304c0ca1bab47a"
52252
53155
  },
52253
53156
  ucdMintValidator: {
52254
- cid: "Qmd8jgKRceLvf5aoTtwdXG2JqMoBK5cRJwrvEtQkgvbFbx",
53157
+ cid: "QmUWR5fLiyimLT9TPXpYx3HgwNwkvR6MxjZ7hdeYCFodbc",
52255
53158
  authorizedCidHex: cidToHex(
52256
- "Qmd8jgKRceLvf5aoTtwdXG2JqMoBK5cRJwrvEtQkgvbFbx"
53159
+ "QmUWR5fLiyimLT9TPXpYx3HgwNwkvR6MxjZ7hdeYCFodbc"
52257
53160
  ),
52258
53161
  name: "Ucd Mint Validator",
52259
53162
  description: "Production Ucd Mint Validator",
52260
53163
  version: "1.2.1",
52261
53164
  deployed: true,
52262
- deployedAt: 1786465627201,
52263
- size: 82739,
52264
- hash: "2bdd9aebdaad58a43a4731d5b7284f2531b7a9caaf8caf5719d891c4ed33cb2e",
53165
+ deployedAt: 1787923919527,
53166
+ size: 86197,
53167
+ hash: "c2d80939746cc37f65ef2f63c6a3215b929214a63f10c78144e1f5c98320dabf",
52265
53168
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
52266
53169
  pkp: {
52267
53170
  publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
@@ -52269,17 +53172,17 @@ var require_pkg_src2 = __commonJS2({
52269
53172
  }
52270
53173
  },
52271
53174
  processPaymentValidator: {
52272
- cid: "QmNXVdysXDhCaQ1uNE2Vgjbuzy6yUEnnVgHzmDfNKXMU6z",
53175
+ cid: "QmXmXuMRAjMLdgKGyTf9KQdGwYrDp8DxkiF44TvSXDf7wF",
52273
53176
  authorizedCidHex: cidToHex(
52274
- "QmNXVdysXDhCaQ1uNE2Vgjbuzy6yUEnnVgHzmDfNKXMU6z"
53177
+ "QmXmXuMRAjMLdgKGyTf9KQdGwYrDp8DxkiF44TvSXDf7wF"
52275
53178
  ),
52276
53179
  name: "Process Payment Validator",
52277
53180
  description: "Production Process Payment Validator",
52278
53181
  version: "1.2.1",
52279
53182
  deployed: true,
52280
- deployedAt: 1786465654796,
52281
- size: 78736,
52282
- hash: "17191ecc9c009e0fa5ab52c876330beb2a9a75d30cccb92e7c0c04f169df088b",
53183
+ deployedAt: 1787923987153,
53184
+ size: 82217,
53185
+ hash: "13defa19614215ab3b1fe88955d69e530d13a09475396af932fe0e213637da2f",
52283
53186
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
52284
53187
  pkp: {
52285
53188
  publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
@@ -52287,17 +53190,17 @@ var require_pkg_src2 = __commonJS2({
52287
53190
  }
52288
53191
  },
52289
53192
  extendPositionValidator: {
52290
- cid: "QmYwBsyrhGfHWyRKx549G4tKHxsBLAuRUHcecigeUCkFav",
53193
+ cid: "QmU8h99EEVEsQkxroXiYqLsKZw9gNjE6N5CcTpE9aUc12m",
52291
53194
  authorizedCidHex: cidToHex(
52292
- "QmYwBsyrhGfHWyRKx549G4tKHxsBLAuRUHcecigeUCkFav"
53195
+ "QmU8h99EEVEsQkxroXiYqLsKZw9gNjE6N5CcTpE9aUc12m"
52293
53196
  ),
52294
53197
  name: "Extend Position Validator",
52295
53198
  description: "Production Extend Position Validator",
52296
53199
  version: "1.2.1",
52297
53200
  deployed: true,
52298
- deployedAt: 1786465681874,
52299
- size: 76515,
52300
- hash: "1d4e085335af80f194a663a577876902c83015177e95906a0b461fa93bd5da08",
53201
+ deployedAt: 1787923999294,
53202
+ size: 79975,
53203
+ hash: "31c1aaf883ef22f37681ddb0a4a949be5c05304b6aef178989475a2da935ef9a",
52301
53204
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
52302
53205
  pkp: {
52303
53206
  publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
@@ -52305,17 +53208,17 @@ var require_pkg_src2 = __commonJS2({
52305
53208
  }
52306
53209
  },
52307
53210
  btcWithdrawal: {
52308
- cid: "QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh",
53211
+ cid: "QmZQWET9pzrVD4gwQuSzYZmqa24JrUNtnnGFDd513sxMCY",
52309
53212
  authorizedCidHex: cidToHex(
52310
- "QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh"
53213
+ "QmZQWET9pzrVD4gwQuSzYZmqa24JrUNtnnGFDd513sxMCY"
52311
53214
  ),
52312
53215
  name: "Btc Withdrawal",
52313
53216
  description: "Production Btc Withdrawal",
52314
53217
  version: "1.2.7",
52315
53218
  deployed: true,
52316
- deployedAt: 1786446046614,
52317
- size: 97456,
52318
- hash: "3cae8250861832f91ee3c573abeb50ff27b9acd34148176071cbfbabb359fc91",
53219
+ deployedAt: 1787924017769,
53220
+ size: 100069,
53221
+ hash: "4f8e27414e4da235e63d6ae1325c63f3d2fb956464515a21aa007a99935f0f13",
52319
53222
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
52320
53223
  pkp: {
52321
53224
  publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
@@ -52427,30 +53330,30 @@ var require_pkg_src2 = __commonJS2({
52427
53330
  hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
52428
53331
  },
52429
53332
  agentModuleExecutor: {
52430
- cid: "QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ",
53333
+ cid: "QmcD65vuremot5fsHVgp9JBAmei6gAaEtm5mdtLP7Yt9Kf",
52431
53334
  authorizedCidHex: cidToHex(
52432
- "QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ"
53335
+ "QmcD65vuremot5fsHVgp9JBAmei6gAaEtm5mdtLP7Yt9Kf"
52433
53336
  ),
52434
53337
  name: "Agent Module Executor",
52435
53338
  description: "Production Agent Module Executor",
52436
53339
  version: "1.1.1",
52437
53340
  deployed: true,
52438
- deployedAt: 1786446108348,
52439
- size: 11655,
52440
- hash: "d4e2149f843d6c2699fc61114d54b268ba4ed2c46ebdaee1145e0f101ec2a1ec"
53341
+ deployedAt: 1787924032013,
53342
+ size: 13878,
53343
+ hash: "a7f0204700912e26e5a354bee13a1242a2baa218643b3bb22d28481f67f9baf4"
52441
53344
  },
52442
53345
  staleSpendRecoveryValidator: {
52443
- cid: "QmXQWT8V4wjuvH8BbC7xrkYxsVu5AKfvfWcS7jnYfrexYm",
53346
+ cid: "QmNuwo4PT4AikAmhMdZgPWCb2mJDwWa9TnUqrqvofjbrT8",
52444
53347
  authorizedCidHex: cidToHex(
52445
- "QmXQWT8V4wjuvH8BbC7xrkYxsVu5AKfvfWcS7jnYfrexYm"
53348
+ "QmNuwo4PT4AikAmhMdZgPWCb2mJDwWa9TnUqrqvofjbrT8"
52446
53349
  ),
52447
53350
  name: "Stale Spend Recovery Validator",
52448
53351
  description: "Production Stale Spend Recovery Validator",
52449
53352
  version: "1.1.2",
52450
53353
  deployed: true,
52451
- deployedAt: 1785173285829,
52452
- size: 37108,
52453
- hash: "04de5fc5b6f5131dc1544e3d3d187a1f9ef9616ffd12483d119f9102b3671791",
53354
+ deployedAt: 1787924048772,
53355
+ size: 41424,
53356
+ hash: "3c5f028d2bef4344768462993616d45e30d9d44ef126e04d6eb579821d57d99c",
52454
53357
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
52455
53358
  pkp: {
52456
53359
  publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
@@ -52458,17 +53361,17 @@ var require_pkg_src2 = __commonJS2({
52458
53361
  }
52459
53362
  },
52460
53363
  btcUtxoInvalidator: {
52461
- cid: "Qmf4Ze8yhnQhHbnX5RPgJrC7Jw1aA3gbpfpd52kFg7fd1m",
53364
+ cid: "QmaNGeWut7EiGwW4zUc2sFSt7RY5NWFgxYboyG333TwrJf",
52462
53365
  authorizedCidHex: cidToHex(
52463
- "Qmf4Ze8yhnQhHbnX5RPgJrC7Jw1aA3gbpfpd52kFg7fd1m"
53366
+ "QmaNGeWut7EiGwW4zUc2sFSt7RY5NWFgxYboyG333TwrJf"
52464
53367
  ),
52465
53368
  name: "Btc Utxo Invalidator",
52466
53369
  description: "Production Btc Utxo Invalidator",
52467
53370
  version: "1.0.0",
52468
53371
  deployed: true,
52469
- deployedAt: 1786465704240,
52470
- size: 62553,
52471
- hash: "1dcea2b49e545c423195be22e072dc5e3039ed1c95a8490b23505956029f5b33"
53372
+ deployedAt: 1787924133241,
53373
+ size: 66026,
53374
+ hash: "603bc50920d7f1dee77086f2c518d9e2922ab3858a419d3fbea8221ea3a6d9e9"
52472
53375
  }
52473
53376
  };
52474
53377
  function getDeploymentsForNetwork(network) {
@@ -53229,6 +54132,101 @@ ${errorReport}`);
53229
54132
  var SECONDS_PER_DAY = 86400;
53230
54133
  var DAYS_PER_MONTH = 30;
53231
54134
  var LIT_ACTION_ETH_RPC_TIMEOUT_MS = 8e3;
54135
+ var PINNED_CONTRACT_ADDRESSES = {
54136
+ 1: {
54137
+ PositionManager: "0x12A1836e56139ccaD8722B89519d84233efc224B",
54138
+ LoanOperationsManagerModule: "0x2561974A40F1AEed1251d0A090A83cF8536FB9E9",
54139
+ BTCSpendAuthorizer: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
54140
+ BitcoinProviderRegistry: "0x4ab3Fb96e02893Ed6FAa61bad1918390c8DbbFFC",
54141
+ LITActionValidator: "0xD2c5d59c2CC5c409AC65ce0A817236aeC6869512",
54142
+ PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C"
54143
+ },
54144
+ 11155111: {
54145
+ PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
54146
+ LoanOperationsManagerModule: "0x3e05e760a87715207b7F4e8fD35EF7559BcA72C0",
54147
+ BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
54148
+ BitcoinProviderRegistry: "0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",
54149
+ LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
54150
+ PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9"
54151
+ }
54152
+ };
54153
+ function getPinnedContractAddresses(chainId) {
54154
+ return PINNED_CONTRACT_ADDRESSES[chainId] ?? null;
54155
+ }
54156
+ var PROTOCOL_EIP712_DOMAIN_NAME = "DiamondHands.Protocol";
54157
+ var PROTOCOL_EIP712_DOMAIN_VERSION = "1";
54158
+ var BORROWER_AUTHORIZATION_PRIMARY_TYPES = {
54159
+ MINT: "MintRequest",
54160
+ REPAY: "RepayRequest",
54161
+ RENEW: "RenewRequest",
54162
+ WITHDRAW: "WithdrawRequest"
54163
+ };
54164
+ var BORROWER_AUTHORIZATION_FIELDS = {
54165
+ MintRequest: [
54166
+ { name: "positionId", type: "bytes32" },
54167
+ { name: "mintAmount", type: "uint256" },
54168
+ { name: "quantumTimestamp", type: "uint256" }
54169
+ ],
54170
+ RepayRequest: [
54171
+ { name: "positionId", type: "bytes32" },
54172
+ { name: "paymentAmount", type: "uint256" },
54173
+ { name: "quantumTimestamp", type: "uint256" }
54174
+ ],
54175
+ RenewRequest: [
54176
+ { name: "positionId", type: "bytes32" },
54177
+ { name: "selectedTerm", type: "uint256" },
54178
+ { name: "quantumTimestamp", type: "uint256" }
54179
+ ],
54180
+ WithdrawRequest: [
54181
+ { name: "positionId", type: "bytes32" },
54182
+ { name: "totalDeduction", type: "uint256" },
54183
+ { name: "withdrawalAddress", type: "string" },
54184
+ { name: "quantumTimestamp", type: "uint256" }
54185
+ ]
54186
+ };
54187
+ var BORROWER_AUTHORIZATION_ENCODE_TYPES = {
54188
+ MintRequest: "MintRequest(bytes32 positionId,uint256 mintAmount,uint256 quantumTimestamp)",
54189
+ RepayRequest: "RepayRequest(bytes32 positionId,uint256 paymentAmount,uint256 quantumTimestamp)",
54190
+ RenewRequest: "RenewRequest(bytes32 positionId,uint256 selectedTerm,uint256 quantumTimestamp)",
54191
+ WithdrawRequest: "WithdrawRequest(bytes32 positionId,uint256 totalDeduction,string withdrawalAddress,uint256 quantumTimestamp)"
54192
+ };
54193
+ function borrowerAuthorizationTypes(primaryType) {
54194
+ const fields = BORROWER_AUTHORIZATION_FIELDS[primaryType];
54195
+ if (!fields) {
54196
+ throw new Error(
54197
+ `Unknown borrower authorization primary type "${primaryType}"; expected one of ${Object.keys(BORROWER_AUTHORIZATION_FIELDS).join(", ")}`
54198
+ );
54199
+ }
54200
+ return { [primaryType]: fields.map((field) => ({ ...field })) };
54201
+ }
54202
+ function buildBorrowerAuthorizationDomain(chainId, verifyingContractOverride) {
54203
+ if (!Number.isInteger(chainId) || chainId <= 0) {
54204
+ throw new Error(
54205
+ `Borrower authorization domain requires a positive integer chainId, got ${String(chainId)}`
54206
+ );
54207
+ }
54208
+ const pinned = getPinnedContractAddresses(chainId);
54209
+ const pinnedLom = pinned?.LoanOperationsManagerModule;
54210
+ if (pinnedLom && verifyingContractOverride) {
54211
+ if (pinnedLom.toLowerCase() !== verifyingContractOverride.toLowerCase()) {
54212
+ throw new Error(
54213
+ `Refusing a caller-supplied verifyingContract that contradicts the pin for chainId ${chainId}: caller ${verifyingContractOverride}, pinned ${pinnedLom}`
54214
+ );
54215
+ }
54216
+ }
54217
+ const verifyingContract = pinnedLom ?? verifyingContractOverride;
54218
+ if (!verifyingContract) {
54219
+ throw new Error(
54220
+ `No pinned LoanOperationsManagerModule for chainId ${chainId} and no verifyingContract supplied; refusing to build a borrower authorization domain without one`
54221
+ );
54222
+ }
54223
+ return {
54224
+ name: PROTOCOL_EIP712_DOMAIN_NAME,
54225
+ version: PROTOCOL_EIP712_DOMAIN_VERSION,
54226
+ chainId,
54227
+ verifyingContract
54228
+ };
54229
+ }
53232
54230
  var EVMChain = /* @__PURE__ */ ((EVMChain3) => {
53233
54231
  EVMChain3["SEPOLIA"] = "sepolia";
53234
54232
  EVMChain3["ETHEREUM"] = "ethereum";
@@ -57024,6 +58022,77 @@ async function awaitSafeSubmissionWindowOnChain(signatureQuantum, chainNow, slee
57024
58022
  );
57025
58023
  return { waited: waitedSeconds > 0, waitedSeconds };
57026
58024
  }
58025
+ init_deployment_addresses();
58026
+ var BORROWER_AUTHORIZATION_712_DOMAIN_NAME = "DiamondHands.Protocol";
58027
+ var BORROWER_AUTHORIZATION_712_DOMAIN_VERSION = "1";
58028
+ var BORROWER_AUTHORIZATION_712_FIELDS = {
58029
+ MintRequest: [
58030
+ { name: "positionId", type: "bytes32" },
58031
+ { name: "mintAmount", type: "uint256" },
58032
+ { name: "quantumTimestamp", type: "uint256" }
58033
+ ],
58034
+ RepayRequest: [
58035
+ { name: "positionId", type: "bytes32" },
58036
+ { name: "paymentAmount", type: "uint256" },
58037
+ { name: "quantumTimestamp", type: "uint256" }
58038
+ ],
58039
+ RenewRequest: [
58040
+ { name: "positionId", type: "bytes32" },
58041
+ { name: "selectedTerm", type: "uint256" },
58042
+ { name: "quantumTimestamp", type: "uint256" }
58043
+ ],
58044
+ WithdrawRequest: [
58045
+ { name: "positionId", type: "bytes32" },
58046
+ { name: "totalDeduction", type: "uint256" },
58047
+ { name: "withdrawalAddress", type: "string" },
58048
+ { name: "quantumTimestamp", type: "uint256" }
58049
+ ]
58050
+ };
58051
+ function borrowerAuthorization712Types(primaryType) {
58052
+ const fields = BORROWER_AUTHORIZATION_712_FIELDS[primaryType];
58053
+ if (!fields) {
58054
+ throw new Error(
58055
+ `Unknown borrower authorization primary type "${primaryType}"; expected one of ` + Object.keys(BORROWER_AUTHORIZATION_712_FIELDS).join(", ")
58056
+ );
58057
+ }
58058
+ return { [primaryType]: fields.map((field) => ({ ...field })) };
58059
+ }
58060
+ function buildBorrowerAuthorization712Domain(chainId) {
58061
+ if (!Number.isInteger(chainId) || chainId <= 0) {
58062
+ throw new Error(
58063
+ `Borrower authorization domain requires a positive integer chainId, got ${String(chainId)}`
58064
+ );
58065
+ }
58066
+ const deployment = Object.values(ALL_DEPLOYMENTS).find(
58067
+ (d) => d.chainId === chainId
58068
+ );
58069
+ const verifyingContract = deployment?.contracts?.LoanOperationsManagerModule;
58070
+ if (!verifyingContract) {
58071
+ throw new Error(
58072
+ `No LoanOperationsManagerModule deployment known for chainId ${chainId}; refusing to build a borrower authorization domain without one`
58073
+ );
58074
+ }
58075
+ return {
58076
+ name: BORROWER_AUTHORIZATION_712_DOMAIN_NAME,
58077
+ version: BORROWER_AUTHORIZATION_712_DOMAIN_VERSION,
58078
+ chainId,
58079
+ verifyingContract
58080
+ };
58081
+ }
58082
+ async function signBorrowerAuthorization712(signer, primaryType, chainId, message) {
58083
+ const signTypedData = signer.signTypedData;
58084
+ if (typeof signTypedData !== "function") {
58085
+ throw new Error(
58086
+ `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.`
58087
+ );
58088
+ }
58089
+ return signTypedData.call(
58090
+ signer,
58091
+ buildBorrowerAuthorization712Domain(chainId),
58092
+ borrowerAuthorization712Types(primaryType),
58093
+ message
58094
+ );
58095
+ }
57027
58096
  var PKP_NFT_ABI = [
57028
58097
  "function getPubkey(uint256 tokenId) external view returns (bytes memory)"
57029
58098
  ];
@@ -57036,29 +58105,11 @@ async function generateMintAuthorization(positionId, amount, chainId, signerOrPr
57036
58105
  const signer = signerOrPrecomputed;
57037
58106
  const timestamp = calculateNextQuantumTimestamp();
57038
58107
  const action = "mint-ucd";
57039
- const actionHash = (0, import_ethers16.keccak256)((0, import_ethers16.toUtf8Bytes)(action));
57040
- const types = [
57041
- "bytes32",
57042
- // positionId
57043
- "uint256",
57044
- // timestamp
57045
- "uint256",
57046
- // chainId
57047
- "uint256",
57048
- // amount
57049
- "bytes32"
57050
- // actionHash
57051
- ];
57052
- const values = [
58108
+ const signature = await signBorrowerAuthorization712(signer, "MintRequest", chainId, {
57053
58109
  positionId,
57054
- timestamp,
57055
- chainId,
57056
- amount.toString(),
57057
- actionHash
57058
- ];
57059
- const messageHash = (0, import_ethers16.solidityPackedKeccak256)(types, values);
57060
- const messageHashBytes = (0, import_ethers16.getBytes)(messageHash);
57061
- const signature = await signer.signMessage(messageHashBytes);
58110
+ mintAmount: amount.toString(),
58111
+ quantumTimestamp: timestamp
58112
+ });
57062
58113
  return {
57063
58114
  positionId,
57064
58115
  timestamp,
@@ -57095,44 +58146,17 @@ async function generatePaymentAuthorization(positionId, amount, chainId, signerO
57095
58146
  throw new Error(`timestamp must be a number, got ${typeof timestamp}`);
57096
58147
  }
57097
58148
  const action = "make-payment";
57098
- const actionHash = (0, import_ethers16.keccak256)((0, import_ethers16.toUtf8Bytes)(action));
57099
- if (typeof actionHash !== "string") {
57100
- throw new Error(`actionHash must be a string, got ${typeof actionHash}`);
57101
- }
57102
- const types = [
57103
- "bytes32",
57104
- // positionId
57105
- "uint256",
57106
- // timestamp
57107
- "uint256",
57108
- // chainId
57109
- "uint256",
57110
- // amount
57111
- "bytes32"
57112
- // actionHash
57113
- ];
57114
58149
  const amountStr = amount.toString();
57115
- if (typeof amountStr !== "string") {
57116
- throw new Error(
57117
- `amount.toString() must return a string, got ${typeof amountStr}`
57118
- );
57119
- }
57120
- const values = [positionId, timestamp, chainId, amountStr, actionHash];
57121
- for (let i = 0; i < values.length; i++) {
57122
- if (typeof values[i] === "object" && values[i] !== null) {
57123
- throw new Error(
57124
- `Value at index ${i} is an object: ${JSON.stringify(values[i])}`
57125
- );
57126
- }
57127
- }
57128
- const messageHash = (0, import_ethers16.solidityPackedKeccak256)(types, values);
57129
- const messageHashBytes = (0, import_ethers16.getBytes)(messageHash);
57130
- const signature = await signer.signMessage(messageHashBytes);
58150
+ const signature = await signBorrowerAuthorization712(signer, "RepayRequest", chainId, {
58151
+ positionId,
58152
+ paymentAmount: amountStr,
58153
+ quantumTimestamp: timestamp
58154
+ });
57131
58155
  return {
57132
58156
  positionId,
57133
58157
  timestamp,
57134
58158
  chainId,
57135
- amount: amount.toString(),
58159
+ amount: amountStr,
57136
58160
  action,
57137
58161
  signature
57138
58162
  };
@@ -57219,32 +58243,12 @@ async function generateWithdrawAuthorization(positionId, amount, chainId, signer
57219
58243
  const signer = signerOrPrecomputed;
57220
58244
  const timestamp = calculateNextQuantumTimestamp();
57221
58245
  const action = "withdraw-btc";
57222
- const actionHash = (0, import_ethers16.keccak256)((0, import_ethers16.toUtf8Bytes)(action));
57223
- const types = [
57224
- "bytes32",
57225
- // positionId
57226
- "uint256",
57227
- // timestamp
57228
- "uint256",
57229
- // chainId
57230
- "uint256",
57231
- // amount (in satoshis)
57232
- "string",
57233
- // destinationAddress (Bitcoin address)
57234
- "bytes32"
57235
- // actionHash
57236
- ];
57237
- const values = [
58246
+ const signature = await signBorrowerAuthorization712(signer, "WithdrawRequest", chainId, {
57238
58247
  positionId,
57239
- timestamp,
57240
- chainId,
57241
- amount.toString(),
57242
- destinationAddress,
57243
- actionHash
57244
- ];
57245
- const messageHash = (0, import_ethers16.solidityPackedKeccak256)(types, values);
57246
- const messageHashBytes = (0, import_ethers16.getBytes)(messageHash);
57247
- const signature = await signer.signMessage(messageHashBytes);
58248
+ totalDeduction: amount.toString(),
58249
+ withdrawalAddress: destinationAddress,
58250
+ quantumTimestamp: timestamp
58251
+ });
57248
58252
  return {
57249
58253
  positionId,
57250
58254
  timestamp,
@@ -57293,29 +58297,11 @@ async function generateExtendAuthorization(positionId, newTerm, chainId, signerO
57293
58297
  const signer = signerOrPrecomputed;
57294
58298
  const timestamp = calculateNextQuantumTimestamp();
57295
58299
  const action = "extend-position";
57296
- const actionHash = (0, import_ethers17.keccak256)((0, import_ethers17.toUtf8Bytes)(action));
57297
- const types = [
57298
- "bytes32",
57299
- // positionId
57300
- "uint256",
57301
- // timestamp
57302
- "uint256",
57303
- // chainId
57304
- "uint256",
57305
- // newTerm (extension term in months)
57306
- "bytes32"
57307
- // actionHash
57308
- ];
57309
- const values = [
58300
+ const signature = await signBorrowerAuthorization712(signer, "RenewRequest", chainId, {
57310
58301
  positionId,
57311
- timestamp,
57312
- chainId,
57313
- newTerm,
57314
- actionHash
57315
- ];
57316
- const messageHash = (0, import_ethers17.solidityPackedKeccak256)(types, values);
57317
- const messageHashBytes = (0, import_ethers17.getBytes)(messageHash);
57318
- const signature = await signer.signMessage(messageHashBytes);
58302
+ selectedTerm: newTerm,
58303
+ quantumTimestamp: timestamp
58304
+ });
57319
58305
  return {
57320
58306
  positionId,
57321
58307
  timestamp,
@@ -57550,6 +58536,7 @@ var ServerSession = class {
57550
58536
  store;
57551
58537
  onSignaturePrompt;
57552
58538
  onSignatureResolved;
58539
+ onSessionRestored;
57553
58540
  now;
57554
58541
  fetchImpl;
57555
58542
  cached = null;
@@ -57590,6 +58577,7 @@ var ServerSession = class {
57590
58577
  this.store = opts.persistSession === false ? null : opts.sessionStore ?? createDefaultSessionStore();
57591
58578
  this.onSignaturePrompt = opts.onSignaturePrompt;
57592
58579
  this.onSignatureResolved = opts.onSignatureResolved;
58580
+ this.onSessionRestored = opts.onSessionRestored;
57593
58581
  this.now = opts.now ?? (() => Math.floor(Date.now() / 1e3));
57594
58582
  this.fetchImpl = opts.fetchImpl ?? ((...a) => fetch(...a));
57595
58583
  }
@@ -57670,7 +58658,7 @@ var ServerSession = class {
57670
58658
  */
57671
58659
  async logout() {
57672
58660
  const cached = this.cached;
57673
- const token = cached && cached.expiresAt > this.now() ? cached.token : await this.getValidToken({ silent: true }).catch(() => null);
58661
+ const token = cached && cached.expiresAt > this.now() ? cached.token : await this.tryResolveSilently(this.generation, false).then((session) => session?.token ?? null).catch(() => null);
57674
58662
  await this.clearPersisted();
57675
58663
  if (!token)
57676
58664
  return;
@@ -57742,8 +58730,9 @@ var ServerSession = class {
57742
58730
  *
57743
58731
  * `gen` is the caller's clear-generation snapshot: writes to `this.cached`
57744
58732
  * and the store are skipped if a `clearPersisted()` landed meanwhile.
58733
+ * `announce` gates `onSessionRestored` for the two persisted-store outcomes.
57745
58734
  */
57746
- async tryResolveSilently(gen) {
58735
+ async tryResolveSilently(gen, announce = true) {
57747
58736
  const nowSec = this.now();
57748
58737
  if (this.cached && this.cached.expiresAt - REFRESH_LEEWAY_SECONDS > nowSec) {
57749
58738
  return this.cached;
@@ -57758,6 +58747,8 @@ var ServerSession = class {
57758
58747
  };
57759
58748
  if (gen === this.generation)
57760
58749
  this.cached = adopted;
58750
+ if (announce)
58751
+ this.onSessionRestored?.();
57761
58752
  return adopted;
57762
58753
  }
57763
58754
  try {
@@ -57766,6 +58757,8 @@ var ServerSession = class {
57766
58757
  this.persist(persisted.payload, session);
57767
58758
  this.cached = session;
57768
58759
  }
58760
+ if (announce)
58761
+ this.onSessionRestored?.();
57769
58762
  return session;
57770
58763
  } catch (error) {
57771
58764
  if (!isLoginRejection(error))
@@ -60851,6 +61844,10 @@ function normalizePkpId(pkpId) {
60851
61844
  }
60852
61845
  return pkpId;
60853
61846
  }
61847
+ function isNormalizedChipotlePkpId(pkpId) {
61848
+ const rawId = pkpId.startsWith("0x") ? pkpId.slice(2) : pkpId;
61849
+ return rawId.length === 40;
61850
+ }
60854
61851
  function padPkpIdForSubgraph(pkpId) {
60855
61852
  const raw = pkpId.startsWith("0x") ? pkpId.slice(2) : pkpId;
60856
61853
  if (raw.length === 40) {
@@ -61135,7 +62132,7 @@ var LoanQuery = class {
61135
62132
  batch.map(async (loan) => {
61136
62133
  try {
61137
62134
  const rawId = loan.pkpId?.startsWith("0x") ? loan.pkpId.slice(2) : loan.pkpId;
61138
- const isChipotlePkpId2 = typeof rawId === "string" && rawId.length === 40 && !rawId.toLowerCase().startsWith("04");
62135
+ const isChipotlePkpId2 = typeof rawId === "string" && isNormalizedChipotlePkpId(rawId);
61139
62136
  if (isChipotlePkpId2) {
61140
62137
  if (this.config.positionManagerCoreAddress && this.config.provider) {
61141
62138
  const pmContract = new import_ethers26.Contract(
@@ -61462,6 +62459,7 @@ function createLoanQuery(config) {
61462
62459
  );
61463
62460
  }
61464
62461
  }
62462
+ var STATIC_CALL_DIAGNOSTIC_TIMEOUT_MS = 5e3;
61465
62463
  var WithdrawalAddressModule = class {
61466
62464
  config;
61467
62465
  graphClient;
@@ -61507,13 +62505,17 @@ var WithdrawalAddressModule = class {
61507
62505
  const reg = this.getRegistry();
61508
62506
  if (!reg.success)
61509
62507
  return reg;
62508
+ const normalized = normalizeBitcoinAddress(btcAddress2);
61510
62509
  try {
61511
- const tx2 = await reg.value.addAddress(
61512
- normalizeBitcoinAddress(btcAddress2)
61513
- );
62510
+ const tx2 = await reg.value.addAddress(normalized);
61514
62511
  return success(tx2);
61515
62512
  } catch (error) {
61516
- return this.txFailure("addAddress", error, btcAddress2);
62513
+ return this.txFailure(
62514
+ "addAddress",
62515
+ error,
62516
+ btcAddress2,
62517
+ await this.staticCallDiagnostic(reg.value, "addAddress", normalized)
62518
+ );
61517
62519
  }
61518
62520
  }
61519
62521
  /** Remove a Bitcoin address from the caller's allowlist (effective immediately). */
@@ -61521,13 +62523,17 @@ var WithdrawalAddressModule = class {
61521
62523
  const reg = this.getRegistry();
61522
62524
  if (!reg.success)
61523
62525
  return reg;
62526
+ const normalized = normalizeBitcoinAddress(btcAddress2);
61524
62527
  try {
61525
- const tx2 = await reg.value.removeAddress(
61526
- normalizeBitcoinAddress(btcAddress2)
61527
- );
62528
+ const tx2 = await reg.value.removeAddress(normalized);
61528
62529
  return success(tx2);
61529
62530
  } catch (error) {
61530
- return this.txFailure("removeAddress", error, btcAddress2);
62531
+ return this.txFailure(
62532
+ "removeAddress",
62533
+ error,
62534
+ btcAddress2,
62535
+ await this.staticCallDiagnostic(reg.value, "removeAddress", normalized)
62536
+ );
61531
62537
  }
61532
62538
  }
61533
62539
  /**
@@ -61623,16 +62629,59 @@ var WithdrawalAddressModule = class {
61623
62629
  }
61624
62630
  return success(void 0);
61625
62631
  }
61626
- txFailure(op, error, context) {
62632
+ /**
62633
+ * Ask the node for the reason a failed write did not carry.
62634
+ *
62635
+ * A failing `eth_estimateGas` frequently answers with NOTHING to decode — ethers renders that
62636
+ * as `missing revert data ... data=null, reason=null, revert=null`, which names no cause and
62637
+ * cannot distinguish "the contract rejected this" from "the RPC hiccuped". An `eth_call` of the
62638
+ * same calldata usually does carry the revert reason or custom-error selector, so this runs one
62639
+ * and folds the answer into the reported error.
62640
+ *
62641
+ * Three deliberate properties:
62642
+ *
62643
+ * 1. It runs ONLY after the write has already failed. Gating the write on a static call would
62644
+ * let a flaky endpoint — precisely the condition this exists to diagnose — block an add that
62645
+ * would otherwise have succeeded.
62646
+ * 2. It costs NO extra signature. `staticCall` is `eth_call`: a node read, never a wallet prompt.
62647
+ * 3. It can never throw. A diagnostic that escapes would replace the real cause with itself.
62648
+ * (The `try/catch` here is the authorized exception to CLAUDE.md's forbidden-patterns rule;
62649
+ * it swallows nothing — every branch returns text that is reported alongside the original.)
62650
+ *
62651
+ * A static call that SUCCEEDS is itself a finding: the contract accepts this call, so the
62652
+ * failure lay outside contract logic (RPC, gas, or nonce).
62653
+ */
62654
+ async staticCallDiagnostic(registry, op, normalizedAddress) {
62655
+ try {
62656
+ await Promise.race([
62657
+ registry[op].staticCall(normalizedAddress),
62658
+ // The failure being diagnosed is often an unresponsive endpoint, so the diagnostic must
62659
+ // not inherit that hang — the user is waiting on this error message.
62660
+ new Promise(
62661
+ (_, reject) => setTimeout(
62662
+ () => reject(new Error("static call timed out after 5s")),
62663
+ STATIC_CALL_DIAGNOSTIC_TIMEOUT_MS
62664
+ )
62665
+ )
62666
+ ]);
62667
+ return "static call SUCCEEDED \u2014 the contract accepts this call, so the failure was not contract logic (RPC, gas, or nonce)";
62668
+ } catch (diagnostic) {
62669
+ const code = typeof diagnostic === "object" && diagnostic !== null ? diagnostic.code : void 0;
62670
+ const msg = diagnostic instanceof Error ? diagnostic.message : String(diagnostic);
62671
+ return typeof code === "string" ? `static call reverted [${code}]: ${msg}` : `static call failed: ${msg}`;
62672
+ }
62673
+ }
62674
+ txFailure(op, error, context, diagnostic) {
61627
62675
  const msg = error instanceof Error ? error.message : String(error);
62676
+ const detail = diagnostic ? `${msg} \u2014 ${diagnostic}` : msg;
61628
62677
  return failure(
61629
62678
  new SDKError({
61630
62679
  code: `SDK_WITHDRAWAL_REGISTRY_${op.toUpperCase()}_FAILED`,
61631
- message: `WithdrawalAddressRegistry.${op} failed: ${msg}`,
62680
+ message: `WithdrawalAddressRegistry.${op} failed: ${detail}`,
61632
62681
  category: "CONTRACT",
61633
62682
  severity: "MEDIUM",
61634
62683
  originalError: error instanceof Error ? error : new Error(String(error)),
61635
- context: { op, context }
62684
+ context: { op, context, diagnostic }
61636
62685
  })
61637
62686
  );
61638
62687
  }
@@ -62710,6 +63759,210 @@ function normalizePkpId2(pkpId) {
62710
63759
  }
62711
63760
  return pkpId;
62712
63761
  }
63762
+ function applyLoanEventsFilter(events, opts) {
63763
+ const { wantsEvent, fromTimestamp, toTimestamp, fromBlock, toBlock, limit } = opts;
63764
+ const inBounds = (e) => {
63765
+ const ts = e?.timestamp;
63766
+ const bn = e?.blockNumber;
63767
+ try {
63768
+ if (fromTimestamp !== void 0 && ts !== void 0 && BigInt(ts) < BigInt(fromTimestamp))
63769
+ return false;
63770
+ if (toTimestamp !== void 0 && ts !== void 0 && BigInt(ts) > BigInt(toTimestamp))
63771
+ return false;
63772
+ if (fromBlock !== void 0 && bn !== void 0 && BigInt(bn) < BigInt(fromBlock))
63773
+ return false;
63774
+ if (toBlock !== void 0 && bn !== void 0 && BigInt(bn) > BigInt(toBlock))
63775
+ return false;
63776
+ } catch {
63777
+ return true;
63778
+ }
63779
+ return true;
63780
+ };
63781
+ const narrow = (list, kind) => wantsEvent(kind) ? (list ?? []).filter(inBounds).slice(0, limit) : [];
63782
+ const single = (value, kind) => value && wantsEvent(kind) && inBounds(value) ? value : void 0;
63783
+ const filtered = {
63784
+ ...events,
63785
+ positionCreated: single(events.positionCreated, "positionCreated"),
63786
+ payments: narrow(events.payments, "payment"),
63787
+ statusUpdates: narrow(events.statusUpdates, "status"),
63788
+ liquidation: single(events.liquidation, "liquidation"),
63789
+ mints: narrow(events.mints, "mint"),
63790
+ withdrawals: narrow(events.withdrawals, "withdrawal"),
63791
+ renewals: narrow(events.renewals, "renewal"),
63792
+ operationFailures: narrow(events.operationFailures, "operationFailure"),
63793
+ mintRequests: narrow(events.mintRequests, "mintRequest"),
63794
+ burnRequests: narrow(events.burnRequests, "burnRequest"),
63795
+ collateralEvents: narrow(events.collateralEvents, "collateralEvent"),
63796
+ mintingFees: narrow(events.mintingFees, "mintingFee"),
63797
+ renewalFees: narrow(events.renewalFees, "renewalFee"),
63798
+ totalEvents: 0
63799
+ };
63800
+ 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;
63801
+ return filtered;
63802
+ }
63803
+ function hasLoanEventsFilter(filter2) {
63804
+ if (!filter2)
63805
+ return false;
63806
+ 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;
63807
+ }
63808
+ var WALLET_LOAN_EVENTS_QUERY = `
63809
+ query GetWalletLoanEvents($borrower: Bytes!, $first: Int!, $limit: Int!, $orderDirection: OrderDirection!) {
63810
+ positions(where: { borrower: $borrower }, first: $first, orderBy: id) {
63811
+ id
63812
+ payments(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63813
+ id
63814
+ payer { id }
63815
+ amount
63816
+ type
63817
+ transactionHash
63818
+ timestamp
63819
+ blockNumber
63820
+ logIndex
63821
+ newDebt
63822
+ newCollateralRatio
63823
+ }
63824
+ statusUpdates(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63825
+ id
63826
+ oldStatus
63827
+ newStatus
63828
+ reason
63829
+ timestamp
63830
+ blockNumber
63831
+ transactionHash
63832
+ }
63833
+ liquidation {
63834
+ id
63835
+ liquidator
63836
+ liquidatedAmount
63837
+ collateralSeized
63838
+ transactionHash
63839
+ timestamp
63840
+ blockNumber
63841
+ commitHash
63842
+ commitTimestamp
63843
+ revealDelay
63844
+ }
63845
+ withdrawals(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63846
+ id
63847
+ withdrawalAmount
63848
+ withdrawalAddress
63849
+ networkFee
63850
+ timestamp
63851
+ blockNumber
63852
+ transactionHash
63853
+ logIndex
63854
+ }
63855
+ renewals(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63856
+ id
63857
+ extensionTerm
63858
+ extensionFee
63859
+ newExpiryDate
63860
+ timestamp
63861
+ blockNumber
63862
+ transactionHash
63863
+ logIndex
63864
+ }
63865
+ operationFailures(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63866
+ id
63867
+ operationType
63868
+ reason
63869
+ errorCode
63870
+ amount
63871
+ timestamp
63872
+ blockNumber
63873
+ transactionHash
63874
+ logIndex
63875
+ }
63876
+ mintRequests(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63877
+ id
63878
+ pkpId
63879
+ borrower { id }
63880
+ mintAmount
63881
+ originationFee
63882
+ newDebt
63883
+ newCollateralRatio
63884
+ btcPrice
63885
+ quantumTimestamp
63886
+ opId
63887
+ timestamp
63888
+ blockNumber
63889
+ transactionHash
63890
+ logIndex
63891
+ }
63892
+ burnRequests(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63893
+ id
63894
+ pkpId
63895
+ borrower { id }
63896
+ burnAmount
63897
+ remainingDebt
63898
+ newCollateralRatio
63899
+ opId
63900
+ timestamp
63901
+ blockNumber
63902
+ transactionHash
63903
+ logIndex
63904
+ }
63905
+ mintingFees(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63906
+ id
63907
+ borrower { id }
63908
+ feeAmount
63909
+ mintAmount
63910
+ newDebt
63911
+ btcPrice
63912
+ quantumTimestamp
63913
+ timestamp
63914
+ blockNumber
63915
+ transactionHash
63916
+ logIndex
63917
+ }
63918
+ renewalFees(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63919
+ id
63920
+ borrower { id }
63921
+ feeAmount
63922
+ extensionTerm
63923
+ newExpiryDate
63924
+ timestamp
63925
+ blockNumber
63926
+ transactionHash
63927
+ logIndex
63928
+ }
63929
+ positionCreatedEvents(first: 1, orderBy: timestamp, orderDirection: asc) {
63930
+ id
63931
+ pkpId
63932
+ borrower { id }
63933
+ requestedCollateralRatio
63934
+ selectedTerm
63935
+ expiryAt
63936
+ timestamp
63937
+ blockNumber
63938
+ transactionHash
63939
+ }
63940
+ }
63941
+ ucdmintEvents(where: { position_: { borrower: $borrower } }, first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63942
+ id
63943
+ position { id }
63944
+ amount
63945
+ proof
63946
+ minter { id }
63947
+ isCommunityMint
63948
+ timestamp
63949
+ blockNumber
63950
+ transactionHash
63951
+ }
63952
+ collateralEvents(where: { position_: { borrower: $borrower } }, first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63953
+ id
63954
+ position { id }
63955
+ eventType
63956
+ networkFee
63957
+ remainingCollateral
63958
+ collateralRatio
63959
+ timestamp
63960
+ blockNumber
63961
+ transactionHash
63962
+ logIndex
63963
+ }
63964
+ }
63965
+ `;
62713
63966
  var DiamondHandsGraph = class {
62714
63967
  client;
62715
63968
  defaultPageSize;
@@ -62815,7 +64068,7 @@ var DiamondHandsGraph = class {
62815
64068
  /**
62816
64069
  * Get user positions from subgraph
62817
64070
  */
62818
- async getUserPositions(userAddress, first, skip, orderBy, orderDirection) {
64071
+ async getUserPositionsOnly(userAddress, first, skip, orderBy, orderDirection) {
62819
64072
  const query = `
62820
64073
  query GetUserPositions($borrower: Bytes!, $first: Int, $skip: Int, $orderBy: Position_orderBy, $orderDirection: OrderDirection) {
62821
64074
  user(id: $borrower) {
@@ -62856,17 +64109,28 @@ var DiamondHandsGraph = class {
62856
64109
  query,
62857
64110
  variables
62858
64111
  );
62859
- const total = await this.getTotalCountPaginated("{ borrower: $borrower }", {
62860
- borrower: userAddress.toLowerCase()
62861
- });
62862
64112
  let positions = [];
62863
64113
  if (result && result.user && Array.isArray(result.user.positions)) {
62864
64114
  positions = result.user.positions.filter((p) => p != null).map((p) => this.transformGraphPositionToLoanData(p));
62865
64115
  }
62866
- return {
62867
- positions,
62868
- total
62869
- };
64116
+ return positions;
64117
+ }
64118
+ /**
64119
+ * Get user positions, plus an accurate total count.
64120
+ *
64121
+ * The count is a SECOND round trip (`getTotalCountPaginated`, which pages to handle
64122
+ * >1000 items). Callers that only need the rows should use `getUserPositionsOnly` and
64123
+ * skip it — the event paths did not, and paid for a count they immediately discarded on
64124
+ * every activity refresh.
64125
+ */
64126
+ async getUserPositions(userAddress, first, skip, orderBy, orderDirection) {
64127
+ const [positions, total] = await Promise.all([
64128
+ this.getUserPositionsOnly(userAddress, first, skip, orderBy, orderDirection),
64129
+ this.getTotalCountPaginated("{ borrower: $borrower }", {
64130
+ borrower: userAddress.toLowerCase()
64131
+ })
64132
+ ]);
64133
+ return { positions, total };
62870
64134
  }
62871
64135
  /**
62872
64136
  * Get user positions with enriched Bitcoin balance data
@@ -63692,32 +64956,24 @@ var DiamondHandsGraph = class {
63692
64956
  limit = 1e3,
63693
64957
  orderDirection = "desc"
63694
64958
  } = filter2 || {};
64959
+ const wantsEvent = (kind) => !eventTypes || eventTypes.includes(kind);
64960
+ const hasBounds = fromTimestamp !== void 0 || toTimestamp !== void 0 || fromBlock !== void 0 || toBlock !== void 0;
64961
+ const pageSize = hasBounds ? THE_GRAPH_MAX_BATCH_SIZE : limit;
64962
+ const buildPositionWhereClause = () => `where: { position: "${positionId.toLowerCase()}" }`;
63695
64963
  const shouldQuery = {
63696
- positionCreated: !eventTypes || eventTypes.includes("positionCreated"),
63697
- payment: !eventTypes || eventTypes.includes("payment"),
63698
- status: !eventTypes || eventTypes.includes("status"),
63699
- liquidation: !eventTypes || eventTypes.includes("liquidation"),
63700
- mint: !eventTypes || eventTypes.includes("mint"),
63701
- withdrawal: !eventTypes || eventTypes.includes("withdrawal"),
63702
- renewal: !eventTypes || eventTypes.includes("renewal"),
63703
- operationFailure: !eventTypes || eventTypes.includes("operationFailure"),
63704
- mintRequest: !eventTypes || eventTypes.includes("mintRequest"),
63705
- burnRequest: !eventTypes || eventTypes.includes("burnRequest"),
63706
- collateralEvent: !eventTypes || eventTypes.includes("collateralEvent"),
63707
- mintingFee: !eventTypes || eventTypes.includes("mintingFee"),
63708
- renewalFee: !eventTypes || eventTypes.includes("renewalFee")
63709
- };
63710
- const buildPositionWhereClause = () => {
63711
- const conditions = [`position: "${positionId.toLowerCase()}"`];
63712
- if (fromTimestamp)
63713
- conditions.push(`timestamp_gte: "${fromTimestamp}"`);
63714
- if (toTimestamp)
63715
- conditions.push(`timestamp_lte: "${toTimestamp}"`);
63716
- if (fromBlock)
63717
- conditions.push(`blockNumber_gte: "${fromBlock}"`);
63718
- if (toBlock)
63719
- conditions.push(`blockNumber_lte: "${toBlock}"`);
63720
- return `where: { ${conditions.join(", ")} }`;
64964
+ positionCreated: true,
64965
+ payment: true,
64966
+ status: true,
64967
+ liquidation: true,
64968
+ mint: true,
64969
+ withdrawal: true,
64970
+ renewal: true,
64971
+ operationFailure: true,
64972
+ mintRequest: true,
64973
+ burnRequest: true,
64974
+ collateralEvent: true,
64975
+ mintingFee: true,
64976
+ renewalFee: true
63721
64977
  };
63722
64978
  const query = `
63723
64979
  query GetLoanEvents($positionId: Bytes!, $limit: Int!, $orderDirection: OrderDirection!) {
@@ -63953,10 +65209,50 @@ var DiamondHandsGraph = class {
63953
65209
  `;
63954
65210
  const variables = {
63955
65211
  positionId: positionId.toLowerCase(),
63956
- limit,
65212
+ limit: pageSize,
63957
65213
  orderDirection
63958
65214
  };
63959
65215
  const result = await this.client.execute(query, variables);
65216
+ if (hasBounds) {
65217
+ const collections = [
65218
+ ["payments", result.position?.payments],
65219
+ ["statusUpdates", result.position?.statusUpdates],
65220
+ ["withdrawals", result.position?.withdrawals],
65221
+ ["renewals", result.position?.renewals],
65222
+ ["operationFailures", result.position?.operationFailures],
65223
+ ["mintRequests", result.position?.mintRequests],
65224
+ ["burnRequests", result.position?.burnRequests],
65225
+ ["mintingFees", result.position?.mintingFees],
65226
+ ["renewalFees", result.position?.renewalFees],
65227
+ ["mints", result.ucdmintEvents],
65228
+ ["collateralEvents", result.collateralEvents]
65229
+ ];
65230
+ const saturated = collections.filter(([, list]) => (list?.length ?? 0) >= pageSize).map(([name]) => name);
65231
+ if (saturated.length > 0) {
65232
+ log.warn(
65233
+ "[DiamondHandsGraph] bounded getLoanEvents page saturated \u2014 the filtered history may be incomplete",
65234
+ { positionId, pageSize, saturated }
65235
+ );
65236
+ }
65237
+ }
65238
+ const assembled = this.assembleLoanEvents(positionId, result);
65239
+ return applyLoanEventsFilter(assembled, {
65240
+ wantsEvent,
65241
+ fromTimestamp,
65242
+ toTimestamp,
65243
+ fromBlock,
65244
+ toBlock,
65245
+ limit
65246
+ });
65247
+ }
65248
+ /**
65249
+ * Map one position's raw event payload into `LoanEvents`.
65250
+ *
65251
+ * Extracted verbatim from getLoanEvents so the wallet-collapsed path produces
65252
+ * byte-identical objects by construction rather than by a second implementation
65253
+ * that has to be kept in step by hand.
65254
+ */
65255
+ assembleLoanEvents(positionId, result) {
63960
65256
  const rawCreated = result.positionCreatedEvents?.[0];
63961
65257
  const positionCreated = rawCreated ? {
63962
65258
  id: rawCreated.id,
@@ -64161,7 +65457,22 @@ var DiamondHandsGraph = class {
64161
65457
  * @returns One LoanEvents object per position; empty array if the wallet has none.
64162
65458
  */
64163
65459
  async getWalletLoanEvents(userAddress, filter2) {
64164
- const { positions } = await this.getUserPositions(userAddress);
65460
+ if (!hasLoanEventsFilter(filter2)) {
65461
+ return this.getWalletLoanEventsCollapsed(userAddress);
65462
+ }
65463
+ return this.getWalletLoanEventsFanout(userAddress, filter2);
65464
+ }
65465
+ /**
65466
+ * The per-position path: enumerate the wallet's positions, then one `GetLoanEvents` each.
65467
+ *
65468
+ * Used for filtered calls, and as the completeness fallback when the collapsed document
65469
+ * hits a page limit. Costs `1 + N` requests, which is exactly why it is not the default.
65470
+ */
65471
+ async getWalletLoanEventsFanout(userAddress, filter2) {
65472
+ const positions = await this.getUserPositionsOnly(
65473
+ userAddress,
65474
+ THE_GRAPH_MAX_BATCH_SIZE
65475
+ );
64165
65476
  const positionIds = positions.map((p) => p?.id != null ? String(p.id) : "").filter((id) => id.length > 0);
64166
65477
  if (positionIds.length === 0)
64167
65478
  return [];
@@ -64176,6 +65487,81 @@ var DiamondHandsGraph = class {
64176
65487
  }
64177
65488
  return results;
64178
65489
  }
65490
+ /**
65491
+ * The whole wallet's event history in ONE request.
65492
+ *
65493
+ * Replaces `1 + N` round trips (one position enumeration plus one per position) with a
65494
+ * single document. Measured on Sepolia: a wallet holding 44 positions cost 46 requests
65495
+ * per activity refresh against a per-wallet budget of 30/min — this makes it 1.
65496
+ *
65497
+ * Three subgraph facts make it possible, all verified against the deployed schema rather
65498
+ * than assumed:
65499
+ * - ten event collections are `@derivedFrom` on Position, so they nest under a
65500
+ * borrower-filtered `positions(...)`;
65501
+ * - `positionCreatedEvents` is ALSO derived on Position — `getLoanEvents` queries it
65502
+ * top-level, which it never needed to;
65503
+ * - `ucdmintEvents` / `collateralEvents` are not derived and carry no `borrower`
65504
+ * field, but graph-node's nested `position_: { borrower }` filter reaches them.
65505
+ * Without that last one this would be two requests, not one.
65506
+ */
65507
+ async getWalletLoanEventsCollapsed(userAddress) {
65508
+ const borrower = userAddress.toLowerCase();
65509
+ const pageSize = THE_GRAPH_MAX_BATCH_SIZE;
65510
+ const result = await this.client.execute(
65511
+ WALLET_LOAN_EVENTS_QUERY,
65512
+ {
65513
+ borrower,
65514
+ first: pageSize,
65515
+ limit: pageSize,
65516
+ orderDirection: "desc"
65517
+ }
65518
+ );
65519
+ const positions = result.positions || [];
65520
+ const ucdmintEvents = result.ucdmintEvents || [];
65521
+ const collateralEvents = result.collateralEvents || [];
65522
+ const truncated = positions.length >= pageSize || ucdmintEvents.length >= pageSize || collateralEvents.length >= pageSize;
65523
+ if (truncated) {
65524
+ log.warn(
65525
+ "[DiamondHandsGraph] wallet event page limit reached \u2014 falling back to the per-position path to avoid returning a partial history",
65526
+ {
65527
+ borrower,
65528
+ pageSize,
65529
+ positions: positions.length,
65530
+ ucdmintEvents: ucdmintEvents.length,
65531
+ collateralEvents: collateralEvents.length
65532
+ }
65533
+ );
65534
+ return this.getWalletLoanEventsFanout(userAddress);
65535
+ }
65536
+ if (positions.length === 0)
65537
+ return [];
65538
+ const mintsByPosition = /* @__PURE__ */ new Map();
65539
+ for (const m of result.ucdmintEvents || []) {
65540
+ const key = m.position?.id;
65541
+ if (!key)
65542
+ continue;
65543
+ const bucket = mintsByPosition.get(key) || [];
65544
+ bucket.push(m);
65545
+ mintsByPosition.set(key, bucket);
65546
+ }
65547
+ const collateralByPosition = /* @__PURE__ */ new Map();
65548
+ for (const c of result.collateralEvents || []) {
65549
+ const key = c.position?.id;
65550
+ if (!key)
65551
+ continue;
65552
+ const bucket = collateralByPosition.get(key) || [];
65553
+ bucket.push(c);
65554
+ collateralByPosition.set(key, bucket);
65555
+ }
65556
+ return positions.map(
65557
+ (p) => this.assembleLoanEvents(p.id, {
65558
+ position: p,
65559
+ positionCreatedEvents: p.positionCreatedEvents || [],
65560
+ ucdmintEvents: mintsByPosition.get(p.id) || [],
65561
+ collateralEvents: collateralByPosition.get(p.id) || []
65562
+ })
65563
+ );
65564
+ }
64179
65565
  // ============================================================================
64180
65566
  // Protocol-wide Events
64181
65567
  // ============================================================================
@@ -69035,16 +70421,6 @@ function createMockTokenManager(config) {
69035
70421
  }
69036
70422
  }
69037
70423
  var import_dh_lit_actions2 = __toESM2(require_pkg_src2());
69038
- var TelegramBot = null;
69039
- try {
69040
- if (typeof window === "undefined" && typeof global !== "undefined") {
69041
- TelegramBot = null /* stubbed post-build: dh-mcp never uses telegram (F-PUB-2) */;
69042
- }
69043
- } catch (error) {
69044
- log.warn("Telegram bot API not available", {
69045
- error: error instanceof Error ? error.message : String(error)
69046
- });
69047
- }
69048
70424
  function formatMintMessage(mintAmount, loanId, txHash) {
69049
70425
  return `\u2705 DH SDK: ${mintAmount} UCD was minted for loan id: ${loanId} Tx: https://sepolia.etherscan.io/tx/${txHash}`;
69050
70426
  }
@@ -69670,7 +71046,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
69670
71046
  persistSession: config.sessionPersistence?.enabled,
69671
71047
  sessionStore: config.sessionPersistence?.store,
69672
71048
  onSignaturePrompt: config.onSessionSignaturePrompt,
69673
- onSignatureResolved: config.onSessionSignatureResolved
71049
+ onSignatureResolved: config.onSessionSignatureResolved,
71050
+ onSessionRestored: config.onSessionRestored
69674
71051
  });
69675
71052
  }
69676
71053
  const contractManagerResult = createContractManager({
@@ -83339,7 +84716,7 @@ mime-types/index.js:
83339
84716
  *)
83340
84717
 
83341
84718
  axios/dist/node/axios.cjs:
83342
- (*! Axios v1.19.0 Copyright (c) 2026 Matt Zabriskie and contributors *)
84719
+ (*! Axios v1.20.0 Copyright (c) 2026 Matt Zabriskie and contributors *)
83343
84720
 
83344
84721
  safe-buffer/index.js:
83345
84722
  (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)