@bedrock/vc-delivery 4.2.0 → 4.3.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/openId.js CHANGED
@@ -8,8 +8,10 @@ import {
8
8
  } from '@bedrock/validation';
9
9
  import {importJWK, SignJWT} from 'jose';
10
10
  import {
11
- openIdAuthorizationResponseBody, openIdBatchCredentialBody,
12
- openIdCredentialBody, openIdTokenBody,
11
+ openIdAuthorizationResponseBody,
12
+ openIdBatchCredentialBody,
13
+ openIdCredentialBody,
14
+ openIdTokenBody,
13
15
  presentationSubmission as presentationSubmissionSchema
14
16
  } from '../schemas/bedrock-vc-exchanger.js';
15
17
  import {verify, verifyDidProofJwt} from './verify.js';
@@ -235,7 +237,7 @@ export async function createRoutes({
235
237
 
236
238
  {
237
239
  "format": "ldp_vc",
238
- "credential_description": {
240
+ "credential_definition": {
239
241
  "@context": [
240
242
  "https://www.w3.org/2018/credentials/v1",
241
243
  "https://www.w3.org/2018/credentials/examples/v1"
@@ -289,7 +291,7 @@ export async function createRoutes({
289
291
  {
290
292
  credential_requests: [{
291
293
  "format": "ldp_vc",
292
- "credential_description": {
294
+ "credential_definition": {
293
295
  "@context": [
294
296
  "https://www.w3.org/2018/credentials/v1",
295
297
  "https://www.w3.org/2018/credentials/examples/v1"
@@ -528,6 +530,11 @@ async function _processCredentialRequests({req, res, isBatchRequest}) {
528
530
  }
529
531
  credentialRequests = [req.body];
530
532
  }
533
+
534
+ // before asserting, normalize credential requests to use `type` instead of
535
+ // `types`; this is to allow for OID4VCI draft 20 implementers that followed
536
+ // the non-normative examples
537
+ _normalizeCredentialDefinitionTypes({credentialRequests});
531
538
  _assertCredentialRequests(
532
539
  {credentialRequests, expectedCredentialRequests});
533
540
 
@@ -832,3 +839,15 @@ function _validate(validator, data) {
832
839
  throw result.error;
833
840
  }
834
841
  }
842
+
843
+ function _normalizeCredentialDefinitionTypes({credentialRequests}) {
844
+ // normalize credential requests to use `type` instead of `types`
845
+ for(const cr of credentialRequests) {
846
+ if(cr?.credential_definition?.types) {
847
+ if(!cr?.credential_definition?.type) {
848
+ cr.credential_definition.type = cr.credential_definition.types;
849
+ }
850
+ delete cr.credential_definition.types;
851
+ }
852
+ }
853
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrock/vc-delivery",
3
- "version": "4.2.0",
3
+ "version": "4.3.0",
4
4
  "type": "module",
5
5
  "description": "Bedrock Verifiable Credential Delivery",
6
6
  "main": "./lib/index.js",
@@ -22,6 +22,14 @@ const credentialDefinition = {
22
22
  item: {
23
23
  type: 'string'
24
24
  }
25
+ },
26
+ // allow `types` to be flexible for OID4VCI draft 20 implementers
27
+ types: {
28
+ type: 'array',
29
+ minItems: 2,
30
+ item: {
31
+ type: 'string'
32
+ }
25
33
  }
26
34
  }
27
35
  };