nostr-double-ratchet 0.0.16 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Invite.d.ts.map +1 -1
- package/dist/Session.d.ts +9 -3
- package/dist/Session.d.ts.map +1 -1
- package/dist/nostr-double-ratchet.es.js +113 -104
- package/dist/nostr-double-ratchet.umd.js +1 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Invite.ts +5 -0
- package/src/Session.ts +7 -5
- package/src/utils.ts +8 -0
|
@@ -198,7 +198,7 @@ const Bi = (e, t, n) => e & t ^ ~e & n, ki = (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 Ii = class extends Ci {
|
|
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
|
}
|
|
@@ -231,9 +231,9 @@ let Ui = class extends Ci {
|
|
|
231
231
|
this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
|
|
232
232
|
}
|
|
233
233
|
};
|
|
234
|
-
const $t = /* @__PURE__ */ Ai(() => new
|
|
234
|
+
const $t = /* @__PURE__ */ Ai(() => new Ii());
|
|
235
235
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
236
|
-
const Gn = BigInt(0), ot = BigInt(1),
|
|
236
|
+
const Gn = BigInt(0), ot = BigInt(1), Ui = BigInt(2), at = (e) => e instanceof Uint8Array, Li = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
|
|
237
237
|
function De(e) {
|
|
238
238
|
if (!at(e))
|
|
239
239
|
throw new Error("Uint8Array expected");
|
|
@@ -300,7 +300,7 @@ function W(e, t, n) {
|
|
|
300
300
|
throw new Error(`${e} expected ${n} bytes, got ${i}`);
|
|
301
301
|
return r;
|
|
302
302
|
}
|
|
303
|
-
function
|
|
303
|
+
function Ie(...e) {
|
|
304
304
|
const t = new Uint8Array(e.reduce((r, i) => r + i.length, 0));
|
|
305
305
|
let n = 0;
|
|
306
306
|
return e.forEach((r) => {
|
|
@@ -331,7 +331,7 @@ function Oi(e) {
|
|
|
331
331
|
function Mi(e, t) {
|
|
332
332
|
return e >> BigInt(t) & ot;
|
|
333
333
|
}
|
|
334
|
-
const Pi = (e, t, n) => e | (n ? ot : Gn) << BigInt(t), Yt = (e) => (
|
|
334
|
+
const Pi = (e, t, n) => e | (n ? ot : Gn) << BigInt(t), Yt = (e) => (Ui << BigInt(e - 1)) - ot, Nt = (e) => new Uint8Array(e), Cn = (e) => Uint8Array.from(e);
|
|
335
335
|
function Jn(e, t, n) {
|
|
336
336
|
if (typeof e != "number" || e < 2)
|
|
337
337
|
throw new Error("hashLen must be a number");
|
|
@@ -354,7 +354,7 @@ function Jn(e, t, n) {
|
|
|
354
354
|
const b = r.slice();
|
|
355
355
|
g.push(b), u += r.length;
|
|
356
356
|
}
|
|
357
|
-
return
|
|
357
|
+
return Ie(...g);
|
|
358
358
|
};
|
|
359
359
|
return (u, g) => {
|
|
360
360
|
o(), a(u);
|
|
@@ -399,7 +399,7 @@ const qi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
399
399
|
bytesToHex: De,
|
|
400
400
|
bytesToNumberBE: F,
|
|
401
401
|
bytesToNumberLE: Ft,
|
|
402
|
-
concatBytes:
|
|
402
|
+
concatBytes: Ie,
|
|
403
403
|
createHmacDrbg: Jn,
|
|
404
404
|
ensureBytes: W,
|
|
405
405
|
equalBytes: Ti,
|
|
@@ -671,8 +671,8 @@ function Qi(e, t) {
|
|
|
671
671
|
const h = p * a;
|
|
672
672
|
let d = Number(o & u);
|
|
673
673
|
o >>= b, d > a && (d -= g, o += At);
|
|
674
|
-
const y = h, m = h + Math.abs(d) - 1, A = p % 2 !== 0,
|
|
675
|
-
d === 0 ? f = f.add(n(A, s[y])) : l = l.add(n(
|
|
674
|
+
const y = h, m = h + Math.abs(d) - 1, A = p % 2 !== 0, I = d < 0;
|
|
675
|
+
d === 0 ? f = f.add(n(A, s[y])) : l = l.add(n(I, s[m]));
|
|
676
676
|
}
|
|
677
677
|
return { p: l, f };
|
|
678
678
|
},
|
|
@@ -770,7 +770,7 @@ BigInt(4);
|
|
|
770
770
|
function rs(e) {
|
|
771
771
|
const t = es(e), { Fp: n } = t, r = t.toBytes || ((p, h, d) => {
|
|
772
772
|
const y = h.toAffine();
|
|
773
|
-
return
|
|
773
|
+
return Ie(Uint8Array.from([4]), n.toBytes(y.x), n.toBytes(y.y));
|
|
774
774
|
}), i = t.fromBytes || ((p) => {
|
|
775
775
|
const h = p.subarray(1), d = n.fromBytes(h.subarray(0, n.BYTES)), y = n.fromBytes(h.subarray(n.BYTES, 2 * n.BYTES));
|
|
776
776
|
return { x: d, y };
|
|
@@ -887,7 +887,7 @@ function rs(e) {
|
|
|
887
887
|
*/
|
|
888
888
|
equals(h) {
|
|
889
889
|
f(h);
|
|
890
|
-
const { px: d, py: y, pz: m } = this, { px: A, py:
|
|
890
|
+
const { px: d, py: y, pz: m } = this, { px: A, py: I, pz: B } = h, E = n.eql(n.mul(d, B), n.mul(A, m)), x = n.eql(n.mul(y, B), n.mul(I, m));
|
|
891
891
|
return E && x;
|
|
892
892
|
}
|
|
893
893
|
/**
|
|
@@ -901,9 +901,9 @@ function rs(e) {
|
|
|
901
901
|
// https://eprint.iacr.org/2015/1060, algorithm 3
|
|
902
902
|
// Cost: 8M + 3S + 3*a + 2*b3 + 15add.
|
|
903
903
|
double() {
|
|
904
|
-
const { a: h, b: d } = t, y = n.mul(d, _n), { px: m, py: A, pz:
|
|
905
|
-
let B = n.ZERO, E = n.ZERO, x = n.ZERO, S = n.mul(m, m), P = n.mul(A, A), _ = n.mul(
|
|
906
|
-
return K = n.add(K, K), x = n.mul(m,
|
|
904
|
+
const { a: h, b: d } = t, y = n.mul(d, _n), { px: m, py: A, pz: I } = this;
|
|
905
|
+
let B = n.ZERO, E = n.ZERO, x = n.ZERO, S = n.mul(m, m), P = n.mul(A, A), _ = n.mul(I, I), K = n.mul(m, A);
|
|
906
|
+
return K = n.add(K, K), x = n.mul(m, I), x = n.add(x, x), B = n.mul(h, x), E = n.mul(y, _), E = n.add(B, E), B = n.sub(P, E), E = n.add(P, E), E = n.mul(B, E), B = n.mul(K, B), x = n.mul(y, x), _ = n.mul(h, _), K = n.sub(S, _), K = n.mul(h, K), K = n.add(K, x), x = n.add(S, S), S = n.add(x, S), S = n.add(S, _), S = n.mul(S, K), E = n.add(E, S), _ = n.mul(A, I), _ = n.add(_, _), S = n.mul(_, K), B = n.sub(B, S), x = n.mul(_, P), x = n.add(x, x), x = n.add(x, x), new u(B, E, x);
|
|
907
907
|
}
|
|
908
908
|
// Renes-Costello-Batina exception-free addition formula.
|
|
909
909
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
@@ -911,13 +911,13 @@ function rs(e) {
|
|
|
911
911
|
// Cost: 12M + 0S + 3*a + 3*b3 + 23add.
|
|
912
912
|
add(h) {
|
|
913
913
|
f(h);
|
|
914
|
-
const { px: d, py: y, pz: m } = this, { px: A, py:
|
|
914
|
+
const { px: d, py: y, pz: m } = this, { px: A, py: I, pz: B } = h;
|
|
915
915
|
let E = n.ZERO, x = n.ZERO, S = n.ZERO;
|
|
916
916
|
const P = t.a, _ = n.mul(t.b, _n);
|
|
917
|
-
let K = n.mul(d, A), T = n.mul(y,
|
|
917
|
+
let K = n.mul(d, A), T = n.mul(y, I), R = n.mul(m, B), H = n.add(d, y), w = n.add(A, I);
|
|
918
918
|
H = n.mul(H, w), w = n.add(K, T), H = n.sub(H, w), w = n.add(d, m);
|
|
919
919
|
let v = n.add(A, B);
|
|
920
|
-
return w = n.mul(w, v), v = n.add(K, R), w = n.sub(w, v), v = n.add(y, m), E = n.add(
|
|
920
|
+
return w = n.mul(w, v), v = n.add(K, R), w = n.sub(w, v), v = n.add(y, m), E = n.add(I, B), v = n.mul(v, E), E = n.add(T, R), v = n.sub(v, E), S = n.mul(P, w), E = n.mul(_, R), S = n.add(E, S), E = n.sub(T, S), S = n.add(T, S), x = n.mul(E, S), T = n.add(K, K), T = n.add(T, K), R = n.mul(P, R), w = n.mul(_, w), T = n.add(T, R), R = n.sub(K, R), R = n.mul(P, R), w = n.add(w, R), K = n.mul(T, w), x = n.add(x, K), K = n.mul(v, w), E = n.mul(H, E), E = n.sub(E, K), K = n.mul(H, T), S = n.mul(v, S), S = n.add(S, K), new u(E, x, S);
|
|
921
921
|
}
|
|
922
922
|
subtract(h) {
|
|
923
923
|
return this.add(h.negate());
|
|
@@ -945,10 +945,10 @@ function rs(e) {
|
|
|
945
945
|
const { endo: y } = t;
|
|
946
946
|
if (!y)
|
|
947
947
|
return b.unsafeLadder(this, h);
|
|
948
|
-
let { k1neg: m, k1: A, k2neg:
|
|
948
|
+
let { k1neg: m, k1: A, k2neg: I, k2: B } = y.splitScalar(h), E = d, x = d, S = this;
|
|
949
949
|
for (; A > ae || B > ae; )
|
|
950
950
|
A & Y && (E = E.add(S)), B & Y && (x = x.add(S)), S = S.double(), A >>= Y, B >>= Y;
|
|
951
|
-
return m && (E = E.negate()),
|
|
951
|
+
return m && (E = E.negate()), I && (x = x.negate()), x = new u(n.mul(x.px, y.beta), x.py, x.pz), E.add(x);
|
|
952
952
|
}
|
|
953
953
|
/**
|
|
954
954
|
* Constant time multiplication.
|
|
@@ -964,12 +964,12 @@ function rs(e) {
|
|
|
964
964
|
let d = h, y, m;
|
|
965
965
|
const { endo: A } = t;
|
|
966
966
|
if (A) {
|
|
967
|
-
const { k1neg:
|
|
967
|
+
const { k1neg: I, k1: B, k2neg: E, k2: x } = A.splitScalar(d);
|
|
968
968
|
let { p: S, f: P } = this.wNAF(B), { p: _, f: K } = this.wNAF(x);
|
|
969
|
-
S = b.constTimeNegate(
|
|
969
|
+
S = b.constTimeNegate(I, S), _ = b.constTimeNegate(E, _), _ = new u(n.mul(_.px, A.beta), _.py, _.pz), y = S.add(_), m = P.add(K);
|
|
970
970
|
} else {
|
|
971
|
-
const { p:
|
|
972
|
-
y =
|
|
971
|
+
const { p: I, f: B } = this.wNAF(d);
|
|
972
|
+
y = I, m = B;
|
|
973
973
|
}
|
|
974
974
|
return u.normalizeZ([y, m])[0];
|
|
975
975
|
}
|
|
@@ -980,8 +980,8 @@ function rs(e) {
|
|
|
980
980
|
* @returns non-zero affine point
|
|
981
981
|
*/
|
|
982
982
|
multiplyAndAddUnsafe(h, d, y) {
|
|
983
|
-
const m = u.BASE, A = (B, E) => E === ae || E === Y || !B.equals(m) ? B.multiplyUnsafe(E) : B.multiply(E),
|
|
984
|
-
return
|
|
983
|
+
const m = u.BASE, A = (B, E) => E === ae || E === Y || !B.equals(m) ? B.multiplyUnsafe(E) : B.multiply(E), I = A(this, d).add(A(h, y));
|
|
984
|
+
return I.is0() ? void 0 : I;
|
|
985
985
|
}
|
|
986
986
|
// Converts Projective point to affine (x, y) coordinates.
|
|
987
987
|
// Can accept precomputed Z^-1 - for example, from invertBatch.
|
|
@@ -989,12 +989,12 @@ function rs(e) {
|
|
|
989
989
|
toAffine(h) {
|
|
990
990
|
const { px: d, py: y, pz: m } = this, A = this.is0();
|
|
991
991
|
h == null && (h = A ? n.ONE : n.inv(m));
|
|
992
|
-
const
|
|
992
|
+
const I = n.mul(d, h), B = n.mul(y, h), E = n.mul(m, h);
|
|
993
993
|
if (A)
|
|
994
994
|
return { x: n.ZERO, y: n.ZERO };
|
|
995
995
|
if (!n.eql(E, n.ONE))
|
|
996
996
|
throw new Error("invZ was invalid");
|
|
997
|
-
return { x:
|
|
997
|
+
return { x: I, y: B };
|
|
998
998
|
}
|
|
999
999
|
isTorsionFree() {
|
|
1000
1000
|
const { h, isTorsionFree: d } = t;
|
|
@@ -1051,8 +1051,8 @@ function ss(e) {
|
|
|
1051
1051
|
const { ProjectivePoint: l, normPrivateKeyToScalar: f, weierstrassEquation: u, isWithinCurveOrder: g } = rs({
|
|
1052
1052
|
...t,
|
|
1053
1053
|
toBytes(w, v, N) {
|
|
1054
|
-
const k = v.toAffine(), C = n.toBytes(k.x),
|
|
1055
|
-
return N ?
|
|
1054
|
+
const k = v.toAffine(), C = n.toBytes(k.x), U = Ie;
|
|
1055
|
+
return N ? U(Uint8Array.from([v.hasEvenY() ? 2 : 3]), C) : U(Uint8Array.from([4]), C, n.toBytes(k.y));
|
|
1056
1056
|
},
|
|
1057
1057
|
fromBytes(w) {
|
|
1058
1058
|
const v = w.length, N = w[0], k = w.subarray(1);
|
|
@@ -1060,13 +1060,13 @@ function ss(e) {
|
|
|
1060
1060
|
const C = F(k);
|
|
1061
1061
|
if (!o(C))
|
|
1062
1062
|
throw new Error("Point is not on curve");
|
|
1063
|
-
const
|
|
1064
|
-
let O = n.sqrt(
|
|
1063
|
+
const U = u(C);
|
|
1064
|
+
let O = n.sqrt(U);
|
|
1065
1065
|
const $ = (O & Y) === Y;
|
|
1066
1066
|
return (N & 1) === 1 !== $ && (O = n.neg(O)), { x: C, y: O };
|
|
1067
1067
|
} else if (v === s && N === 4) {
|
|
1068
|
-
const C = n.fromBytes(k.subarray(0, n.BYTES)),
|
|
1069
|
-
return { x: C, y:
|
|
1068
|
+
const C = n.fromBytes(k.subarray(0, n.BYTES)), U = n.fromBytes(k.subarray(n.BYTES, 2 * n.BYTES));
|
|
1069
|
+
return { x: C, y: U };
|
|
1070
1070
|
} else
|
|
1071
1071
|
throw new Error(`Point of length ${v} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`);
|
|
1072
1072
|
}
|
|
@@ -1104,13 +1104,13 @@ function ss(e) {
|
|
|
1104
1104
|
return new y(this.r, this.s, v);
|
|
1105
1105
|
}
|
|
1106
1106
|
recoverPublicKey(v) {
|
|
1107
|
-
const { r: N, s: k, recovery: C } = this,
|
|
1107
|
+
const { r: N, s: k, recovery: C } = this, U = x(W("msgHash", v));
|
|
1108
1108
|
if (C == null || ![0, 1, 2, 3].includes(C))
|
|
1109
1109
|
throw new Error("recovery id invalid");
|
|
1110
1110
|
const O = C === 2 || C === 3 ? N + t.n : N;
|
|
1111
1111
|
if (O >= n.ORDER)
|
|
1112
1112
|
throw new Error("recovery id 2 or 3 invalid");
|
|
1113
|
-
const $ = C & 1 ? "03" : "02", Q = l.fromHex($ + b(O)), ge = a(O), Le = c(-
|
|
1113
|
+
const $ = C & 1 ? "03" : "02", Q = l.fromHex($ + b(O)), ge = a(O), Le = c(-U * ge), We = c(k * ge), we = l.BASE.multiplyAndAddUnsafe(Q, Le, We);
|
|
1114
1114
|
if (!we)
|
|
1115
1115
|
throw new Error("point at infinify");
|
|
1116
1116
|
return we.assertValidity(), we;
|
|
@@ -1169,14 +1169,14 @@ function ss(e) {
|
|
|
1169
1169
|
function A(w, v = !0) {
|
|
1170
1170
|
return l.fromPrivateKey(w).toRawBytes(v);
|
|
1171
1171
|
}
|
|
1172
|
-
function
|
|
1172
|
+
function I(w) {
|
|
1173
1173
|
const v = w instanceof Uint8Array, N = typeof w == "string", k = (v || N) && w.length;
|
|
1174
1174
|
return v ? k === i || k === s : N ? k === 2 * i || k === 2 * s : w instanceof l;
|
|
1175
1175
|
}
|
|
1176
1176
|
function B(w, v, N = !0) {
|
|
1177
|
-
if (
|
|
1177
|
+
if (I(w))
|
|
1178
1178
|
throw new Error("first arg must be private key");
|
|
1179
|
-
if (!
|
|
1179
|
+
if (!I(v))
|
|
1180
1180
|
throw new Error("second arg must be public key");
|
|
1181
1181
|
return l.fromHex(v).multiply(f(w)).toRawBytes(N);
|
|
1182
1182
|
}
|
|
@@ -1197,14 +1197,14 @@ function ss(e) {
|
|
|
1197
1197
|
if (["recovered", "canonical"].some((Ke) => Ke in N))
|
|
1198
1198
|
throw new Error("sign() legacy options not supported");
|
|
1199
1199
|
const { hash: k, randomBytes: C } = t;
|
|
1200
|
-
let { lowS:
|
|
1201
|
-
|
|
1200
|
+
let { lowS: U, prehash: O, extraEntropy: $ } = N;
|
|
1201
|
+
U == null && (U = !0), w = W("msgHash", w), O && (w = W("prehashed msgHash", k(w)));
|
|
1202
1202
|
const Q = x(w), ge = f(v), Le = [P(ge), P(Q)];
|
|
1203
1203
|
if ($ != null) {
|
|
1204
1204
|
const Ke = $ === !0 ? C(n.BYTES) : $;
|
|
1205
1205
|
Le.push(W("extraEntropy", Ke));
|
|
1206
1206
|
}
|
|
1207
|
-
const We =
|
|
1207
|
+
const We = Ie(...Le), we = Q;
|
|
1208
1208
|
function mt(Ke) {
|
|
1209
1209
|
const $e = E(Ke);
|
|
1210
1210
|
if (!g($e))
|
|
@@ -1216,14 +1216,14 @@ function ss(e) {
|
|
|
1216
1216
|
if (Re === ae)
|
|
1217
1217
|
return;
|
|
1218
1218
|
let Nn = (Te.x === ee ? 0 : 2) | Number(Te.y & Y), An = Re;
|
|
1219
|
-
return
|
|
1219
|
+
return U && p(Re) && (An = h(Re), Nn ^= 1), new y(ee, An, Nn);
|
|
1220
1220
|
}
|
|
1221
1221
|
return { seed: We, k2sig: mt };
|
|
1222
1222
|
}
|
|
1223
1223
|
const K = { lowS: t.lowS, prehash: !1 }, T = { lowS: t.lowS, prehash: !1 };
|
|
1224
1224
|
function R(w, v, N = K) {
|
|
1225
|
-
const { seed: k, k2sig: C } = _(w, v, N),
|
|
1226
|
-
return Jn(
|
|
1225
|
+
const { seed: k, k2sig: C } = _(w, v, N), U = t;
|
|
1226
|
+
return Jn(U.hash.outputLen, U.nByteLength, U.hmac)(k, C);
|
|
1227
1227
|
}
|
|
1228
1228
|
l.BASE._setWindowSize(8);
|
|
1229
1229
|
function H(w, v, N, k = T) {
|
|
@@ -1231,7 +1231,7 @@ function ss(e) {
|
|
|
1231
1231
|
const C = w;
|
|
1232
1232
|
if (v = W("msgHash", v), N = W("publicKey", N), "strict" in k)
|
|
1233
1233
|
throw new Error("options.strict was renamed to lowS");
|
|
1234
|
-
const { lowS:
|
|
1234
|
+
const { lowS: U, prehash: O } = k;
|
|
1235
1235
|
let $, Q;
|
|
1236
1236
|
try {
|
|
1237
1237
|
if (typeof C == "string" || C instanceof Uint8Array)
|
|
@@ -1253,7 +1253,7 @@ function ss(e) {
|
|
|
1253
1253
|
throw new Error("signature must be Signature instance, Uint8Array or hex string");
|
|
1254
1254
|
return !1;
|
|
1255
1255
|
}
|
|
1256
|
-
if (
|
|
1256
|
+
if (U && $.hasHighS())
|
|
1257
1257
|
return !1;
|
|
1258
1258
|
O && (v = t.hash(v));
|
|
1259
1259
|
const { r: ge, s: Le } = $, We = x(v), we = a(Le), mt = c(We * we), Ke = c(ge * we), $e = (Te = l.BASE.multiplyAndAddUnsafe(Q, mt, Ke)) == null ? void 0 : Te.toAffine();
|
|
@@ -1320,14 +1320,14 @@ function as(e, t) {
|
|
|
1320
1320
|
return Object.freeze({ ...n(t), create: n });
|
|
1321
1321
|
}
|
|
1322
1322
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
1323
|
-
const ct = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"), tt = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), rr = BigInt(1), nt = BigInt(2),
|
|
1323
|
+
const ct = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"), tt = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), rr = BigInt(1), nt = BigInt(2), In = (e, t) => (e + t / nt) / t;
|
|
1324
1324
|
function ir(e) {
|
|
1325
|
-
const t = ct, n = BigInt(3), r = BigInt(6), i = BigInt(11), s = BigInt(22), o = BigInt(23), c = BigInt(44), a = BigInt(88), l = e * e * e % t, f = l * l * e % t, u = J(f, n, t) * f % t, g = J(u, n, t) * f % t, b = J(g, nt, t) * l % t, p = J(b, i, t) * b % t, h = J(p, s, t) * p % t, d = J(h, c, t) * h % t, y = J(d, a, t) * d % t, m = J(y, c, t) * h % t, A = J(m, n, t) * f % t,
|
|
1325
|
+
const t = ct, n = BigInt(3), r = BigInt(6), i = BigInt(11), s = BigInt(22), o = BigInt(23), c = BigInt(44), a = BigInt(88), l = e * e * e % t, f = l * l * e % t, u = J(f, n, t) * f % t, g = J(u, n, t) * f % t, b = J(g, nt, t) * l % t, p = J(b, i, t) * b % t, h = J(p, s, t) * p % t, d = J(h, c, t) * h % t, y = J(d, a, t) * d % t, m = J(y, c, t) * h % t, A = J(m, n, t) * f % t, I = J(A, o, t) * p % t, B = J(I, r, t) * l % t, E = J(B, nt, t);
|
|
1326
1326
|
if (!Ot.eql(Ot.sqr(E), e))
|
|
1327
1327
|
throw new Error("Cannot find square root");
|
|
1328
1328
|
return E;
|
|
1329
1329
|
}
|
|
1330
|
-
const Ot = Ji(ct, void 0, void 0, { sqrt: ir }),
|
|
1330
|
+
const Ot = Ji(ct, void 0, void 0, { sqrt: ir }), Ue = as({
|
|
1331
1331
|
a: BigInt(0),
|
|
1332
1332
|
b: BigInt(7),
|
|
1333
1333
|
Fp: Ot,
|
|
@@ -1346,7 +1346,7 @@ const Ot = Ji(ct, void 0, void 0, { sqrt: ir }), Ie = as({
|
|
|
1346
1346
|
endo: {
|
|
1347
1347
|
beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
|
|
1348
1348
|
splitScalar: (e) => {
|
|
1349
|
-
const t = tt, n = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), r = -rr * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), i = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), s = n, o = BigInt("0x100000000000000000000000000000000"), c =
|
|
1349
|
+
const t = tt, n = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), r = -rr * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), i = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), s = n, o = BigInt("0x100000000000000000000000000000000"), c = In(s * e, t), a = In(-r * e, t);
|
|
1350
1350
|
let l = V(e - c * n - a * i, t), f = V(-c * r - a * s, t);
|
|
1351
1351
|
const u = l > o, g = f > o;
|
|
1352
1352
|
if (u && (l = t - l), g && (f = t - f), l > o || f > o)
|
|
@@ -1354,18 +1354,18 @@ const Ot = Ji(ct, void 0, void 0, { sqrt: ir }), Ie = as({
|
|
|
1354
1354
|
return { k1neg: u, k1: l, k2neg: g, k2: f };
|
|
1355
1355
|
}
|
|
1356
1356
|
}
|
|
1357
|
-
}, $t), ut = BigInt(0), sr = (e) => typeof e == "bigint" && ut < e && e < ct, cs = (e) => typeof e == "bigint" && ut < e && e < tt,
|
|
1357
|
+
}, $t), ut = BigInt(0), sr = (e) => typeof e == "bigint" && ut < e && e < ct, cs = (e) => typeof e == "bigint" && ut < e && e < tt, Un = {};
|
|
1358
1358
|
function rt(e, ...t) {
|
|
1359
|
-
let n =
|
|
1359
|
+
let n = Un[e];
|
|
1360
1360
|
if (n === void 0) {
|
|
1361
1361
|
const r = $t(Uint8Array.from(e, (i) => i.charCodeAt(0)));
|
|
1362
|
-
n =
|
|
1362
|
+
n = Ie(r, r), Un[e] = n;
|
|
1363
1363
|
}
|
|
1364
|
-
return $t(
|
|
1364
|
+
return $t(Ie(n, ...t));
|
|
1365
1365
|
}
|
|
1366
|
-
const Xt = (e) => e.toRawBytes(!0).slice(1), Mt = (e) => Ne(e, 32), Kt = (e) => V(e, ct), Fe = (e) => V(e, tt), Qt =
|
|
1366
|
+
const Xt = (e) => e.toRawBytes(!0).slice(1), Mt = (e) => Ne(e, 32), Kt = (e) => V(e, ct), Fe = (e) => V(e, tt), Qt = Ue.ProjectivePoint, us = (e, t, n) => Qt.BASE.multiplyAndAddUnsafe(e, t, n);
|
|
1367
1367
|
function Pt(e) {
|
|
1368
|
-
let t =
|
|
1368
|
+
let t = Ue.utils.normPrivateKeyToScalar(e), n = Qt.fromPrivateKey(t);
|
|
1369
1369
|
return { scalar: n.hasEvenY() ? t : Fe(-t), bytes: Xt(n) };
|
|
1370
1370
|
}
|
|
1371
1371
|
function or(e) {
|
|
@@ -1412,7 +1412,7 @@ const Ze = {
|
|
|
1412
1412
|
sign: fs,
|
|
1413
1413
|
verify: cr,
|
|
1414
1414
|
utils: {
|
|
1415
|
-
randomPrivateKey:
|
|
1415
|
+
randomPrivateKey: Ue.utils.randomPrivateKey,
|
|
1416
1416
|
lift_x: or,
|
|
1417
1417
|
pointToBytes: Xt,
|
|
1418
1418
|
numberToBytesBE: Ne,
|
|
@@ -1979,13 +1979,13 @@ gr("bech32m");
|
|
|
1979
1979
|
const _s = {
|
|
1980
1980
|
encode: (e) => new TextDecoder().decode(e),
|
|
1981
1981
|
decode: (e) => new TextEncoder().encode(e)
|
|
1982
|
-
},
|
|
1982
|
+
}, Is = de(Ae(4), pe("0123456789abcdef"), ye(""), pr((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
|
-
})),
|
|
1986
|
+
})), Us = {
|
|
1987
1987
|
utf8: _s,
|
|
1988
|
-
hex:
|
|
1988
|
+
hex: Is,
|
|
1989
1989
|
base16: Ks,
|
|
1990
1990
|
base32: Cs,
|
|
1991
1991
|
base64: he,
|
|
@@ -1993,7 +1993,7 @@ const _s = {
|
|
|
1993
1993
|
base58: Dt,
|
|
1994
1994
|
base58xmr: ks
|
|
1995
1995
|
};
|
|
1996
|
-
`${Object.keys(
|
|
1996
|
+
`${Object.keys(Us).join(", ")}`;
|
|
1997
1997
|
function kt(e) {
|
|
1998
1998
|
if (!Number.isSafeInteger(e) || e < 0)
|
|
1999
1999
|
throw new Error(`positive integer expected, not ${e}`);
|
|
@@ -2189,10 +2189,10 @@ const mr = /* @__PURE__ */ Os({ blockSize: 16, nonceLength: 16 }, function(t, n,
|
|
|
2189
2189
|
const c = Ds(t), a = Z(n), l = Er(s.length, o), f = Z(s), u = Z(l);
|
|
2190
2190
|
let g = a[0], b = a[1], p = a[2], h = a[3];
|
|
2191
2191
|
for (let d = 0; d + 4 <= f.length; ) {
|
|
2192
|
-
const y = g, m = b, A = p,
|
|
2192
|
+
const y = g, m = b, A = p, I = h;
|
|
2193
2193
|
g = f[d + 0], b = f[d + 1], p = f[d + 2], h = f[d + 3];
|
|
2194
2194
|
const { s0: B, s1: E, s2: x, s3: S } = js(c, g, b, p, h);
|
|
2195
|
-
u[d++] = B ^ y, u[d++] = E ^ m, u[d++] = x ^ A, u[d++] = S ^
|
|
2195
|
+
u[d++] = B ^ y, u[d++] = E ^ m, u[d++] = x ^ A, u[d++] = S ^ I;
|
|
2196
2196
|
}
|
|
2197
2197
|
return c.fill(0), Ws(l, i);
|
|
2198
2198
|
}
|
|
@@ -2256,8 +2256,8 @@ function Qs(e, t) {
|
|
|
2256
2256
|
if (m !== a.length)
|
|
2257
2257
|
throw new Error(`arx: nonce must be ${m} or 16 bytes`);
|
|
2258
2258
|
if (m !== 12) {
|
|
2259
|
-
const
|
|
2260
|
-
|
|
2259
|
+
const I = new Uint8Array(12);
|
|
2260
|
+
I.set(a, s ? 0 : 12 - a.length), a = I, b.push(a);
|
|
2261
2261
|
}
|
|
2262
2262
|
const A = Z(a);
|
|
2263
2263
|
for (Xs(e, d, y, A, l, f, u, o); b.length > 0; )
|
|
@@ -2266,11 +2266,11 @@ function Qs(e, t) {
|
|
|
2266
2266
|
};
|
|
2267
2267
|
}
|
|
2268
2268
|
function eo(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], g = t[2], b = t[3], p = t[4], h = t[5], d = t[6], y = t[7], m = i, A = n[0],
|
|
2269
|
+
let o = e[0], c = e[1], a = e[2], l = e[3], f = t[0], u = t[1], g = t[2], b = t[3], p = t[4], h = t[5], d = t[6], y = t[7], m = i, A = n[0], I = n[1], B = n[2], E = o, x = c, S = a, P = l, _ = f, K = u, T = g, R = b, H = p, w = h, v = d, N = y, k = m, C = A, U = I, O = B;
|
|
2270
2270
|
for (let Q = 0; Q < s; Q += 2)
|
|
2271
|
-
E = E + _ | 0, k = L(k ^ E, 16), H = H + k | 0, _ = L(_ ^ H, 12), E = E + _ | 0, k = L(k ^ E, 8), H = H + k | 0, _ = L(_ ^ H, 7), x = x + K | 0, C = L(C ^ x, 16), w = w + C | 0, K = L(K ^ w, 12), x = x + K | 0, C = L(C ^ x, 8), w = w + C | 0, K = L(K ^ w, 7), S = S + T | 0,
|
|
2271
|
+
E = E + _ | 0, k = L(k ^ E, 16), H = H + k | 0, _ = L(_ ^ H, 12), E = E + _ | 0, k = L(k ^ E, 8), H = H + k | 0, _ = L(_ ^ H, 7), x = x + K | 0, C = L(C ^ x, 16), w = w + C | 0, K = L(K ^ w, 12), x = x + K | 0, C = L(C ^ x, 8), w = w + C | 0, K = L(K ^ w, 7), S = S + T | 0, U = L(U ^ S, 16), v = v + U | 0, T = L(T ^ v, 12), S = S + T | 0, U = L(U ^ S, 8), v = v + U | 0, T = L(T ^ v, 7), P = P + R | 0, O = L(O ^ P, 16), N = N + O | 0, R = L(R ^ N, 12), P = P + R | 0, O = L(O ^ P, 8), N = N + O | 0, R = L(R ^ N, 7), E = E + K | 0, O = L(O ^ E, 16), v = v + O | 0, K = L(K ^ v, 12), E = E + K | 0, O = L(O ^ E, 8), v = v + O | 0, K = L(K ^ v, 7), x = x + T | 0, k = L(k ^ x, 16), N = N + k | 0, T = L(T ^ N, 12), x = x + T | 0, k = L(k ^ x, 8), N = N + k | 0, T = L(T ^ N, 7), S = S + R | 0, C = L(C ^ S, 16), H = H + C | 0, R = L(R ^ H, 12), S = S + R | 0, C = L(C ^ S, 8), H = H + C | 0, R = L(R ^ H, 7), P = P + _ | 0, U = L(U ^ P, 16), w = w + U | 0, _ = L(_ ^ w, 12), P = P + _ | 0, U = L(U ^ P, 8), w = w + U | 0, _ = L(_ ^ w, 7);
|
|
2272
2272
|
let $ = 0;
|
|
2273
|
-
r[$++] = o + E | 0, r[$++] = c + x | 0, r[$++] = a + S | 0, r[$++] = l + P | 0, r[$++] = f + _ | 0, r[$++] = u + K | 0, r[$++] = g + T | 0, r[$++] = b + R | 0, r[$++] = p + H | 0, r[$++] = h + w | 0, r[$++] = d + v | 0, r[$++] = y + N | 0, r[$++] = m + k | 0, r[$++] = A + C | 0, r[$++] =
|
|
2273
|
+
r[$++] = o + E | 0, r[$++] = c + x | 0, r[$++] = a + S | 0, r[$++] = l + P | 0, r[$++] = f + _ | 0, r[$++] = u + K | 0, r[$++] = g + T | 0, r[$++] = b + R | 0, r[$++] = p + H | 0, r[$++] = h + w | 0, r[$++] = d + v | 0, r[$++] = y + N | 0, r[$++] = m + k | 0, r[$++] = A + C | 0, r[$++] = I + U | 0, r[$++] = B + O | 0;
|
|
2274
2274
|
}
|
|
2275
2275
|
const Ar = /* @__PURE__ */ Qs(eo, {
|
|
2276
2276
|
counterRight: !1,
|
|
@@ -2317,7 +2317,7 @@ ht.create = (e, t) => new Kr(e, t);
|
|
|
2317
2317
|
function sn(e, t, n) {
|
|
2318
2318
|
return se.hash(e), n === void 0 && (n = new Uint8Array(e.outputLen)), ht(e, Je(n), Je(t));
|
|
2319
2319
|
}
|
|
2320
|
-
const
|
|
2320
|
+
const It = new Uint8Array([0]), qn = new Uint8Array();
|
|
2321
2321
|
function Cr(e, t, n, r = 32) {
|
|
2322
2322
|
if (se.hash(e), se.number(r), r > 255 * e.outputLen)
|
|
2323
2323
|
throw new Error("Length should be <= 255*HashLen");
|
|
@@ -2325,8 +2325,8 @@ function Cr(e, t, n, r = 32) {
|
|
|
2325
2325
|
n === void 0 && (n = qn);
|
|
2326
2326
|
const s = new Uint8Array(i * e.outputLen), o = ht.create(e, t), c = o._cloneInto(), a = new Uint8Array(o.outputLen);
|
|
2327
2327
|
for (let l = 0; l < i; l++)
|
|
2328
|
-
|
|
2329
|
-
return o.destroy(), c.destroy(), a.fill(0),
|
|
2328
|
+
It[0] = l + 1, c.update(l === 0 ? qn : a).update(n).update(It).digestInto(a), s.set(a, e.outputLen * l), o._cloneInto(c);
|
|
2329
|
+
return o.destroy(), c.destroy(), a.fill(0), It.fill(0), s.slice(0, r);
|
|
2330
2330
|
}
|
|
2331
2331
|
var to = Object.defineProperty, D = (e, t) => {
|
|
2332
2332
|
for (var n in t)
|
|
@@ -2485,8 +2485,8 @@ D(lo, {
|
|
|
2485
2485
|
InterestsList: () => Wo,
|
|
2486
2486
|
Interestsets: () => aa,
|
|
2487
2487
|
JobFeedback: () => Lo,
|
|
2488
|
-
JobRequest: () =>
|
|
2489
|
-
JobResult: () =>
|
|
2488
|
+
JobRequest: () => Io,
|
|
2489
|
+
JobResult: () => Uo,
|
|
2490
2490
|
Label: () => ko,
|
|
2491
2491
|
LightningPubRPC: () => Yo,
|
|
2492
2492
|
LiveChatMessage: () => Ao,
|
|
@@ -2521,9 +2521,9 @@ D(lo, {
|
|
|
2521
2521
|
ZapGoal: () => $o,
|
|
2522
2522
|
ZapRequest: () => To,
|
|
2523
2523
|
classifyKind: () => fo,
|
|
2524
|
-
isEphemeralKind: () =>
|
|
2524
|
+
isEphemeralKind: () => Ir,
|
|
2525
2525
|
isKind: () => ho,
|
|
2526
|
-
isParameterizedReplaceableKind: () =>
|
|
2526
|
+
isParameterizedReplaceableKind: () => Ur,
|
|
2527
2527
|
isRegularKind: () => kr,
|
|
2528
2528
|
isReplaceableKind: () => _r
|
|
2529
2529
|
});
|
|
@@ -2533,20 +2533,20 @@ function kr(e) {
|
|
|
2533
2533
|
function _r(e) {
|
|
2534
2534
|
return [0, 3].includes(e) || 1e4 <= e && e < 2e4;
|
|
2535
2535
|
}
|
|
2536
|
-
function
|
|
2536
|
+
function Ir(e) {
|
|
2537
2537
|
return 2e4 <= e && e < 3e4;
|
|
2538
2538
|
}
|
|
2539
|
-
function
|
|
2539
|
+
function Ur(e) {
|
|
2540
2540
|
return 3e4 <= e && e < 4e4;
|
|
2541
2541
|
}
|
|
2542
2542
|
function fo(e) {
|
|
2543
|
-
return kr(e) ? "regular" : _r(e) ? "replaceable" :
|
|
2543
|
+
return kr(e) ? "regular" : _r(e) ? "replaceable" : Ir(e) ? "ephemeral" : Ur(e) ? "parameterized" : "unknown";
|
|
2544
2544
|
}
|
|
2545
2545
|
function ho(e, t) {
|
|
2546
2546
|
const n = t instanceof Array ? t : [t];
|
|
2547
2547
|
return dt(e) && n.includes(e.kind) || !1;
|
|
2548
2548
|
}
|
|
2549
|
-
var po = 0, yo = 1, go = 2, wo = 3, bo = 4, vo = 5, an = 6, cn = 7, Eo = 8, Lr = 13, mo = 14, xo = 16, $r = 40, Tr = 41, Rr = 42, Or = 43, Mr = 44, So = 1040, Pr = 1059, No = 1063, Ao = 1311, Ko = 1971, Co = 1984, Bo = 1984, ko = 1985, _o = 4550,
|
|
2549
|
+
var po = 0, yo = 1, go = 2, wo = 3, bo = 4, vo = 5, an = 6, cn = 7, Eo = 8, Lr = 13, mo = 14, xo = 16, $r = 40, Tr = 41, Rr = 42, Or = 43, Mr = 44, So = 1040, Pr = 1059, No = 1063, Ao = 1311, Ko = 1971, Co = 1984, Bo = 1984, ko = 1985, _o = 4550, Io = 5999, Uo = 6999, Lo = 7e3, $o = 9041, To = 9734, Ro = 9735, Oo = 9802, Mo = 1e4, Po = 10001, Ho = 10002, qo = 10003, Do = 10004, jo = 10005, zo = 10006, Vo = 10007, Wo = 10015, Zo = 10030, Go = 10050, Fo = 10096, Jo = 13194, Yo = 21e3, Hr = 22242, qr = 23194, Xo = 23195, Qo = 24133, un = 27235, ea = 3e4, ta = 30001, na = 30002, ra = 30003, ia = 30004, sa = 30008, oa = 30009, aa = 30015, ca = 30017, ua = 30018, la = 30023, fa = 30024, ha = 30030, da = 30078, pa = 30311, ya = 30315, ga = 30402, wa = 30403, ba = 31922, va = 31923, Ea = 31924, ma = 31925, xa = 31989, Sa = 31990, Na = 34550, Aa = {};
|
|
2550
2550
|
D(Aa, {
|
|
2551
2551
|
getHex64: () => ln,
|
|
2552
2552
|
getInt: () => Dr,
|
|
@@ -2587,9 +2587,9 @@ function ka(e, t) {
|
|
|
2587
2587
|
}
|
|
2588
2588
|
var _a = {};
|
|
2589
2589
|
D(_a, {
|
|
2590
|
-
makeAuthEvent: () =>
|
|
2590
|
+
makeAuthEvent: () => Ia
|
|
2591
2591
|
});
|
|
2592
|
-
function
|
|
2592
|
+
function Ia(e, t) {
|
|
2593
2593
|
return {
|
|
2594
2594
|
kind: Hr,
|
|
2595
2595
|
created_at: Math.floor(Date.now() / 1e3),
|
|
@@ -2600,9 +2600,9 @@ function Ua(e, t) {
|
|
|
2600
2600
|
content: ""
|
|
2601
2601
|
};
|
|
2602
2602
|
}
|
|
2603
|
-
var
|
|
2603
|
+
var Ua;
|
|
2604
2604
|
try {
|
|
2605
|
-
|
|
2605
|
+
Ua = WebSocket;
|
|
2606
2606
|
} catch {
|
|
2607
2607
|
}
|
|
2608
2608
|
var La;
|
|
@@ -2642,7 +2642,7 @@ function gt(e) {
|
|
|
2642
2642
|
let { prefix: t, words: n } = ze.decode(e, fn), r = new Uint8Array(ze.fromWords(n));
|
|
2643
2643
|
switch (t) {
|
|
2644
2644
|
case "nprofile": {
|
|
2645
|
-
let u =
|
|
2645
|
+
let u = Ut(r);
|
|
2646
2646
|
if (!((i = u[0]) != null && i[0]))
|
|
2647
2647
|
throw new Error("missing TLV 0 for nprofile");
|
|
2648
2648
|
if (u[0][0].length !== 32)
|
|
@@ -2656,7 +2656,7 @@ function gt(e) {
|
|
|
2656
2656
|
};
|
|
2657
2657
|
}
|
|
2658
2658
|
case "nevent": {
|
|
2659
|
-
let u =
|
|
2659
|
+
let u = Ut(r);
|
|
2660
2660
|
if (!((s = u[0]) != null && s[0]))
|
|
2661
2661
|
throw new Error("missing TLV 0 for nevent");
|
|
2662
2662
|
if (u[0][0].length !== 32)
|
|
@@ -2676,7 +2676,7 @@ function gt(e) {
|
|
|
2676
2676
|
};
|
|
2677
2677
|
}
|
|
2678
2678
|
case "naddr": {
|
|
2679
|
-
let u =
|
|
2679
|
+
let u = Ut(r);
|
|
2680
2680
|
if (!((a = u[0]) != null && a[0]))
|
|
2681
2681
|
throw new Error("missing TLV 0 for naddr");
|
|
2682
2682
|
if (!((l = u[2]) != null && l[0]))
|
|
@@ -2706,7 +2706,7 @@ function gt(e) {
|
|
|
2706
2706
|
throw new Error(`unknown prefix ${t}`);
|
|
2707
2707
|
}
|
|
2708
2708
|
}
|
|
2709
|
-
function
|
|
2709
|
+
function Ut(e) {
|
|
2710
2710
|
let t = {}, n = e;
|
|
2711
2711
|
for (; n.length > 0; ) {
|
|
2712
2712
|
let r = n[0], i = n[1], s = n.slice(2, 2 + i);
|
|
@@ -2776,13 +2776,13 @@ D(ja, {
|
|
|
2776
2776
|
encrypt: () => zr
|
|
2777
2777
|
});
|
|
2778
2778
|
async function zr(e, t, n) {
|
|
2779
|
-
const r = e instanceof Uint8Array ? M(e) : e, i =
|
|
2779
|
+
const r = e instanceof Uint8Array ? M(e) : e, i = Ue.getSharedSecret(r, "02" + t), s = Vr(i);
|
|
2780
2780
|
let o = Uint8Array.from(fr(16)), c = ne.encode(n), a = mr(s, o).encrypt(c), l = he.encode(new Uint8Array(a)), f = he.encode(new Uint8Array(o.buffer));
|
|
2781
2781
|
return `${l}?iv=${f}`;
|
|
2782
2782
|
}
|
|
2783
2783
|
async function za(e, t, n) {
|
|
2784
2784
|
const r = e instanceof Uint8Array ? M(e) : e;
|
|
2785
|
-
let [i, s] = n.split("?iv="), o =
|
|
2785
|
+
let [i, s] = n.split("?iv="), o = Ue.getSharedSecret(r, "02" + t), c = Vr(o), a = he.decode(s), l = he.decode(i), f = mr(c, a).decrypt(l);
|
|
2786
2786
|
return ue.decode(f);
|
|
2787
2787
|
}
|
|
2788
2788
|
function Vr(e) {
|
|
@@ -3224,11 +3224,11 @@ D(q, {
|
|
|
3224
3224
|
decrypt: () => En,
|
|
3225
3225
|
encrypt: () => vn,
|
|
3226
3226
|
getConversationKey: () => wn,
|
|
3227
|
-
v2: () =>
|
|
3227
|
+
v2: () => Ic
|
|
3228
3228
|
});
|
|
3229
3229
|
var Xr = 1, Qr = 65535;
|
|
3230
3230
|
function wn(e, t) {
|
|
3231
|
-
const n =
|
|
3231
|
+
const n = Ue.getSharedSecret(e, "02" + t).subarray(1, 33);
|
|
3232
3232
|
return sn(fe, n, "nip44-v2");
|
|
3233
3233
|
}
|
|
3234
3234
|
function ei(e, t) {
|
|
@@ -3306,15 +3306,15 @@ function En(e, t) {
|
|
|
3306
3306
|
const l = Ar(s, o, r);
|
|
3307
3307
|
return kc(l);
|
|
3308
3308
|
}
|
|
3309
|
-
var
|
|
3309
|
+
var Ic = {
|
|
3310
3310
|
utils: {
|
|
3311
3311
|
getConversationKey: wn,
|
|
3312
3312
|
calcPaddedLen: bn
|
|
3313
3313
|
},
|
|
3314
3314
|
encrypt: vn,
|
|
3315
3315
|
decrypt: En
|
|
3316
|
-
},
|
|
3317
|
-
D(
|
|
3316
|
+
}, Uc = {};
|
|
3317
|
+
D(Uc, {
|
|
3318
3318
|
makeNwcRequestEvent: () => $c,
|
|
3319
3319
|
parseConnectionString: () => Lc
|
|
3320
3320
|
});
|
|
@@ -3669,6 +3669,11 @@ function Me(e, t = new Uint8Array(32), n = 1) {
|
|
|
3669
3669
|
function Lt(e, t) {
|
|
3670
3670
|
return `${e}:${t}`;
|
|
3671
3671
|
}
|
|
3672
|
+
function au(e) {
|
|
3673
|
+
var n;
|
|
3674
|
+
const t = (n = e.tags) == null ? void 0 : n.find((r) => r[0] === "ms");
|
|
3675
|
+
return t ? parseInt(t[1]) : e.created_at * 1e3;
|
|
3676
|
+
}
|
|
3672
3677
|
const Fc = 1e3, Jc = "0000000000000000000000000000000000000000000000000000000000000000";
|
|
3673
3678
|
class st {
|
|
3674
3679
|
// 1. CHANNEL PUBLIC INTERFACE
|
|
@@ -3733,22 +3738,22 @@ class st {
|
|
|
3733
3738
|
throw new Error("we are not the initiator, so we can't send the first message");
|
|
3734
3739
|
if ("sig" in t)
|
|
3735
3740
|
throw new Error("Event must be unsigned " + JSON.stringify(t));
|
|
3736
|
-
const n = {
|
|
3741
|
+
const n = Date.now(), r = {
|
|
3737
3742
|
...t,
|
|
3738
3743
|
content: t.content || "",
|
|
3739
3744
|
kind: t.kind || Be,
|
|
3740
|
-
created_at: t.created_at || Math.floor(
|
|
3745
|
+
created_at: t.created_at || Math.floor(n / 1e3),
|
|
3741
3746
|
tags: t.tags || [],
|
|
3742
3747
|
pubkey: t.pubkey || Jc
|
|
3743
3748
|
};
|
|
3744
|
-
|
|
3745
|
-
const [
|
|
3746
|
-
return X({
|
|
3747
|
-
content:
|
|
3749
|
+
r.tags.some(([l]) => l === "ms") || r.tags.push(["ms", String(n)]), r.id = qe(r);
|
|
3750
|
+
const [i, s] = this.ratchetEncrypt(JSON.stringify(r)), o = q.getConversationKey(this.state.ourCurrentNostrKey.privateKey, this.state.theirNextNostrPublicKey), c = q.encrypt(JSON.stringify(i), o);
|
|
3751
|
+
return { event: X({
|
|
3752
|
+
content: s,
|
|
3748
3753
|
kind: Be,
|
|
3749
|
-
tags: [["header",
|
|
3754
|
+
tags: [["header", c]],
|
|
3750
3755
|
created_at: Math.floor(Date.now() / 1e3)
|
|
3751
|
-
}, this.state.ourCurrentNostrKey.privateKey);
|
|
3756
|
+
}, this.state.ourCurrentNostrKey.privateKey), innerEvent: r };
|
|
3752
3757
|
}
|
|
3753
3758
|
/**
|
|
3754
3759
|
* Subscribes to incoming messages on this session
|
|
@@ -3894,7 +3899,7 @@ class st {
|
|
|
3894
3899
|
new TextDecoder("utf-8");
|
|
3895
3900
|
new TextEncoder();
|
|
3896
3901
|
function Qe(e, t) {
|
|
3897
|
-
const n =
|
|
3902
|
+
const n = Ue.getSharedSecret(e, "02" + t).subarray(1, 33);
|
|
3898
3903
|
return sn(fe, n, "nip44-v2");
|
|
3899
3904
|
}
|
|
3900
3905
|
class Pe {
|
|
@@ -3952,7 +3957,10 @@ class Pe {
|
|
|
3952
3957
|
throw new Error("Event is not signed");
|
|
3953
3958
|
if (!yt(t))
|
|
3954
3959
|
throw new Error("Event signature is invalid");
|
|
3955
|
-
const { tags: n } = t
|
|
3960
|
+
const { tags: n } = t;
|
|
3961
|
+
if (!n)
|
|
3962
|
+
throw new Error("Invalid invite event: missing tags");
|
|
3963
|
+
const r = (o = n.find(([a]) => a === "ephemeralKey")) == null ? void 0 : o[1], i = (c = n.find(([a]) => a === "sharedSecret")) == null ? void 0 : c[1], s = t.pubkey;
|
|
3956
3964
|
if (!r || !i)
|
|
3957
3965
|
throw new Error("Invalid invite event: missing session key or sharedSecret");
|
|
3958
3966
|
return new Pe(
|
|
@@ -4082,6 +4090,7 @@ export {
|
|
|
4082
4090
|
st as Session,
|
|
4083
4091
|
ou as createEventStream,
|
|
4084
4092
|
su as deserializeSessionState,
|
|
4093
|
+
au as getMillisecondTimestamp,
|
|
4085
4094
|
Me as kdf,
|
|
4086
4095
|
iu as serializeSessionState,
|
|
4087
4096
|
Lt as skippedMessageIndexKey
|