@ghostlytools/cli 1.13.1 → 1.13.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 (93) hide show
  1. package/README.md +6 -4
  2. package/dist/assets/api-DV52o7A8.js +3 -0
  3. package/dist/assets/{api-Dnq86JAA.js → api-O57SNJcb.js} +375 -77
  4. package/dist/assets/api-O57SNJcb.js.map +1 -0
  5. package/dist/assets/{apiKit-nLK4jeTq.js → apiKit-CPTFJHA7.js} +39 -7
  6. package/dist/assets/{apiKit-nLK4jeTq.js.map → apiKit-CPTFJHA7.js.map} +1 -1
  7. package/dist/assets/{appFetch-wqBWi3Ry.js → appFetch-Ca9DNQQ2.js} +2 -2
  8. package/dist/assets/{appFetch-wqBWi3Ry.js.map → appFetch-Ca9DNQQ2.js.map} +1 -1
  9. package/dist/assets/{apps-DBVhKpfe.js → apps-gXpGFPiv.js} +11 -9
  10. package/dist/assets/apps-gXpGFPiv.js.map +1 -0
  11. package/dist/assets/{apps-nLtyhC2f.js → apps-uZTu5FlR.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-Bczllmzf.js → backup-CxH3auHB.js} +8 -6
  15. package/dist/assets/backup-CxH3auHB.js.map +1 -0
  16. package/dist/assets/{backup-D6s0LQdg.js → backup-Di2U6QVH.js} +1 -1
  17. package/dist/assets/{bitcoind-DML_-Xbv.js → bitcoind-BpZn3bRN.js} +2 -2
  18. package/dist/assets/{bitcoind-DML_-Xbv.js.map → bitcoind-BpZn3bRN.js.map} +1 -1
  19. package/dist/assets/{buttons-B3C3vdhH.js → buttons-D4udKEvT.js} +4 -4
  20. package/dist/assets/{buttons-B3C3vdhH.js.map → buttons-D4udKEvT.js.map} +1 -1
  21. package/dist/assets/buttons-YTYEqvGC.js +1 -0
  22. package/dist/assets/{client-B7jRrSnb.js → client-DGx7E8b3.js} +2 -2
  23. package/dist/assets/{client-B7jRrSnb.js.map → client-DGx7E8b3.js.map} +1 -1
  24. package/dist/assets/{engineErrors--9hfgKlK.js → engineErrors-wWlLy54D.js} +11 -3
  25. package/dist/assets/engineErrors-wWlLy54D.js.map +1 -0
  26. package/dist/assets/{fixedHosts-H3i6o9Iy.js → fixedHosts-CODN2pTL.js} +3 -3
  27. package/dist/assets/{fixedHosts-H3i6o9Iy.js.map → fixedHosts-CODN2pTL.js.map} +1 -1
  28. package/dist/assets/{groupMeta--fxSh792.js → groupMeta-CeZpqVVC.js} +105 -36
  29. package/dist/assets/groupMeta-CeZpqVVC.js.map +1 -0
  30. package/dist/assets/{host-CGzVFfMz.js → host-CRA7h5A2.js} +113 -40
  31. package/dist/assets/host-CRA7h5A2.js.map +1 -0
  32. package/dist/assets/{hyperdhtRelay-Ce-gWsRY.js → hyperdhtRelay-B34Zhz4P.js} +2 -2
  33. package/dist/assets/{hyperdhtRelay-Ce-gWsRY.js.map → hyperdhtRelay-B34Zhz4P.js.map} +1 -1
  34. package/dist/assets/{hyperdhtRelay-B4_wdCtx.js → hyperdhtRelay-DDwU5b4P.js} +2 -2
  35. package/dist/assets/{hyperdhtRelay-B4_wdCtx.js.map → hyperdhtRelay-DDwU5b4P.js.map} +1 -1
  36. package/dist/assets/{identityProofs-Cksc_K7_.js → identityProofs-B8zCp5_0.js} +140 -27
  37. package/dist/assets/identityProofs-B8zCp5_0.js.map +1 -0
  38. package/dist/assets/{irohWeb-Dp1i8v6n.js → irohWeb-mnOi2Jp7.js} +10832 -4832
  39. package/dist/assets/irohWeb-mnOi2Jp7.js.map +1 -0
  40. package/dist/assets/{linkPreview-DdMf-YAc.js → linkPreview-5kHmKUTN.js} +20 -8
  41. package/dist/assets/linkPreview-5kHmKUTN.js.map +1 -0
  42. package/dist/assets/{main-C8J53SwH.js → main-Chc871HV.js} +72 -39
  43. package/dist/assets/main-Chc871HV.js.map +1 -0
  44. package/dist/assets/{mainline-DY95WbuK.js → mainline-CDUXtV-I.js} +2 -2
  45. package/dist/assets/{mainline-DY95WbuK.js.map → mainline-CDUXtV-I.js.map} +1 -1
  46. package/dist/assets/{networkReason-Be-hMghr.js → networkReason-DYlPZS5M.js} +2 -2
  47. package/dist/assets/{networkReason-Be-hMghr.js.map → networkReason-DYlPZS5M.js.map} +1 -1
  48. package/dist/assets/{ownDid-oa-T2vmZ.js → ownDid-BOuSlDv-.js} +4 -4
  49. package/dist/assets/{ownDid-oa-T2vmZ.js.map → ownDid-BOuSlDv-.js.map} +1 -1
  50. package/dist/assets/{ownStatus-Bc08eNJY.js → ownStatus-CLA1VPkL.js} +3 -3
  51. package/dist/assets/{ownStatus-Bc08eNJY.js.map → ownStatus-CLA1VPkL.js.map} +1 -1
  52. package/dist/assets/{pairedTransports-Dppn8lUN.js → pairedTransports-DAzupLYo.js} +21 -15
  53. package/dist/assets/pairedTransports-DAzupLYo.js.map +1 -0
  54. package/dist/assets/{paymentIntent-DySU3Ajm.js → paymentIntent-Cr3uZa_0.js} +2 -2
  55. package/dist/assets/{paymentIntent-DySU3Ajm.js.map → paymentIntent-Cr3uZa_0.js.map} +1 -1
  56. package/dist/assets/{profiles-B2uy04ph.js → profiles-BH1bH9aE.js} +2 -2
  57. package/dist/assets/{profiles-B2uy04ph.js.map → profiles-BH1bH9aE.js.map} +1 -1
  58. package/dist/assets/{registry-bLIfG619.js → registry-DAq16T-V.js} +1 -1
  59. package/dist/assets/{registry-DbTLLs3y.js → registry-DP_-RA-v.js} +5 -5
  60. package/dist/assets/{registry-DbTLLs3y.js.map → registry-DP_-RA-v.js.map} +1 -1
  61. package/dist/assets/{relay-CHWg5hpZ.js → relay-gJTOYQJZ.js} +93 -7
  62. package/dist/assets/relay-gJTOYQJZ.js.map +1 -0
  63. package/dist/assets/{resolve-DNX-eecG.js → resolve-B1eQ4dVQ.js} +3 -3
  64. package/dist/assets/{resolve-DNX-eecG.js.map → resolve-B1eQ4dVQ.js.map} +1 -1
  65. package/dist/assets/{server-DWJ4RzJn.js → server-Bd2ofxc1.js} +717 -6389
  66. package/dist/assets/server-Bd2ofxc1.js.map +1 -0
  67. package/dist/assets/{sshForges-BnvwmNj-.js → sshForges-As7dbGXM.js} +2 -2
  68. package/dist/assets/{sshForges-BnvwmNj-.js.map → sshForges-As7dbGXM.js.map} +1 -1
  69. package/dist/assets/{translate-CHj_PdLg.js → translate-DnuQMfj0.js} +10 -4
  70. package/dist/assets/translate-DnuQMfj0.js.map +1 -0
  71. package/dist/assets/{usdt-CBJ4Q5Ji.js → usdt-DLmtf8F9.js} +4 -4
  72. package/dist/assets/{usdt-CBJ4Q5Ji.js.map → usdt-DLmtf8F9.js.map} +1 -1
  73. package/dist/assets/{waitNotice-Cvz5CiKR.js → waitNotice-BHuMofaH.js} +2 -2
  74. package/dist/assets/{waitNotice-Cvz5CiKR.js.map → waitNotice-BHuMofaH.js.map} +1 -1
  75. package/dist/ghostly.mjs +1 -1
  76. package/npm-shrinkwrap.json +2 -2
  77. package/package.json +1 -1
  78. package/dist/assets/api-DF36rBJK.js +0 -3
  79. package/dist/assets/api-Dnq86JAA.js.map +0 -1
  80. package/dist/assets/apps-DBVhKpfe.js.map +0 -1
  81. package/dist/assets/backup-Bczllmzf.js.map +0 -1
  82. package/dist/assets/buttons-DaY5FYlV.js +0 -1
  83. package/dist/assets/engineErrors--9hfgKlK.js.map +0 -1
  84. package/dist/assets/groupMeta--fxSh792.js.map +0 -1
  85. package/dist/assets/host-CGzVFfMz.js.map +0 -1
  86. package/dist/assets/identityProofs-Cksc_K7_.js.map +0 -1
  87. package/dist/assets/irohWeb-Dp1i8v6n.js.map +0 -1
  88. package/dist/assets/linkPreview-DdMf-YAc.js.map +0 -1
  89. package/dist/assets/main-C8J53SwH.js.map +0 -1
  90. package/dist/assets/pairedTransports-Dppn8lUN.js.map +0 -1
  91. package/dist/assets/relay-CHWg5hpZ.js.map +0 -1
  92. package/dist/assets/server-DWJ4RzJn.js.map +0 -1
  93. 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,OAAQ,MAAM,OAAO,KAAM;CAChE,IAAI,IAAI;CACR,OAAO,IAAI,KAAK,MAAM,QAAQ;EAC5B,IAAI,MAAM,OAAO,KAAM;EACvB,MAAM,SAAS,MAAM,IAAI;EACzB,KAAK;EACL,IAAI,WAAW,OAAS,UAAU,OAAQ,UAAU,OAAS,WAAW,GAAM;EAC9E,IAAI,WAAW,OAAQ,WAAW,KAAM;EACxC,MAAM,OAAQ,MAAM,MAAM,IAAK,MAAM,IAAI;EACzC,IAAI,OAAO,KAAK,IAAI,OAAO,MAAM,QAAQ;EAEzC,IAAI,UAAU,OAAQ,UAAU,OAAQ,WAAW,OAAQ,WAAW,OAAQ,WAAW,OAAQ,QAAQ,GACvG,OAAO;GAAE,QAAS,MAAM,IAAI,MAAM,IAAK,MAAM,IAAI;GAAI,OAAQ,MAAM,IAAI,MAAM,IAAK,MAAM,IAAI;EAAG;EACjG,KAAK;CACP;AACF;;;;;AAMA,SAAgB,eAAe,OAA2C;CACxE,IAAI,UAAU,MAAM,UAAU,MAAM,OAAO;CAC3C,IAAI,OAAO,UAAU,YAAY,MAAM,SAAA,QAA8B,CAAC,MAAM,WAAW,MAAM,GAAG;CAChG,MAAM,OAAO,MAAM,MAAM,EAAa;CACtC,IAAI,CAAC,yBAAyB,KAAK,IAAI,KAAK,KAAK,SAAS,MAA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AC,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-DGx7E8b3.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-CeZpqVVC.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-BH1bH9aE.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-CLA1VPkL.js";
