zattera-js 0.1.0
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/LICENSE +21 -0
- package/README.md +694 -0
- package/dist/browser/index.js +2466 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/node/auth/index.js +188 -0
- package/dist/node/auth/index.js.map +1 -0
- package/dist/node/auth/keys.js +264 -0
- package/dist/node/auth/keys.js.map +1 -0
- package/dist/node/auth/memo.js +79 -0
- package/dist/node/auth/memo.js.map +1 -0
- package/dist/node/auth/serializer.js +162 -0
- package/dist/node/auth/serializer.js.map +1 -0
- package/dist/node/client/index.js +838 -0
- package/dist/node/client/index.js.map +1 -0
- package/dist/node/index.js +30 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/node_modules/@noble/ciphers/aes.js +254 -0
- package/dist/node/node_modules/@noble/ciphers/aes.js.map +1 -0
- package/dist/node/node_modules/@noble/ciphers/utils.js +113 -0
- package/dist/node/node_modules/@noble/ciphers/utils.js.map +1 -0
- package/dist/node/node_modules/@noble/hashes/esm/_md.js +146 -0
- package/dist/node/node_modules/@noble/hashes/esm/_md.js.map +1 -0
- package/dist/node/node_modules/@noble/hashes/esm/_u64.js +51 -0
- package/dist/node/node_modules/@noble/hashes/esm/_u64.js.map +1 -0
- package/dist/node/node_modules/@noble/hashes/esm/legacy.js +123 -0
- package/dist/node/node_modules/@noble/hashes/esm/legacy.js.map +1 -0
- package/dist/node/node_modules/@noble/hashes/esm/sha2.js +346 -0
- package/dist/node/node_modules/@noble/hashes/esm/sha2.js.map +1 -0
- package/dist/node/node_modules/@noble/hashes/esm/utils.js +73 -0
- package/dist/node/node_modules/@noble/hashes/esm/utils.js.map +1 -0
- package/dist/node/node_modules/@noble/secp256k1/index.js +578 -0
- package/dist/node/node_modules/@noble/secp256k1/index.js.map +1 -0
- package/dist/node/node_modules/bs58/node_modules/base-x/src/esm/index.js +132 -0
- package/dist/node/node_modules/bs58/node_modules/base-x/src/esm/index.js.map +1 -0
- package/dist/node/node_modules/bs58/src/esm/index.js +7 -0
- package/dist/node/node_modules/bs58/src/esm/index.js.map +1 -0
- package/dist/node/types/index.js +48 -0
- package/dist/node/types/index.js.map +1 -0
- package/dist/node/utils/chain-id.js +9 -0
- package/dist/node/utils/chain-id.js.map +1 -0
- package/dist/types/auth/index.d.ts +134 -0
- package/dist/types/auth/index.d.ts.map +1 -0
- package/dist/types/auth/keys.d.ts +112 -0
- package/dist/types/auth/keys.d.ts.map +1 -0
- package/dist/types/auth/memo.d.ts +51 -0
- package/dist/types/auth/memo.d.ts.map +1 -0
- package/dist/types/auth/serializer.d.ts +57 -0
- package/dist/types/auth/serializer.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +360 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +593 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/utils/chain-id.d.ts +10 -0
- package/dist/types/utils/chain-id.d.ts.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,2466 @@
|
|
|
1
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2
|
+
function Pe(e) {
|
|
3
|
+
return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
|
|
4
|
+
}
|
|
5
|
+
function Kt(e, ...t) {
|
|
6
|
+
if (!Pe(e))
|
|
7
|
+
throw new Error("Uint8Array expected");
|
|
8
|
+
if (t.length > 0 && !t.includes(e.length))
|
|
9
|
+
throw new Error("Uint8Array expected of length " + t + ", got length=" + e.length);
|
|
10
|
+
}
|
|
11
|
+
function $t(e, t = !0) {
|
|
12
|
+
if (e.destroyed)
|
|
13
|
+
throw new Error("Hash instance has been destroyed");
|
|
14
|
+
if (t && e.finished)
|
|
15
|
+
throw new Error("Hash#digest() has already been called");
|
|
16
|
+
}
|
|
17
|
+
function Ke(e, t) {
|
|
18
|
+
Kt(e);
|
|
19
|
+
const n = t.outputLen;
|
|
20
|
+
if (e.length < n)
|
|
21
|
+
throw new Error("digestInto() expects output buffer of length at least " + n);
|
|
22
|
+
}
|
|
23
|
+
function J(...e) {
|
|
24
|
+
for (let t = 0; t < e.length; t++)
|
|
25
|
+
e[t].fill(0);
|
|
26
|
+
}
|
|
27
|
+
function Ct(e) {
|
|
28
|
+
return new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
29
|
+
}
|
|
30
|
+
function C(e, t) {
|
|
31
|
+
return e << 32 - t | e >>> t;
|
|
32
|
+
}
|
|
33
|
+
function wt(e, t) {
|
|
34
|
+
return e << t | e >>> 32 - t >>> 0;
|
|
35
|
+
}
|
|
36
|
+
function Me(e) {
|
|
37
|
+
if (typeof e != "string")
|
|
38
|
+
throw new Error("string expected");
|
|
39
|
+
return new Uint8Array(new TextEncoder().encode(e));
|
|
40
|
+
}
|
|
41
|
+
function ae(e) {
|
|
42
|
+
return typeof e == "string" && (e = Me(e)), Kt(e), e;
|
|
43
|
+
}
|
|
44
|
+
class Ve {
|
|
45
|
+
}
|
|
46
|
+
function Mt(e) {
|
|
47
|
+
const t = (s) => e().update(ae(s)).digest(), n = e();
|
|
48
|
+
return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
|
|
49
|
+
}
|
|
50
|
+
function We(e, t, n, s) {
|
|
51
|
+
if (typeof e.setBigUint64 == "function")
|
|
52
|
+
return e.setBigUint64(t, n, s);
|
|
53
|
+
const r = BigInt(32), i = BigInt(4294967295), o = Number(n >> r & i), u = Number(n & i), a = s ? 4 : 0, c = s ? 0 : 4;
|
|
54
|
+
e.setUint32(t + a, o, s), e.setUint32(t + c, u, s);
|
|
55
|
+
}
|
|
56
|
+
function Le(e, t, n) {
|
|
57
|
+
return e & t ^ ~e & n;
|
|
58
|
+
}
|
|
59
|
+
function Ye(e, t, n) {
|
|
60
|
+
return e & t ^ e & n ^ t & n;
|
|
61
|
+
}
|
|
62
|
+
class Vt extends Ve {
|
|
63
|
+
constructor(t, n, s, r) {
|
|
64
|
+
super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = t, this.outputLen = n, this.padOffset = s, this.isLE = r, this.buffer = new Uint8Array(t), this.view = Ct(this.buffer);
|
|
65
|
+
}
|
|
66
|
+
update(t) {
|
|
67
|
+
$t(this), t = ae(t), Kt(t);
|
|
68
|
+
const { view: n, buffer: s, blockLen: r } = this, i = t.length;
|
|
69
|
+
for (let o = 0; o < i; ) {
|
|
70
|
+
const u = Math.min(r - this.pos, i - o);
|
|
71
|
+
if (u === r) {
|
|
72
|
+
const a = Ct(t);
|
|
73
|
+
for (; r <= i - o; o += r)
|
|
74
|
+
this.process(a, o);
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
s.set(t.subarray(o, o + u), this.pos), this.pos += u, o += u, this.pos === r && (this.process(n, 0), this.pos = 0);
|
|
78
|
+
}
|
|
79
|
+
return this.length += t.length, this.roundClean(), this;
|
|
80
|
+
}
|
|
81
|
+
digestInto(t) {
|
|
82
|
+
$t(this), Ke(t, this), this.finished = !0;
|
|
83
|
+
const { buffer: n, view: s, blockLen: r, isLE: i } = this;
|
|
84
|
+
let { pos: o } = this;
|
|
85
|
+
n[o++] = 128, J(this.buffer.subarray(o)), this.padOffset > r - o && (this.process(s, 0), o = 0);
|
|
86
|
+
for (let f = o; f < r; f++)
|
|
87
|
+
n[f] = 0;
|
|
88
|
+
We(s, r - 8, BigInt(this.length * 8), i), this.process(s, 0);
|
|
89
|
+
const u = Ct(t), a = this.outputLen;
|
|
90
|
+
if (a % 4)
|
|
91
|
+
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
92
|
+
const c = a / 4, h = this.get();
|
|
93
|
+
if (c > h.length)
|
|
94
|
+
throw new Error("_sha2: outputLen bigger than state");
|
|
95
|
+
for (let f = 0; f < c; f++)
|
|
96
|
+
u.setUint32(4 * f, h[f], i);
|
|
97
|
+
}
|
|
98
|
+
digest() {
|
|
99
|
+
const { buffer: t, outputLen: n } = this;
|
|
100
|
+
this.digestInto(t);
|
|
101
|
+
const s = t.slice(0, n);
|
|
102
|
+
return this.destroy(), s;
|
|
103
|
+
}
|
|
104
|
+
_cloneInto(t) {
|
|
105
|
+
t || (t = new this.constructor()), t.set(...this.get());
|
|
106
|
+
const { blockLen: n, buffer: s, length: r, finished: i, destroyed: o, pos: u } = this;
|
|
107
|
+
return t.destroyed = o, t.finished = i, t.length = r, t.pos = u, r % n && t.buffer.set(s), t;
|
|
108
|
+
}
|
|
109
|
+
clone() {
|
|
110
|
+
return this._cloneInto();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const M = /* @__PURE__ */ Uint32Array.from([
|
|
114
|
+
1779033703,
|
|
115
|
+
3144134277,
|
|
116
|
+
1013904242,
|
|
117
|
+
2773480762,
|
|
118
|
+
1359893119,
|
|
119
|
+
2600822924,
|
|
120
|
+
528734635,
|
|
121
|
+
1541459225
|
|
122
|
+
]), E = /* @__PURE__ */ Uint32Array.from([
|
|
123
|
+
1779033703,
|
|
124
|
+
4089235720,
|
|
125
|
+
3144134277,
|
|
126
|
+
2227873595,
|
|
127
|
+
1013904242,
|
|
128
|
+
4271175723,
|
|
129
|
+
2773480762,
|
|
130
|
+
1595750129,
|
|
131
|
+
1359893119,
|
|
132
|
+
2917565137,
|
|
133
|
+
2600822924,
|
|
134
|
+
725511199,
|
|
135
|
+
528734635,
|
|
136
|
+
4215389547,
|
|
137
|
+
1541459225,
|
|
138
|
+
327033209
|
|
139
|
+
]), xt = /* @__PURE__ */ BigInt(2 ** 32 - 1), Zt = /* @__PURE__ */ BigInt(32);
|
|
140
|
+
function je(e, t = !1) {
|
|
141
|
+
return t ? { h: Number(e & xt), l: Number(e >> Zt & xt) } : { h: Number(e >> Zt & xt) | 0, l: Number(e & xt) | 0 };
|
|
142
|
+
}
|
|
143
|
+
function Ge(e, t = !1) {
|
|
144
|
+
const n = e.length;
|
|
145
|
+
let s = new Uint32Array(n), r = new Uint32Array(n);
|
|
146
|
+
for (let i = 0; i < n; i++) {
|
|
147
|
+
const { h: o, l: u } = je(e[i], t);
|
|
148
|
+
[s[i], r[i]] = [o, u];
|
|
149
|
+
}
|
|
150
|
+
return [s, r];
|
|
151
|
+
}
|
|
152
|
+
const Xt = (e, t, n) => e >>> n, Qt = (e, t, n) => e << 32 - n | t >>> n, nt = (e, t, n) => e >>> n | t << 32 - n, st = (e, t, n) => e << 32 - n | t >>> n, mt = (e, t, n) => e << 64 - n | t >>> n - 32, At = (e, t, n) => e >>> n - 32 | t << 64 - n;
|
|
153
|
+
function D(e, t, n, s) {
|
|
154
|
+
const r = (t >>> 0) + (s >>> 0);
|
|
155
|
+
return { h: e + n + (r / 2 ** 32 | 0) | 0, l: r | 0 };
|
|
156
|
+
}
|
|
157
|
+
const ze = (e, t, n) => (e >>> 0) + (t >>> 0) + (n >>> 0), $e = (e, t, n, s) => t + n + s + (e / 2 ** 32 | 0) | 0, Ze = (e, t, n, s) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (s >>> 0), Xe = (e, t, n, s, r) => t + n + s + r + (e / 2 ** 32 | 0) | 0, Qe = (e, t, n, s, r) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (s >>> 0) + (r >>> 0), Je = (e, t, n, s, r, i) => t + n + s + r + i + (e / 2 ** 32 | 0) | 0, tn = /* @__PURE__ */ Uint32Array.from([
|
|
158
|
+
1116352408,
|
|
159
|
+
1899447441,
|
|
160
|
+
3049323471,
|
|
161
|
+
3921009573,
|
|
162
|
+
961987163,
|
|
163
|
+
1508970993,
|
|
164
|
+
2453635748,
|
|
165
|
+
2870763221,
|
|
166
|
+
3624381080,
|
|
167
|
+
310598401,
|
|
168
|
+
607225278,
|
|
169
|
+
1426881987,
|
|
170
|
+
1925078388,
|
|
171
|
+
2162078206,
|
|
172
|
+
2614888103,
|
|
173
|
+
3248222580,
|
|
174
|
+
3835390401,
|
|
175
|
+
4022224774,
|
|
176
|
+
264347078,
|
|
177
|
+
604807628,
|
|
178
|
+
770255983,
|
|
179
|
+
1249150122,
|
|
180
|
+
1555081692,
|
|
181
|
+
1996064986,
|
|
182
|
+
2554220882,
|
|
183
|
+
2821834349,
|
|
184
|
+
2952996808,
|
|
185
|
+
3210313671,
|
|
186
|
+
3336571891,
|
|
187
|
+
3584528711,
|
|
188
|
+
113926993,
|
|
189
|
+
338241895,
|
|
190
|
+
666307205,
|
|
191
|
+
773529912,
|
|
192
|
+
1294757372,
|
|
193
|
+
1396182291,
|
|
194
|
+
1695183700,
|
|
195
|
+
1986661051,
|
|
196
|
+
2177026350,
|
|
197
|
+
2456956037,
|
|
198
|
+
2730485921,
|
|
199
|
+
2820302411,
|
|
200
|
+
3259730800,
|
|
201
|
+
3345764771,
|
|
202
|
+
3516065817,
|
|
203
|
+
3600352804,
|
|
204
|
+
4094571909,
|
|
205
|
+
275423344,
|
|
206
|
+
430227734,
|
|
207
|
+
506948616,
|
|
208
|
+
659060556,
|
|
209
|
+
883997877,
|
|
210
|
+
958139571,
|
|
211
|
+
1322822218,
|
|
212
|
+
1537002063,
|
|
213
|
+
1747873779,
|
|
214
|
+
1955562222,
|
|
215
|
+
2024104815,
|
|
216
|
+
2227730452,
|
|
217
|
+
2361852424,
|
|
218
|
+
2428436474,
|
|
219
|
+
2756734187,
|
|
220
|
+
3204031479,
|
|
221
|
+
3329325298
|
|
222
|
+
]), V = /* @__PURE__ */ new Uint32Array(64);
|
|
223
|
+
class en extends Vt {
|
|
224
|
+
constructor(t = 32) {
|
|
225
|
+
super(64, t, 8, !1), this.A = M[0] | 0, this.B = M[1] | 0, this.C = M[2] | 0, this.D = M[3] | 0, this.E = M[4] | 0, this.F = M[5] | 0, this.G = M[6] | 0, this.H = M[7] | 0;
|
|
226
|
+
}
|
|
227
|
+
get() {
|
|
228
|
+
const { A: t, B: n, C: s, D: r, E: i, F: o, G: u, H: a } = this;
|
|
229
|
+
return [t, n, s, r, i, o, u, a];
|
|
230
|
+
}
|
|
231
|
+
// prettier-ignore
|
|
232
|
+
set(t, n, s, r, i, o, u, a) {
|
|
233
|
+
this.A = t | 0, this.B = n | 0, this.C = s | 0, this.D = r | 0, this.E = i | 0, this.F = o | 0, this.G = u | 0, this.H = a | 0;
|
|
234
|
+
}
|
|
235
|
+
process(t, n) {
|
|
236
|
+
for (let f = 0; f < 16; f++, n += 4)
|
|
237
|
+
V[f] = t.getUint32(n, !1);
|
|
238
|
+
for (let f = 16; f < 64; f++) {
|
|
239
|
+
const l = V[f - 15], d = V[f - 2], y = C(l, 7) ^ C(l, 18) ^ l >>> 3, b = C(d, 17) ^ C(d, 19) ^ d >>> 10;
|
|
240
|
+
V[f] = b + V[f - 7] + y + V[f - 16] | 0;
|
|
241
|
+
}
|
|
242
|
+
let { A: s, B: r, C: i, D: o, E: u, F: a, G: c, H: h } = this;
|
|
243
|
+
for (let f = 0; f < 64; f++) {
|
|
244
|
+
const l = C(u, 6) ^ C(u, 11) ^ C(u, 25), d = h + l + Le(u, a, c) + tn[f] + V[f] | 0, b = (C(s, 2) ^ C(s, 13) ^ C(s, 22)) + Ye(s, r, i) | 0;
|
|
245
|
+
h = c, c = a, a = u, u = o + d | 0, o = i, i = r, r = s, s = d + b | 0;
|
|
246
|
+
}
|
|
247
|
+
s = s + this.A | 0, r = r + this.B | 0, i = i + this.C | 0, o = o + this.D | 0, u = u + this.E | 0, a = a + this.F | 0, c = c + this.G | 0, h = h + this.H | 0, this.set(s, r, i, o, u, a, c, h);
|
|
248
|
+
}
|
|
249
|
+
roundClean() {
|
|
250
|
+
J(V);
|
|
251
|
+
}
|
|
252
|
+
destroy() {
|
|
253
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0), J(this.buffer);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const ue = Ge([
|
|
257
|
+
"0x428a2f98d728ae22",
|
|
258
|
+
"0x7137449123ef65cd",
|
|
259
|
+
"0xb5c0fbcfec4d3b2f",
|
|
260
|
+
"0xe9b5dba58189dbbc",
|
|
261
|
+
"0x3956c25bf348b538",
|
|
262
|
+
"0x59f111f1b605d019",
|
|
263
|
+
"0x923f82a4af194f9b",
|
|
264
|
+
"0xab1c5ed5da6d8118",
|
|
265
|
+
"0xd807aa98a3030242",
|
|
266
|
+
"0x12835b0145706fbe",
|
|
267
|
+
"0x243185be4ee4b28c",
|
|
268
|
+
"0x550c7dc3d5ffb4e2",
|
|
269
|
+
"0x72be5d74f27b896f",
|
|
270
|
+
"0x80deb1fe3b1696b1",
|
|
271
|
+
"0x9bdc06a725c71235",
|
|
272
|
+
"0xc19bf174cf692694",
|
|
273
|
+
"0xe49b69c19ef14ad2",
|
|
274
|
+
"0xefbe4786384f25e3",
|
|
275
|
+
"0x0fc19dc68b8cd5b5",
|
|
276
|
+
"0x240ca1cc77ac9c65",
|
|
277
|
+
"0x2de92c6f592b0275",
|
|
278
|
+
"0x4a7484aa6ea6e483",
|
|
279
|
+
"0x5cb0a9dcbd41fbd4",
|
|
280
|
+
"0x76f988da831153b5",
|
|
281
|
+
"0x983e5152ee66dfab",
|
|
282
|
+
"0xa831c66d2db43210",
|
|
283
|
+
"0xb00327c898fb213f",
|
|
284
|
+
"0xbf597fc7beef0ee4",
|
|
285
|
+
"0xc6e00bf33da88fc2",
|
|
286
|
+
"0xd5a79147930aa725",
|
|
287
|
+
"0x06ca6351e003826f",
|
|
288
|
+
"0x142929670a0e6e70",
|
|
289
|
+
"0x27b70a8546d22ffc",
|
|
290
|
+
"0x2e1b21385c26c926",
|
|
291
|
+
"0x4d2c6dfc5ac42aed",
|
|
292
|
+
"0x53380d139d95b3df",
|
|
293
|
+
"0x650a73548baf63de",
|
|
294
|
+
"0x766a0abb3c77b2a8",
|
|
295
|
+
"0x81c2c92e47edaee6",
|
|
296
|
+
"0x92722c851482353b",
|
|
297
|
+
"0xa2bfe8a14cf10364",
|
|
298
|
+
"0xa81a664bbc423001",
|
|
299
|
+
"0xc24b8b70d0f89791",
|
|
300
|
+
"0xc76c51a30654be30",
|
|
301
|
+
"0xd192e819d6ef5218",
|
|
302
|
+
"0xd69906245565a910",
|
|
303
|
+
"0xf40e35855771202a",
|
|
304
|
+
"0x106aa07032bbd1b8",
|
|
305
|
+
"0x19a4c116b8d2d0c8",
|
|
306
|
+
"0x1e376c085141ab53",
|
|
307
|
+
"0x2748774cdf8eeb99",
|
|
308
|
+
"0x34b0bcb5e19b48a8",
|
|
309
|
+
"0x391c0cb3c5c95a63",
|
|
310
|
+
"0x4ed8aa4ae3418acb",
|
|
311
|
+
"0x5b9cca4f7763e373",
|
|
312
|
+
"0x682e6ff3d6b2b8a3",
|
|
313
|
+
"0x748f82ee5defb2fc",
|
|
314
|
+
"0x78a5636f43172f60",
|
|
315
|
+
"0x84c87814a1f0ab72",
|
|
316
|
+
"0x8cc702081a6439ec",
|
|
317
|
+
"0x90befffa23631e28",
|
|
318
|
+
"0xa4506cebde82bde9",
|
|
319
|
+
"0xbef9a3f7b2c67915",
|
|
320
|
+
"0xc67178f2e372532b",
|
|
321
|
+
"0xca273eceea26619c",
|
|
322
|
+
"0xd186b8c721c0c207",
|
|
323
|
+
"0xeada7dd6cde0eb1e",
|
|
324
|
+
"0xf57d4f7fee6ed178",
|
|
325
|
+
"0x06f067aa72176fba",
|
|
326
|
+
"0x0a637dc5a2c898a6",
|
|
327
|
+
"0x113f9804bef90dae",
|
|
328
|
+
"0x1b710b35131c471b",
|
|
329
|
+
"0x28db77f523047d84",
|
|
330
|
+
"0x32caab7b40c72493",
|
|
331
|
+
"0x3c9ebe0a15c9bebc",
|
|
332
|
+
"0x431d67c49c100d4c",
|
|
333
|
+
"0x4cc5d4becb3e42b6",
|
|
334
|
+
"0x597f299cfc657e2a",
|
|
335
|
+
"0x5fcb6fab3ad6faec",
|
|
336
|
+
"0x6c44198c4a475817"
|
|
337
|
+
].map((e) => BigInt(e))), nn = ue[0], sn = ue[1], W = /* @__PURE__ */ new Uint32Array(80), L = /* @__PURE__ */ new Uint32Array(80);
|
|
338
|
+
class rn extends Vt {
|
|
339
|
+
constructor(t = 64) {
|
|
340
|
+
super(128, t, 16, !1), this.Ah = E[0] | 0, this.Al = E[1] | 0, this.Bh = E[2] | 0, this.Bl = E[3] | 0, this.Ch = E[4] | 0, this.Cl = E[5] | 0, this.Dh = E[6] | 0, this.Dl = E[7] | 0, this.Eh = E[8] | 0, this.El = E[9] | 0, this.Fh = E[10] | 0, this.Fl = E[11] | 0, this.Gh = E[12] | 0, this.Gl = E[13] | 0, this.Hh = E[14] | 0, this.Hl = E[15] | 0;
|
|
341
|
+
}
|
|
342
|
+
// prettier-ignore
|
|
343
|
+
get() {
|
|
344
|
+
const { Ah: t, Al: n, Bh: s, Bl: r, Ch: i, Cl: o, Dh: u, Dl: a, Eh: c, El: h, Fh: f, Fl: l, Gh: d, Gl: y, Hh: b, Hl: _ } = this;
|
|
345
|
+
return [t, n, s, r, i, o, u, a, c, h, f, l, d, y, b, _];
|
|
346
|
+
}
|
|
347
|
+
// prettier-ignore
|
|
348
|
+
set(t, n, s, r, i, o, u, a, c, h, f, l, d, y, b, _) {
|
|
349
|
+
this.Ah = t | 0, this.Al = n | 0, this.Bh = s | 0, this.Bl = r | 0, this.Ch = i | 0, this.Cl = o | 0, this.Dh = u | 0, this.Dl = a | 0, this.Eh = c | 0, this.El = h | 0, this.Fh = f | 0, this.Fl = l | 0, this.Gh = d | 0, this.Gl = y | 0, this.Hh = b | 0, this.Hl = _ | 0;
|
|
350
|
+
}
|
|
351
|
+
process(t, n) {
|
|
352
|
+
for (let p = 0; p < 16; p++, n += 4)
|
|
353
|
+
W[p] = t.getUint32(n), L[p] = t.getUint32(n += 4);
|
|
354
|
+
for (let p = 16; p < 80; p++) {
|
|
355
|
+
const A = W[p - 15] | 0, m = L[p - 15] | 0, F = nt(A, m, 1) ^ nt(A, m, 8) ^ Xt(A, m, 7), at = st(A, m, 1) ^ st(A, m, 8) ^ Qt(A, m, 7), q = W[p - 2] | 0, I = L[p - 2] | 0, _t = nt(q, I, 19) ^ mt(q, I, 61) ^ Xt(q, I, 6), Rt = st(q, I, 19) ^ At(q, I, 61) ^ Qt(q, I, 6), pt = Ze(at, Rt, L[p - 7], L[p - 16]), kt = Xe(pt, F, _t, W[p - 7], W[p - 16]);
|
|
356
|
+
W[p] = kt | 0, L[p] = pt | 0;
|
|
357
|
+
}
|
|
358
|
+
let { Ah: s, Al: r, Bh: i, Bl: o, Ch: u, Cl: a, Dh: c, Dl: h, Eh: f, El: l, Fh: d, Fl: y, Gh: b, Gl: _, Hh: x, Hl: g } = this;
|
|
359
|
+
for (let p = 0; p < 80; p++) {
|
|
360
|
+
const A = nt(f, l, 14) ^ nt(f, l, 18) ^ mt(f, l, 41), m = st(f, l, 14) ^ st(f, l, 18) ^ At(f, l, 41), F = f & d ^ ~f & b, at = l & y ^ ~l & _, q = Qe(g, m, at, sn[p], L[p]), I = Je(q, x, A, F, nn[p], W[p]), _t = q | 0, Rt = nt(s, r, 28) ^ mt(s, r, 34) ^ mt(s, r, 39), pt = st(s, r, 28) ^ At(s, r, 34) ^ At(s, r, 39), kt = s & i ^ s & u ^ i & u, Oe = r & o ^ r & a ^ o & a;
|
|
361
|
+
x = b | 0, g = _ | 0, b = d | 0, _ = y | 0, d = f | 0, y = l | 0, { h: f, l } = D(c | 0, h | 0, I | 0, _t | 0), c = u | 0, h = a | 0, u = i | 0, a = o | 0, i = s | 0, o = r | 0;
|
|
362
|
+
const zt = ze(_t, pt, Oe);
|
|
363
|
+
s = $e(zt, I, Rt, kt), r = zt | 0;
|
|
364
|
+
}
|
|
365
|
+
({ h: s, l: r } = D(this.Ah | 0, this.Al | 0, s | 0, r | 0)), { h: i, l: o } = D(this.Bh | 0, this.Bl | 0, i | 0, o | 0), { h: u, l: a } = D(this.Ch | 0, this.Cl | 0, u | 0, a | 0), { h: c, l: h } = D(this.Dh | 0, this.Dl | 0, c | 0, h | 0), { h: f, l } = D(this.Eh | 0, this.El | 0, f | 0, l | 0), { h: d, l: y } = D(this.Fh | 0, this.Fl | 0, d | 0, y | 0), { h: b, l: _ } = D(this.Gh | 0, this.Gl | 0, b | 0, _ | 0), { h: x, l: g } = D(this.Hh | 0, this.Hl | 0, x | 0, g | 0), this.set(s, r, i, o, u, a, c, h, f, l, d, y, b, _, x, g);
|
|
366
|
+
}
|
|
367
|
+
roundClean() {
|
|
368
|
+
J(W, L);
|
|
369
|
+
}
|
|
370
|
+
destroy() {
|
|
371
|
+
J(this.buffer), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
const R = /* @__PURE__ */ Mt(() => new en()), fe = /* @__PURE__ */ Mt(() => new rn());
|
|
375
|
+
function on(e) {
|
|
376
|
+
const t = R(new TextEncoder().encode(e));
|
|
377
|
+
return Array.from(t).map((n) => n.toString(16).padStart(2, "0")).join("");
|
|
378
|
+
}
|
|
379
|
+
class cs {
|
|
380
|
+
endpoint;
|
|
381
|
+
chainId;
|
|
382
|
+
timeout;
|
|
383
|
+
retries;
|
|
384
|
+
requestId;
|
|
385
|
+
constructor(t) {
|
|
386
|
+
this.endpoint = t.endpoint, this.chainId = on(t.networkName || "zattera"), this.timeout = t.timeout ?? 3e4, this.retries = t.retries ?? 3, this.requestId = 0;
|
|
387
|
+
}
|
|
388
|
+
getNextId() {
|
|
389
|
+
return ++this.requestId;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Get the configured chain ID
|
|
393
|
+
*/
|
|
394
|
+
getChainId() {
|
|
395
|
+
return this.chainId;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Internal method to make JSON-RPC 2.0 requests with retry logic
|
|
399
|
+
*/
|
|
400
|
+
async request(t, n = {}) {
|
|
401
|
+
const s = {
|
|
402
|
+
jsonrpc: "2.0",
|
|
403
|
+
method: t,
|
|
404
|
+
params: n,
|
|
405
|
+
id: this.getNextId()
|
|
406
|
+
};
|
|
407
|
+
let r = null;
|
|
408
|
+
for (let i = 0; i <= this.retries; i++)
|
|
409
|
+
try {
|
|
410
|
+
const o = new AbortController(), u = setTimeout(() => o.abort(), this.timeout), a = await fetch(this.endpoint, {
|
|
411
|
+
method: "POST",
|
|
412
|
+
headers: {
|
|
413
|
+
"Content-Type": "application/json"
|
|
414
|
+
},
|
|
415
|
+
body: JSON.stringify(s),
|
|
416
|
+
signal: o.signal
|
|
417
|
+
});
|
|
418
|
+
if (clearTimeout(u), !a.ok)
|
|
419
|
+
throw new Error(`HTTP error! status: ${a.status}`);
|
|
420
|
+
const c = await a.json();
|
|
421
|
+
if (c.error)
|
|
422
|
+
throw new Error(
|
|
423
|
+
`RPC error ${c.error.code}: ${c.error.message}`
|
|
424
|
+
);
|
|
425
|
+
if (c.result === void 0)
|
|
426
|
+
throw new Error("No result in RPC response");
|
|
427
|
+
return c.result;
|
|
428
|
+
} catch (o) {
|
|
429
|
+
r = o instanceof Error ? o : new Error(String(o)), i < this.retries && await new Promise(
|
|
430
|
+
(u) => setTimeout(u, 1e3 * Math.pow(2, i))
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
throw r ?? new Error("Request failed");
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Make batch JSON-RPC requests
|
|
437
|
+
*/
|
|
438
|
+
async batch(t) {
|
|
439
|
+
const n = t.map((r) => ({
|
|
440
|
+
jsonrpc: "2.0",
|
|
441
|
+
method: r.method,
|
|
442
|
+
params: r.params ?? {},
|
|
443
|
+
id: this.getNextId()
|
|
444
|
+
}));
|
|
445
|
+
let s = null;
|
|
446
|
+
for (let r = 0; r <= this.retries; r++)
|
|
447
|
+
try {
|
|
448
|
+
const i = new AbortController(), o = setTimeout(() => i.abort(), this.timeout), u = await fetch(this.endpoint, {
|
|
449
|
+
method: "POST",
|
|
450
|
+
headers: {
|
|
451
|
+
"Content-Type": "application/json"
|
|
452
|
+
},
|
|
453
|
+
body: JSON.stringify(n),
|
|
454
|
+
signal: i.signal
|
|
455
|
+
});
|
|
456
|
+
if (clearTimeout(o), !u.ok)
|
|
457
|
+
throw new Error(`HTTP error! status: ${u.status}`);
|
|
458
|
+
return (await u.json()).map((c) => {
|
|
459
|
+
if (c.error)
|
|
460
|
+
throw new Error(
|
|
461
|
+
`RPC error ${c.error.code}: ${c.error.message}`
|
|
462
|
+
);
|
|
463
|
+
if (c.result === void 0)
|
|
464
|
+
throw new Error("No result in RPC response");
|
|
465
|
+
return c.result;
|
|
466
|
+
});
|
|
467
|
+
} catch (i) {
|
|
468
|
+
s = i instanceof Error ? i : new Error(String(i)), r < this.retries && await new Promise(
|
|
469
|
+
(o) => setTimeout(o, 1e3 * Math.pow(2, r))
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
throw s ?? new Error("Batch request failed");
|
|
473
|
+
}
|
|
474
|
+
// ============================================================================
|
|
475
|
+
// Generic RPC Call
|
|
476
|
+
// ============================================================================
|
|
477
|
+
/**
|
|
478
|
+
* Generic RPC call method for custom or new API methods
|
|
479
|
+
*/
|
|
480
|
+
async call(t, n = {}) {
|
|
481
|
+
return this.request(t, n);
|
|
482
|
+
}
|
|
483
|
+
// ============================================================================
|
|
484
|
+
// Database API - Global Properties
|
|
485
|
+
// ============================================================================
|
|
486
|
+
/**
|
|
487
|
+
* Get compile-time chain configuration constants
|
|
488
|
+
*/
|
|
489
|
+
async getConfig() {
|
|
490
|
+
return this.request("database_api.get_config", {});
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Get current dynamic global properties (head block, supply, etc.)
|
|
494
|
+
*/
|
|
495
|
+
async getDynamicGlobalProperties() {
|
|
496
|
+
return this.request(
|
|
497
|
+
"database_api.get_dynamic_global_properties",
|
|
498
|
+
{}
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Get active witness schedule
|
|
503
|
+
*/
|
|
504
|
+
async getWitnessSchedule() {
|
|
505
|
+
return this.request(
|
|
506
|
+
"database_api.get_witness_schedule",
|
|
507
|
+
{}
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Get hardfork properties and version information
|
|
512
|
+
*/
|
|
513
|
+
async getHardforkProperties() {
|
|
514
|
+
return this.request(
|
|
515
|
+
"database_api.get_hardfork_properties",
|
|
516
|
+
{}
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Get reward fund details
|
|
521
|
+
*/
|
|
522
|
+
async getRewardFunds() {
|
|
523
|
+
return (await this.request("database_api.get_reward_funds", {})).funds;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Get current median price feed
|
|
527
|
+
*/
|
|
528
|
+
async getCurrentPriceFeed() {
|
|
529
|
+
return this.request(
|
|
530
|
+
"database_api.get_current_price_feed",
|
|
531
|
+
{}
|
|
532
|
+
);
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Get price feed history
|
|
536
|
+
*/
|
|
537
|
+
async getFeedHistory() {
|
|
538
|
+
return this.request("database_api.get_feed_history", {});
|
|
539
|
+
}
|
|
540
|
+
// ============================================================================
|
|
541
|
+
// Database API - Witnesses
|
|
542
|
+
// ============================================================================
|
|
543
|
+
/**
|
|
544
|
+
* List witnesses by specified order
|
|
545
|
+
*/
|
|
546
|
+
async listWitnesses(t) {
|
|
547
|
+
return (await this.request("database_api.list_witnesses", t)).witnesses;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Find specific witnesses by account names
|
|
551
|
+
*/
|
|
552
|
+
async findWitnesses(t) {
|
|
553
|
+
return (await this.request("database_api.find_witnesses", {
|
|
554
|
+
owners: t
|
|
555
|
+
})).witnesses;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* List witness votes
|
|
559
|
+
*/
|
|
560
|
+
async listWitnessVotes(t, n, s) {
|
|
561
|
+
return this.request("database_api.list_witness_votes", {
|
|
562
|
+
start: t,
|
|
563
|
+
limit: n,
|
|
564
|
+
order: s
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Get currently active witnesses
|
|
569
|
+
*/
|
|
570
|
+
async getActiveWitnesses() {
|
|
571
|
+
return (await this.request(
|
|
572
|
+
"database_api.get_active_witnesses",
|
|
573
|
+
{}
|
|
574
|
+
)).witnesses;
|
|
575
|
+
}
|
|
576
|
+
// ============================================================================
|
|
577
|
+
// Database API - Accounts
|
|
578
|
+
// ============================================================================
|
|
579
|
+
/**
|
|
580
|
+
* List accounts by specified order
|
|
581
|
+
*/
|
|
582
|
+
async listAccounts(t) {
|
|
583
|
+
return (await this.request("database_api.list_accounts", t)).accounts;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Find specific accounts by names
|
|
587
|
+
*/
|
|
588
|
+
async findAccounts(t) {
|
|
589
|
+
return (await this.request("database_api.find_accounts", t)).accounts;
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* List account owner authority change history
|
|
593
|
+
*/
|
|
594
|
+
async listOwnerHistories(t, n) {
|
|
595
|
+
return this.request(
|
|
596
|
+
"database_api.list_owner_histories",
|
|
597
|
+
{ start: t, limit: n }
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Find owner history for specific account
|
|
602
|
+
*/
|
|
603
|
+
async findOwnerHistories(t) {
|
|
604
|
+
return this.request(
|
|
605
|
+
"database_api.find_owner_histories",
|
|
606
|
+
{ owner: t }
|
|
607
|
+
);
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* List account recovery requests
|
|
611
|
+
*/
|
|
612
|
+
async listAccountRecoveryRequests(t, n, s) {
|
|
613
|
+
return this.request(
|
|
614
|
+
"database_api.list_account_recovery_requests",
|
|
615
|
+
{ start: t, limit: n, order: s }
|
|
616
|
+
);
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Find account recovery requests
|
|
620
|
+
*/
|
|
621
|
+
async findAccountRecoveryRequests(t) {
|
|
622
|
+
return this.request(
|
|
623
|
+
"database_api.find_account_recovery_requests",
|
|
624
|
+
{ accounts: t }
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* List escrows
|
|
629
|
+
*/
|
|
630
|
+
async listEscrows(t, n, s) {
|
|
631
|
+
return this.request("database_api.list_escrows", {
|
|
632
|
+
start: t,
|
|
633
|
+
limit: n,
|
|
634
|
+
order: s
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Find escrows
|
|
639
|
+
*/
|
|
640
|
+
async findEscrows(t) {
|
|
641
|
+
return this.request("database_api.find_escrows", { from: t });
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* List vesting delegations
|
|
645
|
+
*/
|
|
646
|
+
async listVestingDelegations(t, n, s) {
|
|
647
|
+
return this.request(
|
|
648
|
+
"database_api.list_vesting_delegations",
|
|
649
|
+
{ start: t, limit: n, order: s }
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Find vesting delegations
|
|
654
|
+
*/
|
|
655
|
+
async findVestingDelegations(t) {
|
|
656
|
+
return this.request(
|
|
657
|
+
"database_api.find_vesting_delegations",
|
|
658
|
+
{ account: t }
|
|
659
|
+
);
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* List SBD conversion requests
|
|
663
|
+
*/
|
|
664
|
+
async listDollarConversionRequests(t, n, s) {
|
|
665
|
+
return this.request(
|
|
666
|
+
"database_api.list_dollar_conversion_requests",
|
|
667
|
+
{ start: t, limit: n, order: s }
|
|
668
|
+
);
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Find SBD conversion requests
|
|
672
|
+
*/
|
|
673
|
+
async findDollarConversionRequests(t) {
|
|
674
|
+
return this.request(
|
|
675
|
+
"database_api.find_dollar_conversion_requests",
|
|
676
|
+
{ account: t }
|
|
677
|
+
);
|
|
678
|
+
}
|
|
679
|
+
// ============================================================================
|
|
680
|
+
// Database API - Comments
|
|
681
|
+
// ============================================================================
|
|
682
|
+
/**
|
|
683
|
+
* List comments by specified order
|
|
684
|
+
*/
|
|
685
|
+
async listComments(t, n, s) {
|
|
686
|
+
return this.request("database_api.list_comments", {
|
|
687
|
+
start: t,
|
|
688
|
+
limit: n,
|
|
689
|
+
order: s
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Find specific comments
|
|
694
|
+
*/
|
|
695
|
+
async findComments(t) {
|
|
696
|
+
return this.request("database_api.find_comments", {
|
|
697
|
+
comments: t
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* List votes
|
|
702
|
+
*/
|
|
703
|
+
async listVotes(t, n, s) {
|
|
704
|
+
return this.request("database_api.list_votes", {
|
|
705
|
+
start: t,
|
|
706
|
+
limit: n,
|
|
707
|
+
order: s
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Find specific votes
|
|
712
|
+
*/
|
|
713
|
+
async findVotes(t, n) {
|
|
714
|
+
return this.request("database_api.find_votes", {
|
|
715
|
+
author: t,
|
|
716
|
+
permlink: n
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
// ============================================================================
|
|
720
|
+
// Database API - Market
|
|
721
|
+
// ============================================================================
|
|
722
|
+
/**
|
|
723
|
+
* List limit orders
|
|
724
|
+
*/
|
|
725
|
+
async listLimitOrders(t, n, s) {
|
|
726
|
+
return this.request("database_api.list_limit_orders", {
|
|
727
|
+
start: t,
|
|
728
|
+
limit: n,
|
|
729
|
+
order: s
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Find limit orders
|
|
734
|
+
*/
|
|
735
|
+
async findLimitOrders(t) {
|
|
736
|
+
return this.request("database_api.find_limit_orders", {
|
|
737
|
+
account: t
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Get current order book
|
|
742
|
+
*/
|
|
743
|
+
async getOrderBook(t = 50) {
|
|
744
|
+
return this.request("database_api.get_order_book", {
|
|
745
|
+
limit: t
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
// ============================================================================
|
|
749
|
+
// Database API - Authority & Validation
|
|
750
|
+
// ============================================================================
|
|
751
|
+
/**
|
|
752
|
+
* Get transaction as hex string
|
|
753
|
+
*/
|
|
754
|
+
async getTransactionHex(t) {
|
|
755
|
+
return this.request("database_api.get_transaction_hex", { trx: t });
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Get required signatures for transaction
|
|
759
|
+
*/
|
|
760
|
+
async getRequiredSignatures(t, n) {
|
|
761
|
+
return this.request(
|
|
762
|
+
"database_api.get_required_signatures",
|
|
763
|
+
{ trx: t, available_keys: n }
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* Get all potential signatures for transaction
|
|
768
|
+
*/
|
|
769
|
+
async getPotentialSignatures(t) {
|
|
770
|
+
return this.request(
|
|
771
|
+
"database_api.get_potential_signatures",
|
|
772
|
+
{ trx: t }
|
|
773
|
+
);
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* Verify transaction has required authority
|
|
777
|
+
*/
|
|
778
|
+
async verifyAuthority(t) {
|
|
779
|
+
return this.request(
|
|
780
|
+
"database_api.verify_authority",
|
|
781
|
+
{ trx: t }
|
|
782
|
+
);
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Verify account has authority from signers
|
|
786
|
+
*/
|
|
787
|
+
async verifyAccountAuthority(t, n) {
|
|
788
|
+
return this.request(
|
|
789
|
+
"database_api.verify_account_authority",
|
|
790
|
+
{ account: t, signers: n }
|
|
791
|
+
);
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* Verify arbitrary signatures
|
|
795
|
+
*/
|
|
796
|
+
async verifySignatures(t, n, s, r, i, o) {
|
|
797
|
+
return this.request(
|
|
798
|
+
"database_api.verify_signatures",
|
|
799
|
+
{
|
|
800
|
+
hash: t,
|
|
801
|
+
signatures: n,
|
|
802
|
+
required_owner: s,
|
|
803
|
+
required_active: r,
|
|
804
|
+
required_posting: i,
|
|
805
|
+
required_other: o
|
|
806
|
+
}
|
|
807
|
+
);
|
|
808
|
+
}
|
|
809
|
+
// ============================================================================
|
|
810
|
+
// Network Broadcast API
|
|
811
|
+
// ============================================================================
|
|
812
|
+
/**
|
|
813
|
+
* Broadcast transaction to the network
|
|
814
|
+
*/
|
|
815
|
+
async broadcastTransaction(t, n = -1) {
|
|
816
|
+
return this.request(
|
|
817
|
+
"network_broadcast_api.broadcast_transaction",
|
|
818
|
+
{ trx: t, max_block_age: n }
|
|
819
|
+
);
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Broadcast block to the network
|
|
823
|
+
*/
|
|
824
|
+
async broadcastBlock(t) {
|
|
825
|
+
return this.request("network_broadcast_api.broadcast_block", {
|
|
826
|
+
block: t
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
// ============================================================================
|
|
830
|
+
// Block API
|
|
831
|
+
// ============================================================================
|
|
832
|
+
/**
|
|
833
|
+
* Get block header by block number
|
|
834
|
+
*/
|
|
835
|
+
async getBlockHeader(t) {
|
|
836
|
+
return (await this.request("block_api.get_block_header", {
|
|
837
|
+
block_num: t
|
|
838
|
+
})).header;
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Get full block by block number
|
|
842
|
+
*/
|
|
843
|
+
async getBlock(t) {
|
|
844
|
+
return (await this.request("block_api.get_block", {
|
|
845
|
+
block_num: t
|
|
846
|
+
})).block;
|
|
847
|
+
}
|
|
848
|
+
// ============================================================================
|
|
849
|
+
// Account History API
|
|
850
|
+
// ============================================================================
|
|
851
|
+
/**
|
|
852
|
+
* Get operations in a specific block
|
|
853
|
+
*/
|
|
854
|
+
async getOpsInBlock(t) {
|
|
855
|
+
return this.request("account_history_api.get_ops_in_block", t);
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Get transaction by ID
|
|
859
|
+
*/
|
|
860
|
+
async getTransaction(t) {
|
|
861
|
+
return this.request(
|
|
862
|
+
"account_history.get_transaction",
|
|
863
|
+
{ id: t }
|
|
864
|
+
);
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* Get account operation history
|
|
868
|
+
*/
|
|
869
|
+
async getAccountHistory(t) {
|
|
870
|
+
return this.request(
|
|
871
|
+
"account_history.get_account_history",
|
|
872
|
+
t
|
|
873
|
+
);
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* Enumerate virtual operations in block range
|
|
877
|
+
*/
|
|
878
|
+
async enumVirtualOps(t, n) {
|
|
879
|
+
return this.request("account_history_api.enum_virtual_ops", {
|
|
880
|
+
block_range_begin: t,
|
|
881
|
+
block_range_end: n
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
// ============================================================================
|
|
885
|
+
// Tags/Discussion API
|
|
886
|
+
// ============================================================================
|
|
887
|
+
/**
|
|
888
|
+
* Get trending tags
|
|
889
|
+
*/
|
|
890
|
+
async getTrendingTags(t = "", n = 100) {
|
|
891
|
+
return (await this.request("tags_api.get_trending_tags", {
|
|
892
|
+
start_tag: t,
|
|
893
|
+
limit: n
|
|
894
|
+
})).tags;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Get tags used by author
|
|
898
|
+
*/
|
|
899
|
+
async getTagsUsedByAuthor(t) {
|
|
900
|
+
return this.request("tags_api.get_tags_used_by_author", {
|
|
901
|
+
author: t
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* Get single discussion/post
|
|
906
|
+
*/
|
|
907
|
+
async getDiscussion(t, n) {
|
|
908
|
+
return this.request("tags_api.get_discussion", {
|
|
909
|
+
author: t,
|
|
910
|
+
permlink: n
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* Get replies to a post
|
|
915
|
+
*/
|
|
916
|
+
async getContentReplies(t, n) {
|
|
917
|
+
return (await this.request("tags_api.get_content_replies", {
|
|
918
|
+
author: t,
|
|
919
|
+
permlink: n
|
|
920
|
+
})).discussions;
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Get discussions by trending
|
|
924
|
+
*/
|
|
925
|
+
async getDiscussionsByTrending(t) {
|
|
926
|
+
return this.request("tags_api.get_discussions_by_trending", t);
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* Get discussions by creation time
|
|
930
|
+
*/
|
|
931
|
+
async getDiscussionsByCreated(t) {
|
|
932
|
+
return this.request("tags_api.get_discussions_by_created", t);
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Get discussions by activity
|
|
936
|
+
*/
|
|
937
|
+
async getDiscussionsByActive(t) {
|
|
938
|
+
return this.request("tags_api.get_discussions_by_active", t);
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* Get discussions by cashout time
|
|
942
|
+
*/
|
|
943
|
+
async getDiscussionsByCashout(t) {
|
|
944
|
+
return this.request("tags_api.get_discussions_by_cashout", t);
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* Get discussions by votes
|
|
948
|
+
*/
|
|
949
|
+
async getDiscussionsByVotes(t) {
|
|
950
|
+
return this.request("tags_api.get_discussions_by_votes", t);
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* Get discussions by children count
|
|
954
|
+
*/
|
|
955
|
+
async getDiscussionsByChildren(t) {
|
|
956
|
+
return this.request("tags_api.get_discussions_by_children", t);
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Get hot discussions
|
|
960
|
+
*/
|
|
961
|
+
async getDiscussionsByHot(t) {
|
|
962
|
+
return this.request("tags_api.get_discussions_by_hot", t);
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* Get discussions from follower feed
|
|
966
|
+
*/
|
|
967
|
+
async getDiscussionsByFeed(t) {
|
|
968
|
+
return this.request("tags_api.get_discussions_by_feed", t);
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* Get discussions from blog
|
|
972
|
+
*/
|
|
973
|
+
async getDiscussionsByBlog(t) {
|
|
974
|
+
return this.request("tags_api.get_discussions_by_blog", t);
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* Get discussions by comment count
|
|
978
|
+
*/
|
|
979
|
+
async getDiscussionsByComments(t) {
|
|
980
|
+
return this.request("tags_api.get_discussions_by_comments", t);
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* Get promoted discussions
|
|
984
|
+
*/
|
|
985
|
+
async getDiscussionsByPromoted(t) {
|
|
986
|
+
return this.request("tags_api.get_discussions_by_promoted", t);
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Get active votes on a post
|
|
990
|
+
*/
|
|
991
|
+
async getActiveVotes(t, n) {
|
|
992
|
+
return this.request("tags_api.get_active_votes", {
|
|
993
|
+
author: t,
|
|
994
|
+
permlink: n
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
// ============================================================================
|
|
998
|
+
// Follow API
|
|
999
|
+
// ============================================================================
|
|
1000
|
+
/**
|
|
1001
|
+
* Get followers of an account
|
|
1002
|
+
*/
|
|
1003
|
+
async getFollowers(t) {
|
|
1004
|
+
return (await this.request("follow_api.get_followers", t)).followers;
|
|
1005
|
+
}
|
|
1006
|
+
/**
|
|
1007
|
+
* Get accounts that an account is following
|
|
1008
|
+
*/
|
|
1009
|
+
async getFollowing(t) {
|
|
1010
|
+
return (await this.request("follow_api.get_following", t)).following;
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Get follower and following counts
|
|
1014
|
+
*/
|
|
1015
|
+
async getFollowCount(t) {
|
|
1016
|
+
return this.request("follow_api.get_follow_count", { account: t });
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Get feed entries
|
|
1020
|
+
*/
|
|
1021
|
+
async getFeedEntries(t, n = 0, s = 100) {
|
|
1022
|
+
return this.request("follow_api.get_feed_entries", {
|
|
1023
|
+
account: t,
|
|
1024
|
+
start_entry_id: n,
|
|
1025
|
+
limit: s
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Get feed with full comments
|
|
1030
|
+
*/
|
|
1031
|
+
async getFeed(t, n = 0, s = 100) {
|
|
1032
|
+
return this.request("follow_api.get_feed", {
|
|
1033
|
+
account: t,
|
|
1034
|
+
start_entry_id: n,
|
|
1035
|
+
limit: s
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* Get blog entries
|
|
1040
|
+
*/
|
|
1041
|
+
async getBlogEntries(t, n = 0, s = 100) {
|
|
1042
|
+
return this.request("follow_api.get_blog_entries", {
|
|
1043
|
+
account: t,
|
|
1044
|
+
start_entry_id: n,
|
|
1045
|
+
limit: s
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Get blog with full comments
|
|
1050
|
+
*/
|
|
1051
|
+
async getBlog(t, n = 0, s = 100) {
|
|
1052
|
+
return this.request("follow_api.get_blog", {
|
|
1053
|
+
account: t,
|
|
1054
|
+
start_entry_id: n,
|
|
1055
|
+
limit: s
|
|
1056
|
+
});
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Get account reputation scores
|
|
1060
|
+
*/
|
|
1061
|
+
async getAccountReputations(t = "", n = 100) {
|
|
1062
|
+
return this.request("follow_api.get_account_reputations", {
|
|
1063
|
+
account_lower_bound: t,
|
|
1064
|
+
limit: n
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
/**
|
|
1068
|
+
* Get accounts that reblogged a post
|
|
1069
|
+
*/
|
|
1070
|
+
async getRebloggedBy(t, n) {
|
|
1071
|
+
return this.request("follow_api.get_reblogged_by", {
|
|
1072
|
+
author: t,
|
|
1073
|
+
permlink: n
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* Get blog author statistics
|
|
1078
|
+
*/
|
|
1079
|
+
async getBlogAuthors(t) {
|
|
1080
|
+
return this.request("follow_api.get_blog_authors", {
|
|
1081
|
+
blog_account: t
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
// ============================================================================
|
|
1085
|
+
// Market History API
|
|
1086
|
+
// ============================================================================
|
|
1087
|
+
/**
|
|
1088
|
+
* Get market ticker
|
|
1089
|
+
*/
|
|
1090
|
+
async getTicker() {
|
|
1091
|
+
return this.request("market_history_api.get_ticker", {});
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* Get market volume
|
|
1095
|
+
*/
|
|
1096
|
+
async getVolume() {
|
|
1097
|
+
return this.request("market_history_api.get_volume", {});
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* Get market order book
|
|
1101
|
+
*/
|
|
1102
|
+
async getMarketOrderBook(t = 50) {
|
|
1103
|
+
return this.request("market_history_api.get_order_book", {
|
|
1104
|
+
limit: t
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Get trade history
|
|
1109
|
+
*/
|
|
1110
|
+
async getTradeHistory(t, n, s = 100) {
|
|
1111
|
+
return this.request("market_history_api.get_trade_history", {
|
|
1112
|
+
start: t,
|
|
1113
|
+
end: n,
|
|
1114
|
+
limit: s
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Get recent trades
|
|
1119
|
+
*/
|
|
1120
|
+
async getRecentTrades(t = 100) {
|
|
1121
|
+
return this.request("market_history_api.get_recent_trades", {
|
|
1122
|
+
limit: t
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
|
+
/**
|
|
1126
|
+
* Get market history buckets
|
|
1127
|
+
*/
|
|
1128
|
+
async getMarketHistory(t, n, s) {
|
|
1129
|
+
return this.request(
|
|
1130
|
+
"market_history_api.get_market_history",
|
|
1131
|
+
{
|
|
1132
|
+
bucket_seconds: t,
|
|
1133
|
+
start: n,
|
|
1134
|
+
end: s
|
|
1135
|
+
}
|
|
1136
|
+
);
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* Get available bucket sizes
|
|
1140
|
+
*/
|
|
1141
|
+
async getMarketHistoryBuckets() {
|
|
1142
|
+
return (await this.request(
|
|
1143
|
+
"market_history_api.get_market_history_buckets",
|
|
1144
|
+
{}
|
|
1145
|
+
)).bucket_sizes;
|
|
1146
|
+
}
|
|
1147
|
+
// ============================================================================
|
|
1148
|
+
// Account By Key API
|
|
1149
|
+
// ============================================================================
|
|
1150
|
+
/**
|
|
1151
|
+
* Get accounts that can sign with given public keys
|
|
1152
|
+
*/
|
|
1153
|
+
async getKeyReferences(t) {
|
|
1154
|
+
return this.request("account_by_key_api.get_key_references", {
|
|
1155
|
+
keys: t
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
// ============================================================================
|
|
1159
|
+
// JSON-RPC Meta API
|
|
1160
|
+
// ============================================================================
|
|
1161
|
+
/**
|
|
1162
|
+
* Get list of all available RPC methods
|
|
1163
|
+
*/
|
|
1164
|
+
async getMethods() {
|
|
1165
|
+
return this.request("jsonrpc.get_methods", {});
|
|
1166
|
+
}
|
|
1167
|
+
/**
|
|
1168
|
+
* Get signature (parameters and return type) for an RPC method
|
|
1169
|
+
*/
|
|
1170
|
+
async getSignature(t) {
|
|
1171
|
+
return this.request("jsonrpc.get_signature", { method: t });
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */
|
|
1175
|
+
const cn = {
|
|
1176
|
+
p: 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,
|
|
1177
|
+
n: 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,
|
|
1178
|
+
b: 7n,
|
|
1179
|
+
Gx: 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,
|
|
1180
|
+
Gy: 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n
|
|
1181
|
+
}, { p: Z, n: H, Gx: an, Gy: un, b: he } = cn, U = 32, X = 64, B = (e = "") => {
|
|
1182
|
+
throw new Error(e);
|
|
1183
|
+
}, le = (e) => typeof e == "bigint", de = (e) => typeof e == "string", fn = (e) => e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array", tt = (e, t) => !fn(e) || typeof t == "number" && t > 0 && e.length !== t ? B("Uint8Array expected") : e, Q = (e) => new Uint8Array(e), hn = (e) => Uint8Array.from(e), ye = (e, t) => e.toString(16).padStart(t, "0"), qt = (e) => Array.from(tt(e)).map((t) => ye(t, 2)).join(""), O = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 }, Jt = (e) => {
|
|
1184
|
+
if (e >= O._0 && e <= O._9)
|
|
1185
|
+
return e - O._0;
|
|
1186
|
+
if (e >= O.A && e <= O.F)
|
|
1187
|
+
return e - (O.A - 10);
|
|
1188
|
+
if (e >= O.a && e <= O.f)
|
|
1189
|
+
return e - (O.a - 10);
|
|
1190
|
+
}, Wt = (e) => {
|
|
1191
|
+
const t = "hex invalid";
|
|
1192
|
+
if (!de(e))
|
|
1193
|
+
return B(t);
|
|
1194
|
+
const n = e.length, s = n / 2;
|
|
1195
|
+
if (n % 2)
|
|
1196
|
+
return B(t);
|
|
1197
|
+
const r = Q(s);
|
|
1198
|
+
for (let i = 0, o = 0; i < s; i++, o += 2) {
|
|
1199
|
+
const u = Jt(e.charCodeAt(o)), a = Jt(e.charCodeAt(o + 1));
|
|
1200
|
+
if (u === void 0 || a === void 0)
|
|
1201
|
+
return B(t);
|
|
1202
|
+
r[i] = u * 16 + a;
|
|
1203
|
+
}
|
|
1204
|
+
return r;
|
|
1205
|
+
}, k = (e, t) => tt(de(e) ? Wt(e) : hn(tt(e)), t), be = () => globalThis?.crypto, ln = () => be()?.subtle ?? B("crypto.subtle must be defined"), et = (...e) => {
|
|
1206
|
+
const t = Q(e.reduce((s, r) => s + tt(r).length, 0));
|
|
1207
|
+
let n = 0;
|
|
1208
|
+
return e.forEach((s) => {
|
|
1209
|
+
t.set(s, n), n += s.length;
|
|
1210
|
+
}), t;
|
|
1211
|
+
}, ge = (e = U) => be().getRandomValues(Q(e)), ot = BigInt, dt = (e, t, n, s = "bad number: out of range") => le(e) && t <= e && e < n ? e : B(s), w = (e, t = Z) => {
|
|
1212
|
+
const n = e % t;
|
|
1213
|
+
return n >= 0n ? n : t + n;
|
|
1214
|
+
}, S = (e) => w(e, H), yt = (e, t) => {
|
|
1215
|
+
(e === 0n || t <= 0n) && B("no inverse n=" + e + " mod=" + t);
|
|
1216
|
+
let n = w(e, t), s = t, r = 0n, i = 1n;
|
|
1217
|
+
for (; n !== 0n; ) {
|
|
1218
|
+
const o = s / n, u = s % n, a = r - i * o;
|
|
1219
|
+
s = n, n = u, r = i, i = a;
|
|
1220
|
+
}
|
|
1221
|
+
return s === 1n ? w(r, t) : B("no inverse");
|
|
1222
|
+
}, te = (e) => e instanceof v ? e : B("Point expected"), _e = (e) => w(w(e * e) * e + he), ee = (e) => dt(e, 0n, Z), ft = (e) => dt(e, 1n, Z), Ht = (e) => dt(e, 1n, H), Ft = (e) => (e & 1n) === 0n, Et = (e) => Uint8Array.of(e), pe = (e) => Et(Ft(e) ? 2 : 3), dn = (e) => {
|
|
1223
|
+
const t = _e(ft(e));
|
|
1224
|
+
let n = 1n;
|
|
1225
|
+
for (let s = t, r = (Z + 1n) / 4n; r > 0n; r >>= 1n)
|
|
1226
|
+
r & 1n && (n = n * s % Z), s = s * s % Z;
|
|
1227
|
+
return w(n * n) === t ? n : B("sqrt invalid");
|
|
1228
|
+
};
|
|
1229
|
+
class v {
|
|
1230
|
+
static BASE;
|
|
1231
|
+
static ZERO;
|
|
1232
|
+
px;
|
|
1233
|
+
py;
|
|
1234
|
+
pz;
|
|
1235
|
+
constructor(t, n, s) {
|
|
1236
|
+
this.px = ee(t), this.py = ft(n), this.pz = ee(s), Object.freeze(this);
|
|
1237
|
+
}
|
|
1238
|
+
/** Convert Uint8Array or hex string to Point. */
|
|
1239
|
+
static fromBytes(t) {
|
|
1240
|
+
tt(t);
|
|
1241
|
+
let n;
|
|
1242
|
+
const s = t[0], r = t.subarray(1), i = vt(r, 0, U), o = t.length;
|
|
1243
|
+
if (o === U + 1 && [2, 3].includes(s)) {
|
|
1244
|
+
let u = dn(i);
|
|
1245
|
+
const a = Ft(u);
|
|
1246
|
+
Ft(ot(s)) !== a && (u = w(-u)), n = new v(i, u, 1n);
|
|
1247
|
+
}
|
|
1248
|
+
return o === X + 1 && s === 4 && (n = new v(i, vt(r, U, X), 1n)), n ? n.assertValidity() : B("bad point: not on curve");
|
|
1249
|
+
}
|
|
1250
|
+
/** Equality check: compare points P&Q. */
|
|
1251
|
+
equals(t) {
|
|
1252
|
+
const { px: n, py: s, pz: r } = this, { px: i, py: o, pz: u } = te(t), a = w(n * u), c = w(i * r), h = w(s * u), f = w(o * r);
|
|
1253
|
+
return a === c && h === f;
|
|
1254
|
+
}
|
|
1255
|
+
is0() {
|
|
1256
|
+
return this.equals($);
|
|
1257
|
+
}
|
|
1258
|
+
/** Flip point over y coordinate. */
|
|
1259
|
+
negate() {
|
|
1260
|
+
return new v(this.px, w(-this.py), this.pz);
|
|
1261
|
+
}
|
|
1262
|
+
/** Point doubling: P+P, complete formula. */
|
|
1263
|
+
double() {
|
|
1264
|
+
return this.add(this);
|
|
1265
|
+
}
|
|
1266
|
+
/**
|
|
1267
|
+
* Point addition: P+Q, complete, exception-free formula
|
|
1268
|
+
* (Renes-Costello-Batina, algo 1 of [2015/1060](https://eprint.iacr.org/2015/1060)).
|
|
1269
|
+
* Cost: `12M + 0S + 3*a + 3*b3 + 23add`.
|
|
1270
|
+
*/
|
|
1271
|
+
// prettier-ignore
|
|
1272
|
+
add(t) {
|
|
1273
|
+
const { px: n, py: s, pz: r } = this, { px: i, py: o, pz: u } = te(t), a = 0n, c = he;
|
|
1274
|
+
let h = 0n, f = 0n, l = 0n;
|
|
1275
|
+
const d = w(c * 3n);
|
|
1276
|
+
let y = w(n * i), b = w(s * o), _ = w(r * u), x = w(n + s), g = w(i + o);
|
|
1277
|
+
x = w(x * g), g = w(y + b), x = w(x - g), g = w(n + r);
|
|
1278
|
+
let p = w(i + u);
|
|
1279
|
+
return g = w(g * p), p = w(y + _), g = w(g - p), p = w(s + r), h = w(o + u), p = w(p * h), h = w(b + _), p = w(p - h), l = w(a * g), h = w(d * _), l = w(h + l), h = w(b - l), l = w(b + l), f = w(h * l), b = w(y + y), b = w(b + y), _ = w(a * _), g = w(d * g), b = w(b + _), _ = w(y - _), _ = w(a * _), g = w(g + _), y = w(b * g), f = w(f + y), y = w(p * g), h = w(x * h), h = w(h - y), y = w(x * b), l = w(p * l), l = w(l + y), new v(h, f, l);
|
|
1280
|
+
}
|
|
1281
|
+
/**
|
|
1282
|
+
* Point-by-scalar multiplication. Scalar must be in range 1 <= n < CURVE.n.
|
|
1283
|
+
* Uses {@link wNAF} for base point.
|
|
1284
|
+
* Uses fake point to mitigate side-channel leakage.
|
|
1285
|
+
* @param n scalar by which point is multiplied
|
|
1286
|
+
* @param safe safe mode guards against timing attacks; unsafe mode is faster
|
|
1287
|
+
*/
|
|
1288
|
+
multiply(t, n = !0) {
|
|
1289
|
+
if (!n && t === 0n)
|
|
1290
|
+
return $;
|
|
1291
|
+
if (Ht(t), t === 1n)
|
|
1292
|
+
return this;
|
|
1293
|
+
if (this.equals(K))
|
|
1294
|
+
return Un(t).p;
|
|
1295
|
+
let s = $, r = K;
|
|
1296
|
+
for (let i = this; t > 0n; i = i.double(), t >>= 1n)
|
|
1297
|
+
t & 1n ? s = s.add(i) : n && (r = r.add(i));
|
|
1298
|
+
return s;
|
|
1299
|
+
}
|
|
1300
|
+
/** Convert point to 2d xy affine point. (X, Y, Z) ∋ (x=X/Z, y=Y/Z) */
|
|
1301
|
+
toAffine() {
|
|
1302
|
+
const { px: t, py: n, pz: s } = this;
|
|
1303
|
+
if (this.equals($))
|
|
1304
|
+
return { x: 0n, y: 0n };
|
|
1305
|
+
if (s === 1n)
|
|
1306
|
+
return { x: t, y: n };
|
|
1307
|
+
const r = yt(s, Z);
|
|
1308
|
+
return w(s * r) !== 1n && B("inverse invalid"), { x: w(t * r), y: w(n * r) };
|
|
1309
|
+
}
|
|
1310
|
+
/** Checks if the point is valid and on-curve. */
|
|
1311
|
+
assertValidity() {
|
|
1312
|
+
const { x: t, y: n } = this.toAffine();
|
|
1313
|
+
return ft(t), ft(n), w(n * n) === _e(t) ? this : B("bad point: not on curve");
|
|
1314
|
+
}
|
|
1315
|
+
/** Converts point to 33/65-byte Uint8Array. */
|
|
1316
|
+
toBytes(t = !0) {
|
|
1317
|
+
const { x: n, y: s } = this.assertValidity().toAffine(), r = z(n);
|
|
1318
|
+
return t ? et(pe(s), r) : et(Et(4), r, z(s));
|
|
1319
|
+
}
|
|
1320
|
+
/** Create 3d xyz point from 2d xy. (0, 0) => (0, 1, 0), not (0, 0, 1) */
|
|
1321
|
+
static fromAffine(t) {
|
|
1322
|
+
const { x: n, y: s } = t;
|
|
1323
|
+
return n === 0n && s === 0n ? $ : new v(n, s, 1n);
|
|
1324
|
+
}
|
|
1325
|
+
toHex(t) {
|
|
1326
|
+
return qt(this.toBytes(t));
|
|
1327
|
+
}
|
|
1328
|
+
static fromPrivateKey(t) {
|
|
1329
|
+
return K.multiply(It(t));
|
|
1330
|
+
}
|
|
1331
|
+
static fromHex(t) {
|
|
1332
|
+
return v.fromBytes(k(t));
|
|
1333
|
+
}
|
|
1334
|
+
get x() {
|
|
1335
|
+
return this.toAffine().x;
|
|
1336
|
+
}
|
|
1337
|
+
get y() {
|
|
1338
|
+
return this.toAffine().y;
|
|
1339
|
+
}
|
|
1340
|
+
toRawBytes(t) {
|
|
1341
|
+
return this.toBytes(t);
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
const K = new v(an, un, 1n), $ = new v(0n, 1n, 0n);
|
|
1345
|
+
v.BASE = K;
|
|
1346
|
+
v.ZERO = $;
|
|
1347
|
+
const we = (e, t, n) => K.multiply(t, !1).add(e.multiply(n, !1)).assertValidity(), bt = (e) => ot("0x" + (qt(e) || "0")), vt = (e, t, n) => bt(e.subarray(t, n)), yn = 2n ** 256n, z = (e) => Wt(ye(dt(e, 0n, yn), X)), It = (e) => {
|
|
1348
|
+
const t = le(e) ? e : bt(k(e, U));
|
|
1349
|
+
return dt(t, 1n, H, "private key invalid 3");
|
|
1350
|
+
}, St = (e) => e > H >> 1n, bn = (e, t = !0) => K.multiply(It(e)).toBytes(t);
|
|
1351
|
+
let Tt = class ut {
|
|
1352
|
+
r;
|
|
1353
|
+
s;
|
|
1354
|
+
recovery;
|
|
1355
|
+
constructor(t, n, s) {
|
|
1356
|
+
this.r = Ht(t), this.s = Ht(n), s != null && (this.recovery = s), Object.freeze(this);
|
|
1357
|
+
}
|
|
1358
|
+
/** Create signature from 64b compact (r || s) representation. */
|
|
1359
|
+
static fromBytes(t) {
|
|
1360
|
+
tt(t, X);
|
|
1361
|
+
const n = vt(t, 0, U), s = vt(t, U, X);
|
|
1362
|
+
return new ut(n, s);
|
|
1363
|
+
}
|
|
1364
|
+
toBytes() {
|
|
1365
|
+
const { r: t, s: n } = this;
|
|
1366
|
+
return et(z(t), z(n));
|
|
1367
|
+
}
|
|
1368
|
+
/** Copy signature, with newly added recovery bit. */
|
|
1369
|
+
addRecoveryBit(t) {
|
|
1370
|
+
return new ut(this.r, this.s, t);
|
|
1371
|
+
}
|
|
1372
|
+
hasHighS() {
|
|
1373
|
+
return St(this.s);
|
|
1374
|
+
}
|
|
1375
|
+
toCompactRawBytes() {
|
|
1376
|
+
return this.toBytes();
|
|
1377
|
+
}
|
|
1378
|
+
toCompactHex() {
|
|
1379
|
+
return qt(this.toBytes());
|
|
1380
|
+
}
|
|
1381
|
+
recoverPublicKey(t) {
|
|
1382
|
+
return mn(this, t);
|
|
1383
|
+
}
|
|
1384
|
+
static fromCompact(t) {
|
|
1385
|
+
return ut.fromBytes(k(t, X));
|
|
1386
|
+
}
|
|
1387
|
+
assertValidity() {
|
|
1388
|
+
return this;
|
|
1389
|
+
}
|
|
1390
|
+
normalizeS() {
|
|
1391
|
+
const { r: t, s: n, recovery: s } = this;
|
|
1392
|
+
return St(n) ? new ut(t, S(-n), s) : this;
|
|
1393
|
+
}
|
|
1394
|
+
};
|
|
1395
|
+
const xe = (e) => {
|
|
1396
|
+
const t = e.length * 8 - 256;
|
|
1397
|
+
t > 1024 && B("msg invalid");
|
|
1398
|
+
const n = bt(e);
|
|
1399
|
+
return t > 0 ? n >> ot(t) : n;
|
|
1400
|
+
}, Lt = (e) => S(xe(tt(e))), me = { lowS: !0 }, gn = { lowS: !0 }, _n = (e, t, n = me) => {
|
|
1401
|
+
["der", "recovered", "canonical"].some((l) => l in n) && B("option not supported");
|
|
1402
|
+
let { lowS: s, extraEntropy: r } = n;
|
|
1403
|
+
s == null && (s = !0);
|
|
1404
|
+
const i = z, o = Lt(k(e)), u = i(o), a = It(t), c = [i(a), u];
|
|
1405
|
+
r && c.push(r === !0 ? ge(U) : k(r));
|
|
1406
|
+
const h = o, f = (l) => {
|
|
1407
|
+
const d = xe(l);
|
|
1408
|
+
if (!(1n <= d && d < H))
|
|
1409
|
+
return;
|
|
1410
|
+
const y = K.multiply(d).toAffine(), b = S(y.x);
|
|
1411
|
+
if (b === 0n)
|
|
1412
|
+
return;
|
|
1413
|
+
const _ = yt(d, H), x = S(_ * S(h + S(a * b)));
|
|
1414
|
+
if (x === 0n)
|
|
1415
|
+
return;
|
|
1416
|
+
let g = x, p = (y.x === b ? 0 : 2) | Number(y.y & 1n);
|
|
1417
|
+
return s && St(x) && (g = S(-x), p ^= 1), new Tt(b, g, p);
|
|
1418
|
+
};
|
|
1419
|
+
return { seed: et(...c), k2sig: f };
|
|
1420
|
+
}, pn = (e) => {
|
|
1421
|
+
let t = Q(U), n = Q(U), s = 0;
|
|
1422
|
+
const r = Q(0), i = () => {
|
|
1423
|
+
t.fill(1), n.fill(0), s = 0;
|
|
1424
|
+
}, o = 1e3, u = "drbg: tried 1000 values";
|
|
1425
|
+
{
|
|
1426
|
+
const a = (...f) => vn.hmacSha256Async(n, t, ...f), c = async (f = r) => {
|
|
1427
|
+
n = await a(Et(0), f), t = await a(), f.length !== 0 && (n = await a(Et(1), f), t = await a());
|
|
1428
|
+
}, h = async () => (s++ >= o && B(u), t = await a(), t);
|
|
1429
|
+
return async (f, l) => {
|
|
1430
|
+
i(), await c(f);
|
|
1431
|
+
let d;
|
|
1432
|
+
for (; !(d = l(await h())); )
|
|
1433
|
+
await c();
|
|
1434
|
+
return i(), d;
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
}, wn = async (e, t, n = me) => {
|
|
1438
|
+
const { seed: s, k2sig: r } = _n(e, t, n);
|
|
1439
|
+
return await pn()(s, r);
|
|
1440
|
+
}, xn = (e, t, n, s = gn) => {
|
|
1441
|
+
let { lowS: r } = s;
|
|
1442
|
+
r == null && (r = !0), "strict" in s && B("option not supported");
|
|
1443
|
+
let i;
|
|
1444
|
+
const o = e && typeof e == "object" && "r" in e;
|
|
1445
|
+
!o && k(e).length !== X && B("signature must be 64 bytes");
|
|
1446
|
+
try {
|
|
1447
|
+
i = o ? new Tt(e.r, e.s) : Tt.fromCompact(e);
|
|
1448
|
+
const u = Lt(k(t)), a = v.fromBytes(k(n)), { r: c, s: h } = i;
|
|
1449
|
+
if (r && St(h))
|
|
1450
|
+
return !1;
|
|
1451
|
+
const f = yt(h, H), l = S(u * f), d = S(c * f), y = we(a, l, d).toAffine();
|
|
1452
|
+
return S(y.x) === c;
|
|
1453
|
+
} catch {
|
|
1454
|
+
return !1;
|
|
1455
|
+
}
|
|
1456
|
+
}, mn = (e, t) => {
|
|
1457
|
+
const { r: n, s, recovery: r } = e;
|
|
1458
|
+
[0, 1, 2, 3].includes(r) || B("recovery id invalid");
|
|
1459
|
+
const i = Lt(k(t, U)), o = r === 2 || r === 3 ? n + H : n;
|
|
1460
|
+
ft(o);
|
|
1461
|
+
const u = pe(ot(r)), a = et(u, z(o)), c = v.fromBytes(a), h = yt(o, H), f = S(-i * h), l = S(s * h);
|
|
1462
|
+
return we(c, f, l);
|
|
1463
|
+
}, An = (e, t, n = !0) => v.fromBytes(k(t)).multiply(It(e)).toBytes(n), Bn = (e) => {
|
|
1464
|
+
e = k(e), (e.length < U + 8 || e.length > 1024) && B("expected 40-1024b");
|
|
1465
|
+
const t = w(bt(e), H - 1n);
|
|
1466
|
+
return z(t + 1n);
|
|
1467
|
+
}, En = "SHA-256", vn = {
|
|
1468
|
+
hexToBytes: Wt,
|
|
1469
|
+
bytesToHex: qt,
|
|
1470
|
+
concatBytes: et,
|
|
1471
|
+
bytesToNumberBE: bt,
|
|
1472
|
+
numberToBytesBE: z,
|
|
1473
|
+
mod: w,
|
|
1474
|
+
invert: yt,
|
|
1475
|
+
// math utilities
|
|
1476
|
+
hmacSha256Async: async (e, ...t) => {
|
|
1477
|
+
const n = ln(), s = "HMAC", r = await n.importKey("raw", e, { name: s, hash: { name: En } }, !1, ["sign"]);
|
|
1478
|
+
return Q(await n.sign(s, r, et(...t)));
|
|
1479
|
+
},
|
|
1480
|
+
hmacSha256Sync: void 0,
|
|
1481
|
+
// For TypeScript. Actual logic is below
|
|
1482
|
+
hashToPrivateKey: Bn,
|
|
1483
|
+
randomBytes: ge
|
|
1484
|
+
}, Ut = 8, Sn = 256, Ae = Math.ceil(Sn / Ut) + 1, Dt = 2 ** (Ut - 1), Tn = () => {
|
|
1485
|
+
const e = [];
|
|
1486
|
+
let t = K, n = t;
|
|
1487
|
+
for (let s = 0; s < Ae; s++) {
|
|
1488
|
+
n = t, e.push(n);
|
|
1489
|
+
for (let r = 1; r < Dt; r++)
|
|
1490
|
+
n = n.add(t), e.push(n);
|
|
1491
|
+
t = n.double();
|
|
1492
|
+
}
|
|
1493
|
+
return e;
|
|
1494
|
+
};
|
|
1495
|
+
let ne;
|
|
1496
|
+
const se = (e, t) => {
|
|
1497
|
+
const n = t.negate();
|
|
1498
|
+
return e ? n : t;
|
|
1499
|
+
}, Un = (e) => {
|
|
1500
|
+
const t = ne || (ne = Tn());
|
|
1501
|
+
let n = $, s = K;
|
|
1502
|
+
const r = 2 ** Ut, i = r, o = ot(r - 1), u = ot(Ut);
|
|
1503
|
+
for (let a = 0; a < Ae; a++) {
|
|
1504
|
+
let c = Number(e & o);
|
|
1505
|
+
e >>= u, c > Dt && (c -= i, e += 1n);
|
|
1506
|
+
const h = a * Dt, f = h, l = h + Math.abs(c) - 1, d = a % 2 !== 0, y = c < 0;
|
|
1507
|
+
c === 0 ? s = s.add(se(d, t[f])) : n = n.add(se(y, t[l]));
|
|
1508
|
+
}
|
|
1509
|
+
return { p: n, f: s };
|
|
1510
|
+
}, qn = /* @__PURE__ */ Uint8Array.from([
|
|
1511
|
+
7,
|
|
1512
|
+
4,
|
|
1513
|
+
13,
|
|
1514
|
+
1,
|
|
1515
|
+
10,
|
|
1516
|
+
6,
|
|
1517
|
+
15,
|
|
1518
|
+
3,
|
|
1519
|
+
12,
|
|
1520
|
+
0,
|
|
1521
|
+
9,
|
|
1522
|
+
5,
|
|
1523
|
+
2,
|
|
1524
|
+
14,
|
|
1525
|
+
11,
|
|
1526
|
+
8
|
|
1527
|
+
]), Be = Uint8Array.from(new Array(16).fill(0).map((e, t) => t)), In = Be.map((e) => (9 * e + 5) % 16), Ee = /* @__PURE__ */ (() => {
|
|
1528
|
+
const n = [[Be], [In]];
|
|
1529
|
+
for (let s = 0; s < 4; s++)
|
|
1530
|
+
for (let r of n)
|
|
1531
|
+
r.push(r[s].map((i) => qn[i]));
|
|
1532
|
+
return n;
|
|
1533
|
+
})(), ve = Ee[0], Se = Ee[1], Te = /* @__PURE__ */ [
|
|
1534
|
+
[11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],
|
|
1535
|
+
[12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],
|
|
1536
|
+
[13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],
|
|
1537
|
+
[14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],
|
|
1538
|
+
[15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5]
|
|
1539
|
+
].map((e) => Uint8Array.from(e)), Rn = /* @__PURE__ */ ve.map((e, t) => e.map((n) => Te[t][n])), kn = /* @__PURE__ */ Se.map((e, t) => e.map((n) => Te[t][n])), Cn = /* @__PURE__ */ Uint32Array.from([
|
|
1540
|
+
0,
|
|
1541
|
+
1518500249,
|
|
1542
|
+
1859775393,
|
|
1543
|
+
2400959708,
|
|
1544
|
+
2840853838
|
|
1545
|
+
]), Nn = /* @__PURE__ */ Uint32Array.from([
|
|
1546
|
+
1352829926,
|
|
1547
|
+
1548603684,
|
|
1548
|
+
1836072691,
|
|
1549
|
+
2053994217,
|
|
1550
|
+
0
|
|
1551
|
+
]);
|
|
1552
|
+
function re(e, t, n, s) {
|
|
1553
|
+
return e === 0 ? t ^ n ^ s : e === 1 ? t & n | ~t & s : e === 2 ? (t | ~n) ^ s : e === 3 ? t & s | n & ~s : t ^ (n | ~s);
|
|
1554
|
+
}
|
|
1555
|
+
const Bt = /* @__PURE__ */ new Uint32Array(16);
|
|
1556
|
+
class Hn extends Vt {
|
|
1557
|
+
constructor() {
|
|
1558
|
+
super(64, 20, 8, !0), this.h0 = 1732584193, this.h1 = -271733879, this.h2 = -1732584194, this.h3 = 271733878, this.h4 = -1009589776;
|
|
1559
|
+
}
|
|
1560
|
+
get() {
|
|
1561
|
+
const { h0: t, h1: n, h2: s, h3: r, h4: i } = this;
|
|
1562
|
+
return [t, n, s, r, i];
|
|
1563
|
+
}
|
|
1564
|
+
set(t, n, s, r, i) {
|
|
1565
|
+
this.h0 = t | 0, this.h1 = n | 0, this.h2 = s | 0, this.h3 = r | 0, this.h4 = i | 0;
|
|
1566
|
+
}
|
|
1567
|
+
process(t, n) {
|
|
1568
|
+
for (let d = 0; d < 16; d++, n += 4)
|
|
1569
|
+
Bt[d] = t.getUint32(n, !0);
|
|
1570
|
+
let s = this.h0 | 0, r = s, i = this.h1 | 0, o = i, u = this.h2 | 0, a = u, c = this.h3 | 0, h = c, f = this.h4 | 0, l = f;
|
|
1571
|
+
for (let d = 0; d < 5; d++) {
|
|
1572
|
+
const y = 4 - d, b = Cn[d], _ = Nn[d], x = ve[d], g = Se[d], p = Rn[d], A = kn[d];
|
|
1573
|
+
for (let m = 0; m < 16; m++) {
|
|
1574
|
+
const F = wt(s + re(d, i, u, c) + Bt[x[m]] + b, p[m]) + f | 0;
|
|
1575
|
+
s = f, f = c, c = wt(u, 10) | 0, u = i, i = F;
|
|
1576
|
+
}
|
|
1577
|
+
for (let m = 0; m < 16; m++) {
|
|
1578
|
+
const F = wt(r + re(y, o, a, h) + Bt[g[m]] + _, A[m]) + l | 0;
|
|
1579
|
+
r = l, l = h, h = wt(a, 10) | 0, a = o, o = F;
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
this.set(this.h1 + u + h | 0, this.h2 + c + l | 0, this.h3 + f + r | 0, this.h4 + s + o | 0, this.h0 + i + a | 0);
|
|
1583
|
+
}
|
|
1584
|
+
roundClean() {
|
|
1585
|
+
J(Bt);
|
|
1586
|
+
}
|
|
1587
|
+
destroy() {
|
|
1588
|
+
this.destroyed = !0, J(this.buffer), this.set(0, 0, 0, 0, 0);
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
const ie = /* @__PURE__ */ Mt(() => new Hn());
|
|
1592
|
+
function Fn(e) {
|
|
1593
|
+
if (e.length >= 255)
|
|
1594
|
+
throw new TypeError("Alphabet too long");
|
|
1595
|
+
const t = new Uint8Array(256);
|
|
1596
|
+
for (let c = 0; c < t.length; c++)
|
|
1597
|
+
t[c] = 255;
|
|
1598
|
+
for (let c = 0; c < e.length; c++) {
|
|
1599
|
+
const h = e.charAt(c), f = h.charCodeAt(0);
|
|
1600
|
+
if (t[f] !== 255)
|
|
1601
|
+
throw new TypeError(h + " is ambiguous");
|
|
1602
|
+
t[f] = c;
|
|
1603
|
+
}
|
|
1604
|
+
const n = e.length, s = e.charAt(0), r = Math.log(n) / Math.log(256), i = Math.log(256) / Math.log(n);
|
|
1605
|
+
function o(c) {
|
|
1606
|
+
if (c instanceof Uint8Array || (ArrayBuffer.isView(c) ? c = new Uint8Array(c.buffer, c.byteOffset, c.byteLength) : Array.isArray(c) && (c = Uint8Array.from(c))), !(c instanceof Uint8Array))
|
|
1607
|
+
throw new TypeError("Expected Uint8Array");
|
|
1608
|
+
if (c.length === 0)
|
|
1609
|
+
return "";
|
|
1610
|
+
let h = 0, f = 0, l = 0;
|
|
1611
|
+
const d = c.length;
|
|
1612
|
+
for (; l !== d && c[l] === 0; )
|
|
1613
|
+
l++, h++;
|
|
1614
|
+
const y = (d - l) * i + 1 >>> 0, b = new Uint8Array(y);
|
|
1615
|
+
for (; l !== d; ) {
|
|
1616
|
+
let g = c[l], p = 0;
|
|
1617
|
+
for (let A = y - 1; (g !== 0 || p < f) && A !== -1; A--, p++)
|
|
1618
|
+
g += 256 * b[A] >>> 0, b[A] = g % n >>> 0, g = g / n >>> 0;
|
|
1619
|
+
if (g !== 0)
|
|
1620
|
+
throw new Error("Non-zero carry");
|
|
1621
|
+
f = p, l++;
|
|
1622
|
+
}
|
|
1623
|
+
let _ = y - f;
|
|
1624
|
+
for (; _ !== y && b[_] === 0; )
|
|
1625
|
+
_++;
|
|
1626
|
+
let x = s.repeat(h);
|
|
1627
|
+
for (; _ < y; ++_)
|
|
1628
|
+
x += e.charAt(b[_]);
|
|
1629
|
+
return x;
|
|
1630
|
+
}
|
|
1631
|
+
function u(c) {
|
|
1632
|
+
if (typeof c != "string")
|
|
1633
|
+
throw new TypeError("Expected String");
|
|
1634
|
+
if (c.length === 0)
|
|
1635
|
+
return new Uint8Array();
|
|
1636
|
+
let h = 0, f = 0, l = 0;
|
|
1637
|
+
for (; c[h] === s; )
|
|
1638
|
+
f++, h++;
|
|
1639
|
+
const d = (c.length - h) * r + 1 >>> 0, y = new Uint8Array(d);
|
|
1640
|
+
for (; h < c.length; ) {
|
|
1641
|
+
const g = c.charCodeAt(h);
|
|
1642
|
+
if (g > 255)
|
|
1643
|
+
return;
|
|
1644
|
+
let p = t[g];
|
|
1645
|
+
if (p === 255)
|
|
1646
|
+
return;
|
|
1647
|
+
let A = 0;
|
|
1648
|
+
for (let m = d - 1; (p !== 0 || A < l) && m !== -1; m--, A++)
|
|
1649
|
+
p += n * y[m] >>> 0, y[m] = p % 256 >>> 0, p = p / 256 >>> 0;
|
|
1650
|
+
if (p !== 0)
|
|
1651
|
+
throw new Error("Non-zero carry");
|
|
1652
|
+
l = A, h++;
|
|
1653
|
+
}
|
|
1654
|
+
let b = d - l;
|
|
1655
|
+
for (; b !== d && y[b] === 0; )
|
|
1656
|
+
b++;
|
|
1657
|
+
const _ = new Uint8Array(f + (d - b));
|
|
1658
|
+
let x = f;
|
|
1659
|
+
for (; b !== d; )
|
|
1660
|
+
_[x++] = y[b++];
|
|
1661
|
+
return _;
|
|
1662
|
+
}
|
|
1663
|
+
function a(c) {
|
|
1664
|
+
const h = u(c);
|
|
1665
|
+
if (h)
|
|
1666
|
+
return h;
|
|
1667
|
+
throw new Error("Non-base" + n + " character");
|
|
1668
|
+
}
|
|
1669
|
+
return {
|
|
1670
|
+
encode: o,
|
|
1671
|
+
decodeUnsafe: u,
|
|
1672
|
+
decode: a
|
|
1673
|
+
};
|
|
1674
|
+
}
|
|
1675
|
+
var Dn = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
1676
|
+
const ct = Fn(Dn);
|
|
1677
|
+
class T {
|
|
1678
|
+
key;
|
|
1679
|
+
constructor(t) {
|
|
1680
|
+
if (t.length !== 32)
|
|
1681
|
+
throw new Error("Private key must be 32 bytes");
|
|
1682
|
+
this.key = t;
|
|
1683
|
+
}
|
|
1684
|
+
/**
|
|
1685
|
+
* Create PrivateKey from WIF (Wallet Import Format) string
|
|
1686
|
+
*/
|
|
1687
|
+
static fromWif(t) {
|
|
1688
|
+
const n = ct.decode(t);
|
|
1689
|
+
if (n[0] !== 128)
|
|
1690
|
+
throw new Error("Invalid WIF version byte");
|
|
1691
|
+
const s = n.slice(1, 33), r = n.slice(33, 37), i = R(n.slice(0, 33)), u = R(i).slice(0, 4);
|
|
1692
|
+
if (!qe(r, u))
|
|
1693
|
+
throw new Error("Invalid WIF checksum");
|
|
1694
|
+
return new T(s);
|
|
1695
|
+
}
|
|
1696
|
+
/**
|
|
1697
|
+
* Create PrivateKey from seed string
|
|
1698
|
+
*/
|
|
1699
|
+
static fromSeed(t) {
|
|
1700
|
+
const n = R(new TextEncoder().encode(t));
|
|
1701
|
+
return new T(n);
|
|
1702
|
+
}
|
|
1703
|
+
/**
|
|
1704
|
+
* Generate PrivateKey from account name, password and role
|
|
1705
|
+
*/
|
|
1706
|
+
static fromLogin(t, n, s = "active") {
|
|
1707
|
+
const i = (t + s + n).trim().replace(/\s+/g, " ");
|
|
1708
|
+
return T.fromSeed(i);
|
|
1709
|
+
}
|
|
1710
|
+
/**
|
|
1711
|
+
* Convert to WIF format
|
|
1712
|
+
*/
|
|
1713
|
+
toWif() {
|
|
1714
|
+
const t = new Uint8Array(33);
|
|
1715
|
+
t[0] = 128, t.set(this.key, 1);
|
|
1716
|
+
const n = R(t), r = R(n).slice(0, 4), i = new Uint8Array(37);
|
|
1717
|
+
return i.set(t), i.set(r, 33), ct.encode(i);
|
|
1718
|
+
}
|
|
1719
|
+
/**
|
|
1720
|
+
* Get the public key
|
|
1721
|
+
*/
|
|
1722
|
+
toPublic() {
|
|
1723
|
+
const t = bn(this.key, !0);
|
|
1724
|
+
return new gt(t);
|
|
1725
|
+
}
|
|
1726
|
+
/**
|
|
1727
|
+
* Get raw bytes
|
|
1728
|
+
*/
|
|
1729
|
+
toBytes() {
|
|
1730
|
+
return this.key;
|
|
1731
|
+
}
|
|
1732
|
+
/**
|
|
1733
|
+
* Sign a message hash
|
|
1734
|
+
* @param messageHash The message hash to sign
|
|
1735
|
+
* @returns Signature with recovery parameter
|
|
1736
|
+
*/
|
|
1737
|
+
async sign(t) {
|
|
1738
|
+
const n = await wn(t, this.key, {
|
|
1739
|
+
lowS: !0
|
|
1740
|
+
// Enforce canonical signatures (prevents malleability)
|
|
1741
|
+
});
|
|
1742
|
+
return new Ue({ signature: n.toCompactRawBytes(), recovery: n.recovery ?? 0 });
|
|
1743
|
+
}
|
|
1744
|
+
/**
|
|
1745
|
+
* Get shared secret with a public key (for ECIES encryption)
|
|
1746
|
+
* @param publicKey The public key to generate shared secret with
|
|
1747
|
+
* @returns Shared secret as Uint8Array
|
|
1748
|
+
*/
|
|
1749
|
+
getSharedSecret(t) {
|
|
1750
|
+
return An(this.key, t.toBytes(), !0).slice(1);
|
|
1751
|
+
}
|
|
1752
|
+
/**
|
|
1753
|
+
* Derive child key from offset (hierarchical key derivation)
|
|
1754
|
+
* @param offset Offset string for derivation
|
|
1755
|
+
* @returns New derived PrivateKey
|
|
1756
|
+
*/
|
|
1757
|
+
child(t) {
|
|
1758
|
+
const n = R(new TextEncoder().encode(t)), s = BigInt("0x" + Array.from(n).map((c) => c.toString(16).padStart(2, "0")).join("")), r = BigInt("0x" + Array.from(this.key).map((c) => c.toString(16).padStart(2, "0")).join("")), i = BigInt("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"), u = ((r + s) % i).toString(16).padStart(64, "0"), a = new Uint8Array(32);
|
|
1759
|
+
for (let c = 0; c < 32; c++)
|
|
1760
|
+
a[c] = parseInt(u.slice(c * 2, c * 2 + 2), 16);
|
|
1761
|
+
return new T(a);
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
class gt {
|
|
1765
|
+
key;
|
|
1766
|
+
constructor(t) {
|
|
1767
|
+
if (t.length !== 33)
|
|
1768
|
+
throw new Error("Compressed public key must be 33 bytes");
|
|
1769
|
+
this.key = t;
|
|
1770
|
+
}
|
|
1771
|
+
/**
|
|
1772
|
+
* Create PublicKey from string (e.g., "ZTR...")
|
|
1773
|
+
*/
|
|
1774
|
+
static fromString(t, n = "ZTR") {
|
|
1775
|
+
if (!t.startsWith(n))
|
|
1776
|
+
throw new Error(`Public key must start with ${n}`);
|
|
1777
|
+
const s = t.substring(n.length), r = ct.decode(s), i = r.slice(0, 33), o = r.slice(33), a = ie(i).slice(0, 4);
|
|
1778
|
+
if (!qe(o, a))
|
|
1779
|
+
throw new Error("Invalid public key checksum");
|
|
1780
|
+
return new gt(i);
|
|
1781
|
+
}
|
|
1782
|
+
/**
|
|
1783
|
+
* Convert to string format (e.g., "ZTR...")
|
|
1784
|
+
*/
|
|
1785
|
+
toString(t = "ZTR") {
|
|
1786
|
+
const n = ie(this.key).slice(0, 4), s = new Uint8Array(37);
|
|
1787
|
+
return s.set(this.key), s.set(n, 33), t + ct.encode(s);
|
|
1788
|
+
}
|
|
1789
|
+
/**
|
|
1790
|
+
* Get raw bytes
|
|
1791
|
+
*/
|
|
1792
|
+
toBytes() {
|
|
1793
|
+
return this.key;
|
|
1794
|
+
}
|
|
1795
|
+
/**
|
|
1796
|
+
* Verify a signature
|
|
1797
|
+
*/
|
|
1798
|
+
async verify(t, n) {
|
|
1799
|
+
try {
|
|
1800
|
+
return xn(n.toCompact(), t, this.key);
|
|
1801
|
+
} catch {
|
|
1802
|
+
return !1;
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
/**
|
|
1806
|
+
* Derive child key from offset (hierarchical key derivation)
|
|
1807
|
+
* Note: This is not implemented for public keys alone, derive from private key instead
|
|
1808
|
+
* @param _offset Offset string for derivation (unused)
|
|
1809
|
+
* @returns Never - throws error
|
|
1810
|
+
*/
|
|
1811
|
+
child(t) {
|
|
1812
|
+
throw new Error("PublicKey.child() requires private key derivation");
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
class Ue {
|
|
1816
|
+
sig;
|
|
1817
|
+
recovery;
|
|
1818
|
+
constructor(t) {
|
|
1819
|
+
if (t instanceof Uint8Array) {
|
|
1820
|
+
if (t.length !== 65)
|
|
1821
|
+
throw new Error("Signature must be 65 bytes");
|
|
1822
|
+
const n = t[0];
|
|
1823
|
+
if (n === void 0)
|
|
1824
|
+
throw new Error("Invalid signature: missing recovery byte");
|
|
1825
|
+
this.recovery = n - 27, this.sig = t.slice(1);
|
|
1826
|
+
} else
|
|
1827
|
+
this.sig = t.signature, this.recovery = t.recovery ?? 0;
|
|
1828
|
+
}
|
|
1829
|
+
/**
|
|
1830
|
+
* Get compact signature (65 bytes: recovery + r + s)
|
|
1831
|
+
*/
|
|
1832
|
+
toCompact() {
|
|
1833
|
+
return this.sig;
|
|
1834
|
+
}
|
|
1835
|
+
/**
|
|
1836
|
+
* Get full signature with recovery parameter (65 bytes)
|
|
1837
|
+
*/
|
|
1838
|
+
toBuffer() {
|
|
1839
|
+
const t = new Uint8Array(65);
|
|
1840
|
+
return t[0] = this.recovery + 27, t.set(this.sig, 1), t;
|
|
1841
|
+
}
|
|
1842
|
+
/**
|
|
1843
|
+
* Recover public key from signature and message hash
|
|
1844
|
+
*/
|
|
1845
|
+
async recoverPublicKey(t) {
|
|
1846
|
+
const i = Tt.fromCompact(this.sig).addRecoveryBit(this.recovery).recoverPublicKey(t).toRawBytes(!0);
|
|
1847
|
+
return new gt(i);
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
function qe(e, t) {
|
|
1851
|
+
if (e.length !== t.length) return !1;
|
|
1852
|
+
for (let n = 0; n < e.length; n++)
|
|
1853
|
+
if (e[n] !== t[n]) return !1;
|
|
1854
|
+
return !0;
|
|
1855
|
+
}
|
|
1856
|
+
function oe(e, t, n = ["owner", "active", "posting", "memo"]) {
|
|
1857
|
+
const s = {};
|
|
1858
|
+
for (const r of n) {
|
|
1859
|
+
const i = T.fromLogin(e, t, r), o = i.toPublic();
|
|
1860
|
+
s[r] = {
|
|
1861
|
+
private: i.toWif(),
|
|
1862
|
+
public: o.toString()
|
|
1863
|
+
};
|
|
1864
|
+
}
|
|
1865
|
+
return s;
|
|
1866
|
+
}
|
|
1867
|
+
function as(e) {
|
|
1868
|
+
try {
|
|
1869
|
+
return T.fromWif(e), !0;
|
|
1870
|
+
} catch {
|
|
1871
|
+
return !1;
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
function us(e, t = "ZTR") {
|
|
1875
|
+
try {
|
|
1876
|
+
return gt.fromString(e, t), !0;
|
|
1877
|
+
} catch {
|
|
1878
|
+
return !1;
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
class Ie {
|
|
1882
|
+
buffer = [];
|
|
1883
|
+
/**
|
|
1884
|
+
* Write a uint8 (1 byte)
|
|
1885
|
+
*/
|
|
1886
|
+
writeUInt8(t) {
|
|
1887
|
+
this.buffer.push(t & 255);
|
|
1888
|
+
}
|
|
1889
|
+
/**
|
|
1890
|
+
* Write a uint16 (2 bytes, little-endian)
|
|
1891
|
+
*/
|
|
1892
|
+
writeUInt16(t) {
|
|
1893
|
+
this.buffer.push(t & 255), this.buffer.push(t >> 8 & 255);
|
|
1894
|
+
}
|
|
1895
|
+
/**
|
|
1896
|
+
* Write a uint32 (4 bytes, little-endian)
|
|
1897
|
+
*/
|
|
1898
|
+
writeUInt32(t) {
|
|
1899
|
+
this.buffer.push(t & 255), this.buffer.push(t >> 8 & 255), this.buffer.push(t >> 16 & 255), this.buffer.push(t >> 24 & 255);
|
|
1900
|
+
}
|
|
1901
|
+
/**
|
|
1902
|
+
* Write a uint64 (8 bytes, little-endian)
|
|
1903
|
+
*/
|
|
1904
|
+
writeUInt64(t) {
|
|
1905
|
+
const n = typeof t == "number" ? BigInt(t) : t;
|
|
1906
|
+
for (let s = 0; s < 8; s++)
|
|
1907
|
+
this.buffer.push(Number(n >> BigInt(s * 8) & BigInt(255)));
|
|
1908
|
+
}
|
|
1909
|
+
/**
|
|
1910
|
+
* Write variable-length integer
|
|
1911
|
+
*/
|
|
1912
|
+
writeVarint32(t) {
|
|
1913
|
+
for (; t >= 128; )
|
|
1914
|
+
this.buffer.push(t & 127 | 128), t >>= 7;
|
|
1915
|
+
this.buffer.push(t & 127);
|
|
1916
|
+
}
|
|
1917
|
+
/**
|
|
1918
|
+
* Write a string
|
|
1919
|
+
*/
|
|
1920
|
+
writeString(t) {
|
|
1921
|
+
const n = new TextEncoder().encode(t);
|
|
1922
|
+
this.writeVarint32(n.length);
|
|
1923
|
+
for (const s of n)
|
|
1924
|
+
this.buffer.push(s);
|
|
1925
|
+
}
|
|
1926
|
+
/**
|
|
1927
|
+
* Write bytes
|
|
1928
|
+
*/
|
|
1929
|
+
writeBytes(t) {
|
|
1930
|
+
for (const n of t)
|
|
1931
|
+
this.buffer.push(n);
|
|
1932
|
+
}
|
|
1933
|
+
/**
|
|
1934
|
+
* Write array with length prefix
|
|
1935
|
+
*/
|
|
1936
|
+
writeArray(t, n) {
|
|
1937
|
+
this.writeVarint32(t.length);
|
|
1938
|
+
for (const s of t)
|
|
1939
|
+
n(s);
|
|
1940
|
+
}
|
|
1941
|
+
/**
|
|
1942
|
+
* Get the serialized buffer
|
|
1943
|
+
*/
|
|
1944
|
+
toBuffer() {
|
|
1945
|
+
return new Uint8Array(this.buffer);
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
function Yt(e) {
|
|
1949
|
+
const t = new Ie();
|
|
1950
|
+
t.writeUInt16(e.ref_block_num), t.writeUInt32(e.ref_block_prefix);
|
|
1951
|
+
const n = new Date(e.expiration), s = Math.floor(n.getTime() / 1e3);
|
|
1952
|
+
return t.writeUInt32(s), t.writeArray(e.operations, (r) => {
|
|
1953
|
+
On(t, r);
|
|
1954
|
+
}), t.writeArray(e.extensions, (r) => {
|
|
1955
|
+
typeof r == "object" && r !== null && t.writeString(JSON.stringify(r));
|
|
1956
|
+
}), t.toBuffer();
|
|
1957
|
+
}
|
|
1958
|
+
function On(e, t) {
|
|
1959
|
+
if (!Array.isArray(t) || t.length !== 2)
|
|
1960
|
+
throw new Error("Invalid operation format");
|
|
1961
|
+
const [n, s] = t;
|
|
1962
|
+
if (typeof n == "number")
|
|
1963
|
+
e.writeVarint32(n);
|
|
1964
|
+
else if (typeof n == "string") {
|
|
1965
|
+
const r = Pn(n);
|
|
1966
|
+
e.writeVarint32(r);
|
|
1967
|
+
}
|
|
1968
|
+
Re(e, s);
|
|
1969
|
+
}
|
|
1970
|
+
function Pn(e) {
|
|
1971
|
+
return {
|
|
1972
|
+
vote: 0,
|
|
1973
|
+
comment: 1,
|
|
1974
|
+
transfer: 2,
|
|
1975
|
+
transfer_to_vesting: 3,
|
|
1976
|
+
withdraw_vesting: 4,
|
|
1977
|
+
limit_order_create: 5,
|
|
1978
|
+
limit_order_cancel: 6,
|
|
1979
|
+
feed_publish: 7,
|
|
1980
|
+
convert: 8,
|
|
1981
|
+
account_create: 9,
|
|
1982
|
+
account_update: 10,
|
|
1983
|
+
witness_update: 11,
|
|
1984
|
+
account_witness_vote: 12,
|
|
1985
|
+
account_witness_proxy: 13
|
|
1986
|
+
// ... more operations
|
|
1987
|
+
}[e] ?? -1;
|
|
1988
|
+
}
|
|
1989
|
+
function Re(e, t) {
|
|
1990
|
+
if (t != null) {
|
|
1991
|
+
if (typeof t == "string")
|
|
1992
|
+
e.writeString(t);
|
|
1993
|
+
else if (typeof t == "number")
|
|
1994
|
+
e.writeUInt32(t);
|
|
1995
|
+
else if (typeof t == "boolean")
|
|
1996
|
+
e.writeUInt8(t ? 1 : 0);
|
|
1997
|
+
else if (typeof t == "object")
|
|
1998
|
+
for (const n of Object.values(t))
|
|
1999
|
+
Re(e, n);
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
function fs(e) {
|
|
2003
|
+
const t = new Ie(), n = Yt(e);
|
|
2004
|
+
return t.writeBytes(n), e.signatures ? t.writeArray(e.signatures, (s) => {
|
|
2005
|
+
t.writeBytes(s);
|
|
2006
|
+
}) : t.writeVarint32(0), t.toBuffer();
|
|
2007
|
+
}
|
|
2008
|
+
/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */
|
|
2009
|
+
function Kn(e) {
|
|
2010
|
+
return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
|
|
2011
|
+
}
|
|
2012
|
+
function P(e, t, n = "") {
|
|
2013
|
+
const s = Kn(e), r = e?.length, i = t !== void 0;
|
|
2014
|
+
if (!s || i && r !== t) {
|
|
2015
|
+
const o = n && `"${n}" `, u = i ? ` of length ${t}` : "", a = s ? `length=${r}` : `type=${typeof e}`;
|
|
2016
|
+
throw new Error(o + "expected Uint8Array" + u + ", got " + a);
|
|
2017
|
+
}
|
|
2018
|
+
return e;
|
|
2019
|
+
}
|
|
2020
|
+
function Y(e) {
|
|
2021
|
+
return new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4));
|
|
2022
|
+
}
|
|
2023
|
+
function lt(...e) {
|
|
2024
|
+
for (let t = 0; t < e.length; t++)
|
|
2025
|
+
e[t].fill(0);
|
|
2026
|
+
}
|
|
2027
|
+
const Mn = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
2028
|
+
function Vn(e, t) {
|
|
2029
|
+
return e.buffer === t.buffer && // best we can do, may fail with an obscure Proxy
|
|
2030
|
+
e.byteOffset < t.byteOffset + t.byteLength && // a starts before b end
|
|
2031
|
+
t.byteOffset < e.byteOffset + e.byteLength;
|
|
2032
|
+
}
|
|
2033
|
+
function ke(e, t) {
|
|
2034
|
+
if (Vn(e, t) && e.byteOffset < t.byteOffset)
|
|
2035
|
+
throw new Error("complex overlap of input and output is not supported");
|
|
2036
|
+
}
|
|
2037
|
+
const Wn = /* @__NO_SIDE_EFFECTS__ */ (e, t) => {
|
|
2038
|
+
function n(s, ...r) {
|
|
2039
|
+
if (P(s, void 0, "key"), !Mn)
|
|
2040
|
+
throw new Error("Non little-endian hardware is not yet supported");
|
|
2041
|
+
if (e.nonceLength !== void 0) {
|
|
2042
|
+
const h = r[0];
|
|
2043
|
+
P(h, e.varSizeNonce ? void 0 : e.nonceLength, "nonce");
|
|
2044
|
+
}
|
|
2045
|
+
const i = e.tagLength;
|
|
2046
|
+
i && r[1] !== void 0 && P(r[1], void 0, "AAD");
|
|
2047
|
+
const o = t(s, ...r), u = (h, f) => {
|
|
2048
|
+
if (f !== void 0) {
|
|
2049
|
+
if (h !== 2)
|
|
2050
|
+
throw new Error("cipher output not supported");
|
|
2051
|
+
P(f, void 0, "output");
|
|
2052
|
+
}
|
|
2053
|
+
};
|
|
2054
|
+
let a = !1;
|
|
2055
|
+
return {
|
|
2056
|
+
encrypt(h, f) {
|
|
2057
|
+
if (a)
|
|
2058
|
+
throw new Error("cannot encrypt() twice with same key + nonce");
|
|
2059
|
+
return a = !0, P(h), u(o.encrypt.length, f), o.encrypt(h, f);
|
|
2060
|
+
},
|
|
2061
|
+
decrypt(h, f) {
|
|
2062
|
+
if (P(h), i && h.length < i)
|
|
2063
|
+
throw new Error('"ciphertext" expected length bigger than tagLength=' + i);
|
|
2064
|
+
return u(o.decrypt.length, f), o.decrypt(h, f);
|
|
2065
|
+
}
|
|
2066
|
+
};
|
|
2067
|
+
}
|
|
2068
|
+
return Object.assign(n, e), n;
|
|
2069
|
+
};
|
|
2070
|
+
function Ce(e, t, n = !0) {
|
|
2071
|
+
if (t === void 0)
|
|
2072
|
+
return new Uint8Array(e);
|
|
2073
|
+
if (t.length !== e)
|
|
2074
|
+
throw new Error('"output" expected Uint8Array of length ' + e + ", got: " + t.length);
|
|
2075
|
+
if (n && !it(t))
|
|
2076
|
+
throw new Error("invalid output, must be aligned");
|
|
2077
|
+
return t;
|
|
2078
|
+
}
|
|
2079
|
+
function it(e) {
|
|
2080
|
+
return e.byteOffset % 4 === 0;
|
|
2081
|
+
}
|
|
2082
|
+
function ht(e) {
|
|
2083
|
+
return Uint8Array.from(e);
|
|
2084
|
+
}
|
|
2085
|
+
function Ln(e = 32) {
|
|
2086
|
+
const t = typeof globalThis == "object" ? globalThis.crypto : null;
|
|
2087
|
+
if (typeof t?.getRandomValues != "function")
|
|
2088
|
+
throw new Error("crypto.getRandomValues must be defined");
|
|
2089
|
+
return t.getRandomValues(new Uint8Array(e));
|
|
2090
|
+
}
|
|
2091
|
+
const G = 16, Yn = 283;
|
|
2092
|
+
function jn(e) {
|
|
2093
|
+
if (![16, 24, 32].includes(e.length))
|
|
2094
|
+
throw new Error('"aes key" expected Uint8Array of length 16/24/32, got length=' + e.length);
|
|
2095
|
+
}
|
|
2096
|
+
function jt(e) {
|
|
2097
|
+
return e << 1 ^ Yn & -(e >> 7);
|
|
2098
|
+
}
|
|
2099
|
+
function rt(e, t) {
|
|
2100
|
+
let n = 0;
|
|
2101
|
+
for (; t > 0; t >>= 1)
|
|
2102
|
+
n ^= e & -(t & 1), e = jt(e);
|
|
2103
|
+
return n;
|
|
2104
|
+
}
|
|
2105
|
+
const Ot = /* @__PURE__ */ (() => {
|
|
2106
|
+
const e = new Uint8Array(256);
|
|
2107
|
+
for (let n = 0, s = 1; n < 256; n++, s ^= jt(s))
|
|
2108
|
+
e[n] = s;
|
|
2109
|
+
const t = new Uint8Array(256);
|
|
2110
|
+
t[0] = 99;
|
|
2111
|
+
for (let n = 0; n < 255; n++) {
|
|
2112
|
+
let s = e[255 - n];
|
|
2113
|
+
s |= s << 8, t[e[n]] = (s ^ s >> 4 ^ s >> 5 ^ s >> 6 ^ s >> 7 ^ 99) & 255;
|
|
2114
|
+
}
|
|
2115
|
+
return lt(e), t;
|
|
2116
|
+
})(), Gn = /* @__PURE__ */ Ot.map((e, t) => Ot.indexOf(t)), zn = (e) => e << 24 | e >>> 8, Nt = (e) => e << 8 | e >>> 24;
|
|
2117
|
+
function Ne(e, t) {
|
|
2118
|
+
if (e.length !== 256)
|
|
2119
|
+
throw new Error("Wrong sbox length");
|
|
2120
|
+
const n = new Uint32Array(256).map((c, h) => t(e[h])), s = n.map(Nt), r = s.map(Nt), i = r.map(Nt), o = new Uint32Array(256 * 256), u = new Uint32Array(256 * 256), a = new Uint16Array(256 * 256);
|
|
2121
|
+
for (let c = 0; c < 256; c++)
|
|
2122
|
+
for (let h = 0; h < 256; h++) {
|
|
2123
|
+
const f = c * 256 + h;
|
|
2124
|
+
o[f] = n[c] ^ s[h], u[f] = r[c] ^ i[h], a[f] = e[c] << 8 | e[h];
|
|
2125
|
+
}
|
|
2126
|
+
return { sbox: e, sbox2: a, T0: n, T1: s, T2: r, T3: i, T01: o, T23: u };
|
|
2127
|
+
}
|
|
2128
|
+
const Gt = /* @__PURE__ */ Ne(Ot, (e) => rt(e, 3) << 24 | e << 16 | e << 8 | rt(e, 2)), He = /* @__PURE__ */ Ne(Gn, (e) => rt(e, 11) << 24 | rt(e, 13) << 16 | rt(e, 9) << 8 | rt(e, 14)), $n = /* @__PURE__ */ (() => {
|
|
2129
|
+
const e = new Uint8Array(16);
|
|
2130
|
+
for (let t = 0, n = 1; t < 16; t++, n = jt(n))
|
|
2131
|
+
e[t] = n;
|
|
2132
|
+
return e;
|
|
2133
|
+
})();
|
|
2134
|
+
function Fe(e) {
|
|
2135
|
+
P(e);
|
|
2136
|
+
const t = e.length;
|
|
2137
|
+
jn(e);
|
|
2138
|
+
const { sbox2: n } = Gt, s = [];
|
|
2139
|
+
it(e) || s.push(e = ht(e));
|
|
2140
|
+
const r = Y(e), i = r.length, o = (a) => N(n, a, a, a, a), u = new Uint32Array(t + 28);
|
|
2141
|
+
u.set(r);
|
|
2142
|
+
for (let a = i; a < u.length; a++) {
|
|
2143
|
+
let c = u[a - 1];
|
|
2144
|
+
a % i === 0 ? c = o(zn(c)) ^ $n[a / i - 1] : i > 6 && a % i === 4 && (c = o(c)), u[a] = u[a - i] ^ c;
|
|
2145
|
+
}
|
|
2146
|
+
return lt(...s), u;
|
|
2147
|
+
}
|
|
2148
|
+
function Zn(e) {
|
|
2149
|
+
const t = Fe(e), n = t.slice(), s = t.length, { sbox2: r } = Gt, { T0: i, T1: o, T2: u, T3: a } = He;
|
|
2150
|
+
for (let c = 0; c < s; c += 4)
|
|
2151
|
+
for (let h = 0; h < 4; h++)
|
|
2152
|
+
n[c + h] = t[s - c - 4 + h];
|
|
2153
|
+
lt(t);
|
|
2154
|
+
for (let c = 4; c < s - 4; c++) {
|
|
2155
|
+
const h = n[c], f = N(r, h, h, h, h);
|
|
2156
|
+
n[c] = i[f & 255] ^ o[f >>> 8 & 255] ^ u[f >>> 16 & 255] ^ a[f >>> 24];
|
|
2157
|
+
}
|
|
2158
|
+
return n;
|
|
2159
|
+
}
|
|
2160
|
+
function j(e, t, n, s, r, i) {
|
|
2161
|
+
return e[n << 8 & 65280 | s >>> 8 & 255] ^ t[r >>> 8 & 65280 | i >>> 24 & 255];
|
|
2162
|
+
}
|
|
2163
|
+
function N(e, t, n, s, r) {
|
|
2164
|
+
return e[t & 255 | n & 65280] | e[s >>> 16 & 255 | r >>> 16 & 65280] << 16;
|
|
2165
|
+
}
|
|
2166
|
+
function ce(e, t, n, s, r) {
|
|
2167
|
+
const { sbox2: i, T01: o, T23: u } = Gt;
|
|
2168
|
+
let a = 0;
|
|
2169
|
+
t ^= e[a++], n ^= e[a++], s ^= e[a++], r ^= e[a++];
|
|
2170
|
+
const c = e.length / 4 - 2;
|
|
2171
|
+
for (let y = 0; y < c; y++) {
|
|
2172
|
+
const b = e[a++] ^ j(o, u, t, n, s, r), _ = e[a++] ^ j(o, u, n, s, r, t), x = e[a++] ^ j(o, u, s, r, t, n), g = e[a++] ^ j(o, u, r, t, n, s);
|
|
2173
|
+
t = b, n = _, s = x, r = g;
|
|
2174
|
+
}
|
|
2175
|
+
const h = e[a++] ^ N(i, t, n, s, r), f = e[a++] ^ N(i, n, s, r, t), l = e[a++] ^ N(i, s, r, t, n), d = e[a++] ^ N(i, r, t, n, s);
|
|
2176
|
+
return { s0: h, s1: f, s2: l, s3: d };
|
|
2177
|
+
}
|
|
2178
|
+
function Xn(e, t, n, s, r) {
|
|
2179
|
+
const { sbox2: i, T01: o, T23: u } = He;
|
|
2180
|
+
let a = 0;
|
|
2181
|
+
t ^= e[a++], n ^= e[a++], s ^= e[a++], r ^= e[a++];
|
|
2182
|
+
const c = e.length / 4 - 2;
|
|
2183
|
+
for (let y = 0; y < c; y++) {
|
|
2184
|
+
const b = e[a++] ^ j(o, u, t, r, s, n), _ = e[a++] ^ j(o, u, n, t, r, s), x = e[a++] ^ j(o, u, s, n, t, r), g = e[a++] ^ j(o, u, r, s, n, t);
|
|
2185
|
+
t = b, n = _, s = x, r = g;
|
|
2186
|
+
}
|
|
2187
|
+
const h = e[a++] ^ N(i, t, r, s, n), f = e[a++] ^ N(i, n, t, r, s), l = e[a++] ^ N(i, s, n, t, r), d = e[a++] ^ N(i, r, s, n, t);
|
|
2188
|
+
return { s0: h, s1: f, s2: l, s3: d };
|
|
2189
|
+
}
|
|
2190
|
+
function Qn(e) {
|
|
2191
|
+
if (P(e), e.length % G !== 0)
|
|
2192
|
+
throw new Error("aes-(cbc/ecb).decrypt ciphertext should consist of blocks with size " + G);
|
|
2193
|
+
}
|
|
2194
|
+
function Jn(e, t, n) {
|
|
2195
|
+
P(e);
|
|
2196
|
+
let s = e.length;
|
|
2197
|
+
const r = s % G;
|
|
2198
|
+
if (!t && r !== 0)
|
|
2199
|
+
throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");
|
|
2200
|
+
it(e) || (e = ht(e));
|
|
2201
|
+
const i = Y(e);
|
|
2202
|
+
if (t) {
|
|
2203
|
+
let u = G - r;
|
|
2204
|
+
u || (u = G), s = s + u;
|
|
2205
|
+
}
|
|
2206
|
+
n = Ce(s, n), ke(e, n);
|
|
2207
|
+
const o = Y(n);
|
|
2208
|
+
return { b: i, o, out: n };
|
|
2209
|
+
}
|
|
2210
|
+
function ts(e, t) {
|
|
2211
|
+
if (!t)
|
|
2212
|
+
return e;
|
|
2213
|
+
const n = e.length;
|
|
2214
|
+
if (!n)
|
|
2215
|
+
throw new Error("aes/pcks5: empty ciphertext not allowed");
|
|
2216
|
+
const s = e[n - 1];
|
|
2217
|
+
if (s <= 0 || s > 16)
|
|
2218
|
+
throw new Error("aes/pcks5: wrong padding");
|
|
2219
|
+
const r = e.subarray(0, -s);
|
|
2220
|
+
for (let i = 0; i < s; i++)
|
|
2221
|
+
if (e[n - i - 1] !== s)
|
|
2222
|
+
throw new Error("aes/pcks5: wrong padding");
|
|
2223
|
+
return r;
|
|
2224
|
+
}
|
|
2225
|
+
function es(e) {
|
|
2226
|
+
const t = new Uint8Array(16), n = Y(t);
|
|
2227
|
+
t.set(e);
|
|
2228
|
+
const s = G - e.length;
|
|
2229
|
+
for (let r = G - s; r < G; r++)
|
|
2230
|
+
t[r] = s;
|
|
2231
|
+
return n;
|
|
2232
|
+
}
|
|
2233
|
+
const De = /* @__PURE__ */ Wn({ blockSize: 16, nonceLength: 16 }, function(t, n, s = {}) {
|
|
2234
|
+
const r = !s.disablePadding;
|
|
2235
|
+
return {
|
|
2236
|
+
encrypt(i, o) {
|
|
2237
|
+
const u = Fe(t), { b: a, o: c, out: h } = Jn(i, r, o);
|
|
2238
|
+
let f = n;
|
|
2239
|
+
const l = [u];
|
|
2240
|
+
it(f) || l.push(f = ht(f));
|
|
2241
|
+
const d = Y(f);
|
|
2242
|
+
let y = d[0], b = d[1], _ = d[2], x = d[3], g = 0;
|
|
2243
|
+
for (; g + 4 <= a.length; )
|
|
2244
|
+
y ^= a[g + 0], b ^= a[g + 1], _ ^= a[g + 2], x ^= a[g + 3], { s0: y, s1: b, s2: _, s3: x } = ce(u, y, b, _, x), c[g++] = y, c[g++] = b, c[g++] = _, c[g++] = x;
|
|
2245
|
+
if (r) {
|
|
2246
|
+
const p = es(i.subarray(g * 4));
|
|
2247
|
+
y ^= p[0], b ^= p[1], _ ^= p[2], x ^= p[3], { s0: y, s1: b, s2: _, s3: x } = ce(u, y, b, _, x), c[g++] = y, c[g++] = b, c[g++] = _, c[g++] = x;
|
|
2248
|
+
}
|
|
2249
|
+
return lt(...l), h;
|
|
2250
|
+
},
|
|
2251
|
+
decrypt(i, o) {
|
|
2252
|
+
Qn(i);
|
|
2253
|
+
const u = Zn(t);
|
|
2254
|
+
let a = n;
|
|
2255
|
+
const c = [u];
|
|
2256
|
+
it(a) || c.push(a = ht(a));
|
|
2257
|
+
const h = Y(a);
|
|
2258
|
+
o = Ce(i.length, o), it(i) || c.push(i = ht(i)), ke(i, o);
|
|
2259
|
+
const f = Y(i), l = Y(o);
|
|
2260
|
+
let d = h[0], y = h[1], b = h[2], _ = h[3];
|
|
2261
|
+
for (let x = 0; x + 4 <= f.length; ) {
|
|
2262
|
+
const g = d, p = y, A = b, m = _;
|
|
2263
|
+
d = f[x + 0], y = f[x + 1], b = f[x + 2], _ = f[x + 3];
|
|
2264
|
+
const { s0: F, s1: at, s2: q, s3: I } = Xn(u, d, y, b, _);
|
|
2265
|
+
l[x++] = F ^ g, l[x++] = at ^ p, l[x++] = q ^ A, l[x++] = I ^ m;
|
|
2266
|
+
}
|
|
2267
|
+
return lt(...c), ts(o, r);
|
|
2268
|
+
}
|
|
2269
|
+
};
|
|
2270
|
+
});
|
|
2271
|
+
function ns(e = 8) {
|
|
2272
|
+
return Ln(e);
|
|
2273
|
+
}
|
|
2274
|
+
function hs(e, t, n, s) {
|
|
2275
|
+
n.startsWith("#") || (n = "#" + n);
|
|
2276
|
+
const r = n.slice(1), i = new TextEncoder().encode(r), o = s ?? ns(8), u = e.getSharedSecret(t), a = new Uint8Array(o.length + u.length);
|
|
2277
|
+
a.set(o), a.set(u, o.length);
|
|
2278
|
+
const c = fe(a), h = c.slice(0, 16), f = c.slice(16, 48), d = De(f, h).encrypt(i), b = R(f).slice(0, 4), _ = new Uint8Array(o.length + b.length + d.length);
|
|
2279
|
+
return _.set(o, 0), _.set(b, o.length), _.set(d, o.length + b.length), "#" + ct.encode(_);
|
|
2280
|
+
}
|
|
2281
|
+
function ls(e, t) {
|
|
2282
|
+
if (!t.startsWith("#"))
|
|
2283
|
+
return t;
|
|
2284
|
+
throw new Error("decodeMemo requires sender public key - use decodeMemoWithKey instead");
|
|
2285
|
+
}
|
|
2286
|
+
function ds(e, t, n) {
|
|
2287
|
+
if (!n.startsWith("#"))
|
|
2288
|
+
return n;
|
|
2289
|
+
try {
|
|
2290
|
+
const s = ct.decode(n.slice(1)), r = s.slice(0, 8), i = s.slice(8, 12), o = s.slice(12), u = e.getSharedSecret(t), a = new Uint8Array(r.length + u.length);
|
|
2291
|
+
a.set(r), a.set(u, r.length);
|
|
2292
|
+
const c = fe(a), h = c.slice(0, 16), f = c.slice(16, 48), d = R(f).slice(0, 4);
|
|
2293
|
+
let y = !0;
|
|
2294
|
+
for (let g = 0; g < 4; g++)
|
|
2295
|
+
if (i[g] !== d[g]) {
|
|
2296
|
+
y = !1;
|
|
2297
|
+
break;
|
|
2298
|
+
}
|
|
2299
|
+
if (!y)
|
|
2300
|
+
throw new Error("Invalid memo checksum");
|
|
2301
|
+
const _ = De(f, h).decrypt(o);
|
|
2302
|
+
return "#" + new TextDecoder().decode(_);
|
|
2303
|
+
} catch (s) {
|
|
2304
|
+
throw new Error(`Failed to decode memo: ${s instanceof Error ? s.message : String(s)}`);
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
async function ss(e, t, n) {
|
|
2308
|
+
const s = Yt(e), r = Pt(n), i = new Uint8Array(r.length + s.length);
|
|
2309
|
+
i.set(r), i.set(s, r.length);
|
|
2310
|
+
const o = R(i), u = [];
|
|
2311
|
+
for (const a of t) {
|
|
2312
|
+
const h = await (typeof a == "string" ? T.fromWif(a) : a).sign(o);
|
|
2313
|
+
u.push(rs(h.toBuffer()));
|
|
2314
|
+
}
|
|
2315
|
+
return {
|
|
2316
|
+
...e,
|
|
2317
|
+
signatures: u
|
|
2318
|
+
};
|
|
2319
|
+
}
|
|
2320
|
+
async function ys(e, t) {
|
|
2321
|
+
const { signatures: n, ...s } = e, r = Yt(s), i = Pt(t), o = new Uint8Array(i.length + r.length);
|
|
2322
|
+
o.set(i), o.set(r, i.length);
|
|
2323
|
+
const u = R(o), a = [];
|
|
2324
|
+
for (const c of n) {
|
|
2325
|
+
const h = Pt(c), l = await new Ue(h).recoverPublicKey(u);
|
|
2326
|
+
a.push(l);
|
|
2327
|
+
}
|
|
2328
|
+
return a;
|
|
2329
|
+
}
|
|
2330
|
+
function bs(e, t, n, s) {
|
|
2331
|
+
const r = typeof n == "string" ? n : n.toISOString().split(".")[0] ?? "";
|
|
2332
|
+
return {
|
|
2333
|
+
ref_block_num: e & 65535,
|
|
2334
|
+
// Ensure it's within uint16 range
|
|
2335
|
+
ref_block_prefix: t >>> 0,
|
|
2336
|
+
// Ensure it's uint32
|
|
2337
|
+
expiration: r,
|
|
2338
|
+
operations: s,
|
|
2339
|
+
extensions: []
|
|
2340
|
+
};
|
|
2341
|
+
}
|
|
2342
|
+
function Pt(e) {
|
|
2343
|
+
const t = e.startsWith("0x") ? e.slice(2) : e, n = new Uint8Array(t.length / 2);
|
|
2344
|
+
for (let s = 0; s < t.length; s += 2)
|
|
2345
|
+
n[s / 2] = parseInt(t.slice(s, s + 2), 16);
|
|
2346
|
+
return n;
|
|
2347
|
+
}
|
|
2348
|
+
function rs(e) {
|
|
2349
|
+
return Array.from(e).map((t) => t.toString(16).padStart(2, "0")).join("");
|
|
2350
|
+
}
|
|
2351
|
+
const gs = {
|
|
2352
|
+
/**
|
|
2353
|
+
* Generate all role keys from account name and password
|
|
2354
|
+
* @param name Account name
|
|
2355
|
+
* @param password Password
|
|
2356
|
+
* @param roles Array of role names (default: ['owner', 'active', 'posting', 'memo'])
|
|
2357
|
+
* @returns Object mapping roles to private WIF keys and public keys
|
|
2358
|
+
*
|
|
2359
|
+
* @example
|
|
2360
|
+
* ```typescript
|
|
2361
|
+
* const keys = Auth.getPrivateKeys('alice', 'password123');
|
|
2362
|
+
* console.log(keys.active); // WIF private key
|
|
2363
|
+
* console.log(keys.activePubkey); // ZTR... public key
|
|
2364
|
+
* ```
|
|
2365
|
+
*/
|
|
2366
|
+
getPrivateKeys(e, t, n = ["owner", "active", "posting", "memo"]) {
|
|
2367
|
+
const s = {}, r = oe(e, t, n);
|
|
2368
|
+
for (const i of n) {
|
|
2369
|
+
const o = r[i];
|
|
2370
|
+
o && (s[i] = o.private, s[`${i}Pubkey`] = o.public);
|
|
2371
|
+
}
|
|
2372
|
+
return s;
|
|
2373
|
+
},
|
|
2374
|
+
/**
|
|
2375
|
+
* Generate public keys only from account name and password
|
|
2376
|
+
* @param name Account name
|
|
2377
|
+
* @param password Password
|
|
2378
|
+
* @param roles Array of role names
|
|
2379
|
+
* @returns Object mapping roles to public keys
|
|
2380
|
+
*/
|
|
2381
|
+
generateKeys(e, t, n = ["owner", "active", "posting", "memo"]) {
|
|
2382
|
+
const s = oe(e, t, n), r = {};
|
|
2383
|
+
for (const i of n) {
|
|
2384
|
+
const o = s[i];
|
|
2385
|
+
o && (r[i] = o.public);
|
|
2386
|
+
}
|
|
2387
|
+
return r;
|
|
2388
|
+
},
|
|
2389
|
+
/**
|
|
2390
|
+
* Convert account credentials to WIF format for a specific role
|
|
2391
|
+
* @param name Account name
|
|
2392
|
+
* @param password Password
|
|
2393
|
+
* @param role Role name (e.g., 'active', 'posting')
|
|
2394
|
+
* @returns WIF private key
|
|
2395
|
+
*/
|
|
2396
|
+
toWif(e, t, n = "active") {
|
|
2397
|
+
return T.fromLogin(e, t, n).toWif();
|
|
2398
|
+
},
|
|
2399
|
+
/**
|
|
2400
|
+
* Convert WIF private key to public key
|
|
2401
|
+
* @param privateWif WIF format private key
|
|
2402
|
+
* @param addressPrefix Address prefix (default: 'ZTR')
|
|
2403
|
+
* @returns Public key string
|
|
2404
|
+
*/
|
|
2405
|
+
wifToPublic(e, t = "ZTR") {
|
|
2406
|
+
return T.fromWif(e).toPublic().toString(t);
|
|
2407
|
+
},
|
|
2408
|
+
/**
|
|
2409
|
+
* Check if a WIF key is valid
|
|
2410
|
+
* @param privateWif WIF format private key
|
|
2411
|
+
* @returns true if valid, false otherwise
|
|
2412
|
+
*/
|
|
2413
|
+
isWif(e) {
|
|
2414
|
+
try {
|
|
2415
|
+
return T.fromWif(e), !0;
|
|
2416
|
+
} catch {
|
|
2417
|
+
return !1;
|
|
2418
|
+
}
|
|
2419
|
+
},
|
|
2420
|
+
/**
|
|
2421
|
+
* Sign a transaction with private keys
|
|
2422
|
+
* @param tx Transaction to sign
|
|
2423
|
+
* @param keys Array of WIF private keys
|
|
2424
|
+
* @param chainId Chain ID
|
|
2425
|
+
* @returns Signed transaction
|
|
2426
|
+
*/
|
|
2427
|
+
signTransaction(e, t, n) {
|
|
2428
|
+
return ss(e, t, n);
|
|
2429
|
+
},
|
|
2430
|
+
/**
|
|
2431
|
+
* Verify account credentials against authorities
|
|
2432
|
+
* @param name Account name
|
|
2433
|
+
* @param password Password
|
|
2434
|
+
* @param auths Authority public keys to verify against
|
|
2435
|
+
* @param role Role to check (default: 'active')
|
|
2436
|
+
* @returns true if credentials match, false otherwise
|
|
2437
|
+
*/
|
|
2438
|
+
verify(e, t, n, s = "active") {
|
|
2439
|
+
const i = T.fromLogin(e, t, s).toPublic().toString("ZTR"), o = n[s];
|
|
2440
|
+
return o ? o.includes(i) : !1;
|
|
2441
|
+
}
|
|
2442
|
+
};
|
|
2443
|
+
var is = /* @__PURE__ */ ((e) => (e[e.PARSE_ERROR = -32700] = "PARSE_ERROR", e[e.INVALID_REQUEST = -32600] = "INVALID_REQUEST", e[e.METHOD_NOT_FOUND = -32601] = "METHOD_NOT_FOUND", e[e.INVALID_PARAMS = -32602] = "INVALID_PARAMS", e[e.INTERNAL_ERROR = -32603] = "INTERNAL_ERROR", e[e.SERVER_ERROR = -32e3] = "SERVER_ERROR", e[e.NO_PARAMS = -32001] = "NO_PARAMS", e[e.PARSE_PARAMS_ERROR = -32002] = "PARSE_PARAMS_ERROR", e[e.ERROR_DURING_CALL = -32003] = "ERROR_DURING_CALL", e))(is || {}), os = /* @__PURE__ */ ((e) => (e.BY_NAME = "by_name", e.BY_PROXY = "by_proxy", e.BY_NEXT_VESTING_WITHDRAWAL = "by_next_vesting_withdrawal", e.BY_ACCOUNT = "by_account", e.BY_EXPIRATION = "by_expiration", e.BY_EFFECTIVE_DATE = "by_effective_date", e.BY_VOTE = "by_vote", e.BY_ACCOUNT_WITNESS = "by_account_witness", e.BY_WITNESS_ACCOUNT = "by_witness_account", e.BY_FROM_ID = "by_from_id", e.BY_RATIFICATION_DEADLINE = "by_ratification_deadline", e.BY_WITHDRAW_ROUTE = "by_withdraw_route", e.BY_DESTINATION = "by_destination", e.BY_COMPLETE_FROM_ID = "by_complete_from_id", e.BY_TO_COMPLETE = "by_to_complete", e.BY_DELEGATION = "by_delegation", e.BY_ACCOUNT_EXPIRATION = "by_account_expiration", e.BY_CONVERSION_DATE = "by_conversion_date", e.BY_CASHOUT_TIME = "by_cashout_time", e.BY_PERMLINK = "by_permlink", e.BY_ROOT = "by_root", e.BY_PARENT = "by_parent", e.BY_LAST_UPDATE = "by_last_update", e.BY_AUTHOR_LAST_UPDATE = "by_author_last_update", e.BY_COMMENT_VOTER = "by_comment_voter", e.BY_VOTER_COMMENT = "by_voter_comment", e.BY_PRICE = "by_price", e.BY_ACCOUNT_CREATION = "by_account_creation", e))(os || {});
|
|
2444
|
+
export {
|
|
2445
|
+
gs as Auth,
|
|
2446
|
+
is as JsonRpcErrorCode,
|
|
2447
|
+
os as ListOrder,
|
|
2448
|
+
T as PrivateKey,
|
|
2449
|
+
gt as PublicKey,
|
|
2450
|
+
Ue as Signature,
|
|
2451
|
+
Ie as TransactionSerializer,
|
|
2452
|
+
cs as ZatteraClient,
|
|
2453
|
+
bs as createTransaction,
|
|
2454
|
+
ls as decodeMemo,
|
|
2455
|
+
ds as decodeMemoWithKey,
|
|
2456
|
+
hs as encodeMemo,
|
|
2457
|
+
on as generateChainId,
|
|
2458
|
+
oe as generateKeys,
|
|
2459
|
+
us as isPublicKey,
|
|
2460
|
+
as as isWif,
|
|
2461
|
+
fs as serializeSignedTransaction,
|
|
2462
|
+
Yt as serializeTransaction,
|
|
2463
|
+
ss as signTransaction,
|
|
2464
|
+
ys as verifyTransactionSignatures
|
|
2465
|
+
};
|
|
2466
|
+
//# sourceMappingURL=index.js.map
|