burnledger 0.9.0 → 0.10.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.
Files changed (88) hide show
  1. package/README.md +9 -4
  2. package/dist/cjs/audit-pack.d.ts +201 -0
  3. package/dist/cjs/audit-pack.d.ts.map +1 -0
  4. package/dist/cjs/audit-pack.js +867 -0
  5. package/dist/cjs/audit-pack.js.map +1 -0
  6. package/dist/cjs/client.d.ts +41 -1
  7. package/dist/cjs/client.d.ts.map +1 -1
  8. package/dist/cjs/client.js +107 -59
  9. package/dist/cjs/client.js.map +1 -1
  10. package/dist/cjs/enclave-registration.d.ts +14 -2
  11. package/dist/cjs/enclave-registration.d.ts.map +1 -1
  12. package/dist/cjs/enclave-registration.js +14 -2
  13. package/dist/cjs/enclave-registration.js.map +1 -1
  14. package/dist/cjs/index.d.ts +46 -2
  15. package/dist/cjs/index.d.ts.map +1 -1
  16. package/dist/cjs/index.js +114 -2
  17. package/dist/cjs/index.js.map +1 -1
  18. package/dist/cjs/models.d.ts +28 -2
  19. package/dist/cjs/models.d.ts.map +1 -1
  20. package/dist/cjs/models.js +19 -1
  21. package/dist/cjs/models.js.map +1 -1
  22. package/dist/cjs/node-runtime.d.ts +40 -0
  23. package/dist/cjs/node-runtime.d.ts.map +1 -0
  24. package/dist/cjs/node-runtime.js +42 -0
  25. package/dist/cjs/node-runtime.js.map +1 -0
  26. package/dist/cjs/run-record.d.ts +130 -0
  27. package/dist/cjs/run-record.d.ts.map +1 -0
  28. package/dist/cjs/run-record.js +272 -0
  29. package/dist/cjs/run-record.js.map +1 -0
  30. package/dist/cjs/verify.d.ts +58 -0
  31. package/dist/cjs/verify.d.ts.map +1 -1
  32. package/dist/cjs/verify.js +277 -38
  33. package/dist/cjs/verify.js.map +1 -1
  34. package/dist/cjs/webhooks.d.ts +9 -2
  35. package/dist/cjs/webhooks.d.ts.map +1 -1
  36. package/dist/cjs/webhooks.js +29 -11
  37. package/dist/cjs/webhooks.js.map +1 -1
  38. package/dist/esm/audit-pack.d.ts +201 -0
  39. package/dist/esm/audit-pack.d.ts.map +1 -0
  40. package/dist/esm/audit-pack.js +858 -0
  41. package/dist/esm/audit-pack.js.map +1 -0
  42. package/dist/esm/cli.d.ts +52 -0
  43. package/dist/esm/cli.d.ts.map +1 -1
  44. package/dist/esm/cli.js +283 -11
  45. package/dist/esm/cli.js.map +1 -1
  46. package/dist/esm/client.d.ts +41 -1
  47. package/dist/esm/client.d.ts.map +1 -1
  48. package/dist/esm/client.js +108 -27
  49. package/dist/esm/client.js.map +1 -1
  50. package/dist/esm/enclave-registration.d.ts +14 -2
  51. package/dist/esm/enclave-registration.d.ts.map +1 -1
  52. package/dist/esm/enclave-registration.js +14 -2
  53. package/dist/esm/enclave-registration.js.map +1 -1
  54. package/dist/esm/index.d.ts +46 -2
  55. package/dist/esm/index.d.ts.map +1 -1
  56. package/dist/esm/index.js +64 -1
  57. package/dist/esm/index.js.map +1 -1
  58. package/dist/esm/models.d.ts +28 -2
  59. package/dist/esm/models.d.ts.map +1 -1
  60. package/dist/esm/models.js +18 -1
  61. package/dist/esm/models.js.map +1 -1
  62. package/dist/esm/node-runtime.d.ts +40 -0
  63. package/dist/esm/node-runtime.d.ts.map +1 -0
  64. package/dist/esm/node-runtime.js +38 -0
  65. package/dist/esm/node-runtime.js.map +1 -0
  66. package/dist/esm/run-record.d.ts +130 -0
  67. package/dist/esm/run-record.d.ts.map +1 -0
  68. package/dist/esm/run-record.js +262 -0
  69. package/dist/esm/run-record.js.map +1 -0
  70. package/dist/esm/verify.d.ts +58 -0
  71. package/dist/esm/verify.d.ts.map +1 -1
  72. package/dist/esm/verify.js +270 -41
  73. package/dist/esm/verify.js.map +1 -1
  74. package/dist/esm/webhooks.d.ts +9 -2
  75. package/dist/esm/webhooks.d.ts.map +1 -1
  76. package/dist/esm/webhooks.js +29 -11
  77. package/dist/esm/webhooks.js.map +1 -1
  78. package/package.json +1 -1
  79. package/src/audit-pack.ts +1067 -0
  80. package/src/cli.ts +289 -10
  81. package/src/client.ts +132 -27
  82. package/src/enclave-registration.ts +14 -2
  83. package/src/index.ts +130 -1
  84. package/src/models.ts +47 -3
  85. package/src/node-runtime.ts +57 -0
  86. package/src/run-record.ts +371 -0
  87. package/src/verify.ts +301 -41
  88. package/src/webhooks.ts +28 -11
@@ -0,0 +1,130 @@
1
+ /** The run record (docs/run-record.md, ADR-031 option C).
2
+ *
3
+ * A port of core/run_record.go, verdict for verdict. A run is one bulk
4
+ * deletion cycle; the run record is the enclave's signed word on it — what the
5
+ * customer declared the input list to be, what the enclave actually issued
6
+ * under the run, and when it opened and closed. Held beside every record of
7
+ * the run (an audit pack filtered by run_id, every page of it), it lets a
8
+ * reader establish that the records are exactly what was issued, how many
9
+ * listed subjects have no record, and whether the run closed in time.
10
+ *
11
+ * What it does not establish is that the list was the regulator's list: the
12
+ * enclave never sees the list, and list_digest and list_count are the
13
+ * customer's assertion, signed and dated here rather than implicit.
14
+ */
15
+ import type { CryptoOps } from "./crypto.js";
16
+ import { type PublicKeyInfo } from "./verify.js";
17
+ /** The domain-separation tag of a run record. */
18
+ export declare const PAYLOAD_TYPE_RUN_RECORD = "burnledger.run_record.v1";
19
+ /** What a run was: a regulator's bulk cycle or a customer's own sweep. Carried
20
+ * signed, so an auditor reads what the customer claimed the run to be rather
21
+ * than inferring it from a date. */
22
+ export type RunKind = "drop_cycle" | "bulk_erasure";
23
+ export declare const NIL_UUID = "00000000-0000-0000-0000-000000000000";
24
+ /** Mirrors core.RunRecord, as GET /v1/runs/{id} serves it under `record` and
25
+ * an audit pack carries it in its header. UUIDs are canonical lowercase,
26
+ * timestamps whole-second UTC, exactly as the payload signs them. */
27
+ export interface RunRecord {
28
+ runId: string;
29
+ runKind: string;
30
+ /** Signed, so a run record cannot be presented as another team's. */
31
+ teamId: string;
32
+ /** The customer's assertion about the input list: SHA-256 over its canonical
33
+ * form (one normalized identifier per line, sorted, LF-terminated), and how
34
+ * many entries it had. 32 bytes. */
35
+ listDigest: Uint8Array;
36
+ listCount: number;
37
+ /** Merkle root and count over the DISTINCT subject hashes the enclave issued
38
+ * records for under this run, leaves sorted. Computed by the enclave, never
39
+ * asserted. 32 bytes. */
40
+ subjectsRoot: Uint8Array;
41
+ subjectsCount: number;
42
+ /** Merkle root and count over the certificate ids issued under this run,
43
+ * leaves sorted. A run with no records has zero roots and zero counts. */
44
+ recordsRoot: Uint8Array;
45
+ recordsCount: number;
46
+ /** The systems every record in the run covered. */
47
+ systemIds: string[];
48
+ openedAt: string;
49
+ closedAt: string;
50
+ /** The customer-declared deadline, so "on time" is checkable against closedAt. */
51
+ notAfter: string;
52
+ issuer: {
53
+ keyId: string;
54
+ enclavePcr0: string;
55
+ };
56
+ /** 64 bytes. */
57
+ signature: Uint8Array;
58
+ transparencyStatus: string;
59
+ /** The record's own inclusion proof once it is in the log, in the shape a
60
+ * certificate's takes. Outside the signature, as on a certificate. */
61
+ transparency?: Record<string, unknown>;
62
+ }
63
+ /** What a verifier learns about a run record's signature (core.RunRecordResult). */
64
+ export type RunRecordResult = "VALID" | "MALFORMED_RUN_RECORD" | "UNKNOWN_KEY" | "KEY_UNUSABLE" | "INVALID_RUN_RECORD_SIGNATURE";
65
+ /** Mirrors core.RunCheck: what a reader learns by holding a run record beside
66
+ * the records issued under it. */
67
+ export interface RunCheck {
68
+ /** The certificate ids reproduce records_root and records_count. */
69
+ recordsMatch: boolean;
70
+ /** The subject hashes reproduce subjects_root and subjects_count. */
71
+ subjectsMatch: boolean;
72
+ /** listCount minus subjectsCount: how many listed subjects have no record in
73
+ * the run. Zero is the number an auditor wants. */
74
+ listShortfall: number;
75
+ /** closedAt <= notAfter. */
76
+ closedInTime: boolean;
77
+ /** Records whose own signed run_id (format 10.0 and later) names a different
78
+ * run, or no run, while the pack presents them as this run's. A record
79
+ * without the field (older formats) is neither counted nor refused: it says
80
+ * nothing about its run, and the roots are what bind it. */
81
+ mislabelled: number;
82
+ }
83
+ /** What checkRunAgainstRecords needs from one record of the run. */
84
+ export interface RunCheckRecord {
85
+ certificateId: string;
86
+ /** subject.identifier_hash, 32 bytes. */
87
+ subjectHash: Uint8Array;
88
+ /** The record's own signed run_id, when it carries one. */
89
+ runId?: string;
90
+ formatVersion?: string;
91
+ }
92
+ /** Read a run record as served, refusing what Go's ParseRunRecordDocument and
93
+ * the unmarshal behind it refuse. Throws a VerificationError naming the field. */
94
+ export declare function parseRunRecordDocument(doc: unknown): RunRecord;
95
+ /** The canonical signing payload. Every signed field is present; the system
96
+ * ids are sorted so two records over the same set sign the same bytes. Mirrors
97
+ * core.BuildRunRecordPayload, including its refusal of an unknown run_kind. */
98
+ export declare function buildRunRecordPayload(r: RunRecord): Uint8Array;
99
+ /** Checks the record's signature against the reader's keys, in the order every
100
+ * verifier uses: the shape, the key's authority at the record's own close
101
+ * instant, then the signature. Mirrors core.VerifyRunRecord. */
102
+ export declare function verifyRunRecord(crypto: CryptoOps, r: RunRecord, keys: Map<string, PublicKeyInfo>): Promise<RunRecordResult>;
103
+ /** What the run record's log leaf commits to: the SHA-256 of its canonical
104
+ * payload. A certificate leaf hashes the whole document less its transparency
105
+ * block; a run record's payload already is the whole signed document. */
106
+ export declare function runRecordHash(crypto: CryptoOps, r: RunRecord): Promise<Uint8Array>;
107
+ /** Checks the record's own transparency proof the way a certificate's is
108
+ * checked, under core.TransparencyResult's names: NOT_INCLUDED when it carries
109
+ * none, INVALID_INCLUSION_PROOF for a leaf that is not a RUN_RECORD leaf,
110
+ * UNREADABLE_DOCUMENT where the leaf cannot be built. Mirrors
111
+ * core.VerifyRunRecordInclusion. */
112
+ export declare function verifyRunRecordInclusion(crypto: CryptoOps, r: RunRecord, key: PublicKeyInfo): Promise<string>;
113
+ /** What a run record commits to, from what was issued under it. Subjects are
114
+ * de-duplicated — a subject certified twice in one run is one subject — and
115
+ * both leaf sets are sorted, so the roots do not depend on issuance order and a
116
+ * verifier can reproduce them from a pack in any order. A subject leaf is its
117
+ * 32-byte hash and a record leaf the certificate id's 16 bytes, both through
118
+ * the RFC 6962 leaf hash. Mirrors core.RunRoots. */
119
+ export declare function runRoots(crypto: CryptoOps, subjects: Uint8Array[], certificateIds: string[]): Promise<{
120
+ subjectsRoot: Uint8Array;
121
+ subjectsCount: number;
122
+ recordsRoot: Uint8Array;
123
+ recordsCount: number;
124
+ }>;
125
+ /** Reproduces the run record's roots from the records a reader holds and
126
+ * compares them. The reader must hold every record of the run — a complete
127
+ * chain of pack pages filtered by the run — or the roots cannot match, which
128
+ * is the honest answer for a partial set. Mirrors core.CheckRunAgainstRecords. */
129
+ export declare function checkRunAgainstRecords(crypto: CryptoOps, r: RunRecord, records: RunCheckRecord[]): Promise<RunCheck>;
130
+ //# sourceMappingURL=run-record.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-record.d.ts","sourceRoot":"","sources":["../../src/run-record.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAgBL,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAErB,iDAAiD;AACjD,eAAO,MAAM,uBAAuB,6BAA6B,CAAC;AAElE;;oCAEoC;AACpC,MAAM,MAAM,OAAO,GAAG,YAAY,GAAG,cAAc,CAAC;AAIpD,eAAO,MAAM,QAAQ,yCAAyC,CAAC;AAE/D;;qEAEqE;AACrE,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,MAAM,EAAE,MAAM,CAAC;IACf;;wCAEoC;IACpC,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB;;6BAEyB;IACzB,YAAY,EAAE,UAAU,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB;8EAC0E;IAC1E,WAAW,EAAE,UAAU,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,mDAAmD;I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Z,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,GAC/B,OAAO,CAAC,eAAe,CAAC,CAW1B;AAED;;yEAEyE;AACzE,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAElF;AAED;;;;oCAIoC;AACpC,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,SAAS,EACjB,CAAC,EAAE,SAAS,EACZ,GAAG,EAAE,aAAa,GACjB,OAAO,CAAC,MAAM,CAAC,CAoBjB;AAiBD;;;;;oDAKoD;AACpD,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,UAAU,EAAE,EACtB,cAAc,EAAE,MAAM,EAAE,GACvB,OAAO,CAAC;IAAE,YAAY,EAAE,UAAU,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,UAAU,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,CAiB7G;AAMD;;;kFAGkF;AAClF,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,SAAS,EACjB,CAAC,EAAE,SAAS,EACZ,OAAO,EAAE,cAAc,EAAE,GACxB,OAAO,CAAC,QAAQ,CAAC,CAgBnB"}
@@ -0,0 +1,272 @@
1
+ "use strict";
2
+ /** The run record (docs/run-record.md, ADR-031 option C).
3
+ *
4
+ * A port of core/run_record.go, verdict for verdict. A run is one bulk
5
+ * deletion cycle; the run record is the enclave's signed word on it — what the
6
+ * customer declared the input list to be, what the enclave actually issued
7
+ * under the run, and when it opened and closed. Held beside every record of
8
+ * the run (an audit pack filtered by run_id, every page of it), it lets a
9
+ * reader establish that the records are exactly what was issued, how many
10
+ * listed subjects have no record, and whether the run closed in time.
11
+ *
12
+ * What it does not establish is that the list was the regulator's list: the
13
+ * enclave never sees the list, and list_digest and list_count are the
14
+ * customer's assertion, signed and dated here rather than implicit.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.NIL_UUID = exports.PAYLOAD_TYPE_RUN_RECORD = void 0;
18
+ exports.parseRunRecordDocument = parseRunRecordDocument;
19
+ exports.buildRunRecordPayload = buildRunRecordPayload;
20
+ exports.verifyRunRecord = verifyRunRecord;
21
+ exports.runRecordHash = runRecordHash;
22
+ exports.verifyRunRecordInclusion = verifyRunRecordInclusion;
23
+ exports.runRoots = runRoots;
24
+ exports.checkRunAgainstRecords = checkRunAgainstRecords;
25
+ const errors_js_1 = require("./errors.js");
26
+ const verify_js_1 = require("./verify.js");
27
+ /** The domain-separation tag of a run record. */
28
+ exports.PAYLOAD_TYPE_RUN_RECORD = "burnledger.run_record.v1";
29
+ const RUN_KINDS = new Set(["drop_cycle", "bulk_erasure"]);
30
+ exports.NIL_UUID = "00000000-0000-0000-0000-000000000000";
31
+ function isObject(v) {
32
+ return v !== null && typeof v === "object" && !Array.isArray(v);
33
+ }
34
+ /** A UUID field as Go's uuid.UUID unmarshals it: null or absent is the nil
35
+ * UUID (encoding/json leaves the zero value), a string in any form uuid.Parse
36
+ * reads is canonical, anything else fails the document. */
37
+ function uuidOrNil(v, path) {
38
+ if (v === null || v === undefined)
39
+ return exports.NIL_UUID;
40
+ if (typeof v !== "string")
41
+ throw new errors_js_1.VerificationError(`${path} is not a string`);
42
+ try {
43
+ return (0, verify_js_1.formatUuid)((0, verify_js_1.parseUuid)(v));
44
+ }
45
+ catch (e) {
46
+ if (e instanceof TypeError)
47
+ throw new errors_js_1.VerificationError(`${path} is not a UUID: ${JSON.stringify(v)}`);
48
+ throw e;
49
+ }
50
+ }
51
+ /** A fixed byte array as Go's [N]byte unmarshals it: null or absent is all
52
+ * zero, anything else must be exactly N bytes. */
53
+ function bytesOrZero(v, path, length) {
54
+ if (v === null || v === undefined)
55
+ return new Uint8Array(length);
56
+ return (0, verify_js_1.decodeFixed)(v, path, length);
57
+ }
58
+ /** A count as Go's uint64 unmarshals it: null or absent is 0, and a fraction
59
+ * or a negative fails the document. */
60
+ function countOrZero(v, path) {
61
+ if (v === null || v === undefined)
62
+ return 0;
63
+ if (typeof v !== "number" || !Number.isSafeInteger(v) || v < 0) {
64
+ throw new errors_js_1.VerificationError(`${path} is not a non-negative integer: ${JSON.stringify(v)}`);
65
+ }
66
+ return v;
67
+ }
68
+ function stringOrEmpty(v, path) {
69
+ if (v === null || v === undefined)
70
+ return "";
71
+ if (typeof v !== "string")
72
+ throw new errors_js_1.VerificationError(`${path} is not a string`);
73
+ return v;
74
+ }
75
+ /** Read a run record as served, refusing what Go's ParseRunRecordDocument and
76
+ * the unmarshal behind it refuse. Throws a VerificationError naming the field. */
77
+ function parseRunRecordDocument(doc) {
78
+ if (!isObject(doc))
79
+ throw new errors_js_1.VerificationError("run record: not a JSON object");
80
+ const rawIssuer = doc.issuer;
81
+ if (rawIssuer !== null && rawIssuer !== undefined && !isObject(rawIssuer)) {
82
+ throw new errors_js_1.VerificationError("issuer is not an object");
83
+ }
84
+ const issuer = isObject(rawIssuer) ? rawIssuer : {};
85
+ const rawSystems = doc.system_ids;
86
+ let systemIds = [];
87
+ if (rawSystems !== null && rawSystems !== undefined) {
88
+ if (!Array.isArray(rawSystems))
89
+ throw new errors_js_1.VerificationError("system_ids is not an array");
90
+ systemIds = rawSystems.map((v, i) => uuidOrNil(v, `system_ids[${i}]`));
91
+ }
92
+ const record = {
93
+ runId: uuidOrNil(doc.run_id, "run_id"),
94
+ runKind: stringOrEmpty(doc.run_kind, "run_kind"),
95
+ teamId: uuidOrNil(doc.team_id, "team_id"),
96
+ listDigest: bytesOrZero(doc.list_digest, "list_digest", 32),
97
+ listCount: countOrZero(doc.list_count, "list_count"),
98
+ subjectsRoot: bytesOrZero(doc.subjects_root, "subjects_root", 32),
99
+ subjectsCount: countOrZero(doc.subjects_count, "subjects_count"),
100
+ recordsRoot: bytesOrZero(doc.records_root, "records_root", 32),
101
+ recordsCount: countOrZero(doc.records_count, "records_count"),
102
+ systemIds,
103
+ openedAt: (0, verify_js_1.formatTimestamp)(doc.opened_at, "opened_at"),
104
+ closedAt: (0, verify_js_1.formatTimestamp)(doc.closed_at, "closed_at"),
105
+ notAfter: (0, verify_js_1.formatTimestamp)(doc.not_after, "not_after"),
106
+ issuer: {
107
+ keyId: stringOrEmpty(issuer.key_id, "issuer.key_id"),
108
+ enclavePcr0: stringOrEmpty(issuer.enclave_pcr0, "issuer.enclave_pcr0"),
109
+ },
110
+ signature: bytesOrZero(doc.signature, "signature", 64),
111
+ transparencyStatus: stringOrEmpty(doc.transparency_status, "transparency_status"),
112
+ };
113
+ const transparency = doc.transparency;
114
+ if (transparency !== null && transparency !== undefined) {
115
+ if (!isObject(transparency))
116
+ throw new errors_js_1.VerificationError("transparency is not an object");
117
+ record.transparency = transparency;
118
+ }
119
+ return record;
120
+ }
121
+ /** The canonical signing payload. Every signed field is present; the system
122
+ * ids are sorted so two records over the same set sign the same bytes. Mirrors
123
+ * core.BuildRunRecordPayload, including its refusal of an unknown run_kind. */
124
+ function buildRunRecordPayload(r) {
125
+ if (!RUN_KINDS.has(r.runKind)) {
126
+ throw new errors_js_1.VerificationError(`run record: unknown run_kind ${r.runKind}`);
127
+ }
128
+ return (0, verify_js_1.canonicalJson)({
129
+ payload_type: exports.PAYLOAD_TYPE_RUN_RECORD,
130
+ closed_at: (0, verify_js_1.formatTimestamp)(r.closedAt, "closed_at"),
131
+ enclave_pcr0: r.issuer.enclavePcr0,
132
+ key_id: r.issuer.keyId,
133
+ list_count: r.listCount,
134
+ list_digest: (0, verify_js_1.bytesToHex)(r.listDigest),
135
+ not_after: (0, verify_js_1.formatTimestamp)(r.notAfter, "not_after"),
136
+ opened_at: (0, verify_js_1.formatTimestamp)(r.openedAt, "opened_at"),
137
+ records_count: r.recordsCount,
138
+ records_root: (0, verify_js_1.bytesToHex)(r.recordsRoot),
139
+ run_id: r.runId,
140
+ run_kind: r.runKind,
141
+ subjects_count: r.subjectsCount,
142
+ subjects_root: (0, verify_js_1.bytesToHex)(r.subjectsRoot),
143
+ system_ids: [...r.systemIds].sort(),
144
+ team_id: r.teamId,
145
+ });
146
+ }
147
+ function epochSeconds(rfc3339, field) {
148
+ return Math.floor(Date.parse((0, verify_js_1.formatTimestamp)(rfc3339, field)) / 1000);
149
+ }
150
+ /** Checks the record's signature against the reader's keys, in the order every
151
+ * verifier uses: the shape, the key's authority at the record's own close
152
+ * instant, then the signature. Mirrors core.VerifyRunRecord. */
153
+ async function verifyRunRecord(crypto, r, keys) {
154
+ const closedAt = epochSeconds(r.closedAt, "closed_at");
155
+ if (!RUN_KINDS.has(r.runKind) || r.runId === exports.NIL_UUID || closedAt < epochSeconds(r.openedAt, "opened_at")) {
156
+ return "MALFORMED_RUN_RECORD";
157
+ }
158
+ const key = keys.get(r.issuer.keyId);
159
+ if (key === undefined)
160
+ return "UNKNOWN_KEY";
161
+ if (!(0, verify_js_1.keyIsUsable)((0, verify_js_1.evaluateKey)(key, closedAt)))
162
+ return "KEY_UNUSABLE";
163
+ const payload = buildRunRecordPayload(r);
164
+ if (!(await crypto.ed25519Verify(key.keyBytes, payload, r.signature)))
165
+ return "INVALID_RUN_RECORD_SIGNATURE";
166
+ return "VALID";
167
+ }
168
+ /** What the run record's log leaf commits to: the SHA-256 of its canonical
169
+ * payload. A certificate leaf hashes the whole document less its transparency
170
+ * block; a run record's payload already is the whole signed document. */
171
+ function runRecordHash(crypto, r) {
172
+ return crypto.sha256(buildRunRecordPayload(r));
173
+ }
174
+ /** Checks the record's own transparency proof the way a certificate's is
175
+ * checked, under core.TransparencyResult's names: NOT_INCLUDED when it carries
176
+ * none, INVALID_INCLUSION_PROOF for a leaf that is not a RUN_RECORD leaf,
177
+ * UNREADABLE_DOCUMENT where the leaf cannot be built. Mirrors
178
+ * core.VerifyRunRecordInclusion. */
179
+ async function verifyRunRecordInclusion(crypto, r, key) {
180
+ const transparency = r.transparency;
181
+ if (transparency === undefined)
182
+ return "NOT_INCLUDED";
183
+ if (transparency.entry_type !== "RUN_RECORD")
184
+ return "INVALID_INCLUSION_PROOF";
185
+ let leaf;
186
+ try {
187
+ const payload = (0, verify_js_1.buildLogLeafPayload)("RUN_RECORD", r.runId, await runRecordHash(crypto, r), transparency.appended_at);
188
+ leaf = await (0, verify_js_1.hashLeaf)(crypto, payload);
189
+ }
190
+ catch (e) {
191
+ if (e instanceof errors_js_1.VerificationError)
192
+ return "UNREADABLE_DOCUMENT";
193
+ throw e;
194
+ }
195
+ try {
196
+ await (0, verify_js_1.verifyTransparencyHead)(crypto, transparency, key, r.issuer.keyId);
197
+ await (0, verify_js_1.verifyTransparencyInclusion)(crypto, transparency, leaf);
198
+ }
199
+ catch (e) {
200
+ if (e instanceof errors_js_1.VerificationError)
201
+ return (0, verify_js_1.transparencyVerdictName)(e);
202
+ throw e;
203
+ }
204
+ return "VALID";
205
+ }
206
+ function compareBytes(a, b) {
207
+ const n = Math.min(a.length, b.length);
208
+ for (let i = 0; i < n; i++) {
209
+ if (a[i] !== b[i])
210
+ return a[i] - b[i];
211
+ }
212
+ return a.length - b.length;
213
+ }
214
+ /** The root over a leaf set the way a run record commits to one: leaves
215
+ * sorted bytewise, and 32 zero bytes for the empty set. */
216
+ async function sortedRoot(crypto, leaves) {
217
+ if (leaves.length === 0)
218
+ return new Uint8Array(32);
219
+ return (0, verify_js_1.merkleRoot)(crypto, [...leaves].sort(compareBytes));
220
+ }
221
+ /** What a run record commits to, from what was issued under it. Subjects are
222
+ * de-duplicated — a subject certified twice in one run is one subject — and
223
+ * both leaf sets are sorted, so the roots do not depend on issuance order and a
224
+ * verifier can reproduce them from a pack in any order. A subject leaf is its
225
+ * 32-byte hash and a record leaf the certificate id's 16 bytes, both through
226
+ * the RFC 6962 leaf hash. Mirrors core.RunRoots. */
227
+ async function runRoots(crypto, subjects, certificateIds) {
228
+ const seen = new Set();
229
+ const subjectLeaves = [];
230
+ for (const s of subjects) {
231
+ const key = (0, verify_js_1.bytesToHex)(s);
232
+ if (seen.has(key))
233
+ continue;
234
+ seen.add(key);
235
+ subjectLeaves.push(await (0, verify_js_1.hashLeaf)(crypto, s));
236
+ }
237
+ const recordLeaves = [];
238
+ for (const id of certificateIds)
239
+ recordLeaves.push(await (0, verify_js_1.hashLeaf)(crypto, (0, verify_js_1.parseUuid)(id)));
240
+ return {
241
+ subjectsRoot: await sortedRoot(crypto, subjectLeaves),
242
+ subjectsCount: subjectLeaves.length,
243
+ recordsRoot: await sortedRoot(crypto, recordLeaves),
244
+ recordsCount: recordLeaves.length,
245
+ };
246
+ }
247
+ function bytesEqual(a, b) {
248
+ return compareBytes(a, b) === 0;
249
+ }
250
+ /** Reproduces the run record's roots from the records a reader holds and
251
+ * compares them. The reader must hold every record of the run — a complete
252
+ * chain of pack pages filtered by the run — or the roots cannot match, which
253
+ * is the honest answer for a partial set. Mirrors core.CheckRunAgainstRecords. */
254
+ async function checkRunAgainstRecords(crypto, r, records) {
255
+ let mislabelled = 0;
256
+ for (const rec of records) {
257
+ if (rec.runId !== undefined && rec.runId !== r.runId)
258
+ mislabelled++;
259
+ if (rec.runId === undefined && rec.formatVersion !== undefined && (0, verify_js_1.signatureCoversRunId)(rec.formatVersion)) {
260
+ mislabelled++;
261
+ }
262
+ }
263
+ const roots = await runRoots(crypto, records.map((rec) => rec.subjectHash), records.map((rec) => rec.certificateId));
264
+ return {
265
+ recordsMatch: bytesEqual(roots.recordsRoot, r.recordsRoot) && roots.recordsCount === r.recordsCount,
266
+ subjectsMatch: bytesEqual(roots.subjectsRoot, r.subjectsRoot) && roots.subjectsCount === r.subjectsCount,
267
+ listShortfall: r.listCount - r.subjectsCount,
268
+ closedInTime: epochSeconds(r.closedAt, "closed_at") <= epochSeconds(r.notAfter, "not_after"),
269
+ mislabelled,
270
+ };
271
+ }
272
+ //# sourceMappingURL=run-record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-record.js","sourceRoot":"","sources":["../../src/run-record.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;;;;;;AAGH,2CAAgD;AAChD,2CAiB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AAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;IACrH,OAAO;QACL,YAAY,EAAE,UAAU,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,YAAY,KAAK,CAAC,CAAC,YAAY;QACnG,aAAa,EAAE,UAAU,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC,aAAa,KAAK,CAAC,CAAC,aAAa;QACxG,aAAa,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,aAAa;QAC5C,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,QAAQ,EAAE,WAAW,CAAC;QAC5F,WAAW;KACZ,CAAC;AACJ,CAAC"}
@@ -16,6 +16,7 @@
16
16
  * output at issuance time (transparency_status=PENDING, no transparency).
17
17
  */
18
18
  import type { CryptoOps } from "./crypto.js";
19
+ import { VerificationError } from "./errors.js";
19
20
  import type { TransparencyResult, VerificationResult } from "./models.js";
20
21
  /**
21
22
  * Every format this build can read, oldest first. Mirrors core.FormatVersions()
@@ -28,6 +29,17 @@ import type { TransparencyResult, VerificationResult } from "./models.js";
28
29
  * script on the page could otherwise push a version onto it.
29
30
  */
30
31
  export declare const KNOWN_FORMAT_VERSIONS: readonly string[];
32
+ /**
33
+ * Does this format sign the top-level run_id (ADR-031)?
34
+ *
35
+ * v10 onward, and optional even there: a record issued outside a run has none.
36
+ * A record OLDER than v10 that carries one is refused outright rather than
37
+ * signed without it — the field would ride in the JSON beside a signature that
38
+ * says nothing about it. Exported for the audit pack verifier, which asks the
39
+ * same question of a record that carries none: below v10 that says nothing
40
+ * about its run, from v10 it says the record was issued under no run.
41
+ */
42
+ export declare function signatureCoversRunId(version: string): boolean;
31
43
  /** Decode hex: whole bytes, digits in either case, nothing else. Anything else
32
44
  * throws TypeError. It is exported, so its input is a boundary: reading a stray
33
45
  * character as 0, as it once did, turned a typo into different bytes. */
@@ -199,6 +211,18 @@ export declare function registrationQualifier(image: IssuingImage): string;
199
211
  export declare function verifyCertificate(crypto: CryptoOps, certificate: Cert, publicKeys: Map<string, PublicKeyInfo>, options?: VerifyOptions): Promise<VerificationResult>;
200
212
  /** Verify the transparency proof embedded in a certificate. */
201
213
  export declare function verifyTransparency(crypto: CryptoOps, certificate: Cert, publicKeys: Map<string, PublicKeyInfo>): Promise<TransparencyResult>;
214
+ /** The first half of a transparency check, shared with the run record's
215
+ * (run-record.ts): the key's authority at the head's own timestamp, then the
216
+ * head's signature. The tree head carries its own timestamp, so this path
217
+ * always has an anchor; a timestamp that does not read leaves none, which is
218
+ * the same conservative answer as no proof at all. Throws the VerificationError
219
+ * the caller reports. Exported as an internal seam, not from index.ts. */
220
+ export declare function verifyTransparencyHead(crypto: CryptoOps, transparency: Doc, pki: PublicKeyInfo, keyId: string): Promise<void>;
221
+ /** The second half: an already-hashed leaf against the signed head, after the
222
+ * unsigned duplicates beside the proof are held to the signed copies. Throws
223
+ * the VerificationError the caller reports. Exported as an internal seam. */
224
+ export declare function verifyTransparencyInclusion(crypto: CryptoOps, transparency: Doc, leaf: Uint8Array): Promise<void>;
225
+ export declare function transparencyVerdictName(e: VerificationError): string;
202
226
  /** Reconstruct the certificate JSON as it existed at issuance time.
203
227
  *
204
228
  * At issuance: transparency_status = "PENDING", transparency = nil (omitted).
@@ -214,6 +238,30 @@ export declare function issuanceBytes(certificate: Cert): Uint8Array;
214
238
  * this and must be able to prove the two agree. Not re-exported from index.ts,
215
239
  * so it stays off the published API. */
