@ipab/cli 0.1.0-rc.5 → 0.1.0-rc.7
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 +128 -22
- package/dist/app-authoring.d.ts +5 -0
- package/dist/app-authoring.d.ts.map +1 -1
- package/dist/app-authoring.js +4 -1
- package/dist/app-authoring.js.map +1 -1
- package/dist/app-templates.d.ts +0 -1
- package/dist/app-templates.d.ts.map +1 -1
- package/dist/app-templates.js +6 -45
- package/dist/app-templates.js.map +1 -1
- package/dist/builtins/skill.ipab.car +0 -0
- package/dist/builtins/template.bundle-viewer.car +0 -0
- package/dist/builtins/template.check.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 +1 -39
- package/dist/builtins.js.map +1 -1
- package/dist/cli.d.ts +4 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +934 -336
- package/dist/cli.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.d.ts +16 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +20 -10
- 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 +2 -2
- package/dist/ipc.d.ts.map +1 -1
- package/dist/ipc.js +44 -12
- package/dist/ipc.js.map +1 -1
- package/dist/kubo-install.d.ts +18 -1
- package/dist/kubo-install.d.ts.map +1 -1
- package/dist/kubo-install.js +424 -61
- package/dist/kubo-install.js.map +1 -1
- package/dist/kubo-release.d.ts +19 -0
- package/dist/kubo-release.d.ts.map +1 -1
- package/dist/kubo-release.js +164 -0
- package/dist/kubo-release.js.map +1 -1
- package/dist/kubo.d.ts +1 -0
- package/dist/kubo.d.ts.map +1 -1
- package/dist/kubo.js +102 -96
- 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.map +1 -1
- package/dist/runtime.js +6 -5
- package/dist/runtime.js.map +1 -1
- package/dist/skill-definition.d.ts +6 -0
- package/dist/skill-definition.d.ts.map +1 -0
- package/dist/skill-definition.js +38 -0
- package/dist/skill-definition.js.map +1 -0
- package/dist/skill-source.d.ts +5 -0
- package/dist/skill-source.d.ts.map +1 -0
- package/dist/skill-source.js +12 -0
- package/dist/skill-source.js.map +1 -0
- package/dist/skills.d.ts +84 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +736 -0
- package/dist/skills.js.map +1 -0
- package/dist/space.d.ts +15 -2
- package/dist/space.d.ts.map +1 -1
- package/dist/space.js +153 -3
- package/dist/space.js.map +1 -1
- package/dist/state-storage-windows.js +1 -1
- package/dist/state-storage.d.ts +3 -1
- package/dist/state-storage.d.ts.map +1 -1
- package/dist/state-storage.js +38 -7
- package/dist/state-storage.js.map +1 -1
- package/dist/state.d.ts +40 -6
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +208 -82
- 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 +2 -2
- package/dist/swarm-files.js.map +1 -1
- package/dist/swarm-meta.d.ts +17 -0
- package/dist/swarm-meta.d.ts.map +1 -0
- package/dist/swarm-meta.js +96 -0
- package/dist/swarm-meta.js.map +1 -0
- package/dist/swarm.d.ts +117 -8
- package/dist/swarm.d.ts.map +1 -1
- package/dist/swarm.js +1275 -131
- package/dist/swarm.js.map +1 -1
- package/dist/template-paths.d.ts +7 -0
- package/dist/template-paths.d.ts.map +1 -0
- package/dist/template-paths.js +23 -0
- package/dist/template-paths.js.map +1 -0
- package/dist/template-presentation.d.ts +20 -0
- package/dist/template-presentation.d.ts.map +1 -0
- package/dist/template-presentation.js +133 -0
- package/dist/template-presentation.js.map +1 -0
- package/dist/template-source.d.ts +2 -1
- package/dist/template-source.d.ts.map +1 -1
- package/dist/template-source.js +7 -1
- package/dist/template-source.js.map +1 -1
- package/dist/templates.d.ts +11 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +53 -0
- package/dist/templates.js.map +1 -0
- package/package.json +7 -6
- package/src/app-authoring.ts +18 -2
- package/src/app-templates.ts +8 -72
- package/src/builtins.ts +2 -48
- package/src/cli.ts +1154 -387
- package/src/content-provider.ts +4 -2
- package/src/context.ts +45 -10
- package/src/doctor.ts +902 -0
- package/src/identity.ts +10 -10
- package/src/ipc.ts +63 -10
- package/src/kubo-install.ts +562 -78
- package/src/kubo-release.ts +213 -0
- package/src/kubo.ts +134 -106
- package/src/pins.ts +188 -126
- package/src/publish-source.ts +103 -0
- package/src/runtime.ts +6 -5
- package/src/skill-definition.ts +53 -0
- package/src/skill-source.ts +15 -0
- package/src/skills.ts +1005 -0
- package/src/space.ts +214 -5
- package/src/state-storage-windows.ts +1 -1
- package/src/state-storage.ts +53 -7
- package/src/state.ts +357 -98
- package/src/swarm-envelope.ts +14 -0
- package/src/swarm-files.ts +2 -1
- package/src/swarm-meta.ts +109 -0
- package/src/swarm.ts +1877 -175
- package/src/template-paths.ts +43 -0
- package/src/template-presentation.ts +151 -0
- package/src/template-source.ts +9 -2
- package/src/templates.ts +77 -0
- package/dist/setup.d.ts +0 -8
- package/dist/setup.d.ts.map +0 -1
- package/dist/setup.js +0 -27
- package/dist/setup.js.map +0 -1
- package/src/setup.ts +0 -34
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { TreeEntry } from "@ipab/bundle-builder";
|
|
2
|
+
import { HostError } from "./errors.js";
|
|
3
|
+
import { relativePath } from "./space.js";
|
|
4
|
+
|
|
5
|
+
export function templateOutputPath(source: string, kind: TreeEntry["kind"]) {
|
|
6
|
+
relativePath(source);
|
|
7
|
+
const original = source.slice("project/".length);
|
|
8
|
+
const rendered = kind === "file" && original.endsWith(".liquid");
|
|
9
|
+
const target = relativePath(
|
|
10
|
+
rendered ? original.slice(0, -".liquid".length) : original,
|
|
11
|
+
);
|
|
12
|
+
if (
|
|
13
|
+
target
|
|
14
|
+
.split("/")
|
|
15
|
+
.some(
|
|
16
|
+
(part) =>
|
|
17
|
+
["node_modules", ".git", "dist"].includes(part.toLowerCase()) ||
|
|
18
|
+
/^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])(?:\.|$)/i.test(part),
|
|
19
|
+
)
|
|
20
|
+
)
|
|
21
|
+
throw new HostError(`Unsafe template output path: ${target}.`);
|
|
22
|
+
return { target, rendered };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function addTemplateOutputPath(
|
|
26
|
+
paths: Map<string, TreeEntry["kind"]>,
|
|
27
|
+
target: string,
|
|
28
|
+
kind: TreeEntry["kind"],
|
|
29
|
+
) {
|
|
30
|
+
const key = target.toLowerCase();
|
|
31
|
+
if (
|
|
32
|
+
paths.has(key) ||
|
|
33
|
+
[...paths].some(
|
|
34
|
+
([existing, existingKind]) =>
|
|
35
|
+
(existingKind === "file" && key.startsWith(`${existing}/`)) ||
|
|
36
|
+
(kind === "file" && existing.startsWith(`${key}/`)),
|
|
37
|
+
)
|
|
38
|
+
)
|
|
39
|
+
throw new HostError(
|
|
40
|
+
`Duplicate or overlapping template output path: ${target}.`,
|
|
41
|
+
);
|
|
42
|
+
paths.set(key, kind);
|
|
43
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import {
|
|
2
|
+
listTree,
|
|
3
|
+
type ReadonlyFileTree,
|
|
4
|
+
type TreeEntry,
|
|
5
|
+
} from "@ipab/bundle-builder";
|
|
6
|
+
import type { IpfsStore } from "@ipab/ipfs-store";
|
|
7
|
+
import { bundleLimits, ContentBundleError } from "@ipab/bundle";
|
|
8
|
+
import type {
|
|
9
|
+
TemplateDefinition,
|
|
10
|
+
TemplateParameter,
|
|
11
|
+
} from "./template-definition.js";
|
|
12
|
+
import { addTemplateOutputPath, templateOutputPath } from "./template-paths.js";
|
|
13
|
+
import { templateSource } from "./template-source.js";
|
|
14
|
+
|
|
15
|
+
class PreviewLimit extends Error {}
|
|
16
|
+
|
|
17
|
+
function previewLimit(cause: unknown) {
|
|
18
|
+
for (let depth = 0; depth < 16 && cause instanceof Error; depth++) {
|
|
19
|
+
if (cause instanceof PreviewLimit) return cause;
|
|
20
|
+
cause = cause.cause;
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function projectOutputTree(tree: ReadonlyFileTree) {
|
|
26
|
+
const entries: { path: string; kind: TreeEntry["kind"] }[] = [];
|
|
27
|
+
const paths = new Map<string, TreeEntry["kind"]>();
|
|
28
|
+
let pathBytes = 0;
|
|
29
|
+
const collect = async (directory: string, depth: number): Promise<void> => {
|
|
30
|
+
if (depth >= 8) throw new PreviewLimit("depth limit (8)");
|
|
31
|
+
for (const entry of await listTree(tree, directory)) {
|
|
32
|
+
if (entries.length >= 64) throw new PreviewLimit("entry limit (64)");
|
|
33
|
+
const source = `${directory}/${entry.name}`;
|
|
34
|
+
const { target } = templateOutputPath(source, entry.kind);
|
|
35
|
+
pathBytes += Buffer.byteLength(target);
|
|
36
|
+
if (pathBytes > 16 * 1024)
|
|
37
|
+
throw new PreviewLimit("path byte limit (16 KiB)");
|
|
38
|
+
addTemplateOutputPath(paths, target, entry.kind);
|
|
39
|
+
entries.push({ path: target, kind: entry.kind });
|
|
40
|
+
if (entry.kind === "directory") await collect(source, depth + 1);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
let truncated: string | undefined;
|
|
44
|
+
try {
|
|
45
|
+
await collect("project", 0);
|
|
46
|
+
} catch (cause) {
|
|
47
|
+
const limit = previewLimit(cause);
|
|
48
|
+
if (!limit) throw cause;
|
|
49
|
+
truncated = limit.message;
|
|
50
|
+
}
|
|
51
|
+
return { entries, truncated };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export async function templateOutputTree(store: IpfsStore, cid: string) {
|
|
55
|
+
let reads = 0,
|
|
56
|
+
bytes = 0;
|
|
57
|
+
try {
|
|
58
|
+
const source = await templateSource(cid, {
|
|
59
|
+
async resolveCid(key, options) {
|
|
60
|
+
if (++reads > 512) throw new PreviewLimit("content read limit (512)");
|
|
61
|
+
const block = await store.block.get(key.toString(), options);
|
|
62
|
+
if (block.byteLength > bundleLimits.blockBytes)
|
|
63
|
+
throw new ContentBundleError(
|
|
64
|
+
"LIMIT_EXCEEDED",
|
|
65
|
+
"Template source exceeds the Bundle block byte limit.",
|
|
66
|
+
);
|
|
67
|
+
bytes += block.byteLength;
|
|
68
|
+
if (bytes > 2 * 1024 * 1024)
|
|
69
|
+
throw new PreviewLimit("content byte limit (2 MiB)");
|
|
70
|
+
return block;
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
return await projectOutputTree(source.tree);
|
|
74
|
+
} catch (cause) {
|
|
75
|
+
const limit = previewLimit(cause);
|
|
76
|
+
if (!limit) throw cause;
|
|
77
|
+
return { entries: [], truncated: limit.message };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function hasDefault(parameter: TemplateParameter) {
|
|
82
|
+
return Object.hasOwn(parameter, "default");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function templateParameterRows(definition: TemplateDefinition) {
|
|
86
|
+
const names = Object.keys(definition.parameters).sort();
|
|
87
|
+
const ordered = [
|
|
88
|
+
"name",
|
|
89
|
+
"description",
|
|
90
|
+
...names.filter((name) => name !== "name" && name !== "description"),
|
|
91
|
+
];
|
|
92
|
+
return ordered
|
|
93
|
+
.filter((name) => Object.hasOwn(definition.parameters, name))
|
|
94
|
+
.map((name) => {
|
|
95
|
+
const parameter = definition.parameters[name]!;
|
|
96
|
+
return [
|
|
97
|
+
name,
|
|
98
|
+
parameter.type,
|
|
99
|
+
parameter.required && !hasDefault(parameter) ? "yes" : "no",
|
|
100
|
+
hasDefault(parameter) ? JSON.stringify(parameter.default) : "-",
|
|
101
|
+
name === "name"
|
|
102
|
+
? "NAME positional"
|
|
103
|
+
: name === "description"
|
|
104
|
+
? "--description TEXT"
|
|
105
|
+
: `--param ${name}=VALUE`,
|
|
106
|
+
];
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function templateRenderExample(
|
|
111
|
+
selector: string,
|
|
112
|
+
swarm: string,
|
|
113
|
+
definition: TemplateDefinition,
|
|
114
|
+
shell: "powershell" | "posix",
|
|
115
|
+
) {
|
|
116
|
+
const quote = (value: string) => {
|
|
117
|
+
// Shell controls cannot safely be embedded in a copyable, single-line example.
|
|
118
|
+
const safe = [...value].some(
|
|
119
|
+
(char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127,
|
|
120
|
+
);
|
|
121
|
+
if (safe)
|
|
122
|
+
throw new Error(
|
|
123
|
+
"Cannot produce a render example containing control characters.",
|
|
124
|
+
);
|
|
125
|
+
return shell === "powershell"
|
|
126
|
+
? `'${value.replaceAll("'", "''")}'`
|
|
127
|
+
: `'${value.replaceAll("'", "'\\''")}'`;
|
|
128
|
+
};
|
|
129
|
+
const args = [
|
|
130
|
+
"ipab",
|
|
131
|
+
"--swarm",
|
|
132
|
+
quote(swarm),
|
|
133
|
+
"templates",
|
|
134
|
+
"render",
|
|
135
|
+
quote(selector),
|
|
136
|
+
quote("my-project"),
|
|
137
|
+
];
|
|
138
|
+
for (const name of Object.keys(definition.parameters).sort()) {
|
|
139
|
+
const parameter = definition.parameters[name]!;
|
|
140
|
+
if (name === "name" || !parameter.required || hasDefault(parameter))
|
|
141
|
+
continue;
|
|
142
|
+
const example = {
|
|
143
|
+
string: "VALUE",
|
|
144
|
+
number: "0",
|
|
145
|
+
boolean: "true",
|
|
146
|
+
json: "null",
|
|
147
|
+
}[parameter.type];
|
|
148
|
+
args.push("--param", quote(`${name}=${example}`));
|
|
149
|
+
}
|
|
150
|
+
return args.join(" ");
|
|
151
|
+
}
|
package/src/template-source.ts
CHANGED
|
@@ -13,8 +13,15 @@ import { readCar, selectedTree, type AuthoringOptions } from "./authoring.js";
|
|
|
13
13
|
import { HostError } from "./errors.js";
|
|
14
14
|
import { builtinTemplateSchema } from "./template-definition.js";
|
|
15
15
|
|
|
16
|
-
export
|
|
17
|
-
|
|
16
|
+
export const seedTemplateNames = [
|
|
17
|
+
"node",
|
|
18
|
+
"web-app",
|
|
19
|
+
"check",
|
|
20
|
+
"bundle-viewer",
|
|
21
|
+
] as const;
|
|
22
|
+
|
|
23
|
+
export async function seedTemplateSource(
|
|
24
|
+
selector: (typeof seedTemplateNames)[number],
|
|
18
25
|
options: AuthoringOptions = {},
|
|
19
26
|
) {
|
|
20
27
|
const car = await readCar(
|
package/src/templates.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { lstat } from "node:fs/promises";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { CID } from "multiformats/cid";
|
|
4
|
+
import { bundleLimits, openBundle } from "@ipab/bundle";
|
|
5
|
+
import type { IpfsStore } from "@ipab/ipfs-store";
|
|
6
|
+
import { HostError } from "./errors.js";
|
|
7
|
+
import { publicationSource } from "./publish-source.js";
|
|
8
|
+
import { bytes } from "./space.js";
|
|
9
|
+
import {
|
|
10
|
+
templateDefinition,
|
|
11
|
+
templateSchemaCid,
|
|
12
|
+
} from "./template-definition.js";
|
|
13
|
+
|
|
14
|
+
export async function inspectTemplate(store: IpfsStore, cid: string) {
|
|
15
|
+
const bundle = await openBundle(CID.parse(cid), {
|
|
16
|
+
resolveCid: (key) => store.block.get(key.toString()),
|
|
17
|
+
});
|
|
18
|
+
if (bundle.schemaKey !== templateSchemaCid.toString())
|
|
19
|
+
throw new HostError(
|
|
20
|
+
"Template Bundle must use the exact project-template type CID.",
|
|
21
|
+
);
|
|
22
|
+
const definition = templateDefinition(
|
|
23
|
+
await bytes(
|
|
24
|
+
await bundle.readFile(bundle.manifest.entry),
|
|
25
|
+
bundleLimits.parsingBytes,
|
|
26
|
+
),
|
|
27
|
+
);
|
|
28
|
+
return {
|
|
29
|
+
templateCid: bundle.cid.toString(),
|
|
30
|
+
typeCid: bundle.schemaKey,
|
|
31
|
+
title: bundle.manifest.title,
|
|
32
|
+
description: bundle.manifest.description,
|
|
33
|
+
definition,
|
|
34
|
+
parameters: definition.parameters,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function templatePublicationSource(
|
|
39
|
+
input: string,
|
|
40
|
+
store: IpfsStore,
|
|
41
|
+
) {
|
|
42
|
+
let cid: CID | undefined;
|
|
43
|
+
try {
|
|
44
|
+
cid = CID.parse(input);
|
|
45
|
+
} catch {
|
|
46
|
+
// Only explicit local Template Bundles are accepted besides exact CIDs.
|
|
47
|
+
}
|
|
48
|
+
if (!cid) {
|
|
49
|
+
if (
|
|
50
|
+
/^[A-Za-z][A-Za-z0-9+.-]*:/.test(input) &&
|
|
51
|
+
!/^[A-Za-z]:[\\/]/.test(input)
|
|
52
|
+
)
|
|
53
|
+
throw new HostError(
|
|
54
|
+
"Template SOURCE does not accept URIs; use an exact CID, self-contained CAR or explicit Template Bundle directory.",
|
|
55
|
+
);
|
|
56
|
+
const path = resolve(input);
|
|
57
|
+
const stat = await lstat(path);
|
|
58
|
+
if (
|
|
59
|
+
stat.isSymbolicLink() ||
|
|
60
|
+
(!stat.isDirectory() &&
|
|
61
|
+
!(stat.isFile() && path.toLowerCase().endsWith(".car")))
|
|
62
|
+
)
|
|
63
|
+
throw new HostError(
|
|
64
|
+
"Template SOURCE must be an exact CID, self-contained CAR or explicit Template Bundle directory.",
|
|
65
|
+
);
|
|
66
|
+
if (stat.isDirectory()) {
|
|
67
|
+
const manifest = await lstat(resolve(path, ".bundle.yaml"));
|
|
68
|
+
if (!manifest.isFile() || manifest.isSymbolicLink())
|
|
69
|
+
throw new HostError(
|
|
70
|
+
"Template directory requires an explicit regular .bundle.yaml.",
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const content = await publicationSource(input, store);
|
|
75
|
+
await inspectTemplate(store, content);
|
|
76
|
+
return content;
|
|
77
|
+
}
|
package/dist/setup.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type InstallOptions } from "./kubo-install.js";
|
|
2
|
-
export declare function setupDevice(stateDir: string, env: NodeJS.ProcessEnv, options?: InstallOptions): Promise<{
|
|
3
|
-
kuboVersion: string;
|
|
4
|
-
binary: string;
|
|
5
|
-
publicKey: string;
|
|
6
|
-
fingerprint: string;
|
|
7
|
-
}>;
|
|
8
|
-
//# sourceMappingURL=setup.d.ts.map
|
package/dist/setup.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEtE,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,OAAO,GAAE,cAAmB;;;;;GAwB7B"}
|
package/dist/setup.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { accountIdentity } from "./identity.js";
|
|
2
|
-
import { kuboBinary, KUBO_VERSION } from "./kubo.js";
|
|
3
|
-
import { keyId } from "@ipab/bundle/pointer/crypto";
|
|
4
|
-
import { prepareStateStorage } from "./state-storage.js";
|
|
5
|
-
import { setupFailure } from "./kubo-install.js";
|
|
6
|
-
export async function setupDevice(stateDir, env, options = {}) {
|
|
7
|
-
options.signal?.throwIfAborted();
|
|
8
|
-
prepareStateStorage(stateDir, env);
|
|
9
|
-
const binary = await kuboBinary(stateDir, options);
|
|
10
|
-
try {
|
|
11
|
-
options.signal?.throwIfAborted();
|
|
12
|
-
options.diagnostic?.("Preparing the protected HOME account identity...");
|
|
13
|
-
const identity = await accountIdentity(env, true);
|
|
14
|
-
options.signal?.throwIfAborted();
|
|
15
|
-
return {
|
|
16
|
-
kuboVersion: KUBO_VERSION,
|
|
17
|
-
binary,
|
|
18
|
-
publicKey: identity.publicKey,
|
|
19
|
-
fingerprint: await keyId(identity.publicKey),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
catch (cause) {
|
|
23
|
-
options.signal?.throwIfAborted();
|
|
24
|
-
throw setupFailure("identity preparation", "protected account identity", cause);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=setup.js.map
|
package/dist/setup.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAuB,MAAM,mBAAmB,CAAC;AAEtE,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,QAAgB,EAChB,GAAsB,EACtB,UAA0B,EAAE;IAE5B,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;IACjC,mBAAmB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IACnC,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACnD,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;QACjC,OAAO,CAAC,UAAU,EAAE,CAAC,kDAAkD,CAAC,CAAC;QACzE,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAClD,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;QACjC,OAAO;YACL,WAAW,EAAE,YAAY;YACzB,MAAM;YACN,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,WAAW,EAAE,MAAM,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC;SAC7C,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;QACjC,MAAM,YAAY,CAChB,sBAAsB,EACtB,4BAA4B,EAC5B,KAAK,CACN,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/src/setup.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { accountIdentity } from "./identity.js";
|
|
2
|
-
import { kuboBinary, KUBO_VERSION } from "./kubo.js";
|
|
3
|
-
import { keyId } from "@ipab/bundle/pointer/crypto";
|
|
4
|
-
import { prepareStateStorage } from "./state-storage.js";
|
|
5
|
-
import { setupFailure, type InstallOptions } from "./kubo-install.js";
|
|
6
|
-
|
|
7
|
-
export async function setupDevice(
|
|
8
|
-
stateDir: string,
|
|
9
|
-
env: NodeJS.ProcessEnv,
|
|
10
|
-
options: InstallOptions = {},
|
|
11
|
-
) {
|
|
12
|
-
options.signal?.throwIfAborted();
|
|
13
|
-
prepareStateStorage(stateDir, env);
|
|
14
|
-
const binary = await kuboBinary(stateDir, options);
|
|
15
|
-
try {
|
|
16
|
-
options.signal?.throwIfAborted();
|
|
17
|
-
options.diagnostic?.("Preparing the protected HOME account identity...");
|
|
18
|
-
const identity = await accountIdentity(env, true);
|
|
19
|
-
options.signal?.throwIfAborted();
|
|
20
|
-
return {
|
|
21
|
-
kuboVersion: KUBO_VERSION,
|
|
22
|
-
binary,
|
|
23
|
-
publicKey: identity.publicKey,
|
|
24
|
-
fingerprint: await keyId(identity.publicKey),
|
|
25
|
-
};
|
|
26
|
-
} catch (cause) {
|
|
27
|
-
options.signal?.throwIfAborted();
|
|
28
|
-
throw setupFailure(
|
|
29
|
-
"identity preparation",
|
|
30
|
-
"protected account identity",
|
|
31
|
-
cause,
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
}
|