Skip to content

Commit

Permalink
enable switch back to any credential
Browse files Browse the repository at this point in the history
  • Loading branch information
leoniefritsch committed Sep 10, 2024
1 parent 8c9a31a commit 514e939
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 96 deletions.
94 changes: 28 additions & 66 deletions frontend/src/components/PresentationRequest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,31 @@
import { useToast } from 'vue-toastification';
import QrcodeVue from 'qrcode.vue';
function getInputDescriptor(ct) {
return {
id: "eecc_verifier_request_" + ct || "VerifiableCredential",
format: {
ldp_vc: {
proof_type: ["Ed25519Signature2018", "Ed25519Signature2020"],
},
},
constraints: {
fields: [
{
path: ["$.type"],
filter: {
type: "array",
contains: {
type: "string",
pattern: ct || "VerifiableCredential",
},
},
},
],
},
};
}
export default {
name: 'PresentationRequest',
props: {
Expand Down Expand Up @@ -56,8 +81,6 @@ export default {
if (this.intervalId) clearInterval(this.intervalId);
this.intervalId = setInterval(this.getPresentation, 3000);
this.registerPresentationRequest();
console.log('composeTypesWithOr:', this.composeTypesWithOr);
console.log('CredentialTypes', this.CredentialTypes);
},
beforeUnmount() {
if (this.intervalId) clearInterval(this.intervalId)
Expand All @@ -75,8 +98,6 @@ export default {
},
},
},
// function getInputDescriptor(credentialType) {
// return {
computed: {
authentication: {
get() {
Expand All @@ -93,70 +114,15 @@ export default {
]
}
if (this.composeTypesWithOr) {
console.log("composeTypesWithOr is true:",this.composeTypesWithOr)
definition.input_descriptors.push(
{
"id": "eecc_verifier_request_" + this.credentialTypes.join("|") || "VerifiableCredential",
"format": {
"ldp_vc": {
"proof_type": [
"Ed25519Signature2018",
"Ed25519Signature2020"
]
}
},
"constraints": {
"fields": [
{
"path": [
"$.type"
],
"filter": {
"type": "array",
"contains": {
"type": "string",
"pattern": this.credentialTypes.join("|") || "VerifiableCredential"
}
}
}
]
}
}
);
getInputDescriptor(this.credentialTypes.join("|"))
);
}
if (!this.composeTypesWithOr) {
console.log("composeTypesWithOr is false:",this.composeTypesWithOr)
for (const credentialType of this.credentialTypes) {
definition.input_descriptors.push(
{
"id": "eecc_verifier_request_" + credentialType || "VerifiableCredential",
"format": {
"ldp_vc": {
"proof_type": [
"Ed25519Signature2018",
"Ed25519Signature2020"
]
}
},
"constraints": {
"fields": [
{
"path": [
"$.type"
],
"filter": {
"type": "array",
"contains": {
"type": "string",
"pattern": credentialType || "VerifiableCredential"
}
}
}
]
}
}
getInputDescriptor(credentialType)
);
}
}
return definition;
Expand All @@ -181,8 +147,6 @@ export default {
},
methods: {
getPresentation() {
console.log('Log composeTypesWithOr', this.composeTypesWithOr);
console.log('Log credentialTypes', this.credentialTypes);
if (this.presentationRequestId) {
this.$api.get(this.$store.state.OPENID_ENDPOINT + 'presentation' + this.getRequestPath())
.then((res) => {
Expand All @@ -207,8 +171,6 @@ export default {
});
}
console.log('Log after: composeTypesWithOr', this.composeTypesWithOr);
console.log('Log after: CredentialTypes', this.CredentialTypes);
},
getRequestPath() {
return this.presentationRequestId ? '/' + this.presentationRequestId : '';
Expand Down
45 changes: 15 additions & 30 deletions frontend/src/views/PresentationRequest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,23 @@
</button>
</div>
</div>
<div v-if="customCredentialTypes.length >= 2" class="col-6">
<div class="form-check form-switch">
<input v-model="composeTypesWithOr" class="form-check-input" type="checkbox"
id="composeTypesWithOrSwitch">
<label class="form-check-label" for="composeTypesWithOrSwitch"><small>one credential is sufficient
</small></label>
<div class="row mx-md-3" v-if="customCredentialTypes.length >= 2">
<div class="col-6 mt-2">
<div class="form-check form-switch">
<input v-model="composeTypesWithOr" class="form-check-input" type="checkbox" id="composeTypesWithOrSwitch">
<label class="form-check-label" for="composeTypesWithOrSwitch">
<small>any credential is sufficient</small>
</label>
</div>
</div>
</div>
</div>
</div>
<div v-if="selectedCredential === 'custom'">
<PresentationRequest :credentialTypes="customCredentialTypes" :composeTypesWithOr="composeTypesWithOr"/>
</div>
<div v-if="selectedCredential === 'any'">
<PresentationRequest :credentialTypes="['']" :composeTypesWithOr="false"/>
</div>
<PresentationRequest :credentialTypes="customCredentialTypes" :composeTypesWithOr="composeTypesWithOr"/>
</div>
</div>
</template>
Expand All @@ -75,27 +82,5 @@ export default {
components: {
PresentationRequest
},
// watch: {
// customCredentialTypes: {
// handler() {
// this.registerPresentationRequest();
// },
// deep: true
// },
// enableCustomCredentialType(newValue) {
// if (newValue && this.customCredentialType) this.credentialType = this.customCredentialType;
// else this.credentialType = undefined;
// }
// },
// methods: {
// setCustomCredentialType() {
// if (this.customChangeTimeout) clearTimeout(this.customChangeTimeout);
// this.customChangeTimeout = setTimeout(() => this.credentialType = this.customCredentialType, 500);
// }
// },
mounted() {
console.log('composeTypesWithOr:', this.composeTypesWithOr);
console.log('customCredentialTypes', this.customCredentialTypes);
},
}
</script>

0 comments on commit 514e939

Please sign in to comment.