216
240
  export declare function canonicalJson(obj: unknown): Uint8Array;
241
+ type Doc = Record<string, unknown>;
242
+ /** The 16 bytes of a UUID, in any form Go's uuid.Parse reads. Throws TypeError
243
+ * for anything else: a UUID reaches a signed payload only as its canonical
244
+ * string, and an unreadable one must not be signed as whatever text arrived. */
245
+ export declare function parseUuid(text: string): Uint8Array;
246
+ /** The canonical lowercase 8-4-4-4-12 form, as Go's uuid.UUID.String prints:
247
+ * the only form a UUID takes inside a signed payload. */
248
+ export declare function formatUuid(bytes: Uint8Array): string;
249
+ /**
250
+ * Decode a fixed-size byte field — a hash, a key, a signature.
251
+ *
252
+ * Go marshals `[N]byte` as an array of numbers; hand-written documents carry
253
+ * hex or standard base64. A well-formed value of the right size is never
254
+ * ambiguous between the two text forms, because base64 of 32 or 64 bytes ends
255
+ * in padding hex cannot contain.
256
+ *
257
+ * Everything else is refused here, by name: a number, an array element that is
258
+ * not a byte, text that is neither encoding, the wrong length. Decoding it
259
+ * leniently instead wrapped 300 to 44 inside a Uint8Array, produced bytes no
260
+ * signature covers and blamed the signature — or threw from inside atob.
261
+ */
262
+ /** Exported for run-record.ts, whose digests and roots arrive in the same
263
+ * shapes; not published from index.ts. */
264
+ export declare function decodeFixed(value: unknown, path: string, length: number): Uint8Array;
217
265
  /** Normalize a certificate timestamp to the UTC form Go signs.
218
266
  *
219
267
  * Go builds every payload timestamp as `t.UTC().Format("2006-01-02T15:04:05Z")`
@@ -239,6 +287,10 @@ export declare function canonicalJson(obj: unknown): Uint8Array;
239
287
  * always used, for callers normalizing a time that is not a field of a document.
240
288
  */
