@ghostlytools/cli 1.4.5 → 1.5.1

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 (89) hide show
  1. package/README.md +14 -7
  2. package/dist/assets/{api-D70he3-A.js → api-Dy_05gaq.js} +93 -62
  3. package/dist/assets/api-Dy_05gaq.js.map +1 -0
  4. package/dist/assets/{api-XX7bbtTZ.js → api-oUpBfryK.js} +2 -2
  5. package/dist/assets/{apiKit-CpsEqF-1.js → apiKit-B-PUYkXH.js} +2 -2
  6. package/dist/assets/{apiKit-CpsEqF-1.js.map → apiKit-B-PUYkXH.js.map} +1 -1
  7. package/dist/assets/{apps-DVMnlwGF.js → apps-C6MBfO-I.js} +1 -1
  8. package/dist/assets/{apps-VA8W_YCQ.js → apps-ejb6H1lT.js} +2 -2
  9. package/dist/assets/{apps-VA8W_YCQ.js.map → apps-ejb6H1lT.js.map} +1 -1
  10. package/dist/assets/{arkade-DxgW4-dK.js → arkade-DXyOeKEI.js} +2 -2
  11. package/dist/assets/{arkade-DxgW4-dK.js.map → arkade-DXyOeKEI.js.map} +1 -1
  12. package/dist/assets/{backup-BRTH1y3-.js → backup-Bt6UjCiM.js} +1 -1
  13. package/dist/assets/{backup-c9xvXgCS.js → backup-DRIIguzE.js} +6 -6
  14. package/dist/assets/{backup-c9xvXgCS.js.map → backup-DRIIguzE.js.map} +1 -1
  15. package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
  16. package/dist/assets/{blobFiles-B0rNnHlO.js → blobFiles-1wUBd8ZD.js} +3 -3
  17. package/dist/assets/{blobFiles-B0rNnHlO.js.map → blobFiles-1wUBd8ZD.js.map} +1 -1
  18. package/dist/assets/buttons-B3bi6p_d.js +2 -0
  19. package/dist/assets/{buttons-D31LBftz.js → buttons-DoccJ_cK.js} +3 -3
  20. package/dist/assets/{buttons-D31LBftz.js.map → buttons-DoccJ_cK.js.map} +1 -1
  21. package/dist/assets/daemonProof-CWTVNUmr.js +254 -0
  22. package/dist/assets/daemonProof-CWTVNUmr.js.map +1 -0
  23. package/dist/assets/{envelope-hAl4pblf.js → envelope-hJ0SfbAh.js} +2 -2
  24. package/dist/assets/{envelope-hAl4pblf.js.map → envelope-hJ0SfbAh.js.map} +1 -1
  25. package/dist/assets/fedimint_client_wasm_bg-BtHHlFpp.js.map +1 -1
  26. package/dist/assets/{fileBytes-B-fqGdEd.js → fileBytes-B8eTZfAT.js} +3 -3
  27. package/dist/assets/{fileBytes-B-fqGdEd.js.map → fileBytes-B8eTZfAT.js.map} +1 -1
  28. package/dist/assets/{fileBytes-C2jycN_7.js → fileBytes-gTd_8l-P.js} +1 -1
  29. package/dist/assets/{fileBytes-D6fqFQEX.js → fileBytes-uRqLyxa0.js} +2 -2
  30. package/dist/assets/{fileBytes-D6fqFQEX.js.map → fileBytes-uRqLyxa0.js.map} +1 -1
  31. package/dist/assets/{fileBytesIdb-_HnxdacI.js → fileBytesIdb-BIFKtgln.js} +3 -3
  32. package/dist/assets/{fileBytesIdb-_HnxdacI.js.map → fileBytesIdb-BIFKtgln.js.map} +1 -1
  33. package/dist/assets/fileBytesIdb-BVVr_rWX.js +2 -0
  34. package/dist/assets/{fileBytesOpfs-p_CANncD.js → fileBytesOpfs-ChrHcCVV.js} +3 -3
  35. package/dist/assets/{fileBytesOpfs-p_CANncD.js.map → fileBytesOpfs-ChrHcCVV.js.map} +1 -1
  36. package/dist/assets/{groupFiles-gQ8_792r.js → groupFiles-BXPINkVJ.js} +60 -14
  37. package/dist/assets/groupFiles-BXPINkVJ.js.map +1 -0
  38. package/dist/assets/{host-Dmo6m7So.js → host-CzgYwupN.js} +15 -122
  39. package/dist/assets/host-CzgYwupN.js.map +1 -0
  40. package/dist/assets/{hyperdhtRelay-DwkZ8vpt.js → hyperdhtRelay-CJBqsS_e.js} +2 -2
  41. package/dist/assets/{hyperdhtRelay-DwkZ8vpt.js.map → hyperdhtRelay-CJBqsS_e.js.map} +1 -1
  42. package/dist/assets/{idb-CMVgtn2k.js → idb-BJARz3Qi.js} +5 -3
  43. package/dist/assets/idb-BJARz3Qi.js.map +1 -0
  44. package/dist/assets/{irohWeb-DKJhESuV.js → irohWeb-CrGOD-OD.js} +2 -2
  45. package/dist/assets/{irohWeb-DKJhESuV.js.map → irohWeb-CrGOD-OD.js.map} +1 -1
  46. package/dist/assets/{main-DgXvK9Cr.js → main-BDOIJ_ls.js} +240 -53
  47. package/dist/assets/main-BDOIJ_ls.js.map +1 -0
  48. package/dist/assets/{mainline-9j_FqcJe.js → mainline-Cw7rnEWM.js} +2 -2
  49. package/dist/assets/{mainline-9j_FqcJe.js.map → mainline-Cw7rnEWM.js.map} +1 -1
  50. package/dist/assets/{networkReason-Bp8Huk9Z.js → networkReason-C0VY94cG.js} +3 -3
  51. package/dist/assets/{networkReason-Bp8Huk9Z.js.map → networkReason-C0VY94cG.js.map} +1 -1
  52. package/dist/assets/{nwc-DxIjNmYz.js → nwc-lpGWvzYU.js} +3 -3
  53. package/dist/assets/{nwc-DxIjNmYz.js.map → nwc-lpGWvzYU.js.map} +1 -1
  54. package/dist/assets/{nwcProvider-CyGVe35t.js → nwcProvider-CAGRn2ly.js} +2 -2
  55. package/dist/assets/{nwcProvider-CyGVe35t.js.map → nwcProvider-CAGRn2ly.js.map} +1 -1
  56. package/dist/assets/{profiles-ClRPr6y8.js → profiles-BehWURA9.js} +7 -3
  57. package/dist/assets/profiles-BehWURA9.js.map +1 -0
  58. package/dist/assets/{registry-siqMiD8L.js → registry-D2bK-k1T.js} +1 -1
  59. package/dist/assets/{registry-BTIRr7gH.js → registry-DWkkBN57.js} +3 -3
  60. package/dist/assets/registry-DWkkBN57.js.map +1 -0
  61. package/dist/assets/{resolve-CZ4yb7wp.js → resolve-CvYK0Lbt.js} +2 -2
  62. package/dist/assets/{resolve-CZ4yb7wp.js.map → resolve-CvYK0Lbt.js.map} +1 -1
  63. package/dist/assets/{restoredRows-DeBImGRd.js → restoredRows-DGuKtIBz.js} +2 -2
  64. package/dist/assets/{restoredRows-DeBImGRd.js.map → restoredRows-DGuKtIBz.js.map} +1 -1
  65. package/dist/assets/{server-ZrkwMbFo.js → server-BktMmp7L.js} +1141 -310
  66. package/dist/assets/server-BktMmp7L.js.map +1 -0
  67. package/dist/assets/{src-CxEO33Hb.js → src-Bpy99Z2K.js} +828 -57
  68. package/dist/assets/src-Bpy99Z2K.js.map +1 -0
  69. package/dist/assets/{usdt-exH8dIZK.js → usdt-DFusiw8x.js} +3 -3
  70. package/dist/assets/{usdt-exH8dIZK.js.map → usdt-DFusiw8x.js.map} +1 -1
  71. package/dist/assets/{turnRefs-Dndxqyxk.js → words-Z-izzDBN.js} +61 -3
  72. package/dist/assets/words-Z-izzDBN.js.map +1 -0
  73. package/dist/ghostly.mjs +1 -1
  74. package/package.json +1 -1
  75. package/skills/ghostly/scripts/status +3 -2
  76. package/dist/assets/api-D70he3-A.js.map +0 -1
  77. package/dist/assets/buttons-CtGCix-8.js +0 -2
  78. package/dist/assets/daemonProof-B53VnZ1Z.js +0 -100
  79. package/dist/assets/daemonProof-B53VnZ1Z.js.map +0 -1
  80. package/dist/assets/fileBytesIdb-DOxm_BKt.js +0 -2
  81. package/dist/assets/groupFiles-gQ8_792r.js.map +0 -1
  82. package/dist/assets/host-Dmo6m7So.js.map +0 -1
  83. package/dist/assets/idb-CMVgtn2k.js.map +0 -1
  84. package/dist/assets/main-DgXvK9Cr.js.map +0 -1
  85. package/dist/assets/profiles-ClRPr6y8.js.map +0 -1
  86. package/dist/assets/registry-BTIRr7gH.js.map +0 -1
  87. package/dist/assets/server-ZrkwMbFo.js.map +0 -1
  88. package/dist/assets/src-CxEO33Hb.js.map +0 -1
  89. package/dist/assets/turnRefs-Dndxqyxk.js.map +0 -1
