@agent-blueprint-protocol/verifier 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +891 -0
  2. package/LICENSE +190 -0
  3. package/NOTICE +4 -0
  4. package/README.md +199 -0
  5. package/dist/corpus/cases/base64url-decode.json +1 -0
  6. package/dist/corpus/cases/blueprint-decode.json +1 -0
  7. package/dist/corpus/cases/bounds-new.json +1 -0
  8. package/dist/corpus/cases/bounds_algebra-intersect.json +1 -0
  9. package/dist/corpus/cases/canonicalization-encode.json +1 -0
  10. package/dist/corpus/cases/compatibility-verify.json +1 -0
  11. package/dist/corpus/cases/deployment-decode.json +1 -0
  12. package/dist/corpus/cases/digest-tagged.json +1 -0
  13. package/dist/corpus/cases/extension-resolve.json +1 -0
  14. package/dist/corpus/cases/federation-decode.json +1 -0
  15. package/dist/corpus/cases/federation-verify_commitment.json +1 -0
  16. package/dist/corpus/cases/json-decode.json +1 -0
  17. package/dist/corpus/cases/negotiation-negotiate.json +1 -0
  18. package/dist/corpus/cases/portability-scan.json +1 -0
  19. package/dist/corpus/cases/schema-validate_instance.json +1 -0
  20. package/dist/corpus/cases/signature-verify.json +1 -0
  21. package/dist/corpus/index.json +1 -0
  22. package/dist/corpus/schemas/estate-contract.schema.json +1 -0
  23. package/dist/corpus/schemas/object.schema.json +1 -0
  24. package/dist/corpus/vectors/blueprint-golden.json +1 -0
  25. package/dist/corpus/vectors/deployment-golden.json +1 -0
  26. package/dist/corpus/vectors/rfc8785-numbers.json +1 -0
  27. package/dist/kit/cli.mjs +24 -0
  28. package/dist/verifier/b64url.d.ts +16 -0
  29. package/dist/verifier/b64url.js +36 -0
  30. package/dist/verifier/blueprint.d.ts +56 -0
  31. package/dist/verifier/blueprint.js +795 -0
  32. package/dist/verifier/bounds.d.ts +19 -0
  33. package/dist/verifier/bounds.js +45 -0
  34. package/dist/verifier/bounds_algebra.d.ts +27 -0
  35. package/dist/verifier/bounds_algebra.js +282 -0
  36. package/dist/verifier/canonical.d.ts +17 -0
  37. package/dist/verifier/canonical.js +160 -0
  38. package/dist/verifier/cli.d.ts +1 -0
  39. package/dist/verifier/cli.js +149 -0
  40. package/dist/verifier/compatibility.d.ts +22 -0
  41. package/dist/verifier/compatibility.js +112 -0
  42. package/dist/verifier/corpus.d.ts +42 -0
  43. package/dist/verifier/corpus.js +672 -0
  44. package/dist/verifier/decode.d.ts +16 -0
  45. package/dist/verifier/decode.js +457 -0
  46. package/dist/verifier/deployment.d.ts +49 -0
  47. package/dist/verifier/deployment.js +830 -0
  48. package/dist/verifier/digest.d.ts +23 -0
  49. package/dist/verifier/digest.js +58 -0
  50. package/dist/verifier/extension.d.ts +11 -0
  51. package/dist/verifier/extension.js +75 -0
  52. package/dist/verifier/federation.d.ts +76 -0
  53. package/dist/verifier/federation.js +817 -0
  54. package/dist/verifier/negotiation.d.ts +29 -0
  55. package/dist/verifier/negotiation.js +324 -0
  56. package/dist/verifier/portability.d.ts +12 -0
  57. package/dist/verifier/portability.js +184 -0
  58. package/dist/verifier/predicate.d.ts +10 -0
  59. package/dist/verifier/predicate.js +172 -0
  60. package/dist/verifier/registry.d.ts +16 -0
  61. package/dist/verifier/registry.js +120 -0
  62. package/dist/verifier/registry_engine.d.ts +42 -0
  63. package/dist/verifier/registry_engine.js +220 -0
  64. package/dist/verifier/report.d.ts +13 -0
  65. package/dist/verifier/report.js +29 -0
  66. package/dist/verifier/run_corpus.d.ts +1 -0
  67. package/dist/verifier/run_corpus.js +81 -0
  68. package/dist/verifier/runner.d.ts +20 -0
  69. package/dist/verifier/runner.js +778 -0
  70. package/dist/verifier/schema.d.ts +20 -0
  71. package/dist/verifier/schema.js +623 -0
  72. package/dist/verifier/self_checks.d.ts +1 -0
  73. package/dist/verifier/self_checks.js +316 -0
  74. package/dist/verifier/signature.d.ts +23 -0
  75. package/dist/verifier/signature.js +226 -0
  76. package/dist/verifier/value.d.ts +44 -0
  77. package/dist/verifier/value.js +77 -0
  78. package/package.json +42 -0
