@ipab/cli 0.1.0-rc.2 → 0.1.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -14
- package/dist/app-authoring.d.ts.map +1 -1
- package/dist/app-authoring.js +11 -2
- package/dist/app-authoring.js.map +1 -1
- package/dist/app-definition.d.ts +52 -57
- package/dist/app-definition.d.ts.map +1 -1
- package/dist/app-definition.js +33 -38
- package/dist/app-definition.js.map +1 -1
- package/dist/app-templates.d.ts.map +1 -1
- package/dist/app-templates.js +2 -1
- package/dist/app-templates.js.map +1 -1
- package/dist/assembly.d.ts.map +1 -1
- package/dist/assembly.js +3 -4
- package/dist/assembly.js.map +1 -1
- package/dist/authoring.d.ts +3 -7
- package/dist/authoring.d.ts.map +1 -1
- package/dist/authoring.js +22 -12
- package/dist/authoring.js.map +1 -1
- package/dist/builtins/skill.ipab.car +0 -0
- package/dist/builtins/template.node.car +0 -0
- package/dist/builtins/template.web-app.car +0 -0
- package/dist/builtins.d.ts.map +1 -1
- package/dist/builtins.js +18 -2
- package/dist/builtins.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +306 -116
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +2 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +19 -15
- package/dist/config.js.map +1 -1
- package/dist/content-provider.d.ts +1 -1
- package/dist/content-provider.d.ts.map +1 -1
- package/dist/content-provider.js +5 -2
- package/dist/content-provider.js.map +1 -1
- package/dist/get.d.ts.map +1 -1
- package/dist/get.js +34 -15
- package/dist/get.js.map +1 -1
- package/dist/kubo.d.ts +38 -0
- package/dist/kubo.d.ts.map +1 -0
- package/dist/kubo.js +528 -0
- package/dist/kubo.js.map +1 -0
- package/dist/pins.d.ts +3 -3
- package/dist/pins.js +1 -1
- package/dist/pins.js.map +1 -1
- package/dist/setup.d.ts +7 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +22 -0
- package/dist/setup.js.map +1 -0
- package/dist/source-bundle.d.ts +3 -8
- package/dist/source-bundle.d.ts.map +1 -1
- package/dist/source-bundle.js +16 -11
- package/dist/source-bundle.js.map +1 -1
- package/dist/space.d.ts.map +1 -1
- package/dist/space.js +2 -2
- package/dist/space.js.map +1 -1
- package/dist/state.d.ts +4 -4
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +11 -12
- package/dist/state.js.map +1 -1
- package/dist/swarm-envelope.d.ts +36 -0
- package/dist/swarm-envelope.d.ts.map +1 -0
- package/dist/swarm-envelope.js +145 -0
- package/dist/swarm-envelope.js.map +1 -0
- package/dist/swarm-files.d.ts +5 -0
- package/dist/swarm-files.d.ts.map +1 -0
- package/dist/swarm-files.js +94 -0
- package/dist/swarm-files.js.map +1 -0
- package/dist/swarm.d.ts +117 -57
- package/dist/swarm.d.ts.map +1 -1
- package/dist/swarm.js +1033 -548
- package/dist/swarm.js.map +1 -1
- package/dist/template-definition.d.ts +47 -52
- package/dist/template-definition.d.ts.map +1 -1
- package/dist/template-definition.js +36 -41
- package/dist/template-definition.js.map +1 -1
- package/dist/template-source.d.ts +2 -0
- package/dist/template-source.d.ts.map +1 -1
- package/dist/template-source.js +4 -3
- package/dist/template-source.js.map +1 -1
- package/package.json +3 -3
- package/src/app-authoring.ts +22 -5
- package/src/app-definition.ts +33 -39
- package/src/app-templates.ts +9 -1
- package/src/assembly.ts +7 -4
- package/src/authoring.ts +31 -14
- package/src/builtins.ts +23 -2
- package/src/cli.ts +362 -139
- package/src/config.ts +22 -18
- package/src/content-provider.ts +5 -4
- package/src/get.ts +37 -15
- package/src/kubo.ts +691 -0
- package/src/pins.ts +1 -1
- package/src/setup.ts +21 -0
- package/src/source-bundle.ts +25 -12
- package/src/space.ts +2 -5
- package/src/state.ts +14 -13
- package/src/swarm-envelope.ts +255 -0
- package/src/swarm-files.ts +100 -0
- package/src/swarm.ts +1676 -837
- package/src/template-definition.ts +36 -41
- package/src/template-source.ts +10 -3
package/dist/cli.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createInterface } from "node:readline/promises";
|
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import { IpfsStore } from "@ipab/ipfs-store";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
|
+
import { CID } from "multiformats/cid";
|
|
5
6
|
import stringWidth from "string-width";
|
|
6
7
|
import { configKey, effectiveConfig, parseValue, publicUrl, stateLocation, storeConfiguration, visibleConfig, } from "./config.js";
|
|
7
8
|
import { HostError, message, object, syntax } from "./errors.js";
|
|
@@ -13,7 +14,9 @@ import { buildBundle, inspectBundle, importBundle } from "./authoring.js";
|
|
|
13
14
|
import { initApp } from "./app-authoring.js";
|
|
14
15
|
import { assembleBundle } from "./assembly.js";
|
|
15
16
|
import { getBundle } from "./get.js";
|
|
16
|
-
import {
|
|
17
|
+
import { setupDevice } from "./setup.js";
|
|
18
|
+
import { keyId } from "@ipab/bundle/pointer/crypto";
|
|
19
|
+
import { createSwarm, requestMembership, approveMembership, exportRequest, removeMember, resumeRemoval, updateProfile, verifiedRequest, membershipRequestSummary, swarmHeader, addSwarm, updateSwarm, searchNames, resolveReference, publish, } from "./swarm.js";
|
|
17
20
|
import { schemaAlias } from "./app-definition.js";
|
|
18
21
|
import { addPin, deletePin, pinDetails, renamePin } from "./pins.js";
|
|
19
22
|
import { logFiles } from "./logs.js";
|
|
@@ -50,16 +53,20 @@ export const processIO = {
|
|
|
50
53
|
},
|
|
51
54
|
};
|
|
52
55
|
const commands = {
|
|
56
|
+
setup: "setup [--yes]",
|
|
53
57
|
"swarm create": "swarm create [--service URL] [--resume OPERATION]",
|
|
54
|
-
"swarm request": "swarm request
|
|
55
|
-
"swarm
|
|
56
|
-
"swarm
|
|
57
|
-
"swarm
|
|
58
|
+
"swarm request": "swarm request CONFIG_URL --owner-fingerprint FINGERPRINT [--output FILE] [--alias ALIAS]",
|
|
59
|
+
"swarm export": "swarm export URL_OR_ALIAS --output FILE",
|
|
60
|
+
"swarm approve": "swarm approve REQUEST_FILE [--again] --yes",
|
|
61
|
+
"swarm exclude": "swarm exclude MEMBER_PUBLIC_KEY [--swarm URL_OR_ALIAS] --yes",
|
|
62
|
+
"swarm resume": "swarm resume [URL_OR_ALIAS]",
|
|
63
|
+
"swarm profile": "swarm profile [URL_OR_ALIAS] [--name NAME] [--address MULTIADDR]",
|
|
64
|
+
"swarm status": "swarm status [URL_OR_ALIAS]",
|
|
58
65
|
"swarm list": "swarm list",
|
|
59
|
-
"swarm add": "swarm add
|
|
60
|
-
"swarm use": "swarm use
|
|
61
|
-
"swarm remove": "swarm remove
|
|
62
|
-
"swarm update": "swarm update [
|
|
66
|
+
"swarm add": "swarm add CONFIG_URL [--alias ALIAS]",
|
|
67
|
+
"swarm use": "swarm use URL_OR_ALIAS",
|
|
68
|
+
"swarm remove": "swarm remove URL_OR_ALIAS",
|
|
69
|
+
"swarm update": "swarm update [URL_OR_ALIAS] [--name TEXT] [--description TEXT]",
|
|
63
70
|
publish: "publish CID_OR_CAR [--name NAME [--expect OLD_NODE_CID | --snapshot]]",
|
|
64
71
|
get: "get REF [--raw] [--force | --no-force] [-o DIRECTORY]",
|
|
65
72
|
search: "search QUERY [--current] [--force | --no-force]",
|
|
@@ -97,6 +104,17 @@ const groups = {
|
|
|
97
104
|
history: "View and remove execution history",
|
|
98
105
|
};
|
|
99
106
|
const commandHelp = {
|
|
107
|
+
setup: {
|
|
108
|
+
summary: "Verify/install Kubo and prepare the protected HOME account identity",
|
|
109
|
+
examples: ["ipab setup --yes", "ipab setup"],
|
|
110
|
+
options: [
|
|
111
|
+
"--yes Confirm installation and identity initialization outside a TTY.",
|
|
112
|
+
],
|
|
113
|
+
notes: [
|
|
114
|
+
"Idempotent: reuse the same verified program and existing identity.",
|
|
115
|
+
"Does not create Swarm repos, start or contact any daemon, deploy services or install login startup.",
|
|
116
|
+
],
|
|
117
|
+
},
|
|
100
118
|
"swarm create": {
|
|
101
119
|
summary: "Create a swarm using the account HOME identity",
|
|
102
120
|
options: [
|
|
@@ -113,32 +131,56 @@ const commandHelp = {
|
|
|
113
131
|
],
|
|
114
132
|
notes: [
|
|
115
133
|
"Creation uses the protected, origin-bound API key and owner possession proof.",
|
|
116
|
-
"
|
|
117
|
-
"Returns
|
|
134
|
+
"Installs checksum-verified Kubo on demand; each Swarm has its own protected repo and ports.",
|
|
135
|
+
"Returns the public organization configuration URL; owner needs no certificate.",
|
|
118
136
|
],
|
|
119
137
|
},
|
|
120
138
|
"swarm request": {
|
|
121
|
-
summary: "
|
|
122
|
-
examples: [
|
|
139
|
+
summary: "Save and export a signed self-contained membership Request",
|
|
140
|
+
examples: [
|
|
141
|
+
"ipab swarm request CONFIG_URL --owner-fingerprint TRUSTED_FINGERPRINT --output request.json --alias work",
|
|
142
|
+
],
|
|
143
|
+
options: [
|
|
144
|
+
"--owner-fingerprint VALUE Verify Owner through a trusted independent channel.",
|
|
145
|
+
"--name NAME Initial public display name.",
|
|
146
|
+
"--alias ALIAS Pre-register the target for lazy onboarding.",
|
|
147
|
+
"--output FILE Export the saved exact Request; no expiry or new PeerID on retry.",
|
|
148
|
+
],
|
|
123
149
|
notes: [
|
|
124
|
-
"
|
|
150
|
+
"No Invite, Response file, password or Join. Next normal use fetches and decrypts the approved package.",
|
|
125
151
|
],
|
|
126
152
|
},
|
|
127
153
|
"swarm approve": {
|
|
128
154
|
summary: "Owner signs a certificate for an exact request",
|
|
129
155
|
options: [
|
|
130
156
|
"--yes Explicit approval; required outside a TTY.",
|
|
131
|
-
"--
|
|
157
|
+
"--again Explicit fresh approval of an old Request; history is advisory.",
|
|
158
|
+
],
|
|
159
|
+
examples: ["ipab swarm approve request.json --yes"],
|
|
160
|
+
notes: [
|
|
161
|
+
"Creates a public profile and publishes an Owner-signed X25519/AES-GCM package. Exact-ID certificates have no expiry.",
|
|
132
162
|
],
|
|
133
|
-
examples: ["ipab swarm approve REQUEST_CID --yes"],
|
|
134
|
-
notes: ["Returns one response CID. Never exports the owner private key."],
|
|
135
163
|
},
|
|
136
|
-
"swarm
|
|
137
|
-
summary: "
|
|
138
|
-
examples: ["ipab swarm
|
|
139
|
-
|
|
164
|
+
"swarm export": {
|
|
165
|
+
summary: "Re-export the same persisted Request",
|
|
166
|
+
examples: ["ipab swarm export work --output request.json"],
|
|
167
|
+
},
|
|
168
|
+
"swarm exclude": {
|
|
169
|
+
summary: "Owner removes a member with irreversible HEAD/key rotation",
|
|
170
|
+
examples: ["ipab --swarm work swarm exclude MEMBER_PUBLIC_KEY --yes"],
|
|
140
171
|
notes: [
|
|
141
|
-
"
|
|
172
|
+
"Freezes the old HEAD atomically, preserves its final committed publication, rotates the key and remaining packages, deletes the leaving profile and retires the old HEAD.",
|
|
173
|
+
],
|
|
174
|
+
},
|
|
175
|
+
"swarm resume": {
|
|
176
|
+
summary: "Owner resumes an interrupted organization switch",
|
|
177
|
+
examples: ["ipab swarm resume work"],
|
|
178
|
+
},
|
|
179
|
+
"swarm profile": {
|
|
180
|
+
summary: "Update your public display name and LAN/VPN IPv4 TCP address",
|
|
181
|
+
examples: [
|
|
182
|
+
"ipab swarm profile work --name Wei",
|
|
183
|
+
"ipab swarm profile work --address /ip4/192.168.1.12/tcp/4001/p2p/PEER_ID",
|
|
142
184
|
],
|
|
143
185
|
},
|
|
144
186
|
"swarm status": {
|
|
@@ -158,7 +200,7 @@ const commandHelp = {
|
|
|
158
200
|
options: [
|
|
159
201
|
"--alias ALIAS Unique local alias; does not rename the shared swarm.",
|
|
160
202
|
],
|
|
161
|
-
examples: ["ipab swarm add
|
|
203
|
+
examples: ["ipab swarm add CONFIG_URL --alias work"],
|
|
162
204
|
notes: [
|
|
163
205
|
"Not a membership grant. The first registration becomes the saved default only if none exists.",
|
|
164
206
|
],
|
|
@@ -176,8 +218,8 @@ const commandHelp = {
|
|
|
176
218
|
],
|
|
177
219
|
},
|
|
178
220
|
"swarm update": {
|
|
179
|
-
summary: "
|
|
180
|
-
arguments: ["
|
|
221
|
+
summary: "Owner updates public organization information",
|
|
222
|
+
arguments: ["URL_OR_ALIAS Defaults to the effective current swarm."],
|
|
181
223
|
options: [
|
|
182
224
|
"--name TEXT Replace the shared display name; empty text clears it.",
|
|
183
225
|
"--description TEXT Replace the shared description; empty text clears it.",
|
|
@@ -187,9 +229,8 @@ const commandHelp = {
|
|
|
187
229
|
'ipab swarm update --description ""',
|
|
188
230
|
],
|
|
189
231
|
notes: [
|
|
190
|
-
"Requires at least one field.
|
|
191
|
-
"
|
|
192
|
-
"Automatically retries HEAD contention while preserving current Names and unspecified properties.",
|
|
232
|
+
"Requires at least one field. Members can change only their own profile.",
|
|
233
|
+
"Content-CID CAS prevents overwriting concurrent organization changes.",
|
|
193
234
|
"Shared name changes do not rename local registry aliases.",
|
|
194
235
|
],
|
|
195
236
|
},
|
|
@@ -234,16 +275,18 @@ const commandHelp = {
|
|
|
234
275
|
"--raw Select the Artifact node instead of its value.",
|
|
235
276
|
"--force Refresh the shared Name's swarm HEAD.",
|
|
236
277
|
"--no-force Override swarm.forceRefresh and use valid cached headers.",
|
|
237
|
-
"-o, --output DIRECTORY New or empty directory; defaults to
|
|
278
|
+
"-o, --output DIRECTORY New or empty directory; defaults to a unique temporary directory.",
|
|
238
279
|
],
|
|
239
280
|
examples: [
|
|
240
281
|
"ipab --json get ipab:///apps/hello -o hello-app",
|
|
241
282
|
"ipab get ipab://work/apps/hello -o hello-app",
|
|
283
|
+
"ipab get CONTENT_CID",
|
|
242
284
|
"ipab get --raw RELEASE_CID",
|
|
243
285
|
],
|
|
244
286
|
notes: [
|
|
245
|
-
"
|
|
246
|
-
"
|
|
287
|
+
"Stdout contains only the absolute directory path; --json also returns content and original target CIDs.",
|
|
288
|
+
"Temporary exports remain after exit; copy before cleanup, not symlink. Use --output for a persistent destination.",
|
|
289
|
+
"ipab://ALIAS_OR_ENCODED_CONFIG_URL/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
|
|
247
290
|
"Does not install, build, edit, or automatically retrieve associated source.",
|
|
248
291
|
],
|
|
249
292
|
},
|
|
@@ -294,7 +337,7 @@ const commandHelp = {
|
|
|
294
337
|
],
|
|
295
338
|
notes: [
|
|
296
339
|
"Recipe explicitly maps source files and exact CID imports to target paths.",
|
|
297
|
-
"
|
|
340
|
+
"Instance paths come from .bundle.yaml; the referenced file defines the type. Imported DAG identities are preserved.",
|
|
298
341
|
"Legacy App ipab.yaml is rejected; use project preparation tools separately.",
|
|
299
342
|
"Select explicit files; review private files before providing Bundles.",
|
|
300
343
|
"Store failures preserve the CAR; retry with ipab bundle import FILE.car.",
|
|
@@ -311,7 +354,7 @@ const commandHelp = {
|
|
|
311
354
|
],
|
|
312
355
|
examples: [
|
|
313
356
|
"ipab bundle build note",
|
|
314
|
-
"ipab bundle build types\\.bundle.yaml --schema-only",
|
|
357
|
+
"ipab bundle build types\\.bundle-type.yaml --schema-only",
|
|
315
358
|
],
|
|
316
359
|
notes: [
|
|
317
360
|
"Imports into the configured Store without pinning or executing Apps.",
|
|
@@ -350,7 +393,7 @@ const commandHelp = {
|
|
|
350
393
|
],
|
|
351
394
|
notes: [
|
|
352
395
|
"Apps are NOT sandboxed; run only Apps you trust.",
|
|
353
|
-
"ipab://
|
|
396
|
+
"ipab://ALIAS_OR_ENCODED_CONFIG_URL/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
|
|
354
397
|
"History stores argv by default; do not put secrets in arguments.",
|
|
355
398
|
"Logs may contain secrets; stdin is never logged. Logging makes output non-TTY.",
|
|
356
399
|
"--json is not supported; App stdio is passed through.",
|
|
@@ -372,7 +415,7 @@ const commandHelp = {
|
|
|
372
415
|
],
|
|
373
416
|
notes: [
|
|
374
417
|
"Requires a saved registration and App support for the exact content type.",
|
|
375
|
-
"ipab://
|
|
418
|
+
"ipab://ALIAS_OR_ENCODED_CONFIG_URL/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
|
|
376
419
|
"Apps are NOT sandboxed; run only Apps you trust.",
|
|
377
420
|
"Logs may contain secrets; stdin is never logged. Logging makes output non-TTY.",
|
|
378
421
|
"--json is not supported; App stdio is passed through.",
|
|
@@ -521,7 +564,7 @@ const commandHelp = {
|
|
|
521
564
|
};
|
|
522
565
|
export function help(path = "") {
|
|
523
566
|
const globalOptions = `Global options (before COMMAND):
|
|
524
|
-
--swarm
|
|
567
|
+
--swarm URL|ALIAS Select shared swarm (otherwise swarm.default; URI swarm takes precedence)
|
|
525
568
|
--state-dir PATH Set the local state directory
|
|
526
569
|
--store-gateway URL Use a read-only upstream HTTP gateway
|
|
527
570
|
--json Output management/development metadata, not App stdio`;
|
|
@@ -541,6 +584,7 @@ Create:
|
|
|
541
584
|
bundle ${groups.bundle}
|
|
542
585
|
|
|
543
586
|
Manage:
|
|
587
|
+
setup ${commandHelp.setup.summary}
|
|
544
588
|
swarm ${groups.swarm}
|
|
545
589
|
search Search formal Names across registered swarms
|
|
546
590
|
publish ${commandHelp.publish.summary}
|
|
@@ -759,7 +803,7 @@ export function parse(argv) {
|
|
|
759
803
|
result.positional = tokens;
|
|
760
804
|
return result;
|
|
761
805
|
}
|
|
762
|
-
if (!["open", "init", "build", "publish", "get", "search"].includes(group)) {
|
|
806
|
+
if (!["open", "init", "build", "publish", "get", "search", "setup"].includes(group)) {
|
|
763
807
|
if (![
|
|
764
808
|
"bundle",
|
|
765
809
|
"pin",
|
|
@@ -793,51 +837,73 @@ export function parse(argv) {
|
|
|
793
837
|
tokens.includes("pointers.apiKey") &&
|
|
794
838
|
!(tokens.length === 2 && tokens[1] === "-"))
|
|
795
839
|
syntax("API key must be provided through '-' and piped stdin; never pass it in command arguments.");
|
|
796
|
-
const booleans = result.path === "
|
|
797
|
-
? ["
|
|
798
|
-
: result.path === "build"
|
|
799
|
-
? ["replace", "no-import"]
|
|
800
|
-
: result.path === "
|
|
801
|
-
? ["
|
|
802
|
-
: result.path === "
|
|
803
|
-
? ["
|
|
804
|
-
: result.path === "
|
|
805
|
-
? ["
|
|
806
|
-
: result.path === "
|
|
807
|
-
? ["
|
|
808
|
-
: result.path === "
|
|
809
|
-
? ["
|
|
810
|
-
: result.path === "
|
|
840
|
+
const booleans = result.path === "setup"
|
|
841
|
+
? ["yes"]
|
|
842
|
+
: result.path === "bundle build"
|
|
843
|
+
? ["replace", "schema-only", "no-import"]
|
|
844
|
+
: result.path === "build"
|
|
845
|
+
? ["replace", "no-import"]
|
|
846
|
+
: result.path === "publish"
|
|
847
|
+
? ["snapshot"]
|
|
848
|
+
: result.path === "get"
|
|
849
|
+
? ["raw", "force", "no-force"]
|
|
850
|
+
: result.path === "search"
|
|
851
|
+
? ["current", "force", "no-force"]
|
|
852
|
+
: result.path === "swarm approve"
|
|
853
|
+
? ["yes", "again"]
|
|
854
|
+
: result.path === "swarm exclude"
|
|
811
855
|
? ["yes"]
|
|
812
|
-
: result.path === "
|
|
813
|
-
? ["
|
|
814
|
-
:
|
|
856
|
+
: result.path === "register set"
|
|
857
|
+
? ["replace"]
|
|
858
|
+
: result.path === "history remove"
|
|
859
|
+
? ["yes"]
|
|
860
|
+
: result.path === "open"
|
|
861
|
+
? ["log", "raw", "force", "no-force"]
|
|
862
|
+
: [];
|
|
815
863
|
const values = result.path === "swarm create"
|
|
816
864
|
? ["service", "resume", "name", "description", "alias"]
|
|
817
|
-
: result.path === "swarm add"
|
|
865
|
+
: result.path === "swarm add"
|
|
818
866
|
? ["alias"]
|
|
819
|
-
: result.path === "swarm
|
|
820
|
-
? ["name", "
|
|
821
|
-
: result.path === "swarm
|
|
822
|
-
? ["
|
|
823
|
-
: result.path === "
|
|
824
|
-
? ["name", "
|
|
825
|
-
: result.path === "
|
|
826
|
-
? ["
|
|
827
|
-
: result.path === "
|
|
828
|
-
? [
|
|
829
|
-
: result.path === "
|
|
830
|
-
? ["
|
|
831
|
-
: result.path === "
|
|
832
|
-
? ["
|
|
833
|
-
: result.path === "
|
|
834
|
-
? ["
|
|
835
|
-
: result.path === "
|
|
836
|
-
|
|
837
|
-
|
|
867
|
+
: result.path === "swarm request"
|
|
868
|
+
? ["owner-fingerprint", "name", "alias", "output"]
|
|
869
|
+
: result.path === "swarm export"
|
|
870
|
+
? ["output"]
|
|
871
|
+
: result.path === "swarm profile"
|
|
872
|
+
? ["name", "address"]
|
|
873
|
+
: result.path === "swarm update"
|
|
874
|
+
? ["name", "description"]
|
|
875
|
+
: result.path === "swarm approve"
|
|
876
|
+
? []
|
|
877
|
+
: result.path === "publish"
|
|
878
|
+
? ["name", "expect"]
|
|
879
|
+
: result.path === "get"
|
|
880
|
+
? ["output"]
|
|
881
|
+
: result.path === "init"
|
|
882
|
+
? ["template"]
|
|
883
|
+
: result.path === "bundle build" ||
|
|
884
|
+
result.path === "build"
|
|
885
|
+
? ["output"]
|
|
886
|
+
: result.path === "history list"
|
|
887
|
+
? [
|
|
888
|
+
"app",
|
|
889
|
+
"status",
|
|
890
|
+
"since",
|
|
891
|
+
"until",
|
|
892
|
+
"limit",
|
|
893
|
+
"before",
|
|
894
|
+
]
|
|
895
|
+
: result.path === "history remove"
|
|
896
|
+
? ["app", "status", "since", "until"]
|
|
897
|
+
: result.path === "pin list"
|
|
898
|
+
? ["type"]
|
|
899
|
+
: [];
|
|
838
900
|
while (tokens.length) {
|
|
839
901
|
const value = tokens.shift();
|
|
840
|
-
if (
|
|
902
|
+
if (result.path === "swarm exclude" &&
|
|
903
|
+
/^--[A-Za-z0-9_-]{41}$/.test(value)) {
|
|
904
|
+
result.positional.push(value);
|
|
905
|
+
}
|
|
906
|
+
else if (value.startsWith("--") || value === "-o") {
|
|
841
907
|
const option = value === "-o" ? "output" : value.slice(2);
|
|
842
908
|
if (result.path === "init" && option === "param") {
|
|
843
909
|
const input = tokens.shift();
|
|
@@ -853,7 +919,9 @@ export function parse(argv) {
|
|
|
853
919
|
else if (values.includes(option)) {
|
|
854
920
|
const input = tokens.shift();
|
|
855
921
|
if (input === undefined ||
|
|
856
|
-
input.startsWith("--")
|
|
922
|
+
(input.startsWith("--") &&
|
|
923
|
+
!(["resume", "owner-fingerprint"].includes(option) &&
|
|
924
|
+
/^[A-Za-z0-9_-]{43}$/.test(input))) ||
|
|
857
925
|
(input === "" && result.path !== "swarm update"))
|
|
858
926
|
syntax(`${value} needs a value.`);
|
|
859
927
|
result.options[option] = input;
|
|
@@ -871,10 +939,14 @@ export function parse(argv) {
|
|
|
871
939
|
flags.swarm !== undefined)
|
|
872
940
|
syntax("--current and --swarm are mutually exclusive.");
|
|
873
941
|
const counts = {
|
|
942
|
+
setup: [0, 0],
|
|
874
943
|
"swarm create": [0, 0],
|
|
875
944
|
"swarm request": [1, 1],
|
|
876
945
|
"swarm approve": [1, 1],
|
|
877
|
-
"swarm
|
|
946
|
+
"swarm export": [1, 1],
|
|
947
|
+
"swarm exclude": [1, 1],
|
|
948
|
+
"swarm resume": [0, 1],
|
|
949
|
+
"swarm profile": [0, 1],
|
|
878
950
|
"swarm status": [0, 1],
|
|
879
951
|
"swarm list": [0, 0],
|
|
880
952
|
"swarm add": [1, 1],
|
|
@@ -967,6 +1039,17 @@ async function performCli(argv, io, env) {
|
|
|
967
1039
|
}
|
|
968
1040
|
if (parsed.path === "history remove" && !parsed.options.yes && !io.tty)
|
|
969
1041
|
syntax("Non-interactive history remove requires --yes.");
|
|
1042
|
+
if (parsed.path === "setup") {
|
|
1043
|
+
if (!parsed.options.yes &&
|
|
1044
|
+
(!io.tty ||
|
|
1045
|
+
!(await io.confirm("Install checksum-verified Kubo and initialize/reuse the protected HOME identity? No daemon will be contacted or started."))))
|
|
1046
|
+
throw new HostError("Setup requires explicit --yes or interactive confirmation.");
|
|
1047
|
+
const result = await setupDevice(stateLocation(parsed.flags, env).path, env);
|
|
1048
|
+
io.out(parsed.flags.json
|
|
1049
|
+
? JSON.stringify(result)
|
|
1050
|
+
: `Kubo ${result.kuboVersion}: ${result.binary}\nAccount fingerprint: ${result.fingerprint}\nReady. Nodes start only when a Swarm is used.`);
|
|
1051
|
+
return 0;
|
|
1052
|
+
}
|
|
970
1053
|
const builtins = await builtinContent();
|
|
971
1054
|
state = new State(stateLocation(parsed.flags, env).path, builtins.pins);
|
|
972
1055
|
if (parsed.path === "config reset" &&
|
|
@@ -987,11 +1070,15 @@ async function performCli(argv, io, env) {
|
|
|
987
1070
|
? undefined
|
|
988
1071
|
: String(value("swarm.default"));
|
|
989
1072
|
const swarmContext = () => ({
|
|
990
|
-
store
|
|
1073
|
+
get store() {
|
|
1074
|
+
return store;
|
|
1075
|
+
},
|
|
1076
|
+
set store(next) {
|
|
1077
|
+
store = next;
|
|
1078
|
+
},
|
|
991
1079
|
state: state,
|
|
992
1080
|
env,
|
|
993
1081
|
stateDir: stateLocation(parsed.flags, env).path,
|
|
994
|
-
provider: String(value("swarm.provider") ?? "http://127.0.0.1:5001"),
|
|
995
1082
|
cacheTtl: Number(value("swarm.cacheTtl")),
|
|
996
1083
|
forceRefresh: parsed.options.force
|
|
997
1084
|
? true
|
|
@@ -1022,7 +1109,13 @@ async function performCli(argv, io, env) {
|
|
|
1022
1109
|
switch (parsed.path) {
|
|
1023
1110
|
case "swarm list": {
|
|
1024
1111
|
const result = { swarms: state.swarms(), ...selection() };
|
|
1025
|
-
emit(
|
|
1112
|
+
emit({
|
|
1113
|
+
...result,
|
|
1114
|
+
swarms: result.swarms.map((entry) => ({
|
|
1115
|
+
configUrl: entry.cid,
|
|
1116
|
+
alias: entry.alias,
|
|
1117
|
+
})),
|
|
1118
|
+
}, [
|
|
1026
1119
|
...result.swarms.map((entry) => `${entry.cid === result.savedCurrent ? "*" : " "} ${printable(entry.alias ?? entry.cid)} ${entry.cid}`),
|
|
1027
1120
|
`Saved current: ${result.savedCurrent ?? "(none)"}`,
|
|
1028
1121
|
`Effective current: ${result.effectiveCurrent ?? "(none)"} (${result.source})`,
|
|
@@ -1048,16 +1141,56 @@ async function performCli(argv, io, env) {
|
|
|
1048
1141
|
case "swarm create":
|
|
1049
1142
|
case "swarm request":
|
|
1050
1143
|
case "swarm approve":
|
|
1051
|
-
case "swarm
|
|
1144
|
+
case "swarm export":
|
|
1145
|
+
case "swarm exclude":
|
|
1146
|
+
case "swarm resume":
|
|
1147
|
+
case "swarm profile":
|
|
1052
1148
|
case "swarm status":
|
|
1053
1149
|
case "publish":
|
|
1054
1150
|
case "get": {
|
|
1055
1151
|
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1056
1152
|
const context = swarmContext();
|
|
1153
|
+
if (parsed.path === "swarm export") {
|
|
1154
|
+
const id = await exportRequest(context, state.resolveSwarm(first), String(parsed.options.output ?? ""));
|
|
1155
|
+
emit({ id }, id);
|
|
1156
|
+
break;
|
|
1157
|
+
}
|
|
1158
|
+
if (["swarm exclude", "swarm resume", "swarm profile"].includes(parsed.path)) {
|
|
1159
|
+
const url = parsed.path === "swarm exclude"
|
|
1160
|
+
? selectedSwarm
|
|
1161
|
+
: first
|
|
1162
|
+
? state.resolveSwarm(first)
|
|
1163
|
+
: selectedSwarm;
|
|
1164
|
+
if (!url)
|
|
1165
|
+
syntax("Select a Swarm configuration URL or alias.");
|
|
1166
|
+
if (parsed.path === "swarm exclude") {
|
|
1167
|
+
if (!parsed.options.yes)
|
|
1168
|
+
syntax("Member removal is irreversible; --yes required.");
|
|
1169
|
+
await removeMember(context, url, first);
|
|
1170
|
+
}
|
|
1171
|
+
else if (parsed.path === "swarm resume")
|
|
1172
|
+
await resumeRemoval(context, url);
|
|
1173
|
+
else {
|
|
1174
|
+
const profile = await updateProfile(context, url, {
|
|
1175
|
+
...(typeof parsed.options.name === "string"
|
|
1176
|
+
? { name: parsed.options.name }
|
|
1177
|
+
: {}),
|
|
1178
|
+
...(typeof parsed.options.address === "string"
|
|
1179
|
+
? { addresses: [parsed.options.address] }
|
|
1180
|
+
: {}),
|
|
1181
|
+
});
|
|
1182
|
+
emit(profile, JSON.stringify(profile));
|
|
1183
|
+
store = context.store;
|
|
1184
|
+
break;
|
|
1185
|
+
}
|
|
1186
|
+
store = context.store;
|
|
1187
|
+
emit({ url, completed: true }, `Organization switch complete: ${url}`);
|
|
1188
|
+
break;
|
|
1189
|
+
}
|
|
1057
1190
|
if (parsed.path === "swarm update") {
|
|
1058
1191
|
const cid = first ? state.resolveSwarm(first) : selectedSwarm;
|
|
1059
1192
|
if (!cid)
|
|
1060
|
-
syntax("swarm update requires a registered alias,
|
|
1193
|
+
syntax("swarm update requires a registered alias, configuration URL or current swarm.");
|
|
1061
1194
|
const result = await updateSwarm(context, cid, {
|
|
1062
1195
|
...(typeof parsed.options.name === "string"
|
|
1063
1196
|
? { name: parsed.options.name }
|
|
@@ -1066,16 +1199,20 @@ async function performCli(argv, io, env) {
|
|
|
1066
1199
|
? { description: parsed.options.description }
|
|
1067
1200
|
: {}),
|
|
1068
1201
|
});
|
|
1069
|
-
emit(result, `Swarm: ${result.
|
|
1202
|
+
emit(result, `Swarm: ${result.configUrl}\nName: ${printable(result.properties.name)}\nDescription: ${printable(result.properties.description)}\nHEAD ID: ${result.headId}\nConfig content CID: ${result.valueCid}`);
|
|
1070
1203
|
break;
|
|
1071
1204
|
}
|
|
1072
1205
|
if (parsed.path === "swarm add") {
|
|
1073
|
-
const cid =
|
|
1206
|
+
const cid = state.resolveSwarm(first);
|
|
1074
1207
|
await addSwarm(context, cid, typeof parsed.options.alias === "string"
|
|
1075
1208
|
? parsed.options.alias
|
|
1076
1209
|
: undefined);
|
|
1077
1210
|
const entry = state.registeredSwarm(cid);
|
|
1078
|
-
emit({
|
|
1211
|
+
emit({
|
|
1212
|
+
configUrl: entry.cid,
|
|
1213
|
+
alias: entry.alias,
|
|
1214
|
+
savedCurrent: state.config()["swarm.default"] ?? null,
|
|
1215
|
+
}, `Registered swarm ${entry.alias ?? cid} (${cid}).`);
|
|
1079
1216
|
break;
|
|
1080
1217
|
}
|
|
1081
1218
|
if (parsed.path === "search") {
|
|
@@ -1104,24 +1241,60 @@ async function performCli(argv, io, env) {
|
|
|
1104
1241
|
if (parsed.path === "swarm status") {
|
|
1105
1242
|
const cid = first ? state.resolveSwarm(first) : selectedSwarm;
|
|
1106
1243
|
if (!cid)
|
|
1107
|
-
syntax("swarm status requires a
|
|
1108
|
-
const
|
|
1109
|
-
|
|
1244
|
+
syntax("swarm status requires a configuration URL or swarm.default.");
|
|
1245
|
+
const { head, config } = await swarmHeader(context, cid, true);
|
|
1246
|
+
store = context.store;
|
|
1110
1247
|
emit({
|
|
1111
|
-
cid,
|
|
1112
|
-
|
|
1248
|
+
configUrl: cid,
|
|
1249
|
+
owner: config.owner,
|
|
1250
|
+
ownerFingerprint: await keyId(config.owner),
|
|
1251
|
+
epoch: config.epoch,
|
|
1252
|
+
peerId: context.node.peerId,
|
|
1253
|
+
addresses: context.node.addresses,
|
|
1113
1254
|
root: head.root,
|
|
1114
|
-
|
|
1115
|
-
properties:
|
|
1116
|
-
|
|
1255
|
+
valueCid: head.cid,
|
|
1256
|
+
properties: {
|
|
1257
|
+
name: config.name,
|
|
1258
|
+
description: config.description,
|
|
1259
|
+
},
|
|
1260
|
+
}, `Swarm: ${cid}\nOwner fingerprint: ${await keyId(config.owner)}\nPeerID: ${context.node.peerId}\nLocal address: ${context.node.addresses.join(", ")}\nName: ${printable(config.name)}\nDescription: ${printable(config.description)}\nHEAD: ${head.root}\nContent CID: ${head.cid}`);
|
|
1117
1261
|
break;
|
|
1118
1262
|
}
|
|
1119
1263
|
if (parsed.path === "get") {
|
|
1120
|
-
const
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1264
|
+
const localCid = first.startsWith("ipab://")
|
|
1265
|
+
? undefined
|
|
1266
|
+
: state.resolve(first);
|
|
1267
|
+
const builtin = builtins.pins.find((pin) => pin.cid === localCid);
|
|
1268
|
+
const selected = builtin
|
|
1269
|
+
? { cid: builtin.cid, targetCid: builtin.cid }
|
|
1270
|
+
: await resolveReference(context, first, selectedSwarm, (reference) => state.resolve(reference), Boolean(parsed.options.raw));
|
|
1271
|
+
const contentStore = context.store;
|
|
1272
|
+
const source = IpfsStore.fromClient({
|
|
1273
|
+
block: {
|
|
1274
|
+
get: (key, options) => {
|
|
1275
|
+
options?.signal?.throwIfAborted();
|
|
1276
|
+
const builtin = builtins.blocks.get(CID.parse(key).toV1().toString());
|
|
1277
|
+
return builtin
|
|
1278
|
+
? Promise.resolve(builtin.slice())
|
|
1279
|
+
: contentStore.block.get(key, options);
|
|
1280
|
+
},
|
|
1281
|
+
},
|
|
1282
|
+
}, contentStore.limits);
|
|
1283
|
+
let directory;
|
|
1284
|
+
try {
|
|
1285
|
+
directory = await getBundle(source, selected.cid, typeof parsed.options.output === "string"
|
|
1286
|
+
? parsed.options.output
|
|
1287
|
+
: undefined);
|
|
1288
|
+
}
|
|
1289
|
+
finally {
|
|
1290
|
+
await source.close();
|
|
1291
|
+
}
|
|
1292
|
+
const closing = store;
|
|
1293
|
+
store = undefined;
|
|
1294
|
+
await closeStore(closing, undefined);
|
|
1295
|
+
state.close();
|
|
1296
|
+
state = undefined;
|
|
1297
|
+
emit({ ...selected, directory }, directory);
|
|
1125
1298
|
break;
|
|
1126
1299
|
}
|
|
1127
1300
|
let cid;
|
|
@@ -1143,20 +1316,29 @@ async function performCli(argv, io, env) {
|
|
|
1143
1316
|
});
|
|
1144
1317
|
}
|
|
1145
1318
|
else if (parsed.path === "swarm request")
|
|
1146
|
-
cid = await requestMembership(context,
|
|
1319
|
+
cid = await requestMembership(context, first, {
|
|
1320
|
+
ownerFingerprint: String(parsed.options["owner-fingerprint"] ?? ""),
|
|
1321
|
+
...(typeof parsed.options.name === "string"
|
|
1322
|
+
? { name: parsed.options.name }
|
|
1323
|
+
: {}),
|
|
1324
|
+
...(typeof parsed.options.alias === "string"
|
|
1325
|
+
? { alias: parsed.options.alias }
|
|
1326
|
+
: {}),
|
|
1327
|
+
...(typeof parsed.options.output === "string"
|
|
1328
|
+
? { output: parsed.options.output }
|
|
1329
|
+
: {}),
|
|
1330
|
+
});
|
|
1147
1331
|
else if (parsed.path === "swarm approve") {
|
|
1332
|
+
const request = await verifiedRequest(first);
|
|
1333
|
+
io.err(await membershipRequestSummary(request));
|
|
1148
1334
|
if (!parsed.options.yes &&
|
|
1149
1335
|
(!io.tty ||
|
|
1150
|
-
!(await io.confirm(`Approve
|
|
1336
|
+
!(await io.confirm(`Approve the verified Request ${request.id} above? This grants current HEAD and the member's profile write access; all reads are public.`))))
|
|
1151
1337
|
throw new HostError("Approval requires explicit --yes or interactive confirmation.");
|
|
1152
|
-
cid = await approveMembership(context,
|
|
1153
|
-
|
|
1154
|
-
|
|
1338
|
+
cid = await approveMembership(context, request, {
|
|
1339
|
+
again: Boolean(parsed.options.again),
|
|
1340
|
+
});
|
|
1155
1341
|
}
|
|
1156
|
-
else if (parsed.path === "swarm join")
|
|
1157
|
-
cid = await joinSwarm(context, exactCid(first), typeof parsed.options.alias === "string"
|
|
1158
|
-
? parsed.options.alias
|
|
1159
|
-
: undefined);
|
|
1160
1342
|
else {
|
|
1161
1343
|
let content;
|
|
1162
1344
|
if (first.toLowerCase().endsWith(".car"))
|
|
@@ -1174,9 +1356,14 @@ async function performCli(argv, io, env) {
|
|
|
1174
1356
|
snapshot: Boolean(parsed.options.snapshot),
|
|
1175
1357
|
});
|
|
1176
1358
|
}
|
|
1177
|
-
|
|
1359
|
+
store = context.store;
|
|
1360
|
+
if (parsed.path === "swarm create")
|
|
1178
1361
|
io.err(`Registered swarm ${state.registeredSwarm(cid).alias ?? cid}. Saved current: ${state.config()["swarm.default"] ?? "(none)"}.`);
|
|
1179
|
-
emit(
|
|
1362
|
+
emit(parsed.path === "swarm request"
|
|
1363
|
+
? { requestId: cid }
|
|
1364
|
+
: parsed.path === "swarm create" || parsed.path === "swarm approve"
|
|
1365
|
+
? { configUrl: cid }
|
|
1366
|
+
: { cid }, cid);
|
|
1180
1367
|
break;
|
|
1181
1368
|
}
|
|
1182
1369
|
case "store usage":
|
|
@@ -1309,7 +1496,7 @@ async function performCli(argv, io, env) {
|
|
|
1309
1496
|
io.err(`Next: ipab bundle build ${JSON.stringify(result.directory)}`);
|
|
1310
1497
|
}
|
|
1311
1498
|
else
|
|
1312
|
-
emit(result, `Kind: ${result.kind}\
|
|
1499
|
+
emit(result, `Kind: ${result.kind}\n${result.manifest ? `Title: ${printable(result.manifest.title)}\nEntry: ${result.manifest.entry}\nType file: ${result.manifest.type}\n` : ""}Type CID: ${result.schemaCid}\nContent type: ${result.type.contentType}\nDefinition validation: passed\nStorage verification: ${result.validation.storage}\nEntry validation: ${result.validation.entry?.status ?? "not-applicable"}`);
|
|
1313
1500
|
}
|
|
1314
1501
|
catch (cause) {
|
|
1315
1502
|
if (cancelled)
|
|
@@ -1346,11 +1533,12 @@ async function performCli(argv, io, env) {
|
|
|
1346
1533
|
io.err(`Unfinished pin operations (not usable pins): ${JSON.stringify(pending)}. Retry pin add/delete.`);
|
|
1347
1534
|
if (invalid.length)
|
|
1348
1535
|
io.err(`Legacy non-Bundle pins (not usable pins): ${JSON.stringify(invalid)}. Retention is unchanged; delete explicitly and wrap content in a Bundle before pinning again.`);
|
|
1349
|
-
emit({ items: listed, pending, invalid }, table(["NAME", "CID", "KIND", "
|
|
1536
|
+
emit({ items: listed, pending, invalid }, table(["NAME", "CID", "KIND", "TITLE", "TYPE CID", "SOURCE"], listed.map((pin) => [
|
|
1350
1537
|
pin.name,
|
|
1351
1538
|
pin.cid,
|
|
1352
1539
|
pin.kind,
|
|
1353
|
-
pin.
|
|
1540
|
+
pin.title,
|
|
1541
|
+
pin.schemaCid,
|
|
1354
1542
|
pin.builtin ? "built-in (read-only)" : "user",
|
|
1355
1543
|
]), "No named pins."));
|
|
1356
1544
|
break;
|
|
@@ -1358,7 +1546,7 @@ async function performCli(argv, io, env) {
|
|
|
1358
1546
|
case "pin add": {
|
|
1359
1547
|
io.err("Fetching, verifying and retaining content in Store...");
|
|
1360
1548
|
const result = await addPin(state, first, second, await storeConfiguration(value("store.gateway")));
|
|
1361
|
-
emit(result, `${result.name} → ${result.cid}\
|
|
1549
|
+
emit(result, `${result.name} → ${result.cid}\nTitle: ${printable(result.title)}\nType CID: ${result.schemaCid}`);
|
|
1362
1550
|
break;
|
|
1363
1551
|
}
|
|
1364
1552
|
case "pin delete": {
|
|
@@ -1371,7 +1559,7 @@ async function performCli(argv, io, env) {
|
|
|
1371
1559
|
if (!pin)
|
|
1372
1560
|
throw new HostError(`Pin "${first}" does not exist. Run ipab pin list.`);
|
|
1373
1561
|
const result = pinDetails(pin);
|
|
1374
|
-
emit(result, `Name: ${printable(result.name)}\nCID: ${result.cid}\
|
|
1562
|
+
emit(result, `Name: ${printable(result.name)}\nCID: ${result.cid}\nTitle: ${printable(result.title)}\nType CID: ${result.schemaCid}\nSource: ${result.builtin ? "built-in (read-only; content bundled with IPAB)" : "local registration (not live node verification)"}`);
|
|
1375
1563
|
break;
|
|
1376
1564
|
}
|
|
1377
1565
|
case "pin rename": {
|
|
@@ -1489,7 +1677,9 @@ async function performCli(argv, io, env) {
|
|
|
1489
1677
|
throw new HostError("Execution logging requires history.enabled=true.");
|
|
1490
1678
|
await recoverInactive(state);
|
|
1491
1679
|
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1492
|
-
const
|
|
1680
|
+
const context = swarmContext();
|
|
1681
|
+
const target = (await resolveReference(context, first, selectedSwarm, (reference) => state.resolve(reference), Boolean(parsed.options.raw))).cid;
|
|
1682
|
+
store = context.store;
|
|
1493
1683
|
let appCid;
|
|
1494
1684
|
let appArgv;
|
|
1495
1685
|
if (parsed.path === "open") {
|