@onchaindiligence/agent-evidence 0.1.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 (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +98 -0
  3. package/conformance/README.md +31 -0
  4. package/conformance/duplicate-outer-key.json +1 -0
  5. package/conformance/manifest.json +74 -0
  6. package/conformance/missing-parent.json +31 -0
  7. package/conformance/noncanonical-payload.json +31 -0
  8. package/conformance/rfc8785-vectors.json +31 -0
  9. package/conformance/valid-full-graph.json +31 -0
  10. package/dist/canonical.d.ts +14 -0
  11. package/dist/canonical.d.ts.map +1 -0
  12. package/dist/canonical.js +249 -0
  13. package/dist/canonical.js.map +1 -0
  14. package/dist/constants.d.ts +9 -0
  15. package/dist/constants.d.ts.map +1 -0
  16. package/dist/constants.js +9 -0
  17. package/dist/constants.js.map +1 -0
  18. package/dist/dsse.d.ts +10 -0
  19. package/dist/dsse.d.ts.map +1 -0
  20. package/dist/dsse.js +85 -0
  21. package/dist/dsse.js.map +1 -0
  22. package/dist/errors.d.ts +16 -0
  23. package/dist/errors.d.ts.map +1 -0
  24. package/dist/errors.js +19 -0
  25. package/dist/errors.js.map +1 -0
  26. package/dist/graph.d.ts +3 -0
  27. package/dist/graph.d.ts.map +1 -0
  28. package/dist/graph.js +227 -0
  29. package/dist/graph.js.map +1 -0
  30. package/dist/index.d.ts +14 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +10 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/records.d.ts +14 -0
  35. package/dist/records.d.ts.map +1 -0
  36. package/dist/records.js +55 -0
  37. package/dist/records.js.map +1 -0
  38. package/dist/schema.d.ts +4 -0
  39. package/dist/schema.d.ts.map +1 -0
  40. package/dist/schema.js +45 -0
  41. package/dist/schema.js.map +1 -0
  42. package/dist/trust.d.ts +64 -0
  43. package/dist/trust.d.ts.map +1 -0
  44. package/dist/trust.js +254 -0
  45. package/dist/trust.js.map +1 -0
  46. package/dist/types.d.ts +83 -0
  47. package/dist/types.d.ts.map +1 -0
  48. package/dist/types.js +2 -0
  49. package/dist/types.js.map +1 -0
  50. package/dist/verifier.d.ts +5 -0
  51. package/dist/verifier.d.ts.map +1 -0
  52. package/dist/verifier.js +489 -0
  53. package/dist/verifier.js.map +1 -0
  54. package/examples/withheld-payment.mjs +67 -0
  55. package/package.json +65 -0
  56. package/schemas/attestation-key.schema.json +88 -0
  57. package/schemas/bundle-payload.schema.json +32 -0
  58. package/schemas/catalog.json +20 -0
  59. package/schemas/common.schema.json +35 -0
  60. package/schemas/dsse-envelope.schema.json +34 -0
  61. package/schemas/portable-file.schema.json +62 -0
  62. package/schemas/proof.schema.json +98 -0
  63. package/schemas/record.schema.json +286 -0
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@onchaindiligence/agent-evidence",
3
+ "version": "0.1.0",
4
+ "description": "Deterministic Agent Evidence v0 construction, DSSE sealing, and offline tri-state verification for Node.js",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "schemas",
17
+ "conformance",
18
+ "examples",
19
+ "LICENSE",
20
+ "README.md"
21
+ ],
22
+ "scripts": {
23
+ "sync-assets": "node scripts/sync-assets.mjs",
24
+ "check:assets": "node scripts/sync-assets.mjs --check",
25
+ "clean": "node scripts/clean.mjs",
26
+ "build": "npm run check:assets && npm run clean && tsc -p tsconfig.json",
27
+ "test": "npm run build && node --test test/*.test.mjs",
28
+ "test:external": "npm run build && node test/external-consumer.mjs",
29
+ "test:cross-language": "npm run build && node test/cross-language.mjs",
30
+ "prepack": "npm run build"
31
+ },
32
+ "keywords": [
33
+ "agent-evidence",
34
+ "dsse",
35
+ "provenance",
36
+ "offline-verification",
37
+ "ed25519"
38
+ ],
39
+ "author": "OnChainDiligence",
40
+ "license": "MIT",
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/Qazza1/onchaindiligence.git",
44
+ "directory": "packages/agent-evidence"
45
+ },
46
+ "homepage": "https://github.com/Qazza1/onchaindiligence/tree/main/packages/agent-evidence#readme",
47
+ "bugs": {
48
+ "url": "https://github.com/Qazza1/onchaindiligence/issues"
49
+ },
50
+ "engines": {
51
+ "node": ">=20.19"
52
+ },
53
+ "dependencies": {
54
+ "ajv": "^8.20.0",
55
+ "ajv-formats": "^3.0.1"
56
+ },
57
+ "devDependencies": {
58
+ "@types/node": "^22.0.0",
59
+ "typescript": "^5.6.0"
60
+ },
61
+ "publishConfig": {
62
+ "access": "public",
63
+ "provenance": true
64
+ }
65
+ }
@@ -0,0 +1,88 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://onchaindiligence.com/schemas/agent-evidence/v0/attestation-key.schema.json",
4
+ "title": "Agent Evidence v0 trusted Ed25519 key record",
5
+ "type": "object",
6
+ "required": ["key_id", "algorithm", "public_key_pem", "status", "valid_from", "valid_until", "status_changed_at"],
7
+ "properties": {
8
+ "key_id": { "type": "string", "pattern": "^ed25519-[A-Za-z0-9_-]{16}$" },
9
+ "algorithm": { "const": "ed25519" },
10
+ "public_key_pem": {
11
+ "type": "string",
12
+ "pattern": "^-----BEGIN PUBLIC KEY-----\\n[A-Za-z0-9+/=\\n]+-----END PUBLIC KEY-----\\n?$",
13
+ "maxLength": 4096
14
+ },
15
+ "status": { "enum": ["active", "retired", "revoked", "compromised"] },
16
+ "valid_from": {
17
+ "anyOf": [
18
+ { "$ref": "common.schema.json#/$defs/timestamp" },
19
+ { "type": "null" }
20
+ ]
21
+ },
22
+ "valid_until": {
23
+ "anyOf": [
24
+ { "$ref": "common.schema.json#/$defs/timestamp" },
25
+ { "type": "null" }
26
+ ]
27
+ },
28
+ "status_changed_at": {
29
+ "anyOf": [
30
+ { "$ref": "common.schema.json#/$defs/timestamp" },
31
+ { "type": "null" }
32
+ ]
33
+ },
34
+ "status_reason": { "type": "string", "minLength": 1, "maxLength": 4096 },
35
+ "replacement_key_id": {
36
+ "anyOf": [
37
+ { "type": "string", "pattern": "^ed25519-[A-Za-z0-9_-]{16}$" },
38
+ { "type": "null" }
39
+ ]
40
+ },
41
+ "compromised_at": {
42
+ "anyOf": [
43
+ { "$ref": "common.schema.json#/$defs/timestamp" },
44
+ { "type": "null" }
45
+ ]
46
+ }
47
+ },
48
+ "allOf": [
49
+ {
50
+ "if": { "type": "object", "properties": { "status": { "const": "active" } }, "required": ["status"] },
51
+ "then": { "type": "object", "properties": { "valid_until": { "type": "null" } } }
52
+ },
53
+ {
54
+ "if": { "type": "object", "properties": { "status": { "const": "retired" } }, "required": ["status"] },
55
+ "then": {
56
+ "type": "object",
57
+ "properties": {
58
+ "valid_from": { "$ref": "common.schema.json#/$defs/timestamp" },
59
+ "valid_until": { "$ref": "common.schema.json#/$defs/timestamp" },
60
+ "status_changed_at": { "$ref": "common.schema.json#/$defs/timestamp" }
61
+ }
62
+ }
63
+ },
64
+ {
65
+ "if": { "type": "object", "properties": { "status": { "const": "compromised" } }, "required": ["status"] },
66
+ "then": {
67
+ "type": "object",
68
+ "required": ["compromised_at"],
69
+ "properties": {
70
+ "compromised_at": { "$ref": "common.schema.json#/$defs/timestamp" },
71
+ "status_changed_at": { "$ref": "common.schema.json#/$defs/timestamp" }
72
+ }
73
+ }
74
+ },
75
+ {
76
+ "if": { "type": "object", "properties": { "status": { "const": "revoked" } }, "required": ["status"] },
77
+ "then": {
78
+ "type": "object",
79
+ "required": ["status_reason"],
80
+ "properties": {
81
+ "status_reason": { "type": "string", "minLength": 1, "maxLength": 4096 },
82
+ "status_changed_at": { "$ref": "common.schema.json#/$defs/timestamp" }
83
+ }
84
+ }
85
+ }
86
+ ],
87
+ "additionalProperties": false
88
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://onchaindiligence.com/schemas/agent-evidence/v0/bundle-payload.schema.json",
4
+ "title": "Agent Evidence v0 signed bundle payload",
5
+ "type": "object",
6
+ "required": ["bundle_version", "bundle_id", "created_at", "run_id", "root_ids", "records", "extensions"],
7
+ "properties": {
8
+ "bundle_version": { "const": "onchaindiligence.agent-evidence.bundle.v0" },
9
+ "bundle_id": { "$ref": "common.schema.json#/$defs/contentId" },
10
+ "created_at": { "$ref": "common.schema.json#/$defs/timestamp" },
11
+ "run_id": { "$ref": "common.schema.json#/$defs/contentId" },
12
+ "root_ids": {
13
+ "allOf": [
14
+ { "$ref": "common.schema.json#/$defs/idList" },
15
+ { "type": "array", "minItems": 1 }
16
+ ]
17
+ },
18
+ "records": {
19
+ "type": "array",
20
+ "minItems": 1,
21
+ "maxItems": 10000,
22
+ "items": { "$ref": "record.schema.json" }
23
+ },
24
+ "extensions": {
25
+ "type": "object",
26
+ "propertyNames": { "type": "string", "format": "uri" },
27
+ "additionalProperties": true,
28
+ "maxProperties": 256
29
+ }
30
+ },
31
+ "additionalProperties": false
32
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "specification_id": "onchaindiligence.agent-evidence.v0",
3
+ "schema_dialect": "https://json-schema.org/draft/2020-12/schema",
4
+ "schemas": [
5
+ "common.schema.json",
6
+ "attestation-key.schema.json",
7
+ "dsse-envelope.schema.json",
8
+ "proof.schema.json",
9
+ "record.schema.json",
10
+ "bundle-payload.schema.json",
11
+ "portable-file.schema.json"
12
+ ],
13
+ "entry_points": {
14
+ "portable_file": "portable-file.schema.json",
15
+ "signed_payload": "bundle-payload.schema.json",
16
+ "record": "record.schema.json",
17
+ "proof": "proof.schema.json",
18
+ "trusted_key_record": "attestation-key.schema.json"
19
+ }
20
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://onchaindiligence.com/schemas/agent-evidence/v0/common.schema.json",
4
+ "title": "Agent Evidence v0 common values",
5
+ "$defs": {
6
+ "timestamp": {
7
+ "type": "string",
8
+ "format": "date-time",
9
+ "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$"
10
+ },
11
+ "contentId": {
12
+ "type": "string",
13
+ "pattern": "^sha256:[A-Za-z0-9_-]{43}$"
14
+ },
15
+ "sha256Digest": {
16
+ "type": "object",
17
+ "required": ["sha256"],
18
+ "properties": {
19
+ "sha256": { "type": "string", "pattern": "^[A-Za-z0-9_-]{43}$" }
20
+ },
21
+ "additionalProperties": false
22
+ },
23
+ "decimalString": {
24
+ "type": "string",
25
+ "pattern": "^(0|[1-9][0-9]*)(\\.[0-9]+)?$"
26
+ },
27
+ "nonEmptyString": { "type": "string", "minLength": 1, "maxLength": 4096 },
28
+ "idList": {
29
+ "type": "array",
30
+ "items": { "$ref": "#/$defs/contentId" },
31
+ "uniqueItems": true,
32
+ "maxItems": 10000
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://onchaindiligence.com/schemas/agent-evidence/v0/dsse-envelope.schema.json",
4
+ "title": "DSSE v1 envelope",
5
+ "type": "object",
6
+ "required": ["payloadType", "payload", "signatures"],
7
+ "properties": {
8
+ "payloadType": { "type": "string", "minLength": 1, "maxLength": 1024 },
9
+ "payload": {
10
+ "type": "string",
11
+ "contentEncoding": "base64",
12
+ "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
13
+ },
14
+ "signatures": {
15
+ "type": "array",
16
+ "minItems": 1,
17
+ "maxItems": 16,
18
+ "items": {
19
+ "type": "object",
20
+ "required": ["keyid", "sig"],
21
+ "properties": {
22
+ "keyid": { "type": "string", "pattern": "^ed25519-[A-Za-z0-9_-]{16}$" },
23
+ "sig": {
24
+ "type": "string",
25
+ "contentEncoding": "base64",
26
+ "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
27
+ }
28
+ },
29
+ "additionalProperties": false
30
+ }
31
+ }
32
+ },
33
+ "additionalProperties": false
34
+ }
@@ -0,0 +1,62 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://onchaindiligence.com/schemas/agent-evidence/v0/portable-file.schema.json",
4
+ "title": "Agent Evidence v0 portable file",
5
+ "type": "object",
6
+ "required": ["media_type", "bundle_version", "envelope", "verification_material"],
7
+ "properties": {
8
+ "media_type": { "const": "application/vnd.onchaindiligence.agent-evidence+json" },
9
+ "bundle_version": { "const": "onchaindiligence.agent-evidence.bundle.v0" },
10
+ "envelope": {
11
+ "allOf": [
12
+ { "$ref": "dsse-envelope.schema.json" },
13
+ {
14
+ "type": "object",
15
+ "properties": {
16
+ "payloadType": { "const": "application/vnd.onchaindiligence.agent-evidence.bundle.v0+json" }
17
+ }
18
+ }
19
+ ]
20
+ },
21
+ "verification_material": {
22
+ "type": "object",
23
+ "required": ["keys", "registry_snapshots", "anchors"],
24
+ "properties": {
25
+ "keys": {
26
+ "type": "array",
27
+ "items": { "$ref": "attestation-key.schema.json" },
28
+ "maxItems": 1024
29
+ },
30
+ "registry_snapshots": {
31
+ "type": "array",
32
+ "maxItems": 64,
33
+ "items": {
34
+ "type": "object",
35
+ "required": ["media_type", "digest", "value"],
36
+ "properties": {
37
+ "media_type": { "type": "string", "minLength": 1, "maxLength": 1024 },
38
+ "digest": { "$ref": "common.schema.json#/$defs/sha256Digest" },
39
+ "value": {}
40
+ },
41
+ "additionalProperties": false
42
+ }
43
+ },
44
+ "anchors": {
45
+ "type": "array",
46
+ "maxItems": 256,
47
+ "items": {
48
+ "type": "object",
49
+ "required": ["anchor_type", "value"],
50
+ "properties": {
51
+ "anchor_type": { "type": "string", "minLength": 1, "maxLength": 256 },
52
+ "value": {}
53
+ },
54
+ "additionalProperties": false
55
+ }
56
+ }
57
+ },
58
+ "additionalProperties": false
59
+ }
60
+ },
61
+ "additionalProperties": false
62
+ }
@@ -0,0 +1,98 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://onchaindiligence.com/schemas/agent-evidence/v0/proof.schema.json",
4
+ "title": "Agent Evidence v0 source proof",
5
+ "oneOf": [
6
+ { "$ref": "#/$defs/dsseProof" },
7
+ { "$ref": "#/$defs/attestationV2Proof" },
8
+ { "$ref": "#/$defs/attestationV1Proof" },
9
+ { "$ref": "#/$defs/externalDigestProof" }
10
+ ],
11
+ "$defs": {
12
+ "dsseProof": {
13
+ "type": "object",
14
+ "required": ["proof_type", "statement_media_type", "envelope"],
15
+ "properties": {
16
+ "proof_type": { "const": "dsse-ed25519-v1" },
17
+ "statement_media_type": { "type": "string", "minLength": 1, "maxLength": 1024 },
18
+ "envelope": { "$ref": "dsse-envelope.schema.json" }
19
+ },
20
+ "additionalProperties": false
21
+ },
22
+ "v2Envelope": {
23
+ "type": "object",
24
+ "required": ["data", "attestation"],
25
+ "properties": {
26
+ "data": {},
27
+ "attestation": {
28
+ "type": "object",
29
+ "required": ["signed", "schema_version", "issuer", "purpose", "issued_at", "key_id", "algorithm", "canonicalization", "signature"],
30
+ "properties": {
31
+ "signed": { "const": true },
32
+ "schema_version": { "const": "onchaindiligence.attestation.v2" },
33
+ "issuer": { "type": "string", "format": "uri" },
34
+ "purpose": { "type": "string", "minLength": 1, "maxLength": 256 },
35
+ "issued_at": { "$ref": "common.schema.json#/$defs/timestamp" },
36
+ "key_id": { "type": "string", "pattern": "^ed25519-[A-Za-z0-9_-]{16}$" },
37
+ "algorithm": { "const": "ed25519" },
38
+ "canonicalization": { "const": "RFC8785" },
39
+ "signature": { "type": "string", "pattern": "^[A-Za-z0-9_-]{86}$" },
40
+ "signing_input_hint": { "type": "string", "maxLength": 4096 }
41
+ },
42
+ "additionalProperties": false
43
+ }
44
+ },
45
+ "additionalProperties": false
46
+ },
47
+ "v1Envelope": {
48
+ "type": "object",
49
+ "required": ["data", "attestation"],
50
+ "properties": {
51
+ "data": {},
52
+ "attestation": {
53
+ "type": "object",
54
+ "required": ["signed", "issued_at", "key_id", "algorithm", "signature"],
55
+ "properties": {
56
+ "signed": { "const": true },
57
+ "issued_at": { "$ref": "common.schema.json#/$defs/timestamp" },
58
+ "key_id": { "type": "string", "pattern": "^ed25519-[A-Za-z0-9_-]{16}$" },
59
+ "algorithm": { "const": "ed25519" },
60
+ "signature": { "type": "string", "pattern": "^[A-Za-z0-9_-]{86}$" },
61
+ "schema_version": false
62
+ },
63
+ "additionalProperties": true
64
+ }
65
+ },
66
+ "additionalProperties": false
67
+ },
68
+ "attestationV2Proof": {
69
+ "type": "object",
70
+ "required": ["proof_type", "envelope"],
71
+ "properties": {
72
+ "proof_type": { "const": "onchaindiligence-attestation-v2" },
73
+ "envelope": { "$ref": "#/$defs/v2Envelope" }
74
+ },
75
+ "additionalProperties": false
76
+ },
77
+ "attestationV1Proof": {
78
+ "type": "object",
79
+ "required": ["proof_type", "envelope"],
80
+ "properties": {
81
+ "proof_type": { "const": "onchaindiligence-attestation-v1" },
82
+ "envelope": { "$ref": "#/$defs/v1Envelope" }
83
+ },
84
+ "additionalProperties": false
85
+ },
86
+ "externalDigestProof": {
87
+ "type": "object",
88
+ "required": ["proof_type", "media_type", "digest"],
89
+ "properties": {
90
+ "proof_type": { "const": "external-digest" },
91
+ "media_type": { "type": "string", "minLength": 1, "maxLength": 1024 },
92
+ "digest": { "$ref": "common.schema.json#/$defs/sha256Digest" },
93
+ "reference": { "type": "string", "format": "uri", "maxLength": 8192 }
94
+ },
95
+ "additionalProperties": false
96
+ }
97
+ }
98
+ }