@zanii/certify 0.0.0-stage → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/LICENSE +159 -0
  2. package/README.md +112 -2
  3. package/dist/appliance-execution.d.ts +18 -0
  4. package/dist/appliance-execution.js +12 -0
  5. package/dist/appliance.d.ts +135 -0
  6. package/dist/appliance.js +253 -0
  7. package/dist/assurance-status.d.ts +58 -0
  8. package/dist/assurance-status.js +86 -0
  9. package/dist/audit-renewal.d.ts +39 -0
  10. package/dist/audit-renewal.js +62 -0
  11. package/dist/audit.d.ts +69 -0
  12. package/dist/audit.js +112 -0
  13. package/dist/beacon-client.d.ts +38 -0
  14. package/dist/beacon-client.js +52 -0
  15. package/dist/beacon.d.ts +84 -0
  16. package/dist/beacon.js +106 -0
  17. package/dist/bitstring-status.d.ts +56 -0
  18. package/dist/bitstring-status.js +135 -0
  19. package/dist/board.d.ts +218 -0
  20. package/dist/board.js +428 -0
  21. package/dist/bundle.d.ts +92 -0
  22. package/dist/bundle.js +109 -0
  23. package/dist/certificate.d.ts +161 -0
  24. package/dist/certificate.js +345 -0
  25. package/dist/cli-messages.json +148 -0
  26. package/dist/cli.d.ts +16 -0
  27. package/dist/cli.js +369 -0
  28. package/dist/current-issuer-vc.d.ts +20 -0
  29. package/dist/current-issuer-vc.js +60 -0
  30. package/dist/evidence-share.d.ts +89 -0
  31. package/dist/evidence-share.js +479 -0
  32. package/dist/federation.d.ts +103 -0
  33. package/dist/federation.js +240 -0
  34. package/dist/feed-snapshot.d.ts +97 -0
  35. package/dist/feed-snapshot.js +186 -0
  36. package/dist/fingerprint.d.ts +23 -0
  37. package/dist/fingerprint.js +48 -0
  38. package/dist/formats/status-v2.schema.json +31 -0
  39. package/dist/governance.d.ts +242 -0
  40. package/dist/governance.js +411 -0
  41. package/dist/identity.d.ts +79 -0
  42. package/dist/identity.js +146 -0
  43. package/dist/impartiality.d.ts +47 -0
  44. package/dist/impartiality.js +85 -0
  45. package/dist/index.d.ts +58 -0
  46. package/dist/index.js +59 -0
  47. package/dist/issuer-authorization.d.ts +4 -0
  48. package/dist/issuer-authorization.js +52 -0
  49. package/dist/issuer-resolution.d.ts +25 -0
  50. package/dist/issuer-resolution.js +89 -0
  51. package/dist/licence-owner-entry.d.ts +20 -0
  52. package/dist/licence-owner-entry.js +33 -0
  53. package/dist/licence-owner.d.ts +67 -0
  54. package/dist/licence-owner.js +180 -0
  55. package/dist/licence.d.ts +174 -0
  56. package/dist/licence.js +400 -0
  57. package/dist/live-evidence.d.ts +135 -0
  58. package/dist/live-evidence.js +210 -0
  59. package/dist/nitro-roots.d.ts +3 -0
  60. package/dist/nitro-roots.js +20 -0
  61. package/dist/nitro-x509.d.ts +16 -0
  62. package/dist/nitro-x509.js +141 -0
  63. package/dist/nitro.d.ts +74 -0
  64. package/dist/nitro.js +329 -0
  65. package/dist/normalization.d.ts +8 -0
  66. package/dist/normalization.js +10 -0
  67. package/dist/pq.d.ts +32 -0
  68. package/dist/pq.js +69 -0
  69. package/dist/profile.d.ts +20 -0
  70. package/dist/profile.js +161 -0
  71. package/dist/register.d.ts +79 -0
  72. package/dist/register.js +134 -0
  73. package/dist/rotation.d.ts +49 -0
  74. package/dist/rotation.js +124 -0
  75. package/dist/royalty-reconciliation.d.ts +24 -0
  76. package/dist/royalty-reconciliation.js +88 -0
  77. package/dist/runtime-client.d.ts +38 -0
  78. package/dist/runtime-client.js +185 -0
  79. package/dist/runtime-gateway.d.ts +24 -0
  80. package/dist/runtime-gateway.js +167 -0
  81. package/dist/runtime-knowledge.d.ts +28 -0
  82. package/dist/runtime-knowledge.js +75 -0
  83. package/dist/runtime-nitro.d.ts +30 -0
  84. package/dist/runtime-nitro.js +57 -0
  85. package/dist/runtime.d.ts +226 -0
  86. package/dist/runtime.js +254 -0
  87. package/dist/sandbox-delegation.d.ts +38 -0
  88. package/dist/sandbox-delegation.js +61 -0
  89. package/dist/schema-dialect.d.ts +1 -0
  90. package/dist/schema-dialect.js +97 -0
  91. package/dist/schemas/clause-map.schema.json +52 -0
  92. package/dist/schemas/profile.schema.json +80 -0
  93. package/dist/schemas/scenarios.schema.json +573 -0
  94. package/dist/schemas/suite.schema.json +138 -0
  95. package/dist/scheme-authority.d.ts +5 -0
  96. package/dist/scheme-authority.js +15 -0
  97. package/dist/scheme-entry.d.ts +25 -0
  98. package/dist/scheme-entry.js +85 -0
  99. package/dist/scheme-history.d.ts +5 -0
  100. package/dist/scheme-history.js +87 -0
  101. package/dist/scheme-log.d.ts +98 -0
  102. package/dist/scheme-log.js +266 -0
  103. package/dist/scheme-merkle.d.ts +2 -0
  104. package/dist/scheme-merkle.js +20 -0
  105. package/dist/scheme-text.d.ts +25 -0
  106. package/dist/scheme-text.js +46 -0
  107. package/dist/scheme-timing.d.ts +16 -0
  108. package/dist/scheme-timing.js +22 -0
  109. package/dist/scheme-transition.d.ts +47 -0
  110. package/dist/scheme-transition.js +101 -0
  111. package/dist/scoring.d.ts +35 -0
  112. package/dist/scoring.js +50 -0
  113. package/dist/shared.d.ts +16 -0
  114. package/dist/shared.js +20 -0
  115. package/dist/signer.d.ts +18 -0
  116. package/dist/signer.js +49 -0
  117. package/dist/signing-identity.d.ts +1 -0
  118. package/dist/signing-identity.js +11 -0
  119. package/dist/status.d.ts +113 -0
  120. package/dist/status.js +204 -0
  121. package/dist/succession.d.ts +21 -0
  122. package/dist/succession.js +67 -0
  123. package/dist/suite.d.ts +257 -0
  124. package/dist/suite.js +441 -0
  125. package/dist/vc.d.ts +29 -0
  126. package/dist/vc.js +96 -0
  127. package/dist/verification-bounds.d.ts +5 -0
  128. package/dist/verification-bounds.js +76 -0
  129. package/dist/verification-policy.d.ts +32 -0
  130. package/dist/verification-policy.js +85 -0
  131. package/dist/witness.d.ts +19 -0
  132. package/dist/witness.js +80 -0
  133. package/package.json +57 -3
