@digitalbazaar/oid4-client 3.7.0 → 4.0.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/OID4Client.js CHANGED
@@ -178,7 +178,7 @@ export class OID4Client {
178
178
  }
179
179
  }
180
180
 
181
- // wallet / client receives credential:
181
+ // wallet / client receives credential(s):
182
182
  /* Note: The credential is not wrapped here in a VP in the current spec:
183
183
 
184
184
  HTTP/1.1 200 OK
@@ -186,10 +186,17 @@ export class OID4Client {
186
186
  Cache-Control: no-store
187
187
 
188
188
  {
189
- "format": "ldp_vc"
189
+ "format": "ldp_vc",
190
190
  "credential" : {...}
191
191
  }
192
192
 
193
+ OR (if multiple VCs *of the same type* were issued)
194
+
195
+ {
196
+ "format": "ldp_vc",
197
+ "credentials" : {...}
198
+ }
199
+
193
200
  OR (if multiple `requests` were given)
194
201
 
195
202
  {
package/lib/oid4vp.js CHANGED
@@ -446,7 +446,9 @@ function _filterToValue({filter, strict = false}) {
446
446
  partial support as it will be treated as a simple string not a regex; regex
447
447
  is a DoS attack vector
448
448
 
449
- `array`: with `items` or `contains` where uses a `string` filter
449
+ `array`: with `contains` where uses a `string` filter
450
+
451
+ `allOf`: supported only with the above schemas present in it.
450
452
 
451
453
  */
452
454
  let value;
@@ -455,14 +457,18 @@ function _filterToValue({filter, strict = false}) {
455
457
  if(type === 'array') {
456
458
  if(filter.contains) {
457
459
  if(Array.isArray(filter.contains)) {
458
- value = filter.contains.map(filter => _filterToValue({filter, strict}));
459
- } else {
460
- value = _filterToValue({filter: filter.contains, strict});
460
+ return filter.contains.map(filter => _filterToValue({filter, strict}));
461
461
  }
462
- } else if(strict) {
462
+ return _filterToValue({filter: filter.contains, strict});
463
+ }
464
+ if(Array.isArray(filter.allOf) && filter.allOf.every(f => f.contains)) {
465
+ return filter.allOf.map(
466
+ f => _filterToValue({filter: f.contains, strict}));
467
+ }
468
+ if(strict) {
463
469
  throw new Error(
464
- 'Unsupported filter; array filters must use "enum" or "contains" ' +
465
- 'with a string filter.');
470
+ 'Unsupported filter; array filters must use "allOf" and/or ' +
471
+ '"contains" with a string filter.');
466
472
  }
467
473
  return value;
468
474
  }
@@ -584,9 +590,11 @@ export function _fromQueryByExampleQuery({credentialQuery, prefixJwtVcPath}) {
584
590
  const filter = {};
585
591
  if(Array.isArray(value)) {
586
592
  filter.type = 'array';
587
- filter.contains = value.map(v => ({
588
- type: 'string',
589
- const: v
593
+ filter.allOf = value.map(v => ({
594
+ contains: {
595
+ type: 'string',
596
+ const: v
597
+ }
590
598
  }));
591
599
  } else if(key === 'type') {
592
600
  // special provision for array/string for `type`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalbazaar/oid4-client",
3
- "version": "3.7.0",
3
+ "version": "4.0.0",
4
4
  "description": "An OID4 (VC + VP) client",
5
5
  "homepage": "https://github.com/digitalbazaar/oid4-client",
6
6
  "author": {