@@ -0,0 +1,23 @@
1
+ export type Domain = "blueprint_content" | "deployment_content" | "federation_envelope" | "signature" | "extension_schema" | "extension_registry" | "conformance_report" | "corpus_index";
2
+ export declare const SEPARATORS: Record<Domain, string>;
3
+ export interface Digest {
4
+ algorithm: "sha-256";
5
+ bytes: Buffer;
6
+ }
7
+ export declare function of(data: Buffer): Digest;
8
+ export declare function hash(domain: Domain, data: Buffer): Digest;
9
+ export declare function toTagged(digest: Digest): string;
10
+ export declare function fromTagged(input: string): {
11
+ ok: true;
12
+ v: Digest;
13
+ } | {
14
+ ok: false;
15
+ e: string;
16
+ };
17
+ export declare function equal(a: Digest, b: Digest): boolean;
18
+ export declare function verifyContent(domain: Domain, jcsBytes: Buffer, tagged: string): {
19
+ ok: true;
20
+ } | {
21
+ ok: false;
22
+ e: string;
23
+ };
@@ -0,0 +1,58 @@
1
+ // Domain-separated SHA-256 digests — the mirror of AgentBlueprintProtocol.Digest:
2
+ // preimage `separator || 0x00 || jcs_bytes` under the registered separator
3
+ // (base §8.2), tagged wire form "sha-256:<43-char unpadded base64url>".
4
+ import { createHash } from "node:crypto";
5
+ import * as b64 from "./b64url.js";
6
+ export const SEPARATORS = {
7
+ blueprint_content: "agent-blueprint-protocol/blueprint-content",
8
+ deployment_content: "agent-blueprint-protocol/deployment-content",
9
+ federation_envelope: "agent-blueprint-protocol/federation-envelope",
10
+ signature: "agent-blueprint-protocol/signature",
11
+ extension_schema: "agent-blueprint-protocol/extension-schema",
12
+ extension_registry: "agent-blueprint-protocol/extension-registry",
13
+ conformance_report: "agent-blueprint-protocol/conformance-report",
14
+ corpus_index: "agent-blueprint-protocol/corpus-index",
15
+ };
16
+ const SIZES = { "sha-256": 32 };
17
+ const TAGS = Object.keys(SIZES);
18
+ export function of(data) {
19
+ return { algorithm: "sha-256", bytes: createHash("sha256").update(data).digest() };
20
+ }
21
+ export function hash(domain, data) {
22
+ return of(Buffer.concat([Buffer.from(SEPARATORS[domain], "utf8"), Buffer.from([0]), data]));
23
+ }
24
+ export function toTagged(digest) {
25
+ return "sha-256:" + b64.encode(digest.bytes);
26
+ }
27
+ export function fromTagged(input) {
28
+ const colon = input.indexOf(":");
29
+ if (colon === -1)
30
+ return { ok: false, e: "digest_encoding_invalid" };
31
+ const tag = input.slice(0, colon);
32
+ const body = input.slice(colon + 1);
33
+ if (!TAGS.includes(tag))
34
+ return { ok: false, e: "digest_algorithm_unsupported" };
35
+ const decoded = b64.decodeStrict(body);
36
+ if (!decoded.ok)
37
+ return { ok: false, e: "digest_encoding_invalid" };
38
+ if (decoded.v.length !== SIZES[tag])
39
+ return { ok: false, e: "digest_encoding_invalid" };
40
+ return { ok: true, v: { algorithm: "sha-256", bytes: decoded.v } };
41
+ }
42
+ // Constant-time equality over the digest bytes (the twin's xor-accumulate).
43
+ export function equal(a, b) {
44
+ if (a.bytes.length !== b.bytes.length || a.algorithm !== b.algorithm)
45
+ return false;
46
+ let diff = 0;
47
+ for (let i = 0; i < a.bytes.length; i++)
48
+ diff |= a.bytes[i] ^ b.bytes[i];
49
+ return diff === 0;
50
+ }
51
+ export function verifyContent(domain, jcsBytes, tagged) {
52
+ const declared = fromTagged(tagged);
53
+ if (!declared.ok)
54
+ return declared;
55
+ if (equal(hash(domain, jcsBytes), declared.v))
56
+ return { ok: true };
57
+ return { ok: false, e: "digest_mismatch" };
58
+ }
@@ -0,0 +1,11 @@
1
+ import type { Value } from "./value.ts";
2
+ type VResult = {
3
+ ok: true;
4
+ } | {
5
+ ok: false;
6
+ e: string;
7
+ };
8
+ export declare function envelopeOk(value: Value): VResult;
9
+ export declare function bodies(members: [string, Value][]): [string, Value][];
10
+ export declare function criticalNamespaces(members: [string, Value][]): Set<string>;
11
+ export {};
@@ -0,0 +1,75 @@
1
+ // The positional extension envelope — the mirror of AgentBlueprintProtocol.Extension:
2
+ // {"critical": {ns → body}, "optional": {ns → body}}, shared by both artifact
3
+ // tables as a table check and by the scans as the open-region walk.
4
+ const IDENTIFIER_BYTES = 512;
5
+ const CEILING_EXTENSIONS = 32;
6
+ const NAMESPACE = /^[a-z0-9][a-z0-9.-]*\/[a-z0-9][a-z0-9.-]*$/;
7
+ // The envelope shape check a table carries: exactly critical + optional
8
+ // regions, namespace form, total cardinality, no namespace in both.
9
+ export function envelopeOk(value) {
10
+ if (value.t !== "obj")
11
+ return { ok: false, e: "invalid_type" };
12
+ const members = value.v;
13
+ const names = members.map(([name]) => name).sort();
14
+ if (names.length !== 2 || names[0] !== "critical" || names[1] !== "optional") {
15
+ // A single missing half is a missing member; anything else unknown.
16
+ const raw = members.map(([name]) => name);
17
+ if (raw.length === 1 && (raw[0] === "critical" || raw[0] === "optional")) {
18
+ return { ok: false, e: "missing_required_field" };
19
+ }
20
+ return { ok: false, e: "unknown_member" };
21
+ }
22
+ const namespaces = [];
23
+ for (const [, regionValue] of members) {
24
+ if (regionValue.t !== "obj")
25
+ return { ok: false, e: "invalid_type" };
26
+ for (const [ns] of regionValue.v) {
27
+ if (!namespaceForm(ns))
28
+ return { ok: false, e: "extension_namespace_invalid" };
29
+ namespaces.push(ns);
30
+ }
31
+ }
32
+ if (namespaces.length > CEILING_EXTENSIONS)
33
+ return { ok: false, e: "invalid_cardinality" };
34
+ if (new Set(namespaces).size !== namespaces.length)
35
+ return { ok: false, e: "extension_duplicate" };
36
+ return { ok: true };
37
+ }
38
+ // Every {namespace, body} pair in the envelope, both regions, in document
39
+ // order — the scan's walk over the open region. `members` is the ROOT member
40
+ // list (the "extensions" member is located by name).
41
+ export function bodies(members) {
42
+ const out = [];
43
+ const extensions = memberValue(members, "extensions");
44
+ if (extensions === null || extensions.t !== "obj")
45
+ return out;
46
+ for (const [, regionValue] of extensions.v) {
47
+ if (regionValue.t !== "obj")
48
+ continue;
49
+ for (const [ns, body] of regionValue.v)
50
+ out.push([ns, body]);
51
+ }
52
+ return out;
53
+ }
54
+ // The critical region's namespace set for THIS value — the authored-channel
55
+ // tie (a validated-critical list must sit inside this set).
56
+ export function criticalNamespaces(members) {
57
+ const out = new Set();
58
+ const extensions = memberValue(members, "extensions");
59
+ if (extensions === null || extensions.t !== "obj")
60
+ return out;
61
+ for (const [region, regionValue] of extensions.v) {
62
+ if (region !== "critical" || regionValue.t !== "obj")
63
+ continue;
64
+ for (const [ns] of regionValue.v)
65
+ out.add(ns);
66
+ }
67
+ return out;
68
+ }
69
+ function namespaceForm(ns) {
70
+ return Buffer.byteLength(ns, "utf8") <= IDENTIFIER_BYTES && NAMESPACE.test(ns);
71
+ }
72
+ function memberValue(members, name) {
73
+ const found = members.find(([key]) => key === name);
74
+ return found ? found[1] : null;
75
+ }
@@ -0,0 +1,76 @@
1
+ import type { Bounds } from "./bounds.ts";
2
+ import * as digest from "./digest.ts";
3
+ import * as signature from "./signature.ts";
4
+ import type { Value } from "./value.ts";
5
+ export interface Envelope {
6
+ value: Value;
7
+ }
8
+ export interface PriorReceipt {
9
+ taskIdentity: string;
10
+ terminalState: string;
11
+ terminalCommitment: digest.Digest;
12
+ }
13
+ export interface Context {
14
+ keys: signature.PublicKey[];
15
+ issuer?: unknown;
16
+ subject?: unknown;
17
+ audience?: unknown;
18
+ issuerKeySets: Record<string, signature.PublicKey[]> | null;
19
+ createdAfter?: string;
20
+ createdBefore?: string;
21
+ priorReceipts: PriorReceipt[];
22
+ }
23
+ export type CodecResult = {
24
+ ok: true;
25
+ v: string | {
26
+ decoded: true;
27
+ };
28
+ } | {
29
+ ok: false;
30
+ e: string;
31
+ };
32
+ export declare function decode(bytes: Buffer | string | symbol, bounds?: Bounds | Record<string, unknown>): {
33
+ ok: true;
34
+ v: Envelope;
35
+ } | {
36
+ ok: false;
37
+ e: string;
38
+ };
39
+ export declare function fromValue(value: Value): {
40
+ ok: true;
41
+ v: Envelope;
42
+ } | {
43
+ ok: false;
44
+ e: string;
45
+ };
46
+ export declare function canonicalBytes(envelope: Envelope): {
47
+ ok: true;
48
+ v: string;
49
+ } | {
50
+ ok: false;
51
+ e: string;
52
+ };
53
+ export declare function fromA2aState(spelling: string): CodecResult;
54
+ export declare function toA2aState(spelling: string): CodecResult;
55
+ export declare function fromMcpState(spelling: string): CodecResult;
56
+ export declare function toMcpState(spelling: string): CodecResult;
57
+ export declare function a2aCarrierKey(): string;
58
+ export declare function mcpCarrierKey(): string;
59
+ export declare function fromA2aCarrier(carrier: Value): CodecResult;
60
+ export declare function fromMcpCarrier(carrier: Value): CodecResult;
61
+ export declare function terminalCommitment(envelope: Envelope): {
62
+ ok: true;
63
+ v: digest.Digest;
64
+ } | {
65
+ ok: false;
66
+ e: string;
67
+ };
68
+ export declare function verifyCommitment(envelope: Envelope, context: Context): {
69
+ ok: true;
70
+ v: {
71
+ taskIdentity: string;
72
+ };
73
+ } | {
74
+ ok: false;
75
+ e: string;
76
+ };