@gardenfi/utils 2.0.6-beta.8 → 2.0.6-beta.9

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.
Files changed (123) hide show
  1. package/dist/index100.cjs +1 -1
  2. package/dist/index100.js +5 -11
  3. package/dist/index101.cjs +1 -1
  4. package/dist/index101.js +10 -11
  5. package/dist/index102.cjs +1 -1
  6. package/dist/index102.js +2 -20
  7. package/dist/index103.cjs +1 -1
  8. package/dist/index103.js +1 -1
  9. package/dist/index104.cjs +1 -1
  10. package/dist/index104.js +1 -1
  11. package/dist/index106.cjs +1 -1
  12. package/dist/index106.js +1 -1
  13. package/dist/index15.cjs +1 -1
  14. package/dist/index15.js +1 -1
  15. package/dist/index20.cjs +1 -1
  16. package/dist/index20.js +1 -1
  17. package/dist/index21.cjs +16 -1
  18. package/dist/index21.js +113 -30
  19. package/dist/index22.cjs +1 -16
  20. package/dist/index22.js +30 -113
  21. package/dist/index24.cjs +1 -1
  22. package/dist/index24.js +1 -1
  23. package/dist/index25.cjs +1 -1
  24. package/dist/index25.js +2 -2
  25. package/dist/index30.cjs +1 -1
  26. package/dist/index30.js +1 -1
  27. package/dist/index33.cjs +1 -1
  28. package/dist/index33.js +1 -1
  29. package/dist/index35.cjs +1 -1
  30. package/dist/index35.js +2 -2
  31. package/dist/index38.cjs +1 -1
  32. package/dist/index38.js +1 -1
  33. package/dist/index41.cjs +1 -1
  34. package/dist/index41.js +1 -1
  35. package/dist/index50.cjs +1 -1
  36. package/dist/index50.js +1 -1
  37. package/dist/index51.cjs +1 -1
  38. package/dist/index51.js +1 -1
  39. package/dist/index53.cjs +1 -1
  40. package/dist/index53.js +3 -3
  41. package/dist/index54.cjs +1 -1
  42. package/dist/index54.js +1 -1
  43. package/dist/index55.cjs +1 -1
  44. package/dist/index55.js +1 -1
  45. package/dist/index56.cjs +1 -1
  46. package/dist/index56.js +1 -1
  47. package/dist/index57.cjs +1 -1
  48. package/dist/index57.js +7 -7
  49. package/dist/index58.cjs +1 -1
  50. package/dist/index58.js +3 -3
  51. package/dist/index59.cjs +1 -1
  52. package/dist/index59.js +1 -1
  53. package/dist/index60.cjs +1 -1
  54. package/dist/index60.js +6 -12
  55. package/dist/index61.cjs +1 -1
  56. package/dist/index61.js +10 -32
  57. package/dist/index62.cjs +1 -1
  58. package/dist/index62.js +34 -6
  59. package/dist/index63.cjs +1 -2
  60. package/dist/index63.js +8 -59
  61. package/dist/index64.cjs +2 -1
  62. package/dist/index64.js +60 -2
  63. package/dist/index65.cjs +1 -1
  64. package/dist/index65.js +2 -7
  65. package/dist/index66.cjs +1 -1
  66. package/dist/index66.js +6 -4
  67. package/dist/index67.cjs +1 -1
  68. package/dist/index67.js +4 -11
  69. package/dist/index68.cjs +1 -5
  70. package/dist/index68.js +11 -56
  71. package/dist/index69.cjs +5 -2
  72. package/dist/index69.js +48 -26
  73. package/dist/index70.cjs +1 -1
  74. package/dist/index70.js +3 -5
  75. package/dist/index71.cjs +2 -1
  76. package/dist/index71.js +34 -3
  77. package/dist/index72.cjs +1 -1
  78. package/dist/index72.js +5 -21
  79. package/dist/index73.cjs +1 -1
  80. package/dist/index73.js +21 -8
  81. package/dist/index74.cjs +1 -1
  82. package/dist/index74.js +8 -10
  83. package/dist/index75.cjs +1 -1
  84. package/dist/index75.js +10 -11
  85. package/dist/index76.cjs +1 -1
  86. package/dist/index76.js +11 -6
  87. package/dist/index77.cjs +1 -1
  88. package/dist/index77.js +6 -13
  89. package/dist/index78.cjs +1 -1
  90. package/dist/index78.js +12 -31
  91. package/dist/index79.cjs +1 -1
  92. package/dist/index79.js +32 -14
  93. package/dist/index80.cjs +1 -1
  94. package/dist/index80.js +14 -64
  95. package/dist/index81.cjs +1 -1
  96. package/dist/index81.js +61 -24
  97. package/dist/index82.cjs +1 -1
  98. package/dist/index82.js +28 -3
  99. package/dist/index83.cjs +1 -1
  100. package/dist/index83.js +3 -4
  101. package/dist/index84.cjs +1 -1
  102. package/dist/index84.js +3 -8
  103. package/dist/index85.cjs +1 -1
  104. package/dist/index85.js +8 -191
  105. package/dist/index86.cjs +1 -1
  106. package/dist/index86.js +191 -18
  107. package/dist/index87.cjs +1 -1
  108. package/dist/index87.js +18 -8
  109. package/dist/index9.cjs +1 -1
  110. package/dist/index9.js +1 -1
  111. package/dist/index91.cjs +1 -1
  112. package/dist/index91.js +1 -1
  113. package/dist/index94.cjs +1 -1
  114. package/dist/index94.js +6 -6
  115. package/dist/index96.cjs +1 -1
  116. package/dist/index96.js +10 -11
  117. package/dist/index97.cjs +1 -1
  118. package/dist/index97.js +18 -37
  119. package/dist/index98.cjs +1 -1
  120. package/dist/index98.js +39 -2
  121. package/dist/index99.cjs +1 -1
  122. package/dist/index99.js +13 -5
  123. package/package.json +1 -1
