Skip to content

Commit

Permalink
intermediate commit
Browse files Browse the repository at this point in the history
Signed-off-by: F-Node-Karlsruhe <christian.fries@eecc.de>
  • Loading branch information
F-Node-Karlsruhe committed Oct 9, 2023
1 parent 3858087 commit 1ca43ad
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
4 changes: 2 additions & 2 deletions frontend/src/api.js
Original file line number Diff line number Diff line change
@@ -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,*/*'
Expand Down
12 changes: 10 additions & 2 deletions frontend/src/views/Entry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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!`);
})
})
})
},
Expand Down
35 changes: 21 additions & 14 deletions frontend/src/views/Verify.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 } });
Expand Down

0 comments on commit 1ca43ad

Please sign in to comment.