7
+ import { U as shellWord, W as jsonOut, a as contactKeyOf, b as nameKey, x as namedByThem } from "./apiKit-CPTFJHA7.js";
8
+ import { c as waitsFor, o as longTextChat, r as dhtOnlyNotice, s as waitNotice } from "./waitNotice-BHuMofaH.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.2",
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-uZTu5FlR.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-uZTu5FlR.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-uZTu5FlR.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-uZTu5FlR.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-uZTu5FlR.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
@@ -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
  /**
@@ -4473,15 +4491,15 @@ var VERSION = package_default.version;
4473
4491
  * command a running daemon answers loads none of them, and starts about as fast as Node does. Statically imported, they
4474
4492
  * cost every command ~100 ms before its socket was opened.
4475
4493
  */
4476
- var engineApi = () => import("./api-DF36rBJK.js");
4477
- var engineHost = () => import("./host-CGzVFfMz.js");
4494
+ var engineApi = () => import("./api-DV52o7A8.js");
4495
+ var engineHost = () => import("./host-CRA7h5A2.js");
4478
4496
  /**
4479
4497
  * `--translate <lang>`'s translator, or null (not asked; or the runtime is not there, said on stderr). Loaded only when
4480
4498
  * asked: the app's message parser it reads costs every other command nothing.
4481
4499
  */
