@ipab/bundle 0.0.0 → 0.1.0-rc.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 preset-pnpm-monorepo contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,192 @@
1
- # @ipab/bundle
1
+ # Bundle runtime
2
2
 
3
- Bootstrap placeholder only. Real releases start at 0.1.0+.
3
+ `@ipab/bundle` validates immutable UnixFS Content Bundles and their complete
4
+ single-block type definitions. Callers own the block resolver/Store. There is no
5
+ upload, pinning, network schema resolution or Schema Bundle directory.
6
+
7
+ ## One definition
8
+
9
+ The root `.bundle.yaml` is the Bundle type definition, not a pointer to an
10
+ external Schema. JSON-style YAML is legal:
11
+
12
+ ```yaml
13
+ name: Note
14
+ description: ""
15
+ entry:
16
+ path: data.json
17
+ schema:
18
+ type: object
19
+ required: [title]
20
+ properties:
21
+ title:
22
+ type: string
23
+ contentType: application/json
24
+ ```
25
+
26
+ `name` is a required nonblank string. `description` is an optional string;
27
+ missing descriptions normalize to `""`, while null is rejected. `entry` and all
28
+ its `path` and `contentType` fields are required. `schema` is optional; other
29
+ entry fields, including the removed `defaultValue`, are rejected.
30
+
31
+ - `path` is a safe relative file path from the Bundle root, not a mutable
32
+ initialization suggestion. It cannot collide with `.bundle.yaml` or
33
+ `.bundle-ignore` control paths.
34
+ - `schema` is a self-contained standard JSON Schema Draft 2020-12 object or
35
+ boolean for decoded entry data only. Absence means no data constraints.
36
+ - `contentType` accepts any legal MIME, including legal parameters. The
37
+ structured parsers support `application/json`, `application/yaml`,
38
+ `application/jsonl` and `text/markdown`. Other MIME entries are opaque bytes:
39
+ any declared schema is checked, but entry data validation is unsupported.
40
+ Parser selection ignores case but does not strip MIME parameters;
41
+ parameterized MIME is legal and currently reports `unsupported`.
42
+ - Entry data is supplied by the author or a general Template Bundle. Schema
43
+ annotations such as `default` never generate or mutate it. Root `ipab init`
44
+ renders Template Bundles; `bundle init` has been removed.
45
+
46
+ The complete normalized definition is directly encoded as canonical DAG-CBOR
47
+ with a CIDv1/DAG-CBOR/SHA-256 identity. That CID is the Schema-to-App
48
+ registration key. The block contains the definition object, not a JSON string or
49
+ UnixFS wrapper. `encodeSchema` now takes this complete definition, not a bare
50
+ JSON Schema. `openSchema` requires the same complete profile.
51
+
52
+ **The encoded type block must be at most 1 MiB (1,048,576 bytes), inclusive.**
53
+ This is a project protocol ceiling, not a universal IPFS backend claim. There is
54
+ no chunking fallback. `schemaBytes` can lower but cannot bypass the ceiling.
55
+ Source definition text is bounded by operation parsing/manifest budgets, not the
56
+ obsolete 64 KiB pointer-manifest limit.
57
+
58
+ Name, description, schema and fixed path/MIME all affect type identity.
59
+ Omitted/empty descriptions, object field order, YAML comments and source
60
+ formatting do not. Schema literal values are preserved: no `$schema` is
61
+ injected, and absent schema differs from explicit `true`. Actual entry data is
62
+ not part of this type CID. The UnixFS root still includes original
63
+ `.bundle.yaml` bytes, so editing comments/formatting can change the content root
64
+ while preserving type identity.
65
+
66
+ ## Entry validation and opaque resources
67
+
68
+ JSON/YAML decode to one JSON-compatible value. JSONL decodes the complete
69
+ ordered array, including an empty file as `[]`; CRLF and terminal newlines are
70
+ accepted, blank internal lines are not. Duplicate keys, invalid
71
+ UTF-8/surrogates, nonfinite numbers and unsafe integers are rejected. Files are
72
+ not rewritten.
73
+
74
+ Markdown decodes only its leading YAML frontmatter object; `entry.schema`
75
+ validates that object, not the instruction body. Frontmatter starts with an
76
+ exact `---` line at the beginning and ends with the next exact `---` line. LF
77
+ and CRLF are supported, including a closing delimiter at EOF. Missing or empty
78
+ frontmatter decodes to `{}`; required fields can still reject it. An opening
79
+ delimiter without a closing delimiter, non-object metadata or invalid YAML is
80
+ rejected using the same strict parsing and work/depth limits. The entire
81
+ Markdown entry, including its body, must be valid UTF-8 and fit the entry byte
82
+ budget. Body syntax, links and referenced resources are not parsed or loaded.
83
+ File reads preserve all original bytes.
84
+
85
+ There is no default-based Markdown generation. See the
86
+ [Agent Skill example](../../examples/agent-skill) and
87
+ [authoring reference](../../docs/reference.md#agent-skill-bundle) for a complete
88
+ reusable Skill type definition.
89
+
90
+ The loader verifies the complete selected storage DAG and paths, parses the
91
+ definition and validates the actual entry when its MIME has a structured parser.
92
+ Opaque entry bytes still undergo size, path and storage integrity checks.
93
+ Resources and nested Bundles remain opaque: no business parsing or recursive
94
+ contracts. Strings do not trigger reads; reference interpretation belongs to the
95
+ App.
96
+
97
+ Type identity is reproducible from the retained `.bundle.yaml`; opening a
98
+ content root never requests an external Schema block. A separately distributed
99
+ type CID still requires its block to be available when explicitly loaded by CID.
100
+
101
+ ## Standard JSON Schema
102
+
103
+ Entry schemas use Draft 2020-12. Omitted `$schema` selects that draft; an
104
+ explicit declaration must be `https://json-schema.org/draft/2020-12/schema`.
105
+ Standard constraints include scalar bounds, `pattern`, `allOf`/`oneOf`/`not`,
106
+ conditionals, `prefixItems`, `contains`, dependencies and unevaluated
107
+ items/properties. Validation does not coerce types, apply defaults, remove
108
+ fields or execute schema-provided code. Unknown extension keywords and `format`
109
+ are annotations, not resource readers or execution hooks; `x-content-ref` has no
110
+ special behavior.
111
+
112
+ References must resolve to schema nodes within the entry schema document. Local
113
+ JSON Pointers and anchors are supported; external loading is disabled. All
114
+ definitions, including unused ones, are checked. Productive data recursion is
115
+ allowed; nonproductive same-data cycles are rejected. CBOR byte strings and IPLD
116
+ links are not JSON-compatible type-definition data.
117
+
118
+ Draft meta-schema checking uses Ajv2020; data evaluation uses the TypeBox
119
+ `Check` interpreter, not generated validation code. Nested `$id` resources and
120
+ document-local pointer/anchor references are supported without an external
121
+ resolver. Shared work/depth limits cover traversal and evaluation access, not
122
+ wall-clock execution of ECMA regular expressions. This is not a sandbox or a
123
+ hard CPU/time limit for untrusted schemas.
124
+
125
+ ## API
126
+
127
+ `validateSchemaValue(definitions, data, { charge, depth })` exposes the same
128
+ Draft 2020-12 entry validator used by `openBundle`. Supply definitions from
129
+ `encodeSchema` / `inspectSchema`, parsed JSON-compatible data, a finite work
130
+ budget through `charge`, and a positive validation depth. This validates data
131
+ only; it does not load or verify a storage DAG.
132
+
133
+ `@ipab/bundle/data` provides parsing, canonical JSON, schema encoding and entry
134
+ validation without importing the Store/DAG runtime. Use it for trusted App
135
+ adapters that already receive file access through an IPAB context.
136
+
137
+ ```ts
138
+ import { encodeSchema, openBundle, parseBundleManifest } from "@ipab/bundle";
139
+
140
+ const definition = parseBundleManifest(sourceYamlBytes);
141
+ const type = await encodeSchema(definition);
142
+ const bundle = await openBundle(rootCid, {
143
+ resolveCid: (cid, request) => store.block.get(cid.toString(), request),
144
+ });
145
+ const stream = await bundle.readFile(bundle.manifest.entry.path);
146
+ ```
147
+
148
+ - `parseBundleManifest(bytes, maximum?, charge?)`: parse/normalize the complete
149
+ YAML definition and check its shape. Full schema checking happens through
150
+ `inspectBundleSchema`/`encodeSchema`/opening.
151
+ - `inspectBundleSchema(value, options?)`: check complete definition, all schema
152
+ references.
153
+ - `encodeSchema(value, options?)`: return `SchemaBlock` with exact `cid`,
154
+ canonical `bytes`, normalized `manifest`, entry `schema` and pointer index.
155
+ - `openSchema(cid, options)`: verify hash, codec, budgets, canonical normalized
156
+ encoding and the complete profile of one type block.
157
+ - `inspectSchema(value, options?)`: pure low-level Draft 2020-12 schema check;
158
+ it does not encode or publish a standalone type.
159
+ - `openBundle(root, options)`: verify storage, definition and entry; return
160
+ `kind: "content"`, `manifest`, `schemaKey`, `schema`, `cid`, `readFile`, and
161
+ `validation: {status, contentType}`. Status is `validated` only when a
162
+ supported parser and an explicit schema validate actual data; `schema-absent`
163
+ means parsed data without schema constraints; `unsupported` means the MIME has
164
+ no structured parser, not successful schema validation.
165
+ - `validateContentBundle(root, schemaBlock, options)`: also require the derived
166
+ type CID to match the explicit validator; never trust its mutable metadata.
167
+ - `canonicalJson`, `parseData`, `safePath`, `bundleLimits`,
168
+ `resolveBundleLimits`, `schemaBlockBytes`.
169
+
170
+ Future `readFile` streams have independent signals, unchanged bytes and
171
+ backpressure/cancellation. Missing blocks still fail after opening. No permanent
172
+ cache, bundle `close`, or resolver ownership transfer is implied.
173
+
174
+ Defaults: whole-operation 64 MiB unique blocks/parsing, 16,384 blocks, 2
175
+ MiB/block, 2,048 files, 100,000 work nodes; JSON/tree/validation depths 64; 8
176
+ MiB/entry file. The type block ceiling is 1 MiB. Overrides must be known
177
+ positive safe integers. Errors preserve code, path, pointer, reference chain and
178
+ cause.
179
+
180
+ ## Breaking change
181
+
182
+ The old `{ entry: { path, schemaCid, contentType } }` pointer manifest and bare
183
+ Schema block profile are removed. Update definitions, rebuild Content/App
184
+ Bundles, and register their new type CIDs. There is no automatic migration.
185
+ Schema Bundle directories, builtin keys, the dedicated Schema Builder and
186
+ special `x-content-ref` interpretation remain removed.
187
+
188
+ The former required `entry.defaultValue` is now forbidden, `entry.schema` is
189
+ optional, and MIME is no longer a four-value enum. Removing defaults changes
190
+ canonical type bytes and therefore type CIDs. Rebuild definitions and all
191
+ embedded supported-schema CARs, then explicitly update pins/registrations.
192
+ Template parameter `default` values are separate and remain supported.
@@ -0,0 +1,8 @@
1
+ import { CID } from "multiformats/cid";
2
+ import type { BundleLimits, ContentBundle, OpenBundleOptions, SchemaBlock } from "./types.js";
3
+ export declare const bundleLimits: Readonly<BundleLimits>;
4
+ export declare function resolveBundleLimits(overrides?: Partial<BundleLimits>): BundleLimits;
5
+ export declare function openBundle(root: CID, options: OpenBundleOptions): Promise<ContentBundle>;
6
+ export declare function openSchema(root: CID, options: OpenBundleOptions): Promise<SchemaBlock>;
7
+ export declare function validateContentBundle(root: CID, schema: SchemaBlock, options: OpenBundleOptions): Promise<ContentBundle>;
8
+ //# sourceMappingURL=bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAcvC,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,WAAW,EACZ,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,YAAY,CAa9C,CAAC;AACH,wBAAgB,mBAAmB,CACjC,SAAS,GAAE,OAAO,CAAC,YAAY,CAAM,GACpC,YAAY,CAad;AA2UD,wBAAsB,UAAU,CAC9B,IAAI,EAAE,GAAG,EACT,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,aAAa,CAAC,CAExB;AACD,wBAAsB,UAAU,CAC9B,IAAI,EAAE,GAAG,EACT,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,WAAW,CAAC,CA4CtB;AACD,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,aAAa,CAAC,CAExB"}
package/dist/bundle.js ADDED
@@ -0,0 +1,283 @@
1
+ import { ContentError, IpfsStore, openContent } from "@ipab/ipfs-store";
2
+ import { CID } from "multiformats/cid";
3
+ import { ContentBundleError } from "./errors.js";
4
+ import { entryValidation, parseBundleManifest, parseData, safePath, } from "./parsing.js";
5
+ import { decodeSchema, encodeSchema, schemaBlockBytes, validateValue, } from "./schema.js";
6
+ export const bundleLimits = Object.freeze({
7
+ bytes: 64 * 1024 * 1024,
8
+ blocks: 16_384,
9
+ blockBytes: 2 * 1024 * 1024,
10
+ parsingBytes: 64 * 1024 * 1024,
11
+ files: 2048,
12
+ depth: 64,
13
+ jsonDepth: 64,
14
+ validationDepth: 64,
15
+ manifestBytes: 64 * 1024 * 1024,
16
+ schemaBytes: schemaBlockBytes,
17
+ documentBytes: 8 * 1024 * 1024,
18
+ nodes: 100_000,
19
+ });
20
+ export function resolveBundleLimits(overrides = {}) {
21
+ const limits = { ...bundleLimits, ...overrides };
22
+ for (const [key, value] of Object.entries(limits))
23
+ if (!Object.hasOwn(bundleLimits, key) ||
24
+ !Number.isSafeInteger(value) ||
25
+ value <= 0)
26
+ throw new ContentBundleError("OPTIONS_INVALID", "Limits must be known positive safe integers.");
27
+ return limits;
28
+ }
29
+ function contextual(cause, path, pointer = "", chain = [], signal) {
30
+ if (cause instanceof ContentBundleError)
31
+ return new ContentBundleError(cause.code, cause.message, cause.path || path, cause.pointer || pointer, [...chain, ...cause.referenceChain], { cause });
32
+ const capacity = (cause instanceof ContentError && cause.code === "capacity_exceeded") ||
33
+ (cause instanceof Error && /capacity exceeded/u.test(cause.message));
34
+ return new ContentBundleError(signal?.aborted
35
+ ? "ABORTED"
36
+ : capacity
37
+ ? "LIMIT_EXCEEDED"
38
+ : "CONTENT_UNAVAILABLE", "Cannot read or verify bundle content.", path, pointer, chain, { cause });
39
+ }
40
+ async function collect(node, maximum) {
41
+ if (node.type === "directory")
42
+ throw new ContentBundleError("CONTENT_INVALID", "Expected a regular file.");
43
+ if (node.size > BigInt(maximum))
44
+ throw new ContentBundleError("LIMIT_EXCEEDED", "File exceeds its parsing byte limit.");
45
+ const parts = [];
46
+ let length = 0;
47
+ for await (const part of node.content()) {
48
+ length += part.byteLength;
49
+ if (length > maximum)
50
+ throw new ContentBundleError("LIMIT_EXCEEDED", "File exceeds its parsing byte limit.");
51
+ parts.push(part);
52
+ }
53
+ const bytes = new Uint8Array(length);
54
+ let offset = 0;
55
+ for (const part of parts) {
56
+ bytes.set(part, offset);
57
+ offset += part.byteLength;
58
+ }
59
+ return bytes;
60
+ }
61
+ function reader(root, files, source, limits) {
62
+ return async (path, request = {}) => {
63
+ safePath(path);
64
+ if (!files.has(path))
65
+ throw new ContentBundleError("CONTENT_UNAVAILABLE", "Bundle file does not exist.", path);
66
+ const lifetime = new AbortController();
67
+ const signal = request.signal
68
+ ? AbortSignal.any([request.signal, lifetime.signal])
69
+ : lifetime.signal;
70
+ let node;
71
+ const seen = new Set();
72
+ let bytesRead = 0;
73
+ try {
74
+ node = await openContent({
75
+ block: {
76
+ get: async (value, options) => {
77
+ const cid = CID.parse(value);
78
+ const bytes = await source.resolveCid(cid, options ?? {});
79
+ const key = cid.toV1().toString();
80
+ if (!seen.has(key)) {
81
+ seen.add(key);
82
+ bytesRead += bytes.byteLength;
83
+ if (bytesRead > limits.bytes || seen.size > limits.blocks)
84
+ throw new ContentBundleError("LIMIT_EXCEEDED", "File stream block/byte budget exceeded.", path);
85
+ }
86
+ return bytes;
87
+ },
88
+ },
89
+ }, `${root.toString()}/${path}`, {
90
+ cacheBlocks: false,
91
+ signal,
92
+ retainedBlocks: new Map(),
93
+ retentionBudget: { bytes: 0, limit: limits.bytes },
94
+ maxBlockBytes: limits.blockBytes,
95
+ maxDagBlocks: limits.blocks,
96
+ depth: limits.depth,
97
+ });
98
+ if (node.type !== "raw" && node.type !== "file")
99
+ throw new ContentBundleError("CONTENT_INVALID", "Expected a file.", path);
100
+ }
101
+ catch (cause) {
102
+ throw contextual(cause, path, "", [], signal);
103
+ }
104
+ const iterator = node.content()[Symbol.asyncIterator]();
105
+ let finished = false;
106
+ const release = async () => {
107
+ if (!finished) {
108
+ finished = true;
109
+ lifetime.abort();
110
+ await iterator.return();
111
+ }
112
+ };
113
+ return new ReadableStream({
114
+ async pull(controller) {
115
+ try {
116
+ signal.throwIfAborted();
117
+ const part = await iterator.next();
118
+ if (part.done) {
119
+ await release();
120
+ controller.close();
121
+ }
122
+ else
123
+ controller.enqueue(Uint8Array.from(part.value));
124
+ }
125
+ catch (cause) {
126
+ const error = contextual(cause, path, "", [], signal);
127
+ try {
128
+ await release();
129
+ }
130
+ finally {
131
+ controller.error(error);
132
+ }
133
+ }
134
+ },
135
+ cancel: release,
136
+ }, { highWaterMark: 0 });
137
+ };
138
+ }
139
+ async function operation(rootCid, options, expected) {
140
+ const limits = resolveBundleLimits(options.limits);
141
+ if (typeof options.resolveCid !== "function")
142
+ throw new ContentBundleError("OPTIONS_INVALID", "A CID block resolver is required.");
143
+ const cid = CID.decode(Uint8Array.from(rootCid.bytes));
144
+ if (cid.code !== 0x70)
145
+ throw new ContentBundleError("CONTENT_INVALID", "Bundle root must be a UnixFS directory CID.");
146
+ const store = IpfsStore.fromClient({
147
+ block: {
148
+ get: async (value, request) => options.resolveCid(CID.parse(value), request ?? {}),
149
+ },
150
+ }, {
151
+ bytes: limits.bytes,
152
+ blocks: limits.blocks,
153
+ blockBytes: limits.blockBytes,
154
+ depth: limits.depth,
155
+ });
156
+ const request = options.signal ? { signal: options.signal } : {};
157
+ const files = new Set();
158
+ const directories = new Set();
159
+ let parsed = 0, work = 0;
160
+ const charge = () => {
161
+ if (options.signal?.aborted)
162
+ throw new ContentBundleError("ABORTED", "Bundle validation cancelled.", "", "", [], { cause: options.signal.reason });
163
+ if (++work > limits.nodes)
164
+ throw new ContentBundleError("LIMIT_EXCEEDED", "Schema/data work budget exceeded.");
165
+ };
166
+ const join = (base, path) => base ? `${base}/${safePath(path)}` : safePath(path);
167
+ const read = (path) => store.read(path ? `${cid.toString()}/${path}` : cid, request);
168
+ const bytesAt = async (path, maximum) => {
169
+ if (!files.has(path))
170
+ throw new ContentBundleError("CONTENT_UNAVAILABLE", "Bundle file does not exist.", path);
171
+ const bytes = await collect(await read(path), maximum);
172
+ parsed += bytes.byteLength;
173
+ if (parsed > limits.parsingBytes)
174
+ throw new ContentBundleError("LIMIT_EXCEEDED", "Parsing byte budget exceeded.", path);
175
+ return bytes;
176
+ };
177
+ const index = async (path, depth) => {
178
+ charge();
179
+ if (depth > limits.depth)
180
+ throw new ContentBundleError("LIMIT_EXCEEDED", "Tree depth exceeded.", path);
181
+ const node = await read(path);
182
+ if (node.type === "directory") {
183
+ if (directories.has(path))
184
+ throw new ContentBundleError("PATH_INVALID", "Duplicate directory.", path);
185
+ directories.add(path);
186
+ for await (const child of node.entries()) {
187
+ if (child.name.includes("/"))
188
+ throw new ContentBundleError("PATH_INVALID", "Unsafe directory name.", path);
189
+ await index(join(path, child.name), depth + 1);
190
+ }
191
+ }
192
+ else {
193
+ if (!path || files.has(path))
194
+ throw new ContentBundleError("PATH_INVALID", "Invalid or duplicate file.", path);
195
+ if (files.size >= limits.files)
196
+ throw new ContentBundleError("LIMIT_EXCEEDED", "File count exceeded.", path);
197
+ files.add(path);
198
+ }
199
+ };
200
+ try {
201
+ await store.prepare(cid, request);
202
+ await index("", 0);
203
+ const manifest = parseBundleManifest(await bytesAt(".bundle.yaml", limits.manifestBytes), limits.manifestBytes, charge);
204
+ const schema = await encodeSchema(manifest, {
205
+ nodes: limits.nodes,
206
+ depth: limits.validationDepth,
207
+ jsonDepth: limits.jsonDepth,
208
+ schemaBytes: limits.schemaBytes,
209
+ charge,
210
+ });
211
+ if (expected && !schema.cid.equals(expected.cid))
212
+ throw new ContentBundleError("SCHEMA_INVALID", "Schema CID differs from the explicit validator.");
213
+ const path = manifest.entry.path;
214
+ const validation = entryValidation(manifest.entry);
215
+ try {
216
+ const bytes = await bytesAt(path, limits.documentBytes);
217
+ if (validation.status !== "unsupported") {
218
+ const value = parseData(bytes, manifest.entry.contentType.toLowerCase(), limits.nodes, limits.jsonDepth, charge);
219
+ if (manifest.entry.schema !== undefined)
220
+ validateValue(schema, value, {
221
+ charge,
222
+ depth: limits.validationDepth,
223
+ });
224
+ }
225
+ }
226
+ catch (cause) {
227
+ throw contextual(cause, path, "", [], options.signal);
228
+ }
229
+ return Object.freeze({
230
+ kind: "content",
231
+ get cid() {
232
+ return CID.decode(Uint8Array.from(cid.bytes));
233
+ },
234
+ manifest,
235
+ schemaKey: schema.cid.toString(),
236
+ schema,
237
+ validation,
238
+ readFile: reader(cid, files, options, limits),
239
+ });
240
+ }
241
+ catch (cause) {
242
+ throw contextual(cause, cid.toString(), "", [], options.signal);
243
+ }
244
+ finally {
245
+ await store.close();
246
+ }
247
+ }
248
+ export async function openBundle(root, options) {
249
+ return operation(root, options);
250
+ }
251
+ export async function openSchema(root, options) {
252
+ const limits = resolveBundleLimits(options.limits);
253
+ if (typeof options.resolveCid !== "function")
254
+ throw new ContentBundleError("OPTIONS_INVALID", "A CID block resolver is required.");
255
+ if (root.version !== 1 || root.code !== 0x71 || root.multihash.code !== 0x12)
256
+ throw new ContentBundleError("SCHEMA_INVALID", "Schema must be a CIDv1 DAG-CBOR SHA-256 block.");
257
+ let work = 0;
258
+ try {
259
+ options.signal?.throwIfAborted();
260
+ const bytes = await options.resolveCid(root, options.signal ? { signal: options.signal } : {});
261
+ if (bytes.length >
262
+ Math.min(limits.blockBytes, limits.bytes, limits.parsingBytes))
263
+ throw new ContentBundleError("LIMIT_EXCEEDED", "Schema read byte budget exceeded.");
264
+ return await decodeSchema(root, bytes, {
265
+ nodes: limits.nodes,
266
+ depth: limits.validationDepth,
267
+ jsonDepth: limits.jsonDepth,
268
+ schemaBytes: limits.schemaBytes,
269
+ charge() {
270
+ options.signal?.throwIfAborted();
271
+ if (++work > limits.nodes)
272
+ throw new ContentBundleError("LIMIT_EXCEEDED", "Schema work budget exceeded.");
273
+ },
274
+ });
275
+ }
276
+ catch (cause) {
277
+ throw contextual(cause, root.toString(), "", [], options.signal);
278
+ }
279
+ }
280
+ export async function validateContentBundle(root, schema, options) {
281
+ return operation(root, options, schema);
282
+ }
283
+ //# sourceMappingURL=bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.js","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAExE,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,SAAS,EACT,QAAQ,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,aAAa,GACd,MAAM,aAAa,CAAC;AAQrB,MAAM,CAAC,MAAM,YAAY,GAA2B,MAAM,CAAC,MAAM,CAAC;IAChE,KAAK,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;IACvB,MAAM,EAAE,MAAM;IACd,UAAU,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI;IAC3B,YAAY,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;IAC9B,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,EAAE;IACT,SAAS,EAAE,EAAE;IACb,eAAe,EAAE,EAAE;IACnB,aAAa,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;IAC/B,WAAW,EAAE,gBAAgB;IAC7B,aAAa,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI;IAC9B,KAAK,EAAE,OAAO;CACf,CAAC,CAAC;AACH,MAAM,UAAU,mBAAmB,CACjC,YAAmC,EAAE;IAErC,MAAM,MAAM,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,SAAS,EAAE,CAAC;IACjD,KAAK,MAAM,CAAC,GAAG,EAAE,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IAAI,EAAE,IAAI,GAAG,MAAM,CAAC,KAAK;oBACvB,MAAM,IAAI,kBAAkB,CAC1B,gBAAgB,EAChB,8BAA8B,CAC/B,CAAC;YACN,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC;AACH,CAAC;AACD,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,IAAS,EACT,MAAmB,EACnB,OAA0B;IAE1B,OAAO,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAC1C,CAAC"}
package/dist/data.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export { parseBundleManifest, parseData, canonicalJson, safePath, } from "./parsing.js";
2
+ export { encodeSchema, inspectSchema, schemaDialect, validateValue as validateSchemaValue, } from "./schema.js";
3
+ export type { SchemaOptions, ValidationContext } from "./schema.js";
4
+ export type { BundleManifest, SchemaDefinitions, SchemaBlock, } from "./types.js";
5
+ //# sourceMappingURL=data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,SAAS,EACT,aAAa,EACb,QAAQ,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,IAAI,mBAAmB,GACrC,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACpE,YAAY,EACV,cAAc,EACd,iBAAiB,EACjB,WAAW,GACZ,MAAM,YAAY,CAAC"}
package/dist/data.js ADDED
@@ -0,0 +1,3 @@
1
+ export { parseBundleManifest, parseData, canonicalJson, safePath, } from "./parsing.js";
2
+ export { encodeSchema, inspectSchema, schemaDialect, validateValue as validateSchemaValue, } from "./schema.js";
3
+ //# sourceMappingURL=data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.js","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,SAAS,EACT,aAAa,EACb,QAAQ,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,IAAI,mBAAmB,GACrC,MAAM,aAAa,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { ContentBundleErrorCode } from "./types.js";
2
+ export declare class ContentBundleError extends Error {
3
+ readonly code: ContentBundleErrorCode;
4
+ readonly path: string;
5
+ readonly pointer: string;
6
+ readonly referenceChain: readonly string[];
7
+ readonly name = "ContentBundleError";
8
+ constructor(code: ContentBundleErrorCode, message: string, path?: string, pointer?: string, referenceChain?: readonly string[], options?: ErrorOptions);
9
+ }
10
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEzD,qBAAa,kBAAmB,SAAQ,KAAK;IAIzC,QAAQ,CAAC,IAAI,EAAE,sBAAsB;IAErC,QAAQ,CAAC,IAAI;IACb,QAAQ,CAAC,OAAO;IAChB,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE;IAP5C,SAAkB,IAAI,wBAAwB;gBAGnC,IAAI,EAAE,sBAAsB,EACrC,OAAO,EAAE,MAAM,EACN,IAAI,SAAK,EACT,OAAO,SAAK,EACZ,cAAc,GAAE,SAAS,MAAM,EAAO,EAC/C,OAAO,CAAC,EAAE,YAAY;CAIzB"}
package/dist/errors.js ADDED
@@ -0,0 +1,15 @@
1
+ export class ContentBundleError extends Error {
2
+ code;
3
+ path;
4
+ pointer;
5
+ referenceChain;
6
+ name = "ContentBundleError";
7
+ constructor(code, message, path = "", pointer = "", referenceChain = [], options) {
8
+ super(message, options);
9
+ this.code = code;
10
+ this.path = path;
11
+ this.pointer = pointer;
12
+ this.referenceChain = referenceChain;
13
+ }
14
+ }
15
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAIhC;IAEA;IACA;IACA;IAPO,IAAI,GAAG,oBAAoB,CAAC;IAE9C,YACW,IAA4B,EACrC,OAAe,EACN,OAAO,EAAE,EACT,UAAU,EAAE,EACZ,iBAAoC,EAAE,EAC/C,OAAsB;QAEtB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAPf,SAAI,GAAJ,IAAI,CAAwB;QAE5B,SAAI,GAAJ,IAAI,CAAK;QACT,YAAO,GAAP,OAAO,CAAK;QACZ,mBAAc,GAAd,cAAc,CAAwB;IAIjD,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ export { openBundle, openSchema, validateContentBundle, bundleLimits, resolveBundleLimits, } from "./bundle.js";
2
+ export { parseBundleManifest, parseData, canonicalJson, safePath, } from "./parsing.js";
3
+ export { inspectSchema, inspectBundleSchema, encodeSchema, decodeSchema, schemaBlockBytes, schemaDialect, declaresBundleSchema, validateValue as validateSchemaValue, } from "./schema.js";
4
+ export type { SchemaOptions, ValidationContext } from "./schema.js";
5
+ export { ContentBundleError } from "./errors.js";
6
+ export type { ContentBundle, EntryValidation, OpenBundleOptions, BundleLimits, BundleManifest, ContentType, JsonSchema, SchemaBlock, SchemaDefinitions, ContentBundleErrorCode, } from "./types.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,UAAU,EACV,qBAAqB,EACrB,YAAY,EACZ,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,mBAAmB,EACnB,SAAS,EACT,aAAa,EACb,QAAQ,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,oBAAoB,EACpB,aAAa,IAAI,mBAAmB,GACrC,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,YAAY,EACV,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,WAAW,EACX,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { openBundle, openSchema, validateContentBundle, bundleLimits, resolveBundleLimits, } from "./bundle.js";
2
+ export { parseBundleManifest, parseData, canonicalJson, safePath, } from "./parsing.js";
3
+ export { inspectSchema, inspectBundleSchema, encodeSchema, decodeSchema, schemaBlockBytes, schemaDialect, declaresBundleSchema, validateValue as validateSchemaValue, } from "./schema.js";
4
+ export { ContentBundleError } from "./errors.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,UAAU,EACV,qBAAqB,EACrB,YAAY,EACZ,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,mBAAmB,EACnB,SAAS,EACT,aAAa,EACb,QAAQ,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,oBAAoB,EACpB,aAAa,IAAI,mBAAmB,GACrC,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { BundleManifest, ContentType, EntryValidation } from "./types.js";
2
+ export declare function entryValidation(entry: BundleManifest["entry"]): EntryValidation;
3
+ export declare function record(value: unknown): value is Record<string, unknown>;
4
+ export declare function safePath(path: string): string;
5
+ export declare function assertJson(value: unknown, maximumNodes?: number, maximumDepth?: number, charge?: () => void): void;
6
+ export declare function canonicalJson(value: unknown, nodes?: number, depth?: number, charge?: () => void): Uint8Array;
7
+ export declare function parseData(bytes: Uint8Array, type: ContentType, nodes?: number, depth?: number, charge?: () => void): unknown;
8
+ export declare function normalizeBundleManifest(value: unknown): BundleManifest;
9
+ export declare function parseBundleManifest(bytes: Uint8Array, maximum?: number, charge?: () => void): BundleManifest;
10
+ //# sourceMappingURL=parsing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parsing.d.ts","sourceRoot":"","sources":["../src/parsing.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAc/E,wBAAgB,eAAe,CAC7B,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,GAC7B,eAAe,CASjB;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEvE;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAmB7C;AAED,wBAAgB,UAAU,CACxB,KAAK,EAAE,OAAO,EACd,YAAY,SAAU,EACtB,YAAY,SAAK,EACjB,MAAM,GAAE,MAAM,IAAe,GAC5B,IAAI,CA0DN;AA8ED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,EACd,KAAK,SAAU,EACf,KAAK,SAAK,EACV,MAAM,GAAE,MAAM,IAAe,GAC5B,UAAU,CAYZ;AAoBD,wBAAgB,SAAS,CACvB,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,WAAW,EACjB,KAAK,SAAU,EACf,KAAK,SAAK,EACV,MAAM,GAAE,MAAM,IAAe,GAC5B,OAAO,CAqFT;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAqDtE;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,UAAU,EACjB,OAAO,SAAmB,EAC1B,MAAM,GAAE,MAAM,IAAe,GAC5B,cAAc,CAqBhB"}