From 5119d3d25b3b79c0103b47b5bc7457bec279bf53 Mon Sep 17 00:00:00 2001 From: A9-dev Date: Tue, 3 Sep 2024 08:23:44 +0100 Subject: [PATCH] chore: change to hastrust for /manufacturer --- .../src/app/components/ManufacturerInfoTable.js | 11 +++-------- .../src/app/manufacturer/[manufacturer_id]/page.js | 2 +- packages/cahn_demo/server/emailToPublicKeys.json | 6 +++++- packages/cahn_demo/server/output/output.pl | 2 +- packages/cahn_demo/server/output/output_db.pl | 6 ++---- .../custom/verifiable_credentials_1725348171449.json | 1 + .../uploads/vcs/rules/output_manufacturer_data.json | 2 +- 7 files changed, 14 insertions(+), 16 deletions(-) create mode 100644 packages/cahn_demo/server/uploads/vcs/custom/verifiable_credentials_1725348171449.json diff --git a/packages/cahn_demo/client/src/app/components/ManufacturerInfoTable.js b/packages/cahn_demo/client/src/app/components/ManufacturerInfoTable.js index a993cdf..18e61c0 100644 --- a/packages/cahn_demo/client/src/app/components/ManufacturerInfoTable.js +++ b/packages/cahn_demo/client/src/app/components/ManufacturerInfoTable.js @@ -16,7 +16,6 @@ import { tableCellClasses } from "@mui/material/TableCell"; import { styled } from "@mui/material/styles"; import DoDisturbIcon from "@mui/icons-material/DoDisturb"; import CheckIcon from "@mui/icons-material/Check"; -import { useEffect } from "react"; const StyledTableRow = styled(TableRow)(({ theme }) => ({ "&:nth-of-type(even)": { @@ -126,18 +125,14 @@ export default function ManufacturerInfoTable({ manufacturerData }) { ) : ( ) } - label={manufacturerData.CanIssueManufacturerTrust.toString()} - color={ - manufacturerData.CanIssueManufacturerTrust - ? "success" - : "error" - } + label={manufacturerData.HasTrust.toString()} + color={manufacturerData.HasTrust ? "success" : "error"} /> diff --git a/packages/cahn_demo/client/src/app/manufacturer/[manufacturer_id]/page.js b/packages/cahn_demo/client/src/app/manufacturer/[manufacturer_id]/page.js index 68726f4..662ebf8 100644 --- a/packages/cahn_demo/client/src/app/manufacturer/[manufacturer_id]/page.js +++ b/packages/cahn_demo/client/src/app/manufacturer/[manufacturer_id]/page.js @@ -31,7 +31,7 @@ const Page = ({ params }) => { }, ], - CanIssueManufacturerTrust: false, + HasTrust: false, }); const [permissionedUsers, setPermissionedUsers] = useState([]); diff --git a/packages/cahn_demo/server/emailToPublicKeys.json b/packages/cahn_demo/server/emailToPublicKeys.json index 0967ef4..84961ec 100644 --- a/packages/cahn_demo/server/emailToPublicKeys.json +++ b/packages/cahn_demo/server/emailToPublicKeys.json @@ -1 +1,5 @@ -{} +{ + "henry@nquiringminds.com": [ + "+Wyk2K/P5tDL+GlgV7UdY/CGU/5Jx38rp3JPk1v7JVI=" + ] +} \ No newline at end of file diff --git a/packages/cahn_demo/server/output/output.pl b/packages/cahn_demo/server/output/output.pl index d3a1788..262c7ff 100644 --- a/packages/cahn_demo/server/output/output.pl +++ b/packages/cahn_demo/server/output/output.pl @@ -701,6 +701,6 @@ ), % Format the output - format(atom(ManufacturerData), '{"CreatedAtManufacturer": "~w", "ManufacturerId": "~w", "Manufacturer": "~w", "DeviceTypes": ~w, "CanIssueManufacturerTrust": ~w}', + format(atom(ManufacturerData), '{"CreatedAtManufacturer": "~w", "ManufacturerId": "~w", "Manufacturer": "~w", "DeviceTypes": ~w, "HasTrust": ~w}', [CreatedAtManufacturer, ManufacturerId, Manufacturer, DeviceTypeDataList, CanIssueManufacturerTrust]). diff --git a/packages/cahn_demo/server/output/output_db.pl b/packages/cahn_demo/server/output/output_db.pl index c648fcc..67a0ad3 100644 --- a/packages/cahn_demo/server/output/output_db.pl +++ b/packages/cahn_demo/server/output/output_db.pl @@ -1,6 +1,5 @@ -created(1725284556.401133). -assert(device_type_trust("henry@nquiringminds.com",1725284541476,"EvilPhone-id")). -assert(manufacturer_trust(1725284533884,"EvilInc-id","henry@nquiringminds.com")). +created(1725348180.9507234). +assert(user(false,_,false,1725348171449,"henry@nquiringminds.com","henry-user")). assert(device_type(1723716151033,"TrustPhone-id","TrustPhone")). assert(device_type(1723716151033,"VulnerableCamera-id","VulnerableCamera")). assert(device_type(1723716151033,"EvilPhone-id","EvilPhone")). @@ -30,4 +29,3 @@ assert(sbom(1723716151033,"VulnerableCameraSBOM-id","VulnerableCamera SBOM information")). assert(manufacturer(1723716151033,"EvilInc-id","EvilInc")). assert(manufacturer(1723716151033,"TrustCorp-id","TrustCorp")). -assert(user(true,true,true,1725284526714,"henry@nquiringminds.com","henry-user")). diff --git a/packages/cahn_demo/server/uploads/vcs/custom/verifiable_credentials_1725348171449.json b/packages/cahn_demo/server/uploads/vcs/custom/verifiable_credentials_1725348171449.json new file mode 100644 index 0000000..5dc597f --- /dev/null +++ b/packages/cahn_demo/server/uploads/vcs/custom/verifiable_credentials_1725348171449.json @@ -0,0 +1 @@ +{"@context":["https://www.w3.org/ns/credentials/v2"],"id":"urn:uuid:2bc4c672-90d5-42aa-a2c3-52142c07e515","type":["VerifiableCredential","UserCredential"],"name":null,"description":null,"issuer":"urn:uuid:585df7b5-8891-4630-9f5d-a5659f3abe04","validFrom":"2024-08-28T14:15:50.307579Z","validUntil":null,"credentialStatus":null,"credentialSchema":{"id":"https://github.com/nqminds/ClaimCascade/blob/claim_verifier/packages/claim_verifier/user.yaml","type":"JsonSchema"},"credentialSubject":{"type":"fact","schemaName":"user","id":"083cef13-d875-4327-9809-664c4e87f2dc","timestamp":1716287268891,"fact":{"id":"henry@nquiringminds.com","username":"henry-user","created_at":1725348171449,"can_issue_device_trust":false,"can_issue_manufacturer_trust":false}}} diff --git a/packages/cahn_demo/server/uploads/vcs/rules/output_manufacturer_data.json b/packages/cahn_demo/server/uploads/vcs/rules/output_manufacturer_data.json index 93904c8..da5b936 100644 --- a/packages/cahn_demo/server/uploads/vcs/rules/output_manufacturer_data.json +++ b/packages/cahn_demo/server/uploads/vcs/rules/output_manufacturer_data.json @@ -12,6 +12,6 @@ "type": "rule", "id": "b1c3d5e4-f5g6-7h89-i0j1-2k3l4m5n6o7p", "timestamp": 1724315344564, - "rule": "output_manufacturer_data(ManufacturerId, ManufacturerData) :-\n manufacturer(CreatedAtManufacturer, ManufacturerId, Manufacturer),\n\n % Retrieve device type data for devices manufactured by this manufacturer\n findall(DeviceTypeData, (\n manufactured(_CreatedAtManufactured, DeviceTypeId, ManufacturerId),\n\n % Retrieve device type information\n (device_type(CreatedAtDeviceType, DeviceTypeId, DeviceType) ->\n true\n ;\n (CreatedAtDeviceType = unknown, DeviceType = unknown)\n ),\n\n format(atom(DeviceTypeData), '{\"DeviceTypeId\": \"~w\", \"CreatedAtDeviceType\": \"~w\", \"DeviceType\": \"~w\"}', \n [DeviceTypeId, CreatedAtDeviceType, DeviceType])\n ), DeviceTypeDataList),\n\n % Check if there is a user that can issue manufacturer trust\n ( \n once((manufacturer_trust(_, ManufacturerId, UserId), user(_, true, _, _, UserId, _))) ->\n CanIssueManufacturerTrust = true\n ; \n CanIssueManufacturerTrust = false\n ),\n\n % Format the output\n format(atom(ManufacturerData), '{\"CreatedAtManufacturer\": \"~w\", \"ManufacturerId\": \"~w\", \"Manufacturer\": \"~w\", \"DeviceTypes\": ~w, \"CanIssueManufacturerTrust\": ~w}', \n [CreatedAtManufacturer, ManufacturerId, Manufacturer, DeviceTypeDataList, CanIssueManufacturerTrust])." + "rule": "output_manufacturer_data(ManufacturerId, ManufacturerData) :-\n manufacturer(CreatedAtManufacturer, ManufacturerId, Manufacturer),\n\n % Retrieve device type data for devices manufactured by this manufacturer\n findall(DeviceTypeData, (\n manufactured(_CreatedAtManufactured, DeviceTypeId, ManufacturerId),\n\n % Retrieve device type information\n (device_type(CreatedAtDeviceType, DeviceTypeId, DeviceType) ->\n true\n ;\n (CreatedAtDeviceType = unknown, DeviceType = unknown)\n ),\n\n format(atom(DeviceTypeData), '{\"DeviceTypeId\": \"~w\", \"CreatedAtDeviceType\": \"~w\", \"DeviceType\": \"~w\"}', \n [DeviceTypeId, CreatedAtDeviceType, DeviceType])\n ), DeviceTypeDataList),\n\n % Check if there is a user that can issue manufacturer trust\n ( \n once((manufacturer_trust(_, ManufacturerId, UserId), user(_, true, _, _, UserId, _))) ->\n CanIssueManufacturerTrust = true\n ; \n CanIssueManufacturerTrust = false\n ),\n\n % Format the output\n format(atom(ManufacturerData), '{\"CreatedAtManufacturer\": \"~w\", \"ManufacturerId\": \"~w\", \"Manufacturer\": \"~w\", \"DeviceTypes\": ~w, \"HasTrust\": ~w}', \n [CreatedAtManufacturer, ManufacturerId, Manufacturer, DeviceTypeDataList, CanIssueManufacturerTrust])." } }