@gardenfi/utils 2.0.6 → 2.1.0-beta.2

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 (230) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.js +22 -20
  3. package/dist/index10.cjs +1 -1
  4. package/dist/index10.js +37 -19
  5. package/dist/index100.cjs +1 -1
  6. package/dist/index100.js +26 -126
  7. package/dist/index101.cjs +1 -1
  8. package/dist/index101.js +3 -113
  9. package/dist/index102.cjs +1 -1
  10. package/dist/index102.js +10 -77
  11. package/dist/index103.cjs +1 -1
  12. package/dist/index103.js +20 -2
  13. package/dist/index104.cjs +1 -1
  14. package/dist/index104.js +11 -16
  15. package/dist/index105.cjs +1 -1
  16. package/dist/index105.js +17 -17
  17. package/dist/index106.cjs +1 -1
  18. package/dist/index106.js +639 -12
  19. package/dist/index107.cjs +1 -1
  20. package/dist/index107.js +161 -212
  21. package/dist/index109.cjs +1 -1
  22. package/dist/index109.js +127 -34
  23. package/dist/index11.cjs +1 -1
  24. package/dist/index11.js +19 -134
  25. package/dist/index110.cjs +1 -1
  26. package/dist/index110.js +2 -19
  27. package/dist/index111.cjs +1 -1
  28. package/dist/index111.js +2 -70
  29. package/dist/index112.cjs +1 -1
  30. package/dist/index112.js +33 -63
  31. package/dist/index113.cjs +1 -1
  32. package/dist/index113.js +39 -2
  33. package/dist/index114.cjs +1 -1
  34. package/dist/index114.js +5 -41
  35. package/dist/index115.cjs +1 -1
  36. package/dist/index115.js +10 -643
  37. package/dist/index116.cjs +1 -1
  38. package/dist/index116.js +6 -231
  39. package/dist/index117.cjs +1 -1
  40. package/dist/index117.js +17 -169
  41. package/dist/index118.cjs +1 -0
  42. package/dist/index118.js +7 -0
  43. package/dist/index12.cjs +1 -1
  44. package/dist/index12.js +136 -10
  45. package/dist/index13.cjs +1 -1
  46. package/dist/index13.js +15 -2
  47. package/dist/index14.cjs +1 -1
  48. package/dist/index14.js +2 -34
  49. package/dist/index15.cjs +1 -1
  50. package/dist/index15.js +32 -17
  51. package/dist/index16.cjs +1 -1
  52. package/dist/index16.js +14 -183
  53. package/dist/index17.cjs +1 -1
  54. package/dist/index17.js +187 -92
  55. package/dist/index18.cjs +1 -1
  56. package/dist/index18.js +92 -34
  57. package/dist/index19.cjs +1 -1
  58. package/dist/index19.js +36 -32
  59. package/dist/index20.cjs +1 -16
  60. package/dist/index20.js +30 -112
  61. package/dist/index21.cjs +16 -1
  62. package/dist/index21.js +113 -30
  63. package/dist/index22.cjs +1 -1
  64. package/dist/index22.js +31 -18
  65. package/dist/index23.cjs +1 -1
  66. package/dist/index23.js +41 -7
  67. package/dist/index24.cjs +1 -1
  68. package/dist/index24.js +3 -3
  69. package/dist/index25.cjs +1 -1
  70. package/dist/index25.js +23 -19
  71. package/dist/index26.cjs +1 -1
  72. package/dist/index26.js +6 -8
  73. package/dist/index27.cjs +1 -1
  74. package/dist/index27.js +12 -30
  75. package/dist/index28.cjs +1 -1
  76. package/dist/index28.js +15 -26
  77. package/dist/index29.cjs +1 -2
  78. package/dist/index29.js +5 -65
  79. package/dist/index30.cjs +1 -1
  80. package/dist/index30.js +13 -51
  81. package/dist/index31.cjs +1 -1
  82. package/dist/index31.js +10 -12
  83. package/dist/index32.cjs +1 -1
  84. package/dist/index32.js +12 -24
  85. package/dist/index33.cjs +1 -1
  86. package/dist/index33.js +11 -75
  87. package/dist/index34.cjs +1 -1
  88. package/dist/index34.js +13 -23
  89. package/dist/index35.cjs +1 -1
  90. package/dist/index35.js +23 -7
  91. package/dist/index36.cjs +1 -1
  92. package/dist/index36.js +55 -32
  93. package/dist/index37.cjs +1 -1
  94. package/dist/index37.js +16 -15
  95. package/dist/index38.cjs +1 -1
  96. package/dist/index38.js +6 -2
  97. package/dist/index39.cjs +1 -1
  98. package/dist/index39.js +8 -8
  99. package/dist/index4.cjs +1 -1
  100. package/dist/index4.js +2 -2
  101. package/dist/index40.cjs +1 -1
  102. package/dist/index40.js +171 -20
  103. package/dist/index41.cjs +1 -1
  104. package/dist/index41.js +100 -9
  105. package/dist/index42.cjs +1 -1
  106. package/dist/index42.js +20 -33
  107. package/dist/index43.cjs +1 -2
  108. package/dist/index43.js +17 -59
  109. package/dist/index44.cjs +1 -1
  110. package/dist/index44.js +8 -2
  111. package/dist/index45.cjs +1 -1
  112. package/dist/index45.js +21 -6
  113. package/dist/index46.cjs +1 -1
  114. package/dist/index46.js +8 -6
  115. package/dist/index47.cjs +1 -1
  116. package/dist/index47.js +31 -4
  117. package/dist/index48.cjs +1 -1
  118. package/dist/index48.js +26 -11
  119. package/dist/index49.cjs +2 -5
  120. package/dist/index49.js +53 -44
  121. package/dist/index50.cjs +1 -2
  122. package/dist/index50.js +50 -33
  123. package/dist/index51.cjs +1 -1
  124. package/dist/index51.js +12 -5
  125. package/dist/index52.cjs +1 -1
  126. package/dist/index52.js +24 -3
  127. package/dist/index53.cjs +1 -1
  128. package/dist/index53.js +75 -21
  129. package/dist/index54.cjs +1 -1
  130. package/dist/index54.js +7 -12
  131. package/dist/index55.cjs +1 -1
  132. package/dist/index55.js +32 -55
  133. package/dist/index56.cjs +1 -1
  134. package/dist/index56.js +15 -8
  135. package/dist/index57.cjs +1 -1
  136. package/dist/index57.js +2 -22
  137. package/dist/index58.cjs +1 -1
  138. package/dist/index58.js +8 -11
  139. package/dist/index59.cjs +1 -1
  140. package/dist/index59.js +20 -8
  141. package/dist/index6.cjs +1 -1
  142. package/dist/index6.js +40 -22
  143. package/dist/index60.cjs +1 -1
  144. package/dist/index60.js +11 -9
  145. package/dist/index61.cjs +1 -1
  146. package/dist/index61.js +34 -11
  147. package/dist/index62.cjs +1 -1
  148. package/dist/index62.js +40 -6
  149. package/dist/index63.cjs +1 -1
  150. package/dist/index63.js +34 -13
  151. package/dist/index64.cjs +1 -1
  152. package/dist/index64.js +68 -31
  153. package/dist/index65.cjs +1 -1
  154. package/dist/index65.js +112 -14
  155. package/dist/index66.cjs +1 -1
  156. package/dist/index66.js +64 -61
  157. package/dist/index67.cjs +1 -1
  158. package/dist/index67.js +2 -28
  159. package/dist/index68.cjs +1 -1
  160. package/dist/index68.js +17 -3
  161. package/dist/index69.cjs +1 -1
  162. package/dist/index69.js +223 -3
  163. package/dist/index7.cjs +1 -1
  164. package/dist/index7.js +24 -2
  165. package/dist/index70.cjs +1 -1
  166. package/dist/index70.js +231 -13
  167. package/dist/index71.cjs +2 -1
  168. package/dist/index71.js +59 -41
  169. package/dist/index72.cjs +1 -1
  170. package/dist/index72.js +21 -5
  171. package/dist/index73.cjs +1 -1
  172. package/dist/index73.js +4 -8
  173. package/dist/index74.cjs +1 -1
  174. package/dist/index74.js +3 -103
  175. package/dist/index75.cjs +1 -1
  176. package/dist/index75.js +8 -191
  177. package/dist/index76.cjs +1 -1
  178. package/dist/index76.js +102 -16
  179. package/dist/index77.cjs +1 -1
  180. package/dist/index77.js +16 -10
  181. package/dist/index78.cjs +1 -1
  182. package/dist/index78.js +8 -19
  183. package/dist/index79.cjs +1 -1
  184. package/dist/index79.js +9 -11
  185. package/dist/index8.cjs +1 -1
  186. package/dist/index8.js +2 -100
  187. package/dist/index80.cjs +1 -1
  188. package/dist/index80.js +11 -25
  189. package/dist/index81.cjs +1 -1
  190. package/dist/index81.js +13 -6
  191. package/dist/index82.cjs +1 -1
  192. package/dist/index82.js +18 -13
  193. package/dist/index83.cjs +1 -1
  194. package/dist/index83.js +6 -15
  195. package/dist/index84.cjs +1 -1
  196. package/dist/index84.js +42 -5
  197. package/dist/index85.cjs +1 -1
  198. package/dist/index85.js +78 -13
  199. package/dist/index86.cjs +1 -1
  200. package/dist/index86.js +14 -10
  201. package/dist/index87.cjs +1 -1
  202. package/dist/index87.js +18 -16
  203. package/dist/index88.cjs +1 -1
  204. package/dist/index88.js +182 -162
  205. package/dist/index89.cjs +1 -1
  206. package/dist/index89.js +62 -36
  207. package/dist/index9.cjs +1 -1
  208. package/dist/index9.js +105 -34
  209. package/dist/index91.cjs +1 -1
  210. package/dist/index91.js +2 -5
  211. package/dist/index92.cjs +1 -1
  212. package/dist/index92.js +6 -10
  213. package/dist/index93.cjs +1 -1
  214. package/dist/index93.js +12 -2
  215. package/dist/index94.cjs +5 -1
  216. package/dist/index94.js +49 -97
  217. package/dist/index95.cjs +2 -1
  218. package/dist/index95.js +33 -41
  219. package/dist/index96.cjs +1 -1
  220. package/dist/index96.js +5 -20
  221. package/dist/index97.cjs +1 -1
  222. package/dist/index97.js +3 -6
  223. package/dist/index98.cjs +1 -1
  224. package/dist/index98.js +7 -5
  225. package/dist/index99.cjs +1 -1
  226. package/dist/index99.js +30 -35
  227. package/dist/src/index.d.ts +1 -0
  228. package/dist/src/lib/auth/siwe/siwe.d.ts +3 -2
  229. package/dist/src/lib/digestKey/digestKey.d.ts +12 -0
  230. package/package.json +4 -1
