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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Verifiable credentials use VC prototyping library now (#238).

## [2.1.0] - 2025-09-25

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PropTypes from "prop-types";
import GppGoodIcon from '@mui/icons-material/GppGood';
import GppBadIcon from '@mui/icons-material/GppBad';
import GppMaybeIcon from '@mui/icons-material/GppMaybe';
import { coreVerify } from '../../../vendor/vcCore';
import { SolidApi } from '../../../vendor/vc-prototyping-library/solid/bundle/api';
import comunicaEngineWrapper from '../../../comunicaEngineWrapper/comunicaEngineWrapper';
import { translateUrlToProxiedUrl } from '../../../lib/utils';

Expand All @@ -16,6 +16,9 @@ const VERIFICATION_STATES = {
ERROR: 'ERROR'
}

let vcApi;
let vcPublicKey;

/**
* @param {object} props - the props passed to the component
* @param {string} props.source - the source to check
Expand All @@ -38,16 +41,38 @@ function SourceVerificationIcon({ source, httpProxies }) {
const verifyFunction = async (source, fetchFunction) => {
try {
const response = await fetchFunction(source);
const verifiableCredential = await response.json();
const { validationResult, verificationResult } = await coreVerify(verifiableCredential);
if (validationResult.valid) {
if (verificationResult.verified) {
const txt = await response.text();

if (!vcApi) {
vcApi = new SolidApi({
// For verify-only application, next fields are not used, so set them to "N/A"
email: "N/A", password: "N/A", css: "N/A", webId: "N/A",
contentsToPreload: [
{
url: "https://www.w3.org/2018/credentials/v1",
type: "context",
document: { "@context": { "@version": 1.1, "@protected": true, "id": "@id", "type": "@type", "VerifiableCredential": { "@id": "https://www.w3.org/2018/credentials#VerifiableCredential", "@context": { "@version": 1.1, "@protected": true, "id": "@id", "type": "@type", "cred": "https://www.w3.org/2018/credentials#", "sec": "https://w3id.org/security#", "xsd": "http://www.w3.org/2001/XMLSchema#", "credentialSchema": { "@id": "cred:credentialSchema", "@type": "@id", "@context": { "@version": 1.1, "@protected": true, "id": "@id", "type": "@type", "cred": "https://www.w3.org/2018/credentials#", "JsonSchemaValidator2018": "cred:JsonSchemaValidator2018" } }, "credentialStatus": { "@id": "cred:credentialStatus", "@type": "@id" }, "credentialSubject": { "@id": "cred:credentialSubject", "@type": "@id" }, "evidence": { "@id": "cred:evidence", "@type": "@id" }, "expirationDate": { "@id": "cred:expirationDate", "@type": "xsd:dateTime" }, "holder": { "@id": "cred:holder", "@type": "@id" }, "issued": { "@id": "cred:issued", "@type": "xsd:dateTime" }, "issuer": { "@id": "cred:issuer", "@type": "@id" }, "issuanceDate": { "@id": "cred:issuanceDate", "@type": "xsd:dateTime" }, "proof": { "@id": "sec:proof", "@type": "@id", "@container": "@graph" }, "refreshService": { "@id": "cred:refreshService", "@type": "@id", "@context": { "@version": 1.1, "@protected": true, "id": "@id", "type": "@type", "cred": "https://www.w3.org/2018/credentials#", "ManualRefreshService2018": "cred:ManualRefreshService2018" } }, "termsOfUse": { "@id": "cred:termsOfUse", "@type": "@id" }, "validFrom": { "@id": "cred:validFrom", "@type": "xsd:dateTime" }, "validUntil": { "@id": "cred:validUntil", "@type": "xsd:dateTime" } } }, "VerifiablePresentation": { "@id": "https://www.w3.org/2018/credentials#VerifiablePresentation", "@context": { "@version": 1.1, "@protected": true, "id": "@id", "type": "@type", "cred": "https://www.w3.org/2018/credentials#", "sec": "https://w3id.org/security#", "holder": { "@id": "cred:holder", "@type": "@id" }, "proof": { "@id": "sec:proof", "@type": "@id", "@container": "@graph" }, "verifiableCredential": { "@id": "cred:verifiableCredential", "@type": "@id", "@container": "@graph" } } }, "EcdsaSecp256k1Signature2019": { "@id": "https://w3id.org/security#EcdsaSecp256k1Signature2019", "@context": { "@version": 1.1, "@protected": true, "id": "@id", "type": "@type", "sec": "https://w3id.org/security#", "xsd": "http://www.w3.org/2001/XMLSchema#", "challenge": "sec:challenge", "created": { "@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime" }, "domain": "sec:domain", "expires": { "@id": "sec:expiration", "@type": "xsd:dateTime" }, "jws": "sec:jws", "nonce": "sec:nonce", "proofPurpose": { "@id": "sec:proofPurpose", "@type": "@vocab", "@context": { "@version": 1.1, "@protected": true, "id": "@id", "type": "@type", "sec": "https://w3id.org/security#", "assertionMethod": { "@id": "sec:assertionMethod", "@type": "@id", "@container": "@set" }, "authentication": { "@id": "sec:authenticationMethod", "@type": "@id", "@container": "@set" } } }, "proofValue": "sec:proofValue", "verificationMethod": { "@id": "sec:verificationMethod", "@type": "@id" } } }, "EcdsaSecp256r1Signature2019": { "@id": "https://w3id.org/security#EcdsaSecp256r1Signature2019", "@context": { "@version": 1.1, "@protected": true, "id": "@id", "type": "@type", "sec": "https://w3id.org/security#", "xsd": "http://www.w3.org/2001/XMLSchema#", "challenge": "sec:challenge", "created": { "@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime" }, "domain": "sec:domain", "expires": { "@id": "sec:expiration", "@type": "xsd:dateTime" }, "jws": "sec:jws", "nonce": "sec:nonce", "proofPurpose": { "@id": "sec:proofPurpose", "@type": "@vocab", "@context": { "@version": 1.1, "@protected": true, "id": "@id", "type": "@type", "sec": "https://w3id.org/security#", "assertionMethod": { "@id": "sec:assertionMethod", "@type": "@id", "@container": "@set" }, "authentication": { "@id": "sec:authenticationMethod", "@type": "@id", "@container": "@set" } } }, "proofValue": "sec:proofValue", "verificationMethod": { "@id": "sec:verificationMethod", "@type": "@id" } } }, "Ed25519Signature2018": { "@id": "https://w3id.org/security#Ed25519Signature2018", "@context": { "@version": 1.1, "@protected": true, "id": "@id", "type": "@type", "sec": "https://w3id.org/security#", "xsd": "http://www.w3.org/2001/XMLSchema#", "challenge": "sec:challenge", "created": { "@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime" }, "domain": "sec:domain", "expires": { "@id": "sec:expiration", "@type": "xsd:dateTime" }, "jws": "sec:jws", "nonce": "sec:nonce", "proofPurpose": { "@id": "sec:proofPurpose", "@type": "@vocab", "@context": { "@version": 1.1, "@protected": true, "id": "@id", "type": "@type", "sec": "https://w3id.org/security#", "assertionMethod": { "@id": "sec:assertionMethod", "@type": "@id", "@container": "@set" }, "authentication": { "@id": "sec:authenticationMethod", "@type": "@id", "@container": "@set" } } }, "proofValue": "sec:proofValue", "verificationMethod": { "@id": "sec:verificationMethod", "@type": "@id" } } }, "RsaSignature2018": { "@id": "https://w3id.org/security#RsaSignature2018", "@context": { "@version": 1.1, "@protected": true, "challenge": "sec:challenge", "created": { "@id": "http://purl.org/dc/terms/created", "@type": "xsd:dateTime" }, "domain": "sec:domain", "expires": { "@id": "sec:expiration", "@type": "xsd:dateTime" }, "jws": "sec:jws", "nonce": "sec:nonce", "proofPurpose": { "@id": "sec:proofPurpose", "@type": "@vocab", "@context": { "@version": 1.1, "@protected": true, "id": "@id", "type": "@type", "sec": "https://w3id.org/security#", "assertionMethod": { "@id": "sec:assertionMethod", "@type": "@id", "@container": "@set" }, "authentication": { "@id": "sec:authenticationMethod", "@type": "@id", "@container": "@set" } } }, "proofValue": "sec:proofValue", "verificationMethod": { "@id": "sec:verificationMethod", "@type": "@id" } } }, "proof": { "@id": "https://w3id.org/security#proof", "@type": "@id", "@container": "@graph" } } }
},
{
url: "https://w3id.org/security/data-integrity/v2",
type: "context",
document: { "@context": { "id": "@id", "type": "@type", "@protected": true, "proof": { "@id": "https://w3id.org/security#proof", "@type": "@id", "@container": "@graph" }, "DataIntegrityProof": { "@id": "https://w3id.org/security#DataIntegrityProof", "@context": { "@protected": true, "id": "@id", "type": "@type", "challenge": "https://w3id.org/security#challenge", "created": { "@id": "http://purl.org/dc/terms/created", "@type": "http://www.w3.org/2001/XMLSchema#dateTime" }, "domain": "https://w3id.org/security#domain", "expires": { "@id": "https://w3id.org/security#expiration", "@type": "http://www.w3.org/2001/XMLSchema#dateTime" }, "nonce": "https://w3id.org/security#nonce", "previousProof": { "@id": "https://w3id.org/security#previousProof", "@type": "@id" }, "proofPurpose": { "@id": "https://w3id.org/security#proofPurpose", "@type": "@vocab", "@context": { "@protected": true, "id": "@id", "type": "@type", "assertionMethod": { "@id": "https://w3id.org/security#assertionMethod", "@type": "@id", "@container": "@set" }, "authentication": { "@id": "https://w3id.org/security#authenticationMethod", "@type": "@id", "@container": "@set" }, "capabilityInvocation": { "@id": "https://w3id.org/security#capabilityInvocationMethod", "@type": "@id", "@container": "@set" }, "capabilityDelegation": { "@id": "https://w3id.org/security#capabilityDelegationMethod", "@type": "@id", "@container": "@set" }, "keyAgreement": { "@id": "https://w3id.org/security#keyAgreementMethod", "@type": "@id", "@container": "@set" } } }, "cryptosuite": { "@id": "https://w3id.org/security#cryptosuite", "@type": "https://w3id.org/security#cryptosuiteString" }, "proofValue": { "@id": "https://w3id.org/security#proofValue", "@type": "https://w3id.org/security#multibase" }, "verificationMethod": { "@id": "https://w3id.org/security#verificationMethod", "@type": "@id" } } } } }
}
]
});
vcPublicKey = await vcApi.retrievePublicKey();
}

const verificationResult = await vcApi.verify({ contentType: 'application/ld+json', content: txt }, vcPublicKey);
switch (verificationResult) {
case 'pass':
return VERIFICATION_STATES.VERIFIED;
} else {
case 'fail':
return VERIFICATION_STATES.NOT_VERIFIED;
}
} else {
return VERIFICATION_STATES.INVALID_SOURCE;
case 'not signed':
return VERIFICATION_STATES.INVALID_SOURCE;
default:
return VERIFICATION_STATES.ERROR;
}
} catch (error) {
return VERIFICATION_STATES.ERROR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function TableHeader({ children }) {
<Link
target="_blank"
href={link}
key={link}
sx={{ height: "100%", margin: "0 0 0 5px", "& > *": { verticalAlign: "middle" } }}
>
<LinkIcon
Expand Down
Loading