@333eco/origin-verify 0.1.1 → 0.1.3
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 +1 -1
- package/media.mjs +18 -8
- package/package.json +1 -1
- package/trust.mjs +8 -5
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ Four states. Each stands alone and none implies another.
|
|
|
26
26
|
| state | it says | it rests on |
|
|
27
27
|
|---|---|---|
|
|
28
28
|
| `included` | this record is in the tree this checkpoint signs, and the log cannot later remove it unnoticed | the operator's keys and the Merkle proof |
|
|
29
|
-
| `witnessed` | enough outside witnesses cosigned the checkpoint | their signatures. ⚠️ False today:
|
|
29
|
+
| `witnessed` | enough outside witnesses cosigned the checkpoint | their signatures. ⚠️ False today: the log is on the Witness Network's testing list, not yet staging. Testing witnesses may cosign and `witnesses` names them, but they are not counted, because they may reset or disappear |
|
|
30
30
|
| `timestamped` | a checkpoint holding this record existed by this time | each authority's word, one per token |
|
|
31
31
|
| `bitcoin` | a checkpoint holding this record existed by this block | Bitcoin's proof of work |
|
|
32
32
|
|
package/media.mjs
CHANGED
|
@@ -7,14 +7,23 @@ const SIG = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
|
|
|
7
7
|
const MAX_PIXELS = 100_000_000;
|
|
8
8
|
export const isPng = (b) => SIG.every((x, i) => b[i] === x);
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
/** Stops at `limit`: a small file can inflate to gigabytes, and the header already says how big a real one can be. */
|
|
11
|
+
async function inflate(data, limit) {
|
|
12
|
+
const reader = new Blob([data]).stream().pipeThrough(new DecompressionStream("deflate")).getReader(), parts = [];
|
|
13
|
+
let total = 0;
|
|
14
|
+
for (;;) {
|
|
15
|
+
const { done, value } = await reader.read();
|
|
16
|
+
if (done) break;
|
|
17
|
+
total += value.length;
|
|
18
|
+
if (total > limit) { await reader.cancel().catch(() => {}); throw new Error("a PNG that inflates past what its header allows"); }
|
|
19
|
+
parts.push(value);
|
|
20
|
+
}
|
|
21
|
+
return concat(...parts);
|
|
13
22
|
}
|
|
14
23
|
const ADAM7 = [[0, 0, 8, 8], [4, 0, 8, 8], [0, 4, 4, 8], [2, 0, 4, 4], [0, 2, 2, 4], [1, 0, 2, 2], [0, 1, 1, 2]];
|
|
15
24
|
|
|
16
25
|
/** Returns { width, height, rgb, alpha } as 8-bit rasters. `rgb` is null for 16-bit gray, which PIL clips rather than reduces, so no hash could match it. */
|
|
17
|
-
export async function decodePng(b) {
|
|
26
|
+
export async function decodePng(b, { maxPixels = MAX_PIXELS } = {}) {
|
|
18
27
|
if (!isPng(b)) throw new Error("not a PNG");
|
|
19
28
|
const dv = new DataView(b.buffer, b.byteOffset, b.length);
|
|
20
29
|
let i = 8, width, height, depth, color, interlace, palette = null, trns = null;
|
|
@@ -29,11 +38,12 @@ export async function decodePng(b) {
|
|
|
29
38
|
else if (type === "IEND") break;
|
|
30
39
|
i += 12 + len;
|
|
31
40
|
}
|
|
32
|
-
if (!width || !height || !idat.length || width * height >
|
|
41
|
+
if (!width || !height || !idat.length || width * height > maxPixels) throw new Error("a PNG this reader will not open");
|
|
33
42
|
const channels = { 0: 1, 2: 3, 3: 1, 4: 2, 6: 4 }[color];
|
|
34
43
|
if (!channels || (color === 3 && !palette)) throw new Error("a PNG with an unknown color type");
|
|
35
44
|
const bitsPerPixel = channels * depth, bpp = Math.max(1, bitsPerPixel >> 3);
|
|
36
|
-
|
|
45
|
+
// The most a real image of this size can need; interlacing repeats a line's filter byte in up to seven passes, so a generous bound covers it.
|
|
46
|
+
const raw = await inflate(concat(...idat), (Math.ceil((width * bitsPerPixel) / 8) + 1) * height * (interlace === 1 ? 2 : 1) + 1024);
|
|
37
47
|
const rgb = new Uint8Array(width * height * 3), alpha = new Uint8Array(width * height).fill(255);
|
|
38
48
|
let at = 0;
|
|
39
49
|
const pass = (w, h, put) => {
|
|
@@ -136,13 +146,13 @@ export async function canvasDecoder(bytes, mime) {
|
|
|
136
146
|
* The hashes a claim carries. `decode(bytes)` is the caller's own decoder for other image types, returning { width, height, rgb, alpha }: it may give `phash`, never `pixels`.
|
|
137
147
|
* A file that is not a picture, or that nothing can decode, simply has neither: it can still be signed, and found only by its exact bytes.
|
|
138
148
|
*/
|
|
139
|
-
export async function hashFile(bytes, { decode } = {}) {
|
|
149
|
+
export async function hashFile(bytes, { decode, maxPixels } = {}) {
|
|
140
150
|
const b = new Uint8Array(bytes);
|
|
141
151
|
const sha = new Uint8Array(await crypto.subtle.digest("SHA-256", b));
|
|
142
152
|
const out = { sha256: hex(sha), bytes: b.length };
|
|
143
153
|
try {
|
|
144
154
|
if (isPng(b)) {
|
|
145
|
-
const png = await decodePng(b);
|
|
155
|
+
const png = await decodePng(b, maxPixels ? { maxPixels } : {});
|
|
146
156
|
if (png.rgb) { out.pixels = hex(new Uint8Array(await crypto.subtle.digest("SHA-256", png.rgb))); out.phash = phashOf(png); }
|
|
147
157
|
} else if (decode) {
|
|
148
158
|
const r = await decode(b);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@333eco/origin-verify",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Checks a B-Origin record with no help from its operator: signatures, its place in the public log, witness cosignatures, RFC 3161 tokens, OpenTimestamps proofs against Bitcoin, and a signer's reveal. Browser or Node, no runtime dependencies.",
|
|
5
5
|
"license": "CC0-1.0",
|
|
6
6
|
"author": "Thon Ly",
|
package/trust.mjs
CHANGED
|
@@ -7,15 +7,18 @@ export default {
|
|
|
7
7
|
},
|
|
8
8
|
"rpId": "sign.333.eco",
|
|
9
9
|
"webOrigin": "https://sign.333.eco",
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
// The Witness Network's TESTING list (2026-11-04). These witnesses may reset or disappear, so they are named and NOT counted: no witnessQuorum, so `witnessed` stays false.
|
|
11
|
+
// A move to staging puts back that list's keys and a quorum. Read from each operator's own page, 2026-11-04.
|
|
12
|
+
"witnessLabel": "testing witnesses",
|
|
12
13
|
"witnesses": [
|
|
13
14
|
"witness.navigli.sunlight.geomys.org+a3e00fe2+BNy/co4C1Hn1p+INwJrfUlgz7W55dSZReusH/GhUhJ/G",
|
|
14
|
-
"krabbel.ct.ipng.ch+4b10dbd8+BO4sLOtnhktlqMCejDx9C5LDd+/xZxbmBb6BP9ZD2Def",
|
|
15
|
-
"witness.gdbsecurity.com+a1398f73+BAbIijGonVIk3ikDac+KKlSm1ELHOzcddhjjB6zB4BNf",
|
|
16
15
|
"markovianprotocol.com/witness+41b8827f+BJKLl8rBYM0oUxSaWh9rjTldTprEpYj/SWVIGgacA9XC",
|
|
17
16
|
"witness.stagemole.eu+67f7aea0+BEqSG3yu9YrmcM3BHvQYTxwFj3uSWakQepafafpUqklv",
|
|
18
|
-
"
|
|
17
|
+
"transparency.dev/DEV:witness-little-garden+d8042a87+BCtusOxINQNUTN5Oj8HObRkh2yHf/MwYaGX4CPdiVEPM",
|
|
18
|
+
"kladje.ct.ipng.ch+cdfb671b+BH6mAtKyb9gR+D1sL6TSGLbGoRqcX5AXpBgluXmaimp7",
|
|
19
|
+
"rgdd.se/poc-witness+db03732e+BCjJKlo6BU0xfIb8LutqerIFTWIXEA0L5n3tW3QyPFgG",
|
|
20
|
+
"witness1.smartit.nu/witness1+a48c820f+BPSFWg9G6KPiO7QPryYO5Xq4oYJJ+kAvLKLSimDhoxMO",
|
|
21
|
+
"remora.n621.de+da77ade7+BOvN63jn/bLvkieywe8R6UYAtVtNbZpXh34x7onlmtw2"
|
|
19
22
|
],
|
|
20
23
|
"tsaRoots": {
|
|
21
24
|
"accv-es": [
|