@ghostlytools/cli 1.13.1 → 1.13.3

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 (112) hide show
  1. package/README.md +15 -12
  2. package/dist/assets/api-DO0YMLiB.js +3 -0
  3. package/dist/assets/{api-Dnq86JAA.js → api-Dz2cw7WD.js} +512 -103
  4. package/dist/assets/api-Dz2cw7WD.js.map +1 -0
  5. package/dist/assets/{apiKit-nLK4jeTq.js → apiKit-DAFsWtyk.js} +53 -7
  6. package/dist/assets/apiKit-DAFsWtyk.js.map +1 -0
  7. package/dist/assets/{appFetch-wqBWi3Ry.js → appFetch-BQO5Pk7W.js} +2 -2
  8. package/dist/assets/{appFetch-wqBWi3Ry.js.map → appFetch-BQO5Pk7W.js.map} +1 -1
  9. package/dist/assets/{apps-DBVhKpfe.js → apps-B88rYWRm.js} +51 -23
  10. package/dist/assets/apps-B88rYWRm.js.map +1 -0
  11. package/dist/assets/{apps-nLtyhC2f.js → apps-D4KRpZB4.js} +1 -1
  12. package/dist/assets/{arkade-DryM-q5n.js → arkade-B6UNf5HI.js} +2 -2
  13. package/dist/assets/{arkade-DryM-q5n.js.map → arkade-B6UNf5HI.js.map} +1 -1
  14. package/dist/assets/{backup-D6s0LQdg.js → backup-BeXBtbVL.js} +1 -1
  15. package/dist/assets/{backup-Bczllmzf.js → backup-CNLY905d.js} +15 -8
  16. package/dist/assets/backup-CNLY905d.js.map +1 -0
  17. package/dist/assets/bark_ffi_wasm_bg-CjjCN3FD.js +5 -0
  18. package/dist/assets/{bitcoind-DML_-Xbv.js → bitcoind-BXZdQ1wZ.js} +2 -2
  19. package/dist/assets/{bitcoind-DML_-Xbv.js.map → bitcoind-BXZdQ1wZ.js.map} +1 -1
  20. package/dist/assets/bitcoindevkit_bg-D6IFIaJi.js +5 -0
  21. package/dist/assets/{buttons-B3C3vdhH.js → buttons-BKojbx0Q.js} +4 -4
  22. package/dist/assets/{buttons-B3C3vdhH.js.map → buttons-BKojbx0Q.js.map} +1 -1
  23. package/dist/assets/buttons-_5Fw8uHn.js +1 -0
  24. package/dist/assets/{client-B7jRrSnb.js → client-BtPhfWjK.js} +2 -2
  25. package/dist/assets/{client-B7jRrSnb.js.map → client-BtPhfWjK.js.map} +1 -1
  26. package/dist/assets/{engineErrors--9hfgKlK.js → engineErrors-wWlLy54D.js} +11 -3
  27. package/dist/assets/engineErrors-wWlLy54D.js.map +1 -0
  28. package/dist/assets/{fedimintSdk-D-6H9Pe7.js → fedimintSdk-eLXBrj9i.js} +2 -2
  29. package/dist/assets/{fedimintSdk-D-6H9Pe7.js.map → fedimintSdk-eLXBrj9i.js.map} +1 -1
  30. package/dist/assets/fedimint_client_wasm_bg-CRQlnJdu.js +5 -0
  31. package/dist/assets/{fixedHosts-H3i6o9Iy.js → fixedHosts-BJFL8Ell.js} +3 -3
  32. package/dist/assets/{fixedHosts-H3i6o9Iy.js.map → fixedHosts-BJFL8Ell.js.map} +1 -1
  33. package/dist/assets/{groupMeta--fxSh792.js → groupMeta-Cz95F6sX.js} +201 -43
  34. package/dist/assets/groupMeta-Cz95F6sX.js.map +1 -0
  35. package/dist/assets/{host-CGzVFfMz.js → host-BsBWxTtW.js} +276 -53
  36. package/dist/assets/host-BsBWxTtW.js.map +1 -0
  37. package/dist/assets/{hyperdhtRelay-Ce-gWsRY.js → hyperdhtRelay-B34Zhz4P.js} +2 -2
  38. package/dist/assets/{hyperdhtRelay-Ce-gWsRY.js.map → hyperdhtRelay-B34Zhz4P.js.map} +1 -1
  39. package/dist/assets/{hyperdhtRelay-B4_wdCtx.js → hyperdhtRelay-DDwU5b4P.js} +2 -2
  40. package/dist/assets/{hyperdhtRelay-B4_wdCtx.js.map → hyperdhtRelay-DDwU5b4P.js.map} +1 -1
  41. package/dist/assets/{identityProofs-Cksc_K7_.js → identityProofs-zI_Iy9uI.js} +154 -27
  42. package/dist/assets/identityProofs-zI_Iy9uI.js.map +1 -0
  43. package/dist/assets/{irohWeb-Dp1i8v6n.js → irohWeb-BLDcHwYz.js} +10866 -4829
  44. package/dist/assets/irohWeb-BLDcHwYz.js.map +1 -0
  45. package/dist/assets/{linkPreview-DdMf-YAc.js → linkPreview-5kHmKUTN.js} +20 -8
  46. package/dist/assets/linkPreview-5kHmKUTN.js.map +1 -0
  47. package/dist/assets/{main-C8J53SwH.js → main-D48Ben7C.js} +122 -49
  48. package/dist/assets/main-D48Ben7C.js.map +1 -0
  49. package/dist/assets/{mainline-DY95WbuK.js → mainline-CDUXtV-I.js} +2 -2
  50. package/dist/assets/{mainline-DY95WbuK.js.map → mainline-CDUXtV-I.js.map} +1 -1
  51. package/dist/assets/{networkReason-Be-hMghr.js → networkReason-DYlPZS5M.js} +2 -2
  52. package/dist/assets/{networkReason-Be-hMghr.js.map → networkReason-DYlPZS5M.js.map} +1 -1
  53. package/dist/assets/{ownDid-oa-T2vmZ.js → ownDid-CwxFBzOH.js} +6 -5
  54. package/dist/assets/ownDid-CwxFBzOH.js.map +1 -0
  55. package/dist/assets/{ownStatus-Bc08eNJY.js → ownStatus-DjD0sQKF.js} +34 -11
  56. package/dist/assets/ownStatus-DjD0sQKF.js.map +1 -0
  57. package/dist/assets/{pairedTransports-Dppn8lUN.js → pairedTransports-DAzupLYo.js} +21 -15
  58. package/dist/assets/pairedTransports-DAzupLYo.js.map +1 -0
  59. package/dist/assets/{paymentIntent-DySU3Ajm.js → paymentIntent-Cr3uZa_0.js} +2 -2
  60. package/dist/assets/{paymentIntent-DySU3Ajm.js.map → paymentIntent-Cr3uZa_0.js.map} +1 -1
  61. package/dist/assets/{profiles-B2uy04ph.js → profiles-BAJf0c9E.js} +33 -8
  62. package/dist/assets/profiles-BAJf0c9E.js.map +1 -0
  63. package/dist/assets/{registry-bLIfG619.js → registry-CHwHTWbK.js} +1 -1
  64. package/dist/assets/{registry-DbTLLs3y.js → registry-CPuexTle.js} +25 -13
  65. package/dist/assets/registry-CPuexTle.js.map +1 -0
  66. package/dist/assets/{relay-CHWg5hpZ.js → relay-gJTOYQJZ.js} +93 -7
  67. package/dist/assets/relay-gJTOYQJZ.js.map +1 -0
  68. package/dist/assets/{resolve-DNX-eecG.js → resolve-BqmGXKn4.js} +3 -3
  69. package/dist/assets/{resolve-DNX-eecG.js.map → resolve-BqmGXKn4.js.map} +1 -1
  70. package/dist/assets/{server-DWJ4RzJn.js → server-e4oKeNez.js} +901 -6262
  71. package/dist/assets/server-e4oKeNez.js.map +1 -0
  72. package/dist/assets/{sshForges-BnvwmNj-.js → sshForges-Cqt3qfWe.js} +2 -2
  73. package/dist/assets/{sshForges-BnvwmNj-.js.map → sshForges-Cqt3qfWe.js.map} +1 -1
  74. package/dist/assets/{translate-CHj_PdLg.js → translate-DnuQMfj0.js} +10 -4
  75. package/dist/assets/translate-DnuQMfj0.js.map +1 -0
  76. package/dist/assets/{usdt-CBJ4Q5Ji.js → usdt-DLmtf8F9.js} +4 -4
  77. package/dist/assets/{usdt-CBJ4Q5Ji.js.map → usdt-DLmtf8F9.js.map} +1 -1
  78. package/dist/assets/{waitNotice-Cvz5CiKR.js → waitNotice-mB0Ym145.js} +2 -2
  79. package/dist/assets/{waitNotice-Cvz5CiKR.js.map → waitNotice-mB0Ym145.js.map} +1 -1
  80. package/dist/ghostly.mjs +1 -1
  81. package/npm-shrinkwrap.json +2 -2
  82. package/package.json +1 -1
  83. package/dist/assets/api-DF36rBJK.js +0 -3
  84. package/dist/assets/api-Dnq86JAA.js.map +0 -1
  85. package/dist/assets/apiKit-nLK4jeTq.js.map +0 -1
  86. package/dist/assets/apps-DBVhKpfe.js.map +0 -1
  87. package/dist/assets/backup-Bczllmzf.js.map +0 -1
  88. package/dist/assets/bark_ffi_wasm_bg-CcafsJla.js +0 -5
  89. package/dist/assets/bark_ffi_wasm_bg-CcafsJla.js.map +0 -1
  90. package/dist/assets/bark_ffi_wasm_bg-VNmaJsc9.wasm +0 -0
  91. package/dist/assets/bitcoindevkit_bg-BWQHx7vd.js +0 -5
  92. package/dist/assets/bitcoindevkit_bg-BWQHx7vd.js.map +0 -1
  93. package/dist/assets/bitcoindevkit_bg-DXil67yS.wasm +0 -0
  94. package/dist/assets/buttons-DaY5FYlV.js +0 -1
  95. package/dist/assets/engineErrors--9hfgKlK.js.map +0 -1
  96. package/dist/assets/fedimint_client_wasm_bg-Cr5xGD-w.js +0 -5
  97. package/dist/assets/fedimint_client_wasm_bg-Cr5xGD-w.js.map +0 -1
  98. package/dist/assets/fedimint_client_wasm_bg-DeFtkIv6.wasm +0 -0
  99. package/dist/assets/groupMeta--fxSh792.js.map +0 -1
  100. package/dist/assets/host-CGzVFfMz.js.map +0 -1
  101. package/dist/assets/identityProofs-Cksc_K7_.js.map +0 -1
  102. package/dist/assets/irohWeb-Dp1i8v6n.js.map +0 -1
  103. package/dist/assets/linkPreview-DdMf-YAc.js.map +0 -1
  104. package/dist/assets/main-C8J53SwH.js.map +0 -1
  105. package/dist/assets/ownDid-oa-T2vmZ.js.map +0 -1
  106. package/dist/assets/ownStatus-Bc08eNJY.js.map +0 -1
  107. package/dist/assets/pairedTransports-Dppn8lUN.js.map +0 -1
  108. package/dist/assets/profiles-B2uy04ph.js.map +0 -1
  109. package/dist/assets/registry-DbTLLs3y.js.map +0 -1
  110. package/dist/assets/relay-CHWg5hpZ.js.map +0 -1
  111. package/dist/assets/server-DWJ4RzJn.js.map +0 -1
  112. package/dist/assets/translate-CHj_PdLg.js.map +0 -1
