@cardanowall/poe-standard 0.3.0 → 0.5.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/dist/carriage.cjs +1972 -0
- package/dist/carriage.cjs.map +1 -0
- package/dist/carriage.d.cts +55 -0
- package/dist/carriage.d.ts +55 -0
- package/dist/carriage.js +1967 -0
- package/dist/carriage.js.map +1 -0
- package/dist/encoder.cjs +29 -77
- package/dist/encoder.cjs.map +1 -1
- package/dist/encoder.d.cts +10 -0
- package/dist/encoder.d.ts +10 -0
- package/dist/encoder.js +29 -77
- package/dist/encoder.js.map +1 -1
- package/dist/error-codes.cjs +129 -37
- package/dist/error-codes.cjs.map +1 -1
- package/dist/error-codes.d.cts +11 -6
- package/dist/error-codes.d.ts +11 -6
- package/dist/error-codes.js +126 -38
- package/dist/error-codes.js.map +1 -1
- package/dist/index.cjs +1085 -838
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -58
- package/dist/index.d.ts +4 -58
- package/dist/index.js +1074 -833
- package/dist/index.js.map +1 -1
- package/dist/schema.cjs +101 -87
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.d.cts +69 -47
- package/dist/schema.d.ts +69 -47
- package/dist/schema.js +99 -86
- package/dist/schema.js.map +1 -1
- package/dist/validator.cjs +927 -577
- package/dist/validator.cjs.map +1 -1
- package/dist/validator.d.cts +48 -7
- package/dist/validator.d.ts +48 -7
- package/dist/validator.js +927 -578
- package/dist/validator.js.map +1 -1
- package/package.json +8 -2
package/dist/encoder.d.cts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { PoeRecord } from './schema.cjs';
|
|
2
2
|
import 'zod';
|
|
3
3
|
|
|
4
|
+
/** Canonical CBOR bytes of the full record body — the bytes the chunk-array
|
|
5
|
+
* transport carries on chain (see `carriage.ts`). */
|
|
4
6
|
declare function encodePoeRecord(record: PoeRecord): Uint8Array;
|
|
7
|
+
/**
|
|
8
|
+
* Canonical CBOR bytes of the record body **with `sigs` removed** — the body
|
|
9
|
+
* a record-level signature covers. Producers prepend the 25-byte UTF-8 domain
|
|
10
|
+
* prefix `cardano-poe-record-sig-v1` before invoking Ed25519 (the crypto-core
|
|
11
|
+
* helper `buildLabel309SigStructure` handles the prefix and the
|
|
12
|
+
* `Sig_structure` wrapping). Extension keys are part of the signed body and
|
|
13
|
+
* pass through verbatim.
|
|
14
|
+
*/
|
|
5
15
|
declare function encodeRecordBodyForSigning(record: PoeRecord): Uint8Array;
|
|
6
16
|
|
|
7
17
|
export { encodePoeRecord, encodeRecordBodyForSigning };
|
package/dist/encoder.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { PoeRecord } from './schema.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
|
|
4
|
+
/** Canonical CBOR bytes of the full record body — the bytes the chunk-array
|
|
5
|
+
* transport carries on chain (see `carriage.ts`). */
|
|
4
6
|
declare function encodePoeRecord(record: PoeRecord): Uint8Array;
|
|
7
|
+
/**
|
|
8
|
+
* Canonical CBOR bytes of the record body **with `sigs` removed** — the body
|
|
9
|
+
* a record-level signature covers. Producers prepend the 25-byte UTF-8 domain
|
|
10
|
+
* prefix `cardano-poe-record-sig-v1` before invoking Ed25519 (the crypto-core
|
|
11
|
+
* helper `buildLabel309SigStructure` handles the prefix and the
|
|
12
|
+
* `Sig_structure` wrapping). Extension keys are part of the signed body and
|
|
13
|
+
* pass through verbatim.
|
|
14
|
+
*/
|
|
5
15
|
declare function encodeRecordBodyForSigning(record: PoeRecord): Uint8Array;
|
|
6
16
|
|
|
7
17
|
export { encodePoeRecord, encodeRecordBodyForSigning };
|
package/dist/encoder.js
CHANGED
|
@@ -1592,95 +1592,47 @@ function encodeCanonicalCbor(value) {
|
|
|
1592
1592
|
|
|
1593
1593
|
// src/encoder.ts
|
|
1594
1594
|
function encodePoeRecord(record) {
|
|
1595
|
-
return encodeCanonicalCbor(
|
|
1596
|
-
}
|
|
1597
|
-
function encodeRecordBodyForSigning(record) {
|
|
1598
|
-
const body = recordToCborInternal(
|
|
1595
|
+
return encodeCanonicalCbor(toCborValue(
|
|
1599
1596
|
record,
|
|
1600
1597
|
/* includeSigs */
|
|
1601
|
-
|
|
1602
|
-
);
|
|
1603
|
-
return encodeCanonicalCbor(body);
|
|
1598
|
+
true
|
|
1599
|
+
));
|
|
1604
1600
|
}
|
|
1605
|
-
function
|
|
1606
|
-
return
|
|
1601
|
+
function encodeRecordBodyForSigning(record) {
|
|
1602
|
+
return encodeCanonicalCbor(toCborValue(
|
|
1607
1603
|
record,
|
|
1608
1604
|
/* includeSigs */
|
|
1609
|
-
|
|
1610
|
-
);
|
|
1611
|
-
}
|
|
1612
|
-
function recordToCborInternal(record, includeSigs) {
|
|
1613
|
-
const out = { v: record.v };
|
|
1614
|
-
if (record.items !== void 0) out["items"] = record.items.map(itemToCbor);
|
|
1615
|
-
if (record.merkle !== void 0) out["merkle"] = record.merkle.map(merkleToCbor);
|
|
1616
|
-
if (record.supersedes !== void 0) out["supersedes"] = record.supersedes;
|
|
1617
|
-
if (includeSigs && record.sigs !== void 0) out["sigs"] = record.sigs.map(sigEntryToCbor);
|
|
1618
|
-
if (record.crit !== void 0) out["crit"] = record.crit.slice();
|
|
1619
|
-
for (const [k4, v3] of Object.entries(record)) {
|
|
1620
|
-
if (k4 === "v" || k4 === "items" || k4 === "merkle" || k4 === "supersedes" || k4 === "sigs" || k4 === "crit") {
|
|
1621
|
-
continue;
|
|
1622
|
-
}
|
|
1623
|
-
out[k4] = v3;
|
|
1624
|
-
}
|
|
1625
|
-
return out;
|
|
1626
|
-
}
|
|
1627
|
-
function itemToCbor(item) {
|
|
1628
|
-
const out = { hashes: hashesToCbor(item.hashes) };
|
|
1629
|
-
if (item.uris !== void 0) {
|
|
1630
|
-
out["uris"] = item.uris.map((chunks) => chunks.slice());
|
|
1631
|
-
}
|
|
1632
|
-
if (item.enc !== void 0) {
|
|
1633
|
-
out["enc"] = envelopeToCbor(item.enc);
|
|
1634
|
-
}
|
|
1635
|
-
return out;
|
|
1605
|
+
false
|
|
1606
|
+
));
|
|
1636
1607
|
}
|
|
1637
|
-
function
|
|
1608
|
+
function toCborValue(record, includeSigs) {
|
|
1638
1609
|
const out = {};
|
|
1639
|
-
for (const [
|
|
1640
|
-
|
|
1610
|
+
for (const [key, value] of Object.entries(record)) {
|
|
1611
|
+
if (value === void 0) continue;
|
|
1612
|
+
if (!includeSigs && key === "sigs") continue;
|
|
1613
|
+
out[key] = stripUndefined(value);
|
|
1641
1614
|
}
|
|
1642
1615
|
return out;
|
|
1643
1616
|
}
|
|
1644
|
-
function
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
root: commit.root,
|
|
1648
|
-
leaf_count: commit.leaf_count
|
|
1649
|
-
};
|
|
1650
|
-
if (commit.uris !== void 0) {
|
|
1651
|
-
out["uris"] = commit.uris.map((chunks) => chunks.slice());
|
|
1617
|
+
function stripUndefined(value) {
|
|
1618
|
+
if (value === null || typeof value !== "object" || value instanceof Uint8Array) {
|
|
1619
|
+
return value;
|
|
1652
1620
|
}
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
function envelopeToCbor(enc) {
|
|
1656
|
-
const out = {
|
|
1657
|
-
scheme: enc.scheme,
|
|
1658
|
-
aead: enc.aead,
|
|
1659
|
-
nonce: enc.nonce
|
|
1660
|
-
};
|
|
1661
|
-
if (enc.kem !== void 0) out["kem"] = enc.kem;
|
|
1662
|
-
if (enc.slots !== void 0) out["slots"] = enc.slots.map(slotToCbor);
|
|
1663
|
-
if (enc.slots_mac !== void 0) out["slots_mac"] = enc.slots_mac;
|
|
1664
|
-
if (enc.passphrase !== void 0) out["passphrase"] = passphraseToCbor(enc.passphrase);
|
|
1665
|
-
return out;
|
|
1666
|
-
}
|
|
1667
|
-
function slotToCbor(slot) {
|
|
1668
|
-
if (slot.kem_ct !== void 0) {
|
|
1669
|
-
return { kem_ct: slot.kem_ct.map((c4) => c4), wrap: slot.wrap };
|
|
1621
|
+
if (Array.isArray(value)) {
|
|
1622
|
+
return value.map((element) => stripUndefined(element));
|
|
1670
1623
|
}
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
}
|
|
1679
|
-
}
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
out["cose_key"] = entry.cose_key.map((b5) => b5);
|
|
1624
|
+
if (value instanceof Map) {
|
|
1625
|
+
const out2 = /* @__PURE__ */ new Map();
|
|
1626
|
+
for (const [k4, v3] of value) {
|
|
1627
|
+
if (v3 === void 0) continue;
|
|
1628
|
+
out2.set(k4, stripUndefined(v3));
|
|
1629
|
+
}
|
|
1630
|
+
return out2;
|
|
1631
|
+
}
|
|
1632
|
+
const out = {};
|
|
1633
|
+
for (const [k4, v3] of Object.entries(value)) {
|
|
1634
|
+
if (v3 === void 0) continue;
|
|
1635
|
+
out[k4] = stripUndefined(v3);
|
|
1684
1636
|
}
|
|
1685
1637
|
return out;
|
|
1686
1638
|
}
|