@mikeargento/bitgraph-audit 0.1.0
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 +21 -0
- package/README.md +11 -0
- package/dist/anchors.d.ts +31 -0
- package/dist/anchors.d.ts.map +1 -0
- package/dist/anchors.js +116 -0
- package/dist/anchors.js.map +1 -0
- package/dist/anomalies.d.ts +42 -0
- package/dist/anomalies.d.ts.map +1 -0
- package/dist/anomalies.js +642 -0
- package/dist/anomalies.js.map +1 -0
- package/dist/attestation.d.ts +20 -0
- package/dist/attestation.d.ts.map +1 -0
- package/dist/attestation.js +795 -0
- package/dist/attestation.js.map +1 -0
- package/dist/audit.d.ts +19 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +116 -0
- package/dist/audit.js.map +1 -0
- package/dist/authority.d.ts +37 -0
- package/dist/authority.d.ts.map +1 -0
- package/dist/authority.js +126 -0
- package/dist/authority.js.map +1 -0
- package/dist/aws-nitro-root-ca.d.ts +24 -0
- package/dist/aws-nitro-root-ca.d.ts.map +1 -0
- package/dist/aws-nitro-root-ca.js +44 -0
- package/dist/aws-nitro-root-ca.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +257 -0
- package/dist/cli.js.map +1 -0
- package/dist/contents-hash.d.ts +30 -0
- package/dist/contents-hash.d.ts.map +1 -0
- package/dist/contents-hash.js +73 -0
- package/dist/contents-hash.js.map +1 -0
- package/dist/export.d.ts +64 -0
- package/dist/export.d.ts.map +1 -0
- package/dist/export.js +192 -0
- package/dist/export.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/ingest.d.ts +36 -0
- package/dist/ingest.d.ts.map +1 -0
- package/dist/ingest.js +828 -0
- package/dist/ingest.js.map +1 -0
- package/dist/reconstruct.d.ts +40 -0
- package/dist/reconstruct.d.ts.map +1 -0
- package/dist/reconstruct.js +400 -0
- package/dist/reconstruct.js.map +1 -0
- package/dist/report-json.d.ts +3 -0
- package/dist/report-json.d.ts.map +1 -0
- package/dist/report-json.js +290 -0
- package/dist/report-json.js.map +1 -0
- package/dist/report-md.d.ts +3 -0
- package/dist/report-md.d.ts.map +1 -0
- package/dist/report-md.js +853 -0
- package/dist/report-md.js.map +1 -0
- package/dist/rlp.d.ts +37 -0
- package/dist/rlp.d.ts.map +1 -0
- package/dist/rlp.js +120 -0
- package/dist/rlp.js.map +1 -0
- package/dist/tar.d.ts +47 -0
- package/dist/tar.d.ts.map +1 -0
- package/dist/tar.js +483 -0
- package/dist/tar.js.map +1 -0
- package/dist/temporal.d.ts +55 -0
- package/dist/temporal.d.ts.map +1 -0
- package/dist/temporal.js +461 -0
- package/dist/temporal.js.map +1 -0
- package/dist/types.d.ts +1389 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/validity.d.ts +21 -0
- package/dist/validity.d.ts.map +1 -0
- package/dist/validity.js +86 -0
- package/dist/validity.js.map +1 -0
- package/dist/verify-tiers.d.ts +11 -0
- package/dist/verify-tiers.d.ts.map +1 -0
- package/dist/verify-tiers.js +120 -0
- package/dist/verify-tiers.js.map +1 -0
- package/dist/witness.d.ts +25 -0
- package/dist/witness.d.ts.map +1 -0
- package/dist/witness.js +308 -0
- package/dist/witness.js.map +1 -0
- package/package.json +42 -0
- package/src/anchors.ts +168 -0
- package/src/anomalies.ts +773 -0
- package/src/attestation.ts +878 -0
- package/src/audit.ts +136 -0
- package/src/authority.ts +165 -0
- package/src/aws-nitro-root-ca.ts +47 -0
- package/src/cli.ts +284 -0
- package/src/contents-hash.ts +95 -0
- package/src/export.ts +278 -0
- package/src/index.ts +122 -0
- package/src/ingest.ts +967 -0
- package/src/reconstruct.ts +491 -0
- package/src/report-json.ts +331 -0
- package/src/report-md.ts +1067 -0
- package/src/rlp.ts +142 -0
- package/src/tar.ts +587 -0
- package/src/temporal.ts +629 -0
- package/src/types.ts +1528 -0
- package/src/validity.ts +90 -0
- package/src/verify-tiers.ts +137 -0
- package/src/witness.ts +407 -0
package/dist/tar.js
ADDED
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
// Copyright (c) 2024-2026 Mike Argento. Licensed under the MIT License. See LICENSE.
|
|
2
|
+
/**
|
|
3
|
+
* Minimal streaming tar reader.
|
|
4
|
+
*
|
|
5
|
+
* Coverage, per docs/BUNDLE-FORMAT.md section 4: POSIX ustar headers, PAX
|
|
6
|
+
* extended headers (typeflags 'x' and 'g'; the 'path' and 'size' keywords
|
|
7
|
+
* are applied, other keywords are parsed and ignored), and GNU long-name
|
|
8
|
+
* entries (typeflag 'L'; 'K' long-linkname entries are consumed and
|
|
9
|
+
* discarded because links are not bundle entries). GNU base-256 numeric
|
|
10
|
+
* fields are supported for large sizes.
|
|
11
|
+
*
|
|
12
|
+
* Design constraints:
|
|
13
|
+
* - Pure streaming over an AsyncIterable of byte chunks. Nothing is
|
|
14
|
+
* written to disk and no entry is buffered by this module; entry bodies
|
|
15
|
+
* are exposed as async chunk generators the caller consumes (or
|
|
16
|
+
* abandons; unconsumed bytes are skipped automatically).
|
|
17
|
+
* - Only regular-file entries carry content of interest. Directories,
|
|
18
|
+
* symlinks, hard links, devices, and FIFOs are yielded as kind "other"
|
|
19
|
+
* so callers can count them, but their bodies are never interpreted and
|
|
20
|
+
* links are never followed or dereferenced.
|
|
21
|
+
* - Corrupt structure (bad checksum, truncation, malformed PAX records)
|
|
22
|
+
* throws; a corrupt container is not a readable bundle.
|
|
23
|
+
*/
|
|
24
|
+
const BLOCK = 512;
|
|
25
|
+
/**
|
|
26
|
+
* Read tar entries sequentially from a byte stream.
|
|
27
|
+
*
|
|
28
|
+
* When `limits` is supplied, the reader enforces caps against untrusted
|
|
29
|
+
* archives: a total decompressed-byte ceiling, a maximum entry count, and
|
|
30
|
+
* a maximum size for metadata entries buffered whole (PAX headers and GNU
|
|
31
|
+
* long names). Exceeding any cap throws so the caller aborts cleanly.
|
|
32
|
+
*/
|
|
33
|
+
export async function* readTarEntries(source, limits) {
|
|
34
|
+
const reader = new ChunkReader(source, limits?.maxTotalBytes);
|
|
35
|
+
const maxEntryCount = limits?.maxEntryCount ?? Number.POSITIVE_INFINITY;
|
|
36
|
+
const maxMetadataEntryBytes = limits?.maxMetadataEntryBytes ?? Number.POSITIVE_INFINITY;
|
|
37
|
+
let pendingPax = null;
|
|
38
|
+
let globalPax = null;
|
|
39
|
+
let pendingLongName = null;
|
|
40
|
+
let entryCount = 0;
|
|
41
|
+
const guardMetadata = (size, kind) => {
|
|
42
|
+
if (size > maxMetadataEntryBytes) {
|
|
43
|
+
throw new Error(`tar: ${kind} metadata entry of ${size} bytes exceeds the ${maxMetadataEntryBytes}-byte cap`);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
for (;;) {
|
|
47
|
+
const block = await reader.readExact(BLOCK);
|
|
48
|
+
if (block === null) {
|
|
49
|
+
// EOF at a block boundary without the two-zero-block trailer.
|
|
50
|
+
// Tolerated: everything read so far was structurally complete.
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (isZeroBlock(block)) {
|
|
54
|
+
// End-of-archive marker. The second zero block and any trailing
|
|
55
|
+
// padding are irrelevant.
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (++entryCount > maxEntryCount) {
|
|
59
|
+
throw new Error(`tar: archive exceeds the maximum of ${maxEntryCount} entries`);
|
|
60
|
+
}
|
|
61
|
+
const header = parseHeader(block);
|
|
62
|
+
const typeflag = header.typeflag;
|
|
63
|
+
// --- Metadata entries that modify the NEXT real entry ---------------
|
|
64
|
+
if (typeflag === "x" || typeflag === "g") {
|
|
65
|
+
guardMetadata(header.size, "PAX");
|
|
66
|
+
const data = await readAll(reader, header.size);
|
|
67
|
+
await reader.skip(padOf(header.size));
|
|
68
|
+
const records = parsePaxRecords(data);
|
|
69
|
+
if (typeflag === "x") {
|
|
70
|
+
pendingPax = records;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
globalPax = mergePax(globalPax, records);
|
|
74
|
+
}
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (typeflag === "L") {
|
|
78
|
+
guardMetadata(header.size, "GNU long-name");
|
|
79
|
+
const data = await readAll(reader, header.size);
|
|
80
|
+
await reader.skip(padOf(header.size));
|
|
81
|
+
pendingLongName = decodeString(stripTrailingNuls(data));
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (typeflag === "K") {
|
|
85
|
+
// GNU long linkname. Links are not bundle entries; discard.
|
|
86
|
+
await reader.skip(header.size + padOf(header.size));
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
// --- Real entry ------------------------------------------------------
|
|
90
|
+
let path = header.name;
|
|
91
|
+
if (globalPax !== null && globalPax.has("path"))
|
|
92
|
+
path = globalPax.get("path");
|
|
93
|
+
if (pendingLongName !== null)
|
|
94
|
+
path = pendingLongName;
|
|
95
|
+
if (pendingPax !== null && pendingPax.has("path"))
|
|
96
|
+
path = pendingPax.get("path");
|
|
97
|
+
let size = header.size;
|
|
98
|
+
const paxSize = pendingPax?.get("size") ?? globalPax?.get("size");
|
|
99
|
+
if (paxSize !== undefined) {
|
|
100
|
+
const parsed = Number(paxSize);
|
|
101
|
+
if (!Number.isSafeInteger(parsed) || parsed < 0) {
|
|
102
|
+
throw new Error("tar: invalid PAX size value");
|
|
103
|
+
}
|
|
104
|
+
size = parsed;
|
|
105
|
+
}
|
|
106
|
+
pendingPax = null;
|
|
107
|
+
pendingLongName = null;
|
|
108
|
+
const isFile = typeflag === "0" || typeflag === "\0";
|
|
109
|
+
const state = { remaining: size };
|
|
110
|
+
const body = bodyGenerator(reader, state);
|
|
111
|
+
yield {
|
|
112
|
+
path,
|
|
113
|
+
size,
|
|
114
|
+
kind: isFile ? "file" : "other",
|
|
115
|
+
typeflag,
|
|
116
|
+
body,
|
|
117
|
+
};
|
|
118
|
+
// Skip whatever the consumer left unread, plus block padding.
|
|
119
|
+
if (state.remaining > 0) {
|
|
120
|
+
await reader.skip(state.remaining);
|
|
121
|
+
state.remaining = 0;
|
|
122
|
+
}
|
|
123
|
+
await reader.skip(padOf(size));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// ---------------------------------------------------------------------------
|
|
127
|
+
// Body streaming
|
|
128
|
+
// ---------------------------------------------------------------------------
|
|
129
|
+
async function* bodyGenerator(reader, state) {
|
|
130
|
+
while (state.remaining > 0) {
|
|
131
|
+
const chunk = await reader.readSome(state.remaining);
|
|
132
|
+
if (chunk === null) {
|
|
133
|
+
throw new Error("tar: truncated archive (unexpected end of stream inside entry body)");
|
|
134
|
+
}
|
|
135
|
+
state.remaining -= chunk.length;
|
|
136
|
+
yield chunk;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async function readAll(reader, size) {
|
|
140
|
+
if (size === 0)
|
|
141
|
+
return new Uint8Array(0);
|
|
142
|
+
const data = await reader.readExact(size);
|
|
143
|
+
if (data === null) {
|
|
144
|
+
throw new Error("tar: truncated archive (unexpected end of stream)");
|
|
145
|
+
}
|
|
146
|
+
return data;
|
|
147
|
+
}
|
|
148
|
+
function parseHeader(block) {
|
|
149
|
+
verifyChecksum(block);
|
|
150
|
+
const rawType = block[156];
|
|
151
|
+
const typeflag = rawType === 0 ? "\0" : String.fromCharCode(rawType);
|
|
152
|
+
let name = decodeString(fieldBytes(block, 0, 100));
|
|
153
|
+
const magic = decodeString(fieldBytes(block, 257, 6));
|
|
154
|
+
if (magic === "ustar") {
|
|
155
|
+
const prefix = decodeString(fieldBytes(block, 345, 155));
|
|
156
|
+
if (prefix.length > 0) {
|
|
157
|
+
name = `${prefix}/${name}`;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const size = parseNumeric(block.subarray(124, 136));
|
|
161
|
+
return { name, size, typeflag };
|
|
162
|
+
}
|
|
163
|
+
/** Extract a NUL-terminated field. */
|
|
164
|
+
function fieldBytes(block, offset, length) {
|
|
165
|
+
const raw = block.subarray(offset, offset + length);
|
|
166
|
+
let end = raw.indexOf(0);
|
|
167
|
+
if (end === -1)
|
|
168
|
+
end = raw.length;
|
|
169
|
+
return raw.subarray(0, end);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Parse a tar numeric field: ASCII octal (NUL/space padded), or GNU
|
|
173
|
+
* base-256 when the high bit of the first byte is set.
|
|
174
|
+
*/
|
|
175
|
+
function parseNumeric(field) {
|
|
176
|
+
if (field.length > 0 && (field[0] & 0x80) !== 0) {
|
|
177
|
+
// GNU base-256: big-endian binary, first byte's low 7 bits included.
|
|
178
|
+
let value = 0n;
|
|
179
|
+
for (let i = 0; i < field.length; i++) {
|
|
180
|
+
const byte = i === 0 ? field[0] & 0x7f : field[i];
|
|
181
|
+
value = (value << 8n) | BigInt(byte);
|
|
182
|
+
}
|
|
183
|
+
if (value > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
184
|
+
throw new Error("tar: numeric field exceeds the supported range");
|
|
185
|
+
}
|
|
186
|
+
return Number(value);
|
|
187
|
+
}
|
|
188
|
+
const text = decodeString(field).trim().replace(/\0+$/, "").trim();
|
|
189
|
+
if (text.length === 0)
|
|
190
|
+
return 0;
|
|
191
|
+
const value = Number.parseInt(text, 8);
|
|
192
|
+
if (!Number.isSafeInteger(value) || value < 0) {
|
|
193
|
+
throw new Error(`tar: invalid octal numeric field: "${text}"`);
|
|
194
|
+
}
|
|
195
|
+
return value;
|
|
196
|
+
}
|
|
197
|
+
function verifyChecksum(block) {
|
|
198
|
+
const stored = parseNumeric(block.subarray(148, 156));
|
|
199
|
+
let sum = 0;
|
|
200
|
+
for (let i = 0; i < BLOCK; i++) {
|
|
201
|
+
sum += i >= 148 && i < 156 ? 0x20 : block[i];
|
|
202
|
+
}
|
|
203
|
+
if (sum !== stored) {
|
|
204
|
+
throw new Error("tar: header checksum mismatch (corrupt or not a tar archive)");
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function isZeroBlock(block) {
|
|
208
|
+
for (let i = 0; i < block.length; i++) {
|
|
209
|
+
if (block[i] !== 0)
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
// ---------------------------------------------------------------------------
|
|
215
|
+
// PAX records
|
|
216
|
+
// ---------------------------------------------------------------------------
|
|
217
|
+
/**
|
|
218
|
+
* Parse PAX extended-header data: a sequence of "len key=value\n" records
|
|
219
|
+
* where len is the decimal byte length of the whole record including the
|
|
220
|
+
* digits, the space, and the trailing newline.
|
|
221
|
+
*/
|
|
222
|
+
function parsePaxRecords(data) {
|
|
223
|
+
const records = new Map();
|
|
224
|
+
let offset = 0;
|
|
225
|
+
while (offset < data.length) {
|
|
226
|
+
let cursor = offset;
|
|
227
|
+
while (cursor < data.length && data[cursor] !== 0x20)
|
|
228
|
+
cursor++;
|
|
229
|
+
if (cursor >= data.length) {
|
|
230
|
+
throw new Error("tar: malformed PAX record (no length delimiter)");
|
|
231
|
+
}
|
|
232
|
+
const length = Number(decodeString(data.subarray(offset, cursor)));
|
|
233
|
+
if (!Number.isInteger(length) || length <= 0 || offset + length > data.length) {
|
|
234
|
+
throw new Error("tar: malformed PAX record (bad length)");
|
|
235
|
+
}
|
|
236
|
+
const record = data.subarray(cursor + 1, offset + length);
|
|
237
|
+
if (record.length === 0 || record[record.length - 1] !== 0x0a) {
|
|
238
|
+
throw new Error("tar: malformed PAX record (missing newline)");
|
|
239
|
+
}
|
|
240
|
+
const text = decodeString(record.subarray(0, record.length - 1));
|
|
241
|
+
const eq = text.indexOf("=");
|
|
242
|
+
if (eq === -1) {
|
|
243
|
+
throw new Error("tar: malformed PAX record (missing '=')");
|
|
244
|
+
}
|
|
245
|
+
records.set(text.slice(0, eq), text.slice(eq + 1));
|
|
246
|
+
offset += length;
|
|
247
|
+
}
|
|
248
|
+
return records;
|
|
249
|
+
}
|
|
250
|
+
function mergePax(base, overlay) {
|
|
251
|
+
const merged = new Map(base ?? []);
|
|
252
|
+
for (const [key, value] of overlay)
|
|
253
|
+
merged.set(key, value);
|
|
254
|
+
return merged;
|
|
255
|
+
}
|
|
256
|
+
// ---------------------------------------------------------------------------
|
|
257
|
+
// Byte helpers
|
|
258
|
+
// ---------------------------------------------------------------------------
|
|
259
|
+
function decodeString(bytes) {
|
|
260
|
+
return new TextDecoder("utf-8").decode(bytes);
|
|
261
|
+
}
|
|
262
|
+
function stripTrailingNuls(bytes) {
|
|
263
|
+
let end = bytes.length;
|
|
264
|
+
while (end > 0 && bytes[end - 1] === 0)
|
|
265
|
+
end--;
|
|
266
|
+
return bytes.subarray(0, end);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Pull-based reader over an async chunk stream.
|
|
270
|
+
*/
|
|
271
|
+
class ChunkReader {
|
|
272
|
+
iter;
|
|
273
|
+
chunks = [];
|
|
274
|
+
head = 0;
|
|
275
|
+
available = 0;
|
|
276
|
+
ended = false;
|
|
277
|
+
totalPulled = 0;
|
|
278
|
+
maxTotalBytes;
|
|
279
|
+
constructor(source, maxTotalBytes) {
|
|
280
|
+
this.iter = source[Symbol.asyncIterator]();
|
|
281
|
+
this.maxTotalBytes = maxTotalBytes ?? Number.POSITIVE_INFINITY;
|
|
282
|
+
}
|
|
283
|
+
async fill() {
|
|
284
|
+
if (this.ended)
|
|
285
|
+
return false;
|
|
286
|
+
const result = await this.iter.next();
|
|
287
|
+
if (result.done === true) {
|
|
288
|
+
this.ended = true;
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
const chunk = result.value;
|
|
292
|
+
if (chunk.length > 0) {
|
|
293
|
+
this.totalPulled += chunk.length;
|
|
294
|
+
if (this.totalPulled > this.maxTotalBytes) {
|
|
295
|
+
throw new Error(`tar: archive exceeds the maximum decompressed size of ${this.maxTotalBytes} bytes`);
|
|
296
|
+
}
|
|
297
|
+
this.chunks.push(chunk);
|
|
298
|
+
this.available += chunk.length;
|
|
299
|
+
}
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Read exactly n bytes. Returns null on a clean EOF with nothing
|
|
304
|
+
* buffered; throws if the stream ends mid-read.
|
|
305
|
+
*/
|
|
306
|
+
async readExact(n) {
|
|
307
|
+
while (this.available < n) {
|
|
308
|
+
const more = await this.fill();
|
|
309
|
+
if (!more) {
|
|
310
|
+
if (this.available === 0)
|
|
311
|
+
return null;
|
|
312
|
+
throw new Error("tar: truncated archive (unexpected end of stream)");
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return this.take(n);
|
|
316
|
+
}
|
|
317
|
+
/** Read between 1 and max bytes. Returns null at EOF. */
|
|
318
|
+
async readSome(max) {
|
|
319
|
+
while (this.available === 0) {
|
|
320
|
+
const more = await this.fill();
|
|
321
|
+
if (!more)
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
const first = this.chunks[0];
|
|
325
|
+
const take = Math.min(max, first.length - this.head);
|
|
326
|
+
const out = first.subarray(this.head, this.head + take);
|
|
327
|
+
this.advance(take, first);
|
|
328
|
+
return out;
|
|
329
|
+
}
|
|
330
|
+
async skip(n) {
|
|
331
|
+
let remaining = n;
|
|
332
|
+
while (remaining > 0) {
|
|
333
|
+
const chunk = await this.readSome(remaining);
|
|
334
|
+
if (chunk === null) {
|
|
335
|
+
throw new Error("tar: truncated archive (unexpected end of stream)");
|
|
336
|
+
}
|
|
337
|
+
remaining -= chunk.length;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
take(n) {
|
|
341
|
+
const out = new Uint8Array(n);
|
|
342
|
+
let copied = 0;
|
|
343
|
+
while (copied < n) {
|
|
344
|
+
const first = this.chunks[0];
|
|
345
|
+
const take = Math.min(n - copied, first.length - this.head);
|
|
346
|
+
out.set(first.subarray(this.head, this.head + take), copied);
|
|
347
|
+
copied += take;
|
|
348
|
+
this.advance(take, first);
|
|
349
|
+
}
|
|
350
|
+
return out;
|
|
351
|
+
}
|
|
352
|
+
advance(consumed, first) {
|
|
353
|
+
this.head += consumed;
|
|
354
|
+
this.available -= consumed;
|
|
355
|
+
if (this.head === first.length) {
|
|
356
|
+
this.chunks.shift();
|
|
357
|
+
this.head = 0;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
function padOf(size) {
|
|
362
|
+
return (BLOCK - (size % BLOCK)) % BLOCK;
|
|
363
|
+
}
|
|
364
|
+
/** Build a complete tar archive (ustar + PAX long paths) in memory. */
|
|
365
|
+
export function writeTarArchive(files) {
|
|
366
|
+
const parts = [];
|
|
367
|
+
for (const file of files) {
|
|
368
|
+
const pathBytes = new TextEncoder().encode(file.path);
|
|
369
|
+
if (pathBytes.length <= 100) {
|
|
370
|
+
parts.push(writeHeader(file.path, "", file.content.length, "0"));
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
const split = splitUstarPath(file.path, pathBytes);
|
|
374
|
+
if (split !== null) {
|
|
375
|
+
parts.push(writeHeader(split.name, split.prefix, file.content.length, "0"));
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
// PAX extended header carrying the full path, then a header whose
|
|
379
|
+
// name field holds a deterministic truncation.
|
|
380
|
+
const record = paxPathRecord(file.path);
|
|
381
|
+
const paxName = truncateBytes(`PaxHeaders.0/${file.path}`, 100);
|
|
382
|
+
parts.push(writeHeader(paxName, "", record.length, "x"), padBlock(record));
|
|
383
|
+
parts.push(writeHeader(truncateBytes(file.path, 100), "", file.content.length, "0"));
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
parts.push(padBlock(file.content));
|
|
387
|
+
}
|
|
388
|
+
parts.push(new Uint8Array(BLOCK), new Uint8Array(BLOCK));
|
|
389
|
+
return concatParts(parts);
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Split a long path for the ustar prefix field: the rightmost "/" such
|
|
393
|
+
* that the name part fits 100 bytes and the prefix part fits 155 bytes.
|
|
394
|
+
* Returns null when no split works (PAX fallback).
|
|
395
|
+
*/
|
|
396
|
+
function splitUstarPath(path, pathBytes) {
|
|
397
|
+
for (let i = path.length - 1; i > 0; i--) {
|
|
398
|
+
if (path.charCodeAt(i) !== 0x2f)
|
|
399
|
+
continue;
|
|
400
|
+
const prefix = path.slice(0, i);
|
|
401
|
+
const name = path.slice(i + 1);
|
|
402
|
+
const prefixLen = new TextEncoder().encode(prefix).length;
|
|
403
|
+
const nameLen = pathBytes.length - prefixLen - 1;
|
|
404
|
+
if (name.length > 0 && nameLen <= 100 && prefixLen <= 155) {
|
|
405
|
+
return { prefix, name };
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return null;
|
|
409
|
+
}
|
|
410
|
+
function writeHeader(name, prefix, size, typeflag) {
|
|
411
|
+
const block = new Uint8Array(BLOCK);
|
|
412
|
+
const ascii = (text, offset, length) => {
|
|
413
|
+
const bytes = new TextEncoder().encode(text);
|
|
414
|
+
block.set(bytes.subarray(0, Math.min(bytes.length, length)), offset);
|
|
415
|
+
};
|
|
416
|
+
ascii(name, 0, 100);
|
|
417
|
+
block.set(octal(0o644, 8), 100); // mode
|
|
418
|
+
block.set(octal(0, 8), 108); // uid
|
|
419
|
+
block.set(octal(0, 8), 116); // gid
|
|
420
|
+
block.set(octal(size, 12), 124); // size
|
|
421
|
+
block.set(octal(0, 12), 136); // mtime, fixed 0 for determinism
|
|
422
|
+
for (let i = 148; i < 156; i++)
|
|
423
|
+
block[i] = 0x20; // checksum spaces
|
|
424
|
+
block[156] = typeflag.charCodeAt(0);
|
|
425
|
+
ascii("ustar", 257, 6); // magic, NUL-terminated by the zeroed block
|
|
426
|
+
ascii("00", 263, 2); // version
|
|
427
|
+
if (prefix.length > 0)
|
|
428
|
+
ascii(prefix, 345, 155);
|
|
429
|
+
let sum = 0;
|
|
430
|
+
for (let i = 0; i < BLOCK; i++)
|
|
431
|
+
sum += block[i];
|
|
432
|
+
ascii(sum.toString(8).padStart(6, "0"), 148, 6);
|
|
433
|
+
block[154] = 0;
|
|
434
|
+
block[155] = 0x20;
|
|
435
|
+
return block;
|
|
436
|
+
}
|
|
437
|
+
function octal(value, length) {
|
|
438
|
+
const out = new Uint8Array(length);
|
|
439
|
+
const text = value.toString(8).padStart(length - 1, "0");
|
|
440
|
+
for (let i = 0; i < text.length; i++)
|
|
441
|
+
out[i] = text.charCodeAt(i);
|
|
442
|
+
out[length - 1] = 0;
|
|
443
|
+
return out;
|
|
444
|
+
}
|
|
445
|
+
/** PAX record "<len> path=<value>\n" where len counts the whole record. */
|
|
446
|
+
function paxPathRecord(path) {
|
|
447
|
+
const baseBytes = new TextEncoder().encode(` path=${path}\n`);
|
|
448
|
+
let length = baseBytes.length + 1;
|
|
449
|
+
while (String(length).length + baseBytes.length !== length) {
|
|
450
|
+
length = String(length).length + baseBytes.length;
|
|
451
|
+
}
|
|
452
|
+
return concatParts([new TextEncoder().encode(String(length)), baseBytes]);
|
|
453
|
+
}
|
|
454
|
+
/** Truncate a string to at most n UTF-8 bytes (paths here are ASCII in practice). */
|
|
455
|
+
function truncateBytes(text, n) {
|
|
456
|
+
const bytes = new TextEncoder().encode(text);
|
|
457
|
+
if (bytes.length <= n)
|
|
458
|
+
return text;
|
|
459
|
+
let end = n;
|
|
460
|
+
// Do not cut inside a multi-byte sequence.
|
|
461
|
+
while (end > 0 && (bytes[end] & 0xc0) === 0x80)
|
|
462
|
+
end--;
|
|
463
|
+
return new TextDecoder("utf-8").decode(bytes.subarray(0, end));
|
|
464
|
+
}
|
|
465
|
+
function padBlock(content) {
|
|
466
|
+
const padding = padOf(content.length);
|
|
467
|
+
if (padding === 0)
|
|
468
|
+
return content;
|
|
469
|
+
const out = new Uint8Array(content.length + padding);
|
|
470
|
+
out.set(content, 0);
|
|
471
|
+
return out;
|
|
472
|
+
}
|
|
473
|
+
function concatParts(parts) {
|
|
474
|
+
const total = parts.reduce((sum, part) => sum + part.length, 0);
|
|
475
|
+
const out = new Uint8Array(total);
|
|
476
|
+
let offset = 0;
|
|
477
|
+
for (const part of parts) {
|
|
478
|
+
out.set(part, offset);
|
|
479
|
+
offset += part.length;
|
|
480
|
+
}
|
|
481
|
+
return out;
|
|
482
|
+
}
|
|
483
|
+
//# sourceMappingURL=tar.js.map
|
package/dist/tar.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tar.js","sourceRoot":"","sources":["../src/tar.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,KAAK,GAAG,GAAG,CAAC;AAiClB;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,cAAc,CACnC,MAAiC,EACjC,MAAkB;IAElB,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;IAC9D,MAAM,aAAa,GAAG,MAAM,EAAE,aAAa,IAAI,MAAM,CAAC,iBAAiB,CAAC;IACxE,MAAM,qBAAqB,GAAG,MAAM,EAAE,qBAAqB,IAAI,MAAM,CAAC,iBAAiB,CAAC;IACxF,IAAI,UAAU,GAA+B,IAAI,CAAC;IAClD,IAAI,SAAS,GAA+B,IAAI,CAAC;IACjD,IAAI,eAAe,GAAkB,IAAI,CAAC;IAC1C,IAAI,UAAU,GAAG,CAAC,CAAC;IAEnB,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,IAAY,EAAQ,EAAE;QACzD,IAAI,IAAI,GAAG,qBAAqB,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CACb,QAAQ,IAAI,sBAAsB,IAAI,sBAAsB,qBAAqB,WAAW,CAC7F,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;IAEF,SAAS,CAAC;QACR,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC5C,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,8DAA8D;YAC9D,+DAA+D;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,2CAA2C;IAC3C,OAAO,GAAG,GAAG,CAAC,IAAI,CAAE,KAAK,CAAC,GAAG,CAAY,GAAG,IAAI,CAAC,KAAK,IAAI;QAAE,GAAG,EAAE,CAAC;IAClE,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;AACjE,CAAC;AAED,SAAS,QAAQ,CAAC,OAAmB;IACnC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACtC,IAAI,OAAO,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IAClC,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC;IACrD,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACpB,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,WAAW,CAAC,KAAmB;IACtC,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAChE,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IAClC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACtB,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;IACxB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bitgraph-audit temporal bounds
|
|
3
|
+
*
|
|
4
|
+
* Turns verified anchor witnesses into one-sided wall-clock bounds on
|
|
5
|
+
* segments of the observed record. Only anchors with a VERIFIED witness
|
|
6
|
+
* (witness.ts) contribute: an anchor without one still establishes causal
|
|
7
|
+
* order, but confers no wall-clock evidence. Nothing here reads a block
|
|
8
|
+
* number as a time, an unsigned metadata timestamp, or a manifest time.
|
|
9
|
+
*
|
|
10
|
+
* Bound semantics, stated once and enforced everywhere:
|
|
11
|
+
*
|
|
12
|
+
* not-before (lower bound): a proof causally AFTER an anchor that
|
|
13
|
+
* consumed the hash of a block published at time T was COMMITTED no
|
|
14
|
+
* earlier than T. Grounded in block-hash unpredictability: the hash did
|
|
15
|
+
* not exist before T and the covered proofs embed it through the chain.
|
|
16
|
+
* This additionally assumes the anchored header is a genuine, publicly
|
|
17
|
+
* published Ethereum block, which this offline audit cannot confirm: it
|
|
18
|
+
* checks the header's structure and hash binding, not proof-of-work,
|
|
19
|
+
* consensus, or chain membership. Every not-before claim states that
|
|
20
|
+
* assumption. Sound along chain-link evidence, subject to it.
|
|
21
|
+
*
|
|
22
|
+
* not-after (upper bound): a proof causally BEFORE an anchor existed
|
|
23
|
+
* before that anchor's commit, and the consumed block proves the commit
|
|
24
|
+
* came AT OR AFTER its timestamp T, not how promptly. Reading T as a
|
|
25
|
+
* wall-clock ceiling therefore additionally assumes the anchor consumed
|
|
26
|
+
* a recently published block. The deployed anchor service commits the
|
|
27
|
+
* latest block on a short interval, but that is service behavior, not
|
|
28
|
+
* proof; the assumption is stated on every not-after bound and on every
|
|
29
|
+
* cross-epoch ordering derived from one. This is a deliberate
|
|
30
|
+
* correction toward honesty over the looser "existed by T" phrasing:
|
|
31
|
+
* the anchor mechanism is inbound-only (a block hash committed INTO the
|
|
32
|
+
* chain), and an inbound commitment cannot cryptographically upper-bound
|
|
33
|
+
* prior events.
|
|
34
|
+
*
|
|
35
|
+
* Evidence classes: a bound holds along a verified prevB64 hash-link path
|
|
36
|
+
* ("chain-link") or, weaker, by commit-counter ordering within the same
|
|
37
|
+
* partition ("counter-order", which relies on the authority's counter
|
|
38
|
+
* discipline rather than verifiable links). Every bound record states
|
|
39
|
+
* which class supports it. Bounds never cross partitions; epoch-level
|
|
40
|
+
* aggregation only collects the per-partition results.
|
|
41
|
+
*
|
|
42
|
+
* Bounds attach to segments, never to individual proofs, and a one-sided
|
|
43
|
+
* bound is never presented as an interval. Segments with no verified
|
|
44
|
+
* anchor evidence are ordered-but-unanchored. Cross-epoch ordering pairs
|
|
45
|
+
* are evidence, never divergence; overlapping or absent bounds mean
|
|
46
|
+
* concurrent-or-unordered.
|
|
47
|
+
*
|
|
48
|
+
* Run after verifyObservedProofs, reconstructChains, identifyAnchors, and
|
|
49
|
+
* verifyAnchorWitnesses. Populates EpochRecord.anchorBounds on the given
|
|
50
|
+
* reconstruction (the typed Phase 4c extension point) and returns the
|
|
51
|
+
* segment-level analysis.
|
|
52
|
+
*/
|
|
53
|
+
import type { AnchorIdentification, AnchorWitnessAnalysis, IngestResult, ReconstructionResult, TemporalAnalysis } from "./types.js";
|
|
54
|
+
export declare function deriveTemporalBounds(ingest: IngestResult, reconstruction: ReconstructionResult, identification: AnchorIdentification, witnessAnalysis: AnchorWitnessAnalysis): TemporalAnalysis;
|
|
55
|
+
//# sourceMappingURL=temporal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temporal.d.ts","sourceRoot":"","sources":["../src/temporal.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,OAAO,KAAK,EACV,oBAAoB,EAEpB,qBAAqB,EAIrB,YAAY,EAEZ,oBAAoB,EAEpB,gBAAgB,EAEjB,MAAM,YAAY,CAAC;AAOpB,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,EACpB,cAAc,EAAE,oBAAoB,EACpC,cAAc,EAAE,oBAAoB,EACpC,eAAe,EAAE,qBAAqB,GACrC,gBAAgB,CAuClB"}
|