Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ jobs:
- name: Lint Python (Ruff)
run: ruff check tools

- name: Validate Schema (AJV Strict)
run: npm run lint:schema

- name: Lint Schema (KYA)
run: |
for file in examples/*.json; do
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ test: ## Run pytest suite
pytest tools/tests/ -v

lint: ## Run lint/format checks
npm run lint:schema
ruff check tools
@for file in $(EXAMPLES); do \
$(PYTHON) $(LINTER) $$file; \
Expand Down
78 changes: 78 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
"name": "open-kya-rep",
"private": true,
"devDependencies": {
"ajv": "^8.17.1",
"ajv-formats": "^3.0.1",
"prettier": "3.2.5"
},
"scripts": {
"lint:schema": "node tools/ajv-validate-schema.js",
"format": "prettier --write README.md schema/**/*.json examples/**/*.json spec/**/*.html .github/workflows/*.yml",
"lint": "prettier --check README.md schema/**/*.json examples/**/*.json spec/**/*.html .github/workflows/*.yml"
}
Expand Down
86 changes: 77 additions & 9 deletions schema/kya-manifest.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,26 +353,41 @@
"allOf": [
{
"if": {
"type": "object",
"properties": { "updatePolicy": { "const": "immutable" } },
"required": ["updatePolicy"]
},
"then": {
"type": "object",
"properties": {
"tee": { "type": "object", "required": ["measurementHash"] }
"tee": {
"type": "object",
"required": ["measurementHash"],
"properties": {
"measurementHash": { "$ref": "#/$defs/hex" }
}
}
}
}
},
{
"if": {
"type": "object",
"properties": { "updatePolicy": { "const": "signedRelease" } },
"required": ["updatePolicy"]
},
"then": {
"type": "object",
"required": ["authoritativeSigner"],
"properties": {
"authoritativeSigner": { "$ref": "#/$defs/did" },
"tee": {
"type": "object",
"required": ["signerHash", "minimumSvn"]
"required": ["signerHash", "minimumSvn"],
"properties": {
"signerHash": { "$ref": "#/$defs/hex" },
"minimumSvn": { "type": "integer", "minimum": 0 }
}
}
}
}
Expand Down Expand Up @@ -531,15 +546,31 @@
"allOf": [
{
"anyOf": [
{ "required": ["validFrom"] },
{ "required": ["issuanceDate"] }
{
"type": "object",
"required": ["validFrom"],
"properties": { "validFrom": { "$ref": "#/$defs/dateTime" } }
},
{
"type": "object",
"required": ["issuanceDate"],
"properties": { "issuanceDate": { "$ref": "#/$defs/dateTime" } }
}
]
},
{
"not": {
"anyOf": [
{ "required": ["digestMultibase"] },
{ "required": ["location"] }
{
"type": "object",
"required": ["digestMultibase"],
"properties": { "digestMultibase": { "type": "string" } }
},
{
"type": "object",
"required": ["location"],
"properties": { "location": { "$ref": "#/$defs/uri" } }
}
]
}
},
Expand Down Expand Up @@ -589,10 +620,17 @@
"allOf": [
{
"if": {
"type": "object",
"properties": { "method": { "const": "proverIntermediary" } },
"required": ["method"]
},
"then": { "required": ["verificationKeyMultibase"] }
"then": {
"type": "object",
"required": ["verificationKeyMultibase"],
"properties": {
"verificationKeyMultibase": { "type": "string", "minLength": 1 }
}
}
}
],
"additionalProperties": true
Expand All @@ -608,8 +646,18 @@
},
"allOf": [
{
"if": { "required": ["id"] },
"then": { "required": ["digestMultibase"] }
"if": {
"type": "object",
"required": ["id"],
"properties": { "id": { "$ref": "#/$defs/uri" } }
},
"then": {
"type": "object",
"required": ["digestMultibase"],
"properties": {
"digestMultibase": { "type": "string", "minLength": 1 }
}
}
}
],
"additionalProperties": true
Expand All @@ -620,8 +668,11 @@
"allOf": [
{
"if": {
"type": "object",
"properties": {
"type": {
"type": "array",
"items": { "type": "string" },
"anyOf": [
{ "contains": { "const": "SolvencyCredential" } },
{ "contains": { "const": "kya:SolvencyCredential" } }
Expand All @@ -630,15 +681,19 @@
}
},
"then": {
"type": "object",
"properties": {
"credentialSubject": { "$ref": "#/$defs/solvencySubject" }
}
}
},
{
"if": {
"type": "object",
"properties": {
"type": {
"type": "array",
"items": { "type": "string" },
"anyOf": [
{ "contains": { "const": "InsuranceCredential" } },
{ "contains": { "const": "kya:InsuranceCredential" } }
Expand All @@ -647,15 +702,19 @@
}
},
"then": {
"type": "object",
"properties": {
"credentialSubject": { "$ref": "#/$defs/insuranceSubject" }
}
}
},
{
"if": {
"type": "object",
"properties": {
"type": {
"type": "array",
"items": { "type": "string" },
"anyOf": [
{ "contains": { "const": "AuditCredential" } },
{ "contains": { "const": "kya:AuditCredential" } }
Expand All @@ -664,15 +723,19 @@
}
},
"then": {
"type": "object",
"properties": {
"credentialSubject": { "$ref": "#/$defs/auditSubject" }
}
}
},
{
"if": {
"type": "object",
"properties": {
"type": {
"type": "array",
"items": { "type": "string" },
"anyOf": [
{ "contains": { "const": "LegalEntityCredential" } },
{ "contains": { "const": "kya:LegalEntityCredential" } }
Expand All @@ -681,15 +744,19 @@
}
},
"then": {
"type": "object",
"properties": {
"credentialSubject": { "$ref": "#/$defs/legalEntitySubject" }
}
}
},
{
"if": {
"type": "object",
"properties": {
"type": {
"type": "array",
"items": { "type": "string" },
"anyOf": [
{ "contains": { "const": "LicenseCredential" } },
{ "contains": { "const": "kya:LicenseCredential" } }
Expand All @@ -698,6 +765,7 @@
}
},
"then": {
"type": "object",
"properties": {
"credentialSubject": { "$ref": "#/$defs/licenseSubject" }
}
Expand Down
30 changes: 30 additions & 0 deletions tools/ajv-validate-schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env node
"use strict";

const fs = require("fs");
const path = require("path");
const Ajv = require("ajv");
const addFormats = require("ajv-formats");

const schemaPath = path.join(__dirname, "..", "schema", "kya-manifest.schema.json");
const schema = JSON.parse(fs.readFileSync(schemaPath, "utf-8"));

const ajv = new Ajv({
strict: true,
allErrors: true,
});
addFormats(ajv);

try {
ajv.compile(schema);
console.log("AJV strict schema validation: PASS");
process.exit(0);
} catch (error) {
console.error("AJV strict schema validation: FAIL");
if (error && error.message) {
console.error(error.message);
} else {
console.error(String(error));
}
process.exit(1);
}