@ghostlytools/cli 1.3.1 → 1.3.2

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 (60) hide show
  1. package/dist/assets/{api-TiB5QSG9.js → api-SYPJgFRU.js} +2 -2
  2. package/dist/assets/{api-Dq2QXQDk.js → api-aup3Amud.js} +9 -9
  3. package/dist/assets/{api-Dq2QXQDk.js.map → api-aup3Amud.js.map} +1 -1
  4. package/dist/assets/{apiKit-CA2x5GJF.js → apiKit-DYkVEs6r.js} +25 -29
  5. package/dist/assets/apiKit-DYkVEs6r.js.map +1 -0
  6. package/dist/assets/{apps-C-T8jeji.js → apps-DcZKu29s.js} +1 -1
  7. package/dist/assets/{apps-BxV9i_Y4.js → apps-Rbk2HHXb.js} +2 -2
  8. package/dist/assets/{apps-BxV9i_Y4.js.map → apps-Rbk2HHXb.js.map} +1 -1
  9. package/dist/assets/{arkade-C_qDmHnm.js → arkade-CuWlNnCz.js} +4 -4
  10. package/dist/assets/arkade-CuWlNnCz.js.map +1 -0
  11. package/dist/assets/{backup-CnMN2oUK.js → backup-CJWLDHuS.js} +4 -4
  12. package/dist/assets/{backup-CnMN2oUK.js.map → backup-CJWLDHuS.js.map} +1 -1
  13. package/dist/assets/{backup-Bugnn3Ue.js → backup-CSMw2GHv.js} +1 -1
  14. package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
  15. package/dist/assets/buttons-CGRqZ7z0.js +2 -0
  16. package/dist/assets/{buttons-CvNBzh2S.js → buttons-QEnAGWoC.js} +3 -3
  17. package/dist/assets/{buttons-CvNBzh2S.js.map → buttons-QEnAGWoC.js.map} +1 -1
  18. package/dist/assets/{envelope-WjingYSc.js → envelope-K27mzoyu.js} +2 -2
  19. package/dist/assets/{envelope-WjingYSc.js.map → envelope-K27mzoyu.js.map} +1 -1
  20. package/dist/assets/fedimint_client_wasm_bg-BtHHlFpp.js.map +1 -1
  21. package/dist/assets/{groupFiles-IEUW3DQz.js → groupFiles-DHTrTA4I.js} +43 -16
  22. package/dist/assets/groupFiles-DHTrTA4I.js.map +1 -0
  23. package/dist/assets/{host-CWt-jtqz.js → host-C7hA-Za7.js} +102 -34
  24. package/dist/assets/host-C7hA-Za7.js.map +1 -0
  25. package/dist/assets/{hyperdhtRelay-CPYwSLLS.js → hyperdhtRelay-BVoWY2ua.js} +2 -2
  26. package/dist/assets/{hyperdhtRelay-CPYwSLLS.js.map → hyperdhtRelay-BVoWY2ua.js.map} +1 -1
  27. package/dist/assets/{irohWeb-4oChIOIp.js → irohWeb-BJPk9bMn.js} +2 -2
  28. package/dist/assets/{irohWeb-4oChIOIp.js.map → irohWeb-BJPk9bMn.js.map} +1 -1
  29. package/dist/assets/{main-DbqcdShN.js → main-DC8cUkDx.js} +14 -14
  30. package/dist/assets/{main-DbqcdShN.js.map → main-DC8cUkDx.js.map} +1 -1
  31. package/dist/assets/{mainline-ZkiOnevs.js → mainline-CxbxpoU4.js} +2 -2
  32. package/dist/assets/{mainline-ZkiOnevs.js.map → mainline-CxbxpoU4.js.map} +1 -1
  33. package/dist/assets/{networkReason-CetKkTPo.js → networkReason-D42iNuUB.js} +2 -2
  34. package/dist/assets/{networkReason-CetKkTPo.js.map → networkReason-D42iNuUB.js.map} +1 -1
  35. package/dist/assets/{nwc-CgkqyvsE.js → nwc-Cm4sYgLv.js} +3 -3
  36. package/dist/assets/{nwc-CgkqyvsE.js.map → nwc-Cm4sYgLv.js.map} +1 -1
  37. package/dist/assets/{nwcProvider-4eVz_8HP.js → nwcProvider-0D7vdPDd.js} +2 -2
  38. package/dist/assets/{nwcProvider-4eVz_8HP.js.map → nwcProvider-0D7vdPDd.js.map} +1 -1
  39. package/dist/assets/{registry-OBJBnHVQ.js → registry-CLolR0kM.js} +1 -1
  40. package/dist/assets/{registry-DlAKO0Fy.js → registry-CVdSZW5l.js} +3 -3
  41. package/dist/assets/{registry-DlAKO0Fy.js.map → registry-CVdSZW5l.js.map} +1 -1
  42. package/dist/assets/{resolve-CouHhCpJ.js → resolve-BnlEajYz.js} +2 -2
  43. package/dist/assets/{resolve-CouHhCpJ.js.map → resolve-BnlEajYz.js.map} +1 -1
  44. package/dist/assets/{server-Ss0gJ-nw.js → server-CJNEKxzE.js} +112 -33
  45. package/dist/assets/server-CJNEKxzE.js.map +1 -0
  46. package/dist/assets/{src-DDzSERyc.js → src-yMUQvdyL.js} +157 -141
  47. package/dist/assets/src-yMUQvdyL.js.map +1 -0
  48. package/dist/assets/{turnRefs-B87dtrHM.js → turnRefs-B2a8to9q.js} +2 -2
  49. package/dist/assets/{turnRefs-B87dtrHM.js.map → turnRefs-B2a8to9q.js.map} +1 -1
  50. package/dist/assets/{usdt-Fj8CQO2z.js → usdt-DesFeDiG.js} +3 -3
  51. package/dist/assets/{usdt-Fj8CQO2z.js.map → usdt-DesFeDiG.js.map} +1 -1
  52. package/dist/ghostly.mjs +1 -1
  53. package/package.json +1 -1
  54. package/dist/assets/apiKit-CA2x5GJF.js.map +0 -1
  55. package/dist/assets/arkade-C_qDmHnm.js.map +0 -1
  56. package/dist/assets/buttons-Bj7Vf7Pn.js +0 -2
  57. package/dist/assets/groupFiles-IEUW3DQz.js.map +0 -1
  58. package/dist/assets/host-CWt-jtqz.js.map +0 -1
  59. package/dist/assets/server-Ss0gJ-nw.js.map +0 -1
  60. package/dist/assets/src-DDzSERyc.js.map +0 -1
