@ipab/cli 0.1.0-rc.0 → 0.1.0-rc.10
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 +230 -7
- package/dist/app-authoring.d.ts +16 -2
- package/dist/app-authoring.d.ts.map +1 -1
- package/dist/app-authoring.js +151 -66
- package/dist/app-authoring.js.map +1 -1
- package/dist/app-definition.d.ts +52 -63
- package/dist/app-definition.d.ts.map +1 -1
- package/dist/app-definition.js +33 -44
- package/dist/app-definition.js.map +1 -1
- package/dist/app-prebuild.d.ts +18 -0
- package/dist/app-prebuild.d.ts.map +1 -1
- package/dist/app-prebuild.js +46 -0
- package/dist/app-prebuild.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 +15 -45
- package/dist/app-templates.js.map +1 -1
- package/dist/assembly.d.ts +7 -0
- package/dist/assembly.d.ts.map +1 -0
- package/dist/assembly.js +130 -0
- package/dist/assembly.js.map +1 -0
- package/dist/authoring.d.ts +8 -21
- package/dist/authoring.d.ts.map +1 -1
- package/dist/authoring.js +35 -54
- package/dist/authoring.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 +5 -32
- package/dist/builtins.js.map +1 -1
- package/dist/bundled-skills.d.ts +14 -0
- package/dist/bundled-skills.d.ts.map +1 -0
- package/dist/bundled-skills.js +34 -0
- package/dist/bundled-skills.js.map +1 -0
- package/dist/cli.d.ts +8 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2009 -308
- package/dist/cli.js.map +1 -1
- package/dist/config-secret.d.ts +3 -0
- package/dist/config-secret.d.ts.map +1 -0
- package/dist/config-secret.js +12 -0
- package/dist/config-secret.js.map +1 -0
- package/dist/config.d.ts +9 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +164 -23
- package/dist/config.js.map +1 -1
- package/dist/content-provider.d.ts +32 -0
- package/dist/content-provider.d.ts.map +1 -0
- package/dist/content-provider.js +222 -0
- package/dist/content-provider.js.map +1 -0
- 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 +26 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +56 -2
- package/dist/context.js.map +1 -1
- package/dist/daemon-ui.d.ts +93 -0
- package/dist/daemon-ui.d.ts.map +1 -0
- package/dist/daemon-ui.js +713 -0
- package/dist/daemon-ui.js.map +1 -0
- package/dist/daemon.d.ts +21 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/daemon.js +317 -0
- package/dist/daemon.js.map +1 -0
- package/dist/doctor.d.ts +32 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +684 -0
- package/dist/doctor.js.map +1 -0
- package/dist/errors.d.ts +1 -8
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -20
- package/dist/errors.js.map +1 -1
- package/dist/get.d.ts +3 -0
- package/dist/get.d.ts.map +1 -0
- package/dist/get.js +80 -0
- package/dist/get.js.map +1 -0
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +6 -14
- package/dist/history.js.map +1 -1
- package/dist/host-error.d.ts +9 -0
- package/dist/host-error.d.ts.map +1 -0
- package/dist/host-error.js +21 -0
- package/dist/host-error.js.map +1 -0
- package/dist/identity.d.ts +16 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +119 -0
- package/dist/identity.js.map +1 -0
- package/dist/ipc.d.ts +5 -1
- package/dist/ipc.d.ts.map +1 -1
- package/dist/ipc.js +125 -4
- 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 +119 -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-topology.d.ts +19 -0
- package/dist/kubo-topology.d.ts.map +1 -0
- package/dist/kubo-topology.js +113 -0
- package/dist/kubo-topology.js.map +1 -0
- package/dist/kubo.d.ts +85 -0
- package/dist/kubo.d.ts.map +1 -0
- package/dist/kubo.js +755 -0
- package/dist/kubo.js.map +1 -0
- package/dist/pins.d.ts +18 -20
- package/dist/pins.d.ts.map +1 -1
- package/dist/pins.js +146 -126
- package/dist/pins.js.map +1 -1
- package/dist/pivot-rpc.d.ts +62 -0
- package/dist/pivot-rpc.d.ts.map +1 -0
- package/dist/pivot-rpc.js +407 -0
- package/dist/pivot-rpc.js.map +1 -0
- package/dist/pivot-service.d.ts +16 -0
- package/dist/pivot-service.d.ts.map +1 -0
- package/dist/pivot-service.js +50 -0
- package/dist/pivot-service.js.map +1 -0
- 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 +9 -4
- package/dist/runtime.js.map +1 -1
- package/dist/search-index.d.ts +64 -0
- package/dist/search-index.d.ts.map +1 -0
- package/dist/search-index.js +409 -0
- package/dist/search-index.js.map +1 -0
- package/dist/search-service.d.ts +23 -0
- package/dist/search-service.d.ts.map +1 -0
- package/dist/search-service.js +116 -0
- package/dist/search-service.js.map +1 -0
- 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 +9 -0
- package/dist/skill-source.d.ts.map +1 -0
- package/dist/skill-source.js +24 -0
- package/dist/skill-source.js.map +1 -0
- package/dist/skills.d.ts +104 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +894 -0
- package/dist/skills.js.map +1 -0
- package/dist/source-bundle.d.ts +3 -9
- package/dist/source-bundle.d.ts.map +1 -1
- package/dist/source-bundle.js +17 -13
- package/dist/source-bundle.js.map +1 -1
- package/dist/space-path.d.ts +3 -0
- package/dist/space-path.d.ts.map +1 -0
- package/dist/space-path.js +17 -0
- package/dist/space-path.js.map +1 -0
- package/dist/space.d.ts +16 -4
- package/dist/space.d.ts.map +1 -1
- package/dist/space.js +170 -24
- package/dist/space.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 +333 -0
- package/dist/state-storage.js.map +1 -0
- package/dist/state.d.ts +128 -16
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +506 -94
- package/dist/state.js.map +1 -1
- package/dist/swarm-envelope.d.ts +57 -0
- package/dist/swarm-envelope.d.ts.map +1 -0
- package/dist/swarm-envelope.js +299 -0
- package/dist/swarm-envelope.js.map +1 -0
- package/dist/swarm-files.d.ts +6 -0
- package/dist/swarm-files.d.ts.map +1 -0
- package/dist/swarm-files.js +116 -0
- package/dist/swarm-files.js.map +1 -0
- package/dist/swarm-meta.d.ts +15 -0
- package/dist/swarm-meta.d.ts.map +1 -0
- package/dist/swarm-meta.js +68 -0
- package/dist/swarm-meta.js.map +1 -0
- package/dist/swarm-observations.d.ts +40 -0
- package/dist/swarm-observations.d.ts.map +1 -0
- package/dist/swarm-observations.js +271 -0
- package/dist/swarm-observations.js.map +1 -0
- package/dist/swarm.d.ts +469 -0
- package/dist/swarm.d.ts.map +1 -0
- package/dist/swarm.js +4708 -0
- package/dist/swarm.js.map +1 -0
- package/dist/template-definition.d.ts +45 -67
- package/dist/template-definition.d.ts.map +1 -1
- package/dist/template-definition.js +35 -49
- package/dist/template-definition.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 +4 -1
- package/dist/template-source.d.ts.map +1 -1
- package/dist/template-source.js +11 -4
- 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/dist/unixfs-tree.d.ts +67 -0
- package/dist/unixfs-tree.d.ts.map +1 -0
- package/dist/unixfs-tree.js +329 -0
- package/dist/unixfs-tree.js.map +1 -0
- package/package.json +18 -11
- package/src/app-authoring.ts +254 -88
- package/src/app-definition.ts +33 -45
- package/src/app-prebuild.ts +61 -0
- package/src/app-templates.ts +28 -71
- package/src/assembly.ts +185 -0
- package/src/authoring.ts +63 -72
- package/src/builtins.ts +7 -38
- package/src/bundled-skills.ts +60 -0
- package/src/cli.ts +2500 -376
- package/src/config-secret.ts +14 -0
- package/src/config.ts +215 -26
- package/src/content-provider.ts +299 -0
- package/src/context-types.ts +11 -0
- package/src/context.ts +100 -2
- package/src/daemon-ui.ts +812 -0
- package/src/daemon.ts +386 -0
- package/src/doctor.ts +1082 -0
- package/src/errors.ts +1 -25
- package/src/get.ts +90 -0
- package/src/history.ts +5 -15
- package/src/host-error.ts +26 -0
- package/src/identity.ts +175 -0
- package/src/ipc.ts +161 -4
- package/src/kubo-install.ts +936 -0
- package/src/kubo-peering.ts +126 -0
- package/src/kubo-peers.ts +144 -0
- package/src/kubo-release.ts +230 -0
- package/src/kubo-topology.ts +148 -0
- package/src/kubo.ts +1088 -0
- package/src/pins.ts +190 -142
- package/src/pivot-rpc.ts +601 -0
- package/src/pivot-service.ts +87 -0
- package/src/publish-source.ts +103 -0
- package/src/runtime.ts +16 -3
- package/src/search-index.ts +560 -0
- package/src/search-service.ts +152 -0
- package/src/skill-definition.ts +53 -0
- package/src/skill-source.ts +29 -0
- package/src/skills.ts +1236 -0
- package/src/source-bundle.ts +26 -14
- package/src/space-path.ts +30 -0
- package/src/space.ts +230 -42
- package/src/state-storage-windows.ts +134 -0
- package/src/state-storage.ts +378 -0
- package/src/state.ts +782 -116
- package/src/swarm-envelope.ts +461 -0
- package/src/swarm-files.ts +126 -0
- package/src/swarm-meta.ts +98 -0
- package/src/swarm-observations.ts +393 -0
- package/src/swarm.ts +7051 -0
- package/src/template-definition.ts +35 -49
- package/src/template-paths.ts +43 -0
- package/src/template-presentation.ts +151 -0
- package/src/template-source.ts +19 -5
- package/src/templates.ts +77 -0
- package/src/unixfs-tree.ts +401 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { syntax } from "./errors.js";
|
|
2
|
+
export { verifyStateStorage as secureConfigurationStorage } from "./state-storage.js";
|
|
3
|
+
|
|
4
|
+
export async function readSecretStream(
|
|
5
|
+
input: AsyncIterable<string>,
|
|
6
|
+
): Promise<string> {
|
|
7
|
+
let text = "";
|
|
8
|
+
for await (const chunk of input) {
|
|
9
|
+
if (Buffer.byteLength(text) + Buffer.byteLength(chunk) > 64)
|
|
10
|
+
syntax("API key input exceeds 64 bytes.");
|
|
11
|
+
text += chunk;
|
|
12
|
+
}
|
|
13
|
+
return text.trim();
|
|
14
|
+
}
|
package/src/config.ts
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { homedir } from "node:os";
|
|
2
2
|
import { join, resolve } from "node:path";
|
|
3
|
+
import { CID } from "multiformats/cid";
|
|
3
4
|
import { readContentConfiguration } from "@ipab/ipfs-store/node";
|
|
4
5
|
import type { StoreConfiguration } from "@ipab/ipfs-store";
|
|
5
|
-
import { HostError, object, syntax } from "./
|
|
6
|
+
import { HostError, object, syntax } from "./host-error.js";
|
|
6
7
|
|
|
7
8
|
export type ConfigKey =
|
|
8
|
-
| "
|
|
9
|
+
| "daemon.uiPort"
|
|
10
|
+
| "swarm.default"
|
|
11
|
+
| "swarm.listen"
|
|
12
|
+
| "swarm.pivot"
|
|
13
|
+
| "swarm.cacheTtl"
|
|
14
|
+
| "swarm.syncInterval"
|
|
15
|
+
| "swarm.forceRefresh"
|
|
16
|
+
| "store.gateway"
|
|
17
|
+
| "pointers.service"
|
|
18
|
+
| "pointers.apiKey"
|
|
9
19
|
| "history.enabled"
|
|
10
20
|
| "history.limit"
|
|
11
21
|
| "output.retention"
|
|
@@ -13,8 +23,9 @@ export type ConfigKey =
|
|
|
13
23
|
export type ConfigValue = string | boolean | number | null;
|
|
14
24
|
export type Source = "flag" | "env" | "user" | "default";
|
|
15
25
|
export interface GlobalOptions {
|
|
26
|
+
swarm?: string;
|
|
16
27
|
stateDir?: string;
|
|
17
|
-
|
|
28
|
+
storeGateway?: string;
|
|
18
29
|
json: boolean;
|
|
19
30
|
}
|
|
20
31
|
export interface ConfigItem {
|
|
@@ -23,14 +34,31 @@ export interface ConfigItem {
|
|
|
23
34
|
source: Source;
|
|
24
35
|
}
|
|
25
36
|
export const defaults: Record<ConfigKey, ConfigValue> = {
|
|
26
|
-
"
|
|
37
|
+
"daemon.uiPort": 0,
|
|
38
|
+
"swarm.default": null,
|
|
39
|
+
"swarm.listen": "lan",
|
|
40
|
+
"swarm.pivot": false,
|
|
41
|
+
"swarm.cacheTtl": 300,
|
|
42
|
+
"swarm.syncInterval": 60,
|
|
43
|
+
"swarm.forceRefresh": false,
|
|
44
|
+
"store.gateway": null,
|
|
45
|
+
"pointers.service": null,
|
|
46
|
+
"pointers.apiKey": null,
|
|
27
47
|
"history.enabled": true,
|
|
28
48
|
"history.limit": 20,
|
|
29
49
|
"output.retention": "history",
|
|
30
50
|
"bundle.outputDir": "dist",
|
|
31
51
|
};
|
|
32
|
-
const environments: Record<ConfigKey, string
|
|
33
|
-
"
|
|
52
|
+
const environments: Partial<Record<ConfigKey, string>> = {
|
|
53
|
+
"daemon.uiPort": "IPAB_DAEMON_UI_PORT",
|
|
54
|
+
"swarm.listen": "IPAB_SWARM_LISTEN",
|
|
55
|
+
"swarm.pivot": "IPAB_SWARM_PIVOT",
|
|
56
|
+
"swarm.cacheTtl": "IPAB_SWARM_CACHE_TTL",
|
|
57
|
+
"swarm.syncInterval": "IPAB_SWARM_SYNC_INTERVAL",
|
|
58
|
+
"swarm.forceRefresh": "IPAB_SWARM_FORCE_REFRESH",
|
|
59
|
+
"store.gateway": "IPAB_STORE_GATEWAY",
|
|
60
|
+
"pointers.service": "IPAB_POINTERS_SERVICE",
|
|
61
|
+
"pointers.apiKey": "IPAB_POINTERS_API_KEY",
|
|
34
62
|
"history.enabled": "IPAB_HISTORY_ENABLED",
|
|
35
63
|
"history.limit": "IPAB_HISTORY_LIMIT",
|
|
36
64
|
"output.retention": "IPAB_OUTPUT_RETENTION",
|
|
@@ -65,21 +93,134 @@ export function publicUrl(value: string): string {
|
|
|
65
93
|
return url.toString();
|
|
66
94
|
}
|
|
67
95
|
|
|
96
|
+
export function pointerService(value: string): string {
|
|
97
|
+
let url: URL;
|
|
98
|
+
try {
|
|
99
|
+
url = new URL(value);
|
|
100
|
+
} catch {
|
|
101
|
+
syntax(
|
|
102
|
+
"Pointer service must be a canonical HTTPS origin (HTTP loopback allowed).",
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
if (
|
|
106
|
+
url.username ||
|
|
107
|
+
url.password ||
|
|
108
|
+
url.search ||
|
|
109
|
+
url.hash ||
|
|
110
|
+
url.pathname !== "/" ||
|
|
111
|
+
(url.protocol !== "https:" &&
|
|
112
|
+
!(
|
|
113
|
+
url.protocol === "http:" &&
|
|
114
|
+
["localhost", "127.0.0.1", "[::1]"].includes(url.hostname)
|
|
115
|
+
)) ||
|
|
116
|
+
value !== url.origin
|
|
117
|
+
)
|
|
118
|
+
syntax(
|
|
119
|
+
"Pointer service must be a canonical HTTPS origin (HTTP loopback allowed).",
|
|
120
|
+
);
|
|
121
|
+
return url.origin;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function visibleConfig(item: ConfigItem): ConfigItem {
|
|
125
|
+
return item.key === "pointers.apiKey" && item.value !== null
|
|
126
|
+
? { ...item, value: "<redacted>" }
|
|
127
|
+
: item;
|
|
128
|
+
}
|
|
129
|
+
|
|
68
130
|
export function parseValue(
|
|
69
131
|
key: ConfigKey,
|
|
70
132
|
value: unknown,
|
|
71
133
|
text = false,
|
|
72
134
|
): ConfigValue {
|
|
73
135
|
if (text && typeof value === "string") {
|
|
74
|
-
if (key === "
|
|
136
|
+
if (key === "daemon.uiPort" && value === "default") return defaults[key];
|
|
137
|
+
if (key.startsWith("swarm.") && value === "default")
|
|
138
|
+
return key === "swarm.cacheTtl" ||
|
|
139
|
+
key === "swarm.syncInterval" ||
|
|
140
|
+
key === "swarm.forceRefresh" ||
|
|
141
|
+
key === "swarm.pivot" ||
|
|
142
|
+
key === "swarm.listen"
|
|
143
|
+
? defaults[key]
|
|
144
|
+
: null;
|
|
145
|
+
if (
|
|
146
|
+
key === "history.enabled" ||
|
|
147
|
+
key === "swarm.forceRefresh" ||
|
|
148
|
+
key === "swarm.pivot"
|
|
149
|
+
) {
|
|
75
150
|
if (value === "true") return true;
|
|
76
151
|
if (value === "false") return false;
|
|
77
152
|
}
|
|
78
153
|
if (key === "history.limit" && /^[1-9]\d*$/.test(value))
|
|
79
154
|
value = Number(value);
|
|
80
|
-
if (
|
|
155
|
+
if (
|
|
156
|
+
(key === "daemon.uiPort" ||
|
|
157
|
+
key === "swarm.cacheTtl" ||
|
|
158
|
+
key === "swarm.syncInterval") &&
|
|
159
|
+
typeof value === "string" &&
|
|
160
|
+
/^(0|[1-9]\d*)$/.test(value)
|
|
161
|
+
)
|
|
162
|
+
value = Number(value);
|
|
163
|
+
if (
|
|
164
|
+
["store.gateway", "pointers.service", "pointers.apiKey"].includes(key) &&
|
|
165
|
+
value === "default"
|
|
166
|
+
)
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
if (key === "pointers.service" || key === "pointers.apiKey") {
|
|
170
|
+
if (value === null) return null;
|
|
171
|
+
if (key === "pointers.service" && typeof value === "string")
|
|
172
|
+
return pointerService(value);
|
|
173
|
+
if (
|
|
174
|
+
key === "pointers.apiKey" &&
|
|
175
|
+
typeof value === "string" &&
|
|
176
|
+
/^[A-Za-z0-9_-]{43}$/.test(value) &&
|
|
177
|
+
Buffer.from(value, "base64url").toString("base64url") === value
|
|
178
|
+
)
|
|
179
|
+
return value;
|
|
180
|
+
syntax(
|
|
181
|
+
key === "pointers.apiKey"
|
|
182
|
+
? "Invalid pointers.apiKey; expected a canonical base64url encoding of 32 bytes."
|
|
183
|
+
: "Invalid pointers.service; expected a canonical HTTPS origin or default.",
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
if (key === "daemon.uiPort") {
|
|
187
|
+
if (
|
|
188
|
+
typeof value === "number" &&
|
|
189
|
+
Number.isSafeInteger(value) &&
|
|
190
|
+
value >= 0 &&
|
|
191
|
+
value <= 65535
|
|
192
|
+
)
|
|
193
|
+
return value;
|
|
194
|
+
syntax(
|
|
195
|
+
"daemon.uiPort requires an integer port from 0 to 65535 (0 for automatic).",
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
if (key === "swarm.cacheTtl" || key === "swarm.syncInterval") {
|
|
199
|
+
const minimum = key === "swarm.syncInterval" ? 1 : 0;
|
|
200
|
+
if (
|
|
201
|
+
Number.isSafeInteger(value) &&
|
|
202
|
+
typeof value === "number" &&
|
|
203
|
+
value >= minimum &&
|
|
204
|
+
value <= 86400
|
|
205
|
+
)
|
|
206
|
+
return value;
|
|
207
|
+
syntax(
|
|
208
|
+
`${key} requires an integer number of seconds from ${minimum} to 86400.`,
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
if (key === "swarm.forceRefresh" || key === "swarm.pivot") {
|
|
212
|
+
if (typeof value === "boolean") return value;
|
|
213
|
+
syntax(`${key} requires true or false.`);
|
|
81
214
|
}
|
|
82
|
-
if (key === "
|
|
215
|
+
if (key === "swarm.listen") {
|
|
216
|
+
if (value === "lan" || value === "loopback") return value;
|
|
217
|
+
syntax("swarm.listen requires lan or loopback.");
|
|
218
|
+
}
|
|
219
|
+
if (key.startsWith("swarm.") && value === null) return null;
|
|
220
|
+
if (key === "swarm.default" && typeof value === "string") {
|
|
221
|
+
return swarmUrl(value);
|
|
222
|
+
}
|
|
223
|
+
if (key === "store.gateway" && value === null) return null;
|
|
83
224
|
if (
|
|
84
225
|
key === "bundle.outputDir" &&
|
|
85
226
|
typeof value === "string" &&
|
|
@@ -87,7 +228,8 @@ export function parseValue(
|
|
|
87
228
|
!value.includes("\0")
|
|
88
229
|
)
|
|
89
230
|
return value;
|
|
90
|
-
if (key === "store.
|
|
231
|
+
if (key === "store.gateway" && typeof value === "string")
|
|
232
|
+
return publicUrl(value);
|
|
91
233
|
if (key === "history.enabled" && typeof value === "boolean") return value;
|
|
92
234
|
if (
|
|
93
235
|
key === "history.limit" &&
|
|
@@ -113,6 +255,38 @@ export function parseValue(
|
|
|
113
255
|
);
|
|
114
256
|
}
|
|
115
257
|
|
|
258
|
+
export function rejectLegacySwarmCid(value: string): void {
|
|
259
|
+
try {
|
|
260
|
+
CID.parse(value);
|
|
261
|
+
} catch {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
throw new HostError(
|
|
265
|
+
"The old Swarm CID protocol is unsupported. Ask the Owner for the Swarm configuration URL.",
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export function swarmUrl(value: string): string {
|
|
270
|
+
try {
|
|
271
|
+
const url = new URL(value);
|
|
272
|
+
pointerService(url.origin);
|
|
273
|
+
if (
|
|
274
|
+
url.username ||
|
|
275
|
+
url.password ||
|
|
276
|
+
url.search ||
|
|
277
|
+
url.hash ||
|
|
278
|
+
url.toString() !== value ||
|
|
279
|
+
!/^\/v1\/[a-f0-9]{16}\/[a-f0-9]{16}$/.test(url.pathname)
|
|
280
|
+
)
|
|
281
|
+
throw new Error();
|
|
282
|
+
return value;
|
|
283
|
+
} catch {
|
|
284
|
+
rejectLegacySwarmCid(value);
|
|
285
|
+
return syntax(
|
|
286
|
+
"Swarm requires an exact /v1/{scope}/{variable} configuration URL (HTTPS or HTTP loopback), with two 16-character lowercase hex IDs and no credentials, query or fragment.",
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
116
290
|
export function validateUserConfig(
|
|
117
291
|
value: unknown,
|
|
118
292
|
): Partial<Record<ConfigKey, ConfigValue>> {
|
|
@@ -162,19 +336,38 @@ export function effectiveConfig(
|
|
|
162
336
|
user: Partial<Record<ConfigKey, ConfigValue>>,
|
|
163
337
|
flags: GlobalOptions,
|
|
164
338
|
env: NodeJS.ProcessEnv = process.env,
|
|
339
|
+
resolveSwarm?: (reference: string) => string,
|
|
165
340
|
): ConfigItem[] {
|
|
341
|
+
if (env.IPAB_STORE_RPC !== undefined)
|
|
342
|
+
syntax(
|
|
343
|
+
"IPAB_STORE_RPC is no longer supported. Remove it and use IPAB_STORE_GATEWAY with an HTTP gateway URL.",
|
|
344
|
+
);
|
|
166
345
|
const result = (Object.keys(defaults) as ConfigKey[]).map(
|
|
167
346
|
(key): ConfigItem => {
|
|
168
|
-
const
|
|
169
|
-
const
|
|
347
|
+
const environment = environments[key];
|
|
348
|
+
const variable = environment === undefined ? undefined : env[environment];
|
|
349
|
+
const flag =
|
|
350
|
+
key === "store.gateway"
|
|
351
|
+
? flags.storeGateway
|
|
352
|
+
: key === "swarm.default"
|
|
353
|
+
? flags.swarm
|
|
354
|
+
: undefined;
|
|
170
355
|
// Invalid lower layers are not hidden by a higher-priority override.
|
|
356
|
+
const parse = (value: string) =>
|
|
357
|
+
parseValue(
|
|
358
|
+
key,
|
|
359
|
+
key === "swarm.default" && value !== "default" && resolveSwarm
|
|
360
|
+
? resolveSwarm(value)
|
|
361
|
+
: value,
|
|
362
|
+
true,
|
|
363
|
+
);
|
|
171
364
|
const environmental =
|
|
172
|
-
variable === undefined ? undefined :
|
|
365
|
+
variable === undefined ? undefined : parse(variable);
|
|
173
366
|
return {
|
|
174
367
|
key,
|
|
175
368
|
value:
|
|
176
369
|
flag !== undefined
|
|
177
|
-
?
|
|
370
|
+
? parse(flag)
|
|
178
371
|
: variable !== undefined
|
|
179
372
|
? environmental!
|
|
180
373
|
: Object.hasOwn(user, key)
|
|
@@ -201,20 +394,16 @@ export function effectiveConfig(
|
|
|
201
394
|
}
|
|
202
395
|
|
|
203
396
|
export async function storeConfiguration(
|
|
204
|
-
|
|
397
|
+
gateway: ConfigValue,
|
|
205
398
|
): Promise<StoreConfiguration> {
|
|
206
|
-
const config =
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
? [config.apiUrl]
|
|
399
|
+
const config = await readContentConfiguration(
|
|
400
|
+
gateway === null ? {} : { gateway: publicUrl(String(gateway)) },
|
|
401
|
+
);
|
|
402
|
+
const urls = config.gateway
|
|
403
|
+
? typeof config.gateway === "string"
|
|
404
|
+
? [config.gateway]
|
|
213
405
|
: config.gateway
|
|
214
|
-
|
|
215
|
-
? [config.gateway]
|
|
216
|
-
: config.gateway
|
|
217
|
-
: [];
|
|
406
|
+
: [];
|
|
218
407
|
for (const url of urls) publicUrl(url);
|
|
219
408
|
return config;
|
|
220
409
|
}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createWriter,
|
|
3
|
+
headerLength,
|
|
4
|
+
blockLength,
|
|
5
|
+
} from "@ipld/car/buffer-writer";
|
|
6
|
+
import * as dagPb from "@ipld/dag-pb";
|
|
7
|
+
import * as dagCbor from "@ipld/dag-cbor";
|
|
8
|
+
import { CID } from "multiformats/cid";
|
|
9
|
+
import type { IpfsStore } from "@ipab/ipfs-store";
|
|
10
|
+
import { bundleLimits, openBundle } from "@ipab/bundle";
|
|
11
|
+
import { bytes } from "./space.js";
|
|
12
|
+
import { HostError } from "./errors.js";
|
|
13
|
+
import { publicUrl } from "./config.js";
|
|
14
|
+
|
|
15
|
+
export async function contentCar(
|
|
16
|
+
store: IpfsStore,
|
|
17
|
+
roots: readonly string[],
|
|
18
|
+
signal?: AbortSignal,
|
|
19
|
+
): Promise<Uint8Array> {
|
|
20
|
+
const blocks = new Map<string, { cid: CID; bytes: Uint8Array }>();
|
|
21
|
+
let total = 0;
|
|
22
|
+
const visit = async (cid: CID, depth: number): Promise<void> => {
|
|
23
|
+
const key = cid.toV1().toString();
|
|
24
|
+
if (blocks.has(key)) return;
|
|
25
|
+
if (depth > bundleLimits.depth || blocks.size >= bundleLimits.blocks)
|
|
26
|
+
throw new HostError("Publication DAG exceeds limits.");
|
|
27
|
+
const value = await store.block.get(key, signal ? { signal } : {});
|
|
28
|
+
total += value.length;
|
|
29
|
+
if (total > bundleLimits.bytes)
|
|
30
|
+
throw new HostError("Publication exceeds byte budget.");
|
|
31
|
+
blocks.set(key, { cid, bytes: value });
|
|
32
|
+
if (cid.code === dagPb.code)
|
|
33
|
+
for (const link of dagPb.decode(value).Links)
|
|
34
|
+
await visit(link.Hash, depth + 1);
|
|
35
|
+
else if (cid.code === dagCbor.code) {
|
|
36
|
+
const scan = async (value: unknown): Promise<void> => {
|
|
37
|
+
const link = CID.asCID(value);
|
|
38
|
+
if (link) await visit(link, depth + 1);
|
|
39
|
+
else if (Array.isArray(value))
|
|
40
|
+
for (const item of value) await scan(item);
|
|
41
|
+
else if (value && typeof value === "object")
|
|
42
|
+
for (const item of Object.values(value)) await scan(item);
|
|
43
|
+
};
|
|
44
|
+
await scan(dagCbor.decode(value));
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const cids = [...new Set(roots)].map((root) => CID.parse(root));
|
|
48
|
+
for (const cid of cids) await visit(cid, 0);
|
|
49
|
+
const size =
|
|
50
|
+
headerLength({ roots: cids }) +
|
|
51
|
+
[...blocks.values()].reduce((sum, block) => sum + blockLength(block), 0);
|
|
52
|
+
const writer = createWriter(new ArrayBuffer(size), { roots: cids });
|
|
53
|
+
for (const block of blocks.values()) writer.write(block);
|
|
54
|
+
return writer.close();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Builds a CAR containing only the specified single blocks (non-recursive, e.g. v7 path
|
|
59
|
+
* directory blocks) plus the full DAG closure of `recursiveRoots` (e.g. published target).
|
|
60
|
+
*/
|
|
61
|
+
export async function shallowContentCar(
|
|
62
|
+
store: IpfsStore,
|
|
63
|
+
directBlocks: readonly string[],
|
|
64
|
+
recursiveRoots: readonly string[],
|
|
65
|
+
signal?: AbortSignal,
|
|
66
|
+
): Promise<Uint8Array> {
|
|
67
|
+
const blocks = new Map<string, { cid: CID; bytes: Uint8Array }>();
|
|
68
|
+
let total = 0;
|
|
69
|
+
const recordSingle = async (cid: CID): Promise<Uint8Array> => {
|
|
70
|
+
const key = cid.toV1().toString();
|
|
71
|
+
const existing = blocks.get(key);
|
|
72
|
+
if (existing) return existing.bytes;
|
|
73
|
+
if (blocks.size >= bundleLimits.blocks)
|
|
74
|
+
throw new HostError("Publication DAG exceeds limits.");
|
|
75
|
+
const value = await store.block.get(key, signal ? { signal } : {});
|
|
76
|
+
total += value.length;
|
|
77
|
+
if (total > bundleLimits.bytes)
|
|
78
|
+
throw new HostError("Publication exceeds byte budget.");
|
|
79
|
+
blocks.set(key, { cid: cid.toV1(), bytes: value });
|
|
80
|
+
return value;
|
|
81
|
+
};
|
|
82
|
+
const visit = async (cid: CID, depth: number): Promise<void> => {
|
|
83
|
+
const key = cid.toV1().toString();
|
|
84
|
+
if (blocks.has(key)) return;
|
|
85
|
+
if (depth > bundleLimits.depth || blocks.size >= bundleLimits.blocks)
|
|
86
|
+
throw new HostError("Publication DAG exceeds limits.");
|
|
87
|
+
const value = await recordSingle(cid);
|
|
88
|
+
if (cid.code === dagPb.code)
|
|
89
|
+
for (const link of dagPb.decode(value).Links)
|
|
90
|
+
await visit(link.Hash, depth + 1);
|
|
91
|
+
else if (cid.code === dagCbor.code) {
|
|
92
|
+
const scan = async (item: unknown): Promise<void> => {
|
|
93
|
+
const link = CID.asCID(item);
|
|
94
|
+
if (link) await visit(link, depth + 1);
|
|
95
|
+
else if (Array.isArray(item))
|
|
96
|
+
for (const entry of item) await scan(entry);
|
|
97
|
+
else if (item && typeof item === "object")
|
|
98
|
+
for (const entry of Object.values(item)) await scan(entry);
|
|
99
|
+
};
|
|
100
|
+
await scan(dagCbor.decode(value));
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
for (const root of [...new Set(recursiveRoots)])
|
|
104
|
+
await visit(CID.parse(root), 0);
|
|
105
|
+
for (const root of [...new Set(directBlocks)])
|
|
106
|
+
await recordSingle(CID.parse(root));
|
|
107
|
+
const cids = [...new Set([...directBlocks, ...recursiveRoots])].map((root) =>
|
|
108
|
+
CID.parse(root).toV1(),
|
|
109
|
+
);
|
|
110
|
+
const size =
|
|
111
|
+
headerLength({ roots: cids }) +
|
|
112
|
+
[...blocks.values()].reduce((sum, block) => sum + blockLength(block), 0);
|
|
113
|
+
const writer = createWriter(new ArrayBuffer(size), { roots: cids });
|
|
114
|
+
for (const block of blocks.values()) writer.write(block);
|
|
115
|
+
return writer.close();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Explicit upload bridge, not a Store backend or daemon lifecycle controller. */
|
|
119
|
+
export async function provideContent(
|
|
120
|
+
store: IpfsStore,
|
|
121
|
+
roots: readonly string[],
|
|
122
|
+
endpoint: string,
|
|
123
|
+
fetcher: typeof fetch = fetch,
|
|
124
|
+
authorizationToken?: string,
|
|
125
|
+
retainedRoots: readonly string[] = roots,
|
|
126
|
+
signal?: AbortSignal,
|
|
127
|
+
): Promise<void> {
|
|
128
|
+
const url = new URL(publicUrl(endpoint));
|
|
129
|
+
if (
|
|
130
|
+
url.protocol !== "https:" &&
|
|
131
|
+
!["localhost", "127.0.0.1", "[::1]"].includes(url.hostname)
|
|
132
|
+
)
|
|
133
|
+
throw new HostError(
|
|
134
|
+
"Kubo provider must use HTTPS or account-local loopback HTTP.",
|
|
135
|
+
);
|
|
136
|
+
const car = await contentCar(store, roots, signal);
|
|
137
|
+
const owner = `publication:${roots[0]!}`;
|
|
138
|
+
await store.retain(owner, retainedRoots, signal ? { signal } : {});
|
|
139
|
+
await store.confirmRetained(owner, retainedRoots, signal ? { signal } : {});
|
|
140
|
+
const data = new FormData();
|
|
141
|
+
data.append("file", new Blob([Uint8Array.from(car)]), "content.car");
|
|
142
|
+
const response = await fetcher(
|
|
143
|
+
`${url.toString().replace(/\/$/, "")}/api/v0/dag/import?pin-roots=true`,
|
|
144
|
+
{
|
|
145
|
+
method: "POST",
|
|
146
|
+
...(authorizationToken
|
|
147
|
+
? { headers: { authorization: `Bearer ${authorizationToken}` } }
|
|
148
|
+
: {}),
|
|
149
|
+
body: data,
|
|
150
|
+
redirect: "error",
|
|
151
|
+
signal: signal
|
|
152
|
+
? AbortSignal.any([signal, AbortSignal.timeout(30_000)])
|
|
153
|
+
: AbortSignal.timeout(30_000),
|
|
154
|
+
},
|
|
155
|
+
);
|
|
156
|
+
if (!response.ok || !response.body)
|
|
157
|
+
throw new HostError(
|
|
158
|
+
`Content provider import failed (HTTP ${response.status}); HEAD was not changed.`,
|
|
159
|
+
);
|
|
160
|
+
const text = new TextDecoder("utf-8", { fatal: true }).decode(
|
|
161
|
+
await bytes(response.body, 256 * 1024),
|
|
162
|
+
);
|
|
163
|
+
const accepted = new Set<string>();
|
|
164
|
+
for (const line of text.trim().split(/\r?\n/)) {
|
|
165
|
+
const item = JSON.parse(line) as {
|
|
166
|
+
Root?: { Cid?: { "/"?: string }; PinErrorMsg?: string };
|
|
167
|
+
ErrMsg?: string;
|
|
168
|
+
};
|
|
169
|
+
if (item.ErrMsg || item.Root?.PinErrorMsg)
|
|
170
|
+
throw new HostError("Content provider failed to pin imported roots.");
|
|
171
|
+
if (item.Root?.Cid?.["/"])
|
|
172
|
+
accepted.add(CID.parse(item.Root.Cid["/"]).toV1().toString());
|
|
173
|
+
}
|
|
174
|
+
if (roots.some((root) => !accepted.has(CID.parse(root).toV1().toString())))
|
|
175
|
+
throw new HostError(
|
|
176
|
+
"Content provider did not confirm every imported/pinned root; HEAD was not changed.",
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Shallow provider bridge for v7 UnixFS root updates:
|
|
182
|
+
* - Retains `directBlocks` directly (non-recursively) and `recursiveRoots` recursively in local Store.
|
|
183
|
+
* - Imports a shallow CAR into Kubo with `pin-roots=false`.
|
|
184
|
+
* - Calls `/api/v0/pin/add?recursive=false` for each direct path directory block,
|
|
185
|
+
* and `/api/v0/pin/add?recursive=true` for each recursive content root.
|
|
186
|
+
*/
|
|
187
|
+
export async function provideShallowContent(
|
|
188
|
+
store: IpfsStore,
|
|
189
|
+
options: {
|
|
190
|
+
directBlocks: readonly string[];
|
|
191
|
+
recursiveRoots: readonly string[];
|
|
192
|
+
retainedDirect?: readonly string[];
|
|
193
|
+
retainedRecursive?: readonly string[];
|
|
194
|
+
endpoint: string;
|
|
195
|
+
fetcher?: typeof fetch;
|
|
196
|
+
authorizationToken?: string;
|
|
197
|
+
owner?: string;
|
|
198
|
+
signal?: AbortSignal;
|
|
199
|
+
},
|
|
200
|
+
): Promise<void> {
|
|
201
|
+
const {
|
|
202
|
+
directBlocks,
|
|
203
|
+
recursiveRoots,
|
|
204
|
+
endpoint,
|
|
205
|
+
fetcher = fetch,
|
|
206
|
+
authorizationToken,
|
|
207
|
+
signal,
|
|
208
|
+
} = options;
|
|
209
|
+
const retainedDirect = options.retainedDirect ?? directBlocks;
|
|
210
|
+
const retainedRecursive = options.retainedRecursive ?? recursiveRoots;
|
|
211
|
+
const url = new URL(publicUrl(endpoint));
|
|
212
|
+
if (
|
|
213
|
+
url.protocol !== "https:" &&
|
|
214
|
+
!["localhost", "127.0.0.1", "[::1]"].includes(url.hostname)
|
|
215
|
+
)
|
|
216
|
+
throw new HostError(
|
|
217
|
+
"Kubo provider must use HTTPS or account-local loopback HTTP.",
|
|
218
|
+
);
|
|
219
|
+
const car = await shallowContentCar(
|
|
220
|
+
store,
|
|
221
|
+
directBlocks,
|
|
222
|
+
recursiveRoots,
|
|
223
|
+
signal,
|
|
224
|
+
);
|
|
225
|
+
const owner =
|
|
226
|
+
options.owner ??
|
|
227
|
+
`publication:${directBlocks[0] ?? recursiveRoots[0] ?? "empty"}`;
|
|
228
|
+
const retainOptions = signal ? { signal } : {};
|
|
229
|
+
if (retainedDirect.length) {
|
|
230
|
+
await store.retainDirect(owner, retainedDirect, retainOptions);
|
|
231
|
+
await store.confirmDirectRetained(owner, retainedDirect, retainOptions);
|
|
232
|
+
}
|
|
233
|
+
if (retainedRecursive.length) {
|
|
234
|
+
await store.retain(owner, retainedRecursive, retainOptions);
|
|
235
|
+
await store.confirmRetained(owner, retainedRecursive, retainOptions);
|
|
236
|
+
}
|
|
237
|
+
const base = url.toString().replace(/\/$/, "");
|
|
238
|
+
const headers = authorizationToken
|
|
239
|
+
? { authorization: `Bearer ${authorizationToken}` }
|
|
240
|
+
: undefined;
|
|
241
|
+
const requestSignal = () =>
|
|
242
|
+
signal
|
|
243
|
+
? AbortSignal.any([signal, AbortSignal.timeout(30_000)])
|
|
244
|
+
: AbortSignal.timeout(30_000);
|
|
245
|
+
const data = new FormData();
|
|
246
|
+
data.append("file", new Blob([Uint8Array.from(car)]), "content.car");
|
|
247
|
+
const response = await fetcher(`${base}/api/v0/dag/import?pin-roots=false`, {
|
|
248
|
+
method: "POST",
|
|
249
|
+
...(headers ? { headers } : {}),
|
|
250
|
+
body: data,
|
|
251
|
+
redirect: "error",
|
|
252
|
+
signal: requestSignal(),
|
|
253
|
+
});
|
|
254
|
+
if (!response.ok || !response.body)
|
|
255
|
+
throw new HostError(
|
|
256
|
+
`Content provider import failed (HTTP ${response.status}); HEAD was not changed.`,
|
|
257
|
+
);
|
|
258
|
+
const text = new TextDecoder("utf-8", { fatal: true }).decode(
|
|
259
|
+
await bytes(response.body, 256 * 1024),
|
|
260
|
+
);
|
|
261
|
+
for (const line of text.trim().split(/\r?\n/)) {
|
|
262
|
+
if (!line.trim()) continue;
|
|
263
|
+
const item = JSON.parse(line) as { ErrMsg?: string };
|
|
264
|
+
if (item.ErrMsg)
|
|
265
|
+
throw new HostError("Content provider failed to import shallow blocks.");
|
|
266
|
+
}
|
|
267
|
+
const pinOne = async (cid: string, recursive: boolean) => {
|
|
268
|
+
const pinResponse = await fetcher(
|
|
269
|
+
`${base}/api/v0/pin/add?arg=${encodeURIComponent(cid)}&recursive=${recursive ? "true" : "false"}`,
|
|
270
|
+
{
|
|
271
|
+
method: "POST",
|
|
272
|
+
...(headers ? { headers } : {}),
|
|
273
|
+
redirect: "error",
|
|
274
|
+
signal: requestSignal(),
|
|
275
|
+
},
|
|
276
|
+
);
|
|
277
|
+
if (!pinResponse.ok || !pinResponse.body)
|
|
278
|
+
throw new HostError(
|
|
279
|
+
`Content provider pin failed for ${cid} (HTTP ${pinResponse.status}); HEAD was not changed.`,
|
|
280
|
+
);
|
|
281
|
+
await bytes(pinResponse.body, 64 * 1024);
|
|
282
|
+
};
|
|
283
|
+
for (const cid of [...new Set(directBlocks)])
|
|
284
|
+
await pinOne(CID.parse(cid).toV1().toString(), false);
|
|
285
|
+
for (const cid of [...new Set(recursiveRoots)])
|
|
286
|
+
await pinOne(CID.parse(cid).toV1().toString(), true);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export async function bundleJson(store: IpfsStore, root: string) {
|
|
290
|
+
const bundle = await openBundle(CID.parse(root), {
|
|
291
|
+
resolveCid: (cid) => store.block.get(cid.toString()),
|
|
292
|
+
});
|
|
293
|
+
const value: unknown = JSON.parse(
|
|
294
|
+
new TextDecoder("utf-8", { fatal: true }).decode(
|
|
295
|
+
await bytes(await bundle.readFile(bundle.manifest.entry), 1024 * 1024),
|
|
296
|
+
),
|
|
297
|
+
);
|
|
298
|
+
return { bundle, value };
|
|
299
|
+
}
|