@ipab/cli 0.1.0-rc.4 → 0.1.0-rc.6
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 +88 -16
- package/dist/app-templates.js +1 -1
- package/dist/app-templates.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/cli.d.ts +6 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +656 -278
- package/dist/cli.js.map +1 -1
- package/dist/config-secret.d.ts +1 -1
- package/dist/config-secret.d.ts.map +1 -1
- package/dist/config-secret.js +2 -73
- package/dist/config-secret.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +12 -1
- 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 +4 -3
- package/dist/content-provider.js.map +1 -1
- package/dist/context-types.d.ts +12 -0
- package/dist/context-types.d.ts.map +1 -0
- package/dist/context-types.js +2 -0
- package/dist/context-types.js.map +1 -0
- package/dist/context.d.ts +6 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +24 -9
- package/dist/context.js.map +1 -1
- package/dist/doctor.d.ts +29 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +576 -0
- package/dist/doctor.js.map +1 -0
- package/dist/identity.d.ts +1 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +9 -9
- package/dist/identity.js.map +1 -1
- package/dist/ipc.d.ts +3 -2
- package/dist/ipc.d.ts.map +1 -1
- package/dist/ipc.js +33 -9
- package/dist/ipc.js.map +1 -1
- package/dist/kubo-install.d.ts +26 -0
- package/dist/kubo-install.d.ts.map +1 -0
- package/dist/kubo-install.js +724 -0
- package/dist/kubo-install.js.map +1 -0
- package/dist/kubo-peering.d.ts +11 -0
- package/dist/kubo-peering.d.ts.map +1 -0
- package/dist/kubo-peering.js +93 -0
- package/dist/kubo-peering.js.map +1 -0
- package/dist/kubo-peers.d.ts +12 -0
- package/dist/kubo-peers.d.ts.map +1 -0
- package/dist/kubo-peers.js +118 -0
- package/dist/kubo-peers.js.map +1 -0
- package/dist/kubo-release.d.ts +22 -0
- package/dist/kubo-release.d.ts.map +1 -0
- package/dist/kubo-release.js +176 -0
- package/dist/kubo-release.js.map +1 -0
- package/dist/kubo.d.ts +12 -4
- package/dist/kubo.d.ts.map +1 -1
- package/dist/kubo.js +218 -259
- package/dist/kubo.js.map +1 -1
- package/dist/pins.d.ts +15 -17
- package/dist/pins.d.ts.map +1 -1
- package/dist/pins.js +144 -106
- package/dist/pins.js.map +1 -1
- package/dist/publish-source.d.ts +3 -0
- package/dist/publish-source.d.ts.map +1 -0
- package/dist/publish-source.js +85 -0
- package/dist/publish-source.js.map +1 -0
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +4 -2
- package/dist/runtime.js.map +1 -1
- package/dist/state-storage-windows.d.ts +2 -0
- package/dist/state-storage-windows.d.ts.map +1 -0
- package/dist/state-storage-windows.js +114 -0
- package/dist/state-storage-windows.js.map +1 -0
- package/dist/state-storage.d.ts +5 -0
- package/dist/state-storage.d.ts.map +1 -0
- package/dist/state-storage.js +330 -0
- package/dist/state-storage.js.map +1 -0
- package/dist/state.d.ts +42 -8
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +254 -98
- package/dist/state.js.map +1 -1
- package/dist/swarm-envelope.d.ts +1 -0
- package/dist/swarm-envelope.d.ts.map +1 -1
- package/dist/swarm-envelope.js +12 -0
- package/dist/swarm-envelope.js.map +1 -1
- package/dist/swarm-files.d.ts +1 -1
- package/dist/swarm-files.d.ts.map +1 -1
- package/dist/swarm-files.js +4 -1
- package/dist/swarm-files.js.map +1 -1
- package/dist/swarm.d.ts +70 -11
- package/dist/swarm.d.ts.map +1 -1
- package/dist/swarm.js +1033 -167
- package/dist/swarm.js.map +1 -1
- package/package.json +4 -4
- package/src/app-templates.ts +1 -1
- package/src/cli.ts +827 -356
- package/src/config-secret.ts +2 -84
- package/src/config.ts +14 -1
- package/src/content-provider.ts +4 -2
- package/src/context-types.ts +11 -0
- package/src/context.ts +39 -9
- package/src/doctor.ts +902 -0
- package/src/identity.ts +10 -10
- package/src/ipc.ts +49 -8
- package/src/kubo-install.ts +936 -0
- package/src/kubo-peering.ts +126 -0
- package/src/kubo-peers.ts +145 -0
- package/src/kubo-release.ts +230 -0
- package/src/kubo.ts +302 -336
- package/src/pins.ts +188 -126
- package/src/publish-source.ts +103 -0
- package/src/runtime.ts +10 -2
- package/src/state-storage-windows.ts +134 -0
- package/src/state-storage.ts +375 -0
- package/src/state.ts +410 -118
- package/src/swarm-envelope.ts +14 -0
- package/src/swarm-files.ts +4 -0
- package/src/swarm.ts +1482 -207
- package/dist/setup.d.ts +0 -7
- package/dist/setup.d.ts.map +0 -1
- package/dist/setup.js +0 -22
- package/dist/setup.js.map +0 -1
- package/src/setup.ts +0 -21
package/src/identity.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { homedir } from "node:os";
|
|
|
3
3
|
import { join, resolve } from "node:path";
|
|
4
4
|
import {
|
|
5
5
|
protectAccountOnly,
|
|
6
|
-
requireAccountOnly,
|
|
7
6
|
requireAccountOnlyMany,
|
|
8
7
|
} from "@ipab/bundle/pointer/protected-files";
|
|
9
8
|
import {
|
|
@@ -26,7 +25,6 @@ export async function protectedPath(
|
|
|
26
25
|
directory = false,
|
|
27
26
|
): Promise<void> {
|
|
28
27
|
await regularPath(path, directory);
|
|
29
|
-
await requireAccountOnly(path);
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
export interface ProtectedPath {
|
|
@@ -39,7 +37,6 @@ export async function protectedPaths(
|
|
|
39
37
|
): Promise<void> {
|
|
40
38
|
for (const entry of paths)
|
|
41
39
|
await regularPath(entry.path, entry.directory ?? false);
|
|
42
|
-
await requireAccountOnlyMany(paths.map((entry) => entry.path));
|
|
43
40
|
}
|
|
44
41
|
|
|
45
42
|
async function regularPath(path: string, directory: boolean): Promise<void> {
|
|
@@ -66,14 +63,15 @@ export async function readIdentityFile(path: string): Promise<Identity> {
|
|
|
66
63
|
return decodeIdentityFile(path);
|
|
67
64
|
}
|
|
68
65
|
async function decodeIdentityFile(path: string): Promise<Identity> {
|
|
66
|
+
const stat = await lstat(path);
|
|
67
|
+
if (stat.size > 16 * 1024)
|
|
68
|
+
throw new HostError(
|
|
69
|
+
"Invalid credential encoding. Restore the existing protected key file.",
|
|
70
|
+
);
|
|
71
|
+
const text = await readFile(path, "utf8");
|
|
69
72
|
let value: Record<string, unknown>;
|
|
70
73
|
try {
|
|
71
|
-
|
|
72
|
-
if (stat.size > 16 * 1024) throw new Error("oversized");
|
|
73
|
-
value = object(
|
|
74
|
-
JSON.parse(await readFile(path, "utf8")) as unknown,
|
|
75
|
-
"identity",
|
|
76
|
-
);
|
|
74
|
+
value = object(JSON.parse(text) as unknown, "identity");
|
|
77
75
|
} catch {
|
|
78
76
|
throw new HostError(
|
|
79
77
|
"Invalid credential encoding. Restore the existing protected key file.",
|
|
@@ -102,6 +100,7 @@ async function decodeIdentityFile(path: string): Promise<Identity> {
|
|
|
102
100
|
export async function accountIdentity(
|
|
103
101
|
env: NodeJS.ProcessEnv,
|
|
104
102
|
initialize = false,
|
|
103
|
+
verifyPermissions = false,
|
|
105
104
|
): Promise<Identity> {
|
|
106
105
|
const home = resolve(env.HOME ?? env.USERPROFILE ?? homedir());
|
|
107
106
|
const parent = join(home, ".ipab");
|
|
@@ -141,6 +140,7 @@ export async function accountIdentity(
|
|
|
141
140
|
await regularPath(parent, true);
|
|
142
141
|
await regularPath(directory, true);
|
|
143
142
|
await regularPath(file, false);
|
|
144
|
-
|
|
143
|
+
if (verifyPermissions)
|
|
144
|
+
await requireAccountOnlyMany([parent, directory, file]);
|
|
145
145
|
return decodeIdentityFile(file);
|
|
146
146
|
}
|
package/src/ipc.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ChildProcess } from "node:child_process";
|
|
2
2
|
import type { IpfsStore } from "@ipab/ipfs-store";
|
|
3
|
+
import { openBundle } from "@ipab/bundle";
|
|
3
4
|
import { CID } from "multiformats/cid";
|
|
4
5
|
import { HostError, message, object } from "./errors.js";
|
|
5
|
-
import { requestFrame, type Reply } from "./context.js";
|
|
6
|
+
import { requestFrame, type BundleInspection, type Reply } from "./context.js";
|
|
6
7
|
import { CHUNK_BYTES, type OutputSpace, relativePath } from "./space.js";
|
|
7
8
|
import type { Ownership } from "./history.js";
|
|
8
9
|
|
|
@@ -75,9 +76,11 @@ export class ContextServer {
|
|
|
75
76
|
readonly output: OutputSpace,
|
|
76
77
|
readonly fatal: (error: Error) => void,
|
|
77
78
|
readonly appCid: string,
|
|
78
|
-
readonly
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
readonly resolveBundleReference?: (
|
|
80
|
+
reference: string,
|
|
81
|
+
signal: AbortSignal,
|
|
82
|
+
swarm?: string,
|
|
83
|
+
) => Promise<Pick<BundleInspection, "cid" | "targetCid" | "swarm">>,
|
|
81
84
|
) {
|
|
82
85
|
child.on("message", this.receive);
|
|
83
86
|
}
|
|
@@ -156,10 +159,48 @@ export class ContextServer {
|
|
|
156
159
|
): Promise<unknown> {
|
|
157
160
|
signal.throwIfAborted();
|
|
158
161
|
if (operation === "identity") return this.appCid;
|
|
159
|
-
if (operation === "
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
if (operation === "inspectBundle") {
|
|
163
|
+
const request = object(args, "Bundle inspection request");
|
|
164
|
+
if (
|
|
165
|
+
typeof request.reference !== "string" ||
|
|
166
|
+
!request.reference ||
|
|
167
|
+
request.reference.length > 2048
|
|
168
|
+
)
|
|
169
|
+
throw new HostError(
|
|
170
|
+
"Bundle reference must contain 1..2048 characters.",
|
|
171
|
+
);
|
|
172
|
+
if (
|
|
173
|
+
request.swarm !== undefined &&
|
|
174
|
+
(typeof request.swarm !== "string" || request.swarm.length > 2048)
|
|
175
|
+
)
|
|
176
|
+
throw new HostError("Invalid Bundle inspection Swarm.");
|
|
177
|
+
if (!this.resolveBundleReference)
|
|
178
|
+
throw new HostError(
|
|
179
|
+
"Bundle inspection is unavailable in this context.",
|
|
180
|
+
);
|
|
181
|
+
const resolved = await this.resolveBundleReference(
|
|
182
|
+
request.reference,
|
|
183
|
+
signal,
|
|
184
|
+
request.swarm,
|
|
185
|
+
);
|
|
186
|
+
await this.owner.retain([resolved.targetCid, resolved.cid], signal);
|
|
187
|
+
const bundle = await openBundle(CID.parse(resolved.cid), {
|
|
188
|
+
signal,
|
|
189
|
+
resolveCid: (cid, options) =>
|
|
190
|
+
this.store.block.get(cid.toString(), options),
|
|
191
|
+
});
|
|
192
|
+
const result: BundleInspection = {
|
|
193
|
+
...resolved,
|
|
194
|
+
title: bundle.manifest.title,
|
|
195
|
+
description: bundle.manifest.description,
|
|
196
|
+
entry: bundle.manifest.entry,
|
|
197
|
+
contentType: bundle.schema.type.contentType,
|
|
198
|
+
schemaCid: bundle.schemaKey,
|
|
199
|
+
files: [...bundle.files],
|
|
200
|
+
};
|
|
201
|
+
if (Buffer.byteLength(JSON.stringify(result)) > 1024 * 1024)
|
|
202
|
+
throw new HostError("Bundle inspection exceeds 1 MiB.");
|
|
203
|
+
return result;
|
|
163
204
|
}
|
|
164
205
|
if (operation === "read") {
|
|
165
206
|
if (this.reads.size + this.writes.size + this.openingReads >= 32)
|