@candypoets/nipworker 0.93.0 → 0.95.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/NarrowTypes.js +139 -119
  2. package/dist/cache/index.js +55 -55
  3. package/dist/cache/pkg/cache.d.ts +1 -1
  4. package/dist/cache/pkg/cache_bg.wasm.d.ts +1 -1
  5. package/dist/connections/index.js +16 -16
  6. package/dist/connections/pkg/connections.d.ts +2 -2
  7. package/dist/connections/pkg/connections_bg.wasm.d.ts +2 -2
  8. package/dist/connections/proxy.js +1 -1
  9. package/dist/connections/proxy.js.map +4 -4
  10. package/dist/crypto/index.js +40 -40
  11. package/dist/generated/nostr/fb/content-block.d.ts +3 -2
  12. package/dist/generated/nostr/fb/content-block.d.ts.map +1 -1
  13. package/dist/generated/nostr/fb/content-data.d.ts +5 -3
  14. package/dist/generated/nostr/fb/content-data.d.ts.map +1 -1
  15. package/dist/generated/nostr/fb/emoji-data.d.ts +30 -0
  16. package/dist/generated/nostr/fb/emoji-data.d.ts.map +1 -0
  17. package/dist/generated/nostr/fb/kind1018-parsed.d.ts +37 -0
  18. package/dist/generated/nostr/fb/kind1018-parsed.d.ts.map +1 -0
  19. package/dist/generated/nostr/fb/kind1068-parsed.d.ts +58 -0
  20. package/dist/generated/nostr/fb/kind1068-parsed.d.ts.map +1 -0
  21. package/dist/generated/nostr/fb/kind20-parsed.d.ts.map +1 -1
  22. package/dist/generated/nostr/fb/parsed-data-union.d.ts +2 -0
  23. package/dist/generated/nostr/fb/parsed-data-union.d.ts.map +1 -1
  24. package/dist/generated/nostr/fb/parsed-data.d.ts +17 -13
  25. package/dist/generated/nostr/fb/parsed-data.d.ts.map +1 -1
  26. package/dist/generated/nostr/fb/parsed-event.d.ts +4 -2
  27. package/dist/generated/nostr/fb/parsed-event.d.ts.map +1 -1
  28. package/dist/generated/nostr/fb/poll-option.d.ts +26 -0
  29. package/dist/generated/nostr/fb/poll-option.d.ts.map +1 -0
  30. package/dist/generated/nostr/fb/poll-type.d.ts +5 -0
  31. package/dist/generated/nostr/fb/poll-type.d.ts.map +1 -0
  32. package/dist/generated/nostr/fb.d.ts +5 -0
  33. package/dist/generated/nostr/fb.d.ts.map +1 -1
  34. package/dist/index.js +159 -150
  35. package/dist/index2.js +31 -31
  36. package/dist/lib/ConnectionTracker.d.ts +2 -0
  37. package/dist/lib/ConnectionTracker.d.ts.map +1 -1
  38. package/dist/lib/NarrowTypes.d.ts +6 -1
  39. package/dist/lib/NarrowTypes.d.ts.map +1 -1
  40. package/dist/parser/index.js +306 -306
  41. package/dist/relayProxyServer.js +298 -352
  42. package/dist/utils.js +91 -82
  43. package/dist/worker-message.js +1151 -763
  44. package/package.json +1 -1
package/dist/utils.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { nip19 as $, generateSecretKey as B, getPublicKey as A } from "nostr-tools";
2
2
  import { g as G } from "./index2.js";
3
3
  import { b as N } from "./NarrowTypes.js";
