Skip to content

Commit

Permalink
and or funcitionality works
Browse files Browse the repository at this point in the history
  • Loading branch information
leoniefritsch committed Sep 10, 2024
1 parent 759471e commit 8c9a31a
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 29 deletions.
104 changes: 78 additions & 26 deletions frontend/src/components/PresentationRequest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export default {
mode: {
type: String,
default: 'verify'
},
composeTypesWithOr: {
type: Boolean,
default: false
}
},
data() {
Expand All @@ -52,6 +56,8 @@ 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 @@ -62,8 +68,15 @@ export default {
this.registerPresentationRequest();
},
deep: true
}
},
composeTypesWithOr: {
handler() {
this.registerPresentationRequest();
},
},
},
// function getInputDescriptor(credentialType) {
// return {
computed: {
authentication: {
get() {
Expand All @@ -79,38 +92,73 @@ export default {
"input_descriptors": [
]
}
for (const credentialType of this.credentialTypes) {
if (this.composeTypesWithOr) {
console.log("composeTypesWithOr is true:",this.composeTypesWithOr)
definition.input_descriptors.push(
{
"id": "eecc_verifier_request_" + credentialType || "VerifiableCredential",
"format": {
"ldp_vc": {
"proof_type": [
"Ed25519Signature2018",
"Ed25519Signature2020"
{
"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"
}
}
}
]
}
},
"constraints": {
"fields": [
{
"path": [
"$.type"
],
"filter": {
"type": "array",
"contains": {
"type": "string",
"pattern": credentialType || "VerifiableCredential"
}
);
}
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"
}
}
}
}
]
]
}
}
}
);
);
}
}
}
return definition;
},
Expand All @@ -133,6 +181,8 @@ 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 @@ -157,6 +207,8 @@ export default {
});
}
console.log('Log after: composeTypesWithOr', this.composeTypesWithOr);
console.log('Log after: CredentialTypes', this.CredentialTypes);
},
getRequestPath() {
return this.presentationRequestId ? '/' + this.presentationRequestId : '';
Expand Down
37 changes: 34 additions & 3 deletions frontend/src/views/PresentationRequest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,16 @@
</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>
</div>
</div>
<PresentationRequest :credentialTypes="customCredentialTypes" />
<PresentationRequest :credentialTypes="customCredentialTypes" :composeTypesWithOr="composeTypesWithOr"/>
</div>
</div>
</template>
Expand All @@ -60,11 +68,34 @@ export default {
return {
selectedCredential: 'any',
customCredentialTypes: [""],
customChangeTimeout: undefined
customChangeTimeout: undefined,
composeTypesWithOr: false,
}
},
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 8c9a31a

Please sign in to comment.