@bedrock/vc-delivery 5.3.5 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/oid4/http.js +24 -19
- package/package.json +1 -1
package/lib/oid4/http.js
CHANGED
|
@@ -203,28 +203,33 @@ export async function createRoutes({
|
|
|
203
203
|
return;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
206
|
+
// send VC(s)
|
|
207
|
+
const {
|
|
208
|
+
response: {verifiablePresentation: {verifiableCredential}},
|
|
209
|
+
format
|
|
210
|
+
} = result;
|
|
211
|
+
// FIXME: "format" doesn't seem to be in the spec anymore (draft 14+)...
|
|
212
|
+
const credentials = verifiableCredential.map(vc => {
|
|
213
|
+
// parse any enveloped VC
|
|
214
|
+
let credential;
|
|
215
|
+
if(vc.type === 'EnvelopedVerifiableCredential' &&
|
|
216
|
+
vc.id?.startsWith('data:application/jwt,')) {
|
|
217
|
+
credential = vc.id.slice('data:application/jwt,'.length);
|
|
218
|
+
} else {
|
|
219
|
+
credential = vc;
|
|
220
|
+
}
|
|
221
|
+
return credential;
|
|
222
|
+
});
|
|
212
223
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
credential = vc.id.slice('data:application/jwt,'.length);
|
|
218
|
-
} else {
|
|
219
|
-
credential = vc;
|
|
220
|
-
}
|
|
224
|
+
/* Note: The `/credential` route only supports sending VCs of the same
|
|
225
|
+
type, but there can be more than one of them. The above `isBatchRequest`
|
|
226
|
+
check will ensure that the workflow used here only allows a single
|
|
227
|
+
credential request, indicating a single type. */
|
|
221
228
|
|
|
222
229
|
// send OID4VCI response
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
credential
|
|
227
|
-
});
|
|
230
|
+
const response = credentials.length === 1 ?
|
|
231
|
+
{format, credential: credentials[0]} : {format, credentials};
|
|
232
|
+
res.json(response);
|
|
228
233
|
}));
|
|
229
234
|
|
|
230
235
|
// a credential delivery server endpoint
|