@gardenfi/utils 2.0.4 → 2.0.6
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 +33 -24
- package/dist/index10.cjs +1 -1
- package/dist/index10.js +24 -32
- package/dist/index100.cjs +1 -0
- package/dist/index100.js +130 -0
- package/dist/index101.cjs +1 -0
- package/dist/index101.js +115 -0
- package/dist/index102.cjs +1 -0
- package/dist/index102.js +81 -0
- package/dist/index103.cjs +1 -0
- package/dist/index103.js +4 -0
- package/dist/index104.cjs +1 -0
- package/dist/index104.js +20 -0
- package/dist/index105.cjs +1 -0
- package/dist/index105.js +21 -0
- package/dist/index106.cjs +1 -0
- package/dist/index106.js +19 -0
- package/dist/index107.cjs +1 -0
- package/dist/index107.js +226 -0
- package/dist/index108.cjs +2 -0
- package/dist/index108.js +5 -0
- package/dist/index109.cjs +1 -0
- package/dist/index109.js +37 -0
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +136 -14
- package/dist/index110.cjs +1 -0
- package/dist/index110.js +21 -0
- package/dist/index111.cjs +1 -0
- package/dist/index111.js +72 -0
- package/dist/index112.cjs +1 -0
- package/dist/index112.js +70 -0
- package/dist/index113.cjs +1 -0
- package/dist/index113.js +4 -0
- package/dist/index114.cjs +1 -0
- package/dist/index114.js +43 -0
- package/dist/index115.cjs +1 -0
- package/dist/index115.js +646 -0
- package/dist/index116.cjs +1 -0
- package/dist/index116.js +234 -0
- package/dist/index117.cjs +1 -0
- package/dist/index117.js +175 -0
- package/dist/index12.cjs +1 -1
- package/dist/index12.js +9 -182
- package/dist/index13.cjs +1 -1
- package/dist/index13.js +2 -94
- package/dist/index14.cjs +1 -16
- package/dist/index14.js +32 -112
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +18 -31
- package/dist/index16.cjs +1 -1
- package/dist/index16.js +188 -31
- package/dist/index17.cjs +1 -1
- package/dist/index17.js +93 -17
- package/dist/index18.cjs +1 -1
- package/dist/index18.js +35 -7
- package/dist/index19.cjs +1 -1
- package/dist/index19.js +31 -20
- package/dist/index20.cjs +16 -1
- package/dist/index20.js +113 -21
- package/dist/index21.cjs +1 -1
- package/dist/index21.js +31 -9
- package/dist/index22.cjs +1 -1
- package/dist/index22.js +17 -31
- package/dist/index23.cjs +1 -1
- package/dist/index23.js +7 -26
- package/dist/index24.cjs +1 -1
- package/dist/index24.js +41 -19
- package/dist/index25.cjs +1 -1
- package/dist/index25.js +19 -49
- package/dist/index26.cjs +1 -1
- package/dist/index26.js +8 -12
- package/dist/index27.cjs +1 -1
- package/dist/index27.js +30 -23
- package/dist/index28.cjs +1 -1
- package/dist/index28.js +25 -74
- package/dist/index29.cjs +2 -1
- package/dist/index29.js +62 -20
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +30 -7
- package/dist/index30.cjs +1 -1
- package/dist/index30.js +51 -7
- package/dist/index31.cjs +1 -1
- package/dist/index31.js +12 -32
- package/dist/index32.cjs +1 -1
- package/dist/index32.js +24 -15
- package/dist/index33.cjs +1 -1
- package/dist/index33.js +76 -2
- package/dist/index34.cjs +1 -1
- package/dist/index34.js +23 -8
- package/dist/index35.cjs +1 -1
- package/dist/index35.js +7 -20
- package/dist/index36.cjs +1 -1
- package/dist/index36.js +32 -12
- package/dist/index37.cjs +1 -1
- package/dist/index37.js +15 -34
- package/dist/index38.cjs +1 -2
- package/dist/index38.js +2 -60
- package/dist/index39.cjs +1 -1
- package/dist/index39.js +9 -2
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +2 -2
- package/dist/index40.cjs +1 -1
- package/dist/index40.js +20 -4
- package/dist/index41.cjs +1 -1
- package/dist/index41.js +12 -11
- package/dist/index42.cjs +1 -1
- package/dist/index42.js +34 -3
- package/dist/index43.cjs +2 -1
- package/dist/index43.js +58 -20
- package/dist/index44.cjs +1 -1
- package/dist/index44.js +2 -13
- package/dist/index45.cjs +1 -1
- package/dist/index45.js +5 -54
- package/dist/index46.cjs +1 -1
- package/dist/index46.js +6 -6
- package/dist/index47.cjs +1 -1
- package/dist/index47.js +4 -21
- package/dist/index48.cjs +1 -1
- package/dist/index48.js +11 -11
- package/dist/index49.cjs +5 -1
- package/dist/index49.js +56 -3
- package/dist/index50.cjs +2 -1
- package/dist/index50.js +32 -9
- package/dist/index51.cjs +1 -1
- package/dist/index51.js +5 -19
- package/dist/index52.cjs +1 -1
- package/dist/index52.js +3 -6
- package/dist/index53.cjs +1 -1
- package/dist/index53.js +21 -8
- package/dist/index54.cjs +1 -1
- package/dist/index54.js +11 -103
- package/dist/index55.cjs +1 -1
- package/dist/index55.js +51 -24
- package/dist/index56.cjs +1 -1
- package/dist/index56.js +8 -18
- package/dist/index57.cjs +1 -1
- package/dist/index57.js +20 -37
- package/dist/index58.cjs +1 -0
- package/dist/index58.js +14 -0
- package/dist/index59.cjs +1 -0
- package/dist/index59.js +11 -0
- package/dist/index60.cjs +1 -0
- package/dist/index60.js +13 -0
- package/dist/index61.cjs +1 -0
- package/dist/index61.js +14 -0
- package/dist/index62.cjs +1 -0
- package/dist/index62.js +9 -0
- package/dist/index63.cjs +1 -0
- package/dist/index63.js +16 -0
- package/dist/index64.cjs +1 -0
- package/dist/index64.js +35 -0
- package/dist/index65.cjs +1 -0
- package/dist/index65.js +17 -0
- package/dist/index66.cjs +1 -0
- package/dist/index66.js +67 -0
- package/dist/index67.cjs +1 -0
- package/dist/index67.js +30 -0
- package/dist/index68.cjs +1 -0
- package/dist/index68.js +5 -0
- package/dist/index69.cjs +1 -0
- package/dist/index69.js +6 -0
- package/dist/index7.cjs +1 -1
- package/dist/index7.js +2 -109
- package/dist/index70.cjs +1 -0
- package/dist/index70.js +16 -0
- package/dist/index71.cjs +1 -0
- package/dist/index71.js +44 -0
- package/dist/index72.cjs +1 -0
- package/dist/index72.js +8 -0
- package/dist/index73.cjs +1 -0
- package/dist/index73.js +11 -0
- package/dist/index74.cjs +1 -0
- package/dist/index74.js +106 -0
- package/dist/index75.cjs +1 -0
- package/dist/index75.js +194 -0
- package/dist/index76.cjs +1 -0
- package/dist/index76.js +21 -0
- package/dist/index77.cjs +1 -0
- package/dist/index77.js +14 -0
- package/dist/index78.cjs +1 -0
- package/dist/index78.js +22 -0
- package/dist/index79.cjs +1 -0
- package/dist/index79.js +15 -0
- package/dist/index8.cjs +1 -1
- package/dist/index8.js +95 -10
- package/dist/index80.cjs +1 -0
- package/dist/index80.js +28 -0
- package/dist/index81.cjs +1 -0
- package/dist/index81.js +9 -0
- package/dist/index82.cjs +1 -0
- package/dist/index82.js +16 -0
- package/dist/index83.cjs +1 -0
- package/dist/index83.js +18 -0
- package/dist/index84.cjs +1 -0
- package/dist/index84.js +8 -0
- package/dist/index85.cjs +1 -0
- package/dist/index85.js +16 -0
- package/dist/index86.cjs +1 -0
- package/dist/index86.js +13 -0
- package/dist/index87.cjs +1 -0
- package/dist/index87.js +19 -0
- package/dist/index88.cjs +1 -0
- package/dist/index88.js +174 -0
- package/dist/index89.cjs +1 -0
- package/dist/index89.js +41 -0
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +44 -2
- package/dist/index90.cjs +1 -0
- package/dist/index90.js +11 -0
- package/dist/index91.cjs +1 -0
- package/dist/index91.js +7 -0
- package/dist/index92.cjs +1 -0
- package/dist/index92.js +13 -0
- package/dist/index93.cjs +1 -0
- package/dist/index93.js +4 -0
- package/dist/index94.cjs +1 -0
- package/dist/index94.js +107 -0
- package/dist/index95.cjs +1 -0
- package/dist/index95.js +45 -0
- package/dist/index96.cjs +1 -0
- package/dist/index96.js +23 -0
- package/dist/index97.cjs +1 -0
- package/dist/index97.js +9 -0
- package/dist/index98.cjs +1 -0
- package/dist/index98.js +7 -0
- package/dist/index99.cjs +1 -0
- package/dist/index99.js +40 -0
- package/dist/src/lib/auth/apikey/apikey.d.ts +12 -0
- package/dist/src/lib/auth/auth.types.d.ts +21 -8
- package/dist/src/lib/auth/index.d.ts +5 -1
- package/dist/src/lib/auth/passkey/passkey.d.ts +10 -0
- package/dist/src/lib/auth/passkey/passkey.types.d.ts +17 -0
- package/dist/src/lib/auth/passkey/passkeyLogin.d.ts +37 -0
- package/dist/src/lib/auth/{siwe.d.ts → siwe/siwe.d.ts} +4 -15
- package/dist/src/lib/utils.d.ts +3 -0
- package/package.json +2 -1
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"});const a=require("./index43.cjs"),l=require("./index69.cjs"),u=require("./index42.cjs"),f=require("./index34.cjs"),m=require("./index24.cjs"),h=new TextEncoder;function A(e,n={}){return typeof e=="number"||typeof e=="bigint"?B(e,n):typeof e=="boolean"?x(e,n):l.isHex(e)?c(e,n):T(e,n)}function x(e,n={}){const t=new Uint8Array(1);return t[0]=Number(e),typeof n.size=="number"?(f.assertSize(t,{size:n.size}),u.pad(t,{size:n.size})):t}const i={zero:48,nine:57,A:65,F:70,a:97,f:102};function g(e){if(e>=i.zero&&e<=i.nine)return e-i.zero;if(e>=i.A&&e<=i.F)return e-(i.A-10);if(e>=i.a&&e<=i.f)return e-(i.a-10)}function c(e,n={}){let t=e;n.size&&(f.assertSize(t,{size:n.size}),t=u.pad(t,{dir:"right",size:n.size}));let r=t.slice(2);r.length%2&&(r=`0${r}`);const d=r.length/2,y=new Uint8Array(d);for(let s=0,o=0;s<d;s++){const b=g(r.charCodeAt(o++)),z=g(r.charCodeAt(o++));if(b===void 0||z===void 0)throw new a.BaseError(`Invalid byte sequence ("${r[o-2]}${r[o-1]}" in "${r}").`);y[s]=b*16+z}return y}function B(e,n){const t=m.numberToHex(e,n);return c(t)}function T(e,n={}){const t=h.encode(e);return typeof n.size=="number"?(f.assertSize(t,{size:n.size}),u.pad(t,{dir:"right",size:n.size})):t}exports.boolToBytes=x;exports.hexToBytes=c;exports.numberToBytes=B;exports.stringToBytes=T;exports.toBytes=A;
|
package/dist/index55.js
CHANGED
|
@@ -1,31 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { BaseError as g } from "./index43.js";
|
|
2
|
+
import { isHex as x } from "./index69.js";
|
|
3
|
+
import { pad as s } from "./index42.js";
|
|
4
|
+
import { assertSize as u } from "./index34.js";
|
|
5
|
+
import { numberToHex as h } from "./index24.js";
|
|
6
|
+
const A = /* @__PURE__ */ new TextEncoder();
|
|
7
|
+
function F(e, n = {}) {
|
|
8
|
+
return typeof e == "number" || typeof e == "bigint" ? T(e, n) : typeof e == "boolean" ? B(e, n) : x(e) ? y(e, n) : l(e, n);
|
|
4
9
|
}
|
|
5
|
-
function
|
|
6
|
-
|
|
10
|
+
function B(e, n = {}) {
|
|
11
|
+
const r = new Uint8Array(1);
|
|
12
|
+
return r[0] = Number(e), typeof n.size == "number" ? (u(r, { size: n.size }), s(r, { size: n.size })) : r;
|
|
7
13
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
const t = {
|
|
15
|
+
zero: 48,
|
|
16
|
+
nine: 57,
|
|
17
|
+
A: 65,
|
|
18
|
+
F: 70,
|
|
19
|
+
a: 97,
|
|
20
|
+
f: 102
|
|
21
|
+
};
|
|
22
|
+
function m(e) {
|
|
23
|
+
if (e >= t.zero && e <= t.nine)
|
|
24
|
+
return e - t.zero;
|
|
25
|
+
if (e >= t.A && e <= t.F)
|
|
26
|
+
return e - (t.A - 10);
|
|
27
|
+
if (e >= t.a && e <= t.f)
|
|
28
|
+
return e - (t.a - 10);
|
|
29
|
+
}
|
|
30
|
+
function y(e, n = {}) {
|
|
31
|
+
let r = e;
|
|
32
|
+
n.size && (u(r, { size: n.size }), r = s(r, { dir: "right", size: n.size }));
|
|
33
|
+
let i = r.slice(2);
|
|
34
|
+
i.length % 2 && (i = `0${i}`);
|
|
35
|
+
const z = i.length / 2, d = new Uint8Array(z);
|
|
36
|
+
for (let f = 0, o = 0; f < z; f++) {
|
|
37
|
+
const b = m(i.charCodeAt(o++)), c = m(i.charCodeAt(o++));
|
|
38
|
+
if (b === void 0 || c === void 0)
|
|
39
|
+
throw new g(`Invalid byte sequence ("${i[o - 2]}${i[o - 1]}" in "${i}").`);
|
|
40
|
+
d[f] = b * 16 + c;
|
|
41
|
+
}
|
|
42
|
+
return d;
|
|
13
43
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (t && e.finished)
|
|
18
|
-
throw new Error("Hash#digest() has already been called");
|
|
44
|
+
function T(e, n) {
|
|
45
|
+
const r = h(e, n);
|
|
46
|
+
return y(r);
|
|
19
47
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (e.length < r)
|
|
24
|
-
throw new Error("digestInto() expects output buffer of length at least " + r);
|
|
48
|
+
function l(e, n = {}) {
|
|
49
|
+
const r = A.encode(e);
|
|
50
|
+
return typeof n.size == "number" ? (u(r, { size: n.size }), s(r, { dir: "right", size: n.size })) : r;
|
|
25
51
|
}
|
|
26
52
|
export {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
53
|
+
B as boolToBytes,
|
|
54
|
+
y as hexToBytes,
|
|
55
|
+
T as numberToBytes,
|
|
56
|
+
l as stringToBytes,
|
|
57
|
+
F as toBytes
|
|
31
58
|
};
|
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 c=require("./index94.cjs"),o=require("./index69.cjs"),i=require("./index55.cjs"),n=require("./index24.cjs");function u(e,r){const s=r||"hex",t=c.keccak_256(o.isHex(e,{strict:!1})?i.toBytes(e):e);return s==="bytes"?t:n.toHex(t)}exports.keccak256=u;
|
package/dist/index56.js
CHANGED
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { keccak_256 as c } from "./index94.js";
|
|
2
|
+
import { isHex as i } from "./index69.js";
|
|
3
|
+
import { toBytes as m } from "./index55.js";
|
|
4
|
+
import { toHex as s } from "./index24.js";
|
|
5
|
+
function x(t, r) {
|
|
6
|
+
const e = r || "hex", o = c(i(t, { strict: !1 }) ? m(t) : t);
|
|
7
|
+
return e === "bytes" ? o : s(o);
|
|
4
8
|
}
|
|
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];
|
|
10
|
-
}
|
|
11
|
-
return [n, l];
|
|
12
|
-
}
|
|
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
9
|
export {
|
|
15
|
-
|
|
16
|
-
A as rotlBH,
|
|
17
|
-
B as rotlBL,
|
|
18
|
-
g as rotlSH,
|
|
19
|
-
m as rotlSL,
|
|
20
|
-
h as split
|
|
10
|
+
x as keccak256
|
|
21
11
|
};
|
package/dist/index57.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 i extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&t!==void 0&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const s=this.keys().next().value;s&&this.delete(s)}return this}}exports.LruMap=i;
|
package/dist/index57.js
CHANGED
|
@@ -1,41 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
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();
|
|
1
|
+
class r extends Map {
|
|
2
|
+
constructor(e) {
|
|
3
|
+
super(), Object.defineProperty(this, "maxSize", {
|
|
4
|
+
enumerable: !0,
|
|
5
|
+
configurable: !0,
|
|
6
|
+
writable: !0,
|
|
7
|
+
value: void 0
|
|
8
|
+
}), this.maxSize = e;
|
|
9
|
+
}
|
|
10
|
+
get(e) {
|
|
11
|
+
const t = super.get(e);
|
|
12
|
+
return super.has(e) && t !== void 0 && (this.delete(e), super.set(e, t)), t;
|
|
13
|
+
}
|
|
14
|
+
set(e, t) {
|
|
15
|
+
if (super.set(e, t), this.maxSize && this.size > this.maxSize) {
|
|
16
|
+
const s = this.keys().next().value;
|
|
17
|
+
s && this.delete(s);
|
|
18
|
+
}
|
|
19
|
+
return this;
|
|
26
20
|
}
|
|
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
21
|
}
|
|
32
22
|
export {
|
|
33
|
-
|
|
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
|
|
23
|
+
r as LruMap
|
|
41
24
|
};
|
package/dist/index58.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index57.cjs"),i=require("./index53.cjs"),o=/^0x[a-fA-F0-9]{40}$/,t=new c.LruMap(8192);function f(e,n){const{strict:s=!0}=n??{},r=`${e}.${s}`;if(t.has(r))return t.get(r);const u=o.test(e)?e.toLowerCase()===e?!0:s?i.checksumAddress(e)===e:!0:!1;return t.set(r,u),u}exports.isAddress=f;exports.isAddressCache=t;
|
package/dist/index58.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LruMap as u } from "./index57.js";
|
|
2
|
+
import { checksumAddress as c } from "./index53.js";
|
|
3
|
+
const i = /^0x[a-fA-F0-9]{40}$/, r = /* @__PURE__ */ new u(8192);
|
|
4
|
+
function h(t, s) {
|
|
5
|
+
const { strict: n = !0 } = s ?? {}, e = `${t}.${n}`;
|
|
6
|
+
if (r.has(e))
|
|
7
|
+
return r.get(e);
|
|
8
|
+
const o = i.test(t) ? t.toLowerCase() === t ? !0 : n ? c(t) === t : !0 : !1;
|
|
9
|
+
return r.set(e, o), o;
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
h as isAddress,
|
|
13
|
+
r as isAddressCache
|
|
14
|
+
};
|
package/dist/index59.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index55.cjs"),l=require("./index24.cjs");function c(o){const{kzg:s}=o,n=o.to??(typeof o.blobs[0]=="string"?"hex":"bytes"),e=typeof o.blobs[0]=="string"?o.blobs.map(t=>i.hexToBytes(t)):o.blobs,b=[];for(const t of e)b.push(Uint8Array.from(s.blobToKzgCommitment(t)));return n==="bytes"?b:b.map(t=>l.bytesToHex(t))}exports.blobsToCommitments=c;
|
package/dist/index59.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { hexToBytes as i } from "./index55.js";
|
|
2
|
+
import { bytesToHex as f } from "./index24.js";
|
|
3
|
+
function y(o) {
|
|
4
|
+
const { kzg: s } = o, n = o.to ?? (typeof o.blobs[0] == "string" ? "hex" : "bytes"), m = typeof o.blobs[0] == "string" ? o.blobs.map((t) => i(t)) : o.blobs, b = [];
|
|
5
|
+
for (const t of m)
|
|
6
|
+
b.push(Uint8Array.from(s.blobToKzgCommitment(t)));
|
|
7
|
+
return n === "bytes" ? b : b.map((t) => f(t));
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
y as blobsToCommitments
|
|
11
|
+
};
|
package/dist/index60.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./index55.cjs"),y=require("./index24.cjs");function f(t){const{kzg:c}=t,e=t.to??(typeof t.blobs[0]=="string"?"hex":"bytes"),n=typeof t.blobs[0]=="string"?t.blobs.map(o=>b.hexToBytes(o)):t.blobs,i=typeof t.commitments[0]=="string"?t.commitments.map(o=>b.hexToBytes(o)):t.commitments,s=[];for(let o=0;o<n.length;o++){const l=n[o],m=i[o];s.push(Uint8Array.from(c.computeBlobKzgProof(l,m)))}return e==="bytes"?s:s.map(o=>y.bytesToHex(o))}exports.blobsToProofs=f;
|
package/dist/index60.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { hexToBytes as b } from "./index55.js";
|
|
2
|
+
import { bytesToHex as y } from "./index24.js";
|
|
3
|
+
function h(t) {
|
|
4
|
+
const { kzg: m } = t, c = t.to ?? (typeof t.blobs[0] == "string" ? "hex" : "bytes"), s = typeof t.blobs[0] == "string" ? t.blobs.map((o) => b(o)) : t.blobs, i = typeof t.commitments[0] == "string" ? t.commitments.map((o) => b(o)) : t.commitments, n = [];
|
|
5
|
+
for (let o = 0; o < s.length; o++) {
|
|
6
|
+
const f = s[o], l = i[o];
|
|
7
|
+
n.push(Uint8Array.from(m.computeBlobKzgProof(f, l)));
|
|
8
|
+
}
|
|
9
|
+
return c === "bytes" ? n : n.map((o) => y(o));
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
h as blobsToProofs
|
|
13
|
+
};
|
package/dist/index61.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index62.cjs");function c(o){const{commitments:e,version:s}=o,n=o.to??(typeof e[0]=="string"?"hex":"bytes"),t=[];for(const m of e)t.push(i.commitmentToVersionedHash({commitment:m,to:n,version:s}));return t}exports.commitmentsToVersionedHashes=c;
|
package/dist/index61.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { commitmentToVersionedHash as i } from "./index62.js";
|
|
2
|
+
function r(o) {
|
|
3
|
+
const { commitments: t, version: n } = o, e = o.to ?? (typeof t[0] == "string" ? "hex" : "bytes"), s = [];
|
|
4
|
+
for (const m of t)
|
|
5
|
+
s.push(i({
|
|
6
|
+
commitment: m,
|
|
7
|
+
to: e,
|
|
8
|
+
version: n
|
|
9
|
+
}));
|
|
10
|
+
return s;
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
r as commitmentsToVersionedHashes
|
|
14
|
+
};
|
package/dist/index62.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index24.cjs"),r=require("./index97.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/index62.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { bytesToHex as i } from "./index24.js";
|
|
2
|
+
import { sha256 as m } from "./index97.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
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
f as commitmentToVersionedHash
|
|
9
|
+
};
|
package/dist/index63.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index59.cjs"),m=require("./index60.cjs"),u=require("./index64.cjs");function f(t){const{data:i,kzg:n,to:b}=t,s=t.blobs??u.toBlobs({data:i,to:b}),e=t.commitments??r.blobsToCommitments({blobs:s,kzg:n,to:b}),l=t.proofs??m.blobsToProofs({blobs:s,commitments:e,kzg:n,to:b}),c=[];for(let o=0;o<s.length;o++)c.push({blob:s[o],commitment:e[o],proof:l[o]});return c}exports.toBlobSidecars=f;
|
package/dist/index63.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { blobsToCommitments as f } from "./index59.js";
|
|
2
|
+
import { blobsToProofs as l } from "./index60.js";
|
|
3
|
+
import { toBlobs as p } from "./index64.js";
|
|
4
|
+
function k(t) {
|
|
5
|
+
const { data: i, kzg: n, to: m } = t, s = t.blobs ?? p({ data: i, to: m }), b = t.commitments ?? f({ blobs: s, kzg: n, to: m }), r = t.proofs ?? l({ blobs: s, commitments: b, kzg: n, to: m }), c = [];
|
|
6
|
+
for (let o = 0; o < s.length; o++)
|
|
7
|
+
c.push({
|
|
8
|
+
blob: s[o],
|
|
9
|
+
commitment: b[o],
|
|
10
|
+
proof: r[o]
|
|
11
|
+
});
|
|
12
|
+
return c;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
k as toBlobSidecars
|
|
16
|
+
};
|
package/dist/index64.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index98.cjs"),y=require("./index99.cjs"),u=require("./index100.cjs"),B=require("./index47.cjs"),h=require("./index55.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/index64.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { maxBytesPerTransaction as y, bytesPerBlob as a, fieldElementsPerBlob as f, bytesPerFieldElement as p } from "./index98.js";
|
|
2
|
+
import { EmptyBlobError as c, BlobSizeTooLargeError as h } from "./index99.js";
|
|
3
|
+
import { createCursor as B } from "./index100.js";
|
|
4
|
+
import { size as u } from "./index47.js";
|
|
5
|
+
import { hexToBytes as x } from "./index55.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
|
|
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);
|
|
30
|
+
}
|
|
31
|
+
return m === "bytes" ? s.map((t) => t.bytes) : s.map((t) => d(t.bytes));
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
S as toBlobs
|
|
35
|
+
};
|
package/dist/index65.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index29.cjs");function f(e){if(e.type)return e.type;if(typeof e.authorizationList<"u")return"eip7702";if(typeof e.blobs<"u"||typeof e.blobVersionedHashes<"u"||typeof e.maxFeePerBlobGas<"u"||typeof e.sidecars<"u")return"eip4844";if(typeof e.maxFeePerGas<"u"||typeof e.maxPriorityFeePerGas<"u")return"eip1559";if(typeof e.gasPrice<"u")return typeof e.accessList<"u"?"eip2930":"legacy";throw new i.InvalidSerializableTransactionError({transaction:e})}exports.getTransactionType=f;
|
package/dist/index65.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { InvalidSerializableTransactionError as f } from "./index29.js";
|
|
2
|
+
function d(e) {
|
|
3
|
+
if (e.type)
|
|
4
|
+
return e.type;
|
|
5
|
+
if (typeof e.authorizationList < "u")
|
|
6
|
+
return "eip7702";
|
|
7
|
+
if (typeof e.blobs < "u" || typeof e.blobVersionedHashes < "u" || typeof e.maxFeePerBlobGas < "u" || typeof e.sidecars < "u")
|
|
8
|
+
return "eip4844";
|
|
9
|
+
if (typeof e.maxFeePerGas < "u" || typeof e.maxPriorityFeePerGas < "u")
|
|
10
|
+
return "eip1559";
|
|
11
|
+
if (typeof e.gasPrice < "u")
|
|
12
|
+
return typeof e.accessList < "u" ? "eip2930" : "legacy";
|
|
13
|
+
throw new f({ transaction: e });
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
d as getTransactionType
|
|
17
|
+
};
|
package/dist/index66.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./index49.cjs"),z=require("./index54.cjs"),o=require("./index67.cjs"),T=require("./index58.cjs"),u=require("./index47.cjs"),q=require("./index24.cjs"),g=require("./index68.cjs");function P(e){const{domain:n,message:b,primaryType:a,types:r}=e,c=(l,h)=>{for(const v of l){const{name:I,type:s}=v,t=h[I],y=s.match(g.integerRegex);if(y&&(typeof t=="number"||typeof t=="bigint")){const[w,i,D]=y;q.numberToHex(t,{signed:i==="int",size:Number.parseInt(D)/8})}if(s==="address"&&typeof t=="string"&&!T.isAddress(t))throw new z.InvalidAddressError({address:t});const f=s.match(g.bytesRegex);if(f){const[w,i]=f;if(i&&u.size(t)!==Number.parseInt(i))throw new E.BytesSizeMismatchError({expectedSize:Number.parseInt(i),givenSize:u.size(t)})}const p=r[s];p&&(x(s),c(p,t))}};if(r.EIP712Domain&&n){if(typeof n!="object")throw new o.InvalidDomainError({domain:n});c(r.EIP712Domain,n)}if(a!=="EIP712Domain")if(r[a])c(r[a],b);else throw new o.InvalidPrimaryTypeError({primaryType:a,types:r})}function d({domain:e}){return[typeof(e==null?void 0:e.name)=="string"&&{name:"name",type:"string"},(e==null?void 0:e.version)&&{name:"version",type:"string"},(typeof(e==null?void 0:e.chainId)=="number"||typeof(e==null?void 0:e.chainId)=="bigint")&&{name:"chainId",type:"uint256"},(e==null?void 0:e.verifyingContract)&&{name:"verifyingContract",type:"address"},(e==null?void 0:e.salt)&&{name:"salt",type:"bytes32"}].filter(Boolean)}function x(e){if(e==="address"||e==="bool"||e==="string"||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new o.InvalidStructTypeError({type:e})}exports.getTypesForEIP712Domain=d;exports.validateTypedData=P;
|
package/dist/index66.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { BytesSizeMismatchError as m } from "./index49.js";
|
|
2
|
+
import { InvalidAddressError as w } from "./index54.js";
|
|
3
|
+
import { InvalidDomainError as E, InvalidPrimaryTypeError as z, InvalidStructTypeError as D } from "./index67.js";
|
|
4
|
+
import { isAddress as T } from "./index58.js";
|
|
5
|
+
import { size as y } from "./index47.js";
|
|
6
|
+
import { numberToHex as x } from "./index24.js";
|
|
7
|
+
import { integerRegex as P, bytesRegex as S } from "./index68.js";
|
|
8
|
+
function j(e) {
|
|
9
|
+
const { domain: n, message: g, primaryType: o, types: r } = e, f = (h, b) => {
|
|
10
|
+
for (const u of h) {
|
|
11
|
+
const { name: l, type: s } = u, t = b[l], a = s.match(P);
|
|
12
|
+
if (a && (typeof t == "number" || typeof t == "bigint")) {
|
|
13
|
+
const [I, i, v] = a;
|
|
14
|
+
x(t, {
|
|
15
|
+
signed: i === "int",
|
|
16
|
+
size: Number.parseInt(v) / 8
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
if (s === "address" && typeof t == "string" && !T(t))
|
|
20
|
+
throw new w({ address: t });
|
|
21
|
+
const p = s.match(S);
|
|
22
|
+
if (p) {
|
|
23
|
+
const [I, i] = p;
|
|
24
|
+
if (i && y(t) !== Number.parseInt(i))
|
|
25
|
+
throw new m({
|
|
26
|
+
expectedSize: Number.parseInt(i),
|
|
27
|
+
givenSize: y(t)
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
const c = r[s];
|
|
31
|
+
c && (_(s), f(c, t));
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
if (r.EIP712Domain && n) {
|
|
35
|
+
if (typeof n != "object")
|
|
36
|
+
throw new E({ domain: n });
|
|
37
|
+
f(r.EIP712Domain, n);
|
|
38
|
+
}
|
|
39
|
+
if (o !== "EIP712Domain")
|
|
40
|
+
if (r[o])
|
|
41
|
+
f(r[o], g);
|
|
42
|
+
else
|
|
43
|
+
throw new z({ primaryType: o, types: r });
|
|
44
|
+
}
|
|
45
|
+
function F({ domain: e }) {
|
|
46
|
+
return [
|
|
47
|
+
typeof (e == null ? void 0 : e.name) == "string" && { name: "name", type: "string" },
|
|
48
|
+
(e == null ? void 0 : e.version) && { name: "version", type: "string" },
|
|
49
|
+
(typeof (e == null ? void 0 : e.chainId) == "number" || typeof (e == null ? void 0 : e.chainId) == "bigint") && {
|
|
50
|
+
name: "chainId",
|
|
51
|
+
type: "uint256"
|
|
52
|
+
},
|
|
53
|
+
(e == null ? void 0 : e.verifyingContract) && {
|
|
54
|
+
name: "verifyingContract",
|
|
55
|
+
type: "address"
|
|
56
|
+
},
|
|
57
|
+
(e == null ? void 0 : e.salt) && { name: "salt", type: "bytes32" }
|
|
58
|
+
].filter(Boolean);
|
|
59
|
+
}
|
|
60
|
+
function _(e) {
|
|
61
|
+
if (e === "address" || e === "bool" || e === "string" || e.startsWith("bytes") || e.startsWith("uint") || e.startsWith("int"))
|
|
62
|
+
throw new D({ type: e });
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
F as getTypesForEIP712Domain,
|
|
66
|
+
j as validateTypedData
|
|
67
|
+
};
|
package/dist/index67.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index38.cjs"),e=require("./index43.cjs");class i extends e.BaseError{constructor({domain:r}){super(`Invalid domain "${s.stringify(r)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class o extends e.BaseError{constructor({primaryType:r,types:a}){super(`Invalid primary type \`${r}\` must be one of \`${JSON.stringify(Object.keys(a))}\`.`,{docsPath:"/api/glossary/Errors#typeddatainvalidprimarytypeerror",metaMessages:["Check that the primary type is a key in `types`."]})}}class n extends e.BaseError{constructor({type:r}){super(`Struct type "${r}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}exports.InvalidDomainError=i;exports.InvalidPrimaryTypeError=o;exports.InvalidStructTypeError=n;
|
package/dist/index67.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { stringify as a } from "./index38.js";
|
|
2
|
+
import { BaseError as t } from "./index43.js";
|
|
3
|
+
class n extends t {
|
|
4
|
+
constructor({ domain: r }) {
|
|
5
|
+
super(`Invalid domain "${a(r)}".`, {
|
|
6
|
+
metaMessages: ["Must be a valid EIP-712 domain."]
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
class p extends t {
|
|
11
|
+
constructor({ primaryType: r, types: s }) {
|
|
12
|
+
super(`Invalid primary type \`${r}\` must be one of \`${JSON.stringify(Object.keys(s))}\`.`, {
|
|
13
|
+
docsPath: "/api/glossary/Errors#typeddatainvalidprimarytypeerror",
|
|
14
|
+
metaMessages: ["Check that the primary type is a key in `types`."]
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
class y extends t {
|
|
19
|
+
constructor({ type: r }) {
|
|
20
|
+
super(`Struct type "${r}" is invalid.`, {
|
|
21
|
+
metaMessages: ["Struct type must not be a Solidity type."],
|
|
22
|
+
name: "InvalidStructTypeError"
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
n as InvalidDomainError,
|
|
28
|
+
p as InvalidPrimaryTypeError,
|
|
29
|
+
y as InvalidStructTypeError
|
|
30
|
+
};
|
package/dist/index68.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,t=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;exports.bytesRegex=e;exports.integerRegex=t;
|
package/dist/index68.js
ADDED
package/dist/index69.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function r(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}exports.isHex=r;
|
package/dist/index69.js
ADDED
package/dist/index7.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=(t=>(t.Authorization="Authorization",t.ApiKey="api-key",t))(e||{});exports.AuthHeaderEnum=e;
|
package/dist/index7.js
CHANGED
|
@@ -1,111 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { MemoryStorage as f } from "./index8.js";
|
|
3
|
-
import { StoreKeys as d } from "./index9.js";
|
|
4
|
-
import { jwtDecode as m } from "jwt-decode";
|
|
5
|
-
import { Authorization as w } from "./index3.js";
|
|
6
|
-
import { Url as g } from "./index6.js";
|
|
7
|
-
import { createSiweMessage as y } from "./index14.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();
|
|
11
|
-
}
|
|
12
|
-
verifyToken(e, r) {
|
|
13
|
-
try {
|
|
14
|
-
const t = p(e);
|
|
15
|
-
if (!t) return n(!1);
|
|
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
|
-
}
|
|
23
|
-
}
|
|
24
|
-
async getToken() {
|
|
25
|
-
var s;
|
|
26
|
-
if (!((s = this.walletClient.account) != null && s.address))
|
|
27
|
-
return a("Wallet client does not have an account");
|
|
28
|
-
const e = this.store.getItem(d.AUTH_TOKEN);
|
|
29
|
-
if (e) {
|
|
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);
|
|
56
|
-
}
|
|
57
|
-
async signStatement() {
|
|
58
|
-
var l;
|
|
59
|
-
if (!((l = this.walletClient.account) != null && l.address))
|
|
60
|
-
return a("Wallet client does not have a valid account");
|
|
61
|
-
const e = /* @__PURE__ */ new Date(), r = new Date(e.getTime() + 300 * 1e3), i = (await u.get(
|
|
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");
|
|
105
|
-
}
|
|
106
|
-
}
|
|
1
|
+
var o = /* @__PURE__ */ ((i) => (i.Authorization = "Authorization", i.ApiKey = "api-key", i))(o || {});
|
|
107
2
|
export {
|
|
108
|
-
|
|
109
|
-
I as Siwe,
|
|
110
|
-
p as parseJwt
|
|
3
|
+
o as AuthHeaderEnum
|
|
111
4
|
};
|
package/dist/index70.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index71.cjs"),n=require("./index34.cjs"),a=require("./index55.cjs");function g({r:i,s:o,to:u="hex",v:e,yParity:r}){const s=(()=>{if(r===0||r===1)return r;if(e&&(e===27n||e===28n||e>=35n))return e%2n===0n?1:0;throw new Error("Invalid `v` or `yParity` value")})(),t=`0x${new c.secp256k1.Signature(n.hexToBigInt(i),n.hexToBigInt(o)).toCompactHex()}${s===0?"1b":"1c"}`;return u==="hex"?t:a.hexToBytes(t)}exports.serializeSignature=g;
|