nostr-double-ratchet 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Invite.d.ts.map +1 -1
- package/dist/nostr-double-ratchet.es.js +697 -702
- package/dist/nostr-double-ratchet.umd.js +1 -1
- package/package.json +1 -1
- package/src/Invite.ts +5 -15
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var ee = (e, t, n) =>
|
|
4
|
-
function
|
|
1
|
+
var si = Object.defineProperty;
|
|
2
|
+
var oi = (e, t, n) => t in e ? si(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var ee = (e, t, n) => oi(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
function mn(e) {
|
|
5
5
|
if (!Number.isSafeInteger(e) || e < 0)
|
|
6
6
|
throw new Error(`Wrong positive integer: ${e}`);
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function On(e, ...t) {
|
|
9
9
|
if (!(e instanceof Uint8Array))
|
|
10
10
|
throw new Error("Expected Uint8Array");
|
|
11
11
|
if (t.length > 0 && !t.includes(e.length))
|
|
12
12
|
throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function ai(e) {
|
|
15
15
|
if (typeof e != "function" || typeof e.create != "function")
|
|
16
16
|
throw new Error("Hash should be wrapped by utils.wrapConstructor");
|
|
17
|
-
|
|
17
|
+
mn(e.outputLen), mn(e.blockLen);
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function nt(e, t = !0) {
|
|
20
20
|
if (e.destroyed)
|
|
21
21
|
throw new Error("Hash instance has been destroyed");
|
|
22
22
|
if (t && e.finished)
|
|
23
23
|
throw new Error("Hash#digest() has already been called");
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
|
|
25
|
+
function ci(e, t) {
|
|
26
|
+
On(e);
|
|
27
27
|
const n = t.outputLen;
|
|
28
28
|
if (e.length < n)
|
|
29
29
|
throw new Error(`digestInto() expects output buffer of length at least ${n}`);
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const St = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
|
|
32
32
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
33
|
-
const
|
|
34
|
-
if (!
|
|
33
|
+
const Pn = (e) => e instanceof Uint8Array, At = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), ne = (e, t) => e << 32 - t | e >>> t, li = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
34
|
+
if (!li)
|
|
35
35
|
throw new Error("Non little-endian hardware is not supported");
|
|
36
|
-
function
|
|
36
|
+
function ui(e) {
|
|
37
37
|
if (typeof e != "string")
|
|
38
38
|
throw new Error(`utf8ToBytes expected string, got ${typeof e}`);
|
|
39
39
|
return new Uint8Array(new TextEncoder().encode(e));
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
if (typeof e == "string" && (e =
|
|
41
|
+
function Zt(e) {
|
|
42
|
+
if (typeof e == "string" && (e = ui(e)), !Pn(e))
|
|
43
43
|
throw new Error(`expected Uint8Array, got ${typeof e}`);
|
|
44
44
|
return e;
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function fi(...e) {
|
|
47
47
|
const t = new Uint8Array(e.reduce((r, i) => r + i.length, 0));
|
|
48
48
|
let n = 0;
|
|
49
49
|
return e.forEach((r) => {
|
|
50
|
-
if (!
|
|
50
|
+
if (!Pn(r))
|
|
51
51
|
throw new Error("Uint8Array expected");
|
|
52
52
|
t.set(r, n), n += r.length;
|
|
53
53
|
}), t;
|
|
54
54
|
}
|
|
55
|
-
let
|
|
55
|
+
let Mn = class {
|
|
56
56
|
// Safe version that clones internal state
|
|
57
57
|
clone() {
|
|
58
58
|
return this._cloneInto();
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
|
-
function
|
|
62
|
-
const t = (r) => e().update(
|
|
61
|
+
function hi(e) {
|
|
62
|
+
const t = (r) => e().update(Zt(r)).digest(), n = e();
|
|
63
63
|
return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
if (
|
|
67
|
-
return
|
|
65
|
+
function Hn(e = 32) {
|
|
66
|
+
if (St && typeof St.getRandomValues == "function")
|
|
67
|
+
return St.getRandomValues(new Uint8Array(e));
|
|
68
68
|
throw new Error("crypto.getRandomValues must be defined");
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function di(e, t, n, r) {
|
|
71
71
|
if (typeof e.setBigUint64 == "function")
|
|
72
72
|
return e.setBigUint64(t, n, r);
|
|
73
73
|
const i = BigInt(32), s = BigInt(4294967295), o = Number(n >> i & s), a = Number(n & s), c = r ? 4 : 0, l = r ? 0 : 4;
|
|
74
74
|
e.setUint32(t + c, o, r), e.setUint32(t + l, a, r);
|
|
75
75
|
}
|
|
76
|
-
let
|
|
76
|
+
let yi = class extends Mn {
|
|
77
77
|
constructor(t, n, r, i) {
|
|
78
|
-
super(), this.blockLen = t, this.outputLen = n, this.padOffset = r, this.isLE = i, this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.buffer = new Uint8Array(t), this.view =
|
|
78
|
+
super(), this.blockLen = t, this.outputLen = n, this.padOffset = r, this.isLE = i, this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.buffer = new Uint8Array(t), this.view = At(this.buffer);
|
|
79
79
|
}
|
|
80
80
|
update(t) {
|
|
81
|
-
|
|
81
|
+
nt(this);
|
|
82
82
|
const { view: n, buffer: r, blockLen: i } = this;
|
|
83
|
-
t =
|
|
83
|
+
t = Zt(t);
|
|
84
84
|
const s = t.length;
|
|
85
85
|
for (let o = 0; o < s; ) {
|
|
86
86
|
const a = Math.min(i - this.pos, s - o);
|
|
87
87
|
if (a === i) {
|
|
88
|
-
const c =
|
|
88
|
+
const c = At(t);
|
|
89
89
|
for (; i <= s - o; o += i)
|
|
90
90
|
this.process(c, o);
|
|
91
91
|
continue;
|
|
@@ -95,14 +95,14 @@ let pi = class extends Hn {
|
|
|
95
95
|
return this.length += t.length, this.roundClean(), this;
|
|
96
96
|
}
|
|
97
97
|
digestInto(t) {
|
|
98
|
-
|
|
98
|
+
nt(this), ci(t, this), this.finished = !0;
|
|
99
99
|
const { buffer: n, view: r, blockLen: i, isLE: s } = this;
|
|
100
100
|
let { pos: o } = this;
|
|
101
101
|
n[o++] = 128, this.buffer.subarray(o).fill(0), this.padOffset > i - o && (this.process(r, 0), o = 0);
|
|
102
102
|
for (let u = o; u < i; u++)
|
|
103
103
|
n[u] = 0;
|
|
104
|
-
|
|
105
|
-
const a =
|
|
104
|
+
di(r, i - 8, BigInt(this.length * 8), s), this.process(r, 0);
|
|
105
|
+
const a = At(t), c = this.outputLen;
|
|
106
106
|
if (c % 4)
|
|
107
107
|
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
108
108
|
const l = c / 4, f = this.get();
|
|
@@ -123,7 +123,7 @@ let pi = class extends Hn {
|
|
|
123
123
|
return t.length = i, t.pos = a, t.finished = s, t.destroyed = o, i % n && t.buffer.set(r), t;
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
|
-
const
|
|
126
|
+
const pi = (e, t, n) => e & t ^ ~e & n, gi = (e, t, n) => e & t ^ e & n ^ t & n, wi = /* @__PURE__ */ new Uint32Array([
|
|
127
127
|
1116352408,
|
|
128
128
|
1899447441,
|
|
129
129
|
3049323471,
|
|
@@ -198,7 +198,7 @@ const gi = (e, t, n) => e & t ^ ~e & n, wi = (e, t, n) => e & t ^ e & n ^ t & n,
|
|
|
198
198
|
528734635,
|
|
199
199
|
1541459225
|
|
200
200
|
]), we = /* @__PURE__ */ new Uint32Array(64);
|
|
201
|
-
let
|
|
201
|
+
let bi = class extends yi {
|
|
202
202
|
constructor() {
|
|
203
203
|
super(64, 32, 8, !1), this.A = ge[0] | 0, this.B = ge[1] | 0, this.C = ge[2] | 0, this.D = ge[3] | 0, this.E = ge[4] | 0, this.F = ge[5] | 0, this.G = ge[6] | 0, this.H = ge[7] | 0;
|
|
204
204
|
}
|
|
@@ -219,7 +219,7 @@ let vi = class extends pi {
|
|
|
219
219
|
}
|
|
220
220
|
let { A: r, B: i, C: s, D: o, E: a, F: c, G: l, H: f } = this;
|
|
221
221
|
for (let u = 0; u < 64; u++) {
|
|
222
|
-
const d = ne(a, 6) ^ ne(a, 11) ^ ne(a, 25), p = f + d +
|
|
222
|
+
const d = ne(a, 6) ^ ne(a, 11) ^ ne(a, 25), p = f + d + pi(a, c, l) + wi[u] + we[u] | 0, h = (ne(r, 2) ^ ne(r, 13) ^ ne(r, 22)) + gi(r, i, s) | 0;
|
|
223
223
|
f = l, l = c, c = a, a = o + p | 0, o = s, s = i, i = r, r = p + h | 0;
|
|
224
224
|
}
|
|
225
225
|
r = r + this.A | 0, i = i + this.B | 0, s = s + this.C | 0, o = o + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, l = l + this.G | 0, f = f + this.H | 0, this.set(r, i, s, o, a, c, l, f);
|
|
@@ -231,22 +231,22 @@ let vi = class extends pi {
|
|
|
231
231
|
this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
|
|
232
232
|
}
|
|
233
233
|
};
|
|
234
|
-
const
|
|
234
|
+
const Tt = /* @__PURE__ */ hi(() => new bi());
|
|
235
235
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
236
|
-
const
|
|
236
|
+
const qn = BigInt(0), ct = BigInt(1), vi = BigInt(2), lt = (e) => e instanceof Uint8Array, mi = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
|
|
237
237
|
function qe(e) {
|
|
238
|
-
if (!
|
|
238
|
+
if (!lt(e))
|
|
239
239
|
throw new Error("Uint8Array expected");
|
|
240
240
|
let t = "";
|
|
241
241
|
for (let n = 0; n < e.length; n++)
|
|
242
|
-
t +=
|
|
242
|
+
t += mi[e[n]];
|
|
243
243
|
return t;
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function Dn(e) {
|
|
246
246
|
const t = e.toString(16);
|
|
247
247
|
return t.length & 1 ? `0${t}` : t;
|
|
248
248
|
}
|
|
249
|
-
function
|
|
249
|
+
function Ft(e) {
|
|
250
250
|
if (typeof e != "string")
|
|
251
251
|
throw new Error("hex string expected, got " + typeof e);
|
|
252
252
|
return BigInt(e === "" ? "0" : `0x${e}`);
|
|
@@ -267,21 +267,21 @@ function De(e) {
|
|
|
267
267
|
return n;
|
|
268
268
|
}
|
|
269
269
|
function G(e) {
|
|
270
|
-
return
|
|
270
|
+
return Ft(qe(e));
|
|
271
271
|
}
|
|
272
|
-
function
|
|
273
|
-
if (!
|
|
272
|
+
function Wt(e) {
|
|
273
|
+
if (!lt(e))
|
|
274
274
|
throw new Error("Uint8Array expected");
|
|
275
|
-
return
|
|
275
|
+
return Ft(qe(Uint8Array.from(e).reverse()));
|
|
276
276
|
}
|
|
277
277
|
function xe(e, t) {
|
|
278
278
|
return De(e.toString(16).padStart(t * 2, "0"));
|
|
279
279
|
}
|
|
280
|
-
function
|
|
280
|
+
function Gt(e, t) {
|
|
281
281
|
return xe(e, t).reverse();
|
|
282
282
|
}
|
|
283
|
-
function
|
|
284
|
-
return De(
|
|
283
|
+
function Ei(e) {
|
|
284
|
+
return De(Dn(e));
|
|
285
285
|
}
|
|
286
286
|
function Z(e, t, n) {
|
|
287
287
|
let r;
|
|
@@ -291,7 +291,7 @@ function Z(e, t, n) {
|
|
|
291
291
|
} catch (s) {
|
|
292
292
|
throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${s}`);
|
|
293
293
|
}
|
|
294
|
-
else if (
|
|
294
|
+
else if (lt(t))
|
|
295
295
|
r = Uint8Array.from(t);
|
|
296
296
|
else
|
|
297
297
|
throw new Error(`${e} must be hex string or Uint8Array`);
|
|
@@ -304,12 +304,12 @@ function ke(...e) {
|
|
|
304
304
|
const t = new Uint8Array(e.reduce((r, i) => r + i.length, 0));
|
|
305
305
|
let n = 0;
|
|
306
306
|
return e.forEach((r) => {
|
|
307
|
-
if (!
|
|
307
|
+
if (!lt(r))
|
|
308
308
|
throw new Error("Uint8Array expected");
|
|
309
309
|
t.set(r, n), n += r.length;
|
|
310
310
|
}), t;
|
|
311
311
|
}
|
|
312
|
-
function
|
|
312
|
+
function xi(e, t) {
|
|
313
313
|
if (e.length !== t.length)
|
|
314
314
|
return !1;
|
|
315
315
|
for (let n = 0; n < e.length; n++)
|
|
@@ -317,33 +317,33 @@ function Si(e, t) {
|
|
|
317
317
|
return !1;
|
|
318
318
|
return !0;
|
|
319
319
|
}
|
|
320
|
-
function
|
|
320
|
+
function Si(e) {
|
|
321
321
|
if (typeof e != "string")
|
|
322
322
|
throw new Error(`utf8ToBytes expected string, got ${typeof e}`);
|
|
323
323
|
return new Uint8Array(new TextEncoder().encode(e));
|
|
324
324
|
}
|
|
325
|
-
function
|
|
325
|
+
function Ai(e) {
|
|
326
326
|
let t;
|
|
327
|
-
for (t = 0; e >
|
|
327
|
+
for (t = 0; e > qn; e >>= ct, t += 1)
|
|
328
328
|
;
|
|
329
329
|
return t;
|
|
330
330
|
}
|
|
331
|
-
function
|
|
332
|
-
return e >> BigInt(t) &
|
|
331
|
+
function Ki(e, t) {
|
|
332
|
+
return e >> BigInt(t) & ct;
|
|
333
333
|
}
|
|
334
|
-
const
|
|
335
|
-
function
|
|
334
|
+
const Ni = (e, t, n) => e | (n ? ct : qn) << BigInt(t), Jt = (e) => (vi << BigInt(e - 1)) - ct, Kt = (e) => new Uint8Array(e), En = (e) => Uint8Array.from(e);
|
|
335
|
+
function jn(e, t, n) {
|
|
336
336
|
if (typeof e != "number" || e < 2)
|
|
337
337
|
throw new Error("hashLen must be a number");
|
|
338
338
|
if (typeof t != "number" || t < 2)
|
|
339
339
|
throw new Error("qByteLen must be a number");
|
|
340
340
|
if (typeof n != "function")
|
|
341
341
|
throw new Error("hmacFn must be a function");
|
|
342
|
-
let r =
|
|
342
|
+
let r = Kt(e), i = Kt(e), s = 0;
|
|
343
343
|
const o = () => {
|
|
344
344
|
r.fill(1), i.fill(0), s = 0;
|
|
345
|
-
}, a = (...u) => n(i, r, ...u), c = (u =
|
|
346
|
-
i = a(
|
|
345
|
+
}, a = (...u) => n(i, r, ...u), c = (u = Kt()) => {
|
|
346
|
+
i = a(En([0]), u), r = a(), u.length !== 0 && (i = a(En([1]), u), r = a());
|
|
347
347
|
}, l = () => {
|
|
348
348
|
if (s++ >= 1e3)
|
|
349
349
|
throw new Error("drbg: tried 1000 values");
|
|
@@ -364,7 +364,7 @@ function Vn(e, t, n) {
|
|
|
364
364
|
return o(), p;
|
|
365
365
|
};
|
|
366
366
|
}
|
|
367
|
-
const
|
|
367
|
+
const Bi = {
|
|
368
368
|
bigint: (e) => typeof e == "bigint",
|
|
369
369
|
function: (e) => typeof e == "function",
|
|
370
370
|
boolean: (e) => typeof e == "boolean",
|
|
@@ -375,9 +375,9 @@ const Ci = {
|
|
|
375
375
|
field: (e, t) => t.Fp.isValid(e),
|
|
376
376
|
hash: (e) => typeof e == "function" && Number.isSafeInteger(e.outputLen)
|
|
377
377
|
};
|
|
378
|
-
function
|
|
378
|
+
function Je(e, t, n = {}) {
|
|
379
379
|
const r = (i, s, o) => {
|
|
380
|
-
const a =
|
|
380
|
+
const a = Bi[s];
|
|
381
381
|
if (typeof a != "function")
|
|
382
382
|
throw new Error(`Invalid validator "${s}", expected function`);
|
|
383
383
|
const c = e[i];
|
|
@@ -390,37 +390,37 @@ function Ye(e, t, n = {}) {
|
|
|
390
390
|
r(i, s, !0);
|
|
391
391
|
return e;
|
|
392
392
|
}
|
|
393
|
-
const
|
|
393
|
+
const Ci = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
394
394
|
__proto__: null,
|
|
395
|
-
bitGet:
|
|
396
|
-
bitLen:
|
|
397
|
-
bitMask:
|
|
398
|
-
bitSet:
|
|
395
|
+
bitGet: Ki,
|
|
396
|
+
bitLen: Ai,
|
|
397
|
+
bitMask: Jt,
|
|
398
|
+
bitSet: Ni,
|
|
399
399
|
bytesToHex: qe,
|
|
400
400
|
bytesToNumberBE: G,
|
|
401
|
-
bytesToNumberLE:
|
|
401
|
+
bytesToNumberLE: Wt,
|
|
402
402
|
concatBytes: ke,
|
|
403
|
-
createHmacDrbg:
|
|
403
|
+
createHmacDrbg: jn,
|
|
404
404
|
ensureBytes: Z,
|
|
405
|
-
equalBytes:
|
|
405
|
+
equalBytes: xi,
|
|
406
406
|
hexToBytes: De,
|
|
407
|
-
hexToNumber:
|
|
407
|
+
hexToNumber: Ft,
|
|
408
408
|
numberToBytesBE: xe,
|
|
409
|
-
numberToBytesLE:
|
|
410
|
-
numberToHexUnpadded:
|
|
411
|
-
numberToVarBytesBE:
|
|
412
|
-
utf8ToBytes:
|
|
413
|
-
validateObject:
|
|
409
|
+
numberToBytesLE: Gt,
|
|
410
|
+
numberToHexUnpadded: Dn,
|
|
411
|
+
numberToVarBytesBE: Ei,
|
|
412
|
+
utf8ToBytes: Si,
|
|
413
|
+
validateObject: Je
|
|
414
414
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
415
415
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
416
|
-
const V = BigInt(0), q = BigInt(1), Ne = BigInt(2),
|
|
416
|
+
const V = BigInt(0), q = BigInt(1), Ne = BigInt(2), ki = BigInt(3), $t = BigInt(4), xn = BigInt(5), Sn = BigInt(8);
|
|
417
417
|
BigInt(9);
|
|
418
418
|
BigInt(16);
|
|
419
419
|
function z(e, t) {
|
|
420
420
|
const n = e % t;
|
|
421
421
|
return n >= V ? n : t + n;
|
|
422
422
|
}
|
|
423
|
-
function
|
|
423
|
+
function Ui(e, t, n) {
|
|
424
424
|
if (n <= V || t < V)
|
|
425
425
|
throw new Error("Expected power/modulo > 0");
|
|
426
426
|
if (n === q)
|
|
@@ -436,7 +436,7 @@ function J(e, t, n) {
|
|
|
436
436
|
r *= r, r %= n;
|
|
437
437
|
return r;
|
|
438
438
|
}
|
|
439
|
-
function
|
|
439
|
+
function Rt(e, t) {
|
|
440
440
|
if (e === V || t <= V)
|
|
441
441
|
throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);
|
|
442
442
|
let n = z(e, t), r = t, i = V, s = q;
|
|
@@ -448,15 +448,15 @@ function Ot(e, t) {
|
|
|
448
448
|
throw new Error("invert: does not exist");
|
|
449
449
|
return z(i, t);
|
|
450
450
|
}
|
|
451
|
-
function
|
|
451
|
+
function Ii(e) {
|
|
452
452
|
const t = (e - q) / Ne;
|
|
453
453
|
let n, r, i;
|
|
454
454
|
for (n = e - q, r = 0; n % Ne === V; n /= Ne, r++)
|
|
455
455
|
;
|
|
456
|
-
for (i = Ne; i < e &&
|
|
456
|
+
for (i = Ne; i < e && Ui(i, t, e) !== e - q; i++)
|
|
457
457
|
;
|
|
458
458
|
if (r === 1) {
|
|
459
|
-
const o = (e + q) /
|
|
459
|
+
const o = (e + q) / $t;
|
|
460
460
|
return function(c, l) {
|
|
461
461
|
const f = c.pow(l, o);
|
|
462
462
|
if (!c.eql(c.sqr(f), l))
|
|
@@ -481,9 +481,9 @@ function _i(e) {
|
|
|
481
481
|
return u;
|
|
482
482
|
};
|
|
483
483
|
}
|
|
484
|
-
function
|
|
485
|
-
if (e %
|
|
486
|
-
const t = (e + q) /
|
|
484
|
+
function _i(e) {
|
|
485
|
+
if (e % $t === ki) {
|
|
486
|
+
const t = (e + q) / $t;
|
|
487
487
|
return function(r, i) {
|
|
488
488
|
const s = r.pow(i, t);
|
|
489
489
|
if (!r.eql(r.sqr(s), i))
|
|
@@ -491,8 +491,8 @@ function Li(e) {
|
|
|
491
491
|
return s;
|
|
492
492
|
};
|
|
493
493
|
}
|
|
494
|
-
if (e %
|
|
495
|
-
const t = (e -
|
|
494
|
+
if (e % Sn === xn) {
|
|
495
|
+
const t = (e - xn) / Sn;
|
|
496
496
|
return function(r, i) {
|
|
497
497
|
const s = r.mul(i, Ne), o = r.pow(s, t), a = r.mul(i, o), c = r.mul(r.mul(a, Ne), o), l = r.mul(a, r.sub(c, r.ONE));
|
|
498
498
|
if (!r.eql(r.sqr(l), i))
|
|
@@ -500,9 +500,9 @@ function Li(e) {
|
|
|
500
500
|
return l;
|
|
501
501
|
};
|
|
502
502
|
}
|
|
503
|
-
return
|
|
503
|
+
return Ii(e);
|
|
504
504
|
}
|
|
505
|
-
const
|
|
505
|
+
const Li = [
|
|
506
506
|
"create",
|
|
507
507
|
"isValid",
|
|
508
508
|
"is0",
|
|
@@ -521,16 +521,16 @@ const Ti = [
|
|
|
521
521
|
"mulN",
|
|
522
522
|
"sqrN"
|
|
523
523
|
];
|
|
524
|
-
function
|
|
524
|
+
function Ti(e) {
|
|
525
525
|
const t = {
|
|
526
526
|
ORDER: "bigint",
|
|
527
527
|
MASK: "bigint",
|
|
528
528
|
BYTES: "isSafeInteger",
|
|
529
529
|
BITS: "isSafeInteger"
|
|
530
|
-
}, n =
|
|
531
|
-
return
|
|
530
|
+
}, n = Li.reduce((r, i) => (r[i] = "function", r), t);
|
|
531
|
+
return Je(e, n);
|
|
532
532
|
}
|
|
533
|
-
function
|
|
533
|
+
function $i(e, t, n) {
|
|
534
534
|
if (n < V)
|
|
535
535
|
throw new Error("Expected power > 0");
|
|
536
536
|
if (n === V)
|
|
@@ -542,25 +542,25 @@ function Ri(e, t, n) {
|
|
|
542
542
|
n & q && (r = e.mul(r, i)), i = e.sqr(i), n >>= q;
|
|
543
543
|
return r;
|
|
544
544
|
}
|
|
545
|
-
function
|
|
545
|
+
function Ri(e, t) {
|
|
546
546
|
const n = new Array(t.length), r = t.reduce((s, o, a) => e.is0(o) ? s : (n[a] = s, e.mul(s, o)), e.ONE), i = e.inv(r);
|
|
547
547
|
return t.reduceRight((s, o, a) => e.is0(o) ? s : (n[a] = e.mul(s, n[a]), e.mul(s, o)), i), n;
|
|
548
548
|
}
|
|
549
|
-
function
|
|
549
|
+
function Vn(e, t) {
|
|
550
550
|
const n = t !== void 0 ? t : e.toString(2).length, r = Math.ceil(n / 8);
|
|
551
551
|
return { nBitLength: n, nByteLength: r };
|
|
552
552
|
}
|
|
553
|
-
function
|
|
553
|
+
function Oi(e, t, n = !1, r = {}) {
|
|
554
554
|
if (e <= V)
|
|
555
555
|
throw new Error(`Expected Field ORDER > 0, got ${e}`);
|
|
556
|
-
const { nBitLength: i, nByteLength: s } =
|
|
556
|
+
const { nBitLength: i, nByteLength: s } = Vn(e, t);
|
|
557
557
|
if (s > 2048)
|
|
558
558
|
throw new Error("Field lengths over 2048 bytes are not supported");
|
|
559
|
-
const o =
|
|
559
|
+
const o = _i(e), a = Object.freeze({
|
|
560
560
|
ORDER: e,
|
|
561
561
|
BITS: i,
|
|
562
562
|
BYTES: s,
|
|
563
|
-
MASK:
|
|
563
|
+
MASK: Jt(i),
|
|
564
564
|
ZERO: V,
|
|
565
565
|
ONE: q,
|
|
566
566
|
create: (c) => z(c, e),
|
|
@@ -577,48 +577,48 @@ function Pi(e, t, n = !1, r = {}) {
|
|
|
577
577
|
add: (c, l) => z(c + l, e),
|
|
578
578
|
sub: (c, l) => z(c - l, e),
|
|
579
579
|
mul: (c, l) => z(c * l, e),
|
|
580
|
-
pow: (c, l) =>
|
|
581
|
-
div: (c, l) => z(c *
|
|
580
|
+
pow: (c, l) => $i(a, c, l),
|
|
581
|
+
div: (c, l) => z(c * Rt(l, e), e),
|
|
582
582
|
// Same as above, but doesn't normalize
|
|
583
583
|
sqrN: (c) => c * c,
|
|
584
584
|
addN: (c, l) => c + l,
|
|
585
585
|
subN: (c, l) => c - l,
|
|
586
586
|
mulN: (c, l) => c * l,
|
|
587
|
-
inv: (c) =>
|
|
587
|
+
inv: (c) => Rt(c, e),
|
|
588
588
|
sqrt: r.sqrt || ((c) => o(a, c)),
|
|
589
|
-
invertBatch: (c) =>
|
|
589
|
+
invertBatch: (c) => Ri(a, c),
|
|
590
590
|
// TODO: do we really need constant cmov?
|
|
591
591
|
// We don't have const-time bigints anyway, so probably will be not very useful
|
|
592
592
|
cmov: (c, l, f) => f ? l : c,
|
|
593
|
-
toBytes: (c) => n ?
|
|
593
|
+
toBytes: (c) => n ? Gt(c, s) : xe(c, s),
|
|
594
594
|
fromBytes: (c) => {
|
|
595
595
|
if (c.length !== s)
|
|
596
596
|
throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);
|
|
597
|
-
return n ?
|
|
597
|
+
return n ? Wt(c) : G(c);
|
|
598
598
|
}
|
|
599
599
|
});
|
|
600
600
|
return Object.freeze(a);
|
|
601
601
|
}
|
|
602
|
-
function
|
|
602
|
+
function zn(e) {
|
|
603
603
|
if (typeof e != "bigint")
|
|
604
604
|
throw new Error("field order must be bigint");
|
|
605
605
|
const t = e.toString(2).length;
|
|
606
606
|
return Math.ceil(t / 8);
|
|
607
607
|
}
|
|
608
|
-
function
|
|
609
|
-
const t =
|
|
608
|
+
function Zn(e) {
|
|
609
|
+
const t = zn(e);
|
|
610
610
|
return t + Math.ceil(t / 2);
|
|
611
611
|
}
|
|
612
|
-
function
|
|
613
|
-
const r = e.length, i =
|
|
612
|
+
function Pi(e, t, n = !1) {
|
|
613
|
+
const r = e.length, i = zn(t), s = Zn(t);
|
|
614
614
|
if (r < 16 || r < s || r > 1024)
|
|
615
615
|
throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);
|
|
616
|
-
const o = n ? G(e) :
|
|
617
|
-
return n ?
|
|
616
|
+
const o = n ? G(e) : Wt(e), a = z(o, t - q) + q;
|
|
617
|
+
return n ? Gt(a, i) : xe(a, i);
|
|
618
618
|
}
|
|
619
619
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
620
|
-
const
|
|
621
|
-
function
|
|
620
|
+
const Mi = BigInt(0), Nt = BigInt(1);
|
|
621
|
+
function Hi(e, t) {
|
|
622
622
|
const n = (i, s) => {
|
|
623
623
|
const o = s.negate();
|
|
624
624
|
return i ? o : s;
|
|
@@ -631,8 +631,8 @@ function qi(e, t) {
|
|
|
631
631
|
// non-const time multiplication ladder
|
|
632
632
|
unsafeLadder(i, s) {
|
|
633
633
|
let o = e.ZERO, a = i;
|
|
634
|
-
for (; s >
|
|
635
|
-
s &
|
|
634
|
+
for (; s > Mi; )
|
|
635
|
+
s & Nt && (o = o.add(a)), a = a.double(), s >>= Nt;
|
|
636
636
|
return o;
|
|
637
637
|
},
|
|
638
638
|
/**
|
|
@@ -670,7 +670,7 @@ function qi(e, t) {
|
|
|
670
670
|
for (let g = 0; g < a; g++) {
|
|
671
671
|
const h = g * c;
|
|
672
672
|
let y = Number(o & u);
|
|
673
|
-
o >>= p, y > c && (y -= d, o +=
|
|
673
|
+
o >>= p, y > c && (y -= d, o += Nt);
|
|
674
674
|
const w = h, E = h + Math.abs(y) - 1, K = g % 2 !== 0, I = y < 0;
|
|
675
675
|
y === 0 ? f = f.add(n(K, s[w])) : l = l.add(n(I, s[E]));
|
|
676
676
|
}
|
|
@@ -683,8 +683,8 @@ function qi(e, t) {
|
|
|
683
683
|
}
|
|
684
684
|
};
|
|
685
685
|
}
|
|
686
|
-
function
|
|
687
|
-
return
|
|
686
|
+
function Fn(e) {
|
|
687
|
+
return Ti(e.Fp), Je(e, {
|
|
688
688
|
n: "bigint",
|
|
689
689
|
h: "bigint",
|
|
690
690
|
Gx: "field",
|
|
@@ -693,15 +693,15 @@ function Wn(e) {
|
|
|
693
693
|
nBitLength: "isSafeInteger",
|
|
694
694
|
nByteLength: "isSafeInteger"
|
|
695
695
|
}), Object.freeze({
|
|
696
|
-
...
|
|
696
|
+
...Vn(e.n, e.nBitLength),
|
|
697
697
|
...e,
|
|
698
698
|
p: e.Fp.ORDER
|
|
699
699
|
});
|
|
700
700
|
}
|
|
701
701
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
702
|
-
function
|
|
703
|
-
const t =
|
|
704
|
-
|
|
702
|
+
function qi(e) {
|
|
703
|
+
const t = Fn(e);
|
|
704
|
+
Je(t, {
|
|
705
705
|
a: "field",
|
|
706
706
|
b: "field"
|
|
707
707
|
}, {
|
|
@@ -722,7 +722,7 @@ function Di(e) {
|
|
|
722
722
|
}
|
|
723
723
|
return Object.freeze({ ...t });
|
|
724
724
|
}
|
|
725
|
-
const { bytesToNumberBE:
|
|
725
|
+
const { bytesToNumberBE: Di, hexToBytes: ji } = Ci, Be = {
|
|
726
726
|
// asn.1 DER encoding utils
|
|
727
727
|
Err: class extends Error {
|
|
728
728
|
constructor(t = "") {
|
|
@@ -740,10 +740,10 @@ const { bytesToNumberBE: ji, hexToBytes: Vi } = ki, Be = {
|
|
|
740
740
|
throw new t("Invalid signature integer: negative");
|
|
741
741
|
if (r[0] === 0 && !(r[1] & 128))
|
|
742
742
|
throw new t("Invalid signature integer: unnecessary leading zero");
|
|
743
|
-
return { d:
|
|
743
|
+
return { d: Di(r), l: e.subarray(n + 2) };
|
|
744
744
|
},
|
|
745
745
|
toSig(e) {
|
|
746
|
-
const { Err: t } = Be, n = typeof e == "string" ?
|
|
746
|
+
const { Err: t } = Be, n = typeof e == "string" ? ji(e) : e;
|
|
747
747
|
if (!(n instanceof Uint8Array))
|
|
748
748
|
throw new Error("ui8a expected");
|
|
749
749
|
let r = n.length;
|
|
@@ -765,10 +765,10 @@ const { bytesToNumberBE: ji, hexToBytes: Vi } = ki, Be = {
|
|
|
765
765
|
}
|
|
766
766
|
}, ce = BigInt(0), Y = BigInt(1);
|
|
767
767
|
BigInt(2);
|
|
768
|
-
const
|
|
768
|
+
const An = BigInt(3);
|
|
769
769
|
BigInt(4);
|
|
770
|
-
function
|
|
771
|
-
const t =
|
|
770
|
+
function Vi(e) {
|
|
771
|
+
const t = qi(e), { Fp: n } = t, r = t.toBytes || ((g, h, y) => {
|
|
772
772
|
const w = h.toAffine();
|
|
773
773
|
return ke(Uint8Array.from([4]), n.toBytes(w.x), n.toBytes(w.y));
|
|
774
774
|
}), i = t.fromBytes || ((g) => {
|
|
@@ -901,7 +901,7 @@ function zi(e) {
|
|
|
901
901
|
// https://eprint.iacr.org/2015/1060, algorithm 3
|
|
902
902
|
// Cost: 8M + 3S + 3*a + 2*b3 + 15add.
|
|
903
903
|
double() {
|
|
904
|
-
const { a: h, b: y } = t, w = n.mul(y,
|
|
904
|
+
const { a: h, b: y } = t, w = n.mul(y, An), { px: E, py: K, pz: I } = this;
|
|
905
905
|
let C = n.ZERO, m = n.ZERO, x = n.ZERO, S = n.mul(E, E), P = n.mul(K, K), U = n.mul(I, I), N = n.mul(E, K);
|
|
906
906
|
return N = n.add(N, N), x = n.mul(E, I), x = n.add(x, x), C = n.mul(h, x), m = n.mul(w, U), m = n.add(C, m), C = n.sub(P, m), m = n.add(P, m), m = n.mul(C, m), C = n.mul(N, C), x = n.mul(w, x), U = n.mul(h, U), N = n.sub(S, U), N = n.mul(h, N), N = n.add(N, x), x = n.add(S, S), S = n.add(x, S), S = n.add(S, U), S = n.mul(S, N), m = n.add(m, S), U = n.mul(K, I), U = n.add(U, U), S = n.mul(U, N), C = n.sub(C, S), x = n.mul(U, P), x = n.add(x, x), x = n.add(x, x), new u(C, m, x);
|
|
907
907
|
}
|
|
@@ -913,7 +913,7 @@ function zi(e) {
|
|
|
913
913
|
f(h);
|
|
914
914
|
const { px: y, py: w, pz: E } = this, { px: K, py: I, pz: C } = h;
|
|
915
915
|
let m = n.ZERO, x = n.ZERO, S = n.ZERO;
|
|
916
|
-
const P = t.a, U = n.mul(t.b,
|
|
916
|
+
const P = t.a, U = n.mul(t.b, An);
|
|
917
917
|
let N = n.mul(y, K), $ = n.mul(w, I), R = n.mul(E, C), H = n.add(y, w), b = n.add(K, I);
|
|
918
918
|
H = n.mul(H, b), b = n.add(N, $), H = n.sub(H, b), b = n.add(y, E);
|
|
919
919
|
let v = n.add(K, C);
|
|
@@ -1016,7 +1016,7 @@ function zi(e) {
|
|
|
1016
1016
|
}
|
|
1017
1017
|
}
|
|
1018
1018
|
u.BASE = new u(t.Gx, t.Gy, n.ONE), u.ZERO = new u(n.ZERO, n.ONE, n.ZERO);
|
|
1019
|
-
const d = t.nBitLength, p =
|
|
1019
|
+
const d = t.nBitLength, p = Hi(u, t.endo ? Math.ceil(d / 2) : d);
|
|
1020
1020
|
return {
|
|
1021
1021
|
CURVE: t,
|
|
1022
1022
|
ProjectivePoint: u,
|
|
@@ -1025,9 +1025,9 @@ function zi(e) {
|
|
|
1025
1025
|
isWithinCurveOrder: o
|
|
1026
1026
|
};
|
|
1027
1027
|
}
|
|
1028
|
-
function
|
|
1029
|
-
const t =
|
|
1030
|
-
return
|
|
1028
|
+
function zi(e) {
|
|
1029
|
+
const t = Fn(e);
|
|
1030
|
+
return Je(t, {
|
|
1031
1031
|
hash: "hash",
|
|
1032
1032
|
hmac: "function",
|
|
1033
1033
|
randomBytes: "function"
|
|
@@ -1037,8 +1037,8 @@ function Zi(e) {
|
|
|
1037
1037
|
lowS: "boolean"
|
|
1038
1038
|
}), Object.freeze({ lowS: !0, ...t });
|
|
1039
1039
|
}
|
|
1040
|
-
function
|
|
1041
|
-
const t =
|
|
1040
|
+
function Zi(e) {
|
|
1041
|
+
const t = zi(e), { Fp: n, n: r } = t, i = n.BYTES + 1, s = 2 * n.BYTES + 1;
|
|
1042
1042
|
function o(b) {
|
|
1043
1043
|
return ce < b && b < n.ORDER;
|
|
1044
1044
|
}
|
|
@@ -1046,9 +1046,9 @@ function Fi(e) {
|
|
|
1046
1046
|
return z(b, r);
|
|
1047
1047
|
}
|
|
1048
1048
|
function c(b) {
|
|
1049
|
-
return
|
|
1049
|
+
return Rt(b, r);
|
|
1050
1050
|
}
|
|
1051
|
-
const { ProjectivePoint: l, normPrivateKeyToScalar: f, weierstrassEquation: u, isWithinCurveOrder: d } =
|
|
1051
|
+
const { ProjectivePoint: l, normPrivateKeyToScalar: f, weierstrassEquation: u, isWithinCurveOrder: d } = Vi({
|
|
1052
1052
|
...t,
|
|
1053
1053
|
toBytes(b, v, A) {
|
|
1054
1054
|
const k = v.toAffine(), B = n.toBytes(k.x), _ = ke;
|
|
@@ -1151,8 +1151,8 @@ function Fi(e) {
|
|
|
1151
1151
|
* (groupLen + ceil(groupLen / 2)) with modulo bias being negligible.
|
|
1152
1152
|
*/
|
|
1153
1153
|
randomPrivateKey: () => {
|
|
1154
|
-
const b =
|
|
1155
|
-
return
|
|
1154
|
+
const b = Zn(t.n);
|
|
1155
|
+
return Pi(t.randomBytes(b), t.n);
|
|
1156
1156
|
},
|
|
1157
1157
|
/**
|
|
1158
1158
|
* Creates precompute table for an arbitrary EC point. Makes point "cached".
|
|
@@ -1185,7 +1185,7 @@ function Fi(e) {
|
|
|
1185
1185
|
return A > 0 ? v >> BigInt(A) : v;
|
|
1186
1186
|
}, x = t.bits2int_modN || function(b) {
|
|
1187
1187
|
return a(m(b));
|
|
1188
|
-
}, S =
|
|
1188
|
+
}, S = Jt(t.nBitLength);
|
|
1189
1189
|
function P(b) {
|
|
1190
1190
|
if (typeof b != "bigint")
|
|
1191
1191
|
throw new Error("bigint expected");
|
|
@@ -1205,25 +1205,25 @@ function Fi(e) {
|
|
|
1205
1205
|
Ie.push(Z("extraEntropy", Ke));
|
|
1206
1206
|
}
|
|
1207
1207
|
const ze = ke(...Ie), pe = X;
|
|
1208
|
-
function
|
|
1208
|
+
function xt(Ke) {
|
|
1209
1209
|
const _e = m(Ke);
|
|
1210
1210
|
if (!d(_e))
|
|
1211
1211
|
return;
|
|
1212
|
-
const
|
|
1212
|
+
const wn = c(_e), Le = l.BASE.multiply(_e).toAffine(), Q = a(Le.x);
|
|
1213
1213
|
if (Q === ce)
|
|
1214
1214
|
return;
|
|
1215
|
-
const Te = a(
|
|
1215
|
+
const Te = a(wn * a(pe + Q * ye));
|
|
1216
1216
|
if (Te === ce)
|
|
1217
1217
|
return;
|
|
1218
|
-
let
|
|
1219
|
-
return _ && g(Te) && (
|
|
1218
|
+
let bn = (Le.x === Q ? 0 : 2) | Number(Le.y & Y), vn = Te;
|
|
1219
|
+
return _ && g(Te) && (vn = h(Te), bn ^= 1), new w(Q, vn, bn);
|
|
1220
1220
|
}
|
|
1221
|
-
return { seed: ze, k2sig:
|
|
1221
|
+
return { seed: ze, k2sig: xt };
|
|
1222
1222
|
}
|
|
1223
1223
|
const N = { lowS: t.lowS, prehash: !1 }, $ = { lowS: t.lowS, prehash: !1 };
|
|
1224
1224
|
function R(b, v, A = N) {
|
|
1225
1225
|
const { seed: k, k2sig: B } = U(b, v, A), _ = t;
|
|
1226
|
-
return
|
|
1226
|
+
return jn(_.hash.outputLen, _.nByteLength, _.hmac)(k, B);
|
|
1227
1227
|
}
|
|
1228
1228
|
l.BASE._setWindowSize(8);
|
|
1229
1229
|
function H(b, v, A, k = $) {
|
|
@@ -1256,7 +1256,7 @@ function Fi(e) {
|
|
|
1256
1256
|
if (_ && T.hasHighS())
|
|
1257
1257
|
return !1;
|
|
1258
1258
|
O && (v = t.hash(v));
|
|
1259
|
-
const { r: ye, s: Ie } = T, ze = x(v), pe = c(Ie),
|
|
1259
|
+
const { r: ye, s: Ie } = T, ze = x(v), pe = c(Ie), xt = a(ze * pe), Ke = a(ye * pe), _e = (Le = l.BASE.multiplyAndAddUnsafe(X, xt, Ke)) == null ? void 0 : Le.toAffine();
|
|
1260
1260
|
return _e ? a(_e.x) === ye : !1;
|
|
1261
1261
|
}
|
|
1262
1262
|
return {
|
|
@@ -1270,10 +1270,10 @@ function Fi(e) {
|
|
|
1270
1270
|
utils: E
|
|
1271
1271
|
};
|
|
1272
1272
|
}
|
|
1273
|
-
let
|
|
1273
|
+
let Wn = class extends Mn {
|
|
1274
1274
|
constructor(t, n) {
|
|
1275
|
-
super(), this.finished = !1, this.destroyed = !1,
|
|
1276
|
-
const r =
|
|
1275
|
+
super(), this.finished = !1, this.destroyed = !1, ai(t);
|
|
1276
|
+
const r = Zt(n);
|
|
1277
1277
|
if (this.iHash = t.create(), typeof this.iHash.update != "function")
|
|
1278
1278
|
throw new Error("Expected instance of class which extends utils.Hash");
|
|
1279
1279
|
this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
|
|
@@ -1287,10 +1287,10 @@ let Gn = class extends Hn {
|
|
|
1287
1287
|
this.oHash.update(s), s.fill(0);
|
|
1288
1288
|
}
|
|
1289
1289
|
update(t) {
|
|
1290
|
-
return
|
|
1290
|
+
return nt(this), this.iHash.update(t), this;
|
|
1291
1291
|
}
|
|
1292
1292
|
digestInto(t) {
|
|
1293
|
-
|
|
1293
|
+
nt(this), On(t, this.outputLen), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
|
|
1294
1294
|
}
|
|
1295
1295
|
digest() {
|
|
1296
1296
|
const t = new Uint8Array(this.oHash.outputLen);
|
|
@@ -1305,33 +1305,33 @@ let Gn = class extends Hn {
|
|
|
1305
1305
|
this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
|
|
1306
1306
|
}
|
|
1307
1307
|
};
|
|
1308
|
-
const
|
|
1309
|
-
|
|
1308
|
+
const Gn = (e, t, n) => new Wn(e, t).update(n).digest();
|
|
1309
|
+
Gn.create = (e, t) => new Wn(e, t);
|
|
1310
1310
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
1311
|
-
function
|
|
1311
|
+
function Fi(e) {
|
|
1312
1312
|
return {
|
|
1313
1313
|
hash: e,
|
|
1314
|
-
hmac: (t, ...n) =>
|
|
1315
|
-
randomBytes:
|
|
1314
|
+
hmac: (t, ...n) => Gn(e, t, fi(...n)),
|
|
1315
|
+
randomBytes: Hn
|
|
1316
1316
|
};
|
|
1317
1317
|
}
|
|
1318
|
-
function
|
|
1319
|
-
const n = (r) =>
|
|
1318
|
+
function Wi(e, t) {
|
|
1319
|
+
const n = (r) => Zi({ ...e, ...Fi(r) });
|
|
1320
1320
|
return Object.freeze({ ...n(t), create: n });
|
|
1321
1321
|
}
|
|
1322
1322
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
1323
|
-
const
|
|
1324
|
-
function
|
|
1325
|
-
const t =
|
|
1326
|
-
if (!
|
|
1323
|
+
const ut = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"), rt = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), Jn = BigInt(1), it = BigInt(2), Kn = (e, t) => (e + t / it) / t;
|
|
1324
|
+
function Yn(e) {
|
|
1325
|
+
const t = ut, n = BigInt(3), r = BigInt(6), i = BigInt(11), s = BigInt(22), o = BigInt(23), a = BigInt(44), c = BigInt(88), l = e * e * e % t, f = l * l * e % t, u = J(f, n, t) * f % t, d = J(u, n, t) * f % t, p = J(d, it, t) * l % t, g = J(p, i, t) * p % t, h = J(g, s, t) * g % t, y = J(h, a, t) * h % t, w = J(y, c, t) * y % t, E = J(w, a, t) * h % t, K = J(E, n, t) * f % t, I = J(K, o, t) * g % t, C = J(I, r, t) * l % t, m = J(C, it, t);
|
|
1326
|
+
if (!Ot.eql(Ot.sqr(m), e))
|
|
1327
1327
|
throw new Error("Cannot find square root");
|
|
1328
1328
|
return m;
|
|
1329
1329
|
}
|
|
1330
|
-
const
|
|
1330
|
+
const Ot = Oi(ut, void 0, void 0, { sqrt: Yn }), Ue = Wi({
|
|
1331
1331
|
a: BigInt(0),
|
|
1332
1332
|
b: BigInt(7),
|
|
1333
|
-
Fp:
|
|
1334
|
-
n:
|
|
1333
|
+
Fp: Ot,
|
|
1334
|
+
n: rt,
|
|
1335
1335
|
// Base point (x, y) aka generator point
|
|
1336
1336
|
Gx: BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),
|
|
1337
1337
|
Gy: BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),
|
|
@@ -1346,7 +1346,7 @@ const Pt = Pi(ft, void 0, void 0, { sqrt: Xn }), Ue = Gi({
|
|
|
1346
1346
|
endo: {
|
|
1347
1347
|
beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
|
|
1348
1348
|
splitScalar: (e) => {
|
|
1349
|
-
const t =
|
|
1349
|
+
const t = rt, n = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), r = -Jn * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), i = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), s = n, o = BigInt("0x100000000000000000000000000000000"), a = Kn(s * e, t), c = Kn(-r * e, t);
|
|
1350
1350
|
let l = z(e - a * n - c * i, t), f = z(-a * r - c * s, t);
|
|
1351
1351
|
const u = l > o, d = f > o;
|
|
1352
1352
|
if (u && (l = t - l), d && (f = t - f), l > o || f > o)
|
|
@@ -1354,84 +1354,84 @@ const Pt = Pi(ft, void 0, void 0, { sqrt: Xn }), Ue = Gi({
|
|
|
1354
1354
|
return { k1neg: u, k1: l, k2neg: d, k2: f };
|
|
1355
1355
|
}
|
|
1356
1356
|
}
|
|
1357
|
-
},
|
|
1358
|
-
function
|
|
1359
|
-
let n =
|
|
1357
|
+
}, Tt), ft = BigInt(0), Xn = (e) => typeof e == "bigint" && ft < e && e < ut, Gi = (e) => typeof e == "bigint" && ft < e && e < rt, Nn = {};
|
|
1358
|
+
function st(e, ...t) {
|
|
1359
|
+
let n = Nn[e];
|
|
1360
1360
|
if (n === void 0) {
|
|
1361
|
-
const r =
|
|
1362
|
-
n = ke(r, r),
|
|
1361
|
+
const r = Tt(Uint8Array.from(e, (i) => i.charCodeAt(0)));
|
|
1362
|
+
n = ke(r, r), Nn[e] = n;
|
|
1363
1363
|
}
|
|
1364
|
-
return
|
|
1364
|
+
return Tt(ke(n, ...t));
|
|
1365
1365
|
}
|
|
1366
|
-
const
|
|
1367
|
-
function
|
|
1368
|
-
let t = Ue.utils.normPrivateKeyToScalar(e), n =
|
|
1369
|
-
return { scalar: n.hasEvenY() ? t :
|
|
1366
|
+
const Yt = (e) => e.toRawBytes(!0).slice(1), Pt = (e) => xe(e, 32), Bt = (e) => z(e, ut), We = (e) => z(e, rt), Xt = Ue.ProjectivePoint, Ji = (e, t, n) => Xt.BASE.multiplyAndAddUnsafe(e, t, n);
|
|
1367
|
+
function Mt(e) {
|
|
1368
|
+
let t = Ue.utils.normPrivateKeyToScalar(e), n = Xt.fromPrivateKey(t);
|
|
1369
|
+
return { scalar: n.hasEvenY() ? t : We(-t), bytes: Yt(n) };
|
|
1370
1370
|
}
|
|
1371
|
-
function
|
|
1372
|
-
if (!
|
|
1371
|
+
function Qn(e) {
|
|
1372
|
+
if (!Xn(e))
|
|
1373
1373
|
throw new Error("bad x: need 0 < x < p");
|
|
1374
|
-
const t =
|
|
1375
|
-
let r =
|
|
1376
|
-
r %
|
|
1377
|
-
const i = new
|
|
1374
|
+
const t = Bt(e * e), n = Bt(t * e + BigInt(7));
|
|
1375
|
+
let r = Yn(n);
|
|
1376
|
+
r % it !== ft && (r = Bt(-r));
|
|
1377
|
+
const i = new Xt(e, r, Jn);
|
|
1378
1378
|
return i.assertValidity(), i;
|
|
1379
1379
|
}
|
|
1380
|
-
function
|
|
1381
|
-
return
|
|
1380
|
+
function er(...e) {
|
|
1381
|
+
return We(G(st("BIP0340/challenge", ...e)));
|
|
1382
1382
|
}
|
|
1383
|
-
function
|
|
1384
|
-
return
|
|
1383
|
+
function Yi(e) {
|
|
1384
|
+
return Mt(e).bytes;
|
|
1385
1385
|
}
|
|
1386
|
-
function
|
|
1387
|
-
const r = Z("message", e), { bytes: i, scalar: s } =
|
|
1388
|
-
if (l ===
|
|
1386
|
+
function Xi(e, t, n = Hn(32)) {
|
|
1387
|
+
const r = Z("message", e), { bytes: i, scalar: s } = Mt(t), o = Z("auxRand", n, 32), a = Pt(s ^ G(st("BIP0340/aux", o))), c = st("BIP0340/nonce", a, i, r), l = We(G(c));
|
|
1388
|
+
if (l === ft)
|
|
1389
1389
|
throw new Error("sign failed: k is zero");
|
|
1390
|
-
const { bytes: f, scalar: u } =
|
|
1391
|
-
if (p.set(f, 0), p.set(
|
|
1390
|
+
const { bytes: f, scalar: u } = Mt(l), d = er(f, i, r), p = new Uint8Array(64);
|
|
1391
|
+
if (p.set(f, 0), p.set(Pt(We(u + d * s)), 32), !tr(p, r, i))
|
|
1392
1392
|
throw new Error("sign: Invalid signature produced");
|
|
1393
1393
|
return p;
|
|
1394
1394
|
}
|
|
1395
|
-
function
|
|
1395
|
+
function tr(e, t, n) {
|
|
1396
1396
|
const r = Z("signature", e, 64), i = Z("message", t), s = Z("publicKey", n, 32);
|
|
1397
1397
|
try {
|
|
1398
|
-
const o =
|
|
1399
|
-
if (!
|
|
1398
|
+
const o = Qn(G(s)), a = G(r.subarray(0, 32));
|
|
1399
|
+
if (!Xn(a))
|
|
1400
1400
|
return !1;
|
|
1401
1401
|
const c = G(r.subarray(32, 64));
|
|
1402
|
-
if (!
|
|
1402
|
+
if (!Gi(c))
|
|
1403
1403
|
return !1;
|
|
1404
|
-
const l =
|
|
1404
|
+
const l = er(Pt(a), Yt(o), i), f = Ji(o, c, We(-l));
|
|
1405
1405
|
return !(!f || !f.hasEvenY() || f.toAffine().x !== a);
|
|
1406
1406
|
} catch {
|
|
1407
1407
|
return !1;
|
|
1408
1408
|
}
|
|
1409
1409
|
}
|
|
1410
1410
|
const Ze = {
|
|
1411
|
-
getPublicKey:
|
|
1412
|
-
sign:
|
|
1413
|
-
verify:
|
|
1411
|
+
getPublicKey: Yi,
|
|
1412
|
+
sign: Xi,
|
|
1413
|
+
verify: tr,
|
|
1414
1414
|
utils: {
|
|
1415
1415
|
randomPrivateKey: Ue.utils.randomPrivateKey,
|
|
1416
|
-
lift_x:
|
|
1417
|
-
pointToBytes:
|
|
1416
|
+
lift_x: Qn,
|
|
1417
|
+
pointToBytes: Yt,
|
|
1418
1418
|
numberToBytesBE: xe,
|
|
1419
1419
|
bytesToNumberBE: G,
|
|
1420
|
-
taggedHash:
|
|
1420
|
+
taggedHash: st,
|
|
1421
1421
|
mod: z
|
|
1422
1422
|
}
|
|
1423
|
-
},
|
|
1423
|
+
}, Ct = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
|
|
1424
1424
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
1425
|
-
const
|
|
1426
|
-
if (!
|
|
1425
|
+
const Qt = (e) => e instanceof Uint8Array, kt = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), re = (e, t) => e << 32 - t | e >>> t, Qi = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
1426
|
+
if (!Qi)
|
|
1427
1427
|
throw new Error("Non little-endian hardware is not supported");
|
|
1428
|
-
const
|
|
1428
|
+
const es = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
|
|
1429
1429
|
function M(e) {
|
|
1430
|
-
if (!
|
|
1430
|
+
if (!Qt(e))
|
|
1431
1431
|
throw new Error("Uint8Array expected");
|
|
1432
1432
|
let t = "";
|
|
1433
1433
|
for (let n = 0; n < e.length; n++)
|
|
1434
|
-
t +=
|
|
1434
|
+
t += es[e[n]];
|
|
1435
1435
|
return t;
|
|
1436
1436
|
}
|
|
1437
1437
|
function W(e) {
|
|
@@ -1449,98 +1449,98 @@ function W(e) {
|
|
|
1449
1449
|
}
|
|
1450
1450
|
return n;
|
|
1451
1451
|
}
|
|
1452
|
-
function
|
|
1452
|
+
function ts(e) {
|
|
1453
1453
|
if (typeof e != "string")
|
|
1454
1454
|
throw new Error(`utf8ToBytes expected string, got ${typeof e}`);
|
|
1455
1455
|
return new Uint8Array(new TextEncoder().encode(e));
|
|
1456
1456
|
}
|
|
1457
|
-
function
|
|
1458
|
-
if (typeof e == "string" && (e =
|
|
1457
|
+
function Ge(e) {
|
|
1458
|
+
if (typeof e == "string" && (e = ts(e)), !Qt(e))
|
|
1459
1459
|
throw new Error(`expected Uint8Array, got ${typeof e}`);
|
|
1460
1460
|
return e;
|
|
1461
1461
|
}
|
|
1462
|
-
function
|
|
1462
|
+
function ht(...e) {
|
|
1463
1463
|
const t = new Uint8Array(e.reduce((r, i) => r + i.length, 0));
|
|
1464
1464
|
let n = 0;
|
|
1465
1465
|
return e.forEach((r) => {
|
|
1466
|
-
if (!
|
|
1466
|
+
if (!Qt(r))
|
|
1467
1467
|
throw new Error("Uint8Array expected");
|
|
1468
1468
|
t.set(r, n), n += r.length;
|
|
1469
1469
|
}), t;
|
|
1470
1470
|
}
|
|
1471
|
-
class
|
|
1471
|
+
class nr {
|
|
1472
1472
|
// Safe version that clones internal state
|
|
1473
1473
|
clone() {
|
|
1474
1474
|
return this._cloneInto();
|
|
1475
1475
|
}
|
|
1476
1476
|
}
|
|
1477
|
-
function
|
|
1478
|
-
const t = (r) => e().update(
|
|
1477
|
+
function rr(e) {
|
|
1478
|
+
const t = (r) => e().update(Ge(r)).digest(), n = e();
|
|
1479
1479
|
return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
|
|
1480
1480
|
}
|
|
1481
|
-
function
|
|
1482
|
-
if (
|
|
1483
|
-
return
|
|
1481
|
+
function ir(e = 32) {
|
|
1482
|
+
if (Ct && typeof Ct.getRandomValues == "function")
|
|
1483
|
+
return Ct.getRandomValues(new Uint8Array(e));
|
|
1484
1484
|
throw new Error("crypto.getRandomValues must be defined");
|
|
1485
1485
|
}
|
|
1486
|
-
function
|
|
1486
|
+
function Ht(e) {
|
|
1487
1487
|
if (!Number.isSafeInteger(e) || e < 0)
|
|
1488
1488
|
throw new Error(`Wrong positive integer: ${e}`);
|
|
1489
1489
|
}
|
|
1490
|
-
function
|
|
1490
|
+
function ns(e) {
|
|
1491
1491
|
if (typeof e != "boolean")
|
|
1492
1492
|
throw new Error(`Expected boolean, not ${e}`);
|
|
1493
1493
|
}
|
|
1494
|
-
function
|
|
1494
|
+
function sr(e, ...t) {
|
|
1495
1495
|
if (!(e instanceof Uint8Array))
|
|
1496
1496
|
throw new Error("Expected Uint8Array");
|
|
1497
1497
|
if (t.length > 0 && !t.includes(e.length))
|
|
1498
1498
|
throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`);
|
|
1499
1499
|
}
|
|
1500
|
-
function
|
|
1500
|
+
function rs(e) {
|
|
1501
1501
|
if (typeof e != "function" || typeof e.create != "function")
|
|
1502
1502
|
throw new Error("Hash should be wrapped by utils.wrapConstructor");
|
|
1503
|
-
|
|
1503
|
+
Ht(e.outputLen), Ht(e.blockLen);
|
|
1504
1504
|
}
|
|
1505
|
-
function
|
|
1505
|
+
function is(e, t = !0) {
|
|
1506
1506
|
if (e.destroyed)
|
|
1507
1507
|
throw new Error("Hash instance has been destroyed");
|
|
1508
1508
|
if (t && e.finished)
|
|
1509
1509
|
throw new Error("Hash#digest() has already been called");
|
|
1510
1510
|
}
|
|
1511
|
-
function
|
|
1512
|
-
|
|
1511
|
+
function ss(e, t) {
|
|
1512
|
+
sr(e);
|
|
1513
1513
|
const n = t.outputLen;
|
|
1514
1514
|
if (e.length < n)
|
|
1515
1515
|
throw new Error(`digestInto() expects output buffer of length at least ${n}`);
|
|
1516
1516
|
}
|
|
1517
1517
|
const se = {
|
|
1518
|
-
number:
|
|
1519
|
-
bool:
|
|
1520
|
-
bytes:
|
|
1521
|
-
hash:
|
|
1522
|
-
exists:
|
|
1523
|
-
output:
|
|
1518
|
+
number: Ht,
|
|
1519
|
+
bool: ns,
|
|
1520
|
+
bytes: sr,
|
|
1521
|
+
hash: rs,
|
|
1522
|
+
exists: is,
|
|
1523
|
+
output: ss
|
|
1524
1524
|
};
|
|
1525
|
-
function
|
|
1525
|
+
function os(e, t, n, r) {
|
|
1526
1526
|
if (typeof e.setBigUint64 == "function")
|
|
1527
1527
|
return e.setBigUint64(t, n, r);
|
|
1528
1528
|
const i = BigInt(32), s = BigInt(4294967295), o = Number(n >> i & s), a = Number(n & s), c = r ? 4 : 0, l = r ? 0 : 4;
|
|
1529
1529
|
e.setUint32(t + c, o, r), e.setUint32(t + l, a, r);
|
|
1530
1530
|
}
|
|
1531
|
-
class
|
|
1531
|
+
class as extends nr {
|
|
1532
1532
|
constructor(t, n, r, i) {
|
|
1533
|
-
super(), this.blockLen = t, this.outputLen = n, this.padOffset = r, this.isLE = i, this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.buffer = new Uint8Array(t), this.view =
|
|
1533
|
+
super(), this.blockLen = t, this.outputLen = n, this.padOffset = r, this.isLE = i, this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.buffer = new Uint8Array(t), this.view = kt(this.buffer);
|
|
1534
1534
|
}
|
|
1535
1535
|
update(t) {
|
|
1536
1536
|
se.exists(this);
|
|
1537
1537
|
const { view: n, buffer: r, blockLen: i } = this;
|
|
1538
|
-
t =
|
|
1538
|
+
t = Ge(t);
|
|
1539
1539
|
const s = t.length;
|
|
1540
1540
|
for (let o = 0; o < s; ) {
|
|
1541
1541
|
const a = Math.min(i - this.pos, s - o);
|
|
1542
1542
|
if (a === i) {
|
|
1543
|
-
const c =
|
|
1543
|
+
const c = kt(t);
|
|
1544
1544
|
for (; i <= s - o; o += i)
|
|
1545
1545
|
this.process(c, o);
|
|
1546
1546
|
continue;
|
|
@@ -1556,8 +1556,8 @@ class cs extends rr {
|
|
|
1556
1556
|
n[o++] = 128, this.buffer.subarray(o).fill(0), this.padOffset > i - o && (this.process(r, 0), o = 0);
|
|
1557
1557
|
for (let u = o; u < i; u++)
|
|
1558
1558
|
n[u] = 0;
|
|
1559
|
-
|
|
1560
|
-
const a =
|
|
1559
|
+
os(r, i - 8, BigInt(this.length * 8), s), this.process(r, 0);
|
|
1560
|
+
const a = kt(t), c = this.outputLen;
|
|
1561
1561
|
if (c % 4)
|
|
1562
1562
|
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
1563
1563
|
const l = c / 4, f = this.get();
|
|
@@ -1578,7 +1578,7 @@ class cs extends rr {
|
|
|
1578
1578
|
return t.length = i, t.pos = a, t.finished = s, t.destroyed = o, i % n && t.buffer.set(r), t;
|
|
1579
1579
|
}
|
|
1580
1580
|
}
|
|
1581
|
-
const
|
|
1581
|
+
const cs = (e, t, n) => e & t ^ ~e & n, ls = (e, t, n) => e & t ^ e & n ^ t & n, us = new Uint32Array([
|
|
1582
1582
|
1116352408,
|
|
1583
1583
|
1899447441,
|
|
1584
1584
|
3049323471,
|
|
@@ -1653,7 +1653,7 @@ const ls = (e, t, n) => e & t ^ ~e & n, us = (e, t, n) => e & t ^ e & n ^ t & n,
|
|
|
1653
1653
|
528734635,
|
|
1654
1654
|
1541459225
|
|
1655
1655
|
]), ve = new Uint32Array(64);
|
|
1656
|
-
class
|
|
1656
|
+
class or extends as {
|
|
1657
1657
|
constructor() {
|
|
1658
1658
|
super(64, 32, 8, !1), this.A = be[0] | 0, this.B = be[1] | 0, this.C = be[2] | 0, this.D = be[3] | 0, this.E = be[4] | 0, this.F = be[5] | 0, this.G = be[6] | 0, this.H = be[7] | 0;
|
|
1659
1659
|
}
|
|
@@ -1674,7 +1674,7 @@ class ar extends cs {
|
|
|
1674
1674
|
}
|
|
1675
1675
|
let { A: r, B: i, C: s, D: o, E: a, F: c, G: l, H: f } = this;
|
|
1676
1676
|
for (let u = 0; u < 64; u++) {
|
|
1677
|
-
const d = re(a, 6) ^ re(a, 11) ^ re(a, 25), p = f + d +
|
|
1677
|
+
const d = re(a, 6) ^ re(a, 11) ^ re(a, 25), p = f + d + cs(a, c, l) + us[u] + ve[u] | 0, h = (re(r, 2) ^ re(r, 13) ^ re(r, 22)) + ls(r, i, s) | 0;
|
|
1678
1678
|
f = l, l = c, c = a, a = o + p | 0, o = s, s = i, i = r, r = p + h | 0;
|
|
1679
1679
|
}
|
|
1680
1680
|
r = r + this.A | 0, i = i + this.B | 0, s = s + this.C | 0, o = o + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, l = l + this.G | 0, f = f + this.H | 0, this.set(r, i, s, o, a, c, l, f);
|
|
@@ -1686,13 +1686,13 @@ class ar extends cs {
|
|
|
1686
1686
|
this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
|
|
1687
1687
|
}
|
|
1688
1688
|
}
|
|
1689
|
-
class
|
|
1689
|
+
class fs extends or {
|
|
1690
1690
|
constructor() {
|
|
1691
1691
|
super(), this.A = -1056596264, this.B = 914150663, this.C = 812702999, this.D = -150054599, this.E = -4191439, this.F = 1750603025, this.G = 1694076839, this.H = -1090891868, this.outputLen = 28;
|
|
1692
1692
|
}
|
|
1693
1693
|
}
|
|
1694
|
-
const Se =
|
|
1695
|
-
|
|
1694
|
+
const Se = rr(() => new or());
|
|
1695
|
+
rr(() => new fs());
|
|
1696
1696
|
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
1697
1697
|
function Ve(e) {
|
|
1698
1698
|
if (!Number.isSafeInteger(e))
|
|
@@ -1746,7 +1746,7 @@ function de(e = "") {
|
|
|
1746
1746
|
}
|
|
1747
1747
|
};
|
|
1748
1748
|
}
|
|
1749
|
-
function
|
|
1749
|
+
function dt(e, t = "=") {
|
|
1750
1750
|
if (Ve(e), typeof t != "string")
|
|
1751
1751
|
throw new Error("padding chr should be string");
|
|
1752
1752
|
return {
|
|
@@ -1776,12 +1776,12 @@ function yt(e, t = "=") {
|
|
|
1776
1776
|
}
|
|
1777
1777
|
};
|
|
1778
1778
|
}
|
|
1779
|
-
function
|
|
1779
|
+
function ar(e) {
|
|
1780
1780
|
if (typeof e != "function")
|
|
1781
1781
|
throw new Error("normalize fn should be function");
|
|
1782
1782
|
return { encode: (t) => t, decode: (t) => e(t) };
|
|
1783
1783
|
}
|
|
1784
|
-
function
|
|
1784
|
+
function Bn(e, t, n) {
|
|
1785
1785
|
if (t < 2)
|
|
1786
1786
|
throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);
|
|
1787
1787
|
if (n < 2)
|
|
@@ -1814,16 +1814,16 @@ function Cn(e, t, n) {
|
|
|
1814
1814
|
i.push(0);
|
|
1815
1815
|
return i.reverse();
|
|
1816
1816
|
}
|
|
1817
|
-
const
|
|
1818
|
-
function
|
|
1817
|
+
const cr = (e, t) => t ? cr(t, e % t) : e, ot = (e, t) => e + (t - cr(e, t));
|
|
1818
|
+
function qt(e, t, n, r) {
|
|
1819
1819
|
if (!Array.isArray(e))
|
|
1820
1820
|
throw new Error("convertRadix2: data should be array");
|
|
1821
1821
|
if (t <= 0 || t > 32)
|
|
1822
1822
|
throw new Error(`convertRadix2: wrong from=${t}`);
|
|
1823
1823
|
if (n <= 0 || n > 32)
|
|
1824
1824
|
throw new Error(`convertRadix2: wrong to=${n}`);
|
|
1825
|
-
if (
|
|
1826
|
-
throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${
|
|
1825
|
+
if (ot(t, n) > 32)
|
|
1826
|
+
throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${ot(t, n)}`);
|
|
1827
1827
|
let i = 0, s = 0;
|
|
1828
1828
|
const o = 2 ** n - 1, a = [];
|
|
1829
1829
|
for (const c of e) {
|
|
@@ -1841,39 +1841,39 @@ function Dt(e, t, n, r) {
|
|
|
1841
1841
|
throw new Error(`Non-zero padding: ${i}`);
|
|
1842
1842
|
return r && s > 0 && a.push(i >>> 0), a;
|
|
1843
1843
|
}
|
|
1844
|
-
function
|
|
1844
|
+
function hs(e) {
|
|
1845
1845
|
return Ve(e), {
|
|
1846
1846
|
encode: (t) => {
|
|
1847
1847
|
if (!(t instanceof Uint8Array))
|
|
1848
1848
|
throw new Error("radix.encode input should be Uint8Array");
|
|
1849
|
-
return
|
|
1849
|
+
return Bn(Array.from(t), 2 ** 8, e);
|
|
1850
1850
|
},
|
|
1851
1851
|
decode: (t) => {
|
|
1852
1852
|
if (!Array.isArray(t) || t.length && typeof t[0] != "number")
|
|
1853
1853
|
throw new Error("radix.decode input should be array of strings");
|
|
1854
|
-
return Uint8Array.from(
|
|
1854
|
+
return Uint8Array.from(Bn(t, e, 2 ** 8));
|
|
1855
1855
|
}
|
|
1856
1856
|
};
|
|
1857
1857
|
}
|
|
1858
1858
|
function Ae(e, t = !1) {
|
|
1859
1859
|
if (Ve(e), e <= 0 || e > 32)
|
|
1860
1860
|
throw new Error("radix2: bits should be in (0..32]");
|
|
1861
|
-
if (
|
|
1861
|
+
if (ot(8, e) > 32 || ot(e, 8) > 32)
|
|
1862
1862
|
throw new Error("radix2: carry overflow");
|
|
1863
1863
|
return {
|
|
1864
1864
|
encode: (n) => {
|
|
1865
1865
|
if (!(n instanceof Uint8Array))
|
|
1866
1866
|
throw new Error("radix2.encode input should be Uint8Array");
|
|
1867
|
-
return
|
|
1867
|
+
return qt(Array.from(n), 8, e, !t);
|
|
1868
1868
|
},
|
|
1869
1869
|
decode: (n) => {
|
|
1870
1870
|
if (!Array.isArray(n) || n.length && typeof n[0] != "number")
|
|
1871
1871
|
throw new Error("radix2.decode input should be array of strings");
|
|
1872
|
-
return Uint8Array.from(
|
|
1872
|
+
return Uint8Array.from(qt(n, e, 8, t));
|
|
1873
1873
|
}
|
|
1874
1874
|
};
|
|
1875
1875
|
}
|
|
1876
|
-
function
|
|
1876
|
+
function Cn(e) {
|
|
1877
1877
|
if (typeof e != "function")
|
|
1878
1878
|
throw new Error("unsafeWrapper fn should be function");
|
|
1879
1879
|
return function(...t) {
|
|
@@ -1883,25 +1883,25 @@ function kn(e) {
|
|
|
1883
1883
|
}
|
|
1884
1884
|
};
|
|
1885
1885
|
}
|
|
1886
|
-
const
|
|
1887
|
-
fe(Ae(5), he("0123456789ABCDEFGHIJKLMNOPQRSTUV"),
|
|
1888
|
-
fe(Ae(5), he("0123456789ABCDEFGHJKMNPQRSTVWXYZ"), de(""),
|
|
1889
|
-
const ue = fe(Ae(6), he("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
const
|
|
1886
|
+
const ds = fe(Ae(4), he("0123456789ABCDEF"), de("")), ys = fe(Ae(5), he("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), dt(5), de(""));
|
|
1887
|
+
fe(Ae(5), he("0123456789ABCDEFGHIJKLMNOPQRSTUV"), dt(5), de(""));
|
|
1888
|
+
fe(Ae(5), he("0123456789ABCDEFGHJKMNPQRSTVWXYZ"), de(""), ar((e) => e.toUpperCase().replace(/O/g, "0").replace(/[IL]/g, "1")));
|
|
1889
|
+
const ue = fe(Ae(6), he("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), dt(6), de("")), ps = fe(Ae(6), he("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), dt(6), de("")), en = (e) => fe(hs(58), he(e), de("")), Dt = en("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
1890
|
+
en("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ");
|
|
1891
|
+
en("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");
|
|
1892
|
+
const kn = [0, 2, 3, 5, 6, 7, 9, 10, 11], gs = {
|
|
1893
1893
|
encode(e) {
|
|
1894
1894
|
let t = "";
|
|
1895
1895
|
for (let n = 0; n < e.length; n += 8) {
|
|
1896
1896
|
const r = e.subarray(n, n + 8);
|
|
1897
|
-
t +=
|
|
1897
|
+
t += Dt.encode(r).padStart(kn[r.length], "1");
|
|
1898
1898
|
}
|
|
1899
1899
|
return t;
|
|
1900
1900
|
},
|
|
1901
1901
|
decode(e) {
|
|
1902
1902
|
let t = [];
|
|
1903
1903
|
for (let n = 0; n < e.length; n += 11) {
|
|
1904
|
-
const r = e.slice(n, n + 11), i =
|
|
1904
|
+
const r = e.slice(n, n + 11), i = kn.indexOf(r.length), s = Dt.decode(r);
|
|
1905
1905
|
for (let o = 0; o < s.length - i; o++)
|
|
1906
1906
|
if (s[o] !== 0)
|
|
1907
1907
|
throw new Error("base58xmr: wrong padding");
|
|
@@ -1909,15 +1909,15 @@ const Un = [0, 2, 3, 5, 6, 7, 9, 10, 11], ws = {
|
|
|
1909
1909
|
}
|
|
1910
1910
|
return Uint8Array.from(t);
|
|
1911
1911
|
}
|
|
1912
|
-
},
|
|
1912
|
+
}, jt = fe(he("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), de("")), Un = [996825010, 642813549, 513874426, 1027748829, 705979059];
|
|
1913
1913
|
function Fe(e) {
|
|
1914
1914
|
const t = e >> 25;
|
|
1915
1915
|
let n = (e & 33554431) << 5;
|
|
1916
|
-
for (let r = 0; r <
|
|
1917
|
-
(t >> r & 1) === 1 && (n ^=
|
|
1916
|
+
for (let r = 0; r < Un.length; r++)
|
|
1917
|
+
(t >> r & 1) === 1 && (n ^= Un[r]);
|
|
1918
1918
|
return n;
|
|
1919
1919
|
}
|
|
1920
|
-
function
|
|
1920
|
+
function In(e, t, n = 1) {
|
|
1921
1921
|
const r = e.length;
|
|
1922
1922
|
let i = 1;
|
|
1923
1923
|
for (let s = 0; s < r; s++) {
|
|
@@ -1933,10 +1933,10 @@ function _n(e, t, n = 1) {
|
|
|
1933
1933
|
i = Fe(i) ^ s;
|
|
1934
1934
|
for (let s = 0; s < 6; s++)
|
|
1935
1935
|
i = Fe(i);
|
|
1936
|
-
return i ^= n,
|
|
1936
|
+
return i ^= n, jt.encode(qt([i % 2 ** 30], 30, 5, !1));
|
|
1937
1937
|
}
|
|
1938
|
-
function
|
|
1939
|
-
const t = e === "bech32" ? 1 : 734539939, n = Ae(5), r = n.decode, i = n.encode, s =
|
|
1938
|
+
function lr(e) {
|
|
1939
|
+
const t = e === "bech32" ? 1 : 734539939, n = Ae(5), r = n.decode, i = n.encode, s = Cn(r);
|
|
1940
1940
|
function o(f, u, d = 90) {
|
|
1941
1941
|
if (typeof f != "string")
|
|
1942
1942
|
throw new Error(`bech32.encode prefix should be string, not ${typeof f}`);
|
|
@@ -1945,7 +1945,7 @@ function ur(e) {
|
|
|
1945
1945
|
const p = f.length + 7 + u.length;
|
|
1946
1946
|
if (d !== !1 && p > d)
|
|
1947
1947
|
throw new TypeError(`Length ${p} exceeds limit ${d}`);
|
|
1948
|
-
return f = f.toLowerCase(), `${f}1${
|
|
1948
|
+
return f = f.toLowerCase(), `${f}1${jt.encode(u)}${In(f, u, t)}`;
|
|
1949
1949
|
}
|
|
1950
1950
|
function a(f, u = 90) {
|
|
1951
1951
|
if (typeof f != "string")
|
|
@@ -1962,65 +1962,65 @@ function ur(e) {
|
|
|
1962
1962
|
const g = f.slice(0, p), h = f.slice(p + 1);
|
|
1963
1963
|
if (h.length < 6)
|
|
1964
1964
|
throw new Error("Data must be at least 6 characters long");
|
|
1965
|
-
const y =
|
|
1965
|
+
const y = jt.decode(h).slice(0, -6), w = In(g, y, t);
|
|
1966
1966
|
if (!h.endsWith(w))
|
|
1967
1967
|
throw new Error(`Invalid checksum in ${f}: expected "${w}"`);
|
|
1968
1968
|
return { prefix: g, words: y };
|
|
1969
1969
|
}
|
|
1970
|
-
const c =
|
|
1970
|
+
const c = Cn(a);
|
|
1971
1971
|
function l(f) {
|
|
1972
1972
|
const { prefix: u, words: d } = a(f, !1);
|
|
1973
1973
|
return { prefix: u, words: d, bytes: r(d) };
|
|
1974
1974
|
}
|
|
1975
1975
|
return { encode: o, decode: a, decodeToBytes: l, decodeUnsafe: c, fromWords: r, fromWordsUnsafe: s, toWords: i };
|
|
1976
1976
|
}
|
|
1977
|
-
const je =
|
|
1978
|
-
|
|
1979
|
-
const
|
|
1977
|
+
const je = lr("bech32");
|
|
1978
|
+
lr("bech32m");
|
|
1979
|
+
const ws = {
|
|
1980
1980
|
encode: (e) => new TextDecoder().decode(e),
|
|
1981
1981
|
decode: (e) => new TextEncoder().encode(e)
|
|
1982
|
-
},
|
|
1982
|
+
}, bs = fe(Ae(4), he("0123456789abcdef"), de(""), ar((e) => {
|
|
1983
1983
|
if (typeof e != "string" || e.length % 2)
|
|
1984
1984
|
throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);
|
|
1985
1985
|
return e.toLowerCase();
|
|
1986
|
-
})),
|
|
1987
|
-
utf8:
|
|
1988
|
-
hex:
|
|
1989
|
-
base16:
|
|
1990
|
-
base32:
|
|
1986
|
+
})), vs = {
|
|
1987
|
+
utf8: ws,
|
|
1988
|
+
hex: bs,
|
|
1989
|
+
base16: ds,
|
|
1990
|
+
base32: ys,
|
|
1991
1991
|
base64: ue,
|
|
1992
|
-
base64url:
|
|
1993
|
-
base58:
|
|
1994
|
-
base58xmr:
|
|
1992
|
+
base64url: ps,
|
|
1993
|
+
base58: Dt,
|
|
1994
|
+
base58xmr: gs
|
|
1995
1995
|
};
|
|
1996
|
-
`${Object.keys(
|
|
1997
|
-
function
|
|
1996
|
+
`${Object.keys(vs).join(", ")}`;
|
|
1997
|
+
function Ut(e) {
|
|
1998
1998
|
if (!Number.isSafeInteger(e) || e < 0)
|
|
1999
1999
|
throw new Error(`positive integer expected, not ${e}`);
|
|
2000
2000
|
}
|
|
2001
|
-
function
|
|
2001
|
+
function _n(e) {
|
|
2002
2002
|
if (typeof e != "boolean")
|
|
2003
2003
|
throw new Error(`boolean expected, not ${e}`);
|
|
2004
2004
|
}
|
|
2005
|
-
function
|
|
2005
|
+
function ms(e) {
|
|
2006
2006
|
return e instanceof Uint8Array || e != null && typeof e == "object" && e.constructor.name === "Uint8Array";
|
|
2007
2007
|
}
|
|
2008
2008
|
function le(e, ...t) {
|
|
2009
|
-
if (!
|
|
2009
|
+
if (!ms(e))
|
|
2010
2010
|
throw new Error("Uint8Array expected");
|
|
2011
2011
|
if (t.length > 0 && !t.includes(e.length))
|
|
2012
2012
|
throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`);
|
|
2013
2013
|
}
|
|
2014
2014
|
/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */
|
|
2015
|
-
const F = (e) => new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4)),
|
|
2016
|
-
if (!
|
|
2015
|
+
const F = (e) => new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4)), Es = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
2016
|
+
if (!Es)
|
|
2017
2017
|
throw new Error("Non little-endian hardware is not supported");
|
|
2018
|
-
function
|
|
2018
|
+
function xs(e, t) {
|
|
2019
2019
|
if (t == null || typeof t != "object")
|
|
2020
2020
|
throw new Error("options must be defined");
|
|
2021
2021
|
return Object.assign(e, t);
|
|
2022
2022
|
}
|
|
2023
|
-
function
|
|
2023
|
+
function Ss(e, t) {
|
|
2024
2024
|
if (e.length !== t.length)
|
|
2025
2025
|
return !1;
|
|
2026
2026
|
let n = 0;
|
|
@@ -2028,19 +2028,19 @@ function As(e, t) {
|
|
|
2028
2028
|
n |= e[r] ^ t[r];
|
|
2029
2029
|
return n === 0;
|
|
2030
2030
|
}
|
|
2031
|
-
const
|
|
2032
|
-
function
|
|
2033
|
-
return e << 1 ^
|
|
2031
|
+
const As = /* @__NO_SIDE_EFFECTS__ */ (e, t) => (Object.assign(t, e), t), Ee = 16, Ks = 283;
|
|
2032
|
+
function tn(e) {
|
|
2033
|
+
return e << 1 ^ Ks & -(e >> 7);
|
|
2034
2034
|
}
|
|
2035
2035
|
function Pe(e, t) {
|
|
2036
2036
|
let n = 0;
|
|
2037
2037
|
for (; t > 0; t >>= 1)
|
|
2038
|
-
n ^= e & -(t & 1), e =
|
|
2038
|
+
n ^= e & -(t & 1), e = tn(e);
|
|
2039
2039
|
return n;
|
|
2040
2040
|
}
|
|
2041
|
-
const
|
|
2041
|
+
const Vt = /* @__PURE__ */ (() => {
|
|
2042
2042
|
let e = new Uint8Array(256);
|
|
2043
|
-
for (let n = 0, r = 1; n < 256; n++, r ^=
|
|
2043
|
+
for (let n = 0, r = 1; n < 256; n++, r ^= tn(r))
|
|
2044
2044
|
e[n] = r;
|
|
2045
2045
|
const t = new Uint8Array(256);
|
|
2046
2046
|
t[0] = 99;
|
|
@@ -2049,11 +2049,11 @@ const zt = /* @__PURE__ */ (() => {
|
|
|
2049
2049
|
r |= r << 8, t[e[n]] = (r ^ r >> 4 ^ r >> 5 ^ r >> 6 ^ r >> 7 ^ 99) & 255;
|
|
2050
2050
|
}
|
|
2051
2051
|
return t;
|
|
2052
|
-
})(),
|
|
2053
|
-
function
|
|
2052
|
+
})(), Ns = /* @__PURE__ */ Vt.map((e, t) => Vt.indexOf(t)), Bs = (e) => e << 24 | e >>> 8, It = (e) => e << 8 | e >>> 24;
|
|
2053
|
+
function ur(e, t) {
|
|
2054
2054
|
if (e.length !== 256)
|
|
2055
2055
|
throw new Error("Wrong sbox length");
|
|
2056
|
-
const n = new Uint32Array(256).map((l, f) => t(e[f])), r = n.map(
|
|
2056
|
+
const n = new Uint32Array(256).map((l, f) => t(e[f])), r = n.map(It), i = r.map(It), s = i.map(It), o = new Uint32Array(256 * 256), a = new Uint32Array(256 * 256), c = new Uint16Array(256 * 256);
|
|
2057
2057
|
for (let l = 0; l < 256; l++)
|
|
2058
2058
|
for (let f = 0; f < 256; f++) {
|
|
2059
2059
|
const u = l * 256 + f;
|
|
@@ -2061,27 +2061,27 @@ function fr(e, t) {
|
|
|
2061
2061
|
}
|
|
2062
2062
|
return { sbox: e, sbox2: c, T0: n, T1: r, T2: i, T3: s, T01: o, T23: a };
|
|
2063
2063
|
}
|
|
2064
|
-
const
|
|
2064
|
+
const nn = /* @__PURE__ */ ur(Vt, (e) => Pe(e, 3) << 24 | e << 16 | e << 8 | Pe(e, 2)), fr = /* @__PURE__ */ ur(Ns, (e) => Pe(e, 11) << 24 | Pe(e, 13) << 16 | Pe(e, 9) << 8 | Pe(e, 14)), Cs = /* @__PURE__ */ (() => {
|
|
2065
2065
|
const e = new Uint8Array(16);
|
|
2066
|
-
for (let t = 0, n = 1; t < 16; t++, n =
|
|
2066
|
+
for (let t = 0, n = 1; t < 16; t++, n = tn(n))
|
|
2067
2067
|
e[t] = n;
|
|
2068
2068
|
return e;
|
|
2069
2069
|
})();
|
|
2070
|
-
function
|
|
2070
|
+
function hr(e) {
|
|
2071
2071
|
le(e);
|
|
2072
2072
|
const t = e.length;
|
|
2073
2073
|
if (![16, 24, 32].includes(t))
|
|
2074
2074
|
throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${t}`);
|
|
2075
|
-
const { sbox2: n } =
|
|
2075
|
+
const { sbox2: n } = nn, r = F(e), i = r.length, s = (a) => oe(n, a, a, a, a), o = new Uint32Array(t + 28);
|
|
2076
2076
|
o.set(r);
|
|
2077
2077
|
for (let a = i; a < o.length; a++) {
|
|
2078
2078
|
let c = o[a - 1];
|
|
2079
|
-
a % i === 0 ? c = s(
|
|
2079
|
+
a % i === 0 ? c = s(Bs(c)) ^ Cs[a / i - 1] : i > 6 && a % i === 4 && (c = s(c)), o[a] = o[a - i] ^ c;
|
|
2080
2080
|
}
|
|
2081
2081
|
return o;
|
|
2082
2082
|
}
|
|
2083
|
-
function
|
|
2084
|
-
const t =
|
|
2083
|
+
function ks(e) {
|
|
2084
|
+
const t = hr(e), n = t.slice(), r = t.length, { sbox2: i } = nn, { T0: s, T1: o, T2: a, T3: c } = fr;
|
|
2085
2085
|
for (let l = 0; l < r; l += 4)
|
|
2086
2086
|
for (let f = 0; f < 4; f++)
|
|
2087
2087
|
n[l + f] = t[r - l - 4 + f];
|
|
@@ -2098,8 +2098,8 @@ function me(e, t, n, r, i, s) {
|
|
|
2098
2098
|
function oe(e, t, n, r, i) {
|
|
2099
2099
|
return e[t & 255 | n & 65280] | e[r >>> 16 & 255 | i >>> 16 & 65280] << 16;
|
|
2100
2100
|
}
|
|
2101
|
-
function
|
|
2102
|
-
const { sbox2: s, T01: o, T23: a } =
|
|
2101
|
+
function Ln(e, t, n, r, i) {
|
|
2102
|
+
const { sbox2: s, T01: o, T23: a } = nn;
|
|
2103
2103
|
let c = 0;
|
|
2104
2104
|
t ^= e[c++], n ^= e[c++], r ^= e[c++], i ^= e[c++];
|
|
2105
2105
|
const l = e.length / 4 - 2;
|
|
@@ -2110,8 +2110,8 @@ function Tn(e, t, n, r, i) {
|
|
|
2110
2110
|
const f = e[c++] ^ oe(s, t, n, r, i), u = e[c++] ^ oe(s, n, r, i, t), d = e[c++] ^ oe(s, r, i, t, n), p = e[c++] ^ oe(s, i, t, n, r);
|
|
2111
2111
|
return { s0: f, s1: u, s2: d, s3: p };
|
|
2112
2112
|
}
|
|
2113
|
-
function
|
|
2114
|
-
const { sbox2: s, T01: o, T23: a } =
|
|
2113
|
+
function Us(e, t, n, r, i) {
|
|
2114
|
+
const { sbox2: s, T01: o, T23: a } = fr;
|
|
2115
2115
|
let c = 0;
|
|
2116
2116
|
t ^= e[c++], n ^= e[c++], r ^= e[c++], i ^= e[c++];
|
|
2117
2117
|
const l = e.length / 4 - 2;
|
|
@@ -2122,18 +2122,18 @@ function Is(e, t, n, r, i) {
|
|
|
2122
2122
|
const f = e[c++] ^ oe(s, t, i, r, n), u = e[c++] ^ oe(s, n, t, i, r), d = e[c++] ^ oe(s, r, n, t, i), p = e[c++] ^ oe(s, i, r, n, t);
|
|
2123
2123
|
return { s0: f, s1: u, s2: d, s3: p };
|
|
2124
2124
|
}
|
|
2125
|
-
function
|
|
2125
|
+
function dr(e, t) {
|
|
2126
2126
|
if (!t)
|
|
2127
2127
|
return new Uint8Array(e);
|
|
2128
2128
|
if (le(t), t.length < e)
|
|
2129
2129
|
throw new Error(`aes: wrong destination length, expected at least ${e}, got: ${t.length}`);
|
|
2130
2130
|
return t;
|
|
2131
2131
|
}
|
|
2132
|
-
function
|
|
2132
|
+
function Is(e) {
|
|
2133
2133
|
if (le(e), e.length % Ee !== 0)
|
|
2134
2134
|
throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${Ee}`);
|
|
2135
2135
|
}
|
|
2136
|
-
function
|
|
2136
|
+
function _s(e, t, n) {
|
|
2137
2137
|
let r = e.length;
|
|
2138
2138
|
const i = r % Ee;
|
|
2139
2139
|
if (!t && i !== 0)
|
|
@@ -2143,10 +2143,10 @@ function Ls(e, t, n) {
|
|
|
2143
2143
|
let c = Ee - i;
|
|
2144
2144
|
c || (c = Ee), r = r + c;
|
|
2145
2145
|
}
|
|
2146
|
-
const o =
|
|
2146
|
+
const o = dr(r, n), a = F(o);
|
|
2147
2147
|
return { b: s, o: a, out: o };
|
|
2148
2148
|
}
|
|
2149
|
-
function
|
|
2149
|
+
function Ls(e, t) {
|
|
2150
2150
|
if (!t)
|
|
2151
2151
|
return e;
|
|
2152
2152
|
const n = e.length;
|
|
@@ -2161,7 +2161,7 @@ function Ts(e, t) {
|
|
|
2161
2161
|
throw new Error("aes/pcks5: wrong padding");
|
|
2162
2162
|
return i;
|
|
2163
2163
|
}
|
|
2164
|
-
function
|
|
2164
|
+
function Ts(e) {
|
|
2165
2165
|
const t = new Uint8Array(16), n = F(t);
|
|
2166
2166
|
t.set(e);
|
|
2167
2167
|
const r = Ee - e.length;
|
|
@@ -2169,56 +2169,56 @@ function $s(e) {
|
|
|
2169
2169
|
t[i] = r;
|
|
2170
2170
|
return n;
|
|
2171
2171
|
}
|
|
2172
|
-
const
|
|
2172
|
+
const yr = /* @__PURE__ */ As({ blockSize: 16, nonceLength: 16 }, function(t, n, r = {}) {
|
|
2173
2173
|
le(t), le(n, 16);
|
|
2174
2174
|
const i = !r.disablePadding;
|
|
2175
2175
|
return {
|
|
2176
2176
|
encrypt: (s, o) => {
|
|
2177
|
-
const a =
|
|
2177
|
+
const a = hr(t), { b: c, o: l, out: f } = _s(s, i, o), u = F(n);
|
|
2178
2178
|
let d = u[0], p = u[1], g = u[2], h = u[3], y = 0;
|
|
2179
2179
|
for (; y + 4 <= c.length; )
|
|
2180
|
-
d ^= c[y + 0], p ^= c[y + 1], g ^= c[y + 2], h ^= c[y + 3], { s0: d, s1: p, s2: g, s3: h } =
|
|
2180
|
+
d ^= c[y + 0], p ^= c[y + 1], g ^= c[y + 2], h ^= c[y + 3], { s0: d, s1: p, s2: g, s3: h } = Ln(a, d, p, g, h), l[y++] = d, l[y++] = p, l[y++] = g, l[y++] = h;
|
|
2181
2181
|
if (i) {
|
|
2182
|
-
const w =
|
|
2183
|
-
d ^= w[0], p ^= w[1], g ^= w[2], h ^= w[3], { s0: d, s1: p, s2: g, s3: h } =
|
|
2182
|
+
const w = Ts(s.subarray(y * 4));
|
|
2183
|
+
d ^= w[0], p ^= w[1], g ^= w[2], h ^= w[3], { s0: d, s1: p, s2: g, s3: h } = Ln(a, d, p, g, h), l[y++] = d, l[y++] = p, l[y++] = g, l[y++] = h;
|
|
2184
2184
|
}
|
|
2185
2185
|
return a.fill(0), f;
|
|
2186
2186
|
},
|
|
2187
2187
|
decrypt: (s, o) => {
|
|
2188
|
-
|
|
2189
|
-
const a =
|
|
2188
|
+
Is(s);
|
|
2189
|
+
const a = ks(t), c = F(n), l = dr(s.length, o), f = F(s), u = F(l);
|
|
2190
2190
|
let d = c[0], p = c[1], g = c[2], h = c[3];
|
|
2191
2191
|
for (let y = 0; y + 4 <= f.length; ) {
|
|
2192
2192
|
const w = d, E = p, K = g, I = h;
|
|
2193
2193
|
d = f[y + 0], p = f[y + 1], g = f[y + 2], h = f[y + 3];
|
|
2194
|
-
const { s0: C, s1: m, s2: x, s3: S } =
|
|
2194
|
+
const { s0: C, s1: m, s2: x, s3: S } = Us(a, d, p, g, h);
|
|
2195
2195
|
u[y++] = C ^ w, u[y++] = m ^ E, u[y++] = x ^ K, u[y++] = S ^ I;
|
|
2196
2196
|
}
|
|
2197
|
-
return a.fill(0),
|
|
2197
|
+
return a.fill(0), Ls(l, i);
|
|
2198
2198
|
}
|
|
2199
2199
|
};
|
|
2200
|
-
}),
|
|
2201
|
-
|
|
2200
|
+
}), pr = (e) => Uint8Array.from(e.split("").map((t) => t.charCodeAt(0))), $s = pr("expand 16-byte k"), Rs = pr("expand 32-byte k"), Os = F($s), gr = F(Rs);
|
|
2201
|
+
gr.slice();
|
|
2202
2202
|
function L(e, t) {
|
|
2203
2203
|
return e << t | e >>> 32 - t;
|
|
2204
2204
|
}
|
|
2205
|
-
function
|
|
2205
|
+
function zt(e) {
|
|
2206
2206
|
return e.byteOffset % 4 === 0;
|
|
2207
2207
|
}
|
|
2208
|
-
const
|
|
2209
|
-
function
|
|
2210
|
-
const c = i.length, l = new Uint8Array(
|
|
2208
|
+
const Xe = 64, Ps = 16, wr = 2 ** 32 - 1, Tn = new Uint32Array();
|
|
2209
|
+
function Ms(e, t, n, r, i, s, o, a) {
|
|
2210
|
+
const c = i.length, l = new Uint8Array(Xe), f = F(l), u = zt(i) && zt(s), d = u ? F(i) : Tn, p = u ? F(s) : Tn;
|
|
2211
2211
|
for (let g = 0; g < c; o++) {
|
|
2212
|
-
if (e(t, n, r, f, o, a), o >=
|
|
2212
|
+
if (e(t, n, r, f, o, a), o >= wr)
|
|
2213
2213
|
throw new Error("arx: counter overflow");
|
|
2214
|
-
const h = Math.min(
|
|
2215
|
-
if (u && h ===
|
|
2214
|
+
const h = Math.min(Xe, c - g);
|
|
2215
|
+
if (u && h === Xe) {
|
|
2216
2216
|
const y = g / 4;
|
|
2217
2217
|
if (g % 4 !== 0)
|
|
2218
2218
|
throw new Error("arx: invalid block position");
|
|
2219
|
-
for (let w = 0, E; w <
|
|
2219
|
+
for (let w = 0, E; w < Ps; w++)
|
|
2220
2220
|
E = y + w, p[E] = d[E] ^ f[w];
|
|
2221
|
-
g +=
|
|
2221
|
+
g += Xe;
|
|
2222
2222
|
continue;
|
|
2223
2223
|
}
|
|
2224
2224
|
for (let y = 0, w; y < h; y++)
|
|
@@ -2226,26 +2226,26 @@ function Hs(e, t, n, r, i, s, o, a) {
|
|
|
2226
2226
|
g += h;
|
|
2227
2227
|
}
|
|
2228
2228
|
}
|
|
2229
|
-
function
|
|
2230
|
-
const { allowShortKeys: n, extendNonceFn: r, counterLength: i, counterRight: s, rounds: o } =
|
|
2229
|
+
function Hs(e, t) {
|
|
2230
|
+
const { allowShortKeys: n, extendNonceFn: r, counterLength: i, counterRight: s, rounds: o } = xs({ allowShortKeys: !1, counterLength: 8, counterRight: !1, rounds: 20 }, t);
|
|
2231
2231
|
if (typeof e != "function")
|
|
2232
2232
|
throw new Error("core must be a function");
|
|
2233
|
-
return
|
|
2233
|
+
return Ut(i), Ut(o), _n(s), _n(n), (a, c, l, f, u = 0) => {
|
|
2234
2234
|
le(a), le(c), le(l);
|
|
2235
2235
|
const d = l.length;
|
|
2236
|
-
if (f || (f = new Uint8Array(d)), le(f),
|
|
2236
|
+
if (f || (f = new Uint8Array(d)), le(f), Ut(u), u < 0 || u >= wr)
|
|
2237
2237
|
throw new Error("arx: counter overflow");
|
|
2238
2238
|
if (f.length < d)
|
|
2239
2239
|
throw new Error(`arx: output (${f.length}) is shorter than data (${d})`);
|
|
2240
2240
|
const p = [];
|
|
2241
2241
|
let g = a.length, h, y;
|
|
2242
2242
|
if (g === 32)
|
|
2243
|
-
h = a.slice(), p.push(h), y =
|
|
2243
|
+
h = a.slice(), p.push(h), y = gr;
|
|
2244
2244
|
else if (g === 16 && n)
|
|
2245
|
-
h = new Uint8Array(32), h.set(a), h.set(a, 16), y =
|
|
2245
|
+
h = new Uint8Array(32), h.set(a), h.set(a, 16), y = Os, p.push(h);
|
|
2246
2246
|
else
|
|
2247
2247
|
throw new Error(`arx: invalid 32-byte key, got length=${g}`);
|
|
2248
|
-
|
|
2248
|
+
zt(c) || (c = c.slice(), p.push(c));
|
|
2249
2249
|
const w = F(h);
|
|
2250
2250
|
if (r) {
|
|
2251
2251
|
if (c.length !== 24)
|
|
@@ -2260,27 +2260,27 @@ function qs(e, t) {
|
|
|
2260
2260
|
I.set(c, s ? 0 : 12 - c.length), c = I, p.push(c);
|
|
2261
2261
|
}
|
|
2262
2262
|
const K = F(c);
|
|
2263
|
-
for (
|
|
2263
|
+
for (Ms(e, y, w, K, l, f, u, o); p.length > 0; )
|
|
2264
2264
|
p.pop().fill(0);
|
|
2265
2265
|
return f;
|
|
2266
2266
|
};
|
|
2267
2267
|
}
|
|
2268
|
-
function
|
|
2268
|
+
function qs(e, t, n, r, i, s = 20) {
|
|
2269
2269
|
let o = e[0], a = e[1], c = e[2], l = e[3], f = t[0], u = t[1], d = t[2], p = t[3], g = t[4], h = t[5], y = t[6], w = t[7], E = i, K = n[0], I = n[1], C = n[2], m = o, x = a, S = c, P = l, U = f, N = u, $ = d, R = p, H = g, b = h, v = y, A = w, k = E, B = K, _ = I, O = C;
|
|
2270
2270
|
for (let X = 0; X < s; X += 2)
|
|
2271
2271
|
m = m + U | 0, k = L(k ^ m, 16), H = H + k | 0, U = L(U ^ H, 12), m = m + U | 0, k = L(k ^ m, 8), H = H + k | 0, U = L(U ^ H, 7), x = x + N | 0, B = L(B ^ x, 16), b = b + B | 0, N = L(N ^ b, 12), x = x + N | 0, B = L(B ^ x, 8), b = b + B | 0, N = L(N ^ b, 7), S = S + $ | 0, _ = L(_ ^ S, 16), v = v + _ | 0, $ = L($ ^ v, 12), S = S + $ | 0, _ = L(_ ^ S, 8), v = v + _ | 0, $ = L($ ^ v, 7), P = P + R | 0, O = L(O ^ P, 16), A = A + O | 0, R = L(R ^ A, 12), P = P + R | 0, O = L(O ^ P, 8), A = A + O | 0, R = L(R ^ A, 7), m = m + N | 0, O = L(O ^ m, 16), v = v + O | 0, N = L(N ^ v, 12), m = m + N | 0, O = L(O ^ m, 8), v = v + O | 0, N = L(N ^ v, 7), x = x + $ | 0, k = L(k ^ x, 16), A = A + k | 0, $ = L($ ^ A, 12), x = x + $ | 0, k = L(k ^ x, 8), A = A + k | 0, $ = L($ ^ A, 7), S = S + R | 0, B = L(B ^ S, 16), H = H + B | 0, R = L(R ^ H, 12), S = S + R | 0, B = L(B ^ S, 8), H = H + B | 0, R = L(R ^ H, 7), P = P + U | 0, _ = L(_ ^ P, 16), b = b + _ | 0, U = L(U ^ b, 12), P = P + U | 0, _ = L(_ ^ P, 8), b = b + _ | 0, U = L(U ^ b, 7);
|
|
2272
2272
|
let T = 0;
|
|
2273
2273
|
r[T++] = o + m | 0, r[T++] = a + x | 0, r[T++] = c + S | 0, r[T++] = l + P | 0, r[T++] = f + U | 0, r[T++] = u + N | 0, r[T++] = d + $ | 0, r[T++] = p + R | 0, r[T++] = g + H | 0, r[T++] = h + b | 0, r[T++] = y + v | 0, r[T++] = w + A | 0, r[T++] = E + k | 0, r[T++] = K + B | 0, r[T++] = I + _ | 0, r[T++] = C + O | 0;
|
|
2274
2274
|
}
|
|
2275
|
-
const
|
|
2275
|
+
const br = /* @__PURE__ */ Hs(qs, {
|
|
2276
2276
|
counterRight: !1,
|
|
2277
2277
|
counterLength: 4,
|
|
2278
2278
|
allowShortKeys: !1
|
|
2279
2279
|
});
|
|
2280
|
-
class
|
|
2280
|
+
class vr extends nr {
|
|
2281
2281
|
constructor(t, n) {
|
|
2282
2282
|
super(), this.finished = !1, this.destroyed = !1, se.hash(t);
|
|
2283
|
-
const r =
|
|
2283
|
+
const r = Ge(n);
|
|
2284
2284
|
if (this.iHash = t.create(), typeof this.iHash.update != "function")
|
|
2285
2285
|
throw new Error("Expected instance of class which extends utils.Hash");
|
|
2286
2286
|
this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
|
|
@@ -2312,28 +2312,28 @@ class mr extends rr {
|
|
|
2312
2312
|
this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
|
|
2313
2313
|
}
|
|
2314
2314
|
}
|
|
2315
|
-
const
|
|
2316
|
-
|
|
2317
|
-
function
|
|
2318
|
-
return se.hash(e), n === void 0 && (n = new Uint8Array(e.outputLen)),
|
|
2315
|
+
const yt = (e, t, n) => new vr(e, t).update(n).digest();
|
|
2316
|
+
yt.create = (e, t) => new vr(e, t);
|
|
2317
|
+
function rn(e, t, n) {
|
|
2318
|
+
return se.hash(e), n === void 0 && (n = new Uint8Array(e.outputLen)), yt(e, Ge(n), Ge(t));
|
|
2319
2319
|
}
|
|
2320
|
-
const
|
|
2321
|
-
function
|
|
2320
|
+
const _t = new Uint8Array([0]), $n = new Uint8Array();
|
|
2321
|
+
function mr(e, t, n, r = 32) {
|
|
2322
2322
|
if (se.hash(e), se.number(r), r > 255 * e.outputLen)
|
|
2323
2323
|
throw new Error("Length should be <= 255*HashLen");
|
|
2324
2324
|
const i = Math.ceil(r / e.outputLen);
|
|
2325
|
-
n === void 0 && (n =
|
|
2326
|
-
const s = new Uint8Array(i * e.outputLen), o =
|
|
2325
|
+
n === void 0 && (n = $n);
|
|
2326
|
+
const s = new Uint8Array(i * e.outputLen), o = yt.create(e, t), a = o._cloneInto(), c = new Uint8Array(o.outputLen);
|
|
2327
2327
|
for (let l = 0; l < i; l++)
|
|
2328
|
-
|
|
2329
|
-
return o.destroy(), a.destroy(), c.fill(0),
|
|
2328
|
+
_t[0] = l + 1, a.update(l === 0 ? $n : c).update(n).update(_t).digestInto(c), s.set(c, e.outputLen * l), o._cloneInto(a);
|
|
2329
|
+
return o.destroy(), a.destroy(), c.fill(0), _t.fill(0), s.slice(0, r);
|
|
2330
2330
|
}
|
|
2331
|
-
var
|
|
2331
|
+
var Ds = Object.defineProperty, D = (e, t) => {
|
|
2332
2332
|
for (var n in t)
|
|
2333
|
-
|
|
2334
|
-
}, $e = Symbol("verified"),
|
|
2335
|
-
function
|
|
2336
|
-
if (!
|
|
2333
|
+
Ds(e, n, { get: t[n], enumerable: !0 });
|
|
2334
|
+
}, $e = Symbol("verified"), js = (e) => e instanceof Object;
|
|
2335
|
+
function Er(e) {
|
|
2336
|
+
if (!js(e) || typeof e.kind != "number" || typeof e.content != "string" || typeof e.created_at != "number" || typeof e.pubkey != "string" || !e.pubkey.match(/^[a-f0-9]{64}$/) || !Array.isArray(e.tags))
|
|
2337
2337
|
return !1;
|
|
2338
2338
|
for (let t = 0; t < e.tags.length; t++) {
|
|
2339
2339
|
let n = e.tags[t];
|
|
@@ -2345,32 +2345,32 @@ function xr(e) {
|
|
|
2345
2345
|
}
|
|
2346
2346
|
return !0;
|
|
2347
2347
|
}
|
|
2348
|
-
var
|
|
2349
|
-
D(
|
|
2350
|
-
Queue: () =>
|
|
2351
|
-
QueueNode: () =>
|
|
2352
|
-
binarySearch: () =>
|
|
2353
|
-
insertEventIntoAscendingList: () =>
|
|
2354
|
-
insertEventIntoDescendingList: () =>
|
|
2355
|
-
normalizeURL: () =>
|
|
2348
|
+
var Vs = {};
|
|
2349
|
+
D(Vs, {
|
|
2350
|
+
Queue: () => Ws,
|
|
2351
|
+
QueueNode: () => xr,
|
|
2352
|
+
binarySearch: () => sn,
|
|
2353
|
+
insertEventIntoAscendingList: () => Fs,
|
|
2354
|
+
insertEventIntoDescendingList: () => Zs,
|
|
2355
|
+
normalizeURL: () => zs,
|
|
2356
2356
|
utf8Decoder: () => ie,
|
|
2357
2357
|
utf8Encoder: () => te
|
|
2358
2358
|
});
|
|
2359
2359
|
var ie = new TextDecoder("utf-8"), te = new TextEncoder();
|
|
2360
|
-
function
|
|
2360
|
+
function zs(e) {
|
|
2361
2361
|
e.indexOf("://") === -1 && (e = "wss://" + e);
|
|
2362
2362
|
let t = new URL(e);
|
|
2363
2363
|
return t.pathname = t.pathname.replace(/\/+/g, "/"), t.pathname.endsWith("/") && (t.pathname = t.pathname.slice(0, -1)), (t.port === "80" && t.protocol === "ws:" || t.port === "443" && t.protocol === "wss:") && (t.port = ""), t.searchParams.sort(), t.hash = "", t.toString();
|
|
2364
2364
|
}
|
|
2365
|
-
function
|
|
2366
|
-
const [n, r] =
|
|
2365
|
+
function Zs(e, t) {
|
|
2366
|
+
const [n, r] = sn(e, (i) => t.id === i.id ? 0 : t.created_at === i.created_at ? -1 : i.created_at - t.created_at);
|
|
2367
2367
|
return r || e.splice(n, 0, t), e;
|
|
2368
2368
|
}
|
|
2369
|
-
function
|
|
2370
|
-
const [n, r] =
|
|
2369
|
+
function Fs(e, t) {
|
|
2370
|
+
const [n, r] = sn(e, (i) => t.id === i.id ? 0 : t.created_at === i.created_at ? -1 : t.created_at - i.created_at);
|
|
2371
2371
|
return r || e.splice(n, 0, t), e;
|
|
2372
2372
|
}
|
|
2373
|
-
function
|
|
2373
|
+
function sn(e, t) {
|
|
2374
2374
|
let n = 0, r = e.length - 1;
|
|
2375
2375
|
for (; n <= r; ) {
|
|
2376
2376
|
const i = Math.floor((n + r) / 2), s = t(e[i]);
|
|
@@ -2380,21 +2380,21 @@ function on(e, t) {
|
|
|
2380
2380
|
}
|
|
2381
2381
|
return [n, !1];
|
|
2382
2382
|
}
|
|
2383
|
-
var
|
|
2383
|
+
var xr = class {
|
|
2384
2384
|
constructor(e) {
|
|
2385
2385
|
ee(this, "value");
|
|
2386
2386
|
ee(this, "next", null);
|
|
2387
2387
|
ee(this, "prev", null);
|
|
2388
2388
|
this.value = e;
|
|
2389
2389
|
}
|
|
2390
|
-
},
|
|
2390
|
+
}, Ws = class {
|
|
2391
2391
|
constructor() {
|
|
2392
2392
|
ee(this, "first");
|
|
2393
2393
|
ee(this, "last");
|
|
2394
2394
|
this.first = null, this.last = null;
|
|
2395
2395
|
}
|
|
2396
2396
|
enqueue(e) {
|
|
2397
|
-
const t = new
|
|
2397
|
+
const t = new xr(e);
|
|
2398
2398
|
return this.last ? this.last === this.first ? (this.last = t, this.last.prev = this.first, this.first.next = t) : (t.prev = this.last, this.last.next = t, this.last = t) : (this.first = t, this.last = t), !0;
|
|
2399
2399
|
}
|
|
2400
2400
|
dequeue() {
|
|
@@ -2407,7 +2407,7 @@ var Sr = class {
|
|
|
2407
2407
|
const e = this.first;
|
|
2408
2408
|
return this.first = e.next, e.value;
|
|
2409
2409
|
}
|
|
2410
|
-
},
|
|
2410
|
+
}, Gs = class {
|
|
2411
2411
|
generateSecretKey() {
|
|
2412
2412
|
return Ze.utils.randomPrivateKey();
|
|
2413
2413
|
}
|
|
@@ -2416,12 +2416,12 @@ var Sr = class {
|
|
|
2416
2416
|
}
|
|
2417
2417
|
finalizeEvent(e, t) {
|
|
2418
2418
|
const n = e;
|
|
2419
|
-
return n.pubkey = M(Ze.getPublicKey(t)), n.id =
|
|
2419
|
+
return n.pubkey = M(Ze.getPublicKey(t)), n.id = tt(n), n.sig = M(Ze.sign(tt(n), t)), n[$e] = !0, n;
|
|
2420
2420
|
}
|
|
2421
2421
|
verifyEvent(e) {
|
|
2422
2422
|
if (typeof e[$e] == "boolean")
|
|
2423
2423
|
return e[$e];
|
|
2424
|
-
const t =
|
|
2424
|
+
const t = tt(e);
|
|
2425
2425
|
if (t !== e.id)
|
|
2426
2426
|
return e[$e] = !1, !1;
|
|
2427
2427
|
try {
|
|
@@ -2432,130 +2432,130 @@ var Sr = class {
|
|
|
2432
2432
|
}
|
|
2433
2433
|
}
|
|
2434
2434
|
};
|
|
2435
|
-
function
|
|
2436
|
-
if (!
|
|
2435
|
+
function Js(e) {
|
|
2436
|
+
if (!Er(e))
|
|
2437
2437
|
throw new Error("can't serialize event with wrong or missing properties");
|
|
2438
2438
|
return JSON.stringify([0, e.pubkey, e.created_at, e.kind, e.tags, e.content]);
|
|
2439
2439
|
}
|
|
2440
|
-
function
|
|
2441
|
-
let t = Se(te.encode(
|
|
2440
|
+
function tt(e) {
|
|
2441
|
+
let t = Se(te.encode(Js(e)));
|
|
2442
2442
|
return M(t);
|
|
2443
2443
|
}
|
|
2444
|
-
var
|
|
2445
|
-
D(
|
|
2446
|
-
Application: () =>
|
|
2447
|
-
BadgeAward: () =>
|
|
2448
|
-
BadgeDefinition: () =>
|
|
2449
|
-
BlockedRelaysList: () =>
|
|
2450
|
-
BookmarkList: () =>
|
|
2451
|
-
Bookmarksets: () =>
|
|
2452
|
-
Calendar: () =>
|
|
2453
|
-
CalendarEventRSVP: () =>
|
|
2454
|
-
ChannelCreation: () =>
|
|
2455
|
-
ChannelHideMessage: () =>
|
|
2456
|
-
ChannelMessage: () =>
|
|
2457
|
-
ChannelMetadata: () =>
|
|
2458
|
-
ChannelMuteUser: () =>
|
|
2459
|
-
ClassifiedListing: () =>
|
|
2460
|
-
ClientAuth: () =>
|
|
2461
|
-
CommunitiesList: () =>
|
|
2462
|
-
CommunityDefinition: () =>
|
|
2463
|
-
CommunityPostApproval: () =>
|
|
2464
|
-
Contacts: () =>
|
|
2465
|
-
CreateOrUpdateProduct: () =>
|
|
2466
|
-
CreateOrUpdateStall: () =>
|
|
2467
|
-
Curationsets: () =>
|
|
2468
|
-
Date: () =>
|
|
2469
|
-
DraftClassifiedListing: () =>
|
|
2470
|
-
DraftLong: () =>
|
|
2471
|
-
Emojisets: () =>
|
|
2472
|
-
EncryptedDirectMessage: () =>
|
|
2473
|
-
EncryptedDirectMessages: () =>
|
|
2474
|
-
EventDeletion: () =>
|
|
2475
|
-
FileMetadata: () =>
|
|
2476
|
-
FileServerPreference: () =>
|
|
2477
|
-
Followsets: () =>
|
|
2478
|
-
GenericRepost: () =>
|
|
2479
|
-
Genericlists: () =>
|
|
2480
|
-
HTTPAuth: () =>
|
|
2481
|
-
Handlerinformation: () =>
|
|
2482
|
-
Handlerrecommendation: () =>
|
|
2483
|
-
Highlights: () =>
|
|
2484
|
-
InterestsList: () =>
|
|
2485
|
-
Interestsets: () =>
|
|
2486
|
-
JobFeedback: () =>
|
|
2487
|
-
JobRequest: () =>
|
|
2488
|
-
JobResult: () =>
|
|
2489
|
-
Label: () =>
|
|
2490
|
-
LightningPubRPC: () =>
|
|
2491
|
-
LiveChatMessage: () =>
|
|
2492
|
-
LiveEvent: () =>
|
|
2493
|
-
LongFormArticle: () =>
|
|
2494
|
-
Metadata: () =>
|
|
2495
|
-
Mutelist: () =>
|
|
2496
|
-
NWCWalletInfo: () =>
|
|
2497
|
-
NWCWalletRequest: () =>
|
|
2498
|
-
NWCWalletResponse: () =>
|
|
2499
|
-
NostrConnect: () =>
|
|
2500
|
-
OpenTimestamps: () =>
|
|
2501
|
-
Pinlist: () =>
|
|
2502
|
-
ProblemTracker: () =>
|
|
2503
|
-
ProfileBadges: () =>
|
|
2504
|
-
PublicChatsList: () =>
|
|
2505
|
-
Reaction: () =>
|
|
2506
|
-
RecommendRelay: () =>
|
|
2507
|
-
RelayList: () =>
|
|
2508
|
-
Relaysets: () =>
|
|
2509
|
-
Report: () =>
|
|
2510
|
-
Reporting: () =>
|
|
2511
|
-
Repost: () =>
|
|
2512
|
-
SearchRelaysList: () =>
|
|
2513
|
-
ShortTextNote: () =>
|
|
2514
|
-
Time: () =>
|
|
2515
|
-
UserEmojiList: () =>
|
|
2516
|
-
UserStatuses: () =>
|
|
2517
|
-
Zap: () =>
|
|
2518
|
-
ZapGoal: () =>
|
|
2519
|
-
ZapRequest: () =>
|
|
2520
|
-
classifyKind: () =>
|
|
2521
|
-
isEphemeralKind: () =>
|
|
2522
|
-
isParameterizedReplaceableKind: () =>
|
|
2523
|
-
isRegularKind: () =>
|
|
2524
|
-
isReplaceableKind: () =>
|
|
2444
|
+
var pt = new Gs(), Me = pt.generateSecretKey, Ce = pt.getPublicKey, ae = pt.finalizeEvent, gt = pt.verifyEvent, Ys = {};
|
|
2445
|
+
D(Ys, {
|
|
2446
|
+
Application: () => Xo,
|
|
2447
|
+
BadgeAward: () => oo,
|
|
2448
|
+
BadgeDefinition: () => zo,
|
|
2449
|
+
BlockedRelaysList: () => Uo,
|
|
2450
|
+
BookmarkList: () => Bo,
|
|
2451
|
+
Bookmarksets: () => Do,
|
|
2452
|
+
Calendar: () => sa,
|
|
2453
|
+
CalendarEventRSVP: () => oa,
|
|
2454
|
+
ChannelCreation: () => Br,
|
|
2455
|
+
ChannelHideMessage: () => Ur,
|
|
2456
|
+
ChannelMessage: () => kr,
|
|
2457
|
+
ChannelMetadata: () => Cr,
|
|
2458
|
+
ChannelMuteUser: () => Ir,
|
|
2459
|
+
ClassifiedListing: () => ta,
|
|
2460
|
+
ClientAuth: () => _r,
|
|
2461
|
+
CommunitiesList: () => Co,
|
|
2462
|
+
CommunityDefinition: () => la,
|
|
2463
|
+
CommunityPostApproval: () => go,
|
|
2464
|
+
Contacts: () => no,
|
|
2465
|
+
CreateOrUpdateProduct: () => Wo,
|
|
2466
|
+
CreateOrUpdateStall: () => Fo,
|
|
2467
|
+
Curationsets: () => jo,
|
|
2468
|
+
Date: () => ra,
|
|
2469
|
+
DraftClassifiedListing: () => na,
|
|
2470
|
+
DraftLong: () => Jo,
|
|
2471
|
+
Emojisets: () => Yo,
|
|
2472
|
+
EncryptedDirectMessage: () => ro,
|
|
2473
|
+
EncryptedDirectMessages: () => io,
|
|
2474
|
+
EventDeletion: () => so,
|
|
2475
|
+
FileMetadata: () => lo,
|
|
2476
|
+
FileServerPreference: () => To,
|
|
2477
|
+
Followsets: () => Mo,
|
|
2478
|
+
GenericRepost: () => ao,
|
|
2479
|
+
Genericlists: () => Ho,
|
|
2480
|
+
HTTPAuth: () => cn,
|
|
2481
|
+
Handlerinformation: () => ca,
|
|
2482
|
+
Handlerrecommendation: () => aa,
|
|
2483
|
+
Highlights: () => So,
|
|
2484
|
+
InterestsList: () => _o,
|
|
2485
|
+
Interestsets: () => Zo,
|
|
2486
|
+
JobFeedback: () => vo,
|
|
2487
|
+
JobRequest: () => wo,
|
|
2488
|
+
JobResult: () => bo,
|
|
2489
|
+
Label: () => po,
|
|
2490
|
+
LightningPubRPC: () => Ro,
|
|
2491
|
+
LiveChatMessage: () => uo,
|
|
2492
|
+
LiveEvent: () => Qo,
|
|
2493
|
+
LongFormArticle: () => Go,
|
|
2494
|
+
Metadata: () => Qs,
|
|
2495
|
+
Mutelist: () => Ao,
|
|
2496
|
+
NWCWalletInfo: () => $o,
|
|
2497
|
+
NWCWalletRequest: () => Lr,
|
|
2498
|
+
NWCWalletResponse: () => Oo,
|
|
2499
|
+
NostrConnect: () => Po,
|
|
2500
|
+
OpenTimestamps: () => co,
|
|
2501
|
+
Pinlist: () => Ko,
|
|
2502
|
+
ProblemTracker: () => fo,
|
|
2503
|
+
ProfileBadges: () => Vo,
|
|
2504
|
+
PublicChatsList: () => ko,
|
|
2505
|
+
Reaction: () => an,
|
|
2506
|
+
RecommendRelay: () => to,
|
|
2507
|
+
RelayList: () => No,
|
|
2508
|
+
Relaysets: () => qo,
|
|
2509
|
+
Report: () => ho,
|
|
2510
|
+
Reporting: () => yo,
|
|
2511
|
+
Repost: () => on,
|
|
2512
|
+
SearchRelaysList: () => Io,
|
|
2513
|
+
ShortTextNote: () => eo,
|
|
2514
|
+
Time: () => ia,
|
|
2515
|
+
UserEmojiList: () => Lo,
|
|
2516
|
+
UserStatuses: () => ea,
|
|
2517
|
+
Zap: () => xo,
|
|
2518
|
+
ZapGoal: () => mo,
|
|
2519
|
+
ZapRequest: () => Eo,
|
|
2520
|
+
classifyKind: () => Xs,
|
|
2521
|
+
isEphemeralKind: () => Kr,
|
|
2522
|
+
isParameterizedReplaceableKind: () => Nr,
|
|
2523
|
+
isRegularKind: () => Sr,
|
|
2524
|
+
isReplaceableKind: () => Ar
|
|
2525
2525
|
});
|
|
2526
|
-
function
|
|
2526
|
+
function Sr(e) {
|
|
2527
2527
|
return 1e3 <= e && e < 1e4 || [1, 2, 4, 5, 6, 7, 8, 16, 40, 41, 42, 43, 44].includes(e);
|
|
2528
2528
|
}
|
|
2529
|
-
function
|
|
2529
|
+
function Ar(e) {
|
|
2530
2530
|
return [0, 3].includes(e) || 1e4 <= e && e < 2e4;
|
|
2531
2531
|
}
|
|
2532
|
-
function
|
|
2532
|
+
function Kr(e) {
|
|
2533
2533
|
return 2e4 <= e && e < 3e4;
|
|
2534
2534
|
}
|
|
2535
|
-
function
|
|
2535
|
+
function Nr(e) {
|
|
2536
2536
|
return 3e4 <= e && e < 4e4;
|
|
2537
2537
|
}
|
|
2538
|
-
function
|
|
2539
|
-
return
|
|
2540
|
-
}
|
|
2541
|
-
var
|
|
2542
|
-
D(
|
|
2543
|
-
getHex64: () =>
|
|
2544
|
-
getInt: () =>
|
|
2545
|
-
getSubscriptionId: () =>
|
|
2546
|
-
matchEventId: () =>
|
|
2547
|
-
matchEventKind: () =>
|
|
2548
|
-
matchEventPubkey: () =>
|
|
2538
|
+
function Xs(e) {
|
|
2539
|
+
return Sr(e) ? "regular" : Ar(e) ? "replaceable" : Kr(e) ? "ephemeral" : Nr(e) ? "parameterized" : "unknown";
|
|
2540
|
+
}
|
|
2541
|
+
var Qs = 0, eo = 1, to = 2, no = 3, ro = 4, io = 4, so = 5, on = 6, an = 7, oo = 8, ao = 16, Br = 40, Cr = 41, kr = 42, Ur = 43, Ir = 44, co = 1040, lo = 1063, uo = 1311, fo = 1971, ho = 1984, yo = 1984, po = 1985, go = 4550, wo = 5999, bo = 6999, vo = 7e3, mo = 9041, Eo = 9734, xo = 9735, So = 9802, Ao = 1e4, Ko = 10001, No = 10002, Bo = 10003, Co = 10004, ko = 10005, Uo = 10006, Io = 10007, _o = 10015, Lo = 10030, To = 10096, $o = 13194, Ro = 21e3, _r = 22242, Lr = 23194, Oo = 23195, Po = 24133, cn = 27235, Mo = 3e4, Ho = 30001, qo = 30002, Do = 30003, jo = 30004, Vo = 30008, zo = 30009, Zo = 30015, Fo = 30017, Wo = 30018, Go = 30023, Jo = 30024, Yo = 30030, Xo = 30078, Qo = 30311, ea = 30315, ta = 30402, na = 30403, ra = 31922, ia = 31923, sa = 31924, oa = 31925, aa = 31989, ca = 31990, la = 34550, ua = {};
|
|
2542
|
+
D(ua, {
|
|
2543
|
+
getHex64: () => ln,
|
|
2544
|
+
getInt: () => Tr,
|
|
2545
|
+
getSubscriptionId: () => fa,
|
|
2546
|
+
matchEventId: () => ha,
|
|
2547
|
+
matchEventKind: () => ya,
|
|
2548
|
+
matchEventPubkey: () => da
|
|
2549
2549
|
});
|
|
2550
|
-
function
|
|
2550
|
+
function ln(e, t) {
|
|
2551
2551
|
let n = t.length + 3, r = e.indexOf(`"${t}":`) + n, i = e.slice(r).indexOf('"') + r + 1;
|
|
2552
2552
|
return e.slice(i, i + 64);
|
|
2553
2553
|
}
|
|
2554
|
-
function
|
|
2554
|
+
function Tr(e, t) {
|
|
2555
2555
|
let n = t.length, r = e.indexOf(`"${t}":`) + n + 3, i = e.slice(r), s = Math.min(i.indexOf(","), i.indexOf("}"));
|
|
2556
2556
|
return parseInt(i.slice(0, s), 10);
|
|
2557
2557
|
}
|
|
2558
|
-
function
|
|
2558
|
+
function fa(e) {
|
|
2559
2559
|
let t = e.slice(0, 22).indexOf('"EVENT"');
|
|
2560
2560
|
if (t === -1)
|
|
2561
2561
|
return null;
|
|
@@ -2568,22 +2568,22 @@ function ha(e) {
|
|
|
2568
2568
|
let s = r + 1 + i;
|
|
2569
2569
|
return e.slice(r + 1, s);
|
|
2570
2570
|
}
|
|
2571
|
+
function ha(e, t) {
|
|
2572
|
+
return t === ln(e, "id");
|
|
2573
|
+
}
|
|
2571
2574
|
function da(e, t) {
|
|
2572
|
-
return t ===
|
|
2575
|
+
return t === ln(e, "pubkey");
|
|
2573
2576
|
}
|
|
2574
2577
|
function ya(e, t) {
|
|
2575
|
-
return t ===
|
|
2578
|
+
return t === Tr(e, "kind");
|
|
2576
2579
|
}
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
var ga = {};
|
|
2581
|
-
D(ga, {
|
|
2582
|
-
makeAuthEvent: () => wa
|
|
2580
|
+
var pa = {};
|
|
2581
|
+
D(pa, {
|
|
2582
|
+
makeAuthEvent: () => ga
|
|
2583
2583
|
});
|
|
2584
|
-
function
|
|
2584
|
+
function ga(e, t) {
|
|
2585
2585
|
return {
|
|
2586
|
-
kind:
|
|
2586
|
+
kind: _r,
|
|
2587
2587
|
created_at: Math.floor(Date.now() / 1e3),
|
|
2588
2588
|
tags: [
|
|
2589
2589
|
["relay", e],
|
|
@@ -2592,22 +2592,22 @@ function wa(e, t) {
|
|
|
2592
2592
|
content: ""
|
|
2593
2593
|
};
|
|
2594
2594
|
}
|
|
2595
|
-
var
|
|
2595
|
+
var wa;
|
|
2596
2596
|
try {
|
|
2597
|
-
|
|
2597
|
+
wa = WebSocket;
|
|
2598
2598
|
} catch {
|
|
2599
2599
|
}
|
|
2600
|
-
var
|
|
2600
|
+
var ba;
|
|
2601
2601
|
try {
|
|
2602
|
-
|
|
2602
|
+
ba = WebSocket;
|
|
2603
2603
|
} catch {
|
|
2604
2604
|
}
|
|
2605
|
-
var
|
|
2606
|
-
D(
|
|
2607
|
-
BECH32_REGEX: () =>
|
|
2608
|
-
Bech32MaxSize: () =>
|
|
2609
|
-
decode: () =>
|
|
2610
|
-
encodeBytes: () =>
|
|
2605
|
+
var va = {};
|
|
2606
|
+
D(va, {
|
|
2607
|
+
BECH32_REGEX: () => $r,
|
|
2608
|
+
Bech32MaxSize: () => un,
|
|
2609
|
+
decode: () => wt,
|
|
2610
|
+
encodeBytes: () => bt,
|
|
2611
2611
|
naddrEncode: () => Na,
|
|
2612
2612
|
neventEncode: () => Ka,
|
|
2613
2613
|
noteEncode: () => Sa,
|
|
@@ -2616,17 +2616,17 @@ D(We, {
|
|
|
2616
2616
|
nrelayEncode: () => Ba,
|
|
2617
2617
|
nsecEncode: () => Ea
|
|
2618
2618
|
});
|
|
2619
|
-
var
|
|
2619
|
+
var un = 5e3, $r = /[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;
|
|
2620
2620
|
function ma(e) {
|
|
2621
2621
|
const t = new Uint8Array(4);
|
|
2622
2622
|
return t[0] = e >> 24 & 255, t[1] = e >> 16 & 255, t[2] = e >> 8 & 255, t[3] = e & 255, t;
|
|
2623
2623
|
}
|
|
2624
|
-
function
|
|
2624
|
+
function wt(e) {
|
|
2625
2625
|
var i, s, o, a, c, l, f, u;
|
|
2626
|
-
let { prefix: t, words: n } = je.decode(e,
|
|
2626
|
+
let { prefix: t, words: n } = je.decode(e, un), r = new Uint8Array(je.fromWords(n));
|
|
2627
2627
|
switch (t) {
|
|
2628
2628
|
case "nprofile": {
|
|
2629
|
-
let d =
|
|
2629
|
+
let d = Qe(r);
|
|
2630
2630
|
if (!((i = d[0]) != null && i[0]))
|
|
2631
2631
|
throw new Error("missing TLV 0 for nprofile");
|
|
2632
2632
|
if (d[0][0].length !== 32)
|
|
@@ -2640,7 +2640,7 @@ function bt(e) {
|
|
|
2640
2640
|
};
|
|
2641
2641
|
}
|
|
2642
2642
|
case "nevent": {
|
|
2643
|
-
let d =
|
|
2643
|
+
let d = Qe(r);
|
|
2644
2644
|
if (!((s = d[0]) != null && s[0]))
|
|
2645
2645
|
throw new Error("missing TLV 0 for nevent");
|
|
2646
2646
|
if (d[0][0].length !== 32)
|
|
@@ -2660,7 +2660,7 @@ function bt(e) {
|
|
|
2660
2660
|
};
|
|
2661
2661
|
}
|
|
2662
2662
|
case "naddr": {
|
|
2663
|
-
let d =
|
|
2663
|
+
let d = Qe(r);
|
|
2664
2664
|
if (!((c = d[0]) != null && c[0]))
|
|
2665
2665
|
throw new Error("missing TLV 0 for naddr");
|
|
2666
2666
|
if (!((l = d[2]) != null && l[0]))
|
|
@@ -2682,7 +2682,7 @@ function bt(e) {
|
|
|
2682
2682
|
};
|
|
2683
2683
|
}
|
|
2684
2684
|
case "nrelay": {
|
|
2685
|
-
let d =
|
|
2685
|
+
let d = Qe(r);
|
|
2686
2686
|
if (!((u = d[0]) != null && u[0]))
|
|
2687
2687
|
throw new Error("missing TLV 0 for nrelay");
|
|
2688
2688
|
return {
|
|
@@ -2699,7 +2699,7 @@ function bt(e) {
|
|
|
2699
2699
|
throw new Error(`unknown prefix ${t}`);
|
|
2700
2700
|
}
|
|
2701
2701
|
}
|
|
2702
|
-
function
|
|
2702
|
+
function Qe(e) {
|
|
2703
2703
|
let t = {}, n = e;
|
|
2704
2704
|
for (; n.length > 0; ) {
|
|
2705
2705
|
let r = n[0], i = n[1], s = n.slice(2, 2 + i);
|
|
@@ -2710,115 +2710,115 @@ function et(e) {
|
|
|
2710
2710
|
return t;
|
|
2711
2711
|
}
|
|
2712
2712
|
function Ea(e) {
|
|
2713
|
-
return
|
|
2713
|
+
return bt("nsec", e);
|
|
2714
2714
|
}
|
|
2715
2715
|
function xa(e) {
|
|
2716
|
-
return
|
|
2716
|
+
return bt("npub", W(e));
|
|
2717
2717
|
}
|
|
2718
2718
|
function Sa(e) {
|
|
2719
|
-
return
|
|
2719
|
+
return bt("note", W(e));
|
|
2720
2720
|
}
|
|
2721
|
-
function
|
|
2721
|
+
function Ye(e, t) {
|
|
2722
2722
|
let n = je.toWords(t);
|
|
2723
|
-
return je.encode(e, n,
|
|
2723
|
+
return je.encode(e, n, un);
|
|
2724
2724
|
}
|
|
2725
|
-
function
|
|
2726
|
-
return
|
|
2725
|
+
function bt(e, t) {
|
|
2726
|
+
return Ye(e, t);
|
|
2727
2727
|
}
|
|
2728
2728
|
function Aa(e) {
|
|
2729
|
-
let t =
|
|
2729
|
+
let t = vt({
|
|
2730
2730
|
0: [W(e.pubkey)],
|
|
2731
2731
|
1: (e.relays || []).map((n) => te.encode(n))
|
|
2732
2732
|
});
|
|
2733
|
-
return
|
|
2733
|
+
return Ye("nprofile", t);
|
|
2734
2734
|
}
|
|
2735
2735
|
function Ka(e) {
|
|
2736
2736
|
let t;
|
|
2737
2737
|
e.kind !== void 0 && (t = ma(e.kind));
|
|
2738
|
-
let n =
|
|
2738
|
+
let n = vt({
|
|
2739
2739
|
0: [W(e.id)],
|
|
2740
2740
|
1: (e.relays || []).map((r) => te.encode(r)),
|
|
2741
2741
|
2: e.author ? [W(e.author)] : [],
|
|
2742
2742
|
3: t ? [new Uint8Array(t)] : []
|
|
2743
2743
|
});
|
|
2744
|
-
return
|
|
2744
|
+
return Ye("nevent", n);
|
|
2745
2745
|
}
|
|
2746
2746
|
function Na(e) {
|
|
2747
2747
|
let t = new ArrayBuffer(4);
|
|
2748
2748
|
new DataView(t).setUint32(0, e.kind, !1);
|
|
2749
|
-
let n =
|
|
2749
|
+
let n = vt({
|
|
2750
2750
|
0: [te.encode(e.identifier)],
|
|
2751
2751
|
1: (e.relays || []).map((r) => te.encode(r)),
|
|
2752
2752
|
2: [W(e.pubkey)],
|
|
2753
2753
|
3: [new Uint8Array(t)]
|
|
2754
2754
|
});
|
|
2755
|
-
return
|
|
2755
|
+
return Ye("naddr", n);
|
|
2756
2756
|
}
|
|
2757
2757
|
function Ba(e) {
|
|
2758
|
-
let t =
|
|
2758
|
+
let t = vt({
|
|
2759
2759
|
0: [te.encode(e)]
|
|
2760
2760
|
});
|
|
2761
|
-
return
|
|
2761
|
+
return Ye("nrelay", t);
|
|
2762
2762
|
}
|
|
2763
|
-
function
|
|
2763
|
+
function vt(e) {
|
|
2764
2764
|
let t = [];
|
|
2765
2765
|
return Object.entries(e).reverse().forEach(([n, r]) => {
|
|
2766
2766
|
r.forEach((i) => {
|
|
2767
2767
|
let s = new Uint8Array(i.length + 2);
|
|
2768
2768
|
s.set([parseInt(n)], 0), s.set([i.length], 1), s.set(i, 2), t.push(s);
|
|
2769
2769
|
});
|
|
2770
|
-
}),
|
|
2770
|
+
}), ht(...t);
|
|
2771
2771
|
}
|
|
2772
2772
|
var Ca = {};
|
|
2773
2773
|
D(Ca, {
|
|
2774
2774
|
decrypt: () => ka,
|
|
2775
|
-
encrypt: () =>
|
|
2775
|
+
encrypt: () => Rr
|
|
2776
2776
|
});
|
|
2777
|
-
async function
|
|
2778
|
-
const r = e instanceof Uint8Array ? M(e) : e, i = Ue.getSharedSecret(r, "02" + t), s =
|
|
2779
|
-
let o = Uint8Array.from(
|
|
2777
|
+
async function Rr(e, t, n) {
|
|
2778
|
+
const r = e instanceof Uint8Array ? M(e) : e, i = Ue.getSharedSecret(r, "02" + t), s = Or(i);
|
|
2779
|
+
let o = Uint8Array.from(ir(16)), a = te.encode(n), c = yr(s, o).encrypt(a), l = ue.encode(new Uint8Array(c)), f = ue.encode(new Uint8Array(o.buffer));
|
|
2780
2780
|
return `${l}?iv=${f}`;
|
|
2781
2781
|
}
|
|
2782
2782
|
async function ka(e, t, n) {
|
|
2783
2783
|
const r = e instanceof Uint8Array ? M(e) : e;
|
|
2784
|
-
let [i, s] = n.split("?iv="), o = Ue.getSharedSecret(r, "02" + t), a =
|
|
2784
|
+
let [i, s] = n.split("?iv="), o = Ue.getSharedSecret(r, "02" + t), a = Or(o), c = ue.decode(s), l = ue.decode(i), f = yr(a, c).decrypt(l);
|
|
2785
2785
|
return ie.decode(f);
|
|
2786
2786
|
}
|
|
2787
|
-
function
|
|
2787
|
+
function Or(e) {
|
|
2788
2788
|
return e.slice(1, 33);
|
|
2789
2789
|
}
|
|
2790
2790
|
var Ua = {};
|
|
2791
2791
|
D(Ua, {
|
|
2792
|
-
NIP05_REGEX: () =>
|
|
2792
|
+
NIP05_REGEX: () => Pr,
|
|
2793
2793
|
isValid: () => La,
|
|
2794
|
-
queryProfile: () =>
|
|
2794
|
+
queryProfile: () => Mr,
|
|
2795
2795
|
searchDomain: () => _a,
|
|
2796
2796
|
useFetchImplementation: () => Ia
|
|
2797
2797
|
});
|
|
2798
|
-
var
|
|
2798
|
+
var Pr = /^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/, mt;
|
|
2799
2799
|
try {
|
|
2800
|
-
|
|
2800
|
+
mt = fetch;
|
|
2801
2801
|
} catch {
|
|
2802
2802
|
}
|
|
2803
2803
|
function Ia(e) {
|
|
2804
|
-
|
|
2804
|
+
mt = e;
|
|
2805
2805
|
}
|
|
2806
2806
|
async function _a(e, t = "") {
|
|
2807
2807
|
try {
|
|
2808
2808
|
const n = `https://${e}/.well-known/nostr.json?name=${t}`;
|
|
2809
|
-
return (await (await
|
|
2809
|
+
return (await (await mt(n, { redirect: "error" })).json()).names;
|
|
2810
2810
|
} catch {
|
|
2811
2811
|
return {};
|
|
2812
2812
|
}
|
|
2813
2813
|
}
|
|
2814
|
-
async function
|
|
2814
|
+
async function Mr(e) {
|
|
2815
2815
|
var s;
|
|
2816
|
-
const t = e.match(
|
|
2816
|
+
const t = e.match(Pr);
|
|
2817
2817
|
if (!t)
|
|
2818
2818
|
return null;
|
|
2819
2819
|
const [n, r = "_", i] = t;
|
|
2820
2820
|
try {
|
|
2821
|
-
const o = `https://${i}/.well-known/nostr.json?name=${r}`, a = await (await
|
|
2821
|
+
const o = `https://${i}/.well-known/nostr.json?name=${r}`, a = await (await mt(o, { redirect: "error" })).json();
|
|
2822
2822
|
let c = a.names[r];
|
|
2823
2823
|
return c ? { pubkey: c, relays: (s = a.relays) == null ? void 0 : s[c] } : null;
|
|
2824
2824
|
} catch {
|
|
@@ -2826,7 +2826,7 @@ async function Hr(e) {
|
|
|
2826
2826
|
}
|
|
2827
2827
|
}
|
|
2828
2828
|
async function La(e, t) {
|
|
2829
|
-
let n = await
|
|
2829
|
+
let n = await Mr(t);
|
|
2830
2830
|
return n ? n.pubkey === e : !1;
|
|
2831
2831
|
}
|
|
2832
2832
|
var Ta = {};
|
|
@@ -2879,13 +2879,13 @@ D(Ra, {
|
|
|
2879
2879
|
fetchRelayInformation: () => Pa,
|
|
2880
2880
|
useFetchImplementation: () => Oa
|
|
2881
2881
|
});
|
|
2882
|
-
var
|
|
2882
|
+
var Hr;
|
|
2883
2883
|
try {
|
|
2884
|
-
|
|
2884
|
+
Hr = fetch;
|
|
2885
2885
|
} catch {
|
|
2886
2886
|
}
|
|
2887
2887
|
function Oa(e) {
|
|
2888
|
-
|
|
2888
|
+
Hr = e;
|
|
2889
2889
|
}
|
|
2890
2890
|
async function Pa(e) {
|
|
2891
2891
|
return await (await fetch(e.replace("ws://", "http://").replace("wss://", "https://"), {
|
|
@@ -2894,10 +2894,10 @@ async function Pa(e) {
|
|
|
2894
2894
|
}
|
|
2895
2895
|
var Ma = {};
|
|
2896
2896
|
D(Ma, {
|
|
2897
|
-
getPow: () =>
|
|
2897
|
+
getPow: () => qr,
|
|
2898
2898
|
minePow: () => Ha
|
|
2899
2899
|
});
|
|
2900
|
-
function
|
|
2900
|
+
function qr(e) {
|
|
2901
2901
|
let t = 0;
|
|
2902
2902
|
for (let n = 0; n < e.length; n++) {
|
|
2903
2903
|
const r = parseInt(e[n], 16);
|
|
@@ -2915,7 +2915,7 @@ function Ha(e, t) {
|
|
|
2915
2915
|
const r = e, i = ["nonce", n.toString(), t.toString()];
|
|
2916
2916
|
for (r.tags.push(i); ; ) {
|
|
2917
2917
|
const s = Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3);
|
|
2918
|
-
if (s !== r.created_at && (n = 0, r.created_at = s), i[1] = (++n).toString(), r.id =
|
|
2918
|
+
if (s !== r.created_at && (n = 0, r.created_at = s), i[1] = (++n).toString(), r.id = tt(r), qr(r.id) >= t)
|
|
2919
2919
|
break;
|
|
2920
2920
|
}
|
|
2921
2921
|
return r;
|
|
@@ -2924,12 +2924,12 @@ var qa = {};
|
|
|
2924
2924
|
D(qa, {
|
|
2925
2925
|
finishRepostEvent: () => Da,
|
|
2926
2926
|
getRepostedEvent: () => ja,
|
|
2927
|
-
getRepostedEventPointer: () =>
|
|
2927
|
+
getRepostedEventPointer: () => Dr
|
|
2928
2928
|
});
|
|
2929
2929
|
function Da(e, t, n, r) {
|
|
2930
2930
|
return ae(
|
|
2931
2931
|
{
|
|
2932
|
-
kind:
|
|
2932
|
+
kind: on,
|
|
2933
2933
|
tags: [...e.tags ?? [], ["e", t.id, n], ["p", t.pubkey]],
|
|
2934
2934
|
content: e.content === "" ? "" : JSON.stringify(t),
|
|
2935
2935
|
created_at: e.created_at
|
|
@@ -2937,8 +2937,8 @@ function Da(e, t, n, r) {
|
|
|
2937
2937
|
r
|
|
2938
2938
|
);
|
|
2939
2939
|
}
|
|
2940
|
-
function
|
|
2941
|
-
if (e.kind !==
|
|
2940
|
+
function Dr(e) {
|
|
2941
|
+
if (e.kind !== on)
|
|
2942
2942
|
return;
|
|
2943
2943
|
let t, n;
|
|
2944
2944
|
for (let r = e.tags.length - 1; r >= 0 && (t === void 0 || n === void 0); r--) {
|
|
@@ -2953,7 +2953,7 @@ function jr(e) {
|
|
|
2953
2953
|
};
|
|
2954
2954
|
}
|
|
2955
2955
|
function ja(e, { skipVerification: t } = {}) {
|
|
2956
|
-
const n =
|
|
2956
|
+
const n = Dr(e);
|
|
2957
2957
|
if (n === void 0 || e.content === "")
|
|
2958
2958
|
return;
|
|
2959
2959
|
let r;
|
|
@@ -2962,27 +2962,27 @@ function ja(e, { skipVerification: t } = {}) {
|
|
|
2962
2962
|
} catch {
|
|
2963
2963
|
return;
|
|
2964
2964
|
}
|
|
2965
|
-
if (r.id === n.id && !(!t && !
|
|
2965
|
+
if (r.id === n.id && !(!t && !gt(r)))
|
|
2966
2966
|
return r;
|
|
2967
2967
|
}
|
|
2968
2968
|
var Va = {};
|
|
2969
2969
|
D(Va, {
|
|
2970
|
-
NOSTR_URI_REGEX: () =>
|
|
2970
|
+
NOSTR_URI_REGEX: () => Et,
|
|
2971
2971
|
parse: () => Za,
|
|
2972
2972
|
test: () => za
|
|
2973
2973
|
});
|
|
2974
|
-
var
|
|
2974
|
+
var Et = new RegExp(`nostr:(${$r.source})`);
|
|
2975
2975
|
function za(e) {
|
|
2976
|
-
return typeof e == "string" && new RegExp(`^${
|
|
2976
|
+
return typeof e == "string" && new RegExp(`^${Et.source}$`).test(e);
|
|
2977
2977
|
}
|
|
2978
2978
|
function Za(e) {
|
|
2979
|
-
const t = e.match(new RegExp(`^${
|
|
2979
|
+
const t = e.match(new RegExp(`^${Et.source}$`));
|
|
2980
2980
|
if (!t)
|
|
2981
2981
|
throw new Error(`Invalid Nostr URI: ${e}`);
|
|
2982
2982
|
return {
|
|
2983
2983
|
uri: t[0],
|
|
2984
2984
|
value: t[1],
|
|
2985
|
-
decoded:
|
|
2985
|
+
decoded: wt(t[1])
|
|
2986
2986
|
};
|
|
2987
2987
|
}
|
|
2988
2988
|
var Fa = {};
|
|
@@ -2995,7 +2995,7 @@ function Wa(e, t, n) {
|
|
|
2995
2995
|
return ae(
|
|
2996
2996
|
{
|
|
2997
2997
|
...e,
|
|
2998
|
-
kind:
|
|
2998
|
+
kind: an,
|
|
2999
2999
|
tags: [...e.tags ?? [], ...r, ["e", t.id], ["p", t.pubkey]],
|
|
3000
3000
|
content: e.content ?? "+"
|
|
3001
3001
|
},
|
|
@@ -3003,7 +3003,7 @@ function Wa(e, t, n) {
|
|
|
3003
3003
|
);
|
|
3004
3004
|
}
|
|
3005
3005
|
function Ga(e) {
|
|
3006
|
-
if (e.kind !==
|
|
3006
|
+
if (e.kind !== an)
|
|
3007
3007
|
return;
|
|
3008
3008
|
let t, n;
|
|
3009
3009
|
for (let r = e.tags.length - 1; r >= 0 && (t === void 0 || n === void 0); r--) {
|
|
@@ -3020,19 +3020,19 @@ function Ga(e) {
|
|
|
3020
3020
|
var Ja = {};
|
|
3021
3021
|
D(Ja, {
|
|
3022
3022
|
matchAll: () => Ya,
|
|
3023
|
-
regex: () =>
|
|
3023
|
+
regex: () => fn,
|
|
3024
3024
|
replaceAll: () => Xa
|
|
3025
3025
|
});
|
|
3026
|
-
var
|
|
3026
|
+
var fn = () => new RegExp(`\\b${Et.source}\\b`, "g");
|
|
3027
3027
|
function* Ya(e) {
|
|
3028
|
-
const t = e.matchAll(
|
|
3028
|
+
const t = e.matchAll(fn());
|
|
3029
3029
|
for (const n of t)
|
|
3030
3030
|
try {
|
|
3031
3031
|
const [r, i] = n;
|
|
3032
3032
|
yield {
|
|
3033
3033
|
uri: r,
|
|
3034
3034
|
value: i,
|
|
3035
|
-
decoded:
|
|
3035
|
+
decoded: wt(i),
|
|
3036
3036
|
start: n.index,
|
|
3037
3037
|
end: n.index + r.length
|
|
3038
3038
|
};
|
|
@@ -3040,10 +3040,10 @@ function* Ya(e) {
|
|
|
3040
3040
|
}
|
|
3041
3041
|
}
|
|
3042
3042
|
function Xa(e, t) {
|
|
3043
|
-
return e.replaceAll(
|
|
3043
|
+
return e.replaceAll(fn(), (n, r) => t({
|
|
3044
3044
|
uri: n,
|
|
3045
3045
|
value: r,
|
|
3046
|
-
decoded:
|
|
3046
|
+
decoded: wt(r)
|
|
3047
3047
|
}));
|
|
3048
3048
|
}
|
|
3049
3049
|
var Qa = {};
|
|
@@ -3064,7 +3064,7 @@ var ec = (e, t) => {
|
|
|
3064
3064
|
return;
|
|
3065
3065
|
return ae(
|
|
3066
3066
|
{
|
|
3067
|
-
kind:
|
|
3067
|
+
kind: Br,
|
|
3068
3068
|
tags: [...e.tags ?? []],
|
|
3069
3069
|
content: n,
|
|
3070
3070
|
created_at: e.created_at
|
|
@@ -3081,7 +3081,7 @@ var ec = (e, t) => {
|
|
|
3081
3081
|
return;
|
|
3082
3082
|
return ae(
|
|
3083
3083
|
{
|
|
3084
|
-
kind:
|
|
3084
|
+
kind: Cr,
|
|
3085
3085
|
tags: [["e", e.channel_create_event_id], ...e.tags ?? []],
|
|
3086
3086
|
content: n,
|
|
3087
3087
|
created_at: e.created_at
|
|
@@ -3092,7 +3092,7 @@ var ec = (e, t) => {
|
|
|
3092
3092
|
const n = [["e", e.channel_create_event_id, e.relay_url, "root"]];
|
|
3093
3093
|
return e.reply_to_channel_message_event_id && n.push(["e", e.reply_to_channel_message_event_id, e.relay_url, "reply"]), ae(
|
|
3094
3094
|
{
|
|
3095
|
-
kind:
|
|
3095
|
+
kind: kr,
|
|
3096
3096
|
tags: [...n, ...e.tags ?? []],
|
|
3097
3097
|
content: e.content,
|
|
3098
3098
|
created_at: e.created_at
|
|
@@ -3109,7 +3109,7 @@ var ec = (e, t) => {
|
|
|
3109
3109
|
return;
|
|
3110
3110
|
return ae(
|
|
3111
3111
|
{
|
|
3112
|
-
kind:
|
|
3112
|
+
kind: Ur,
|
|
3113
3113
|
tags: [["e", e.channel_message_event_id], ...e.tags ?? []],
|
|
3114
3114
|
content: n,
|
|
3115
3115
|
created_at: e.created_at
|
|
@@ -3126,7 +3126,7 @@ var ec = (e, t) => {
|
|
|
3126
3126
|
return;
|
|
3127
3127
|
return ae(
|
|
3128
3128
|
{
|
|
3129
|
-
kind:
|
|
3129
|
+
kind: Ir,
|
|
3130
3130
|
tags: [["p", e.pubkey_to_mute], ...e.tags ?? []],
|
|
3131
3131
|
content: n,
|
|
3132
3132
|
created_at: e.created_at
|
|
@@ -3135,14 +3135,14 @@ var ec = (e, t) => {
|
|
|
3135
3135
|
);
|
|
3136
3136
|
}, sc = {};
|
|
3137
3137
|
D(sc, {
|
|
3138
|
-
EMOJI_SHORTCODE_REGEX: () =>
|
|
3138
|
+
EMOJI_SHORTCODE_REGEX: () => jr,
|
|
3139
3139
|
matchAll: () => oc,
|
|
3140
|
-
regex: () =>
|
|
3140
|
+
regex: () => hn,
|
|
3141
3141
|
replaceAll: () => ac
|
|
3142
3142
|
});
|
|
3143
|
-
var
|
|
3143
|
+
var jr = /:(\w+):/, hn = () => new RegExp(`\\B${jr.source}\\B`, "g");
|
|
3144
3144
|
function* oc(e) {
|
|
3145
|
-
const t = e.matchAll(
|
|
3145
|
+
const t = e.matchAll(hn());
|
|
3146
3146
|
for (const n of t)
|
|
3147
3147
|
try {
|
|
3148
3148
|
const [r, i] = n;
|
|
@@ -3156,7 +3156,7 @@ function* oc(e) {
|
|
|
3156
3156
|
}
|
|
3157
3157
|
}
|
|
3158
3158
|
function ac(e, t) {
|
|
3159
|
-
return e.replaceAll(
|
|
3159
|
+
return e.replaceAll(hn(), (n, r) => t({
|
|
3160
3160
|
shortcode: n,
|
|
3161
3161
|
name: r
|
|
3162
3162
|
}));
|
|
@@ -3166,42 +3166,42 @@ D(cc, {
|
|
|
3166
3166
|
useFetchImplementation: () => lc,
|
|
3167
3167
|
validateGithub: () => uc
|
|
3168
3168
|
});
|
|
3169
|
-
var
|
|
3169
|
+
var dn;
|
|
3170
3170
|
try {
|
|
3171
|
-
|
|
3171
|
+
dn = fetch;
|
|
3172
3172
|
} catch {
|
|
3173
3173
|
}
|
|
3174
3174
|
function lc(e) {
|
|
3175
|
-
|
|
3175
|
+
dn = e;
|
|
3176
3176
|
}
|
|
3177
3177
|
async function uc(e, t, n) {
|
|
3178
3178
|
try {
|
|
3179
|
-
return await (await
|
|
3179
|
+
return await (await dn(`https://gist.github.com/${t}/${n}/raw`)).text() === `Verifying that I control the following Nostr public key: ${e}`;
|
|
3180
3180
|
} catch {
|
|
3181
3181
|
return !1;
|
|
3182
3182
|
}
|
|
3183
3183
|
}
|
|
3184
3184
|
var j = {};
|
|
3185
3185
|
D(j, {
|
|
3186
|
-
decrypt: () =>
|
|
3187
|
-
encrypt: () =>
|
|
3188
|
-
getConversationKey: () =>
|
|
3186
|
+
decrypt: () => Jr,
|
|
3187
|
+
encrypt: () => Gr,
|
|
3188
|
+
getConversationKey: () => Zr,
|
|
3189
3189
|
v2: () => pc
|
|
3190
3190
|
});
|
|
3191
|
-
var
|
|
3192
|
-
function
|
|
3191
|
+
var Vr = 1, zr = 65535;
|
|
3192
|
+
function Zr(e, t) {
|
|
3193
3193
|
const n = Ue.getSharedSecret(e, "02" + t).subarray(1, 33);
|
|
3194
|
-
return
|
|
3194
|
+
return rn(Se, n, "nip44-v2");
|
|
3195
3195
|
}
|
|
3196
|
-
function
|
|
3197
|
-
const n =
|
|
3196
|
+
function Fr(e, t) {
|
|
3197
|
+
const n = mr(Se, e, t, 76);
|
|
3198
3198
|
return {
|
|
3199
3199
|
chacha_key: n.subarray(0, 32),
|
|
3200
3200
|
chacha_nonce: n.subarray(32, 44),
|
|
3201
3201
|
hmac_key: n.subarray(44, 76)
|
|
3202
3202
|
};
|
|
3203
3203
|
}
|
|
3204
|
-
function
|
|
3204
|
+
function yn(e) {
|
|
3205
3205
|
if (!Number.isSafeInteger(e) || e < 1)
|
|
3206
3206
|
throw new Error("expected positive integer");
|
|
3207
3207
|
if (e <= 32)
|
|
@@ -3210,26 +3210,26 @@ function pn(e) {
|
|
|
3210
3210
|
return n * (Math.floor((e - 1) / n) + 1);
|
|
3211
3211
|
}
|
|
3212
3212
|
function fc(e) {
|
|
3213
|
-
if (!Number.isSafeInteger(e) || e <
|
|
3213
|
+
if (!Number.isSafeInteger(e) || e < Vr || e > zr)
|
|
3214
3214
|
throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");
|
|
3215
3215
|
const t = new Uint8Array(2);
|
|
3216
3216
|
return new DataView(t.buffer).setUint16(0, e, !1), t;
|
|
3217
3217
|
}
|
|
3218
3218
|
function hc(e) {
|
|
3219
|
-
const t = te.encode(e), n = t.length, r = fc(n), i = new Uint8Array(
|
|
3220
|
-
return
|
|
3219
|
+
const t = te.encode(e), n = t.length, r = fc(n), i = new Uint8Array(yn(n) - n);
|
|
3220
|
+
return ht(r, t, i);
|
|
3221
3221
|
}
|
|
3222
3222
|
function dc(e) {
|
|
3223
3223
|
const t = new DataView(e.buffer).getUint16(0), n = e.subarray(2, 2 + t);
|
|
3224
|
-
if (t <
|
|
3224
|
+
if (t < Vr || t > zr || n.length !== t || e.length !== 2 + yn(t))
|
|
3225
3225
|
throw new Error("invalid padding");
|
|
3226
3226
|
return ie.decode(n);
|
|
3227
3227
|
}
|
|
3228
|
-
function
|
|
3228
|
+
function Wr(e, t, n) {
|
|
3229
3229
|
if (n.length !== 32)
|
|
3230
3230
|
throw new Error("AAD associated data must be 32 bytes");
|
|
3231
|
-
const r =
|
|
3232
|
-
return
|
|
3231
|
+
const r = ht(n, t);
|
|
3232
|
+
return yt(Se, e, r);
|
|
3233
3233
|
}
|
|
3234
3234
|
function yc(e) {
|
|
3235
3235
|
if (typeof e != "string")
|
|
@@ -3257,24 +3257,24 @@ function yc(e) {
|
|
|
3257
3257
|
mac: n.subarray(-32)
|
|
3258
3258
|
};
|
|
3259
3259
|
}
|
|
3260
|
-
function
|
|
3261
|
-
const { chacha_key: r, chacha_nonce: i, hmac_key: s } =
|
|
3262
|
-
return ue.encode(
|
|
3260
|
+
function Gr(e, t, n = ir(32)) {
|
|
3261
|
+
const { chacha_key: r, chacha_nonce: i, hmac_key: s } = Fr(t, n), o = hc(e), a = br(r, i, o), c = Wr(s, a, n);
|
|
3262
|
+
return ue.encode(ht(new Uint8Array([2]), n, a, c));
|
|
3263
3263
|
}
|
|
3264
|
-
function
|
|
3265
|
-
const { nonce: n, ciphertext: r, mac: i } = yc(e), { chacha_key: s, chacha_nonce: o, hmac_key: a } =
|
|
3266
|
-
if (!
|
|
3264
|
+
function Jr(e, t) {
|
|
3265
|
+
const { nonce: n, ciphertext: r, mac: i } = yc(e), { chacha_key: s, chacha_nonce: o, hmac_key: a } = Fr(t, n), c = Wr(a, r, n);
|
|
3266
|
+
if (!Ss(c, i))
|
|
3267
3267
|
throw new Error("invalid MAC");
|
|
3268
|
-
const l =
|
|
3268
|
+
const l = br(s, o, r);
|
|
3269
3269
|
return dc(l);
|
|
3270
3270
|
}
|
|
3271
3271
|
var pc = {
|
|
3272
3272
|
utils: {
|
|
3273
|
-
getConversationKey:
|
|
3274
|
-
calcPaddedLen:
|
|
3273
|
+
getConversationKey: Zr,
|
|
3274
|
+
calcPaddedLen: yn
|
|
3275
3275
|
},
|
|
3276
|
-
encrypt:
|
|
3277
|
-
decrypt:
|
|
3276
|
+
encrypt: Gr,
|
|
3277
|
+
decrypt: Jr
|
|
3278
3278
|
}, gc = {};
|
|
3279
3279
|
D(gc, {
|
|
3280
3280
|
makeNwcRequestEvent: () => bc,
|
|
@@ -3287,13 +3287,13 @@ function wc(e) {
|
|
|
3287
3287
|
return { pubkey: r, relay: i, secret: s };
|
|
3288
3288
|
}
|
|
3289
3289
|
async function bc(e, t, n) {
|
|
3290
|
-
const i = await
|
|
3290
|
+
const i = await Rr(t, e, JSON.stringify({
|
|
3291
3291
|
method: "pay_invoice",
|
|
3292
3292
|
params: {
|
|
3293
3293
|
invoice: n
|
|
3294
3294
|
}
|
|
3295
3295
|
})), s = {
|
|
3296
|
-
kind:
|
|
3296
|
+
kind: Lr,
|
|
3297
3297
|
created_at: Math.round(Date.now() / 1e3),
|
|
3298
3298
|
content: i,
|
|
3299
3299
|
tags: [["p", e]]
|
|
@@ -3308,13 +3308,13 @@ D(vc, {
|
|
|
3308
3308
|
useFetchImplementation: () => mc,
|
|
3309
3309
|
validateZapRequest: () => Sc
|
|
3310
3310
|
});
|
|
3311
|
-
var
|
|
3311
|
+
var pn;
|
|
3312
3312
|
try {
|
|
3313
|
-
|
|
3313
|
+
pn = fetch;
|
|
3314
3314
|
} catch {
|
|
3315
3315
|
}
|
|
3316
3316
|
function mc(e) {
|
|
3317
|
-
|
|
3317
|
+
pn = e;
|
|
3318
3318
|
}
|
|
3319
3319
|
async function Ec(e) {
|
|
3320
3320
|
try {
|
|
@@ -3327,7 +3327,7 @@ async function Ec(e) {
|
|
|
3327
3327
|
t = new URL(`/.well-known/lnurlp/${o}`, `https://${a}`).toString();
|
|
3328
3328
|
} else
|
|
3329
3329
|
return null;
|
|
3330
|
-
let s = await (await
|
|
3330
|
+
let s = await (await pn(t)).json();
|
|
3331
3331
|
if (s.allowsNostr && s.nostrPubkey)
|
|
3332
3332
|
return s.callback;
|
|
3333
3333
|
} catch {
|
|
@@ -3364,9 +3364,9 @@ function Sc(e) {
|
|
|
3364
3364
|
} catch {
|
|
3365
3365
|
return "Invalid zap request JSON.";
|
|
3366
3366
|
}
|
|
3367
|
-
if (!
|
|
3367
|
+
if (!Er(t))
|
|
3368
3368
|
return "Zap request is not a valid Nostr event.";
|
|
3369
|
-
if (!
|
|
3369
|
+
if (!gt(t))
|
|
3370
3370
|
return "Invalid signature on zap request.";
|
|
3371
3371
|
let n = t.tags.find(([s, o]) => s === "p" && o);
|
|
3372
3372
|
if (!n)
|
|
@@ -3393,20 +3393,20 @@ function Ac({
|
|
|
3393
3393
|
var Kc = {};
|
|
3394
3394
|
D(Kc, {
|
|
3395
3395
|
getToken: () => Nc,
|
|
3396
|
-
hashPayload: () =>
|
|
3397
|
-
unpackEventFromToken: () =>
|
|
3398
|
-
validateEvent: () =>
|
|
3399
|
-
validateEventKind: () =>
|
|
3400
|
-
validateEventMethodTag: () =>
|
|
3401
|
-
validateEventPayloadTag: () =>
|
|
3402
|
-
validateEventTimestamp: () =>
|
|
3403
|
-
validateEventUrlTag: () =>
|
|
3396
|
+
hashPayload: () => gn,
|
|
3397
|
+
unpackEventFromToken: () => Xr,
|
|
3398
|
+
validateEvent: () => ii,
|
|
3399
|
+
validateEventKind: () => ei,
|
|
3400
|
+
validateEventMethodTag: () => ni,
|
|
3401
|
+
validateEventPayloadTag: () => ri,
|
|
3402
|
+
validateEventTimestamp: () => Qr,
|
|
3403
|
+
validateEventUrlTag: () => ti,
|
|
3404
3404
|
validateToken: () => Bc
|
|
3405
3405
|
});
|
|
3406
|
-
var
|
|
3406
|
+
var Yr = "Nostr ";
|
|
3407
3407
|
async function Nc(e, t, n, r = !1, i) {
|
|
3408
3408
|
const s = {
|
|
3409
|
-
kind:
|
|
3409
|
+
kind: cn,
|
|
3410
3410
|
tags: [
|
|
3411
3411
|
["u", e],
|
|
3412
3412
|
["method", t]
|
|
@@ -3414,68 +3414,68 @@ async function Nc(e, t, n, r = !1, i) {
|
|
|
3414
3414
|
created_at: Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3),
|
|
3415
3415
|
content: ""
|
|
3416
3416
|
};
|
|
3417
|
-
i && s.tags.push(["payload",
|
|
3417
|
+
i && s.tags.push(["payload", gn(i)]);
|
|
3418
3418
|
const o = await n(s);
|
|
3419
|
-
return (r ?
|
|
3419
|
+
return (r ? Yr : "") + ue.encode(te.encode(JSON.stringify(o)));
|
|
3420
3420
|
}
|
|
3421
3421
|
async function Bc(e, t, n) {
|
|
3422
|
-
const r = await
|
|
3422
|
+
const r = await Xr(e).catch((s) => {
|
|
3423
3423
|
throw s;
|
|
3424
3424
|
});
|
|
3425
|
-
return await
|
|
3425
|
+
return await ii(r, t, n).catch((s) => {
|
|
3426
3426
|
throw s;
|
|
3427
3427
|
});
|
|
3428
3428
|
}
|
|
3429
|
-
async function
|
|
3429
|
+
async function Xr(e) {
|
|
3430
3430
|
if (!e)
|
|
3431
3431
|
throw new Error("Missing token");
|
|
3432
|
-
e = e.replace(
|
|
3432
|
+
e = e.replace(Yr, "");
|
|
3433
3433
|
const t = ie.decode(ue.decode(e));
|
|
3434
3434
|
if (!t || t.length === 0 || !t.startsWith("{"))
|
|
3435
3435
|
throw new Error("Invalid token");
|
|
3436
3436
|
return JSON.parse(t);
|
|
3437
3437
|
}
|
|
3438
|
-
function
|
|
3438
|
+
function Qr(e) {
|
|
3439
3439
|
return e.created_at ? Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3) - e.created_at < 60 : !1;
|
|
3440
3440
|
}
|
|
3441
|
-
function
|
|
3442
|
-
return e.kind ===
|
|
3441
|
+
function ei(e) {
|
|
3442
|
+
return e.kind === cn;
|
|
3443
3443
|
}
|
|
3444
|
-
function
|
|
3444
|
+
function ti(e, t) {
|
|
3445
3445
|
const n = e.tags.find((r) => r[0] === "u");
|
|
3446
3446
|
return n ? n.length > 0 && n[1] === t : !1;
|
|
3447
3447
|
}
|
|
3448
|
-
function
|
|
3448
|
+
function ni(e, t) {
|
|
3449
3449
|
const n = e.tags.find((r) => r[0] === "method");
|
|
3450
3450
|
return n ? n.length > 0 && n[1].toLowerCase() === t.toLowerCase() : !1;
|
|
3451
3451
|
}
|
|
3452
|
-
function
|
|
3452
|
+
function gn(e) {
|
|
3453
3453
|
const t = Se(te.encode(JSON.stringify(e)));
|
|
3454
3454
|
return M(t);
|
|
3455
3455
|
}
|
|
3456
|
-
function
|
|
3456
|
+
function ri(e, t) {
|
|
3457
3457
|
const n = e.tags.find((i) => i[0] === "payload");
|
|
3458
3458
|
if (!n)
|
|
3459
3459
|
return !1;
|
|
3460
|
-
const r =
|
|
3460
|
+
const r = gn(t);
|
|
3461
3461
|
return n.length > 0 && n[1] === r;
|
|
3462
3462
|
}
|
|
3463
|
-
async function
|
|
3464
|
-
if (!
|
|
3463
|
+
async function ii(e, t, n, r) {
|
|
3464
|
+
if (!gt(e))
|
|
3465
3465
|
throw new Error("Invalid nostr event, signature invalid");
|
|
3466
|
-
if (!ti(e))
|
|
3467
|
-
throw new Error("Invalid nostr event, kind invalid");
|
|
3468
3466
|
if (!ei(e))
|
|
3467
|
+
throw new Error("Invalid nostr event, kind invalid");
|
|
3468
|
+
if (!Qr(e))
|
|
3469
3469
|
throw new Error("Invalid nostr event, created_at timestamp invalid");
|
|
3470
|
-
if (!
|
|
3470
|
+
if (!ti(e, t))
|
|
3471
3471
|
throw new Error("Invalid nostr event, url tag invalid");
|
|
3472
|
-
if (!
|
|
3472
|
+
if (!ni(e, n))
|
|
3473
3473
|
throw new Error("Invalid nostr event, method tag invalid");
|
|
3474
|
-
if (r && typeof r == "object" && Object.keys(r).length > 0 && !
|
|
3474
|
+
if (r && typeof r == "object" && Object.keys(r).length > 0 && !ri(e, r))
|
|
3475
3475
|
throw new Error("Invalid nostr event, payload tag does not match request body hash");
|
|
3476
3476
|
return !0;
|
|
3477
3477
|
}
|
|
3478
|
-
const He = 4,
|
|
3478
|
+
const He = 4, Rn = 30078, Rc = 100;
|
|
3479
3479
|
var Cc = /* @__PURE__ */ ((e) => (e[e.Us = 0] = "Us", e[e.Them = 1] = "Them", e))(Cc || {});
|
|
3480
3480
|
function Oc(e) {
|
|
3481
3481
|
return JSON.stringify({
|
|
@@ -3556,16 +3556,16 @@ async function* Mc(e) {
|
|
|
3556
3556
|
}
|
|
3557
3557
|
}
|
|
3558
3558
|
function Re(e, t = new Uint8Array(32), n = 1) {
|
|
3559
|
-
const r =
|
|
3559
|
+
const r = rn(Se, e, t), i = [];
|
|
3560
3560
|
for (let s = 1; s <= n; s++)
|
|
3561
|
-
i.push(
|
|
3561
|
+
i.push(mr(Se, r, new Uint8Array([s]), 32));
|
|
3562
3562
|
return i;
|
|
3563
3563
|
}
|
|
3564
|
-
function
|
|
3564
|
+
function Lt(e, t) {
|
|
3565
3565
|
return `${e}:${t}`;
|
|
3566
3566
|
}
|
|
3567
3567
|
const kc = 1e3;
|
|
3568
|
-
class
|
|
3568
|
+
class at {
|
|
3569
3569
|
// 1. CHANNEL PUBLIC INTERFACE
|
|
3570
3570
|
constructor(t, n) {
|
|
3571
3571
|
ee(this, "nostrUnsubscribe");
|
|
@@ -3601,7 +3601,7 @@ class ct {
|
|
|
3601
3601
|
previousSendingChainMessageCount: 0,
|
|
3602
3602
|
skippedMessageKeys: {},
|
|
3603
3603
|
skippedHeaderKeys: {}
|
|
3604
|
-
}, p = new
|
|
3604
|
+
}, p = new at(t, d);
|
|
3605
3605
|
return o && (p.name = o), p;
|
|
3606
3606
|
}
|
|
3607
3607
|
/**
|
|
@@ -3683,7 +3683,7 @@ class ct {
|
|
|
3683
3683
|
for (; this.state.receivingChainMessageNumber < t; ) {
|
|
3684
3684
|
const [r, i] = Re(this.state.receivingChainKey, new Uint8Array([1]), 2);
|
|
3685
3685
|
this.state.receivingChainKey = r;
|
|
3686
|
-
const s =
|
|
3686
|
+
const s = Lt(n, this.state.receivingChainMessageNumber);
|
|
3687
3687
|
if (this.state.skippedMessageKeys[s] = i, !this.state.skippedHeaderKeys[n]) {
|
|
3688
3688
|
const o = [];
|
|
3689
3689
|
if (this.state.ourCurrentNostrKey) {
|
|
@@ -3698,7 +3698,7 @@ class ct {
|
|
|
3698
3698
|
}
|
|
3699
3699
|
trySkippedMessageKeys(t, n, r) {
|
|
3700
3700
|
var s;
|
|
3701
|
-
const i =
|
|
3701
|
+
const i = Lt(r, t.number);
|
|
3702
3702
|
if (i in this.state.skippedMessageKeys) {
|
|
3703
3703
|
const o = this.state.skippedMessageKeys[i];
|
|
3704
3704
|
return delete this.state.skippedMessageKeys[i], Object.keys(this.state.skippedMessageKeys).some((c) => c.startsWith(`${r}:`)) || (delete this.state.skippedHeaderKeys[r], (s = this.nostrUnsubscribe) == null || s.call(this), this.nostrUnsubscribe = void 0), j.decrypt(n, o);
|
|
@@ -3737,7 +3737,7 @@ class ct {
|
|
|
3737
3737
|
{ authors: [this.state.theirNostrPublicKey], kinds: [He] },
|
|
3738
3738
|
(a) => this.handleNostrEvent(a)
|
|
3739
3739
|
)), r && (this.skipMessageKeys(n.previousChainLength, t.pubkey), this.ratchetStep(n.nextPublicKey));
|
|
3740
|
-
else if (!(
|
|
3740
|
+
else if (!(Lt(t.pubkey, n.number) in this.state.skippedMessageKeys))
|
|
3741
3741
|
return;
|
|
3742
3742
|
const s = this.ratchetDecrypt(n, t.content, t.pubkey);
|
|
3743
3743
|
this.internalSubscriptions.forEach((a) => a({ id: t.id, data: s, pubkey: n.nextPublicKey, time: n.time }));
|
|
@@ -3757,9 +3757,9 @@ class ct {
|
|
|
3757
3757
|
}
|
|
3758
3758
|
new TextDecoder("utf-8");
|
|
3759
3759
|
new TextEncoder();
|
|
3760
|
-
function
|
|
3760
|
+
function et(e, t) {
|
|
3761
3761
|
const n = Ue.getSharedSecret(e, "02" + t).subarray(1, 33);
|
|
3762
|
-
return
|
|
3762
|
+
return rn(Se, n, "nip44-v2");
|
|
3763
3763
|
}
|
|
3764
3764
|
class Oe {
|
|
3765
3765
|
constructor(t, n, r, i, s, o, a = []) {
|
|
@@ -3784,21 +3784,16 @@ class Oe {
|
|
|
3784
3784
|
let s;
|
|
3785
3785
|
try {
|
|
3786
3786
|
s = JSON.parse(i);
|
|
3787
|
-
} catch (
|
|
3788
|
-
throw new Error("Invite data in URL hash is not valid JSON: " +
|
|
3787
|
+
} catch (l) {
|
|
3788
|
+
throw new Error("Invite data in URL hash is not valid JSON: " + l);
|
|
3789
3789
|
}
|
|
3790
3790
|
const { inviter: o, sessionKey: a, linkSecret: c } = s;
|
|
3791
3791
|
if (!o || !a || !c)
|
|
3792
3792
|
throw new Error("Missing required fields (inviter, sessionKey, linkSecret) in invite data.");
|
|
3793
|
-
const l = We.decode(o), f = We.decode(a);
|
|
3794
|
-
if (typeof l.data != "string")
|
|
3795
|
-
throw new Error("Decoded inviter is not a string");
|
|
3796
|
-
if (typeof f.data != "string")
|
|
3797
|
-
throw new Error("Decoded session key is not a string");
|
|
3798
3793
|
return new Oe(
|
|
3799
|
-
|
|
3794
|
+
a,
|
|
3800
3795
|
c,
|
|
3801
|
-
|
|
3796
|
+
o
|
|
3802
3797
|
);
|
|
3803
3798
|
}
|
|
3804
3799
|
static deserialize(t) {
|
|
@@ -3817,7 +3812,7 @@ class Oe {
|
|
|
3817
3812
|
var o, a;
|
|
3818
3813
|
if (!t.sig)
|
|
3819
3814
|
throw new Error("Event is not signed");
|
|
3820
|
-
if (!
|
|
3815
|
+
if (!gt(t))
|
|
3821
3816
|
throw new Error("Event signature is invalid");
|
|
3822
3817
|
const { tags: n } = t, r = (o = n.find(([c]) => c === "sessionKey")) == null ? void 0 : o[1], i = (a = n.find(([c]) => c === "linkSecret")) == null ? void 0 : a[1], s = t.pubkey;
|
|
3823
3818
|
if (!r || !i)
|
|
@@ -3830,7 +3825,7 @@ class Oe {
|
|
|
3830
3825
|
}
|
|
3831
3826
|
static fromUser(t, n) {
|
|
3832
3827
|
const r = {
|
|
3833
|
-
kinds: [
|
|
3828
|
+
kinds: [Rn],
|
|
3834
3829
|
authors: [t],
|
|
3835
3830
|
limit: 1,
|
|
3836
3831
|
"#d": ["nostr-double-ratchet/invite"]
|
|
@@ -3868,15 +3863,15 @@ class Oe {
|
|
|
3868
3863
|
*/
|
|
3869
3864
|
getUrl(t = "https://iris.to") {
|
|
3870
3865
|
const n = {
|
|
3871
|
-
inviter:
|
|
3872
|
-
sessionKey:
|
|
3866
|
+
inviter: this.inviter,
|
|
3867
|
+
sessionKey: this.inviterSessionPublicKey,
|
|
3873
3868
|
linkSecret: this.linkSecret
|
|
3874
3869
|
}, r = new URL(t);
|
|
3875
3870
|
return r.hash = encodeURIComponent(JSON.stringify(n)), console.log("url", r.toString()), r.toString();
|
|
3876
3871
|
}
|
|
3877
3872
|
getEvent() {
|
|
3878
3873
|
return {
|
|
3879
|
-
kind:
|
|
3874
|
+
kind: Rn,
|
|
3880
3875
|
pubkey: this.inviter,
|
|
3881
3876
|
content: "",
|
|
3882
3877
|
created_at: Math.floor(Date.now() / 1e3),
|
|
@@ -3899,7 +3894,7 @@ class Oe {
|
|
|
3899
3894
|
* so the inviter can create the channel on their side.
|
|
3900
3895
|
*/
|
|
3901
3896
|
async accept(t, n, r) {
|
|
3902
|
-
const i = Me(), s = Ce(i), o = this.inviter || this.inviterSessionPublicKey, a = W(this.linkSecret), c =
|
|
3897
|
+
const i = Me(), s = Ce(i), o = this.inviter || this.inviterSessionPublicKey, a = W(this.linkSecret), c = at.init(t, this.inviterSessionPublicKey, i, !0, a, void 0), l = Me(), f = Ce(l), u = typeof r == "function" ? r : (g, h) => Promise.resolve(j.encrypt(g, et(r, h))), d = {
|
|
3903
3898
|
pubkey: n,
|
|
3904
3899
|
tags: [["secret", this.linkSecret]],
|
|
3905
3900
|
content: await u(s, o),
|
|
@@ -3907,7 +3902,7 @@ class Oe {
|
|
|
3907
3902
|
}, p = {
|
|
3908
3903
|
kind: He,
|
|
3909
3904
|
pubkey: f,
|
|
3910
|
-
content: j.encrypt(JSON.stringify(d),
|
|
3905
|
+
content: j.encrypt(JSON.stringify(d), et(l, this.inviterSessionPublicKey)),
|
|
3911
3906
|
created_at: Math.floor(Date.now() / 1e3),
|
|
3912
3907
|
tags: [["p", this.inviterSessionPublicKey]]
|
|
3913
3908
|
};
|
|
@@ -3926,14 +3921,14 @@ class Oe {
|
|
|
3926
3921
|
console.error("Invite has reached maximum number of uses");
|
|
3927
3922
|
return;
|
|
3928
3923
|
}
|
|
3929
|
-
const o = await j.decrypt(s.content,
|
|
3924
|
+
const o = await j.decrypt(s.content, et(this.inviterSessionPrivateKey, s.pubkey)), a = JSON.parse(o);
|
|
3930
3925
|
if (!a.tags || !a.tags.some(([g, h]) => g === "secret" && h === this.linkSecret)) {
|
|
3931
3926
|
console.error("Invalid secret from event", s);
|
|
3932
3927
|
return;
|
|
3933
3928
|
}
|
|
3934
|
-
const c = typeof t == "function" ? t : (g, h) => Promise.resolve(j.decrypt(g,
|
|
3929
|
+
const c = typeof t == "function" ? t : (g, h) => Promise.resolve(j.decrypt(g, et(t, h))), l = a.pubkey;
|
|
3935
3930
|
this.usedBy.push(l);
|
|
3936
|
-
const f = await c(a.content, l), u = W(this.linkSecret), d = s.id, p =
|
|
3931
|
+
const f = await c(a.content, l), u = W(this.linkSecret), d = s.id, p = at.init(n, f, this.inviterSessionPrivateKey, !1, u, d);
|
|
3937
3932
|
r(p, l);
|
|
3938
3933
|
} catch (o) {
|
|
3939
3934
|
console.error("Error processing invite message:", o);
|
|
@@ -3942,8 +3937,8 @@ class Oe {
|
|
|
3942
3937
|
}
|
|
3943
3938
|
}
|
|
3944
3939
|
export {
|
|
3945
|
-
|
|
3946
|
-
|
|
3940
|
+
at as Channel,
|
|
3941
|
+
Rn as INVITE_EVENT_KIND,
|
|
3947
3942
|
Oe as Invite,
|
|
3948
3943
|
Rc as MAX_SKIP,
|
|
3949
3944
|
He as MESSAGE_EVENT_KIND,
|
|
@@ -3952,5 +3947,5 @@ export {
|
|
|
3952
3947
|
Pc as deserializeChannelState,
|
|
3953
3948
|
Re as kdf,
|
|
3954
3949
|
Oc as serializeChannelState,
|
|
3955
|
-
|
|
3950
|
+
Lt as skippedMessageIndexKey
|
|
3956
3951
|
};
|