@@ -106,20 +106,27 @@ var LINK_CLOSERS = {
106
106
  * and full stop, the full-width ! , : ; ? and brackets, the corner quotes, the Arabic comma, semicolon and question
107
107
  * mark, the Urdu full stop. No address holds one as typed, so a link stops at the first.
108
108
  */
109
- var LINK_STOP = /[、。〈-】!(),:;?،؛؟۔]/;
109
+ var LINK_STOP_CHARS = "、。〈-】!(),:;?،؛؟۔";
110
+ var LINK_STOP = new RegExp(`[${LINK_STOP_CHARS}]`);
110
111
  /** What a link leaves out at its end: a sentence's punctuation ("…", "»", "”" too), never a path's "/". */
111
112
  var LINK_TRAILING = /[.,;:!?'"*_>…»’”]/;
112
113
  /**
113
114
  * What a chat puts right after a link with no space and no address ends with: an emoji ("https://x.example/a🔥", with
114
- * its skin tone, presentation selector, joiners and flag tags) and characters that draw as nothing. Read one code point
115
- * at a time from the end, so an emoji inside an address stays in it.
115
+ * its skin tone, presentation selector, joiners and flag tags) and characters that draw as nothing, the direction marks
116
+ * and isolates a right-to-left sentence puts around a link among them. Read one code point at a time from the end, so
117
+ * an emoji inside an address stays in it.
116
118
  */
117
- var LINK_TAIL = /^(?:\p{Extended_Pictographic}|\p{Emoji_Modifier}|\p{Regional_Indicator}|[\u200b\u200c\u2060\ufeff\u{e0020}-\u{e007f}]|\u200d|\ufe0e|\ufe0f)$/u;
119
+ var LINK_TAIL = /^(?:\p{Extended_Pictographic}|\p{Emoji_Modifier}|\p{Regional_Indicator}|[\u200b\u200c\u2060\ufeff\u{e0020}-\u{e007f}]|[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]|\u200d|\ufe0e|\ufe0f)$/u;
120
+ /** The direction marks and isolates alone: a payment link, which keeps an emoji at its end, still ends before these. */
121
+ var DIRECTION_TAIL = /^[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]$/;
118
122
  /** How many UTF-16 units of `url` before `end` are an emoji's or an invisible character's last code point (0: none). */
119
123
  function linkTail(url, end) {
120
124
  const units = end > 1 && /[\udc00-\udfff]/.test(url[end - 1]) && /[\ud800-\udbff]/.test(url[end - 2]) ? 2 : 1;
121
125
  return end > 0 && LINK_TAIL.test(url.slice(end - units, end)) ? units : 0;
122
126
  }
127
+ function directionTail(url, end) {
128
+ return end > 0 && DIRECTION_TAIL.test(url[end - 1]) ? 1 : 0;
129
+ }
123
130
  /** A link up to the first `LINK_STOP`: "https://x.example/a。" opens /a, not /a%E3%80%82. */
124
131
  function linkStop(url) {
125
132
  const at = url.search(LINK_STOP);
@@ -148,7 +155,7 @@ function trimEnd(whole, tails) {
148
155
  while (end > 0) {
149
156
  const last = url[end - 1];
150
157
  const opener = LINK_CLOSERS[last];
151
- const tail = tails ? linkTail(url, end) : 0;
158
+ const tail = tails ? linkTail(url, end) : directionTail(url, end);
152
159
  if (tail) {
153
160
  end -= tail;
154
161
  continue;
@@ -161,9 +168,14 @@ function trimEnd(whole, tails) {
161
168
  }
162
169
  /** Characters of a link worth reading: a longer one is no address anyone shares, and is left as text. */
163
170
  var LINK_MAX_CHARS = 4096;
171
+ /**
172
+ * An http(s) link's run in a text, as a `RegExp` source: up to a space or a `LINK_STOP_CHARS` character, as the bubble
173
+ * reads it. A link written right after another one's "。" or "،", with no space, is a run of its own.
174
+ */
175
+ var LINK_RUN = String.raw`https?:\/\/[^\s${LINK_STOP_CHARS}]+`;
164
176
  /** The http(s) links of a text, in order, each ending as the bubble ends it. */
165
177
  function linksIn(text) {
166
- return [...text.matchAll(/https?:\/\/\S+/gi)].filter((match) => match[0].length <= LINK_MAX_CHARS).map((match) => linkEnd(match[0])).filter((url) => url.length > 8);
178
+ return [...text.matchAll(new RegExp(LINK_RUN, "gi"))].filter((match) => match[0].length <= LINK_MAX_CHARS).map((match) => linkEnd(match[0])).filter((url) => url.length > 8);
167
179
  }
168
180
  /**
169
181
  * The link as a preview names it: parsed, http(s) only, without tracking parameters (`utm_*`, `fbclid`, …). The
@@ -247,6 +259,6 @@ function parseLinkPreview(raw, text) {
247
259
  if (JSON.stringify(preview).length > LINK_PREVIEW_LIMITS.jsonChars) return;
248
260
  return preview;
249
261
  }
250
- export { MAX_AVATAR_LENGTH as a, parseLinkPreview as i, linkStop as n, sanitizeAvatar as o, linkTail as r, LINK_TRAILING as t };
262
+ export { parseLinkPreview as a, linkTail as i, LINK_TRAILING as n, MAX_AVATAR_LENGTH as o, linkStop as r, sanitizeAvatar as s, LINK_STOP_CHARS as t };
251
263
 
252
- //# sourceMappingURL=linkPreview-DdMf-YAc.js.map
264
+ //# sourceMappingURL=linkPreview-5kHmKUTN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linkPreview-5kHmKUTN.js","names":[],"sources":["../../../core/src/avatar.ts","../../../core/src/linkPreview.ts"],"sourcesContent":["/**\n * A profile picture as it travels between paired peers: a small square JPEG in a data URL. The picture\n * a contact sends is shown next to their chats, so it is checked here before anything draws it: the\n * format, the size, and the dimensions its header declares (a tiny file can claim a huge image).\n */\n\n/** Longest data URL kept: a 128×128 JPEG is a few KB; this leaves room and no more. */\nexport const MAX_AVATAR_LENGTH = 48_000;\n/** Largest side a picture may declare. What Ghostly sends is 128. */\nexport const MAX_AVATAR_SIDE = 512;\nconst PREFIX = \"data:image/jpeg;base64,\";\n\n/** Width and height from a JPEG's frame header, or undefined when there is none before the image data. */\nexport function jpegSize(bytes: Uint8Array): { width: number; height: number } | undefined {\n if (bytes.length < 4 || bytes[0] !== 0xff || bytes[1] !== 0xd8) return;\n let i = 2;\n while (i + 4 <= bytes.length) {\n if (bytes[i] !== 0xff) return;\n const marker = bytes[i + 1];\n i += 2;\n if (marker === 0xd8 || (marker >= 0xd0 && marker <= 0xd7) || marker === 0x01) continue;\n if (marker === 0xd9 || marker === 0xda) return;\n const size = (bytes[i] << 8) | bytes[i + 1];\n if (size < 2 || i + size > bytes.length) return;\n // Start-of-frame markers (baseline, progressive, …), not DHT/JPG/DAC.\n if (marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc && size >= 7)\n return { height: (bytes[i + 3] << 8) | bytes[i + 4], width: (bytes[i + 5] << 8) | bytes[i + 6] };\n i += size;\n }\n}\n\n/**\n * The picture if it is one Ghostly will show, `null` for \"no picture\" (an empty string), and undefined\n * for anything else, which is ignored.\n */\nexport function sanitizeAvatar(value: unknown): string | null | undefined {\n if (value === \"\" || value === null) return null;\n if (typeof value !== \"string\" || value.length > MAX_AVATAR_LENGTH || !value.startsWith(PREFIX)) return;\n const data = value.slice(PREFIX.length);\n if (!/^[A-Za-z0-9+/]+={0,2}$/.test(data) || data.length % 4 !== 0) return;\n let binary: string;\n try { binary = atob(data); } catch { return; }\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);\n const size = jpegSize(bytes);\n if (!size || size.width < 1 || size.height < 1 || size.width > MAX_AVATAR_SIDE || size.height > MAX_AVATAR_SIDE) return;\n return value;\n}\n","import { jpegSize } from \"./avatar\";\n\n/**\n * A link preview as it travels with a chat message (WISP 401 § Link previews): what the sender's app read from the\n * page when the message was written, carried in the message so the reader never contacts the site. Every field\n * but the link is optional. The receiver checks it here and drops it, never the message, when anything is off.\n */\nexport interface LinkPreview {\n /** The link the preview is of: a link of the message's text, without its tracking parameters (`canonicalUrl`). */\n u: string;\n /** The page's title. */\n t?: string;\n /** Its description. */\n d?: string;\n /** The site's name (\"YouTube\"). */\n s?: string;\n /** A thumbnail redrawn by the sender: a JPEG `data:` URL (`LINK_PREVIEW_LIMITS.imageBytes`, `imageSide`). */\n i?: string;\n}\n\nexport const LINK_PREVIEW_LIMITS = {\n urlChars: 2048,\n titleChars: 200,\n descriptionChars: 300,\n siteChars: 80,\n /** The thumbnail's JPEG bytes. Ghostly draws it at most 320 pixels wide and fits it under this. */\n imageBytes: 20_000,\n /** The largest side a thumbnail may declare in its header (a tiny file can claim a huge image). */\n imageSide: 640,\n /** The preview as JSON. With a text of 16 KiB the message frame stays under the 60 KiB a session takes. */\n jsonChars: 30 * 1024,\n} as const;\n\nconst JPEG_PREFIX = \"data:image/jpeg;base64,\";\n\n/**\n * Query parameters that only say where a click came from. They are dropped from a previewed link, and the card\n * shows and opens the link without them.\n */\nconst TRACKING_PARAMS = new Set([\n \"fbclid\", \"gclid\", \"dclid\", \"gbraid\", \"wbraid\", \"msclkid\", \"yclid\", \"twclid\", \"ttclid\", \"li_fat_id\", \"igshid\", \"igsh\",\n \"mc_cid\", \"mc_eid\", \"_hsenc\", \"_hsmi\", \"mkt_tok\", \"oly_anon_id\", \"oly_enc_id\", \"vero_id\", \"rb_clickid\", \"srsltid\",\n \"ref_src\", \"ref_url\", \"si\", \"__s\", \"s_cid\", \"spm\",\n]);\nconst isTracking = (name: string) => /^utm_/i.test(name) || TRACKING_PARAMS.has(name.toLowerCase());\n\nconst LINK_CLOSERS: Record<string, string> = { \")\": \"(\", \"]\": \"[\", \"}\": \"{\" };\n\n/**\n * Punctuation a sentence in Chinese, Japanese or Arabic puts right after a link, with no space: the ideographic comma\n * and full stop, the full-width ! , : ; ? and brackets, the corner quotes, the Arabic comma, semicolon and question\n * mark, the Urdu full stop. No address holds one as typed, so a link stops at the first.\n */\nexport const LINK_STOP_CHARS = \"、。〈-】!(),:;?،؛؟۔\";\nconst LINK_STOP = new RegExp(`[${LINK_STOP_CHARS}]`);\n\n/** What a link leaves out at its end: a sentence's punctuation (\"…\", \"»\", \"”\" too), never a path's \"/\". */\nexport const LINK_TRAILING = /[.,;:!?'\"*_>…»’”]/;\n\n/**\n * What a chat puts right after a link with no space and no address ends with: an emoji (\"https://x.example/a🔥\", with\n * its skin tone, presentation selector, joiners and flag tags) and characters that draw as nothing, the direction marks\n * and isolates a right-to-left sentence puts around a link among them. Read one code point at a time from the end, so\n * an emoji inside an address stays in it.\n */\nconst LINK_TAIL = /^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200b\\u200c\\u2060\\ufeff\\u{e0020}-\\u{e007f}]|[\\u061c\\u200e\\u200f\\u202a-\\u202e\\u2066-\\u2069]|\\u200d|\\ufe0e|\\ufe0f)$/u;\n\n/** The direction marks and isolates alone: a payment link, which keeps an emoji at its end, still ends before these. */\nconst DIRECTION_TAIL = /^[\\u061c\\u200e\\u200f\\u202a-\\u202e\\u2066-\\u2069]$/;\n\n/** How many UTF-16 units of `url` before `end` are an emoji's or an invisible character's last code point (0: none). */\nexport function linkTail(url: string, end: number): number {\n const units = end > 1 && /[\\udc00-\\udfff]/.test(url[end - 1]) && /[\\ud800-\\udbff]/.test(url[end - 2]) ? 2 : 1;\n return end > 0 && LINK_TAIL.test(url.slice(end - units, end)) ? units : 0;\n}\n\nfunction directionTail(url: string, end: number): number {\n return end > 0 && DIRECTION_TAIL.test(url[end - 1]) ? 1 : 0;\n}\n\n/** A link up to the first `LINK_STOP`: \"https://x.example/a。\" opens /a, not /a%E3%80%82. */\nexport function linkStop(url: string): string {\n const at = url.search(LINK_STOP);\n return at < 0 ? url : url.slice(0, at);\n}\n\n/**\n * A link ends where the sentence around it takes over: trailing punctuation (\"see https://x.example/a.\", in any of\n * the app's languages), an emoji or invisible character (`linkTail`) and a closing bracket or quote the link did not\n * open (\"(https://x.example/a)\") are left as text. The same rule as the message bubble's links.\n */\nexport function linkEnd(whole: string): string {\n return trimEnd(whole, true);\n}\n\n/**\n * A payment link (`bitcoin:`, `monero:`…) ends as a web link does, but keeps an emoji at its end: its label or message\n * is text written as it is (\"…&label=Pizza 🍕\"), cut at 140 characters wherever that falls. A direction mark or\n * isolate typed after it is still left out, so \"bitcoin:bc1q…\\u200f.\" pays bc1q….\n */\nexport function uriEnd(whole: string): string {\n return trimEnd(whole, false);\n}\n\nfunction trimEnd(whole: string, tails: boolean): string {\n const url = linkStop(whole);\n // Brackets counted once, then taken off as they go: linear in the link, however many \")\" a peer puts at its end.\n const count: Record<string, number> = { \"(\": 0, \")\": 0, \"[\": 0, \"]\": 0, \"{\": 0, \"}\": 0 };\n for (const c of url) if (c in count) count[c]++;\n let end = url.length;\n while (end > 0) {\n const last = url[end - 1];\n const opener = LINK_CLOSERS[last];\n const tail = tails ? linkTail(url, end) : directionTail(url, end);\n if (tail) { end -= tail; continue; }\n if (!LINK_TRAILING.test(last) && !(opener && count[last] > count[opener])) break;\n if (opener) count[last]--;\n end--;\n }\n return url.slice(0, end);\n}\n\n/** Characters of a link worth reading: a longer one is no address anyone shares, and is left as text. */\nexport const LINK_MAX_CHARS = 4 * 1024;\n\n/**\n * An http(s) link's run in a text, as a `RegExp` source: up to a space or a `LINK_STOP_CHARS` character, as the bubble\n * reads it. A link written right after another one's \"。\" or \"،\", with no space, is a run of its own.\n */\nexport const LINK_RUN = String.raw`https?:\\/\\/[^\\s${LINK_STOP_CHARS}]+`;\n\n/** The http(s) links of a text, in order, each ending as the bubble ends it. */\nexport function linksIn(text: string): string[] {\n return [...text.matchAll(new RegExp(LINK_RUN, \"gi\"))].filter(match => match[0].length <= LINK_MAX_CHARS).map(match => linkEnd(match[0])).filter(url => url.length > 8);\n}\n\n/**\n * The link as a preview names it: parsed, http(s) only, without tracking parameters (`utm_*`, `fbclid`, …). The\n * other parameters keep their order and spelling. Null for anything that is not an http(s) URL.\n */\nexport function canonicalUrl(link: string): string | null {\n if (link.length > LINK_PREVIEW_LIMITS.urlChars * 2) return null;\n let url: URL;\n try { url = new URL(link); } catch { return null; }\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") return null;\n if (url.username || url.password) return null;\n const kept = url.search.slice(1).split(\"&\").filter(pair => {\n if (!pair) return false;\n const name = pair.split(\"=\")[0];\n let decoded = name;\n try { decoded = decodeURIComponent(name.replace(/\\+/g, \" \")); } catch { /* the name as written */ }\n return !isTracking(decoded);\n });\n url.search = kept.length ? `?${kept.join(\"&\")}` : \"\";\n const out = url.href;\n return out.length <= LINK_PREVIEW_LIMITS.urlChars ? out : null;\n}\n\n/** Text as a preview carries it: one line, control characters out, cut at `max` characters. */\nfunction clip(value: unknown, max: number): string | undefined {\n if (typeof value !== \"string\") return undefined;\n // eslint-disable-next-line no-control-regex\n const clean = value.replace(/[\\u0000-\\u001f\\u007f-\\u009f‎‏‪-‮⁦-⁩]+/g, \" \").replace(/\\s+/g, \" \").trim();\n if (!clean) return undefined;\n return clean.length > max ? `${clean.slice(0, max - 1).trimEnd()}…` : clean;\n}\n\n/**\n * A thumbnail's size in pixels, from its JPEG header: a card keeps its box before the picture decodes. Undefined for\n * anything but a JPEG data URL within the limits.\n */\nexport function previewImageSize(value: unknown): { width: number; height: number } | undefined {\n if (typeof value !== \"string\" || !value.startsWith(JPEG_PREFIX)) return;\n const data = value.slice(JPEG_PREFIX.length);\n if (data.length > Math.ceil(LINK_PREVIEW_LIMITS.imageBytes / 3) * 4 || data.length % 4 !== 0 || !/^[A-Za-z0-9+/]+={0,2}$/.test(data)) return;\n let binary: string;\n try { binary = atob(data); } catch { return; }\n if (binary.length > LINK_PREVIEW_LIMITS.imageBytes) return;\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);\n return jpegSize(bytes);\n}\n\n/** The thumbnail if it is one Ghostly shows: a JPEG data URL within the limits whose header declares a sane size. */\nexport function sanitizePreviewImage(value: unknown): string | undefined {\n const size = previewImageSize(value);\n const side = LINK_PREVIEW_LIMITS.imageSide;\n if (!size || size.width < 1 || size.height < 1 || size.width > side || size.height > side) return;\n return value as string;\n}\n\n/**\n * A preview as a message may carry it, or undefined. `text` is the message's: the preview must be of one of its\n * links (compared without tracking parameters), so a card can never point somewhere the text does not. Titles and\n * descriptions are cut to their limits; a bad thumbnail is dropped and the rest kept.\n */\nexport function parseLinkPreview(raw: unknown, text: string): LinkPreview | undefined {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return;\n const value = raw as Record<string, unknown>;\n if (typeof value.u !== \"string\") return;\n const u = canonicalUrl(value.u);\n if (!u || !linksIn(text).some(link => canonicalUrl(link) === u)) return;\n const preview: LinkPreview = { u };\n const t = clip(value.t, LINK_PREVIEW_LIMITS.titleChars), d = clip(value.d, LINK_PREVIEW_LIMITS.descriptionChars);\n const s = clip(value.s, LINK_PREVIEW_LIMITS.siteChars), i = sanitizePreviewImage(value.i);\n if (t) preview.t = t;\n if (d) preview.d = d;\n if (s) preview.s = s;\n if (i) preview.i = i;\n // A card with nothing but the link says no more than the link does.\n if (!t && !d && !i) return;\n if (JSON.stringify(preview).length > LINK_PREVIEW_LIMITS.jsonChars) return;\n return preview;\n}\n"],"mappings":";;;;;;;AAOA,IAAa,oBAAoB;AAGjC,IAAM,SAAS;;AAGf,SAAgB,SAAS,OAAkE;CACzF,IAAI,MAAM,SAAS,KAAK,MAAM,OAAO,OA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iB,KAAK;CACnC,MAAM,OAAO,oBAAoB;CACjC,IAAI,CAAC,QAAQ,KAAK,QAAQ,KAAK,KAAK,SAAS,KAAK,KAAK,QAAQ,QAAQ,KAAK,SAAS,MAAM;CAC3F,OAAO;AACT;;;;;;AAOA,SAAgB,iBAAiB,KAAc,MAAuC;CACpF,IAAI,CAAC,OAAO,OAAO,QAAQ,YAAY,MAAM,QAAQ,GAAG,GAAG;CAC3D,MAAM,QAAQ;CACd,IAAI,OAAO,MAAM,MAAM,UAAU;CACjC,MAAM,IAAI,aAAa,MAAM,CAAC;CAC9B,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,CAAC,MAAK,SAAQ,aAAa,IAAI,MAAM,CAAC,GAAG;CACjE,MAAM,UAAuB,EAAE,EAAE;CACjC,MAAM,IAAI,KAAK,MAAM,GAAG,oBAAoB,UAAU,GAAG,IAAI,KAAK,MAAM,GAAG,oBAAoB,gBAAgB;CAC/G,MAAM,IAAI,KAAK,MAAM,GAAG,oBAAoB,SAAS,GAAG,IAAI,qBAAqB,MAAM,CAAC;CACxF,IAAI,GAAG,QAAQ,IAAI;CACnB,IAAI,GAAG,QAAQ,IAAI;CACnB,IAAI,GAAG,QAAQ,IAAI;CACnB,IAAI,GAAG,QAAQ,IAAI;CAEnB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG;CACpB,IAAI,KAAK,UAAU,OAAO,CAAC,CAAC,SAAS,oBAAoB,WAAW;CACpE,OAAO;AACT"}
@@ -1,19 +1,20 @@
1
1
  import { a as secretValue, i as localFileError, n as EXIT, o as shownValue, r as asCliError, t as CliError } from "./errors-JVJsO8Iu.js";
2
- import { a as endedUnsent, i as endedUnanswered, o as isNotTheDaemon, p as CALL_RATES, r as connectDaemon, s as notTheDaemon, t as DaemonClient, y as isCallRate } from "./client-B7jRrSnb.js";
2
+ import { a as endedUnsent, i as endedUnanswered, o as isNotTheDaemon, p as CALL_RATES, r as connectDaemon, s as notTheDaemon, t as DaemonClient, y as isCallRate } from "./client-BtPhfWjK.js";
3
3
  import { n as dropSecretEnv, t as childEnv } from "./childEnv-C-99hdbL.js";
4
- import { $n as reactionEmoji, O as GROUP_FILE_LIMITS, On as VOICE_LIMITS, Tr as cardUrl, _r as RUN_RESULTS, fr as CRON_LINE, gr as ROUTINE_STATES, hr as PR_STATES, kr as statusCardBytes, mr as PR_CHECKS, pr as ITEM_STATES, vr as STATUS_CARD_LIMITS, wr as cardLine, xt as STATUS_AVAILABILITIES, yr as TASK_STATUSES } from "./groupMeta--fxSh792.js";
5
- import { S as userPath, _ as profileExists, b as startingDaemon, c as createProfile, d as daemonClaim, f as ghostlyHome, g as noProfile, i as checkProfileName, l as currentProfile, m as lockOwner, o as checkShownNameOption, p as listProfiles, s as claimForDaemon, u as currentProfileOrNone, v as profilePaths, w as ownProfile, y as selectProfile } from "./profiles-B2uy04ph.js";
6
- import { _ as hideSecretFields, a as PAY_METHODS, c as turnRef, d as ENGINE_METHODS, f as ENGINE_PARAMS, h as SECRET_RESULTS, i as CHAT_METHODS, m as READ_PARAMS, o as TRANSPORT_NAMES, p as ENGINE_READS, r as ADDRESS_TYPES, s as WALLET_TYPES, t as checkOwnStatus } from "./ownStatus-Bc08eNJY.js";
7
- import { B as shellWord, V as jsonOut, a as contactKeyOf, b as namedByThem, y as nameKey } from "./apiKit-nLK4jeTq.js";
8
- import { c as waitsFor, o as longTextChat, r as dhtOnlyNotice, s as waitNotice } from "./waitNotice-Cvz5CiKR.js";
4
+ import { $n as reactionEmoji, O as GROUP_FILE_LIMITS, On as VOICE_LIMITS, Tr as cardUrl, _r as RUN_RESULTS, fr as CRON_LINE, gr as ROUTINE_STATES, hr as PR_STATES, kr as statusCardBytes, mr as PR_CHECKS, pr as ITEM_STATES, vr as STATUS_CARD_LIMITS, wr as cardLine, xt as STATUS_AVAILABILITIES, yr as TASK_STATUSES } from "./groupMeta-Cz95F6sX.js";
5
+ import { S as userPath, T as ownProfile, _ as profileExists, b as startingDaemon, c as createProfile, d as daemonClaim, f as ghostlyHome, g as noProfile, i as checkProfileName, l as currentProfile, m as lockOwner, o as checkShownNameOption, p as listProfiles, s as claimForDaemon, u as currentProfileOrNone, v as profilePaths, y as selectProfile } from "./profiles-BAJf0c9E.js";
6
+ import { _ as hideSecretFields, a as PAY_METHODS, c as turnRef, d as ENGINE_METHODS, f as ENGINE_PARAMS, h as SECRET_RESULTS, i as CHAT_METHODS, m as READ_PARAMS, o as TRANSPORT_NAMES, p as ENGINE_READS, r as ADDRESS_TYPES, s as WALLET_TYPES, t as checkOwnStatus } from "./ownStatus-DjD0sQKF.js";
7
+ import { G as jsonOut, W as shellWord, a as contactKeyOf, b as nameKey, x as namedByThem } from "./apiKit-DAFsWtyk.js";
8
+ import { c as waitsFor, o as longTextChat, r as dhtOnlyNotice, s as waitNotice } from "./waitNotice-mB0Ym145.js";
9
9
  import { spawn } from "node:child_process";
10
10
  import { accessSync, closeSync, constants, existsSync, fstatSync, openSync, readFileSync, readSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
11
11
  import { dirname, resolve, sep } from "node:path";
12
+ import { randomUUID } from "node:crypto";
12
13
  import { connect } from "node:net";
13
14
  import { format } from "node:util";
14
15
  var package_default = {
15
16
  name: "@ghostlytools/cli",
16
- version: "1.13.1",
17
+ version: "1.13.3",
17
18
  type: "module",
18
19
  description: "Ghostly for bots and terminals: the app's own engine, headless on Node, behind a daemon and a `ghostly` command with JSON output.",
19
20
  license: "MIT",
@@ -1210,7 +1211,7 @@ var commands$8 = {
1210
1211
  description: "Replace the three files when they are there"
1211
1212
  }
1212
1213
  },
1213
- run: async ({ options }, a) => (await import("./apps-nLtyhC2f.js")).initApp(a.dir, {
1214
+ run: async ({ options }, a) => (await import("./apps-D4KRpZB4.js")).initApp(a.dir, {
1214
1215
  name: options.name,
1215
1216
  title: options.title,
1216
1217
  force: options.force === true
@@ -1250,7 +1251,7 @@ var commands$8 = {
1250
1251
  description: "This version's sequence, higher than the bundle at --out's (default: one more than it)"
1251
1252
  }
1252
1253
  },
1253
- run: async ({ options }, a) => (await import("./apps-nLtyhC2f.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
1254
+ run: async ({ options }, a) => (await import("./apps-D4KRpZB4.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
1254
1255
  },
1255
1256
  "app revoke": {
1256
1257
  method: "app.revoke",
@@ -1283,7 +1284,7 @@ var commands$8 = {
1283
1284
  description: "Allow --up-to past the bundle's own sequence (versions published from elsewhere), and a --reason that looks like a seed, a key or ecash"
1284
1285
  }
1285
1286
  },
1286
- run: async ({ options }, a) => (await import("./apps-nLtyhC2f.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>] [--bundle <file>] [--force]"), {
1287
+ run: async ({ options }, a) => (await import("./apps-D4KRpZB4.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>] [--bundle <file>] [--force]"), {
1287
1288
  digests: options.digest,
1288
1289
  upTo: options["up-to"],
1289
1290
  reason: options.reason,
@@ -1344,7 +1345,7 @@ var commands$8 = {
1344
1345
  usage: "app verify <bundle|url>",
1345
1346
  summary: "Check a .ghostlyapp as a client would, from a file or an https URL: its manifest and digest, or refused (exit 1) with the reason, revoked when the ghostly-revoke.json beside it (for a URL, or beside one of its sources) revokes this version",
1346
1347
  args: ["bundle"],
1347
- run: async (_, a) => (await import("./apps-nLtyhC2f.js")).verifyApp(a.bundle)
1348
+ run: async (_, a) => (await import("./apps-D4KRpZB4.js")).verifyApp(a.bundle)
1348
1349
  },
1349
1350
  "store sign": {
1350
1351
  method: "store.sign",
@@ -1361,7 +1362,7 @@ var commands$8 = {
1361
1362
  description: "The folder to write ghostly-store.json and ghostly-store.sig in (default: the index's)"
1362
1363
  }
1363
1364
  },
1364
- run: async ({ options }, a) => (await import("./apps-nLtyhC2f.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
1365
+ run: async ({ options }, a) => (await import("./apps-D4KRpZB4.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
1365
1366
  }
1366
1367
  };
1367
1368
  // src/commands/calls.ts
@@ -2148,7 +2149,7 @@ var commands$5 = {
2148
2149
  "file resend": {
2149
2150
  method: "file.action",
2150
2151
  usage: "file resend [<chat>] <file>",
2151
- summary: "Send again a file that stopped moving or failed: it goes on from what the contact holds",
2152
+ summary: "Send again a file that stopped moving or failed: it goes on from what the contact holds (not one cancelled or declined: file send it again)",
2152
2153
  args: ["chat?", "file"],
2153
2154
  params: (_, a) => ({
2154
2155
  chat: a.chat,
@@ -2473,7 +2474,7 @@ var commands$3 = {
2473
2474
  "group create": {
2474
2475
  method: "group.create",
2475
2476
  usage: "group create <name...> [--mesh] [--force]",
2476
- summary: "A community (a link anyone can open) or, with --mesh, a private group of up to 32",
2477
+ summary: "A community (anyone who has its link can join) or, with --mesh, a private group of up to 32",
2477
2478
  args: ["name..."],
2478
2479
  options: {
2479
2480
  mesh: {
@@ -2606,7 +2607,7 @@ var commands$3 = {
2606
2607
  "group link": {
2607
2608
  method: "group.link",
2608
2609
  usage: "group link <group> [--off] [--reset]",
2609
- summary: "Turn the group's link on (--reset: a new one), or --off",
2610
+ summary: "Print the group's link (anyone who has it can join); --reset: a new one, the old one stops working; --off",
2610
2611
  args: ["group"],
2611
2612
  options: {
2612
2613
  off: {
@@ -3042,7 +3043,7 @@ var commands$1 = {
3042
3043
  "pay": {
3043
3044
  method: "pay",
3044
3045
  usage: "pay <invoice|lightning-address|lnurl> [--amount sats] [--network n] [--max-fee sats] [--card <id>] [--comment t] [--chat <chat>] [--confirm-real] [--force]",
3045
- summary: "Pay over Lightning from Testnet, or --network mainnet with --confirm-real",
3046
+ summary: "Pay over Lightning from Testnet, or --network mainnet with --confirm-real. paid false: not settled yet (pending at the mint or the card's source, or its answer lost); it settles by itself, is never paid twice, and its note says what is set aside and where to look",
3046
3047
  args: ["target"],
3047
3048
  options: {
3048
3049
  amount: {
@@ -3227,7 +3228,7 @@ var commands$1 = {
3227
3228
  "wallet redeem": {
3228
3229
  method: "wallet.redeem",
3229
3230
  usage: "wallet redeem [<cashu-token> | -]",
3230
- summary: "Take the ecash of a Cashu token (its mint must be one of yours); the token on stdin keeps it out of ps",
3231
+ summary: "Take the ecash of a Cashu token (its mint must be one of yours: wallet add-mint <url>); the token on stdin keeps it out of ps",
3231
3232
  args: ["token?"],
3232
3233
  params: (_, { token }) => ({ token })
3233
3234
  },
@@ -3279,7 +3280,7 @@ var commands = {
3279
3280
  "service enable": {
3280
3281
  method: "service.enable",
3281
3282
  usage: "service enable <service> [--off]",
3282
- summary: "Turn a shared app on or off",
3283
+ summary: "Turn a shared app on or off; <service> is its id, as service add and service list show it",
3283
3284
  args: ["service"],
3284
3285
  options: { off: {
3285
3286
  type: "boolean",
@@ -3320,14 +3321,14 @@ var commands = {
3320
3321
  "service remove": {
3321
3322
  method: "service.remove",
3322
3323
  usage: "service remove <service>",
3323
- summary: "Stop sharing a web app with anyone",
3324
+ summary: "Stop sharing a web app with anyone; <service> is its id, as service add and service list show it",
3324
3325
  args: ["service"],
3325
3326
  params: (_, a) => ({ service: a.service })
3326
3327
  },
3327
3328
  "service share": {
3328
3329
  method: "service.share",
3329
3330
  usage: "service share <service> <chat> [--off]",
3330
- summary: "Give (or take back) a contact access to a web app",
3331
+ summary: "Give (or take back) a contact access to a web app; <service> is its id, as service add and service list show it",
3331
3332
  args: ["service", "chat"],
3332
3333
  options: { off: {
3333
3334
  type: "boolean",
@@ -3566,6 +3567,22 @@ function positionals(command, values) {
3566
3567
  function noMoreThan(count, values, usage) {
3567
3568
  if (values.length > count) throw strayValue(values) ?? new CliError("usage", `Too many arguments: ghostly ${usage}`);
3568
3569
  }
3570
+ // src/identityWait.ts
3571
+ /**
3572
+ * What `identity add` writes on stderr while an in-app signer waits: only the events of its own call (`request`, the
3573
+ * id it gave `identity.add`), never another proof's waiting on the same daemon. On a terminal in words, as every
3574
+ * other wait (`ghostly: …`), the link or code on its own line; on a pipe the event's JSON line.
3575
+ */
3576
+ function identityWaitLines(event, request, terminal) {
3577
+ if (event.type !== "identity.approval" && event.type !== "identity.progress" || event.request !== request) return "";
3578
+ if (!terminal) return JSON.stringify(event) + "\n";
3579
+ if (event.type === "identity.progress") return `ghostly: ${String(event.message)}\n`;
3580
+ const lines = [];
3581
+ if (typeof event.url === "string") lines.push("ghostly: Approve the request at this link:", event.url);
3582
+ if (typeof event.qr === "string") lines.push(`ghostly: Approve the request with this code${typeof event.label === "string" ? ` (${event.label.replace(/^Or (\w)/, (_, c) => c.toUpperCase())})` : ""}:`, event.qr);
3583
+ for (const note of Array.isArray(event.notes) ? event.notes : []) lines.push(`ghostly: ${String(note)}`);
3584
+ return lines.map((line) => line + "\n").join("");
3585
+ }
3569
3586
  // src/listen.ts
3570
3587
  /** The cursor's own write failed, not the event's handling. */
3571
3588
  var CursorError = class extends Error {
@@ -3746,7 +3763,7 @@ function checkWebhook(url, from = "--webhook") {
3746
3763
  }
3747
3764
  /**
3748
3765
  * The event number a cursor file holds, or undefined when there is no file (a first start: live events). A file that is
3749
- * there and holds no whole number (empty, half-written, edited by hand) is refused, naming the file and what it holds:
3766
+ * there and holds no whole number (empty, half-written, edited by hand) is refused, naming the file and how much it holds:
3750
3767
  * taken as no cursor, the listener started at the journal's end and skipped every event since the last one handled,
3751
3768
  * without a word, and its next write replaced the file.
3752
3769
  */
@@ -3761,7 +3778,8 @@ function readCursor(path) {
3761
3778
  const trimmed = text.trim();
3762
3779
  const value = trimmed === "" ? NaN : Number(trimmed);
3763
3780
  if (Number.isSafeInteger(value) && value >= 0 && /^\d+$/.test(trimmed)) return value;
3764
- const shown = trimmed === "" ? "nothing" : JSON.stringify(trimmed.length > 32 ? `${trimmed.slice(0, 32)}…` : trimmed);
3781
+ const words = trimmed.split(/\s+/).length, bytes = Buffer.byteLength(trimmed);
3782
+ const shown = trimmed === "" ? "nothing" : `${words} ${words === 1 ? "word" : "words"}, ${bytes} ${bytes === 1 ? "byte" : "bytes"}`;
3765
3783
  throw new CliError("bad_request", `${path} holds no event number (${shown}): fix or remove it, or give --since`);
3766
3784
  }
3767
3785
  /**
@@ -3986,6 +4004,14 @@ function runExec(command, event, toStderr, profile) {
3986
4004
  /** The longest wait between two tries of a webhook that is not answering. */
3987
4005
  var RETRY_MAX_MS = 6e4;
3988
4006
  /**
4007
+ * The TLS error a failed post met, as Node names it (`DEPTH_ZERO_SELF_SIGNED_CERT`, `ERR_SSL_WRONG_VERSION_NUMBER` for
4008
+ * https:// to a plain http server), or null for any other failure.
4009
+ */
4010
+ function tlsFailure(error) {
4011
+ const code = error?.cause?.code;
4012
+ return typeof code === "string" && /^ERR_(SSL|TLS)_|CERT|SELF_SIGNED|UNABLE_TO_/.test(code) ? code : null;
4013
+ }
4014
+ /**
3989
4015
  * Posts one event; resolves true once the bridge took it, or the status it refused it with (a 4xx or a redirect, posted
3990
4016
  * once: before, three times with backoff, three refusals in the bridge's log for an event stderr said was not tried again).
3991
4017
  * A bridge that is not there (refused connection, timeout, 5xx, 408, 429) has not handled the event: it is tried again,
@@ -3995,7 +4021,7 @@ var RETRY_MAX_MS = 6e4;
3995
4021
  async function post(url, event, retryMs) {
3996
4022
  let wait = retryMs, holding = false;
3997
4023
  for (let attempt = 0;; attempt++) {
3998
- let down = true, status = 0;
4024
+ let down = true, status = 0, tls = null;
3999
4025
  try {
4000
4026
  const response = await fetch(url, {
4001
4027
  method: "POST",
@@ -4015,11 +4041,13 @@ async function post(url, event, retryMs) {
4015
4041
  }
4016
4042
  status = response.status;
4017
4043
  down = status >= 500 || status === 408 || status === 429;
4018
- } catch {}
4044
+ } catch (error) {
4045
+ tls = tlsFailure(error);
4046
+ }
4019
4047
  if (!down) return status;
4020
4048
  if (down && attempt >= 2 && !holding) {
4021
4049
  holding = true;
4022
- process.stderr.write(`ghostly: the webhook at ${url.origin} is not answering: holding event ${event.seq} (${event.type}) until it does\n`);
4050
+ process.stderr.write(tls ? `ghostly: the webhook at ${url.origin} failed TLS (${tls}): holding event ${event.seq} (${event.type}) until it passes; on this machine give it as http://, or restart listen with NODE_EXTRA_CA_CERTS set to the file of the certificate that signed the bridge's\n` : `ghostly: the webhook at ${url.origin} is not answering: holding event ${event.seq} (${event.type}) until it does\n`);
4023
4051
  }
4024
4052
  await new Promise((resolve) => setTimeout(resolve, wait));
4025
4053
  wait = Math.min(wait * 2, RETRY_MAX_MS);
@@ -4118,7 +4146,8 @@ function eventHandler(options) {
4118
4146
  return;
4119
4147
  }
4120
4148
  hook.stopped = true;
4121
- process.stderr.write(`ghostly: stopped while --exec ran on event ${hook.event.seq} (${hook.event.type}): ended it, and the event is handed again at the next start\n`);
4149
+ const { seq, type } = hook.event;
4150
+ process.stderr.write(options.cursor ? `ghostly: stopped while --exec ran on event ${seq} (${type}): ended it, and the event is handed again at the next start\n` : `ghostly: stopped while --exec ran on event ${seq} (${type}): ended it; with no --cursor it is not handed again (start with --since ${seq - 1} to run it again)\n`);
4122
4151
  hook.signal("SIGTERM");
4123
4152
  if (!await within(hook.ended, stopMs)) {
4124
4153
  hook.signal("SIGKILL");
@@ -4473,15 +4502,15 @@ var VERSION = package_default.version;
4473
4502
  * command a running daemon answers loads none of them, and starts about as fast as Node does. Statically imported, they
4474
4503
  * cost every command ~100 ms before its socket was opened.
4475
4504
  */
4476
- var engineApi = () => import("./api-DF36rBJK.js");
4477
- var engineHost = () => import("./host-CGzVFfMz.js");
4505
+ var engineApi = () => import("./api-DO0YMLiB.js");
4506
+ var engineHost = () => import("./host-BsBWxTtW.js");
4478
4507
  /**
4479
4508
  * `--translate <lang>`'s translator, or null (not asked; or the runtime is not there, said on stderr). Loaded only when
4480
4509
  * asked: the app's message parser it reads costs every other command nothing.
4481
4510
  */
4482
4511
  async function translatorFor(value, home) {
4483
4512
  if (value === void 0) return null;
4484
- const { loadDetector, openTranslator, translateTarget } = await import("./translate-CHj_PdLg.js");
4513
+ const { loadDetector, openTranslator, translateTarget } = await import("./translate-DnuQMfj0.js");
4485
4514
  return openTranslator({
4486
4515
  home,
4487
4516
  to: translateTarget(value),
@@ -4664,7 +4693,8 @@ function oneGroupOnly(method) {
4664
4693
  * payments), none from a chat's history: `wallet list` took 1.3 s and 239 MB instead of 0.48 s and 146 MB with 50,000
4665
4694
  * messages; `payment list --chat` starts the chat it names. `identity providers` reads nothing of the profile, and
4666
4695
  * `call auto` and `group auto` with no on|off what it keeps: each took 1.6 s and 211 MB instead of 0.8 s and 152 MB
4667
- * with 50,000.
4696
+ * with 50,000. `saved list` reads each saved row by its key, a quoted original by its id and the contact's name from
4697
+ * the chat's record: 1.2 s instead of 0.7 s with 30,000 messages, nothing saved.
4668
4698
  */
4669
4699
  var NO_HISTORY_READS = /* @__PURE__ */ new Set([
4670
4700
  "status",
@@ -4683,13 +4713,17 @@ var NO_HISTORY_READS = /* @__PURE__ */ new Set([
4683
4713
  "wallet.list",
4684
4714
  "wallet.history",
4685
4715
  "payment.list",
4686
- "identity.providers"
4716
+ "identity.providers",
4717
+ "saved.list"
4687
4718
  ]);
4688
4719
  /**
4689
4720
  * Changes kept outside any chat (this profile's status, which each chat says on its next session; x401 keys and
4690
4721
  * credentials; a service; a draft; a served app), and `call answer` and `call flush`, which a one-shot refuses whatever
4691
4722
  * the chats say: a one-shot for one leaves every saved chat unstarted too. Each read every 1:1 chat whole first: with
4692
- * 30,000 messages in the profile, about 0.95 s and 200 MB instead of 0.45 s and 140 MB.
4723
+ * 30,000 messages in the profile, about 0.95 s and 200 MB instead of 0.45 s and 140 MB. The wallet's own stores too (an
4724
+ * address, a Lightning card's name or default, a wallet removed): each started every chat, 20 relay requests and 0.35 s
4725
+ * more with 10 chats and 30,000 messages, a refusal too. A removal tells a contact of a request it closes only on a chat
4726
+ * that is open; one away hears when their chat opens.
4693
4727
  */
4694
4728
  var NO_HISTORY_WRITES = /* @__PURE__ */ new Set([
4695
4729
  "status.set",
@@ -4702,7 +4736,11 @@ var NO_HISTORY_WRITES = /* @__PURE__ */ new Set([
4702
4736
  "app.serve",
4703
4737
  "app.unserve",
4704
4738
  "call.answer",
4705
- "call.flush"
4739
+ "call.flush",
4740
+ "wallet.address",
4741
+ "lightning.rename",
4742
+ "lightning.default",
4743
+ "wallet.remove"
4706
4744
  ]);
4707
4745
  /** Whether a one-shot for this call leaves every saved chat unstarted, its history unread (`NO_HISTORY_READS`, `NO_HISTORY_WRITES`). */
4708
4746
  function readsNoHistory(method, params = {}) {
@@ -4771,6 +4809,8 @@ var LOCAL_WRITES = /* @__PURE__ */ new Set([
4771
4809
  "saved.remove",
4772
4810
  "app.serve",
4773
4811
  "app.unserve",
4812
+ "lightning.rename",
4813
+ "lightning.default",
4774
4814
  "status.set",
4775
4815
  "status.clear"
4776
4816
  ]);
@@ -4821,13 +4861,18 @@ function answerWithin(method, params) {
4821
4861
  if (waits !== void 0) return (waits + 10) * 1e3;
4822
4862
  if (readOnly(method, params)) return ANSWER_MS;
4823
4863
  }
4824
- /** `again`: whether a read the daemon left unanswered as it stopped is asked once more (`throughDaemon`). */
4825
- async function session(g, options, again = true) {
4864
+ /**
4865
+ * `again`: whether a read the daemon left unanswered as it stopped is asked once more (`throughDaemon`). `first`: the
4866
+ * call a one-shot makes, whose own words are checked before the profile opens (api.ts `refuseBeforeStart`): a malformed
4867
+ * one opened it online and started every saved chat to be refused (with 10 chats, 20 relay requests and 0.4 s more).
4868
+ */
4869
+ async function session(g, options, again = true, first) {
4826
4870
  requireProfile(g);
4827
4871
  const anew = again ? () => session(g, options, false) : void 0;
4828
4872
  const client = await connectDaemon(g.paths);
4829
4873
  if (client) return throughDaemon(client, anew);
4830
- const [, { callApi, startNamedChats }] = await Promise.all([engineHost(), engineApi()]);
4874
+ const [, { callApi, refuseBeforeStart, startNamedChats }] = await Promise.all([engineHost(), engineApi()]);
4875
+ if (first) await refuseBeforeStart(first.method, first.params);
4831
4876
  const host = await openOneShot(g, options);
4832
4877
  if (host instanceof DaemonClient) return throughDaemon(host, anew);
4833
4878
  const call = async (m, p) => {
@@ -4972,8 +5017,8 @@ async function openOneShot(g, options = {}, mode = "one-shot") {
4972
5017
  * nothing of the groups, `deferChats` too when it names that chat or makes or joins a new one (`oneChatOnly`), `offline`
4973
5018
  * when it only reads or changes only this device (`offlineCall`).
4974
5019
  */
4975
- async function withSession(g, work, options = {}) {
4976
- const s = await session(g, options);
5020
+ async function withSession(g, work, options = {}, first) {
5021
+ const s = await session(g, options, true, first);
4977
5022
  const stops = interruptible(s);
4978
5023
  try {
4979
5024
  return await stops.run(work);
@@ -5193,7 +5238,7 @@ var SPECIAL = [
5193
5238
  ],
5194
5239
  [
5195
5240
  "settings set <key> <json-value> [--force]",
5196
- "Change one: relays, irohRelays, hyperdhtRelay, iceServers, publicProfiles, online, shareProfile, sendTyping, autoDownloads, serveFiles, daemonPresence, nick. daemonPresence true: contacts see this profile online while a daemon runs it (off by default). <json-value> - (or none, piped) reads it from stdin: a TURN password stays out of ps",
5241
+ "Change one: relays, irohRelays, hyperdhtRelay, iceServers, publicProfiles, online, shareProfile, sendTyping, autoDownloads, serveFiles, daemonPresence, nick. daemonPresence true: contacts see this profile online while a daemon runs it (off by default). hyperdhtRelay is kept for the apps: this CLI's own HyperDHT does not dial through it. <json-value> - (or none, piped) reads it from stdin: a TURN password stays out of ps",
5197
5242
  { force: o("boolean", "Set a nick even if it looks like a seed, a key or ecash") }
5198
5243
  ],
5199
5244
  [
@@ -5586,7 +5631,7 @@ async function profileCommand(sub, argv) {
5586
5631
  if (!given || !name) throw new CliError("usage", `Missing <${given ? "new profile" : "file"}>: ghostly profile restore <file> <new profile> [--passphrase-file f] [--use]`);
5587
5632
  noMoreThan(2, parsed.positionals, "profile restore <file> <new profile> [--passphrase-file f] [--use]");
5588
5633
  const file = here(given);
5589
- const { backupFileProtection, restoreProfile } = await import("./backup-D6s0LQdg.js");
5634
+ const { backupFileProtection, restoreProfile } = await import("./backup-BeXBtbVL.js");
5590
5635
  const protection = await backupFileProtection(file);
5591
5636
  const paths = await restoreProfile(g.home, checkProfileName(name), file, protection === "none" ? void 0 : await backupPassphrase(parsed.options["passphrase-file"], RESTORE_PASSPHRASE));
5592
5637
  if (parsed.options.use) selectProfile(g.home, name);
@@ -6259,13 +6304,14 @@ async function listenCommand(argv) {
6259
6304
  };
6260
6305
  onStopSignals(stop);
6261
6306
  onReaderGone(stop);
6262
- let off = null, left = [];
6307
+ let off = null, left = [], gap;
6263
6308
  const open = (from) => {
6264
6309
  for (;;) {
6265
- const events = left.length ? left : host.ctx.hub.replay(from ?? host.ctx.hub.lastSeq);
6310
+ const events = (left.length ? left : host.ctx.hub.replay(from ?? host.ctx.hub.lastSeq)).filter((e) => e.type !== "events.gap" || e.id !== gap);
6266
6311
  left = [];
6267
6312
  if (!events.length) break;
6268
6313
  for (let i = 0; i < events.length; i++) {
6314
+ if (events[i].type === "events.gap") gap = events[i].id;
6269
6315
  feed.take(events[i]);
6270
6316
  if (feed.paused) {
6271
6317
  left = events.slice(i + 1);
@@ -6433,7 +6479,7 @@ async function textCommand(name, argv) {
6433
6479
  };
6434
6480
  if (spec.target === "group") params.mentions = parsed.options.mention ?? [];
6435
6481
  if (parsed.options.reply !== void 0) params.reply = parsed.options.reply;
6436
- if (!spec.message) Object.assign(params, (await import("./buttons-DaY5FYlV.js")).buttonsOf(parsed.options));
6482
+ if (!spec.message) Object.assign(params, (await import("./buttons-_5Fw8uHn.js")).buttonsOf(parsed.options));
6437
6483
  print(await withSession(g, (s) => {
6438
6484
  if (parsed.options.wait !== void 0) params.wait = parsed.options.wait;
6439
6485
  if (parsed.options.timeout !== void 0) params.timeout = parsed.options.timeout;
@@ -6477,20 +6523,23 @@ async function identityAddCommand(argv) {
6477
6523
  if (!provider) throw new CliError("usage", "Missing <provider>: ghostly identity add <provider> [subject] [--signer id] [--field name=value]... [--stdin] [--days n] [--timeout s]");
6478
6524
  inRange(parsed.options, "timeout", "a number of seconds", 5, 3600);
6479
6525
  const items = parsed.options.field ?? [];
6480
- const known = parsed.options.days !== void 0 || items.length ? (await import("./registry-bLIfG619.js")).IDENTITY_PROVIDERS.find((p) => p.id === provider) : void 0;
6526
+ const known = parsed.options.days !== void 0 || items.length ? (await import("./registry-CHwHTWbK.js")).IDENTITY_PROVIDERS.find((p) => p.id === provider) : void 0;
6481
6527
  if (known && parsed.options.days !== void 0) inRange(parsed.options, "days", "a whole number", 1, known.validity.maxDays, true);
6482
6528
  const { fields, warning } = await identityFields(items, parsed.options.stdin === true, identitySecretFields(known, parsed.options.signer), readStdin, process.stdin.isTTY === true);
6483
6529
  if (warning) process.stderr.write(`ghostly: ${warning}\n`);
6530
+ const request = randomUUID();
6484
6531
  const params = {
6485
6532
  provider,
6486
6533
  subject: subject.join(" ") || void 0,
6487
6534
  signer: parsed.options.signer,
6488
6535
  fields,
6489
6536
  days: parsed.options.days,
6490
- timeout: parsed.options.timeout
6537
+ timeout: parsed.options.timeout,
6538
+ request
6491
6539
  };
6492
6540
  const tell = (event) => {
6493
- if (event.type === "identity.approval" || event.type === "identity.progress") process.stderr.write(JSON.stringify(event) + "\n");
6541
+ const lines = identityWaitLines(event, request, process.stderr.isTTY === true);
6542
+ if (lines) process.stderr.write(lines);
6494
6543
  };
6495
6544
  const addThroughDaemon = async (client) => {
6496
6545
  await warnVersion(client);
@@ -6509,7 +6558,8 @@ async function identityAddCommand(argv) {
6509
6558
  await addThroughDaemon(client);
6510
6559
  return;
6511
6560
  }
6512
- const [, { callApi }] = await Promise.all([engineHost(), engineApi()]);
6561
+ const [, { callApi, identityProvider }] = await Promise.all([engineHost(), engineApi()]);
6562
+ identityProvider(provider);
6513
6563
  const host = await openOneShot(g);
6514
6564
  if (host instanceof DaemonClient) {
6515
6565
  await addThroughDaemon(host);
@@ -6584,10 +6634,13 @@ async function tableCommand(name, argv) {
6584
6634
  deferGroups: chatOnly(command.method, params) || newChatOnly(command.method),
6585
6635
  deferChats: oneChatOnly(command.method, params) || oneGroupOnly(command.method) || readsNoHistory(command.method, params),
6586
6636
  offline: offlineCall(command.method, params)
6637
+ }, {
6638
+ method: command.method,
6639
+ params
6587
6640
  });
6588
6641
  if (translator) {
6589
6642
  try {
6590
- printAnswer(await (await import("./translate-CHj_PdLg.js")).translateAnswer(result, translator));
6643
+ printAnswer(await (await import("./translate-DnuQMfj0.js")).translateAnswer(result, translator));
6591
6644
  } finally {
6592
6645
  translator.close();
6593
6646
  }
@@ -6775,6 +6828,23 @@ async function main(input) {
6775
6828
  throw unknownCommand(first, two ? second : void 0, three ? third : void 0);
6776
6829
  }
6777
6830
  /**
6831
+ * The app's words for a message action, and the command that does it here: someone coming from the app types `reply`
6832
+ * or `unpin` first, and "did you mean react?" for `unreact` added a reaction instead of taking one back.
6833
+ */
6834
+ var APP_WORDS = {
6835
+ "reply": "send <chat> --reply <message>",
6836
+ "unpin": "pin <chat> --remove",
6837
+ "unreact": "react <chat> <message> --remove",
6838
+ "delete": "message delete <chat> <message>",
6839
+ "history": "chat history <chat>",
6840
+ "message edit": "edit <chat> <message>",
6841
+ "message react": "react <chat> <message> <emoji>",
6842
+ "message pin": "pin <chat> <message>",
6843
+ "message forward": "forward <chat> <message> --to <chat>"
6844
+ };
6845
+ /** The app's search (in a chat and in the chat list), which the CLI does not have: `chat history` and jq do it. */
6846
+ var SEARCH = ["search", "chat search"];
6847
+ /**
6778
6848
  * A command line that names no command. The words of a group (`ghostly chat`, `ghostly wallet frob`, `ghostly x401
6779
6849
  * credential`) are answered with the group's commands, as `ghostly help chat` lists them; before, it was only "Unknown
6780
6850
  * command: chat". The longest group the words name answers: `x401 credential frob` lists add, list and remove.
@@ -6786,6 +6856,9 @@ function unknownCommand(first, second, third) {
6786
6856
  second,
6787
6857
  third
6788
6858
  ].filter((word) => !!word);
6859
+ const said = [asked.slice(0, 2).join(" "), asked[0]].find((words) => words !== void 0 && (Object.hasOwn(APP_WORDS, words) || SEARCH.includes(words)));
6860
+ if (said && SEARCH.includes(said)) return new CliError("usage", `Unknown command: ${said} (the CLI has no search yet: ghostly chat history <chat> --limit n | jq …; ghostly help chat history)`);
6861
+ if (said) return new CliError("usage", `Unknown command: ${said} (ghostly ${APP_WORDS[said]}; ghostly help ${commandWords(APP_WORDS[said]).join(" ")})`);
6789
6862
  const all = helpRows().map((row) => commandWords(row.usage));
6790
6863
  const takes = (group) => [...new Set(all.filter((words) => words.length > group.length && group.every((word, i) => words[i] === word)).map((words) => words[group.length]))];
6791
6864
  const meant = (typed, words) => new CliError("usage", `Unknown command: ${typed.join(" ")} (did you mean ${words.join(" ")}? ghostly help ${words.join(" ")})`);
@@ -6839,4 +6912,4 @@ async function run(argv) {
6839
6912
  }
6840
6913
  export { run };
6841
6914
 
6842
- //# sourceMappingURL=main-C8J53SwH.js.map
6915
+ //# sourceMappingURL=main-D48Ben7C.js.map