From 1ca43ad6cf648df6179d9d71ded79d60aedd03c8 Mon Sep 17 00:00:00 2001 From: F-Node-Karlsruhe Date: Mon, 9 Oct 2023 15:25:11 +0200 Subject: [PATCH] intermediate commit Signed-off-by: F-Node-Karlsruhe --- frontend/src/api.js | 4 ++-- frontend/src/views/Entry.vue | 12 ++++++++++-- frontend/src/views/Verify.vue | 35 +++++++++++++++++++++-------------- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/frontend/src/api.js b/frontend/src/api.js index e067c0b..d115c9c 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -1,6 +1,6 @@ import axios from 'axios' -const axiosInstance = axios.create({ - baseURL: process.env.VERIFIER_API || 'https://ssi.eecc.de/api/verifier', +const axiosInstance = axios.create({ + baseURL: process.env.VERIFIER_API || 'http://localhost:3000/api/verifier', timeout: 5000, headers: { 'Accept': 'application/ld+json,application/json,*/*' diff --git a/frontend/src/views/Entry.vue b/frontend/src/views/Entry.vue index 609cbd0..7586595 100644 --- a/frontend/src/views/Entry.vue +++ b/frontend/src/views/Entry.vue @@ -107,14 +107,22 @@ export default { onFileChange(e) { var files = Array.from(e.target.files || e.dataTransfer.files); files.forEach(file => { - if (file.type != 'application/json') this.toast.warning(`Credential '${file.name}'' must be provided as a json file!`); + console.log(file.type) + if (file.type != 'application/json') this.toast.warning(`Credential '${file.name}'' must be provided as a json or jwt file!`); + new Response(file).json().then(json => { this.$store.dispatch("addVerifiables", Array.isArray(json) ? json : [json]); }, () => { - this.toast.warning(`'${file.name}' is not a json file!`); + new Response(file).text().then(text => { + + this.$store.dispatch("addVerifiables", [text]); + + }, () => { + this.toast.warning(`'${file.name}' is neither a json nor a jwt file!`); + }) }) }) }, diff --git a/frontend/src/views/Verify.vue b/frontend/src/views/Verify.vue index 88a4cb9..1f4b4b9 100644 --- a/frontend/src/views/Verify.vue +++ b/frontend/src/views/Verify.vue @@ -219,24 +219,31 @@ export default { }, async verify(verifiable) { - if (getVerifiableType(verifiable) == VerifiableType.PRESENTATION) { + // jwt vs json format + if (typeof verifiable == 'string') { + this.addCredential({ jwt: verifiable }); + } + else { + + if (getVerifiableType(verifiable) == VerifiableType.PRESENTATION) { - const presentation = { - presentation: - { - holder: getHolder(verifiable), - challenge: Array.isArray(verifiable.proof) ? verifiable.proof[0].challenge : verifiable.proof.challenge, - domain: Array.isArray(verifiable.proof) ? verifiable.proof[0].domain : verifiable.proof.domain + const presentation = { + presentation: + { + holder: getHolder(verifiable), + challenge: Array.isArray(verifiable.proof) ? verifiable.proof[0].challenge : verifiable.proof.challenge, + domain: Array.isArray(verifiable.proof) ? verifiable.proof[0].domain : verifiable.proof.domain + } } - } - if (Array.isArray(verifiable.verifiableCredential)) verifiable.verifiableCredential.forEach( - (credential) => this.addCredential({ ...credential, presentation }) - ); - else this.addCredential({ ...verifiable.verifiableCredential, presentation }); + if (Array.isArray(verifiable.verifiableCredential)) verifiable.verifiableCredential.forEach( + (credential) => this.addCredential({ ...credential, presentation }) + ); + else this.addCredential({ ...verifiable.verifiableCredential, presentation }); - } else { - this.addCredential({ ...verifiable }); + } else { + this.addCredential({ ...verifiable }); + } } const res = await this.$api.post('/', [verifiable], { params: { challenge: this.$route.query.challenge } });