package/README.md CHANGED
@@ -149,6 +149,7 @@ The rows are in alphabetical order of their first command, and every command of
149
149
  | `invite join [<invite-or-link> \| -] [--label <name>]` | Join a chat (your own invite is refused). The invite comes from stdin when none is given or `-`, out of `ps` and the shell's history; on the command line the CLI warns |
150
150
  | `lightning default <card>`, `lightning rename <card> <name>` | Lightning cards: which receives by default |
151
151
  | `listen [--since seq] [--cursor file] [--type t]… [--turns] [--from <chat\|key>]… [--group <group>]… [--exec cmd] [--webhook url] [--print]` | The event stream; `--from` and `--group` an allowlist, `--turns` one `agent.turn` per message to answer ([Events](#events)) |
152
+ | `message delete <chat\|group> <message> --everyone` | Deletes a message of yours for everyone (a text, a card, a file or a voice message; never a payment): it goes from this device at once and from every member's as the message's last edit, once they are back if they are away. An app from before this shows "🗑 Message removed" in its place. Without `--everyone`, only this device forgets it |
152
153
  | `message retry\|delete\|details <chat> <message>` | One message |
153
154
  | `pay <invoice\|address\|lnurl> [--amount sats] [--network n] [--max-fee sats] [--confirm-real]` | Pay over Lightning (Testnet unless `--network mainnet`) |
154
155
  | `payment list [--chat c]`, `payment check <chat> <payment>`, `payment reclaim <payment>` | Payments and requests |
@@ -159,6 +160,7 @@ The rows are in alphabetical order of their first command, and every command of
159
160
  | `profile show`, `profile set [--name <name>] [--share-profile \| --no-share-profile]` | The name contacts see |
160
161
  | `react <chat> <message> <emoji> [--remove]` | React to a message with one emoji; a new one replaces yours, `--remove` takes it back |
161
162
  | `routine send <chat\|group> --name <name> --schedule "every day 01:00" [--cron "0 1 * * *"] [--state active\|paused] [--next <time>] [--run ok\|failed\|skipped[:summary]] [--link url]… [--id id] [--json json\|-\|file] [--force]`, `routine update <chat\|group> <routine> [fields…]` | A routine card for something a bot runs on a schedule (WISP 405 · Status Cards): its name, schedule (and cron line, shown only), state, last run and result, next run and up to 10 recent runs. `--run` records a run now as the last one; `--next` takes milliseconds or a date. Updates merge and are paced as `task update`'s. The app shows it, and runs nothing |
163
+ | `saved add\|remove <chat\|group> <message>`, `saved list` | Saved messages: mark a message of a chat or a group to find it again, kept for this profile on this device and never sent (the app shows the same list in its Saved view). `saved list` gives them the last saved first, each as it is now (an edit shows its latest text) with its `chat` or `group` and `savedAt`; a deleted message drops out |
162
164
  | `send <chat> [text…] [--reply <message>] [--button id:Label]… [--style id=primary\|neutral\|danger]… [--once] [--id id] [--stdin] [--force] [--wait none\|sent\|delivered] [--timeout s]` | Send text (arguments, or stdin); `--reply` quotes a message of the chat. `--button yes:Yes` (1 to 6; the id ends at the first colon; no two labels alike ignoring case and spaces, and no label that is another button's id, else exit 2) puts buttons under the text, which is the question and what older apps show, so say how to answer in words. `--once`: one answer a person. A question that goes on the DHT floor or into a hold (the contact's app closed) reaches them as text alone; the engine sends its buttons again once the chat is live, as an edit of the buttons alone (no `message.edited` for it). The answer adds `buttons` (the question's id, `ask-…` unless `--id`), `card`, and `pressable`: whether the contact's app shows buttons (null until it says). A press comes back as `button.pressed` ([Events](#events)) |
163
165
  | `service add <name> <http://127.0.0.1:port>`, `service share <service> <chat> [--off]`, `service list`, `service remove\|enable` | Share a web app on this machine, per contact |
164
166
  | `service peer <chat>`, `service open <chat> <service> [--port p]`, `service close <chat> <service>` | A contact's app on a loopback port here (daemon). `url` is a link for your browser, `http://<random>.localhost:<port>/.ghostly-open/<token>`: it sets the service's cookie and shows the app on a host name of its own; any other host name, or a request without that cookie, gets 404. Chrome, Edge and curl reach `*.localhost` names by themselves; Safari and Node's `fetch` on macOS may not (add the name to `/etc/hosts` for them) |
@@ -238,7 +240,8 @@ service manager instead.
238
240
 
239
241
  `send` and `group send` refuse text that looks like a recovery phrase, a private key (nsec, WIF, xprv, 64 hex
240
242
  characters named as a key) or a Cashu token (money anyone who reads it can take), with exit `5`, unless `--force`;
241
- so do `edit`, `forward`, `button update --text` and the task, routine and usage cards (any text on the card).
243
+ so do `edit`, `forward`, `button update --text`, the task, routine and usage cards (any text on the card) and the
244
+ memo of `chat pay` and `chat request`.
242
245
  It is the app's own detector.
243
246
 
244
247
  ### Real money
@@ -297,14 +300,14 @@ chat (`chat list`, `chat show`, `chat rename`, …) and `engine getState` print
297
300
  waiting, resolving, on-dht, live, …), `chat.connection` (`live`, `transport`), `typing.started` (with `kind` and, when given, `status`; again when either changes) and `typing.stopped` (the contact is writing, or stopped: a message, a stop, or 6 s of silence), `chat.joined` (the contact's app
298
301
  announced itself; not a message), `chat.announced`, `message.received` (`message.nick`: the name the contact gave), `message.sent`, `message.delivery`
299
302
  (`delivery`: sending, queued, waiting, held, sent, delivered, failed), `message.edited` (a text changed in place, the
300
- contact's or mine: once per edit number, with `edits` and the message as it is now; `group.message.edited` in a group), `message.deleted`, `group.created`,
303
+ contact's or mine: once per edit number, with `edits` and the message as it is now; `group.message.edited` in a group), `message.deleted` (`{chat, messageId}`: a message gone from this device, deleted here or for everyone by its author; `group.deleted` with `group` in a group), `group.created`,
301
304
  `group.status`, `group.members` (`joined`, `left`), `group.typing.started` (`member`, `kind`, and `status` when given; again when either changes) and `group.typing.stopped` (`member`: a member of a private group is writing, or stopped), `group.message` (`message.member` is the author's key,
302
305
  `message.nick` their name from the roster; `message.mentioned` when it names this profile), `group.mentioned`
303
306
  (`{group, messageId, message}`: a mention of this profile learned after the message's `group.message`, which said
304
307
  none: a copy another member handed on without it, completed by the author's, or an edit that names this profile; once), `group.sent`, `group.event`, `file.offered` (a file over 25 MiB waits for `file accept`),
305
308
  `file.stage`, `file.done`, `file.failed` (each with `chat`, or `group` for a group's file, `file`, `messageId`), `chat.held` and
306
309
  `chat.released` (`chat disconnect --hold`), `identity.received` and `identity.status` (what a contact
307
- showed, as checked here), `identity.approval` and `identity.progress` (a signer waits on a link or a code), `group.deleted`, `group.removed`, `payment.created` and
310
+ showed, as checked here), `identity.approval` and `identity.progress` (a signer waits on a link or a code), `group.deleted` (`{group, messageId}`: a group's message deleted, not the group), `group.removed`, `payment.created` and
308
311
  `payment.updated` (`payment`: id, chat, kind request|payment, direction in|out, amount, memo, state pending|
309
312
  settled|failed, network, method), `call.incoming`, `call.outgoing`, `call.connected` and `call.ended` (voice
310
313
  calls: see [Calls](#calls)), `app.opened` (`chat`, `app`, `version`), `app.closed` (`chat`, `app`, and `offline`
@@ -387,11 +390,15 @@ receive|address|redeem`, `wallet.mint.add`, `lightning.default|rename`, `pay`, `
387
390
  `{"method":"<engine call>","params":{…},"confirmReal":false,"yes":false}` for anything else the app does. Parameters are the
388
391
  commands' (see `src/api.ts`). Errors: `{"id":…,"error":{"code","message","details"?}}` with the codes above.
389
392
 
390
- Before its first request, a program can check that the socket is the profile's daemon and not a process that opened
391
- its path first (on Windows the socket is a named pipe, which any account of the machine may open): send
393
+ The daemon's first line on every connection is `{"greeting":{"pid":…,"at":…,"proof":"<hex>"}}`, which a program
394
+ that does not check it can skip. Before it writes anything, a program can check that the socket is the profile's
395
+ daemon and not a process that opened its path first (on Windows the socket is a named pipe, which any account of the
396
+ machine may open): the greeting's `proof` is HMAC-SHA256 over `ghostly-greeting:<pid>:<at>` keyed with the 32 bytes
397
+ (hex) in `daemon.secret` in the profile's folder, which the daemon writes anew, 0600, at every start; `at` (ms) is
398
+ recent and `pid` is the one in `daemon.lock`. Then send
392
399
  `{"id":"hello","method":"daemon.hello","params":{"nonce":"<16 random bytes, hex>"}}`; the answer's `proof` is
393
- HMAC-SHA256 over `ghostly-daemon:<nonce>` keyed with the 32 bytes (hex) in `daemon.secret` in the profile's folder,
394
- which the daemon writes anew, 0600, at every start. The CLI sends nothing else until that proof matches.
400
+ HMAC-SHA256 over `ghostly-daemon:<nonce>` with the same key. The CLI writes nothing until the greeting checks out,
401
+ and nothing but the hello until its proof matches.
395
402
 
396
403
  ## Calls
397
404
 
@@ -1,15 +1,15 @@
1
- import { Ac as isAppRef, Ba as appCardId, Bi as identityStatement, Ec as appRef, Ha as cardLine, Ic as readImageMeta, Mr as TYPING_REFRESH_MS, Pr as sanitizeTypingStatus, Qc as ownInviteRefusal, Qr as APP_DATA_MAX_BYTES, Un as GROUP_FILE_LIMITS, Wa as checkStatusCard, Xc as inviteLink, Xl as MAX_AVATAR_LENGTH, Y as groupName, Zl as sanitizeAvatar, aa as sanitizeMime, ca as baseMime, da as voicePeaksOf, ho as GhostlyHttpError, ia as sanitizeFileName, jr as TYPING_KINDS, lo as AWAITING_PEER_MS, nu as randomBytes$1, oa as PLAYABLE_AUDIO, pc as APP_PERMISSIONS, ru as toBase64Url, sa as VOICE_LIMITS, ua as parseVoiceMeta, vc as isAppUrl, yo as LIMITS, za as STATUS_CARD_LIMITS } from "./src-CxEO33Hb.js";
2
- import { l as fileStore } from "./idb-CMVgtn2k.js";
3
- import { O as waitingGroupFile, T as removeStored, U as iceServerProblem, W as iceServerSetting, i as groupOfFile, l as replyRef, n as groupFileId, v as paymentNetwork } from "./groupFiles-gQ8_792r.js";
4
- import { f as FILE_BYTES_STEP, o as fileBytes, s as fileBytesOf } from "./fileBytes-B-fqGdEd.js";
5
- import { t as IDENTITY_PROVIDERS } from "./registry-BTIRr7gH.js";
6
- import { a as waitForEdit, c as findSecret, i as pressable, n as buttonsCard, o as waitForGroupFrame, s as waitForMessage, t as BUTTON_METHODS } from "./buttons-D31LBftz.js";
7
- import { a as ENGINE_PARAMS, i as ENGINE_METHODS, l as engineParamsProblem, n as withStoredIds, o as ENGINE_READS, r as DESTRUCTIVE_CALLS, s as READ_PARAMS } from "./turnRefs-Dndxqyxk.js";
1
+ import { Co as GhostlyHttpError, Dc as isAppUrl, Do as LIMITS, Fc as appRef, Gc as readImageMeta, Hi as identityStatement, Ja as appCardId, Ka as STATUS_CARD_LIMITS, Mr as TYPING_REFRESH_MS, Pr as sanitizeTypingStatus, Qa as checkStatusCard, Sc as APP_PERMISSIONS, Un as GROUP_FILE_LIMITS, Xa as cardLine, Y as groupName, _o as AWAITING_PEER_MS, al as inviteLink, au as MAX_AVATAR_LENGTH, ca as PLAYABLE_AUDIO, du as randomBytes$1, ei as APP_DATA_MAX_BYTES, fa as parseVoiceMeta, fu as toBase64Url, jr as TYPING_KINDS, la as VOICE_LIMITS, ma as voicePeaksOf, oa as sanitizeFileName, ou as sanitizeAvatar, pa as voiceDownloadName, sa as sanitizeMime, sl as ownInviteRefusal, ua as baseMime, zc as isAppRef } from "./src-Bpy99Z2K.js";
2
+ import { l as fileStore } from "./idb-BJARz3Qi.js";
3
+ import { O as waitingGroupFile, T as removeStored, U as iceServerProblem, W as iceServerSetting, i as groupOfFile, l as replyRef, n as groupFileId, v as paymentNetwork } from "./groupFiles-BXPINkVJ.js";
4
+ import { f as FILE_BYTES_STEP, o as fileBytes, s as fileBytesOf } from "./fileBytes-B8eTZfAT.js";
5
+ import { t as IDENTITY_PROVIDERS } from "./registry-DWkkBN57.js";
6
+ import { a as waitForEdit, c as findSecret, i as pressable, n as buttonsCard, o as waitForGroupFrame, s as waitForMessage, t as BUTTON_METHODS } from "./buttons-DoccJ_cK.js";
7
+ import { a as WALLET_TYPES, c as DESTRUCTIVE_CALLS, d as ENGINE_READS, f as READ_PARAMS, i as TRANSPORT_NAMES, l as ENGINE_METHODS, m as engineParamsProblem, n as CHAT_METHODS, r as PAY_METHODS, s as withStoredIds, t as ADDRESS_TYPES, u as ENGINE_PARAMS } from "./words-Z-izzDBN.js";
8
8
  import { i as localFileError, r as asCliError, t as CliError } from "./errors-BLSPp0tK.js";
9
- import { _ as str, a as findChat, c as groupOf, d as messageOf, f as node, g as state, h as sentAt, i as chatOrGroup, l as inviteTaken, m as oneOf, n as bool, o as findChatOrGroup, p as num, r as chatOf, s as findGroup, u as list, v as waitForState } from "./apiKit-CpsEqF-1.js";
10
- import { a as checkShownName } from "./profiles-ClRPr6y8.js";
11
- import { t as BACKUP_METHODS } from "./backup-c9xvXgCS.js";
12
- import { o as checkedBundle } from "./apps-VA8W_YCQ.js";
9
+ import { _ as str, a as findChat, c as groupOf, d as messageOf, f as node, g as state, h as sentAt, i as chatOrGroup, l as inviteTaken, m as oneOf, n as bool, o as findChatOrGroup, p as num, r as chatOf, s as findGroup, u as list, v as waitForState } from "./apiKit-B-PUYkXH.js";
10
+ import { a as checkShownName } from "./profiles-BehWURA9.js";
11
+ import { t as BACKUP_METHODS } from "./backup-DRIIguzE.js";
12
+ import { o as checkedBundle } from "./apps-ejb6H1lT.js";
13
13
  import { generateMnemonic } from "@scure/bip39";
14
14
  import { wordlist } from "@scure/bip39/wordlists/english.js";
15
15
  import { openAsBlob, readFileSync, renameSync, writeFileSync } from "node:fs";
@@ -477,7 +477,7 @@ function decodeWithFfmpeg(path, command = process.env.GHOSTLY_FFMPEG || "ffmpeg"
477
477
  * In a group (WISP 503 · Group Files) the file is announced as a group message, and each member's app fetches the
478
478
  * bytes from whoever holds them: by itself up to the automatic limits, on `file accept` past them.
479
479
  */
480
- var TYPES$1 = {
480
+ var TYPES = {
481
481
  ".png": "image/png",
482
482
  ".jpg": "image/jpeg",
483
483
  ".jpeg": "image/jpeg",
@@ -499,7 +499,7 @@ var TYPES$1 = {
499
499
  ".mov": "video/quicktime"
500
500
  };
501
501
  function mimeOf(path, given) {
502
- return sanitizeMime(given ?? TYPES$1[extname(path).toLowerCase()] ?? "application/octet-stream");
502
+ return sanitizeMime(given ?? TYPES[extname(path).toLowerCase()] ?? "application/octet-stream");
503
503
  }
504
504
  /** A chat's files as the timeline shows them, with where each transfer stands (`transferOf`, by file id). */
505
505
  function filesOf(messages, transferOf) {
@@ -871,7 +871,11 @@ var FILE_METHODS = {
871
871
  size: transfer.size
872
872
  };
873
873
  },
874
- /** Writes a received (or sent) file to disk: into `dir` under its own name (`saveName`), or to `path`. Never over a file unless `force`. */
874
+ /**
875
+ * Writes a received (or sent) file to disk: into `dir` under its own name (`saveName`), a voice message under the one
876
+ * Ghostly makes for it as the apps' Download does (`voiceDownloadName`, never the sender's), or to `path`. Never over
877
+ * a file unless `force`.
878
+ */
875
879
  async "file.save"(ctx, params) {
876
880
  const fileId = str(params, "file", true);
877
881
  if (params.chat !== void 0) fileChat(ctx, params, fileId);
@@ -884,7 +888,7 @@ var FILE_METHODS = {
884
888
  if (stored.leftOut) throw new CliError("not_found", "Not in this backup: the light backup this profile was restored from left the file out");
885
889
  const transfer = stored.direction === "out" ? void 0 : state(ctx).transfers[fileId] ?? stored.transfer;
886
890
  if (transfer && transfer.state !== "done") throw new CliError("unavailable", `The file is not all here yet (${transfer.transferred} of ${transfer.size} bytes)`);
887
- const target = str(params, "path") ? resolve(str(params, "path", true)) : join(resolve(str(params, "dir") ?? "."), saveName(stored.metadata.name));
891
+ const target = str(params, "path") ? resolve(str(params, "path", true)) : join(resolve(str(params, "dir") ?? "."), saveName(stored.metadata.voice ? voiceDownloadName(stored.metadata.mime, stored.metadata.timestamp) : stored.metadata.name));
888
892
  const flags = bool(params, "force") ? "w" : "wx";
889
893
  let out;
890
894
  try {
@@ -2198,6 +2202,14 @@ function cookieValues(header, name) {
2198
2202
  function sameSecret(a, b) {
2199
2203
  return a.length === b.length && timingSafeEqual(Buffer.from(a), Buffer.from(b));
2200
2204
  }
2205
+ /**
2206
+ * Added to every answer of a contact's app, next to any policy the contact sends (a browser enforces both): its
2207
+ * scripts and forms reach its own origin and public https sites, never plain http. The page is served from
2208
+ * `<random>.localhost`, which Chrome counts as this machine, so its own guard for requests to local addresses
2209
+ * (Local Network Access) would not ask before the page read or posted to another service on 127.0.0.1 or the local
2210
+ * network. Pictures, frames and navigation are not covered.
2211
+ */
2212
+ var OPENED_SERVICE_CSP = "connect-src 'self' https: wss:; form-action 'self' https:";
2201
2213
  function plain(response, status, text, headers = {}) {
2202
2214
  response.writeHead(status, {
2203
2215
  "content-type": "text/plain; charset=utf-8",
@@ -2288,8 +2300,10 @@ async function proxy(request, response, chunks, send, cookies) {
2288
2300
  if (!cookie) continue;
2289
2301
  if (cookies.size < MAX_COOKIE_NAMES) cookies.add(setCookieName(cookie));
2290
2302
  out[lower] = [...out[lower] ?? [], cookie];
2291
- } else out[lower] = value;
2303
+ } else if (lower === "content-security-policy") out[lower] = [...out[lower] ?? [], value];
2304
+ else out[lower] = value;
2292
2305
  }
2306
+ out["content-security-policy"] = [...out["content-security-policy"] ?? [], OPENED_SERVICE_CSP];
2293
2307
  response.writeHead(answer.status, out);
2294
2308
  await pipeline(Readable.from(answer.body, { objectMode: false }), response);
2295
2309
  } catch (error) {
@@ -2719,30 +2733,6 @@ var NOT_SENT = {
2719
2733
  * call says `confirmReal: true` (the CLI's `--confirm-real`): no flag, no spend.
2720
2734
  */
2721
2735
  var NETWORKS = ["mainnet", "testnet"];
2722
- var TYPES = [
2723
- "cashu",
2724
- "lightning",
2725
- "arkade",
2726
- "bark",
2727
- "spark",
2728
- "bitcoin",
2729
- "fedimint",
2730
- "usdt"
2731
- ];
2732
- var METHODS$1 = [
2733
- "cashu",
2734
- "arkade",
2735
- "usdt",
2736
- "bark",
2737
- "bitcoin",
2738
- "fedimint",
2739
- "spark"
2740
- ];
2741
- var CHAT_METHODS = [
2742
- "cashu",
2743
- "lightning",
2744
- ...METHODS$1.filter((m) => m !== "cashu")
2745
- ];
2746
2736
  /**
2747
2737
  * What the app has and a headless Ghostly cannot run yet, and why (WISP 1100 § Wallet SDKs on Node). New offers
2748
2738
  * them as unavailable; creating one is refused before the engine is asked.
@@ -2961,7 +2951,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
2961
2951
  };
2962
2952
  },
2963
2953
  async "wallet.create"(ctx, params) {
2964
- const type = oneOf(params, "type", TYPES, "cashu");
2954
+ const type = oneOf(params, "type", WALLET_TYPES, "cashu");
2965
2955
  const n = network(params);
2966
2956
  const gap = NODE_GAPS[type];
2967
2957
  if (gap) throw new CliError("unavailable", gap);
@@ -2983,7 +2973,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
2983
2973
  }), state(ctx));
2984
2974
  },
2985
2975
  async "wallet.remove"(ctx, params) {
2986
- const type = oneOf(params, "type", TYPES, "cashu");
2976
+ const type = oneOf(params, "type", WALLET_TYPES, "cashu");
2987
2977
  const n = network(params);
2988
2978
  const card = cardOf(ctx, params, type);
2989
2979
  try {
@@ -3005,7 +2995,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
3005
2995
  } };
3006
2996
  },
3007
2997
  async "wallet.faucet"(ctx, params) {
3008
- const type = oneOf(params, "type", TYPES, "cashu");
2998
+ const type = oneOf(params, "type", WALLET_TYPES, "cashu");
3009
2999
  if (network(params) !== "testnet") throw new CliError("refused", "Test coins are for Testnet wallets only");
3010
3000
  const card = cardOf(ctx, params, type);
3011
3001
  return node(ctx).walletTestCoins({
@@ -3048,12 +3038,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
3048
3038
  };
3049
3039
  },
3050
3040
  async "wallet.address"(ctx, params) {
3051
- const type = oneOf(params, "type", [
3052
- "bitcoin",
3053
- "arkade",
3054
- "spark",
3055
- "usdt"
3056
- ], "bitcoin");
3041
+ const type = oneOf(params, "type", ADDRESS_TYPES, "bitcoin");
3057
3042
  const n = network(params);
3058
3043
  if (type === "bitcoin") return {
3059
3044
  type,
@@ -3182,7 +3167,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
3182
3167
  const link = chatOf(ctx, params);
3183
3168
  const amount = num(params, "amount", 0, { min: 1 });
3184
3169
  if (!amount) throw new CliError("bad_request", "amount is required");
3185
- const method = params.method === void 0 ? void 0 : oneOf(params, "method", METHODS$1, "cashu");
3170
+ const method = params.method === void 0 ? void 0 : oneOf(params, "method", PAY_METHODS, "cashu");
3186
3171
  const rail = params.rail === void 0 ? void 0 : oneOf(params, "rail", ["cashu", "lightning"], "cashu");
3187
3172
  await federationsOpen(ctx);
3188
3173
  const { paymentId } = await node(ctx).requestPayment({
@@ -3346,16 +3331,6 @@ function relayRefused(error, patch) {
3346
3331
  ].filter((key) => Object.hasOwn(patch, key));
3347
3332
  return new CliError("bad_request", `${keys.join(", ") || "relays"}: ${error.message.replace(/^Enter /, "give ").replace(/^(Not|Use) /, (word) => word.toLowerCase())}`);
3348
3333
  }
3349
- var TRANSPORT_NAMES = {
3350
- auto: "auto",
3351
- dht: "dht",
3352
- webrtc: "webrtc/1",
3353
- iroh: "iroh/1",
3354
- hyperdht: "hyperdht/1",
3355
- "webrtc/1": "webrtc/1",
3356
- "iroh/1": "iroh/1",
3357
- "hyperdht/1": "hyperdht/1"
3358
- };
3359
3334
  /** The engine keeps a chat's name to 48 UTF-16 units (renameLink). */
3360
3335
  var CHAT_NAME_UNITS = 48;
3361
3336
  /**
@@ -3732,6 +3707,30 @@ var METHODS = {
3732
3707
  removed: remove
3733
3708
  };
3734
3709
  },
3710
+ /** Saved messages: a mark on a message of a chat or a group, kept for this profile on this device; nothing is sent. */
3711
+ async "saved.add"(ctx, params) {
3712
+ return saveMark(ctx, params, false);
3713
+ },
3714
+ async "saved.remove"(ctx, params) {
3715
+ return saveMark(ctx, params, true);
3716
+ },
3717
+ /** The saved messages, the last saved first, each as it is now and named by its chat or group. */
3718
+ async "saved.list"(ctx) {
3719
+ const { links, groups } = state(ctx);
3720
+ return (await node(ctx).savedMessages()).map(({ savedAt, message }) => {
3721
+ if (!message.linkId.startsWith("group:")) return {
3722
+ chat: message.linkId,
3723
+ savedAt,
3724
+ message: chatMessageJson(message, links.find((l) => l.id === message.linkId))
3725
+ };
3726
+ const id = message.linkId.slice(6);
3727
+ return {
3728
+ group: id,
3729
+ savedAt,
3730
+ message: groupMessageJson(message, groups.find((g) => g.id === id))
3731
+ };
3732
+ });
3733
+ },
3735
3734
  /**
3736
3735
  * WISP 400 § Forwards: messages of a chat or a group sent on to up to 5 chats and groups, each as a new message of mine
3737
3736
  * that says it was forwarded (one hop more) and nothing of who wrote it. A file goes from the bytes here, never
@@ -3819,7 +3818,24 @@ var METHODS = {
3819
3818
  };
3820
3819
  },
3821
3820
  async "chat.delete"(ctx, params) {
3822
- const link = chatOf(ctx, params);
3821
+ if (bool(params, "everyone")) {
3822
+ const target = chatOrGroup(ctx, str(params, "chat", true));
3823
+ const ref = str(params, "message", true);
3824
+ const message = await messageOf(ctx, target.linkId, ref, (m) => m.sender === "me");
3825
+ if (!message) throw new CliError("not_found", `No message ${ref} of yours in this ${target.group ? "group" : "chat"}: only your own messages are deleted for everyone`);
3826
+ const result = await node(ctx).removeMessage({
3827
+ linkId: target.linkId,
3828
+ messageId: message.id
3829
+ });
3830
+ if (result.error) throw new CliError(result.refused ? "refused" : "unavailable", result.error);
3831
+ return {
3832
+ [target.group ? "group" : "chat"]: target.id,
3833
+ deleted: message.id,
3834
+ everyone: true
3835
+ };
3836
+ }
3837
+ const ref = str(params, "message") ?? "<message>";
3838
+ const link = chatNotGroup(ctx, params, "message delete", `${/^[\w.:<>-]+$/.test(ref) ? ref : JSON.stringify(ref)} --everyone`);
3823
3839
  const messageId = str(params, "message", true);
3824
3840
  if (!await node(ctx).getMessage(link.id, messageId)) throw new CliError("not_found", `No message ${messageId} in this chat`);
3825
3841
  await node(ctx).deleteMessage({
@@ -4143,6 +4159,7 @@ var METHODS = {
4143
4159
  const raw = params.params;
4144
4160
  if (raw !== void 0 && (raw === null || typeof raw !== "object" || Array.isArray(raw))) throw new CliError("bad_request", "params must be an object");
4145
4161
  const args = raw;
4162
+ if (method === "updateSettings" && args?.settings && typeof args.settings === "object" && "relayOnly" in args.settings) throw new CliError("bad_request", "relayOnly is not a setting yet: Hide my IP from contacts comes in a later release");
4146
4163
  if (args && "confirmedReal" in args && !bool(params, "confirmReal")) throw new CliError("confirm", `${method} spends real money: pass --confirm-real (confirmReal: true over the socket) to confirm it`);
4147
4164
  const deletes = DESTRUCTIVE_CALLS.get(method);
4148
4165
  if (deletes && !bool(params, "yes")) throw new CliError("confirm", `${method} ${deletes}; pass --yes (yes: true over the socket) to go on`);
@@ -4304,6 +4321,20 @@ function editRefused(message, ref, where, error, refused) {
4304
4321
  * A page of a chat's or a group's history. Without `after` only that page is read from the store (the newest, or those
4305
4322
  * before `before`), so a long chat's is as quick as a short one's; with `after` the whole history is read and cut.
4306
4323
  */
4324
+ async function saveMark(ctx, params, remove) {
4325
+ const target = chatOrGroup(ctx, str(params, "chat", true)), messageId = str(params, "message", true);
4326
+ const result = await node(ctx).saveMessage({
4327
+ linkId: target.linkId,
4328
+ messageId,
4329
+ remove
4330
+ });
4331
+ if (result.error) throw new CliError(/not in this chat/.test(result.error) ? "not_found" : "bad_request", result.error);
4332
+ return {
4333
+ [target.group ? "group" : "chat"]: target.id,
4334
+ messageId,
4335
+ saved: !remove
4336
+ };
4337
+ }
4307
4338
  async function historyOf(ctx, chat, params, json = messageJson) {
4308
4339
  if (params.after !== void 0 && params.after !== null) {
4309
4340
  const whole = await node(ctx).getMessages(chat), { messages, more } = history(whole, params);
@@ -4400,4 +4431,4 @@ async function callApi(ctx, method, params = {}) {
4400
4431
  //#endregion
4401
4432
  export { flushCardUpdates as _, hideStateSecrets as a, paymentJson as c, nodeLocalFetch as d, chatJson as f, resumeHolds as g, groupMessageJson as h, groupSendRefused as i, reportAppFrames as l, groupJson as m, SETTABLE as n, mentionsFor as o, chatMessageJson as p, callApi as r, redactSettings as s, API_METHODS as t, servedApps as u };
4402
4433
 
4403
- //# sourceMappingURL=api-D70he3-A.js.map
4434
+ //# sourceMappingURL=api-Dy_05gaq.js.map