package/dist/index9.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index17.cjs"),f=require("./index13.cjs"),h=require("./index14.cjs"),d=require("viem"),o=require("./index3.cjs"),g=require("./index7.cjs"),w=require("./index19.cjs"),m=require("./index20.cjs"),y=require("./index22.cjs");class c{constructor(n,i,e){this.API=new g.Url("https://api.garden.finance"),this.url=n??this.API,this.walletClient=i,this.domain=(e==null?void 0:e.domain)||"app.garden.finance",this.domain.startsWith("https://")&&(this.domain=this.domain.split("https://")[1]),this.signingStatement=(e==null?void 0:e.signingStatement)??"Garden.fi",this.store=(e==null?void 0:e.store)??new f.MemoryStorage}static fromDigestKey(n,i,e){const r=d.createWalletClient({account:w.privateKeyToAccount(o.add0x(i.digestKey)),transport:d.http(),chain:m.mainnet});return new c(n,r,e)}verifyToken(n,i){try{const e=o.parseJwt(n);if(!e)return t.Ok(!1);const r=Math.floor(Date.now()/1e3)+120;return t.Ok(e.exp>r&&e.user_id.toLowerCase()===i.toLowerCase())}catch{return t.Ok(!1)}}async getToken(){var a;if(!((a=this.walletClient.account)!=null&&a.address))return t.Err("Wallet client does not have an account");const n=this.store.getItem(h.StoreKeys.AUTH_TOKEN);if(n){const s=this.verifyToken(n,this.walletClient.account.address);if(s.ok&&s.val)return t.Ok(n)}const i=await this.signStatement();if(i.error)return t.Err(i.error);const e=await t.Fetcher.post(this.url.endpoint("verify"),{body:JSON.stringify({...i.val}),headers:{"Content-Type":"application/json"}});if(e.error)return t.Err(e.error);const r=e.result;if(!r)return t.Err("Failed to get token");if(!this.verifyToken(r,this.walletClient.account.address).val)throw new Error("Token verification failed");return this.store.setItem(h.StoreKeys.AUTH_TOKEN,r),t.Ok(r)}async signStatement(){var u;if(!((u=this.walletClient.account)!=null&&u.address))return t.Err("Wallet client does not have a valid account");const n=new Date,i=new Date(n.getTime()+300*1e3),r=(await t.Fetcher.get(this.url.endpoint("nonce"))).result;if(!r)return t.Err("Failed to get nonce");const l=await this.walletClient.getChainId(),a=y.createSiweMessage({domain:this.domain,address:this.walletClient.account.address,statement:this.signingStatement,nonce:r,uri:"https://"+this.domain,version:"1",chainId:l,notBefore:i}),s=await this.walletClient.signMessage({account:this.walletClient.account,message:a});return t.Ok({message:a,signature:s,nonce:r})}async getAuthHeaders(){const n=await this.getToken();return n.error?t.Err(n.error):t.Ok({Authorization:o.Authorization(n.val)})}}exports.Siwe=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index17.cjs"),f=require("./index13.cjs"),h=require("./index14.cjs"),d=require("viem"),o=require("./index3.cjs"),g=require("./index7.cjs"),w=require("./index19.cjs"),m=require("./index20.cjs"),y=require("./index21.cjs");class c{constructor(n,i,e){this.API=new g.Url("https://api.garden.finance"),this.url=n??this.API,this.walletClient=i,this.domain=(e==null?void 0:e.domain)||"app.garden.finance",this.domain.startsWith("https://")&&(this.domain=this.domain.split("https://")[1]),this.signingStatement=(e==null?void 0:e.signingStatement)??"Garden.fi",this.store=(e==null?void 0:e.store)??new f.MemoryStorage}static fromDigestKey(n,i,e){const r=d.createWalletClient({account:w.privateKeyToAccount(o.add0x(i.digestKey)),transport:d.http(),chain:m.mainnet});return new c(n,r,e)}verifyToken(n,i){try{const e=o.parseJwt(n);if(!e)return t.Ok(!1);const r=Math.floor(Date.now()/1e3)+120;return t.Ok(e.exp>r&&e.user_id.toLowerCase()===i.toLowerCase())}catch{return t.Ok(!1)}}async getToken(){var a;if(!((a=this.walletClient.account)!=null&&a.address))return t.Err("Wallet client does not have an account");const n=this.store.getItem(h.StoreKeys.AUTH_TOKEN);if(n){const s=this.verifyToken(n,this.walletClient.account.address);if(s.ok&&s.val)return t.Ok(n)}const i=await this.signStatement();if(i.error)return t.Err(i.error);const e=await t.Fetcher.post(this.url.endpoint("verify"),{body:JSON.stringify({...i.val}),headers:{"Content-Type":"application/json"}});if(e.error)return t.Err(e.error);const r=e.result;if(!r)return t.Err("Failed to get token");if(!this.verifyToken(r,this.walletClient.account.address).val)throw new Error("Token verification failed");return this.store.setItem(h.StoreKeys.AUTH_TOKEN,r),t.Ok(r)}async signStatement(){var u;if(!((u=this.walletClient.account)!=null&&u.address))return t.Err("Wallet client does not have a valid account");const n=new Date,i=new Date(n.getTime()+300*1e3),r=(await t.Fetcher.get(this.url.endpoint("nonce"))).result;if(!r)return t.Err("Failed to get nonce");const l=await this.walletClient.getChainId(),a=y.createSiweMessage({domain:this.domain,address:this.walletClient.account.address,statement:this.signingStatement,nonce:r,uri:"https://"+this.domain,version:"1",chainId:l,notBefore:i}),s=await this.walletClient.signMessage({account:this.walletClient.account,message:a});return t.Ok({message:a,signature:s,nonce:r})}async getAuthHeaders(){const n=await this.getToken();return n.error?t.Err(n.error):t.Ok({Authorization:o.Authorization(n.val)})}}exports.Siwe=c;
package/dist/index9.js CHANGED
@@ -6,7 +6,7 @@ import { add0x as g, parseJwt as y, Authorization as p } from "./index3.js";
6
6
  import { Url as v } from "./index7.js";
