@ghostlytools/cli 1.4.5 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -7
- package/dist/assets/{api-XX7bbtTZ.js → api-C_IHKsrl.js} +2 -2
- package/dist/assets/{api-D70he3-A.js → api-ClHM_G5A.js} +87 -60
- package/dist/assets/api-ClHM_G5A.js.map +1 -0
- package/dist/assets/{apiKit-CpsEqF-1.js → apiKit-gS-yfb25.js} +2 -2
- package/dist/assets/{apiKit-CpsEqF-1.js.map → apiKit-gS-yfb25.js.map} +1 -1
- package/dist/assets/{apps-VA8W_YCQ.js → apps-DP8pElH-.js} +2 -2
- package/dist/assets/{apps-VA8W_YCQ.js.map → apps-DP8pElH-.js.map} +1 -1
- package/dist/assets/{apps-DVMnlwGF.js → apps-DyihkNO-.js} +1 -1
- package/dist/assets/{arkade-DxgW4-dK.js → arkade-GzJoov-w.js} +2 -2
- package/dist/assets/{arkade-DxgW4-dK.js.map → arkade-GzJoov-w.js.map} +1 -1
- package/dist/assets/{backup-BRTH1y3-.js → backup-A_C4hYNO.js} +1 -1
- package/dist/assets/{backup-c9xvXgCS.js → backup-DKDXkaS1.js} +6 -6
- package/dist/assets/{backup-c9xvXgCS.js.map → backup-DKDXkaS1.js.map} +1 -1
- package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
- package/dist/assets/{blobFiles-B0rNnHlO.js → blobFiles-1wUBd8ZD.js} +3 -3
- package/dist/assets/{blobFiles-B0rNnHlO.js.map → blobFiles-1wUBd8ZD.js.map} +1 -1
- package/dist/assets/{buttons-D31LBftz.js → buttons-BDw8cqDq.js} +3 -3
- package/dist/assets/{buttons-D31LBftz.js.map → buttons-BDw8cqDq.js.map} +1 -1
- package/dist/assets/buttons-CNkxiN2c.js +2 -0
- package/dist/assets/daemonProof-CWTVNUmr.js +254 -0
- package/dist/assets/daemonProof-CWTVNUmr.js.map +1 -0
- package/dist/assets/{envelope-hAl4pblf.js → envelope-DEvU5FA9.js} +2 -2
- package/dist/assets/{envelope-hAl4pblf.js.map → envelope-DEvU5FA9.js.map} +1 -1
- package/dist/assets/fedimint_client_wasm_bg-BtHHlFpp.js.map +1 -1
- package/dist/assets/{fileBytes-B-fqGdEd.js → fileBytes-B8eTZfAT.js} +3 -3
- package/dist/assets/{fileBytes-B-fqGdEd.js.map → fileBytes-B8eTZfAT.js.map} +1 -1
- package/dist/assets/{fileBytes-C2jycN_7.js → fileBytes-gTd_8l-P.js} +1 -1
- package/dist/assets/{fileBytes-D6fqFQEX.js → fileBytes-uRqLyxa0.js} +2 -2
- package/dist/assets/{fileBytes-D6fqFQEX.js.map → fileBytes-uRqLyxa0.js.map} +1 -1
- package/dist/assets/{fileBytesIdb-_HnxdacI.js → fileBytesIdb-BIFKtgln.js} +3 -3
- package/dist/assets/{fileBytesIdb-_HnxdacI.js.map → fileBytesIdb-BIFKtgln.js.map} +1 -1
- package/dist/assets/fileBytesIdb-BVVr_rWX.js +2 -0
- package/dist/assets/{fileBytesOpfs-p_CANncD.js → fileBytesOpfs-ChrHcCVV.js} +3 -3
- package/dist/assets/{fileBytesOpfs-p_CANncD.js.map → fileBytesOpfs-ChrHcCVV.js.map} +1 -1
- package/dist/assets/{groupFiles-gQ8_792r.js → groupFiles-Cr4Gj9-R.js} +45 -13
- package/dist/assets/groupFiles-Cr4Gj9-R.js.map +1 -0
- package/dist/assets/{host-Dmo6m7So.js → host-D0MIWyOe.js} +15 -122
- package/dist/assets/host-D0MIWyOe.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-DwkZ8vpt.js → hyperdhtRelay-SBo4aoMk.js} +2 -2
- package/dist/assets/{hyperdhtRelay-DwkZ8vpt.js.map → hyperdhtRelay-SBo4aoMk.js.map} +1 -1
- package/dist/assets/{idb-CMVgtn2k.js → idb-BJARz3Qi.js} +5 -3
- package/dist/assets/idb-BJARz3Qi.js.map +1 -0
- package/dist/assets/{irohWeb-DKJhESuV.js → irohWeb-D2WaYPdN.js} +2 -2
- package/dist/assets/{irohWeb-DKJhESuV.js.map → irohWeb-D2WaYPdN.js.map} +1 -1
- package/dist/assets/{main-DgXvK9Cr.js → main-DUG0nGLw.js} +240 -53
- package/dist/assets/main-DUG0nGLw.js.map +1 -0
- package/dist/assets/{mainline-9j_FqcJe.js → mainline-B8NGRodL.js} +2 -2
- package/dist/assets/{mainline-9j_FqcJe.js.map → mainline-B8NGRodL.js.map} +1 -1
- package/dist/assets/{networkReason-Bp8Huk9Z.js → networkReason-BAnNO1Ji.js} +3 -3
- package/dist/assets/{networkReason-Bp8Huk9Z.js.map → networkReason-BAnNO1Ji.js.map} +1 -1
- package/dist/assets/{nwc-DxIjNmYz.js → nwc-DQT3rx-s.js} +3 -3
- package/dist/assets/{nwc-DxIjNmYz.js.map → nwc-DQT3rx-s.js.map} +1 -1
- package/dist/assets/{nwcProvider-CyGVe35t.js → nwcProvider-Dq647EAl.js} +2 -2
- package/dist/assets/{nwcProvider-CyGVe35t.js.map → nwcProvider-Dq647EAl.js.map} +1 -1
- package/dist/assets/{profiles-ClRPr6y8.js → profiles-BehWURA9.js} +7 -3
- package/dist/assets/profiles-BehWURA9.js.map +1 -0
- package/dist/assets/{registry-siqMiD8L.js → registry-DFiOxH5q.js} +1 -1
- package/dist/assets/{registry-BTIRr7gH.js → registry-ieI8INKT.js} +3 -3
- package/dist/assets/registry-ieI8INKT.js.map +1 -0
- package/dist/assets/{resolve-CZ4yb7wp.js → resolve-C39pc4Kf.js} +2 -2
- package/dist/assets/{resolve-CZ4yb7wp.js.map → resolve-C39pc4Kf.js.map} +1 -1
- package/dist/assets/{restoredRows-DeBImGRd.js → restoredRows-DGuKtIBz.js} +2 -2
- package/dist/assets/{restoredRows-DeBImGRd.js.map → restoredRows-DGuKtIBz.js.map} +1 -1
- package/dist/assets/{server-ZrkwMbFo.js → server-DIICuvgy.js} +832 -149
- package/dist/assets/server-DIICuvgy.js.map +1 -0
- package/dist/assets/{src-CxEO33Hb.js → src-CwMTZ5Hj.js} +762 -54
- package/dist/assets/src-CwMTZ5Hj.js.map +1 -0
- package/dist/assets/{usdt-exH8dIZK.js → usdt-CxSyuXq4.js} +3 -3
- package/dist/assets/{usdt-exH8dIZK.js.map → usdt-CxSyuXq4.js.map} +1 -1
- package/dist/assets/{turnRefs-Dndxqyxk.js → words-31VaDW5h.js} +61 -3
- package/dist/assets/words-31VaDW5h.js.map +1 -0
- package/dist/ghostly.mjs +1 -1
- package/package.json +1 -1
- package/skills/ghostly/scripts/status +3 -2
- package/dist/assets/api-D70he3-A.js.map +0 -1
- package/dist/assets/buttons-CtGCix-8.js +0 -2
- package/dist/assets/daemonProof-B53VnZ1Z.js +0 -100
- package/dist/assets/daemonProof-B53VnZ1Z.js.map +0 -1
- package/dist/assets/fileBytesIdb-DOxm_BKt.js +0 -2
- package/dist/assets/groupFiles-gQ8_792r.js.map +0 -1
- package/dist/assets/host-Dmo6m7So.js.map +0 -1
- package/dist/assets/idb-CMVgtn2k.js.map +0 -1
- package/dist/assets/main-DgXvK9Cr.js.map +0 -1
- package/dist/assets/profiles-ClRPr6y8.js.map +0 -1
- package/dist/assets/registry-BTIRr7gH.js.map +0 -1
- package/dist/assets/server-ZrkwMbFo.js.map +0 -1
- package/dist/assets/src-CxEO33Hb.js.map +0 -1
- 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
|
|
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
|
|
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
|
|
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
|
-
|
|
391
|
-
|
|
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>`
|
|
394
|
-
|
|
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,3 +1,3 @@
|
|
|
1
|
-
import { a as findChat, s as findGroup } from "./apiKit-
|
|
2
|
-
import { a as hideStateSecrets, i as groupSendRefused, n as SETTABLE, o as mentionsFor, r as callApi, s as redactSettings, t as API_METHODS } from "./api-
|
|
1
|
+
import { a as findChat, s as findGroup } from "./apiKit-gS-yfb25.js";
|
|
2
|
+
import { a as hideStateSecrets, i as groupSendRefused, n as SETTABLE, o as mentionsFor, r as callApi, s as redactSettings, t as API_METHODS } from "./api-ClHM_G5A.js";
|
|
3
3
|
export { API_METHODS, SETTABLE, callApi, findChat, findGroup, groupSendRefused, hideStateSecrets, mentionsFor, redactSettings };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { l as fileStore } from "./idb-
|
|
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-
|
|
4
|
-
import { f as FILE_BYTES_STEP, o as fileBytes, s as fileBytesOf } from "./fileBytes-
|
|
5
|
-
import { t as IDENTITY_PROVIDERS } from "./registry-
|
|
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-
|
|
7
|
-
import { a as
|
|
1
|
+
import { Ec as isAppUrl, Eo as LIMITS, Ga as STATUS_CARD_LIMITS, Hi as identityStatement, Mr as TYPING_REFRESH_MS, Pc as appRef, Pr as sanitizeTypingStatus, Rc as isAppRef, So as GhostlyHttpError, Un as GROUP_FILE_LIMITS, Wc as readImageMeta, Y as groupName, Ya as cardLine, Za as checkStatusCard, au as sanitizeAvatar, ca as PLAYABLE_AUDIO, du as toBase64Url, ei as APP_DATA_MAX_BYTES, fa as parseVoiceMeta, go as AWAITING_PEER_MS, il as inviteLink, iu as MAX_AVATAR_LENGTH, jr as TYPING_KINDS, la as VOICE_LIMITS, oa as sanitizeFileName, ol as ownInviteRefusal, pa as voicePeaksOf, qa as appCardId, sa as sanitizeMime, ua as baseMime, uu as randomBytes$1, xc as APP_PERMISSIONS } from "./src-CwMTZ5Hj.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-Cr4Gj9-R.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-ieI8INKT.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-BDw8cqDq.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-31VaDW5h.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-
|
|
10
|
-
import { a as checkShownName } from "./profiles-
|
|
11
|
-
import { t as BACKUP_METHODS } from "./backup-
|
|
12
|
-
import { o as checkedBundle } from "./apps-
|
|
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-gS-yfb25.js";
|
|
10
|
+
import { a as checkShownName } from "./profiles-BehWURA9.js";
|
|
11
|
+
import { t as BACKUP_METHODS } from "./backup-DKDXkaS1.js";
|
|
12
|
+
import { o as checkedBundle } from "./apps-DP8pElH-.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
|
|
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
|
|
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) {
|
|
@@ -2198,6 +2198,14 @@ function cookieValues(header, name) {
|
|
|
2198
2198
|
function sameSecret(a, b) {
|
|
2199
2199
|
return a.length === b.length && timingSafeEqual(Buffer.from(a), Buffer.from(b));
|
|
2200
2200
|
}
|
|
2201
|
+
/**
|
|
2202
|
+
* Added to every answer of a contact's app, next to any policy the contact sends (a browser enforces both): its
|
|
2203
|
+
* scripts and forms reach its own origin and public https sites, never plain http. The page is served from
|
|
2204
|
+
* `<random>.localhost`, which Chrome counts as this machine, so its own guard for requests to local addresses
|
|
2205
|
+
* (Local Network Access) would not ask before the page read or posted to another service on 127.0.0.1 or the local
|
|
2206
|
+
* network. Pictures, frames and navigation are not covered.
|
|
2207
|
+
*/
|
|
2208
|
+
var OPENED_SERVICE_CSP = "connect-src 'self' https: wss:; form-action 'self' https:";
|
|
2201
2209
|
function plain(response, status, text, headers = {}) {
|
|
2202
2210
|
response.writeHead(status, {
|
|
2203
2211
|
"content-type": "text/plain; charset=utf-8",
|
|
@@ -2288,8 +2296,10 @@ async function proxy(request, response, chunks, send, cookies) {
|
|
|
2288
2296
|
if (!cookie) continue;
|
|
2289
2297
|
if (cookies.size < MAX_COOKIE_NAMES) cookies.add(setCookieName(cookie));
|
|
2290
2298
|
out[lower] = [...out[lower] ?? [], cookie];
|
|
2291
|
-
} else out[lower] = value;
|
|
2299
|
+
} else if (lower === "content-security-policy") out[lower] = [...out[lower] ?? [], value];
|
|
2300
|
+
else out[lower] = value;
|
|
2292
2301
|
}
|
|
2302
|
+
out["content-security-policy"] = [...out["content-security-policy"] ?? [], OPENED_SERVICE_CSP];
|
|
2293
2303
|
response.writeHead(answer.status, out);
|
|
2294
2304
|
await pipeline(Readable.from(answer.body, { objectMode: false }), response);
|
|
2295
2305
|
} catch (error) {
|
|
@@ -2719,30 +2729,6 @@ var NOT_SENT = {
|
|
|
2719
2729
|
* call says `confirmReal: true` (the CLI's `--confirm-real`): no flag, no spend.
|
|
2720
2730
|
*/
|
|
2721
2731
|
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
2732
|
/**
|
|
2747
2733
|
* What the app has and a headless Ghostly cannot run yet, and why (WISP 1100 § Wallet SDKs on Node). New offers
|
|
2748
2734
|
* them as unavailable; creating one is refused before the engine is asked.
|
|
@@ -2961,7 +2947,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
|
|
|
2961
2947
|
};
|
|
2962
2948
|
},
|
|
2963
2949
|
async "wallet.create"(ctx, params) {
|
|
2964
|
-
const type = oneOf(params, "type",
|
|
2950
|
+
const type = oneOf(params, "type", WALLET_TYPES, "cashu");
|
|
2965
2951
|
const n = network(params);
|
|
2966
2952
|
const gap = NODE_GAPS[type];
|
|
2967
2953
|
if (gap) throw new CliError("unavailable", gap);
|
|
@@ -2983,7 +2969,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
|
|
|
2983
2969
|
}), state(ctx));
|
|
2984
2970
|
},
|
|
2985
2971
|
async "wallet.remove"(ctx, params) {
|
|
2986
|
-
const type = oneOf(params, "type",
|
|
2972
|
+
const type = oneOf(params, "type", WALLET_TYPES, "cashu");
|
|
2987
2973
|
const n = network(params);
|
|
2988
2974
|
const card = cardOf(ctx, params, type);
|
|
2989
2975
|
try {
|
|
@@ -3005,7 +2991,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
|
|
|
3005
2991
|
} };
|
|
3006
2992
|
},
|
|
3007
2993
|
async "wallet.faucet"(ctx, params) {
|
|
3008
|
-
const type = oneOf(params, "type",
|
|
2994
|
+
const type = oneOf(params, "type", WALLET_TYPES, "cashu");
|
|
3009
2995
|
if (network(params) !== "testnet") throw new CliError("refused", "Test coins are for Testnet wallets only");
|
|
3010
2996
|
const card = cardOf(ctx, params, type);
|
|
3011
2997
|
return node(ctx).walletTestCoins({
|
|
@@ -3048,12 +3034,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
|
|
|
3048
3034
|
};
|
|
3049
3035
|
},
|
|
3050
3036
|
async "wallet.address"(ctx, params) {
|
|
3051
|
-
const type = oneOf(params, "type",
|
|
3052
|
-
"bitcoin",
|
|
3053
|
-
"arkade",
|
|
3054
|
-
"spark",
|
|
3055
|
-
"usdt"
|
|
3056
|
-
], "bitcoin");
|
|
3037
|
+
const type = oneOf(params, "type", ADDRESS_TYPES, "bitcoin");
|
|
3057
3038
|
const n = network(params);
|
|
3058
3039
|
if (type === "bitcoin") return {
|
|
3059
3040
|
type,
|
|
@@ -3182,7 +3163,7 @@ var WALLET_METHODS = Object.fromEntries(Object.entries({
|
|
|
3182
3163
|
const link = chatOf(ctx, params);
|
|
3183
3164
|
const amount = num(params, "amount", 0, { min: 1 });
|
|
3184
3165
|
if (!amount) throw new CliError("bad_request", "amount is required");
|
|
3185
|
-
const method = params.method === void 0 ? void 0 : oneOf(params, "method",
|
|
3166
|
+
const method = params.method === void 0 ? void 0 : oneOf(params, "method", PAY_METHODS, "cashu");
|
|
3186
3167
|
const rail = params.rail === void 0 ? void 0 : oneOf(params, "rail", ["cashu", "lightning"], "cashu");
|
|
3187
3168
|
await federationsOpen(ctx);
|
|
3188
3169
|
const { paymentId } = await node(ctx).requestPayment({
|
|
@@ -3346,16 +3327,6 @@ function relayRefused(error, patch) {
|
|
|
3346
3327
|
].filter((key) => Object.hasOwn(patch, key));
|
|
3347
3328
|
return new CliError("bad_request", `${keys.join(", ") || "relays"}: ${error.message.replace(/^Enter /, "give ").replace(/^(Not|Use) /, (word) => word.toLowerCase())}`);
|
|
3348
3329
|
}
|
|
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
3330
|
/** The engine keeps a chat's name to 48 UTF-16 units (renameLink). */
|
|
3360
3331
|
var CHAT_NAME_UNITS = 48;
|
|
3361
3332
|
/**
|
|
@@ -3732,6 +3703,30 @@ var METHODS = {
|
|
|
3732
3703
|
removed: remove
|
|
3733
3704
|
};
|
|
3734
3705
|
},
|
|
3706
|
+
/** Saved messages: a mark on a message of a chat or a group, kept for this profile on this device; nothing is sent. */
|
|
3707
|
+
async "saved.add"(ctx, params) {
|
|
3708
|
+
return saveMark(ctx, params, false);
|
|
3709
|
+
},
|
|
3710
|
+
async "saved.remove"(ctx, params) {
|
|
3711
|
+
return saveMark(ctx, params, true);
|
|
3712
|
+
},
|
|
3713
|
+
/** The saved messages, the last saved first, each as it is now and named by its chat or group. */
|
|
3714
|
+
async "saved.list"(ctx) {
|
|
3715
|
+
const { links, groups } = state(ctx);
|
|
3716
|
+
return (await node(ctx).savedMessages()).map(({ savedAt, message }) => {
|
|
3717
|
+
if (!message.linkId.startsWith("group:")) return {
|
|
3718
|
+
chat: message.linkId,
|
|
3719
|
+
savedAt,
|
|
3720
|
+
message: chatMessageJson(message, links.find((l) => l.id === message.linkId))
|
|
3721
|
+
};
|
|
3722
|
+
const id = message.linkId.slice(6);
|
|
3723
|
+
return {
|
|
3724
|
+
group: id,
|
|
3725
|
+
savedAt,
|
|
3726
|
+
message: groupMessageJson(message, groups.find((g) => g.id === id))
|
|
3727
|
+
};
|
|
3728
|
+
});
|
|
3729
|
+
},
|
|
3735
3730
|
/**
|
|
3736
3731
|
* 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
3732
|
* that says it was forwarded (one hop more) and nothing of who wrote it. A file goes from the bytes here, never
|
|
@@ -3819,7 +3814,24 @@ var METHODS = {
|
|
|
3819
3814
|
};
|
|
3820
3815
|
},
|
|
3821
3816
|
async "chat.delete"(ctx, params) {
|
|
3822
|
-
|
|
3817
|
+
if (bool(params, "everyone")) {
|
|
3818
|
+
const target = chatOrGroup(ctx, str(params, "chat", true));
|
|
3819
|
+
const ref = str(params, "message", true);
|
|
3820
|
+
const message = await messageOf(ctx, target.linkId, ref, (m) => m.sender === "me");
|
|
3821
|
+
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`);
|
|
3822
|
+
const result = await node(ctx).removeMessage({
|
|
3823
|
+
linkId: target.linkId,
|
|
3824
|
+
messageId: message.id
|
|
3825
|
+
});
|
|
3826
|
+
if (result.error) throw new CliError(result.refused ? "refused" : "unavailable", result.error);
|
|
3827
|
+
return {
|
|
3828
|
+
[target.group ? "group" : "chat"]: target.id,
|
|
3829
|
+
deleted: message.id,
|
|
3830
|
+
everyone: true
|
|
3831
|
+
};
|
|
3832
|
+
}
|
|
3833
|
+
const ref = str(params, "message") ?? "<message>";
|
|
3834
|
+
const link = chatNotGroup(ctx, params, "message delete", `${/^[\w.:<>-]+$/.test(ref) ? ref : JSON.stringify(ref)} --everyone`);
|
|
3823
3835
|
const messageId = str(params, "message", true);
|
|
3824
3836
|
if (!await node(ctx).getMessage(link.id, messageId)) throw new CliError("not_found", `No message ${messageId} in this chat`);
|
|
3825
3837
|
await node(ctx).deleteMessage({
|
|
@@ -4143,6 +4155,7 @@ var METHODS = {
|
|
|
4143
4155
|
const raw = params.params;
|
|
4144
4156
|
if (raw !== void 0 && (raw === null || typeof raw !== "object" || Array.isArray(raw))) throw new CliError("bad_request", "params must be an object");
|
|
4145
4157
|
const args = raw;
|
|
4158
|
+
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
4159
|
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
4160
|
const deletes = DESTRUCTIVE_CALLS.get(method);
|
|
4148
4161
|
if (deletes && !bool(params, "yes")) throw new CliError("confirm", `${method} ${deletes}; pass --yes (yes: true over the socket) to go on`);
|
|
@@ -4304,6 +4317,20 @@ function editRefused(message, ref, where, error, refused) {
|
|
|
4304
4317
|
* 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
4318
|
* 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
4319
|
*/
|
|
4320
|
+
async function saveMark(ctx, params, remove) {
|
|
4321
|
+
const target = chatOrGroup(ctx, str(params, "chat", true)), messageId = str(params, "message", true);
|
|
4322
|
+
const result = await node(ctx).saveMessage({
|
|
4323
|
+
linkId: target.linkId,
|
|
4324
|
+
messageId,
|
|
4325
|
+
remove
|
|
4326
|
+
});
|
|
4327
|
+
if (result.error) throw new CliError(/not in this chat/.test(result.error) ? "not_found" : "bad_request", result.error);
|
|
4328
|
+
return {
|
|
4329
|
+
[target.group ? "group" : "chat"]: target.id,
|
|
4330
|
+
messageId,
|
|
4331
|
+
saved: !remove
|
|
4332
|
+
};
|
|
4333
|
+
}
|
|
4307
4334
|
async function historyOf(ctx, chat, params, json = messageJson) {
|
|
4308
4335
|
if (params.after !== void 0 && params.after !== null) {
|
|
4309
4336
|
const whole = await node(ctx).getMessages(chat), { messages, more } = history(whole, params);
|
|
@@ -4400,4 +4427,4 @@ async function callApi(ctx, method, params = {}) {
|
|
|
4400
4427
|
//#endregion
|
|
4401
4428
|
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
4429
|
|
|
4403
|
-
//# sourceMappingURL=api-
|
|
4430
|
+
//# sourceMappingURL=api-ClHM_G5A.js.map
|