@charter-agreement-protocol/verifier 0.4.1 → 0.6.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/CHANGELOG.md +196 -0
- package/README.md +43 -8
- package/conformance/cases/acceptance-verify.json +1 -1
- package/conformance/cases/chain-verify.json +1 -1
- package/conformance/cases/chain-verify_profile.json +1 -0
- package/conformance/cases/charter_revision-decode.json +1 -1
- package/conformance/cases/descriptor_chain-verify.json +1 -1
- package/conformance/cases/governing_revision.json +1 -1
- package/conformance/cases/json-decode.json +1 -1
- package/conformance/cases/party_descriptor-verify.json +1 -1
- package/conformance/cases/receipt-verify.json +1 -1
- package/conformance/cases/termination-verify.json +1 -1
- package/conformance/index.json +1 -1
- package/dist/core.d.ts +49 -15
- package/dist/core.js +943 -306
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +11 -4
package/dist/core.js
CHANGED
|
@@ -6,7 +6,7 @@ const CASE_FORMAT = "charter-agreement-protocol-conformance-cases";
|
|
|
6
6
|
const REPORT_FORMAT = "charter-agreement-protocol-conformance-report";
|
|
7
7
|
const MAXIMUM_CORPUS_FILES = 64;
|
|
8
8
|
const MAXIMUM_CORPUS_BYTES = 33_554_432;
|
|
9
|
-
export const CERTIFIED_INDEX_SHA256_BASE64URL = "
|
|
9
|
+
export const CERTIFIED_INDEX_SHA256_BASE64URL = "n2Se2on9kG3cdeFMiy9OW9lKalvM_02Fmdw-XbYe-A4";
|
|
10
10
|
export const CERTIFIED_REGISTRY_DIGEST = "sha-256:u754joyHGcLCTm1LYV2s6eHauUUdDfJDwwyhbAbxvzc";
|
|
11
11
|
// The fourth certified identity — the specification digest over the spec
|
|
12
12
|
// set — is pinned in priv/release-metadata.json and enforced by the
|
|
@@ -41,6 +41,7 @@ const SEPARATORS = {
|
|
|
41
41
|
signature: "charter-agreement-protocol/signature",
|
|
42
42
|
extension_schema: "charter-agreement-protocol/extension-schema",
|
|
43
43
|
extension_registry: "charter-agreement-protocol/extension-registry",
|
|
44
|
+
signature_registry: "charter-agreement-protocol/signature-registry",
|
|
44
45
|
conformance_report: "charter-agreement-protocol/conformance-report",
|
|
45
46
|
corpus_index: "charter-agreement-protocol/corpus-index",
|
|
46
47
|
};
|
|
@@ -48,44 +49,53 @@ const SURFACES = [
|
|
|
48
49
|
"base64url.decode", "json.decode", "canonicalization.encode", "digest.hash",
|
|
49
50
|
"schema.validate", "party_descriptor.verify", "descriptor_chain.verify",
|
|
50
51
|
"charter_revision.decode", "acceptance.verify", "acceptance.equivocation",
|
|
51
|
-
"termination.verify", "chain.verify", "governing_revision", "receipt.verify",
|
|
52
|
+
"termination.verify", "chain.verify", "chain.verify_profile", "governing_revision", "receipt.verify",
|
|
52
53
|
];
|
|
53
54
|
const CLASSES = [
|
|
54
55
|
"valid", "boundary_near", "exact_bound", "maximum_plus_one", "invalid_encoding",
|
|
55
56
|
"invalid_type", "invalid_constraint", "invalid_cardinality", "unknown_member",
|
|
56
57
|
"missing_required", "non_canonical_bytes", "digest_mismatch", "signature_invalid",
|
|
57
58
|
"chain_invalid", "descriptor_superseded", "descriptor_fork", "equivocation",
|
|
58
|
-
"chain_fork", "
|
|
59
|
+
"chain_fork", "profile_algorithm_outside", "profile_revision_outside", "profile_narrow_valid",
|
|
60
|
+
"supersession", "precedence_selection", "terminated", "outcome_indeterminate",
|
|
59
61
|
"extension_unknown_critical", "extension_optional_roundtrip", "extension_invalid",
|
|
60
62
|
];
|
|
61
63
|
const REQUIRED = {
|
|
64
|
+
"acceptance.equivocation": ["equivocation", "invalid_constraint"],
|
|
65
|
+
"acceptance.verify": ["valid", "invalid_constraint", "signature_invalid", "unknown_member", "profile_narrow_valid", "profile_algorithm_outside", "profile_revision_outside"],
|
|
62
66
|
"base64url.decode": ["valid", "exact_bound", "invalid_encoding"],
|
|
63
|
-
"json.decode": ["valid", "boundary_near", "exact_bound", "maximum_plus_one", "invalid_encoding", "invalid_type"],
|
|
64
67
|
"canonicalization.encode": ["valid", "invalid_encoding", "invalid_type", "non_canonical_bytes"],
|
|
68
|
+
"chain.verify": ["valid", "exact_bound", "maximum_plus_one", "chain_fork", "supersession", "chain_invalid"],
|
|
69
|
+
"chain.verify_profile": ["profile_algorithm_outside", "profile_revision_outside", "profile_narrow_valid"],
|
|
70
|
+
"charter_revision.decode": ["valid", "invalid_encoding", "invalid_type", "invalid_constraint", "invalid_cardinality", "unknown_member", "missing_required", "non_canonical_bytes", "extension_unknown_critical", "extension_invalid"],
|
|
71
|
+
"descriptor_chain.verify": ["signature_invalid", "chain_invalid", "descriptor_superseded", "descriptor_fork"],
|
|
65
72
|
"digest.hash": ["valid", "invalid_type", "digest_mismatch"],
|
|
73
|
+
"governing_revision": ["precedence_selection", "terminated"],
|
|
74
|
+
"json.decode": ["valid", "boundary_near", "exact_bound", "maximum_plus_one", "invalid_encoding", "invalid_type"],
|
|
75
|
+
"party_descriptor.verify": ["valid", "signature_invalid", "invalid_encoding", "unknown_member", "invalid_constraint", "profile_narrow_valid", "profile_algorithm_outside", "profile_revision_outside"],
|
|
76
|
+
"receipt.verify": ["valid", "invalid_constraint", "signature_invalid", "unknown_member", "chain_fork", "terminated", "outcome_indeterminate", "extension_optional_roundtrip", "invalid_encoding", "extension_invalid", "profile_narrow_valid", "profile_algorithm_outside", "profile_revision_outside"],
|
|
66
77
|
"schema.validate": ["valid", "invalid_type", "invalid_constraint", "invalid_cardinality", "unknown_member", "missing_required", "maximum_plus_one"],
|
|
67
|
-
"
|
|
68
|
-
"descriptor_chain.verify": ["signature_invalid", "chain_invalid", "descriptor_superseded", "descriptor_fork"],
|
|
69
|
-
"charter_revision.decode": ["valid", "invalid_type", "invalid_constraint", "invalid_cardinality", "unknown_member", "missing_required", "extension_unknown_critical", "extension_invalid"],
|
|
70
|
-
"acceptance.verify": ["valid", "invalid_constraint", "signature_invalid"],
|
|
71
|
-
"acceptance.equivocation": ["equivocation", "invalid_constraint"],
|
|
72
|
-
"termination.verify": ["valid", "invalid_constraint", "signature_invalid"],
|
|
73
|
-
"chain.verify": ["valid", "chain_fork", "supersession", "chain_invalid"],
|
|
74
|
-
"governing_revision": ["precedence_selection"],
|
|
75
|
-
"receipt.verify": ["valid", "invalid_constraint", "signature_invalid", "chain_fork", "outcome_indeterminate", "extension_optional_roundtrip", "invalid_encoding", "extension_invalid"],
|
|
78
|
+
"termination.verify": ["valid", "invalid_constraint", "signature_invalid", "unknown_member", "profile_narrow_valid", "profile_algorithm_outside", "profile_revision_outside"],
|
|
76
79
|
};
|
|
77
80
|
const ok = (value) => ({ ok: true, value });
|
|
78
81
|
const fail = (code) => ({ ok: false, code });
|
|
79
82
|
const valid = (output) => ({ status: "valid", output });
|
|
80
83
|
const invalid = (code) => ({ status: "invalid", error_code: code });
|
|
81
84
|
const project = (result, projector) => result.ok ? valid(projector(result.value)) : invalid(result.code);
|
|
85
|
+
const NOT_VERIFIED_FLOOR = ["tenancy", "live_policy", "authority", "effect_ownership", "execution", "billing", "evaluation_truth", "legal_validity", "term_satisfaction", "view_completeness", "counterparty_view", "wall_clock"];
|
|
86
|
+
function factsRecord(attrs, additions = []) {
|
|
87
|
+
return { protocol_revision: null, alg: null, ...attrs, not_verified: [...new Set([...NOT_VERIFIED_FLOOR, ...additions])] };
|
|
88
|
+
}
|
|
82
89
|
export function canonical(value) {
|
|
83
90
|
if (value instanceof Number)
|
|
84
91
|
return JSON.stringify(value.valueOf());
|
|
85
92
|
if (value === null || typeof value === "boolean" || typeof value === "string")
|
|
86
93
|
return JSON.stringify(value);
|
|
87
|
-
if (typeof value === "number" && Number.isFinite(value))
|
|
94
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
95
|
+
if (Number.isInteger(value) && !Number.isSafeInteger(value))
|
|
96
|
+
throw new Error("integer_magnitude");
|
|
88
97
|
return JSON.stringify(value);
|
|
98
|
+
}
|
|
89
99
|
if (Array.isArray(value))
|
|
90
100
|
return `[${value.map(canonical).join(",")}]`;
|
|
91
101
|
if (value && typeof value === "object") {
|
|
@@ -132,13 +142,20 @@ function strictBase64url(text) {
|
|
|
132
142
|
// closed codes, in the decoder's own order.
|
|
133
143
|
const MAXIMUM_SAFE_INTEGER = 9007199254740991n;
|
|
134
144
|
const NUMBER_TOKEN = /(?:-?(?:0|[1-9][0-9]*))(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/y;
|
|
135
|
-
|
|
145
|
+
// Retain text order separately from JavaScript's integer-key enumeration.
|
|
146
|
+
// Plain property access remains compatible with existing artifact consumers.
|
|
147
|
+
const JSON_MEMBER_ORDER = new WeakMap();
|
|
148
|
+
function readJsonValue(text, index, limits, depth = 0) {
|
|
136
149
|
index = skipWhitespace(text, index);
|
|
137
150
|
const char = text[index];
|
|
138
151
|
if (char === undefined)
|
|
139
152
|
return { status: "need-character" };
|
|
153
|
+
if ((char === "{" || char === "[") && depth + 1 > limits.max_depth)
|
|
154
|
+
return { status: "error", code: "limit_exceeded" };
|
|
140
155
|
if (char === "{") {
|
|
141
156
|
const members = new Map();
|
|
157
|
+
let duplicate = false;
|
|
158
|
+
let count = 0;
|
|
142
159
|
let cursor = skipWhitespace(text, index + 1);
|
|
143
160
|
if (text[cursor] === "}")
|
|
144
161
|
return { status: "ok", value: {}, index: cursor + 1 };
|
|
@@ -148,15 +165,23 @@ function readJsonValue(text, index) {
|
|
|
148
165
|
const key = readJsonString(text, cursor);
|
|
149
166
|
if (key.status !== "ok")
|
|
150
167
|
return key;
|
|
168
|
+
if (Buffer.byteLength(key.value) > limits.max_string_bytes)
|
|
169
|
+
return { status: "error", code: "limit_exceeded" };
|
|
151
170
|
cursor = skipWhitespace(text, key.index);
|
|
152
171
|
if (text[cursor] !== ":")
|
|
153
172
|
return { status: "syntax" };
|
|
154
|
-
const item = readJsonValue(text, skipWhitespace(text, cursor + 1));
|
|
173
|
+
const item = readJsonValue(text, skipWhitespace(text, cursor + 1), limits, depth + 1);
|
|
155
174
|
if (item.status !== "ok")
|
|
156
175
|
return item;
|
|
157
|
-
const duplicate = members.has(key.value);
|
|
158
|
-
members.set(key.value, item.value);
|
|
159
176
|
cursor = skipWhitespace(text, item.index);
|
|
177
|
+
if (text[cursor] !== "," && text[cursor] !== "}")
|
|
178
|
+
return { status: "syntax" };
|
|
179
|
+
if (item.deferredCode)
|
|
180
|
+
return { status: "error", code: item.deferredCode };
|
|
181
|
+
if (++count > limits.max_object_members)
|
|
182
|
+
return { status: "error", code: "limit_exceeded" };
|
|
183
|
+
duplicate ||= members.has(key.value);
|
|
184
|
+
members.set(key.value, item.value);
|
|
160
185
|
if (text[cursor] === ",") {
|
|
161
186
|
cursor = skipWhitespace(text, cursor + 1);
|
|
162
187
|
continue;
|
|
@@ -164,7 +189,9 @@ function readJsonValue(text, index) {
|
|
|
164
189
|
if (text[cursor] === "}") {
|
|
165
190
|
if (duplicate)
|
|
166
191
|
return { status: "error", code: "duplicate_member" };
|
|
167
|
-
|
|
192
|
+
const object = Object.fromEntries(members);
|
|
193
|
+
JSON_MEMBER_ORDER.set(object, [...members.keys()]);
|
|
194
|
+
return { status: "ok", value: object, index: cursor + 1 };
|
|
168
195
|
}
|
|
169
196
|
return { status: "syntax" };
|
|
170
197
|
}
|
|
@@ -175,11 +202,17 @@ function readJsonValue(text, index) {
|
|
|
175
202
|
if (text[cursor] === "]")
|
|
176
203
|
return { status: "ok", value: items, index: cursor + 1 };
|
|
177
204
|
for (;;) {
|
|
178
|
-
const item = readJsonValue(text, cursor);
|
|
205
|
+
const item = readJsonValue(text, cursor, limits, depth + 1);
|
|
179
206
|
if (item.status !== "ok")
|
|
180
207
|
return item;
|
|
181
|
-
items.push(item.value);
|
|
182
208
|
cursor = skipWhitespace(text, item.index);
|
|
209
|
+
if (text[cursor] !== "," && text[cursor] !== "]")
|
|
210
|
+
return { status: "syntax" };
|
|
211
|
+
if (item.deferredCode)
|
|
212
|
+
return { status: "error", code: item.deferredCode };
|
|
213
|
+
if (items.length >= limits.max_array_items)
|
|
214
|
+
return { status: "error", code: "limit_exceeded" };
|
|
215
|
+
items.push(item.value);
|
|
183
216
|
if (text[cursor] === ",") {
|
|
184
217
|
cursor = skipWhitespace(text, cursor + 1);
|
|
185
218
|
continue;
|
|
@@ -191,6 +224,8 @@ function readJsonValue(text, index) {
|
|
|
191
224
|
}
|
|
192
225
|
if (char === '"') {
|
|
193
226
|
const string = readJsonString(text, index);
|
|
227
|
+
if (string.status === "ok" && Buffer.byteLength(string.value) > limits.max_string_bytes)
|
|
228
|
+
return { status: "error", code: "limit_exceeded" };
|
|
194
229
|
return string.status === "ok" ? { status: "ok", value: string.value, index: string.index } : string;
|
|
195
230
|
}
|
|
196
231
|
for (const [literal, value] of [["true", true], ["false", false], ["null", null]]) {
|
|
@@ -201,15 +236,28 @@ function readJsonValue(text, index) {
|
|
|
201
236
|
const token = NUMBER_TOKEN.exec(text);
|
|
202
237
|
if (token) {
|
|
203
238
|
const literal = token[0];
|
|
239
|
+
// A fraction or exponent that starts without its digits is a syntax error,
|
|
240
|
+
// as in the reference: "1." and "1e" are invalid_syntax, while a "." after
|
|
241
|
+
// a fraction or an "e" after an exponent is ordinary trailing input.
|
|
242
|
+
const next = text[index + literal.length];
|
|
243
|
+
if ((next === "." && !/[.eE]/.test(literal)) || ((next === "e" || next === "E") && !/[eE]/.test(literal)))
|
|
244
|
+
return { status: "syntax" };
|
|
245
|
+
const numberError = (code) => ({ status: "ok", deferredCode: code, index: index + literal.length });
|
|
204
246
|
if (/^-?[0-9]+$/.test(literal)) {
|
|
247
|
+
if (literal.replace(/^-/, "").length > 21)
|
|
248
|
+
return numberError("number_not_double_expressible");
|
|
205
249
|
const magnitude = BigInt(literal);
|
|
206
|
-
if (
|
|
207
|
-
|
|
208
|
-
|
|
250
|
+
if (magnitude > MAXIMUM_SAFE_INTEGER || magnitude < -MAXIMUM_SAFE_INTEGER) {
|
|
251
|
+
if (JSON.stringify(Number(literal)) !== literal)
|
|
252
|
+
return numberError("number_not_double_expressible");
|
|
253
|
+
return { status: "ok", value: new Number(Number(literal)), index: index + literal.length };
|
|
209
254
|
}
|
|
210
255
|
}
|
|
211
|
-
else
|
|
212
|
-
|
|
256
|
+
else {
|
|
257
|
+
if (literal.length > 32)
|
|
258
|
+
return numberError("number_not_double_expressible");
|
|
259
|
+
if (!Number.isFinite(Number(literal)))
|
|
260
|
+
return numberError("invalid_number");
|
|
213
261
|
}
|
|
214
262
|
// Float-ness follows the lexeme (fraction or exponent), never the value:
|
|
215
263
|
// "0.0" and "2e0" are floats even though their double is integral, so the
|
|
@@ -257,25 +305,36 @@ function skipWhitespace(text, index) {
|
|
|
257
305
|
index += 1;
|
|
258
306
|
return index;
|
|
259
307
|
}
|
|
260
|
-
export function decodeJsonText(text) {
|
|
261
|
-
|
|
308
|
+
export function decodeJsonText(text, selected = {}) {
|
|
309
|
+
if (!validLimits(selected))
|
|
310
|
+
return fail("invalid_limits");
|
|
311
|
+
if (typeof text !== "string")
|
|
312
|
+
return fail("invalid_type");
|
|
313
|
+
const limits = { ...DEFAULT_LIMITS, ...selected };
|
|
314
|
+
if (Buffer.byteLength(text) > limits.max_bytes)
|
|
315
|
+
return fail("limit_exceeded");
|
|
316
|
+
const value = readJsonValue(text, 0, limits);
|
|
262
317
|
if (value.status === "need-character" || value.status === "syntax")
|
|
263
318
|
return fail("invalid_syntax");
|
|
264
319
|
if (value.status === "error")
|
|
265
320
|
return fail(value.code);
|
|
266
321
|
if (value.index === undefined || skipWhitespace(text, value.index) !== text.length)
|
|
267
322
|
return fail("trailing_bytes");
|
|
323
|
+
if (value.deferredCode)
|
|
324
|
+
return fail(value.deferredCode);
|
|
268
325
|
return ok(value.value);
|
|
269
326
|
}
|
|
270
|
-
function decodeJsonBytes(bytes) {
|
|
327
|
+
function decodeJsonBytes(bytes, limits = DEFAULT_LIMITS) {
|
|
271
328
|
try {
|
|
272
|
-
|
|
329
|
+
if (bytes.length > limits.max_bytes)
|
|
330
|
+
return fail("limit_exceeded");
|
|
331
|
+
return decodeJsonText(new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes), limits);
|
|
273
332
|
}
|
|
274
333
|
catch (_error) {
|
|
275
334
|
return fail("invalid_encoding");
|
|
276
335
|
}
|
|
277
336
|
}
|
|
278
|
-
const
|
|
337
|
+
export const DEFAULT_LIMITS = Object.freeze({
|
|
279
338
|
max_bytes: 1_048_576,
|
|
280
339
|
max_depth: 64,
|
|
281
340
|
max_object_members: 1_024,
|
|
@@ -283,10 +342,11 @@ const JSON_DEFAULT_LIMITS = {
|
|
|
283
342
|
max_string_bytes: 65_536,
|
|
284
343
|
max_artifact_set_items: 1_024,
|
|
285
344
|
max_artifact_set_bytes: 67_108_864,
|
|
286
|
-
};
|
|
345
|
+
});
|
|
346
|
+
const JSON_DEFAULT_LIMITS = DEFAULT_LIMITS;
|
|
287
347
|
// The compiled maximums mirror lib/charter_agreement_protocol/limits.ex: the
|
|
288
348
|
// greatest caller-selectable value per field, not the defaults.
|
|
289
|
-
const
|
|
349
|
+
export const MAXIMUM_LIMITS = Object.freeze({
|
|
290
350
|
max_bytes: 16_777_216,
|
|
291
351
|
max_depth: 128,
|
|
292
352
|
max_object_members: 65_536,
|
|
@@ -294,12 +354,13 @@ const LIMIT_MAXIMUMS = {
|
|
|
294
354
|
max_string_bytes: 1_048_576,
|
|
295
355
|
max_artifact_set_items: 4_096,
|
|
296
356
|
max_artifact_set_bytes: 1_073_741_824,
|
|
297
|
-
};
|
|
357
|
+
});
|
|
358
|
+
const LIMIT_MAXIMUMS = MAXIMUM_LIMITS;
|
|
298
359
|
function validLimits(selected) {
|
|
299
|
-
if (
|
|
360
|
+
if (!isRecord(selected))
|
|
300
361
|
return false;
|
|
301
362
|
const maximums = LIMIT_MAXIMUMS;
|
|
302
|
-
return Object.entries(selected).every(([name, value]) => name
|
|
363
|
+
return Object.entries(selected).every(([name, value]) => Object.hasOwn(maximums, name) && Number.isInteger(value) && value >= 0 && value <= maximums[name]);
|
|
303
364
|
}
|
|
304
365
|
function jsonWithinLimits(value, bytes, selected = {}) {
|
|
305
366
|
const limits = { ...JSON_DEFAULT_LIMITS, ...selected };
|
|
@@ -317,7 +378,7 @@ function jsonWithinLimits(value, bytes, selected = {}) {
|
|
|
317
378
|
item.forEach((child) => visit(child, depth + 1));
|
|
318
379
|
return;
|
|
319
380
|
}
|
|
320
|
-
if (item && typeof item === "object") {
|
|
381
|
+
if (item && typeof item === "object" && !(item instanceof Number)) {
|
|
321
382
|
const entries = Object.entries(item);
|
|
322
383
|
if (depth + 1 > limits.max_depth || entries.length > limits.max_object_members)
|
|
323
384
|
throw new Error("limit");
|
|
@@ -346,7 +407,7 @@ export function jsonProjection(value) {
|
|
|
346
407
|
if (Array.isArray(value))
|
|
347
408
|
return { tag: "array", items: value.map(jsonProjection) };
|
|
348
409
|
if (value && typeof value === "object")
|
|
349
|
-
return { tag: "object", members: Object.
|
|
410
|
+
return { tag: "object", members: (JSON_MEMBER_ORDER.get(value) ?? Object.keys(value)).map((key) => [key, jsonProjection(value[key])]) };
|
|
350
411
|
if (typeof value === "string")
|
|
351
412
|
return { tag: "string", value };
|
|
352
413
|
if (typeof value === "boolean")
|
|
@@ -354,46 +415,49 @@ export function jsonProjection(value) {
|
|
|
354
415
|
return { tag: "float", value };
|
|
355
416
|
}
|
|
356
417
|
const PROTECTED_MEMBERS = ["alg", "kid", "typ"];
|
|
357
|
-
function
|
|
418
|
+
function canonicalTextError(value, text) {
|
|
419
|
+
try {
|
|
420
|
+
return canonical(value) === text ? null : "non_canonical_bytes";
|
|
421
|
+
}
|
|
422
|
+
catch (error) {
|
|
423
|
+
return error instanceof Error ? error.message : "invalid_type";
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
function decodeJws(compact, limits = DEFAULT_LIMITS, expectedTyp) {
|
|
358
427
|
if (typeof compact !== "string")
|
|
359
428
|
return fail("compact_invalid");
|
|
360
|
-
if (Buffer.byteLength(compact) >
|
|
429
|
+
if (Buffer.byteLength(compact) > limits.max_bytes)
|
|
361
430
|
return fail("limit_exceeded");
|
|
362
431
|
const segments = compact.split(".");
|
|
363
432
|
if (segments.length !== 3)
|
|
364
433
|
return fail("compact_invalid");
|
|
365
|
-
const
|
|
366
|
-
|
|
434
|
+
const protectedBytes = strictBase64url(segments[0]);
|
|
435
|
+
const payloadBytes = strictBase64url(segments[1]);
|
|
436
|
+
const signatureBytes = strictBase64url(segments[2]);
|
|
437
|
+
if (!protectedBytes.ok || !payloadBytes.ok)
|
|
367
438
|
return fail("compact_invalid");
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
// framing-layer code the reference decoder emits for that segment.
|
|
373
|
-
const headerValue = decodeJsonBytes(headerBytes);
|
|
374
|
-
if (!headerValue.ok)
|
|
439
|
+
if (!signatureBytes.ok)
|
|
440
|
+
return fail("signature_invalid");
|
|
441
|
+
const headerValue = decodeJsonBytes(protectedBytes.value, limits);
|
|
442
|
+
if (!headerValue.ok || !isRecord(headerValue.value) || canonicalTextError(headerValue.value, protectedBytes.value.toString()))
|
|
375
443
|
return fail("protected_header_invalid");
|
|
376
|
-
const payloadValue = decodeJsonBytes(payloadBytes);
|
|
377
|
-
if (!payloadValue.ok)
|
|
378
|
-
return fail("non_canonical_bytes");
|
|
379
444
|
const header = headerValue.value;
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
445
|
+
if (!exactKeys(header, PROTECTED_MEMBERS) || typeof header.alg !== "string" || !ALG_ROWS.some((row) => row.name === header.alg) ||
|
|
446
|
+
typeof header.typ !== "string" || (expectedTyp !== undefined && header.typ !== expectedTyp) ||
|
|
447
|
+
typeof header.kid !== "string" || !/^[A-Za-z0-9._~-]{1,128}$/.test(header.kid))
|
|
383
448
|
return fail("protected_header_invalid");
|
|
384
|
-
|
|
385
|
-
if (
|
|
449
|
+
const payloadValue = decodeJsonBytes(payloadBytes.value, limits);
|
|
450
|
+
if (!payloadValue.ok || canonicalTextError(payloadValue.value, payloadBytes.value.toString()))
|
|
386
451
|
return fail("non_canonical_bytes");
|
|
387
|
-
|
|
388
|
-
|
|
452
|
+
if (!isRecord(payloadValue.value))
|
|
453
|
+
return fail("protected_header_invalid");
|
|
454
|
+
const payload = payloadValue.value;
|
|
455
|
+
if (typeof payload.protocol_revision !== "number" || !Number.isInteger(payload.protocol_revision) || !algBinds(header.alg, payload.protocol_revision))
|
|
389
456
|
return fail("protected_header_invalid");
|
|
390
|
-
// Per-row signature length: checked only after the header names the
|
|
391
|
-
// algorithm (64 for the classical rows, 2420/3309/4627 for ML-DSA).
|
|
392
457
|
const row = ALG_ROWS.find((one) => one.name === header.alg);
|
|
393
|
-
|
|
394
|
-
if (!row || signature.length !== row.signatureBytes)
|
|
458
|
+
if (signatureBytes.value.length !== row.signatureBytes)
|
|
395
459
|
return fail("signature_invalid");
|
|
396
|
-
return ok({ header, payload, payloadBytes, signature, signingInput: Buffer.from(`${segments[0]}.${segments[1]}`) });
|
|
460
|
+
return ok({ header, payload, payloadBytes: payloadBytes.value, signature: signatureBytes.value, signingInput: Buffer.from(`${segments[0]}.${segments[1]}`) });
|
|
397
461
|
}
|
|
398
462
|
const ED25519_FIELD_PRIME = 2n ** 255n - 19n;
|
|
399
463
|
const ED25519_SUBGROUP_ORDER = 2n ** 252n + 27742317777372353535851937790883648493n;
|
|
@@ -476,16 +540,32 @@ function keyMatchesRow(key, row) {
|
|
|
476
540
|
const bytes = Buffer.from(key.public_key, "base64url");
|
|
477
541
|
return bytes.length === row.publicKeyBytes && bytes.toString("base64url") === key.public_key;
|
|
478
542
|
}
|
|
479
|
-
function verifyDecodedJws(decoded, typ, keys) {
|
|
543
|
+
function verifyDecodedJws(decoded, typ, keys, settings = DEFAULT_SETTINGS) {
|
|
544
|
+
const admission = profileError(decoded.header.alg, decoded.payload.protocol_revision, settings);
|
|
545
|
+
if (admission)
|
|
546
|
+
return fail(admission);
|
|
480
547
|
const row = ALG_ROWS.find((one) => one.name === decoded.header.alg);
|
|
481
548
|
if (!row || decoded.header.typ !== typ || typeof decoded.header.kid !== "string")
|
|
482
|
-
return
|
|
549
|
+
return fail("signature_invalid");
|
|
483
550
|
const key = keys.find((one) => one.key_id === decoded.header.kid && keyMatchesRow(one, row));
|
|
484
551
|
if (!key)
|
|
485
|
-
return
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
552
|
+
return fail("signature_invalid");
|
|
553
|
+
const bytes = Buffer.from(key.public_key, "base64url");
|
|
554
|
+
if (decoded.signature.length !== row.signatureBytes || bytes.length !== row.publicKeyBytes)
|
|
555
|
+
return fail("signature_invalid");
|
|
556
|
+
if (row.keyAlgorithm === "Ed25519" && (!strictEd25519Point(bytes) || !strictEd25519Point(decoded.signature.subarray(0, 32)) || decodeLittleEndian(decoded.signature.subarray(32)) >= ED25519_SUBGROUP_ORDER))
|
|
557
|
+
return fail("signature_invalid");
|
|
558
|
+
if (!runtimeSupportsAlgorithm(row.keyAlgorithm))
|
|
559
|
+
return fail("algorithm_unsupported_on_substrate");
|
|
560
|
+
try {
|
|
561
|
+
const prefix = row.keyAlgorithm === "Ed25519" ? Buffer.from("302a300506032b6570032100", "hex") : ML_DSA_SPKI_PREFIXES[row.keyAlgorithm];
|
|
562
|
+
const spki = createPublicKey({ key: Buffer.concat([prefix, bytes]), format: "der", type: "spki" });
|
|
563
|
+
const verified = nodeVerifySignature(null, decoded.signingInput, spki, decoded.signature);
|
|
564
|
+
return verified ? ok(null) : fail("signature_invalid");
|
|
565
|
+
}
|
|
566
|
+
catch (_error) {
|
|
567
|
+
return fail(katVerifies(row.keyAlgorithm) ? "signature_invalid" : "algorithm_unsupported_on_substrate");
|
|
568
|
+
}
|
|
489
569
|
}
|
|
490
570
|
const TIMESTAMP_GRAMMAR = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?Z$/;
|
|
491
571
|
// Exact RFC 3339 UTC parse mirroring Timestamp.ex: real calendar date, hour
|
|
@@ -500,10 +580,9 @@ function parseTimestamp(value) {
|
|
|
500
580
|
if (!match)
|
|
501
581
|
return null;
|
|
502
582
|
const [year, month, day, hour, minute, second] = match.slice(1, 7).map(Number);
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
const utc =
|
|
506
|
-
const date = new Date(utc);
|
|
583
|
+
const date = new Date(0);
|
|
584
|
+
date.setUTCFullYear(year, month - 1, day);
|
|
585
|
+
const utc = date.getTime();
|
|
507
586
|
if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day)
|
|
508
587
|
return null;
|
|
509
588
|
if (hour > 23 || minute > 59 || second > 60)
|
|
@@ -524,39 +603,45 @@ function compareTimestamps(left, right) {
|
|
|
524
603
|
return 0;
|
|
525
604
|
return paddedLeft < paddedRight ? -1 : 1;
|
|
526
605
|
}
|
|
527
|
-
function descriptorFromCompact(compact, predecessor = null) {
|
|
528
|
-
const decoded = decodeJws(compact);
|
|
606
|
+
function descriptorFromCompact(compact, predecessor = null, settings = DEFAULT_SETTINGS) {
|
|
607
|
+
const decoded = decodeJws(compact, settings.limits, "cap+party");
|
|
529
608
|
if (!decoded.ok)
|
|
530
609
|
return decoded;
|
|
531
610
|
const payload = decoded.value.payload;
|
|
532
611
|
const keys = predecessor ? predecessor.payload.verification_keys : payload.verification_keys;
|
|
533
|
-
const
|
|
534
|
-
const grammar = keyGrammarError(payload);
|
|
612
|
+
const grammar = descriptorClaimsError(payload);
|
|
535
613
|
if (grammar)
|
|
536
614
|
return fail(grammar);
|
|
537
|
-
const resolved = Array.isArray(keys) && keys.find((one) => one.key_id === decoded.value.header.kid && keyMatchesRow(one, descriptorRow));
|
|
538
|
-
if (!resolved)
|
|
539
|
-
return fail("descriptor_key_invalid");
|
|
540
|
-
if (!verifyDecodedJws(decoded.value, "cap+party", keys))
|
|
541
|
-
return fail("signature_invalid");
|
|
542
|
-
if (!parseTimestamp(payload.effective_from)) {
|
|
543
|
-
return fail("timestamp_invalid");
|
|
544
|
-
}
|
|
545
615
|
const digest = taggedHash("party_descriptor_content", decoded.value.payloadBytes);
|
|
546
616
|
if (payload.descriptor_number === 1) {
|
|
617
|
+
if (predecessor)
|
|
618
|
+
return fail("descriptor_chain_invalid");
|
|
547
619
|
if (payload.prev_descriptor_digest !== undefined)
|
|
548
620
|
return fail("descriptor_invalid");
|
|
549
621
|
}
|
|
550
|
-
else if (!predecessor || payload.prev_descriptor_digest !== predecessor.digest || payload.descriptor_number !== predecessor.payload.descriptor_number + 1) {
|
|
622
|
+
else if (!predecessor || payload.prev_descriptor_digest !== predecessor.digest || payload.descriptor_number !== predecessor.payload.descriptor_number + 1 || payload.party_id !== (predecessor.payload.party_id ?? predecessor.digest)) {
|
|
551
623
|
return fail("descriptor_chain_invalid");
|
|
552
624
|
}
|
|
553
|
-
|
|
625
|
+
// The envelope is admitted before its kid is looked up, as in the
|
|
626
|
+
// reference, so an out-of-profile artifact whose kid names no key reports
|
|
627
|
+
// the profile code. Acceptances and terminations do the same.
|
|
628
|
+
const descriptorAdmission = profileError(decoded.value.header.alg, payload.protocol_revision, settings);
|
|
629
|
+
if (descriptorAdmission)
|
|
630
|
+
return fail(descriptorAdmission);
|
|
631
|
+
const resolved = Array.isArray(keys) && keys.find((one) => one.key_id === decoded.value.header.kid && one.status === "active");
|
|
632
|
+
if (!resolved)
|
|
633
|
+
return fail("descriptor_key_invalid");
|
|
634
|
+
if (!parseTimestamp(payload.effective_from)) {
|
|
635
|
+
return fail("timestamp_invalid");
|
|
636
|
+
}
|
|
637
|
+
const signature = verifyDecodedJws(decoded.value, "cap+party", keys, settings);
|
|
638
|
+
if (!signature.ok)
|
|
639
|
+
return signature;
|
|
640
|
+
return ok(factsRecord({ ...decoded.value, digest, compact, lineage: [compact, ...(predecessor?.lineage ?? [])], protocol_revision: payload.protocol_revision, alg: decoded.value.header.alg }));
|
|
554
641
|
}
|
|
555
|
-
// The
|
|
556
|
-
//
|
|
557
|
-
//
|
|
558
|
-
// descriptor passes the schema and rejects at the codec's revision gate
|
|
559
|
-
// (descriptor_invalid) — no honest producer could have minted it.
|
|
642
|
+
// The nested schema admits registry encoding lengths; extraction checks
|
|
643
|
+
// the decoded bytes against the selected algorithm and canonical spelling.
|
|
644
|
+
// Those extraction failures use descriptor_invalid.
|
|
560
645
|
function keyGrammarError(payload) {
|
|
561
646
|
if (!Array.isArray(payload.verification_keys) || payload.verification_keys.length === 0) {
|
|
562
647
|
return "nested_invalid";
|
|
@@ -572,7 +657,7 @@ function keyGrammarError(payload) {
|
|
|
572
657
|
return "nested_invalid";
|
|
573
658
|
const bytes = Buffer.from(one.public_key, "base64url");
|
|
574
659
|
if (bytes.length !== row.publicKeyBytes || bytes.toString("base64url") !== one.public_key) {
|
|
575
|
-
return "
|
|
660
|
+
return "descriptor_invalid";
|
|
576
661
|
}
|
|
577
662
|
if (one.algorithm !== "Ed25519" &&
|
|
578
663
|
!(Number.isInteger(payload.protocol_revision) && payload.protocol_revision >= 3)) {
|
|
@@ -581,43 +666,86 @@ function keyGrammarError(payload) {
|
|
|
581
666
|
}
|
|
582
667
|
return null;
|
|
583
668
|
}
|
|
584
|
-
function descriptorChain(compacts) {
|
|
669
|
+
function descriptorChain(compacts, settings = DEFAULT_SETTINGS) {
|
|
585
670
|
if (!Array.isArray(compacts) || compacts.length === 0)
|
|
586
671
|
return fail("descriptor_chain_invalid");
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
if (!decoded.ok)
|
|
594
|
-
return fail("descriptor_chain_invalid");
|
|
595
|
-
const prev = decoded.value.payload.prev_descriptor_digest;
|
|
596
|
-
const predecessor = prev ? descriptors.find((one) => one.digest === prev) : null;
|
|
597
|
-
if (prev && !predecessor)
|
|
598
|
-
continue;
|
|
599
|
-
const verified = descriptorFromCompact(pending[index], predecessor);
|
|
600
|
-
if (!verified.ok)
|
|
601
|
-
return fail("descriptor_chain_invalid");
|
|
602
|
-
descriptors.push(verified.value);
|
|
603
|
-
pending.splice(index, 1);
|
|
604
|
-
progressed = true;
|
|
605
|
-
}
|
|
606
|
-
if (!progressed)
|
|
672
|
+
if (compacts.length > settings.limits.max_artifact_set_items)
|
|
673
|
+
return fail("limit_exceeded");
|
|
674
|
+
const entries = [];
|
|
675
|
+
for (const compact of compacts) {
|
|
676
|
+
const decoded = decodeJws(compact, settings.limits, "cap+party");
|
|
677
|
+
if (!decoded.ok || descriptorClaimsError(decoded.value.payload))
|
|
607
678
|
return fail("descriptor_chain_invalid");
|
|
679
|
+
entries.push({ compact, digest: taggedHash("party_descriptor_content", decoded.value.payloadBytes), payload: decoded.value.payload });
|
|
608
680
|
}
|
|
681
|
+
const roots = entries.filter((entry) => entry.payload.descriptor_number === 1);
|
|
682
|
+
if (roots.length !== 1 || new Set(entries.map((entry) => entry.digest)).size !== entries.length)
|
|
683
|
+
return fail("descriptor_chain_invalid");
|
|
684
|
+
const root = descriptorFromCompact(roots[0].compact, null, settings);
|
|
685
|
+
if (!root.ok)
|
|
686
|
+
return historyFailure([root.code]);
|
|
687
|
+
const descriptors = [root.value];
|
|
609
688
|
const children = new Map();
|
|
610
|
-
for (const
|
|
611
|
-
const prev =
|
|
689
|
+
for (const entry of entries) {
|
|
690
|
+
const prev = entry.payload.prev_descriptor_digest;
|
|
612
691
|
if (prev)
|
|
613
|
-
children.set(prev, [...(children.get(prev)
|
|
614
|
-
}
|
|
615
|
-
|
|
692
|
+
children.set(prev, [...(children.get(prev) ?? []), entry]);
|
|
693
|
+
}
|
|
694
|
+
for (let i = 0; i < descriptors.length; i++) {
|
|
695
|
+
const siblings = children.get(descriptors[i].digest) ?? [];
|
|
696
|
+
const results = siblings.map((entry) => descriptorFromCompact(entry.compact, descriptors[i], settings));
|
|
697
|
+
const failures = results.filter((result) => !result.ok).map((result) => result.code);
|
|
698
|
+
if (failures.length > 0)
|
|
699
|
+
return historyFailure(failures);
|
|
700
|
+
for (const result of results)
|
|
701
|
+
if (result.ok)
|
|
702
|
+
descriptors.push(result.value);
|
|
703
|
+
}
|
|
704
|
+
if (descriptors.length !== entries.length)
|
|
705
|
+
return fail("descriptor_chain_invalid");
|
|
706
|
+
const siblings = [...children.values()].filter((group) => group.length > 1).flat().map((entry) => entry.digest);
|
|
707
|
+
const fork = siblings.length > 0;
|
|
708
|
+
descriptors.sort((a, b) => a.payload.descriptor_number - b.payload.descriptor_number || a.digest.localeCompare(b.digest));
|
|
616
709
|
const positions = Object.fromEntries(descriptors.map((one) => [one.digest, fork ? "contested" : (children.has(one.digest) ? "superseded" : "head")]));
|
|
617
|
-
|
|
710
|
+
for (const descriptor of descriptors)
|
|
711
|
+
Object.assign(descriptor, { descriptor_position: positions[descriptor.digest] });
|
|
712
|
+
const fork_evidence = fork ? factsRecord({ kind: "sibling_descriptors", sibling_descriptors: [...new Set(siblings)].sort() }) : null;
|
|
713
|
+
return ok(factsRecord({ descriptors, topology: fork ? "forked" : "linear", positions, siblingDescriptors: [...new Set(siblings)].sort(), fork_evidence }));
|
|
714
|
+
}
|
|
715
|
+
function historyFailure(codes) {
|
|
716
|
+
const ordered = ["algorithm_outside_profile", "revision_outside_profile", "algorithm_unsupported_on_substrate"];
|
|
717
|
+
if (codes.some((code) => !ordered.includes(code)))
|
|
718
|
+
return fail("descriptor_chain_invalid");
|
|
719
|
+
return fail(ordered.find((code) => codes.includes(code)));
|
|
720
|
+
}
|
|
721
|
+
function descriptorViews(compacts, settings = DEFAULT_SETTINGS) {
|
|
722
|
+
if (!Array.isArray(compacts))
|
|
723
|
+
return fail("chain_invalid");
|
|
724
|
+
const groups = new Map();
|
|
725
|
+
for (const compact of compacts) {
|
|
726
|
+
const decoded = decodeJws(compact, settings.limits, "cap+party");
|
|
727
|
+
if (!decoded.ok)
|
|
728
|
+
return decoded;
|
|
729
|
+
const shape = descriptorClaimsError(decoded.value.payload);
|
|
730
|
+
if (shape)
|
|
731
|
+
return fail(shape);
|
|
732
|
+
const id = decoded.value.payload.party_id ?? taggedHash("party_descriptor_content", decoded.value.payloadBytes);
|
|
733
|
+
groups.set(id, [...(groups.get(id) ?? []), compact]);
|
|
734
|
+
}
|
|
735
|
+
if (groups.size !== 2)
|
|
736
|
+
return fail("chain_invalid");
|
|
737
|
+
const histories = [];
|
|
738
|
+
for (const id of [...groups.keys()].sort()) {
|
|
739
|
+
const chain = descriptorChain(groups.get(id), settings);
|
|
740
|
+
if (!chain.ok)
|
|
741
|
+
return chain;
|
|
742
|
+
histories.push(chain.value);
|
|
743
|
+
}
|
|
744
|
+
return ok(factsRecord({ histories, descriptors: histories.flatMap((chain) => chain.descriptors),
|
|
745
|
+
positions: Object.assign({}, ...histories.map((chain) => chain.positions)),
|
|
746
|
+
siblingDescriptors: histories.flatMap((chain) => chain.siblingDescriptors),
|
|
747
|
+
topology: histories.some((chain) => chain.topology === "forked") ? "forked" : "linear" }));
|
|
618
748
|
}
|
|
619
|
-
const REVISION_FIELDS = ["abp_bindings", "attribution_declaration", "charter_id", "effective_from", "extensions", "legal_text", "parties", "precedence_declaration", "prev_revision_digest", "protocol_revision", "receipt_profile", "revision_number", "supersedes", "termination_rules"];
|
|
620
|
-
const REVISION_REQUIRED = ["abp_bindings", "attribution_declaration", "effective_from", "extensions", "legal_text", "parties", "precedence_declaration", "protocol_revision", "receipt_profile", "revision_number", "termination_rules"];
|
|
621
749
|
const EXTENSION_PROFILES = [
|
|
622
750
|
{ namespace: "com.example/pricing-indexed", owner: "Example Charter Profiles", criticality: "critical", state: "active", schema_digest: "sha-256:W88CU79l5r7YYCv2vuUTELifnM4GDKfbZPULSpDgQ2Y", a2a_uri: "https://example.com/charter-profiles/pricing-indexed", promoted_at_revision: null, surface: "charter_revision" },
|
|
623
751
|
{ namespace: "com.example/pricing-indexed-observation", owner: "Example Charter Profiles", criticality: "optional", state: "active", schema_digest: "sha-256:6e4emU-CATXhAVFi9XaIIZUzZbCAQBcGkVwJpkZzWk8", a2a_uri: "https://example.com/charter-profiles/pricing-indexed-observation", promoted_at_revision: null, surface: "receipt" },
|
|
@@ -645,69 +773,199 @@ function extensionRegistryDigest() {
|
|
|
645
773
|
]));
|
|
646
774
|
return taggedHash("extension_registry", Buffer.from(canonical(document)));
|
|
647
775
|
}
|
|
648
|
-
function
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
776
|
+
function isRecord(value) {
|
|
777
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && !(value instanceof Number);
|
|
778
|
+
}
|
|
779
|
+
function field(name, type, constraint, required = true) {
|
|
780
|
+
return { name, type, constraint, required };
|
|
781
|
+
}
|
|
782
|
+
const stringBytes = (min, max) => (value) => Buffer.byteLength(value) >= min && Buffer.byteLength(value) <= max;
|
|
783
|
+
const integerRange = (min, max) => (value) => value >= min && value <= max;
|
|
784
|
+
const oneOf = (...values) => (value) => values.includes(value);
|
|
785
|
+
const digestPattern = (value) => /^sha-256:[A-Za-z0-9_-]{43}$/.test(value);
|
|
786
|
+
const digestField = (name, required = true) => field(name, "string", digestPattern, required);
|
|
787
|
+
const safeIntegerField = (name) => field(name, "integer", integerRange(1, Number.MAX_SAFE_INTEGER));
|
|
788
|
+
const roleField = (name) => field(name, "string", stringBytes(1, 128));
|
|
789
|
+
const timeField = (name, required = true) => field(name, "string", stringBytes(1, 64), required);
|
|
790
|
+
const nestedField = (name, type, nested, cardinality) => ({ name, type, required: true, nested, cardinality });
|
|
791
|
+
function schemaError(value, fields) {
|
|
792
|
+
if (!isRecord(value))
|
|
793
|
+
return "invalid_type";
|
|
794
|
+
if (Object.keys(value).some((name) => !fields.some((rule) => rule.name === name)))
|
|
795
|
+
return "unknown_member";
|
|
796
|
+
if (fields.some((rule) => rule.required && !Object.hasOwn(value, rule.name)))
|
|
797
|
+
return "missing_required";
|
|
798
|
+
const present = fields.filter((rule) => Object.hasOwn(value, rule.name));
|
|
799
|
+
for (const rule of present) {
|
|
800
|
+
const item = value[rule.name];
|
|
801
|
+
const typed = rule.type === "object" ? isRecord(item) : rule.type === "array" ? Array.isArray(item) :
|
|
802
|
+
rule.type === "integer" ? typeof item === "number" && Number.isInteger(item) : typeof item === "string";
|
|
803
|
+
if (!typed)
|
|
804
|
+
return "invalid_type";
|
|
805
|
+
}
|
|
806
|
+
if (present.some((rule) => rule.constraint && !rule.constraint(value[rule.name])))
|
|
807
|
+
return "constraint_violation";
|
|
808
|
+
if (present.some((rule) => rule.cardinality && (value[rule.name].length < rule.cardinality[0] || value[rule.name].length > rule.cardinality[1])))
|
|
809
|
+
return "cardinality_violation";
|
|
810
|
+
for (const rule of present) {
|
|
811
|
+
if (!rule.nested)
|
|
812
|
+
continue;
|
|
813
|
+
const items = rule.type === "array" ? value[rule.name] : [value[rule.name]];
|
|
814
|
+
if (items.some((item) => schemaError(item, rule.nested) !== null))
|
|
815
|
+
return "nested_invalid";
|
|
654
816
|
}
|
|
655
|
-
|
|
656
|
-
|
|
817
|
+
return null;
|
|
818
|
+
}
|
|
819
|
+
const REVISION_SCHEMA = [
|
|
820
|
+
field("protocol_revision", "integer", integerRange(1, 2)), digestField("charter_id", false),
|
|
821
|
+
safeIntegerField("revision_number"), digestField("prev_revision_digest", false),
|
|
822
|
+
nestedField("parties", "array", [digestField("party_descriptor_digest"), roleField("role")], [2, 2]),
|
|
823
|
+
nestedField("legal_text", "object", [digestField("content_digest"), field("media_type", "string", stringBytes(1, 255)), field("uri_hint", "string", stringBytes(1, 2048), false)]),
|
|
824
|
+
field("precedence_declaration", "string", oneOf("legal_text_governs", "machine_terms_govern")),
|
|
825
|
+
nestedField("attribution_declaration", "object", [field("basis", "string", oneOf("bound_deployments", "legal_text")), digestField("detail_digest", false)]),
|
|
826
|
+
timeField("effective_from"), timeField("effective_until", false),
|
|
827
|
+
nestedField("termination_rules", "object", [{ name: "reason_codes", type: "array", required: true, cardinality: [1, 64] }]),
|
|
828
|
+
nestedField("abp_bindings", "array", [roleField("party_role"), field("blueprint_id", "string", (v) => stringBytes(3, 512)(v) && /^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._-]*$/.test(v)), safeIntegerField("release_number"), digestField("content_digest"), digestField("deployment_digest")], [0, 64]),
|
|
829
|
+
field("receipt_profile", "string", (v) => stringBytes(3, 512)(v) && /^[a-z0-9][a-z0-9.-]*\/[a-z0-9][a-z0-9.-]*$/.test(v)),
|
|
830
|
+
{ name: "supersedes", type: "array", required: false, cardinality: [0, 8] }, field("extensions", "object"),
|
|
831
|
+
];
|
|
832
|
+
const DESCRIPTOR_SCHEMA = [
|
|
833
|
+
field("protocol_revision", "integer", integerRange(1, 3)), digestField("party_id", false),
|
|
834
|
+
safeIntegerField("descriptor_number"), digestField("prev_descriptor_digest", false),
|
|
835
|
+
nestedField("verification_keys", "array", [
|
|
836
|
+
field("key_id", "string", (v) => /^[A-Za-z0-9._~-]{1,128}$/.test(v)),
|
|
837
|
+
field("algorithm", "string", oneOf("Ed25519", "ML-DSA-44", "ML-DSA-65", "ML-DSA-87")),
|
|
838
|
+
field("public_key", "string", (v) => /^(?:[A-Za-z0-9_-]{43}|[A-Za-z0-9_-]{1750}|[A-Za-z0-9_-]{2603}|[A-Za-z0-9_-]{3456})$/.test(v)),
|
|
839
|
+
field("status", "string", oneOf("active", "retired")),
|
|
840
|
+
], [1, 32]),
|
|
841
|
+
nestedField("attestation_hints", "array", [field("kind", "string", stringBytes(1, 64)), field("uri", "string", stringBytes(1, 2048))], [0, 16]),
|
|
842
|
+
field("extensions", "object"), timeField("effective_from"),
|
|
843
|
+
];
|
|
844
|
+
const ACCEPTANCE_SCHEMA = [
|
|
845
|
+
field("protocol_revision", "integer", integerRange(1, 3)), digestField("charter_id"),
|
|
846
|
+
safeIntegerField("revision_number"), digestField("revision_digest"), digestField("prev_revision_digest", false),
|
|
847
|
+
digestField("party_descriptor_digest"), roleField("party_role"), timeField("accepted_at"),
|
|
848
|
+
];
|
|
849
|
+
const TERMINATION_SCHEMA = [
|
|
850
|
+
field("protocol_revision", "integer", integerRange(1, 3)), digestField("charter_id"),
|
|
851
|
+
digestField("governing_revision_digest"), digestField("party_descriptor_digest"),
|
|
852
|
+
roleField("party_role"), roleField("reason_code"), timeField("effective_at"), timeField("issued_at"), digestField("detail_digest", false),
|
|
853
|
+
];
|
|
854
|
+
const RECEIPT_SCHEMA = [
|
|
855
|
+
field("protocol_revision", "integer", integerRange(1, 3)), digestField("charter_id"),
|
|
856
|
+
safeIntegerField("revision_number"), digestField("revision_digest"), roleField("issuing_party_role"), roleField("agent_party_role"), digestField("deployment_digest"),
|
|
857
|
+
nestedField("grant", "object", [field("scheme", "string", oneOf("bap", "host")), field("id", "string", stringBytes(1, 512)), digestField("grant_digest", false)]),
|
|
858
|
+
field("invocation_id", "string", stringBytes(1, 512)), field("decision", "string", oneOf("accepted", "rejected")),
|
|
859
|
+
field("outcome", "string", oneOf("effect_committed", "no_effect", "indeterminate")),
|
|
860
|
+
timeField("occurred_at"), timeField("recorded_at"), field("extensions", "object"),
|
|
861
|
+
];
|
|
862
|
+
const INDEXED_CURRENCIES = new Set("AED AFN ALL AMD AOA ARS AUD AWG AZN BAM BBD BDT BHD BIF BMD BND BOB BOV BRL BSD BTN BWP BYN BZD CAD CDF CHE CHF CHW CLF CLP CNY COP COU CRC CUP CVE CZK DJF DKK DOP DZD EGP ERN ETB EUR FJD FKP GBP GEL GHS GIP GMD GNF GTQ GYD HKD HNL HTG HUF IDR ILS INR IQD IRR ISK JMD JOD JPY KES KGS KHR KMF KPW KRW KWD KYD KZT LAK LBP LKR LRD LSL LYD MAD MDL MGA MKD MMK MNT MOP MRU MUR MVR MWK MXN MXV MYR MZN NAD NGN NIO NOK NPR NZD OMR PAB PEN PGK PHP PKR PLN PYG QAR RON RSD RUB RWF SAR SBD SCR SDG SEK SGD SHP SLE SOS SRD SSP STN SVC SYP SZL THB TJS TMT TND TOP TRY TTD TWD TZS UAH UGX USD USN UYI UYU UYW UZS VED VES VND VUV WST XAD XAF XAG XAU XBA XBB XBC XBD XCD XCG XDR XOF XPD XPF XPT XSU XTS XUA XXX YER ZAR ZMW ZWG".split(" "));
|
|
863
|
+
const INDEXED_TERMS_SCHEMA = [
|
|
864
|
+
field("currency", "string", (v) => INDEXED_CURRENCIES.has(v)),
|
|
865
|
+
field("base_amount_minor", "integer", integerRange(0, Number.MAX_SAFE_INTEGER)),
|
|
866
|
+
nestedField("index", "object", [digestField("series_document_digest"), field("series_id", "string", stringBytes(1, 128)), field("observation_lag_days", "integer", integerRange(0, 90))]),
|
|
867
|
+
field("formula", "string", oneOf("index_plus_spread")),
|
|
868
|
+
field("spread_bps", "integer", integerRange(-10000, 10000)),
|
|
869
|
+
field("floor_amount_minor", "integer", integerRange(0, Number.MAX_SAFE_INTEGER), false),
|
|
870
|
+
field("cap_amount_minor", "integer", integerRange(0, Number.MAX_SAFE_INTEGER), false),
|
|
871
|
+
field("tolerance_bps", "integer", integerRange(0, 10000)),
|
|
872
|
+
];
|
|
873
|
+
const INDEXED_OBSERVATION_SCHEMA = [
|
|
874
|
+
digestField("observed_index_digest"), field("observation_instant", "string", (v) => parseTimestamp(v) !== null),
|
|
875
|
+
field("computed_amount_minor", "integer", integerRange(0, Number.MAX_SAFE_INTEGER)),
|
|
876
|
+
];
|
|
877
|
+
function indexedBodyError(namespace, body) {
|
|
878
|
+
const shape = schemaError(body, namespace === "com.example/pricing-indexed" ? INDEXED_TERMS_SCHEMA : INDEXED_OBSERVATION_SCHEMA);
|
|
879
|
+
if (shape)
|
|
880
|
+
return shape;
|
|
881
|
+
const values = body;
|
|
882
|
+
if (namespace === "com.example/pricing-indexed" && values.floor_amount_minor !== undefined && values.cap_amount_minor !== undefined && values.floor_amount_minor > values.cap_amount_minor)
|
|
883
|
+
return "cross_field_invalid";
|
|
884
|
+
return null;
|
|
885
|
+
}
|
|
886
|
+
function extensionError(envelope, surface) {
|
|
887
|
+
if (!isRecord(envelope))
|
|
888
|
+
return "invalid_type";
|
|
889
|
+
if (!exactKeys(envelope, ["critical", "optional"]) || !isRecord(envelope.critical) || !isRecord(envelope.optional))
|
|
890
|
+
return "unknown_member";
|
|
891
|
+
const names = [...Object.keys(envelope.critical), ...Object.keys(envelope.optional)];
|
|
892
|
+
if (names.some((namespace) => !stringBytes(1, 512)(namespace) || !/^[a-z0-9][a-z0-9.-]*\/[a-z0-9][a-z0-9.-]*$/.test(namespace)))
|
|
893
|
+
return "extension_namespace_invalid";
|
|
894
|
+
if (new Set(names).size !== names.length)
|
|
895
|
+
return "extension_duplicate";
|
|
896
|
+
if (names.length > 32)
|
|
897
|
+
return "cardinality_violation";
|
|
898
|
+
for (const position of ["critical", "optional"]) {
|
|
899
|
+
for (const namespace of Object.keys(envelope[position])) {
|
|
900
|
+
const entry = EXTENSION_PROFILES.find((profile) => profile.namespace === namespace);
|
|
901
|
+
if (!entry || entry.state === "reserved" || entry.state === "retired") {
|
|
902
|
+
if (position === "optional")
|
|
903
|
+
continue;
|
|
904
|
+
return entry?.state === "retired" ? "extension_retired" : "extension_unknown_critical";
|
|
905
|
+
}
|
|
906
|
+
if (entry.criticality !== position)
|
|
907
|
+
return "extension_criticality_conflict";
|
|
908
|
+
if (entry.surface !== surface)
|
|
909
|
+
return "extension_scope_invalid";
|
|
910
|
+
if (entry.schema_digest === null)
|
|
911
|
+
return "extension_schema_unavailable";
|
|
912
|
+
const body = indexedBodyError(namespace, envelope[position][namespace]);
|
|
913
|
+
if (body)
|
|
914
|
+
return body;
|
|
915
|
+
}
|
|
657
916
|
}
|
|
658
|
-
|
|
917
|
+
return null;
|
|
918
|
+
}
|
|
919
|
+
function validTaggedDigest(value) {
|
|
920
|
+
return digestPattern(value) && strictBase64url(value.slice(8)).ok;
|
|
921
|
+
}
|
|
922
|
+
function revisionFromText(text, limits = DEFAULT_LIMITS) {
|
|
923
|
+
if (typeof text !== "string")
|
|
924
|
+
return fail("invalid_type");
|
|
925
|
+
const decoded = decodeJsonText(text, limits);
|
|
926
|
+
if (!decoded.ok)
|
|
927
|
+
return decoded;
|
|
928
|
+
const encoding = canonicalTextError(decoded.value, text);
|
|
929
|
+
if (encoding)
|
|
930
|
+
return fail(encoding);
|
|
931
|
+
const value = decoded.value;
|
|
932
|
+
const shape = schemaError(value, REVISION_SCHEMA);
|
|
933
|
+
if (shape)
|
|
934
|
+
return fail(shape);
|
|
935
|
+
const digests = [value.charter_id, value.prev_revision_digest, value.legal_text.content_digest, value.attribution_declaration.detail_digest, ...value.parties.map((party) => party.party_descriptor_digest)].filter((v) => v !== undefined);
|
|
936
|
+
if (digests.some((v) => !validTaggedDigest(v)))
|
|
659
937
|
return fail("revision_invalid");
|
|
660
|
-
const
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
if (!Array.isArray(value.parties) || new Set(value.parties.map((one) => one.role)).size !== value.parties.length)
|
|
938
|
+
const from = parseTimestamp(value.effective_from);
|
|
939
|
+
const until = value.effective_until === undefined ? null : parseTimestamp(value.effective_until);
|
|
940
|
+
if (!from || (value.effective_until !== undefined && !until))
|
|
941
|
+
return fail("timestamp_invalid");
|
|
942
|
+
const reasons = value.termination_rules.reason_codes;
|
|
943
|
+
if (reasons.some((v) => typeof v !== "string" || !stringBytes(1, 128)(v)) || new Set(reasons).size !== reasons.length)
|
|
667
944
|
return fail("revision_invalid");
|
|
668
|
-
if (
|
|
669
|
-
return fail("nested_invalid");
|
|
670
|
-
if (value.revision_number === 1 && (value.supersedes !== undefined || value.prev_revision_digest !== undefined || value.charter_id !== undefined))
|
|
945
|
+
if (value.abp_bindings.some((binding) => !validTaggedDigest(binding.content_digest) || !validTaggedDigest(binding.deployment_digest)))
|
|
671
946
|
return fail("revision_invalid");
|
|
672
|
-
|
|
947
|
+
const supersedes = value.supersedes ?? [];
|
|
948
|
+
if (supersedes.some((v) => typeof v !== "string" || !validTaggedDigest(v)) || new Set(supersedes).size !== supersedes.length)
|
|
949
|
+
return fail("revision_invalid");
|
|
950
|
+
const extensions = extensionError(value.extensions, "charter_revision");
|
|
951
|
+
if (extensions)
|
|
952
|
+
return fail(extensions);
|
|
953
|
+
if (!EXTENSION_PROFILES.some((profile) => profile.namespace === value.receipt_profile && profile.surface === "receipt" && profile.state === "active" && profile.criticality === "optional"))
|
|
954
|
+
return fail("revision_invalid");
|
|
955
|
+
if (value.revision_number === 1 ? (value.charter_id !== undefined || value.prev_revision_digest !== undefined || supersedes.length !== 0) : (value.charter_id === undefined || value.prev_revision_digest === undefined))
|
|
956
|
+
return fail("revision_invalid");
|
|
957
|
+
if (until && compareTimestamps(from, until) >= 0)
|
|
958
|
+
return fail("revision_invalid");
|
|
959
|
+
const roles = value.parties.map((party) => party.role);
|
|
960
|
+
if (new Set(value.parties.map((party) => party.party_descriptor_digest)).size !== value.parties.length)
|
|
961
|
+
return fail("revision_invalid");
|
|
962
|
+
if (new Set(roles).size !== roles.length || value.abp_bindings.some((binding) => !roles.includes(binding.party_role)))
|
|
673
963
|
return fail("revision_invalid");
|
|
674
|
-
const critical = value.extensions?.critical || {};
|
|
675
|
-
const optional = value.extensions?.optional || {};
|
|
676
|
-
const names = [...Object.keys(critical), ...Object.keys(optional)];
|
|
677
|
-
if (names.some((namespace) => Buffer.byteLength(namespace) > 512 || !/^[a-z0-9][a-z0-9.-]*\/[a-z0-9][a-z0-9.-]*$/.test(namespace))) {
|
|
678
|
-
return fail("extension_namespace_invalid");
|
|
679
|
-
}
|
|
680
|
-
if (new Set(names).size !== names.length)
|
|
681
|
-
return fail("extension_duplicate");
|
|
682
|
-
for (const namespace of Object.keys(critical)) {
|
|
683
|
-
const profile = EXTENSION_PROFILES.find((entry) => entry.namespace === namespace);
|
|
684
|
-
if (!profile || profile.state === "reserved")
|
|
685
|
-
return fail("extension_unknown_critical");
|
|
686
|
-
if (profile.state === "retired")
|
|
687
|
-
return fail("extension_retired");
|
|
688
|
-
if (profile.criticality !== "critical")
|
|
689
|
-
return fail("extension_criticality_conflict");
|
|
690
|
-
if (profile.surface !== "charter_revision")
|
|
691
|
-
return fail("extension_scope_invalid");
|
|
692
|
-
if (profile.schema_digest === null)
|
|
693
|
-
return fail("extension_schema_unavailable");
|
|
694
|
-
if (namespace === "com.example/pricing-indexed" && critical[namespace]?.formula !== "index_plus_spread")
|
|
695
|
-
return fail("constraint_violation");
|
|
696
|
-
}
|
|
697
|
-
for (const namespace of Object.keys(optional)) {
|
|
698
|
-
const profile = EXTENSION_PROFILES.find((entry) => entry.namespace === namespace);
|
|
699
|
-
if (!profile || profile.state === "reserved" || profile.state === "retired")
|
|
700
|
-
continue;
|
|
701
|
-
if (profile.surface !== "charter_revision")
|
|
702
|
-
return fail("extension_scope_invalid");
|
|
703
|
-
if (profile.schema_digest === null)
|
|
704
|
-
return fail("extension_schema_unavailable");
|
|
705
|
-
}
|
|
706
964
|
const bytes = Buffer.from(text);
|
|
707
|
-
return ok({ value, bytes, digest: taggedHash("charter_revision_content", bytes) });
|
|
965
|
+
return ok(factsRecord({ value, bytes, digest: taggedHash("charter_revision_content", bytes), protocol_revision: value.protocol_revision }));
|
|
708
966
|
}
|
|
709
|
-
function acceptanceFromCompact(compact, revision, chain) {
|
|
710
|
-
const decoded = decodeJws(compact);
|
|
967
|
+
function acceptanceFromCompact(compact, revision, chain, settings = DEFAULT_SETTINGS) {
|
|
968
|
+
const decoded = decodeJws(compact, settings.limits, "cap+acceptance");
|
|
711
969
|
if (!decoded.ok)
|
|
712
970
|
return decoded;
|
|
713
971
|
const claims = decoded.value.payload;
|
|
@@ -715,31 +973,47 @@ function acceptanceFromCompact(compact, revision, chain) {
|
|
|
715
973
|
if (acceptanceShape)
|
|
716
974
|
return fail(acceptanceShape);
|
|
717
975
|
const descriptor = chain.descriptors.find((one) => one.digest === claims.party_descriptor_digest);
|
|
718
|
-
if (!descriptor || !verifyDecodedJws(decoded.value, "cap+acceptance", descriptor.payload.verification_keys))
|
|
719
|
-
return fail("signature_invalid");
|
|
720
976
|
const expectedCharter = revision.value.charter_id || revision.digest;
|
|
721
977
|
const party = revision.value.parties.find((one) => one.party_descriptor_digest === claims.party_descriptor_digest);
|
|
722
978
|
const mismatch = claims.charter_id !== expectedCharter || claims.revision_number !== revision.value.revision_number || claims.revision_digest !== revision.digest || claims.party_role !== party?.role || (revision.value.prev_revision_digest || undefined) !== (claims.prev_revision_digest || undefined);
|
|
723
979
|
if (mismatch)
|
|
724
980
|
return fail("acceptance_claims_mismatch");
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
981
|
+
if (!descriptor)
|
|
982
|
+
return fail("acceptance_claims_mismatch");
|
|
983
|
+
const acceptanceAdmission = profileError(decoded.value.header.alg, claims.protocol_revision, settings);
|
|
984
|
+
if (acceptanceAdmission)
|
|
985
|
+
return fail(acceptanceAdmission);
|
|
986
|
+
if (!descriptor.payload.verification_keys.some((key) => key.key_id === decoded.value.header.kid && key.status === "active"))
|
|
987
|
+
return fail("acceptance_invalid");
|
|
988
|
+
const signature = verifyDecodedJws(decoded.value, "cap+acceptance", descriptor.payload.verification_keys, settings);
|
|
989
|
+
if (!signature.ok)
|
|
990
|
+
return signature;
|
|
991
|
+
return ok(factsRecord({ claims, digest: taggedHash("acceptance_content", decoded.value.payloadBytes), descriptorPosition: chain.positions[claims.party_descriptor_digest], protocol_revision: claims.protocol_revision, alg: decoded.value.header.alg }));
|
|
992
|
+
}
|
|
993
|
+
function terminationFromCompact(compact, revision, chain, settings = DEFAULT_SETTINGS) {
|
|
994
|
+
const decoded = decodeJws(compact, settings.limits, "cap+termination");
|
|
729
995
|
if (!decoded.ok)
|
|
730
996
|
return decoded;
|
|
731
997
|
const claims = decoded.value.payload;
|
|
998
|
+
const terminationShape = terminationClaimsError(claims);
|
|
999
|
+
if (terminationShape)
|
|
1000
|
+
return fail(terminationShape);
|
|
732
1001
|
const descriptor = chain.descriptors.find((one) => one.digest === claims.party_descriptor_digest);
|
|
733
|
-
if (!descriptor || !verifyDecodedJws(decoded.value, "cap+termination", descriptor.payload.verification_keys))
|
|
734
|
-
return fail("signature_invalid");
|
|
735
1002
|
const expectedCharter = revision.value.charter_id || revision.digest;
|
|
736
1003
|
const party = revision.value.parties.find((one) => one.party_descriptor_digest === claims.party_descriptor_digest);
|
|
737
1004
|
if (claims.charter_id !== expectedCharter || claims.governing_revision_digest !== revision.digest || claims.party_role !== party?.role || !revision.value.termination_rules.reason_codes.includes(claims.reason_code))
|
|
738
1005
|
return fail("termination_claims_mismatch");
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
1006
|
+
if (!descriptor)
|
|
1007
|
+
return fail("termination_claims_mismatch");
|
|
1008
|
+
const terminationAdmission = profileError(decoded.value.header.alg, claims.protocol_revision, settings);
|
|
1009
|
+
if (terminationAdmission)
|
|
1010
|
+
return fail(terminationAdmission);
|
|
1011
|
+
if (!descriptor.payload.verification_keys.some((key) => key.key_id === decoded.value.header.kid && key.status === "active"))
|
|
1012
|
+
return fail("termination_invalid");
|
|
1013
|
+
const signature = verifyDecodedJws(decoded.value, "cap+termination", descriptor.payload.verification_keys, settings);
|
|
1014
|
+
if (!signature.ok)
|
|
1015
|
+
return signature;
|
|
1016
|
+
return ok(factsRecord({ claims, digest: taggedHash("termination_content", decoded.value.payloadBytes), descriptorPosition: chain.positions[claims.party_descriptor_digest], protocol_revision: claims.protocol_revision, alg: decoded.value.header.alg }));
|
|
743
1017
|
}
|
|
744
1018
|
// Chain-level structural checks mirroring Chain.verify: unique revision
|
|
745
1019
|
// digests, exactly one genesis defining one charter identity, exact
|
|
@@ -747,19 +1021,211 @@ function terminationFromCompact(compact, revision, chain) {
|
|
|
747
1021
|
// coordinates, dual acceptance against the revision's actual party pairs (any
|
|
748
1022
|
// two roles — never hardcoded names), verified termination notices, and the
|
|
749
1023
|
// reference topology/governing semantics with ancestry coverage.
|
|
750
|
-
|
|
1024
|
+
// The capability probe mirror: one verifiable verdict per registry row,
|
|
1025
|
+
// derived from the SAME pinned known-answer vectors as the reference
|
|
1026
|
+
// implementation (identical bytes; a capable runtime must verify each
|
|
1027
|
+
// triple). Linked-crypto identity is informational only — it never decides
|
|
1028
|
+
// a verdict.
|
|
1029
|
+
const KNOWN_ANSWER_MESSAGE = Buffer.from("charter-agreement-protocol capability known-answer");
|
|
1030
|
+
const KNOWN_ANSWERS = {
|
|
1031
|
+
"Ed25519": {
|
|
1032
|
+
publicKey: "GzQZjEZ9YYJWL3R3uwR0owiJSd55-Dl33NgTbuWBewc",
|
|
1033
|
+
signature: "-H0dvAgkit6g5XUHSeemuI_1BQK2ZZaip-cskYhB6Jv2YNBAASg3B57dXW30ezxbH9YVPgWc3TA3qx74TN5UDA",
|
|
1034
|
+
},
|
|
1035
|
+
"ML-DSA-44": {
|
|
1036
|
+
publicKey: "eZXohjF26xlaoAtC8VRJ1q3BslIgF8E7VmFo-eakCL6nkVT5WNKGnswbF-MpIn-5dushxTjsPHGpJ--TRc3PIUTXc48LRWsrR5oaTIPNicT-dIFInl9geCmg_-2QFYvT7-gHjQWz2EhUbCxRt3lHIyRRyYRadtkRL6c8LV6eTnhYo9rJjhmwPl9eVvYfgF-LCY-Qe3ZUUYGiwoh5K0KAZmH5ttDV8Y78xyFwWwB24nNNqTGgo5nc-G35yWKwHY9CI_xSkZ5XtdGjLY0R2zmYYMEvubfdxVyFM38_oG7qglm-4W92j4kmXhX4_rR-UKQD4_GjBK57jtHMjE9ClmrPjn4ACjP1XeSVED71VAhbuRKvE_h1t746u_GkdoPTWZfLToJTiTRFOlQ1NDHxSo8MkbRwRuqTYolxl9M-Ndoc_RxFoXVjQTheib6Q3Xpt_JP0mt9i1keuVWOf5ufirUg6pox-M_uZ5gySLbARLeUx-HXAYtxbGAQuWhG8cALf2unHOVwBVHvvO3n9Fss5Zf39Ib4v_XoBtI7rMnVooTLfWqm2__PofD03vlOELeErYRdtxumwZOpHPCbO9fH9TOEJqTW42xL4e84cftGHBEORxi99cHynTnzf1IZbK3jRALPlMrpmXwO-UXUr_MMb2E3udaIa43Egn-A54RJfAu8kg27a2tjSGlpyX4JMu44lGHgZdFDtlqTsejhuK1JjqvCAYMcqKhaZxdiqrvR3doUcSOj0isrSEAoalwF1WJlU0ke3OnYVJC6MslpW_4O6iJHTPDLv_9rzVLp5BsQBuQT-9vbsRm7YaHkO043yACmWXmcC__DKGXAGkBlbMNM9kidM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HhX99bDWOO5xSEnggqGIIriMYS2uhGpyOfDhaI4D7RM6PCheKpt7XwsTQDDJNc-OSwH_NoSxeaPMLtnew-KgT0_VGRtlvQPWn1o5NkaeKs3CUjW260yCsCHoVArVTeAsOSCtpTTtxyKRgHCPJ3VA1fNIpXGBPPeQgv30DHTMpHpsr-zsPNZ5PU7TlQb3AUI-UnP_0XLSY5-UyMKRPeGgf2fo8agKKbhIbRlcRRzfWPd3bSaNpdZ2AI-bbprJEnwkgbM4A0p7wBXuLHzhS4rC24QMQj92dxBrqzUmZfL-Ihj--5dgcvQqVZIq-9mMCYuhZZt4NHSidqLLoCRchOTuFqsno8iw3Ro-W7jVyAxMgMnmCzdHS8_gOGhwmlekEMEbE3AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADChQaHCctMg",
|
|
1046
|
+
},
|
|
1047
|
+
};
|
|
1048
|
+
function katVerifies(keyAlgorithm, message = KNOWN_ANSWER_MESSAGE) {
|
|
1049
|
+
const vector = KNOWN_ANSWERS[keyAlgorithm];
|
|
1050
|
+
if (!vector)
|
|
1051
|
+
return false;
|
|
1052
|
+
const signature = Buffer.from(vector.signature, "base64url");
|
|
1053
|
+
if (keyAlgorithm === "Ed25519") {
|
|
1054
|
+
try {
|
|
1055
|
+
// Raw Ed25519 public key wrapped in its SPKI DER prefix.
|
|
1056
|
+
const spki = Buffer.concat([
|
|
1057
|
+
Buffer.from("302a300506032b6570032100", "hex"),
|
|
1058
|
+
Buffer.from(vector.publicKey, "base64url"),
|
|
1059
|
+
]);
|
|
1060
|
+
const key = createPublicKey({ key: spki, format: "der", type: "spki" });
|
|
1061
|
+
return nodeVerifySignature(null, message, key, signature);
|
|
1062
|
+
}
|
|
1063
|
+
catch (_error) {
|
|
1064
|
+
return false;
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
return mldsa(keyAlgorithm, vector.publicKey, message, signature);
|
|
1068
|
+
}
|
|
1069
|
+
// The known-answer signature over any other message must fail: a runtime
|
|
1070
|
+
// whose verify accepts everything is never counted as supporting a key type.
|
|
1071
|
+
const KNOWN_ANSWER_TAMPERED = Buffer.from("charter-agreement-protocol capability known-answer, tampered");
|
|
1072
|
+
// Importing an algorithm-specific SPKI asks the runtime whether it knows
|
|
1073
|
+
// that key type without running a signature vector. This works on Node 24.8
|
|
1074
|
+
// as well as runtimes that support the ML-DSA key types. A runtime whose key
|
|
1075
|
+
// objects do not report their type (Bun's ML-DSA keys, for example) is asked
|
|
1076
|
+
// once through the known-answer vector instead, and the answer is kept. A
|
|
1077
|
+
// provider failure during the real crypto call is classified by the selected
|
|
1078
|
+
// vector only.
|
|
1079
|
+
const UNTYPED_KEY_SUPPORT = new Map();
|
|
1080
|
+
function runtimeSupportsAlgorithm(keyAlgorithm) {
|
|
1081
|
+
const vector = KNOWN_ANSWERS[keyAlgorithm];
|
|
1082
|
+
if (!vector)
|
|
1083
|
+
return false;
|
|
1084
|
+
const prefix = keyAlgorithm === "Ed25519" ? Buffer.from("302a300506032b6570032100", "hex") : ML_DSA_SPKI_PREFIXES[keyAlgorithm];
|
|
1085
|
+
try {
|
|
1086
|
+
const key = createPublicKey({ key: Buffer.concat([prefix, Buffer.from(vector.publicKey, "base64url")]), format: "der", type: "spki" });
|
|
1087
|
+
if (key.asymmetricKeyType !== undefined)
|
|
1088
|
+
return key.asymmetricKeyType === keyAlgorithm.toLowerCase();
|
|
1089
|
+
}
|
|
1090
|
+
catch (_error) {
|
|
1091
|
+
return false;
|
|
1092
|
+
}
|
|
1093
|
+
const known = UNTYPED_KEY_SUPPORT.get(keyAlgorithm);
|
|
1094
|
+
if (known !== undefined)
|
|
1095
|
+
return known;
|
|
1096
|
+
const supported = katVerifies(keyAlgorithm) && !katVerifies(keyAlgorithm, KNOWN_ANSWER_TAMPERED);
|
|
1097
|
+
UNTYPED_KEY_SUPPORT.set(keyAlgorithm, supported);
|
|
1098
|
+
return supported;
|
|
1099
|
+
}
|
|
1100
|
+
export function capabilities() {
|
|
1101
|
+
const algorithms = ALG_ROWS.map((row) => ({
|
|
1102
|
+
name: row.name,
|
|
1103
|
+
keyAlgorithm: row.keyAlgorithm,
|
|
1104
|
+
verifiable: katVerifies(row.keyAlgorithm),
|
|
1105
|
+
}));
|
|
1106
|
+
// A browser page has no `process`; it then reports no linked library.
|
|
1107
|
+
const versions = typeof process === "undefined" ? undefined : process.versions;
|
|
1108
|
+
return { linkedCrypto: versions?.openssl ?? "", algorithms };
|
|
1109
|
+
}
|
|
1110
|
+
// The signature registry's published identity, mirroring the reference
|
|
1111
|
+
// Algorithm.registry_digest/0 byte for byte: the canonical object of every
|
|
1112
|
+
// row under the signature-registry digest domain.
|
|
1113
|
+
export function algorithmRegistryDigest() {
|
|
1114
|
+
const value = Object.fromEntries(ALG_ROWS.map((row) => [
|
|
1115
|
+
row.name,
|
|
1116
|
+
Object.fromEntries([
|
|
1117
|
+
["name", row.name],
|
|
1118
|
+
["min_protocol_revision", row.minProtocolRevision],
|
|
1119
|
+
["key_algorithm", row.keyAlgorithm],
|
|
1120
|
+
["public_key_bytes", row.publicKeyBytes],
|
|
1121
|
+
["signature_bytes", row.signatureBytes],
|
|
1122
|
+
]),
|
|
1123
|
+
]));
|
|
1124
|
+
return taggedDigest("signature_registry", Buffer.from(canonical(value), "utf8"));
|
|
1125
|
+
}
|
|
1126
|
+
// Strict like the reference Profile.new/1: shape errors report invalid_type;
|
|
1127
|
+
// unknown names or out-of-accepted-range bounds report invalid_profile.
|
|
1128
|
+
// Omitted members mean the full axis.
|
|
1129
|
+
function parseProfile(spec) {
|
|
1130
|
+
const registryNames = ALG_ROWS.map((row) => row.name);
|
|
1131
|
+
let algorithms = registryNames;
|
|
1132
|
+
if (spec !== undefined && spec.algorithms !== undefined) {
|
|
1133
|
+
if (!Array.isArray(spec.algorithms))
|
|
1134
|
+
return { ok: false, code: "invalid_type" };
|
|
1135
|
+
const names = spec.algorithms;
|
|
1136
|
+
if (names.length === 0 || new Set(names).size !== names.length)
|
|
1137
|
+
return { ok: false, code: "invalid_profile" };
|
|
1138
|
+
if (!names.every((name) => typeof name === "string" && registryNames.includes(name))) {
|
|
1139
|
+
return { ok: false, code: "invalid_profile" };
|
|
1140
|
+
}
|
|
1141
|
+
algorithms = names;
|
|
1142
|
+
}
|
|
1143
|
+
let minRevision = Math.min(...ACCEPTED_PROTOCOL_REVISIONS);
|
|
1144
|
+
let maxRevision = Math.max(...ACCEPTED_PROTOCOL_REVISIONS);
|
|
1145
|
+
if (spec !== undefined && spec.revisions !== undefined) {
|
|
1146
|
+
const bounds = spec.revisions;
|
|
1147
|
+
if (typeof bounds !== "object" || bounds === null ||
|
|
1148
|
+
typeof bounds.min !== "number" || typeof bounds.max !== "number") {
|
|
1149
|
+
return { ok: false, code: "invalid_type" };
|
|
1150
|
+
}
|
|
1151
|
+
if (!ACCEPTED_PROTOCOL_REVISIONS.includes(bounds.min) ||
|
|
1152
|
+
!ACCEPTED_PROTOCOL_REVISIONS.includes(bounds.max) || bounds.min > bounds.max) {
|
|
1153
|
+
return { ok: false, code: "invalid_profile" };
|
|
1154
|
+
}
|
|
1155
|
+
minRevision = bounds.min;
|
|
1156
|
+
maxRevision = bounds.max;
|
|
1157
|
+
}
|
|
1158
|
+
return { ok: true, algorithms, minRevision, maxRevision };
|
|
1159
|
+
}
|
|
1160
|
+
const DEFAULT_SETTINGS = { limits: DEFAULT_LIMITS, profile: { algorithms: ALG_ROWS.map((row) => row.name), minRevision: 1, maxRevision: 3 } };
|
|
1161
|
+
function resolveOptions(options = {}) {
|
|
1162
|
+
if (!isRecord(options) || (options.limits !== undefined && !validLimits(options.limits)))
|
|
1163
|
+
return fail("invalid_limits");
|
|
1164
|
+
if (options.profile !== undefined && (!isRecord(options.profile) || Object.keys(options.profile).some((key) => key !== "algorithms" && key !== "revisions")))
|
|
1165
|
+
return fail("invalid_profile");
|
|
1166
|
+
const profile = parseProfile(options.profile);
|
|
1167
|
+
if (!profile.ok)
|
|
1168
|
+
return fail("invalid_profile");
|
|
1169
|
+
return ok({ limits: { ...DEFAULT_LIMITS, ...options.limits }, profile });
|
|
1170
|
+
}
|
|
1171
|
+
function profileError(alg, revision, settings) {
|
|
1172
|
+
if (alg !== null && !settings.profile.algorithms.includes(alg))
|
|
1173
|
+
return "algorithm_outside_profile";
|
|
1174
|
+
if (revision < settings.profile.minRevision || revision > settings.profile.maxRevision)
|
|
1175
|
+
return "revision_outside_profile";
|
|
1176
|
+
return null;
|
|
1177
|
+
}
|
|
1178
|
+
function revisionWithProfile(text, settings) {
|
|
1179
|
+
const revision = revisionFromText(text, settings.limits);
|
|
1180
|
+
if (!revision.ok)
|
|
1181
|
+
return revision;
|
|
1182
|
+
const admission = profileError(null, revision.value.value.protocol_revision, settings);
|
|
1183
|
+
return admission ? fail(admission) : revision;
|
|
1184
|
+
}
|
|
1185
|
+
function boundedArtifacts(lists, limits) {
|
|
1186
|
+
let bytes = 0;
|
|
1187
|
+
for (const list of lists) {
|
|
1188
|
+
if (!Array.isArray(list))
|
|
1189
|
+
return "invalid_type";
|
|
1190
|
+
for (let i = 0; i < list.length; i++) {
|
|
1191
|
+
if (i >= limits.max_artifact_set_items)
|
|
1192
|
+
return "limit_exceeded";
|
|
1193
|
+
if (typeof list[i] !== "string")
|
|
1194
|
+
return "invalid_type";
|
|
1195
|
+
}
|
|
1196
|
+
bytes += list.reduce((total, text) => total + Buffer.byteLength(text), 0);
|
|
1197
|
+
if (bytes > limits.max_artifact_set_bytes)
|
|
1198
|
+
return "limit_exceeded";
|
|
1199
|
+
}
|
|
1200
|
+
return null;
|
|
1201
|
+
}
|
|
1202
|
+
function chainWithOptions(input, options = {}) {
|
|
1203
|
+
const settings = resolveOptions(options);
|
|
1204
|
+
return settings.ok ? chainFromInput(input, settings.value) : settings;
|
|
1205
|
+
}
|
|
1206
|
+
function chainFromInput(input, settings = DEFAULT_SETTINGS) {
|
|
1207
|
+
if (!isRecord(input))
|
|
1208
|
+
return fail("chain_invalid");
|
|
1209
|
+
const bounded = boundedArtifacts([input.revisions, input.acceptances, input.descriptors, input.terminations], settings.limits);
|
|
1210
|
+
if (bounded)
|
|
1211
|
+
return fail(bounded);
|
|
751
1212
|
if (!Array.isArray(input.revisions) || input.revisions.length === 0)
|
|
752
1213
|
return fail("chain_invalid");
|
|
753
|
-
const descriptors =
|
|
1214
|
+
const descriptors = descriptorViews(input.descriptors, settings);
|
|
754
1215
|
if (!descriptors.ok)
|
|
755
|
-
return
|
|
1216
|
+
return descriptors;
|
|
756
1217
|
const revisions = [];
|
|
757
1218
|
for (const text of input.revisions) {
|
|
758
|
-
const revision = revisionFromText(text);
|
|
1219
|
+
const revision = revisionFromText(text, settings.limits);
|
|
759
1220
|
if (!revision.ok)
|
|
760
|
-
return
|
|
1221
|
+
return revision;
|
|
761
1222
|
revisions.push(revision.value);
|
|
762
1223
|
}
|
|
1224
|
+
for (const revision of revisions) {
|
|
1225
|
+
const admission = profileError(null, revision.value.protocol_revision, settings);
|
|
1226
|
+
if (admission)
|
|
1227
|
+
return fail(admission);
|
|
1228
|
+
}
|
|
763
1229
|
const byDigest = new Map(revisions.map((one) => [one.digest, one]));
|
|
764
1230
|
if (byDigest.size !== revisions.length)
|
|
765
1231
|
return fail("chain_invalid");
|
|
@@ -785,35 +1251,37 @@ function chainFromInput(input) {
|
|
|
785
1251
|
}
|
|
786
1252
|
}
|
|
787
1253
|
}
|
|
1254
|
+
const owners = new Map(descriptors.value.descriptors.map((one) => [one.digest, one.payload.party_id ?? one.digest]));
|
|
1255
|
+
const named = new Set();
|
|
1256
|
+
for (const revision of revisions) {
|
|
1257
|
+
const parties = revision.value.parties.map((party) => owners.get(party.party_descriptor_digest)).filter((id) => id !== undefined);
|
|
1258
|
+
if (new Set(parties).size !== parties.length)
|
|
1259
|
+
return fail("chain_invalid");
|
|
1260
|
+
for (const id of parties)
|
|
1261
|
+
named.add(id);
|
|
1262
|
+
}
|
|
1263
|
+
if (descriptors.value.histories.some((history) => !named.has(history.descriptors[0].payload.party_id ?? history.descriptors[0].digest)))
|
|
1264
|
+
return fail("chain_invalid");
|
|
788
1265
|
const acceptances = [];
|
|
789
1266
|
const coordinates = new Set();
|
|
790
1267
|
for (const compact of (input.acceptances || [])) {
|
|
791
|
-
const decoded = decodeJws(compact);
|
|
1268
|
+
const decoded = decodeJws(compact, settings.limits, "cap+acceptance");
|
|
792
1269
|
if (!decoded.ok)
|
|
1270
|
+
return decoded;
|
|
1271
|
+
if (typeof decoded.value.payload.revision_digest !== "string" || typeof decoded.value.payload.party_descriptor_digest !== "string")
|
|
793
1272
|
return fail("chain_invalid");
|
|
794
1273
|
const revision = byDigest.get(decoded.value.payload.revision_digest);
|
|
795
|
-
if (!revision)
|
|
1274
|
+
if (!revision || !descriptors.value.descriptors.some((one) => one.digest === decoded.value.payload.party_descriptor_digest))
|
|
796
1275
|
return fail("chain_invalid");
|
|
797
|
-
const verified = acceptanceFromCompact(compact, revision, descriptors.value);
|
|
1276
|
+
const verified = acceptanceFromCompact(compact, revision, descriptors.value, settings);
|
|
798
1277
|
if (!verified.ok)
|
|
799
|
-
return
|
|
1278
|
+
return verified;
|
|
800
1279
|
const coordinate = `${verified.value.claims.revision_digest}\0${verified.value.claims.party_descriptor_digest}\0${verified.value.claims.party_role}`;
|
|
801
1280
|
if (coordinates.has(coordinate))
|
|
802
1281
|
return fail("chain_invalid");
|
|
803
1282
|
coordinates.add(coordinate);
|
|
804
1283
|
acceptances.push(verified.value);
|
|
805
1284
|
}
|
|
806
|
-
for (const compact of (input.terminations || [])) {
|
|
807
|
-
const decoded = decodeJws(compact);
|
|
808
|
-
if (!decoded.ok)
|
|
809
|
-
return fail("chain_invalid");
|
|
810
|
-
const revision = byDigest.get(decoded.value.payload.governing_revision_digest);
|
|
811
|
-
if (!revision)
|
|
812
|
-
return fail("chain_invalid");
|
|
813
|
-
const verified = terminationFromCompact(compact, revision, descriptors.value);
|
|
814
|
-
if (!verified.ok)
|
|
815
|
-
return fail("chain_invalid");
|
|
816
|
-
}
|
|
817
1285
|
const accepted = revisions.filter((revision) => {
|
|
818
1286
|
const expected = new Set(revision.value.parties.map((party) => `${party.party_descriptor_digest}\0${party.role}`));
|
|
819
1287
|
const actual = new Set(acceptances
|
|
@@ -826,6 +1294,24 @@ function chainFromInput(input) {
|
|
|
826
1294
|
return false;
|
|
827
1295
|
return true;
|
|
828
1296
|
});
|
|
1297
|
+
const acceptedSet = new Set(accepted.map((one) => one.digest));
|
|
1298
|
+
if (accepted.some((one) => (one.value.supersedes ?? []).some((digest) => !acceptedSet.has(digest))))
|
|
1299
|
+
return fail("chain_invalid");
|
|
1300
|
+
const terminations = [];
|
|
1301
|
+
for (const compact of (input.terminations || [])) {
|
|
1302
|
+
const decoded = decodeJws(compact, settings.limits, "cap+termination");
|
|
1303
|
+
if (!decoded.ok)
|
|
1304
|
+
return decoded;
|
|
1305
|
+
if (typeof decoded.value.payload.governing_revision_digest !== "string" || typeof decoded.value.payload.party_descriptor_digest !== "string")
|
|
1306
|
+
return fail("chain_invalid");
|
|
1307
|
+
const revision = byDigest.get(decoded.value.payload.governing_revision_digest);
|
|
1308
|
+
if (!revision || !descriptors.value.descriptors.some((one) => one.digest === decoded.value.payload.party_descriptor_digest))
|
|
1309
|
+
return fail("chain_invalid");
|
|
1310
|
+
const verified = terminationFromCompact(compact, revision, descriptors.value, settings);
|
|
1311
|
+
if (!verified.ok)
|
|
1312
|
+
return verified;
|
|
1313
|
+
terminations.push(verified.value);
|
|
1314
|
+
}
|
|
829
1315
|
const superseded = new Set(accepted.flatMap((one) => one.value.supersedes || []));
|
|
830
1316
|
const active = accepted.filter((one) => !superseded.has(one.digest));
|
|
831
1317
|
const maximum = Math.max(...active.map((one) => one.value.revision_number));
|
|
@@ -849,7 +1335,7 @@ function chainFromInput(input) {
|
|
|
849
1335
|
};
|
|
850
1336
|
const linear = heads.length === 1 && ancestryCovers(heads[0].digest);
|
|
851
1337
|
const topology = active.length > 0 && !linear ? "forked" : "linear";
|
|
852
|
-
return ok({ descriptors: descriptors.value, revisions, acceptances, accepted, acceptedDigests: accepted.map((one) => one.digest).sort(), supersededDigests: [...superseded].sort(), topology, charterId });
|
|
1338
|
+
return ok(factsRecord({ descriptors: descriptors.value, revisions, acceptances, terminations, accepted, acceptedDigests: accepted.map((one) => one.digest).sort(), supersededDigests: [...superseded].sort(), topology, charterId }));
|
|
853
1339
|
}
|
|
854
1340
|
// Governing mirrors the reference semantics exactly: candidates are accepted,
|
|
855
1341
|
// non-superseded, and effective at the instant (start-inclusive, end-exclusive
|
|
@@ -866,6 +1352,14 @@ function effectiveAt(revision, at) {
|
|
|
866
1352
|
return until !== null && compareTimestamps(at, until) < 0;
|
|
867
1353
|
}
|
|
868
1354
|
function governing(chain, at) {
|
|
1355
|
+
const closed = chain.terminations.some((notice) => {
|
|
1356
|
+
const effective = parseTimestamp(notice.claims.effective_at);
|
|
1357
|
+
return compareTimestamps(effective, at) <= 0 &&
|
|
1358
|
+
selectGoverning(chain, effective) === notice.claims.governing_revision_digest;
|
|
1359
|
+
});
|
|
1360
|
+
return closed ? "none" : selectGoverning(chain, at);
|
|
1361
|
+
}
|
|
1362
|
+
function selectGoverning(chain, at) {
|
|
869
1363
|
const applicable = chain.accepted.filter((one) => !chain.supersededDigests.includes(one.digest) && effectiveAt(one, at));
|
|
870
1364
|
if (applicable.length === 0)
|
|
871
1365
|
return "none";
|
|
@@ -920,8 +1414,10 @@ function receiptSigningKeys(chain, claimedRevision, role) {
|
|
|
920
1414
|
}));
|
|
921
1415
|
return [...new Map(keys.map((key) => [canonical(key), key])).values()];
|
|
922
1416
|
}
|
|
923
|
-
function receiptFromCompact(compact,
|
|
924
|
-
const
|
|
1417
|
+
function receiptFromCompact(compact, context, settings = DEFAULT_SETTINGS) {
|
|
1418
|
+
const revisionOnly = context.kind === "revision";
|
|
1419
|
+
const chain = context.kind === "chain" ? context.chain : { accepted: [context.revision], charterId: context.revision.value.charter_id || context.revision.digest };
|
|
1420
|
+
const decoded = decodeJws(compact, settings.limits, "cap+receipt");
|
|
925
1421
|
if (!decoded.ok)
|
|
926
1422
|
return decoded;
|
|
927
1423
|
const claims = decoded.value.payload;
|
|
@@ -929,19 +1425,46 @@ function receiptFromCompact(compact, chain) {
|
|
|
929
1425
|
if (receiptShape)
|
|
930
1426
|
return fail(receiptShape);
|
|
931
1427
|
const claimedRevision = chain.accepted.find((one) => one.digest === claims.revision_digest);
|
|
932
|
-
const verifiedPublicKeys = new Set(receiptSigningKeys(chain, claimedRevision, claims.issuing_party_role)
|
|
933
|
-
.filter((key) => verifyDecodedJws(decoded.value, "cap+receipt", [key]))
|
|
934
|
-
.map((key) => key.public_key));
|
|
935
|
-
if (verifiedPublicKeys.size !== 1)
|
|
936
|
-
return fail("signature_invalid");
|
|
937
1428
|
const receiptTiming = receiptTimingError(claims);
|
|
938
1429
|
if (receiptTiming)
|
|
939
1430
|
return fail(receiptTiming);
|
|
940
|
-
const governingDigest = governing(chain, parseTimestamp(claims.occurred_at));
|
|
1431
|
+
const governingDigest = context.kind === "revision" ? "contested" : governing(context.chain, parseTimestamp(claims.occurred_at));
|
|
941
1432
|
const projection = projectReceipt(claims, chain, governingDigest);
|
|
942
1433
|
if (!projection.ok)
|
|
943
1434
|
return projection;
|
|
944
|
-
|
|
1435
|
+
if (revisionOnly) {
|
|
1436
|
+
if (!claimedRevision)
|
|
1437
|
+
return fail("receipt_claims_mismatch");
|
|
1438
|
+
const admission = profileError(decoded.value.header.alg, claims.protocol_revision, settings);
|
|
1439
|
+
if (admission)
|
|
1440
|
+
return fail(admission);
|
|
1441
|
+
return ok(factsRecord({ claims, digest: taggedHash("receipt_content", decoded.value.payloadBytes), ...projection.value, optionalExtensions: Object.keys(claims.extensions?.optional || {}).sort(), protocol_revision: claims.protocol_revision, alg: decoded.value.header.alg }, ["signature"]));
|
|
1442
|
+
}
|
|
1443
|
+
// The envelope is admitted before any key is looked up, so an
|
|
1444
|
+
// out-of-profile receipt reports the profile rejection in both context
|
|
1445
|
+
// forms, even when its kid names no key in the view.
|
|
1446
|
+
const envelopeAdmission = profileError(decoded.value.header.alg, claims.protocol_revision, settings);
|
|
1447
|
+
if (envelopeAdmission)
|
|
1448
|
+
return fail(envelopeAdmission);
|
|
1449
|
+
const candidates = receiptSigningKeys(context.chain, claimedRevision, claims.issuing_party_role)
|
|
1450
|
+
.filter((key) => key.key_id === decoded.value.header.kid && key.status === "active")
|
|
1451
|
+
.map((key) => ({ key, result: verifyDecodedJws(decoded.value, "cap+receipt", [key], settings) }));
|
|
1452
|
+
const verifiedPublicKeys = new Set(candidates.filter((one) => one.result.ok).map((one) => one.key.public_key));
|
|
1453
|
+
if (verifiedPublicKeys.size !== 1) {
|
|
1454
|
+
const diagnostic = candidates.find((one) => !one.result.ok && ["algorithm_outside_profile", "revision_outside_profile", "algorithm_unsupported_on_substrate"].includes(one.result.code));
|
|
1455
|
+
return fail(verifiedPublicKeys.size === 0 && diagnostic && !diagnostic.result.ok ? diagnostic.result.code : "signature_invalid");
|
|
1456
|
+
}
|
|
1457
|
+
return ok(factsRecord({ claims, digest: taggedHash("receipt_content", decoded.value.payloadBytes), ...projection.value, optionalExtensions: Object.keys(claims.extensions?.optional || {}).sort(), protocol_revision: claims.protocol_revision, alg: decoded.value.header.alg }));
|
|
1458
|
+
}
|
|
1459
|
+
function receiptWithContext(compact, context, settings) {
|
|
1460
|
+
if (typeof context === "string") {
|
|
1461
|
+
const revision = revisionWithProfile(context, settings);
|
|
1462
|
+
if (!revision.ok)
|
|
1463
|
+
return revision;
|
|
1464
|
+
return receiptFromCompact(compact, { kind: "revision", revision: revision.value }, settings);
|
|
1465
|
+
}
|
|
1466
|
+
const chain = chainFromInput(context, settings);
|
|
1467
|
+
return chain.ok ? receiptFromCompact(compact, { kind: "chain", chain: chain.value }, settings) : chain;
|
|
945
1468
|
}
|
|
946
1469
|
function execute(one) {
|
|
947
1470
|
const input = one.input;
|
|
@@ -954,7 +1477,7 @@ function execute(one) {
|
|
|
954
1477
|
if (input.limits !== undefined && !validLimits(input.limits))
|
|
955
1478
|
return invalid("invalid_limits");
|
|
956
1479
|
const bytes = "text" in input ? Buffer.from(input.text) : Buffer.from(input.bytes_base64url, "base64url");
|
|
957
|
-
const decoded = decodeJsonBytes(bytes);
|
|
1480
|
+
const decoded = decodeJsonBytes(bytes, { ...DEFAULT_LIMITS, ...input.limits });
|
|
958
1481
|
if (!decoded.ok)
|
|
959
1482
|
return invalid(decoded.code);
|
|
960
1483
|
return project(jsonWithinLimits(decoded.value, bytes, input.limits), jsonProjection);
|
|
@@ -1009,8 +1532,19 @@ function execute(one) {
|
|
|
1009
1532
|
return valid({ members });
|
|
1010
1533
|
}
|
|
1011
1534
|
case "party_descriptor.verify": {
|
|
1012
|
-
|
|
1013
|
-
|
|
1535
|
+
// A case may name its predecessor history, genesis first; each entry
|
|
1536
|
+
// verifies under the full profile against the one before it.
|
|
1537
|
+
let predecessor = null;
|
|
1538
|
+
for (const compact of (input.predecessor_compacts ?? [])) {
|
|
1539
|
+
const verified = verifyDescriptor(compact, predecessor);
|
|
1540
|
+
if (!verified.ok)
|
|
1541
|
+
throw new Error("corpus predecessor history does not verify");
|
|
1542
|
+
predecessor = verified.facts;
|
|
1543
|
+
}
|
|
1544
|
+
const verified = verifyDescriptor(input.compact, predecessor, { profile: input.profile });
|
|
1545
|
+
if (!verified.ok)
|
|
1546
|
+
return invalid(verified.code);
|
|
1547
|
+
return valid({ descriptor_digest: verified.facts.descriptor_digest, party_id: verified.facts.party_id, descriptor_number: verified.facts.descriptor_number });
|
|
1014
1548
|
}
|
|
1015
1549
|
case "descriptor_chain.verify": {
|
|
1016
1550
|
const chain = descriptorChain(input.compacts);
|
|
@@ -1021,11 +1555,12 @@ function execute(one) {
|
|
|
1021
1555
|
case "charter_revision.decode":
|
|
1022
1556
|
return project(revisionFromText(input.text), (revision) => ({ revision_digest: revision.digest, revision_number: revision.value.revision_number, precedence_declaration: revision.value.precedence_declaration, abp_binding: { blueprint_id: revision.value.abp_bindings[0].blueprint_id, release_number: revision.value.abp_bindings[0].release_number, content_digest: revision.value.abp_bindings[0].content_digest, deployment_digest: revision.value.abp_bindings[0].deployment_digest } }));
|
|
1023
1557
|
case "acceptance.verify": {
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1558
|
+
// The runner calls the public function, so the corpus checks the code
|
|
1559
|
+
// consumers run.
|
|
1560
|
+
const verified = verifyAcceptance(input.compact, input.revision_text, input.descriptor_compacts, { profile: input.profile });
|
|
1561
|
+
if (!verified.ok)
|
|
1562
|
+
return invalid(verified.code);
|
|
1563
|
+
return valid({ acceptance_digest: verified.facts.acceptance_digest, revision_digest: verified.facts.claims.revision_digest, party_descriptor_digest: verified.facts.claims.party_descriptor_digest, descriptor_position: verified.facts.descriptor_position });
|
|
1029
1564
|
}
|
|
1030
1565
|
case "acceptance.equivocation": {
|
|
1031
1566
|
const chain = descriptorChain(input.descriptor_compacts);
|
|
@@ -1047,18 +1582,24 @@ function execute(one) {
|
|
|
1047
1582
|
return valid({ kind: "acceptance_equivocation", revision_number: facts[0].value.claims.revision_number, revision_digests: facts.map((oneFact) => oneFact.value.claims.revision_digest).sort(), winner: null });
|
|
1048
1583
|
}
|
|
1049
1584
|
case "termination.verify": {
|
|
1050
|
-
const
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
return project(terminationFromCompact(input.compact, revision.value, chain.value), (facts) => ({ termination_digest: facts.digest, governing_revision_digest: facts.claims.governing_revision_digest, party_descriptor_digest: facts.claims.party_descriptor_digest, reason_code: facts.claims.reason_code, descriptor_position: facts.descriptorPosition }));
|
|
1585
|
+
const verified = verifyTermination(input.compact, input.revision_text, input.descriptor_compacts, { profile: input.profile });
|
|
1586
|
+
if (!verified.ok)
|
|
1587
|
+
return invalid(verified.code);
|
|
1588
|
+
return valid({ termination_digest: verified.facts.termination_digest, governing_revision_digest: verified.facts.claims.governing_revision_digest, party_descriptor_digest: verified.facts.claims.party_descriptor_digest, reason_code: verified.facts.claims.reason_code, descriptor_position: verified.facts.descriptor_position });
|
|
1055
1589
|
}
|
|
1056
1590
|
case "chain.verify": {
|
|
1057
|
-
const chain =
|
|
1591
|
+
const chain = chainWithOptions(input, { limits: input.limits });
|
|
1058
1592
|
return project(chain, (facts) => ({ charter_id: facts.charterId, topology: facts.topology, accepted_revision_digests: facts.acceptedDigests, superseded_revision_digests: facts.supersededDigests }));
|
|
1059
1593
|
}
|
|
1594
|
+
case "chain.verify_profile": {
|
|
1595
|
+
const profile = parseProfile(input.profile);
|
|
1596
|
+
if (!profile.ok)
|
|
1597
|
+
return invalid(profile.code);
|
|
1598
|
+
const chain = chainWithOptions(input, { profile: input.profile });
|
|
1599
|
+
return project(chain, (facts) => ({ charter_id: facts.charterId, topology: facts.topology }));
|
|
1600
|
+
}
|
|
1060
1601
|
case "governing_revision": {
|
|
1061
|
-
const chain =
|
|
1602
|
+
const chain = chainWithOptions(input, { limits: input.limits });
|
|
1062
1603
|
if (!chain.ok)
|
|
1063
1604
|
return invalid("governing_invalid");
|
|
1064
1605
|
return valid({
|
|
@@ -1069,10 +1610,10 @@ function execute(one) {
|
|
|
1069
1610
|
});
|
|
1070
1611
|
}
|
|
1071
1612
|
case "receipt.verify": {
|
|
1072
|
-
const
|
|
1073
|
-
if (!
|
|
1074
|
-
return invalid(
|
|
1075
|
-
return project(
|
|
1613
|
+
const settings = resolveOptions({ profile: input.profile });
|
|
1614
|
+
if (!settings.ok)
|
|
1615
|
+
return invalid(settings.code);
|
|
1616
|
+
return project(receiptWithContext(input.compact, input.revision_text ?? input.chain, settings.value), (facts) => ({ receipt_digest: facts.digest, revision_number: facts.claims.revision_number, revision_digest: facts.claims.revision_digest, decision: facts.claims.decision, outcome: facts.claims.outcome, chain_conflict: facts.chainConflict, governing_match: facts.governingMatch, deployment_digest_matched: facts.deploymentMatched, optional_extensions_retained: facts.optionalExtensions }));
|
|
1076
1617
|
}
|
|
1077
1618
|
default:
|
|
1078
1619
|
throw new Error("unsupported surface");
|
|
@@ -1149,6 +1690,8 @@ export function reportFor(root) {
|
|
|
1149
1690
|
const corpus = loadCorpus(root);
|
|
1150
1691
|
const results = corpus.cases.map((one) => {
|
|
1151
1692
|
const actual = execute(one);
|
|
1693
|
+
if (actual.status === "invalid" && actual.error_code === "algorithm_unsupported_on_substrate")
|
|
1694
|
+
throw new Error("algorithm_unsupported_on_substrate: corpus verification unavailable");
|
|
1152
1695
|
return { id: one.id, surface: one.surface, agree: canonical(actual) === canonical(one.expect), expected: one.expect, actual };
|
|
1153
1696
|
});
|
|
1154
1697
|
const agreed = results.filter((one) => one.agree).length;
|
|
@@ -1266,7 +1809,7 @@ export function selfChecks() {
|
|
|
1266
1809
|
if (parseTimestamp("2026-06-30T23:59:60Z") === null || parseTimestamp("2024-03-31T23:59:60Z") !== null) {
|
|
1267
1810
|
throw new Error("leap-second window drifted");
|
|
1268
1811
|
}
|
|
1269
|
-
if (parseTimestamp("2026-02-30T00:00:00Z") !== null || parseTimestamp("0000-01-01T00:00:00Z")
|
|
1812
|
+
if (parseTimestamp("2026-02-30T00:00:00Z") !== null || parseTimestamp("0000-01-01T00:00:00Z") === null || parseTimestamp("0000-02-29T00:00:00Z") === null) {
|
|
1270
1813
|
throw new Error("calendar validation drifted");
|
|
1271
1814
|
}
|
|
1272
1815
|
const halfMs = parseTimestamp("2026-01-01T00:00:00.0005Z");
|
|
@@ -1307,11 +1850,14 @@ export function decodeArtifact(compact) {
|
|
|
1307
1850
|
if (!decoded.ok)
|
|
1308
1851
|
return { ok: false, code: decoded.code };
|
|
1309
1852
|
const { header, payload } = decoded.value;
|
|
1310
|
-
return { ok: true, facts: { alg: header.alg, kid: header.kid, typ: header.typ, payload } };
|
|
1853
|
+
return { ok: true, facts: factsRecord({ alg: header.alg, kid: header.kid, typ: header.typ, payload, protocol_revision: payload.protocol_revision }, ["signature"]) };
|
|
1311
1854
|
}
|
|
1312
1855
|
// Strict signature verification over exact bytes with a base64url public
|
|
1313
1856
|
// key under the registry row for `alg` — the wrong-key guard primitive.
|
|
1314
|
-
export function verifySignature(message, signature, publicKeyBase64url, alg) {
|
|
1857
|
+
export function verifySignature(message, signature, publicKeyBase64url, alg, options = {}) {
|
|
1858
|
+
const settings = resolveOptions(options);
|
|
1859
|
+
if (!settings.ok || !settings.value.profile.algorithms.includes(alg) || message.length > settings.value.limits.max_bytes)
|
|
1860
|
+
return false;
|
|
1315
1861
|
const row = ALG_ROWS.find((one) => one.name === alg);
|
|
1316
1862
|
if (!row)
|
|
1317
1863
|
return false;
|
|
@@ -1322,68 +1868,114 @@ export function verifySignature(message, signature, publicKeyBase64url, alg) {
|
|
|
1322
1868
|
return ed25519(publicKeyBase64url, message, signature);
|
|
1323
1869
|
return mldsa(row.keyAlgorithm, publicKeyBase64url, message, signature);
|
|
1324
1870
|
}
|
|
1325
|
-
|
|
1326
|
-
|
|
1871
|
+
const PREDECESSOR_PASS_THROUGH = new Set(["algorithm_outside_profile", "revision_outside_profile", "algorithm_unsupported_on_substrate"]);
|
|
1872
|
+
function reverifyPredecessor(supplied, settings) {
|
|
1873
|
+
if (supplied === null)
|
|
1874
|
+
return ok(null);
|
|
1875
|
+
if (!isRecord(supplied) || !Array.isArray(supplied.lineage) || supplied.lineage.length === 0)
|
|
1876
|
+
return fail("descriptor_chain_invalid");
|
|
1877
|
+
let previous = null;
|
|
1878
|
+
for (const compact of [...supplied.lineage].reverse()) {
|
|
1879
|
+
if (typeof compact !== "string")
|
|
1880
|
+
return fail("descriptor_chain_invalid");
|
|
1881
|
+
const verified = descriptorFromCompact(compact, previous, settings);
|
|
1882
|
+
// A profile rejection, or a runtime that cannot check the signature, is
|
|
1883
|
+
// reported as itself, as a chain view reports it; any other failure is a
|
|
1884
|
+
// broken chain.
|
|
1885
|
+
if (!verified.ok)
|
|
1886
|
+
return PREDECESSOR_PASS_THROUGH.has(verified.code) ? verified : fail("descriptor_chain_invalid");
|
|
1887
|
+
previous = verified.value;
|
|
1888
|
+
}
|
|
1889
|
+
if (!previous || (supplied.descriptor_digest ?? supplied.digest) !== previous.digest ||
|
|
1890
|
+
(supplied.digest !== undefined && supplied.digest !== previous.digest))
|
|
1891
|
+
return fail("descriptor_chain_invalid");
|
|
1892
|
+
return ok(previous);
|
|
1893
|
+
}
|
|
1894
|
+
export function verifyDescriptor(compact, predecessor = null, options = {}) {
|
|
1895
|
+
const settings = resolveOptions(options);
|
|
1896
|
+
if (!settings.ok)
|
|
1897
|
+
return settings;
|
|
1898
|
+
const previous = reverifyPredecessor(predecessor, settings.value);
|
|
1899
|
+
if (!previous.ok)
|
|
1900
|
+
return previous;
|
|
1901
|
+
const verified = descriptorFromCompact(compact, previous.value, settings.value);
|
|
1327
1902
|
if (!verified.ok)
|
|
1328
1903
|
return { ok: false, code: verified.code };
|
|
1329
1904
|
const one = verified.value;
|
|
1330
1905
|
return {
|
|
1331
1906
|
ok: true,
|
|
1332
|
-
facts: {
|
|
1907
|
+
facts: factsRecord({
|
|
1333
1908
|
descriptor_digest: one.digest,
|
|
1334
|
-
party_id: one.digest,
|
|
1909
|
+
party_id: one.payload.party_id ?? one.digest,
|
|
1335
1910
|
descriptor_number: one.payload.descriptor_number,
|
|
1911
|
+
lineage: [...one.lineage],
|
|
1336
1912
|
protocol_revision: one.payload.protocol_revision,
|
|
1337
|
-
|
|
1913
|
+
alg: one.header.alg,
|
|
1914
|
+
}),
|
|
1338
1915
|
};
|
|
1339
1916
|
}
|
|
1340
|
-
export function verifyDescriptorChain(compacts) {
|
|
1341
|
-
const
|
|
1917
|
+
export function verifyDescriptorChain(compacts, options = {}) {
|
|
1918
|
+
const settings = resolveOptions(options);
|
|
1919
|
+
if (!settings.ok)
|
|
1920
|
+
return settings;
|
|
1921
|
+
const verified = descriptorChain(compacts, settings.value);
|
|
1342
1922
|
if (!verified.ok)
|
|
1343
1923
|
return { ok: false, code: verified.code };
|
|
1344
1924
|
return { ok: true, facts: verified.value };
|
|
1345
1925
|
}
|
|
1346
|
-
export function verifyAcceptance(compact, revisionText, descriptorCompacts) {
|
|
1347
|
-
const
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1926
|
+
export function verifyAcceptance(compact, revisionText, descriptorCompacts, options = {}) {
|
|
1927
|
+
const settings = resolveOptions(options);
|
|
1928
|
+
if (!settings.ok)
|
|
1929
|
+
return settings;
|
|
1930
|
+
const revision = revisionWithProfile(revisionText, settings.value);
|
|
1931
|
+
if (!revision.ok)
|
|
1932
|
+
return revision;
|
|
1933
|
+
const chain = descriptorChain(descriptorCompacts, settings.value);
|
|
1934
|
+
if (!chain.ok)
|
|
1935
|
+
return chain;
|
|
1936
|
+
const verified = acceptanceFromCompact(compact, revision.value, chain.value, settings.value);
|
|
1352
1937
|
if (!verified.ok)
|
|
1353
1938
|
return { ok: false, code: verified.code };
|
|
1354
|
-
return { ok: true, facts: { acceptance_digest: verified.value.digest, claims: verified.value.claims, descriptor_position: verified.value.descriptorPosition } };
|
|
1355
|
-
}
|
|
1356
|
-
export function verifyTermination(compact, revisionText, descriptorCompacts) {
|
|
1357
|
-
const
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1939
|
+
return { ok: true, facts: factsRecord({ acceptance_digest: verified.value.digest, claims: verified.value.claims, descriptor_position: verified.value.descriptorPosition, protocol_revision: verified.value.protocol_revision, alg: verified.value.alg }) };
|
|
1940
|
+
}
|
|
1941
|
+
export function verifyTermination(compact, revisionText, descriptorCompacts, options = {}) {
|
|
1942
|
+
const settings = resolveOptions(options);
|
|
1943
|
+
if (!settings.ok)
|
|
1944
|
+
return settings;
|
|
1945
|
+
const revision = revisionWithProfile(revisionText, settings.value);
|
|
1946
|
+
if (!revision.ok)
|
|
1947
|
+
return revision;
|
|
1948
|
+
const chain = descriptorChain(descriptorCompacts, settings.value);
|
|
1949
|
+
if (!chain.ok)
|
|
1950
|
+
return chain;
|
|
1951
|
+
const verified = terminationFromCompact(compact, revision.value, chain.value, settings.value);
|
|
1362
1952
|
if (!verified.ok)
|
|
1363
1953
|
return { ok: false, code: verified.code };
|
|
1364
|
-
return { ok: true, facts: { termination_digest: verified.value.digest, claims: verified.value.claims, descriptor_position: verified.value.descriptorPosition } };
|
|
1954
|
+
return { ok: true, facts: factsRecord({ termination_digest: verified.value.digest, claims: verified.value.claims, descriptor_position: verified.value.descriptorPosition, protocol_revision: verified.value.protocol_revision, alg: verified.value.alg }) };
|
|
1365
1955
|
}
|
|
1366
|
-
export function verifyChain(chainInput) {
|
|
1367
|
-
const verified =
|
|
1956
|
+
export function verifyChain(chainInput, options = {}) {
|
|
1957
|
+
const verified = chainWithOptions(chainInput, options);
|
|
1368
1958
|
if (!verified.ok)
|
|
1369
1959
|
return { ok: false, code: verified.code };
|
|
1370
1960
|
return { ok: true, facts: verified.value };
|
|
1371
1961
|
}
|
|
1372
|
-
export function verifyReceipt(compact,
|
|
1373
|
-
const
|
|
1374
|
-
if (!
|
|
1375
|
-
return
|
|
1376
|
-
const verified =
|
|
1962
|
+
export function verifyReceipt(compact, context, options = {}) {
|
|
1963
|
+
const settings = resolveOptions(options);
|
|
1964
|
+
if (!settings.ok)
|
|
1965
|
+
return settings;
|
|
1966
|
+
const verified = receiptWithContext(compact, context, settings.value);
|
|
1377
1967
|
if (!verified.ok)
|
|
1378
1968
|
return { ok: false, code: verified.code };
|
|
1379
1969
|
return {
|
|
1380
1970
|
ok: true,
|
|
1381
|
-
facts: {
|
|
1971
|
+
facts: factsRecord({
|
|
1972
|
+
protocol_revision: verified.value.protocol_revision,
|
|
1973
|
+
alg: verified.value.alg,
|
|
1382
1974
|
receipt_digest: verified.value.digest,
|
|
1383
1975
|
claims: verified.value.claims,
|
|
1384
1976
|
governing_match: verified.value.governingMatch,
|
|
1385
1977
|
chain_conflict: verified.value.chainConflict,
|
|
1386
|
-
},
|
|
1978
|
+
}, typeof context === "string" ? ["signature"] : []),
|
|
1387
1979
|
};
|
|
1388
1980
|
}
|
|
1389
1981
|
// ---------------------------------------------------------------------------
|
|
@@ -1397,47 +1989,69 @@ export function verifyReceipt(compact, chainInput) {
|
|
|
1397
1989
|
export function checkSigningClaims(kind, claims) {
|
|
1398
1990
|
if (!claims || typeof claims !== "object" || Array.isArray(claims))
|
|
1399
1991
|
return { ok: false, code: "invalid_type" };
|
|
1400
|
-
const error = kind === "descriptor" ?
|
|
1992
|
+
const error = kind === "descriptor" ? signingDescriptorError(claims) :
|
|
1401
1993
|
kind === "acceptance" ? acceptanceClaimsError(claims) :
|
|
1402
1994
|
kind === "termination" ? terminationClaimsError(claims) :
|
|
1403
1995
|
kind === "receipt" ? (receiptGrantError(claims) ?? receiptTimingError(claims)) :
|
|
1404
1996
|
"invalid_type";
|
|
1405
1997
|
return error ? { ok: false, code: error } : { ok: true };
|
|
1406
1998
|
}
|
|
1999
|
+
// Preserve the preflight helper's existing local-code precedence.
|
|
2000
|
+
function signingDescriptorError(claims) {
|
|
2001
|
+
if (claims.descriptor_number === 1 && claims.prev_descriptor_digest !== undefined)
|
|
2002
|
+
return "descriptor_invalid";
|
|
2003
|
+
const grammar = keyGrammarError(claims);
|
|
2004
|
+
return grammar ?? descriptorClaimsError(claims);
|
|
2005
|
+
}
|
|
1407
2006
|
function acceptanceClaimsError(claims) {
|
|
1408
|
-
|
|
2007
|
+
const shape = schemaError(claims, ACCEPTANCE_SCHEMA);
|
|
2008
|
+
if (shape)
|
|
2009
|
+
return shape;
|
|
2010
|
+
if ([claims.charter_id, claims.revision_digest, claims.prev_revision_digest, claims.party_descriptor_digest].filter((value) => value !== undefined).some((value) => !validTaggedDigest(value)))
|
|
1409
2011
|
return "acceptance_invalid";
|
|
1410
2012
|
if (!parseTimestamp(claims.accepted_at))
|
|
1411
2013
|
return "timestamp_invalid";
|
|
2014
|
+
if ((claims.revision_number === 1) !== (claims.prev_revision_digest === undefined))
|
|
2015
|
+
return "acceptance_invalid";
|
|
1412
2016
|
return null;
|
|
1413
2017
|
}
|
|
1414
2018
|
function terminationClaimsError(claims) {
|
|
2019
|
+
const shape = schemaError(claims, TERMINATION_SCHEMA);
|
|
2020
|
+
if (shape)
|
|
2021
|
+
return shape;
|
|
2022
|
+
if ([claims.charter_id, claims.governing_revision_digest, claims.party_descriptor_digest, claims.detail_digest].filter((value) => value !== undefined).some((value) => !validTaggedDigest(value)))
|
|
2023
|
+
return "termination_invalid";
|
|
1415
2024
|
const issuedAt = parseTimestamp(claims.issued_at);
|
|
1416
2025
|
const effectiveAt = parseTimestamp(claims.effective_at);
|
|
1417
|
-
if (!issuedAt || !effectiveAt
|
|
2026
|
+
if (!issuedAt || !effectiveAt)
|
|
2027
|
+
return "timestamp_invalid";
|
|
2028
|
+
if (compareTimestamps(issuedAt, effectiveAt) > 0)
|
|
1418
2029
|
return "termination_invalid";
|
|
1419
2030
|
return null;
|
|
1420
2031
|
}
|
|
1421
2032
|
function receiptGrantError(claims) {
|
|
1422
|
-
|
|
2033
|
+
const shape = schemaError(claims, RECEIPT_SCHEMA);
|
|
2034
|
+
if (shape)
|
|
2035
|
+
return shape;
|
|
2036
|
+
if ([claims.charter_id, claims.revision_digest, claims.deployment_digest, claims.grant.grant_digest].filter((value) => value !== undefined).some((value) => !validTaggedDigest(value)))
|
|
1423
2037
|
return "receipt_invalid";
|
|
1424
|
-
const
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
return "extension_scope_invalid";
|
|
1431
|
-
if (profile.schema_digest === null)
|
|
1432
|
-
return "extension_schema_unavailable";
|
|
1433
|
-
}
|
|
1434
|
-
return null;
|
|
2038
|
+
const allowed = receiptTimingMatrixError(claims);
|
|
2039
|
+
if (allowed)
|
|
2040
|
+
return allowed;
|
|
2041
|
+
if (claims.grant.scheme === "bap" && claims.grant.grant_digest === undefined)
|
|
2042
|
+
return "receipt_invalid";
|
|
2043
|
+
return extensionError(claims.extensions, "receipt");
|
|
1435
2044
|
}
|
|
1436
2045
|
function receiptTimingError(claims) {
|
|
1437
2046
|
const occurredAt = parseTimestamp(claims.occurred_at);
|
|
1438
2047
|
const recordedAt = parseTimestamp(claims.recorded_at);
|
|
1439
|
-
if (!occurredAt || !recordedAt
|
|
2048
|
+
if (!occurredAt || !recordedAt)
|
|
2049
|
+
return "timestamp_invalid";
|
|
2050
|
+
if (compareTimestamps(recordedAt, occurredAt) < 0)
|
|
1440
2051
|
return "receipt_invalid";
|
|
2052
|
+
return receiptTimingMatrixError(claims);
|
|
2053
|
+
}
|
|
2054
|
+
function receiptTimingMatrixError(claims) {
|
|
1441
2055
|
// The closed matrix mirrors the reference decoder: rejected requires
|
|
1442
2056
|
// no_effect; accepted admits effect_committed, no_effect, or indeterminate.
|
|
1443
2057
|
const outcomeAllowed = claims.decision === "rejected" ? claims.outcome === "no_effect" :
|
|
@@ -1447,12 +2061,22 @@ function receiptTimingError(claims) {
|
|
|
1447
2061
|
return null;
|
|
1448
2062
|
}
|
|
1449
2063
|
function descriptorClaimsError(payload) {
|
|
2064
|
+
const shape = schemaError(payload, DESCRIPTOR_SCHEMA);
|
|
2065
|
+
if (shape)
|
|
2066
|
+
return shape;
|
|
2067
|
+
if ([payload.party_id, payload.prev_descriptor_digest].filter((value) => value !== undefined).some((value) => !validTaggedDigest(value)))
|
|
2068
|
+
return "descriptor_invalid";
|
|
1450
2069
|
const grammar = keyGrammarError(payload);
|
|
1451
2070
|
if (grammar)
|
|
1452
2071
|
return grammar;
|
|
2072
|
+
if (new Set(payload.verification_keys.map((key) => key.key_id)).size !== payload.verification_keys.length || !payload.verification_keys.some((key) => key.status === "active"))
|
|
2073
|
+
return "descriptor_invalid";
|
|
2074
|
+
const extensions = extensionError(payload.extensions, "party_descriptor");
|
|
2075
|
+
if (extensions)
|
|
2076
|
+
return extensions;
|
|
1453
2077
|
if (!parseTimestamp(payload.effective_from))
|
|
1454
2078
|
return "timestamp_invalid";
|
|
1455
|
-
if (payload.descriptor_number === 1
|
|
2079
|
+
if (payload.descriptor_number === 1 ? (payload.prev_descriptor_digest !== undefined || payload.party_id !== undefined) : (payload.prev_descriptor_digest === undefined || payload.party_id === undefined))
|
|
1456
2080
|
return "descriptor_invalid";
|
|
1457
2081
|
return null;
|
|
1458
2082
|
}
|
|
@@ -1464,28 +2088,31 @@ function descriptorClaimsError(payload) {
|
|
|
1464
2088
|
// ---------------------------------------------------------------------------
|
|
1465
2089
|
// The unique governing revision in a verified view at one UTC instant -
|
|
1466
2090
|
// a digest, or "contested"/"none" (never silently resolved).
|
|
1467
|
-
export function governingRevision(chainInput, at) {
|
|
2091
|
+
export function governingRevision(chainInput, at, options = {}) {
|
|
1468
2092
|
const instant = typeof at === "string" ? parseTimestamp(at) : null;
|
|
1469
2093
|
if (!instant)
|
|
1470
2094
|
return { ok: false, code: "invalid_type" };
|
|
1471
2095
|
if (!chainInput || typeof chainInput !== "object" || Array.isArray(chainInput)) {
|
|
1472
2096
|
return { ok: false, code: "signing_input_invalid" };
|
|
1473
2097
|
}
|
|
1474
|
-
const chain =
|
|
2098
|
+
const chain = chainWithOptions(chainInput, options);
|
|
1475
2099
|
if (!chain.ok)
|
|
1476
|
-
return
|
|
2100
|
+
return chain;
|
|
1477
2101
|
return { ok: true, governing: governing(chain.value, instant) };
|
|
1478
2102
|
}
|
|
1479
2103
|
// Decode one canonical unsigned Charter Revision: the parsed claims plus
|
|
1480
2104
|
// its content digest, computed over the exact text bytes.
|
|
1481
|
-
export function decodeCharterRevision(text) {
|
|
1482
|
-
const
|
|
2105
|
+
export function decodeCharterRevision(text, options = {}) {
|
|
2106
|
+
const settings = resolveOptions(options);
|
|
2107
|
+
if (!settings.ok)
|
|
2108
|
+
return settings;
|
|
2109
|
+
const revision = revisionFromText(text, settings.value.limits);
|
|
1483
2110
|
if (!revision.ok)
|
|
1484
2111
|
return { ok: false, code: revision.code };
|
|
1485
2112
|
return { ok: true, revision: revision.value.value, digest: revision.value.digest };
|
|
1486
2113
|
}
|
|
1487
|
-
export function revisionDigest(text) {
|
|
1488
|
-
const revision = decodeCharterRevision(text);
|
|
2114
|
+
export function revisionDigest(text, options = {}) {
|
|
2115
|
+
const revision = decodeCharterRevision(text, options);
|
|
1489
2116
|
if (!revision.ok)
|
|
1490
2117
|
return revision;
|
|
1491
2118
|
return { ok: true, digest: revision.digest };
|
|
@@ -1539,13 +2166,13 @@ function jsonValueError(value) {
|
|
|
1539
2166
|
// decode (the reference producer's exact ordering, so error precedence
|
|
1540
2167
|
// matches too).
|
|
1541
2168
|
function buildSigningInput(kind, kid, claims, algorithm) {
|
|
1542
|
-
if (typeof algorithm === "undefined"
|
|
2169
|
+
if (typeof algorithm === "undefined")
|
|
1543
2170
|
algorithm = defaultEmissionName();
|
|
1544
2171
|
if (typeof algorithm !== "string" || !(algorithm in emissions())) {
|
|
1545
|
-
return { ok: false, code: "
|
|
2172
|
+
return { ok: false, code: "signing_input_invalid" };
|
|
1546
2173
|
}
|
|
1547
2174
|
if (!claims || typeof claims !== "object" || Array.isArray(claims)) {
|
|
1548
|
-
return { ok: false, code: "
|
|
2175
|
+
return { ok: false, code: "signing_input_invalid" };
|
|
1549
2176
|
}
|
|
1550
2177
|
const record = claims;
|
|
1551
2178
|
if (jsonValueError(record))
|
|
@@ -1559,7 +2186,7 @@ function buildSigningInput(kind, kid, claims, algorithm) {
|
|
|
1559
2186
|
}
|
|
1560
2187
|
const row = ALG_ROWS.find((one) => one.name === algorithm);
|
|
1561
2188
|
if (!row)
|
|
1562
|
-
return { ok: false, code: "
|
|
2189
|
+
return { ok: false, code: "signing_input_invalid" };
|
|
1563
2190
|
const payloadSegment = encodeBase64url(Buffer.from(canonical(record), "utf8"));
|
|
1564
2191
|
const protectedSegment = encodeBase64url(Buffer.from(canonical({ alg: algorithm, kid, typ: PRODUCER_TYPES[kind] }), "utf8"));
|
|
1565
2192
|
const message = Buffer.from(`${protectedSegment}.${payloadSegment}`, "utf8");
|
|
@@ -1572,12 +2199,12 @@ function buildSigningInput(kind, kid, claims, algorithm) {
|
|
|
1572
2199
|
// decode_for_signing inside the Elixir build pipeline.
|
|
1573
2200
|
const claimsGate = checkSigningClaims(kind, record);
|
|
1574
2201
|
if (!claimsGate.ok)
|
|
1575
|
-
return { ok: false, code:
|
|
2202
|
+
return { ok: false, code: "signing_input_invalid" };
|
|
1576
2203
|
// The provisional check: a zero signature at the row's exact length must
|
|
1577
2204
|
// frame and bind.
|
|
1578
2205
|
const zeroSignature = Buffer.alloc(row.signatureBytes);
|
|
1579
2206
|
const provisional = `${protectedSegment}.${payloadSegment}.${encodeBase64url(zeroSignature)}`;
|
|
1580
|
-
const decoded =
|
|
2207
|
+
const decoded = decodeSigningArtifact(provisional);
|
|
1581
2208
|
if (!decoded.ok)
|
|
1582
2209
|
return { ok: false, code: "signing_input_invalid" };
|
|
1583
2210
|
return { ok: true, input: { alg: algorithm, protectedSegment, payloadSegment, message } };
|
|
@@ -1609,8 +2236,18 @@ export function terminationSigningInput(kid, claims, chainInput, algorithm) {
|
|
|
1609
2236
|
return { ok: false, code: refusal.code };
|
|
1610
2237
|
return built;
|
|
1611
2238
|
}
|
|
2239
|
+
function decodeSigningArtifact(compact) {
|
|
2240
|
+
const decoded = decodeJws(compact);
|
|
2241
|
+
if (!decoded.ok)
|
|
2242
|
+
return decoded;
|
|
2243
|
+
const kind = Object.keys(PRODUCER_TYPES).find((one) => PRODUCER_TYPES[one] === decoded.value.header.typ);
|
|
2244
|
+
if (!kind)
|
|
2245
|
+
return fail("signing_input_invalid");
|
|
2246
|
+
const checked = checkSigningClaims(kind, decoded.value.payload);
|
|
2247
|
+
return checked.ok ? ok(null) : checked;
|
|
2248
|
+
}
|
|
1612
2249
|
// Assemble a validated signing input and its exact raw signature (the
|
|
1613
|
-
// reference assemble): registry-row length,
|
|
2250
|
+
// reference assemble): registry-row length, full artifact decode, size gate.
|
|
1614
2251
|
export function assembleCompact(input, signature) {
|
|
1615
2252
|
if (!input || typeof input !== "object" || !Buffer.isBuffer(signature))
|
|
1616
2253
|
return { ok: false, code: "invalid_type" };
|
|
@@ -1629,7 +2266,7 @@ export function assembleCompact(input, signature) {
|
|
|
1629
2266
|
const compact = `${input.message.toString("utf8")}.${encodeBase64url(signature)}`;
|
|
1630
2267
|
if (Buffer.byteLength(compact) > JSON_DEFAULT_LIMITS.max_bytes)
|
|
1631
2268
|
return { ok: false, code: "signing_input_invalid" };
|
|
1632
|
-
const decoded =
|
|
2269
|
+
const decoded = decodeSigningArtifact(compact);
|
|
1633
2270
|
if (!decoded.ok)
|
|
1634
2271
|
return { ok: false, code: "signing_input_invalid" };
|
|
1635
2272
|
return { ok: true, compact };
|
|
@@ -1653,7 +2290,7 @@ function refusalChain(chainInput) {
|
|
|
1653
2290
|
if (!chainInput || typeof chainInput !== "object" || Array.isArray(chainInput))
|
|
1654
2291
|
return { invalidSet: "signing_input_invalid" };
|
|
1655
2292
|
const chain = chainFromInput(chainInput);
|
|
1656
|
-
return chain.ok ? { chain: chain.value } : { invalidSet: "chain_invalid" };
|
|
2293
|
+
return chain.ok ? { chain: chain.value } : { invalidSet: chain.code === "invalid_type" ? "invalid_type" : "chain_invalid" };
|
|
1657
2294
|
}
|
|
1658
2295
|
function refusalPartyMatches(revision, claims) {
|
|
1659
2296
|
return revision.value.parties.some((party) => party.role === claims.party_role && party.party_descriptor_digest === claims.party_descriptor_digest);
|