@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.
@@ -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
  });
@@ -45667,22 +46152,82 @@ var { toString } = Object.prototype;
45667
46152
  var { getPrototypeOf } = Object;
45668
46153
  var { iterator, toStringTag } = Symbol;
45669
46154
  var hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
46155
+ var isUnsafeObjectKey = (prop) => typeof prop === "string" && (prop === "__proto__" || prop === "constructor" || prop === "prototype");
46156
+ var isPrototypeBoundary = (obj, prototype2, source) => obj === Object.prototype || !source && prototype2 === null;
46157
+ var isSafeAndFullyMutable = (obj) => {
46158
+ if (!Object.isExtensible(obj)) {
46159
+ return false;
46160
+ }
46161
+ const props = Object.getOwnPropertyNames(obj);
46162
+ if (Object.getOwnPropertySymbols) {
46163
+ props.push(...Object.getOwnPropertySymbols(obj));
46164
+ }
46165
+ return props.every((prop) => {
46166
+ if (isUnsafeObjectKey(prop)) {
46167
+ return false;
46168
+ }
46169
+ const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
46170
+ return !!descriptor && descriptor.configurable && descriptor.writable === true;
46171
+ });
46172
+ };
45670
46173
  var hasOwnInPrototypeChain = (thing, prop) => {
45671
46174
  let obj = thing;
45672
46175
  const seen = [];
45673
- while (obj != null && obj !== Object.prototype) {
46176
+ while (obj != null) {
45674
46177
  if (seen.indexOf(obj) !== -1) {
45675
46178
  return false;
45676
46179
  }
45677
46180
  seen.push(obj);
46181
+ const prototype2 = getPrototypeOf(obj);
46182
+ if (isPrototypeBoundary(obj, prototype2, obj === thing)) {
46183
+ return false;
46184
+ }
45678
46185
  if (hasOwnProperty(obj, prop)) {
45679
46186
  return true;
45680
46187
  }
45681
- obj = getPrototypeOf(obj);
46188
+ obj = prototype2;
45682
46189
  }
45683
46190
  return false;
45684
46191
  };
45685
46192
  var getSafeProp = (obj, prop) => obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : void 0;
46193
+ var toSafeFlatObject = (thing) => {
46194
+ if (thing == null || typeof thing !== "object" && typeof thing !== "function") {
46195
+ return thing;
46196
+ }
46197
+ const sourcePrototype = getPrototypeOf(thing);
46198
+ if (sourcePrototype === null && isSafeAndFullyMutable(thing)) {
46199
+ return thing;
46200
+ }
46201
+ const result = /* @__PURE__ */ Object.create(null);
46202
+ const merged = /* @__PURE__ */ Object.create(null);
46203
+ const seen = [];
46204
+ let current = thing;
46205
+ while (current != null) {
46206
+ if (seen.indexOf(current) !== -1) {
46207
+ break;
46208
+ }
46209
+ seen.push(current);
46210
+ const prototype2 = current === thing ? sourcePrototype : getPrototypeOf(current);
46211
+ if (isPrototypeBoundary(current, prototype2, current === thing)) {
46212
+ break;
46213
+ }
46214
+ const props = Object.getOwnPropertyNames(current);
46215
+ if (Object.getOwnPropertySymbols) {
46216
+ props.push(...Object.getOwnPropertySymbols(current));
46217
+ }
46218
+ for (const prop of props) {
46219
+ if (isUnsafeObjectKey(prop)) {
46220
+ continue;
46221
+ }
46222
+ if (!hasOwnProperty(merged, prop)) {
46223
+ result[prop] = thing[prop];
46224
+ merged[prop] = true;
46225
+ }
46226
+ }
46227
+ current = prototype2;
46228
+ }
46229
+ return result;
46230
+ };
45686
46231
  var kindOf = /* @__PURE__ */ ((cache) => (thing) => {
45687
46232
  const str = toString.call(thing);
45688
46233
  return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
@@ -45717,9 +46262,9 @@ var isPlainObject = (val) => {
45717
46262
  return false;
45718
46263
  }
45719
46264
  const prototype2 = getPrototypeOf(val);
45720
- return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat any genuine (non-Object.prototype-polluted) Symbol.toStringTag or
45721
- // Symbol.iterator as evidence the value is a tagged/iterable type rather
45722
- // than a plain object, while ignoring keys injected onto Object.prototype.
46265
+ return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat safe own/inherited Symbol.toStringTag or Symbol.iterator members as
46266
+ // evidence the value is tagged/iterable, while ignoring members reachable
46267
+ // only through shared or terminal prototype boundaries.
45723
46268
  !hasOwnInPrototypeChain(val, toStringTag) && !hasOwnInPrototypeChain(val, iterator);
45724
46269
  };
45725
46270
  var isEmptyObject = (val) => {
@@ -46130,6 +46675,7 @@ var utils_default = {
46130
46675
  // an alias to avoid ESLint no-prototype-builtins detection
46131
46676
  hasOwnInPrototypeChain,
46132
46677
  getSafeProp,
46678
+ toSafeFlatObject,
46133
46679
  reduceDescriptors,
46134
46680
  freezeMethods,
46135
46681
  toObjectSet,
@@ -46768,24 +47314,16 @@ function toFormData(obj, formData, options) {
46768
47314
  throw new TypeError("target must be an object");
46769
47315
  }
46770
47316
  formData = formData || new (FormData_default || FormData)();
46771
- options = utils_default.toFlatObject(
46772
- options,
46773
- {
46774
- metaTokens: true,
46775
- dots: false,
46776
- indexes: false
46777
- },
46778
- false,
46779
- function defined(option, source) {
46780
- return !utils_default.isUndefined(source[option]);
46781
- }
46782
- );
46783
- const metaTokens = options.metaTokens;
46784
- const visitor = options.visitor || defaultVisitor;
46785
- const dots = options.dots;
46786
- const indexes = options.indexes;
46787
- const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
46788
- const maxDepth = options.maxDepth === void 0 ? DEFAULT_FORM_DATA_MAX_DEPTH : options.maxDepth;
47317
+ const option = (name, fallback) => {
47318
+ const value = utils_default.getSafeProp(options, name);
47319
+ return utils_default.isUndefined(value) ? fallback : value;
47320
+ };
47321
+ const metaTokens = option("metaTokens", true);
47322
+ const visitor = option("visitor") || defaultVisitor;
47323
+ const dots = option("dots", false);
47324
+ const indexes = option("indexes", false);
47325
+ const _Blob = option("Blob") || typeof Blob !== "undefined" && Blob;
47326
+ const maxDepth = option("maxDepth", DEFAULT_FORM_DATA_MAX_DEPTH);
46789
47327
  const useBlob = _Blob && utils_default.isSpecCompliantForm(formData);
46790
47328
  const stack = [];
46791
47329
  if (!utils_default.isFunction(visitor)) {
@@ -46809,7 +47347,10 @@ function toFormData(obj, formData, options) {
46809
47347
  if (Buffer_default && Buffer_default.isBufferAvailable()) {
46810
47348
  return Buffer_default.from(value);
46811
47349
  }
46812
- throw new AxiosError_default("Blob is not supported. Use a Buffer instead.", AxiosError_default.ERR_NOT_SUPPORT);
47350
+ throw new AxiosError_default(
47351
+ "Blob is not supported. Use a Buffer instead.",
47352
+ AxiosError_default.ERR_NOT_SUPPORT
47353
+ );
46813
47354
  }
46814
47355
  return value;
46815
47356
  }
@@ -46955,9 +47496,47 @@ function buildURL(url2, params, options) {
46955
47496
  }
46956
47497
 
46957
47498
  // node_modules/axios/lib/core/InterceptorManager.js
47499
+ var $internals2 = Symbol("internals");
47500
+ function countHandlers(handlers) {
47501
+ return handlers ? handlers.length : 0;
47502
+ }
47503
+ function trimHandlers(handlers) {
47504
+ if (!handlers) {
47505
+ return;
47506
+ }
47507
+ while (handlers.length && handlers[handlers.length - 1] === null) {
47508
+ handlers.pop();
47509
+ }
47510
+ }
47511
+ function syncHandlerEntries(manager, internals) {
47512
+ const handlers = manager.handlers;
47513
+ const length = countHandlers(handlers);
47514
+ if (handlers !== internals.handlersRef) {
47515
+ internals.handlersRef = handlers;
47516
+ internals.handlerEntries.clear();
47517
+ } else if (length !== internals.handlersLength) {
47518
+ if (!length) {
47519
+ internals.handlerEntries.clear();
47520
+ } else {
47521
+ internals.handlerEntries.forEach(function removeStaleEntry(entry, id) {
47522
+ if (handlers[entry.index] !== entry.handler) {
47523
+ internals.handlerEntries.delete(id);
47524
+ }
47525
+ });
47526
+ }
47527
+ }
47528
+ internals.handlersLength = length;
47529
+ }
46958
47530
  var InterceptorManager = class {
46959
47531
  constructor() {
46960
47532
  this.handlers = [];
47533
+ this[$internals2] = {
47534
+ handlersRef: this.handlers,
47535
+ handlersLength: this.handlers.length,
47536
+ handlerEntries: /* @__PURE__ */ new Map(),
47537
+ iterationDepth: 0,
47538
+ nextId: 0
47539
+ };
46961
47540
  }
46962
47541
  /**
46963
47542
  * Add a new interceptor to the stack
@@ -46969,13 +47548,25 @@ var InterceptorManager = class {
46969
47548
  * @return {Number} An ID used to remove interceptor later
46970
47549
  */
46971
47550
  use(fulfilled, rejected, options) {
46972
- this.handlers.push({
47551
+ const handler = {
46973
47552
  fulfilled,
46974
47553
  rejected,
46975
47554
  synchronous: options ? options.synchronous : false,
46976
47555
  runWhen: options ? options.runWhen : null
47556
+ };
47557
+ const internals = this[$internals2];
47558
+ if (this.handlers == null) {
47559
+ this.handlers = [];
47560
+ }
47561
+ syncHandlerEntries(this, internals);
47562
+ const id = internals.nextId++;
47563
+ this.handlers.push(handler);
47564
+ internals.handlerEntries.set(id, {
47565
+ handler,
47566
+ index: this.handlers.length - 1
46977
47567
  });
46978
- return this.handlers.length - 1;
47568
+ internals.handlersLength = this.handlers.length;
47569
+ return id;
46979
47570
  }
46980
47571
  /**
46981
47572
  * Remove an interceptor from the stack
@@ -46985,8 +47576,19 @@ var InterceptorManager = class {
46985
47576
  * @returns {void}
46986
47577
  */
46987
47578
  eject(id) {
46988
- if (this.handlers[id]) {
46989
- this.handlers[id] = null;
47579
+ const internals = this[$internals2];
47580
+ syncHandlerEntries(this, internals);
47581
+ const entry = internals.handlerEntries.get(id);
47582
+ if (entry) {
47583
+ internals.handlerEntries.delete(id);
47584
+ if (this.handlers[entry.index] !== entry.handler) {
47585
+ return;
47586
+ }
47587
+ this.handlers[entry.index] = null;
47588
+ if (!internals.iterationDepth) {
47589
+ trimHandlers(this.handlers);
47590
+ internals.handlersLength = this.handlers.length;
47591
+ }
46990
47592
  }
46991
47593
  }
46992
47594
  /**
@@ -46997,6 +47599,7 @@ var InterceptorManager = class {
46997
47599
  clear() {
46998
47600
  if (this.handlers) {
46999
47601
  this.handlers = [];
47602
+ syncHandlerEntries(this, this[$internals2]);
47000
47603
  }
47001
47604
  }
47002
47605
  /**
@@ -47010,11 +47613,22 @@ var InterceptorManager = class {
47010
47613
  * @returns {void}
47011
47614
  */
47012
47615
  forEach(fn) {
47013
- utils_default.forEach(this.handlers, function forEachHandler(h) {
47014
- if (h !== null) {
47015
- fn(h);
47616
+ const internals = this[$internals2];
47617
+ syncHandlerEntries(this, internals);
47618
+ internals.iterationDepth++;
47619
+ try {
47620
+ utils_default.forEach(this.handlers, function forEachHandler(h) {
47621
+ if (h !== null) {
47622
+ fn(h);
47623
+ }
47624
+ });
47625
+ } finally {
47626
+ if (!--internals.iterationDepth) {
47627
+ syncHandlerEntries(this, internals);
47628
+ trimHandlers(this.handlers);
47629
+ internals.handlersLength = countHandlers(this.handlers);
47016
47630
  }
47017
- });
47631
+ }
47018
47632
  }
47019
47633
  };
47020
47634
  var InterceptorManager_default = InterceptorManager;
@@ -47172,6 +47786,22 @@ function formDataToJSON(formData) {
47172
47786
  }
47173
47787
  var formDataToJSON_default = formDataToJSON;
47174
47788
 
47789
+ // node_modules/axios/lib/core/methodList.js
47790
+ var methodList = Object.freeze([
47791
+ "get",
47792
+ "delete",
47793
+ "head",
47794
+ "options",
47795
+ "post",
47796
+ "put",
47797
+ "patch",
47798
+ "purge",
47799
+ "link",
47800
+ "unlink",
47801
+ "query"
47802
+ ]);
47803
+ var methodList_default = methodList;
47804
+
47175
47805
  // node_modules/axios/lib/defaults/index.js
47176
47806
  var own = (obj, key) => obj != null && utils_default.hasOwnProp(obj, key) ? obj[key] : void 0;
47177
47807
  function stringifySafely2(rawValue, parser, encoder) {
@@ -47284,7 +47914,7 @@ var defaults = {
47284
47914
  }
47285
47915
  }
47286
47916
  };
47287
- utils_default.forEach(["delete", "get", "head", "post", "put", "patch", "query"], (method) => {
47917
+ utils_default.forEach(methodList_default, (method) => {
47288
47918
  defaults.headers[method] = {};
47289
47919
  });
47290
47920
  var defaults_default = defaults;
@@ -47362,19 +47992,21 @@ function combineURLs(baseURL, relativeURL) {
47362
47992
  return baseURL.slice(0, end) + "/" + relativeURL.replace(/^\/+/, "");
47363
47993
  }
47364
47994
 
47365
- // node_modules/axios/lib/core/buildFullPath.js
47366
- var malformedHttpProtocol = /^https?:(?!\/\/)/i;
47367
- var httpProtocolControlCharacters = /[\t\n\r]/g;
47368
- function stripLeadingC0ControlOrSpace(url2) {
47369
- let i = 0;
47370
- while (i < url2.length && url2.charCodeAt(i) <= 32) {
47371
- i++;
47372
- }
47373
- return url2.slice(i);
47374
- }
47995
+ // node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js
47996
+ var urlParserControlCharacters = /[\t\n\r]/g;
47375
47997
  function normalizeURLForProtocolCheck(url2) {
47376
- return stripLeadingC0ControlOrSpace(url2).replace(httpProtocolControlCharacters, "");
47998
+ if (typeof url2 !== "string") {
47999
+ return url2;
48000
+ }
48001
+ let start = 0;
48002
+ while (start < url2.length && url2.charCodeAt(start) <= 32) {
48003
+ start++;
48004
+ }
48005
+ return url2.slice(start).replace(urlParserControlCharacters, "");
47377
48006
  }
48007
+
48008
+ // node_modules/axios/lib/core/buildFullPath.js
48009
+ var malformedHttpProtocol = /^https?:(?!\/\/)/i;
47378
48010
  function redactFragment(fragment) {
47379
48011
  if (!fragment) {
47380
48012
  return fragment;
@@ -47496,7 +48128,7 @@ var import_follow_redirects = __toESM(require_follow_redirects(), 1);
47496
48128
  var import_zlib = __toESM(require("zlib"), 1);
47497
48129
 
47498
48130
  // node_modules/axios/lib/env/data.js
47499
- var VERSION = "1.19.0";
48131
+ var VERSION = "1.20.0";
47500
48132
 
47501
48133
  // node_modules/axios/lib/helpers/parseProtocol.js
47502
48134
  function parseProtocol(url2) {
@@ -47505,7 +48137,7 @@ function parseProtocol(url2) {
47505
48137
  }
47506
48138
 
47507
48139
  // node_modules/axios/lib/helpers/fromDataURI.js
47508
- var DATA_URL_PATTERN = /^([^,;]+\/[^,;]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
48140
+ var DATA_URL_PATTERN = /^([^,;/]+\/[^,;/]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
47509
48141
  function fromDataURI(uri, asBlob, options) {
47510
48142
  const _Blob = options && options.Blob || platform_default.classes.Blob;
47511
48143
  const protocol = parseProtocol(uri);
@@ -47818,6 +48450,7 @@ var Http2Sessions = class {
47818
48450
  }
47819
48451
  getSession(authority, options) {
47820
48452
  options = Object.assign(
48453
+ /* @__PURE__ */ Object.create(null),
47821
48454
  {
47822
48455
  sessionTimeout: 1e3
47823
48456
  },
@@ -47883,6 +48516,7 @@ var Http2Sessions = class {
47883
48516
  };
47884
48517
  }
47885
48518
  session.once("close", removeSession);
48519
+ session.once("error", removeSession);
47886
48520
  let entry = [session, options];
47887
48521
  authoritySessions ? authoritySessions.push(entry) : authoritySessions = this.sessions[authority] = [entry];
47888
48522
  return session;
@@ -47907,6 +48541,13 @@ var callbackify_default = callbackify;
47907
48541
 
47908
48542
  // node_modules/axios/lib/helpers/shouldBypassProxy.js
47909
48543
  var LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["localhost", "0.0.0.0"]);
48544
+ var trimTrailingDots = (value) => {
48545
+ let end = value.length;
48546
+ while (end && value.charCodeAt(end - 1) === 46) {
48547
+ end--;
48548
+ }
48549
+ return end === value.length ? value : value.slice(0, end);
48550
+ };
47910
48551
  var isIPv4Loopback = (host) => {
47911
48552
  const parts = host.split(".");
47912
48553
  if (parts.length !== 4) return false;
@@ -47939,7 +48580,7 @@ var normalizeIPAddress = (host) => {
47939
48580
  if (h.charAt(0) === "[" && h.charAt(h.length - 1) === "]") {
47940
48581
  h = h.slice(1, -1);
47941
48582
  }
47942
- h = h.replace(/\.+$/, "");
48583
+ h = trimTrailingDots(h);
47943
48584
  if (!/^[0-9.xXa-fA-F]+$/.test(h)) return host;
47944
48585
  const parts = h.split(".");
47945
48586
  if (parts.some((p) => p === "")) return host;
@@ -48051,6 +48692,40 @@ var unmapIPv4MappedIPv6 = (host) => {
48051
48692
  }
48052
48693
  return host;
48053
48694
  };
48695
+ var IPV4_OCTET_RE = /^(?:0|[1-9]\d{0,2})$/;
48696
+ var ipv4ToBytes = (host) => {
48697
+ const parts = host.split(".");
48698
+ return parts.length === 4 && parts.every((part) => IPV4_OCTET_RE.test(part) && Number(part) <= 255) ? parts.map(Number) : null;
48699
+ };
48700
+ var IPV6_GROUP_RE = /^[0-9a-f]{1,4}$/i;
48701
+ var ipv6ToBytes = (host) => {
48702
+ const halves = host.split("::");
48703
+ if (halves.length > 2) {
48704
+ return null;
48705
+ }
48706
+ const groups = halves[0] ? halves[0].split(":") : [];
48707
+ if (halves.length === 2) {
48708
+ const rear = halves[1] ? halves[1].split(":") : [];
48709
+ const missing = 8 - groups.length - rear.length;
48710
+ if (missing < 1) {
48711
+ return null;
48712
+ }
48713
+ groups.push(...new Array(missing).fill("0"), ...rear);
48714
+ }
48715
+ if (groups.length !== 8 || groups.some((group) => !IPV6_GROUP_RE.test(group))) {
48716
+ return null;
48717
+ }
48718
+ return groups.flatMap((group) => {
48719
+ const value = Number.parseInt(group, 16);
48720
+ return [value >> 8 & 255, value & 255];
48721
+ });
48722
+ };
48723
+ var ipToBytes = (host) => {
48724
+ if (typeof host !== "string" || !host) {
48725
+ return null;
48726
+ }
48727
+ return host.indexOf(":") !== -1 ? ipv6ToBytes(host) : ipv4ToBytes(host);
48728
+ };
48054
48729
  var normalizeNoProxyHost = (hostname) => {
48055
48730
  if (!hostname) {
48056
48731
  return hostname;
@@ -48058,13 +48733,90 @@ var normalizeNoProxyHost = (hostname) => {
48058
48733
  if (hostname.charAt(0) === "[" && hostname.charAt(hostname.length - 1) === "]") {
48059
48734
  hostname = hostname.slice(1, -1);
48060
48735
  }
48061
- const trimmed = hostname.replace(/\.+$/, "");
48736
+ const trimmed = trimTrailingDots(hostname);
48062
48737
  const ipv4 = normalizeIPAddress(trimmed);
48063
48738
  if (ipv4 !== trimmed) {
48064
48739
  return ipv4;
48065
48740
  }
48066
48741
  return unmapIPv4MappedIPv6(trimmed);
48067
48742
  };
48743
+ var normalizeCidrBase = (input) => {
48744
+ let base = input;
48745
+ const startsBracket = base.charAt(0) === "[";
48746
+ const endsBracket = base.charAt(base.length - 1) === "]";
48747
+ const hasBracket = base.includes("[") || base.includes("]");
48748
+ if (startsBracket || endsBracket) {
48749
+ if (!startsBracket || !endsBracket) {
48750
+ return null;
48751
+ }
48752
+ base = base.slice(1, -1);
48753
+ if (base.indexOf(":") === -1 || base.includes("[") || base.includes("]")) {
48754
+ return null;
48755
+ }
48756
+ } else if (hasBracket) {
48757
+ return null;
48758
+ }
48759
+ if (!base || base.charAt(base.length - 1) === ".") {
48760
+ return null;
48761
+ }
48762
+ const wasIPv6 = base.indexOf(":") !== -1;
48763
+ if (wasIPv6) {
48764
+ try {
48765
+ base = new URL(`http://[${base}]/`).hostname.slice(1, -1);
48766
+ } catch (_err) {
48767
+ return null;
48768
+ }
48769
+ } else {
48770
+ base = normalizeIPAddress(base);
48771
+ if (!ipv4ToBytes(base)) {
48772
+ return null;
48773
+ }
48774
+ }
48775
+ return { normalized: unmapIPv4MappedIPv6(base), wasIPv6 };
48776
+ };
48777
+ var CIDR_ENTRY_RE = /^(.+)\/(0|[1-9]\d{0,2})$/;
48778
+ var parseCidrEntry = (entry) => {
48779
+ if (entry.indexOf("/") === -1) {
48780
+ return void 0;
48781
+ }
48782
+ const match = CIDR_ENTRY_RE.exec(entry);
48783
+ if (!match) {
48784
+ return null;
48785
+ }
48786
+ let prefix = Number(match[2]);
48787
+ const parsedBase = normalizeCidrBase(match[1]);
48788
+ if (!parsedBase) {
48789
+ return null;
48790
+ }
48791
+ const { normalized, wasIPv6 } = parsedBase;
48792
+ if (wasIPv6 && normalized.indexOf(":") === -1) {
48793
+ if (prefix < 96) {
48794
+ return null;
48795
+ }
48796
+ prefix -= 96;
48797
+ }
48798
+ const bytes = ipToBytes(normalized);
48799
+ if (!bytes || prefix > bytes.length * 8) {
48800
+ return null;
48801
+ }
48802
+ return { bytes, prefix };
48803
+ };
48804
+ var isInSubnet = (addressBytes, networkBytes, prefix) => {
48805
+ const fullBytes = prefix >> 3;
48806
+ for (let i = 0; i < fullBytes; i++) {
48807
+ if (addressBytes[i] !== networkBytes[i]) {
48808
+ return false;
48809
+ }
48810
+ }
48811
+ const remainingBits = prefix & 7;
48812
+ if (remainingBits) {
48813
+ const mask = 255 << 8 - remainingBits & 255;
48814
+ if ((addressBytes[fullBytes] & mask) !== (networkBytes[fullBytes] & mask)) {
48815
+ return false;
48816
+ }
48817
+ }
48818
+ return true;
48819
+ };
48068
48820
  function shouldBypassProxy(location) {
48069
48821
  let parsed;
48070
48822
  try {
@@ -48081,6 +48833,7 @@ function shouldBypassProxy(location) {
48081
48833
  }
48082
48834
  const port = Number.parseInt(parsed.port, 10) || DEFAULT_PORTS2[parsed.protocol.split(":", 1)[0]] || 0;
48083
48835
  const hostname = normalizeNoProxyHost(parsed.hostname.toLowerCase());
48836
+ const hostnameBytes = ipToBytes(hostname);
48084
48837
  return noProxy.split(/[\s,]+/).some((entry) => {
48085
48838
  if (!entry) {
48086
48839
  return false;
@@ -48088,6 +48841,10 @@ function shouldBypassProxy(location) {
48088
48841
  if (entry === "*") {
48089
48842
  return true;
48090
48843
  }
48844
+ const cidr = parseCidrEntry(entry);
48845
+ if (cidr !== void 0) {
48846
+ return cidr !== null && !!hostnameBytes && hostnameBytes.length === cidr.bytes.length && isInSubnet(hostnameBytes, cidr.bytes, cidr.prefix);
48847
+ }
48091
48848
  let [entryHost, entryPort] = parseNoProxyEntry(entry);
48092
48849
  entryHost = normalizeNoProxyHost(entryHost);
48093
48850
  if (!entryHost) {
@@ -48173,7 +48930,8 @@ function throttle(fn, freq) {
48173
48930
  }
48174
48931
  };
48175
48932
  const flush = () => lastArgs && invoke(lastArgs);
48176
- return [throttled, flush];
48933
+ const flushWith = (...args) => invoke(args);
48934
+ return [throttled, flush, flushWith];
48177
48935
  }
48178
48936
  var throttle_default = throttle;
48179
48937
 
@@ -48182,7 +48940,7 @@ var progressEventReducer = (listener, isDownloadStream, freq = 3) => {
48182
48940
  let bytesNotified = 0;
48183
48941
  const _speedometer = speedometer_default(50, 250);
48184
48942
  return throttle_default((e) => {
48185
- if (!e || typeof e.loaded !== "number") {
48943
+ if (!e || !utils_default.isNumber(e.loaded)) {
48186
48944
  return;
48187
48945
  }
48188
48946
  const rawLoaded = e.loaded;
@@ -48343,6 +49101,12 @@ var { http: httpFollow, https: httpsFollow } = import_follow_redirects.default;
48343
49101
  var isHttps = /https:?/;
48344
49102
  var kAxiosSocketListener = Symbol("axios.http.socketListener");
48345
49103
  var kAxiosCurrentReq = Symbol("axios.http.currentReq");
49104
+ function handleSocketError(err) {
49105
+ const current = this[kAxiosCurrentReq];
49106
+ if (current && !current.destroyed) {
49107
+ current.destroy(err);
49108
+ }
49109
+ }
48346
49110
  var kAxiosInstalledTunnel = Symbol("axios.http.installedTunnel");
48347
49111
  var tunnelingAgentCache = /* @__PURE__ */ new Map();
48348
49112
  var tunnelingAgentCacheUser = /* @__PURE__ */ new WeakMap();
@@ -48445,10 +49209,10 @@ function isSameOriginRedirect(redirectOptions, requestDetails) {
48445
49209
  return false;
48446
49210
  }
48447
49211
  }
48448
- function setProxy(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent) {
49212
+ function setProxy(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent, allowEnvProxy = true) {
48449
49213
  let proxy = configProxy;
48450
49214
  const proxyEnvAgent = getProxyEnvAgent(options, configHttpAgent, configHttpsAgent);
48451
- if (!proxy && proxy !== false && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
49215
+ if (!proxy && proxy !== false && allowEnvProxy && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
48452
49216
  const proxyUrl = getProxyForUrl(location);
48453
49217
  if (proxyUrl) {
48454
49218
  if (!shouldBypassProxy(location)) {
@@ -48545,9 +49309,13 @@ function setProxy(options, configProxy, location, isRedirect, configHttpsAgent,
48545
49309
  redirectOptions.href,
48546
49310
  true,
48547
49311
  configHttpsAgent,
48548
- configHttpAgent
49312
+ configHttpAgent,
49313
+ allowEnvProxy
48549
49314
  );
48550
49315
  };
49316
+ return Boolean(
49317
+ proxy || configProxy !== false && allowEnvProxy && isNodeEnvProxyEnabled(proxyEnvAgent)
49318
+ );
48551
49319
  }
48552
49320
  var isHttpAdapterSupported = typeof process !== "undefined" && utils_default.kindOf(process) === "process";
48553
49321
  var wrapAsync = (asyncExecutor) => {
@@ -48572,7 +49340,7 @@ var wrapAsync = (asyncExecutor) => {
48572
49340
  };
48573
49341
  var resolveFamily = ({ address, family }) => {
48574
49342
  if (!utils_default.isString(address)) {
48575
- throw TypeError("address must be a string");
49343
+ throw new AxiosError_default("address must be a string", AxiosError_default.ERR_BAD_OPTION_VALUE);
48576
49344
  }
48577
49345
  return {
48578
49346
  address,
@@ -48580,6 +49348,30 @@ var resolveFamily = ({ address, family }) => {
48580
49348
  };
48581
49349
  };
48582
49350
  var buildAddressEntry = (address, family) => resolveFamily(utils_default.isObject(address) ? address : { address, family });
49351
+ var normalizedLookupCache = /* @__PURE__ */ new WeakMap();
49352
+ var normalizeLookup = (lookup) => {
49353
+ let normalized = normalizedLookupCache.get(lookup);
49354
+ if (normalized) {
49355
+ return normalized;
49356
+ }
49357
+ const callbackLookup = callbackify_default(lookup, (value) => utils_default.isArray(value) ? value : [value]);
49358
+ normalized = (hostname, opt, cb) => {
49359
+ callbackLookup(hostname, opt, (err, arg0, arg1) => {
49360
+ if (err) {
49361
+ return cb(err);
49362
+ }
49363
+ let addresses;
49364
+ try {
49365
+ addresses = utils_default.isArray(arg0) ? arg0.map((addr) => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
49366
+ } catch (error) {
49367
+ return cb(error);
49368
+ }
49369
+ opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
49370
+ });
49371
+ };
49372
+ normalizedLookupCache.set(lookup, normalized);
49373
+ return normalized;
49374
+ };
48583
49375
  var http2Transport = {
48584
49376
  request(options, cb) {
48585
49377
  const authority = options.protocol + "//" + options.hostname + ":" + (options.port || (options.protocol === "https:" ? 443 : 80));
@@ -48616,6 +49408,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48616
49408
  let family = own2("family");
48617
49409
  let httpVersion = own2("httpVersion");
48618
49410
  if (httpVersion === void 0) httpVersion = 1;
49411
+ const rawHttpVersion = httpVersion;
48619
49412
  let http2Options = own2("http2Options");
48620
49413
  const httpAgent = own2("httpAgent");
48621
49414
  const httpsAgent = own2("httpsAgent");
@@ -48632,25 +49425,32 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48632
49425
  let rejected = false;
48633
49426
  let req;
48634
49427
  let connectPhaseTimer;
48635
- httpVersion = +httpVersion;
49428
+ try {
49429
+ httpVersion = +httpVersion;
49430
+ } catch (err) {
49431
+ throw new AxiosError_default(
49432
+ "Invalid protocol version: value is not a number",
49433
+ AxiosError_default.ERR_BAD_OPTION_VALUE,
49434
+ config
49435
+ );
49436
+ }
48636
49437
  if (Number.isNaN(httpVersion)) {
48637
- throw TypeError(`Invalid protocol version: '${config.httpVersion}' is not a number`);
49438
+ throw new AxiosError_default(
49439
+ `Invalid protocol version: '${rawHttpVersion}' is not a number`,
49440
+ AxiosError_default.ERR_BAD_OPTION_VALUE,
49441
+ config
49442
+ );
48638
49443
  }
48639
49444
  if (httpVersion !== 1 && httpVersion !== 2) {
48640
- throw TypeError(`Unsupported protocol version '${httpVersion}'`);
49445
+ throw new AxiosError_default(
49446
+ `Unsupported protocol version '${httpVersion}'`,
49447
+ AxiosError_default.ERR_BAD_OPTION_VALUE,
49448
+ config
49449
+ );
48641
49450
  }
48642
49451
  const isHttp2 = httpVersion === 2;
48643
49452
  if (lookup) {
48644
- const _lookup = callbackify_default(lookup, (value) => utils_default.isArray(value) ? value : [value]);
48645
- lookup = (hostname, opt, cb) => {
48646
- _lookup(hostname, opt, (err, arg0, arg1) => {
48647
- if (err) {
48648
- return cb(err);
48649
- }
48650
- const addresses = utils_default.isArray(arg0) ? arg0.map((addr) => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
48651
- opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
48652
- });
48653
- };
49453
+ lookup = normalizeLookup(lookup);
48654
49454
  }
48655
49455
  const abortEmitter = new import_events.EventEmitter();
48656
49456
  function abort(reason) {
@@ -48893,6 +49693,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48893
49693
  utils_default.hasOwnProp(transitional2, "advertiseZstdAcceptEncoding") && transitional2.advertiseZstdAcceptEncoding === true ? ACCEPT_ENCODING_WITH_ZSTD : ACCEPT_ENCODING,
48894
49694
  false
48895
49695
  );
49696
+ if (isHttp2 && lookup) {
49697
+ http2Options = Object.assign(/* @__PURE__ */ Object.create(null), http2Options, { lookup });
49698
+ }
48896
49699
  const options = Object.assign(/* @__PURE__ */ Object.create(null), {
48897
49700
  path: path5,
48898
49701
  method,
@@ -48903,9 +49706,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48903
49706
  family,
48904
49707
  beforeRedirect: dispatchBeforeRedirect,
48905
49708
  beforeRedirects: /* @__PURE__ */ Object.create(null),
48906
- http2Options
49709
+ http2Options,
49710
+ createConnection: void 0
48907
49711
  });
48908
49712
  !utils_default.isUndefined(lookup) && (options.lookup = lookup);
49713
+ let proxyApplied = false;
48909
49714
  if (socketPath) {
48910
49715
  if (typeof socketPath !== "string") {
48911
49716
  return reject(
@@ -48933,13 +49738,17 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48933
49738
  } else {
48934
49739
  options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
48935
49740
  options.port = parsed.port;
48936
- setProxy(
49741
+ proxyApplied = setProxy(
48937
49742
  options,
48938
49743
  configProxy,
48939
49744
  protocol + "//" + parsed.hostname + (parsed.port ? ":" + parsed.port : "") + options.path,
48940
49745
  false,
48941
49746
  httpsAgent,
48942
- httpAgent
49747
+ httpAgent,
49748
+ // The HTTP/2 transport connects independently of HTTP/1 agents, so it
49749
+ // cannot apply either axios-resolved or agent-local environment proxies.
49750
+ // Explicit proxy config is still processed and rejected below.
49751
+ !isHttp2
48943
49752
  );
48944
49753
  }
48945
49754
  let transport;
@@ -48950,6 +49759,15 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
48950
49759
  options.agent = isHttpsRequest ? httpsAgent : httpAgent;
48951
49760
  }
48952
49761
  if (isHttp2) {
49762
+ if (proxyApplied) {
49763
+ return reject(
49764
+ new AxiosError_default(
49765
+ "HTTP/2 requests with a proxy are not supported",
49766
+ AxiosError_default.ERR_NOT_SUPPORT,
49767
+ config
49768
+ )
49769
+ );
49770
+ }
48953
49771
  transport = http2Transport;
48954
49772
  } else {
48955
49773
  const configTransport = own2("transport");
@@ -49037,7 +49855,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
49037
49855
  transformStream,
49038
49856
  progressEventDecorator(
49039
49857
  responseLength,
49040
- progressEventReducer(asyncDecorator(onDownloadProgress, scheduleProgress), true, 3)
49858
+ progressEventReducer(
49859
+ asyncDecorator(onDownloadProgress, scheduleProgress),
49860
+ true,
49861
+ 3
49862
+ )
49041
49863
  )
49042
49864
  )
49043
49865
  );
@@ -49186,12 +50008,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
49186
50008
  socket.setKeepAlive(true, 1e3 * 60);
49187
50009
  }
49188
50010
  if (!socket[kAxiosSocketListener]) {
49189
- socket.on("error", function handleSocketError(err) {
49190
- const current = socket[kAxiosCurrentReq];
49191
- if (current && !current.destroyed) {
49192
- current.destroy(err);
49193
- }
49194
- });
50011
+ socket.on("error", handleSocketError);
49195
50012
  socket[kAxiosSocketListener] = true;
49196
50013
  }
49197
50014
  socket[kAxiosCurrentReq] = req;
@@ -49436,7 +50253,7 @@ function mergeConfig(config1, config2) {
49436
50253
  transformResponse: defaultToConfig2,
49437
50254
  paramsSerializer: defaultToConfig2,
49438
50255
  timeout: defaultToConfig2,
49439
- timeoutMessage: defaultToConfig2,
50256
+ timeoutErrorMessage: defaultToConfig2,
49440
50257
  withCredentials: defaultToConfig2,
49441
50258
  withXSRFToken: defaultToConfig2,
49442
50259
  adapter: defaultToConfig2,
@@ -49513,10 +50330,11 @@ function resolveConfig(config) {
49513
50330
  }
49514
50331
  }
49515
50332
  if (utils_default.isFormData(data)) {
50333
+ const getHeaders = utils_default.getSafeProp(data, "getHeaders");
49516
50334
  if (platform_default.hasStandardBrowserEnv || platform_default.hasStandardBrowserWebWorkerEnv || utils_default.isReactNative(data)) {
49517
50335
  headers.setContentType(void 0);
49518
- } else if (utils_default.isFunction(data.getHeaders)) {
49519
- setFormDataHeaders(headers, data.getHeaders(), own2("formDataHeaderPolicy"));
50336
+ } else if (utils_default.isFunction(getHeaders)) {
50337
+ setFormDataHeaders(headers, getHeaders.call(data), own2("formDataHeaderPolicy"));
49520
50338
  }
49521
50339
  }
49522
50340
  if (platform_default.hasStandardBrowserEnv) {
@@ -49545,7 +50363,7 @@ var xhr_default = isXHRAdapterSupported && function(config) {
49545
50363
  let { responseType, onUploadProgress, onDownloadProgress } = _config;
49546
50364
  let onCanceled;
49547
50365
  let uploadThrottled, downloadThrottled;
49548
- let flushUpload, flushDownload;
50366
+ let flushUpload, flushDownload, flushDownloadWithEvent;
49549
50367
  function done() {
49550
50368
  flushUpload && flushUpload();
49551
50369
  flushDownload && flushDownload();
@@ -49555,7 +50373,27 @@ var xhr_default = isXHRAdapterSupported && function(config) {
49555
50373
  let request = new XMLHttpRequest();
49556
50374
  request.open(_config.method.toUpperCase(), _config.url, true);
49557
50375
  request.timeout = _config.timeout;
49558
- function onloadend() {
50376
+ function onloadend(event) {
50377
+ if (!request) {
50378
+ return;
50379
+ }
50380
+ if (request.status === 0 && (parseProtocol(normalizeURLForProtocolCheck(_config.url)) || parseProtocol(platform_default.origin)) !== "file" && !(request.responseURL && request.responseURL.startsWith("file:"))) {
50381
+ reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED, config, request));
50382
+ done();
50383
+ request = null;
50384
+ return;
50385
+ }
50386
+ try {
50387
+ if (event) {
50388
+ flushDownloadWithEvent && flushDownloadWithEvent(event);
50389
+ } else {
50390
+ flushDownload && flushDownload();
50391
+ }
50392
+ } catch (err) {
50393
+ setTimeout(() => {
50394
+ throw err;
50395
+ });
50396
+ }
49559
50397
  if (!request) {
49560
50398
  return;
49561
50399
  }
@@ -49643,7 +50481,10 @@ var xhr_default = isXHRAdapterSupported && function(config) {
49643
50481
  request.responseType = _config.responseType;
49644
50482
  }
49645
50483
  if (onDownloadProgress) {
49646
- [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
50484
+ [downloadThrottled, flushDownload, flushDownloadWithEvent] = progressEventReducer(
50485
+ onDownloadProgress,
50486
+ true
50487
+ );
49647
50488
  request.addEventListener("progress", downloadThrottled);
49648
50489
  }
49649
50490
  if (onUploadProgress && request.upload) {
@@ -49813,6 +50654,17 @@ var trackStream = (stream4, chunkSize, onProgress, onFinish) => {
49813
50654
 
49814
50655
  // node_modules/axios/lib/adapters/fetch.js
49815
50656
  var DEFAULT_CHUNK_SIZE = 64 * 1024;
50657
+ var DEFAULT_REQUEST_OPTIONS = {
50658
+ cache: "default",
50659
+ redirect: "follow",
50660
+ referrer: "about:client",
50661
+ referrerPolicy: "",
50662
+ mode: "cors",
50663
+ integrity: "",
50664
+ keepalive: false,
50665
+ priority: "auto",
50666
+ window: null
50667
+ };
49816
50668
  var { isFunction: isFunction2 } = utils_default;
49817
50669
  var encodeUTF82 = (str) => encodeURIComponent(str).replace(
49818
50670
  /%([0-9A-F]{2})/gi,
@@ -49943,7 +50795,8 @@ var factory = (env) => {
49943
50795
  withCredentials = "same-origin",
49944
50796
  fetchOptions,
49945
50797
  maxContentLength,
49946
- maxBodyLength
50798
+ maxBodyLength,
50799
+ maxRedirects
49947
50800
  } = resolveConfig_default(config);
49948
50801
  const hasMaxContentLength = utils_default.isNumber(maxContentLength) && maxContentLength > -1;
49949
50802
  const hasMaxBodyLength = utils_default.isNumber(maxBodyLength) && maxBodyLength > -1;
@@ -50073,17 +50926,44 @@ var factory = (env) => {
50073
50926
  }
50074
50927
  }
50075
50928
  headers.set("User-Agent", "axios/" + VERSION, false);
50076
- const resolvedOptions = {
50077
- ...fetchOptions,
50929
+ const safeFetchOptions = fetchOptions == null ? fetchOptions : Object.assign(/* @__PURE__ */ Object.create(null), fetchOptions);
50930
+ if (safeFetchOptions) {
50931
+ delete safeFetchOptions.body;
50932
+ delete safeFetchOptions.headers;
50933
+ delete safeFetchOptions.method;
50934
+ delete safeFetchOptions.signal;
50935
+ delete safeFetchOptions.duplex;
50936
+ delete safeFetchOptions.credentials;
50937
+ }
50938
+ const resolvedOptions = Object.assign(/* @__PURE__ */ Object.create(null), safeFetchOptions, {
50078
50939
  signal: composedSignal,
50079
50940
  method: method.toUpperCase(),
50080
50941
  headers: toByteStringHeaderObject(headers.normalize()),
50081
50942
  body: data,
50082
50943
  duplex: "half",
50083
50944
  credentials: isCredentialsSupported ? withCredentials : void 0
50084
- };
50945
+ });
50946
+ if (isRequestSupported) {
50947
+ utils_default.forEach(DEFAULT_REQUEST_OPTIONS, (value, key) => {
50948
+ if (resolvedOptions[key] === void 0) {
50949
+ resolvedOptions[key] = value;
50950
+ }
50951
+ });
50952
+ if (resolvedOptions.signal === void 0) {
50953
+ resolvedOptions.signal = null;
50954
+ }
50955
+ if (resolvedOptions.body === void 0) {
50956
+ resolvedOptions.body = null;
50957
+ }
50958
+ }
50959
+ if (maxRedirects === 0) {
50960
+ resolvedOptions.redirect = "manual";
50961
+ if (safeFetchOptions) {
50962
+ safeFetchOptions.redirect = "manual";
50963
+ }
50964
+ }
50085
50965
  request = isRequestSupported && new Request(url2, resolvedOptions);
50086
- let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url2, resolvedOptions));
50966
+ let response = await (isRequestSupported ? _fetch(request, safeFetchOptions) : _fetch(url2, resolvedOptions));
50087
50967
  const responseHeaders = AxiosHeaders_default.from(response.headers);
50088
50968
  if (hasMaxContentLength) {
50089
50969
  const declaredLength = utils_default.toFiniteNumber(responseHeaders.getContentLength());
@@ -50302,9 +51182,10 @@ function throwIfCancellationRequested(config) {
50302
51182
  throw new CanceledError_default(null, config);
50303
51183
  }
50304
51184
  }
50305
- function dispatchRequest(config) {
51185
+ function dispatchRequest(_config) {
51186
+ const config = utils_default.toSafeFlatObject(_config);
50306
51187
  throwIfCancellationRequested(config);
50307
- config.headers = AxiosHeaders_default.from(config.headers);
51188
+ config.headers = AxiosHeaders_default.from(utils_default.getSafeProp(config, "headers"));
50308
51189
  config.data = transformData.call(config, config.transformRequest);
50309
51190
  if (["post", "put", "patch"].indexOf(config.method) !== -1) {
50310
51191
  config.headers.setContentType("application/x-www-form-urlencoded", false);
@@ -50434,16 +51315,15 @@ var Axios = class {
50434
51315
  return await this._request(configOrUrl, config);
50435
51316
  } catch (err) {
50436
51317
  if (err instanceof Error) {
50437
- let dummy = {};
50438
- Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
50439
- const stack = (() => {
50440
- if (!dummy.stack) {
50441
- return "";
50442
- }
50443
- const firstNewlineIndex = dummy.stack.indexOf("\n");
50444
- return firstNewlineIndex === -1 ? "" : dummy.stack.slice(firstNewlineIndex + 1);
50445
- })();
50446
51318
  try {
51319
+ let dummy = {};
51320
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
51321
+ const dummyStack = dummy.stack;
51322
+ let stack = "";
51323
+ if (typeof dummyStack === "string") {
51324
+ const firstNewlineIndex = dummyStack.indexOf("\n");
51325
+ stack = firstNewlineIndex === -1 ? "" : dummyStack.slice(firstNewlineIndex + 1);
51326
+ }
50447
51327
  if (!err.stack) {
50448
51328
  err.stack = stack;
50449
51329
  } else if (stack) {
@@ -50513,9 +51393,9 @@ var Axios = class {
50513
51393
  },
50514
51394
  true
50515
51395
  );
50516
- config.method = (config.method || this.defaults.method || "get").toLowerCase();
51396
+ config.method = (utils_default.getSafeProp(config, "method") || utils_default.getSafeProp(this.defaults, "method") || "get").toLowerCase();
50517
51397
  let contextHeaders = headers && utils_default.merge(headers.common, headers[config.method]);
50518
- headers && utils_default.forEach(["delete", "get", "head", "post", "put", "patch", "query", "common"], (method) => {
51398
+ headers && utils_default.forEach(methodList_default.concat("common"), (method) => {
50519
51399
  delete headers[method];
50520
51400
  });
50521
51401
  config.headers = AxiosHeaders_default.concat(contextHeaders, headers);
@@ -50778,14 +51658,22 @@ var HttpStatusCode = {
50778
51658
  Gone: 410,
50779
51659
  LengthRequired: 411,
50780
51660
  PreconditionFailed: 412,
51661
+ /**
51662
+ * @deprecated Use `ContentTooLarge` instead.
51663
+ */
50781
51664
  PayloadTooLarge: 413,
51665
+ ContentTooLarge: 413,
50782
51666
  UriTooLong: 414,
50783
51667
  UnsupportedMediaType: 415,
50784
51668
  RangeNotSatisfiable: 416,
50785
51669
  ExpectationFailed: 417,
50786
51670
  ImATeapot: 418,
50787
51671
  MisdirectedRequest: 421,
51672
+ /**
51673
+ * @deprecated Use `UnprocessableContent` instead.
51674
+ */
50788
51675
  UnprocessableEntity: 422,
51676
+ UnprocessableContent: 422,
50789
51677
  Locked: 423,
50790
51678
  FailedDependency: 424,
50791
51679
  TooEarly: 425,
@@ -50814,7 +51702,9 @@ var HttpStatusCode = {
50814
51702
  InvalidSslCertificate: 526
50815
51703
  };
50816
51704
  Object.entries(HttpStatusCode).forEach(([key, value]) => {
50817
- HttpStatusCode[value] = key;
51705
+ if (HttpStatusCode[value] === void 0) {
51706
+ HttpStatusCode[value] = key;
51707
+ }
50818
51708
  });
50819
51709
  var HttpStatusCode_default = HttpStatusCode;
50820
51710
 
@@ -51437,6 +52327,14 @@ var init_deployment_addresses = __esm2({
51437
52327
  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.",
51438
52328
  executeTx: "0xf1f8d5fc13f45d7a3f932bf1a2d6e29381fdd41cd31298ad785bf7688df07fe6",
51439
52329
  block: 25673200
52330
+ },
52331
+ AgentDelegationRegistry: {
52332
+ newImplementation: "0xa9fF405Edd4329fc3159a64F56B37EBD253e4928",
52333
+ upgradedAt: "2026-07-31T22:03:35.000Z",
52334
+ upgradedBy: "AdminModule/Safe audit-batch upgradeToAndCall; executed by 0xEba7BfAeB35ee18408b424Ee0BB45AdDf776589f in tx 0x8fed0ab7eee3aaaa3792a35b40b0ef74bd09cfb1a175934afd846bee546048d4 (block 25655710)",
52335
+ reason: "Reconciled from chain \u2014 mainnet audit rollout batch (cross-ref onchain-auth/.safe-batches/mainnet-audit-execute.json)",
52336
+ executeTx: "0x8fed0ab7eee3aaaa3792a35b40b0ef74bd09cfb1a175934afd846bee546048d4",
52337
+ block: 25655710
51440
52338
  }
51441
52339
  },
51442
52340
  latestEnv: {
@@ -51986,6 +52884,9 @@ var require_pkg_src2 = __commonJS2({
51986
52884
  });
51987
52885
  var index_exports = {};
51988
52886
  __export22(index_exports, {
52887
+ BORROWER_AUTHORIZATION_ENCODE_TYPES: () => BORROWER_AUTHORIZATION_ENCODE_TYPES,
52888
+ BORROWER_AUTHORIZATION_FIELDS: () => BORROWER_AUTHORIZATION_FIELDS,
52889
+ BORROWER_AUTHORIZATION_PRIMARY_TYPES: () => BORROWER_AUTHORIZATION_PRIMARY_TYPES,
51989
52890
  CHIPOTLE_DEPLOYMENTS: () => CHIPOTLE_DEPLOYMENTS,
51990
52891
  DEFAULT_CACHE_CONFIG: () => DEFAULT_CACHE_CONFIG,
51991
52892
  DEFAULT_DEBUG_CONFIG: () => DEFAULT_DEBUG_CONFIG,
@@ -51998,6 +52899,8 @@ var require_pkg_src2 = __commonJS2({
51998
52899
  PerformanceTracker: () => PerformanceTracker,
51999
52900
  RetryStrategy: () => RetryStrategy,
52000
52901
  analyzeError: () => analyzeError,
52902
+ borrowerAuthorizationTypes: () => borrowerAuthorizationTypes,
52903
+ buildBorrowerAuthorizationDomain: () => buildBorrowerAuthorizationDomain,
52001
52904
  calculateDelay: () => calculateDelay,
52002
52905
  cidToHex: () => cidToHex,
52003
52906
  classifyError: () => classifyError,
@@ -52244,30 +53147,30 @@ var require_pkg_src2 = __commonJS2({
52244
53147
  }
52245
53148
  },
52246
53149
  btcTransactionSigner: {
52247
- cid: "QmakWzTce8NH1Jkgv1xwg83Bg9WmF2UG1Mq76pDYDSwwUp",
53150
+ cid: "QmVi1BYdxvCX3QUhXwPtP6FjWMzqSPtXzrS54YsXjTgjYf",
52248
53151
  authorizedCidHex: cidToHex(
52249
- "QmakWzTce8NH1Jkgv1xwg83Bg9WmF2UG1Mq76pDYDSwwUp"
53152
+ "QmVi1BYdxvCX3QUhXwPtP6FjWMzqSPtXzrS54YsXjTgjYf"
52250
53153
  ),
52251
53154
  name: "Btc Transaction Signer",
52252
53155
  description: "Production Btc Transaction Signer",
52253
53156
  version: "1.1.1",
52254
53157
  deployed: true,
52255
- deployedAt: 1786465606156,
52256
- size: 67999,
52257
- hash: "83f3644c68819215e05ba8db3225571354a009458fc1437f606df6cb9142d3f9"
53158
+ deployedAt: 1787923905597,
53159
+ size: 70646,
53160
+ hash: "37c3bb72a660c8275d92e1b73f9482742d86b64789480b9246304c0ca1bab47a"
52258
53161
  },
52259
53162
  ucdMintValidator: {
52260
- cid: "Qmd8jgKRceLvf5aoTtwdXG2JqMoBK5cRJwrvEtQkgvbFbx",
53163
+ cid: "QmUWR5fLiyimLT9TPXpYx3HgwNwkvR6MxjZ7hdeYCFodbc",
52261
53164
  authorizedCidHex: cidToHex(
52262
- "Qmd8jgKRceLvf5aoTtwdXG2JqMoBK5cRJwrvEtQkgvbFbx"
53165
+ "QmUWR5fLiyimLT9TPXpYx3HgwNwkvR6MxjZ7hdeYCFodbc"
52263
53166
  ),
52264
53167
  name: "Ucd Mint Validator",
52265
53168
  description: "Production Ucd Mint Validator",
52266
53169
  version: "1.2.1",
52267
53170
  deployed: true,
52268
- deployedAt: 1786465627201,
52269
- size: 82739,
52270
- hash: "2bdd9aebdaad58a43a4731d5b7284f2531b7a9caaf8caf5719d891c4ed33cb2e",
53171
+ deployedAt: 1787923919527,
53172
+ size: 86197,
53173
+ hash: "c2d80939746cc37f65ef2f63c6a3215b929214a63f10c78144e1f5c98320dabf",
52271
53174
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
52272
53175
  pkp: {
52273
53176
  publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
@@ -52275,17 +53178,17 @@ var require_pkg_src2 = __commonJS2({
52275
53178
  }
52276
53179
  },
52277
53180
  processPaymentValidator: {
52278
- cid: "QmNXVdysXDhCaQ1uNE2Vgjbuzy6yUEnnVgHzmDfNKXMU6z",
53181
+ cid: "QmXmXuMRAjMLdgKGyTf9KQdGwYrDp8DxkiF44TvSXDf7wF",
52279
53182
  authorizedCidHex: cidToHex(
52280
- "QmNXVdysXDhCaQ1uNE2Vgjbuzy6yUEnnVgHzmDfNKXMU6z"
53183
+ "QmXmXuMRAjMLdgKGyTf9KQdGwYrDp8DxkiF44TvSXDf7wF"
52281
53184
  ),
52282
53185
  name: "Process Payment Validator",
52283
53186
  description: "Production Process Payment Validator",
52284
53187
  version: "1.2.1",
52285
53188
  deployed: true,
52286
- deployedAt: 1786465654796,
52287
- size: 78736,
52288
- hash: "17191ecc9c009e0fa5ab52c876330beb2a9a75d30cccb92e7c0c04f169df088b",
53189
+ deployedAt: 1787923987153,
53190
+ size: 82217,
53191
+ hash: "13defa19614215ab3b1fe88955d69e530d13a09475396af932fe0e213637da2f",
52289
53192
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
52290
53193
  pkp: {
52291
53194
  publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
@@ -52293,17 +53196,17 @@ var require_pkg_src2 = __commonJS2({
52293
53196
  }
52294
53197
  },
52295
53198
  extendPositionValidator: {
52296
- cid: "QmYwBsyrhGfHWyRKx549G4tKHxsBLAuRUHcecigeUCkFav",
53199
+ cid: "QmU8h99EEVEsQkxroXiYqLsKZw9gNjE6N5CcTpE9aUc12m",
52297
53200
  authorizedCidHex: cidToHex(
52298
- "QmYwBsyrhGfHWyRKx549G4tKHxsBLAuRUHcecigeUCkFav"
53201
+ "QmU8h99EEVEsQkxroXiYqLsKZw9gNjE6N5CcTpE9aUc12m"
52299
53202
  ),
52300
53203
  name: "Extend Position Validator",
52301
53204
  description: "Production Extend Position Validator",
52302
53205
  version: "1.2.1",
52303
53206
  deployed: true,
52304
- deployedAt: 1786465681874,
52305
- size: 76515,
52306
- hash: "1d4e085335af80f194a663a577876902c83015177e95906a0b461fa93bd5da08",
53207
+ deployedAt: 1787923999294,
53208
+ size: 79975,
53209
+ hash: "31c1aaf883ef22f37681ddb0a4a949be5c05304b6aef178989475a2da935ef9a",
52307
53210
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
52308
53211
  pkp: {
52309
53212
  publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
@@ -52311,17 +53214,17 @@ var require_pkg_src2 = __commonJS2({
52311
53214
  }
52312
53215
  },
52313
53216
  btcWithdrawal: {
52314
- cid: "QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh",
53217
+ cid: "QmZQWET9pzrVD4gwQuSzYZmqa24JrUNtnnGFDd513sxMCY",
52315
53218
  authorizedCidHex: cidToHex(
52316
- "QmRYVoTTDxk2McvBqxSm9M7YcaBGdTqjnZGPX4Y191DaZh"
53219
+ "QmZQWET9pzrVD4gwQuSzYZmqa24JrUNtnnGFDd513sxMCY"
52317
53220
  ),
52318
53221
  name: "Btc Withdrawal",
52319
53222
  description: "Production Btc Withdrawal",
52320
53223
  version: "1.2.7",
52321
53224
  deployed: true,
52322
- deployedAt: 1786446046614,
52323
- size: 97456,
52324
- hash: "3cae8250861832f91ee3c573abeb50ff27b9acd34148176071cbfbabb359fc91",
53225
+ deployedAt: 1787924017769,
53226
+ size: 100069,
53227
+ hash: "4f8e27414e4da235e63d6ae1325c63f3d2fb956464515a21aa007a99935f0f13",
52325
53228
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
52326
53229
  pkp: {
52327
53230
  publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
@@ -52433,30 +53336,30 @@ var require_pkg_src2 = __commonJS2({
52433
53336
  hash: "03ee5be239c91c735d2c95db89a0d1b77e602cfc18af8eb64b3281fddcd90a72"
52434
53337
  },
52435
53338
  agentModuleExecutor: {
52436
- cid: "QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ",
53339
+ cid: "QmcD65vuremot5fsHVgp9JBAmei6gAaEtm5mdtLP7Yt9Kf",
52437
53340
  authorizedCidHex: cidToHex(
52438
- "QmdhC18wF7PFGMQ8aThdPsEVSpuDewA27dFvbA3bG6kVDQ"
53341
+ "QmcD65vuremot5fsHVgp9JBAmei6gAaEtm5mdtLP7Yt9Kf"
52439
53342
  ),
52440
53343
  name: "Agent Module Executor",
52441
53344
  description: "Production Agent Module Executor",
52442
53345
  version: "1.1.1",
52443
53346
  deployed: true,
52444
- deployedAt: 1786446108348,
52445
- size: 11655,
52446
- hash: "d4e2149f843d6c2699fc61114d54b268ba4ed2c46ebdaee1145e0f101ec2a1ec"
53347
+ deployedAt: 1787924032013,
53348
+ size: 13878,
53349
+ hash: "a7f0204700912e26e5a354bee13a1242a2baa218643b3bb22d28481f67f9baf4"
52447
53350
  },
52448
53351
  staleSpendRecoveryValidator: {
52449
- cid: "QmXQWT8V4wjuvH8BbC7xrkYxsVu5AKfvfWcS7jnYfrexYm",
53352
+ cid: "QmNuwo4PT4AikAmhMdZgPWCb2mJDwWa9TnUqrqvofjbrT8",
52450
53353
  authorizedCidHex: cidToHex(
52451
- "QmXQWT8V4wjuvH8BbC7xrkYxsVu5AKfvfWcS7jnYfrexYm"
53354
+ "QmNuwo4PT4AikAmhMdZgPWCb2mJDwWa9TnUqrqvofjbrT8"
52452
53355
  ),
52453
53356
  name: "Stale Spend Recovery Validator",
52454
53357
  description: "Production Stale Spend Recovery Validator",
52455
53358
  version: "1.1.2",
52456
53359
  deployed: true,
52457
- deployedAt: 1785173285829,
52458
- size: 37108,
52459
- hash: "04de5fc5b6f5131dc1544e3d3d187a1f9ef9616ffd12483d119f9102b3671791",
53360
+ deployedAt: 1787924048772,
53361
+ size: 41424,
53362
+ hash: "3c5f028d2bef4344768462993616d45e30d9d44ef126e04d6eb579821d57d99c",
52460
53363
  validatorWalletAddress: "0x82DB9F515957aA380B596C6eA2Bd30CEF181f236",
52461
53364
  pkp: {
52462
53365
  publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
@@ -52464,17 +53367,17 @@ var require_pkg_src2 = __commonJS2({
52464
53367
  }
52465
53368
  },
52466
53369
  btcUtxoInvalidator: {
52467
- cid: "Qmf4Ze8yhnQhHbnX5RPgJrC7Jw1aA3gbpfpd52kFg7fd1m",
53370
+ cid: "QmaNGeWut7EiGwW4zUc2sFSt7RY5NWFgxYboyG333TwrJf",
52468
53371
  authorizedCidHex: cidToHex(
52469
- "Qmf4Ze8yhnQhHbnX5RPgJrC7Jw1aA3gbpfpd52kFg7fd1m"
53372
+ "QmaNGeWut7EiGwW4zUc2sFSt7RY5NWFgxYboyG333TwrJf"
52470
53373
  ),
52471
53374
  name: "Btc Utxo Invalidator",
52472
53375
  description: "Production Btc Utxo Invalidator",
52473
53376
  version: "1.0.0",
52474
53377
  deployed: true,
52475
- deployedAt: 1786465704240,
52476
- size: 62553,
52477
- hash: "1dcea2b49e545c423195be22e072dc5e3039ed1c95a8490b23505956029f5b33"
53378
+ deployedAt: 1787924133241,
53379
+ size: 66026,
53380
+ hash: "603bc50920d7f1dee77086f2c518d9e2922ab3858a419d3fbea8221ea3a6d9e9"
52478
53381
  }
52479
53382
  };
52480
53383
  function getDeploymentsForNetwork(network) {
@@ -53235,6 +54138,101 @@ ${errorReport}`);
53235
54138
  var SECONDS_PER_DAY = 86400;
53236
54139
  var DAYS_PER_MONTH = 30;
53237
54140
  var LIT_ACTION_ETH_RPC_TIMEOUT_MS = 8e3;
54141
+ var PINNED_CONTRACT_ADDRESSES = {
54142
+ 1: {
54143
+ PositionManager: "0x12A1836e56139ccaD8722B89519d84233efc224B",
54144
+ LoanOperationsManagerModule: "0x2561974A40F1AEed1251d0A090A83cF8536FB9E9",
54145
+ BTCSpendAuthorizer: "0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",
54146
+ BitcoinProviderRegistry: "0x4ab3Fb96e02893Ed6FAa61bad1918390c8DbbFFC",
54147
+ LITActionValidator: "0xD2c5d59c2CC5c409AC65ce0A817236aeC6869512",
54148
+ PositionDelegateRegistry: "0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C"
54149
+ },
54150
+ 11155111: {
54151
+ PositionManager: "0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",
54152
+ LoanOperationsManagerModule: "0x3e05e760a87715207b7F4e8fD35EF7559BcA72C0",
54153
+ BTCSpendAuthorizer: "0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",
54154
+ BitcoinProviderRegistry: "0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",
54155
+ LITActionValidator: "0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",
54156
+ PositionDelegateRegistry: "0x482369De283622E7b05731875ec137d4E3D208F9"
54157
+ }
54158
+ };
54159
+ function getPinnedContractAddresses(chainId) {
54160
+ return PINNED_CONTRACT_ADDRESSES[chainId] ?? null;
54161
+ }
54162
+ var PROTOCOL_EIP712_DOMAIN_NAME = "DiamondHands.Protocol";
54163
+ var PROTOCOL_EIP712_DOMAIN_VERSION = "1";
54164
+ var BORROWER_AUTHORIZATION_PRIMARY_TYPES = {
54165
+ MINT: "MintRequest",
54166
+ REPAY: "RepayRequest",
54167
+ RENEW: "RenewRequest",
54168
+ WITHDRAW: "WithdrawRequest"
54169
+ };
54170
+ var BORROWER_AUTHORIZATION_FIELDS = {
54171
+ MintRequest: [
54172
+ { name: "positionId", type: "bytes32" },
54173
+ { name: "mintAmount", type: "uint256" },
54174
+ { name: "quantumTimestamp", type: "uint256" }
54175
+ ],
54176
+ RepayRequest: [
54177
+ { name: "positionId", type: "bytes32" },
54178
+ { name: "paymentAmount", type: "uint256" },
54179
+ { name: "quantumTimestamp", type: "uint256" }
54180
+ ],
54181
+ RenewRequest: [
54182
+ { name: "positionId", type: "bytes32" },
54183
+ { name: "selectedTerm", type: "uint256" },
54184
+ { name: "quantumTimestamp", type: "uint256" }
54185
+ ],
54186
+ WithdrawRequest: [
54187
+ { name: "positionId", type: "bytes32" },
54188
+ { name: "totalDeduction", type: "uint256" },
54189
+ { name: "withdrawalAddress", type: "string" },
54190
+ { name: "quantumTimestamp", type: "uint256" }
54191
+ ]
54192
+ };
54193
+ var BORROWER_AUTHORIZATION_ENCODE_TYPES = {
54194
+ MintRequest: "MintRequest(bytes32 positionId,uint256 mintAmount,uint256 quantumTimestamp)",
54195
+ RepayRequest: "RepayRequest(bytes32 positionId,uint256 paymentAmount,uint256 quantumTimestamp)",
54196
+ RenewRequest: "RenewRequest(bytes32 positionId,uint256 selectedTerm,uint256 quantumTimestamp)",
54197
+ WithdrawRequest: "WithdrawRequest(bytes32 positionId,uint256 totalDeduction,string withdrawalAddress,uint256 quantumTimestamp)"
54198
+ };
54199
+ function borrowerAuthorizationTypes(primaryType) {
54200
+ const fields = BORROWER_AUTHORIZATION_FIELDS[primaryType];
54201
+ if (!fields) {
54202
+ throw new Error(
54203
+ `Unknown borrower authorization primary type "${primaryType}"; expected one of ${Object.keys(BORROWER_AUTHORIZATION_FIELDS).join(", ")}`
54204
+ );
54205
+ }
54206
+ return { [primaryType]: fields.map((field) => ({ ...field })) };
54207
+ }
54208
+ function buildBorrowerAuthorizationDomain(chainId, verifyingContractOverride) {
54209
+ if (!Number.isInteger(chainId) || chainId <= 0) {
54210
+ throw new Error(
54211
+ `Borrower authorization domain requires a positive integer chainId, got ${String(chainId)}`
54212
+ );
54213
+ }
54214
+ const pinned = getPinnedContractAddresses(chainId);
54215
+ const pinnedLom = pinned?.LoanOperationsManagerModule;
54216
+ if (pinnedLom && verifyingContractOverride) {
54217
+ if (pinnedLom.toLowerCase() !== verifyingContractOverride.toLowerCase()) {
54218
+ throw new Error(
54219
+ `Refusing a caller-supplied verifyingContract that contradicts the pin for chainId ${chainId}: caller ${verifyingContractOverride}, pinned ${pinnedLom}`
54220
+ );
54221
+ }
54222
+ }
54223
+ const verifyingContract = pinnedLom ?? verifyingContractOverride;
54224
+ if (!verifyingContract) {
54225
+ throw new Error(
54226
+ `No pinned LoanOperationsManagerModule for chainId ${chainId} and no verifyingContract supplied; refusing to build a borrower authorization domain without one`
54227
+ );
54228
+ }
54229
+ return {
54230
+ name: PROTOCOL_EIP712_DOMAIN_NAME,
54231
+ version: PROTOCOL_EIP712_DOMAIN_VERSION,
54232
+ chainId,
54233
+ verifyingContract
54234
+ };
54235
+ }
53238
54236
  var EVMChain = /* @__PURE__ */ ((EVMChain3) => {
53239
54237
  EVMChain3["SEPOLIA"] = "sepolia";
53240
54238
  EVMChain3["ETHEREUM"] = "ethereum";
@@ -57030,6 +58028,77 @@ async function awaitSafeSubmissionWindowOnChain(signatureQuantum, chainNow, slee
57030
58028
  );
57031
58029
  return { waited: waitedSeconds > 0, waitedSeconds };
57032
58030
  }
58031
+ init_deployment_addresses();
58032
+ var BORROWER_AUTHORIZATION_712_DOMAIN_NAME = "DiamondHands.Protocol";
58033
+ var BORROWER_AUTHORIZATION_712_DOMAIN_VERSION = "1";
58034
+ var BORROWER_AUTHORIZATION_712_FIELDS = {
58035
+ MintRequest: [
58036
+ { name: "positionId", type: "bytes32" },
58037
+ { name: "mintAmount", type: "uint256" },
58038
+ { name: "quantumTimestamp", type: "uint256" }
58039
+ ],
58040
+ RepayRequest: [
58041
+ { name: "positionId", type: "bytes32" },
58042
+ { name: "paymentAmount", type: "uint256" },
58043
+ { name: "quantumTimestamp", type: "uint256" }
58044
+ ],
58045
+ RenewRequest: [
58046
+ { name: "positionId", type: "bytes32" },
58047
+ { name: "selectedTerm", type: "uint256" },
58048
+ { name: "quantumTimestamp", type: "uint256" }
58049
+ ],
58050
+ WithdrawRequest: [
58051
+ { name: "positionId", type: "bytes32" },
58052
+ { name: "totalDeduction", type: "uint256" },
58053
+ { name: "withdrawalAddress", type: "string" },
58054
+ { name: "quantumTimestamp", type: "uint256" }
58055
+ ]
58056
+ };
58057
+ function borrowerAuthorization712Types(primaryType) {
58058
+ const fields = BORROWER_AUTHORIZATION_712_FIELDS[primaryType];
58059
+ if (!fields) {
58060
+ throw new Error(
58061
+ `Unknown borrower authorization primary type "${primaryType}"; expected one of ` + Object.keys(BORROWER_AUTHORIZATION_712_FIELDS).join(", ")
58062
+ );
58063
+ }
58064
+ return { [primaryType]: fields.map((field) => ({ ...field })) };
58065
+ }
58066
+ function buildBorrowerAuthorization712Domain(chainId) {
58067
+ if (!Number.isInteger(chainId) || chainId <= 0) {
58068
+ throw new Error(
58069
+ `Borrower authorization domain requires a positive integer chainId, got ${String(chainId)}`
58070
+ );
58071
+ }
58072
+ const deployment = Object.values(ALL_DEPLOYMENTS).find(
58073
+ (d) => d.chainId === chainId
58074
+ );
58075
+ const verifyingContract = deployment?.contracts?.LoanOperationsManagerModule;
58076
+ if (!verifyingContract) {
58077
+ throw new Error(
58078
+ `No LoanOperationsManagerModule deployment known for chainId ${chainId}; refusing to build a borrower authorization domain without one`
58079
+ );
58080
+ }
58081
+ return {
58082
+ name: BORROWER_AUTHORIZATION_712_DOMAIN_NAME,
58083
+ version: BORROWER_AUTHORIZATION_712_DOMAIN_VERSION,
58084
+ chainId,
58085
+ verifyingContract
58086
+ };
58087
+ }
58088
+ async function signBorrowerAuthorization712(signer, primaryType, chainId, message) {
58089
+ const signTypedData = signer.signTypedData;
58090
+ if (typeof signTypedData !== "function") {
58091
+ throw new Error(
58092
+ `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.`
58093
+ );
58094
+ }
58095
+ return signTypedData.call(
58096
+ signer,
58097
+ buildBorrowerAuthorization712Domain(chainId),
58098
+ borrowerAuthorization712Types(primaryType),
58099
+ message
58100
+ );
58101
+ }
57033
58102
  var PKP_NFT_ABI = [
57034
58103
  "function getPubkey(uint256 tokenId) external view returns (bytes memory)"
57035
58104
  ];
@@ -57042,29 +58111,11 @@ async function generateMintAuthorization(positionId, amount, chainId, signerOrPr
57042
58111
  const signer = signerOrPrecomputed;
57043
58112
  const timestamp = calculateNextQuantumTimestamp();
57044
58113
  const action = "mint-ucd";
57045
- const actionHash = (0, import_ethers16.keccak256)((0, import_ethers16.toUtf8Bytes)(action));
57046
- const types = [
57047
- "bytes32",
57048
- // positionId
57049
- "uint256",
57050
- // timestamp
57051
- "uint256",
57052
- // chainId
57053
- "uint256",
57054
- // amount
57055
- "bytes32"
57056
- // actionHash
57057
- ];
57058
- const values = [
58114
+ const signature = await signBorrowerAuthorization712(signer, "MintRequest", chainId, {
57059
58115
  positionId,
57060
- timestamp,
57061
- chainId,
57062
- amount.toString(),
57063
- actionHash
57064
- ];
57065
- const messageHash = (0, import_ethers16.solidityPackedKeccak256)(types, values);
57066
- const messageHashBytes = (0, import_ethers16.getBytes)(messageHash);
57067
- const signature = await signer.signMessage(messageHashBytes);
58116
+ mintAmount: amount.toString(),
58117
+ quantumTimestamp: timestamp
58118
+ });
57068
58119
  return {
57069
58120
  positionId,
57070
58121
  timestamp,
@@ -57101,44 +58152,17 @@ async function generatePaymentAuthorization(positionId, amount, chainId, signerO
57101
58152
  throw new Error(`timestamp must be a number, got ${typeof timestamp}`);
57102
58153
  }
57103
58154
  const action = "make-payment";
57104
- const actionHash = (0, import_ethers16.keccak256)((0, import_ethers16.toUtf8Bytes)(action));
57105
- if (typeof actionHash !== "string") {
57106
- throw new Error(`actionHash must be a string, got ${typeof actionHash}`);
57107
- }
57108
- const types = [
57109
- "bytes32",
57110
- // positionId
57111
- "uint256",
57112
- // timestamp
57113
- "uint256",
57114
- // chainId
57115
- "uint256",
57116
- // amount
57117
- "bytes32"
57118
- // actionHash
57119
- ];
57120
58155
  const amountStr = amount.toString();
57121
- if (typeof amountStr !== "string") {
57122
- throw new Error(
57123
- `amount.toString() must return a string, got ${typeof amountStr}`
57124
- );
57125
- }
57126
- const values = [positionId, timestamp, chainId, amountStr, actionHash];
57127
- for (let i = 0; i < values.length; i++) {
57128
- if (typeof values[i] === "object" && values[i] !== null) {
57129
- throw new Error(
57130
- `Value at index ${i} is an object: ${JSON.stringify(values[i])}`
57131
- );
57132
- }
57133
- }
57134
- const messageHash = (0, import_ethers16.solidityPackedKeccak256)(types, values);
57135
- const messageHashBytes = (0, import_ethers16.getBytes)(messageHash);
57136
- const signature = await signer.signMessage(messageHashBytes);
58156
+ const signature = await signBorrowerAuthorization712(signer, "RepayRequest", chainId, {
58157
+ positionId,
58158
+ paymentAmount: amountStr,
58159
+ quantumTimestamp: timestamp
58160
+ });
57137
58161
  return {
57138
58162
  positionId,
57139
58163
  timestamp,
57140
58164
  chainId,
57141
- amount: amount.toString(),
58165
+ amount: amountStr,
57142
58166
  action,
57143
58167
  signature
57144
58168
  };
@@ -57225,32 +58249,12 @@ async function generateWithdrawAuthorization(positionId, amount, chainId, signer
57225
58249
  const signer = signerOrPrecomputed;
57226
58250
  const timestamp = calculateNextQuantumTimestamp();
57227
58251
  const action = "withdraw-btc";
57228
- const actionHash = (0, import_ethers16.keccak256)((0, import_ethers16.toUtf8Bytes)(action));
57229
- const types = [
57230
- "bytes32",
57231
- // positionId
57232
- "uint256",
57233
- // timestamp
57234
- "uint256",
57235
- // chainId
57236
- "uint256",
57237
- // amount (in satoshis)
57238
- "string",
57239
- // destinationAddress (Bitcoin address)
57240
- "bytes32"
57241
- // actionHash
57242
- ];
57243
- const values = [
58252
+ const signature = await signBorrowerAuthorization712(signer, "WithdrawRequest", chainId, {
57244
58253
  positionId,
57245
- timestamp,
57246
- chainId,
57247
- amount.toString(),
57248
- destinationAddress,
57249
- actionHash
57250
- ];
57251
- const messageHash = (0, import_ethers16.solidityPackedKeccak256)(types, values);
57252
- const messageHashBytes = (0, import_ethers16.getBytes)(messageHash);
57253
- const signature = await signer.signMessage(messageHashBytes);
58254
+ totalDeduction: amount.toString(),
58255
+ withdrawalAddress: destinationAddress,
58256
+ quantumTimestamp: timestamp
58257
+ });
57254
58258
  return {
57255
58259
  positionId,
57256
58260
  timestamp,
@@ -57299,29 +58303,11 @@ async function generateExtendAuthorization(positionId, newTerm, chainId, signerO
57299
58303
  const signer = signerOrPrecomputed;
57300
58304
  const timestamp = calculateNextQuantumTimestamp();
57301
58305
  const action = "extend-position";
57302
- const actionHash = (0, import_ethers17.keccak256)((0, import_ethers17.toUtf8Bytes)(action));
57303
- const types = [
57304
- "bytes32",
57305
- // positionId
57306
- "uint256",
57307
- // timestamp
57308
- "uint256",
57309
- // chainId
57310
- "uint256",
57311
- // newTerm (extension term in months)
57312
- "bytes32"
57313
- // actionHash
57314
- ];
57315
- const values = [
58306
+ const signature = await signBorrowerAuthorization712(signer, "RenewRequest", chainId, {
57316
58307
  positionId,
57317
- timestamp,
57318
- chainId,
57319
- newTerm,
57320
- actionHash
57321
- ];
57322
- const messageHash = (0, import_ethers17.solidityPackedKeccak256)(types, values);
57323
- const messageHashBytes = (0, import_ethers17.getBytes)(messageHash);
57324
- const signature = await signer.signMessage(messageHashBytes);
58308
+ selectedTerm: newTerm,
58309
+ quantumTimestamp: timestamp
58310
+ });
57325
58311
  return {
57326
58312
  positionId,
57327
58313
  timestamp,
@@ -57556,6 +58542,7 @@ var ServerSession = class {
57556
58542
  store;
57557
58543
  onSignaturePrompt;
57558
58544
  onSignatureResolved;
58545
+ onSessionRestored;
57559
58546
  now;
57560
58547
  fetchImpl;
57561
58548
  cached = null;
@@ -57596,6 +58583,7 @@ var ServerSession = class {
57596
58583
  this.store = opts.persistSession === false ? null : opts.sessionStore ?? createDefaultSessionStore();
57597
58584
  this.onSignaturePrompt = opts.onSignaturePrompt;
57598
58585
  this.onSignatureResolved = opts.onSignatureResolved;
58586
+ this.onSessionRestored = opts.onSessionRestored;
57599
58587
  this.now = opts.now ?? (() => Math.floor(Date.now() / 1e3));
57600
58588
  this.fetchImpl = opts.fetchImpl ?? ((...a) => fetch(...a));
57601
58589
  }
@@ -57676,7 +58664,7 @@ var ServerSession = class {
57676
58664
  */
57677
58665
  async logout() {
57678
58666
  const cached = this.cached;
57679
- const token = cached && cached.expiresAt > this.now() ? cached.token : await this.getValidToken({ silent: true }).catch(() => null);
58667
+ const token = cached && cached.expiresAt > this.now() ? cached.token : await this.tryResolveSilently(this.generation, false).then((session) => session?.token ?? null).catch(() => null);
57680
58668
  await this.clearPersisted();
57681
58669
  if (!token)
57682
58670
  return;
@@ -57748,8 +58736,9 @@ var ServerSession = class {
57748
58736
  *
57749
58737
  * `gen` is the caller's clear-generation snapshot: writes to `this.cached`
57750
58738
  * and the store are skipped if a `clearPersisted()` landed meanwhile.
58739
+ * `announce` gates `onSessionRestored` for the two persisted-store outcomes.
57751
58740
  */
57752
- async tryResolveSilently(gen) {
58741
+ async tryResolveSilently(gen, announce = true) {
57753
58742
  const nowSec = this.now();
57754
58743
  if (this.cached && this.cached.expiresAt - REFRESH_LEEWAY_SECONDS > nowSec) {
57755
58744
  return this.cached;
@@ -57764,6 +58753,8 @@ var ServerSession = class {
57764
58753
  };
57765
58754
  if (gen === this.generation)
57766
58755
  this.cached = adopted;
58756
+ if (announce)
58757
+ this.onSessionRestored?.();
57767
58758
  return adopted;
57768
58759
  }
57769
58760
  try {
@@ -57772,6 +58763,8 @@ var ServerSession = class {
57772
58763
  this.persist(persisted.payload, session);
57773
58764
  this.cached = session;
57774
58765
  }
58766
+ if (announce)
58767
+ this.onSessionRestored?.();
57775
58768
  return session;
57776
58769
  } catch (error) {
57777
58770
  if (!isLoginRejection(error))
@@ -60857,6 +61850,10 @@ function normalizePkpId(pkpId) {
60857
61850
  }
60858
61851
  return pkpId;
60859
61852
  }
61853
+ function isNormalizedChipotlePkpId(pkpId) {
61854
+ const rawId = pkpId.startsWith("0x") ? pkpId.slice(2) : pkpId;
61855
+ return rawId.length === 40;
61856
+ }
60860
61857
  function padPkpIdForSubgraph(pkpId) {
60861
61858
  const raw = pkpId.startsWith("0x") ? pkpId.slice(2) : pkpId;
60862
61859
  if (raw.length === 40) {
@@ -61141,7 +62138,7 @@ var LoanQuery = class {
61141
62138
  batch.map(async (loan) => {
61142
62139
  try {
61143
62140
  const rawId = loan.pkpId?.startsWith("0x") ? loan.pkpId.slice(2) : loan.pkpId;
61144
- const isChipotlePkpId2 = typeof rawId === "string" && rawId.length === 40 && !rawId.toLowerCase().startsWith("04");
62141
+ const isChipotlePkpId2 = typeof rawId === "string" && isNormalizedChipotlePkpId(rawId);
61145
62142
  if (isChipotlePkpId2) {
61146
62143
  if (this.config.positionManagerCoreAddress && this.config.provider) {
61147
62144
  const pmContract = new import_ethers26.Contract(
@@ -61468,6 +62465,7 @@ function createLoanQuery(config) {
61468
62465
  );
61469
62466
  }
61470
62467
  }
62468
+ var STATIC_CALL_DIAGNOSTIC_TIMEOUT_MS = 5e3;
61471
62469
  var WithdrawalAddressModule = class {
61472
62470
  config;
61473
62471
  graphClient;
@@ -61513,13 +62511,17 @@ var WithdrawalAddressModule = class {
61513
62511
  const reg = this.getRegistry();
61514
62512
  if (!reg.success)
61515
62513
  return reg;
62514
+ const normalized = normalizeBitcoinAddress(btcAddress2);
61516
62515
  try {
61517
- const tx2 = await reg.value.addAddress(
61518
- normalizeBitcoinAddress(btcAddress2)
61519
- );
62516
+ const tx2 = await reg.value.addAddress(normalized);
61520
62517
  return success(tx2);
61521
62518
  } catch (error) {
61522
- return this.txFailure("addAddress", error, btcAddress2);
62519
+ return this.txFailure(
62520
+ "addAddress",
62521
+ error,
62522
+ btcAddress2,
62523
+ await this.staticCallDiagnostic(reg.value, "addAddress", normalized)
62524
+ );
61523
62525
  }
61524
62526
  }
61525
62527
  /** Remove a Bitcoin address from the caller's allowlist (effective immediately). */
@@ -61527,13 +62529,17 @@ var WithdrawalAddressModule = class {
61527
62529
  const reg = this.getRegistry();
61528
62530
  if (!reg.success)
61529
62531
  return reg;
62532
+ const normalized = normalizeBitcoinAddress(btcAddress2);
61530
62533
  try {
61531
- const tx2 = await reg.value.removeAddress(
61532
- normalizeBitcoinAddress(btcAddress2)
61533
- );
62534
+ const tx2 = await reg.value.removeAddress(normalized);
61534
62535
  return success(tx2);
61535
62536
  } catch (error) {
61536
- return this.txFailure("removeAddress", error, btcAddress2);
62537
+ return this.txFailure(
62538
+ "removeAddress",
62539
+ error,
62540
+ btcAddress2,
62541
+ await this.staticCallDiagnostic(reg.value, "removeAddress", normalized)
62542
+ );
61537
62543
  }
61538
62544
  }
61539
62545
  /**
@@ -61629,16 +62635,59 @@ var WithdrawalAddressModule = class {
61629
62635
  }
61630
62636
  return success(void 0);
61631
62637
  }
61632
- txFailure(op, error, context) {
62638
+ /**
62639
+ * Ask the node for the reason a failed write did not carry.
62640
+ *
62641
+ * A failing `eth_estimateGas` frequently answers with NOTHING to decode — ethers renders that
62642
+ * as `missing revert data ... data=null, reason=null, revert=null`, which names no cause and
62643
+ * cannot distinguish "the contract rejected this" from "the RPC hiccuped". An `eth_call` of the
62644
+ * same calldata usually does carry the revert reason or custom-error selector, so this runs one
62645
+ * and folds the answer into the reported error.
62646
+ *
62647
+ * Three deliberate properties:
62648
+ *
62649
+ * 1. It runs ONLY after the write has already failed. Gating the write on a static call would
62650
+ * let a flaky endpoint — precisely the condition this exists to diagnose — block an add that
62651
+ * would otherwise have succeeded.
62652
+ * 2. It costs NO extra signature. `staticCall` is `eth_call`: a node read, never a wallet prompt.
62653
+ * 3. It can never throw. A diagnostic that escapes would replace the real cause with itself.
62654
+ * (The `try/catch` here is the authorized exception to CLAUDE.md's forbidden-patterns rule;
62655
+ * it swallows nothing — every branch returns text that is reported alongside the original.)
62656
+ *
62657
+ * A static call that SUCCEEDS is itself a finding: the contract accepts this call, so the
62658
+ * failure lay outside contract logic (RPC, gas, or nonce).
62659
+ */
62660
+ async staticCallDiagnostic(registry, op, normalizedAddress) {
62661
+ try {
62662
+ await Promise.race([
62663
+ registry[op].staticCall(normalizedAddress),
62664
+ // The failure being diagnosed is often an unresponsive endpoint, so the diagnostic must
62665
+ // not inherit that hang — the user is waiting on this error message.
62666
+ new Promise(
62667
+ (_, reject) => setTimeout(
62668
+ () => reject(new Error("static call timed out after 5s")),
62669
+ STATIC_CALL_DIAGNOSTIC_TIMEOUT_MS
62670
+ )
62671
+ )
62672
+ ]);
62673
+ return "static call SUCCEEDED \u2014 the contract accepts this call, so the failure was not contract logic (RPC, gas, or nonce)";
62674
+ } catch (diagnostic) {
62675
+ const code = typeof diagnostic === "object" && diagnostic !== null ? diagnostic.code : void 0;
62676
+ const msg = diagnostic instanceof Error ? diagnostic.message : String(diagnostic);
62677
+ return typeof code === "string" ? `static call reverted [${code}]: ${msg}` : `static call failed: ${msg}`;
62678
+ }
62679
+ }
62680
+ txFailure(op, error, context, diagnostic) {
61633
62681
  const msg = error instanceof Error ? error.message : String(error);
62682
+ const detail = diagnostic ? `${msg} \u2014 ${diagnostic}` : msg;
61634
62683
  return failure(
61635
62684
  new SDKError({
61636
62685
  code: `SDK_WITHDRAWAL_REGISTRY_${op.toUpperCase()}_FAILED`,
61637
- message: `WithdrawalAddressRegistry.${op} failed: ${msg}`,
62686
+ message: `WithdrawalAddressRegistry.${op} failed: ${detail}`,
61638
62687
  category: "CONTRACT",
61639
62688
  severity: "MEDIUM",
61640
62689
  originalError: error instanceof Error ? error : new Error(String(error)),
61641
- context: { op, context }
62690
+ context: { op, context, diagnostic }
61642
62691
  })
61643
62692
  );
61644
62693
  }
@@ -62716,6 +63765,210 @@ function normalizePkpId2(pkpId) {
62716
63765
  }
62717
63766
  return pkpId;
62718
63767
  }
63768
+ function applyLoanEventsFilter(events, opts) {
63769
+ const { wantsEvent, fromTimestamp, toTimestamp, fromBlock, toBlock, limit } = opts;
63770
+ const inBounds = (e) => {
63771
+ const ts = e?.timestamp;
63772
+ const bn = e?.blockNumber;
63773
+ try {
63774
+ if (fromTimestamp !== void 0 && ts !== void 0 && BigInt(ts) < BigInt(fromTimestamp))
63775
+ return false;
63776
+ if (toTimestamp !== void 0 && ts !== void 0 && BigInt(ts) > BigInt(toTimestamp))
63777
+ return false;
63778
+ if (fromBlock !== void 0 && bn !== void 0 && BigInt(bn) < BigInt(fromBlock))
63779
+ return false;
63780
+ if (toBlock !== void 0 && bn !== void 0 && BigInt(bn) > BigInt(toBlock))
63781
+ return false;
63782
+ } catch {
63783
+ return true;
63784
+ }
63785
+ return true;
63786
+ };
63787
+ const narrow = (list, kind) => wantsEvent(kind) ? (list ?? []).filter(inBounds).slice(0, limit) : [];
63788
+ const single = (value, kind) => value && wantsEvent(kind) && inBounds(value) ? value : void 0;
63789
+ const filtered = {
63790
+ ...events,
63791
+ positionCreated: single(events.positionCreated, "positionCreated"),
63792
+ payments: narrow(events.payments, "payment"),
63793
+ statusUpdates: narrow(events.statusUpdates, "status"),
63794
+ liquidation: single(events.liquidation, "liquidation"),
63795
+ mints: narrow(events.mints, "mint"),
63796
+ withdrawals: narrow(events.withdrawals, "withdrawal"),
63797
+ renewals: narrow(events.renewals, "renewal"),
63798
+ operationFailures: narrow(events.operationFailures, "operationFailure"),
63799
+ mintRequests: narrow(events.mintRequests, "mintRequest"),
63800
+ burnRequests: narrow(events.burnRequests, "burnRequest"),
63801
+ collateralEvents: narrow(events.collateralEvents, "collateralEvent"),
63802
+ mintingFees: narrow(events.mintingFees, "mintingFee"),
63803
+ renewalFees: narrow(events.renewalFees, "renewalFee"),
63804
+ totalEvents: 0
63805
+ };
63806
+ 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;
63807
+ return filtered;
63808
+ }
63809
+ function hasLoanEventsFilter(filter2) {
63810
+ if (!filter2)
63811
+ return false;
63812
+ 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;
63813
+ }
63814
+ var WALLET_LOAN_EVENTS_QUERY = `
63815
+ query GetWalletLoanEvents($borrower: Bytes!, $first: Int!, $limit: Int!, $orderDirection: OrderDirection!) {
63816
+ positions(where: { borrower: $borrower }, first: $first, orderBy: id) {
63817
+ id
63818
+ payments(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63819
+ id
63820
+ payer { id }
63821
+ amount
63822
+ type
63823
+ transactionHash
63824
+ timestamp
63825
+ blockNumber
63826
+ logIndex
63827
+ newDebt
63828
+ newCollateralRatio
63829
+ }
63830
+ statusUpdates(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63831
+ id
63832
+ oldStatus
63833
+ newStatus
63834
+ reason
63835
+ timestamp
63836
+ blockNumber
63837
+ transactionHash
63838
+ }
63839
+ liquidation {
63840
+ id
63841
+ liquidator
63842
+ liquidatedAmount
63843
+ collateralSeized
63844
+ transactionHash
63845
+ timestamp
63846
+ blockNumber
63847
+ commitHash
63848
+ commitTimestamp
63849
+ revealDelay
63850
+ }
63851
+ withdrawals(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63852
+ id
63853
+ withdrawalAmount
63854
+ withdrawalAddress
63855
+ networkFee
63856
+ timestamp
63857
+ blockNumber
63858
+ transactionHash
63859
+ logIndex
63860
+ }
63861
+ renewals(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63862
+ id
63863
+ extensionTerm
63864
+ extensionFee
63865
+ newExpiryDate
63866
+ timestamp
63867
+ blockNumber
63868
+ transactionHash
63869
+ logIndex
63870
+ }
63871
+ operationFailures(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63872
+ id
63873
+ operationType
63874
+ reason
63875
+ errorCode
63876
+ amount
63877
+ timestamp
63878
+ blockNumber
63879
+ transactionHash
63880
+ logIndex
63881
+ }
63882
+ mintRequests(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63883
+ id
63884
+ pkpId
63885
+ borrower { id }
63886
+ mintAmount
63887
+ originationFee
63888
+ newDebt
63889
+ newCollateralRatio
63890
+ btcPrice
63891
+ quantumTimestamp
63892
+ opId
63893
+ timestamp
63894
+ blockNumber
63895
+ transactionHash
63896
+ logIndex
63897
+ }
63898
+ burnRequests(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63899
+ id
63900
+ pkpId
63901
+ borrower { id }
63902
+ burnAmount
63903
+ remainingDebt
63904
+ newCollateralRatio
63905
+ opId
63906
+ timestamp
63907
+ blockNumber
63908
+ transactionHash
63909
+ logIndex
63910
+ }
63911
+ mintingFees(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63912
+ id
63913
+ borrower { id }
63914
+ feeAmount
63915
+ mintAmount
63916
+ newDebt
63917
+ btcPrice
63918
+ quantumTimestamp
63919
+ timestamp
63920
+ blockNumber
63921
+ transactionHash
63922
+ logIndex
63923
+ }
63924
+ renewalFees(first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63925
+ id
63926
+ borrower { id }
63927
+ feeAmount
63928
+ extensionTerm
63929
+ newExpiryDate
63930
+ timestamp
63931
+ blockNumber
63932
+ transactionHash
63933
+ logIndex
63934
+ }
63935
+ positionCreatedEvents(first: 1, orderBy: timestamp, orderDirection: asc) {
63936
+ id
63937
+ pkpId
63938
+ borrower { id }
63939
+ requestedCollateralRatio
63940
+ selectedTerm
63941
+ expiryAt
63942
+ timestamp
63943
+ blockNumber
63944
+ transactionHash
63945
+ }
63946
+ }
63947
+ ucdmintEvents(where: { position_: { borrower: $borrower } }, first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63948
+ id
63949
+ position { id }
63950
+ amount
63951
+ proof
63952
+ minter { id }
63953
+ isCommunityMint
63954
+ timestamp
63955
+ blockNumber
63956
+ transactionHash
63957
+ }
63958
+ collateralEvents(where: { position_: { borrower: $borrower } }, first: $limit, orderBy: timestamp, orderDirection: $orderDirection) {
63959
+ id
63960
+ position { id }
63961
+ eventType
63962
+ networkFee
63963
+ remainingCollateral
63964
+ collateralRatio
63965
+ timestamp
63966
+ blockNumber
63967
+ transactionHash
63968
+ logIndex
63969
+ }
63970
+ }
63971
+ `;
62719
63972
  var DiamondHandsGraph = class {
62720
63973
  client;
62721
63974
  defaultPageSize;
@@ -62821,7 +64074,7 @@ var DiamondHandsGraph = class {
62821
64074
  /**
62822
64075
  * Get user positions from subgraph
62823
64076
  */
62824
- async getUserPositions(userAddress, first, skip, orderBy, orderDirection) {
64077
+ async getUserPositionsOnly(userAddress, first, skip, orderBy, orderDirection) {
62825
64078
  const query = `
62826
64079
  query GetUserPositions($borrower: Bytes!, $first: Int, $skip: Int, $orderBy: Position_orderBy, $orderDirection: OrderDirection) {
62827
64080
  user(id: $borrower) {
@@ -62862,17 +64115,28 @@ var DiamondHandsGraph = class {
62862
64115
  query,
62863
64116
  variables
62864
64117
  );
62865
- const total = await this.getTotalCountPaginated("{ borrower: $borrower }", {
62866
- borrower: userAddress.toLowerCase()
62867
- });
62868
64118
  let positions = [];
62869
64119
  if (result && result.user && Array.isArray(result.user.positions)) {
62870
64120
  positions = result.user.positions.filter((p) => p != null).map((p) => this.transformGraphPositionToLoanData(p));
62871
64121
  }
62872
- return {
62873
- positions,
62874
- total
62875
- };
64122
+ return positions;
64123
+ }
64124
+ /**
64125
+ * Get user positions, plus an accurate total count.
64126
+ *
64127
+ * The count is a SECOND round trip (`getTotalCountPaginated`, which pages to handle
64128
+ * >1000 items). Callers that only need the rows should use `getUserPositionsOnly` and
64129
+ * skip it — the event paths did not, and paid for a count they immediately discarded on
64130
+ * every activity refresh.
64131
+ */
64132
+ async getUserPositions(userAddress, first, skip, orderBy, orderDirection) {
64133
+ const [positions, total] = await Promise.all([
64134
+ this.getUserPositionsOnly(userAddress, first, skip, orderBy, orderDirection),
64135
+ this.getTotalCountPaginated("{ borrower: $borrower }", {
64136
+ borrower: userAddress.toLowerCase()
64137
+ })
64138
+ ]);
64139
+ return { positions, total };
62876
64140
  }
62877
64141
  /**
62878
64142
  * Get user positions with enriched Bitcoin balance data
@@ -63698,32 +64962,24 @@ var DiamondHandsGraph = class {
63698
64962
  limit = 1e3,
63699
64963
  orderDirection = "desc"
63700
64964
  } = filter2 || {};
64965
+ const wantsEvent = (kind) => !eventTypes || eventTypes.includes(kind);
64966
+ const hasBounds = fromTimestamp !== void 0 || toTimestamp !== void 0 || fromBlock !== void 0 || toBlock !== void 0;
64967
+ const pageSize = hasBounds ? THE_GRAPH_MAX_BATCH_SIZE : limit;
64968
+ const buildPositionWhereClause = () => `where: { position: "${positionId.toLowerCase()}" }`;
63701
64969
  const shouldQuery = {
63702
- positionCreated: !eventTypes || eventTypes.includes("positionCreated"),
63703
- payment: !eventTypes || eventTypes.includes("payment"),
63704
- status: !eventTypes || eventTypes.includes("status"),
63705
- liquidation: !eventTypes || eventTypes.includes("liquidation"),
63706
- mint: !eventTypes || eventTypes.includes("mint"),
63707
- withdrawal: !eventTypes || eventTypes.includes("withdrawal"),
63708
- renewal: !eventTypes || eventTypes.includes("renewal"),
63709
- operationFailure: !eventTypes || eventTypes.includes("operationFailure"),
63710
- mintRequest: !eventTypes || eventTypes.includes("mintRequest"),
63711
- burnRequest: !eventTypes || eventTypes.includes("burnRequest"),
63712
- collateralEvent: !eventTypes || eventTypes.includes("collateralEvent"),
63713
- mintingFee: !eventTypes || eventTypes.includes("mintingFee"),
63714
- renewalFee: !eventTypes || eventTypes.includes("renewalFee")
63715
- };
63716
- const buildPositionWhereClause = () => {
63717
- const conditions = [`position: "${positionId.toLowerCase()}"`];
63718
- if (fromTimestamp)
63719
- conditions.push(`timestamp_gte: "${fromTimestamp}"`);
63720
- if (toTimestamp)
63721
- conditions.push(`timestamp_lte: "${toTimestamp}"`);
63722
- if (fromBlock)
63723
- conditions.push(`blockNumber_gte: "${fromBlock}"`);
63724
- if (toBlock)
63725
- conditions.push(`blockNumber_lte: "${toBlock}"`);
63726
- return `where: { ${conditions.join(", ")} }`;
64970
+ positionCreated: true,
64971
+ payment: true,
64972
+ status: true,
64973
+ liquidation: true,
64974
+ mint: true,
64975
+ withdrawal: true,
64976
+ renewal: true,
64977
+ operationFailure: true,
64978
+ mintRequest: true,
64979
+ burnRequest: true,
64980
+ collateralEvent: true,
64981
+ mintingFee: true,
64982
+ renewalFee: true
63727
64983
  };
63728
64984
  const query = `
63729
64985
  query GetLoanEvents($positionId: Bytes!, $limit: Int!, $orderDirection: OrderDirection!) {
@@ -63959,10 +65215,50 @@ var DiamondHandsGraph = class {
63959
65215
  `;
63960
65216
  const variables = {
63961
65217
  positionId: positionId.toLowerCase(),
63962
- limit,
65218
+ limit: pageSize,
63963
65219
  orderDirection
63964
65220
  };
63965
65221
  const result = await this.client.execute(query, variables);
65222
+ if (hasBounds) {
65223
+ const collections = [
65224
+ ["payments", result.position?.payments],
65225
+ ["statusUpdates", result.position?.statusUpdates],
65226
+ ["withdrawals", result.position?.withdrawals],
65227
+ ["renewals", result.position?.renewals],
65228
+ ["operationFailures", result.position?.operationFailures],
65229
+ ["mintRequests", result.position?.mintRequests],
65230
+ ["burnRequests", result.position?.burnRequests],
65231
+ ["mintingFees", result.position?.mintingFees],
65232
+ ["renewalFees", result.position?.renewalFees],
65233
+ ["mints", result.ucdmintEvents],
65234
+ ["collateralEvents", result.collateralEvents]
65235
+ ];
65236
+ const saturated = collections.filter(([, list]) => (list?.length ?? 0) >= pageSize).map(([name]) => name);
65237
+ if (saturated.length > 0) {
65238
+ log.warn(
65239
+ "[DiamondHandsGraph] bounded getLoanEvents page saturated \u2014 the filtered history may be incomplete",
65240
+ { positionId, pageSize, saturated }
65241
+ );
65242
+ }
65243
+ }
65244
+ const assembled = this.assembleLoanEvents(positionId, result);
65245
+ return applyLoanEventsFilter(assembled, {
65246
+ wantsEvent,
65247
+ fromTimestamp,
65248
+ toTimestamp,
65249
+ fromBlock,
65250
+ toBlock,
65251
+ limit
65252
+ });
65253
+ }
65254
+ /**
65255
+ * Map one position's raw event payload into `LoanEvents`.
65256
+ *
65257
+ * Extracted verbatim from getLoanEvents so the wallet-collapsed path produces
65258
+ * byte-identical objects by construction rather than by a second implementation
65259
+ * that has to be kept in step by hand.
65260
+ */
65261
+ assembleLoanEvents(positionId, result) {
63966
65262
  const rawCreated = result.positionCreatedEvents?.[0];
63967
65263
  const positionCreated = rawCreated ? {
63968
65264
  id: rawCreated.id,
@@ -64167,7 +65463,22 @@ var DiamondHandsGraph = class {
64167
65463
  * @returns One LoanEvents object per position; empty array if the wallet has none.
64168
65464
  */
64169
65465
  async getWalletLoanEvents(userAddress, filter2) {
64170
- const { positions } = await this.getUserPositions(userAddress);
65466
+ if (!hasLoanEventsFilter(filter2)) {
65467
+ return this.getWalletLoanEventsCollapsed(userAddress);
65468
+ }
65469
+ return this.getWalletLoanEventsFanout(userAddress, filter2);
65470
+ }
65471
+ /**
65472
+ * The per-position path: enumerate the wallet's positions, then one `GetLoanEvents` each.
65473
+ *
65474
+ * Used for filtered calls, and as the completeness fallback when the collapsed document
65475
+ * hits a page limit. Costs `1 + N` requests, which is exactly why it is not the default.
65476
+ */
65477
+ async getWalletLoanEventsFanout(userAddress, filter2) {
65478
+ const positions = await this.getUserPositionsOnly(
65479
+ userAddress,
65480
+ THE_GRAPH_MAX_BATCH_SIZE
65481
+ );
64171
65482
  const positionIds = positions.map((p) => p?.id != null ? String(p.id) : "").filter((id) => id.length > 0);
64172
65483
  if (positionIds.length === 0)
64173
65484
  return [];
@@ -64182,6 +65493,81 @@ var DiamondHandsGraph = class {
64182
65493
  }
64183
65494
  return results;
64184
65495
  }
65496
+ /**
65497
+ * The whole wallet's event history in ONE request.
65498
+ *
65499
+ * Replaces `1 + N` round trips (one position enumeration plus one per position) with a
65500
+ * single document. Measured on Sepolia: a wallet holding 44 positions cost 46 requests
65501
+ * per activity refresh against a per-wallet budget of 30/min — this makes it 1.
65502
+ *
65503
+ * Three subgraph facts make it possible, all verified against the deployed schema rather
65504
+ * than assumed:
65505
+ * - ten event collections are `@derivedFrom` on Position, so they nest under a
65506
+ * borrower-filtered `positions(...)`;
65507
+ * - `positionCreatedEvents` is ALSO derived on Position — `getLoanEvents` queries it
65508
+ * top-level, which it never needed to;
65509
+ * - `ucdmintEvents` / `collateralEvents` are not derived and carry no `borrower`
65510
+ * field, but graph-node's nested `position_: { borrower }` filter reaches them.
65511
+ * Without that last one this would be two requests, not one.
65512
+ */
65513
+ async getWalletLoanEventsCollapsed(userAddress) {
65514
+ const borrower = userAddress.toLowerCase();
65515
+ const pageSize = THE_GRAPH_MAX_BATCH_SIZE;
65516
+ const result = await this.client.execute(
65517
+ WALLET_LOAN_EVENTS_QUERY,
65518
+ {
65519
+ borrower,
65520
+ first: pageSize,
65521
+ limit: pageSize,
65522
+ orderDirection: "desc"
65523
+ }
65524
+ );
65525
+ const positions = result.positions || [];
65526
+ const ucdmintEvents = result.ucdmintEvents || [];
65527
+ const collateralEvents = result.collateralEvents || [];
65528
+ const truncated = positions.length >= pageSize || ucdmintEvents.length >= pageSize || collateralEvents.length >= pageSize;
65529
+ if (truncated) {
65530
+ log.warn(
65531
+ "[DiamondHandsGraph] wallet event page limit reached \u2014 falling back to the per-position path to avoid returning a partial history",
65532
+ {
65533
+ borrower,
65534
+ pageSize,
65535
+ positions: positions.length,
65536
+ ucdmintEvents: ucdmintEvents.length,
65537
+ collateralEvents: collateralEvents.length
65538
+ }
65539
+ );
65540
+ return this.getWalletLoanEventsFanout(userAddress);
65541
+ }
65542
+ if (positions.length === 0)
65543
+ return [];
65544
+ const mintsByPosition = /* @__PURE__ */ new Map();
65545
+ for (const m of result.ucdmintEvents || []) {
65546
+ const key = m.position?.id;
65547
+ if (!key)
65548
+ continue;
65549
+ const bucket = mintsByPosition.get(key) || [];
65550
+ bucket.push(m);
65551
+ mintsByPosition.set(key, bucket);
65552
+ }
65553
+ const collateralByPosition = /* @__PURE__ */ new Map();
65554
+ for (const c of result.collateralEvents || []) {
65555
+ const key = c.position?.id;
65556
+ if (!key)
65557
+ continue;
65558
+ const bucket = collateralByPosition.get(key) || [];
65559
+ bucket.push(c);
65560
+ collateralByPosition.set(key, bucket);
65561
+ }
65562
+ return positions.map(
65563
+ (p) => this.assembleLoanEvents(p.id, {
65564
+ position: p,
65565
+ positionCreatedEvents: p.positionCreatedEvents || [],
65566
+ ucdmintEvents: mintsByPosition.get(p.id) || [],
65567
+ collateralEvents: collateralByPosition.get(p.id) || []
65568
+ })
65569
+ );
65570
+ }
64185
65571
  // ============================================================================
64186
65572
  // Protocol-wide Events
64187
65573
  // ============================================================================
@@ -69041,16 +70427,6 @@ function createMockTokenManager(config) {
69041
70427
  }
69042
70428
  }
69043
70429
  var import_dh_lit_actions2 = __toESM2(require_pkg_src2());
69044
- var TelegramBot = null;
69045
- try {
69046
- if (typeof window === "undefined" && typeof global !== "undefined") {
69047
- TelegramBot = __require("node-telegram-bot-api");
69048
- }
69049
- } catch (error) {
69050
- log.warn("Telegram bot API not available", {
69051
- error: error instanceof Error ? error.message : String(error)
69052
- });
69053
- }
69054
70430
  function formatMintMessage(mintAmount, loanId, txHash) {
69055
70431
  return `\u2705 DH SDK: ${mintAmount} UCD was minted for loan id: ${loanId} Tx: https://sepolia.etherscan.io/tx/${txHash}`;
69056
70432
  }
@@ -69676,7 +71052,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
69676
71052
  persistSession: config.sessionPersistence?.enabled,
69677
71053
  sessionStore: config.sessionPersistence?.store,
69678
71054
  onSignaturePrompt: config.onSessionSignaturePrompt,
69679
- onSignatureResolved: config.onSessionSignatureResolved
71055
+ onSignatureResolved: config.onSessionSignatureResolved,
71056
+ onSessionRestored: config.onSessionRestored
69680
71057
  });
69681
71058
  }
69682
71059
  const contractManagerResult = createContractManager({
@@ -83319,7 +84696,7 @@ mime-types/index.js:
83319
84696
  *)
83320
84697
 
83321
84698
  axios/dist/node/axios.cjs:
83322
- (*! Axios v1.19.0 Copyright (c) 2026 Matt Zabriskie and contributors *)
84699
+ (*! Axios v1.20.0 Copyright (c) 2026 Matt Zabriskie and contributors *)
83323
84700
 
83324
84701
  safe-buffer/index.js:
83325
84702
  (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)