@ipab/ipfs-store 0.1.0-rc.0 → 0.1.0-rc.2
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 +144 -227
- package/dist/configuration.d.ts +2 -6
- package/dist/configuration.d.ts.map +1 -1
- package/dist/configuration.js +3 -10
- package/dist/configuration.js.map +1 -1
- package/dist/errors.d.ts +2 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +6 -4
- package/dist/node.js.map +1 -1
- package/dist/retention.d.ts +7 -8
- package/dist/retention.d.ts.map +1 -1
- package/dist/retention.js +32 -61
- package/dist/retention.js.map +1 -1
- package/dist/storage.d.ts +3 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +59 -1
- package/dist/storage.js.map +1 -1
- package/dist/store.d.ts +13 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +67 -43
- package/dist/store.js.map +1 -1
- package/package.json +6 -6
- package/src/configuration.ts +10 -24
- package/src/errors.ts +0 -2
- package/src/index.ts +12 -3
- package/src/node.ts +8 -4
- package/src/retention.ts +44 -83
- package/src/storage.ts +69 -1
- package/src/store.ts +94 -58
- package/dist/kubo.d.ts +0 -38
- package/dist/kubo.d.ts.map +0 -1
- package/dist/kubo.js +0 -189
- package/dist/kubo.js.map +0 -1
- package/src/kubo.ts +0 -293
package/README.md
CHANGED
|
@@ -1,246 +1,163 @@
|
|
|
1
1
|
# @ipab/ipfs-store
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
contracts are preserved
|
|
7
|
-
|
|
8
|
-
type-aware lint. Runtime response boundaries are checked explicitly. In-flight
|
|
9
|
-
cancellation preserves Error reasons; a non-Error reason is reported as an Error
|
|
10
|
-
with that original reason in `cause`, rather than rejecting an untyped value.
|
|
11
|
-
|
|
12
|
-
Run `pnpm check` from the repository root. With Kubo installed, the optional
|
|
13
|
-
real-daemon regression runs against disposable offline repositories:
|
|
14
|
-
|
|
15
|
-
```powershell
|
|
16
|
-
$env:KUBO_REAL_TEST = '1'
|
|
17
|
-
pnpm --filter @ipab/ipfs-store exec vitest run --root . --config ..\..\vitest.config.ts test\kubo-real.test.ts
|
|
18
|
-
Remove-Item Env:KUBO_REAL_TEST
|
|
19
|
-
```
|
|
3
|
+
Verified local IPFS/UnixFS storage with optional read-only upstream HTTP
|
|
4
|
+
gateways. The next npm candidate is `0.1.0-rc.2`; `0.1.0-rc.1` is published.
|
|
5
|
+
Source was migrated from `silvermoon-work/task-engine`; the original MIT license
|
|
6
|
+
and CID/protocol contracts are preserved. Kubo RPC storage is no longer
|
|
7
|
+
supported.
|
|
20
8
|
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
Run `pnpm check` from the repository root. Source and tests use strict
|
|
10
|
+
TypeScript, type-aware lint and the shared Vitest configuration.
|
|
23
11
|
|
|
24
|
-
|
|
25
|
-
task scheduling and Engine databases. Library callers own and inject content
|
|
26
|
-
objects; importing this package does not read configuration or start a client.
|
|
12
|
+
## Local Store and upstream gateways
|
|
27
13
|
|
|
28
14
|
```ts
|
|
29
15
|
import { IpfsStore } from "@ipab/ipfs-store";
|
|
30
16
|
|
|
31
|
-
const
|
|
17
|
+
const store = new IpfsStore({
|
|
32
18
|
dataDir: contentDirectory,
|
|
33
|
-
gateway: "
|
|
19
|
+
gateway: "http://lan-storage.example:8080", // optional; an HTTP Gateway, not RPC
|
|
34
20
|
limits: { bytes: 256 * 1024 * 1024, blocks: 16_384, depth: 64 },
|
|
35
21
|
});
|
|
36
|
-
const output = await buildTaskBundle(input, { ...buildOptions, content });
|
|
37
|
-
const engine = createTaskEngine({
|
|
38
|
-
store: engineDatabase,
|
|
39
|
-
ipfsStore: content,
|
|
40
|
-
authorize,
|
|
41
|
-
});
|
|
42
|
-
// Both borrow the same object. The host closes it after all consumers finish.
|
|
43
22
|
```
|
|
44
23
|
|
|
45
|
-
|
|
24
|
+
All writes, persistent pins, usage queries and garbage collection belong to the
|
|
25
|
+
local Store. A gateway only supplies missing blocks, verified before atomic
|
|
26
|
+
local publication. It may be a shared LAN Kubo Gateway or another compatible
|
|
27
|
+
HTTP Gateway. No block is uploaded, no upstream pin is changed and no daemon
|
|
28
|
+
management/GC RPC is issued. No gateway is guessed when unset; local misses
|
|
29
|
+
fail. Successfully pinned complete DAGs remain available without the gateway.
|
|
30
|
+
Unpinned cache can be collected and then needs an available source to reacquire.
|
|
31
|
+
|
|
32
|
+
Local-only use does not load the Helia HTTP gateway transport. Its modules load
|
|
33
|
+
on the first read that uses that transport, within the existing read and
|
|
34
|
+
per-attempt timeout budgets. Later reads in the same process reuse the modules,
|
|
35
|
+
not a running gateway node.
|
|
36
|
+
|
|
37
|
+
`read(cidOrCidPath, { signal? })` returns a discriminated `UnixfsNode`: files
|
|
46
38
|
(`type: "file" | "raw"`) expose `content()` as an async byte stream; directories
|
|
47
39
|
expose `entries()` as an async iterator. It does not materialize the whole file
|
|
48
|
-
or apply
|
|
49
|
-
regular files and UnixFS directories.
|
|
50
|
-
|
|
51
|
-
later readers. Corrupt local content fails rather than silently fetching a
|
|
52
|
-
replacement.
|
|
40
|
+
or apply application portable-path rules. The node profile is SHA-256 raw/DAG-PB
|
|
41
|
+
regular files and UnixFS directories. Corrupt local blocks fail, never silently
|
|
42
|
+
fetching replacements.
|
|
53
43
|
|
|
54
44
|
`prepare(cid, { signal? })` verifies the complete linked DAG with unique-block,
|
|
55
|
-
byte and depth limits.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
API. `contentLinks(cid, bytes)`
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
45
|
+
byte and depth limits. Full DAG preparation supports raw, DAG-PB and canonical
|
|
46
|
+
DAG-CBOR and follows genuine IPLD links, not CID-looking strings or objects.
|
|
47
|
+
Unknown codecs, unsupported hashes, missing/corrupt blocks and exceeded budgets
|
|
48
|
+
fail. Structured blocks also have a 64-level/100,000-node inspection limit.
|
|
49
|
+
Shared subgraphs count once for bytes/blocks, but all paths satisfy the depth
|
|
50
|
+
limit. `block.get` and verified `put` support offline block transfer; low-level
|
|
51
|
+
verified SHA-256 blocks are codec-neutral. CAR framing, manifests, path policy
|
|
52
|
+
and DAG grafting remain outside Store.
|
|
53
|
+
|
|
54
|
+
`ContentBlocks` in `./dag` is the bounded in-memory transfer primitive, not
|
|
55
|
+
another application-level acquisition API. `contentLinks(cid, bytes)` is its
|
|
56
|
+
shared codec-aware extractor; callers verify integrity separately. It reuses the
|
|
57
|
+
identity-safe codec from `ipfs-payload/dag-cbor` without TypeBox/AJV runtime.
|
|
58
|
+
Pin/retain/import/reconciliation always traverse fresh backing reads.
|
|
59
|
+
|
|
60
|
+
`readContent(cid)` and `resolveContent(cid, path)` implement the type-only
|
|
61
|
+
`ReadonlyIpfsAccess` contract. `IpfsNode` is the shared DU: `kind: "file"` with
|
|
62
|
+
a `ReadableStream`, or `kind: "directory"` with an async entry stream. Entries
|
|
63
|
+
carry target CIDs and verified kinds. File cancellation and enumeration retain
|
|
64
|
+
host budgets/signals. Paths are directory-relative slash-separated segments;
|
|
65
|
+
empty path validates and returns the resource. Structured archives are not a
|
|
66
|
+
third file variant. `putContent(byteStream)` creates verified local UnixFS
|
|
67
|
+
content but does not establish persistent retention by itself.
|
|
68
|
+
|
|
69
|
+
`scope(limits?)` borrows backing storage with independent, no-larger reader
|
|
70
|
+
budgets/lifetime; closing it never closes its parent.
|
|
71
|
+
`IpfsStore.fromClient(port, limits?, dataDir?)` adapts a caller-owned block
|
|
72
|
+
source, never writing to or closing that source. Without dataDir it uses
|
|
73
|
+
memory-only `ContentBlocks`. Adapters expose `supportsRetention: false` and
|
|
74
|
+
reject coordinated retention, usage and GC. `withLocalSource(port)` creates a
|
|
75
|
+
coordinated local read-through Store with a borrowed source.
|
|
76
|
+
|
|
77
|
+
## Pins, ownership and imports
|
|
78
|
+
|
|
79
|
+
`pin(root)` verifies the complete DAG and persists a recursive local pin.
|
|
80
|
+
`unpin(root)` releases an unreferenced known pin without deleting blocks.
|
|
81
|
+
Neither `put`, `prepare` nor closing a Store pins/unpins content. `limits.bytes`
|
|
82
|
+
and `retainedBytes` measure in-process retention, not disk quotas.
|
|
83
|
+
|
|
84
|
+
All cooperating hosts sharing a dataDir must preserve the same durable
|
|
85
|
+
coordinationDir (default `<dataDir>/retention`) on SQLite-compatible storage. It
|
|
86
|
+
contains reference/operation metadata, never blocks or CARs. Distinct
|
|
87
|
+
registries/external writers are not a distributed ownership service.
|
|
88
|
+
|
|
89
|
+
`registerOwner`, `retain`, `confirmRetained`, `recoverOwner` and `reconcile`
|
|
90
|
+
coordinate persistent references. `retain` publishes durable intents before
|
|
91
|
+
acquisition/pinning; call `confirmRetained` after committing business
|
|
92
|
+
references. Use `reconcile(owner, () => readPersistedRoots())` to evaluate the
|
|
93
|
+
snapshot inside the participant mutex. Recovery discards abandoned
|
|
94
|
+
intents/imports only when the owner's old executions are stopped; its optional
|
|
95
|
+
`isIdle` predicate and root callback run inside the mutex. Never recover active
|
|
96
|
+
shared owners. Reconciliation verifies all participating roots before releasing
|
|
97
|
+
unreferenced pins. Failures preserve retry metadata; removed-pin counts are not
|
|
98
|
+
disk bytes.
|
|
99
|
+
|
|
100
|
+
`stageBlock(session, cid, bytes)` records and publishes individual local blocks,
|
|
101
|
+
including CAR parents before children. `finishImport(session, root, owner?)`
|
|
102
|
+
verifies and recursively pins the complete DAG before dropping staging
|
|
103
|
+
responsibility. `discardImport` drops that session's responsibility. Interrupted
|
|
104
|
+
imports retain retry metadata and never claim a complete root.
|
|
105
|
+
|
|
106
|
+
## Usage and explicit GC
|
|
107
|
+
|
|
108
|
+
`await store.usage({ signal? })` returns `{ cachedBytes, pinnedBytes }`.
|
|
109
|
+
`cachedBytes` sums canonical CID block file lengths, excluding coordination
|
|
110
|
+
metadata, temporary/unknown files and filesystem allocation overhead.
|
|
111
|
+
`pinnedBytes` is every durable recursive pin's verified DAG block union,
|
|
112
|
+
including indirect descendants and shared subgraphs, deduplicated by CIDv1.
|
|
113
|
+
|
|
114
|
+
`await store.gc({ signal? })` returns `{ removedBlocks, reclaimedBytes }`. It
|
|
115
|
+
collects unprotected blocks across the entire local Store without unpinning. The
|
|
116
|
+
participant mutex protects pin/owner changes and staging. Owner roots, pending
|
|
117
|
+
retention roots and active staged blocks survive. Incomplete import parents are
|
|
118
|
+
protected individually. Unknown files and temporary publications are untouched.
|
|
119
|
+
|
|
120
|
+
Every protected DAG is verified with fresh local-only reads before deletion,
|
|
121
|
+
using per-root content limits. Missing/corrupt content and capacity failures
|
|
122
|
+
abort marking before any deletion; queries/GC never fetch missing blocks or
|
|
123
|
+
trust warmed reader caches. Cancellation/storage failures throw; an interrupted
|
|
124
|
+
sweep may already have deleted blocks and can be retried. Unpinned reads/puts do
|
|
125
|
+
not establish a GC hold. Concurrent uncoordinated writes do not provide
|
|
126
|
+
transactionally exact usage snapshots; publications after initial inventory are
|
|
127
|
+
outside the sweep. No automatic GC, quotas, direct-pin mode or MFS.
|
|
128
|
+
|
|
129
|
+
## Public configuration and migration
|
|
130
|
+
|
|
131
|
+
`@ipab/ipfs-store/node` reads `%LOCALAPPDATA%\TaskContent\config.json` on
|
|
132
|
+
Windows or `~/.config/task-content/config.json` elsewhere. `TASK_CONTENT_CONFIG`
|
|
133
|
+
selects another file:
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"backend": "local",
|
|
138
|
+
"dataDir": "./content",
|
|
139
|
+
"gateway": "http://lan-storage.example:8080"
|
|
140
|
+
}
|
|
115
141
|
```
|
|
116
142
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
recursive retention hint; `unpin(root)` releases an unreferenced known hint.
|
|
139
|
-
Neither `put` nor `prepare` pins. Local pins are durable SQLite metadata, not
|
|
140
|
-
no-ops; releasing one does not delete blocks or add automatic disk GC. Kubo
|
|
141
|
-
hints use `@silvermoon-work/task-engine/<coordinator-id>` names. Kubo's
|
|
142
|
-
`indirect through <CID>` pin status is validated and normalized to `indirect`
|
|
143
|
-
before retention coordination; malformed statuses still fail. Existing
|
|
144
|
-
differently named or unnamed recursive pins are left unchanged; an external
|
|
145
|
-
direct pin that cannot be upgraded without renaming causes an explicit
|
|
146
|
-
unfinished error. Names are **best-effort provenance labels**, not ownership,
|
|
147
|
-
authentication, independent leases or permanent availability. External
|
|
148
|
-
deletion/renaming between checks is not prevented. Reads still verify real
|
|
149
|
-
bytes; missing content is fetched only from the explicitly configured
|
|
150
|
-
backend/source or fails. Closing stores/scopes never unpins.
|
|
151
|
-
|
|
152
|
-
### Participating Engines and recovery
|
|
153
|
-
|
|
154
|
-
All cooperating Engines must use the **same durable coordination directory** and
|
|
155
|
-
preserve it across restarts. It contains only identity, reference and operation
|
|
156
|
-
metadata, never blocks or CARs. Defaults are `<local-dataDir>/retention` or a
|
|
157
|
-
user-level directory keyed by the exact Kubo API URL. For endpoint aliases,
|
|
158
|
-
remote hosts or distinct configurations, explicitly inject the same directory on
|
|
159
|
-
storage that provides SQLite locking/durability; separate registries are not a
|
|
160
|
-
distributed ownership service. Different registry names are treated as external
|
|
161
|
-
and are never claimed or automatically removed by this registry.
|
|
162
|
-
|
|
163
|
-
Engine automatically registers its persistent Store identity and publishes
|
|
164
|
-
Task/Run bundle roots and optional output CIDs, including historical Runs.
|
|
165
|
-
Protection is arranged before publishing new content references. Durable
|
|
166
|
-
write-ahead intents bridge the RPC/database commit gap; after database commit,
|
|
167
|
-
confirmation publishes the root again before clearing the intent. Recovery uses
|
|
168
|
-
the persisted Store's actual full root set. Hosts sharing one business identity
|
|
169
|
-
supply `retentionOwner` and `retentionRoots` and recover that owner once, while
|
|
170
|
-
its executions are stopped.
|
|
171
|
-
|
|
172
|
-
For custom hosts the primitives are `registerOwner`, `retain`,
|
|
173
|
-
`confirmRetained`, `recoverOwner`, and `reconcile`. `retain` publishes an intent
|
|
174
|
-
and confirms the pin request; call `confirmRetained` only after committing the
|
|
175
|
-
business reference. Use `reconcile(owner, () => readPersistedRoots())` so the
|
|
176
|
-
snapshot is read **inside** the participant mutex, not before waiting for it.
|
|
177
|
-
`recoverOwner` discards abandoned intents/import sessions only when that owner's
|
|
178
|
-
old executions are known to have stopped. Never recover an active shared owner.
|
|
179
|
-
Its optional `isIdle` predicate and root callback are evaluated inside the
|
|
180
|
-
mutex; Engine uses this for collection without racing a newly preparing request.
|
|
181
|
-
|
|
182
|
-
Mark-and-sweep first verifies every participating owner's retained graph and
|
|
183
|
-
pending publication/import references. Only then can it remove this
|
|
184
|
-
coordinator's currently named, unreferenced hints. Other visible names remain.
|
|
185
|
-
Missing/corrupt references, inaccessible coordination, cancellation or RPC
|
|
186
|
-
failure prevent a successful cleanup result. An interrupted or uncertain
|
|
187
|
-
pin/unpin remains journaled for retry; no successful pin/unpin is inferred from
|
|
188
|
-
a timeout. Unpin counts are hints removed, not disk bytes reclaimed.
|
|
189
|
-
|
|
190
|
-
Staging also persists an absent/indirect/already-own before-state before the
|
|
191
|
-
atomic raw put. If naming fails after that put created an unnamed pin, recovery
|
|
192
|
-
retries its name assignment, checks the visible result, then permits ordinary
|
|
193
|
-
named cleanup. Another failure remains an explicit unfinished responsibility,
|
|
194
|
-
not a discarded journal row. A genuinely preexisting external unnamed pin has no
|
|
195
|
-
such claim and is never renamed or removed. This is best-effort recovery of a
|
|
196
|
-
recorded system operation, not protection from outsiders racing the request.
|
|
197
|
-
|
|
198
|
-
For block-by-block imports, `stageBlock(session, cid, bytes)` atomically pins a
|
|
199
|
-
raw alias of each Kubo block before later DAG publication; the alias uses the
|
|
200
|
-
same multihash/bytes and does not create an application block copy. This also
|
|
201
|
-
handles CAR parents arriving before their children.
|
|
202
|
-
`finishImport(session, root, owner?)` verifies and recursively pins the finished
|
|
203
|
-
DAG before releasing the session's staging responsibility. A later coordinated
|
|
204
|
-
sweep removes unreferenced staging hints. Interrupted imports retain durable
|
|
205
|
-
retry/recovery metadata and never claim a complete root.
|
|
206
|
-
|
|
207
|
-
## Public configuration
|
|
208
|
-
|
|
209
|
-
CLI hosts use `@ipab/ipfs-store/node`. The default file is
|
|
210
|
-
`%LOCALAPPDATA%\TaskContent\config.json` on Windows and
|
|
211
|
-
`~/.config/task-content/config.json` elsewhere; `TASK_CONTENT_CONFIG` selects
|
|
212
|
-
another file. The canonical configuration is a strict union:
|
|
213
|
-
|
|
214
|
-
- `{ "backend": "local", "dataDir": "...", "gateway": "https://..." }`
|
|
215
|
-
- `{ "backend": "kubo", "apiUrl": "http://127.0.0.1:5001" }`
|
|
216
|
-
|
|
217
|
-
Both branches accept `limits` and optional `coordinationDir`; only Kubo accepts
|
|
218
|
-
`timeoutMs`. Local `gateway` can also be an ordered URL list. Unknown fields,
|
|
219
|
-
cross-branch fields, malformed URLs and non-positive/non-integral limits fail.
|
|
220
|
-
Local paths are relative to the config file. Legacy local JSON without
|
|
221
|
-
`backend`, and legacy `{ dataDir, gateway?, limits? }` constructors, still work.
|
|
222
|
-
Default dataDir is `~/.silvermoon.work/content`, independent of Engine
|
|
223
|
-
databases. No gateway is guessed when unset; local misses fail.
|
|
224
|
-
|
|
225
|
-
Builder's `--content-gateway` / `--content-data-dir` and Engine server's
|
|
226
|
-
`--ipfs-gateway` / `--content-data-dir` override the common defaults separately.
|
|
227
|
-
Existing `server.dataDir` remains the Engine database path, not content storage.
|
|
228
|
-
Engine startup rejects using that same directory as content storage. Local CLI
|
|
229
|
-
overrides conflict explicitly with a selected Kubo configuration; they never
|
|
230
|
-
silently change its backend. Selecting a different backend in an existing file
|
|
231
|
-
requires replacing that file's branch, not merging its fields. Migrate old
|
|
232
|
-
private cache settings explicitly; no blocks/databases are moved. Libraries
|
|
233
|
-
accept injected stores and do not read user configuration themselves.
|
|
234
|
-
`createConfiguredContent()` is an explicit host helper returning an `IpfsStore`
|
|
235
|
-
with its resolved `configuration`; it is never invoked by library imports.
|
|
236
|
-
|
|
237
|
-
The backing storage verifies disk reads and writes a uniquely named complete
|
|
238
|
-
file before atomic hard-link publication. Concurrent processes cannot publish
|
|
239
|
-
partial blocks; an interrupted pending file is not a cache hit. Existing
|
|
240
|
-
published bytes are validated, never overwritten with unverified data. Close
|
|
241
|
-
aborts owned work but never removes blocks or closes an injected source. Stores
|
|
242
|
-
own and close only the gateways they create. Disk retention has no automatic GC.
|
|
243
|
-
In-flight acquisition is deduplicated within each instance, not across
|
|
244
|
-
processes. Canceling one reader detaches only that reader; shared acquisition
|
|
245
|
-
belongs to the client's lifetime and remains available to other readers. CID
|
|
246
|
-
storage accounting and logical file/path/execution budgets remain independent.
|
|
143
|
+
Optional `limits` and `coordinationDir` are supported; gateway may be an ordered
|
|
144
|
+
URL list. Unknown fields, malformed URLs and invalid limits fail. Paths resolve
|
|
145
|
+
relative to the file. Legacy local configurations without `backend` still work.
|
|
146
|
+
Default dataDir is `~/.silvermoon.work/content`. Overrides cannot hide malformed
|
|
147
|
+
lower layers. `createConfiguredContent()` is an explicit host helper; library
|
|
148
|
+
imports never read configuration or start clients.
|
|
149
|
+
|
|
150
|
+
`backend:kubo`, `apiUrl` and Store `timeoutMs` are rejected. Replace old RPC
|
|
151
|
+
configuration explicitly with a local dataDir and HTTP gateway, not port 5001
|
|
152
|
+
RPC. Old Kubo blocks/pins/owner metadata are not moved, released or treated as
|
|
153
|
+
local retention. Existing CLI pin/history records keep their old configuration
|
|
154
|
+
and unsupported cleanup fails explicitly; independently manage old daemon pins
|
|
155
|
+
and create new local pins before relying on offline availability.
|
|
156
|
+
|
|
157
|
+
Local files are verified on read and published by atomic hard-link after
|
|
158
|
+
writing/syncing a unique complete temporary file. Existing publications are
|
|
159
|
+
validated, not overwritten. Close aborts owned work but never deletes blocks or
|
|
160
|
+
closes borrowed sources. Stores close only gateways they create. Acquisition is
|
|
161
|
+
deduplicated per instance; canceling a reader detaches it without canceling
|
|
162
|
+
another reader's shared acquisition. Non-Error cancellation reasons are reported
|
|
163
|
+
as Errors preserving the original reason in `cause`.
|
package/dist/configuration.d.ts
CHANGED
|
@@ -3,15 +3,11 @@ interface CommonConfiguration {
|
|
|
3
3
|
limits?: Partial<ContentLimits>;
|
|
4
4
|
coordinationDir?: string;
|
|
5
5
|
}
|
|
6
|
-
export
|
|
6
|
+
export interface StoreConfiguration extends CommonConfiguration {
|
|
7
7
|
backend: "local";
|
|
8
8
|
dataDir: string;
|
|
9
9
|
gateway?: string | readonly string[];
|
|
10
|
-
}
|
|
11
|
-
backend: "kubo";
|
|
12
|
-
apiUrl: string;
|
|
13
|
-
timeoutMs?: number;
|
|
14
|
-
});
|
|
10
|
+
}
|
|
15
11
|
export type LegacyStoreOptions = Omit<Extract<StoreConfiguration, {
|
|
16
12
|
backend: "local";
|
|
17
13
|
}>, "backend">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAEpE,UAAU,mBAAmB;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AACD,MAAM,
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAEpE,UAAU,mBAAmB;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AACD,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC7D,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;CACtC;AACD,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,OAAO,CAAC,kBAAkB,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,EACjD,SAAS,CACV,CAAC;AACF,MAAM,MAAM,gBAAgB,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;AAEvE,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,CA6DxE"}
|
package/dist/configuration.js
CHANGED
|
@@ -4,11 +4,11 @@ export function validateConfiguration(value) {
|
|
|
4
4
|
throw new Error("Invalid IPFS store configuration.");
|
|
5
5
|
const record = value;
|
|
6
6
|
const backend = Object.hasOwn(record, "backend") ? record.backend : "local";
|
|
7
|
+
if (backend === "kubo")
|
|
8
|
+
throw new Error("Kubo Store RPC is no longer supported. Configure a local dataDir and an HTTP gateway; existing Kubo pins are not migrated or released.");
|
|
7
9
|
const fields = backend === "local"
|
|
8
10
|
? ["backend", "dataDir", "gateway", "limits", "coordinationDir"]
|
|
9
|
-
:
|
|
10
|
-
? ["backend", "apiUrl", "timeoutMs", "limits", "coordinationDir"]
|
|
11
|
-
: [];
|
|
11
|
+
: [];
|
|
12
12
|
if (!fields.length ||
|
|
13
13
|
Object.keys(record).some((key) => !fields.includes(key)))
|
|
14
14
|
throw new Error("Unknown or conflicting IPFS backend configuration field.");
|
|
@@ -30,8 +30,6 @@ export function validateConfiguration(value) {
|
|
|
30
30
|
if (!["http:", "https:"].includes(parsed.protocol) || parsed.hash)
|
|
31
31
|
throw new Error("IPFS URL must use HTTP(S) without a fragment.");
|
|
32
32
|
};
|
|
33
|
-
if (backend === "kubo")
|
|
34
|
-
url(record.apiUrl);
|
|
35
33
|
if (record.gateway !== undefined) {
|
|
36
34
|
const gateways = Array.isArray(record.gateway)
|
|
37
35
|
? record.gateway
|
|
@@ -41,11 +39,6 @@ export function validateConfiguration(value) {
|
|
|
41
39
|
for (const gateway of gateways)
|
|
42
40
|
url(gateway);
|
|
43
41
|
}
|
|
44
|
-
if (record.timeoutMs !== undefined)
|
|
45
|
-
if (!Number.isSafeInteger(record.timeoutMs) ||
|
|
46
|
-
Number(record.timeoutMs) <= 0 ||
|
|
47
|
-
Number(record.timeoutMs) > 2_147_483_647)
|
|
48
|
-
throw new Error("IPFS timeoutMs must be an integer between 1 and 2147483647.");
|
|
49
42
|
if (record.limits !== undefined) {
|
|
50
43
|
if (!record.limits ||
|
|
51
44
|
typeof record.limits !== "object" ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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MAAM,CAAC;YAE5B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACpD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;YACtD,IACE,CAAC,MAAM,CAAC,MAAM,CAAC,oBAAoB,EAAE,GAAG,CAAC;gBACzC,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC;gBAC5B,KAAK,IAAI,CAAC;gBAEV,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,EAAE,GAAG,MAAM,EAAE,OAAO,EAAwB,CAAC;AACtD,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare class ContentError extends Error {
|
|
2
|
-
readonly code: "capacity_exceeded" | "reclamation_unknown" | "missing_block" | "
|
|
3
|
-
constructor(code: "capacity_exceeded" | "reclamation_unknown" | "missing_block" | "
|
|
2
|
+
readonly code: "capacity_exceeded" | "reclamation_unknown" | "missing_block" | "retention_unfinished" | "read_only" | "unsupported_content";
|
|
3
|
+
constructor(code: "capacity_exceeded" | "reclamation_unknown" | "missing_block" | "retention_unfinished" | "read_only" | "unsupported_content", message: string, options?: ErrorOptions);
|
|
4
4
|
}
|
|
5
5
|
export declare function abortError(signal: AbortSignal): Error;
|
|
6
6
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAa,SAAQ,KAAK;IAEnC,QAAQ,CAAC,IAAI,EACT,mBAAmB,GACnB,qBAAqB,GACrB,eAAe,GACf,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAa,SAAQ,KAAK;IAEnC,QAAQ,CAAC,IAAI,EACT,mBAAmB,GACnB,qBAAqB,GACrB,eAAe,GACf,sBAAsB,GACtB,WAAW,GACX,qBAAqB;gBANhB,IAAI,EACT,mBAAmB,GACnB,qBAAqB,GACrB,eAAe,GACf,sBAAsB,GACtB,WAAW,GACX,qBAAqB,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,YAAY;CAKzB;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,KAAK,CAKrD"}
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,YAAa,SAAQ,KAAK;IAE1B;IADX,YACW,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,YAAa,SAAQ,KAAK;IAE1B;IADX,YACW,IAMgB,EACzB,OAAe,EACf,OAAsB;QAEtB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAVf,SAAI,GAAJ,IAAI,CAMY;QAKzB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,UAAU,UAAU,CAAC,MAAmB;IAC5C,MAAM,MAAM,GAAY,MAAM,CAAC,MAAM,CAAC;IACtC,OAAO,MAAM,YAAY,KAAK;QAC5B,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,IAAI,KAAK,CAAC,4BAA4B,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;AACjE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type UnixFSEntry } from "ipfs-unixfs-exporter";
|
|
|
3
3
|
import { CID } from "multiformats/cid";
|
|
4
4
|
export type { IpfsNode, IpfsEntry } from "@silvermoon-work/ipfs-access";
|
|
5
5
|
export { ContentError } from "./errors.js";
|
|
6
|
-
export { IpfsStore, type IpfsStoreOptions, type IpfsReadOptions, type UnixfsNode, type StoreConfiguration, } from "./store.js";
|
|
6
|
+
export { IpfsStore, type IpfsStoreOptions, type IpfsReadOptions, type UnixfsNode, type StoreConfiguration, type StoreUsage, type StoreGcResult, } from "./store.js";
|
|
7
7
|
/** Caller-owned read port. Production hosts use createIpfsGatewayClient. */
|
|
8
8
|
export interface IpfsClient {
|
|
9
9
|
block: {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAIvC,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,SAAS,EACT,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,UAAU,EACf,KAAK,aAAa,GACnB,MAAM,YAAY,CAAC;AA6BpB,4EAA4E;AAC5E,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE;QACL,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;YAAE,MAAM,CAAC,EAAE,WAAW,CAAA;SAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;KAC3E,CAAC;CACH;AACD,MAAM,WAAW,aAAc,SAAQ,UAAU;IAC/C,2EAA2E;IAC3E,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAA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BAAsB,WAAW,CAC/B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,WAAW,CAAC,CA2CtB;AAED,oFAAoF;AACpF,wBAAsB,cAAc,CAClC,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC,CA4Bf"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { trustlessGateway } from "@helia/block-brokers";
|
|
2
|
-
import { createHeliaHTTP } from "@helia/http";
|
|
3
|
-
import { httpGatewayRouting } from "@helia/routers";
|
|
4
1
|
import { unixfs } from "@helia/unixfs";
|
|
5
2
|
import { ContentError } from "./errors.js";
|
|
6
3
|
import { MemoryBlockstore } from "blockstore-core";
|
|
@@ -246,6 +243,12 @@ function gatewaySource(url, allowPath = false) {
|
|
|
246
243
|
return {
|
|
247
244
|
source: endpoint.href,
|
|
248
245
|
async read(cid, signal) {
|
|
246
|
+
signal.throwIfAborted();
|
|
247
|
+
const [{ trustlessGateway }, { createHeliaHTTP }, { httpGatewayRouting },] = await Promise.all([
|
|
248
|
+
import("@helia/block-brokers"),
|
|
249
|
+
import("@helia/http"),
|
|
250
|
+
import("@helia/routers"),
|
|
251
|
+
]);
|
|
249
252
|
signal.throwIfAborted();
|
|
250
253
|
const node = await createHeliaHTTP({
|
|
251
254
|
...isolatedNodeOptions(),
|