nostr-double-ratchet 0.0.35 → 0.0.36
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 +2 -1
- package/dist/Invite.d.ts.map +1 -1
- package/dist/nostr-double-ratchet.es.js +473 -471
- package/dist/nostr-double-ratchet.umd.js +1 -1
- package/package.json +1 -1
- package/src/Invite.ts +5 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var J = (e, t, n) =>
|
|
1
|
+
var Ni = Object.defineProperty;
|
|
2
|
+
var Si = (e, t, n) => t in e ? Ni(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var J = (e, t, n) => Si(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
function Bn(e) {
|
|
5
5
|
if (!Number.isSafeInteger(e) || e < 0)
|
|
6
6
|
throw new Error(`Wrong positive integer: ${e}`);
|
|
@@ -11,7 +11,7 @@ function Fn(e, ...t) {
|
|
|
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
|
Bn(e.outputLen), Bn(e.blockLen);
|
|
@@ -22,7 +22,7 @@ function et(e, t = !0) {
|
|
|
22
22
|
if (t && e.finished)
|
|
23
23
|
throw new Error("Hash#digest() has already been called");
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function Ci(e, t) {
|
|
26
26
|
Fn(e);
|
|
27
27
|
const n = t.outputLen;
|
|
28
28
|
if (e.length < n)
|
|
@@ -30,20 +30,20 @@ function Ai(e, t) {
|
|
|
30
30
|
}
|
|
31
31
|
const xt = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
|
|
32
32
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
33
|
-
const Gn = (e) => e instanceof Uint8Array, Kt = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), re = (e, t) => e << 32 - t | e >>> t,
|
|
34
|
-
if (!
|
|
33
|
+
const Gn = (e) => e instanceof Uint8Array, Kt = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), re = (e, t) => e << 32 - t | e >>> t, ki = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
34
|
+
if (!ki)
|
|
35
35
|
throw new Error("Non little-endian hardware is not supported");
|
|
36
|
-
function
|
|
36
|
+
function Bi(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
41
|
function Vt(e) {
|
|
42
|
-
if (typeof e == "string" && (e =
|
|
42
|
+
if (typeof e == "string" && (e = Bi(e)), !Gn(e))
|
|
43
43
|
throw new Error(`expected Uint8Array, got ${typeof e}`);
|
|
44
44
|
return e;
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function Ii(...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) => {
|
|
@@ -58,7 +58,7 @@ let Jn = class {
|
|
|
58
58
|
return this._cloneInto();
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
|
-
function
|
|
61
|
+
function Ui(e) {
|
|
62
62
|
const t = (r) => e().update(Vt(r)).digest(), n = e();
|
|
63
63
|
return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
|
|
64
64
|
}
|
|
@@ -67,13 +67,13 @@ function Yn(e = 32) {
|
|
|
67
67
|
return xt.getRandomValues(new Uint8Array(e));
|
|
68
68
|
throw new Error("crypto.getRandomValues must be defined");
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function _i(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), c = Number(n & s), a = r ? 4 : 0, l = r ? 0 : 4;
|
|
74
74
|
e.setUint32(t + a, o, r), e.setUint32(t + l, c, r);
|
|
75
75
|
}
|
|
76
|
-
let
|
|
76
|
+
let Li = class extends Jn {
|
|
77
77
|
constructor(t, n, r, i) {
|
|
78
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 = Kt(this.buffer);
|
|
79
79
|
}
|
|
@@ -95,13 +95,13 @@ let _i = class extends Jn {
|
|
|
95
95
|
return this.length += t.length, this.roundClean(), this;
|
|
96
96
|
}
|
|
97
97
|
digestInto(t) {
|
|
98
|
-
et(this),
|
|
98
|
+
et(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
|
-
|
|
104
|
+
_i(r, i - 8, BigInt(this.length * 8), s), this.process(r, 0);
|
|
105
105
|
const c = Kt(t), a = this.outputLen;
|
|
106
106
|
if (a % 4)
|
|
107
107
|
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
@@ -123,7 +123,7 @@ let _i = class extends Jn {
|
|
|
123
123
|
return t.length = i, t.pos = c, t.finished = s, t.destroyed = o, i % n && t.buffer.set(r), t;
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
|
-
const
|
|
126
|
+
const $i = (e, t, n) => e & t ^ ~e & n, Ri = (e, t, n) => e & t ^ e & n ^ t & n, Ti = /* @__PURE__ */ new Uint32Array([
|
|
127
127
|
1116352408,
|
|
128
128
|
1899447441,
|
|
129
129
|
3049323471,
|
|
@@ -198,7 +198,7 @@ const Li = (e, t, n) => e & t ^ ~e & n, $i = (e, t, n) => e & t ^ e & n ^ t & n,
|
|
|
198
198
|
528734635,
|
|
199
199
|
1541459225
|
|
200
200
|
]), ve = /* @__PURE__ */ new Uint32Array(64);
|
|
201
|
-
let
|
|
201
|
+
let Oi = class extends Li {
|
|
202
202
|
constructor() {
|
|
203
203
|
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;
|
|
204
204
|
}
|
|
@@ -219,7 +219,7 @@ let Ti = class extends _i {
|
|
|
219
219
|
}
|
|
220
220
|
let { A: r, B: i, C: s, D: o, E: c, F: a, G: l, H: f } = this;
|
|
221
221
|
for (let u = 0; u < 64; u++) {
|
|
222
|
-
const p = re(c, 6) ^ re(c, 11) ^ re(c, 25), w = f + p +
|
|
222
|
+
const p = re(c, 6) ^ re(c, 11) ^ re(c, 25), w = f + p + $i(c, a, l) + Ti[u] + ve[u] | 0, h = (re(r, 2) ^ re(r, 13) ^ re(r, 22)) + Ri(r, i, s) | 0;
|
|
223
223
|
f = l, l = a, a = c, c = o + w | 0, o = s, s = i, i = r, r = w + 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, c = c + this.E | 0, a = a + this.F | 0, l = l + this.G | 0, f = f + this.H | 0, this.set(r, i, s, o, c, a, l, f);
|
|
@@ -231,15 +231,15 @@ let Ti = class extends _i {
|
|
|
231
231
|
this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
|
|
232
232
|
}
|
|
233
233
|
};
|
|
234
|
-
const $t = /* @__PURE__ */
|
|
234
|
+
const $t = /* @__PURE__ */ Ui(() => new Oi());
|
|
235
235
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
236
|
-
const Xn = BigInt(0), at = BigInt(1),
|
|
237
|
-
function
|
|
236
|
+
const Xn = BigInt(0), at = BigInt(1), Mi = BigInt(2), ct = (e) => e instanceof Uint8Array, Pi = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
|
|
237
|
+
function De(e) {
|
|
238
238
|
if (!ct(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 += Pi[e[n]];
|
|
243
243
|
return t;
|
|
244
244
|
}
|
|
245
245
|
function Qn(e) {
|
|
@@ -267,12 +267,12 @@ function je(e) {
|
|
|
267
267
|
return n;
|
|
268
268
|
}
|
|
269
269
|
function G(e) {
|
|
270
|
-
return Zt(
|
|
270
|
+
return Zt(De(e));
|
|
271
271
|
}
|
|
272
272
|
function Ft(e) {
|
|
273
273
|
if (!ct(e))
|
|
274
274
|
throw new Error("Uint8Array expected");
|
|
275
|
-
return Zt(
|
|
275
|
+
return Zt(De(Uint8Array.from(e).reverse()));
|
|
276
276
|
}
|
|
277
277
|
function Ne(e, t) {
|
|
278
278
|
return je(e.toString(16).padStart(t * 2, "0"));
|
|
@@ -280,7 +280,7 @@ function Ne(e, t) {
|
|
|
280
280
|
function Gt(e, t) {
|
|
281
281
|
return Ne(e, t).reverse();
|
|
282
282
|
}
|
|
283
|
-
function
|
|
283
|
+
function Hi(e) {
|
|
284
284
|
return je(Qn(e));
|
|
285
285
|
}
|
|
286
286
|
function Z(e, t, n) {
|
|
@@ -309,7 +309,7 @@ function Ie(...e) {
|
|
|
309
309
|
t.set(r, n), n += r.length;
|
|
310
310
|
}), t;
|
|
311
311
|
}
|
|
312
|
-
function
|
|
312
|
+
function qi(e, t) {
|
|
313
313
|
if (e.length !== t.length)
|
|
314
314
|
return !1;
|
|
315
315
|
for (let n = 0; n < e.length; n++)
|
|
@@ -322,16 +322,16 @@ function Di(e) {
|
|
|
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 ji(e) {
|
|
326
326
|
let t;
|
|
327
327
|
for (t = 0; e > Xn; e >>= at, t += 1)
|
|
328
328
|
;
|
|
329
329
|
return t;
|
|
330
330
|
}
|
|
331
|
-
function
|
|
331
|
+
function zi(e, t) {
|
|
332
332
|
return e >> BigInt(t) & at;
|
|
333
333
|
}
|
|
334
|
-
const
|
|
334
|
+
const Wi = (e, t, n) => e | (n ? at : Xn) << BigInt(t), Jt = (e) => (Mi << BigInt(e - 1)) - at, Nt = (e) => new Uint8Array(e), In = (e) => Uint8Array.from(e);
|
|
335
335
|
function er(e, t, n) {
|
|
336
336
|
if (typeof e != "number" || e < 2)
|
|
337
337
|
throw new Error("hashLen must be a number");
|
|
@@ -364,7 +364,7 @@ function er(e, t, n) {
|
|
|
364
364
|
return o(), w;
|
|
365
365
|
};
|
|
366
366
|
}
|
|
367
|
-
const
|
|
367
|
+
const Vi = {
|
|
368
368
|
bigint: (e) => typeof e == "bigint",
|
|
369
369
|
function: (e) => typeof e == "function",
|
|
370
370
|
boolean: (e) => typeof e == "boolean",
|
|
@@ -377,7 +377,7 @@ const Wi = {
|
|
|
377
377
|
};
|
|
378
378
|
function Ye(e, t, n = {}) {
|
|
379
379
|
const r = (i, s, o) => {
|
|
380
|
-
const c =
|
|
380
|
+
const c = Vi[s];
|
|
381
381
|
if (typeof c != "function")
|
|
382
382
|
throw new Error(`Invalid validator "${s}", expected function`);
|
|
383
383
|
const a = 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 Zi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
394
394
|
__proto__: null,
|
|
395
|
-
bitGet:
|
|
396
|
-
bitLen:
|
|
395
|
+
bitGet: zi,
|
|
396
|
+
bitLen: ji,
|
|
397
397
|
bitMask: Jt,
|
|
398
|
-
bitSet:
|
|
399
|
-
bytesToHex:
|
|
398
|
+
bitSet: Wi,
|
|
399
|
+
bytesToHex: De,
|
|
400
400
|
bytesToNumberBE: G,
|
|
401
401
|
bytesToNumberLE: Ft,
|
|
402
402
|
concatBytes: Ie,
|
|
403
403
|
createHmacDrbg: er,
|
|
404
404
|
ensureBytes: Z,
|
|
405
|
-
equalBytes:
|
|
405
|
+
equalBytes: qi,
|
|
406
406
|
hexToBytes: je,
|
|
407
407
|
hexToNumber: Zt,
|
|
408
408
|
numberToBytesBE: Ne,
|
|
409
409
|
numberToBytesLE: Gt,
|
|
410
410
|
numberToHexUnpadded: Qn,
|
|
411
|
-
numberToVarBytesBE:
|
|
411
|
+
numberToVarBytesBE: Hi,
|
|
412
412
|
utf8ToBytes: Di,
|
|
413
413
|
validateObject: Ye
|
|
414
414
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
415
415
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
416
|
-
const W = BigInt(0), z = BigInt(1), Ce = BigInt(2),
|
|
416
|
+
const W = BigInt(0), z = BigInt(1), Ce = BigInt(2), Fi = BigInt(3), Rt = BigInt(4), Un = BigInt(5), _n = BigInt(8);
|
|
417
417
|
BigInt(9);
|
|
418
418
|
BigInt(16);
|
|
419
419
|
function V(e, t) {
|
|
420
420
|
const n = e % t;
|
|
421
421
|
return n >= W ? n : t + n;
|
|
422
422
|
}
|
|
423
|
-
function
|
|
423
|
+
function Gi(e, t, n) {
|
|
424
424
|
if (n <= W || t < W)
|
|
425
425
|
throw new Error("Expected power/modulo > 0");
|
|
426
426
|
if (n === z)
|
|
@@ -448,12 +448,12 @@ function Tt(e, t) {
|
|
|
448
448
|
throw new Error("invert: does not exist");
|
|
449
449
|
return V(i, t);
|
|
450
450
|
}
|
|
451
|
-
function
|
|
451
|
+
function Ji(e) {
|
|
452
452
|
const t = (e - z) / Ce;
|
|
453
453
|
let n, r, i;
|
|
454
454
|
for (n = e - z, r = 0; n % Ce === W; n /= Ce, r++)
|
|
455
455
|
;
|
|
456
|
-
for (i = Ce; i < e &&
|
|
456
|
+
for (i = Ce; i < e && Gi(i, t, e) !== e - z; i++)
|
|
457
457
|
;
|
|
458
458
|
if (r === 1) {
|
|
459
459
|
const o = (e + z) / Rt;
|
|
@@ -481,8 +481,8 @@ function Gi(e) {
|
|
|
481
481
|
return u;
|
|
482
482
|
};
|
|
483
483
|
}
|
|
484
|
-
function
|
|
485
|
-
if (e % Rt ===
|
|
484
|
+
function Yi(e) {
|
|
485
|
+
if (e % Rt === Fi) {
|
|
486
486
|
const t = (e + z) / Rt;
|
|
487
487
|
return function(r, i) {
|
|
488
488
|
const s = r.pow(i, t);
|
|
@@ -500,9 +500,9 @@ function Ji(e) {
|
|
|
500
500
|
return l;
|
|
501
501
|
};
|
|
502
502
|
}
|
|
503
|
-
return
|
|
503
|
+
return Ji(e);
|
|
504
504
|
}
|
|
505
|
-
const
|
|
505
|
+
const Xi = [
|
|
506
506
|
"create",
|
|
507
507
|
"isValid",
|
|
508
508
|
"is0",
|
|
@@ -521,16 +521,16 @@ const Yi = [
|
|
|
521
521
|
"mulN",
|
|
522
522
|
"sqrN"
|
|
523
523
|
];
|
|
524
|
-
function
|
|
524
|
+
function Qi(e) {
|
|
525
525
|
const t = {
|
|
526
526
|
ORDER: "bigint",
|
|
527
527
|
MASK: "bigint",
|
|
528
528
|
BYTES: "isSafeInteger",
|
|
529
529
|
BITS: "isSafeInteger"
|
|
530
|
-
}, n =
|
|
530
|
+
}, n = Xi.reduce((r, i) => (r[i] = "function", r), t);
|
|
531
531
|
return Ye(e, n);
|
|
532
532
|
}
|
|
533
|
-
function
|
|
533
|
+
function es(e, t, n) {
|
|
534
534
|
if (n < W)
|
|
535
535
|
throw new Error("Expected power > 0");
|
|
536
536
|
if (n === W)
|
|
@@ -542,7 +542,7 @@ function Qi(e, t, n) {
|
|
|
542
542
|
n & z && (r = e.mul(r, i)), i = e.sqr(i), n >>= z;
|
|
543
543
|
return r;
|
|
544
544
|
}
|
|
545
|
-
function
|
|
545
|
+
function ts(e, t) {
|
|
546
546
|
const n = new Array(t.length), r = t.reduce((s, o, c) => e.is0(o) ? s : (n[c] = s, e.mul(s, o)), e.ONE), i = e.inv(r);
|
|
547
547
|
return t.reduceRight((s, o, c) => e.is0(o) ? s : (n[c] = e.mul(s, n[c]), e.mul(s, o)), i), n;
|
|
548
548
|
}
|
|
@@ -550,13 +550,13 @@ function tr(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 ns(e, t, n = !1, r = {}) {
|
|
554
554
|
if (e <= W)
|
|
555
555
|
throw new Error(`Expected Field ORDER > 0, got ${e}`);
|
|
556
556
|
const { nBitLength: i, nByteLength: s } = tr(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 = Yi(e), c = Object.freeze({
|
|
560
560
|
ORDER: e,
|
|
561
561
|
BITS: i,
|
|
562
562
|
BYTES: s,
|
|
@@ -577,7 +577,7 @@ function ts(e, t, n = !1, r = {}) {
|
|
|
577
577
|
add: (a, l) => V(a + l, e),
|
|
578
578
|
sub: (a, l) => V(a - l, e),
|
|
579
579
|
mul: (a, l) => V(a * l, e),
|
|
580
|
-
pow: (a, l) =>
|
|
580
|
+
pow: (a, l) => es(c, a, l),
|
|
581
581
|
div: (a, l) => V(a * Tt(l, e), e),
|
|
582
582
|
// Same as above, but doesn't normalize
|
|
583
583
|
sqrN: (a) => a * a,
|
|
@@ -586,7 +586,7 @@ function ts(e, t, n = !1, r = {}) {
|
|
|
586
586
|
mulN: (a, l) => a * l,
|
|
587
587
|
inv: (a) => Tt(a, e),
|
|
588
588
|
sqrt: r.sqrt || ((a) => o(c, a)),
|
|
589
|
-
invertBatch: (a) =>
|
|
589
|
+
invertBatch: (a) => ts(c, a),
|
|
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: (a, l, f) => f ? l : a,
|
|
@@ -609,7 +609,7 @@ function rr(e) {
|
|
|
609
609
|
const t = nr(e);
|
|
610
610
|
return t + Math.ceil(t / 2);
|
|
611
611
|
}
|
|
612
|
-
function
|
|
612
|
+
function rs(e, t, n = !1) {
|
|
613
613
|
const r = e.length, i = nr(t), s = rr(t);
|
|
614
614
|
if (r < 16 || r < s || r > 1024)
|
|
615
615
|
throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);
|
|
@@ -617,8 +617,8 @@ function ns(e, t, n = !1) {
|
|
|
617
617
|
return n ? Gt(c, i) : Ne(c, i);
|
|
618
618
|
}
|
|
619
619
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
620
|
-
const
|
|
621
|
-
function
|
|
620
|
+
const is = BigInt(0), St = BigInt(1);
|
|
621
|
+
function ss(e, t) {
|
|
622
622
|
const n = (i, s) => {
|
|
623
623
|
const o = s.negate();
|
|
624
624
|
return i ? o : s;
|
|
@@ -631,7 +631,7 @@ function is(e, t) {
|
|
|
631
631
|
// non-const time multiplication ladder
|
|
632
632
|
unsafeLadder(i, s) {
|
|
633
633
|
let o = e.ZERO, c = i;
|
|
634
|
-
for (; s >
|
|
634
|
+
for (; s > is; )
|
|
635
635
|
s & St && (o = o.add(c)), c = c.double(), s >>= St;
|
|
636
636
|
return o;
|
|
637
637
|
},
|
|
@@ -684,7 +684,7 @@ function is(e, t) {
|
|
|
684
684
|
};
|
|
685
685
|
}
|
|
686
686
|
function ir(e) {
|
|
687
|
-
return
|
|
687
|
+
return Qi(e.Fp), Ye(e, {
|
|
688
688
|
n: "bigint",
|
|
689
689
|
h: "bigint",
|
|
690
690
|
Gx: "field",
|
|
@@ -699,7 +699,7 @@ function ir(e) {
|
|
|
699
699
|
});
|
|
700
700
|
}
|
|
701
701
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
702
|
-
function
|
|
702
|
+
function os(e) {
|
|
703
703
|
const t = ir(e);
|
|
704
704
|
Ye(t, {
|
|
705
705
|
a: "field",
|
|
@@ -722,7 +722,7 @@ function ss(e) {
|
|
|
722
722
|
}
|
|
723
723
|
return Object.freeze({ ...t });
|
|
724
724
|
}
|
|
725
|
-
const { bytesToNumberBE:
|
|
725
|
+
const { bytesToNumberBE: as, hexToBytes: cs } = Zi, ke = {
|
|
726
726
|
// asn.1 DER encoding utils
|
|
727
727
|
Err: class extends Error {
|
|
728
728
|
constructor(t = "") {
|
|
@@ -740,10 +740,10 @@ const { bytesToNumberBE: os, hexToBytes: as } = Vi, ke = {
|
|
|
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: as(r), l: e.subarray(n + 2) };
|
|
744
744
|
},
|
|
745
745
|
toSig(e) {
|
|
746
|
-
const { Err: t } = ke, n = typeof e == "string" ?
|
|
746
|
+
const { Err: t } = ke, n = typeof e == "string" ? cs(e) : e;
|
|
747
747
|
if (!(n instanceof Uint8Array))
|
|
748
748
|
throw new Error("ui8a expected");
|
|
749
749
|
let r = n.length;
|
|
@@ -767,8 +767,8 @@ const { bytesToNumberBE: os, hexToBytes: as } = Vi, ke = {
|
|
|
767
767
|
BigInt(2);
|
|
768
768
|
const Ln = BigInt(3);
|
|
769
769
|
BigInt(4);
|
|
770
|
-
function
|
|
771
|
-
const t =
|
|
770
|
+
function us(e) {
|
|
771
|
+
const t = os(e), { Fp: n } = t, r = t.toBytes || ((g, h, d) => {
|
|
772
772
|
const y = h.toAffine();
|
|
773
773
|
return Ie(Uint8Array.from([4]), n.toBytes(y.x), n.toBytes(y.y));
|
|
774
774
|
}), i = t.fromBytes || ((g) => {
|
|
@@ -791,7 +791,7 @@ function cs(e) {
|
|
|
791
791
|
function a(g) {
|
|
792
792
|
const { allowedPrivateKeyLengths: h, nByteLength: d, wrapPrivateKey: y, n: m } = t;
|
|
793
793
|
if (h && typeof g != "bigint") {
|
|
794
|
-
if (g instanceof Uint8Array && (g =
|
|
794
|
+
if (g instanceof Uint8Array && (g = De(g)), typeof g != "string" || !h.includes(g.length))
|
|
795
795
|
throw new Error("Invalid key");
|
|
796
796
|
g = g.padStart(d * 2, "0");
|
|
797
797
|
}
|
|
@@ -914,10 +914,10 @@ function cs(e) {
|
|
|
914
914
|
const { px: d, py: y, pz: m } = this, { px: S, py: U, pz: k } = h;
|
|
915
915
|
let E = n.ZERO, x = n.ZERO, K = n.ZERO;
|
|
916
916
|
const M = t.a, I = n.mul(t.b, Ln);
|
|
917
|
-
let A = n.mul(d, S), R = n.mul(y, U), T = n.mul(m, k),
|
|
918
|
-
|
|
917
|
+
let A = n.mul(d, S), R = n.mul(y, U), T = n.mul(m, k), q = n.add(d, y), b = n.add(S, U);
|
|
918
|
+
q = n.mul(q, b), b = n.add(A, R), q = n.sub(q, b), b = n.add(d, m);
|
|
919
919
|
let v = n.add(S, k);
|
|
920
|
-
return b = n.mul(b, v), v = n.add(A, T), b = n.sub(b, v), v = n.add(y, m), E = n.add(U, k), v = n.mul(v, E), E = n.add(R, T), v = n.sub(v, E), K = n.mul(M, b), E = n.mul(I, T), K = n.add(E, K), E = n.sub(R, K), K = n.add(R, K), x = n.mul(E, K), R = n.add(A, A), R = n.add(R, A), T = n.mul(M, T), b = n.mul(I, b), R = n.add(R, T), T = n.sub(A, T), T = n.mul(M, T), b = n.add(b, T), A = n.mul(R, b), x = n.add(x, A), A = n.mul(v, b), E = n.mul(
|
|
920
|
+
return b = n.mul(b, v), v = n.add(A, T), b = n.sub(b, v), v = n.add(y, m), E = n.add(U, k), v = n.mul(v, E), E = n.add(R, T), v = n.sub(v, E), K = n.mul(M, b), E = n.mul(I, T), K = n.add(E, K), E = n.sub(R, K), K = n.add(R, K), x = n.mul(E, K), R = n.add(A, A), R = n.add(R, A), T = n.mul(M, T), b = n.mul(I, b), R = n.add(R, T), T = n.sub(A, T), T = n.mul(M, T), b = n.add(b, T), A = n.mul(R, b), x = n.add(x, A), A = n.mul(v, b), E = n.mul(q, E), E = n.sub(E, A), A = n.mul(q, R), K = n.mul(v, K), K = n.add(K, A), new u(E, x, K);
|
|
921
921
|
}
|
|
922
922
|
subtract(h) {
|
|
923
923
|
return this.add(h.negate());
|
|
@@ -1012,11 +1012,11 @@ function cs(e) {
|
|
|
1012
1012
|
return this.assertValidity(), r(u, this, h);
|
|
1013
1013
|
}
|
|
1014
1014
|
toHex(h = !0) {
|
|
1015
|
-
return
|
|
1015
|
+
return De(this.toRawBytes(h));
|
|
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 p = t.nBitLength, w =
|
|
1019
|
+
const p = t.nBitLength, w = ss(u, t.endo ? Math.ceil(p / 2) : p);
|
|
1020
1020
|
return {
|
|
1021
1021
|
CURVE: t,
|
|
1022
1022
|
ProjectivePoint: u,
|
|
@@ -1025,7 +1025,7 @@ function cs(e) {
|
|
|
1025
1025
|
isWithinCurveOrder: o
|
|
1026
1026
|
};
|
|
1027
1027
|
}
|
|
1028
|
-
function
|
|
1028
|
+
function ls(e) {
|
|
1029
1029
|
const t = ir(e);
|
|
1030
1030
|
return Ye(t, {
|
|
1031
1031
|
hash: "hash",
|
|
@@ -1037,8 +1037,8 @@ function us(e) {
|
|
|
1037
1037
|
lowS: "boolean"
|
|
1038
1038
|
}), Object.freeze({ lowS: !0, ...t });
|
|
1039
1039
|
}
|
|
1040
|
-
function
|
|
1041
|
-
const t =
|
|
1040
|
+
function fs(e) {
|
|
1041
|
+
const t = ls(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
|
}
|
|
@@ -1048,7 +1048,7 @@ function ls(e) {
|
|
|
1048
1048
|
function a(b) {
|
|
1049
1049
|
return Tt(b, r);
|
|
1050
1050
|
}
|
|
1051
|
-
const { ProjectivePoint: l, normPrivateKeyToScalar: f, weierstrassEquation: u, isWithinCurveOrder: p } =
|
|
1051
|
+
const { ProjectivePoint: l, normPrivateKeyToScalar: f, weierstrassEquation: u, isWithinCurveOrder: p } = us({
|
|
1052
1052
|
...t,
|
|
1053
1053
|
toBytes(b, v, N) {
|
|
1054
1054
|
const B = v.toAffine(), C = n.toBytes(B.x), _ = Ie;
|
|
@@ -1070,7 +1070,7 @@ function ls(e) {
|
|
|
1070
1070
|
} else
|
|
1071
1071
|
throw new Error(`Point of length ${v} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`);
|
|
1072
1072
|
}
|
|
1073
|
-
}), w = (b) =>
|
|
1073
|
+
}), w = (b) => De(Ne(b, t.nByteLength));
|
|
1074
1074
|
function g(b) {
|
|
1075
1075
|
const v = r >> X;
|
|
1076
1076
|
return b > v;
|
|
@@ -1152,7 +1152,7 @@ function ls(e) {
|
|
|
1152
1152
|
*/
|
|
1153
1153
|
randomPrivateKey: () => {
|
|
1154
1154
|
const b = rr(t.n);
|
|
1155
|
-
return
|
|
1155
|
+
return rs(t.randomBytes(b), t.n);
|
|
1156
1156
|
},
|
|
1157
1157
|
/**
|
|
1158
1158
|
* Creates precompute table for an arbitrary EC point. Makes point "cached".
|
|
@@ -1226,7 +1226,7 @@ function ls(e) {
|
|
|
1226
1226
|
return er(_.hash.outputLen, _.nByteLength, _.hmac)(B, C);
|
|
1227
1227
|
}
|
|
1228
1228
|
l.BASE._setWindowSize(8);
|
|
1229
|
-
function
|
|
1229
|
+
function q(b, v, N, B = R) {
|
|
1230
1230
|
var $e;
|
|
1231
1231
|
const C = b;
|
|
1232
1232
|
if (v = Z("msgHash", v), N = Z("publicKey", N), "strict" in B)
|
|
@@ -1264,7 +1264,7 @@ function ls(e) {
|
|
|
1264
1264
|
getPublicKey: S,
|
|
1265
1265
|
getSharedSecret: k,
|
|
1266
1266
|
sign: T,
|
|
1267
|
-
verify:
|
|
1267
|
+
verify: q,
|
|
1268
1268
|
ProjectivePoint: l,
|
|
1269
1269
|
Signature: y,
|
|
1270
1270
|
utils: m
|
|
@@ -1272,7 +1272,7 @@ function ls(e) {
|
|
|
1272
1272
|
}
|
|
1273
1273
|
let sr = class extends Jn {
|
|
1274
1274
|
constructor(t, n) {
|
|
1275
|
-
super(), this.finished = !1, this.destroyed = !1,
|
|
1275
|
+
super(), this.finished = !1, this.destroyed = !1, Ai(t);
|
|
1276
1276
|
const r = Vt(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");
|
|
@@ -1308,15 +1308,15 @@ let sr = class extends Jn {
|
|
|
1308
1308
|
const or = (e, t, n) => new sr(e, t).update(n).digest();
|
|
1309
1309
|
or.create = (e, t) => new sr(e, t);
|
|
1310
1310
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
1311
|
-
function
|
|
1311
|
+
function hs(e) {
|
|
1312
1312
|
return {
|
|
1313
1313
|
hash: e,
|
|
1314
|
-
hmac: (t, ...n) => or(e, t,
|
|
1314
|
+
hmac: (t, ...n) => or(e, t, Ii(...n)),
|
|
1315
1315
|
randomBytes: Yn
|
|
1316
1316
|
};
|
|
1317
1317
|
}
|
|
1318
|
-
function
|
|
1319
|
-
const n = (r) =>
|
|
1318
|
+
function ds(e, t) {
|
|
1319
|
+
const n = (r) => fs({ ...e, ...hs(r) });
|
|
1320
1320
|
return Object.freeze({ ...n(t), create: n });
|
|
1321
1321
|
}
|
|
1322
1322
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
@@ -1327,7 +1327,7 @@ function cr(e) {
|
|
|
1327
1327
|
throw new Error("Cannot find square root");
|
|
1328
1328
|
return E;
|
|
1329
1329
|
}
|
|
1330
|
-
const Ot =
|
|
1330
|
+
const Ot = ns(ut, void 0, void 0, { sqrt: cr }), Ue = ds({
|
|
1331
1331
|
a: BigInt(0),
|
|
1332
1332
|
b: BigInt(7),
|
|
1333
1333
|
Fp: Ot,
|
|
@@ -1354,7 +1354,7 @@ const Ot = ts(ut, void 0, void 0, { sqrt: cr }), Ue = hs({
|
|
|
1354
1354
|
return { k1neg: u, k1: l, k2neg: p, k2: f };
|
|
1355
1355
|
}
|
|
1356
1356
|
}
|
|
1357
|
-
}, $t), lt = BigInt(0), ur = (e) => typeof e == "bigint" && lt < e && e < ut,
|
|
1357
|
+
}, $t), lt = BigInt(0), ur = (e) => typeof e == "bigint" && lt < e && e < ut, ys = (e) => typeof e == "bigint" && lt < e && e < tt, Rn = {};
|
|
1358
1358
|
function rt(e, ...t) {
|
|
1359
1359
|
let n = Rn[e];
|
|
1360
1360
|
if (n === void 0) {
|
|
@@ -1363,7 +1363,7 @@ function rt(e, ...t) {
|
|
|
1363
1363
|
}
|
|
1364
1364
|
return $t(Ie(n, ...t));
|
|
1365
1365
|
}
|
|
1366
|
-
const Yt = (e) => e.toRawBytes(!0).slice(1), Mt = (e) => Ne(e, 32), At = (e) => V(e, ut), Ge = (e) => V(e, tt), Xt = Ue.ProjectivePoint,
|
|
1366
|
+
const Yt = (e) => e.toRawBytes(!0).slice(1), Mt = (e) => Ne(e, 32), At = (e) => V(e, ut), Ge = (e) => V(e, tt), Xt = Ue.ProjectivePoint, ps = (e, t, n) => Xt.BASE.multiplyAndAddUnsafe(e, t, n);
|
|
1367
1367
|
function Pt(e) {
|
|
1368
1368
|
let t = Ue.utils.normPrivateKeyToScalar(e), n = Xt.fromPrivateKey(t);
|
|
1369
1369
|
return { scalar: n.hasEvenY() ? t : Ge(-t), bytes: Yt(n) };
|
|
@@ -1380,10 +1380,10 @@ function lr(e) {
|
|
|
1380
1380
|
function fr(...e) {
|
|
1381
1381
|
return Ge(G(rt("BIP0340/challenge", ...e)));
|
|
1382
1382
|
}
|
|
1383
|
-
function
|
|
1383
|
+
function gs(e) {
|
|
1384
1384
|
return Pt(e).bytes;
|
|
1385
1385
|
}
|
|
1386
|
-
function
|
|
1386
|
+
function ws(e, t, n = Yn(32)) {
|
|
1387
1387
|
const r = Z("message", e), { bytes: i, scalar: s } = Pt(t), o = Z("auxRand", n, 32), c = Mt(s ^ G(rt("BIP0340/aux", o))), a = rt("BIP0340/nonce", c, i, r), l = Ge(G(a));
|
|
1388
1388
|
if (l === lt)
|
|
1389
1389
|
throw new Error("sign failed: k is zero");
|
|
@@ -1399,17 +1399,17 @@ function hr(e, t, n) {
|
|
|
1399
1399
|
if (!ur(c))
|
|
1400
1400
|
return !1;
|
|
1401
1401
|
const a = G(r.subarray(32, 64));
|
|
1402
|
-
if (!
|
|
1402
|
+
if (!ys(a))
|
|
1403
1403
|
return !1;
|
|
1404
|
-
const l = fr(Mt(c), Yt(o), i), f =
|
|
1404
|
+
const l = fr(Mt(c), Yt(o), i), f = ps(o, a, Ge(-l));
|
|
1405
1405
|
return !(!f || !f.hasEvenY() || f.toAffine().x !== c);
|
|
1406
1406
|
} catch {
|
|
1407
1407
|
return !1;
|
|
1408
1408
|
}
|
|
1409
1409
|
}
|
|
1410
1410
|
const Ze = {
|
|
1411
|
-
getPublicKey:
|
|
1412
|
-
sign:
|
|
1411
|
+
getPublicKey: gs,
|
|
1412
|
+
sign: ws,
|
|
1413
1413
|
verify: hr,
|
|
1414
1414
|
utils: {
|
|
1415
1415
|
randomPrivateKey: Ue.utils.randomPrivateKey,
|
|
@@ -1422,16 +1422,16 @@ const Ze = {
|
|
|
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 Qt = (e) => e instanceof Uint8Array, kt = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), ie = (e, t) => e << 32 - t | e >>> t,
|
|
1426
|
-
if (!
|
|
1425
|
+
const Qt = (e) => e instanceof Uint8Array, kt = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), ie = (e, t) => e << 32 - t | e >>> t, bs = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
1426
|
+
if (!bs)
|
|
1427
1427
|
throw new Error("Non little-endian hardware is not supported");
|
|
1428
|
-
const
|
|
1428
|
+
const vs = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
|
|
1429
1429
|
function P(e) {
|
|
1430
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 += vs[e[n]];
|
|
1435
1435
|
return t;
|
|
1436
1436
|
}
|
|
1437
1437
|
function j(e) {
|
|
@@ -1449,13 +1449,13 @@ function j(e) {
|
|
|
1449
1449
|
}
|
|
1450
1450
|
return n;
|
|
1451
1451
|
}
|
|
1452
|
-
function
|
|
1452
|
+
function ms(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
1457
|
function Je(e) {
|
|
1458
|
-
if (typeof e == "string" && (e =
|
|
1458
|
+
if (typeof e == "string" && (e = ms(e)), !Qt(e))
|
|
1459
1459
|
throw new Error(`expected Uint8Array, got ${typeof e}`);
|
|
1460
1460
|
return e;
|
|
1461
1461
|
}
|
|
@@ -1487,7 +1487,7 @@ 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 Es(e) {
|
|
1491
1491
|
if (typeof e != "boolean")
|
|
1492
1492
|
throw new Error(`Expected boolean, not ${e}`);
|
|
1493
1493
|
}
|
|
@@ -1497,18 +1497,18 @@ function gr(e, ...t) {
|
|
|
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 xs(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 Ks(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
|
|
1511
|
+
function Ns(e, t) {
|
|
1512
1512
|
gr(e);
|
|
1513
1513
|
const n = t.outputLen;
|
|
1514
1514
|
if (e.length < n)
|
|
@@ -1516,19 +1516,19 @@ function Ks(e, t) {
|
|
|
1516
1516
|
}
|
|
1517
1517
|
const se = {
|
|
1518
1518
|
number: Ht,
|
|
1519
|
-
bool:
|
|
1519
|
+
bool: Es,
|
|
1520
1520
|
bytes: gr,
|
|
1521
|
-
hash:
|
|
1522
|
-
exists:
|
|
1523
|
-
output:
|
|
1521
|
+
hash: xs,
|
|
1522
|
+
exists: Ks,
|
|
1523
|
+
output: Ns
|
|
1524
1524
|
};
|
|
1525
|
-
function
|
|
1525
|
+
function Ss(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), c = Number(n & s), a = r ? 4 : 0, l = r ? 0 : 4;
|
|
1529
1529
|
e.setUint32(t + a, o, r), e.setUint32(t + l, c, r);
|
|
1530
1530
|
}
|
|
1531
|
-
class
|
|
1531
|
+
class As extends dr {
|
|
1532
1532
|
constructor(t, n, r, i) {
|
|
1533
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
|
}
|
|
@@ -1556,7 +1556,7 @@ class Ss extends dr {
|
|
|
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
|
-
|
|
1559
|
+
Ss(r, i - 8, BigInt(this.length * 8), s), this.process(r, 0);
|
|
1560
1560
|
const c = kt(t), a = this.outputLen;
|
|
1561
1561
|
if (a % 4)
|
|
1562
1562
|
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
@@ -1578,7 +1578,7 @@ class Ss extends dr {
|
|
|
1578
1578
|
return t.length = i, t.pos = c, 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, ks = (e, t, n) => e & t ^ e & n ^ t & n, Bs = new Uint32Array([
|
|
1582
1582
|
1116352408,
|
|
1583
1583
|
1899447441,
|
|
1584
1584
|
3049323471,
|
|
@@ -1653,7 +1653,7 @@ const As = (e, t, n) => e & t ^ ~e & n, Cs = (e, t, n) => e & t ^ e & n ^ t & n,
|
|
|
1653
1653
|
528734635,
|
|
1654
1654
|
1541459225
|
|
1655
1655
|
]), Ee = new Uint32Array(64);
|
|
1656
|
-
class wr extends
|
|
1656
|
+
class wr extends As {
|
|
1657
1657
|
constructor() {
|
|
1658
1658
|
super(64, 32, 8, !1), this.A = me[0] | 0, this.B = me[1] | 0, this.C = me[2] | 0, this.D = me[3] | 0, this.E = me[4] | 0, this.F = me[5] | 0, this.G = me[6] | 0, this.H = me[7] | 0;
|
|
1659
1659
|
}
|
|
@@ -1674,7 +1674,7 @@ class wr extends Ss {
|
|
|
1674
1674
|
}
|
|
1675
1675
|
let { A: r, B: i, C: s, D: o, E: c, F: a, G: l, H: f } = this;
|
|
1676
1676
|
for (let u = 0; u < 64; u++) {
|
|
1677
|
-
const p = ie(c, 6) ^ ie(c, 11) ^ ie(c, 25), w = f + p +
|
|
1677
|
+
const p = ie(c, 6) ^ ie(c, 11) ^ ie(c, 25), w = f + p + Cs(c, a, l) + Bs[u] + Ee[u] | 0, h = (ie(r, 2) ^ ie(r, 13) ^ ie(r, 22)) + ks(r, i, s) | 0;
|
|
1678
1678
|
f = l, l = a, a = c, c = o + w | 0, o = s, s = i, i = r, r = w + 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, c = c + this.E | 0, a = a + this.F | 0, l = l + this.G | 0, f = f + this.H | 0, this.set(r, i, s, o, c, a, l, f);
|
|
@@ -1686,13 +1686,13 @@ class wr extends Ss {
|
|
|
1686
1686
|
this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
|
|
1687
1687
|
}
|
|
1688
1688
|
}
|
|
1689
|
-
class
|
|
1689
|
+
class Is extends wr {
|
|
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
1694
|
const fe = yr(() => new wr());
|
|
1695
|
-
yr(() => new
|
|
1695
|
+
yr(() => new Is());
|
|
1696
1696
|
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
1697
1697
|
function We(e) {
|
|
1698
1698
|
if (!Number.isSafeInteger(e))
|
|
@@ -1815,7 +1815,7 @@ function Tn(e, t, n) {
|
|
|
1815
1815
|
return i.reverse();
|
|
1816
1816
|
}
|
|
1817
1817
|
const vr = (e, t) => t ? vr(t, e % t) : e, it = (e, t) => e + (t - vr(e, t));
|
|
1818
|
-
function
|
|
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)
|
|
@@ -1841,7 +1841,7 @@ function Dt(e, t, n, r) {
|
|
|
1841
1841
|
throw new Error(`Non-zero padding: ${i}`);
|
|
1842
1842
|
return r && s > 0 && c.push(i >>> 0), c;
|
|
1843
1843
|
}
|
|
1844
|
-
function
|
|
1844
|
+
function Us(e) {
|
|
1845
1845
|
return We(e), {
|
|
1846
1846
|
encode: (t) => {
|
|
1847
1847
|
if (!(t instanceof Uint8Array))
|
|
@@ -1864,12 +1864,12 @@ function Se(e, t = !1) {
|
|
|
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
|
}
|
|
@@ -1883,25 +1883,25 @@ function On(e) {
|
|
|
1883
1883
|
}
|
|
1884
1884
|
};
|
|
1885
1885
|
}
|
|
1886
|
-
const
|
|
1886
|
+
const _s = de(Se(4), ye("0123456789ABCDEF"), pe("")), Ls = de(Se(5), ye("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), ht(5), pe(""));
|
|
1887
1887
|
de(Se(5), ye("0123456789ABCDEFGHIJKLMNOPQRSTUV"), ht(5), pe(""));
|
|
1888
1888
|
de(Se(5), ye("0123456789ABCDEFGHJKMNPQRSTVWXYZ"), pe(""), br((e) => e.toUpperCase().replace(/O/g, "0").replace(/[IL]/g, "1")));
|
|
1889
|
-
const he = de(Se(6), ye("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), ht(6), pe("")),
|
|
1889
|
+
const he = de(Se(6), ye("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), ht(6), pe("")), $s = de(Se(6), ye("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), ht(6), pe("")), en = (e) => de(Us(58), ye(e), pe("")), Dt = en("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
1890
1890
|
en("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ");
|
|
1891
1891
|
en("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");
|
|
1892
|
-
const Mn = [0, 2, 3, 5, 6, 7, 9, 10, 11],
|
|
1892
|
+
const Mn = [0, 2, 3, 5, 6, 7, 9, 10, 11], Rs = {
|
|
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(Mn[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 = Mn.indexOf(r.length), s =
|
|
1904
|
+
const r = e.slice(n, n + 11), i = Mn.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");
|
|
@@ -1933,7 +1933,7 @@ function Hn(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, jt.encode(
|
|
1936
|
+
return i ^= n, jt.encode(qt([i % 2 ** 30], 30, 5, !1));
|
|
1937
1937
|
}
|
|
1938
1938
|
function mr(e) {
|
|
1939
1939
|
const t = e === "bech32" ? 1 : 734539939, n = Se(5), r = n.decode, i = n.encode, s = On(r);
|
|
@@ -1976,46 +1976,46 @@ function mr(e) {
|
|
|
1976
1976
|
}
|
|
1977
1977
|
const ze = mr("bech32");
|
|
1978
1978
|
mr("bech32m");
|
|
1979
|
-
const
|
|
1979
|
+
const Ts = {
|
|
1980
1980
|
encode: (e) => new TextDecoder().decode(e),
|
|
1981
1981
|
decode: (e) => new TextEncoder().encode(e)
|
|
1982
|
-
},
|
|
1982
|
+
}, Os = de(Se(4), ye("0123456789abcdef"), pe(""), br((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
|
+
})), Ms = {
|
|
1987
|
+
utf8: Ts,
|
|
1988
|
+
hex: Os,
|
|
1989
|
+
base16: _s,
|
|
1990
|
+
base32: Ls,
|
|
1991
1991
|
base64: he,
|
|
1992
|
-
base64url:
|
|
1993
|
-
base58:
|
|
1994
|
-
base58xmr:
|
|
1992
|
+
base64url: $s,
|
|
1993
|
+
base58: Dt,
|
|
1994
|
+
base58xmr: Rs
|
|
1995
1995
|
};
|
|
1996
|
-
`${Object.keys(
|
|
1996
|
+
`${Object.keys(Ms).join(", ")}`;
|
|
1997
1997
|
function Bt(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 qn(e) {
|
|
2002
2002
|
if (typeof e != "boolean")
|
|
2003
2003
|
throw new Error(`boolean expected, not ${e}`);
|
|
2004
2004
|
}
|
|
2005
|
-
function
|
|
2005
|
+
function Ps(e) {
|
|
2006
2006
|
return e instanceof Uint8Array || e != null && typeof e == "object" && e.constructor.name === "Uint8Array";
|
|
2007
2007
|
}
|
|
2008
2008
|
function ue(e, ...t) {
|
|
2009
|
-
if (!
|
|
2009
|
+
if (!Ps(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)), Hs = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
2016
|
+
if (!Hs)
|
|
2017
2017
|
throw new Error("Non little-endian hardware is not supported");
|
|
2018
|
-
function
|
|
2018
|
+
function qs(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);
|
|
@@ -2028,9 +2028,9 @@ function Ds(e, t) {
|
|
|
2028
2028
|
n |= e[r] ^ t[r];
|
|
2029
2029
|
return n === 0;
|
|
2030
2030
|
}
|
|
2031
|
-
const
|
|
2031
|
+
const js = /* @__NO_SIDE_EFFECTS__ */ (e, t) => (Object.assign(t, e), t), Ke = 16, zs = 283;
|
|
2032
2032
|
function tn(e) {
|
|
2033
|
-
return e << 1 ^
|
|
2033
|
+
return e << 1 ^ zs & -(e >> 7);
|
|
2034
2034
|
}
|
|
2035
2035
|
function He(e, t) {
|
|
2036
2036
|
let n = 0;
|
|
@@ -2049,7 +2049,7 @@ 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
|
-
})(),
|
|
2052
|
+
})(), Ws = /* @__PURE__ */ zt.map((e, t) => zt.indexOf(t)), Vs = (e) => e << 24 | e >>> 8, It = (e) => e << 8 | e >>> 24;
|
|
2053
2053
|
function Er(e, t) {
|
|
2054
2054
|
if (e.length !== 256)
|
|
2055
2055
|
throw new Error("Wrong sbox length");
|
|
@@ -2061,7 +2061,7 @@ function Er(e, t) {
|
|
|
2061
2061
|
}
|
|
2062
2062
|
return { sbox: e, sbox2: a, T0: n, T1: r, T2: i, T3: s, T01: o, T23: c };
|
|
2063
2063
|
}
|
|
2064
|
-
const nn = /* @__PURE__ */ Er(zt, (e) => He(e, 3) << 24 | e << 16 | e << 8 | He(e, 2)), xr = /* @__PURE__ */ Er(
|
|
2064
|
+
const nn = /* @__PURE__ */ Er(zt, (e) => He(e, 3) << 24 | e << 16 | e << 8 | He(e, 2)), xr = /* @__PURE__ */ Er(Ws, (e) => He(e, 11) << 24 | He(e, 13) << 16 | He(e, 9) << 8 | He(e, 14)), Zs = /* @__PURE__ */ (() => {
|
|
2065
2065
|
const e = new Uint8Array(16);
|
|
2066
2066
|
for (let t = 0, n = 1; t < 16; t++, n = tn(n))
|
|
2067
2067
|
e[t] = n;
|
|
@@ -2076,11 +2076,11 @@ function Kr(e) {
|
|
|
2076
2076
|
o.set(r);
|
|
2077
2077
|
for (let c = i; c < o.length; c++) {
|
|
2078
2078
|
let a = o[c - 1];
|
|
2079
|
-
c % i === 0 ? a = s(
|
|
2079
|
+
c % i === 0 ? a = s(Vs(a)) ^ Zs[c / i - 1] : i > 6 && c % i === 4 && (a = s(a)), o[c] = o[c - i] ^ a;
|
|
2080
2080
|
}
|
|
2081
2081
|
return o;
|
|
2082
2082
|
}
|
|
2083
|
-
function
|
|
2083
|
+
function Fs(e) {
|
|
2084
2084
|
const t = Kr(e), n = t.slice(), r = t.length, { sbox2: i } = nn, { T0: s, T1: o, T2: c, T3: a } = xr;
|
|
2085
2085
|
for (let l = 0; l < r; l += 4)
|
|
2086
2086
|
for (let f = 0; f < 4; f++)
|
|
@@ -2098,7 +2098,7 @@ function xe(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
|
|
2101
|
+
function Dn(e, t, n, r, i) {
|
|
2102
2102
|
const { sbox2: s, T01: o, T23: c } = nn;
|
|
2103
2103
|
let a = 0;
|
|
2104
2104
|
t ^= e[a++], n ^= e[a++], r ^= e[a++], i ^= e[a++];
|
|
@@ -2110,7 +2110,7 @@ function qn(e, t, n, r, i) {
|
|
|
2110
2110
|
const f = e[a++] ^ oe(s, t, n, r, i), u = e[a++] ^ oe(s, n, r, i, t), p = e[a++] ^ oe(s, r, i, t, n), w = e[a++] ^ oe(s, i, t, n, r);
|
|
2111
2111
|
return { s0: f, s1: u, s2: p, s3: w };
|
|
2112
2112
|
}
|
|
2113
|
-
function
|
|
2113
|
+
function Gs(e, t, n, r, i) {
|
|
2114
2114
|
const { sbox2: s, T01: o, T23: c } = xr;
|
|
2115
2115
|
let a = 0;
|
|
2116
2116
|
t ^= e[a++], n ^= e[a++], r ^= e[a++], i ^= e[a++];
|
|
@@ -2129,11 +2129,11 @@ function Nr(e, t) {
|
|
|
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 Js(e) {
|
|
2133
2133
|
if (ue(e), e.length % Ke !== 0)
|
|
2134
2134
|
throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${Ke}`);
|
|
2135
2135
|
}
|
|
2136
|
-
function
|
|
2136
|
+
function Ys(e, t, n) {
|
|
2137
2137
|
let r = e.length;
|
|
2138
2138
|
const i = r % Ke;
|
|
2139
2139
|
if (!t && i !== 0)
|
|
@@ -2146,7 +2146,7 @@ function Js(e, t, n) {
|
|
|
2146
2146
|
const o = Nr(r, n), c = F(o);
|
|
2147
2147
|
return { b: s, o: c, out: o };
|
|
2148
2148
|
}
|
|
2149
|
-
function
|
|
2149
|
+
function Xs(e, t) {
|
|
2150
2150
|
if (!t)
|
|
2151
2151
|
return e;
|
|
2152
2152
|
const n = e.length;
|
|
@@ -2161,7 +2161,7 @@ function Ys(e, t) {
|
|
|
2161
2161
|
throw new Error("aes/pcks5: wrong padding");
|
|
2162
2162
|
return i;
|
|
2163
2163
|
}
|
|
2164
|
-
function
|
|
2164
|
+
function Qs(e) {
|
|
2165
2165
|
const t = new Uint8Array(16), n = F(t);
|
|
2166
2166
|
t.set(e);
|
|
2167
2167
|
const r = Ke - e.length;
|
|
@@ -2169,35 +2169,35 @@ function Xs(e) {
|
|
|
2169
2169
|
t[i] = r;
|
|
2170
2170
|
return n;
|
|
2171
2171
|
}
|
|
2172
|
-
const Sr = /* @__PURE__ */
|
|
2172
|
+
const Sr = /* @__PURE__ */ js({ blockSize: 16, nonceLength: 16 }, function(t, n, r = {}) {
|
|
2173
2173
|
ue(t), ue(n, 16);
|
|
2174
2174
|
const i = !r.disablePadding;
|
|
2175
2175
|
return {
|
|
2176
2176
|
encrypt: (s, o) => {
|
|
2177
|
-
const c = Kr(t), { b: a, o: l, out: f } =
|
|
2177
|
+
const c = Kr(t), { b: a, o: l, out: f } = Ys(s, i, o), u = F(n);
|
|
2178
2178
|
let p = u[0], w = u[1], g = u[2], h = u[3], d = 0;
|
|
2179
2179
|
for (; d + 4 <= a.length; )
|
|
2180
|
-
p ^= a[d + 0], w ^= a[d + 1], g ^= a[d + 2], h ^= a[d + 3], { s0: p, s1: w, s2: g, s3: h } =
|
|
2180
|
+
p ^= a[d + 0], w ^= a[d + 1], g ^= a[d + 2], h ^= a[d + 3], { s0: p, s1: w, s2: g, s3: h } = Dn(c, p, w, g, h), l[d++] = p, l[d++] = w, l[d++] = g, l[d++] = h;
|
|
2181
2181
|
if (i) {
|
|
2182
|
-
const y =
|
|
2183
|
-
p ^= y[0], w ^= y[1], g ^= y[2], h ^= y[3], { s0: p, s1: w, s2: g, s3: h } =
|
|
2182
|
+
const y = Qs(s.subarray(d * 4));
|
|
2183
|
+
p ^= y[0], w ^= y[1], g ^= y[2], h ^= y[3], { s0: p, s1: w, s2: g, s3: h } = Dn(c, p, w, g, h), l[d++] = p, l[d++] = w, l[d++] = g, l[d++] = h;
|
|
2184
2184
|
}
|
|
2185
2185
|
return c.fill(0), f;
|
|
2186
2186
|
},
|
|
2187
2187
|
decrypt: (s, o) => {
|
|
2188
|
-
|
|
2189
|
-
const c =
|
|
2188
|
+
Js(s);
|
|
2189
|
+
const c = Fs(t), a = F(n), l = Nr(s.length, o), f = F(s), u = F(l);
|
|
2190
2190
|
let p = a[0], w = a[1], g = a[2], h = a[3];
|
|
2191
2191
|
for (let d = 0; d + 4 <= f.length; ) {
|
|
2192
2192
|
const y = p, m = w, S = g, U = h;
|
|
2193
2193
|
p = f[d + 0], w = f[d + 1], g = f[d + 2], h = f[d + 3];
|
|
2194
|
-
const { s0: k, s1: E, s2: x, s3: K } =
|
|
2194
|
+
const { s0: k, s1: E, s2: x, s3: K } = Gs(c, p, w, g, h);
|
|
2195
2195
|
u[d++] = k ^ y, u[d++] = E ^ m, u[d++] = x ^ S, u[d++] = K ^ U;
|
|
2196
2196
|
}
|
|
2197
|
-
return c.fill(0),
|
|
2197
|
+
return c.fill(0), Xs(l, i);
|
|
2198
2198
|
}
|
|
2199
2199
|
};
|
|
2200
|
-
}), Ar = (e) => Uint8Array.from(e.split("").map((t) => t.charCodeAt(0))),
|
|
2200
|
+
}), Ar = (e) => Uint8Array.from(e.split("").map((t) => t.charCodeAt(0))), eo = Ar("expand 16-byte k"), to = Ar("expand 32-byte k"), no = F(eo), Cr = F(to);
|
|
2201
2201
|
Cr.slice();
|
|
2202
2202
|
function L(e, t) {
|
|
2203
2203
|
return e << t | e >>> 32 - t;
|
|
@@ -2205,8 +2205,8 @@ function L(e, t) {
|
|
|
2205
2205
|
function Wt(e) {
|
|
2206
2206
|
return e.byteOffset % 4 === 0;
|
|
2207
2207
|
}
|
|
2208
|
-
const Xe = 64,
|
|
2209
|
-
function
|
|
2208
|
+
const Xe = 64, ro = 16, kr = 2 ** 32 - 1, jn = new Uint32Array();
|
|
2209
|
+
function io(e, t, n, r, i, s, o, c) {
|
|
2210
2210
|
const a = i.length, l = new Uint8Array(Xe), f = F(l), u = Wt(i) && Wt(s), p = u ? F(i) : jn, w = u ? F(s) : jn;
|
|
2211
2211
|
for (let g = 0; g < a; o++) {
|
|
2212
2212
|
if (e(t, n, r, f, o, c), o >= kr)
|
|
@@ -2216,7 +2216,7 @@ function ro(e, t, n, r, i, s, o, c) {
|
|
|
2216
2216
|
const d = g / 4;
|
|
2217
2217
|
if (g % 4 !== 0)
|
|
2218
2218
|
throw new Error("arx: invalid block position");
|
|
2219
|
-
for (let y = 0, m; y <
|
|
2219
|
+
for (let y = 0, m; y < ro; y++)
|
|
2220
2220
|
m = d + y, w[m] = p[m] ^ f[y];
|
|
2221
2221
|
g += Xe;
|
|
2222
2222
|
continue;
|
|
@@ -2226,11 +2226,11 @@ function ro(e, t, n, r, i, s, o, c) {
|
|
|
2226
2226
|
g += h;
|
|
2227
2227
|
}
|
|
2228
2228
|
}
|
|
2229
|
-
function
|
|
2230
|
-
const { allowShortKeys: n, extendNonceFn: r, counterLength: i, counterRight: s, rounds: o } =
|
|
2229
|
+
function so(e, t) {
|
|
2230
|
+
const { allowShortKeys: n, extendNonceFn: r, counterLength: i, counterRight: s, rounds: o } = qs({ 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 Bt(i), Bt(o),
|
|
2233
|
+
return Bt(i), Bt(o), qn(s), qn(n), (c, a, l, f, u = 0) => {
|
|
2234
2234
|
ue(c), ue(a), ue(l);
|
|
2235
2235
|
const p = l.length;
|
|
2236
2236
|
if (f || (f = new Uint8Array(p)), ue(f), Bt(u), u < 0 || u >= kr)
|
|
@@ -2242,7 +2242,7 @@ function io(e, t) {
|
|
|
2242
2242
|
if (g === 32)
|
|
2243
2243
|
h = c.slice(), w.push(h), d = Cr;
|
|
2244
2244
|
else if (g === 16 && n)
|
|
2245
|
-
h = new Uint8Array(32), h.set(c), h.set(c, 16), d =
|
|
2245
|
+
h = new Uint8Array(32), h.set(c), h.set(c, 16), d = no, w.push(h);
|
|
2246
2246
|
else
|
|
2247
2247
|
throw new Error(`arx: invalid 32-byte key, got length=${g}`);
|
|
2248
2248
|
Wt(a) || (a = a.slice(), w.push(a));
|
|
@@ -2260,19 +2260,19 @@ function io(e, t) {
|
|
|
2260
2260
|
U.set(a, s ? 0 : 12 - a.length), a = U, w.push(a);
|
|
2261
2261
|
}
|
|
2262
2262
|
const S = F(a);
|
|
2263
|
-
for (
|
|
2263
|
+
for (io(e, d, y, S, l, f, u, o); w.length > 0; )
|
|
2264
2264
|
w.pop().fill(0);
|
|
2265
2265
|
return f;
|
|
2266
2266
|
};
|
|
2267
2267
|
}
|
|
2268
|
-
function
|
|
2269
|
-
let o = e[0], c = e[1], a = e[2], l = e[3], f = t[0], u = t[1], p = t[2], w = t[3], g = t[4], h = t[5], d = t[6], y = t[7], m = i, S = n[0], U = n[1], k = n[2], E = o, x = c, K = a, M = l, I = f, A = u, R = p, T = w,
|
|
2268
|
+
function oo(e, t, n, r, i, s = 20) {
|
|
2269
|
+
let o = e[0], c = e[1], a = e[2], l = e[3], f = t[0], u = t[1], p = t[2], w = t[3], g = t[4], h = t[5], d = t[6], y = t[7], m = i, S = n[0], U = n[1], k = n[2], E = o, x = c, K = a, M = l, I = f, A = u, R = p, T = w, q = g, b = h, v = d, N = y, B = m, C = S, _ = U, O = k;
|
|
2270
2270
|
for (let ee = 0; ee < s; ee += 2)
|
|
2271
|
-
E = E + I | 0, B = L(B ^ E, 16),
|
|
2271
|
+
E = E + I | 0, B = L(B ^ E, 16), q = q + B | 0, I = L(I ^ q, 12), E = E + I | 0, B = L(B ^ E, 8), q = q + B | 0, I = L(I ^ q, 7), x = x + A | 0, C = L(C ^ x, 16), b = b + C | 0, A = L(A ^ b, 12), x = x + A | 0, C = L(C ^ x, 8), b = b + C | 0, A = L(A ^ b, 7), K = K + R | 0, _ = L(_ ^ K, 16), v = v + _ | 0, R = L(R ^ v, 12), K = K + R | 0, _ = L(_ ^ K, 8), v = v + _ | 0, R = L(R ^ v, 7), M = M + T | 0, O = L(O ^ M, 16), N = N + O | 0, T = L(T ^ N, 12), M = M + T | 0, O = L(O ^ M, 8), N = N + O | 0, T = L(T ^ N, 7), E = E + A | 0, O = L(O ^ E, 16), v = v + O | 0, A = L(A ^ v, 12), E = E + A | 0, O = L(O ^ E, 8), v = v + O | 0, A = L(A ^ v, 7), x = x + R | 0, B = L(B ^ x, 16), N = N + B | 0, R = L(R ^ N, 12), x = x + R | 0, B = L(B ^ x, 8), N = N + B | 0, R = L(R ^ N, 7), K = K + T | 0, C = L(C ^ K, 16), q = q + C | 0, T = L(T ^ q, 12), K = K + T | 0, C = L(C ^ K, 8), q = q + C | 0, T = L(T ^ q, 7), M = M + I | 0, _ = L(_ ^ M, 16), b = b + _ | 0, I = L(I ^ b, 12), M = M + I | 0, _ = L(_ ^ M, 8), b = b + _ | 0, I = L(I ^ b, 7);
|
|
2272
2272
|
let $ = 0;
|
|
2273
|
-
r[$++] = o + E | 0, r[$++] = c + x | 0, r[$++] = a + K | 0, r[$++] = l + M | 0, r[$++] = f + I | 0, r[$++] = u + A | 0, r[$++] = p + R | 0, r[$++] = w + T | 0, r[$++] = g +
|
|
2273
|
+
r[$++] = o + E | 0, r[$++] = c + x | 0, r[$++] = a + K | 0, r[$++] = l + M | 0, r[$++] = f + I | 0, r[$++] = u + A | 0, r[$++] = p + R | 0, r[$++] = w + T | 0, r[$++] = g + q | 0, r[$++] = h + b | 0, r[$++] = d + v | 0, r[$++] = y + N | 0, r[$++] = m + B | 0, r[$++] = S + C | 0, r[$++] = U + _ | 0, r[$++] = k + O | 0;
|
|
2274
2274
|
}
|
|
2275
|
-
const Br = /* @__PURE__ */
|
|
2275
|
+
const Br = /* @__PURE__ */ so(oo, {
|
|
2276
2276
|
counterRight: !1,
|
|
2277
2277
|
counterLength: 4,
|
|
2278
2278
|
allowShortKeys: !1
|
|
@@ -2328,12 +2328,12 @@ function Ur(e, t, n, r = 32) {
|
|
|
2328
2328
|
Ut[0] = l + 1, c.update(l === 0 ? zn : a).update(n).update(Ut).digestInto(a), s.set(a, e.outputLen * l), o._cloneInto(c);
|
|
2329
2329
|
return o.destroy(), c.destroy(), a.fill(0), Ut.fill(0), s.slice(0, r);
|
|
2330
2330
|
}
|
|
2331
|
-
var
|
|
2331
|
+
var ao = Object.defineProperty, H = (e, t) => {
|
|
2332
2332
|
for (var n in t)
|
|
2333
|
-
|
|
2334
|
-
}, Te = Symbol("verified"),
|
|
2333
|
+
ao(e, n, { get: t[n], enumerable: !0 });
|
|
2334
|
+
}, Te = Symbol("verified"), co = (e) => e instanceof Object;
|
|
2335
2335
|
function yt(e) {
|
|
2336
|
-
if (!
|
|
2336
|
+
if (!co(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,21 +2345,21 @@ function yt(e) {
|
|
|
2345
2345
|
}
|
|
2346
2346
|
return !0;
|
|
2347
2347
|
}
|
|
2348
|
-
var
|
|
2349
|
-
H(
|
|
2350
|
-
Queue: () =>
|
|
2348
|
+
var uo = {};
|
|
2349
|
+
H(uo, {
|
|
2350
|
+
Queue: () => yo,
|
|
2351
2351
|
QueueNode: () => _r,
|
|
2352
2352
|
binarySearch: () => sn,
|
|
2353
2353
|
bytesToHex: () => P,
|
|
2354
2354
|
hexToBytes: () => j,
|
|
2355
|
-
insertEventIntoAscendingList: () =>
|
|
2356
|
-
insertEventIntoDescendingList: () =>
|
|
2357
|
-
normalizeURL: () =>
|
|
2355
|
+
insertEventIntoAscendingList: () => ho,
|
|
2356
|
+
insertEventIntoDescendingList: () => fo,
|
|
2357
|
+
normalizeURL: () => lo,
|
|
2358
2358
|
utf8Decoder: () => le,
|
|
2359
2359
|
utf8Encoder: () => ne
|
|
2360
2360
|
});
|
|
2361
2361
|
var le = new TextDecoder("utf-8"), ne = new TextEncoder();
|
|
2362
|
-
function
|
|
2362
|
+
function lo(e) {
|
|
2363
2363
|
try {
|
|
2364
2364
|
e.indexOf("://") === -1 && (e = "wss://" + e);
|
|
2365
2365
|
let t = new URL(e);
|
|
@@ -2368,11 +2368,11 @@ function uo(e) {
|
|
|
2368
2368
|
throw new Error(`Invalid URL: ${e}`);
|
|
2369
2369
|
}
|
|
2370
2370
|
}
|
|
2371
|
-
function
|
|
2371
|
+
function fo(e, t) {
|
|
2372
2372
|
const [n, r] = sn(e, (i) => t.id === i.id ? 0 : t.created_at === i.created_at ? -1 : i.created_at - t.created_at);
|
|
2373
2373
|
return r || e.splice(n, 0, t), e;
|
|
2374
2374
|
}
|
|
2375
|
-
function
|
|
2375
|
+
function ho(e, t) {
|
|
2376
2376
|
const [n, r] = sn(e, (i) => t.id === i.id ? 0 : t.created_at === i.created_at ? -1 : t.created_at - i.created_at);
|
|
2377
2377
|
return r || e.splice(n, 0, t), e;
|
|
2378
2378
|
}
|
|
@@ -2393,7 +2393,7 @@ var _r = class {
|
|
|
2393
2393
|
J(this, "prev", null);
|
|
2394
2394
|
this.value = e;
|
|
2395
2395
|
}
|
|
2396
|
-
},
|
|
2396
|
+
}, yo = class {
|
|
2397
2397
|
constructor() {
|
|
2398
2398
|
J(this, "first");
|
|
2399
2399
|
J(this, "last");
|
|
@@ -2413,7 +2413,7 @@ var _r = class {
|
|
|
2413
2413
|
const e = this.first;
|
|
2414
2414
|
return this.first = e.next, this.first && (this.first.prev = null), e.value;
|
|
2415
2415
|
}
|
|
2416
|
-
},
|
|
2416
|
+
}, po = class {
|
|
2417
2417
|
generateSecretKey() {
|
|
2418
2418
|
return Ze.utils.randomPrivateKey();
|
|
2419
2419
|
}
|
|
@@ -2422,12 +2422,12 @@ var _r = class {
|
|
|
2422
2422
|
}
|
|
2423
2423
|
finalizeEvent(e, t) {
|
|
2424
2424
|
const n = e;
|
|
2425
|
-
return n.pubkey = P(Ze.getPublicKey(t)), n.id =
|
|
2425
|
+
return n.pubkey = P(Ze.getPublicKey(t)), n.id = qe(n), n.sig = P(Ze.sign(qe(n), t)), n[Te] = !0, n;
|
|
2426
2426
|
}
|
|
2427
2427
|
verifyEvent(e) {
|
|
2428
2428
|
if (typeof e[Te] == "boolean")
|
|
2429
2429
|
return e[Te];
|
|
2430
|
-
const t =
|
|
2430
|
+
const t = qe(e);
|
|
2431
2431
|
if (t !== e.id)
|
|
2432
2432
|
return e[Te] = !1, !1;
|
|
2433
2433
|
try {
|
|
@@ -2438,98 +2438,98 @@ var _r = class {
|
|
|
2438
2438
|
}
|
|
2439
2439
|
}
|
|
2440
2440
|
};
|
|
2441
|
-
function
|
|
2441
|
+
function go(e) {
|
|
2442
2442
|
if (!yt(e))
|
|
2443
2443
|
throw new Error("can't serialize event with wrong or missing properties");
|
|
2444
2444
|
return JSON.stringify([0, e.pubkey, e.created_at, e.kind, e.tags, e.content]);
|
|
2445
2445
|
}
|
|
2446
|
-
function
|
|
2447
|
-
let t = fe(ne.encode(
|
|
2446
|
+
function qe(e) {
|
|
2447
|
+
let t = fe(ne.encode(go(e)));
|
|
2448
2448
|
return P(t);
|
|
2449
2449
|
}
|
|
2450
|
-
var pt = new
|
|
2451
|
-
H(
|
|
2452
|
-
Application: () =>
|
|
2453
|
-
BadgeAward: () =>
|
|
2454
|
-
BadgeDefinition: () =>
|
|
2455
|
-
BlockedRelaysList: () =>
|
|
2456
|
-
BookmarkList: () =>
|
|
2457
|
-
Bookmarksets: () =>
|
|
2458
|
-
Calendar: () =>
|
|
2459
|
-
CalendarEventRSVP: () =>
|
|
2450
|
+
var pt = new po(), Be = pt.generateSecretKey, ae = pt.getPublicKey, Q = pt.finalizeEvent, gt = pt.verifyEvent, wo = {};
|
|
2451
|
+
H(wo, {
|
|
2452
|
+
Application: () => ga,
|
|
2453
|
+
BadgeAward: () => So,
|
|
2454
|
+
BadgeDefinition: () => ua,
|
|
2455
|
+
BlockedRelaysList: () => Zo,
|
|
2456
|
+
BookmarkList: () => zo,
|
|
2457
|
+
Bookmarksets: () => oa,
|
|
2458
|
+
Calendar: () => Ka,
|
|
2459
|
+
CalendarEventRSVP: () => Na,
|
|
2460
2460
|
ChannelCreation: () => Mr,
|
|
2461
|
-
ChannelHideMessage: () =>
|
|
2461
|
+
ChannelHideMessage: () => qr,
|
|
2462
2462
|
ChannelMessage: () => Hr,
|
|
2463
2463
|
ChannelMetadata: () => Pr,
|
|
2464
|
-
ChannelMuteUser: () =>
|
|
2465
|
-
ClassifiedListing: () =>
|
|
2464
|
+
ChannelMuteUser: () => Dr,
|
|
2465
|
+
ClassifiedListing: () => va,
|
|
2466
2466
|
ClientAuth: () => zr,
|
|
2467
|
-
CommunitiesList: () =>
|
|
2468
|
-
CommunityDefinition: () =>
|
|
2469
|
-
CommunityPostApproval: () =>
|
|
2470
|
-
Contacts: () =>
|
|
2471
|
-
CreateOrUpdateProduct: () =>
|
|
2472
|
-
CreateOrUpdateStall: () =>
|
|
2473
|
-
Curationsets: () =>
|
|
2474
|
-
Date: () =>
|
|
2475
|
-
DirectMessageRelaysList: () =>
|
|
2476
|
-
DraftClassifiedListing: () =>
|
|
2477
|
-
DraftLong: () =>
|
|
2478
|
-
Emojisets: () =>
|
|
2479
|
-
EncryptedDirectMessage: () =>
|
|
2480
|
-
EventDeletion: () =>
|
|
2481
|
-
FileMetadata: () =>
|
|
2482
|
-
FileServerPreference: () =>
|
|
2483
|
-
Followsets: () =>
|
|
2467
|
+
CommunitiesList: () => Wo,
|
|
2468
|
+
CommunityDefinition: () => Ca,
|
|
2469
|
+
CommunityPostApproval: () => Lo,
|
|
2470
|
+
Contacts: () => xo,
|
|
2471
|
+
CreateOrUpdateProduct: () => ha,
|
|
2472
|
+
CreateOrUpdateStall: () => fa,
|
|
2473
|
+
Curationsets: () => aa,
|
|
2474
|
+
Date: () => Ea,
|
|
2475
|
+
DirectMessageRelaysList: () => Yo,
|
|
2476
|
+
DraftClassifiedListing: () => ma,
|
|
2477
|
+
DraftLong: () => ya,
|
|
2478
|
+
Emojisets: () => pa,
|
|
2479
|
+
EncryptedDirectMessage: () => Ko,
|
|
2480
|
+
EventDeletion: () => No,
|
|
2481
|
+
FileMetadata: () => Co,
|
|
2482
|
+
FileServerPreference: () => Xo,
|
|
2483
|
+
Followsets: () => ra,
|
|
2484
2484
|
GenericRepost: () => ln,
|
|
2485
|
-
Genericlists: () =>
|
|
2485
|
+
Genericlists: () => ia,
|
|
2486
2486
|
GiftWrap: () => jr,
|
|
2487
2487
|
HTTPAuth: () => fn,
|
|
2488
|
-
Handlerinformation: () =>
|
|
2489
|
-
Handlerrecommendation: () =>
|
|
2490
|
-
Highlights: () =>
|
|
2491
|
-
InterestsList: () =>
|
|
2492
|
-
Interestsets: () =>
|
|
2493
|
-
JobFeedback: () =>
|
|
2494
|
-
JobRequest: () =>
|
|
2495
|
-
JobResult: () =>
|
|
2496
|
-
Label: () =>
|
|
2497
|
-
LightningPubRPC: () =>
|
|
2498
|
-
LiveChatMessage: () =>
|
|
2499
|
-
LiveEvent: () =>
|
|
2500
|
-
LongFormArticle: () =>
|
|
2501
|
-
Metadata: () =>
|
|
2502
|
-
Mutelist: () =>
|
|
2503
|
-
NWCWalletInfo: () =>
|
|
2488
|
+
Handlerinformation: () => Aa,
|
|
2489
|
+
Handlerrecommendation: () => Sa,
|
|
2490
|
+
Highlights: () => Ho,
|
|
2491
|
+
InterestsList: () => Go,
|
|
2492
|
+
Interestsets: () => la,
|
|
2493
|
+
JobFeedback: () => To,
|
|
2494
|
+
JobRequest: () => $o,
|
|
2495
|
+
JobResult: () => Ro,
|
|
2496
|
+
Label: () => _o,
|
|
2497
|
+
LightningPubRPC: () => ea,
|
|
2498
|
+
LiveChatMessage: () => ko,
|
|
2499
|
+
LiveEvent: () => wa,
|
|
2500
|
+
LongFormArticle: () => da,
|
|
2501
|
+
Metadata: () => mo,
|
|
2502
|
+
Mutelist: () => qo,
|
|
2503
|
+
NWCWalletInfo: () => Qo,
|
|
2504
2504
|
NWCWalletRequest: () => Wr,
|
|
2505
|
-
NWCWalletResponse: () =>
|
|
2506
|
-
NostrConnect: () =>
|
|
2507
|
-
OpenTimestamps: () =>
|
|
2505
|
+
NWCWalletResponse: () => ta,
|
|
2506
|
+
NostrConnect: () => na,
|
|
2507
|
+
OpenTimestamps: () => Ao,
|
|
2508
2508
|
Pinlist: () => Do,
|
|
2509
2509
|
PrivateDirectMessage: () => Or,
|
|
2510
|
-
ProblemTracker: () =>
|
|
2511
|
-
ProfileBadges: () =>
|
|
2512
|
-
PublicChatsList: () =>
|
|
2510
|
+
ProblemTracker: () => Bo,
|
|
2511
|
+
ProfileBadges: () => ca,
|
|
2512
|
+
PublicChatsList: () => Vo,
|
|
2513
2513
|
Reaction: () => un,
|
|
2514
|
-
RecommendRelay: () =>
|
|
2515
|
-
RelayList: () =>
|
|
2516
|
-
Relaysets: () =>
|
|
2517
|
-
Report: () =>
|
|
2518
|
-
Reporting: () =>
|
|
2514
|
+
RecommendRelay: () => Eo,
|
|
2515
|
+
RelayList: () => jo,
|
|
2516
|
+
Relaysets: () => sa,
|
|
2517
|
+
Report: () => Io,
|
|
2518
|
+
Reporting: () => Uo,
|
|
2519
2519
|
Repost: () => cn,
|
|
2520
2520
|
Seal: () => Tr,
|
|
2521
|
-
SearchRelaysList: () =>
|
|
2521
|
+
SearchRelaysList: () => Fo,
|
|
2522
2522
|
ShortTextNote: () => Rr,
|
|
2523
|
-
Time: () =>
|
|
2524
|
-
UserEmojiList: () =>
|
|
2525
|
-
UserStatuses: () =>
|
|
2526
|
-
Zap: () =>
|
|
2527
|
-
ZapGoal: () =>
|
|
2528
|
-
ZapRequest: () =>
|
|
2529
|
-
classifyKind: () =>
|
|
2523
|
+
Time: () => xa,
|
|
2524
|
+
UserEmojiList: () => Jo,
|
|
2525
|
+
UserStatuses: () => ba,
|
|
2526
|
+
Zap: () => Po,
|
|
2527
|
+
ZapGoal: () => Oo,
|
|
2528
|
+
ZapRequest: () => Mo,
|
|
2529
|
+
classifyKind: () => bo,
|
|
2530
2530
|
isAddressableKind: () => an,
|
|
2531
2531
|
isEphemeralKind: () => $r,
|
|
2532
|
-
isKind: () =>
|
|
2532
|
+
isKind: () => vo,
|
|
2533
2533
|
isRegularKind: () => Lr,
|
|
2534
2534
|
isReplaceableKind: () => on
|
|
2535
2535
|
});
|
|
@@ -2545,21 +2545,21 @@ function $r(e) {
|
|
|
2545
2545
|
function an(e) {
|
|
2546
2546
|
return 3e4 <= e && e < 4e4;
|
|
2547
2547
|
}
|
|
2548
|
-
function
|
|
2548
|
+
function bo(e) {
|
|
2549
2549
|
return Lr(e) ? "regular" : on(e) ? "replaceable" : $r(e) ? "ephemeral" : an(e) ? "parameterized" : "unknown";
|
|
2550
2550
|
}
|
|
2551
|
-
function
|
|
2551
|
+
function vo(e, t) {
|
|
2552
2552
|
const n = t instanceof Array ? t : [t];
|
|
2553
2553
|
return yt(e) && n.includes(e.kind) || !1;
|
|
2554
2554
|
}
|
|
2555
|
-
var
|
|
2556
|
-
H(
|
|
2555
|
+
var mo = 0, Rr = 1, Eo = 2, xo = 3, Ko = 4, No = 5, cn = 6, un = 7, So = 8, Tr = 13, Or = 14, ln = 16, Mr = 40, Pr = 41, Hr = 42, qr = 43, Dr = 44, Ao = 1040, jr = 1059, Co = 1063, ko = 1311, Bo = 1971, Io = 1984, Uo = 1984, _o = 1985, Lo = 4550, $o = 5999, Ro = 6999, To = 7e3, Oo = 9041, Mo = 9734, Po = 9735, Ho = 9802, qo = 1e4, Do = 10001, jo = 10002, zo = 10003, Wo = 10004, Vo = 10005, Zo = 10006, Fo = 10007, Go = 10015, Jo = 10030, Yo = 10050, Xo = 10096, Qo = 13194, ea = 21e3, zr = 22242, Wr = 23194, ta = 23195, na = 24133, fn = 27235, ra = 3e4, ia = 30001, sa = 30002, oa = 30003, aa = 30004, ca = 30008, ua = 30009, la = 30015, fa = 30017, ha = 30018, da = 30023, ya = 30024, pa = 30030, ga = 30078, wa = 30311, ba = 30315, va = 30402, ma = 30403, Ea = 31922, xa = 31923, Ka = 31924, Na = 31925, Sa = 31989, Aa = 31990, Ca = 34550, ka = {};
|
|
2556
|
+
H(ka, {
|
|
2557
2557
|
getHex64: () => hn,
|
|
2558
2558
|
getInt: () => Vr,
|
|
2559
|
-
getSubscriptionId: () =>
|
|
2560
|
-
matchEventId: () =>
|
|
2561
|
-
matchEventKind: () =>
|
|
2562
|
-
matchEventPubkey: () =>
|
|
2559
|
+
getSubscriptionId: () => Ba,
|
|
2560
|
+
matchEventId: () => Ia,
|
|
2561
|
+
matchEventKind: () => _a,
|
|
2562
|
+
matchEventPubkey: () => Ua
|
|
2563
2563
|
});
|
|
2564
2564
|
function hn(e, t) {
|
|
2565
2565
|
let n = t.length + 3, r = e.indexOf(`"${t}":`) + n, i = e.slice(r).indexOf('"') + r + 1;
|
|
@@ -2569,7 +2569,7 @@ function Vr(e, t) {
|
|
|
2569
2569
|
let n = t.length, r = e.indexOf(`"${t}":`) + n + 3, i = e.slice(r), s = Math.min(i.indexOf(","), i.indexOf("}"));
|
|
2570
2570
|
return parseInt(i.slice(0, s), 10);
|
|
2571
2571
|
}
|
|
2572
|
-
function
|
|
2572
|
+
function Ba(e) {
|
|
2573
2573
|
let t = e.slice(0, 22).indexOf('"EVENT"');
|
|
2574
2574
|
if (t === -1)
|
|
2575
2575
|
return null;
|
|
@@ -2582,20 +2582,20 @@ function ka(e) {
|
|
|
2582
2582
|
let s = r + 1 + i;
|
|
2583
2583
|
return e.slice(r + 1, s);
|
|
2584
2584
|
}
|
|
2585
|
-
function
|
|
2585
|
+
function Ia(e, t) {
|
|
2586
2586
|
return t === hn(e, "id");
|
|
2587
2587
|
}
|
|
2588
|
-
function
|
|
2588
|
+
function Ua(e, t) {
|
|
2589
2589
|
return t === hn(e, "pubkey");
|
|
2590
2590
|
}
|
|
2591
|
-
function
|
|
2591
|
+
function _a(e, t) {
|
|
2592
2592
|
return t === Vr(e, "kind");
|
|
2593
2593
|
}
|
|
2594
|
-
var
|
|
2595
|
-
H(
|
|
2596
|
-
makeAuthEvent: () =>
|
|
2594
|
+
var La = {};
|
|
2595
|
+
H(La, {
|
|
2596
|
+
makeAuthEvent: () => $a
|
|
2597
2597
|
});
|
|
2598
|
-
function
|
|
2598
|
+
function $a(e, t) {
|
|
2599
2599
|
return {
|
|
2600
2600
|
kind: zr,
|
|
2601
2601
|
created_at: Math.floor(Date.now() / 1e3),
|
|
@@ -2606,32 +2606,32 @@ function La(e, t) {
|
|
|
2606
2606
|
content: ""
|
|
2607
2607
|
};
|
|
2608
2608
|
}
|
|
2609
|
-
var
|
|
2609
|
+
var Ra;
|
|
2610
2610
|
try {
|
|
2611
|
-
|
|
2611
|
+
Ra = WebSocket;
|
|
2612
2612
|
} catch {
|
|
2613
2613
|
}
|
|
2614
|
-
var
|
|
2614
|
+
var Ta;
|
|
2615
2615
|
try {
|
|
2616
|
-
|
|
2616
|
+
Ta = WebSocket;
|
|
2617
2617
|
} catch {
|
|
2618
2618
|
}
|
|
2619
|
-
var
|
|
2620
|
-
H(
|
|
2619
|
+
var Oa = {};
|
|
2620
|
+
H(Oa, {
|
|
2621
2621
|
BECH32_REGEX: () => Zr,
|
|
2622
2622
|
Bech32MaxSize: () => dn,
|
|
2623
|
-
NostrTypeGuard: () =>
|
|
2623
|
+
NostrTypeGuard: () => Ma,
|
|
2624
2624
|
decode: () => wt,
|
|
2625
|
-
decodeNostrURI: () =>
|
|
2625
|
+
decodeNostrURI: () => Ha,
|
|
2626
2626
|
encodeBytes: () => vt,
|
|
2627
|
-
naddrEncode: () =>
|
|
2628
|
-
neventEncode: () =>
|
|
2629
|
-
noteEncode: () =>
|
|
2630
|
-
nprofileEncode: () =>
|
|
2627
|
+
naddrEncode: () => Va,
|
|
2628
|
+
neventEncode: () => Wa,
|
|
2629
|
+
noteEncode: () => ja,
|
|
2630
|
+
nprofileEncode: () => za,
|
|
2631
2631
|
npubEncode: () => Da,
|
|
2632
|
-
nsecEncode: () =>
|
|
2632
|
+
nsecEncode: () => qa
|
|
2633
2633
|
});
|
|
2634
|
-
var
|
|
2634
|
+
var Ma = {
|
|
2635
2635
|
isNProfile: (e) => /^nprofile1[a-z\d]+$/.test(e || ""),
|
|
2636
2636
|
isNEvent: (e) => /^nevent1[a-z\d]+$/.test(e || ""),
|
|
2637
2637
|
isNAddr: (e) => /^naddr1[a-z\d]+$/.test(e || ""),
|
|
@@ -2640,11 +2640,11 @@ var Oa = {
|
|
|
2640
2640
|
isNote: (e) => /^note1[a-z\d]+$/.test(e || ""),
|
|
2641
2641
|
isNcryptsec: (e) => /^ncryptsec1[a-z\d]+$/.test(e || "")
|
|
2642
2642
|
}, dn = 5e3, Zr = /[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;
|
|
2643
|
-
function
|
|
2643
|
+
function Pa(e) {
|
|
2644
2644
|
const t = new Uint8Array(4);
|
|
2645
2645
|
return t[0] = e >> 24 & 255, t[1] = e >> 16 & 255, t[2] = e >> 8 & 255, t[3] = e & 255, t;
|
|
2646
2646
|
}
|
|
2647
|
-
function
|
|
2647
|
+
function Ha(e) {
|
|
2648
2648
|
try {
|
|
2649
2649
|
return e.startsWith("nostr:") && (e = e.substring(6)), wt(e);
|
|
2650
2650
|
} catch {
|
|
@@ -2730,13 +2730,13 @@ function _t(e) {
|
|
|
2730
2730
|
}
|
|
2731
2731
|
return t;
|
|
2732
2732
|
}
|
|
2733
|
-
function
|
|
2733
|
+
function qa(e) {
|
|
2734
2734
|
return vt("nsec", e);
|
|
2735
2735
|
}
|
|
2736
2736
|
function Da(e) {
|
|
2737
2737
|
return vt("npub", j(e));
|
|
2738
2738
|
}
|
|
2739
|
-
function
|
|
2739
|
+
function ja(e) {
|
|
2740
2740
|
return vt("note", j(e));
|
|
2741
2741
|
}
|
|
2742
2742
|
function bt(e, t) {
|
|
@@ -2746,16 +2746,16 @@ function bt(e, t) {
|
|
|
2746
2746
|
function vt(e, t) {
|
|
2747
2747
|
return bt(e, t);
|
|
2748
2748
|
}
|
|
2749
|
-
function
|
|
2749
|
+
function za(e) {
|
|
2750
2750
|
let t = yn({
|
|
2751
2751
|
0: [j(e.pubkey)],
|
|
2752
2752
|
1: (e.relays || []).map((n) => ne.encode(n))
|
|
2753
2753
|
});
|
|
2754
2754
|
return bt("nprofile", t);
|
|
2755
2755
|
}
|
|
2756
|
-
function
|
|
2756
|
+
function Wa(e) {
|
|
2757
2757
|
let t;
|
|
2758
|
-
e.kind !== void 0 && (t =
|
|
2758
|
+
e.kind !== void 0 && (t = Pa(e.kind));
|
|
2759
2759
|
let n = yn({
|
|
2760
2760
|
0: [j(e.id)],
|
|
2761
2761
|
1: (e.relays || []).map((r) => ne.encode(r)),
|
|
@@ -2764,7 +2764,7 @@ function za(e) {
|
|
|
2764
2764
|
});
|
|
2765
2765
|
return bt("nevent", n);
|
|
2766
2766
|
}
|
|
2767
|
-
function
|
|
2767
|
+
function Va(e) {
|
|
2768
2768
|
let t = new ArrayBuffer(4);
|
|
2769
2769
|
new DataView(t).setUint32(0, e.kind, !1);
|
|
2770
2770
|
let n = yn({
|
|
@@ -2784,9 +2784,9 @@ function yn(e) {
|
|
|
2784
2784
|
});
|
|
2785
2785
|
}), ft(...t);
|
|
2786
2786
|
}
|
|
2787
|
-
var
|
|
2788
|
-
H(
|
|
2789
|
-
decrypt: () =>
|
|
2787
|
+
var Za = {};
|
|
2788
|
+
H(Za, {
|
|
2789
|
+
decrypt: () => Fa,
|
|
2790
2790
|
encrypt: () => Fr
|
|
2791
2791
|
});
|
|
2792
2792
|
function Fr(e, t, n) {
|
|
@@ -2794,7 +2794,7 @@ function Fr(e, t, n) {
|
|
|
2794
2794
|
let o = Uint8Array.from(pr(16)), c = ne.encode(n), a = Sr(s, o).encrypt(c), l = he.encode(new Uint8Array(a)), f = he.encode(new Uint8Array(o.buffer));
|
|
2795
2795
|
return `${l}?iv=${f}`;
|
|
2796
2796
|
}
|
|
2797
|
-
function
|
|
2797
|
+
function Fa(e, t, n) {
|
|
2798
2798
|
const r = e instanceof Uint8Array ? P(e) : e;
|
|
2799
2799
|
let [i, s] = n.split("?iv="), o = Ue.getSharedSecret(r, "02" + t), c = Gr(o), a = he.decode(s), l = he.decode(i), f = Sr(c, a).decrypt(l);
|
|
2800
2800
|
return le.decode(f);
|
|
@@ -2802,24 +2802,24 @@ function Za(e, t, n) {
|
|
|
2802
2802
|
function Gr(e) {
|
|
2803
2803
|
return e.slice(1, 33);
|
|
2804
2804
|
}
|
|
2805
|
-
var
|
|
2806
|
-
H(
|
|
2805
|
+
var Ga = {};
|
|
2806
|
+
H(Ga, {
|
|
2807
2807
|
NIP05_REGEX: () => pn,
|
|
2808
|
-
isNip05: () =>
|
|
2809
|
-
isValid: () =>
|
|
2808
|
+
isNip05: () => Ja,
|
|
2809
|
+
isValid: () => Qa,
|
|
2810
2810
|
queryProfile: () => Jr,
|
|
2811
|
-
searchDomain: () =>
|
|
2812
|
-
useFetchImplementation: () =>
|
|
2811
|
+
searchDomain: () => Xa,
|
|
2812
|
+
useFetchImplementation: () => Ya
|
|
2813
2813
|
});
|
|
2814
|
-
var pn = /^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,
|
|
2814
|
+
var pn = /^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/, Ja = (e) => pn.test(e || ""), mt;
|
|
2815
2815
|
try {
|
|
2816
2816
|
mt = fetch;
|
|
2817
2817
|
} catch {
|
|
2818
2818
|
}
|
|
2819
|
-
function
|
|
2819
|
+
function Ya(e) {
|
|
2820
2820
|
mt = e;
|
|
2821
2821
|
}
|
|
2822
|
-
async function
|
|
2822
|
+
async function Xa(e, t = "") {
|
|
2823
2823
|
try {
|
|
2824
2824
|
const n = `https://${e}/.well-known/nostr.json?name=${t}`, r = await mt(n, { redirect: "manual" });
|
|
2825
2825
|
if (r.status !== 200)
|
|
@@ -2845,15 +2845,15 @@ async function Jr(e) {
|
|
|
2845
2845
|
return null;
|
|
2846
2846
|
}
|
|
2847
2847
|
}
|
|
2848
|
-
async function
|
|
2848
|
+
async function Qa(e, t) {
|
|
2849
2849
|
const n = await Jr(t);
|
|
2850
2850
|
return n ? n.pubkey === e : !1;
|
|
2851
2851
|
}
|
|
2852
|
-
var
|
|
2853
|
-
H(
|
|
2854
|
-
parse: () =>
|
|
2852
|
+
var ec = {};
|
|
2853
|
+
H(ec, {
|
|
2854
|
+
parse: () => tc
|
|
2855
2855
|
});
|
|
2856
|
-
function
|
|
2856
|
+
function tc(e) {
|
|
2857
2857
|
const t = {
|
|
2858
2858
|
reply: void 0,
|
|
2859
2859
|
root: void 0,
|
|
@@ -2920,29 +2920,29 @@ function ec(e) {
|
|
|
2920
2920
|
}
|
|
2921
2921
|
}), t;
|
|
2922
2922
|
}
|
|
2923
|
-
var
|
|
2924
|
-
H(
|
|
2925
|
-
fetchRelayInformation: () =>
|
|
2926
|
-
useFetchImplementation: () =>
|
|
2923
|
+
var nc = {};
|
|
2924
|
+
H(nc, {
|
|
2925
|
+
fetchRelayInformation: () => ic,
|
|
2926
|
+
useFetchImplementation: () => rc
|
|
2927
2927
|
});
|
|
2928
2928
|
var Yr;
|
|
2929
2929
|
try {
|
|
2930
2930
|
Yr = fetch;
|
|
2931
2931
|
} catch {
|
|
2932
2932
|
}
|
|
2933
|
-
function
|
|
2933
|
+
function rc(e) {
|
|
2934
2934
|
Yr = e;
|
|
2935
2935
|
}
|
|
2936
|
-
async function
|
|
2936
|
+
async function ic(e) {
|
|
2937
2937
|
return await (await fetch(e.replace("ws://", "http://").replace("wss://", "https://"), {
|
|
2938
2938
|
headers: { Accept: "application/nostr+json" }
|
|
2939
2939
|
})).json();
|
|
2940
2940
|
}
|
|
2941
|
-
var
|
|
2942
|
-
H(
|
|
2941
|
+
var sc = {};
|
|
2942
|
+
H(sc, {
|
|
2943
2943
|
fastEventHash: () => Qr,
|
|
2944
2944
|
getPow: () => Xr,
|
|
2945
|
-
minePow: () =>
|
|
2945
|
+
minePow: () => oc
|
|
2946
2946
|
});
|
|
2947
2947
|
function Xr(e) {
|
|
2948
2948
|
let t = 0;
|
|
@@ -2957,7 +2957,7 @@ function Xr(e) {
|
|
|
2957
2957
|
}
|
|
2958
2958
|
return t;
|
|
2959
2959
|
}
|
|
2960
|
-
function
|
|
2960
|
+
function oc(e, t) {
|
|
2961
2961
|
let n = 0;
|
|
2962
2962
|
const r = e, i = ["nonce", n.toString(), t.toString()];
|
|
2963
2963
|
for (r.tags.push(i); ; ) {
|
|
@@ -2972,29 +2972,29 @@ function Qr(e) {
|
|
|
2972
2972
|
fe(ne.encode(JSON.stringify([0, e.pubkey, e.created_at, e.kind, e.tags, e.content])))
|
|
2973
2973
|
);
|
|
2974
2974
|
}
|
|
2975
|
-
var oc = {};
|
|
2976
|
-
H(oc, {
|
|
2977
|
-
unwrapEvent: () => wc,
|
|
2978
|
-
unwrapManyEvents: () => bc,
|
|
2979
|
-
wrapEvent: () => hi,
|
|
2980
|
-
wrapManyEvents: () => gc
|
|
2981
|
-
});
|
|
2982
2975
|
var ac = {};
|
|
2983
2976
|
H(ac, {
|
|
2977
|
+
unwrapEvent: () => bc,
|
|
2978
|
+
unwrapManyEvents: () => vc,
|
|
2979
|
+
wrapEvent: () => hi,
|
|
2980
|
+
wrapManyEvents: () => wc
|
|
2981
|
+
});
|
|
2982
|
+
var cc = {};
|
|
2983
|
+
H(cc, {
|
|
2984
2984
|
createRumor: () => ci,
|
|
2985
2985
|
createSeal: () => ui,
|
|
2986
2986
|
createWrap: () => li,
|
|
2987
2987
|
unwrapEvent: () => mn,
|
|
2988
2988
|
unwrapManyEvents: () => fi,
|
|
2989
2989
|
wrapEvent: () => st,
|
|
2990
|
-
wrapManyEvents: () =>
|
|
2990
|
+
wrapManyEvents: () => pc
|
|
2991
2991
|
});
|
|
2992
|
-
var
|
|
2993
|
-
H(
|
|
2992
|
+
var D = {};
|
|
2993
|
+
H(D, {
|
|
2994
2994
|
decrypt: () => vn,
|
|
2995
2995
|
encrypt: () => bn,
|
|
2996
2996
|
getConversationKey: () => gn,
|
|
2997
|
-
v2: () =>
|
|
2997
|
+
v2: () => dc
|
|
2998
2998
|
});
|
|
2999
2999
|
var ei = 1, ti = 65535;
|
|
3000
3000
|
function gn(e, t) {
|
|
@@ -3017,17 +3017,17 @@ function wn(e) {
|
|
|
3017
3017
|
const t = 1 << Math.floor(Math.log2(e - 1)) + 1, n = t <= 256 ? 32 : t / 8;
|
|
3018
3018
|
return n * (Math.floor((e - 1) / n) + 1);
|
|
3019
3019
|
}
|
|
3020
|
-
function
|
|
3020
|
+
function uc(e) {
|
|
3021
3021
|
if (!Number.isSafeInteger(e) || e < ei || e > ti)
|
|
3022
3022
|
throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");
|
|
3023
3023
|
const t = new Uint8Array(2);
|
|
3024
3024
|
return new DataView(t.buffer).setUint16(0, e, !1), t;
|
|
3025
3025
|
}
|
|
3026
|
-
function
|
|
3027
|
-
const t = ne.encode(e), n = t.length, r =
|
|
3026
|
+
function lc(e) {
|
|
3027
|
+
const t = ne.encode(e), n = t.length, r = uc(n), i = new Uint8Array(wn(n) - n);
|
|
3028
3028
|
return ft(r, t, i);
|
|
3029
3029
|
}
|
|
3030
|
-
function
|
|
3030
|
+
function fc(e) {
|
|
3031
3031
|
const t = new DataView(e.buffer).getUint16(0), n = e.subarray(2, 2 + t);
|
|
3032
3032
|
if (t < ei || t > ti || n.length !== t || e.length !== 2 + wn(t))
|
|
3033
3033
|
throw new Error("invalid padding");
|
|
@@ -3039,7 +3039,7 @@ function ri(e, t, n) {
|
|
|
3039
3039
|
const r = ft(n, t);
|
|
3040
3040
|
return dt(fe, e, r);
|
|
3041
3041
|
}
|
|
3042
|
-
function
|
|
3042
|
+
function hc(e) {
|
|
3043
3043
|
if (typeof e != "string")
|
|
3044
3044
|
throw new Error("payload must be a valid string");
|
|
3045
3045
|
const t = e.length;
|
|
@@ -3066,24 +3066,24 @@ function fc(e) {
|
|
|
3066
3066
|
};
|
|
3067
3067
|
}
|
|
3068
3068
|
function bn(e, t, n = pr(32)) {
|
|
3069
|
-
const { chacha_key: r, chacha_nonce: i, hmac_key: s } = ni(t, n), o =
|
|
3069
|
+
const { chacha_key: r, chacha_nonce: i, hmac_key: s } = ni(t, n), o = lc(e), c = Br(r, i, o), a = ri(s, c, n);
|
|
3070
3070
|
return he.encode(ft(new Uint8Array([2]), n, c, a));
|
|
3071
3071
|
}
|
|
3072
3072
|
function vn(e, t) {
|
|
3073
|
-
const { nonce: n, ciphertext: r, mac: i } =
|
|
3073
|
+
const { nonce: n, ciphertext: r, mac: i } = hc(e), { chacha_key: s, chacha_nonce: o, hmac_key: c } = ni(t, n), a = ri(c, r, n);
|
|
3074
3074
|
if (!Ds(a, i))
|
|
3075
3075
|
throw new Error("invalid MAC");
|
|
3076
3076
|
const l = Br(s, o, r);
|
|
3077
|
-
return
|
|
3077
|
+
return fc(l);
|
|
3078
3078
|
}
|
|
3079
|
-
var
|
|
3079
|
+
var dc = {
|
|
3080
3080
|
utils: {
|
|
3081
3081
|
getConversationKey: gn,
|
|
3082
3082
|
calcPaddedLen: wn
|
|
3083
3083
|
},
|
|
3084
3084
|
encrypt: bn,
|
|
3085
3085
|
decrypt: vn
|
|
3086
|
-
},
|
|
3086
|
+
}, yc = 2 * 24 * 60 * 60, ii = () => Math.round(Date.now() / 1e3), si = () => Math.round(ii() - Math.random() * yc), oi = (e, t) => gn(e, t), ai = (e, t, n) => bn(JSON.stringify(e), oi(t, n)), Wn = (e, t) => JSON.parse(vn(e.content, oi(t, e.pubkey)));
|
|
3087
3087
|
function ci(e, t) {
|
|
3088
3088
|
const n = {
|
|
3089
3089
|
created_at: ii(),
|
|
@@ -3092,7 +3092,7 @@ function ci(e, t) {
|
|
|
3092
3092
|
...e,
|
|
3093
3093
|
pubkey: ae(t)
|
|
3094
3094
|
};
|
|
3095
|
-
return n.id =
|
|
3095
|
+
return n.id = qe(n), n;
|
|
3096
3096
|
}
|
|
3097
3097
|
function ui(e, t, n) {
|
|
3098
3098
|
return Q(
|
|
@@ -3121,7 +3121,7 @@ function st(e, t, n) {
|
|
|
3121
3121
|
const r = ci(e, t), i = ui(r, t, n);
|
|
3122
3122
|
return li(i, n);
|
|
3123
3123
|
}
|
|
3124
|
-
function
|
|
3124
|
+
function pc(e, t, n) {
|
|
3125
3125
|
if (!n || n.length === 0)
|
|
3126
3126
|
throw new Error("At least one recipient is required.");
|
|
3127
3127
|
const r = ae(t), i = [st(e, t, r)];
|
|
@@ -3139,7 +3139,7 @@ function fi(e, t) {
|
|
|
3139
3139
|
n.push(mn(r, t));
|
|
3140
3140
|
}), n.sort((r, i) => r.created_at - i.created_at), n;
|
|
3141
3141
|
}
|
|
3142
|
-
function
|
|
3142
|
+
function gc(e, t, n, r) {
|
|
3143
3143
|
const i = {
|
|
3144
3144
|
created_at: Math.ceil(Date.now() / 1e3),
|
|
3145
3145
|
kind: Or,
|
|
@@ -3151,23 +3151,23 @@ function pc(e, t, n, r) {
|
|
|
3151
3151
|
}), r && i.tags.push(["e", r.eventId, r.relayUrl || "", "reply"]), n && i.tags.push(["subject", n]), i;
|
|
3152
3152
|
}
|
|
3153
3153
|
function hi(e, t, n, r, i) {
|
|
3154
|
-
const s =
|
|
3154
|
+
const s = gc(t, n, r, i);
|
|
3155
3155
|
return st(s, e, t.publicKey);
|
|
3156
3156
|
}
|
|
3157
|
-
function
|
|
3157
|
+
function wc(e, t, n, r, i) {
|
|
3158
3158
|
if (!t || t.length === 0)
|
|
3159
3159
|
throw new Error("At least one recipient is required.");
|
|
3160
3160
|
return [{ publicKey: ae(e) }, ...t].map(
|
|
3161
3161
|
(o) => hi(e, o, n, r, i)
|
|
3162
3162
|
);
|
|
3163
3163
|
}
|
|
3164
|
-
var
|
|
3165
|
-
H(
|
|
3166
|
-
finishRepostEvent: () =>
|
|
3167
|
-
getRepostedEvent: () =>
|
|
3164
|
+
var bc = mn, vc = fi, mc = {};
|
|
3165
|
+
H(mc, {
|
|
3166
|
+
finishRepostEvent: () => Ec,
|
|
3167
|
+
getRepostedEvent: () => xc,
|
|
3168
3168
|
getRepostedEventPointer: () => di
|
|
3169
3169
|
});
|
|
3170
|
-
function
|
|
3170
|
+
function Ec(e, t, n, r) {
|
|
3171
3171
|
var o;
|
|
3172
3172
|
let i;
|
|
3173
3173
|
const s = [...e.tags ?? [], ["e", t.id, n], ["p", t.pubkey]];
|
|
@@ -3196,7 +3196,7 @@ function di(e) {
|
|
|
3196
3196
|
author: n == null ? void 0 : n[1]
|
|
3197
3197
|
};
|
|
3198
3198
|
}
|
|
3199
|
-
function
|
|
3199
|
+
function xc(e, { skipVerification: t } = {}) {
|
|
3200
3200
|
const n = di(e);
|
|
3201
3201
|
if (n === void 0 || e.content === "")
|
|
3202
3202
|
return;
|
|
@@ -3209,17 +3209,17 @@ function Ec(e, { skipVerification: t } = {}) {
|
|
|
3209
3209
|
if (r.id === n.id && !(!t && !gt(r)))
|
|
3210
3210
|
return r;
|
|
3211
3211
|
}
|
|
3212
|
-
var
|
|
3213
|
-
H(
|
|
3212
|
+
var Kc = {};
|
|
3213
|
+
H(Kc, {
|
|
3214
3214
|
NOSTR_URI_REGEX: () => En,
|
|
3215
|
-
parse: () =>
|
|
3216
|
-
test: () =>
|
|
3215
|
+
parse: () => Sc,
|
|
3216
|
+
test: () => Nc
|
|
3217
3217
|
});
|
|
3218
3218
|
var En = new RegExp(`nostr:(${Zr.source})`);
|
|
3219
|
-
function
|
|
3219
|
+
function Nc(e) {
|
|
3220
3220
|
return typeof e == "string" && new RegExp(`^${En.source}$`).test(e);
|
|
3221
3221
|
}
|
|
3222
|
-
function
|
|
3222
|
+
function Sc(e) {
|
|
3223
3223
|
const t = e.match(new RegExp(`^${En.source}$`));
|
|
3224
3224
|
if (!t)
|
|
3225
3225
|
throw new Error(`Invalid Nostr URI: ${e}`);
|
|
@@ -3229,12 +3229,12 @@ function Nc(e) {
|
|
|
3229
3229
|
decoded: wt(t[1])
|
|
3230
3230
|
};
|
|
3231
3231
|
}
|
|
3232
|
-
var
|
|
3233
|
-
H(
|
|
3234
|
-
finishReactionEvent: () =>
|
|
3235
|
-
getReactedEventPointer: () =>
|
|
3232
|
+
var Ac = {};
|
|
3233
|
+
H(Ac, {
|
|
3234
|
+
finishReactionEvent: () => Cc,
|
|
3235
|
+
getReactedEventPointer: () => kc
|
|
3236
3236
|
});
|
|
3237
|
-
function
|
|
3237
|
+
function Cc(e, t, n) {
|
|
3238
3238
|
const r = t.tags.filter((i) => i.length >= 2 && (i[0] === "e" || i[0] === "p"));
|
|
3239
3239
|
return Q(
|
|
3240
3240
|
{
|
|
@@ -3246,7 +3246,7 @@ function Ac(e, t, n) {
|
|
|
3246
3246
|
n
|
|
3247
3247
|
);
|
|
3248
3248
|
}
|
|
3249
|
-
function
|
|
3249
|
+
function kc(e) {
|
|
3250
3250
|
if (e.kind !== un)
|
|
3251
3251
|
return;
|
|
3252
3252
|
let t, n;
|
|
@@ -3261,12 +3261,12 @@ function Cc(e) {
|
|
|
3261
3261
|
author: n[1]
|
|
3262
3262
|
};
|
|
3263
3263
|
}
|
|
3264
|
-
var
|
|
3265
|
-
H(
|
|
3266
|
-
parse: () =>
|
|
3264
|
+
var Bc = {};
|
|
3265
|
+
H(Bc, {
|
|
3266
|
+
parse: () => Uc
|
|
3267
3267
|
});
|
|
3268
|
-
var
|
|
3269
|
-
function*
|
|
3268
|
+
var Ic = /\W/m, Vn = /\W |\W$|$|,| /m;
|
|
3269
|
+
function* Uc(e) {
|
|
3270
3270
|
const t = e.length;
|
|
3271
3271
|
let n = 0, r = 0;
|
|
3272
3272
|
for (; r < t; ) {
|
|
@@ -3274,7 +3274,7 @@ function* Ic(e) {
|
|
|
3274
3274
|
if (i === -1)
|
|
3275
3275
|
break;
|
|
3276
3276
|
if (e.substring(i - 5, i) === "nostr") {
|
|
3277
|
-
const s = e.substring(i + 60).match(
|
|
3277
|
+
const s = e.substring(i + 60).match(Ic), o = s ? i + 60 + s.index : t;
|
|
3278
3278
|
try {
|
|
3279
3279
|
let c, { data: a, type: l } = wt(e.substring(i + 1, o));
|
|
3280
3280
|
switch (l) {
|
|
@@ -3337,15 +3337,15 @@ function* Ic(e) {
|
|
|
3337
3337
|
}
|
|
3338
3338
|
n !== t && (yield { type: "text", text: e.substring(n) });
|
|
3339
3339
|
}
|
|
3340
|
-
var
|
|
3341
|
-
H(
|
|
3342
|
-
channelCreateEvent: () =>
|
|
3343
|
-
channelHideMessageEvent: () =>
|
|
3344
|
-
channelMessageEvent: () =>
|
|
3345
|
-
channelMetadataEvent: () =>
|
|
3346
|
-
channelMuteUserEvent: () =>
|
|
3340
|
+
var _c = {};
|
|
3341
|
+
H(_c, {
|
|
3342
|
+
channelCreateEvent: () => Lc,
|
|
3343
|
+
channelHideMessageEvent: () => Tc,
|
|
3344
|
+
channelMessageEvent: () => Rc,
|
|
3345
|
+
channelMetadataEvent: () => $c,
|
|
3346
|
+
channelMuteUserEvent: () => Oc
|
|
3347
3347
|
});
|
|
3348
|
-
var
|
|
3348
|
+
var Lc = (e, t) => {
|
|
3349
3349
|
let n;
|
|
3350
3350
|
if (typeof e.content == "object")
|
|
3351
3351
|
n = JSON.stringify(e.content);
|
|
@@ -3362,7 +3362,7 @@ var _c = (e, t) => {
|
|
|
3362
3362
|
},
|
|
3363
3363
|
t
|
|
3364
3364
|
);
|
|
3365
|
-
},
|
|
3365
|
+
}, $c = (e, t) => {
|
|
3366
3366
|
let n;
|
|
3367
3367
|
if (typeof e.content == "object")
|
|
3368
3368
|
n = JSON.stringify(e.content);
|
|
@@ -3379,7 +3379,7 @@ var _c = (e, t) => {
|
|
|
3379
3379
|
},
|
|
3380
3380
|
t
|
|
3381
3381
|
);
|
|
3382
|
-
},
|
|
3382
|
+
}, Rc = (e, t) => {
|
|
3383
3383
|
const n = [["e", e.channel_create_event_id, e.relay_url, "root"]];
|
|
3384
3384
|
return e.reply_to_channel_message_event_id && n.push(["e", e.reply_to_channel_message_event_id, e.relay_url, "reply"]), Q(
|
|
3385
3385
|
{
|
|
@@ -3390,7 +3390,7 @@ var _c = (e, t) => {
|
|
|
3390
3390
|
},
|
|
3391
3391
|
t
|
|
3392
3392
|
);
|
|
3393
|
-
},
|
|
3393
|
+
}, Tc = (e, t) => {
|
|
3394
3394
|
let n;
|
|
3395
3395
|
if (typeof e.content == "object")
|
|
3396
3396
|
n = JSON.stringify(e.content);
|
|
@@ -3400,14 +3400,14 @@ var _c = (e, t) => {
|
|
|
3400
3400
|
return;
|
|
3401
3401
|
return Q(
|
|
3402
3402
|
{
|
|
3403
|
-
kind:
|
|
3403
|
+
kind: qr,
|
|
3404
3404
|
tags: [["e", e.channel_message_event_id], ...e.tags ?? []],
|
|
3405
3405
|
content: n,
|
|
3406
3406
|
created_at: e.created_at
|
|
3407
3407
|
},
|
|
3408
3408
|
t
|
|
3409
3409
|
);
|
|
3410
|
-
},
|
|
3410
|
+
}, Oc = (e, t) => {
|
|
3411
3411
|
let n;
|
|
3412
3412
|
if (typeof e.content == "object")
|
|
3413
3413
|
n = JSON.stringify(e.content);
|
|
@@ -3417,22 +3417,22 @@ var _c = (e, t) => {
|
|
|
3417
3417
|
return;
|
|
3418
3418
|
return Q(
|
|
3419
3419
|
{
|
|
3420
|
-
kind:
|
|
3420
|
+
kind: Dr,
|
|
3421
3421
|
tags: [["p", e.pubkey_to_mute], ...e.tags ?? []],
|
|
3422
3422
|
content: n,
|
|
3423
3423
|
created_at: e.created_at
|
|
3424
3424
|
},
|
|
3425
3425
|
t
|
|
3426
3426
|
);
|
|
3427
|
-
},
|
|
3428
|
-
H(
|
|
3427
|
+
}, Mc = {};
|
|
3428
|
+
H(Mc, {
|
|
3429
3429
|
EMOJI_SHORTCODE_REGEX: () => yi,
|
|
3430
|
-
matchAll: () =>
|
|
3430
|
+
matchAll: () => Pc,
|
|
3431
3431
|
regex: () => xn,
|
|
3432
|
-
replaceAll: () =>
|
|
3432
|
+
replaceAll: () => Hc
|
|
3433
3433
|
});
|
|
3434
3434
|
var yi = /:(\w+):/, xn = () => new RegExp(`\\B${yi.source}\\B`, "g");
|
|
3435
|
-
function*
|
|
3435
|
+
function* Pc(e) {
|
|
3436
3436
|
const t = e.matchAll(xn());
|
|
3437
3437
|
for (const n of t)
|
|
3438
3438
|
try {
|
|
@@ -3446,16 +3446,16 @@ function* Mc(e) {
|
|
|
3446
3446
|
} catch {
|
|
3447
3447
|
}
|
|
3448
3448
|
}
|
|
3449
|
-
function
|
|
3449
|
+
function Hc(e, t) {
|
|
3450
3450
|
return e.replaceAll(xn(), (n, r) => t({
|
|
3451
3451
|
shortcode: n,
|
|
3452
3452
|
name: r
|
|
3453
3453
|
}));
|
|
3454
3454
|
}
|
|
3455
|
-
var
|
|
3456
|
-
H(
|
|
3455
|
+
var qc = {};
|
|
3456
|
+
H(qc, {
|
|
3457
3457
|
useFetchImplementation: () => Dc,
|
|
3458
|
-
validateGithub: () =>
|
|
3458
|
+
validateGithub: () => jc
|
|
3459
3459
|
});
|
|
3460
3460
|
var Kn;
|
|
3461
3461
|
try {
|
|
@@ -3465,25 +3465,25 @@ try {
|
|
|
3465
3465
|
function Dc(e) {
|
|
3466
3466
|
Kn = e;
|
|
3467
3467
|
}
|
|
3468
|
-
async function
|
|
3468
|
+
async function jc(e, t, n) {
|
|
3469
3469
|
try {
|
|
3470
3470
|
return await (await Kn(`https://gist.github.com/${t}/${n}/raw`)).text() === `Verifying that I control the following Nostr public key: ${e}`;
|
|
3471
3471
|
} catch {
|
|
3472
3472
|
return !1;
|
|
3473
3473
|
}
|
|
3474
3474
|
}
|
|
3475
|
-
var
|
|
3476
|
-
H(
|
|
3477
|
-
makeNwcRequestEvent: () =>
|
|
3478
|
-
parseConnectionString: () =>
|
|
3475
|
+
var zc = {};
|
|
3476
|
+
H(zc, {
|
|
3477
|
+
makeNwcRequestEvent: () => Vc,
|
|
3478
|
+
parseConnectionString: () => Wc
|
|
3479
3479
|
});
|
|
3480
|
-
function
|
|
3480
|
+
function Wc(e) {
|
|
3481
3481
|
const { host: t, pathname: n, searchParams: r } = new URL(e), i = n || t, s = r.get("relay"), o = r.get("secret");
|
|
3482
3482
|
if (!i || !s || !o)
|
|
3483
3483
|
throw new Error("invalid connection string");
|
|
3484
3484
|
return { pubkey: i, relay: s, secret: o };
|
|
3485
3485
|
}
|
|
3486
|
-
async function
|
|
3486
|
+
async function Vc(e, t, n) {
|
|
3487
3487
|
const i = Fr(t, e, JSON.stringify({
|
|
3488
3488
|
method: "pay_invoice",
|
|
3489
3489
|
params: {
|
|
@@ -3497,31 +3497,31 @@ async function Wc(e, t, n) {
|
|
|
3497
3497
|
};
|
|
3498
3498
|
return Q(s, t);
|
|
3499
3499
|
}
|
|
3500
|
-
var
|
|
3501
|
-
H(
|
|
3502
|
-
normalizeIdentifier: () =>
|
|
3500
|
+
var Zc = {};
|
|
3501
|
+
H(Zc, {
|
|
3502
|
+
normalizeIdentifier: () => Fc
|
|
3503
3503
|
});
|
|
3504
|
-
function
|
|
3504
|
+
function Fc(e) {
|
|
3505
3505
|
return e = e.trim().toLowerCase(), e = e.normalize("NFKC"), Array.from(e).map((t) => new RegExp("\\p{Letter}", "u").test(t) || new RegExp("\\p{Number}", "u").test(t) ? t : "-").join("");
|
|
3506
3506
|
}
|
|
3507
|
-
var
|
|
3508
|
-
H(
|
|
3509
|
-
getSatoshisAmountFromBolt11: () =>
|
|
3510
|
-
getZapEndpoint: () =>
|
|
3511
|
-
makeZapReceipt: () =>
|
|
3512
|
-
makeZapRequest: () =>
|
|
3513
|
-
useFetchImplementation: () =>
|
|
3514
|
-
validateZapRequest: () =>
|
|
3507
|
+
var Gc = {};
|
|
3508
|
+
H(Gc, {
|
|
3509
|
+
getSatoshisAmountFromBolt11: () => tu,
|
|
3510
|
+
getZapEndpoint: () => Yc,
|
|
3511
|
+
makeZapReceipt: () => eu,
|
|
3512
|
+
makeZapRequest: () => Xc,
|
|
3513
|
+
useFetchImplementation: () => Jc,
|
|
3514
|
+
validateZapRequest: () => Qc
|
|
3515
3515
|
});
|
|
3516
3516
|
var Nn;
|
|
3517
3517
|
try {
|
|
3518
3518
|
Nn = fetch;
|
|
3519
3519
|
} catch {
|
|
3520
3520
|
}
|
|
3521
|
-
function
|
|
3521
|
+
function Jc(e) {
|
|
3522
3522
|
Nn = e;
|
|
3523
3523
|
}
|
|
3524
|
-
async function
|
|
3524
|
+
async function Yc(e) {
|
|
3525
3525
|
try {
|
|
3526
3526
|
let t = "", { lud06: n, lud16: r } = JSON.parse(e.content);
|
|
3527
3527
|
if (n) {
|
|
@@ -3539,7 +3539,7 @@ async function Jc(e) {
|
|
|
3539
3539
|
}
|
|
3540
3540
|
return null;
|
|
3541
3541
|
}
|
|
3542
|
-
function
|
|
3542
|
+
function Xc(e) {
|
|
3543
3543
|
let t = {
|
|
3544
3544
|
kind: 9734,
|
|
3545
3545
|
created_at: Math.round(Date.now() / 1e3),
|
|
@@ -3565,7 +3565,7 @@ function Yc(e) {
|
|
|
3565
3565
|
}
|
|
3566
3566
|
return t;
|
|
3567
3567
|
}
|
|
3568
|
-
function
|
|
3568
|
+
function Qc(e) {
|
|
3569
3569
|
let t;
|
|
3570
3570
|
try {
|
|
3571
3571
|
t = JSON.parse(e);
|
|
@@ -3584,7 +3584,7 @@ function Xc(e) {
|
|
|
3584
3584
|
let r = t.tags.find(([s, o]) => s === "e" && o);
|
|
3585
3585
|
return r && !r[1].match(/^[a-f0-9]{64}$/) ? "Zap request 'e' tag is not valid hex." : t.tags.find(([s, o]) => s === "relays" && o) ? null : "Zap request doesn't have a 'relays' tag.";
|
|
3586
3586
|
}
|
|
3587
|
-
function
|
|
3587
|
+
function eu({
|
|
3588
3588
|
zapRequest: e,
|
|
3589
3589
|
preimage: t,
|
|
3590
3590
|
bolt11: n,
|
|
@@ -3598,7 +3598,7 @@ function Qc({
|
|
|
3598
3598
|
};
|
|
3599
3599
|
return t && o.tags.push(["preimage", t]), o;
|
|
3600
3600
|
}
|
|
3601
|
-
function
|
|
3601
|
+
function tu(e) {
|
|
3602
3602
|
if (e.length < 50)
|
|
3603
3603
|
return 0;
|
|
3604
3604
|
e = e.substring(0, 50);
|
|
@@ -3629,9 +3629,9 @@ function eu(e) {
|
|
|
3629
3629
|
return a * 1e8;
|
|
3630
3630
|
}
|
|
3631
3631
|
}
|
|
3632
|
-
var
|
|
3633
|
-
H(
|
|
3634
|
-
getToken: () =>
|
|
3632
|
+
var nu = {};
|
|
3633
|
+
H(nu, {
|
|
3634
|
+
getToken: () => ru,
|
|
3635
3635
|
hashPayload: () => Sn,
|
|
3636
3636
|
unpackEventFromToken: () => gi,
|
|
3637
3637
|
validateEvent: () => xi,
|
|
@@ -3640,10 +3640,10 @@ H(tu, {
|
|
|
3640
3640
|
validateEventPayloadTag: () => Ei,
|
|
3641
3641
|
validateEventTimestamp: () => wi,
|
|
3642
3642
|
validateEventUrlTag: () => vi,
|
|
3643
|
-
validateToken: () =>
|
|
3643
|
+
validateToken: () => iu
|
|
3644
3644
|
});
|
|
3645
3645
|
var pi = "Nostr ";
|
|
3646
|
-
async function
|
|
3646
|
+
async function ru(e, t, n, r = !1, i) {
|
|
3647
3647
|
const s = {
|
|
3648
3648
|
kind: fn,
|
|
3649
3649
|
tags: [
|
|
@@ -3657,7 +3657,7 @@ async function nu(e, t, n, r = !1, i) {
|
|
|
3657
3657
|
const o = await n(s);
|
|
3658
3658
|
return (r ? pi : "") + he.encode(ne.encode(JSON.stringify(o)));
|
|
3659
3659
|
}
|
|
3660
|
-
async function
|
|
3660
|
+
async function iu(e, t, n) {
|
|
3661
3661
|
const r = await gi(e).catch((s) => {
|
|
3662
3662
|
throw s;
|
|
3663
3663
|
});
|
|
@@ -3714,10 +3714,10 @@ async function xi(e, t, n, r) {
|
|
|
3714
3714
|
throw new Error("Invalid nostr event, payload tag does not match request body hash");
|
|
3715
3715
|
return !0;
|
|
3716
3716
|
}
|
|
3717
|
-
const Oe = 1060, Lt = 30078, Zn = 1059,
|
|
3717
|
+
const Oe = 1060, Lt = 30078, Zn = 1059, su = 14, bu = 100, ou = 1;
|
|
3718
3718
|
function vu(e) {
|
|
3719
3719
|
return JSON.stringify({
|
|
3720
|
-
version:
|
|
3720
|
+
version: ou,
|
|
3721
3721
|
rootKey: P(e.rootKey),
|
|
3722
3722
|
theirCurrentNostrPublicKey: e.theirCurrentNostrPublicKey,
|
|
3723
3723
|
theirNextNostrPublicKey: e.theirNextNostrPublicKey,
|
|
@@ -3813,7 +3813,7 @@ function mu(e) {
|
|
|
3813
3813
|
)
|
|
3814
3814
|
};
|
|
3815
3815
|
}
|
|
3816
|
-
function
|
|
3816
|
+
function au(e) {
|
|
3817
3817
|
return {
|
|
3818
3818
|
rootKey: new Uint8Array(e.rootKey),
|
|
3819
3819
|
theirCurrentNostrPublicKey: e.theirCurrentNostrPublicKey,
|
|
@@ -3873,7 +3873,7 @@ function Ku(e) {
|
|
|
3873
3873
|
const t = (n = e.tags) == null ? void 0 : n.find((r) => r[0] === "ms");
|
|
3874
3874
|
return t ? parseInt(t[1]) : e.created_at * 1e3;
|
|
3875
3875
|
}
|
|
3876
|
-
const
|
|
3876
|
+
const cu = 1e3, uu = "0000000000000000000000000000000000000000000000000000000000000000";
|
|
3877
3877
|
class ot {
|
|
3878
3878
|
// 1. CHANNEL PUBLIC INTERFACE
|
|
3879
3879
|
constructor(t, n) {
|
|
@@ -3898,7 +3898,7 @@ class ot {
|
|
|
3898
3898
|
static init(t, n, r, i, s, o) {
|
|
3899
3899
|
const c = Be();
|
|
3900
3900
|
let a, l, f, u;
|
|
3901
|
-
i ? ([a, l] = Me(s,
|
|
3901
|
+
i ? ([a, l] = Me(s, D.getConversationKey(c, n), 2), f = {
|
|
3902
3902
|
publicKey: ae(r),
|
|
3903
3903
|
privateKey: r
|
|
3904
3904
|
}, u = {
|
|
@@ -3932,7 +3932,7 @@ class ot {
|
|
|
3932
3932
|
send(t) {
|
|
3933
3933
|
return this.sendEvent({
|
|
3934
3934
|
content: t,
|
|
3935
|
-
kind:
|
|
3935
|
+
kind: su
|
|
3936
3936
|
});
|
|
3937
3937
|
}
|
|
3938
3938
|
/**
|
|
@@ -3953,10 +3953,10 @@ class ot {
|
|
|
3953
3953
|
kind: t.kind || Oe,
|
|
3954
3954
|
created_at: t.created_at || Math.floor(n / 1e3),
|
|
3955
3955
|
tags: t.tags || [],
|
|
3956
|
-
pubkey: t.pubkey ||
|
|
3956
|
+
pubkey: t.pubkey || uu
|
|
3957
3957
|
};
|
|
3958
|
-
r.tags.some(([l]) => l === "ms") || r.tags.push(["ms", String(n)]), r.id =
|
|
3959
|
-
const [i, s] = this.ratchetEncrypt(JSON.stringify(r)), o =
|
|
3958
|
+
r.tags.some(([l]) => l === "ms") || r.tags.push(["ms", String(n)]), r.id = qe(r);
|
|
3959
|
+
const [i, s] = this.ratchetEncrypt(JSON.stringify(r)), o = D.getConversationKey(this.state.ourCurrentNostrKey.privateKey, this.state.theirNextNostrPublicKey), c = D.encrypt(JSON.stringify(i), o);
|
|
3960
3960
|
return { event: Q({
|
|
3961
3961
|
content: s,
|
|
3962
3962
|
kind: Oe,
|
|
@@ -3987,41 +3987,41 @@ class ot {
|
|
|
3987
3987
|
number: this.state.sendingChainMessageNumber++,
|
|
3988
3988
|
nextPublicKey: this.state.ourNextNostrKey.publicKey,
|
|
3989
3989
|
previousChainLength: this.state.previousSendingChainMessageCount
|
|
3990
|
-
},
|
|
3990
|
+
}, D.encrypt(t, r)];
|
|
3991
3991
|
}
|
|
3992
3992
|
ratchetDecrypt(t, n, r) {
|
|
3993
3993
|
const i = this.trySkippedMessageKeys(t, n, r);
|
|
3994
3994
|
if (i) return i;
|
|
3995
3995
|
this.skipMessageKeys(t.number, r);
|
|
3996
3996
|
const [s, o] = Me(this.state.receivingChainKey, new Uint8Array([1]), 2);
|
|
3997
|
-
return this.state.receivingChainKey = s, this.state.receivingChainMessageNumber++,
|
|
3997
|
+
return this.state.receivingChainKey = s, this.state.receivingChainMessageNumber++, D.decrypt(n, o);
|
|
3998
3998
|
}
|
|
3999
3999
|
ratchetStep() {
|
|
4000
4000
|
this.state.previousSendingChainMessageCount = this.state.sendingChainMessageNumber, this.state.sendingChainMessageNumber = 0, this.state.receivingChainMessageNumber = 0;
|
|
4001
|
-
const t =
|
|
4001
|
+
const t = D.getConversationKey(this.state.ourNextNostrKey.privateKey, this.state.theirNextNostrPublicKey), [n, r] = Me(this.state.rootKey, t, 2);
|
|
4002
4002
|
this.state.receivingChainKey = r, this.state.ourCurrentNostrKey = this.state.ourNextNostrKey;
|
|
4003
4003
|
const i = Be();
|
|
4004
4004
|
this.state.ourNextNostrKey = {
|
|
4005
4005
|
publicKey: ae(i),
|
|
4006
4006
|
privateKey: i
|
|
4007
4007
|
};
|
|
4008
|
-
const s =
|
|
4008
|
+
const s = D.getConversationKey(this.state.ourNextNostrKey.privateKey, this.state.theirNextNostrPublicKey), [o, c] = Me(n, s, 2);
|
|
4009
4009
|
this.state.rootKey = o, this.state.sendingChainKey = c;
|
|
4010
4010
|
}
|
|
4011
4011
|
// 3. MESSAGE KEY FUNCTIONS
|
|
4012
4012
|
skipMessageKeys(t, n) {
|
|
4013
4013
|
if (!(t <= this.state.receivingChainMessageNumber)) {
|
|
4014
|
-
if (t > this.state.receivingChainMessageNumber +
|
|
4014
|
+
if (t > this.state.receivingChainMessageNumber + cu)
|
|
4015
4015
|
throw new Error("Too many skipped messages");
|
|
4016
4016
|
if (!this.state.skippedKeys[n]) {
|
|
4017
4017
|
if (this.state.skippedKeys[n] = {
|
|
4018
4018
|
headerKeys: [],
|
|
4019
4019
|
messageKeys: {}
|
|
4020
4020
|
}, this.state.ourCurrentNostrKey) {
|
|
4021
|
-
const i =
|
|
4021
|
+
const i = D.getConversationKey(this.state.ourCurrentNostrKey.privateKey, n);
|
|
4022
4022
|
this.state.skippedKeys[n].headerKeys.includes(i) || this.state.skippedKeys[n].headerKeys.push(i);
|
|
4023
4023
|
}
|
|
4024
|
-
const r =
|
|
4024
|
+
const r = D.getConversationKey(this.state.ourNextNostrKey.privateKey, n);
|
|
4025
4025
|
this.state.skippedKeys[n].headerKeys.includes(r) || this.state.skippedKeys[n].headerKeys.push(r);
|
|
4026
4026
|
}
|
|
4027
4027
|
for (; this.state.receivingChainMessageNumber < t; ) {
|
|
@@ -4034,35 +4034,35 @@ class ot {
|
|
|
4034
4034
|
const i = this.state.skippedKeys[r];
|
|
4035
4035
|
if (!i) return null;
|
|
4036
4036
|
const s = i.messageKeys[t.number];
|
|
4037
|
-
return s ? (delete i.messageKeys[t.number], Object.keys(i.messageKeys).length === 0 && delete this.state.skippedKeys[r],
|
|
4037
|
+
return s ? (delete i.messageKeys[t.number], Object.keys(i.messageKeys).length === 0 && delete this.state.skippedKeys[r], D.decrypt(n, s)) : null;
|
|
4038
4038
|
}
|
|
4039
4039
|
// 4. NOSTR EVENT HANDLING
|
|
4040
4040
|
decryptHeader(t) {
|
|
4041
4041
|
const n = t.tags[0][1];
|
|
4042
4042
|
if (this.state.ourCurrentNostrKey) {
|
|
4043
|
-
const s =
|
|
4043
|
+
const s = D.getConversationKey(this.state.ourCurrentNostrKey.privateKey, t.pubkey);
|
|
4044
4044
|
try {
|
|
4045
|
-
return [JSON.parse(
|
|
4045
|
+
return [JSON.parse(D.decrypt(n, s)), !1, !1];
|
|
4046
4046
|
} catch {
|
|
4047
4047
|
}
|
|
4048
4048
|
}
|
|
4049
|
-
const r =
|
|
4049
|
+
const r = D.getConversationKey(this.state.ourNextNostrKey.privateKey, t.pubkey);
|
|
4050
4050
|
try {
|
|
4051
|
-
return [JSON.parse(
|
|
4051
|
+
return [JSON.parse(D.decrypt(n, r)), !0, !1];
|
|
4052
4052
|
} catch {
|
|
4053
4053
|
}
|
|
4054
4054
|
const i = this.state.skippedKeys[t.pubkey];
|
|
4055
4055
|
if (i != null && i.headerKeys)
|
|
4056
4056
|
for (const s of i.headerKeys)
|
|
4057
4057
|
try {
|
|
4058
|
-
return [JSON.parse(
|
|
4058
|
+
return [JSON.parse(D.decrypt(n, s)), !1, !0];
|
|
4059
4059
|
} catch {
|
|
4060
4060
|
}
|
|
4061
4061
|
throw new Error("Failed to decrypt header with current and skipped header keys");
|
|
4062
4062
|
}
|
|
4063
4063
|
handleNostrEvent(t) {
|
|
4064
4064
|
var i, s;
|
|
4065
|
-
const n =
|
|
4065
|
+
const n = au(this.state);
|
|
4066
4066
|
let r = !1;
|
|
4067
4067
|
try {
|
|
4068
4068
|
const [o, c, a] = this.decryptHeader(t);
|
|
@@ -4075,7 +4075,7 @@ class ot {
|
|
|
4075
4075
|
this.state = n;
|
|
4076
4076
|
return;
|
|
4077
4077
|
}
|
|
4078
|
-
if (f.id !==
|
|
4078
|
+
if (f.id !== qe(f)) {
|
|
4079
4079
|
this.state = n;
|
|
4080
4080
|
return;
|
|
4081
4081
|
}
|
|
@@ -4111,10 +4111,10 @@ function Qe(e, t) {
|
|
|
4111
4111
|
const n = Ue.getSharedSecret(e, "02" + t).subarray(1, 33);
|
|
4112
4112
|
return rn(fe, n, "nip44-v2");
|
|
4113
4113
|
}
|
|
4114
|
-
const
|
|
4114
|
+
const lu = 2 * 24 * 60 * 60, Ki = () => Math.round(Date.now() / 1e3), fu = () => Math.round(Ki() - Math.random() * lu);
|
|
4115
4115
|
class Pe {
|
|
4116
|
-
constructor(t, n, r, i, s, o, c = []) {
|
|
4117
|
-
this.inviterEphemeralPublicKey = t, this.sharedSecret = n, this.inviter = r, this.inviterEphemeralPrivateKey = i, this.deviceId = s, this.maxUses = o, this.usedBy = c;
|
|
4116
|
+
constructor(t, n, r, i, s, o, c = [], a = Ki()) {
|
|
4117
|
+
this.inviterEphemeralPublicKey = t, this.sharedSecret = n, this.inviter = r, this.inviterEphemeralPrivateKey = i, this.deviceId = s, this.maxUses = o, this.usedBy = c, this.createdAt = a;
|
|
4118
4118
|
}
|
|
4119
4119
|
static createNew(t, n, r) {
|
|
4120
4120
|
if (!t)
|
|
@@ -4158,7 +4158,8 @@ class Pe {
|
|
|
4158
4158
|
n.inviterEphemeralPrivateKey ? new Uint8Array(n.inviterEphemeralPrivateKey) : void 0,
|
|
4159
4159
|
n.deviceId,
|
|
4160
4160
|
n.maxUses,
|
|
4161
|
-
n.usedBy
|
|
4161
|
+
n.usedBy,
|
|
4162
|
+
n.createdAt
|
|
4162
4163
|
);
|
|
4163
4164
|
}
|
|
4164
4165
|
static fromEvent(t) {
|
|
@@ -4214,7 +4215,8 @@ class Pe {
|
|
|
4214
4215
|
inviterEphemeralPrivateKey: this.inviterEphemeralPrivateKey ? Array.from(this.inviterEphemeralPrivateKey) : void 0,
|
|
4215
4216
|
deviceId: this.deviceId,
|
|
4216
4217
|
maxUses: this.maxUses,
|
|
4217
|
-
usedBy: this.usedBy
|
|
4218
|
+
usedBy: this.usedBy,
|
|
4219
|
+
createdAt: this.createdAt
|
|
4218
4220
|
});
|
|
4219
4221
|
}
|
|
4220
4222
|
/**
|
|
@@ -4235,7 +4237,7 @@ class Pe {
|
|
|
4235
4237
|
kind: Lt,
|
|
4236
4238
|
pubkey: this.inviter,
|
|
4237
4239
|
content: "",
|
|
4238
|
-
created_at:
|
|
4240
|
+
created_at: this.createdAt,
|
|
4239
4241
|
tags: [
|
|
4240
4242
|
["ephemeralKey", this.inviterEphemeralPublicKey],
|
|
4241
4243
|
["sharedSecret", this.sharedSecret],
|
|
@@ -4283,17 +4285,17 @@ class Pe {
|
|
|
4283
4285
|
* so the inviter can create the session on their side.
|
|
4284
4286
|
*/
|
|
4285
4287
|
async accept(t, n, r, i) {
|
|
4286
|
-
const s = Be(), o = ae(s), c = this.inviter || this.inviterEphemeralPublicKey, a = j(this.sharedSecret), l = ot.init(t, this.inviterEphemeralPublicKey, s, !0, a, void 0), f = typeof r == "function" ? r : (m, S) => Promise.resolve(
|
|
4288
|
+
const s = Be(), o = ae(s), c = this.inviter || this.inviterEphemeralPublicKey, a = j(this.sharedSecret), l = ot.init(t, this.inviterEphemeralPublicKey, s, !0, a, void 0), f = typeof r == "function" ? r : (m, S) => Promise.resolve(D.encrypt(m, Qe(r, S))), u = JSON.stringify({
|
|
4287
4289
|
sessionKey: o,
|
|
4288
4290
|
deviceId: i
|
|
4289
4291
|
}), p = await f(u, c), w = {
|
|
4290
4292
|
pubkey: n,
|
|
4291
|
-
content: await
|
|
4293
|
+
content: await D.encrypt(p, a),
|
|
4292
4294
|
created_at: Math.floor(Date.now() / 1e3)
|
|
4293
4295
|
}, g = JSON.stringify(w), h = Be(), d = ae(h), y = {
|
|
4294
4296
|
kind: Zn,
|
|
4295
4297
|
pubkey: d,
|
|
4296
|
-
content:
|
|
4298
|
+
content: D.encrypt(g, Qe(h, this.inviterEphemeralPublicKey)),
|
|
4297
4299
|
created_at: fu(),
|
|
4298
4300
|
tags: [["p", this.inviterEphemeralPublicKey]]
|
|
4299
4301
|
};
|
|
@@ -4310,9 +4312,9 @@ class Pe {
|
|
|
4310
4312
|
try {
|
|
4311
4313
|
if (this.maxUses && this.usedBy.length >= this.maxUses)
|
|
4312
4314
|
return;
|
|
4313
|
-
const o = await
|
|
4315
|
+
const o = await D.decrypt(s.content, Qe(this.inviterEphemeralPrivateKey, s.pubkey)), c = JSON.parse(o), a = j(this.sharedSecret), l = c.pubkey;
|
|
4314
4316
|
this.usedBy.push(l);
|
|
4315
|
-
const f = await
|
|
4317
|
+
const f = await D.decrypt(c.content, a), p = await (typeof t == "function" ? t : (y, m) => Promise.resolve(D.decrypt(y, Qe(t, m))))(f, l);
|
|
4316
4318
|
let w, g;
|
|
4317
4319
|
try {
|
|
4318
4320
|
const y = JSON.parse(p);
|
|
@@ -4328,7 +4330,7 @@ class Pe {
|
|
|
4328
4330
|
}
|
|
4329
4331
|
}
|
|
4330
4332
|
export {
|
|
4331
|
-
|
|
4333
|
+
su as CHAT_MESSAGE_KIND,
|
|
4332
4334
|
Lt as INVITE_EVENT_KIND,
|
|
4333
4335
|
Zn as INVITE_RESPONSE_KIND,
|
|
4334
4336
|
Pe as Invite,
|
|
@@ -4336,7 +4338,7 @@ export {
|
|
|
4336
4338
|
Oe as MESSAGE_EVENT_KIND,
|
|
4337
4339
|
ot as Session,
|
|
4338
4340
|
Eu as createEventStream,
|
|
4339
|
-
|
|
4341
|
+
au as deepCopyState,
|
|
4340
4342
|
mu as deserializeSessionState,
|
|
4341
4343
|
Ku as getMillisecondTimestamp,
|
|
4342
4344
|
Me as kdf,
|