4482
4500
  async function translatorFor(value, home) {
4483
4501
  if (value === void 0) return null;
4484
- const { loadDetector, openTranslator, translateTarget } = await import("./translate-CHj_PdLg.js");
4502
+ const { loadDetector, openTranslator, translateTarget } = await import("./translate-DnuQMfj0.js");
4485
4503
  return openTranslator({
4486
4504
  home,
4487
4505
  to: translateTarget(value),
@@ -4664,7 +4682,8 @@ function oneGroupOnly(method) {
4664
4682
  * 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
4683
  * messages; `payment list --chat` starts the chat it names. `identity providers` reads nothing of the profile, and
4666
4684
  * `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.
4685
+ * with 50,000. `saved list` reads each saved row by its key, a quoted original by its id and the contact's name from
4686
+ * the chat's record: 1.2 s instead of 0.7 s with 30,000 messages, nothing saved.
4668
4687
  */
4669
4688
  var NO_HISTORY_READS = /* @__PURE__ */ new Set([
4670
4689
  "status",
@@ -4683,7 +4702,8 @@ var NO_HISTORY_READS = /* @__PURE__ */ new Set([
4683
4702
  "wallet.list",
4684
4703
  "wallet.history",
4685
4704
  "payment.list",
4686
- "identity.providers"
4705
+ "identity.providers",
4706
+ "saved.list"
4687
4707
  ]);
4688
4708
  /**
4689
4709
  * Changes kept outside any chat (this profile's status, which each chat says on its next session; x401 keys and
@@ -4821,13 +4841,18 @@ function answerWithin(method, params) {
4821
4841
  if (waits !== void 0) return (waits + 10) * 1e3;
4822
4842
  if (readOnly(method, params)) return ANSWER_MS;
4823
4843
  }
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) {
4844
+ /**
4845
+ * `again`: whether a read the daemon left unanswered as it stopped is asked once more (`throughDaemon`). `first`: the
4846
+ * call a one-shot makes, whose own words are checked before the profile opens (api.ts `refuseBeforeStart`): a malformed
4847
+ * one opened it online and started every saved chat to be refused (with 10 chats, 20 relay requests and 0.4 s more).
4848
+ */
4849
+ async function session(g, options, again = true, first) {
4826
4850
  requireProfile(g);
4827
4851
  const anew = again ? () => session(g, options, false) : void 0;
4828
4852
  const client = await connectDaemon(g.paths);
4829
4853
  if (client) return throughDaemon(client, anew);
4830
- const [, { callApi, startNamedChats }] = await Promise.all([engineHost(), engineApi()]);
4854
+ const [, { callApi, refuseBeforeStart, startNamedChats }] = await Promise.all([engineHost(), engineApi()]);
4855
+ if (first) await refuseBeforeStart(first.method, first.params);
4831
4856
  const host = await openOneShot(g, options);
4832
4857
  if (host instanceof DaemonClient) return throughDaemon(host, anew);
4833
4858
  const call = async (m, p) => {
@@ -4972,8 +4997,8 @@ async function openOneShot(g, options = {}, mode = "one-shot") {
4972
4997
  * nothing of the groups, `deferChats` too when it names that chat or makes or joins a new one (`oneChatOnly`), `offline`
4973
4998
  * when it only reads or changes only this device (`offlineCall`).
4974
4999
  */
4975
- async function withSession(g, work, options = {}) {
4976
- const s = await session(g, options);
5000
+ async function withSession(g, work, options = {}, first) {
5001
+ const s = await session(g, options, true, first);
4977
5002
  const stops = interruptible(s);
4978
5003
  try {
4979
5004
  return await stops.run(work);
@@ -5586,7 +5611,7 @@ async function profileCommand(sub, argv) {
5586
5611
  if (!given || !name) throw new CliError("usage", `Missing <${given ? "new profile" : "file"}>: ghostly profile restore <file> <new profile> [--passphrase-file f] [--use]`);
5587
5612
  noMoreThan(2, parsed.positionals, "profile restore <file> <new profile> [--passphrase-file f] [--use]");
5588
5613
  const file = here(given);
5589
- const { backupFileProtection, restoreProfile } = await import("./backup-D6s0LQdg.js");
5614
+ const { backupFileProtection, restoreProfile } = await import("./backup-Di2U6QVH.js");
5590
5615
  const protection = await backupFileProtection(file);
5591
5616
  const paths = await restoreProfile(g.home, checkProfileName(name), file, protection === "none" ? void 0 : await backupPassphrase(parsed.options["passphrase-file"], RESTORE_PASSPHRASE));
5592
5617
  if (parsed.options.use) selectProfile(g.home, name);
@@ -6259,13 +6284,14 @@ async function listenCommand(argv) {
6259
6284
  };
6260
6285
  onStopSignals(stop);
6261
6286
  onReaderGone(stop);
6262
- let off = null, left = [];
6287
+ let off = null, left = [], gap;
6263
6288
  const open = (from) => {
6264
6289
  for (;;) {
6265
- const events = left.length ? left : host.ctx.hub.replay(from ?? host.ctx.hub.lastSeq);
6290
+ const events = (left.length ? left : host.ctx.hub.replay(from ?? host.ctx.hub.lastSeq)).filter((e) => e.type !== "events.gap" || e.id !== gap);
6266
6291
  left = [];
6267
6292
  if (!events.length) break;
6268
6293
  for (let i = 0; i < events.length; i++) {
6294
+ if (events[i].type === "events.gap") gap = events[i].id;
6269
6295
  feed.take(events[i]);
6270
6296
  if (feed.paused) {
6271
6297
  left = events.slice(i + 1);
@@ -6433,7 +6459,7 @@ async function textCommand(name, argv) {
6433
6459
  };
6434
6460
  if (spec.target === "group") params.mentions = parsed.options.mention ?? [];
6435
6461
  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));
6462
+ if (!spec.message) Object.assign(params, (await import("./buttons-YTYEqvGC.js")).buttonsOf(parsed.options));
6437
6463
  print(await withSession(g, (s) => {
6438
6464
  if (parsed.options.wait !== void 0) params.wait = parsed.options.wait;
6439
6465
  if (parsed.options.timeout !== void 0) params.timeout = parsed.options.timeout;
@@ -6477,20 +6503,23 @@ async function identityAddCommand(argv) {
6477
6503
  if (!provider) throw new CliError("usage", "Missing <provider>: ghostly identity add <provider> [subject] [--signer id] [--field name=value]... [--stdin] [--days n] [--timeout s]");
6478
6504
  inRange(parsed.options, "timeout", "a number of seconds", 5, 3600);
6479
6505
  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;
6506
+ const known = parsed.options.days !== void 0 || items.length ? (await import("./registry-DAq16T-V.js")).IDENTITY_PROVIDERS.find((p) => p.id === provider) : void 0;
6481
6507
  if (known && parsed.options.days !== void 0) inRange(parsed.options, "days", "a whole number", 1, known.validity.maxDays, true);
6482
6508
  const { fields, warning } = await identityFields(items, parsed.options.stdin === true, identitySecretFields(known, parsed.options.signer), readStdin, process.stdin.isTTY === true);
6483
6509
  if (warning) process.stderr.write(`ghostly: ${warning}\n`);
6510
+ const request = randomUUID();
6484
6511
  const params = {
6485
6512
  provider,
6486
6513
  subject: subject.join(" ") || void 0,
6487
6514
  signer: parsed.options.signer,
6488
6515
  fields,
6489
6516
  days: parsed.options.days,
6490
- timeout: parsed.options.timeout
6517
+ timeout: parsed.options.timeout,
6518
+ request
6491
6519
  };
6492
6520
  const tell = (event) => {
6493
- if (event.type === "identity.approval" || event.type === "identity.progress") process.stderr.write(JSON.stringify(event) + "\n");
6521
+ const lines = identityWaitLines(event, request, process.stderr.isTTY === true);
6522
+ if (lines) process.stderr.write(lines);
6494
6523
  };
6495
6524
  const addThroughDaemon = async (client) => {
6496
6525
  await warnVersion(client);
@@ -6509,7 +6538,8 @@ async function identityAddCommand(argv) {
6509
6538
  await addThroughDaemon(client);
6510
6539
  return;
6511
6540
  }
6512
- const [, { callApi }] = await Promise.all([engineHost(), engineApi()]);
6541
+ const [, { callApi, identityProvider }] = await Promise.all([engineHost(), engineApi()]);
6542
+ identityProvider(provider);
6513
6543
  const host = await openOneShot(g);
6514
6544
  if (host instanceof DaemonClient) {
6515
6545
  await addThroughDaemon(host);
@@ -6584,10 +6614,13 @@ async function tableCommand(name, argv) {
6584
6614
  deferGroups: chatOnly(command.method, params) || newChatOnly(command.method),
6585
6615
  deferChats: oneChatOnly(command.method, params) || oneGroupOnly(command.method) || readsNoHistory(command.method, params),
6586
6616
  offline: offlineCall(command.method, params)
6617
+ }, {
6618
+ method: command.method,
6619
+ params
6587
6620
  });
6588
6621
  if (translator) {
6589
6622
  try {
6590
- printAnswer(await (await import("./translate-CHj_PdLg.js")).translateAnswer(result, translator));
6623
+ printAnswer(await (await import("./translate-DnuQMfj0.js")).translateAnswer(result, translator));
6591
6624
  } finally {
6592
6625
  translator.close();
6593
6626
  }
@@ -6839,4 +6872,4 @@ async function run(argv) {
6839
6872
  }
6840
6873
  export { run };
6841
6874
 
6842
- //# sourceMappingURL=main-C8J53SwH.js.map
6875
+ //# sourceMappingURL=main-Chc871HV.js.map