7
7
  import { privateKeyToAccount as T } from "./index19.js";
8
8
  import { mainnet as k } from "./index20.js";
9
- import { createSiweMessage as C } from "./index22.js";
9
+ import { createSiweMessage as C } from "./index21.js";
10
10
  class m {
11
11
  constructor(e, i, t) {
12
12
  this.API = new v("https://api.garden.finance"), this.url = e ?? this.API, this.walletClient = i, this.domain = (t == null ? void 0 : t.domain) || "app.garden.finance", this.domain.startsWith("https://") && (this.domain = this.domain.split("https://")[1]), this.signingStatement = (t == null ? void 0 : t.signingStatement) ?? "Garden.fi", this.store = (t == null ? void 0 : t.store) ?? new u();
package/dist/index91.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index63.cjs"),u=require("./index107.cjs"),f=require("./index53.cjs"),g=require("./index25.cjs");function c(n,e="hex"){const i=o(n),s=u.createCursor(new Uint8Array(i.length));return i.encode(s),e==="hex"?g.bytesToHex(s.bytes):s.bytes}function o(n){return Array.isArray(n)?p(n.map(e=>o(e))):y(n)}function p(n){const e=n.reduce((t,h)=>t+h.length,0),i=l(e);return{length:e<=55?1+e:1+i+e,encode(t){e<=55?t.pushByte(192+e):(t.pushByte(247+i),i===1?t.pushUint8(e):i===2?t.pushUint16(e):i===3?t.pushUint24(e):t.pushUint32(e));for(const{encode:h}of n)h(t)}}}function y(n){const e=typeof n=="string"?f.hexToBytes(n):n,i=l(e.length);return{length:e.length===1&&e[0]<128?1:e.length<=55?1+e.length:1+i+e.length,encode(t){e.length===1&&e[0]<128?t.pushBytes(e):e.length<=55?(t.pushByte(128+e.length),t.pushBytes(e)):(t.pushByte(183+i),i===1?t.pushUint8(e.length):i===2?t.pushUint16(e.length):i===3?t.pushUint24(e.length):t.pushUint32(e.length),t.pushBytes(e))}}}function l(n){if(n<2**8)return 1;if(n<2**16)return 2;if(n<2**24)return 3;if(n<2**32)return 4;throw new r.BaseError("Length is too large.")}exports.toRlp=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index64.cjs"),u=require("./index107.cjs"),f=require("./index53.cjs"),g=require("./index25.cjs");function c(n,e="hex"){const i=o(n),s=u.createCursor(new Uint8Array(i.length));return i.encode(s),e==="hex"?g.bytesToHex(s.bytes):s.bytes}function o(n){return Array.isArray(n)?p(n.map(e=>o(e))):y(n)}function p(n){const e=n.reduce((t,h)=>t+h.length,0),i=l(e);return{length:e<=55?1+e:1+i+e,encode(t){e<=55?t.pushByte(192+e):(t.pushByte(247+i),i===1?t.pushUint8(e):i===2?t.pushUint16(e):i===3?t.pushUint24(e):t.pushUint32(e));for(const{encode:h}of n)h(t)}}}function y(n){const e=typeof n=="string"?f.hexToBytes(n):n,i=l(e.length);return{length:e.length===1&&e[0]<128?1:e.length<=55?1+e.length:1+i+e.length,encode(t){e.length===1&&e[0]<128?t.pushBytes(e):e.length<=55?(t.pushByte(128+e.length),t.pushBytes(e)):(t.pushByte(183+i),i===1?t.pushUint8(e.length):i===2?t.pushUint16(e.length):i===3?t.pushUint24(e.length):t.pushUint32(e.length),t.pushBytes(e))}}}function l(n){if(n<2**8)return 1;if(n<2**16)return 2;if(n<2**24)return 3;if(n<2**32)return 4;throw new r.BaseError("Length is too large.")}exports.toRlp=c;
package/dist/index91.js CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseError as l } from "./index63.js";
1
+ import { BaseError as l } from "./index64.js";
2
2
  import { createCursor as r } from "./index107.js";
