@gardenfi/utils 2.1.2-beta.5 → 2.1.2-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index100.cjs +1 -1
- package/dist/index100.js +5 -5
- package/dist/index101.cjs +1 -2
- package/dist/index101.js +11 -3
- package/dist/index102.cjs +1 -1
- package/dist/index102.js +6 -18
- package/dist/index103.cjs +1 -1
- package/dist/index103.js +15 -638
- package/dist/index104.cjs +1 -1
- package/dist/index104.js +5 -173
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +2 -2
- package/dist/index18.cjs +1 -1
- package/dist/index18.js +2 -2
- package/dist/index19.cjs +1 -1
- package/dist/index19.js +9 -9
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +18 -17
- package/dist/index21.cjs +16 -1
- package/dist/index21.js +112 -30
- package/dist/index22.cjs +1 -16
- package/dist/index22.js +30 -113
- package/dist/index23.cjs +1 -2
- package/dist/index23.js +40 -49
- package/dist/index24.cjs +1 -1
- package/dist/index24.js +45 -24
- package/dist/index25.cjs +1 -1
- package/dist/index25.js +25 -41
- package/dist/index26.cjs +1 -1
- package/dist/index26.js +6 -45
- package/dist/index27.cjs +1 -1
- package/dist/index27.js +12 -24
- package/dist/index28.cjs +1 -1
- package/dist/index28.js +15 -6
- package/dist/index29.cjs +1 -1
- package/dist/index29.js +5 -13
- package/dist/index30.cjs +1 -1
- package/dist/index30.js +12 -14
- package/dist/index31.cjs +1 -1
- package/dist/index31.js +10 -5
- package/dist/index32.cjs +1 -1
- package/dist/index32.js +12 -13
- package/dist/index33.cjs +1 -1
- package/dist/index33.js +11 -10
- package/dist/index34.cjs +1 -1
- package/dist/index34.js +13 -12
- package/dist/index35.cjs +1 -1
- package/dist/index35.js +23 -11
- package/dist/index36.cjs +1 -1
- package/dist/index36.js +55 -13
- package/dist/index37.cjs +1 -1
- package/dist/index37.js +16 -23
- package/dist/index38.cjs +1 -1
- package/dist/index38.js +5 -55
- package/dist/index39.cjs +1 -1
- package/dist/index39.js +8 -16
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +3 -5
- package/dist/index40.cjs +1 -1
- package/dist/index40.js +171 -5
- package/dist/index41.cjs +1 -1
- package/dist/index41.js +103 -8
- package/dist/index42.cjs +1 -1
- package/dist/index42.js +20 -170
- package/dist/index43.cjs +2 -1
- package/dist/index43.js +44 -97
- package/dist/index44.cjs +1 -1
- package/dist/index44.js +24 -21
- package/dist/index45.cjs +1 -1
- package/dist/index45.js +1 -1
- package/dist/index46.cjs +1 -1
- package/dist/index46.js +1 -1
- package/dist/index47.cjs +1 -1
- package/dist/index47.js +40 -6
- package/dist/index48.cjs +1 -2
- package/dist/index48.js +33 -58
- package/dist/index49.cjs +1 -1
- package/dist/index49.js +70 -2
- package/dist/index50.cjs +1 -1
- package/dist/index50.js +111 -5
- package/dist/index51.cjs +1 -1
- package/dist/index51.js +67 -4
- package/dist/index52.cjs +1 -1
- package/dist/index52.js +2 -12
- package/dist/index53.cjs +1 -1
- package/dist/index53.js +17 -8
- package/dist/index54.cjs +1 -5
- package/dist/index54.js +215 -48
- package/dist/index55.cjs +1 -2
- package/dist/index55.js +228 -31
- package/dist/index56.cjs +2 -1
- package/dist/index56.js +59 -5
- package/dist/index57.cjs +1 -1
- package/dist/index57.js +22 -2
- package/dist/index58.cjs +1 -1
- package/dist/index58.js +101 -18
- package/dist/index59.cjs +1 -1
- package/dist/index59.js +3 -8
- package/dist/index60.cjs +1 -1
- package/dist/index60.js +16 -9
- package/dist/index61.cjs +1 -1
- package/dist/index61.js +8 -11
- package/dist/index62.cjs +1 -1
- package/dist/index62.js +10 -6
- package/dist/index63.cjs +1 -1
- package/dist/index63.js +11 -13
- package/dist/index64.cjs +1 -1
- package/dist/index64.js +12 -31
- package/dist/index65.cjs +1 -1
- package/dist/index65.js +18 -14
- package/dist/index66.cjs +1 -1
- package/dist/index66.js +6 -64
- package/dist/index67.cjs +1 -1
- package/dist/index67.js +40 -25
- package/dist/index68.cjs +1 -1
- package/dist/index68.js +79 -3
- package/dist/index69.cjs +1 -1
- package/dist/index69.js +14 -3
- package/dist/index70.cjs +1 -1
- package/dist/index70.js +18 -8
- package/dist/index71.cjs +1 -1
- package/dist/index71.js +8 -191
- package/dist/index72.cjs +1 -1
- package/dist/index72.js +191 -18
- package/dist/index73.cjs +1 -1
- package/dist/index73.js +63 -7
- package/dist/index74.cjs +1 -1
- package/dist/index74.js +4 -40
- package/dist/index75.cjs +1 -1
- package/dist/index75.js +2 -35
- package/dist/index76.cjs +1 -1
- package/dist/index76.js +5 -68
- package/dist/index77.cjs +1 -1
- package/dist/index77.js +11 -112
- package/dist/index78.cjs +1 -1
- package/dist/index78.js +8 -68
- package/dist/index79.cjs +5 -1
- package/dist/index79.js +57 -2
- package/dist/index80.cjs +2 -1
- package/dist/index80.js +33 -15
- package/dist/index81.cjs +1 -1
- package/dist/index81.js +5 -223
- package/dist/index82.cjs +1 -1
- package/dist/index82.js +2 -232
- package/dist/index83.cjs +1 -1
- package/dist/index83.js +6 -42
- package/dist/index84.cjs +1 -1
- package/dist/index84.js +30 -102
- package/dist/index85.cjs +1 -1
- package/dist/index85.js +26 -16
- package/dist/index86.cjs +1 -1
- package/dist/index86.js +3 -79
- package/dist/index87.cjs +1 -1
- package/dist/index87.js +10 -17
- package/dist/index88.cjs +1 -1
- package/dist/index88.js +18 -11
- package/dist/index89.cjs +1 -1
- package/dist/index89.js +8 -38
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +2 -2
- package/dist/index90.cjs +1 -1
- package/dist/index90.js +13 -2
- package/dist/index91.cjs +1 -1
- package/dist/index91.js +19 -5
- package/dist/index92.cjs +1 -1
- package/dist/index92.js +643 -10
- package/dist/index93.cjs +1 -1
- package/dist/index93.js +171 -10
- package/dist/index94.cjs +1 -1
- package/dist/index94.js +127 -19
- package/dist/index95.cjs +2 -1
- package/dist/index95.js +3 -128
- package/dist/index96.cjs +1 -1
- package/dist/index96.js +2 -7
- package/dist/index97.cjs +1 -1
- package/dist/index97.js +2 -2
- package/dist/index98.cjs +1 -1
- package/dist/index98.js +2 -2
- package/dist/index99.cjs +1 -1
- package/dist/index99.js +35 -17
- package/package.json +1 -1
package/dist/index84.js
CHANGED
|
@@ -1,107 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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];
|
|
1
|
+
import { maxBytesPerTransaction as y, bytesPerBlob as a, fieldElementsPerBlob as f, bytesPerFieldElement as p } from "./index104.js";
|
|
2
|
+
import { EmptyBlobError as c, BlobSizeTooLargeError as h } from "./index98.js";
|
|
3
|
+
import { createCursor as B } from "./index94.js";
|
|
4
|
+
import { size as u } from "./index74.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
|
|
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;
|
|
33
28
|
}
|
|
34
|
-
|
|
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;
|
|
29
|
+
s.push(t);
|
|
100
30
|
}
|
|
31
|
+
return m === "bytes" ? s.map((t) => t.bytes) : s.map((t) => d(t.bytes));
|
|
101
32
|
}
|
|
102
|
-
const G = (e, t, s) => X(() => new p(t, e, s)), Q = /* @__PURE__ */ G(1, 136, 256 / 8);
|
|
103
33
|
export {
|
|
104
|
-
|
|
105
|
-
D as keccakP,
|
|
106
|
-
Q as keccak_256
|
|
34
|
+
S as toBlobs
|
|
107
35
|
};
|
package/dist/index85.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 s=require("./index82.cjs"),e=require("./index56.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/index85.js
CHANGED
|
@@ -1,20 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { stringify as a } from "./index82.js";
|
|
2
|
+
import { BaseError as t } from "./index56.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
|
+
});
|
|
15
24
|
}
|
|
16
|
-
return t;
|
|
17
25
|
}
|
|
18
26
|
export {
|
|
19
|
-
|
|
27
|
+
n as InvalidDomainError,
|
|
28
|
+
p as InvalidPrimaryTypeError,
|
|
29
|
+
y as InvalidStructTypeError
|
|
20
30
|
};
|
package/dist/index86.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 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/index86.js
CHANGED
|
@@ -1,81 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import { maxUint256 as m } from "./index90.js";
|
|
3
|
-
import { InvalidAddressError as s } from "./index34.js";
|
|
4
|
-
import { BaseError as h } from "./index48.js";
|
|
5
|
-
import { EmptyBlobError as P, InvalidVersionedHashSizeError as p, InvalidVersionedHashVersionError as x } from "./index98.js";
|
|
6
|
-
import { InvalidChainIdError as n } from "./index50.js";
|
|
7
|
-
import { FeeCapTooHighError as w, TipAboveFeeCapError as E } from "./index55.js";
|
|
8
|
-
import { isAddress as f } from "./index35.js";
|
|
9
|
-
import { size as F } from "./index51.js";
|
|
10
|
-
import { slice as I } from "./index89.js";
|
|
11
|
-
import { hexToNumber as G } from "./index37.js";
|
|
12
|
-
function C(t) {
|
|
13
|
-
const { authorizationList: e } = t;
|
|
14
|
-
if (e)
|
|
15
|
-
for (const o of e) {
|
|
16
|
-
const { chainId: r } = o, i = o.address;
|
|
17
|
-
if (!f(i))
|
|
18
|
-
throw new s({ address: i });
|
|
19
|
-
if (r < 0)
|
|
20
|
-
throw new n({ chainId: r });
|
|
21
|
-
}
|
|
22
|
-
d(t);
|
|
23
|
-
}
|
|
24
|
-
function L(t) {
|
|
25
|
-
const { blobVersionedHashes: e } = t;
|
|
26
|
-
if (e) {
|
|
27
|
-
if (e.length === 0)
|
|
28
|
-
throw new P();
|
|
29
|
-
for (const o of e) {
|
|
30
|
-
const r = F(o), i = G(I(o, 0, 1));
|
|
31
|
-
if (r !== 32)
|
|
32
|
-
throw new p({ hash: o, size: r });
|
|
33
|
-
if (i !== c)
|
|
34
|
-
throw new x({
|
|
35
|
-
hash: o,
|
|
36
|
-
version: i
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
d(t);
|
|
41
|
-
}
|
|
42
|
-
function d(t) {
|
|
43
|
-
const { chainId: e, maxPriorityFeePerGas: o, maxFeePerGas: r, to: i } = t;
|
|
44
|
-
if (e <= 0)
|
|
45
|
-
throw new n({ chainId: e });
|
|
46
|
-
if (i && !f(i))
|
|
47
|
-
throw new s({ address: i });
|
|
48
|
-
if (r && r > m)
|
|
49
|
-
throw new w({ maxFeePerGas: r });
|
|
50
|
-
if (o && r && o > r)
|
|
51
|
-
throw new E({ maxFeePerGas: r, maxPriorityFeePerGas: o });
|
|
52
|
-
}
|
|
53
|
-
function B(t) {
|
|
54
|
-
const { chainId: e, maxPriorityFeePerGas: o, gasPrice: r, maxFeePerGas: i, to: a } = t;
|
|
55
|
-
if (e <= 0)
|
|
56
|
-
throw new n({ chainId: e });
|
|
57
|
-
if (a && !f(a))
|
|
58
|
-
throw new s({ address: a });
|
|
59
|
-
if (o || i)
|
|
60
|
-
throw new h("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");
|
|
61
|
-
if (r && r > m)
|
|
62
|
-
throw new w({ maxFeePerGas: r });
|
|
63
|
-
}
|
|
64
|
-
function K(t) {
|
|
65
|
-
const { chainId: e, maxPriorityFeePerGas: o, gasPrice: r, maxFeePerGas: i, to: a } = t;
|
|
66
|
-
if (a && !f(a))
|
|
67
|
-
throw new s({ address: a });
|
|
68
|
-
if (typeof e < "u" && e <= 0)
|
|
69
|
-
throw new n({ chainId: e });
|
|
70
|
-
if (o || i)
|
|
71
|
-
throw new h("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");
|
|
72
|
-
if (r && r > m)
|
|
73
|
-
throw new w({ maxFeePerGas: r });
|
|
74
|
-
}
|
|
1
|
+
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)?$/;
|
|
75
2
|
export {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
L as assertTransactionEIP4844,
|
|
79
|
-
C as assertTransactionEIP7702,
|
|
80
|
-
K as assertTransactionLegacy
|
|
3
|
+
e as bytesRegex,
|
|
4
|
+
t as integerRegex
|
|
81
5
|
};
|
package/dist/index87.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 a=require("./index56.cjs");class t extends a.BaseError{constructor(e){const{docsPath:s,field:r,metaMessages:i}=e;super(`Invalid Sign-In with Ethereum message field "${r}".`,{docsPath:s,metaMessages:i,name:"SiweInvalidMessageFieldError"})}}exports.SiweInvalidMessageFieldError=t;
|
package/dist/index87.js
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
for (let t = 0; t < e.length; t++)
|
|
11
|
-
if (e[t].length - 2 !== 64)
|
|
12
|
-
throw new l({ storageKey: e[t] });
|
|
13
|
-
if (!f(i, { strict: !1 }))
|
|
14
|
-
throw new s({ address: i });
|
|
15
|
-
n.push([i, e]);
|
|
1
|
+
import { BaseError as i } from "./index56.js";
|
|
2
|
+
class d extends i {
|
|
3
|
+
constructor(e) {
|
|
4
|
+
const { docsPath: s, field: r, metaMessages: a } = e;
|
|
5
|
+
super(`Invalid Sign-In with Ethereum message field "${r}".`, {
|
|
6
|
+
docsPath: s,
|
|
7
|
+
metaMessages: a,
|
|
8
|
+
name: "SiweInvalidMessageFieldError"
|
|
9
|
+
});
|
|
16
10
|
}
|
|
17
|
-
return n;
|
|
18
11
|
}
|
|
19
12
|
export {
|
|
20
|
-
|
|
13
|
+
d as SiweInvalidMessageFieldError
|
|
21
14
|
};
|
package/dist/index88.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(/[^a-z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~\%]/i.test(e)||/%[^0-9a-f]/i.test(e)||/%[0-9a-f](:?[^0-9a-f]|$)/i.test(e))return!1;const s=a(e),f=s[1],t=s[2],i=s[3],r=s[4],l=s[5];if(!(f!=null&&f.length&&i.length>=0))return!1;if(t!=null&&t.length){if(!(i.length===0||/^\//.test(i)))return!1}else if(/^\/\//.test(i))return!1;if(!/^[a-z][a-z0-9\+\-\.]*$/.test(f.toLowerCase()))return!1;let n="";return n+=`${f}:`,t!=null&&t.length&&(n+=`//${t}`),n+=i,r!=null&&r.length&&(n+=`?${r}`),l!=null&&l.length&&(n+=`#${l}`),n}function a(e){return e.match(/(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/)}exports.isUri=o;
|
package/dist/index88.js
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
function o(e) {
|
|
2
|
+
if (/[^a-z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~\%]/i.test(e) || /%[^0-9a-f]/i.test(e) || /%[0-9a-f](:?[^0-9a-f]|$)/i.test(e))
|
|
3
|
+
return !1;
|
|
4
|
+
const s = a(e), f = s[1], t = s[2], i = s[3], r = s[4], l = s[5];
|
|
5
|
+
if (!(f != null && f.length && i.length >= 0))
|
|
6
|
+
return !1;
|
|
7
|
+
if (t != null && t.length) {
|
|
8
|
+
if (!(i.length === 0 || /^\//.test(i)))
|
|
9
|
+
return !1;
|
|
10
|
+
} else if (/^\/\//.test(i))
|
|
11
|
+
return !1;
|
|
12
|
+
if (!/^[a-z][a-z0-9\+\-\.]*$/.test(f.toLowerCase()))
|
|
13
|
+
return !1;
|
|
14
|
+
let n = "";
|
|
15
|
+
return n += `${f}:`, t != null && t.length && (n += `//${t}`), n += i, r != null && r.length && (n += `?${r}`), l != null && l.length && (n += `#${l}`), n;
|
|
6
16
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
super(`${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()} size (${r}) exceeds padding size (${s}).`, { name: "SizeExceedsPaddingSizeError" });
|
|
10
|
-
}
|
|
17
|
+
function a(e) {
|
|
18
|
+
return e.match(/(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/);
|
|
11
19
|
}
|
|
12
20
|
export {
|
|
13
|
-
|
|
14
|
-
d as SliceOffsetOutOfBoundsError
|
|
21
|
+
o as isUri
|
|
15
22
|
};
|
package/dist/index89.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 n(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}exports.defineChain=n;
|
package/dist/index89.js
CHANGED
|
@@ -1,41 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
strict: o
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
function s(e, f) {
|
|
12
|
-
if (typeof f == "number" && f > 0 && f > r(e) - 1)
|
|
13
|
-
throw new t({
|
|
14
|
-
offset: f,
|
|
15
|
-
position: "start",
|
|
16
|
-
size: r(e)
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
function c(e, f, i) {
|
|
20
|
-
if (typeof f == "number" && typeof i == "number" && r(e) !== i - f)
|
|
21
|
-
throw new t({
|
|
22
|
-
offset: i,
|
|
23
|
-
position: "end",
|
|
24
|
-
size: r(e)
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
function m(e, f, i, { strict: o } = {}) {
|
|
28
|
-
s(e, f);
|
|
29
|
-
const n = e.slice(f, i);
|
|
30
|
-
return o && c(n, f, i), n;
|
|
31
|
-
}
|
|
32
|
-
function u(e, f, i, { strict: o } = {}) {
|
|
33
|
-
s(e, f);
|
|
34
|
-
const n = `0x${e.replace("0x", "").slice((f ?? 0) * 2, (i ?? e.length) * 2)}`;
|
|
35
|
-
return o && c(n, f, i), n;
|
|
1
|
+
function n(e) {
|
|
2
|
+
return {
|
|
3
|
+
formatters: void 0,
|
|
4
|
+
fees: void 0,
|
|
5
|
+
serializers: void 0,
|
|
6
|
+
...e
|
|
7
|
+
};
|
|
36
8
|
}
|
|
37
9
|
export {
|
|
38
|
-
|
|
39
|
-
m as sliceBytes,
|
|
40
|
-
u as sliceHex
|
|
10
|
+
n as defineChain
|
|
41
11
|
};
|
package/dist/index9.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("tough-cookie"),k=require("fetch-cookie"),n=require("./index17.cjs"),m=require("./index13.cjs"),f=require("./index14.cjs"),w=require("viem"),h=require("./index3.cjs"),y=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("tough-cookie"),k=require("fetch-cookie"),n=require("./index17.cjs"),m=require("./index13.cjs"),f=require("./index14.cjs"),w=require("viem"),h=require("./index3.cjs"),y=require("./index20.cjs"),C=require("./index19.cjs"),T=require("./index21.cjs"),v=c=>c&&c.__esModule?c:{default:c},S=v(k);class d{constructor(t,i,e){if(this.url=t.endpoint("siwe"),this.walletClient=i,this.domain=(e==null?void 0:e.domain)||"app.garden.finance",this.domain.startsWith("https://")&&(this.domain=this.domain.split("https://")[1]),this.signingStatement=(e==null?void 0:e.signingStatement)??"Garden.fi",this.store=(e==null?void 0:e.store)??(typeof window<"u"?window.localStorage:new m.MemoryStorage),typeof window>"u"){const r=new g.CookieJar;this.fetchWithCookies=S.default(fetch,r)}else this.fetchWithCookies=window.fetch.bind(window)}static fromDigestKey(t,i,e){const r=w.createWalletClient({account:C.privateKeyToAccount(h.add0x(i.digestKey)),transport:w.http(),chain:y.mainnet});return new d(t,r,e)}verifyToken(t,i){try{const e=h.parseJwt(t);if(!e)return n.Ok(!1);const r=Math.floor(Date.now()/1e3)+120;return n.Ok(e.exp>r&&e.user_id.toLowerCase()===i.toLowerCase())}catch{return n.Ok(!1)}}async getToken(){var s;if(!((s=this.walletClient.account)!=null&&s.address))return n.Err("Wallet client does not have an account");const t=this.store.getItem(f.StoreKeys.AUTH_TOKEN);if(t){const o=this.verifyToken(t,this.walletClient.account.address);if(o.ok&&o.val)return n.Ok(t)}const i=await this.signStatement();if(i.error)return n.Err(i.error);let e;try{const a=await(await this.fetchWithCookies(this.url.endpoint("tokens"),{method:"POST",body:JSON.stringify({...i.val}),headers:{"Content-Type":"application/json"},credentials:"include"})).json();if(a.error||!a.result)return n.Err(a.error??"Failed to get token");e=a.result}catch(o){return n.Err("Failed to get token",o)}if(!this.verifyToken(e,this.walletClient.account.address).val)throw new Error("Token verification failed");return this.store.setItem(f.StoreKeys.AUTH_TOKEN,e),n.Ok(e)}async signStatement(){var a;if(!((a=this.walletClient.account)!=null&&a.address))return n.Err("Wallet client does not have a valid account");const t=new Date,i=new Date(t.getTime()+300*1e3);let e;try{const l=await(await this.fetchWithCookies(this.url.endpoint("challenges"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include"})).json();if(l.error||!l.result)return n.Err("Failed to get nonce");e=l.result}catch(u){return n.Err("Failed to get nonce",u)}const r=await this.walletClient.getChainId(),s=T.createSiweMessage({domain:this.domain,address:this.walletClient.account.address,statement:this.signingStatement,nonce:e,uri:"https://"+this.domain,version:"1",chainId:r,notBefore:i}),o=await this.walletClient.signMessage({account:this.walletClient.account,message:s});return n.Ok({message:s,signature:o,nonce:e})}async getAuthHeaders(){const t=await this.getToken();return t.error?n.Err(t.error):n.Ok({Authorization:h.Authorization(t.val)})}}exports.Siwe=d;
|
package/dist/index9.js
CHANGED
|
@@ -5,9 +5,9 @@ import { MemoryStorage as w } from "./index13.js";
|
|
|
5
5
|
import { StoreKeys as d } from "./index14.js";
|
|
6
6
|
import { createWalletClient as g, http as k } from "viem";
|
|
7
7
|
import { add0x as p, parseJwt as y, Authorization as C } from "./index3.js";
|
|
8
|
-
import { mainnet as T } from "./
|
|
8
|
+
import { mainnet as T } from "./index20.js";
|
|
9
9
|
import { privateKeyToAccount as v } from "./index19.js";
|
|
10
|
-
import { createSiweMessage as S } from "./
|
|
10
|
+
import { createSiweMessage as S } from "./index21.js";
|
|
11
11
|
class f {
|
|
12
12
|
constructor(e, n, t) {
|
|
13
13
|
if (this.url = e.endpoint("siwe"), this.walletClient = n, 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) ?? (typeof window < "u" ? window.localStorage : new w()), typeof window > "u") {
|
package/dist/index90.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index56.cjs");class i extends t.BaseError{constructor({offset:r,position:s,size:e}){super(`Slice ${s==="start"?"starting":"ending"} at offset "${r}" is out-of-bounds (size: ${e}).`,{name:"SliceOffsetOutOfBoundsError"})}}class d extends t.BaseError{constructor({size:r,targetSize:s,type:e}){super(`${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()} size (${r}) exceeds padding size (${s}).`,{name:"SizeExceedsPaddingSizeError"})}}exports.SizeExceedsPaddingSizeError=d;exports.SliceOffsetOutOfBoundsError=i;
|
package/dist/index90.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import { BaseError as o } from "./index56.js";
|
|
2
|
+
class d extends o {
|
|
3
|
+
constructor({ offset: r, position: s, size: e }) {
|
|
4
|
+
super(`Slice ${s === "start" ? "starting" : "ending"} at offset "${r}" is out-of-bounds (size: ${e}).`, { name: "SliceOffsetOutOfBoundsError" });
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
class n extends o {
|
|
8
|
+
constructor({ size: r, targetSize: s, type: e }) {
|
|
9
|
+
super(`${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()} size (${r}) exceeds padding size (${s}).`, { name: "SizeExceedsPaddingSizeError" });
|
|
10
|
+
}
|
|
11
|
+
}
|
|
2
12
|
export {
|
|
3
|
-
n as
|
|
13
|
+
n as SizeExceedsPaddingSizeError,
|
|
14
|
+
d as SliceOffsetOutOfBoundsError
|
|
4
15
|
};
|
package/dist/index91.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={
|
|
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/index91.js
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
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 };
|
|
4
|
+
}
|
|
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;
|
|
5
14
|
export {
|
|
6
|
-
|
|
15
|
+
f as fromBig,
|
|
16
|
+
A as rotlBH,
|
|
17
|
+
B as rotlBL,
|
|
18
|
+
g as rotlSH,
|
|
19
|
+
m as rotlSL,
|
|
20
|
+
h as split
|
|
7
21
|
};
|
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 tt=require("./index93.cjs"),Q=require("./index54.cjs"),a=require("./index55.cjs");/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ot(h){h.lowS!==void 0&&a.abool("lowS",h.lowS),h.prehash!==void 0&&a.abool("prehash",h.prehash)}function ct(h){const n=tt.validateBasic(h);a.validateObject(n,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:b,a:O}=n;if(t){if(!b.eql(O,b.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...n})}const{bytesToNumberBE:lt,hexToBytes:ut}=a;class it extends Error{constructor(n=""){super(n)}}const Y={Err:it,_tlv:{encode:(h,n)=>{const{Err:t}=Y;if(h<0||h>256)throw new t("tlv.encode: wrong tag");if(n.length&1)throw new t("tlv.encode: unpadded data");const b=n.length/2,O=a.numberToHexUnpadded(b);if(O.length/2&128)throw new t("tlv.encode: long form length too big");const Z=b>127?a.numberToHexUnpadded(O.length/2|128):"";return a.numberToHexUnpadded(h)+Z+O+n},decode(h,n){const{Err:t}=Y;let b=0;if(h<0||h>256)throw new t("tlv.encode: wrong tag");if(n.length<2||n[b++]!==h)throw new t("tlv.decode: wrong tlv");const O=n[b++],Z=!!(O&128);let x=0;if(!Z)x=O;else{const R=O&127;if(!R)throw new t("tlv.decode(long): indefinite length not supported");if(R>4)throw new t("tlv.decode(long): byte length is too big");const L=n.subarray(b,b+R);if(L.length!==R)throw new t("tlv.decode: length bytes not complete");if(L[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(const P of L)x=x<<8|P;if(b+=R,x<128)throw new t("tlv.decode(long): not minimal encoding")}const V=n.subarray(b,b+x);if(V.length!==x)throw new t("tlv.decode: wrong value length");return{v:V,l:n.subarray(b+x)}}},_int:{encode(h){const{Err:n}=Y;if(h<C)throw new n("integer: negative integers are not allowed");let t=a.numberToHexUnpadded(h);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new n("unexpected DER parsing assertion: unpadded hex");return t},decode(h){const{Err:n}=Y;if(h[0]&128)throw new n("invalid signature integer: negative");if(h[0]===0&&!(h[1]&128))throw new n("invalid signature integer: unnecessary leading zero");return lt(h)}},toSig(h){const{Err:n,_int:t,_tlv:b}=Y,O=typeof h=="string"?ut(h):h;a.abytes(O);const{v:Z,l:x}=b.decode(48,O);if(x.length)throw new n("invalid signature: left bytes after parsing");const{v:V,l:R}=b.decode(2,Z),{v:L,l:P}=b.decode(2,R);if(P.length)throw new n("invalid signature: left bytes after parsing");return{r:t.decode(V),s:t.decode(L)}},hexFromSig(h){const{_tlv:n,_int:t}=Y,b=n.encode(2,t.encode(h.r)),O=n.encode(2,t.encode(h.s)),Z=b+O;return n.encode(48,Z)}},C=BigInt(0),T=BigInt(1);BigInt(2);const st=BigInt(3);BigInt(4);function at(h){const n=ct(h),{Fp:t}=n,b=Q.Field(n.n,n.nBitLength),O=n.toBytes||((m,e,s)=>{const c=e.toAffine();return a.concatBytes(Uint8Array.from([4]),t.toBytes(c.x),t.toBytes(c.y))}),Z=n.fromBytes||(m=>{const e=m.subarray(1),s=t.fromBytes(e.subarray(0,t.BYTES)),c=t.fromBytes(e.subarray(t.BYTES,2*t.BYTES));return{x:s,y:c}});function x(m){const{a:e,b:s}=n,c=t.sqr(m),d=t.mul(c,m);return t.add(t.add(d,t.mul(m,e)),s)}if(!t.eql(t.sqr(n.Gy),x(n.Gx)))throw new Error("bad generator point: equation left != right");function V(m){return a.inRange(m,T,n.n)}function R(m){const{allowedPrivateKeyLengths:e,nByteLength:s,wrapPrivateKey:c,n:d}=n;if(e&&typeof m!="bigint"){if(a.isBytes(m)&&(m=a.bytesToHex(m)),typeof m!="string"||!e.includes(m.length))throw new Error("invalid private key");m=m.padStart(s*2,"0")}let p;try{p=typeof m=="bigint"?m:a.bytesToNumberBE(a.ensureBytes("private key",m,s))}catch{throw new Error("invalid private key, expected hex or "+s+" bytes, got "+typeof m)}return c&&(p=Q.mod(p,d)),a.aInRange("private key",p,T,d),p}function L(m){if(!(m instanceof w))throw new Error("ProjectivePoint expected")}const P=a.memoized((m,e)=>{const{px:s,py:c,pz:d}=m;if(t.eql(d,t.ONE))return{x:s,y:c};const p=m.is0();e==null&&(e=p?t.ONE:t.inv(d));const v=t.mul(s,e),g=t.mul(c,e),l=t.mul(d,e);if(p)return{x:t.ZERO,y:t.ZERO};if(!t.eql(l,t.ONE))throw new Error("invZ was invalid");return{x:v,y:g}}),et=a.memoized(m=>{if(m.is0()){if(n.allowInfinityPoint&&!t.is0(m.py))return;throw new Error("bad point: ZERO")}const{x:e,y:s}=m.toAffine();if(!t.isValid(e)||!t.isValid(s))throw new Error("bad point: x or y not FE");const c=t.sqr(s),d=x(e);if(!t.eql(c,d))throw new Error("bad point: equation left != right");if(!m.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class w{constructor(e,s,c){if(this.px=e,this.py=s,this.pz=c,e==null||!t.isValid(e))throw new Error("x required");if(s==null||!t.isValid(s))throw new Error("y required");if(c==null||!t.isValid(c))throw new Error("z required");Object.freeze(this)}static fromAffine(e){const{x:s,y:c}=e||{};if(!e||!t.isValid(s)||!t.isValid(c))throw new Error("invalid affine point");if(e instanceof w)throw new Error("projective point not allowed");const d=p=>t.eql(p,t.ZERO);return d(s)&&d(c)?w.ZERO:new w(s,c,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const s=t.invertBatch(e.map(c=>c.pz));return e.map((c,d)=>c.toAffine(s[d])).map(w.fromAffine)}static fromHex(e){const s=w.fromAffine(Z(a.ensureBytes("pointHex",e)));return s.assertValidity(),s}static fromPrivateKey(e){return w.BASE.multiply(R(e))}static msm(e,s){return tt.pippenger(w,b,e,s)}_setWindowSize(e){j.setWindowSize(this,e)}assertValidity(){et(this)}hasEvenY(){const{y:e}=this.toAffine();if(t.isOdd)return!t.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){L(e);const{px:s,py:c,pz:d}=this,{px:p,py:v,pz:g}=e,l=t.eql(t.mul(s,g),t.mul(p,d)),y=t.eql(t.mul(c,g),t.mul(v,d));return l&&y}negate(){return new w(this.px,t.neg(this.py),this.pz)}double(){const{a:e,b:s}=n,c=t.mul(s,st),{px:d,py:p,pz:v}=this;let g=t.ZERO,l=t.ZERO,y=t.ZERO,u=t.mul(d,d),N=t.mul(p,p),S=t.mul(v,v),B=t.mul(d,p);return B=t.add(B,B),y=t.mul(d,v),y=t.add(y,y),g=t.mul(e,y),l=t.mul(c,S),l=t.add(g,l),g=t.sub(N,l),l=t.add(N,l),l=t.mul(g,l),g=t.mul(B,g),y=t.mul(c,y),S=t.mul(e,S),B=t.sub(u,S),B=t.mul(e,B),B=t.add(B,y),y=t.add(u,u),u=t.add(y,u),u=t.add(u,S),u=t.mul(u,B),l=t.add(l,u),S=t.mul(p,v),S=t.add(S,S),u=t.mul(S,B),g=t.sub(g,u),y=t.mul(S,N),y=t.add(y,y),y=t.add(y,y),new w(g,l,y)}add(e){L(e);const{px:s,py:c,pz:d}=this,{px:p,py:v,pz:g}=e;let l=t.ZERO,y=t.ZERO,u=t.ZERO;const N=n.a,S=t.mul(n.b,st);let B=t.mul(s,p),F=t.mul(c,v),r=t.mul(d,g),o=t.add(s,c),i=t.add(p,v);o=t.mul(o,i),i=t.add(B,F),o=t.sub(o,i),i=t.add(s,d);let f=t.add(p,g);return i=t.mul(i,f),f=t.add(B,r),i=t.sub(i,f),f=t.add(c,d),l=t.add(v,g),f=t.mul(f,l),l=t.add(F,r),f=t.sub(f,l),u=t.mul(N,i),l=t.mul(S,r),u=t.add(l,u),l=t.sub(F,u),u=t.add(F,u),y=t.mul(l,u),F=t.add(B,B),F=t.add(F,B),r=t.mul(N,r),i=t.mul(S,i),F=t.add(F,r),r=t.sub(B,r),r=t.mul(N,r),i=t.add(i,r),B=t.mul(F,i),y=t.add(y,B),B=t.mul(f,i),l=t.mul(o,l),l=t.sub(l,B),B=t.mul(o,F),u=t.mul(f,u),u=t.add(u,B),new w(l,y,u)}subtract(e){return this.add(e.negate())}is0(){return this.equals(w.ZERO)}wNAF(e){return j.wNAFCached(this,e,w.normalizeZ)}multiplyUnsafe(e){const{endo:s,n:c}=n;a.aInRange("scalar",e,C,c);const d=w.ZERO;if(e===C)return d;if(this.is0()||e===T)return this;if(!s||j.hasPrecomputes(this))return j.wNAFCachedUnsafe(this,e,w.normalizeZ);let{k1neg:p,k1:v,k2neg:g,k2:l}=s.splitScalar(e),y=d,u=d,N=this;for(;v>C||l>C;)v&T&&(y=y.add(N)),l&T&&(u=u.add(N)),N=N.double(),v>>=T,l>>=T;return p&&(y=y.negate()),g&&(u=u.negate()),u=new w(t.mul(u.px,s.beta),u.py,u.pz),y.add(u)}multiply(e){const{endo:s,n:c}=n;a.aInRange("scalar",e,T,c);let d,p;if(s){const{k1neg:v,k1:g,k2neg:l,k2:y}=s.splitScalar(e);let{p:u,f:N}=this.wNAF(g),{p:S,f:B}=this.wNAF(y);u=j.constTimeNegate(v,u),S=j.constTimeNegate(l,S),S=new w(t.mul(S.px,s.beta),S.py,S.pz),d=u.add(S),p=N.add(B)}else{const{p:v,f:g}=this.wNAF(e);d=v,p=g}return w.normalizeZ([d,p])[0]}multiplyAndAddUnsafe(e,s,c){const d=w.BASE,p=(g,l)=>l===C||l===T||!g.equals(d)?g.multiplyUnsafe(l):g.multiply(l),v=p(this,s).add(p(e,c));return v.is0()?void 0:v}toAffine(e){return P(this,e)}isTorsionFree(){const{h:e,isTorsionFree:s}=n;if(e===T)return!0;if(s)return s(w,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:s}=n;return e===T?this:s?s(w,this):this.multiplyUnsafe(n.h)}toRawBytes(e=!0){return a.abool("isCompressed",e),this.assertValidity(),O(w,this,e)}toHex(e=!0){return a.abool("isCompressed",e),a.bytesToHex(this.toRawBytes(e))}}w.BASE=new w(n.Gx,n.Gy,t.ONE),w.ZERO=new w(t.ZERO,t.ONE,t.ZERO);const M=n.nBitLength,j=tt.wNAF(w,n.endo?Math.ceil(M/2):M);return{CURVE:n,ProjectivePoint:w,normPrivateKeyToScalar:R,weierstrassEquation:x,isWithinCurveOrder:V}}function dt(h){const n=tt.validateBasic(h);return a.validateObject(n,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...n})}function ft(h){const n=dt(h),{Fp:t,n:b}=n,O=t.BYTES+1,Z=2*t.BYTES+1;function x(r){return Q.mod(r,b)}function V(r){return Q.invert(r,b)}const{ProjectivePoint:R,normPrivateKeyToScalar:L,weierstrassEquation:P,isWithinCurveOrder:et}=at({...n,toBytes(r,o,i){const f=o.toAffine(),E=t.toBytes(f.x),A=a.concatBytes;return a.abool("isCompressed",i),i?A(Uint8Array.from([o.hasEvenY()?2:3]),E):A(Uint8Array.from([4]),E,t.toBytes(f.y))},fromBytes(r){const o=r.length,i=r[0],f=r.subarray(1);if(o===O&&(i===2||i===3)){const E=a.bytesToNumberBE(f);if(!a.inRange(E,T,t.ORDER))throw new Error("Point is not on curve");const A=P(E);let z;try{z=t.sqrt(A)}catch(U){const H=U instanceof Error?": "+U.message:"";throw new Error("Point is not on curve"+H)}const q=(z&T)===T;return(i&1)===1!==q&&(z=t.neg(z)),{x:E,y:z}}else if(o===Z&&i===4){const E=t.fromBytes(f.subarray(0,t.BYTES)),A=t.fromBytes(f.subarray(t.BYTES,2*t.BYTES));return{x:E,y:A}}else{const E=O,A=Z;throw new Error("invalid Point, expected length of "+E+", or uncompressed "+A+", got "+o)}}}),w=r=>a.bytesToHex(a.numberToBytesBE(r,n.nByteLength));function M(r){const o=b>>T;return r>o}function j(r){return M(r)?x(-r):r}const m=(r,o,i)=>a.bytesToNumberBE(r.slice(o,i));class e{constructor(o,i,f){this.r=o,this.s=i,this.recovery=f,this.assertValidity()}static fromCompact(o){const i=n.nByteLength;return o=a.ensureBytes("compactSignature",o,i*2),new e(m(o,0,i),m(o,i,2*i))}static fromDER(o){const{r:i,s:f}=Y.toSig(a.ensureBytes("DER",o));return new e(i,f)}assertValidity(){a.aInRange("r",this.r,T,b),a.aInRange("s",this.s,T,b)}addRecoveryBit(o){return new e(this.r,this.s,o)}recoverPublicKey(o){const{r:i,s:f,recovery:E}=this,A=g(a.ensureBytes("msgHash",o));if(E==null||![0,1,2,3].includes(E))throw new Error("recovery id invalid");const z=E===2||E===3?i+n.n:i;if(z>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const q=E&1?"03":"02",I=R.fromHex(q+w(z)),U=V(z),H=x(-A*U),X=x(f*U),D=R.BASE.multiplyAndAddUnsafe(I,H,X);if(!D)throw new Error("point at infinify");return D.assertValidity(),D}hasHighS(){return M(this.s)}normalizeS(){return this.hasHighS()?new e(this.r,x(-this.s),this.recovery):this}toDERRawBytes(){return a.hexToBytes(this.toDERHex())}toDERHex(){return Y.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return a.hexToBytes(this.toCompactHex())}toCompactHex(){return w(this.r)+w(this.s)}}const s={isValidPrivateKey(r){try{return L(r),!0}catch{return!1}},normPrivateKeyToScalar:L,randomPrivateKey:()=>{const r=Q.getMinHashLength(n.n);return Q.mapHashToField(n.randomBytes(r),n.n)},precompute(r=8,o=R.BASE){return o._setWindowSize(r),o.multiply(BigInt(3)),o}};function c(r,o=!0){return R.fromPrivateKey(r).toRawBytes(o)}function d(r){const o=a.isBytes(r),i=typeof r=="string",f=(o||i)&&r.length;return o?f===O||f===Z:i?f===2*O||f===2*Z:r instanceof R}function p(r,o,i=!0){if(d(r))throw new Error("first arg must be private key");if(!d(o))throw new Error("second arg must be public key");return R.fromHex(o).multiply(L(r)).toRawBytes(i)}const v=n.bits2int||function(r){if(r.length>8192)throw new Error("input is too large");const o=a.bytesToNumberBE(r),i=r.length*8-n.nBitLength;return i>0?o>>BigInt(i):o},g=n.bits2int_modN||function(r){return x(v(r))},l=a.bitMask(n.nBitLength);function y(r){return a.aInRange("num < 2^"+n.nBitLength,r,C,l),a.numberToBytesBE(r,n.nByteLength)}function u(r,o,i=N){if(["recovered","canonical"].some(K=>K in i))throw new Error("sign() legacy options not supported");const{hash:f,randomBytes:E}=n;let{lowS:A,prehash:z,extraEntropy:q}=i;A==null&&(A=!0),r=a.ensureBytes("msgHash",r),ot(i),z&&(r=a.ensureBytes("prehashed msgHash",f(r)));const I=g(r),U=L(o),H=[y(U),y(I)];if(q!=null&&q!==!1){const K=q===!0?E(t.BYTES):q;H.push(a.ensureBytes("extraEntropy",K))}const X=a.concatBytes(...H),D=I;function nt(K){const W=v(K);if(!et(W))return;const rt=V(W),$=R.BASE.multiply(W).toAffine(),k=x($.x);if(k===C)return;const J=x(rt*x(D+k*U));if(J===C)return;let _=($.x===k?0:2)|Number($.y&T),G=J;return A&&M(J)&&(G=j(J),_^=1),new e(k,G,_)}return{seed:X,k2sig:nt}}const N={lowS:n.lowS,prehash:!1},S={lowS:n.lowS,prehash:!1};function B(r,o,i=N){const{seed:f,k2sig:E}=u(r,o,i),A=n;return a.createHmacDrbg(A.hash.outputLen,A.nByteLength,A.hmac)(f,E)}R.BASE._setWindowSize(8);function F(r,o,i,f=S){var _;const E=r;o=a.ensureBytes("msgHash",o),i=a.ensureBytes("publicKey",i);const{lowS:A,prehash:z,format:q}=f;if(ot(f),"strict"in f)throw new Error("options.strict was renamed to lowS");if(q!==void 0&&q!=="compact"&&q!=="der")throw new Error("format must be compact or der");const I=typeof E=="string"||a.isBytes(E),U=!I&&!q&&typeof E=="object"&&E!==null&&typeof E.r=="bigint"&&typeof E.s=="bigint";if(!I&&!U)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let H,X;try{if(U&&(H=new e(E.r,E.s)),I){try{q!=="compact"&&(H=e.fromDER(E))}catch(G){if(!(G instanceof Y.Err))throw G}!H&&q!=="der"&&(H=e.fromCompact(E))}X=R.fromHex(i)}catch{return!1}if(!H||A&&H.hasHighS())return!1;z&&(o=n.hash(o));const{r:D,s:nt}=H,K=g(o),W=V(nt),rt=x(K*W),$=x(D*W),k=(_=R.BASE.multiplyAndAddUnsafe(X,rt,$))==null?void 0:_.toAffine();return k?x(k.x)===D:!1}return{CURVE:n,getPublicKey:c,getSharedSecret:p,sign:B,verify:F,ProjectivePoint:R,Signature:e,utils:s}}exports.DER=Y;exports.DERErr=it;exports.weierstrass=ft;exports.weierstrassPoints=at;
|