241
289
  export declare function formatTimestamp(ts: unknown, field?: string): string;
290
+ /** Port of Go's BuildLogLeafPayload (ADR-016 §4). A RUN_RECORD leaf names its
291
+ * run id where the other two name a certificate id, under the same key
292
+ * (ADR-031). Exported for run-record.ts; not published from index.ts. */
293
+ export declare function buildLogLeafPayload(entryType: unknown, certificateId: string, certificateHash: Uint8Array, appendedAt: unknown): Uint8Array;
242
294
  /**
243
295
  * Port of Go's BuildTreeHeadPayload.
244
296
  *
@@ -253,6 +305,12 @@ export declare function formatTimestamp(ts: unknown, field?: string): string;
253
305
  * between two modules of this package, not published surface.
254
306
  */
255
307
  export declare function buildTreeHeadPayload(head: Record<string, unknown>): Uint8Array;
308
+ /** Exported for run-record.ts, whose roots are trees over these leaves. */
309
+ export declare function hashLeaf(crypto: CryptoOps, data: Uint8Array): Promise<Uint8Array>;
310
+ /** The RFC 6962 root over already-hashed leaves, in the order given. Port of
311
+ * Go's treeHash, which like it takes at least one leaf: the empty tree has no
312
+ * root here, and a caller with nothing to commit to says so itself. */
313
+ export declare function merkleRoot(crypto: CryptoOps, leaves: Uint8Array[]): Promise<Uint8Array>;
256
314
  /** Verify a Merkle consistency proof (RFC 6962 Section 2.1.4).
257
315
  *
258
316
  * Port of Go's VerifyConsistency / Python's _verify_consistency.
@@ -1 +1 @@
1
- {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/verify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAQ7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAyE1E;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAQjD,CAAC;AAqIH;;yEAEyE;AACzE,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAQlD;AAaD,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAQpD;AAoCD;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,aAAa,CAAC;AAE7D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;2DAEuD;IACvD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,qDAAqD;IACrD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM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