@gardenfi/utils 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +22 -17
- package/dist/index10.cjs +1 -1
- package/dist/index10.js +32 -17
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +14 -183
- package/dist/index12.cjs +1 -1
- package/dist/index12.js +186 -92
- package/dist/index13.cjs +1 -16
- package/dist/index13.js +93 -113
- package/dist/index14.cjs +16 -1
- package/dist/index14.js +112 -30
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +18 -17
- package/dist/index16.cjs +1 -1
- package/dist/index16.js +31 -18
- package/dist/index17.cjs +1 -1
- package/dist/index17.js +17 -7
- package/dist/index18.cjs +1 -1
- package/dist/index18.js +6 -19
- package/dist/index19.cjs +1 -1
- package/dist/index19.js +20 -21
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +21 -8
- package/dist/index21.cjs +1 -1
- package/dist/index21.js +8 -31
- package/dist/index22.cjs +1 -1
- package/dist/index22.js +31 -26
- package/dist/index23.cjs +1 -1
- package/dist/index23.js +25 -22
- package/dist/index24.cjs +1 -1
- package/dist/index24.js +22 -50
- package/dist/index25.cjs +1 -1
- package/dist/index25.js +51 -12
- package/dist/index26.cjs +1 -1
- package/dist/index26.js +12 -24
- package/dist/index27.cjs +1 -1
- package/dist/index27.js +24 -75
- package/dist/index28.cjs +1 -1
- package/dist/index28.js +74 -22
- package/dist/index29.cjs +1 -1
- package/dist/index29.js +23 -7
- package/dist/index30.cjs +1 -1
- package/dist/index30.js +7 -32
- package/dist/index31.cjs +1 -1
- package/dist/index31.js +31 -14
- package/dist/index32.cjs +1 -1
- package/dist/index32.js +16 -2
- package/dist/index33.cjs +1 -1
- package/dist/index33.js +2 -9
- package/dist/index34.cjs +1 -1
- package/dist/index34.js +8 -20
- package/dist/index35.cjs +1 -1
- package/dist/index35.js +20 -12
- package/dist/index36.cjs +1 -1
- package/dist/index36.js +10 -32
- package/dist/index37.cjs +1 -2
- package/dist/index37.js +33 -58
- package/dist/index38.cjs +2 -1
- package/dist/index38.js +60 -2
- package/dist/index39.cjs +1 -1
- package/dist/index39.js +2 -5
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +2 -2
- package/dist/index40.cjs +1 -1
- package/dist/index40.js +4 -11
- package/dist/index41.cjs +1 -1
- package/dist/index41.js +11 -3
- package/dist/index42.cjs +1 -1
- package/dist/index42.js +3 -21
- package/dist/index43.cjs +1 -1
- package/dist/index43.js +21 -12
- package/dist/index44.cjs +1 -1
- package/dist/index44.js +11 -54
- package/dist/index45.cjs +1 -1
- package/dist/index45.js +55 -6
- package/dist/index46.cjs +1 -1
- package/dist/index46.js +6 -21
- package/dist/index47.cjs +1 -1
- package/dist/index47.js +21 -11
- package/dist/index48.cjs +1 -1
- package/dist/index48.js +11 -3
- package/dist/index49.cjs +1 -1
- package/dist/index49.js +3 -11
- package/dist/index5.cjs +1 -1
- package/dist/index5.js +43 -19
- package/dist/index50.cjs +1 -1
- package/dist/index50.js +11 -19
- package/dist/index51.cjs +1 -1
- package/dist/index51.js +19 -6
- package/dist/index52.cjs +1 -1
- package/dist/index52.js +6 -8
- package/dist/index53.cjs +1 -1
- package/dist/index53.js +8 -104
- package/dist/index54.cjs +1 -1
- package/dist/index54.js +102 -26
- package/dist/index55.cjs +1 -1
- package/dist/index55.js +27 -17
- package/dist/index56.cjs +1 -1
- package/dist/index56.js +16 -36
- package/dist/index57.cjs +1 -0
- package/dist/index57.js +41 -0
- package/dist/index6.cjs +1 -1
- package/dist/index6.js +19 -104
- package/dist/index7.cjs +1 -1
- package/dist/index7.js +104 -10
- package/dist/index8.cjs +1 -1
- package/dist/index8.js +15 -2
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +2 -34
- package/dist/src/index.d.ts +1 -0
- package/dist/src/lib/result.d.ts +16 -0
- package/package.json +1 -1
package/dist/index53.js
CHANGED
|
@@ -1,107 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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);
|
|
1
|
+
function n(e) {
|
|
2
|
+
return {
|
|
3
|
+
formatters: void 0,
|
|
4
|
+
fees: void 0,
|
|
5
|
+
serializers: void 0,
|
|
6
|
+
...e
|
|
7
|
+
};
|
|
11
8
|
}
|
|
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];
|
|
35
|
-
}
|
|
36
|
-
s.fill(0);
|
|
37
|
-
}
|
|
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);
|
|
82
|
-
}
|
|
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;
|
|
90
|
-
}
|
|
91
|
-
digest() {
|
|
92
|
-
return this.digestInto(new Uint8Array(this.outputLen));
|
|
93
|
-
}
|
|
94
|
-
destroy() {
|
|
95
|
-
this.destroyed = !0, this.state.fill(0);
|
|
96
|
-
}
|
|
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;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
const G = (e, t, s) => X(() => new p(t, e, s)), Q = /* @__PURE__ */ G(1, 136, 256 / 8);
|
|
103
9
|
export {
|
|
104
|
-
|
|
105
|
-
D as keccakP,
|
|
106
|
-
Q as keccak_256
|
|
10
|
+
n as defineChain
|
|
107
11
|
};
|
package/dist/index54.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index55.cjs"),f=require("./index56.cjs"),c=require("./index57.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;
|
package/dist/index54.js
CHANGED
|
@@ -1,31 +1,107 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { anumber as d, aexists as k, abytes as B, aoutput as A } from "./index55.js";
|
|
2
|
+
import { split as H, rotlBH as m, rotlSH as S, rotlBL as T, rotlSL as F } from "./index56.js";
|
|
3
|
+
import { wrapConstructor as X, Hash as E, u32 as U, isLE as x, byteSwap32 as I, toBytes as P } from "./index57.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);
|
|
4
11
|
}
|
|
5
|
-
|
|
6
|
-
|
|
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];
|
|
35
|
+
}
|
|
36
|
+
s.fill(0);
|
|
7
37
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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);
|
|
82
|
+
}
|
|
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;
|
|
90
|
+
}
|
|
91
|
+
digest() {
|
|
92
|
+
return this.digestInto(new Uint8Array(this.outputLen));
|
|
93
|
+
}
|
|
94
|
+
destroy() {
|
|
95
|
+
this.destroyed = !0, this.state.fill(0);
|
|
96
|
+
}
|
|
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;
|
|
100
|
+
}
|
|
25
101
|
}
|
|
102
|
+
const G = (e, t, s) => X(() => new p(t, e, s)), Q = /* @__PURE__ */ G(1, 136, 256 / 8);
|
|
26
103
|
export {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
f as aoutput
|
|
104
|
+
p as Keccak,
|
|
105
|
+
D as keccakP,
|
|
106
|
+
Q as keccak_256
|
|
31
107
|
};
|
package/dist/index55.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function i(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function n(e,...t){if(!i(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function s(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function a(e,t){n(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}exports.abytes=n;exports.aexists=s;exports.anumber=o;exports.aoutput=a;
|
package/dist/index55.js
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
function i(e) {
|
|
2
|
+
if (!Number.isSafeInteger(e) || e < 0)
|
|
3
|
+
throw new Error("positive integer expected, got " + e);
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
function n(e) {
|
|
6
|
+
return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
|
|
7
|
+
}
|
|
8
|
+
function o(e, ...t) {
|
|
9
|
+
if (!n(e))
|
|
10
|
+
throw new Error("Uint8Array expected");
|
|
11
|
+
if (t.length > 0 && !t.includes(e.length))
|
|
12
|
+
throw new Error("Uint8Array expected of length " + t + ", got length=" + e.length);
|
|
13
|
+
}
|
|
14
|
+
function s(e, t = !0) {
|
|
15
|
+
if (e.destroyed)
|
|
16
|
+
throw new Error("Hash instance has been destroyed");
|
|
17
|
+
if (t && e.finished)
|
|
18
|
+
throw new Error("Hash#digest() has already been called");
|
|
19
|
+
}
|
|
20
|
+
function f(e, t) {
|
|
21
|
+
o(e);
|
|
22
|
+
const r = t.outputLen;
|
|
23
|
+
if (e.length < r)
|
|
24
|
+
throw new Error("digestInto() expects output buffer of length at least " + r);
|
|
12
25
|
}
|
|
13
|
-
const g = (t, r, n) => t << n | r >>> 32 - n, m = (t, r, n) => r << n | t >>> 32 - n, A = (t, r, n) => r << n - 32 | t >>> 64 - n, B = (t, r, n) => t << n - 32 | r >>> 64 - n;
|
|
14
26
|
export {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
m as rotlSL,
|
|
20
|
-
h as split
|
|
27
|
+
o as abytes,
|
|
28
|
+
s as aexists,
|
|
29
|
+
i as anumber,
|
|
30
|
+
f as aoutput
|
|
21
31
|
};
|
package/dist/index56.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=BigInt(2**32-1),i=BigInt(32);function u(t,e=!1){return e?{h:Number(t&n),l:Number(t>>i&n)}:{h:Number(t>>i&n)|0,l:Number(t&n)|0}}function g(t,e=!1){let r=new Uint32Array(t.length),l=new Uint32Array(t.length);for(let o=0;o<t.length;o++){const{h:c,l:f}=u(t[o],e);[r[o],l[o]]=[c,f]}return[r,l]}const B=(t,e,r)=>t<<r|e>>>32-r,h=(t,e,r)=>e<<r|t>>>32-r,m=(t,e,r)=>e<<r-32|t>>>64-r,S=(t,e,r)=>t<<r-32|e>>>64-r;exports.fromBig=u;exports.rotlBH=m;exports.rotlBL=S;exports.rotlSH=B;exports.rotlSL=h;exports.split=g;
|
package/dist/index56.js
CHANGED
|
@@ -1,41 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4));
|
|
1
|
+
const o = /* @__PURE__ */ BigInt(4294967295), i = /* @__PURE__ */ BigInt(32);
|
|
2
|
+
function f(t, r = !1) {
|
|
3
|
+
return r ? { h: Number(t & o), l: Number(t >> i & o) } : { h: Number(t >> i & o) | 0, l: Number(t & o) | 0 };
|
|
5
4
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
for (let e = 0; e < t.length; e++)
|
|
12
|
-
t[e] = r(t[e]);
|
|
13
|
-
}
|
|
14
|
-
function u(t) {
|
|
15
|
-
if (typeof t != "string")
|
|
16
|
-
throw new Error("utf8ToBytes expected string, got " + typeof t);
|
|
17
|
-
return new Uint8Array(new TextEncoder().encode(t));
|
|
18
|
-
}
|
|
19
|
-
function i(t) {
|
|
20
|
-
return typeof t == "string" && (t = u(t)), o(t), t;
|
|
21
|
-
}
|
|
22
|
-
class b {
|
|
23
|
-
// Safe version that clones internal state
|
|
24
|
-
clone() {
|
|
25
|
-
return this._cloneInto();
|
|
5
|
+
function h(t, r = !1) {
|
|
6
|
+
let n = new Uint32Array(t.length), l = new Uint32Array(t.length);
|
|
7
|
+
for (let e = 0; e < t.length; e++) {
|
|
8
|
+
const { h: c, l: u } = f(t[e], r);
|
|
9
|
+
[n[e], l[e]] = [c, u];
|
|
26
10
|
}
|
|
11
|
+
return [n, l];
|
|
27
12
|
}
|
|
28
|
-
|
|
29
|
-
const e = (f) => t().update(i(f)).digest(), n = t();
|
|
30
|
-
return e.outputLen = n.outputLen, e.blockLen = n.blockLen, e.create = () => t(), e;
|
|
31
|
-
}
|
|
13
|
+
const g = (t, r, n) => t << n | r >>> 32 - n, m = (t, r, n) => r << n | t >>> 32 - n, A = (t, r, n) => r << n - 32 | t >>> 64 - n, B = (t, r, n) => t << n - 32 | r >>> 64 - n;
|
|
32
14
|
export {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
u as utf8ToBytes,
|
|
40
|
-
x as wrapConstructor
|
|
15
|
+
f as fromBig,
|
|
16
|
+
A as rotlBH,
|
|
17
|
+
B as rotlBL,
|
|
18
|
+
g as rotlSH,
|
|
19
|
+
m as rotlSL,
|
|
20
|
+
h as split
|
|
41
21
|
};
|
package/dist/index57.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index55.cjs");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function c(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}const s=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function o(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function y(t){for(let e=0;e<t.length;e++)t[e]=o(t[e])}function r(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function f(t){return typeof t=="string"&&(t=r(t)),i.abytes(t),t}class p{clone(){return this._cloneInto()}}function b(t){const e=u=>t().update(f(u)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}exports.Hash=p;exports.byteSwap=o;exports.byteSwap32=y;exports.isLE=s;exports.toBytes=f;exports.u32=c;exports.utf8ToBytes=r;exports.wrapConstructor=b;
|
package/dist/index57.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { abytes as o } from "./index55.js";
|
|
2
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3
|
+
function y(t) {
|
|
4
|
+
return new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4));
|
|
5
|
+
}
|
|
6
|
+
const p = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
7
|
+
function r(t) {
|
|
8
|
+
return t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255;
|
|
9
|
+
}
|
|
10
|
+
function s(t) {
|
|
11
|
+
for (let e = 0; e < t.length; e++)
|
|
12
|
+
t[e] = r(t[e]);
|
|
13
|
+
}
|
|
14
|
+
function u(t) {
|
|
15
|
+
if (typeof t != "string")
|
|
16
|
+
throw new Error("utf8ToBytes expected string, got " + typeof t);
|
|
17
|
+
return new Uint8Array(new TextEncoder().encode(t));
|
|
18
|
+
}
|
|
19
|
+
function i(t) {
|
|
20
|
+
return typeof t == "string" && (t = u(t)), o(t), t;
|
|
21
|
+
}
|
|
22
|
+
class b {
|
|
23
|
+
// Safe version that clones internal state
|
|
24
|
+
clone() {
|
|
25
|
+
return this._cloneInto();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function x(t) {
|
|
29
|
+
const e = (f) => t().update(i(f)).digest(), n = t();
|
|
30
|
+
return e.outputLen = n.outputLen, e.blockLen = n.blockLen, e.create = () => t(), e;
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
b as Hash,
|
|
34
|
+
r as byteSwap,
|
|
35
|
+
s as byteSwap32,
|
|
36
|
+
p as isLE,
|
|
37
|
+
i as toBytes,
|
|
38
|
+
y as u32,
|
|
39
|
+
u as utf8ToBytes,
|
|
40
|
+
x as wrapConstructor
|
|
41
|
+
};
|
package/dist/index6.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class r extends URL{constructor(t,e){super(t,e)}endpoint(t){t.startsWith("/")||(t=`/${t}`);const e=`${this.pathname!=="/"?this.pathname:""}${t}`;return new r(e,this)}socket(){if(this.protocol==="https:")return this.origin.replace("https","wss");if(this.protocol==="http:")return this.origin.replace("http","ws");throw new Error("Invalid protocol")}addSearchParams(t){const e=new URLSearchParams(this.search);for(const s in t)e.set(s,t[s]);return new r(`${this.pathname}?${e.toString()}`,this)}}exports.Url=r;
|
package/dist/index6.js
CHANGED
|
@@ -1,111 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { jwtDecode as m } from "jwt-decode";
|
|
5
|
-
import { Authorization as w } from "./index3.js";
|
|
6
|
-
import { Url as g } from "./index5.js";
|
|
7
|
-
import { createSiweMessage as y } from "./index13.js";
|
|
8
|
-
class I {
|
|
9
|
-
constructor(e, r, t) {
|
|
10
|
-
this.API = "https://api.garden.finance", this.url = new g("/", e ?? this.API), this.walletClient = r, 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 f();
|
|
1
|
+
class r extends URL {
|
|
2
|
+
constructor(t, s) {
|
|
3
|
+
super(t, s);
|
|
11
4
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const i = Math.floor(Date.now() / 1e3) + 120;
|
|
17
|
-
return n(
|
|
18
|
-
t.exp > i && t.user_id.toLowerCase() === r.toLowerCase()
|
|
19
|
-
);
|
|
20
|
-
} catch {
|
|
21
|
-
return n(!1);
|
|
22
|
-
}
|
|
5
|
+
endpoint(t) {
|
|
6
|
+
t.startsWith("/") || (t = `/${t}`);
|
|
7
|
+
const s = `${this.pathname !== "/" ? this.pathname : ""}${t}`;
|
|
8
|
+
return new r(s, this);
|
|
23
9
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const o = this.verifyToken(
|
|
31
|
-
e,
|
|
32
|
-
this.walletClient.account.address
|
|
33
|
-
);
|
|
34
|
-
if (o.ok && o.val) return n(e);
|
|
35
|
-
}
|
|
36
|
-
const r = await this.signStatement();
|
|
37
|
-
if (r.error)
|
|
38
|
-
return a(r.error);
|
|
39
|
-
const t = await u.post(
|
|
40
|
-
this.url.endpoint("verify"),
|
|
41
|
-
{
|
|
42
|
-
body: JSON.stringify({
|
|
43
|
-
...r.val
|
|
44
|
-
}),
|
|
45
|
-
headers: {
|
|
46
|
-
"Content-Type": "application/json"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
);
|
|
50
|
-
if (t.error) return a(t.error);
|
|
51
|
-
const i = t.result;
|
|
52
|
-
if (!i) return a("Failed to get token");
|
|
53
|
-
if (!this.verifyToken(i, this.walletClient.account.address).val)
|
|
54
|
-
throw new Error("Token verification failed");
|
|
55
|
-
return this.store.setItem(d.AUTH_TOKEN, i), n(i);
|
|
10
|
+
socket() {
|
|
11
|
+
if (this.protocol === "https:")
|
|
12
|
+
return this.origin.replace("https", "wss");
|
|
13
|
+
if (this.protocol === "http:")
|
|
14
|
+
return this.origin.replace("http", "ws");
|
|
15
|
+
throw new Error("Invalid protocol");
|
|
56
16
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
this.url.endpoint("nonce")
|
|
63
|
-
)).result;
|
|
64
|
-
if (!i)
|
|
65
|
-
return a("Failed to get nonce");
|
|
66
|
-
const h = await this.walletClient.getChainId(), s = y({
|
|
67
|
-
domain: this.domain,
|
|
68
|
-
address: this.walletClient.account.address,
|
|
69
|
-
statement: this.signingStatement,
|
|
70
|
-
nonce: i,
|
|
71
|
-
uri: "https://" + this.domain,
|
|
72
|
-
version: "1",
|
|
73
|
-
chainId: h,
|
|
74
|
-
notBefore: r
|
|
75
|
-
}), o = await this.walletClient.signMessage({
|
|
76
|
-
account: this.walletClient.account,
|
|
77
|
-
message: s
|
|
78
|
-
});
|
|
79
|
-
return n({
|
|
80
|
-
message: s,
|
|
81
|
-
signature: o,
|
|
82
|
-
nonce: i
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const p = (c) => {
|
|
87
|
-
try {
|
|
88
|
-
return m(c);
|
|
89
|
-
} catch {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
class E {
|
|
94
|
-
constructor(e) {
|
|
95
|
-
if (!e.siwe && !e.apiKey)
|
|
96
|
-
throw new Error("Either siwe or apiKey must be provided");
|
|
97
|
-
this.siwe = e.siwe, this.apiKey = e.apiKey;
|
|
98
|
-
}
|
|
99
|
-
async getAuthHeaders() {
|
|
100
|
-
if (this.siwe) {
|
|
101
|
-
const e = await this.siwe.getToken();
|
|
102
|
-
return e.error ? a(e.error) : n({ Authorization: w(e.val) });
|
|
103
|
-
}
|
|
104
|
-
return this.apiKey ? n({ "api-key": this.apiKey }) : a("No authentication method available");
|
|
17
|
+
addSearchParams(t) {
|
|
18
|
+
const s = new URLSearchParams(this.search);
|
|
19
|
+
for (const e in t)
|
|
20
|
+
s.set(e, t[e]);
|
|
21
|
+
return new r(`${this.pathname}?${s.toString()}`, this);
|
|
105
22
|
}
|
|
106
23
|
}
|
|
107
24
|
export {
|
|
108
|
-
|
|
109
|
-
I as Siwe,
|
|
110
|
-
p as parseJwt
|
|
25
|
+
r as Url
|
|
111
26
|
};
|
package/dist/index7.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index12.cjs"),d=require("./index8.cjs"),l=require("./index9.cjs"),w=require("jwt-decode"),f=require("./index3.cjs"),g=require("./index6.cjs"),y=require("./index14.cjs");class m{constructor(t,n,e){this.API="https://api.garden.finance",this.url=new g.Url("/",t??this.API),this.walletClient=n,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 d.MemoryStorage}verifyToken(t,n){try{const e=u(t);if(!e)return r.Ok(!1);const i=Math.floor(Date.now()/1e3)+120;return r.Ok(e.exp>i&&e.user_id.toLowerCase()===n.toLowerCase())}catch{return r.Ok(!1)}}async getToken(){var a;if(!((a=this.walletClient.account)!=null&&a.address))return r.Err("Wallet client does not have an account");const t=this.store.getItem(l.StoreKeys.AUTH_TOKEN);if(t){const s=this.verifyToken(t,this.walletClient.account.address);if(s.ok&&s.val)return r.Ok(t)}const n=await this.signStatement();if(n.error)return r.Err(n.error);const e=await r.Fetcher.post(this.url.endpoint("verify"),{body:JSON.stringify({...n.val}),headers:{"Content-Type":"application/json"}});if(e.error)return r.Err(e.error);const i=e.result;if(!i)return r.Err("Failed to get token");if(!this.verifyToken(i,this.walletClient.account.address).val)throw new Error("Token verification failed");return this.store.setItem(l.StoreKeys.AUTH_TOKEN,i),r.Ok(i)}async signStatement(){var h;if(!((h=this.walletClient.account)!=null&&h.address))return r.Err("Wallet client does not have a valid account");const t=new Date,n=new Date(t.getTime()+300*1e3),i=(await r.Fetcher.get(this.url.endpoint("nonce"))).result;if(!i)return r.Err("Failed to get nonce");const c=await this.walletClient.getChainId(),a=y.createSiweMessage({domain:this.domain,address:this.walletClient.account.address,statement:this.signingStatement,nonce:i,uri:"https://"+this.domain,version:"1",chainId:c,notBefore:n}),s=await this.walletClient.signMessage({account:this.walletClient.account,message:a});return r.Ok({message:a,signature:s,nonce:i})}}const u=o=>{try{return w.jwtDecode(o)}catch{return}};class k{constructor(t){if(!t.siwe&&!t.apiKey)throw new Error("Either siwe or apiKey must be provided");this.siwe=t.siwe,this.apiKey=t.apiKey}async getAuthHeaders(){if(this.siwe){const t=await this.siwe.getToken();return t.error?r.Err(t.error):r.Ok({Authorization:f.Authorization(t.val)})}return this.apiKey?r.Ok({"api-key":this.apiKey}):r.Err("No authentication method available")}}exports.Auth=k;exports.Siwe=m;exports.parseJwt=u;
|