package/dist/index91.js CHANGED
@@ -1,7 +1,4 @@
1
- const e = {
2
- ether: -9,
3
- wei: 9
4
- };
1
+ const o = "2.26.3";
5
2
  export {
6
- e as gweiUnits
3
+ o as version
7
4
  };
package/dist/index92.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(r,i){let t=r.toString();const n=t.startsWith("-");n&&(t=t.slice(1)),t=t.padStart(i,"0");let[l,e]=[t.slice(0,t.length-i),t.slice(t.length-i)];return e=e.replace(/(0+)$/,""),`${n?"-":""}${l||"0"}${e?`.${e}`:""}`}exports.formatUnits=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index71.cjs");class i extends e.BaseError{constructor({chainId:r}){super(typeof r=="number"?`Chain ID "${r}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}exports.InvalidChainIdError=i;
package/dist/index92.js CHANGED
@@ -1,13 +1,9 @@
1
- function a(r, n) {
2
- let t = r.toString();
3
- const i = t.startsWith("-");
4
- i && (t = t.slice(1)), t = t.padStart(n, "0");
5
- let [l, e] = [
6
- t.slice(0, t.length - n),
7
- t.slice(t.length - n)
8
- ];
9
- return e = e.replace(/(0+)$/, ""), `${i ? "-" : ""}${l || "0"}${e ? `.${e}` : ""}`;
1
+ import { BaseError as i } from "./index71.js";
2
+ class o extends i {
3
+ constructor({ chainId: r }) {
4
+ super(typeof r == "number" ? `Chain ID "${r}" is invalid.` : "Chain ID is invalid.", { name: "InvalidChainIdError" });
5
+ }
10
6
  }
11
7
  export {
12
- a as formatUnits
8
+ o as InvalidChainIdError
13
9
  };
package/dist/index93.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"});function r(n,{args:a,eventName:t}={}){return{...n,blockHash:n.blockHash?n.blockHash:null,blockNumber:n.blockNumber?BigInt(n.blockNumber):null,logIndex:n.logIndex?Number(n.logIndex):null,transactionHash:n.transactionHash?n.transactionHash:null,transactionIndex:n.transactionIndex?Number(n.transactionIndex):null,...t?{args:a,eventName:t}:{}}}exports.formatLog=r;
package/dist/index93.js CHANGED
@@ -1,4 +1,14 @@
1
- const n = 2n ** 256n - 1n;
1
+ function r(n, { args: t, eventName: a } = {}) {
2
+ return {
3
+ ...n,
4
+ blockHash: n.blockHash ? n.blockHash : null,
5
+ blockNumber: n.blockNumber ? BigInt(n.blockNumber) : null,
6
+ logIndex: n.logIndex ? Number(n.logIndex) : null,
7
+ transactionHash: n.transactionHash ? n.transactionHash : null,
8
+ transactionIndex: n.transactionIndex ? Number(n.transactionIndex) : null,
9
+ ...a ? { args: t, eventName: a } : {}
10
+ };
11
+ }
2
12
  export {
3
- n as maxUint256
13
+ r as formatLog
4
14
  };
package/dist/index94.cjs CHANGED
@@ -1 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index109.cjs"),f=require("./index110.cjs"),c=require("./index111.cjs"),I=[],O=[],w=[],B=BigInt(0),a=BigInt(1),A=BigInt(2),S=BigInt(7),H=BigInt(256),T=BigInt(113);for(let i=0,t=a,s=1,n=0;i<24;i++){[s,n]=[n,(2*s+3*n)%5],I.push(2*(5*n+s)),O.push((i+1)*(i+2)/2%64);let o=B;for(let r=0;r<7;r++)t=(t<<a^(t>>S)*T)%H,t&A&&(o^=a<<(a<<BigInt(r))-a);w.push(o)}const[m,E]=f.split(w,!0),y=(i,t,s)=>s>32?f.rotlBH(i,t,s):f.rotlSH(i,t,s),b=(i,t,s)=>s>32?f.rotlBL(i,t,s):f.rotlSL(i,t,s);function L(i,t=24){const s=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let e=0;e<10;e++)s[e]=i[e]^i[e+10]^i[e+20]^i[e+30]^i[e+40];for(let e=0;e<10;e+=2){const h=(e+8)%10,p=(e+2)%10,d=s[p],u=s[p+1],_=y(d,u,1)^s[h],g=b(d,u,1)^s[h+1];for(let k=0;k<50;k+=10)i[e+k]^=_,i[e+k+1]^=g}let o=i[2],r=i[3];for(let e=0;e<24;e++){const h=O[e],p=y(o,r,h),d=b(o,r,h),u=I[e];o=i[u],r=i[u+1],i[u]=p,i[u+1]=d}for(let e=0;e<50;e+=10){for(let h=0;h<10;h++)s[h]=i[e+h];for(let h=0;h<10;h++)i[e+h]^=~s[(h+2)%10]&s[(h+4)%10]}i[0]^=m[n],i[1]^=E[n]}s.fill(0)}class x extends c.Hash{constructor(t,s,n,o=!1,r=24){if(super(),this.blockLen=t,this.suffix=s,this.outputLen=n,this.enableXOF=o,this.rounds=r,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,l.anumber(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=c.u32(this.state)}keccak(){c.isLE||c.byteSwap32(this.state32),L(this.state32,this.rounds),c.isLE||c.byteSwap32(this.state32),this.posOut=0,this.pos=0}update(t){l.aexists(this);const{blockLen:s,state:n}=this;t=c.toBytes(t);const o=t.length;for(let r=0;r<o;){const e=Math.min(s-this.pos,o-r);for(let h=0;h<e;h++)n[this.pos++]^=t[r++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:s,pos:n,blockLen:o}=this;t[n]^=s,s&128&&n===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){l.aexists(this,!1),l.abytes(t),this.finish();const s=this.state,{blockLen:n}=this;for(let o=0,r=t.length;o<r;){this.posOut>=n&&this.keccak();const e=Math.min(n-this.posOut,r-o);t.set(s.subarray(this.posOut,this.posOut+e),o),this.posOut+=e,o+=e}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return l.anumber(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(l.aoutput(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:s,suffix:n,outputLen:o,rounds:r,enableXOF:e}=this;return t||(t=new x(s,n,o,e,r)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=r,t.suffix=n,t.outputLen=o,t.enableXOF=e,t.destroyed=this.destroyed,t}}const F=(i,t,s)=>c.wrapConstructor(()=>new x(t,i,s)),P=F(1,136,256/8);exports.Keccak=x;exports.keccakP=L;exports.keccak_256=P;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index73.cjs"),n=require("./index71.cjs");class o extends n.BaseError{constructor({expectedLength:r,givenLength:e,type:t}){super([`ABI encoding array length mismatch for type ${t}.`,`Expected length: ${r}`,`Given length: ${e}`].join(`
2
+ `),{name:"AbiEncodingArrayLengthMismatchError"})}}class a extends n.BaseError{constructor({expectedSize:r,value:e}){super(`Size of bytes "${e}" (bytes${i.size(e)}) does not match expected size (bytes${r}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class c extends n.BaseError{constructor({expectedLength:r,givenLength:e}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${r}`,`Given length (values): ${e}`].join(`
3
+ `),{name:"AbiEncodingLengthMismatchError"})}}class d extends n.BaseError{constructor({expectedSize:r,givenSize:e}){super(`Expected bytes${r}, got bytes${e}.`,{name:"BytesSizeMismatchError"})}}class E extends n.BaseError{constructor(r,{docsPath:e}){super([`Type "${r}" is not a valid encoding type.`,"Please provide a valid ABI type."].join(`
4
+ `),{docsPath:e,name:"InvalidAbiEncodingType"})}}class g extends n.BaseError{constructor(r){super([`Value "${r}" is not a valid array.`].join(`
5
+ `),{name:"InvalidArrayError"})}}exports.AbiEncodingArrayLengthMismatchError=o;exports.AbiEncodingBytesSizeMismatchError=a;exports.AbiEncodingLengthMismatchError=c;exports.BytesSizeMismatchError=d;exports.InvalidAbiEncodingTypeError=E;exports.InvalidArrayError=g;
package/dist/index94.js CHANGED
@@ -1,107 +1,59 @@
1
- import { anumber as d, aexists as k, abytes as B, aoutput as A } from "./index109.js";
2
- import { split as H, rotlBH as m, rotlSH as S, rotlBL as T, rotlSL as F } from "./index110.js";
3
- import { wrapConstructor as X, Hash as E, u32 as U, isLE as x, byteSwap32 as I, toBytes as P } from "./index111.js";
4
- const y = [], L = [], b = [], M = /* @__PURE__ */ BigInt(0), f = /* @__PURE__ */ BigInt(1), R = /* @__PURE__ */ BigInt(2), j = /* @__PURE__ */ BigInt(7), C = /* @__PURE__ */ BigInt(256), q = /* @__PURE__ */ BigInt(113);
5
- for (let e = 0, t = f, s = 1, n = 0; e < 24; e++) {
6
- [s, n] = [n, (2 * s + 3 * n) % 5], y.push(2 * (5 * n + s)), L.push((e + 1) * (e + 2) / 2 % 64);
7
- let o = M;
8
- for (let r = 0; r < 7; r++)
9
- t = (t << f ^ (t >> j) * q) % C, t & R && (o ^= f << (f << /* @__PURE__ */ BigInt(r)) - f);
10
- b.push(o);
11
- }
12
- const [v, z] = /* @__PURE__ */ H(b, !0), O = (e, t, s) => s > 32 ? m(e, t, s) : S(e, t, s), w = (e, t, s) => s > 32 ? T(e, t, s) : F(e, t, s);
13
- function D(e, t = 24) {
14
- const s = new Uint32Array(10);
15
- for (let n = 24 - t; n < 24; n++) {
16
- for (let i = 0; i < 10; i++)
17
- s[i] = e[i] ^ e[i + 10] ^ e[i + 20] ^ e[i + 30] ^ e[i + 40];
18
- for (let i = 0; i < 10; i += 2) {
19
- const h = (i + 8) % 10, l = (i + 2) % 10, u = s[l], c = s[l + 1], _ = O(u, c, 1) ^ s[h], g = w(u, c, 1) ^ s[h + 1];
20
- for (let a = 0; a < 50; a += 10)
21
- e[i + a] ^= _, e[i + a + 1] ^= g;
22
- }
23
- let o = e[2], r = e[3];
24
- for (let i = 0; i < 24; i++) {
25
- const h = L[i], l = O(o, r, h), u = w(o, r, h), c = y[i];
26
- o = e[c], r = e[c + 1], e[c] = l, e[c + 1] = u;
27
- }
28
- for (let i = 0; i < 50; i += 10) {
29
- for (let h = 0; h < 10; h++)
30
- s[h] = e[i + h];
31
- for (let h = 0; h < 10; h++)
32
- e[i + h] ^= ~s[(h + 2) % 10] & s[(h + 4) % 10];
33
- }
34
- e[0] ^= v[n], e[1] ^= z[n];
1
+ import { size as i } from "./index73.js";
2
+ import { BaseError as n } from "./index71.js";
3
+ class c extends n {
4
+ constructor({ expectedLength: e, givenLength: r, type: s }) {
5
+ super([
6
+ `ABI encoding array length mismatch for type ${s}.`,
7
+ `Expected length: ${e}`,
8
+ `Given length: ${r}`
9
+ ].join(`
10
+ `), { name: "AbiEncodingArrayLengthMismatchError" });
35
11
  }
36
- s.fill(0);
37
12
  }
38
- class p extends E {
39
- // NOTE: we accept arguments in bytes instead of bits here.
40
- constructor(t, s, n, o = !1, r = 24) {
41
- if (super(), this.blockLen = t, this.suffix = s, this.outputLen = n, this.enableXOF = o, this.rounds = r, this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, d(n), 0 >= this.blockLen || this.blockLen >= 200)
42
- throw new Error("Sha3 supports only keccak-f1600 function");
43
- this.state = new Uint8Array(200), this.state32 = U(this.state);
44
- }
45
- keccak() {
46
- x || I(this.state32), D(this.state32, this.rounds), x || I(this.state32), this.posOut = 0, this.pos = 0;
47
- }
48
- update(t) {
49
- k(this);
50
- const { blockLen: s, state: n } = this;
51
- t = P(t);
52
- const o = t.length;
53
- for (let r = 0; r < o; ) {
54
- const i = Math.min(s - this.pos, o - r);
55
- for (let h = 0; h < i; h++)
56
- n[this.pos++] ^= t[r++];
57
- this.pos === s && this.keccak();
58
- }
59
- return this;
60
- }
61
- finish() {
62
- if (this.finished)
63
- return;
64
- this.finished = !0;
65
- const { state: t, suffix: s, pos: n, blockLen: o } = this;
66
- t[n] ^= s, s & 128 && n === o - 1 && this.keccak(), t[o - 1] ^= 128, this.keccak();
67
- }
68
- writeInto(t) {
69
- k(this, !1), B(t), this.finish();
70
- const s = this.state, { blockLen: n } = this;
71
- for (let o = 0, r = t.length; o < r; ) {
72
- this.posOut >= n && this.keccak();
73
- const i = Math.min(n - this.posOut, r - o);
74
- t.set(s.subarray(this.posOut, this.posOut + i), o), this.posOut += i, o += i;
75
- }
76
- return t;
77
- }
78
- xofInto(t) {
79
- if (!this.enableXOF)
80
- throw new Error("XOF is not possible for this instance");
81
- return this.writeInto(t);
13
+ class d extends n {
14
+ constructor({ expectedSize: e, value: r }) {
15
+ super(`Size of bytes "${r}" (bytes${i(r)}) does not match expected size (bytes${e}).`, { name: "AbiEncodingBytesSizeMismatchError" });
82
16
  }
83
- xof(t) {
84
- return d(t), this.xofInto(new Uint8Array(t));
85
- }
86
- digestInto(t) {
87
- if (A(t, this), this.finished)
88
- throw new Error("digest() was already called");
89
- return this.writeInto(t), this.destroy(), t;
17
+ }
18
+ class m extends n {
19
+ constructor({ expectedLength: e, givenLength: r }) {
20
+ super([
21
+ "ABI encoding params/values length mismatch.",
22
+ `Expected length (params): ${e}`,
23
+ `Given length (values): ${r}`
24
+ ].join(`
25
+ `), { name: "AbiEncodingLengthMismatchError" });
90
26
  }
91
- digest() {
92
- return this.digestInto(new Uint8Array(this.outputLen));
27
+ }
28
+ class E extends n {
29
+ constructor({ expectedSize: e, givenSize: r }) {
30
+ super(`Expected bytes${e}, got bytes${r}.`, {
31
+ name: "BytesSizeMismatchError"
32
+ });
93
33
  }
94
- destroy() {
95
- this.destroyed = !0, this.state.fill(0);
34
+ }
35
+ class g extends n {
36
+ constructor(e, { docsPath: r }) {
37
+ super([
38
+ `Type "${e}" is not a valid encoding type.`,
39
+ "Please provide a valid ABI type."
40
+ ].join(`
41
+ `), { docsPath: r, name: "InvalidAbiEncodingType" });
96
42
  }
97
- _cloneInto(t) {
98
- const { blockLen: s, suffix: n, outputLen: o, rounds: r, enableXOF: i } = this;
99
- return t || (t = new p(s, n, o, i, r)), t.state32.set(this.state32), t.pos = this.pos, t.posOut = this.posOut, t.finished = this.finished, t.rounds = r, t.suffix = n, t.outputLen = o, t.enableXOF = i, t.destroyed = this.destroyed, t;
43
+ }
44
+ class l extends n {
45
+ constructor(e) {
46
+ super([`Value "${e}" is not a valid array.`].join(`
47
+ `), {
48
+ name: "InvalidArrayError"
49
+ });
100
50
  }
101
51
  }
102
- const G = (e, t, s) => X(() => new p(t, e, s)), Q = /* @__PURE__ */ G(1, 136, 256 / 8);
103
52
  export {
104
- p as Keccak,
105
- D as keccakP,
106
- Q as keccak_256
53
+ c as AbiEncodingArrayLengthMismatchError,
54
+ d as AbiEncodingBytesSizeMismatchError,
55
+ m as AbiEncodingLengthMismatchError,
56
+ E as BytesSizeMismatchError,
57
+ g as InvalidAbiEncodingTypeError,
58
+ l as InvalidArrayError
107
59
  };
package/dist/index95.cjs CHANGED
@@ -1 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index43.cjs"),u=require("./index100.cjs"),f=require("./index55.cjs"),g=require("./index24.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 a=require("./index96.cjs"),t=require("./index71.cjs");class i extends t.BaseError{constructor({cause:r,maxFeePerGas:e}={}){super(`The fee cap (\`maxFeePerGas\`${e?` = ${a.formatGwei(e)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:r,name:"FeeCapTooHighError"})}}Object.defineProperty(i,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class n extends t.BaseError{constructor({cause:r,maxPriorityFeePerGas:e,maxFeePerGas:o}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${e?` = ${a.formatGwei(e)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${o?` = ${a.formatGwei(o)} gwei`:""}).`].join(`
2
+ `),{cause:r,name:"TipAboveFeeCapError"})}}Object.defineProperty(n,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/});exports.FeeCapTooHighError=i;exports.TipAboveFeeCapError=n;
package/dist/index95.js CHANGED
@@ -1,45 +1,37 @@
1
- import { BaseError as l } from "./index43.js";
2
- import { createCursor as r } from "./index100.js";
3
- import { hexToBytes as g } from "./index55.js";
4
- import { bytesToHex as u } from "./index24.js";
5
- function m(n, e = "hex") {
6
- const i = s(n), h = r(new Uint8Array(i.length));
7
- return i.encode(h), e === "hex" ? u(h.bytes) : h.bytes;
1
+ import { formatGwei as a } from "./index96.js";
2
+ import { BaseError as o } from "./index71.js";
3
+ class n extends o {
4
+ constructor({ cause: r, maxFeePerGas: e } = {}) {
5
+ super(`The fee cap (\`maxFeePerGas\`${e ? ` = ${a(e)} gwei` : ""}) cannot be higher than the maximum allowed value (2^256-1).`, {
6
+ cause: r,
7
+ name: "FeeCapTooHighError"
8
+ });
9
+ }
8
10
  }
9
- function s(n) {
10
- return Array.isArray(n) ? p(n.map((e) => s(e))) : y(n);
11
- }
12
- function p(n) {
13
- const e = n.reduce((t, f) => t + f.length, 0), i = o(e);
14
- return {
15
- length: e <= 55 ? 1 + e : 1 + i + e,
16
- encode(t) {
17
- 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));
18
- for (const { encode: f } of n)
19
- f(t);
20
- }
21
- };
22
- }
23
- function y(n) {
24
- const e = typeof n == "string" ? g(n) : n, i = o(e.length);
25
- return {
26
- length: e.length === 1 && e[0] < 128 ? 1 : e.length <= 55 ? 1 + e.length : 1 + i + e.length,
27
- encode(t) {
28
- 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));
29
- }
30
- };
31
- }
32
- function o(n) {
33
- if (n < 2 ** 8)
34
- return 1;
35
- if (n < 2 ** 16)
36
- return 2;
37
- if (n < 2 ** 24)
38
- return 3;
39
- if (n < 2 ** 32)
40
- return 4;
41
- throw new l("Length is too large.");
11
+ Object.defineProperty(n, "nodeMessage", {
12
+ enumerable: !0,
13
+ configurable: !0,
14
+ writable: !0,
15
+ value: /max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/
16
+ });
17
+ class h extends o {
18
+ constructor({ cause: r, maxPriorityFeePerGas: e, maxFeePerGas: t } = {}) {
19
+ super([
20
+ `The provided tip (\`maxPriorityFeePerGas\`${e ? ` = ${a(e)} gwei` : ""}) cannot be higher than the fee cap (\`maxFeePerGas\`${t ? ` = ${a(t)} gwei` : ""}).`
21
+ ].join(`
22
+ `), {
23
+ cause: r,
24
+ name: "TipAboveFeeCapError"
25
+ });
26
+ }
42
27
  }
28
+ Object.defineProperty(h, "nodeMessage", {
29
+ enumerable: !0,
30
+ configurable: !0,
31
+ writable: !0,
32
+ value: /max priority fee per gas higher than max fee per gas|tip higher than fee cap/
33
+ });
43
34
  export {
44
- m as toRlp
35
+ n as FeeCapTooHighError,
36
+ h as TipAboveFeeCapError
45
37
  };
package/dist/index96.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index43.cjs");class t extends o.BaseError{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class i extends o.BaseError{constructor({length:e,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}}class n extends o.BaseError{constructor({count:e,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}}exports.NegativeOffsetError=t;exports.PositionOutOfBoundsError=i;exports.RecursiveReadLimitExceededError=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index114.cjs"),r=require("./index115.cjs");function n(t,e="wei"){return r.formatUnits(t,i.gweiUnits[e])}exports.formatGwei=n;
package/dist/index96.js CHANGED
@@ -1,23 +1,8 @@
1
- import { BaseError as o } from "./index43.js";
2
- class i extends o {
3
- constructor({ offset: e }) {
4
- super(`Offset \`${e}\` cannot be negative.`, {
5
- name: "NegativeOffsetError"
6
- });
7
- }
8
- }
9
- class n extends o {
10
- constructor({ length: e, position: r }) {
11
- super(`Position \`${r}\` is out of bounds (\`0 < position < ${e}\`).`, { name: "PositionOutOfBoundsError" });
12
- }
13
- }
14
- class c extends o {
15
- constructor({ count: e, limit: r }) {
16
- super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${e}\`).`, { name: "RecursiveReadLimitExceededError" });
17
- }
1
+ import { gweiUnits as i } from "./index114.js";
2
+ import { formatUnits as o } from "./index115.js";
3
+ function f(r, t = "wei") {
4
+ return o(r, i[t]);
18
5
  }
19
6
  export {
20
- i as NegativeOffsetError,
21
- n as PositionOutOfBoundsError,
22
- c as RecursiveReadLimitExceededError
7
+ f as formatGwei
23
8
  };
package/dist/index97.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index101.cjs"),s=require("./index69.cjs"),r=require("./index55.cjs");function o(t,i){return e.sha256(s.isHex(t,{strict:!1})?r.toBytes(t):t)}exports.sha256=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function i(e){return new Promise(t=>setTimeout(t,e))}exports.wait=i;
package/dist/index97.js CHANGED
@@ -1,9 +1,6 @@
1
- import { sha256 as o } from "./index101.js";
2
- import { isHex as s } from "./index69.js";
3
- import { toBytes as r } from "./index55.js";
4
- function p(t, i) {
5
- return o(s(t, { strict: !1 }) ? r(t) : t);
1
+ async function n(e) {
2
+ return new Promise((t) => setTimeout(t, e));
6
3
  }
7
4
  export {
8
- p as sha256
5
+ n as wait
9
6
  };
package/dist/index98.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=6,s=32,e=4096,n=s*e,o=n*t-1-1*e*t;exports.bytesPerBlob=n;exports.bytesPerFieldElement=s;exports.fieldElementsPerBlob=e;exports.maxBytesPerTransaction=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index24.cjs"),r=require("./index116.cjs");function c(t){const{commitment:o,version:s=1}=t,n=t.to??(typeof o=="string"?"hex":"bytes"),e=r.sha256(o);return e.set([s],0),n==="bytes"?e:i.bytesToHex(e)}exports.commitmentToVersionedHash=c;
package/dist/index98.js CHANGED
@@ -1,7 +1,9 @@
1
- const e = 32, s = 4096, t = 131072, l = 761855;
1
+ import { bytesToHex as i } from "./index24.js";
2
+ import { sha256 as m } from "./index116.js";
3
+ function f(t) {
4
+ const { commitment: e, version: s = 1 } = t, n = t.to ?? (typeof e == "string" ? "hex" : "bytes"), o = m(e);
5
+ return o.set([s], 0), n === "bytes" ? o : i(o);
6
+ }
2
7
  export {
3
- t as bytesPerBlob,
4
- e as bytesPerFieldElement,
5
- s as fieldElementsPerBlob,
6
- l as maxBytesPerTransaction
8
+ f as commitmentToVersionedHash
7
9
  };
package/dist/index99.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index103.cjs"),s=require("./index43.cjs");class i extends s.BaseError{constructor({maxSize:e,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}}class n extends s.BaseError{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class t extends s.BaseError{constructor({hash:e,size:r}){super(`Versioned hash "${e}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}}class d extends s.BaseError{constructor({hash:e,version:r}){super(`Versioned hash "${e}" version is invalid.`,{metaMessages:[`Expected: ${a.versionedHashVersionKzg}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}}exports.BlobSizeTooLargeError=i;exports.EmptyBlobError=n;exports.InvalidVersionedHashSizeError=t;exports.InvalidVersionedHashVersionError=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index118.cjs"),y=require("./index112.cjs"),u=require("./index109.cjs"),B=require("./index73.cjs"),h=require("./index36.cjs"),d=require("./index24.cjs");function f(t){const a=t.to??(typeof t.data=="string"?"hex":"bytes"),n=typeof t.data=="string"?h.hexToBytes(t.data):t.data,s=B.size(n);if(!s)throw new y.EmptyBlobError;if(s>o.maxBytesPerTransaction)throw new y.BlobSizeTooLargeError({maxSize:o.maxBytesPerTransaction,size:s});const r=[];let b=!0,i=0;for(;b;){const e=u.createCursor(new Uint8Array(o.bytesPerBlob));let l=0;for(;l<o.fieldElementsPerBlob;){const c=n.slice(i,i+(o.bytesPerFieldElement-1));if(e.pushByte(0),e.pushBytes(c),c.length<31){e.pushByte(128),b=!1;break}l++,i+=31}r.push(e)}return a==="bytes"?r.map(e=>e.bytes):r.map(e=>d.bytesToHex(e.bytes))}exports.toBlobs=f;
package/dist/index99.js CHANGED
@@ -1,40 +1,35 @@
1
- import { versionedHashVersionKzg as a } from "./index103.js";
2
- import { BaseError as s } from "./index43.js";
3
- class t extends s {
4
- constructor({ maxSize: e, size: r }) {
5
- super("Blob size is too large.", {
6
- metaMessages: [`Max: ${e} bytes`, `Given: ${r} bytes`],
7
- name: "BlobSizeTooLargeError"
8
- });
9
- }
10
- }
11
- class d extends s {
12
- constructor() {
13
- super("Blob data must not be empty.", { name: "EmptyBlobError" });
14
- }
15
- }
16
- class l extends s {
17
- constructor({ hash: e, size: r }) {
18
- super(`Versioned hash "${e}" size is invalid.`, {
19
- metaMessages: ["Expected: 32", `Received: ${r}`],
20
- name: "InvalidVersionedHashSizeError"
21
- });
22
- }
23
- }
24
- class c extends s {
25
- constructor({ hash: e, version: r }) {
26
- super(`Versioned hash "${e}" version is invalid.`, {
27
- metaMessages: [
28
- `Expected: ${a}`,
29
- `Received: ${r}`
30
- ],
31
- name: "InvalidVersionedHashVersionError"
1
+ import { maxBytesPerTransaction as y, bytesPerBlob as a, fieldElementsPerBlob as f, bytesPerFieldElement as p } from "./index118.js";
2
+ import { EmptyBlobError as c, BlobSizeTooLargeError as h } from "./index112.js";
3
+ import { createCursor as B } from "./index109.js";
4
+ import { size as u } from "./index73.js";
5
+ import { hexToBytes as x } from "./index36.js";
6
+ import { bytesToHex as d } from "./index24.js";
7
+ function S(e) {
8
+ const m = e.to ?? (typeof e.data == "string" ? "hex" : "bytes"), i = typeof e.data == "string" ? x(e.data) : e.data, o = u(i);
9
+ if (!o)
10
+ throw new c();
11
+ if (o > y)
12
+ throw new h({
13
+ maxSize: y,
14
+ size: o
32
15
  });
16
+ const s = [];
17
+ let n = !0, r = 0;
18
+ for (; n; ) {
19
+ const t = B(new Uint8Array(a));
20
+ let l = 0;
21
+ for (; l < f; ) {
22
+ const b = i.slice(r, r + (p - 1));
23
+ if (t.pushByte(0), t.pushBytes(b), b.length < 31) {
24
+ t.pushByte(128), n = !1;
25
+ break;
26
+ }
27
+ l++, r += 31;
28
+ }
29
+ s.push(t);
33
30
  }
31
+ return m === "bytes" ? s.map((t) => t.bytes) : s.map((t) => d(t.bytes));
34
32
  }
35
33
  export {
36
- t as BlobSizeTooLargeError,
37
- d as EmptyBlobError,
38
- l as InvalidVersionedHashSizeError,
39
- c as InvalidVersionedHashVersionError
34
+ S as toBlobs
40
35
  };
@@ -7,3 +7,4 @@ export * from './lib/approve';
7
7
  export * from './lib/blockNumber';
8
8
  export * from './lib/eventBroker';
9
9
  export * from './lib/result';
10
+ export * from './lib/digestKey/digestKey';
@@ -2,16 +2,17 @@ import { AuthHeader, IAuth, SiweOpts } from '../auth.types';
2
2
  import { AsyncResult, Result } from '@catalogfi/utils';
3
3
  import { Url } from '../../url';
4
4
  import { WalletClient } from 'viem';
5
+ import { DigestKey } from '../../digestKey/digestKey';
5
6
 
6
7
  export declare class Siwe implements IAuth {
7
- private readonly API;
8
8
  private readonly url;
9
9
  private store;
10
10
  private walletClient;
11
11
  private readonly signingStatement;
12
12
  private readonly domain;
13
+ private fetchWithCookies;
13
14
  constructor(url: Url, walletClient: WalletClient, opts?: SiweOpts);
14
- static fromDigestKey(url: Url, digestKey: string): Siwe;
15
+ static fromDigestKey(url: Url, digestKey: DigestKey, siweOpts?: SiweOpts): Siwe;
15
16
  verifyToken(token: string, account: string): Result<boolean, string>;
16
17
  getToken(): AsyncResult<string, string>;
17
18
  private signStatement;
@@ -0,0 +1,12 @@
1
+ export declare class DigestKey {
2
+ private _digestKey;
3
+ private _userId;
4
+ constructor(digestKey: string);
5
+ static from(digestKey: string): import('../result').Result<never, string> | import('../result').Result<DigestKey, never>;
6
+ static generateRandom(): import('../result').Result<never, string> | import('../result').Result<DigestKey, never>;
7
+ private static isValidDigestKey;
8
+ private static isValidPrivateKey;
9
+ private static generateRandomDigestKey;
10
+ get digestKey(): string;
11
+ get userId(): string;
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/utils",
3
- "version": "2.0.6",
3
+ "version": "2.1.0-beta.2",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "vite build",
@@ -35,8 +35,11 @@
35
35
  },
36
36
  "sideEffects": false,
37
37
  "dependencies": {
38
+ "@peculiar/webcrypto": "^1.5.0",
38
39
  "@simplewebauthn/browser": "^13.1.0",
40
+ "fetch-cookie": "^3.1.0",
39
41
  "jwt-decode": "^4.0.0",
42
+ "tough-cookie": "^5.1.2",
40
43
  "viem": "^2.21.23"
41
44
  }
42
45
  }