@@ -1,7 +1,7 @@
1
- import { Fn as decodeBolt11, Fr as ChatFiles, Lr as transferEnded, Nn as requestLnurlInvoice, Pn as resolveLightningDestination, Qn as GROUP_HAVE_FRAME, Ta as RateWindow, Ua as replySnippet, Xn as engineText, Yn as engineError, Zn as GROUP_FILE_LIMITS, _l as randomBytes, _n as walletNetworkOf, ar as readGroupHave, er as GROUP_WANT_NO_FRAME, fn as WALLET_NETWORKS, nr as groupFileFallback, or as readGroupWant, rr as isGroupMessageId, sr as readGroupWantNo, tr as fetchesByItself, vl as toBase64Url, ya as fileMessageText } from "./src-DDzSERyc.js";
1
+ import { $n as GROUP_HAVE_FRAME, Ea as RateWindow, Fn as resolveLightningDestination, In as decodeBolt11, Ir as ChatFiles, Pn as requestLnurlInvoice, Qn as GROUP_FILE_LIMITS, Rr as transferEnded, Wa as replySnippet, Xn as engineError, Zn as engineText, bl as randomBytes, cr as readGroupWantNo, fn as WALLET_NETWORKS, ir as isGroupMessageId, nr as fetchesByItself, or as readGroupHave, rr as groupFileFallback, sr as readGroupWant, tr as GROUP_WANT_NO_FRAME, va as fileMessageText, vn as walletNetworkOf, xl as toBase64Url } from "./src-yMUQvdyL.js";
2
2
  import { a as describeProvider, c as offeredIn, d as sourceProblem, n as PROVIDER_PLATFORMS, o as isNothingSpentError, s as networkMode, t as NothingSpentError, u as redact } from "./types-C4_KafL_.js";