@@ -0,0 +1,97 @@
1
+ // Fail closed before the legacy value walker: this is a bounded Certify dialect, not general JSON Schema.
2
+ import { isObj } from "./shared.js";
3
+ import { withinVerificationBudget } from "./verification-bounds.js";
4
+ const KEYWORDS = new Set("$schema $id title $defs $ref type const enum required properties additionalProperties items minItems maxItems uniqueItems minLength maxLength pattern minimum maximum anyOf".split(" "));
5
+ const TYPES = new Set(["object", "array", "string", "integer", "boolean"]);
6
+ const REF = /^#\/\$defs\/[A-Za-z][A-Za-z0-9_-]{0,127}$/;
7
+ export function schemaDialectErrors(schema) {
8
+ if (!withinVerificationBudget(schema, { maxBytes: 1_048_576, maxNodes: 50_000, maxDepth: 32 }))
9
+ return ["schema $: exceeds the dialect JSON budget"];
10
+ const out = [], active = new Set(), visited = new Set();
11
+ const root = isObj(schema) ? schema : {};
12
+ const walk = (s, path) => {
13
+ const error = (message) => out.push(`schema ${path}: ${message}`);
14
+ if (!isObj(s)) {
15
+ error("a schema must be an object");
16
+ return;
17
+ }
18
+ if (active.has(s))
19
+ return;
20
+ if (visited.has(s))
21
+ return;
22
+ active.add(s);
23
+ for (const k of Object.keys(s).sort())
24
+ if (!KEYWORDS.has(k))
25
+ error(`unsupported keyword ${k}`);
26
+ if ("$schema" in s && s.$schema !== "https://json-schema.org/draft/2020-12/schema")
27
+ error("unsupported schema dialect");
28
+ for (const k of ["$id", "title"])
29
+ if (k in s && (typeof s[k] !== "string" || s[k].length > 2048))
30
+ error(`${k} must be a bounded string`);
31
+ if ("type" in s && (typeof s.type !== "string" || !TYPES.has(s.type)))
32
+ error("unsupported type");
33
+ for (const k of ["minLength", "maxLength", "minItems", "maxItems"])
34
+ if (k in s && !(Number.isSafeInteger(s[k]) && s[k] >= 0))
35
+ error(`${k} must be a nonnegative safe integer`);
36
+ for (const k of ["minimum", "maximum"])
37
+ if (k in s && !(typeof s[k] === "number" && Number.isFinite(s[k])))
38
+ error(`${k} must be finite`);
39
+ for (const k of ["additionalProperties", "uniqueItems"])
40
+ if (k in s && typeof s[k] !== "boolean")
41
+ error(`${k} must be boolean`);
42
+ if ("enum" in s && (!Array.isArray(s.enum) || s.enum.length < 1 || s.enum.length > 1000))
43
+ error("enum must contain 1 to 1000 values");
44
+ if ("required" in s && (!Array.isArray(s.required) || s.required.length > 1000 || !s.required.every((x) => typeof x === "string" && x.length <= 256) || new Set(s.required).size !== s.required.length))
45
+ error("required must contain distinct bounded names");
46
+ if ("pattern" in s) {
47
+ if (typeof s.pattern !== "string" || s.pattern.length > 512 || /[^\x00-\x7f]|\\[pPksS]|\(\?(?![:=!])|\\x(?![0-9a-fA-F]{2})|\\u(?![0-9a-fA-F]{4})/.test(s.pattern) || [...s.pattern.matchAll(/\\([A-Za-z0-9])/g)].some((m) => !"dDwWbBtnrfvux".includes(m[1])))
48
+ error("unsupported pattern syntax");
49
+ else
50
+ try {
51
+ new RegExp(s.pattern);
52
+ }
53
+ catch {
54
+ error("invalid pattern");
55
+ }
56
+ }
57
+ if ("$ref" in s) {
58
+ if (typeof s.$ref !== "string" || !REF.test(s.$ref) || !isObj(root.$defs) || !Object.hasOwn(root.$defs, s.$ref.slice(8)))
59
+ error("unresolved or unsupported reference");
60
+ else {
61
+ const chain = new Set([s]);
62
+ let next = root.$defs[s.$ref.slice(8)];
63
+ while (isObj(next) && typeof next.$ref === "string" && REF.test(next.$ref) && Object.hasOwn(root.$defs, next.$ref.slice(8))) {
64
+ if (chain.has(next) || chain.size > 32) {
65
+ error("non-consuming or excessive reference chain");
66
+ break;
67
+ }
68
+ chain.add(next);
69
+ next = root.$defs[next.$ref.slice(8)];
70
+ }
71
+ }
72
+ if (Object.keys(s).some((k) => !["$ref", "$defs", "$schema", "$id", "title"].includes(k)))
73
+ error("reference constraint siblings are unsupported");
74
+ }
75
+ for (const k of ["properties", "$defs"])
76
+ if (k in s) {
77
+ const map = s[k];
78
+ if (!isObj(map) || Object.keys(map).length > 1000 || Object.keys(map).some((name) => name.length > 256))
79
+ error(`${k} must contain bounded schema names`);
80
+ else
81
+ for (const [name, child] of Object.entries(map).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0))
82
+ walk(child, `${path}.${k}.${name}`);
83
+ }
84
+ if ("items" in s)
85
+ walk(s.items, `${path}.items`);
86
+ if ("anyOf" in s) {
87
+ if (!Array.isArray(s.anyOf) || s.anyOf.length < 1 || s.anyOf.length > 32)
88
+ error("anyOf must contain 1 to 32 schemas");
89
+ else
90
+ s.anyOf.forEach((child, i) => walk(child, `${path}.anyOf[${i}]`));
91
+ }
92
+ active.delete(s);
93
+ visited.add(s);
94
+ };
95
+ walk(schema, "$");
96
+ return [...new Set(out)].sort();
97
+ }
@@ -0,0 +1,52 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://zanii.agency/certify/schemas/clause-map.schema.json",
4
+ "title": "Zanii Certify clause map (spec/profiles.md)",
5
+ "type": "object",
6
+ "required": ["v", "type", "slug", "version", "title", "source", "clauses"],
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "v": { "const": 1 },
10
+ "type": { "const": "certify.clause-map" },
11
+ "slug": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,63}$" },
12
+ "version": { "type": "integer", "minimum": 1 },
13
+ "title": { "$ref": "#/$defs/text" },
14
+ "source": {
15
+ "type": "object",
16
+ "required": ["publisher", "document", "url", "date"],
17
+ "additionalProperties": false,
18
+ "properties": {
19
+ "publisher": { "type": "string", "minLength": 1, "maxLength": 200 },
20
+ "document": { "type": "string", "minLength": 1, "maxLength": 500 },
21
+ "url": { "type": "string", "pattern": "^https://" },
22
+ "date": { "type": "string", "pattern": "^\\d{4}-\\d{2}(-\\d{2})?$" }
23
+ }
24
+ },
25
+ "clauses": {
26
+ "type": "array",
27
+ "minItems": 1,
28
+ "items": {
29
+ "type": "object",
30
+ "required": ["id", "title", "ref", "interpretation"],
31
+ "additionalProperties": false,
32
+ "properties": {
33
+ "id": { "type": "string", "pattern": "^[A-Za-z0-9._-]{1,64}$" },
34
+ "title": { "$ref": "#/$defs/text" },
35
+ "ref": { "type": "string", "minLength": 1, "maxLength": 200 },
36
+ "interpretation": { "type": "boolean" }
37
+ }
38
+ }
39
+ }
40
+ },
41
+ "$defs": {
42
+ "text": {
43
+ "type": "object",
44
+ "required": ["en", "ar"],
45
+ "additionalProperties": false,
46
+ "properties": {
47
+ "en": { "type": "string", "minLength": 1, "maxLength": 2000 },
48
+ "ar": { "type": "string", "minLength": 1, "maxLength": 2000 }
49
+ }
50
+ }
51
+ }
52
+ }
@@ -0,0 +1,80 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://zanii.agency/certify/schemas/profile.schema.json",
4
+ "title": "Zanii Certify sector profile (spec/profiles.md)",
5
+ "type": "object",
6
+ "required": ["v", "type", "slug", "version", "scheme", "title", "description", "levels", "clause_maps", "categories"],
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "v": { "const": 1 },
10
+ "type": { "const": "certify.profile" },
11
+ "slug": { "$ref": "#/$defs/slug" },
12
+ "version": { "type": "integer", "minimum": 1 },
13
+ "scheme": { "enum": ["zanii-certify/0.1", "zanii-certify/0.2", "zanii-certify/0.3"] },
14
+ "title": { "$ref": "#/$defs/text" },
15
+ "description": { "$ref": "#/$defs/text" },
16
+ "levels": {
17
+ "type": "array",
18
+ "minItems": 1,
19
+ "uniqueItems": true,
20
+ "items": { "enum": [1, 2, 3] }
21
+ },
22
+ "live_evidence": { "$ref": "#/$defs/live_evidence" },
23
+ "scenarios": { "type": "boolean" },
24
+ "clause_maps": {
25
+ "type": "array",
26
+ "uniqueItems": true,
27
+ "items": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,63}/[1-9][0-9]*$" }
28
+ },
29
+ "categories": {
30
+ "type": "array",
31
+ "minItems": 1,
32
+ "items": { "$ref": "#/$defs/category" }
33
+ }
34
+ },
35
+ "$defs": {
36
+ "live_evidence": {
37
+ "type": "object",
38
+ "additionalProperties": false,
39
+ "properties": {
40
+ "max_guard_block_ppm": { "type": "integer", "minimum": 0, "maximum": 1000000 },
41
+ "max_contradicted_claim_ppm": { "type": "integer", "minimum": 0, "maximum": 1000000 },
42
+ "max_budget_breaches": { "type": "integer", "minimum": 0, "maximum": 1000000 }
43
+ }
44
+ },
45
+ "slug": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,63}$" },
46
+ "text": {
47
+ "type": "object",
48
+ "required": ["en", "ar"],
49
+ "additionalProperties": false,
50
+ "properties": {
51
+ "en": { "type": "string", "minLength": 1, "maxLength": 2000 },
52
+ "ar": { "type": "string", "minLength": 1, "maxLength": 2000 }
53
+ }
54
+ },
55
+ "category": {
56
+ "type": "object",
57
+ "required": ["id", "title", "description", "required_levels", "min_trials", "threshold_ppm", "ci_rule", "clauses"],
58
+ "additionalProperties": false,
59
+ "properties": {
60
+ "id": { "type": "string", "pattern": "^[a-z][a-z0-9_]{0,63}$" },
61
+ "title": { "$ref": "#/$defs/text" },
62
+ "description": { "$ref": "#/$defs/text" },
63
+ "required_levels": {
64
+ "type": "array",
65
+ "minItems": 1,
66
+ "uniqueItems": true,
67
+ "items": { "enum": [1, 2, 3] }
68
+ },
69
+ "min_trials": { "type": "integer", "minimum": 1, "maximum": 1000000 },
70
+ "threshold_ppm": { "type": "integer", "minimum": 0, "maximum": 1000000 },
71
+ "ci_rule": { "const": "wilson95-low" },
72
+ "clauses": {
73
+ "type": "array",
74
+ "uniqueItems": true,
75
+ "items": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,63}:[A-Za-z0-9._-]{1,64}$" }
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }