Skip to content

Commit

Permalink
Merge pull request #33 from european-epc-competence-center/sd-auth
Browse files Browse the repository at this point in the history
Authenticated credential requests
  • Loading branch information
F-Node-Karlsruhe authored Jun 19, 2023
2 parents c257269 + e42c7df commit 95a0aea
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 75 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ WIP
---


1.6.0 (2023-06-19)
---

- add ability to request disclosure of single credentials


1.5.3 (2023-06-14)
---

Expand Down
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vc-verifier",
"version": "1.5.3",
"version": "1.6.0",
"description": "The EECC verifier for verifiable credentials which provides an verification API as well as the corresponding UI.",
"main": "index.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "verifier_frontend",
"version": "1.5.3",
"version": "1.6.0",
"description": "Vue frontend for the EECC vc verifier API",
"scripts": {
"build": "vue-cli-service build",
Expand Down
36 changes: 34 additions & 2 deletions frontend/src/components/Credential.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
<div class="credentialid mt-1"><a :href="credential.id">{{ credential.id }}</a></div>
</div>
<div class="col-2 text-end">
<a v-if="SDCredential" tabindex="0" style="display: inline-block;" type="button" class="me-3"
data-bs-container="body" data-bs-toggle="tooltip" data-bs-html="true"
:data-bs-title="'<strong>Selective disclosure credential</strong><br>' + (disclosed ? 'Already disclosed' : 'Go to details to request more disclosure')">
<i v-if="disclosed" style="font-size: 1.25rem;" class="bi bi-eye-fill text-primary" role="img"
aria-label="SD-Credentials"></i>
<i v-else style="font-size: 1.25rem;" class="bi bi-eye-slash-fill text-secondary" role="img"
aria-label="SD-Credentials"></i>
</a>
<a v-if="credential.presentation && credential.presentation.verified != undefined" tabindex="0"
style="display: inline-block;" type="button" class="me-3" data-bs-container="body"
data-bs-toggle="tooltip" :data-bs-title="'Presentation ' + credential.presentation.status">
Expand Down Expand Up @@ -114,7 +122,7 @@
<div class="accordion-body p-0">
<div class="table-responsive">
<table class="table table-striped mb-1">
<tbody>
<TransitionGroup name="list" tag="tbody">
<tr v-for="(value, key) in credential.credentialSubject" :key="key">
<td><strong>{{ key }}</strong> <a
v-if="credential.context && credential.context.get(key)"
Expand All @@ -135,8 +143,17 @@
<p v-else class="m-0">{{ $getCredentialValue(value) }}</p>
</td>
</tr>
</tbody>
</TransitionGroup>
</table>
<div v-if="SDCredential" class="row m-3 justify-content-center">
<div class="col-md-6 text-center">
<button @click="requestDisclosure" type="button" class="btn btn-outline-primary"
data-bs-container="body" data-bs-toggle="tooltip"
data-bs-title="Make authenticated request to request disclosure of more data fields of this selective disclosure credential"><i
class="bi-file-earmark-lock2-fill" role="img" aria-label="PDF Download"></i>
Disclose more</button>
</div>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -168,6 +185,7 @@ import { getPlainCredential } from '../utils.js';
import * as JsHashes from 'jshashes';
pdfMake.vfs = pdfFonts.pdfMake.vfs;
import { useToast } from "vue-toastification";
import TrimmedBatch from "@/components/TrimmedBatch.vue";
import QRModal from "@/components/QRModal.vue";
Expand All @@ -182,6 +200,7 @@ export default {
},
data() {
return {
toast: useToast(),
getPlainCredential: getPlainCredential
}
},
Expand All @@ -190,6 +209,15 @@ export default {
selector: "[data-bs-toggle='tooltip']"
})
},
computed: {
SDCredential() {
const proof = Array.isArray(this.credential.proof) ? this.credential.proof[0] : this.credential.proof;
return proof.type == 'DataIntegrityProof'
},
disclosed() {
return this.$store.state.disclosedCredentials.includes(this.credential.id);
}
},
methods: {
downloadCredentialPDF(credential) {
// var win = window.open('', '_blank');
Expand Down Expand Up @@ -219,6 +247,10 @@ export default {
getCredCompId(prefix) {
const idHash = new JsHashes.SHA256().hex(this.credential.id || JSON.stringify(this.credential.proof));
return prefix + '-' + idHash.substr(idHash.length - 5, idHash.length);
},
requestDisclosure() {
if (this.disclosed) this.toast.info('Credential already disclosed!')
else this.$store.dispatch("makeAuthenticatedRequest", this.credential.id);
}
}
}
Expand Down
56 changes: 56 additions & 0 deletions frontend/src/store/demoAuth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
export const demoAuthPresentation = {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"type": [
"VerifiablePresentation"
],
"verifiableCredential": [
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"ipfs://QmY9CDY2PoXLgHr2vG4u8mj27cfAyuzVxE2swt8wwFn7Rt",
"https://w3id.org/vc-revocation-list-2020/v1",
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"id": "https://ssi.eecc.de/api/registry/vc/b7440bf7-2317-43e4-9857-4c85032ac4a1",
"type": [
"VerifiableCredential",
"EECCAccessCredential"
],
"issuer": {
"id": "did:web:ssi.eecc.de",
"image": "https://id.eecc.de/assets/img/logo_big.png",
"name": "EECC"
},
"issuanceDate": "2023-06-19T09:58:08Z",
"credentialStatus": {
"id": "https://ssi.eecc.de/api/registry/vc/status/did:web:ssi.eecc.de/1#1",
"type": "RevocationList2020Status",
"revocationListIndex": 1,
"revocationListCredential": "https://ssi.eecc.de/api/registry/vc/status/did:web:ssi.eecc.de/1"
},
"credentialSubject": {
"id": "https://ssi.eecc.de/verifier",
"customer_name": "VC Verifier"
},
"proof": {
"type": "Ed25519Signature2020",
"created": "2023-06-19T09:58:08Z",
"proofPurpose": "assertionMethod",
"verificationMethod": "did:web:ssi.eecc.de#z6MkoHWsmSZnHisAxnVdokYHnXaVqWFZ4H33FnNg13zyymxd",
"proofValue": "z247VYAm5GbG1sAAcqW7QwEL1mfXxaSa3N93EuLc4HeTUm219UjrPMC5gyq5xTAaDQCVMUEVTouyboY4UMTxzjekN"
}
}
],
"holder": "did:web:ssi.eecc.de",
"proof": {
"type": "Ed25519Signature2020",
"created": "2023-06-19T10:19:04Z",
"verificationMethod": "did:web:ssi.eecc.de#z6MkoHWsmSZnHisAxnVdokYHnXaVqWFZ4H33FnNg13zyymxd",
"proofPurpose": "authentication",
"challenge": "demochallenge",
"proofValue": "z3BCT7df4bRXXTa9i79apmiou76M8LVZXGFYHA18xT6wX3PfcpjfWaMc9xhFwmGi9XTj8tth1ai1ASeQoHiGWMn1V"
}
}
29 changes: 24 additions & 5 deletions frontend/src/store/index.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,51 @@
import { createStore } from 'vuex'
import { demoAuthPresentation } from './demoAuth'
import api from '../api'


export default createStore({
state: {
version: '1.5.3',
version: '1.6.0',
verifiables: [],
disclosedCredentials: [],
VC_REGISTRY: process.env.VC_REGISTRY || 'https://ssi.eecc.de/api/registry/vcs/',
OPENID_ENDPOINT: process.env.OPENID_ENDPOINT || 'https://ssi.eecc.de/api/openid/',
showQRModal: false
},
mutations: {
showQRModal(state, payload) {
state.showQRModal = payload.value
state.showQRModal = payload.value;
},
addVerifiables(state, verifiables) {
state.verifiables = state.verifiables.concat(verifiables)
state.verifiables = state.verifiables.concat(Array.isArray(verifiables) ? verifiables : [verifiables])
},
resetVerifiables(state) {
state.verifiables = [];
},
addDisclosedCredential(state, credential) {
state.disclosedCredentials.push(credential.id)
},
},
actions: {
addVerifiables(context, verifiables) {
this.commit('addVerifiables', verifiables)
this.commit('addVerifiables', verifiables);
},
resetVerifiables() {
this.commit('resetVerifiables')
this.commit('resetVerifiables');
},
makeAuthenticatedRequest(context, url, authPresentation) {
// mock authentication if not present
if (!authPresentation) authPresentation = demoAuthPresentation;
// folowing OID4VP with authVP extension
api.post(url, { vp: authPresentation })
.then((res) => {
this.commit('addVerifiables', res.data)
this.commit('addDisclosedCredential', res.data)
})
.catch((error) => {
console.log(error)
});
}
},
modules: {},
})
Loading

0 comments on commit 95a0aea

Please sign in to comment.