3
3
  import { c as fileStore, f as store, i as STORES, m as wrap, o as databaseName, p as transact } from "./idb-B5L8wuOm.js";
4
- import { a as sealSeed, i as newDeviceKey, o as unsealSeed, t as networkReason } from "./networkReason-CetKkTPo.js";
4
+ import { a as sealSeed, i as newDeviceKey, o as unsealSeed, t as networkReason } from "./networkReason-D42iNuUB.js";
5
5
  import { t as BITCOIN_INVOICE_ON_TESTNET, u as mintNetwork } from "./mints-BrlY773j.js";
6
6
  import { f as FILE_BYTES_STEP, o as fileBytes, s as fileBytesOf } from "./fileBytes-Di7VZtmU.js";
7
7
  import { sha256 } from "@noble/hashes/sha2.js";
@@ -2477,6 +2477,7 @@ var GroupFileDesk = class {
2477
2477
  this.byMessage.delete(`${groupId}\n${kept.message}`);
2478
2478
  this.wants.delete(kept.id);
2479
2479
  this.deps.transfers.delete(kept.id);
2480
+ await kept.writing?.catch(() => {});
2480
2481
  await this.deps.store.remove(kept.id).catch(() => {});
2481
2482
  }
2482
2483
  for (const [linkId, edge] of this.edgesById) if (edge.groupId === groupId) {
@@ -2515,7 +2516,7 @@ var GroupFileDesk = class {
2515
2516
  if (no) this.refused(groupId, peer, linkId, no.id, no.why);
2516
2517
  } else if (frame.t === "group-have") {
2517
2518
  const ids = readGroupHave(frame, groupId);
2518
- if (ids) this.heard(groupId, peer, ids);
2519
+ if (ids && this.edge(groupId, peer, linkId).haveTaken.take()) this.heard(groupId, peer, ids);
2519
2520
  }
2520
2521
  }
2521
2522
  /** A community's `group-have`, an application frame its signer sent the group. */
@@ -2852,7 +2853,8 @@ var GroupFileDesk = class {
2852
2853
  edge.busy.add(messageId);
2853
2854
  return "busy";
2854
2855
  }
2855
- if (active.some((a) => a.peer === edge.peer && a.sending)) return "busy";
2856
+ const theirs = active.filter((a) => a.peer === edge.peer);
2857
+ if (theirs.length > 1 || theirs.some((a) => a.sending || this.deps.now() - a.since >= GROUP_FILE_LIMITS.doneWaitMs)) return "busy";
2856
2858
  const today = Math.floor(this.deps.now() / 864e5);
2857
2859
  if (this.served.day !== today) this.served = {
2858
2860
  day: today,
@@ -2863,7 +2865,7 @@ var GroupFileDesk = class {
2863
2865
  }
2864
2866
  /**
2865
2867
  * Transfers served now, all groups together: to whom, what each takes of the day (its size, or what it sent when that
2866
- * is more), and whether bytes are still to go.
2868
+ * is more), whether bytes are still to go, and since when it has not gone further.
2867
2869
  */
2868
2870
  servingNow() {
2869
2871
  const active = [];
@@ -2872,7 +2874,8 @@ var GroupFileDesk = class {
2872
2874
  if (record && !transferEnded(record)) active.push({
2873
2875
  peer: edge.peer,
2874
2876
  size: Math.max(record.file.size, edge.files.sent(wire)),
2875
- sending: record.confirmed < record.file.size
2877
+ sending: record.confirmed < record.file.size,
2878
+ since: edge.servedMoved.get(wire)?.at ?? this.deps.now()
2876
2879
  });
2877
2880
  }
2878
2881
  return active;
@@ -2891,20 +2894,27 @@ var GroupFileDesk = class {
2891
2894
  }
2892
2895
  /**
2893
2896
  * Served transfers that no longer count end, their places free for others (WISP 503 § Serving limits): the asker's
2894
- * session closed, it is not in the roster any more, or its bytes have not moved for `wantWaitMs` (the asker has moved
2895
- * on by then).
2897
+ * session closed, it is not in the roster any more, its bytes have not gone further for `wantWaitMs` (the asker has
2898
+ * moved on by then), or it has all its bytes and the member's next want has overtaken its word for `doneWaitMs`.
2896
2899
  */
2897
2900
  letGo() {
2898
2901
  const now = this.deps.now();
2902
+ const theirs = /* @__PURE__ */ new Map();
2903
+ for (const a of this.servingNow()) theirs.set(a.peer, (theirs.get(a.peer) ?? 0) + 1);
2899
2904
  for (const edge of this.edgesById.values()) for (const wire of [...edge.serving.keys()]) {
2900
2905
  const record = edge.files.get("out", wire);
2901
2906
  if (!record || transferEnded(record)) continue;
2902
2907
  let moved = edge.servedMoved.get(wire);
2903
- if (!moved || moved.confirmed !== record.confirmed) edge.servedMoved.set(wire, moved = {
2908
+ if (!moved) edge.servedMoved.set(wire, moved = {
2904
2909
  confirmed: record.confirmed,
2905
2910
  at: now
2906
2911
  });
2907
- if (!edge.files.live || !this.deps.membership(edge.groupId)?.inRoster(edge.peer) || now - moved.at >= GROUP_FILE_LIMITS.wantWaitMs) edge.files.cancel("out", wire);
2912
+ const gone = !edge.files.live || !this.deps.membership(edge.groupId)?.inRoster(edge.peer);
2913
+ const overtaken = record.confirmed === record.file.size && theirs.get(edge.peer) > 1 && now - moved.at >= GROUP_FILE_LIMITS.doneWaitMs;
2914
+ if (gone || overtaken || now - moved.at >= GROUP_FILE_LIMITS.wantWaitMs) {
2915
+ edge.files.cancel("out", wire);
2916
+ theirs.set(edge.peer, theirs.get(edge.peer) - 1);
2917
+ }
2908
2918
  }
2909
2919
  }
2910
2920
  /**
@@ -2955,6 +2965,7 @@ var GroupFileDesk = class {
2955
2965
  ended: [],
2956
2966
  have: /* @__PURE__ */ new Set(),
2957
2967
  haveSent: new RateWindow(GROUP_FILE_LIMITS.haveFrames, GROUP_FILE_LIMITS.haveWindowMs, () => this.deps.now()),
2968
+ haveTaken: new RateWindow(GROUP_FILE_LIMITS.haveFrames, GROUP_FILE_LIMITS.haveWindowMs, () => this.deps.now()),
2958
2969
  busy: /* @__PURE__ */ new Set(),
2959
2970
  gone: /* @__PURE__ */ new Set()
2960
2971
  };
@@ -2995,13 +3006,23 @@ var GroupFileDesk = class {
2995
3006
  const writer = await this.deps.store.write(kept.id, !kept.fresh);
2996
3007
  kept.fresh = false;
2997
3008
  const resumed = writer.offset > 0;
3009
+ if (!resumed) kept.storedBy = edge.peer;
3010
+ else if (kept.storedBy !== edge.peer) kept.storedBy = void 0;
2998
3011
  let damaged = false;
3012
+ const gone = () => this.kept.get(kept.id) !== kept;
3013
+ const write = async (op) => {
3014
+ if (gone()) {
3015
+ await writer.discard();
3016
+ throw new Error("No such file");
3017
+ }
3018
+ return await (kept.writing = op());
3019
+ };
2999
3020
  return {
3000
3021
  offset: writer.offset,
3001
- append: (bytes) => writer.append(bytes),
3002
- flush: () => writer.flush(),
3022
+ append: (bytes) => write(() => writer.append(bytes)),
3023
+ flush: () => write(() => writer.flush()),
3003
3024
  verify: async () => {
3004
- damaged = await writer.digest() !== kept.meta.d;
3025
+ damaged = await write(() => writer.digest()) !== kept.meta.d;
3005
3026
  const want = this.wants.get(kept.id);
3006
3027
  if (damaged && want) want.why = "damaged";
3007
3028
  return !damaged;
@@ -3009,10 +3030,11 @@ var GroupFileDesk = class {
3009
3030
  discard: () => {
3010
3031
  if (damaged) {
3011
3032
  kept.stored = 0;
3012
- if (resumed) kept.fresh = kept.unclear = true;
3033
+ if (resumed && kept.storedBy !== edge.peer) kept.fresh = kept.unclear = true;
3013
3034
  else kept.damaged.add(edge.peer);
3035
+ kept.storedBy = void 0;
3014
3036
  }
3015
- return kept.idle = (damaged || kept.dropped === record.id ? writer.discard() : writer.close()).catch(() => {});
3037
+ return kept.idle = (damaged || kept.dropped === record.id || gone() ? writer.discard() : writer.close()).catch(() => {});
3016
3038
  }
3017
3039
  };
3018
3040
  }
@@ -3034,6 +3056,11 @@ var GroupFileDesk = class {
3034
3056
  transferChanged(edge, record, transferred) {
3035
3057
  if (transferEnded(record)) this.transferOver(edge, record);
3036
3058
  if (record.direction === "out") {
3059
+ const moved = edge.servedMoved.get(record.id);
3060
+ if (moved && record.confirmed > moved.confirmed) edge.servedMoved.set(record.id, {
3061
+ confirmed: record.confirmed,
3062
+ at: this.deps.now()
3063
+ });
3037
3064
  if (transferEnded(record) && edge.serving.has(record.id)) {
3038
3065
  const today = Math.floor(this.deps.now() / 864e5);
3039
3066
  if (this.served.day !== today) this.served = {
@@ -3199,4 +3226,4 @@ function messageFile(kept) {
3199
3226
  //#endregion
3200
3227
  export { setSingleWriterGate as $, LightningCards as A, breezDatabaseInUse as B, FileAppender as C, streamStored as D, storedSize as E, ProviderSources as F, ModeChanged as G, dropBreezDatabase as H, sourceKey as I, networkLabel as J, ModeGate as K, CASHU_MINT_SOURCE as L, isRecoveryPhrase as M, normalizePhrase as N, waitingGroupFile as O, lightningPaying as P, setAwayWallets as Q, cashuMint as R, WALLET_TYPES as S, removeStored as T, iceServerProblem as U, breezDatabasesFor as V, iceServerSetting as W, refuseAway as X, awayFrom as Y, requireTurn as Z, crossNetwork as _, storedGroupFiles as a, walletInstances as b, receivedPairedReply as c, paymentAlias as d, paymentWireId as f, createTiming as g, createFailure as h, groupOfFile as i, cardsKey as j, CASHU_CARD as k, replyRef as l, assertConfirmedReal as m, groupFileId as n, groupReply as o, WALLET_NAMES as p, WrongNetworkError as q, groupFileText as r, pairedWireReply as s, GroupFileDesk as t, replyTo as u, paymentNetwork as v, readStored as w, MESSAGE_DETAILS_MAX_BYTES as x, paymentNetworksOf as y, breezDatabase as z };
3201
3228
 
3202
- //# sourceMappingURL=groupFiles-IEUW3DQz.js.map
3229
+ //# sourceMappingURL=groupFiles-DHTrTA4I.js.map