4
- import { l as ee, a0 as te, _ as ne, f as se, j as ae, g as oe, $ as ie, a1 as re, p as ce, r as de, H as le, J as ue, D as pe, F as ge, B as he, L as fe, t as ye, v as we, x as ke, z as me, N as Ke, P as ve, R as De, T as Se, V as xe, a5 as Ce, a3 as be, X as Me, a4 as Te, e as Be, d as Ae, Z as Ie, n as Pe, a2 as Re, k as Ee, h as $e, c as Ge, o as Ne, q as Le, G as Ve, I as ze, C as Ze, E as _e, A as He, K as Oe, s as Ue, u as Qe, w as Fe, y as We, M as je, O as Je, Q as Xe, S as Ye, U as qe, W as et, a as tt, i as nt, Y as st, m as at } from "./NarrowTypes.js";
5
- import { J as h, t as d, O as m, Q as M, T, U as I, X as L, Y as V, Z as z, _ as Z, $ as _ } from "./worker-message.js";
6
- class F {
4
+ import { l as ee, a4 as te, a2 as ne, f as se, j as ae, aa as oe, g as ie, a3 as re, a5 as ce, p as de, r as le, L as ue, N as pe, H as ge, J as he, B as fe, P as ye, D as we, F as ke, t as Ke, v as me, x as ve, z as De, R as Se, T as xe, V as Ce, X as be, Z as Me, a9 as Te, a7 as Be, $ as Ae, a8 as Ie, e as Re, d as Ee, a1 as Pe, n as $e, a6 as Ge, k as Ne, h as Le, c as Ve, o as ze, q as Ze, K as _e, M as He, G as Oe, I as Ue, A as Qe, O as je, C as Fe, E as We, s as Xe, u as Ye, w as qe, y as Je, Q as et, S as tt, U as nt, W as st, Y as at, _ as ot, a as it, i as rt, a0 as ct, m as dt } from "./NarrowTypes.js";
5
+ import { O as h, v as d, Q as K, T as M, U as T, X as I, Y as L, Z as V, _ as z, $ as Z, a0 as _ } from "./worker-message.js";
6
+ class j {
7
7
  constructor() {
8
8
  this.knownRelays = /* @__PURE__ */ new Map(), this.incomingCount = 0, this.resolvedCount = 0;
9
9
  }
@@ -36,9 +36,13 @@ class F {
36
36
  get resolutionRate() {
37
37
  return this.incomingCount === 0 ? 0 : this.resolvedCount / this.incomingCount;
38
38
  }
39
+ /** Reset all tracking state for a fresh subscription */
40
+ reset() {
41
+ this.knownRelays.clear(), this.incomingCount = 0, this.resolvedCount = 0;
42
+ }
39
43
  }
40
44
  const t = new TextEncoder();
41
- async function W(c) {
45
+ async function F(c) {
42
46
  var _a, _b, _c, _d, _e2, _f, _g, _h, _i;
43
47
  const i = [], r = (e) => new h(t.encode("text"), t.encode(e), d.NONE, null), l = (e) => new h(
44
48
  t.encode("image"),
@@ -69,7 +73,7 @@ async function W(c) {
69
73
  t.encode(e),
70
74
  d.CashuData,
71
75
  new V(t.encode(e))
72
- ), K = (e) => new h(
76
+ ), m = (e) => new h(
73
77
  t.encode("hashtag"),
74
78
  t.encode(`#${e}`),
75
79
  d.HashtagData,
@@ -79,7 +83,7 @@ async function W(c) {
79
83
  t.encode(e),
80
84
  d.LinkPreviewData,
81
85
  new Z(t.encode(e), null, null, null)
82
- ), P = (e, s) => {
86
+ ), R = (e, s) => {
83
87
  try {
84
88
  const n = $.decode(e), p = n.type;
85
89
  let a = null, g = [], S = null, b = BigInt(0);
@@ -116,7 +120,7 @@ async function W(c) {
116
120
  } catch {
117
121
  return r(s);
118
122
  }
119
- }, R = [
123
+ }, E = [
120
124
  {
121
125
  type: "code",
122
126
  regex: /```([\s\S]*?)```/g,
@@ -131,7 +135,7 @@ async function W(c) {
131
135
  type: "hashtag",
132
136
  // Match hashtags that are not part of a URL
133
137
  regex: new RegExp(`(?<![^\\s"'(])(#[a-zA-Z0-9_]+)(?![a-zA-Z0-9_])`, "g"),
134
- processMatch: (e) => K(e[0].substring(1))
138
+ processMatch: (e) => m(e[0].substring(1))
135
139
  },
136
140
  {
137
141
  type: "image",
@@ -148,7 +152,7 @@ async function W(c) {
148
152
  regex: /nostr:([a-z0-9]+)/gi,
149
153
  processMatch: (e) => {
150
154
  const s = e[1];
151
- return P(s || "", e[0]);
155
+ return R(s || "", e[0]);
152
156
  }
153
157
  },
154
158
  {
@@ -157,7 +161,7 @@ async function W(c) {
157
161
  processMatch: async (e) => v(e[0])
158
162
  }
159
163
  ], C = [];
160
- for (const e of R) {
164
+ for (const e of E) {
161
165
  let s;
162
166
  for (e.regex.lastIndex = 0; (s = e.regex.exec(c)) !== null; ) {
163
167
  const n = s.index, p = n + s[0].length, a = await e.processMatch(s);
@@ -177,31 +181,31 @@ async function W(c) {
177
181
  D < c.length && i.push(r(c.substring(D)));
178
182
  const k = [];
179
183
  let u = [];
180
- const E = (e) => /^\s+$/.test(e);
184
+ const P = (e) => /^\s+$/.test(e);
181
185
  for (let e = 0; e < i.length; e++) {
182
186
  const s = i[e];
183
187
  if (((_a = s == null ? void 0 : s.type) == null ? void 0 : _a.toString()) === "image" || ((_b = s == null ? void 0 : s.type) == null ? void 0 : _b.toString()) === "video") {
184
188
  u.push(s);
185
189
  continue;
186
190
  }
187
- if (!(((_c = s == null ? void 0 : s.type) == null ? void 0 : _c.toString()) === "text" && typeof ((_d = s == null ? void 0 : s.text) == null ? void 0 : _d.toString()) == "string" && E((_e2 = s.text) == null ? void 0 : _e2.toString()) && u.length > 0 && e + 1 < i.length && (((_g = (_f = i[e + 1]) == null ? void 0 : _f.type) == null ? void 0 : _g.toString()) === "image" || ((_i = (_h = i[e + 1]) == null ? void 0 : _h.type) == null ? void 0 : _i.toString()) === "video"))) {
191
+ if (!(((_c = s == null ? void 0 : s.type) == null ? void 0 : _c.toString()) === "text" && typeof ((_d = s == null ? void 0 : s.text) == null ? void 0 : _d.toString()) == "string" && P((_e2 = s.text) == null ? void 0 : _e2.toString()) && u.length > 0 && e + 1 < i.length && (((_g = (_f = i[e + 1]) == null ? void 0 : _f.type) == null ? void 0 : _g.toString()) === "image" || ((_i = (_h = i[e + 1]) == null ? void 0 : _h.type) == null ? void 0 : _i.toString()) === "video"))) {
188
192
  if (u.length > 0) {
189
193
  if (u.length > 1) {
190
194
  const n = u.map((a) => {
191
195
  if (a.dataType === d.ImageData) {
192
196
  const g = a.data;
193
- return new m(
197
+ return new K(
194
198
  new M(t.encode(g.url ?? a.text), null),
195
199
  null
196
200
  );
197
201
  } else if (a.dataType === d.VideoData) {
198
202
  const g = a.data;
199
- return new m(
203
+ return new K(
200
204
  null,
201
205
  new T(t.encode(g.url ?? a.text), null)
202
206
  );
203
207
  }
204
- return new m(null, null);
208
+ return new K(null, null);
205
209
  }), p = u.map((a) => String(a.text ?? "")).join(`
206
210
  `);
207
211
  k.push(
@@ -224,18 +228,18 @@ async function W(c) {
224
228
  const e = u.map((n) => {
225
229
  if (n.dataType === d.ImageData) {
226
230
  const p = n.data;
227
- return new m(
231
+ return new K(
228
232
  new M(t.encode(p.url ?? n.text), null),
229
233
  null
230
234
  );
231
235
  } else if (n.dataType === d.VideoData) {
232
236
  const p = n.data;
233
- return new m(
237
+ return new K(
234
238
  null,
235
239
  new T(t.encode(p.url ?? n.text), null)
236
240
  );
237
241
  }
238
- return new m(null, null);
242
+ return new K(null, null);
239
243
  }), s = u.map((n) => String(n.text ?? "")).join(`
240
244
  `);
241
245
  k.push(
@@ -250,7 +254,7 @@ async function W(c) {
250
254
  k.push(u[0]);
251
255
  return k;
252
256
  }
253
- function j(c, i) {
257
+ function W(c, i) {
254
258
  const r = c[`${String(i)}Length`]();
255
259
  return {
256
260
  [Symbol.iterator]() {
@@ -268,7 +272,7 @@ function j(c, i) {
268
272
  }
269
273
  };
270
274
  }
271
- function J(c, i) {
275
+ function X(c, i) {
272
276
  var _a;
273
277
  if (!c) return [];
274
278
  const r = (_a = c[`${String(i)}Length`]) == null ? void 0 : _a.bind(c);
@@ -280,78 +284,83 @@ function J(c, i) {
280
284
  }
281
285
  return f;
282
286
  }
283
- async function X(c, i) {
287
+ async function Y(c, i) {
284
288
  const r = B(), l = A(r), f = Array.from(r).map((v) => v.toString(16).padStart(2, "0")).join(""), w = A(B()), y = new URLSearchParams();
285
289
  for (const v of i)
286
290
  y.append("relay", v);
287
291
  y.set("secret", w), y.set("name", c);
288
- const K = `nostrconnect://${l}?${y.toString()}`;
289
- return console.log("connect url:", K), G().setNip46QR(K, f), K;
292
+ const m = `nostrconnect://${l}?${y.toString()}`;
293
+ return console.log("connect url:", m), G().setNip46QR(m, f), m;
290
294
  }
291
295
  export {
292
- F as ConnectionTracker,
296
+ j as ConnectionTracker,
293
297
  ee as asBufferFull,
294
298
  te as asCashuData,
295
299
  ne as asCodeData,
296
300
  se as asConnectionStatus,
297
301
  ae as asCountResponse,
298
- oe as asEoce,
299
- ie as asHashtagData,
300
- re as asImageData,
301
- ce as asKind0,
302
- de as asKind1,
303
- le as asKind10002,
304
- ue as asKind10019,
305
- pe as asKind1111,
306
- ge as asKind1311,
307
- he as asKind17,
308
- fe as asKind17375,
309
- ye as asKind3,
310
- we as asKind4,
311
- ke as asKind6,
312
- me as asKind7,
313
- Ke as asKind7374,
314
- ve as asKind7375,
315
- De as asKind7376,
316
- Se as asKind9321,
317
- xe as asKind9735,
318
- Ce as asLinkPreview,
319
- be as asMediaGroupData,
320
- Me as asNip51,
321
- Te as asNostrData,
322
- Be as asNostrEvent,
323
- Ae as asParsedEvent,
324
- Ie as asPreGeneric,
325
- Pe as asValidProofs,
326
- Re as asVideoData,
327
- X as connectWithQRCode,
328
- J as fbArray,
329
- j as fbIterable,
330
- Ee as isBufferFull,
302
+ oe as asEmojiData,
303
+ ie as asEoce,
304
+ re as asHashtagData,
305
+ ce as asImageData,
306
+ de as asKind0,
307
+ le as asKind1,
308
+ ue as asKind10002,
309
+ pe as asKind10019,
310
+ ge as asKind1111,
311
+ he as asKind1311,
312
+ fe as asKind17,
313
+ ye as asKind17375,
314
+ we as asKind20,
315
+ ke as asKind22,
316
+ Ke as asKind3,
317
+ me as asKind4,
318
+ ve as asKind6,
319
+ De as asKind7,
320
+ Se as asKind7374,
321
+ xe as asKind7375,
322
+ Ce as asKind7376,
323
+ be as asKind9321,
324
+ Me as asKind9735,
325
+ Te as asLinkPreview,
326
+ Be as asMediaGroupData,
327
+ Ae as asNip51,
328
+ Ie as asNostrData,
329
+ Re as asNostrEvent,
330
+ Ee as asParsedEvent,
331
+ Pe as asPreGeneric,
332
+ $e as asValidProofs,
333
+ Ge as asVideoData,
334
+ Y as connectWithQRCode,
335
+ X as fbArray,
336
+ W as fbIterable,
337
+ Ne as isBufferFull,
331
338
  N as isConnectionStatus,
332
- $e as isCountResponse,
333
- Ge as isEoce,
334
- Ne as isKind0,
335
- Le as isKind1,
336
- Ve as isKind10002,
337
- ze as isKind10019,
338
- Ze as isKind1111,
339
- _e as isKind1311,
340
- He as isKind17,
341
- Oe as isKind17375,
342
- Ue as isKind3,
343
- Qe as isKind4,
344
- Fe as isKind6,
345
- We as isKind7,
346
- je as isKind7374,
347
- Je as isKind7375,
348
- Xe as isKind7376,
349
- Ye as isKind9321,
350
- qe as isKind9735,
351
- et as isNip51,
352
- tt as isNostrEvent,
353
- nt as isParsedEvent,
354
- st as isPreGeneric,
355
- at as isValidProofs,
356
- W as parseContent
339
+ Le as isCountResponse,
340
+ Ve as isEoce,
341
+ ze as isKind0,
342
+ Ze as isKind1,
343
+ _e as isKind10002,
344
+ He as isKind10019,
345
+ Oe as isKind1111,
346
+ Ue as isKind1311,
347
+ Qe as isKind17,
348
+ je as isKind17375,
349
+ Fe as isKind20,
350
+ We as isKind22,
351
+ Xe as isKind3,
352
+ Ye as isKind4,
353
+ qe as isKind6,
354
+ Je as isKind7,
355
+ et as isKind7374,
356
+ tt as isKind7375,
357
+ nt as isKind7376,
358
+ st as isKind9321,
359
+ at as isKind9735,
360
+ ot as isNip51,
361
+ it as isNostrEvent,
362
+ rt as isParsedEvent,
363
+ ct as isPreGeneric,
364
+ dt as isValidProofs,
365
+ F as parseContent
357
366
  };