@digitalbazaar/oid4-client 5.6.0 → 5.6.2

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.
@@ -43,11 +43,29 @@ export function vprGroupsToPresentationDefinition({
43
43
  input_descriptors
44
44
  };
45
45
 
46
+ // in VPR, each group is an 'AND' and just one group must be selected; to
47
+ // map this to presentation exchange groups, each `input_descriptor`
48
+ // represents a VPR group, but they are all part of the same PR group, and
49
+ // the `submission_requirements` will indicate that just one
50
+ // `input_descriptor` is to be selected via `{pick: 1, count: 1}`
51
+ let peGroupId;
52
+ let submission_requirements;
53
+ if(groupMap.size > 1) {
54
+ peGroupId = crypto.randomUUID();
55
+ submission_requirements = [{
56
+ rule: 'pick',
57
+ count: 1,
58
+ from: peGroupId
59
+ }];
60
+ }
61
+
62
+ // keep track of whether VPR queries express accepted cryptosuites/envelopes
63
+ // to add this to `presentation_definition.format` at the end
46
64
  let acceptsVpJwt = false;
47
65
  let acceptsVcJwt = false;
48
-
49
66
  const ldpVpProofTypes = new Set();
50
67
  const ldpVcProofTypes = new Set();
68
+
51
69
  // note: same group ID is logical "AND" and different group ID is "OR"
52
70
  const groups = [...groupMap.values()];
53
71
  for(const queries of groups) {
@@ -57,7 +75,7 @@ export function vprGroupsToPresentationDefinition({
57
75
  // "credentialQuery" within it
58
76
  for(const queryByExample of queryByExamples) {
59
77
  // should only be one `credentialQuery` but handle each one as a new
60
- // set of input descriptors
78
+ // input descriptor
61
79
  const all = Array.isArray(queryByExample.credentialQuery) ?
62
80
  queryByExample.credentialQuery : [queryByExample.credentialQuery];
63
81
  for(const credentialQuery of all) {
@@ -87,6 +105,10 @@ export function vprGroupsToPresentationDefinition({
87
105
  }
88
106
  }
89
107
 
108
+ if(submission_requirements) {
109
+ inputDescriptor.group = [peGroupId];
110
+ }
111
+
90
112
  input_descriptors.push(inputDescriptor);
91
113
  }
92
114
  }
@@ -108,6 +130,11 @@ export function vprGroupsToPresentationDefinition({
108
130
  }
109
131
  }
110
132
 
133
+ // add `submission_requirements` if
134
+ if(submission_requirements) {
135
+ presentationDefinition.submission_requirements = submission_requirements;
136
+ }
137
+
111
138
  const shouldAddFormat = acceptsVcJwt || acceptsVpJwt ||
112
139
  ldpVcProofTypes.size > 0 || ldpVpProofTypes.size > 0;
113
140
  if(shouldAddFormat && !presentationDefinition.format) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalbazaar/oid4-client",
3
- "version": "5.6.0",
3
+ "version": "5.6.2",
4
4
  "description": "An OID4 (VC + VP) client",
5
5
  "homepage": "https://github.com/digitalbazaar/oid4-client",
6
6
  "author": {