69
69
<div class =" min-w-0 flex-1 text-sm leading-6" >
70
70
<div class =" font-medium select-none text-gray-900" >
71
71
<label :for =" `credential-${credential.id}`" >
72
-
73
- <!-- <div class="flex items-center gap-1">-->
74
- <!-- <CredentialIcon :credentialType="credential.parsedDocument.type.at(-1)" class="h-6 w-6 flex-none rounded-full bg-gray-50"></CredentialIcon>-->
75
- <!-- {{ credential.parsedDocument.type.at(-1) }}-->
76
- <!-- </div>-->
77
-
78
- <!-- <div class="min-w-0 items-center">-->
79
- <!-- <p class="text-lg font-semibold leading-6 text-gray-900">{{ credential?.parsedDocument?.name }}</p>-->
80
- <!-- <p class="ml-1 truncate text-sm leading-5 text-gray-800">{{ credential.id }}</p>-->
81
- <!-- </div>-->
82
-
83
72
<VerifiableCredentialCard
84
73
:class =" [selection[credential.id] == true ? 'shadow-xl shadow-primary-400' : 'shadow-2xl']"
85
74
:credential =" credential.parsedDocument"
88
77
89
78
</label >
90
79
</div >
91
- <div v-if =" credential.disclosures" class =" mt-3 " >
80
+ <div v-if =" credential.disclosures && selection[credential.id] " class =" mt-6 border rounded-xl p-2 " >
92
81
<fieldset >
93
82
<legend class =" text-base font-semibold leading-6 text-gray-900" >Selectively disclosable attributes
94
83
</legend >
111
100
<div class =" ml-3 flex h-6 items-center" >
112
101
<input :id =" `disclosure-${credential.id}-${disclosure[0]}`"
113
102
:name =" `disclosure-${disclosure[0]}`"
114
- class =" h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-600 "
103
+ class =" h-4 w-4 rounded border-gray-300 text-primary-400 focus:ring-primary-500 "
115
104
type =" checkbox"
116
105
@click =" $event.target.checked ? addDisclosure(credential.id, disclosure) : removeDisclosure(credential.id, disclosure) "
117
106
/>
127
116
</div >
128
117
</fieldset >
129
118
130
-
131
119
<Disclosure >
132
120
<DisclosureButton class =" py-2" >
133
121
<ButtonsWaltButton class =" bg-gray-50 text-black" >View presentation definition JSON</ButtonsWaltButton >
137
125
</DisclosurePanel >
138
126
</Disclosure >
139
127
140
- <!--
141
- <ul>
142
- <li v-for="credential of matchedCredentials">
143
- - {{ credential }}
144
- </li>
145
- </ul>
146
-
147
- <div aria-label="Credential list" class="h-full overflow-y-auto shadow-xl">
148
- <div v-for="group in groupedCredentialTypes.keys()" :key="group.id" class="relative">
149
- <div class="sticky top-0 z-10 border-y border-b-gray-200 border-t-gray-100 bg-gray-50 px-3 py-1.5 text-sm font-semibold leading-6 text-gray-900">
150
- <h3>{{ group }}s:</h3>
151
- </div>
152
- <ul class="divide-y divide-gray-100" role="list">
153
- <li v-for="credential in groupedCredentialTypes.get(group)" :key="credential" class="flex gap-x-4 px-3 py-5">
154
- <CredentialIcon :credentialType="credential.name" class="h-6 w-6 flex-none rounded-full bg-gray-50"></CredentialIcon>
155
-
156
- <div class="min-w-0 flex flex-row items-center">
157
- <span class="text-lg font-semibold leading-6 text-gray-900">{{ credential.id }}.</span>
158
- <span class="ml-1 truncate text-sm leading-5 text-gray-800">{{ credential.name }}</span>
159
- </div>
160
- </li>
161
- </ul>
162
- </div>
163
- </div>-->
164
128
</CenterMain >
165
129
</div >
166
130
</template >
@@ -175,7 +139,7 @@ import { useTitle } from "@vueuse/core";
175
139
import VerifiableCredentialCard from " ~/components/credentials/VerifiableCredentialCard.vue" ;
176
140
177
141
import { Disclosure , DisclosureButton , DisclosurePanel } from " @headlessui/vue" ;
178
- import { parseDisclosures } from " ../../../../composables/disclosures" ;
142
+ import { encodeDisclosure , parseDisclosures } from " ../../../../composables/disclosures" ;
179
143
180
144
181
145
const currentWallet = useCurrentWallet ();
@@ -231,18 +195,27 @@ const matchedCredentials = await $fetch(`/r/wallet/${currentWallet.value}/exchan
231
195
});
232
196
233
197
const selection = ref ({});
234
- const selectedCredentialIds = computed (() => {
235
- const _selectedCredentialIds = [];
198
+ const selectedCredentialIds = computed (() => Object .entries (selection .value ).filter ((it ) => it [1 ]).map ((it ) => it [0 ]))
236
199
237
- for (let credentialId in selection .value ) {
238
- if (selection .value [credentialId ] === true )
239
- _selectedCredentialIds .push (credentialId );
240
- }
200
+ const disclosures = ref ({});
201
+ // const encodedDisclosures = computed(() => Object.keys(disclosures.value).map((cred) => disclosures.values[cred].map((disclosure) => encodeDisclosure(disclosure))))
202
+ const encodedDisclosures = computed (() => {
203
+ if (JSON .stringify (disclosures .value ) === " {}" ) return null
204
+
205
+ const m = {}
206
+ for (let credId in disclosures .value ) {
207
+ if (m [credId ] === undefined ) {
208
+ m [credId ] = []
209
+ }
241
210
242
- return _selectedCredentialIds ;
243
- });
211
+ for (let disclosure of disclosures .value [credId ]) {
212
+ console .log (" DISC " , disclosure )
213
+ m [credId ].push (encodeDisclosure (disclosure ))
214
+ }
215
+ }
244
216
245
- const disclosures = ref ({});
217
+ return m
218
+ })
246
219
247
220
function addDisclosure(credentialId : string , disclosure : string ) {
248
221
if (disclosures .value [credentialId ] === undefined ) {
@@ -258,9 +231,10 @@ function removeDisclosure(credentialId: string, disclosure: string) {
258
231
259
232
async function acceptPresentation() {
260
233
const req = {
261
- // did: String,
234
+ // did: String, // todo: choose DID of shared credential
235
+ presentationRequest: request ,
262
236
selectedCredentials: selectedCredentialIds .value ,
263
- presentationRequest: request
237
+ disclosures: encodedDisclosures . value
264
238
};
265
239
266
240
const response = await fetch (` /r/wallet/${currentWallet .value }/exchange/usePresentationRequest ` , {
@@ -292,7 +266,7 @@ async function acceptPresentation() {
292
266
failMessage .value = error .message ;
293
267
294
268
console .log (" Error response: " + JSON .stringify (error ));
295
- // window.alert(error.message )
269
+ window .alert (error .errorMessage )
296
270
297
271
if (error .redirectUri != null ) {
298
272
navigateTo (error .redirectUri as string , {
0 commit comments