@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.
Files changed (2) hide show
  1. package/lib/oid4/http.js +24 -19
  2. 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
- /* Note: The `/credential` route only supports sending a single VC;
207
- assume here that this workflow is configured for a single VC and an
208
- error code would have been sent to the client to use the batch
209
- endpoint if there was more than one VC to deliver. */
210
- const {response, format} = result;
211
- const {verifiablePresentation: {verifiableCredential: [vc]}} = response;
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
- // 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
- }
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
- res.json({
224
- // FIXME: this doesn't seem to be in the spec anymore (draft 14+)...
225
- format,
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrock/vc-delivery",
3
- "version": "5.3.5",
3
+ "version": "5.4.0",
4
4
  "type": "module",
5
5
  "description": "Bedrock Verifiable Credential Delivery",
6
6
  "main": "./lib/index.js",