3
3
  import { hexToBytes as g } from "./index53.js";
4
4
  import { bytesToHex as u } from "./index25.js";
package/dist/index94.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./index108.cjs"),w=require("./index98.cjs"),t=require("./index50.cjs"),P=require("./index63.cjs"),h=require("./index106.cjs"),d=require("./index65.cjs"),n=require("./index69.cjs"),c=require("./index51.cjs"),I=require("./index66.cjs"),u=require("./index97.cjs"),l=require("./index35.cjs");function m(o){const{authorizationList:e}=o;if(e)for(const s of e){const{contractAddress:r,chainId:i}=s;if(!c.isAddress(r))throw new t.InvalidAddressError({address:r});if(i<0)throw new d.InvalidChainIdError({chainId:i})}f(o)}function T(o){const{blobVersionedHashes:e}=o;if(e){if(e.length===0)throw new h.EmptyBlobError;for(const s of e){const r=I.size(s),i=l.hexToNumber(u.slice(s,0,1));if(r!==32)throw new h.InvalidVersionedHashSizeError({hash:s,size:r});if(i!==E.versionedHashVersionKzg)throw new h.InvalidVersionedHashVersionError({hash:s,version:i})}}f(o)}function f(o){const{chainId:e,maxPriorityFeePerGas:s,maxFeePerGas:r,to:i}=o;if(e<=0)throw new d.InvalidChainIdError({chainId:e});if(i&&!c.isAddress(i))throw new t.InvalidAddressError({address:i});if(r&&r>w.maxUint256)throw new n.FeeCapTooHighError({maxFeePerGas:r});if(s&&r&&s>r)throw new n.TipAboveFeeCapError({maxFeePerGas:r,maxPriorityFeePerGas:s})}function x(o){const{chainId:e,maxPriorityFeePerGas:s,gasPrice:r,maxFeePerGas:i,to:a}=o;if(e<=0)throw new d.InvalidChainIdError({chainId:e});if(a&&!c.isAddress(a))throw new t.InvalidAddressError({address:a});if(s||i)throw new P.BaseError("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(r&&r>w.maxUint256)throw new n.FeeCapTooHighError({maxFeePerGas:r})}function v(o){const{chainId:e,maxPriorityFeePerGas:s,gasPrice:r,maxFeePerGas:i,to:a}=o;if(a&&!c.isAddress(a))throw new t.InvalidAddressError({address:a});if(typeof e<"u"&&e<=0)throw new d.InvalidChainIdError({chainId:e});if(s||i)throw new P.BaseError("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(r&&r>w.maxUint256)throw new n.FeeCapTooHighError({maxFeePerGas:r})}exports.assertTransactionEIP1559=f;exports.assertTransactionEIP2930=x;exports.assertTransactionEIP4844=T;exports.assertTransactionEIP7702=m;exports.assertTransactionLegacy=v;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./index108.cjs"),w=require("./index102.cjs"),t=require("./index50.cjs"),P=require("./index64.cjs"),h=require("./index106.cjs"),d=require("./index66.cjs"),n=require("./index71.cjs"),c=require("./index51.cjs"),I=require("./index67.cjs"),u=require("./index98.cjs"),l=require("./index35.cjs");function m(o){const{authorizationList:e}=o;if(e)for(const s of e){const{contractAddress:r,chainId:i}=s;if(!c.isAddress(r))throw new t.InvalidAddressError({address:r});if(i<0)throw new d.InvalidChainIdError({chainId:i})}f(o)}function T(o){const{blobVersionedHashes:e}=o;if(e){if(e.length===0)throw new h.EmptyBlobError;for(const s of e){const r=I.size(s),i=l.hexToNumber(u.slice(s,0,1));if(r!==32)throw new h.InvalidVersionedHashSizeError({hash:s,size:r});if(i!==E.versionedHashVersionKzg)throw new h.InvalidVersionedHashVersionError({hash:s,version:i})}}f(o)}function f(o){const{chainId:e,maxPriorityFeePerGas:s,maxFeePerGas:r,to:i}=o;if(e<=0)throw new d.InvalidChainIdError({chainId:e});if(i&&!c.isAddress(i))throw new t.InvalidAddressError({address:i});if(r&&r>w.maxUint256)throw new n.FeeCapTooHighError({maxFeePerGas:r});if(s&&r&&s>r)throw new n.TipAboveFeeCapError({maxFeePerGas:r,maxPriorityFeePerGas:s})}function x(o){const{chainId:e,maxPriorityFeePerGas:s,gasPrice:r,maxFeePerGas:i,to:a}=o;if(e<=0)throw new d.InvalidChainIdError({chainId:e});if(a&&!c.isAddress(a))throw new t.InvalidAddressError({address:a});if(s||i)throw new P.BaseError("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(r&&r>w.maxUint256)throw new n.FeeCapTooHighError({maxFeePerGas:r})}function v(o){const{chainId:e,maxPriorityFeePerGas:s,gasPrice:r,maxFeePerGas:i,to:a}=o;if(a&&!c.isAddress(a))throw new t.InvalidAddressError({address:a});if(typeof e<"u"&&e<=0)throw new d.InvalidChainIdError({chainId:e});if(s||i)throw new P.BaseError("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(r&&r>w.maxUint256)throw new n.FeeCapTooHighError({maxFeePerGas:r})}exports.assertTransactionEIP1559=f;exports.assertTransactionEIP2930=x;exports.assertTransactionEIP4844=T;exports.assertTransactionEIP7702=m;exports.assertTransactionLegacy=v;
package/dist/index94.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { versionedHashVersionKzg as d } from "./index108.js";
2
- import { maxUint256 as m } from "./index98.js";
2
+ import { maxUint256 as m } from "./index102.js";
3
3
  import { InvalidAddressError as s } from "./index50.js";
4
- import { BaseError as h } from "./index63.js";
4
+ import { BaseError as h } from "./index64.js";
5
5
  import { EmptyBlobError as P, InvalidVersionedHashSizeError as p, InvalidVersionedHashVersionError as x } from "./index106.js";
6
- import { InvalidChainIdError as n } from "./index65.js";
7
- import { FeeCapTooHighError as w, TipAboveFeeCapError as E } from "./index69.js";
6
+ import { InvalidChainIdError as n } from "./index66.js";
7
+ import { FeeCapTooHighError as w, TipAboveFeeCapError as E } from "./index71.js";
8
8
  import { isAddress as f } from "./index51.js";
9
- import { size as F } from "./index66.js";
10
- import { slice as I } from "./index97.js";
9
+ import { size as F } from "./index67.js";
10
+ import { slice as I } from "./index98.js";
11
11
  import { hexToNumber as G } from "./index35.js";
12
12
  function C(t) {
13
13
  const { authorizationList: e } = t;
package/dist/index96.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index63.cjs");class i extends t.BaseError{constructor({offset:r,position:s,size:e}){super(`Slice ${s==="start"?"starting":"ending"} at offset "${r}" is out-of-bounds (size: ${e}).`,{name:"SliceOffsetOutOfBoundsError"})}}class d extends t.BaseError{constructor({size:r,targetSize:s,type:e}){super(`${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()} size (${r}) exceeds padding size (${s}).`,{name:"SizeExceedsPaddingSizeError"})}}exports.SizeExceedsPaddingSizeError=d;exports.SliceOffsetOutOfBoundsError=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index64.cjs");class t extends a.BaseError{constructor(e){const{docsPath:s,field:r,metaMessages:i}=e;super(`Invalid Sign-In with Ethereum message field "${r}".`,{docsPath:s,metaMessages:i,name:"SiweInvalidMessageFieldError"})}}exports.SiweInvalidMessageFieldError=t;
package/dist/index96.js CHANGED
@@ -1,15 +1,14 @@
1
- import { BaseError as o } from "./index63.js";
2
- class d extends o {
3
- constructor({ offset: r, position: s, size: e }) {
4
- super(`Slice ${s === "start" ? "starting" : "ending"} at offset "${r}" is out-of-bounds (size: ${e}).`, { name: "SliceOffsetOutOfBoundsError" });
5
- }
6
- }
7
- class n extends o {
8
- constructor({ size: r, targetSize: s, type: e }) {
9
- super(`${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()} size (${r}) exceeds padding size (${s}).`, { name: "SizeExceedsPaddingSizeError" });
1
+ import { BaseError as i } from "./index64.js";
2
+ class d extends i {
3
+ constructor(e) {
4
+ const { docsPath: s, field: r, metaMessages: a } = e;
5
+ super(`Invalid Sign-In with Ethereum message field "${r}".`, {
6
+ docsPath: s,
7
+ metaMessages: a,
8
+ name: "SiweInvalidMessageFieldError"
9
+ });
10
10
  }
11
11
  }
12
12
  export {
13
- n as SizeExceedsPaddingSizeError,
14
- d as SliceOffsetOutOfBoundsError
13
+ d as SiweInvalidMessageFieldError
15
14
  };
package/dist/index97.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index96.cjs"),O=require("./index83.cjs"),n=require("./index66.cjs");function p(i,e,s,{strict:f}={}){return O.isHex(i,{strict:!1})?l(i,e,s,{strict:f}):u(i,e,s,{strict:f})}function r(i,e){if(typeof e=="number"&&e>0&&e>n.size(i)-1)throw new t.SliceOffsetOutOfBoundsError({offset:e,position:"start",size:n.size(i)})}function c(i,e,s){if(typeof e=="number"&&typeof s=="number"&&n.size(i)!==s-e)throw new t.SliceOffsetOutOfBoundsError({offset:s,position:"end",size:n.size(i)})}function u(i,e,s,{strict:f}={}){r(i,e);const o=i.slice(e,s);return f&&c(o,e,s),o}function l(i,e,s,{strict:f}={}){r(i,e);const o=`0x${i.replace("0x","").slice((e??0)*2,(s??i.length)*2)}`;return f&&c(o,e,s),o}exports.slice=p;exports.sliceBytes=u;exports.sliceHex=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(e){if(/[^a-z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~\%]/i.test(e)||/%[^0-9a-f]/i.test(e)||/%[0-9a-f](:?[^0-9a-f]|$)/i.test(e))return!1;const s=a(e),f=s[1],t=s[2],i=s[3],r=s[4],l=s[5];if(!(f!=null&&f.length&&i.length>=0))return!1;if(t!=null&&t.length){if(!(i.length===0||/^\//.test(i)))return!1}else if(/^\/\//.test(i))return!1;if(!/^[a-z][a-z0-9\+\-\.]*$/.test(f.toLowerCase()))return!1;let n="";return n+=`${f}:`,t!=null&&t.length&&(n+=`//${t}`),n+=i,r!=null&&r.length&&(n+=`?${r}`),l!=null&&l.length&&(n+=`#${l}`),n}function a(e){return e.match(/(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/)}exports.isUri=o;
package/dist/index97.js CHANGED
@@ -1,41 +1,22 @@
1
- import { SliceOffsetOutOfBoundsError as t } from "./index96.js";
2
- import { isHex as p } from "./index83.js";
3
- import { size as r } from "./index66.js";
4
- function w(e, f, i, { strict: o } = {}) {
5
- return p(e, { strict: !1 }) ? u(e, f, i, {
6
- strict: o
7
- }) : m(e, f, i, {
8
- strict: o
9
- });
1
+ function o(e) {
2
+ if (/[^a-z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~\%]/i.test(e) || /%[^0-9a-f]/i.test(e) || /%[0-9a-f](:?[^0-9a-f]|$)/i.test(e))
3
+ return !1;
4
+ const s = a(e), f = s[1], t = s[2], i = s[3], r = s[4], l = s[5];
5
+ if (!(f != null && f.length && i.length >= 0))
6
+ return !1;
7
+ if (t != null && t.length) {
8
+ if (!(i.length === 0 || /^\//.test(i)))
9
+ return !1;
10
+ } else if (/^\/\//.test(i))
11
+ return !1;
12
+ if (!/^[a-z][a-z0-9\+\-\.]*$/.test(f.toLowerCase()))
13
+ return !1;
14
+ let n = "";
15
+ return n += `${f}:`, t != null && t.length && (n += `//${t}`), n += i, r != null && r.length && (n += `?${r}`), l != null && l.length && (n += `#${l}`), n;
10
16
  }
11
- function s(e, f) {
12
- if (typeof f == "number" && f > 0 && f > r(e) - 1)
13
- throw new t({
14
- offset: f,
15
- position: "start",
16
- size: r(e)
17
- });
18
- }
19
- function c(e, f, i) {
20
- if (typeof f == "number" && typeof i == "number" && r(e) !== i - f)
21
- throw new t({
22
- offset: i,
23
- position: "end",
24
- size: r(e)
25
- });
26
- }
27
- function m(e, f, i, { strict: o } = {}) {
28
- s(e, f);
29
- const n = e.slice(f, i);
30
- return o && c(n, f, i), n;
31
- }
32
- function u(e, f, i, { strict: o } = {}) {
33
- s(e, f);
34
- const n = `0x${e.replace("0x", "").slice((f ?? 0) * 2, (i ?? e.length) * 2)}`;
35
- return o && c(n, f, i), n;
17
+ function a(e) {
18
+ return e.match(/(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/);
36
19
  }
37
20
  export {
38
- w as slice,
39
- m as sliceBytes,
40
- u as sliceHex
21
+ o as isUri
41
22
  };
package/dist/index98.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=2n**256n-1n;exports.maxUint256=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index99.cjs"),O=require("./index84.cjs"),n=require("./index67.cjs");function p(i,e,s,{strict:f}={}){return O.isHex(i,{strict:!1})?l(i,e,s,{strict:f}):u(i,e,s,{strict:f})}function r(i,e){if(typeof e=="number"&&e>0&&e>n.size(i)-1)throw new t.SliceOffsetOutOfBoundsError({offset:e,position:"start",size:n.size(i)})}function c(i,e,s){if(typeof e=="number"&&typeof s=="number"&&n.size(i)!==s-e)throw new t.SliceOffsetOutOfBoundsError({offset:s,position:"end",size:n.size(i)})}function u(i,e,s,{strict:f}={}){r(i,e);const o=i.slice(e,s);return f&&c(o,e,s),o}function l(i,e,s,{strict:f}={}){r(i,e);const o=`0x${i.replace("0x","").slice((e??0)*2,(s??i.length)*2)}`;return f&&c(o,e,s),o}exports.slice=p;exports.sliceBytes=u;exports.sliceHex=l;
package/dist/index98.js CHANGED
@@ -1,4 +1,41 @@
1
- const n = 2n ** 256n - 1n;
1
+ import { SliceOffsetOutOfBoundsError as t } from "./index99.js";
2
+ import { isHex as p } from "./index84.js";
3
+ import { size as r } from "./index67.js";
4
+ function w(e, f, i, { strict: o } = {}) {
5
+ return p(e, { strict: !1 }) ? u(e, f, i, {
6
+ strict: o
7
+ }) : m(e, f, i, {
8
+ strict: o
9
+ });
10
+ }
11
+ function s(e, f) {
12
+ if (typeof f == "number" && f > 0 && f > r(e) - 1)
13
+ throw new t({
14
+ offset: f,
15
+ position: "start",
16
+ size: r(e)
17
+ });
18
+ }
19
+ function c(e, f, i) {
20
+ if (typeof f == "number" && typeof i == "number" && r(e) !== i - f)
21
+ throw new t({
22
+ offset: i,
23
+ position: "end",
24
+ size: r(e)
25
+ });
26
+ }
27
+ function m(e, f, i, { strict: o } = {}) {
28
+ s(e, f);
29
+ const n = e.slice(f, i);
30
+ return o && c(n, f, i), n;
31
+ }
32
+ function u(e, f, i, { strict: o } = {}) {
33
+ s(e, f);
34
+ const n = `0x${e.replace("0x", "").slice((f ?? 0) * 2, (i ?? e.length) * 2)}`;
35
+ return o && c(n, f, i), n;
36
+ }
2
37
  export {
3
- n as maxUint256
38
+ w as slice,
39
+ m as sliceBytes,
40
+ u as sliceHex
4
41
  };
package/dist/index99.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={ether:-9,wei:9};exports.gweiUnits=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index64.cjs");class i extends t.BaseError{constructor({offset:r,position:s,size:e}){super(`Slice ${s==="start"?"starting":"ending"} at offset "${r}" is out-of-bounds (size: ${e}).`,{name:"SliceOffsetOutOfBoundsError"})}}class d extends t.BaseError{constructor({size:r,targetSize:s,type:e}){super(`${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()} size (${r}) exceeds padding size (${s}).`,{name:"SizeExceedsPaddingSizeError"})}}exports.SizeExceedsPaddingSizeError=d;exports.SliceOffsetOutOfBoundsError=i;
package/dist/index99.js CHANGED
@@ -1,7 +1,15 @@
1
- const e = {
2
- ether: -9,
3
- wei: 9
4
- };
1
+ import { BaseError as o } from "./index64.js";
2
+ class d extends o {
3
+ constructor({ offset: r, position: s, size: e }) {
4
+ super(`Slice ${s === "start" ? "starting" : "ending"} at offset "${r}" is out-of-bounds (size: ${e}).`, { name: "SliceOffsetOutOfBoundsError" });
5
+ }
6
+ }
7
+ class n extends o {
8
+ constructor({ size: r, targetSize: s, type: e }) {
9
+ super(`${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()} size (${r}) exceeds padding size (${s}).`, { name: "SizeExceedsPaddingSizeError" });
10
+ }
11
+ }
5
12
  export {
6
- e as gweiUnits
13
+ n as SizeExceedsPaddingSizeError,
14
+ d as SliceOffsetOutOfBoundsError
7
15
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/utils",
3
- "version": "2.0.6-beta.8",
3
+ "version": "2.0.6-beta.9",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "vite build",